1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-09 00:22:08 +03:00

get ready for beta release

This commit is contained in:
Leibale
2023-11-09 21:08:53 -05:00
parent 7247777a6f
commit 5b086ba358
12 changed files with 4563 additions and 400 deletions

View File

@@ -1,12 +0,0 @@
.github/
.vscode/
docs/
examples/
packages/
.deepsource.toml
.release-it.json
CONTRIBUTING.md
SECURITY.md
index.ts
tsconfig.base.json
tsconfig.json

4212
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -19,6 +19,7 @@
"gh-pages": "^6.0.0",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"release-it": "^16.2.1",
"tsx": "^3.14.0",
"typedoc": "^0.25.3",
"typescript": "^5.2.2"

View File

@@ -1,6 +0,0 @@
.nyc_output/
coverage/
lib/
.nycrc.json
.release-it.json
tsconfig.json

View File

@@ -1,6 +0,0 @@
.nyc_output/
coverage/
lib/
.nycrc.json
.release-it.json
tsconfig.json

View File

@@ -1,6 +0,0 @@
.nyc_output/
coverage/
lib/
.nycrc.json
.release-it.json
tsconfig.json

View File

@@ -1,28 +1,28 @@
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types';
import { Params, pushParamsArgs } from ".";
// import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types';
// import { Params, pushParamsArgs } from ".";
export interface FtExplainOptions {
PARAMS?: Params;
DIALECT?: number;
}
// export interface FtExplainOptions {
// PARAMS?: Params;
// DIALECT?: number;
// }
export default {
FIRST_KEY_INDEX: undefined,
IS_READ_ONLY: true,
transformArguments(
index: RedisArgument,
query: RedisArgument,
options?: FtExplainOptions
) {
const args = ['FT.EXPLAIN', index, query];
// export default {
// FIRST_KEY_INDEX: undefined,
// IS_READ_ONLY: true,
// transformArguments(
// index: RedisArgument,
// query: RedisArgument,
// options?: FtExplainOptions
// ) {
// const args = ['FT.EXPLAIN', index, query];
pushParamsArgs(args, options?.PARAMS);
// pushParamsArgs(args, options?.PARAMS);
if (options?.DIALECT) {
args.push('DIALECT', options.DIALECT.toString());
}
// if (options?.DIALECT) {
// args.push('DIALECT', options.DIALECT.toString());
// }
return args;
},
transformReply: undefined as unknown as () => SimpleStringReply
} as const satisfies Command;
// return args;
// },
// transformReply: undefined as unknown as () => SimpleStringReply
// } as const satisfies Command;

View File

@@ -1,167 +1,167 @@
import { RedisCommandArgument } from '@redis/client/dist/lib/commands';
import { transformTuplesReply } from '@redis/client/dist/lib/commands/generic-transformers';
// import { RedisCommandArgument } from '@redis/client/dist/lib/commands';
// import { transformTuplesReply } from '@redis/client/dist/lib/commands/generic-transformers';
export function transformArguments(index: string): Array<string> {
return ['FT.INFO', index];
}
// export function transformArguments(index: string): Array<string> {
// return ['FT.INFO', index];
// }
type InfoRawReply = [
'index_name',
RedisCommandArgument,
'index_options',
Array<RedisCommandArgument>,
'index_definition',
Array<RedisCommandArgument>,
'attributes',
Array<Array<RedisCommandArgument>>,
'num_docs',
RedisCommandArgument,
'max_doc_id',
RedisCommandArgument,
'num_terms',
RedisCommandArgument,
'num_records',
RedisCommandArgument,
'inverted_sz_mb',
RedisCommandArgument,
'vector_index_sz_mb',
RedisCommandArgument,
'total_inverted_index_blocks',
RedisCommandArgument,
'offset_vectors_sz_mb',
RedisCommandArgument,
'doc_table_size_mb',
RedisCommandArgument,
'sortable_values_size_mb',
RedisCommandArgument,
'key_table_size_mb',
RedisCommandArgument,
'records_per_doc_avg',
RedisCommandArgument,
'bytes_per_record_avg',
RedisCommandArgument,
'offsets_per_term_avg',
RedisCommandArgument,
'offset_bits_per_record_avg',
RedisCommandArgument,
'hash_indexing_failures',
RedisCommandArgument,
'indexing',
RedisCommandArgument,
'percent_indexed',
RedisCommandArgument,
'gc_stats',
[
'bytes_collected',
RedisCommandArgument,
'total_ms_run',
RedisCommandArgument,
'total_cycles',
RedisCommandArgument,
'average_cycle_time_ms',
RedisCommandArgument,
'last_run_time_ms',
RedisCommandArgument,
'gc_numeric_trees_missed',
RedisCommandArgument,
'gc_blocks_denied',
RedisCommandArgument
],
'cursor_stats',
[
'global_idle',
number,
'global_total',
number,
'index_capacity',
number,
'index_total',
number
],
'stopwords_list'?,
Array<RedisCommandArgument>?
];
// type InfoRawReply = [
// 'index_name',
// RedisCommandArgument,
// 'index_options',
// Array<RedisCommandArgument>,
// 'index_definition',
// Array<RedisCommandArgument>,
// 'attributes',
// Array<Array<RedisCommandArgument>>,
// 'num_docs',
// RedisCommandArgument,
// 'max_doc_id',
// RedisCommandArgument,
// 'num_terms',
// RedisCommandArgument,
// 'num_records',
// RedisCommandArgument,
// 'inverted_sz_mb',
// RedisCommandArgument,
// 'vector_index_sz_mb',
// RedisCommandArgument,
// 'total_inverted_index_blocks',
// RedisCommandArgument,
// 'offset_vectors_sz_mb',
// RedisCommandArgument,
// 'doc_table_size_mb',
// RedisCommandArgument,
// 'sortable_values_size_mb',
// RedisCommandArgument,
// 'key_table_size_mb',
// RedisCommandArgument,
// 'records_per_doc_avg',
// RedisCommandArgument,
// 'bytes_per_record_avg',
// RedisCommandArgument,
// 'offsets_per_term_avg',
// RedisCommandArgument,
// 'offset_bits_per_record_avg',
// RedisCommandArgument,
// 'hash_indexing_failures',
// RedisCommandArgument,
// 'indexing',
// RedisCommandArgument,
// 'percent_indexed',
// RedisCommandArgument,
// 'gc_stats',
// [
// 'bytes_collected',
// RedisCommandArgument,
// 'total_ms_run',
// RedisCommandArgument,
// 'total_cycles',
// RedisCommandArgument,
// 'average_cycle_time_ms',
// RedisCommandArgument,
// 'last_run_time_ms',
// RedisCommandArgument,
// 'gc_numeric_trees_missed',
// RedisCommandArgument,
// 'gc_blocks_denied',
// RedisCommandArgument
// ],
// 'cursor_stats',
// [
// 'global_idle',
// number,
// 'global_total',
// number,
// 'index_capacity',
// number,
// 'index_total',
// number
// ],
// 'stopwords_list'?,
// Array<RedisCommandArgument>?
// ];
interface InfoReply {
indexName: RedisCommandArgument;
indexOptions: Array<RedisCommandArgument>;
indexDefinition: Record<string, RedisCommandArgument>;
attributes: Array<Record<string, RedisCommandArgument>>;
numDocs: RedisCommandArgument;
maxDocId: RedisCommandArgument;
numTerms: RedisCommandArgument;
numRecords: RedisCommandArgument;
invertedSzMb: RedisCommandArgument;
vectorIndexSzMb: RedisCommandArgument;
totalInvertedIndexBlocks: RedisCommandArgument;
offsetVectorsSzMb: RedisCommandArgument;
docTableSizeMb: RedisCommandArgument;
sortableValuesSizeMb: RedisCommandArgument;
keyTableSizeMb: RedisCommandArgument;
recordsPerDocAvg: RedisCommandArgument;
bytesPerRecordAvg: RedisCommandArgument;
offsetsPerTermAvg: RedisCommandArgument;
offsetBitsPerRecordAvg: RedisCommandArgument;
hashIndexingFailures: RedisCommandArgument;
indexing: RedisCommandArgument;
percentIndexed: RedisCommandArgument;
gcStats: {
bytesCollected: RedisCommandArgument;
totalMsRun: RedisCommandArgument;
totalCycles: RedisCommandArgument;
averageCycleTimeMs: RedisCommandArgument;
lastRunTimeMs: RedisCommandArgument;
gcNumericTreesMissed: RedisCommandArgument;
gcBlocksDenied: RedisCommandArgument;
};
cursorStats: {
globalIdle: number;
globalTotal: number;
indexCapacity: number;
idnexTotal: number;
};
stopWords: Array<RedisCommandArgument> | undefined;
}
// interface InfoReply {
// indexName: RedisCommandArgument;
// indexOptions: Array<RedisCommandArgument>;
// indexDefinition: Record<string, RedisCommandArgument>;
// attributes: Array<Record<string, RedisCommandArgument>>;
// numDocs: RedisCommandArgument;
// maxDocId: RedisCommandArgument;
// numTerms: RedisCommandArgument;
// numRecords: RedisCommandArgument;
// invertedSzMb: RedisCommandArgument;
// vectorIndexSzMb: RedisCommandArgument;
// totalInvertedIndexBlocks: RedisCommandArgument;
// offsetVectorsSzMb: RedisCommandArgument;
// docTableSizeMb: RedisCommandArgument;
// sortableValuesSizeMb: RedisCommandArgument;
// keyTableSizeMb: RedisCommandArgument;
// recordsPerDocAvg: RedisCommandArgument;
// bytesPerRecordAvg: RedisCommandArgument;
// offsetsPerTermAvg: RedisCommandArgument;
// offsetBitsPerRecordAvg: RedisCommandArgument;
// hashIndexingFailures: RedisCommandArgument;
// indexing: RedisCommandArgument;
// percentIndexed: RedisCommandArgument;
// gcStats: {
// bytesCollected: RedisCommandArgument;
// totalMsRun: RedisCommandArgument;
// totalCycles: RedisCommandArgument;
// averageCycleTimeMs: RedisCommandArgument;
// lastRunTimeMs: RedisCommandArgument;
// gcNumericTreesMissed: RedisCommandArgument;
// gcBlocksDenied: RedisCommandArgument;
// };
// cursorStats: {
// globalIdle: number;
// globalTotal: number;
// indexCapacity: number;
// idnexTotal: number;
// };
// stopWords: Array<RedisCommandArgument> | undefined;
// }
export function transformReply(rawReply: InfoRawReply): InfoReply {
return {
indexName: rawReply[1],
indexOptions: rawReply[3],
indexDefinition: transformTuplesReply(rawReply[5]),
attributes: rawReply[7].map(attribute => transformTuplesReply(attribute)),
numDocs: rawReply[9],
maxDocId: rawReply[11],
numTerms: rawReply[13],
numRecords: rawReply[15],
invertedSzMb: rawReply[17],
vectorIndexSzMb: rawReply[19],
totalInvertedIndexBlocks: rawReply[21],
offsetVectorsSzMb: rawReply[23],
docTableSizeMb: rawReply[25],
sortableValuesSizeMb: rawReply[27],
keyTableSizeMb: rawReply[29],
recordsPerDocAvg: rawReply[31],
bytesPerRecordAvg: rawReply[33],
offsetsPerTermAvg: rawReply[35],
offsetBitsPerRecordAvg: rawReply[37],
hashIndexingFailures: rawReply[39],
indexing: rawReply[41],
percentIndexed: rawReply[43],
gcStats: {
bytesCollected: rawReply[45][1],
totalMsRun: rawReply[45][3],
totalCycles: rawReply[45][5],
averageCycleTimeMs: rawReply[45][7],
lastRunTimeMs: rawReply[45][9],
gcNumericTreesMissed: rawReply[45][11],
gcBlocksDenied: rawReply[45][13]
},
cursorStats: {
globalIdle: rawReply[47][1],
globalTotal: rawReply[47][3],
indexCapacity: rawReply[47][5],
idnexTotal: rawReply[47][7]
},
stopWords: rawReply[49]
};
}
// export function transformReply(rawReply: InfoRawReply): InfoReply {
// return {
// indexName: rawReply[1],
// indexOptions: rawReply[3],
// indexDefinition: transformTuplesReply(rawReply[5]),
// attributes: rawReply[7].map(attribute => transformTuplesReply(attribute)),
// numDocs: rawReply[9],
// maxDocId: rawReply[11],
// numTerms: rawReply[13],
// numRecords: rawReply[15],
// invertedSzMb: rawReply[17],
// vectorIndexSzMb: rawReply[19],
// totalInvertedIndexBlocks: rawReply[21],
// offsetVectorsSzMb: rawReply[23],
// docTableSizeMb: rawReply[25],
// sortableValuesSizeMb: rawReply[27],
// keyTableSizeMb: rawReply[29],
// recordsPerDocAvg: rawReply[31],
// bytesPerRecordAvg: rawReply[33],
// offsetsPerTermAvg: rawReply[35],
// offsetBitsPerRecordAvg: rawReply[37],
// hashIndexingFailures: rawReply[39],
// indexing: rawReply[41],
// percentIndexed: rawReply[43],
// gcStats: {
// bytesCollected: rawReply[45][1],
// totalMsRun: rawReply[45][3],
// totalCycles: rawReply[45][5],
// averageCycleTimeMs: rawReply[45][7],
// lastRunTimeMs: rawReply[45][9],
// gcNumericTreesMissed: rawReply[45][11],
// gcBlocksDenied: rawReply[45][13]
// },
// cursorStats: {
// globalIdle: rawReply[47][1],
// globalTotal: rawReply[47][3],
// indexCapacity: rawReply[47][5],
// idnexTotal: rawReply[47][7]
// },
// stopWords: rawReply[49]
// };
// }

View File

@@ -1,29 +1,29 @@
import { pushAggregatehOptions, AggregateOptions, transformReply as transformAggregateReply, AggregateRawReply } from './AGGREGATE';
import { ProfileOptions, ProfileRawReply, ProfileReply, transformProfile } from '.';
// import { pushAggregatehOptions, AggregateOptions, transformReply as transformAggregateReply, AggregateRawReply } from './AGGREGATE';
// import { ProfileOptions, ProfileRawReply, ProfileReply, transformProfile } from '.';
export const IS_READ_ONLY = true;
// export const IS_READ_ONLY = true;
export function transformArguments(
index: string,
query: string,
options?: ProfileOptions & AggregateOptions
): Array<string> {
const args = ['FT.PROFILE', index, 'AGGREGATE'];
// export function transformArguments(
// index: string,
// query: string,
// options?: ProfileOptions & AggregateOptions
// ): Array<string> {
// const args = ['FT.PROFILE', index, 'AGGREGATE'];
if (options?.LIMITED) {
args.push('LIMITED');
}
// if (options?.LIMITED) {
// args.push('LIMITED');
// }
args.push('QUERY', query);
pushAggregatehOptions(args, options)
return args;
}
// args.push('QUERY', query);
// pushAggregatehOptions(args, options)
// return args;
// }
type ProfileAggeregateRawReply = ProfileRawReply<AggregateRawReply>;
// type ProfileAggeregateRawReply = ProfileRawReply<AggregateRawReply>;
export function transformReply(reply: ProfileAggeregateRawReply): ProfileReply {
return {
results: transformAggregateReply(reply[0]),
profile: transformProfile(reply[1])
};
}
// export function transformReply(reply: ProfileAggeregateRawReply): ProfileReply {
// return {
// results: transformAggregateReply(reply[0]),
// profile: transformProfile(reply[1])
// };
// }

View File

@@ -1,29 +1,29 @@
import { SearchOptions, SearchRawReply, transformReply as transformSearchReply } from './SEARCH';
import { pushSearchOptions, ProfileOptions, ProfileRawReply, ProfileReply, transformProfile } from '.';
import { RedisCommandArguments } from '@redis/client/dist/lib/commands';
// import { SearchOptions, SearchRawReply, transformReply as transformSearchReply } from './SEARCH';
// import { pushSearchOptions, ProfileOptions, ProfileRawReply, ProfileReply, transformProfile } from '.';
// import { RedisCommandArguments } from '@redis/client/dist/lib/commands';
export const IS_READ_ONLY = true;
// export const IS_READ_ONLY = true;
export function transformArguments(
index: string,
query: string,
options?: ProfileOptions & SearchOptions
): RedisCommandArguments {
let args: RedisCommandArguments = ['FT.PROFILE', index, 'SEARCH'];
// export function transformArguments(
// index: string,
// query: string,
// options?: ProfileOptions & SearchOptions
// ): RedisCommandArguments {
// let args: RedisCommandArguments = ['FT.PROFILE', index, 'SEARCH'];
if (options?.LIMITED) {
args.push('LIMITED');
}
// if (options?.LIMITED) {
// args.push('LIMITED');
// }
args.push('QUERY', query);
return pushSearchOptions(args, options);
}
// args.push('QUERY', query);
// return pushSearchOptions(args, options);
// }
type ProfileSearchRawReply = ProfileRawReply<SearchRawReply>;
// type ProfileSearchRawReply = ProfileRawReply<SearchRawReply>;
export function transformReply(reply: ProfileSearchRawReply, withoutDocuments: boolean): ProfileReply {
return {
results: transformSearchReply(reply[0], withoutDocuments),
profile: transformProfile(reply[1])
};
}
// export function transformReply(reply: ProfileSearchRawReply, withoutDocuments: boolean): ProfileReply {
// return {
// results: transformSearchReply(reply[0], withoutDocuments),
// profile: transformProfile(reply[1])
// };
// }

View File

@@ -1,82 +1,82 @@
import { TimeSeriesAggregationType, TimeSeriesDuplicatePolicies } from '.';
// import { TimeSeriesAggregationType, TimeSeriesDuplicatePolicies } from '.';
export const FIRST_KEY_INDEX = 1;
// export const FIRST_KEY_INDEX = 1;
export const IS_READ_ONLY = true;
// export const IS_READ_ONLY = true;
export function transformArguments(key: string): Array<string> {
return ['TS.INFO', key];
}
// export function transformArguments(key: string): Array<string> {
// return ['TS.INFO', key];
// }
export type InfoRawReply = [
'totalSamples',
number,
'memoryUsage',
number,
'firstTimestamp',
number,
'lastTimestamp',
number,
'retentionTime',
number,
'chunkCount',
number,
'chunkSize',
number,
'chunkType',
string,
'duplicatePolicy',
TimeSeriesDuplicatePolicies | null,
'labels',
Array<[name: string, value: string]>,
'sourceKey',
string | null,
'rules',
Array<[key: string, timeBucket: number, aggregationType: TimeSeriesAggregationType]>
];
// export type InfoRawReply = [
// 'totalSamples',
// number,
// 'memoryUsage',
// number,
// 'firstTimestamp',
// number,
// 'lastTimestamp',
// number,
// 'retentionTime',
// number,
// 'chunkCount',
// number,
// 'chunkSize',
// number,
// 'chunkType',
// string,
// 'duplicatePolicy',
// TimeSeriesDuplicatePolicies | null,
// 'labels',
// Array<[name: string, value: string]>,
// 'sourceKey',
// string | null,
// 'rules',
// Array<[key: string, timeBucket: number, aggregationType: TimeSeriesAggregationType]>
// ];
export interface InfoReply {
totalSamples: number;
memoryUsage: number;
firstTimestamp: number;
lastTimestamp: number;
retentionTime: number;
chunkCount: number;
chunkSize: number;
chunkType: string;
duplicatePolicy: TimeSeriesDuplicatePolicies | null;
labels: Array<{
name: string;
value: string;
}>;
sourceKey: string | null;
rules: Array<{
key: string;
timeBucket: number;
aggregationType: TimeSeriesAggregationType
}>;
}
// export interface InfoReply {
// totalSamples: number;
// memoryUsage: number;
// firstTimestamp: number;
// lastTimestamp: number;
// retentionTime: number;
// chunkCount: number;
// chunkSize: number;
// chunkType: string;
// duplicatePolicy: TimeSeriesDuplicatePolicies | null;
// labels: Array<{
// name: string;
// value: string;
// }>;
// sourceKey: string | null;
// rules: Array<{
// key: string;
// timeBucket: number;
// aggregationType: TimeSeriesAggregationType
// }>;
// }
export function transformReply(reply: InfoRawReply): InfoReply {
return {
totalSamples: reply[1],
memoryUsage: reply[3],
firstTimestamp: reply[5],
lastTimestamp: reply[7],
retentionTime: reply[9],
chunkCount: reply[11],
chunkSize: reply[13],
chunkType: reply[15],
duplicatePolicy: reply[17],
labels: reply[19].map(([name, value]) => ({
name,
value
})),
sourceKey: reply[21],
rules: reply[23].map(([key, timeBucket, aggregationType]) => ({
key,
timeBucket,
aggregationType
}))
};
}
// export function transformReply(reply: InfoRawReply): InfoReply {
// return {
// totalSamples: reply[1],
// memoryUsage: reply[3],
// firstTimestamp: reply[5],
// lastTimestamp: reply[7],
// retentionTime: reply[9],
// chunkCount: reply[11],
// chunkSize: reply[13],
// chunkType: reply[15],
// duplicatePolicy: reply[17],
// labels: reply[19].map(([name, value]) => ({
// name,
// value
// })),
// sourceKey: reply[21],
// rules: reply[23].map(([key, timeBucket, aggregationType]) => ({
// key,
// timeBucket,
// aggregationType
// }))
// };
// }

View File

@@ -1,57 +1,57 @@
import {
transformArguments as transformInfoArguments,
InfoRawReply,
InfoReply,
transformReply as transformInfoReply
} from './INFO';
// import {
// transformArguments as transformInfoArguments,
// InfoRawReply,
// InfoReply,
// transformReply as transformInfoReply
// } from './INFO';
export { IS_READ_ONLY, FIRST_KEY_INDEX } from './INFO';
// export { IS_READ_ONLY, FIRST_KEY_INDEX } from './INFO';
export function transformArguments(key: string): Array<string> {
const args = transformInfoArguments(key);
args.push('DEBUG');
return args;
}
// export function transformArguments(key: string): Array<string> {
// const args = transformInfoArguments(key);
// args.push('DEBUG');
// return args;
// }
type InfoDebugRawReply = [
...InfoRawReply,
'keySelfName',
string,
'chunks',
Array<[
'startTimestamp',
number,
'endTimestamp',
number,
'samples',
number,
'size',
number,
'bytesPerSample',
string
]>
];
// type InfoDebugRawReply = [
// ...InfoRawReply,
// 'keySelfName',
// string,
// 'chunks',
// Array<[
// 'startTimestamp',
// number,
// 'endTimestamp',
// number,
// 'samples',
// number,
// 'size',
// number,
// 'bytesPerSample',
// string
// ]>
// ];
interface InfoDebugReply extends InfoReply {
keySelfName: string;
chunks: Array<{
startTimestamp: number;
endTimestamp: number;
samples: number;
size: number;
bytesPerSample: string;
}>;
}
// interface InfoDebugReply extends InfoReply {
// keySelfName: string;
// chunks: Array<{
// startTimestamp: number;
// endTimestamp: number;
// samples: number;
// size: number;
// bytesPerSample: string;
// }>;
// }
export function transformReply(rawReply: InfoDebugRawReply): InfoDebugReply {
const reply = transformInfoReply(rawReply as unknown as InfoRawReply);
(reply as InfoDebugReply).keySelfName = rawReply[25];
(reply as InfoDebugReply).chunks = rawReply[27].map(chunk => ({
startTimestamp: chunk[1],
endTimestamp: chunk[3],
samples: chunk[5],
size: chunk[7],
bytesPerSample: chunk[9]
}));
return reply as InfoDebugReply;
}
// export function transformReply(rawReply: InfoDebugRawReply): InfoDebugReply {
// const reply = transformInfoReply(rawReply as unknown as InfoRawReply);
// (reply as InfoDebugReply).keySelfName = rawReply[25];
// (reply as InfoDebugReply).chunks = rawReply[27].map(chunk => ({
// startTimestamp: chunk[1],
// endTimestamp: chunk[3],
// samples: chunk[5],
// size: chunk[7],
// bytesPerSample: chunk[9]
// }));
// return reply as InfoDebugReply;
// }