@upstash/redis 1.35.8-canary-2 → 1.36.0-rc.1
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/{chunk-E5HCYSG3.mjs → chunk-U5HO3NMB.mjs} +374 -13
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +291 -18
- package/cloudflare.mjs +10 -14
- package/fastly.d.mts +2 -2
- package/fastly.d.ts +2 -2
- package/fastly.js +282 -5
- package/fastly.mjs +1 -1
- package/nodejs.d.mts +156 -3
- package/nodejs.d.ts +156 -3
- package/nodejs.js +375 -13
- package/nodejs.mjs +13 -9
- package/package.json +1 -1
- package/{zmscore-DhpQcqpW.d.mts → zmscore-BVyzI3wx.d.mts} +202 -1
- package/{zmscore-DhpQcqpW.d.ts → zmscore-BVyzI3wx.d.ts} +202 -1
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@upstash/redis","version":"v1.
|
|
1
|
+
{"name":"@upstash/redis","version":"v1.36.0-rc.1","main":"./nodejs.js","module":"./nodejs.mjs","types":"./nodejs.d.ts","exports":{".":{"import":"./nodejs.mjs","require":"./nodejs.js"},"./node":{"import":"./nodejs.mjs","require":"./nodejs.js"},"./cloudflare":{"import":"./cloudflare.mjs","require":"./cloudflare.js"},"./cloudflare.js":{"import":"./cloudflare.mjs","require":"./cloudflare.js"},"./cloudflare.mjs":{"import":"./cloudflare.mjs","require":"./cloudflare.js"},"./fastly":{"import":"./fastly.mjs","require":"./fastly.js"},"./fastly.js":{"import":"./fastly.mjs","require":"./fastly.js"},"./fastly.mjs":{"import":"./fastly.mjs","require":"./fastly.js"}},"description":"An HTTP/REST based Redis client built on top of Upstash REST API.","repository":{"type":"git","url":"git+https://github.com/upstash/upstash-redis.git"},"keywords":["redis","database","serverless","edge","upstash"],"files":["./*"],"scripts":{"build":"tsup && cp package.json README.md LICENSE dist/","test":"bun test pkg","fmt":"prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"","lint":"eslint \"**/*.{js,ts,tsx}\" --quiet --fix","format":"prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"","format:check":"prettier --check \"**/*.{ts,tsx,js,jsx,json,md}\"","lint:fix":"eslint . -c .ts,.tsx,.js,.jsx --fix","commit":"cz","lint:format":"bun run lint:fix && bun run format","check-exports":"bun run build && cd dist && attw -P"},"author":"Andreas Thomas <dev@chronark.com>","license":"MIT","bugs":{"url":"https://github.com/upstash/upstash-redis/issues"},"homepage":"https://github.com/upstash/upstash-redis#readme","devDependencies":{"@biomejs/biome":"latest","@commitlint/cli":"^19.3.0","@commitlint/config-conventional":"^19.2.2","@typescript-eslint/eslint-plugin":"8.4.0","@typescript-eslint/parser":"8.4.0","bun-types":"1.0.33","eslint":"9.10.0","eslint-plugin-unicorn":"55.0.0","husky":"^9.1.1","prettier":"^3.3.3","tsup":"^8.2.3","typescript":"latest"},"dependencies":{"uncrypto":"^0.1.3"}}
|
|
@@ -317,6 +317,205 @@ declare class ExpireCommand extends Command<"0" | "1", 0 | 1> {
|
|
|
317
317
|
constructor(cmd: [key: string, seconds: number, option?: ExpireOption], opts?: CommandOptions<"0" | "1", 0 | 1>);
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
+
declare const FIELD_TYPES: readonly ["TEXT", "U64", "I64", "F64", "BOOL", "DATE"];
|
|
321
|
+
type FieldType = (typeof FIELD_TYPES)[number];
|
|
322
|
+
type TextField = {
|
|
323
|
+
type: "TEXT";
|
|
324
|
+
noTokenize?: boolean;
|
|
325
|
+
noStem?: boolean;
|
|
326
|
+
};
|
|
327
|
+
type NumericField = {
|
|
328
|
+
type: "U64" | "I64" | "F64";
|
|
329
|
+
fast?: boolean;
|
|
330
|
+
};
|
|
331
|
+
type BoolField = {
|
|
332
|
+
type: "BOOL";
|
|
333
|
+
fast?: boolean;
|
|
334
|
+
};
|
|
335
|
+
type DateField = {
|
|
336
|
+
type: "DATE";
|
|
337
|
+
fast?: boolean;
|
|
338
|
+
};
|
|
339
|
+
type DetailedField = TextField | NumericField | BoolField | DateField;
|
|
340
|
+
type NestedIndexSchema = {
|
|
341
|
+
[key: string]: FieldType | DetailedField | NestedIndexSchema;
|
|
342
|
+
};
|
|
343
|
+
type FlatIndexSchema = {
|
|
344
|
+
[key: string]: FieldType | DetailedField;
|
|
345
|
+
};
|
|
346
|
+
type SchemaPaths<T, Prefix extends string = ""> = {
|
|
347
|
+
[K in keyof T]: K extends string ? T[K] extends FieldType | DetailedField ? Prefix extends "" ? K : `${Prefix}${K}` : T[K] extends object ? SchemaPaths<T[K], `${Prefix}${K}.`> : never : never;
|
|
348
|
+
}[keyof T];
|
|
349
|
+
type ExtractFieldType<T> = T extends FieldType ? T : T extends {
|
|
350
|
+
type: infer U;
|
|
351
|
+
} ? U extends FieldType ? U : never : never;
|
|
352
|
+
type GetFieldAtPath<TSchema, Path extends string> = Path extends `${infer First}.${infer Rest}` ? First extends keyof TSchema ? GetFieldAtPath<TSchema[First], Rest> : never : Path extends keyof TSchema ? TSchema[Path] : never;
|
|
353
|
+
type FieldValueType<T extends FieldType> = T extends "TEXT" ? string : T extends "U64" | "I64" | "F64" ? number : T extends "BOOL" ? boolean : T extends "DATE" ? string : never;
|
|
354
|
+
type GetFieldValueType<TSchema, Path extends string> = GetFieldAtPath<TSchema, Path> extends infer Field ? Field extends FieldType | DetailedField ? FieldValueType<ExtractFieldType<Field>> : never : never;
|
|
355
|
+
type InferSchemaData<TSchema> = {
|
|
356
|
+
[K in keyof TSchema]: TSchema[K] extends FieldType ? FieldValueType<TSchema[K]> : TSchema[K] extends DetailedField ? FieldValueType<ExtractFieldType<TSchema[K]>> : TSchema[K] extends NestedIndexSchema ? InferSchemaData<TSchema[K]> : never;
|
|
357
|
+
};
|
|
358
|
+
type QueryOptions<TSchema extends NestedIndexSchema | FlatIndexSchema> = {
|
|
359
|
+
/** Maximum number of results to return */
|
|
360
|
+
limit?: number;
|
|
361
|
+
/** Number of results to skip */
|
|
362
|
+
offset?: number;
|
|
363
|
+
/** Sort by field (requires FAST option on field) */
|
|
364
|
+
sortBy?: {
|
|
365
|
+
field: SchemaPaths<TSchema>;
|
|
366
|
+
direction?: "ASC" | "DESC";
|
|
367
|
+
};
|
|
368
|
+
} & ({
|
|
369
|
+
noContent: true;
|
|
370
|
+
} | {
|
|
371
|
+
noContent?: false;
|
|
372
|
+
highlight?: {
|
|
373
|
+
fields: SchemaPaths<TSchema>[];
|
|
374
|
+
preTag?: string;
|
|
375
|
+
postTag?: string;
|
|
376
|
+
};
|
|
377
|
+
/** Return only specific fields */
|
|
378
|
+
returnFields?: (SchemaPaths<TSchema> | "$")[];
|
|
379
|
+
});
|
|
380
|
+
type FieldValuePair<TSchema, TField extends string> = TField extends "$" ? {
|
|
381
|
+
$: InferSchemaData<TSchema>;
|
|
382
|
+
} : TField extends SchemaPaths<TSchema> ? {
|
|
383
|
+
[K in TField]: GetFieldValueType<TSchema, TField>;
|
|
384
|
+
} : never;
|
|
385
|
+
type QueryResult<TSchema extends NestedIndexSchema | FlatIndexSchema, TOptions extends QueryOptions<TSchema> | undefined = undefined> = TOptions extends {
|
|
386
|
+
noContent: true;
|
|
387
|
+
} ? {
|
|
388
|
+
key: string;
|
|
389
|
+
score: string;
|
|
390
|
+
} : TOptions extends {
|
|
391
|
+
returnFields: infer TFields extends readonly string[];
|
|
392
|
+
} ? {
|
|
393
|
+
key: string;
|
|
394
|
+
score: string;
|
|
395
|
+
fields: Array<FieldValuePair<TSchema, TFields[number]>>;
|
|
396
|
+
} : {
|
|
397
|
+
key: string;
|
|
398
|
+
score: string;
|
|
399
|
+
fields: Array<FieldValuePair<TSchema, SchemaPaths<TSchema> | "$">>;
|
|
400
|
+
};
|
|
401
|
+
type StringOperationMap<T extends string> = {
|
|
402
|
+
$eq: T;
|
|
403
|
+
$ne: T;
|
|
404
|
+
$in: T[];
|
|
405
|
+
$fuzzy: T | {
|
|
406
|
+
value: T;
|
|
407
|
+
distance?: number;
|
|
408
|
+
transpositionCostOne?: boolean;
|
|
409
|
+
};
|
|
410
|
+
$phrase: T;
|
|
411
|
+
$regex: T;
|
|
412
|
+
};
|
|
413
|
+
type NumberOperationMap<T extends number> = {
|
|
414
|
+
$eq: T;
|
|
415
|
+
$ne: T;
|
|
416
|
+
$in: T[];
|
|
417
|
+
$gt: T;
|
|
418
|
+
$gte: T;
|
|
419
|
+
$lt: T;
|
|
420
|
+
$lte: T;
|
|
421
|
+
};
|
|
422
|
+
type BooleanOperationMap<T extends boolean> = {
|
|
423
|
+
$eq: T;
|
|
424
|
+
$ne: T;
|
|
425
|
+
$in: T[];
|
|
426
|
+
};
|
|
427
|
+
type DateOperationMap<T extends string | Date> = {
|
|
428
|
+
$eq: T;
|
|
429
|
+
$ne: T;
|
|
430
|
+
$in: T[];
|
|
431
|
+
};
|
|
432
|
+
type StringOperations = {
|
|
433
|
+
[K in keyof StringOperationMap<string>]: {
|
|
434
|
+
[P in K]: StringOperationMap<string>[K];
|
|
435
|
+
};
|
|
436
|
+
}[keyof StringOperationMap<string>];
|
|
437
|
+
type NumberOperations = {
|
|
438
|
+
[K in keyof NumberOperationMap<number>]: {
|
|
439
|
+
[P in K]: NumberOperationMap<number>[K];
|
|
440
|
+
};
|
|
441
|
+
}[keyof NumberOperationMap<number>];
|
|
442
|
+
type BooleanOperations = {
|
|
443
|
+
[K in keyof BooleanOperationMap<boolean>]: {
|
|
444
|
+
[P in K]: BooleanOperationMap<boolean>[K];
|
|
445
|
+
};
|
|
446
|
+
}[keyof BooleanOperationMap<boolean>];
|
|
447
|
+
type DateOperations = {
|
|
448
|
+
[K in keyof DateOperationMap<string | Date>]: {
|
|
449
|
+
[P in K]: DateOperationMap<string | Date>[K];
|
|
450
|
+
};
|
|
451
|
+
}[keyof DateOperationMap<string | Date>];
|
|
452
|
+
type OperationsForFieldType<T extends FieldType> = T extends "TEXT" ? StringOperations : T extends "U64" | "I64" | "F64" ? NumberOperations : T extends "BOOL" ? BooleanOperations : T extends "DATE" ? DateOperations : never;
|
|
453
|
+
type PathOperations<TSchema, TPath extends string> = GetFieldAtPath<TSchema, TPath> extends infer Field ? Field extends FieldType | DetailedField ? OperationsForFieldType<ExtractFieldType<Field>> : never : never;
|
|
454
|
+
type QueryLeaf<TSchema> = {
|
|
455
|
+
[Path in SchemaPaths<TSchema>]: {
|
|
456
|
+
[K in Path]: PathOperations<TSchema, Path>;
|
|
457
|
+
};
|
|
458
|
+
}[SchemaPaths<TSchema>];
|
|
459
|
+
type QueryFilter<TSchema extends NestedIndexSchema | FlatIndexSchema> = QueryLeaf<TSchema> | {
|
|
460
|
+
$must: QueryFilter<TSchema>;
|
|
461
|
+
} | {
|
|
462
|
+
$should: QueryFilter<TSchema>;
|
|
463
|
+
} | {
|
|
464
|
+
$not: QueryFilter<TSchema>;
|
|
465
|
+
} | {
|
|
466
|
+
$and: QueryFilter<TSchema>;
|
|
467
|
+
} | {
|
|
468
|
+
$or: QueryFilter<TSchema>;
|
|
469
|
+
} | {
|
|
470
|
+
$boost: {
|
|
471
|
+
query: QueryFilter<TSchema>;
|
|
472
|
+
value: number;
|
|
473
|
+
};
|
|
474
|
+
};
|
|
475
|
+
type QueryResponse<TSchema extends NestedIndexSchema | FlatIndexSchema, TOptions extends QueryOptions<TSchema> | undefined = undefined> = Array<QueryResult<TSchema, TOptions>>;
|
|
476
|
+
type IndexDescription = {
|
|
477
|
+
indexName: string;
|
|
478
|
+
dataType: "hash" | "string";
|
|
479
|
+
prefixes: string[];
|
|
480
|
+
language?: string;
|
|
481
|
+
fields: Array<{
|
|
482
|
+
name: string;
|
|
483
|
+
type: FieldType;
|
|
484
|
+
noTokenize?: boolean;
|
|
485
|
+
noStem?: boolean;
|
|
486
|
+
fast?: boolean;
|
|
487
|
+
}>;
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
type CreateSearchIndexProps<TSchema extends NestedIndexSchema | FlatIndexSchema> = {
|
|
491
|
+
indexName: string;
|
|
492
|
+
prefix: string | string[];
|
|
493
|
+
language?: "english" | "turkish";
|
|
494
|
+
client: Requester;
|
|
495
|
+
} & ({
|
|
496
|
+
dataType: "string";
|
|
497
|
+
schema: TSchema extends NestedIndexSchema ? TSchema : never;
|
|
498
|
+
} | {
|
|
499
|
+
dataType: "hash";
|
|
500
|
+
schema: TSchema extends FlatIndexSchema ? TSchema : never;
|
|
501
|
+
});
|
|
502
|
+
type SearchIndexProps<TSchema extends NestedIndexSchema | FlatIndexSchema> = Pick<CreateSearchIndexProps<TSchema>, "indexName" | "client"> & {
|
|
503
|
+
schema?: CreateSearchIndexProps<TSchema>["schema"];
|
|
504
|
+
};
|
|
505
|
+
declare class SearchIndex<TSchema extends NestedIndexSchema | FlatIndexSchema, TProps extends SearchIndexProps<TSchema>> {
|
|
506
|
+
indexName: TProps["indexName"];
|
|
507
|
+
schema?: TSchema;
|
|
508
|
+
client: Requester;
|
|
509
|
+
constructor({ indexName, schema, client }: TProps);
|
|
510
|
+
waitIndexing(): Promise<string>;
|
|
511
|
+
describe(): Promise<IndexDescription>;
|
|
512
|
+
query<TOptions extends QueryOptions<TSchema>>(filter: QueryFilter<TSchema>, options?: TOptions): Promise<QueryResponse<TSchema, TOptions>>;
|
|
513
|
+
count(filter: QueryFilter<TSchema>): Promise<number>;
|
|
514
|
+
drop(): Promise<string>;
|
|
515
|
+
}
|
|
516
|
+
declare function createSearchIndex<TSchema extends NestedIndexSchema | FlatIndexSchema>(props: CreateSearchIndexProps<TSchema>): Promise<SearchIndex<TSchema, SearchIndexProps<TSchema>>>;
|
|
517
|
+
declare function getSearchIndex<TSchema extends NestedIndexSchema | FlatIndexSchema>(props: SearchIndexProps<TSchema>): SearchIndex<TSchema, SearchIndexProps<TSchema>>;
|
|
518
|
+
|
|
320
519
|
/**
|
|
321
520
|
* @see https://redis.io/commands/append
|
|
322
521
|
*/
|
|
@@ -3154,6 +3353,8 @@ declare class Redis {
|
|
|
3154
3353
|
createScript<TResult = unknown, TReadonly extends boolean = false>(script: string, opts?: {
|
|
3155
3354
|
readonly?: TReadonly;
|
|
3156
3355
|
}): TReadonly extends true ? ScriptRO<TResult> : Script<TResult>;
|
|
3356
|
+
createSearchIndex: <TSchema extends NestedIndexSchema | FlatIndexSchema>(props: Omit<CreateSearchIndexProps<TSchema>, "client">) => Promise<SearchIndex<TSchema, SearchIndexProps<TSchema>>>;
|
|
3357
|
+
getSearchIndex: <TSchema extends NestedIndexSchema | FlatIndexSchema>(props: Omit<SearchIndexProps<TSchema>, "client">) => SearchIndex<TSchema, SearchIndexProps<TSchema>>;
|
|
3157
3358
|
/**
|
|
3158
3359
|
* Create a new pipeline that allows you to send requests in bulk.
|
|
3159
3360
|
*
|
|
@@ -4059,4 +4260,4 @@ declare class ZMScoreCommand<TData> extends Command<string[] | null, number[] |
|
|
|
4059
4260
|
constructor(cmd: [key: string, members: TData[]], opts?: CommandOptions<string[] | null, number[] | null>);
|
|
4060
4261
|
}
|
|
4061
4262
|
|
|
4062
|
-
export {
|
|
4263
|
+
export { HPTtlCommand as $, AppendCommand as A, BitCountCommand as B, CopyCommand as C, DBSizeCommand as D, EchoCommand as E, FlushAllCommand as F, GeoAddCommand as G, type HttpClientConfig as H, GetCommand as I, GetBitCommand as J, GetDelCommand as K, GetExCommand as L, GetRangeCommand as M, type NestedIndexSchema as N, GetSetCommand as O, Pipeline as P, HDelCommand as Q, type RedisOptions as R, HExistsCommand as S, HExpireCommand as T, type UpstashRequest as U, HExpireAtCommand as V, HExpireTimeCommand as W, HTtlCommand as X, HPExpireCommand as Y, HPExpireAtCommand as Z, HPExpireTimeCommand as _, type RequesterConfig as a, RenameCommand as a$, HPersistCommand as a0, HGetCommand as a1, HGetAllCommand as a2, HIncrByCommand as a3, HIncrByFloatCommand as a4, HKeysCommand as a5, HLenCommand as a6, HMGetCommand as a7, HMSetCommand as a8, HRandFieldCommand as a9, JsonStrAppendCommand as aA, JsonStrLenCommand as aB, JsonToggleCommand as aC, JsonTypeCommand as aD, KeysCommand as aE, LIndexCommand as aF, LInsertCommand as aG, LLenCommand as aH, LMoveCommand as aI, LPopCommand as aJ, LPushCommand as aK, LPushXCommand as aL, LRangeCommand as aM, LRemCommand as aN, LSetCommand as aO, LTrimCommand as aP, MGetCommand as aQ, MSetCommand as aR, MSetNXCommand as aS, PersistCommand as aT, PExpireCommand as aU, PExpireAtCommand as aV, PingCommand as aW, PSetEXCommand as aX, PTtlCommand as aY, PublishCommand as aZ, RandomKeyCommand as a_, HScanCommand as aa, HSetCommand as ab, HSetNXCommand as ac, HStrLenCommand as ad, HValsCommand as ae, IncrCommand as af, IncrByCommand as ag, IncrByFloatCommand as ah, JsonArrAppendCommand as ai, JsonArrIndexCommand as aj, JsonArrInsertCommand as ak, JsonArrLenCommand as al, JsonArrPopCommand as am, JsonArrTrimCommand as an, JsonClearCommand as ao, JsonDelCommand as ap, JsonForgetCommand as aq, JsonGetCommand as ar, JsonMergeCommand as as, JsonMGetCommand as at, JsonNumIncrByCommand as au, JsonNumMultByCommand as av, JsonObjKeysCommand as aw, JsonObjLenCommand as ax, JsonRespCommand as ay, JsonSetCommand as az, Redis as b, ZUnionCommand as b$, RenameNXCommand as b0, RPopCommand as b1, RPushCommand as b2, RPushXCommand as b3, SAddCommand as b4, ScanCommand as b5, type ScanCommandOptions as b6, SCardCommand as b7, ScriptExistsCommand as b8, ScriptFlushCommand as b9, TypeCommand as bA, UnlinkCommand as bB, XAddCommand as bC, XRangeCommand as bD, type ScoreMember as bE, type ZAddCommandOptions as bF, ZAddCommand as bG, ZCardCommand as bH, ZCountCommand as bI, ZDiffStoreCommand as bJ, ZIncrByCommand as bK, ZInterStoreCommand as bL, type ZInterStoreCommandOptions as bM, ZLexCountCommand as bN, ZMScoreCommand as bO, ZPopMaxCommand as bP, ZPopMinCommand as bQ, ZRangeCommand as bR, type ZRangeCommandOptions as bS, ZRankCommand as bT, ZRemCommand as bU, ZRemRangeByLexCommand as bV, ZRemRangeByRankCommand as bW, ZRemRangeByScoreCommand as bX, ZRevRankCommand as bY, ZScanCommand as bZ, ZScoreCommand as b_, ScriptLoadCommand as ba, SDiffCommand as bb, SDiffStoreCommand as bc, SetCommand as bd, type SetCommandOptions as be, SetBitCommand as bf, SetExCommand as bg, SetNxCommand as bh, SetRangeCommand as bi, SInterCommand as bj, SInterStoreCommand as bk, SIsMemberCommand as bl, SMembersCommand as bm, SMIsMemberCommand as bn, SMoveCommand as bo, SPopCommand as bp, SRandMemberCommand as bq, SRemCommand as br, SScanCommand as bs, StrLenCommand as bt, SUnionCommand as bu, SUnionStoreCommand as bv, TimeCommand as bw, TouchCommand as bx, TtlCommand as by, type Type as bz, type Requester as c, type ZUnionCommandOptions as c0, ZUnionStoreCommand as c1, type ZUnionStoreCommandOptions as c2, createSearchIndex as c3, getSearchIndex as c4, type SearchIndexProps as c5, type CreateSearchIndexProps as c6, type FlatIndexSchema as c7, type UpstashResponse as d, error as e, BitOpCommand as f, BitPosCommand as g, DecrCommand as h, DecrByCommand as i, DelCommand as j, EvalROCommand as k, EvalCommand as l, EvalshaROCommand as m, EvalshaCommand as n, ExistsCommand as o, ExpireCommand as p, type ExpireOption as q, ExpireAtCommand as r, FlushDBCommand as s, type GeoAddCommandOptions as t, type GeoMember as u, GeoDistCommand as v, GeoHashCommand as w, GeoPosCommand as x, GeoSearchCommand as y, GeoSearchStoreCommand as z };
|
|
@@ -317,6 +317,205 @@ declare class ExpireCommand extends Command<"0" | "1", 0 | 1> {
|
|
|
317
317
|
constructor(cmd: [key: string, seconds: number, option?: ExpireOption], opts?: CommandOptions<"0" | "1", 0 | 1>);
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
+
declare const FIELD_TYPES: readonly ["TEXT", "U64", "I64", "F64", "BOOL", "DATE"];
|
|
321
|
+
type FieldType = (typeof FIELD_TYPES)[number];
|
|
322
|
+
type TextField = {
|
|
323
|
+
type: "TEXT";
|
|
324
|
+
noTokenize?: boolean;
|
|
325
|
+
noStem?: boolean;
|
|
326
|
+
};
|
|
327
|
+
type NumericField = {
|
|
328
|
+
type: "U64" | "I64" | "F64";
|
|
329
|
+
fast?: boolean;
|
|
330
|
+
};
|
|
331
|
+
type BoolField = {
|
|
332
|
+
type: "BOOL";
|
|
333
|
+
fast?: boolean;
|
|
334
|
+
};
|
|
335
|
+
type DateField = {
|
|
336
|
+
type: "DATE";
|
|
337
|
+
fast?: boolean;
|
|
338
|
+
};
|
|
339
|
+
type DetailedField = TextField | NumericField | BoolField | DateField;
|
|
340
|
+
type NestedIndexSchema = {
|
|
341
|
+
[key: string]: FieldType | DetailedField | NestedIndexSchema;
|
|
342
|
+
};
|
|
343
|
+
type FlatIndexSchema = {
|
|
344
|
+
[key: string]: FieldType | DetailedField;
|
|
345
|
+
};
|
|
346
|
+
type SchemaPaths<T, Prefix extends string = ""> = {
|
|
347
|
+
[K in keyof T]: K extends string ? T[K] extends FieldType | DetailedField ? Prefix extends "" ? K : `${Prefix}${K}` : T[K] extends object ? SchemaPaths<T[K], `${Prefix}${K}.`> : never : never;
|
|
348
|
+
}[keyof T];
|
|
349
|
+
type ExtractFieldType<T> = T extends FieldType ? T : T extends {
|
|
350
|
+
type: infer U;
|
|
351
|
+
} ? U extends FieldType ? U : never : never;
|
|
352
|
+
type GetFieldAtPath<TSchema, Path extends string> = Path extends `${infer First}.${infer Rest}` ? First extends keyof TSchema ? GetFieldAtPath<TSchema[First], Rest> : never : Path extends keyof TSchema ? TSchema[Path] : never;
|
|
353
|
+
type FieldValueType<T extends FieldType> = T extends "TEXT" ? string : T extends "U64" | "I64" | "F64" ? number : T extends "BOOL" ? boolean : T extends "DATE" ? string : never;
|
|
354
|
+
type GetFieldValueType<TSchema, Path extends string> = GetFieldAtPath<TSchema, Path> extends infer Field ? Field extends FieldType | DetailedField ? FieldValueType<ExtractFieldType<Field>> : never : never;
|
|
355
|
+
type InferSchemaData<TSchema> = {
|
|
356
|
+
[K in keyof TSchema]: TSchema[K] extends FieldType ? FieldValueType<TSchema[K]> : TSchema[K] extends DetailedField ? FieldValueType<ExtractFieldType<TSchema[K]>> : TSchema[K] extends NestedIndexSchema ? InferSchemaData<TSchema[K]> : never;
|
|
357
|
+
};
|
|
358
|
+
type QueryOptions<TSchema extends NestedIndexSchema | FlatIndexSchema> = {
|
|
359
|
+
/** Maximum number of results to return */
|
|
360
|
+
limit?: number;
|
|
361
|
+
/** Number of results to skip */
|
|
362
|
+
offset?: number;
|
|
363
|
+
/** Sort by field (requires FAST option on field) */
|
|
364
|
+
sortBy?: {
|
|
365
|
+
field: SchemaPaths<TSchema>;
|
|
366
|
+
direction?: "ASC" | "DESC";
|
|
367
|
+
};
|
|
368
|
+
} & ({
|
|
369
|
+
noContent: true;
|
|
370
|
+
} | {
|
|
371
|
+
noContent?: false;
|
|
372
|
+
highlight?: {
|
|
373
|
+
fields: SchemaPaths<TSchema>[];
|
|
374
|
+
preTag?: string;
|
|
375
|
+
postTag?: string;
|
|
376
|
+
};
|
|
377
|
+
/** Return only specific fields */
|
|
378
|
+
returnFields?: (SchemaPaths<TSchema> | "$")[];
|
|
379
|
+
});
|
|
380
|
+
type FieldValuePair<TSchema, TField extends string> = TField extends "$" ? {
|
|
381
|
+
$: InferSchemaData<TSchema>;
|
|
382
|
+
} : TField extends SchemaPaths<TSchema> ? {
|
|
383
|
+
[K in TField]: GetFieldValueType<TSchema, TField>;
|
|
384
|
+
} : never;
|
|
385
|
+
type QueryResult<TSchema extends NestedIndexSchema | FlatIndexSchema, TOptions extends QueryOptions<TSchema> | undefined = undefined> = TOptions extends {
|
|
386
|
+
noContent: true;
|
|
387
|
+
} ? {
|
|
388
|
+
key: string;
|
|
389
|
+
score: string;
|
|
390
|
+
} : TOptions extends {
|
|
391
|
+
returnFields: infer TFields extends readonly string[];
|
|
392
|
+
} ? {
|
|
393
|
+
key: string;
|
|
394
|
+
score: string;
|
|
395
|
+
fields: Array<FieldValuePair<TSchema, TFields[number]>>;
|
|
396
|
+
} : {
|
|
397
|
+
key: string;
|
|
398
|
+
score: string;
|
|
399
|
+
fields: Array<FieldValuePair<TSchema, SchemaPaths<TSchema> | "$">>;
|
|
400
|
+
};
|
|
401
|
+
type StringOperationMap<T extends string> = {
|
|
402
|
+
$eq: T;
|
|
403
|
+
$ne: T;
|
|
404
|
+
$in: T[];
|
|
405
|
+
$fuzzy: T | {
|
|
406
|
+
value: T;
|
|
407
|
+
distance?: number;
|
|
408
|
+
transpositionCostOne?: boolean;
|
|
409
|
+
};
|
|
410
|
+
$phrase: T;
|
|
411
|
+
$regex: T;
|
|
412
|
+
};
|
|
413
|
+
type NumberOperationMap<T extends number> = {
|
|
414
|
+
$eq: T;
|
|
415
|
+
$ne: T;
|
|
416
|
+
$in: T[];
|
|
417
|
+
$gt: T;
|
|
418
|
+
$gte: T;
|
|
419
|
+
$lt: T;
|
|
420
|
+
$lte: T;
|
|
421
|
+
};
|
|
422
|
+
type BooleanOperationMap<T extends boolean> = {
|
|
423
|
+
$eq: T;
|
|
424
|
+
$ne: T;
|
|
425
|
+
$in: T[];
|
|
426
|
+
};
|
|
427
|
+
type DateOperationMap<T extends string | Date> = {
|
|
428
|
+
$eq: T;
|
|
429
|
+
$ne: T;
|
|
430
|
+
$in: T[];
|
|
431
|
+
};
|
|
432
|
+
type StringOperations = {
|
|
433
|
+
[K in keyof StringOperationMap<string>]: {
|
|
434
|
+
[P in K]: StringOperationMap<string>[K];
|
|
435
|
+
};
|
|
436
|
+
}[keyof StringOperationMap<string>];
|
|
437
|
+
type NumberOperations = {
|
|
438
|
+
[K in keyof NumberOperationMap<number>]: {
|
|
439
|
+
[P in K]: NumberOperationMap<number>[K];
|
|
440
|
+
};
|
|
441
|
+
}[keyof NumberOperationMap<number>];
|
|
442
|
+
type BooleanOperations = {
|
|
443
|
+
[K in keyof BooleanOperationMap<boolean>]: {
|
|
444
|
+
[P in K]: BooleanOperationMap<boolean>[K];
|
|
445
|
+
};
|
|
446
|
+
}[keyof BooleanOperationMap<boolean>];
|
|
447
|
+
type DateOperations = {
|
|
448
|
+
[K in keyof DateOperationMap<string | Date>]: {
|
|
449
|
+
[P in K]: DateOperationMap<string | Date>[K];
|
|
450
|
+
};
|
|
451
|
+
}[keyof DateOperationMap<string | Date>];
|
|
452
|
+
type OperationsForFieldType<T extends FieldType> = T extends "TEXT" ? StringOperations : T extends "U64" | "I64" | "F64" ? NumberOperations : T extends "BOOL" ? BooleanOperations : T extends "DATE" ? DateOperations : never;
|
|
453
|
+
type PathOperations<TSchema, TPath extends string> = GetFieldAtPath<TSchema, TPath> extends infer Field ? Field extends FieldType | DetailedField ? OperationsForFieldType<ExtractFieldType<Field>> : never : never;
|
|
454
|
+
type QueryLeaf<TSchema> = {
|
|
455
|
+
[Path in SchemaPaths<TSchema>]: {
|
|
456
|
+
[K in Path]: PathOperations<TSchema, Path>;
|
|
457
|
+
};
|
|
458
|
+
}[SchemaPaths<TSchema>];
|
|
459
|
+
type QueryFilter<TSchema extends NestedIndexSchema | FlatIndexSchema> = QueryLeaf<TSchema> | {
|
|
460
|
+
$must: QueryFilter<TSchema>;
|
|
461
|
+
} | {
|
|
462
|
+
$should: QueryFilter<TSchema>;
|
|
463
|
+
} | {
|
|
464
|
+
$not: QueryFilter<TSchema>;
|
|
465
|
+
} | {
|
|
466
|
+
$and: QueryFilter<TSchema>;
|
|
467
|
+
} | {
|
|
468
|
+
$or: QueryFilter<TSchema>;
|
|
469
|
+
} | {
|
|
470
|
+
$boost: {
|
|
471
|
+
query: QueryFilter<TSchema>;
|
|
472
|
+
value: number;
|
|
473
|
+
};
|
|
474
|
+
};
|
|
475
|
+
type QueryResponse<TSchema extends NestedIndexSchema | FlatIndexSchema, TOptions extends QueryOptions<TSchema> | undefined = undefined> = Array<QueryResult<TSchema, TOptions>>;
|
|
476
|
+
type IndexDescription = {
|
|
477
|
+
indexName: string;
|
|
478
|
+
dataType: "hash" | "string";
|
|
479
|
+
prefixes: string[];
|
|
480
|
+
language?: string;
|
|
481
|
+
fields: Array<{
|
|
482
|
+
name: string;
|
|
483
|
+
type: FieldType;
|
|
484
|
+
noTokenize?: boolean;
|
|
485
|
+
noStem?: boolean;
|
|
486
|
+
fast?: boolean;
|
|
487
|
+
}>;
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
type CreateSearchIndexProps<TSchema extends NestedIndexSchema | FlatIndexSchema> = {
|
|
491
|
+
indexName: string;
|
|
492
|
+
prefix: string | string[];
|
|
493
|
+
language?: "english" | "turkish";
|
|
494
|
+
client: Requester;
|
|
495
|
+
} & ({
|
|
496
|
+
dataType: "string";
|
|
497
|
+
schema: TSchema extends NestedIndexSchema ? TSchema : never;
|
|
498
|
+
} | {
|
|
499
|
+
dataType: "hash";
|
|
500
|
+
schema: TSchema extends FlatIndexSchema ? TSchema : never;
|
|
501
|
+
});
|
|
502
|
+
type SearchIndexProps<TSchema extends NestedIndexSchema | FlatIndexSchema> = Pick<CreateSearchIndexProps<TSchema>, "indexName" | "client"> & {
|
|
503
|
+
schema?: CreateSearchIndexProps<TSchema>["schema"];
|
|
504
|
+
};
|
|
505
|
+
declare class SearchIndex<TSchema extends NestedIndexSchema | FlatIndexSchema, TProps extends SearchIndexProps<TSchema>> {
|
|
506
|
+
indexName: TProps["indexName"];
|
|
507
|
+
schema?: TSchema;
|
|
508
|
+
client: Requester;
|
|
509
|
+
constructor({ indexName, schema, client }: TProps);
|
|
510
|
+
waitIndexing(): Promise<string>;
|
|
511
|
+
describe(): Promise<IndexDescription>;
|
|
512
|
+
query<TOptions extends QueryOptions<TSchema>>(filter: QueryFilter<TSchema>, options?: TOptions): Promise<QueryResponse<TSchema, TOptions>>;
|
|
513
|
+
count(filter: QueryFilter<TSchema>): Promise<number>;
|
|
514
|
+
drop(): Promise<string>;
|
|
515
|
+
}
|
|
516
|
+
declare function createSearchIndex<TSchema extends NestedIndexSchema | FlatIndexSchema>(props: CreateSearchIndexProps<TSchema>): Promise<SearchIndex<TSchema, SearchIndexProps<TSchema>>>;
|
|
517
|
+
declare function getSearchIndex<TSchema extends NestedIndexSchema | FlatIndexSchema>(props: SearchIndexProps<TSchema>): SearchIndex<TSchema, SearchIndexProps<TSchema>>;
|
|
518
|
+
|
|
320
519
|
/**
|
|
321
520
|
* @see https://redis.io/commands/append
|
|
322
521
|
*/
|
|
@@ -3154,6 +3353,8 @@ declare class Redis {
|
|
|
3154
3353
|
createScript<TResult = unknown, TReadonly extends boolean = false>(script: string, opts?: {
|
|
3155
3354
|
readonly?: TReadonly;
|
|
3156
3355
|
}): TReadonly extends true ? ScriptRO<TResult> : Script<TResult>;
|
|
3356
|
+
createSearchIndex: <TSchema extends NestedIndexSchema | FlatIndexSchema>(props: Omit<CreateSearchIndexProps<TSchema>, "client">) => Promise<SearchIndex<TSchema, SearchIndexProps<TSchema>>>;
|
|
3357
|
+
getSearchIndex: <TSchema extends NestedIndexSchema | FlatIndexSchema>(props: Omit<SearchIndexProps<TSchema>, "client">) => SearchIndex<TSchema, SearchIndexProps<TSchema>>;
|
|
3157
3358
|
/**
|
|
3158
3359
|
* Create a new pipeline that allows you to send requests in bulk.
|
|
3159
3360
|
*
|
|
@@ -4059,4 +4260,4 @@ declare class ZMScoreCommand<TData> extends Command<string[] | null, number[] |
|
|
|
4059
4260
|
constructor(cmd: [key: string, members: TData[]], opts?: CommandOptions<string[] | null, number[] | null>);
|
|
4060
4261
|
}
|
|
4061
4262
|
|
|
4062
|
-
export {
|
|
4263
|
+
export { HPTtlCommand as $, AppendCommand as A, BitCountCommand as B, CopyCommand as C, DBSizeCommand as D, EchoCommand as E, FlushAllCommand as F, GeoAddCommand as G, type HttpClientConfig as H, GetCommand as I, GetBitCommand as J, GetDelCommand as K, GetExCommand as L, GetRangeCommand as M, type NestedIndexSchema as N, GetSetCommand as O, Pipeline as P, HDelCommand as Q, type RedisOptions as R, HExistsCommand as S, HExpireCommand as T, type UpstashRequest as U, HExpireAtCommand as V, HExpireTimeCommand as W, HTtlCommand as X, HPExpireCommand as Y, HPExpireAtCommand as Z, HPExpireTimeCommand as _, type RequesterConfig as a, RenameCommand as a$, HPersistCommand as a0, HGetCommand as a1, HGetAllCommand as a2, HIncrByCommand as a3, HIncrByFloatCommand as a4, HKeysCommand as a5, HLenCommand as a6, HMGetCommand as a7, HMSetCommand as a8, HRandFieldCommand as a9, JsonStrAppendCommand as aA, JsonStrLenCommand as aB, JsonToggleCommand as aC, JsonTypeCommand as aD, KeysCommand as aE, LIndexCommand as aF, LInsertCommand as aG, LLenCommand as aH, LMoveCommand as aI, LPopCommand as aJ, LPushCommand as aK, LPushXCommand as aL, LRangeCommand as aM, LRemCommand as aN, LSetCommand as aO, LTrimCommand as aP, MGetCommand as aQ, MSetCommand as aR, MSetNXCommand as aS, PersistCommand as aT, PExpireCommand as aU, PExpireAtCommand as aV, PingCommand as aW, PSetEXCommand as aX, PTtlCommand as aY, PublishCommand as aZ, RandomKeyCommand as a_, HScanCommand as aa, HSetCommand as ab, HSetNXCommand as ac, HStrLenCommand as ad, HValsCommand as ae, IncrCommand as af, IncrByCommand as ag, IncrByFloatCommand as ah, JsonArrAppendCommand as ai, JsonArrIndexCommand as aj, JsonArrInsertCommand as ak, JsonArrLenCommand as al, JsonArrPopCommand as am, JsonArrTrimCommand as an, JsonClearCommand as ao, JsonDelCommand as ap, JsonForgetCommand as aq, JsonGetCommand as ar, JsonMergeCommand as as, JsonMGetCommand as at, JsonNumIncrByCommand as au, JsonNumMultByCommand as av, JsonObjKeysCommand as aw, JsonObjLenCommand as ax, JsonRespCommand as ay, JsonSetCommand as az, Redis as b, ZUnionCommand as b$, RenameNXCommand as b0, RPopCommand as b1, RPushCommand as b2, RPushXCommand as b3, SAddCommand as b4, ScanCommand as b5, type ScanCommandOptions as b6, SCardCommand as b7, ScriptExistsCommand as b8, ScriptFlushCommand as b9, TypeCommand as bA, UnlinkCommand as bB, XAddCommand as bC, XRangeCommand as bD, type ScoreMember as bE, type ZAddCommandOptions as bF, ZAddCommand as bG, ZCardCommand as bH, ZCountCommand as bI, ZDiffStoreCommand as bJ, ZIncrByCommand as bK, ZInterStoreCommand as bL, type ZInterStoreCommandOptions as bM, ZLexCountCommand as bN, ZMScoreCommand as bO, ZPopMaxCommand as bP, ZPopMinCommand as bQ, ZRangeCommand as bR, type ZRangeCommandOptions as bS, ZRankCommand as bT, ZRemCommand as bU, ZRemRangeByLexCommand as bV, ZRemRangeByRankCommand as bW, ZRemRangeByScoreCommand as bX, ZRevRankCommand as bY, ZScanCommand as bZ, ZScoreCommand as b_, ScriptLoadCommand as ba, SDiffCommand as bb, SDiffStoreCommand as bc, SetCommand as bd, type SetCommandOptions as be, SetBitCommand as bf, SetExCommand as bg, SetNxCommand as bh, SetRangeCommand as bi, SInterCommand as bj, SInterStoreCommand as bk, SIsMemberCommand as bl, SMembersCommand as bm, SMIsMemberCommand as bn, SMoveCommand as bo, SPopCommand as bp, SRandMemberCommand as bq, SRemCommand as br, SScanCommand as bs, StrLenCommand as bt, SUnionCommand as bu, SUnionStoreCommand as bv, TimeCommand as bw, TouchCommand as bx, TtlCommand as by, type Type as bz, type Requester as c, type ZUnionCommandOptions as c0, ZUnionStoreCommand as c1, type ZUnionStoreCommandOptions as c2, createSearchIndex as c3, getSearchIndex as c4, type SearchIndexProps as c5, type CreateSearchIndexProps as c6, type FlatIndexSchema as c7, type UpstashResponse as d, error as e, BitOpCommand as f, BitPosCommand as g, DecrCommand as h, DecrByCommand as i, DelCommand as j, EvalROCommand as k, EvalCommand as l, EvalshaROCommand as m, EvalshaCommand as n, ExistsCommand as o, ExpireCommand as p, type ExpireOption as q, ExpireAtCommand as r, FlushDBCommand as s, type GeoAddCommandOptions as t, type GeoMember as u, GeoDistCommand as v, GeoHashCommand as w, GeoPosCommand as x, GeoSearchCommand as y, GeoSearchStoreCommand as z };
|