1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-09 00:22:08 +03:00
Files
node-redis/packages/time-series/lib/commands/ADD.ts
Nikolay Karadzhov 7b737821b2 fix: fix various command import issues (#2944)
* fix: fix various command import issues

there was some sort of a circular dependency
in <module>/lib/commands/index.ts for various modules

fixes #2937 fixes #2941

* remove redundant definition
2025-05-07 16:10:35 +03:00

59 lines
1.4 KiB
TypeScript

import { CommandParser } from '@redis/client/dist/lib/client/parser';
import { RedisArgument, NumberReply, Command } from '@redis/client/dist/lib/RESP/types';
import {
transformTimestampArgument,
parseRetentionArgument,
TimeSeriesEncoding,
parseEncodingArgument,
parseChunkSizeArgument,
TimeSeriesDuplicatePolicies,
Labels,
parseLabelsArgument,
Timestamp,
parseIgnoreArgument
} from './helpers';
export interface TsIgnoreOptions {
maxTimeDiff: number;
maxValDiff: number;
}
export interface TsAddOptions {
RETENTION?: number;
ENCODING?: TimeSeriesEncoding;
CHUNK_SIZE?: number;
ON_DUPLICATE?: TimeSeriesDuplicatePolicies;
LABELS?: Labels;
IGNORE?: TsIgnoreOptions;
}
export default {
IS_READ_ONLY: false,
parseCommand(
parser: CommandParser,
key: RedisArgument,
timestamp: Timestamp,
value: number,
options?: TsAddOptions
) {
parser.push('TS.ADD');
parser.pushKey(key);
parser.push(transformTimestampArgument(timestamp), value.toString());
parseRetentionArgument(parser, options?.RETENTION);
parseEncodingArgument(parser, options?.ENCODING);
parseChunkSizeArgument(parser, options?.CHUNK_SIZE);
if (options?.ON_DUPLICATE) {
parser.push('ON_DUPLICATE', options.ON_DUPLICATE);
}
parseLabelsArgument(parser, options?.LABELS);
parseIgnoreArgument(parser, options?.IGNORE);
},
transformReply: undefined as unknown as () => NumberReply
} as const satisfies Command;