js-valkey-server 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +558 -0
- package/dist/cli.js +17420 -0
- package/dist/cli.js.map +1 -0
- package/dist/core.d.mts +651 -0
- package/dist/core.d.ts +651 -0
- package/dist/core.js +17929 -0
- package/dist/core.js.map +1 -0
- package/dist/core.mjs +17691 -0
- package/dist/core.mjs.map +1 -0
- package/dist/index.d.mts +502 -0
- package/dist/index.d.ts +502 -0
- package/dist/index.js +18845 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +18749 -0
- package/dist/index.mjs.map +1 -0
- package/dist/redis-error-C96iHLJ-.d.mts +1392 -0
- package/dist/redis-error-C96iHLJ-.d.ts +1392 -0
- package/package.json +119 -0
|
@@ -0,0 +1,1392 @@
|
|
|
1
|
+
import { Server } from 'net';
|
|
2
|
+
import { LuaWasmModule, ReplyValue, LoadOptions } from 'lua-redis-wasm';
|
|
3
|
+
|
|
4
|
+
type RedisFlavor = 'redis' | 'valkey';
|
|
5
|
+
type VersionGate = {
|
|
6
|
+
redis?: string;
|
|
7
|
+
valkey?: string;
|
|
8
|
+
};
|
|
9
|
+
type FeatureId = 'expire.conditions' | 'set.get' | 'set.nx-get' | 'set.exat-pxat' | 'command.docs' | 'command.getkeysandflags' | 'acl.dryrun' | 'client.no-evict' | 'client.kill.maxage' | 'client.setinfo' | 'client.setinfo.unknown-subcommand-error' | 'info.multi-section' | 'shutdown.now-force-abort' | 'pubsub.sharded' | 'pubsub.resp3-publish-reply-first' | 'stream.xautoclaim-deleted-ids' | 'bit.byte-bit-range' | 'hscan.novalues' | 'xread.plus-id' | 'cluster.multi-db';
|
|
10
|
+
interface CompatibilityProfile {
|
|
11
|
+
readonly flavor: RedisFlavor;
|
|
12
|
+
readonly version: string;
|
|
13
|
+
readonly versionNum: number;
|
|
14
|
+
has(feature: FeatureId): boolean;
|
|
15
|
+
}
|
|
16
|
+
type CompatibilitySpec = CompatibilityProfile | {
|
|
17
|
+
flavor?: RedisFlavor;
|
|
18
|
+
version?: string;
|
|
19
|
+
} | 'redis-6.2' | 'redis-7.0' | 'redis-7.2' | 'redis-7.4' | 'redis-8.0' | 'valkey-8.0' | 'valkey-9.0';
|
|
20
|
+
declare function parseVersion(version: string): number;
|
|
21
|
+
declare function resolveCompatibilityProfile(spec?: CompatibilitySpec): CompatibilityProfile;
|
|
22
|
+
declare function gateSatisfied(gate: VersionGate, profile: Pick<CompatibilityProfile, 'flavor' | 'versionNum'>): boolean;
|
|
23
|
+
|
|
24
|
+
type ParseContext = {
|
|
25
|
+
commandName: string;
|
|
26
|
+
profile: CompatibilityProfile;
|
|
27
|
+
};
|
|
28
|
+
type ParseNodeResult<TValue> = {
|
|
29
|
+
value: TValue;
|
|
30
|
+
nextIndex: number;
|
|
31
|
+
};
|
|
32
|
+
interface CommandSchema<TValue> {
|
|
33
|
+
parse(input: readonly Buffer[], index: number, ctx: ParseContext): ParseNodeResult<TValue>;
|
|
34
|
+
}
|
|
35
|
+
type InferSchema<TSchema> = TSchema extends CommandSchema<infer TValue> ? TValue : never;
|
|
36
|
+
type SchemaShape = Record<string, CommandSchema<unknown>>;
|
|
37
|
+
type InferShape<TShape extends SchemaShape> = {
|
|
38
|
+
[K in keyof TShape]: InferSchema<TShape[K]>;
|
|
39
|
+
};
|
|
40
|
+
declare function parseCommandArgs<TArgs>(schema: CommandSchema<TArgs>, input: readonly Buffer[], commandName: string, profile?: CompatibilityProfile): TArgs;
|
|
41
|
+
declare const t: {
|
|
42
|
+
custom<TValue>(parse: CommandSchema<TValue>["parse"]): CommandSchema<TValue>;
|
|
43
|
+
key(): CommandSchema<Buffer>;
|
|
44
|
+
bulk(): CommandSchema<Buffer>;
|
|
45
|
+
string(): CommandSchema<string>;
|
|
46
|
+
integer(options?: {
|
|
47
|
+
min?: number;
|
|
48
|
+
max?: number;
|
|
49
|
+
}): CommandSchema<number>;
|
|
50
|
+
bigInteger(options?: {
|
|
51
|
+
min?: bigint;
|
|
52
|
+
max?: bigint;
|
|
53
|
+
}): CommandSchema<bigint>;
|
|
54
|
+
float(): CommandSchema<number>;
|
|
55
|
+
keyword<TKeyword extends string>(expected: TKeyword): CommandSchema<TKeyword>;
|
|
56
|
+
optional<TValue>(schema: CommandSchema<TValue>): CommandSchema<TValue | undefined>;
|
|
57
|
+
variadic<TValue>(schema: CommandSchema<TValue>, options?: {
|
|
58
|
+
min?: number;
|
|
59
|
+
}): CommandSchema<TValue[]>;
|
|
60
|
+
object<TShape extends SchemaShape>(shape: TShape): CommandSchema<InferShape<TShape>>;
|
|
61
|
+
union<TValue>(schemas: readonly CommandSchema<TValue>[]): CommandSchema<TValue>;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
type RedisClusterNodeRole = 'master' | 'replica';
|
|
65
|
+
type RedisClusterNode = {
|
|
66
|
+
id: string;
|
|
67
|
+
role: RedisClusterNodeRole;
|
|
68
|
+
host: string;
|
|
69
|
+
port: number;
|
|
70
|
+
masterId?: string;
|
|
71
|
+
slots: Array<[number, number]>;
|
|
72
|
+
};
|
|
73
|
+
declare const REDIS_CLUSTER_SLOT_COUNT = 16384;
|
|
74
|
+
declare class RedisClusterTopology {
|
|
75
|
+
readonly nodes: readonly RedisClusterNode[];
|
|
76
|
+
constructor(nodes?: readonly RedisClusterNode[]);
|
|
77
|
+
calculateSlot(key: Buffer): number;
|
|
78
|
+
calculateSlotForKeys(keys: readonly Buffer[]): number | null;
|
|
79
|
+
getNode(id: string): RedisClusterNode | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Returns the master node owning the slot. Replicas are never returned —
|
|
82
|
+
* MOVED must always direct the client to a master. Returns undefined if
|
|
83
|
+
* the slot is unassigned.
|
|
84
|
+
*/
|
|
85
|
+
getSlotOwner(slot: number): RedisClusterNode | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Returns whether the node is the master serving the slot. Replicas never
|
|
88
|
+
* own slots for routing purposes — keyed commands sent directly to a
|
|
89
|
+
* replica must redirect to the master via MOVED.
|
|
90
|
+
*/
|
|
91
|
+
nodeOwnsSlot(nodeId: string, slot: number): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Returns whether a node may serve a readonly command for the slot after the
|
|
94
|
+
* client enabled Redis Cluster READONLY mode. Masters may serve their own
|
|
95
|
+
* slots; replicas may serve slots owned by their configured master.
|
|
96
|
+
*/
|
|
97
|
+
nodeCanServeReadonlySlot(nodeId: string, slot: number): boolean;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
type RedisDataTypeName = 'string' | 'hash' | 'list' | 'set' | 'zset' | 'stream';
|
|
101
|
+
type RedisStringData = {
|
|
102
|
+
type: 'string';
|
|
103
|
+
value: Buffer;
|
|
104
|
+
};
|
|
105
|
+
type RedisHashData = {
|
|
106
|
+
type: 'hash';
|
|
107
|
+
fields: Map<string, RedisHashField>;
|
|
108
|
+
};
|
|
109
|
+
type RedisHashField = {
|
|
110
|
+
field: Buffer;
|
|
111
|
+
value: Buffer;
|
|
112
|
+
expiresAt?: number;
|
|
113
|
+
};
|
|
114
|
+
type RedisListData = {
|
|
115
|
+
type: 'list';
|
|
116
|
+
values: Buffer[];
|
|
117
|
+
};
|
|
118
|
+
type RedisSetData = {
|
|
119
|
+
type: 'set';
|
|
120
|
+
members: Map<string, Buffer>;
|
|
121
|
+
};
|
|
122
|
+
type RedisSortedSetData = {
|
|
123
|
+
type: 'zset';
|
|
124
|
+
members: Map<string, RedisSortedSetMember>;
|
|
125
|
+
};
|
|
126
|
+
type RedisSortedSetMember = {
|
|
127
|
+
member: Buffer;
|
|
128
|
+
score: number;
|
|
129
|
+
};
|
|
130
|
+
type StreamId = {
|
|
131
|
+
ms: bigint;
|
|
132
|
+
seq: bigint;
|
|
133
|
+
};
|
|
134
|
+
type RedisStreamEntry = {
|
|
135
|
+
id: StreamId;
|
|
136
|
+
fields: Buffer[];
|
|
137
|
+
};
|
|
138
|
+
type RedisStreamConsumer = {
|
|
139
|
+
name: Buffer;
|
|
140
|
+
seenAt: number;
|
|
141
|
+
activeAt: number | null;
|
|
142
|
+
};
|
|
143
|
+
type RedisStreamPendingEntry = {
|
|
144
|
+
id: StreamId;
|
|
145
|
+
consumerId: string;
|
|
146
|
+
deliveredAt: number;
|
|
147
|
+
deliveryCount: number;
|
|
148
|
+
};
|
|
149
|
+
type RedisStreamConsumerGroup = {
|
|
150
|
+
name: Buffer;
|
|
151
|
+
lastDeliveredId: StreamId;
|
|
152
|
+
entriesRead: number | null;
|
|
153
|
+
consumers: Map<string, RedisStreamConsumer>;
|
|
154
|
+
pending: Map<string, RedisStreamPendingEntry>;
|
|
155
|
+
};
|
|
156
|
+
type RedisStreamData = {
|
|
157
|
+
type: 'stream';
|
|
158
|
+
entries: RedisStreamEntry[];
|
|
159
|
+
lastId: StreamId;
|
|
160
|
+
entriesAdded: number;
|
|
161
|
+
maxDeletedEntryId: StreamId;
|
|
162
|
+
groups: Map<string, RedisStreamConsumerGroup>;
|
|
163
|
+
};
|
|
164
|
+
type RedisDataValue = RedisStringData | RedisHashData | RedisListData | RedisSetData | RedisSortedSetData | RedisStreamData;
|
|
165
|
+
declare function cloneRedisDataValue(value: RedisDataValue): RedisDataValue;
|
|
166
|
+
declare function createStringData(value: Buffer): RedisStringData;
|
|
167
|
+
declare function createHashData(): RedisHashData;
|
|
168
|
+
declare function createListData(): RedisListData;
|
|
169
|
+
declare function createSetData(): RedisSetData;
|
|
170
|
+
declare function createSortedSetData(): RedisSortedSetData;
|
|
171
|
+
|
|
172
|
+
type RedisMutationEvent = {
|
|
173
|
+
type: 'write';
|
|
174
|
+
database: number;
|
|
175
|
+
key: Buffer;
|
|
176
|
+
value: RedisDataValue;
|
|
177
|
+
expiresAt?: number;
|
|
178
|
+
} | {
|
|
179
|
+
type: 'delete';
|
|
180
|
+
database: number;
|
|
181
|
+
key: Buffer;
|
|
182
|
+
} | {
|
|
183
|
+
type: 'expire';
|
|
184
|
+
database: number;
|
|
185
|
+
key: Buffer;
|
|
186
|
+
expiresAt: number;
|
|
187
|
+
} | {
|
|
188
|
+
type: 'persist';
|
|
189
|
+
database: number;
|
|
190
|
+
key: Buffer;
|
|
191
|
+
} | {
|
|
192
|
+
type: 'evict';
|
|
193
|
+
database: number;
|
|
194
|
+
key: Buffer;
|
|
195
|
+
} | {
|
|
196
|
+
type: 'flush';
|
|
197
|
+
database: number;
|
|
198
|
+
};
|
|
199
|
+
type RedisMutationListener = (event: RedisMutationEvent) => void;
|
|
200
|
+
type Unsubscribe = () => void;
|
|
201
|
+
declare class RedisMutationBus {
|
|
202
|
+
private readonly globalListeners;
|
|
203
|
+
private readonly keyListeners;
|
|
204
|
+
subscribe(listener: RedisMutationListener): Unsubscribe;
|
|
205
|
+
subscribeKey(key: Buffer, listener: RedisMutationListener): Unsubscribe;
|
|
206
|
+
emit(event: RedisMutationEvent): void;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
type ExpirationState = {
|
|
210
|
+
kind: 'missing';
|
|
211
|
+
} | {
|
|
212
|
+
kind: 'persistent';
|
|
213
|
+
} | {
|
|
214
|
+
kind: 'expires';
|
|
215
|
+
expiresAt: number;
|
|
216
|
+
};
|
|
217
|
+
type KeyspaceEntry = {
|
|
218
|
+
key: Buffer;
|
|
219
|
+
value: RedisDataValue;
|
|
220
|
+
expiresAt?: number;
|
|
221
|
+
};
|
|
222
|
+
type SetOptions = {
|
|
223
|
+
expiresAt?: number;
|
|
224
|
+
keepTtl?: boolean;
|
|
225
|
+
};
|
|
226
|
+
type KeyspaceMutationTracker = {
|
|
227
|
+
markChanged(): void;
|
|
228
|
+
markCommitted(): void;
|
|
229
|
+
};
|
|
230
|
+
declare class WrongRedisTypeError extends Error {
|
|
231
|
+
readonly expected: RedisDataTypeName;
|
|
232
|
+
readonly actual: RedisDataTypeName;
|
|
233
|
+
constructor(expected: RedisDataTypeName, actual: RedisDataTypeName);
|
|
234
|
+
}
|
|
235
|
+
declare class RedisKeyspace {
|
|
236
|
+
private readonly database;
|
|
237
|
+
private readonly mutations;
|
|
238
|
+
private readonly entries;
|
|
239
|
+
constructor(database: number, mutations: RedisMutationBus);
|
|
240
|
+
get(key: Buffer): RedisDataValue | null;
|
|
241
|
+
getType(key: Buffer): RedisDataTypeName | null;
|
|
242
|
+
set(key: Buffer, value: RedisDataValue, options?: SetOptions): void;
|
|
243
|
+
delete(key: Buffer): boolean;
|
|
244
|
+
expire(key: Buffer, expiresAt: number): boolean;
|
|
245
|
+
persist(key: Buffer): boolean;
|
|
246
|
+
getExpiration(key: Buffer): ExpirationState;
|
|
247
|
+
update<TValue extends RedisDataValue, TResult>(key: Buffer, expectedType: TValue['type'], createValue: () => TValue, mutator: (value: TValue, tracker: KeyspaceMutationTracker) => TResult): TResult;
|
|
248
|
+
flush(): void;
|
|
249
|
+
size(): number;
|
|
250
|
+
entriesSnapshot(): KeyspaceEntry[];
|
|
251
|
+
sweepExpired(now?: number): number;
|
|
252
|
+
private getLiveEntry;
|
|
253
|
+
private evictIfExpired;
|
|
254
|
+
private emitWrite;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
interface RedisTurnHandle {
|
|
258
|
+
release(): void;
|
|
259
|
+
suspend(waitFor: Promise<unknown>): Promise<RedisTurnHandle>;
|
|
260
|
+
}
|
|
261
|
+
interface RedisTurnQueue {
|
|
262
|
+
waitTurn(): Promise<RedisTurnHandle>;
|
|
263
|
+
}
|
|
264
|
+
declare class SerialTurnQueue implements RedisTurnQueue {
|
|
265
|
+
private readonly queue;
|
|
266
|
+
private locked;
|
|
267
|
+
waitTurn(): Promise<RedisTurnHandle>;
|
|
268
|
+
private waitTurnInternal;
|
|
269
|
+
private scheduleNext;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
declare class TrackedHashData {
|
|
273
|
+
private readonly hash;
|
|
274
|
+
private readonly tracker;
|
|
275
|
+
constructor(hash: RedisHashData, tracker: KeyspaceMutationTracker);
|
|
276
|
+
get size(): number;
|
|
277
|
+
getField(field: Buffer): RedisHashField | undefined;
|
|
278
|
+
hasField(field: Buffer): boolean;
|
|
279
|
+
setField(field: Buffer, value: Buffer, options?: {
|
|
280
|
+
forceDirty?: boolean;
|
|
281
|
+
keepTtl?: boolean;
|
|
282
|
+
}): {
|
|
283
|
+
added: boolean;
|
|
284
|
+
valueChanged: boolean;
|
|
285
|
+
};
|
|
286
|
+
setFieldIfAbsent(field: Buffer, value: Buffer): boolean;
|
|
287
|
+
deleteField(field: Buffer): boolean;
|
|
288
|
+
setFieldExpiration(field: Buffer, expiresAt: number): boolean;
|
|
289
|
+
clearFieldExpiration(field: Buffer): boolean;
|
|
290
|
+
entries(): IterableIterator<RedisHashField>;
|
|
291
|
+
private deleteExpiredFields;
|
|
292
|
+
}
|
|
293
|
+
declare class TrackedListData {
|
|
294
|
+
private readonly list;
|
|
295
|
+
private readonly tracker;
|
|
296
|
+
constructor(list: RedisListData, tracker: KeyspaceMutationTracker);
|
|
297
|
+
get length(): number;
|
|
298
|
+
pushLeft(values: readonly Buffer[]): number;
|
|
299
|
+
pushRight(values: readonly Buffer[]): number;
|
|
300
|
+
pop(side: 'left' | 'right'): Buffer | null;
|
|
301
|
+
popMany(side: 'left' | 'right', count: number): Buffer[];
|
|
302
|
+
setAt(index: number, value: Buffer): void;
|
|
303
|
+
insertRelativeTo(pivot: Buffer, element: Buffer, position: 'before' | 'after'): number;
|
|
304
|
+
removeMatching(count: number, element: Buffer): number;
|
|
305
|
+
trim(start: number, stop: number, options?: {
|
|
306
|
+
forceDirty?: boolean;
|
|
307
|
+
}): {
|
|
308
|
+
empty: boolean;
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
declare class TrackedSetData {
|
|
312
|
+
private readonly set;
|
|
313
|
+
private readonly tracker;
|
|
314
|
+
constructor(set: RedisSetData, tracker: KeyspaceMutationTracker);
|
|
315
|
+
get size(): number;
|
|
316
|
+
hasMember(member: Buffer): boolean;
|
|
317
|
+
addMember(member: Buffer): boolean;
|
|
318
|
+
deleteMember(member: Buffer): boolean;
|
|
319
|
+
deleteMemberId(hex: string): boolean;
|
|
320
|
+
randomMemberEntries(): [string, Buffer][];
|
|
321
|
+
replaceMembers(hexSet: Set<string>, bufferMap: Map<string, Buffer>, options?: {
|
|
322
|
+
forceDirty?: boolean;
|
|
323
|
+
}): void;
|
|
324
|
+
}
|
|
325
|
+
declare class TrackedSortedSetData {
|
|
326
|
+
private readonly zset;
|
|
327
|
+
private readonly tracker;
|
|
328
|
+
constructor(zset: RedisSortedSetData, tracker: KeyspaceMutationTracker);
|
|
329
|
+
get size(): number;
|
|
330
|
+
getMember(member: Buffer): RedisSortedSetMember | undefined;
|
|
331
|
+
setScore(member: Buffer, score: number, options?: {
|
|
332
|
+
forceDirty?: boolean;
|
|
333
|
+
}): {
|
|
334
|
+
added: boolean;
|
|
335
|
+
scoreChanged: boolean;
|
|
336
|
+
};
|
|
337
|
+
deleteMember(member: Buffer): boolean;
|
|
338
|
+
deleteMemberId(hex: string): boolean;
|
|
339
|
+
entries(): IterableIterator<[string, RedisSortedSetMember]>;
|
|
340
|
+
replaceMembers(members: Map<string, RedisSortedSetMember>, options?: {
|
|
341
|
+
forceDirty?: boolean;
|
|
342
|
+
}): void;
|
|
343
|
+
}
|
|
344
|
+
type StreamDelivery = {
|
|
345
|
+
id: StreamId;
|
|
346
|
+
fields: Buffer[] | null;
|
|
347
|
+
};
|
|
348
|
+
type ClaimedEntry = {
|
|
349
|
+
id: StreamId;
|
|
350
|
+
fields: Buffer[];
|
|
351
|
+
};
|
|
352
|
+
type AutoClaimedEntry = {
|
|
353
|
+
id: StreamId;
|
|
354
|
+
fields: Buffer[] | null;
|
|
355
|
+
};
|
|
356
|
+
type AutoClaimResult = {
|
|
357
|
+
nextStartId: StreamId;
|
|
358
|
+
claimed: AutoClaimedEntry[];
|
|
359
|
+
deleted: StreamId[];
|
|
360
|
+
};
|
|
361
|
+
declare class TrackedStreamData {
|
|
362
|
+
private readonly stream;
|
|
363
|
+
private readonly tracker;
|
|
364
|
+
constructor(stream: RedisStreamData, tracker: KeyspaceMutationTracker);
|
|
365
|
+
get value(): RedisStreamData;
|
|
366
|
+
get lastId(): StreamId;
|
|
367
|
+
appendEntry(id: StreamId, fields: Buffer[]): void;
|
|
368
|
+
trim(callback: (stream: RedisStreamData) => number): number;
|
|
369
|
+
deleteEntries(targets: readonly StreamId[], compare: (left: StreamId, right: StreamId) => number, onDelete: (entry: RedisStreamEntry) => void): number;
|
|
370
|
+
ack(group: RedisStreamConsumerGroup, ids: readonly StreamId[]): number;
|
|
371
|
+
setId(id: StreamId, options: {
|
|
372
|
+
entriesAdded: number | null;
|
|
373
|
+
maxDeletedId: StreamId | null;
|
|
374
|
+
}): void;
|
|
375
|
+
setGroupId(group: RedisStreamConsumerGroup, lastDeliveredId: StreamId, entriesRead: number | null): void;
|
|
376
|
+
readGroup(group: RedisStreamConsumerGroup, consumerName: Buffer, id: StreamId | '>', options: {
|
|
377
|
+
count: number | null;
|
|
378
|
+
noack: boolean;
|
|
379
|
+
}, now: number): StreamDelivery[];
|
|
380
|
+
claim(group: RedisStreamConsumerGroup, consumerName: Buffer, ids: readonly StreamId[], options: {
|
|
381
|
+
minIdleMs: number;
|
|
382
|
+
idleMs: number | null;
|
|
383
|
+
timeMs: number | null;
|
|
384
|
+
retryCount: number | null;
|
|
385
|
+
force: boolean;
|
|
386
|
+
justId: boolean;
|
|
387
|
+
lastId: StreamId | null;
|
|
388
|
+
}, now: number): ClaimedEntry[];
|
|
389
|
+
autoClaim(group: RedisStreamConsumerGroup, consumerName: Buffer, options: {
|
|
390
|
+
minIdleMs: number;
|
|
391
|
+
start: StreamId;
|
|
392
|
+
count: number;
|
|
393
|
+
justId: boolean;
|
|
394
|
+
cleanDeletedEntries: boolean;
|
|
395
|
+
}, now: number): AutoClaimResult;
|
|
396
|
+
addGroup(groupId: string, group: RedisStreamConsumerGroup): void;
|
|
397
|
+
deleteGroup(groupId: string): boolean;
|
|
398
|
+
addConsumer(group: RedisStreamConsumerGroup, consumerId: string, consumer: RedisStreamConsumer): boolean;
|
|
399
|
+
deleteConsumer(group: RedisStreamConsumerGroup, consumerId: string): number;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
declare class RedisDatabase {
|
|
403
|
+
readonly id: number;
|
|
404
|
+
readonly mutations: RedisMutationBus;
|
|
405
|
+
/**
|
|
406
|
+
* Per-database serialization turn. All sessions targeting this database
|
|
407
|
+
* acquire turns from here so writes do not interleave. Sessions on other
|
|
408
|
+
* databases run on independent queues, which means the mock allows
|
|
409
|
+
* cross-database parallelism — real Redis is single-threaded across all
|
|
410
|
+
* databases. Acceptable for a mock; do not rely on cross-database
|
|
411
|
+
* serialization in tests.
|
|
412
|
+
*/
|
|
413
|
+
readonly turnQueue: RedisTurnQueue;
|
|
414
|
+
/**
|
|
415
|
+
* Name of the command currently executing against this database, set by the
|
|
416
|
+
* CommandExecutor around `definition.execute`. Keyspace notifications read it
|
|
417
|
+
* to name write events after the originating command (e.g. LPUSH → `lpush`),
|
|
418
|
+
* which the mutation bus itself does not carry. `null` outside command
|
|
419
|
+
* execution.
|
|
420
|
+
*/
|
|
421
|
+
activeNotifyCommand: string | null;
|
|
422
|
+
private readonly keyspace;
|
|
423
|
+
constructor(id: number);
|
|
424
|
+
get(key: Buffer): RedisDataValue | null;
|
|
425
|
+
getString(key: Buffer): Buffer | null;
|
|
426
|
+
getType(key: Buffer): RedisDataValue['type'] | null;
|
|
427
|
+
set(key: Buffer, value: RedisDataValue, options?: SetOptions): void;
|
|
428
|
+
setString(key: Buffer, value: Buffer, options?: SetOptions): void;
|
|
429
|
+
delete(key: Buffer): boolean;
|
|
430
|
+
expire(key: Buffer, expiresAt: number): boolean;
|
|
431
|
+
persist(key: Buffer): boolean;
|
|
432
|
+
getExpiration(key: Buffer): ExpirationState;
|
|
433
|
+
getHash(key: Buffer): RedisHashData | null;
|
|
434
|
+
getList(key: Buffer): RedisListData | null;
|
|
435
|
+
getSet(key: Buffer): RedisSetData | null;
|
|
436
|
+
getSortedSet(key: Buffer): RedisSortedSetData | null;
|
|
437
|
+
getStream(key: Buffer): RedisStreamData | null;
|
|
438
|
+
updateHash<TResult>(key: Buffer, mutator: (hash: TrackedHashData) => TResult): TResult;
|
|
439
|
+
updateList<TResult>(key: Buffer, mutator: (list: TrackedListData) => TResult): TResult;
|
|
440
|
+
updateSet<TResult>(key: Buffer, mutator: (set: TrackedSetData) => TResult): TResult;
|
|
441
|
+
updateSortedSet<TResult>(key: Buffer, mutator: (zset: TrackedSortedSetData) => TResult): TResult;
|
|
442
|
+
updateStream<TResult>(key: Buffer, mutator: (stream: TrackedStreamData) => TResult): TResult;
|
|
443
|
+
private getTyped;
|
|
444
|
+
private updateTyped;
|
|
445
|
+
flush(): void;
|
|
446
|
+
size(): number;
|
|
447
|
+
entriesSnapshot(): KeyspaceEntry[];
|
|
448
|
+
sweepExpired(now?: number): number;
|
|
449
|
+
subscribe(listener: RedisMutationListener): Unsubscribe;
|
|
450
|
+
subscribeKey(key: Buffer, listener: RedisMutationListener): Unsubscribe;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
type RedisMonitorCommandEvent = {
|
|
454
|
+
timestampMs: number;
|
|
455
|
+
database: number;
|
|
456
|
+
clientId: string;
|
|
457
|
+
clientAddress?: string;
|
|
458
|
+
command: Buffer;
|
|
459
|
+
args: readonly Buffer[];
|
|
460
|
+
};
|
|
461
|
+
type RedisMonitorCommandListener = (event: RedisMonitorCommandEvent) => void;
|
|
462
|
+
declare class RedisMonitorFeed {
|
|
463
|
+
private readonly listeners;
|
|
464
|
+
get subscriberCount(): number;
|
|
465
|
+
subscribe(listener: RedisMonitorCommandListener): Unsubscribe;
|
|
466
|
+
publish(event: RedisMonitorCommandEvent): void;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
type RedisPubSubMessage = {
|
|
470
|
+
channel: Buffer;
|
|
471
|
+
message: Buffer;
|
|
472
|
+
};
|
|
473
|
+
type RedisPubSubPatternMessage = RedisPubSubMessage & {
|
|
474
|
+
pattern: Buffer;
|
|
475
|
+
};
|
|
476
|
+
type RedisPubSubMessageListener = (message: RedisPubSubMessage) => void;
|
|
477
|
+
type RedisPubSubPatternMessageListener = (message: RedisPubSubPatternMessage) => void;
|
|
478
|
+
declare class RedisPubSubBroker {
|
|
479
|
+
private readonly channels;
|
|
480
|
+
private readonly shardChannels;
|
|
481
|
+
private readonly patterns;
|
|
482
|
+
subscribe(channel: Buffer, listener: RedisPubSubMessageListener): Unsubscribe;
|
|
483
|
+
psubscribe(pattern: Buffer, listener: RedisPubSubPatternMessageListener): Unsubscribe;
|
|
484
|
+
ssubscribe(channel: Buffer, listener: RedisPubSubMessageListener): Unsubscribe;
|
|
485
|
+
publish(channel: Buffer, message: Buffer): number;
|
|
486
|
+
spublish(channel: Buffer, message: Buffer): number;
|
|
487
|
+
channelsMatching(pattern?: Buffer): Buffer[];
|
|
488
|
+
shardChannelsMatching(pattern?: Buffer): Buffer[];
|
|
489
|
+
subscriberCount(channel: Buffer): number;
|
|
490
|
+
shardSubscriberCount(channel: Buffer): number;
|
|
491
|
+
patternSubscriptionCount(): number;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
declare class RedisScriptCache {
|
|
495
|
+
private readonly scripts;
|
|
496
|
+
load(script: Buffer): string;
|
|
497
|
+
get(sha: string): Buffer | null;
|
|
498
|
+
exists(sha: string): boolean;
|
|
499
|
+
existsAll(shas: readonly string[]): boolean[];
|
|
500
|
+
flush(): void;
|
|
501
|
+
size(): number;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
type RedisFunctionDefinition = {
|
|
505
|
+
name: string;
|
|
506
|
+
libraryName: string;
|
|
507
|
+
script: Buffer;
|
|
508
|
+
flags: string[];
|
|
509
|
+
};
|
|
510
|
+
type RedisFunctionLibrary = {
|
|
511
|
+
name: string;
|
|
512
|
+
code: Buffer;
|
|
513
|
+
functions: RedisFunctionDefinition[];
|
|
514
|
+
};
|
|
515
|
+
declare class RedisFunctionRegistry {
|
|
516
|
+
private readonly libraries;
|
|
517
|
+
load(library: RedisFunctionLibrary, replace?: boolean): void;
|
|
518
|
+
delete(name: string): boolean;
|
|
519
|
+
clear(): void;
|
|
520
|
+
list(): RedisFunctionLibrary[];
|
|
521
|
+
findFunction(name: string): RedisFunctionDefinition | null;
|
|
522
|
+
dump(): Buffer;
|
|
523
|
+
restore(payload: Buffer, mode: 'append' | 'flush' | 'replace'): void;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
type RedisValue = {
|
|
527
|
+
kind: 'simple-string';
|
|
528
|
+
value: string;
|
|
529
|
+
} | {
|
|
530
|
+
kind: 'bulk-string';
|
|
531
|
+
value: Buffer | null;
|
|
532
|
+
} | {
|
|
533
|
+
kind: 'integer';
|
|
534
|
+
value: number | bigint;
|
|
535
|
+
} | {
|
|
536
|
+
kind: 'double';
|
|
537
|
+
value: number;
|
|
538
|
+
} | {
|
|
539
|
+
kind: 'boolean';
|
|
540
|
+
value: boolean;
|
|
541
|
+
} | {
|
|
542
|
+
kind: 'big-number';
|
|
543
|
+
value: bigint;
|
|
544
|
+
} | {
|
|
545
|
+
kind: 'verbatim';
|
|
546
|
+
format: string;
|
|
547
|
+
value: Buffer;
|
|
548
|
+
} | {
|
|
549
|
+
kind: 'array';
|
|
550
|
+
items: RedisValue[];
|
|
551
|
+
} | {
|
|
552
|
+
kind: 'set';
|
|
553
|
+
items: RedisValue[];
|
|
554
|
+
} | {
|
|
555
|
+
kind: 'map';
|
|
556
|
+
entries: [RedisValue, RedisValue][];
|
|
557
|
+
} | {
|
|
558
|
+
kind: 'map-pairs';
|
|
559
|
+
entries: [RedisValue, RedisValue][];
|
|
560
|
+
} | {
|
|
561
|
+
kind: 'flat-pairs';
|
|
562
|
+
entries: [RedisValue, RedisValue][];
|
|
563
|
+
} | {
|
|
564
|
+
kind: 'push';
|
|
565
|
+
name: string;
|
|
566
|
+
items: RedisValue[];
|
|
567
|
+
} | {
|
|
568
|
+
kind: 'null';
|
|
569
|
+
} | {
|
|
570
|
+
kind: 'null-array';
|
|
571
|
+
} | {
|
|
572
|
+
kind: 'error';
|
|
573
|
+
message: string;
|
|
574
|
+
code?: string;
|
|
575
|
+
};
|
|
576
|
+
declare const RedisValue: {
|
|
577
|
+
simpleString: (value: string) => RedisValue;
|
|
578
|
+
bulkString: (value: Buffer | null) => RedisValue;
|
|
579
|
+
integer: (value: number | bigint) => RedisValue;
|
|
580
|
+
double: (value: number) => RedisValue;
|
|
581
|
+
boolean: (value: boolean) => RedisValue;
|
|
582
|
+
bigNumber: (value: bigint) => RedisValue;
|
|
583
|
+
verbatim: (format: string, value: Buffer) => RedisValue;
|
|
584
|
+
array: (items: RedisValue[]) => RedisValue;
|
|
585
|
+
set: (items: RedisValue[]) => RedisValue;
|
|
586
|
+
map: (entries: [RedisValue, RedisValue][]) => RedisValue;
|
|
587
|
+
mapPairs: (entries: [RedisValue, RedisValue][]) => RedisValue;
|
|
588
|
+
flatPairs: (entries: [RedisValue, RedisValue][]) => RedisValue;
|
|
589
|
+
push: (name: string, items: RedisValue[]) => RedisValue;
|
|
590
|
+
null: () => RedisValue;
|
|
591
|
+
nullArray: () => RedisValue;
|
|
592
|
+
error: (message: string, code?: string) => RedisValue;
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
type LuaReplyValue = ReplyValue;
|
|
596
|
+
declare class RedisLuaRuntime {
|
|
597
|
+
private readonly hostState;
|
|
598
|
+
private readonly engine;
|
|
599
|
+
constructor(module: LuaWasmModule);
|
|
600
|
+
eval(script: Buffer, keys: readonly Buffer[], args: readonly Buffer[], ctx: RedisExecutionContext, options?: {
|
|
601
|
+
readOnly?: boolean;
|
|
602
|
+
}): ReplyValue;
|
|
603
|
+
private runRedisCommand;
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* Override where the Lua WASM module + Emscripten glue are loaded from — e.g. a
|
|
607
|
+
* CDN URL (`{ modulePath, wasmPath }`) or preloaded bytes (`{ wasmBytes }`).
|
|
608
|
+
* Affects every runtime created afterwards, so set it once before the first EVAL.
|
|
609
|
+
* Mainly useful in browser bundles that want the `.wasm` served from a CDN
|
|
610
|
+
* instead of emitted as a local asset.
|
|
611
|
+
*/
|
|
612
|
+
declare function setLuaWasmLoadOptions(options: LoadOptions): void;
|
|
613
|
+
declare function createRedisLuaRuntime(profile?: CompatibilityProfile): Promise<RedisLuaRuntime>;
|
|
614
|
+
declare function luaReplyToRedisValue(value: ReplyValue): RedisValue;
|
|
615
|
+
|
|
616
|
+
type RedisServerStateOptions = {
|
|
617
|
+
databaseCount?: number;
|
|
618
|
+
clusterTopology?: RedisClusterTopology;
|
|
619
|
+
monitorFeed?: RedisMonitorFeed;
|
|
620
|
+
pubsubBroker?: RedisPubSubBroker;
|
|
621
|
+
scriptCache?: RedisScriptCache;
|
|
622
|
+
functionRegistry?: RedisFunctionRegistry;
|
|
623
|
+
/**
|
|
624
|
+
* Interval for the background active-expiry sweep. Set to `false` to disable
|
|
625
|
+
* the timer for tests that need full manual control of expiration.
|
|
626
|
+
*/
|
|
627
|
+
activeExpiryIntervalMs?: number | false;
|
|
628
|
+
/**
|
|
629
|
+
* Optional server password (Redis `requirepass`). When set, connections start
|
|
630
|
+
* unauthenticated and must `AUTH` before running most commands. When unset,
|
|
631
|
+
* the default user is `nopass` and no authentication is enforced.
|
|
632
|
+
*/
|
|
633
|
+
requirepass?: string;
|
|
634
|
+
compatibility?: CompatibilitySpec;
|
|
635
|
+
};
|
|
636
|
+
declare class RedisServerState {
|
|
637
|
+
readonly databases: RedisDatabase[];
|
|
638
|
+
readonly scriptCache: RedisScriptCache;
|
|
639
|
+
readonly monitorFeed: RedisMonitorFeed;
|
|
640
|
+
readonly pubsubBroker: RedisPubSubBroker;
|
|
641
|
+
readonly functionRegistry: RedisFunctionRegistry;
|
|
642
|
+
readonly clusterTopology: RedisClusterTopology;
|
|
643
|
+
readonly requirepass?: string;
|
|
644
|
+
readonly profile: CompatibilityProfile;
|
|
645
|
+
/**
|
|
646
|
+
* Normalized `notify-keyspace-events` flag string (Redis canonical form, e.g.
|
|
647
|
+
* `"AKE"`). Empty string disables keyspace notifications. Managed via
|
|
648
|
+
* CONFIG GET/SET; read by the wired {@link KeyspaceNotifier} on each mutation.
|
|
649
|
+
*/
|
|
650
|
+
notifyKeyspaceEvents: string;
|
|
651
|
+
private readonly clientSessions;
|
|
652
|
+
private activeExpiryTimer;
|
|
653
|
+
private closed;
|
|
654
|
+
private luaRuntimePromise;
|
|
655
|
+
constructor(options?: RedisServerStateOptions);
|
|
656
|
+
/**
|
|
657
|
+
* Returns this server's own Lua runtime, created lazily and memoized per
|
|
658
|
+
* RedisServerState instance. Scoping the runtime here (rather than a
|
|
659
|
+
* process-wide singleton) keeps each logical node's LuaEngine + script
|
|
660
|
+
* re-entrancy guard isolated, so concurrent EVALs on independent
|
|
661
|
+
* server/cluster nodes never collide (issue #130).
|
|
662
|
+
*/
|
|
663
|
+
getLuaRuntime(): Promise<RedisLuaRuntime>;
|
|
664
|
+
getDatabase(id: number): RedisDatabase;
|
|
665
|
+
registerClientSession(session: RedisClientSession): Unsubscribe;
|
|
666
|
+
getConnectedClients(): readonly RedisClientSession[];
|
|
667
|
+
/**
|
|
668
|
+
* Flushes keyspace data only. Redis script cache is server-wide state and
|
|
669
|
+
* remains intact until SCRIPT FLUSH.
|
|
670
|
+
*/
|
|
671
|
+
flushAllDatabases(): void;
|
|
672
|
+
sweepExpired(now?: number): number;
|
|
673
|
+
close(): void;
|
|
674
|
+
private startActiveExpiry;
|
|
675
|
+
private scheduleActiveExpiry;
|
|
676
|
+
private runActiveExpiryTick;
|
|
677
|
+
private runActiveExpiry;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
type RedisResultOptions = {
|
|
681
|
+
close?: boolean;
|
|
682
|
+
disconnect?: boolean;
|
|
683
|
+
omitReply?: boolean;
|
|
684
|
+
afterReply?: () => void;
|
|
685
|
+
};
|
|
686
|
+
declare class RedisResult {
|
|
687
|
+
readonly value: RedisValue;
|
|
688
|
+
readonly options?: RedisResultOptions | undefined;
|
|
689
|
+
readonly encoded?: Buffer | undefined;
|
|
690
|
+
constructor(value: RedisValue, options?: RedisResultOptions | undefined, encoded?: Buffer | undefined);
|
|
691
|
+
static create(value: RedisValue, options?: RedisResultOptions): RedisResult;
|
|
692
|
+
static preEncoded(value: RedisValue, encoded: Buffer, options?: RedisResultOptions): RedisResult;
|
|
693
|
+
static nil(): RedisResult;
|
|
694
|
+
static ok(): RedisResult;
|
|
695
|
+
static error(message: string, code?: string): RedisResult;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
type RespVersion = 2 | 3;
|
|
699
|
+
type RespEncodeOptions = {
|
|
700
|
+
version?: RespVersion;
|
|
701
|
+
};
|
|
702
|
+
declare function encodeRedisResult(result: RedisResult, options?: RespEncodeOptions): Buffer;
|
|
703
|
+
declare function encodeRedisValue(value: RedisValue, options?: RespEncodeOptions): Buffer;
|
|
704
|
+
|
|
705
|
+
type ParkRequest<TValue> = {
|
|
706
|
+
waitFor: Promise<TValue | null>;
|
|
707
|
+
timeoutMs?: number;
|
|
708
|
+
signal: AbortSignal;
|
|
709
|
+
};
|
|
710
|
+
type ParkHandler = <TValue>(request: ParkRequest<TValue>) => Promise<TValue | null>;
|
|
711
|
+
type ClientSessionMode = 'normal' | 'transaction' | 'subscribed';
|
|
712
|
+
type RedisMonitorContext = {
|
|
713
|
+
readonly disabled?: boolean;
|
|
714
|
+
readonly defer?: boolean;
|
|
715
|
+
readonly clientAddress?: string;
|
|
716
|
+
readonly deferredEvents?: RedisMonitorCommandEvent[];
|
|
717
|
+
};
|
|
718
|
+
interface RedisClientSession {
|
|
719
|
+
readonly id: string;
|
|
720
|
+
readonly clientAddress?: string;
|
|
721
|
+
readonly connectedAtMs: number;
|
|
722
|
+
readonly selectedDatabase: number;
|
|
723
|
+
readonly mode: ClientSessionMode;
|
|
724
|
+
readonly protocolVersion: RespVersion;
|
|
725
|
+
readonly usesSubscribedReplyMode: boolean;
|
|
726
|
+
readonly clusterReadOnly: boolean;
|
|
727
|
+
readonly isAuthenticated: boolean;
|
|
728
|
+
setAuthenticated(value: boolean): void;
|
|
729
|
+
setProtocolVersion(version: RespVersion): void;
|
|
730
|
+
setClusterReadOnly(value: boolean): void;
|
|
731
|
+
selectDatabase(database: number): void;
|
|
732
|
+
beginTransaction(): void;
|
|
733
|
+
queueTransaction(plan: CommandPlan): void;
|
|
734
|
+
drainTransaction(): CommandPlan[];
|
|
735
|
+
discardTransaction(): void;
|
|
736
|
+
markTransactionDirty(): void;
|
|
737
|
+
isTransactionDirty(): boolean;
|
|
738
|
+
executeTransaction(plans: readonly CommandPlan[]): Promise<RedisResult>;
|
|
739
|
+
watch(keys: readonly Buffer[]): void;
|
|
740
|
+
unwatch(): void;
|
|
741
|
+
isWatchDirty(): boolean;
|
|
742
|
+
readonly pubsubChannelCount: number;
|
|
743
|
+
readonly pubsubShardChannelCount: number;
|
|
744
|
+
readonly pubsubPatternCount: number;
|
|
745
|
+
readonly pubsubSubscriptionCount: number;
|
|
746
|
+
subscribePubSubChannels(channels: readonly Buffer[]): RedisResult[];
|
|
747
|
+
unsubscribePubSubChannels(channels: readonly Buffer[]): RedisResult[];
|
|
748
|
+
subscribePubSubShardChannels(channels: readonly Buffer[]): RedisResult[];
|
|
749
|
+
unsubscribePubSubShardChannels(channels: readonly Buffer[]): RedisResult[];
|
|
750
|
+
subscribePubSubPatterns(patterns: readonly Buffer[]): RedisResult[];
|
|
751
|
+
unsubscribePubSubPatterns(patterns: readonly Buffer[]): RedisResult[];
|
|
752
|
+
resetPubSub(): void;
|
|
753
|
+
deferPushesUntilAfterReply(): () => void;
|
|
754
|
+
registerResponseStreamCleanup(cleanup: () => void): () => void;
|
|
755
|
+
resetResponseStreams(): void;
|
|
756
|
+
disconnect(reason?: string): void;
|
|
757
|
+
}
|
|
758
|
+
interface RedisExecutionContext {
|
|
759
|
+
readonly db: RedisDatabase;
|
|
760
|
+
readonly server: RedisServerState;
|
|
761
|
+
readonly session: RedisClientSession;
|
|
762
|
+
readonly executor: CommandExecutor;
|
|
763
|
+
readonly transactionReplay?: boolean;
|
|
764
|
+
readonly nodeRole?: RedisClusterNodeRole;
|
|
765
|
+
readonly monitor?: RedisMonitorContext;
|
|
766
|
+
readonly signal: AbortSignal;
|
|
767
|
+
park: ParkHandler;
|
|
768
|
+
}
|
|
769
|
+
declare function createDefaultParkHandler(): ParkHandler;
|
|
770
|
+
declare function createNoopParkHandler(): ParkHandler;
|
|
771
|
+
/**
|
|
772
|
+
* Park handler for commands replayed inside MULTI/EXEC.
|
|
773
|
+
*
|
|
774
|
+
* Blocking commands (BLPOP, BLMOVE, BLMPOP, BZMPOP, XREAD BLOCK, ...) must not
|
|
775
|
+
* actually block here: real Redis runs them non-blocking inside a transaction
|
|
776
|
+
* and returns the immediate "nothing happened" result (e.g. BLPOP -> nil). This
|
|
777
|
+
* resolves `null` straight away — the same timeout sentinel a real park returns
|
|
778
|
+
* on expiry — so the command takes its non-blocking branch and its `finally`
|
|
779
|
+
* cleanup (wakeup-subscription teardown) runs.
|
|
780
|
+
*
|
|
781
|
+
* Unlike a bare `async () => null`, it still *honors* the park request:
|
|
782
|
+
* - it attaches a no-op handler to `request.waitFor`, so a command whose wait
|
|
783
|
+
* rejects never surfaces an unhandled promise rejection (mirrors
|
|
784
|
+
* {@link createDefaultParkHandler}, which consumes `waitFor`);
|
|
785
|
+
* - it rejects with an AbortError if the session signal is already aborted, so
|
|
786
|
+
* a transaction aborted mid-EXEC propagates immediately instead of swallowing
|
|
787
|
+
* the abort.
|
|
788
|
+
*
|
|
789
|
+
* Commands MUST release any wakeup subscription in a `finally` around
|
|
790
|
+
* `ctx.park(...)`, never by chaining off `waitFor` — a non-blocking park may
|
|
791
|
+
* resolve without `waitFor` ever settling.
|
|
792
|
+
*/
|
|
793
|
+
declare function createNonBlockingParkHandler(): ParkHandler;
|
|
794
|
+
|
|
795
|
+
/**
|
|
796
|
+
* Single-reader stream of server-initiated Redis responses.
|
|
797
|
+
*
|
|
798
|
+
* Phase 1 intentionally keeps backpressure out of this interface. A transport
|
|
799
|
+
* owns the single reader and may pause iteration if its underlying connection
|
|
800
|
+
* applies backpressure. Implementations should treat a second `frames()` reader
|
|
801
|
+
* as unsupported unless they document stronger behavior.
|
|
802
|
+
*/
|
|
803
|
+
interface ResponseStream {
|
|
804
|
+
readonly kind: 'response-stream';
|
|
805
|
+
readonly closed: Promise<void>;
|
|
806
|
+
frames(signal: AbortSignal): AsyncIterable<RedisResult>;
|
|
807
|
+
close(reason?: string): void;
|
|
808
|
+
}
|
|
809
|
+
declare function isResponseStream(value: unknown): value is ResponseStream;
|
|
810
|
+
|
|
811
|
+
type CommandFlag = 'readonly' | 'write' | 'denyoom' | 'admin' | 'noscript' | 'random' | 'blocking' | 'fast' | 'movablekeys' | 'transaction' | 'pubsub' | 'subscribed';
|
|
812
|
+
type CommandCapabilities = {
|
|
813
|
+
blocking?: boolean;
|
|
814
|
+
pushOnly?: boolean;
|
|
815
|
+
movableKeys?: boolean;
|
|
816
|
+
scriptKeys?: boolean;
|
|
817
|
+
/**
|
|
818
|
+
* How the command behaves under cluster mode. `'forbidden'` is always
|
|
819
|
+
* rejected; `'singleDb'` is rejected only when it targets a non-zero
|
|
820
|
+
* database. Consumed by `ClusterPolicy` instead of matching command names.
|
|
821
|
+
*/
|
|
822
|
+
clusterMode?: 'forbidden' | 'singleDb';
|
|
823
|
+
/**
|
|
824
|
+
* Marks the command as a transaction boundary. `'begin'` opens a transaction
|
|
825
|
+
* (MULTI); `'end'` closes one (EXEC/DISCARD). `ClusterPolicy` uses this to
|
|
826
|
+
* reset the per-session pinned slot instead of matching command names.
|
|
827
|
+
*/
|
|
828
|
+
transactionBoundary?: 'begin' | 'end';
|
|
829
|
+
};
|
|
830
|
+
type CommandMonitorMetadata = {
|
|
831
|
+
skip?: boolean;
|
|
832
|
+
redactArgs?: (rawArgs: readonly Buffer[]) => readonly Buffer[];
|
|
833
|
+
};
|
|
834
|
+
type CommandKeySpec = {
|
|
835
|
+
flags: readonly string[];
|
|
836
|
+
beginSearchIndex: number;
|
|
837
|
+
lastKey: number;
|
|
838
|
+
keyStep: number;
|
|
839
|
+
limit?: number;
|
|
840
|
+
notes?: string;
|
|
841
|
+
};
|
|
842
|
+
type CommandDocumentation = {
|
|
843
|
+
summary: string;
|
|
844
|
+
since?: string;
|
|
845
|
+
group: string;
|
|
846
|
+
complexity?: string;
|
|
847
|
+
arguments?: readonly CommandDocumentationArgument[];
|
|
848
|
+
};
|
|
849
|
+
type CommandDocumentationArgument = {
|
|
850
|
+
name: string;
|
|
851
|
+
type: string;
|
|
852
|
+
keySpecIndex?: number;
|
|
853
|
+
token?: string;
|
|
854
|
+
flags?: readonly string[];
|
|
855
|
+
};
|
|
856
|
+
type CommandIntrospection = {
|
|
857
|
+
name?: string;
|
|
858
|
+
arity: number;
|
|
859
|
+
flags?: readonly string[];
|
|
860
|
+
firstKey?: number;
|
|
861
|
+
lastKey?: number;
|
|
862
|
+
keyStep?: number;
|
|
863
|
+
categories?: readonly string[];
|
|
864
|
+
tips?: readonly string[];
|
|
865
|
+
keySpecs?: readonly CommandKeySpec[];
|
|
866
|
+
subcommands?: readonly CommandIntrospection[];
|
|
867
|
+
docs?: CommandDocumentation;
|
|
868
|
+
};
|
|
869
|
+
type CommandExecutionResult = RedisResult | Promise<RedisResult> | ResponseStream;
|
|
870
|
+
interface CommandDefinition<TArgs = unknown> {
|
|
871
|
+
readonly name: string;
|
|
872
|
+
readonly since?: VersionGate;
|
|
873
|
+
readonly schema: CommandSchema<TArgs>;
|
|
874
|
+
readonly flags: readonly CommandFlag[];
|
|
875
|
+
readonly capabilities?: CommandCapabilities;
|
|
876
|
+
readonly monitor?: CommandMonitorMetadata;
|
|
877
|
+
readonly introspection?: CommandIntrospection;
|
|
878
|
+
keys(args: TArgs): readonly Buffer[];
|
|
879
|
+
execute(args: TArgs, ctx: RedisExecutionContext): CommandExecutionResult;
|
|
880
|
+
}
|
|
881
|
+
type CommandPlan<TArgs = unknown> = {
|
|
882
|
+
definition: CommandDefinition<TArgs>;
|
|
883
|
+
args: TArgs;
|
|
884
|
+
keys: readonly Buffer[];
|
|
885
|
+
flags: readonly CommandFlag[];
|
|
886
|
+
rawCommand: Buffer;
|
|
887
|
+
rawArgs: readonly Buffer[];
|
|
888
|
+
};
|
|
889
|
+
declare function defineCommand<TArgs>(definition: CommandDefinition<TArgs>): CommandDefinition<TArgs>;
|
|
890
|
+
|
|
891
|
+
declare class CommandRegistry {
|
|
892
|
+
private readonly commands;
|
|
893
|
+
register<TArgs>(definition: CommandDefinition<TArgs>, options?: {
|
|
894
|
+
override?: boolean;
|
|
895
|
+
}): void;
|
|
896
|
+
override<TArgs>(definition: CommandDefinition<TArgs>): void;
|
|
897
|
+
registerAll(definitions: readonly CommandDefinition<unknown>[], options?: {
|
|
898
|
+
override?: boolean;
|
|
899
|
+
}): void;
|
|
900
|
+
get(name: string): CommandDefinition<unknown> | undefined;
|
|
901
|
+
has(name: string): boolean;
|
|
902
|
+
getAll(): CommandDefinition<unknown>[];
|
|
903
|
+
getNames(): string[];
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
type PolicyResult = RedisResult | void;
|
|
907
|
+
type MaybePromise<TValue> = TValue | Promise<TValue>;
|
|
908
|
+
interface ExecutionPolicy {
|
|
909
|
+
readonly name: string;
|
|
910
|
+
beforeExecute?(plan: CommandPlan, ctx: RedisExecutionContext): MaybePromise<PolicyResult>;
|
|
911
|
+
afterExecute?(plan: CommandPlan, ctx: RedisExecutionContext, result: RedisResult): MaybePromise<RedisResult>;
|
|
912
|
+
onStream?(plan: CommandPlan, ctx: RedisExecutionContext, stream: ResponseStream): MaybePromise<ResponseStream | void>;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
/**
|
|
916
|
+
* The result of running a command: either a finished {@link RedisResult} or a
|
|
917
|
+
* long-lived {@link ResponseStream} (e.g. SUBSCRIBE / MONITOR) whose frames the
|
|
918
|
+
* transport drains over time.
|
|
919
|
+
*/
|
|
920
|
+
type ExecutorResult = RedisResult | ResponseStream;
|
|
921
|
+
type RawExecutionResult = {
|
|
922
|
+
result: ExecutorResult;
|
|
923
|
+
plan?: CommandPlan;
|
|
924
|
+
};
|
|
925
|
+
type CommandExecutorOptions = {
|
|
926
|
+
registry: CommandRegistry;
|
|
927
|
+
policies?: readonly ExecutionPolicy[];
|
|
928
|
+
profile?: CompatibilityProfile;
|
|
929
|
+
};
|
|
930
|
+
/**
|
|
931
|
+
* Central command pipeline shared by every client session.
|
|
932
|
+
*
|
|
933
|
+
* Responsibilities:
|
|
934
|
+
* 1. Resolve a raw command name to a {@link CommandDefinition} (case-insensitive).
|
|
935
|
+
* 2. Parse raw argument buffers into typed args and extract routing keys,
|
|
936
|
+
* producing a {@link CommandPlan}.
|
|
937
|
+
* 3. Run the configured {@link ExecutionPolicy} chain around the command's own
|
|
938
|
+
* `execute`, giving policies (transaction, cluster, ...) a chance to
|
|
939
|
+
* short-circuit, rewrite, or wrap the result.
|
|
940
|
+
*
|
|
941
|
+
* Two execution paths exist on purpose:
|
|
942
|
+
* - {@link executePlan} / {@link executeRaw} — async, used for real network
|
|
943
|
+
* clients; may return a {@link ResponseStream} and may await async commands.
|
|
944
|
+
* - {@link executePlanSync} — synchronous mirror used by the Lua runtime, where
|
|
945
|
+
* `redis.call` must complete in a single tick. Streams and promises are
|
|
946
|
+
* rejected rather than awaited.
|
|
947
|
+
*
|
|
948
|
+
* The executor is stateless per-call: all mutable state lives on the
|
|
949
|
+
* {@link RedisExecutionContext} (and the session it carries).
|
|
950
|
+
*/
|
|
951
|
+
declare class CommandExecutor {
|
|
952
|
+
private readonly registry;
|
|
953
|
+
private readonly policies;
|
|
954
|
+
readonly profile: CompatibilityProfile;
|
|
955
|
+
constructor(options: CommandExecutorOptions);
|
|
956
|
+
getCommandDefinition(name: string): CommandDefinition<unknown> | undefined;
|
|
957
|
+
getCommandDefinitions(): readonly CommandDefinition<unknown>[];
|
|
958
|
+
/**
|
|
959
|
+
* Resolve a raw command + args into a {@link CommandPlan} without executing it.
|
|
960
|
+
* The command name is matched case-insensitively against the registry.
|
|
961
|
+
*
|
|
962
|
+
* @throws {UnknownRedisCommandError} if no command is registered under the name.
|
|
963
|
+
*/
|
|
964
|
+
plan(rawCommand: Buffer | string, rawArgs: readonly Buffer[]): CommandPlan;
|
|
965
|
+
/**
|
|
966
|
+
* Plan and execute a raw command in one step — the normal entry point for a
|
|
967
|
+
* network client.
|
|
968
|
+
*
|
|
969
|
+
* Errors thrown during *planning* (unknown command, arity/parse failures) are
|
|
970
|
+
* caught here and converted into a RESP error reply. Such a failure also marks
|
|
971
|
+
* any open MULTI transaction dirty so a later EXEC is aborted, matching Redis:
|
|
972
|
+
* a command that cannot even be parsed must not silently vanish from the queue.
|
|
973
|
+
* Execution-time errors are handled inside {@link executePlan}.
|
|
974
|
+
*/
|
|
975
|
+
executeRaw(rawCommand: Buffer | string, rawArgs: readonly Buffer[], ctx: RedisExecutionContext): Promise<ExecutorResult>;
|
|
976
|
+
executeRawWithPlan(rawCommand: Buffer | string, rawArgs: readonly Buffer[], ctx: RedisExecutionContext): Promise<RawExecutionResult>;
|
|
977
|
+
private static normalizeCommandName;
|
|
978
|
+
private rawCommandErrorResult;
|
|
979
|
+
/**
|
|
980
|
+
* Run a pre-built plan through the full async pipeline.
|
|
981
|
+
*
|
|
982
|
+
* Order of operations:
|
|
983
|
+
* 1. `beforeExecute` for each policy. The first policy that returns a result
|
|
984
|
+
* short-circuits execution (e.g. the transaction policy queues the command
|
|
985
|
+
* and returns "+QUEUED"; the cluster policy returns a MOVED/CROSSSLOT
|
|
986
|
+
* error). A short-circuit error during MULTI also dirties the transaction.
|
|
987
|
+
* 2. The command's own `execute`.
|
|
988
|
+
* 3. If a {@link ResponseStream} is produced, run it through every policy's
|
|
989
|
+
* `onStream` hook; otherwise await the value and run it through every
|
|
990
|
+
* `afterExecute` hook (each may replace the result).
|
|
991
|
+
*
|
|
992
|
+
* Execution-time {@link RedisCommandError}s become RESP error replies (and
|
|
993
|
+
* dirty an open transaction when appropriate). Non-Redis errors propagate.
|
|
994
|
+
*/
|
|
995
|
+
executePlan(plan: CommandPlan, ctx: RedisExecutionContext): Promise<ExecutorResult>;
|
|
996
|
+
private executePlanInternal;
|
|
997
|
+
/**
|
|
998
|
+
* Synchronous counterpart to {@link executePlan}, used by the Lua runtime for
|
|
999
|
+
* `redis.call` / `redis.pcall`. Lua expects each nested command to resolve
|
|
1000
|
+
* immediately, so anything that would require awaiting — a command that
|
|
1001
|
+
* returns a promise, a {@link ResponseStream}, or an async policy hook — is
|
|
1002
|
+
* rejected with a {@link RedisCommandError} instead of being awaited. Async
|
|
1003
|
+
* command definitions are rejected before invocation so they cannot leave
|
|
1004
|
+
* orphaned work running after the script error (see
|
|
1005
|
+
* {@link assertSyncCommandDefinition}, {@link assertSyncCommandResult}, and
|
|
1006
|
+
* {@link assertSyncPolicyResult}).
|
|
1007
|
+
*
|
|
1008
|
+
* The policy chain and transaction-dirty handling otherwise mirror the async
|
|
1009
|
+
* path exactly.
|
|
1010
|
+
*/
|
|
1011
|
+
executePlanSync(plan: CommandPlan, ctx: RedisExecutionContext): RedisResult;
|
|
1012
|
+
private executePlanSyncInternal;
|
|
1013
|
+
/**
|
|
1014
|
+
* Build a {@link CommandPlan} from a resolved definition: parse the raw buffers
|
|
1015
|
+
* against the command's schema (may throw arity/type errors) and extract the
|
|
1016
|
+
* routing keys used for cluster slot validation. Flags are copied onto the plan
|
|
1017
|
+
* so policies can inspect them without re-resolving the definition.
|
|
1018
|
+
*/
|
|
1019
|
+
private createPlan;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
interface Logger {
|
|
1023
|
+
info(msg: unknown, metadata?: Record<string, unknown>): void;
|
|
1024
|
+
error(msg: unknown, metadata?: Record<string, unknown>): void;
|
|
1025
|
+
debug(msg: unknown, metadata?: Record<string, unknown>): void;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
type Resp2ServerOptions = {
|
|
1029
|
+
server: RedisServerState;
|
|
1030
|
+
executor: CommandExecutor;
|
|
1031
|
+
logger?: Pick<Logger, 'error'>;
|
|
1032
|
+
encoder?: RespEncodeOptions;
|
|
1033
|
+
nodeRole?: RedisClusterNodeRole;
|
|
1034
|
+
};
|
|
1035
|
+
declare class Resp2Server {
|
|
1036
|
+
readonly server: Server;
|
|
1037
|
+
private readonly state;
|
|
1038
|
+
private readonly executor;
|
|
1039
|
+
private readonly logger?;
|
|
1040
|
+
private readonly encoder?;
|
|
1041
|
+
private readonly nodeRole?;
|
|
1042
|
+
private readonly adapters;
|
|
1043
|
+
constructor(options: Resp2ServerOptions);
|
|
1044
|
+
listen(port?: number): Promise<void>;
|
|
1045
|
+
close(): Promise<void>;
|
|
1046
|
+
getAddress(): string;
|
|
1047
|
+
getPort(): number;
|
|
1048
|
+
private handleConnection;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
type RedisClusterOptions = {
|
|
1052
|
+
masters: number;
|
|
1053
|
+
replicasPerMaster?: number;
|
|
1054
|
+
basePort: number;
|
|
1055
|
+
host?: string;
|
|
1056
|
+
databasesPerNode?: number;
|
|
1057
|
+
replicaUpdateDelayMs?: number;
|
|
1058
|
+
compatibility?: CompatibilitySpec;
|
|
1059
|
+
logger?: Pick<Logger, 'error'>;
|
|
1060
|
+
};
|
|
1061
|
+
declare function computeSlotRange(masterIndex: number, masters: number): [number, number];
|
|
1062
|
+
type ReplicationLink = {
|
|
1063
|
+
close(): void;
|
|
1064
|
+
};
|
|
1065
|
+
|
|
1066
|
+
type RedisClusterNodeHandle = {
|
|
1067
|
+
id: string;
|
|
1068
|
+
role: 'master' | 'replica';
|
|
1069
|
+
host: string;
|
|
1070
|
+
port: number;
|
|
1071
|
+
server: RedisServerState;
|
|
1072
|
+
};
|
|
1073
|
+
/**
|
|
1074
|
+
* A cluster of socket-backed nodes: {@link buildClusterNodes} assembles the
|
|
1075
|
+
* TCP-free pipelines, this wraps each in a {@link Resp2Server} and owns their
|
|
1076
|
+
* listen/close lifecycle. The socket layer of {@link buildClusterNodes} — kept
|
|
1077
|
+
* out of `cluster.ts` so the node-assembly there stays free of `net`.
|
|
1078
|
+
*/
|
|
1079
|
+
declare class RedisCluster {
|
|
1080
|
+
readonly topology: RedisClusterTopology;
|
|
1081
|
+
readonly nodes: readonly RedisClusterNodeHandle[];
|
|
1082
|
+
private readonly servers;
|
|
1083
|
+
private readonly replicationLinks;
|
|
1084
|
+
constructor(topology: RedisClusterTopology, nodes: readonly RedisClusterNodeHandle[], servers: readonly Resp2Server[], replicationLinks: readonly ReplicationLink[]);
|
|
1085
|
+
listen(): Promise<void>;
|
|
1086
|
+
close(): Promise<void>;
|
|
1087
|
+
getAddresses(): string[];
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* Builds an **un-started** cluster — call {@link RedisCluster.listen} yourself.
|
|
1091
|
+
*
|
|
1092
|
+
* @deprecated Prefer {@link createRedisServer} with the `cluster` option, which
|
|
1093
|
+
* builds *and* starts the cluster in one call (and is symmetric with
|
|
1094
|
+
* `createRedisMock({ cluster })`). This low-level builder remains for callers
|
|
1095
|
+
* that need to control when `listen()` runs.
|
|
1096
|
+
*/
|
|
1097
|
+
declare function createRedisCluster(options: RedisClusterOptions): RedisCluster;
|
|
1098
|
+
/**
|
|
1099
|
+
* @deprecated Renamed to {@link createRedisCluster} for naming consistency with
|
|
1100
|
+
* `createRedisServer` / `createRedisMock`. This alias will be removed in a
|
|
1101
|
+
* future release.
|
|
1102
|
+
*/
|
|
1103
|
+
declare const buildRedisCluster: typeof createRedisCluster;
|
|
1104
|
+
|
|
1105
|
+
declare class RedisCommandError extends Error {
|
|
1106
|
+
readonly code: string;
|
|
1107
|
+
constructor(message: string, code?: string);
|
|
1108
|
+
}
|
|
1109
|
+
declare class WrongNumberOfArgumentsError extends RedisCommandError {
|
|
1110
|
+
constructor(commandName: string);
|
|
1111
|
+
}
|
|
1112
|
+
declare class RedisSyntaxError extends RedisCommandError {
|
|
1113
|
+
constructor();
|
|
1114
|
+
}
|
|
1115
|
+
/** `AUTH <password>` (single-arg) when the server has no `requirepass` set. */
|
|
1116
|
+
declare class NoPasswordConfiguredError extends RedisCommandError {
|
|
1117
|
+
constructor();
|
|
1118
|
+
}
|
|
1119
|
+
/** Wrong username/password pair on AUTH or HELLO AUTH. */
|
|
1120
|
+
declare class WrongPassError extends RedisCommandError {
|
|
1121
|
+
constructor();
|
|
1122
|
+
}
|
|
1123
|
+
/** A command was issued before authenticating on a password-protected server. */
|
|
1124
|
+
declare class NoAuthError extends RedisCommandError {
|
|
1125
|
+
constructor(message?: string);
|
|
1126
|
+
}
|
|
1127
|
+
/** `HELLO <version>` with a syntactically valid but unsupported protocol version. */
|
|
1128
|
+
declare class NoProtoError extends RedisCommandError {
|
|
1129
|
+
constructor();
|
|
1130
|
+
}
|
|
1131
|
+
/** `HELLO <version>` where version is not a valid integer at all. */
|
|
1132
|
+
declare class HelloProtocolNotIntegerError extends RedisCommandError {
|
|
1133
|
+
constructor();
|
|
1134
|
+
}
|
|
1135
|
+
declare class ExpectedIntegerError extends RedisCommandError {
|
|
1136
|
+
constructor();
|
|
1137
|
+
}
|
|
1138
|
+
declare class IncrDecrOverflowError extends RedisCommandError {
|
|
1139
|
+
constructor(message?: string);
|
|
1140
|
+
}
|
|
1141
|
+
declare class ExpectedFloatError extends RedisCommandError {
|
|
1142
|
+
constructor();
|
|
1143
|
+
}
|
|
1144
|
+
declare class IncrByFloatNanOrInfinityError extends RedisCommandError {
|
|
1145
|
+
constructor();
|
|
1146
|
+
}
|
|
1147
|
+
/** A non-ALPHA SORT met an element that does not parse as a double. */
|
|
1148
|
+
declare class SortScoreNotDoubleError extends RedisCommandError {
|
|
1149
|
+
constructor();
|
|
1150
|
+
}
|
|
1151
|
+
declare class ResultingScoreNaNError extends RedisCommandError {
|
|
1152
|
+
constructor();
|
|
1153
|
+
}
|
|
1154
|
+
declare class MinMaxNotFloatError extends RedisCommandError {
|
|
1155
|
+
constructor();
|
|
1156
|
+
}
|
|
1157
|
+
declare class PositiveCountError extends RedisCommandError {
|
|
1158
|
+
constructor();
|
|
1159
|
+
}
|
|
1160
|
+
declare class LposRankZeroError extends RedisCommandError {
|
|
1161
|
+
constructor();
|
|
1162
|
+
}
|
|
1163
|
+
declare class LposCountNegativeError extends RedisCommandError {
|
|
1164
|
+
constructor();
|
|
1165
|
+
}
|
|
1166
|
+
declare class LposMaxlenNegativeError extends RedisCommandError {
|
|
1167
|
+
constructor();
|
|
1168
|
+
}
|
|
1169
|
+
declare class TimeoutNotFloatError extends RedisCommandError {
|
|
1170
|
+
constructor();
|
|
1171
|
+
}
|
|
1172
|
+
declare class TimeoutNegativeError extends RedisCommandError {
|
|
1173
|
+
constructor();
|
|
1174
|
+
}
|
|
1175
|
+
declare class ZaddNxXxConflictError extends RedisCommandError {
|
|
1176
|
+
constructor();
|
|
1177
|
+
}
|
|
1178
|
+
declare class ZaddGtLtNxConflictError extends RedisCommandError {
|
|
1179
|
+
constructor();
|
|
1180
|
+
}
|
|
1181
|
+
declare class ExpireNxXxGtLtConflictError extends RedisCommandError {
|
|
1182
|
+
constructor();
|
|
1183
|
+
}
|
|
1184
|
+
declare class ExpireGtLtConflictError extends RedisCommandError {
|
|
1185
|
+
constructor();
|
|
1186
|
+
}
|
|
1187
|
+
declare class UnsupportedOptionError extends RedisCommandError {
|
|
1188
|
+
constructor(option: string);
|
|
1189
|
+
}
|
|
1190
|
+
declare class ZaddIncrPairError extends RedisCommandError {
|
|
1191
|
+
constructor();
|
|
1192
|
+
}
|
|
1193
|
+
declare class InvalidLongitudeLatitudeError extends RedisCommandError {
|
|
1194
|
+
constructor(lon: number, lat: number);
|
|
1195
|
+
}
|
|
1196
|
+
declare class GeoUnsupportedUnitError extends RedisCommandError {
|
|
1197
|
+
constructor();
|
|
1198
|
+
}
|
|
1199
|
+
declare class GeoMissingMemberError extends RedisCommandError {
|
|
1200
|
+
constructor();
|
|
1201
|
+
}
|
|
1202
|
+
declare class GeoCountNotPositiveError extends RedisCommandError {
|
|
1203
|
+
constructor();
|
|
1204
|
+
}
|
|
1205
|
+
declare class GeoAnyRequiresCountError extends RedisCommandError {
|
|
1206
|
+
constructor();
|
|
1207
|
+
}
|
|
1208
|
+
declare class GeoRadiusNotNumericError extends RedisCommandError {
|
|
1209
|
+
constructor();
|
|
1210
|
+
}
|
|
1211
|
+
declare class GeoRadiusNegativeError extends RedisCommandError {
|
|
1212
|
+
constructor();
|
|
1213
|
+
}
|
|
1214
|
+
declare class GeoWidthNotNumericError extends RedisCommandError {
|
|
1215
|
+
constructor();
|
|
1216
|
+
}
|
|
1217
|
+
declare class GeoHeightNotNumericError extends RedisCommandError {
|
|
1218
|
+
constructor();
|
|
1219
|
+
}
|
|
1220
|
+
declare class GeoBoxNegativeError extends RedisCommandError {
|
|
1221
|
+
constructor();
|
|
1222
|
+
}
|
|
1223
|
+
declare class GeoRadiusStoreWithOptionsError extends RedisCommandError {
|
|
1224
|
+
constructor();
|
|
1225
|
+
}
|
|
1226
|
+
declare class GeoSearchStoreWithOptionsError extends RedisCommandError {
|
|
1227
|
+
constructor();
|
|
1228
|
+
}
|
|
1229
|
+
declare class OffsetOutOfRangeError extends RedisCommandError {
|
|
1230
|
+
constructor();
|
|
1231
|
+
}
|
|
1232
|
+
/** SETBIT/GETBIT/BITFIELD offset that is negative, non-integer, or >= 2^32. */
|
|
1233
|
+
declare class BitOffsetError extends RedisCommandError {
|
|
1234
|
+
constructor();
|
|
1235
|
+
}
|
|
1236
|
+
/** SETBIT value that is not exactly 0 or 1. */
|
|
1237
|
+
declare class BitValueError extends RedisCommandError {
|
|
1238
|
+
constructor();
|
|
1239
|
+
}
|
|
1240
|
+
/** BITPOS bit argument that is not 0 or 1. */
|
|
1241
|
+
declare class BitPosBitError extends RedisCommandError {
|
|
1242
|
+
constructor();
|
|
1243
|
+
}
|
|
1244
|
+
/** BITOP NOT invoked with more than one source key. */
|
|
1245
|
+
declare class BitOpNotSingleKeyError extends RedisCommandError {
|
|
1246
|
+
constructor();
|
|
1247
|
+
}
|
|
1248
|
+
/** BITFIELD type token that is malformed or u64 (only i64 is allowed at 64 bits). */
|
|
1249
|
+
declare class BitfieldTypeError extends RedisCommandError {
|
|
1250
|
+
constructor();
|
|
1251
|
+
}
|
|
1252
|
+
/** BITFIELD OVERFLOW with a mode other than WRAP/SAT/FAIL. */
|
|
1253
|
+
declare class BitfieldOverflowTypeError extends RedisCommandError {
|
|
1254
|
+
constructor();
|
|
1255
|
+
}
|
|
1256
|
+
/** A non-GET subcommand passed to BITFIELD_RO. */
|
|
1257
|
+
declare class BitfieldRoGetOnlyError extends RedisCommandError {
|
|
1258
|
+
constructor();
|
|
1259
|
+
}
|
|
1260
|
+
declare class WrongTypeRedisError extends RedisCommandError {
|
|
1261
|
+
constructor();
|
|
1262
|
+
}
|
|
1263
|
+
/** A string-type key whose contents are not a valid HyperLogLog encoding. */
|
|
1264
|
+
declare class InvalidHllError extends RedisCommandError {
|
|
1265
|
+
constructor();
|
|
1266
|
+
}
|
|
1267
|
+
declare class InvalidExpireTimeError extends RedisCommandError {
|
|
1268
|
+
constructor(commandName: string);
|
|
1269
|
+
}
|
|
1270
|
+
declare class RedisCrossSlotError extends RedisCommandError {
|
|
1271
|
+
constructor();
|
|
1272
|
+
}
|
|
1273
|
+
declare class RedisMovedError extends RedisCommandError {
|
|
1274
|
+
constructor(slot: number, host: string, port: number);
|
|
1275
|
+
}
|
|
1276
|
+
declare class RedisClusterDownError extends RedisCommandError {
|
|
1277
|
+
constructor();
|
|
1278
|
+
}
|
|
1279
|
+
declare class UnknownScriptSubcommandError extends RedisCommandError {
|
|
1280
|
+
constructor(subcommand: string | Buffer);
|
|
1281
|
+
}
|
|
1282
|
+
declare class UnknownClusterSubcommandError extends RedisCommandError {
|
|
1283
|
+
constructor(subcommand: string | Buffer);
|
|
1284
|
+
}
|
|
1285
|
+
declare class ScriptFlushOptionError extends RedisCommandError {
|
|
1286
|
+
constructor();
|
|
1287
|
+
}
|
|
1288
|
+
declare class ScriptDebugModeError extends RedisCommandError {
|
|
1289
|
+
constructor();
|
|
1290
|
+
}
|
|
1291
|
+
declare class ScriptUnknownCommandError extends RedisCommandError {
|
|
1292
|
+
constructor();
|
|
1293
|
+
}
|
|
1294
|
+
declare class ScriptNotAllowedCommandError extends RedisCommandError {
|
|
1295
|
+
constructor();
|
|
1296
|
+
}
|
|
1297
|
+
declare class ScriptCallNoCommandError extends RedisCommandError {
|
|
1298
|
+
constructor();
|
|
1299
|
+
}
|
|
1300
|
+
declare class WrongNumberOfKeysError extends RedisCommandError {
|
|
1301
|
+
constructor();
|
|
1302
|
+
}
|
|
1303
|
+
declare class NumKeysGreaterThanZeroError extends RedisCommandError {
|
|
1304
|
+
constructor();
|
|
1305
|
+
}
|
|
1306
|
+
/** ZUNION/ZINTER/ZDIFF family when numkeys <= 0. */
|
|
1307
|
+
declare class AtLeastOneInputKeyError extends RedisCommandError {
|
|
1308
|
+
constructor(commandName: string);
|
|
1309
|
+
}
|
|
1310
|
+
declare class WeightNotFloatError extends RedisCommandError {
|
|
1311
|
+
constructor();
|
|
1312
|
+
}
|
|
1313
|
+
declare class CountGreaterThanZeroError extends RedisCommandError {
|
|
1314
|
+
constructor();
|
|
1315
|
+
}
|
|
1316
|
+
declare class LimitCantBeNegativeError extends RedisCommandError {
|
|
1317
|
+
constructor();
|
|
1318
|
+
}
|
|
1319
|
+
declare class StreamLimitRequiresApproxError extends RedisCommandError {
|
|
1320
|
+
constructor();
|
|
1321
|
+
}
|
|
1322
|
+
declare class StreamLimitNegativeError extends RedisCommandError {
|
|
1323
|
+
constructor();
|
|
1324
|
+
}
|
|
1325
|
+
declare class InvalidLexRangeError extends RedisCommandError {
|
|
1326
|
+
constructor();
|
|
1327
|
+
}
|
|
1328
|
+
declare class ZrangeLimitWithoutByError extends RedisCommandError {
|
|
1329
|
+
constructor();
|
|
1330
|
+
}
|
|
1331
|
+
declare class ZrangeWithScoresByLexError extends RedisCommandError {
|
|
1332
|
+
constructor();
|
|
1333
|
+
}
|
|
1334
|
+
declare class NoScriptError extends RedisCommandError {
|
|
1335
|
+
constructor();
|
|
1336
|
+
}
|
|
1337
|
+
declare class ExecWithoutMultiError extends RedisCommandError {
|
|
1338
|
+
constructor();
|
|
1339
|
+
}
|
|
1340
|
+
declare class DiscardWithoutMultiError extends RedisCommandError {
|
|
1341
|
+
constructor();
|
|
1342
|
+
}
|
|
1343
|
+
declare class WatchInsideMultiError extends RedisCommandError {
|
|
1344
|
+
constructor();
|
|
1345
|
+
}
|
|
1346
|
+
declare class TransactionDiscardedError extends RedisCommandError {
|
|
1347
|
+
constructor();
|
|
1348
|
+
}
|
|
1349
|
+
/** EXEC itself is malformed (e.g. wrong arity) — discards the transaction immediately. */
|
|
1350
|
+
declare class ExecCommandAbortError extends RedisCommandError {
|
|
1351
|
+
constructor(reason: string);
|
|
1352
|
+
}
|
|
1353
|
+
declare class IndexOutOfRangeError extends RedisCommandError {
|
|
1354
|
+
constructor();
|
|
1355
|
+
}
|
|
1356
|
+
declare class NoSuchKeyError extends RedisCommandError {
|
|
1357
|
+
constructor();
|
|
1358
|
+
}
|
|
1359
|
+
/** `COPY src dst` (and `SELECT`) when source and destination resolve to the same object. */
|
|
1360
|
+
declare class SameObjectError extends RedisCommandError {
|
|
1361
|
+
constructor();
|
|
1362
|
+
}
|
|
1363
|
+
/** A database index outside `0 .. databaseCount - 1` (e.g. `COPY ... DB 99`, `SELECT 99`). */
|
|
1364
|
+
declare class DbIndexOutOfRangeError extends RedisCommandError {
|
|
1365
|
+
constructor();
|
|
1366
|
+
}
|
|
1367
|
+
declare class InvalidStreamIdError extends RedisCommandError {
|
|
1368
|
+
constructor();
|
|
1369
|
+
}
|
|
1370
|
+
declare class StreamIdEqualOrSmallerError extends RedisCommandError {
|
|
1371
|
+
constructor();
|
|
1372
|
+
}
|
|
1373
|
+
declare class StreamIdNotGreaterThanZeroError extends RedisCommandError {
|
|
1374
|
+
constructor();
|
|
1375
|
+
}
|
|
1376
|
+
declare class StreamElementTooLargeError extends RedisCommandError {
|
|
1377
|
+
constructor();
|
|
1378
|
+
}
|
|
1379
|
+
declare class StreamIdExhaustedError extends RedisCommandError {
|
|
1380
|
+
constructor();
|
|
1381
|
+
}
|
|
1382
|
+
declare class HashValueNotIntegerError extends RedisCommandError {
|
|
1383
|
+
constructor();
|
|
1384
|
+
}
|
|
1385
|
+
declare class HashValueNotFloatError extends RedisCommandError {
|
|
1386
|
+
constructor();
|
|
1387
|
+
}
|
|
1388
|
+
declare class UnknownRedisCommandError extends RedisCommandError {
|
|
1389
|
+
constructor(commandName: string | Buffer, args: readonly Buffer[]);
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
export { ZaddIncrPairError as $, ScriptUnknownCommandError as A, StreamElementTooLargeError as B, type CompatibilitySpec as C, DiscardWithoutMultiError as D, ExecWithoutMultiError as E, type FeatureId as F, StreamIdExhaustedError as G, HashValueNotFloatError as H, IndexOutOfRangeError as I, UnknownRedisCommandError as J, UnknownScriptSubcommandError as K, type Logger as L, MinMaxNotFloatError as M, NoAuthError as N, OffsetOutOfRangeError as O, PositiveCountError as P, WrongNumberOfArgumentsError as Q, RedisCluster as R, ScriptCallNoCommandError as S, TransactionDiscardedError as T, UnknownClusterSubcommandError as U, type VersionGate as V, WatchInsideMultiError as W, WrongNumberOfKeysError as X, WrongPassError as Y, WrongTypeRedisError as Z, ZaddGtLtNxConflictError as _, RedisServerState as a, LposMaxlenNegativeError as a$, ZaddNxXxConflictError as a0, buildRedisCluster as a1, computeSlotRange as a2, createRedisCluster as a3, gateSatisfied as a4, resolveCompatibilityProfile as a5, type ExecutionPolicy as a6, RedisClusterTopology as a7, type RedisClientSession as a8, type RedisClusterNodeRole as a9, type CommandSchema as aA, DbIndexOutOfRangeError as aB, ExecCommandAbortError as aC, type ExpirationState as aD, ExpireGtLtConflictError as aE, ExpireNxXxGtLtConflictError as aF, GeoAnyRequiresCountError as aG, GeoBoxNegativeError as aH, GeoCountNotPositiveError as aI, GeoHeightNotNumericError as aJ, GeoMissingMemberError as aK, GeoRadiusNegativeError as aL, GeoRadiusNotNumericError as aM, GeoRadiusStoreWithOptionsError as aN, GeoSearchStoreWithOptionsError as aO, GeoUnsupportedUnitError as aP, GeoWidthNotNumericError as aQ, HelloProtocolNotIntegerError as aR, IncrByFloatNanOrInfinityError as aS, IncrDecrOverflowError as aT, type InferSchema as aU, InvalidHllError as aV, InvalidLexRangeError as aW, InvalidLongitudeLatitudeError as aX, InvalidStreamIdError as aY, type KeyspaceEntry as aZ, LposCountNegativeError as a_, type ParkHandler as aa, type RedisTurnQueue as ab, type ClientSessionMode as ac, type RespVersion as ad, RedisDatabase as ae, type CommandPlan as af, RedisResult as ag, type Unsubscribe as ah, type ExecutorResult as ai, type RedisTurnHandle as aj, type RedisMonitorContext as ak, type RedisExecutionContext as al, type RespEncodeOptions as am, type CommandDefinition as an, CommandRegistry as ao, AtLeastOneInputKeyError as ap, BitOffsetError as aq, BitOpNotSingleKeyError as ar, BitPosBitError as as, BitValueError as at, BitfieldOverflowTypeError as au, BitfieldRoGetOnlyError as av, BitfieldTypeError as aw, type CommandCapabilities as ax, type CommandExecutionResult as ay, type CommandFlag as az, type RedisClusterNodeHandle as b, luaReplyToRedisValue as b$, LposRankZeroError as b0, type LuaReplyValue as b1, NoProtoError as b2, type ParkRequest as b3, type ParseContext as b4, type ParseNodeResult as b5, REDIS_CLUSTER_SLOT_COUNT as b6, type RedisClusterNode as b7, type RedisDataTypeName as b8, type RedisDataValue as b9, type SetOptions as bA, SortScoreNotDoubleError as bB, StreamIdEqualOrSmallerError as bC, StreamIdNotGreaterThanZeroError as bD, StreamLimitNegativeError as bE, StreamLimitRequiresApproxError as bF, TimeoutNegativeError as bG, TimeoutNotFloatError as bH, UnsupportedOptionError as bI, WeightNotFloatError as bJ, WrongRedisTypeError as bK, ZrangeLimitWithoutByError as bL, ZrangeWithScoresByLexError as bM, cloneRedisDataValue as bN, createDefaultParkHandler as bO, createHashData as bP, createListData as bQ, createNonBlockingParkHandler as bR, createNoopParkHandler as bS, createRedisLuaRuntime as bT, createSetData as bU, createSortedSetData as bV, createStringData as bW, defineCommand as bX, encodeRedisResult as bY, encodeRedisValue as bZ, isResponseStream as b_, RedisFunctionRegistry as ba, type RedisHashData as bb, type RedisHashField as bc, RedisKeyspace as bd, type RedisListData as be, RedisLuaRuntime as bf, type RedisMonitorCommandEvent as bg, type RedisMonitorCommandListener as bh, RedisMonitorFeed as bi, RedisMutationBus as bj, type RedisMutationEvent as bk, type RedisMutationListener as bl, RedisPubSubBroker as bm, type RedisResultOptions as bn, RedisScriptCache as bo, type RedisServerStateOptions as bp, type RedisSetData as bq, type RedisSortedSetData as br, type RedisSortedSetMember as bs, type RedisStreamData as bt, type RedisStringData as bu, type Resp2ServerOptions as bv, type ResponseStream as bw, SameObjectError as bx, ScriptNotAllowedCommandError as by, SerialTurnQueue as bz, Resp2Server as c, parseCommandArgs as c0, parseVersion as c1, setLuaWasmLoadOptions as c2, t as c3, CommandExecutor as d, RedisValue as e, type CompatibilityProfile as f, CountGreaterThanZeroError as g, ExpectedFloatError as h, ExpectedIntegerError as i, HashValueNotIntegerError as j, InvalidExpireTimeError as k, LimitCantBeNegativeError as l, NoPasswordConfiguredError as m, NoScriptError as n, NoSuchKeyError as o, NumKeysGreaterThanZeroError as p, RedisClusterDownError as q, type RedisClusterOptions as r, RedisCommandError as s, RedisCrossSlotError as t, type RedisFlavor as u, RedisMovedError as v, RedisSyntaxError as w, ResultingScoreNaNError as x, ScriptDebugModeError as y, ScriptFlushOptionError as z };
|