@upstash/redis 1.35.8-canary → 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-TWTIJU7S.mjs → chunk-U5HO3NMB.mjs} +374 -13
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +284 -15
- package/cloudflare.mjs +3 -11
- 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/nodejs.d.ts
CHANGED
|
@@ -1,5 +1,158 @@
|
|
|
1
|
-
import { H as HttpClientConfig, R as RedisOptions, a as RequesterConfig, b as Redis$1, c as Requester } from './zmscore-
|
|
2
|
-
export { A as AppendCommand, B as BitCountCommand, f as BitOpCommand, g as BitPosCommand, C as CopyCommand, D as DBSizeCommand, i as DecrByCommand, h as DecrCommand, j as DelCommand, E as EchoCommand, l as EvalCommand, k as EvalROCommand, n as EvalshaCommand, m as EvalshaROCommand, o as ExistsCommand, r as ExpireAtCommand, p as ExpireCommand, q as ExpireOption, F as FlushAllCommand, s as FlushDBCommand, G as GeoAddCommand, t as GeoAddCommandOptions, v as GeoDistCommand, w as GeoHashCommand, u as GeoMember, x as GeoPosCommand, y as GeoSearchCommand, z as GeoSearchStoreCommand, J as GetBitCommand, I as GetCommand, K as GetDelCommand, L as GetExCommand, M as GetRangeCommand,
|
|
1
|
+
import { N as NestedIndexSchema, H as HttpClientConfig, R as RedisOptions, a as RequesterConfig, b as Redis$1, c as Requester } from './zmscore-BVyzI3wx.js';
|
|
2
|
+
export { A as AppendCommand, B as BitCountCommand, f as BitOpCommand, g as BitPosCommand, C as CopyCommand, c6 as CreateSearchIndexProps, D as DBSizeCommand, i as DecrByCommand, h as DecrCommand, j as DelCommand, E as EchoCommand, l as EvalCommand, k as EvalROCommand, n as EvalshaCommand, m as EvalshaROCommand, o as ExistsCommand, r as ExpireAtCommand, p as ExpireCommand, q as ExpireOption, c7 as FlatIndexSchema, F as FlushAllCommand, s as FlushDBCommand, G as GeoAddCommand, t as GeoAddCommandOptions, v as GeoDistCommand, w as GeoHashCommand, u as GeoMember, x as GeoPosCommand, y as GeoSearchCommand, z as GeoSearchStoreCommand, J as GetBitCommand, I as GetCommand, K as GetDelCommand, L as GetExCommand, M as GetRangeCommand, O as GetSetCommand, Q as HDelCommand, S as HExistsCommand, V as HExpireAtCommand, T as HExpireCommand, W as HExpireTimeCommand, a2 as HGetAllCommand, a1 as HGetCommand, a3 as HIncrByCommand, a4 as HIncrByFloatCommand, a5 as HKeysCommand, a6 as HLenCommand, a7 as HMGetCommand, a8 as HMSetCommand, Z as HPExpireAtCommand, Y as HPExpireCommand, _ as HPExpireTimeCommand, $ as HPTtlCommand, a0 as HPersistCommand, a9 as HRandFieldCommand, aa as HScanCommand, ab as HSetCommand, ac as HSetNXCommand, ad as HStrLenCommand, X as HTtlCommand, ae as HValsCommand, ag as IncrByCommand, ah as IncrByFloatCommand, af as IncrCommand, ai as JsonArrAppendCommand, aj as JsonArrIndexCommand, ak as JsonArrInsertCommand, al as JsonArrLenCommand, am as JsonArrPopCommand, an as JsonArrTrimCommand, ao as JsonClearCommand, ap as JsonDelCommand, aq as JsonForgetCommand, ar as JsonGetCommand, at as JsonMGetCommand, as as JsonMergeCommand, au as JsonNumIncrByCommand, av as JsonNumMultByCommand, aw as JsonObjKeysCommand, ax as JsonObjLenCommand, ay as JsonRespCommand, az as JsonSetCommand, aA as JsonStrAppendCommand, aB as JsonStrLenCommand, aC as JsonToggleCommand, aD as JsonTypeCommand, aE as KeysCommand, aF as LIndexCommand, aG as LInsertCommand, aH as LLenCommand, aI as LMoveCommand, aJ as LPopCommand, aK as LPushCommand, aL as LPushXCommand, aM as LRangeCommand, aN as LRemCommand, aO as LSetCommand, aP as LTrimCommand, aQ as MGetCommand, aR as MSetCommand, aS as MSetNXCommand, aV as PExpireAtCommand, aU as PExpireCommand, aX as PSetEXCommand, aY as PTtlCommand, aT as PersistCommand, aW as PingCommand, P as Pipeline, aZ as PublishCommand, b1 as RPopCommand, b2 as RPushCommand, b3 as RPushXCommand, a_ as RandomKeyCommand, a$ as RenameCommand, b0 as RenameNXCommand, b4 as SAddCommand, b7 as SCardCommand, bb as SDiffCommand, bc as SDiffStoreCommand, bj as SInterCommand, bk as SInterStoreCommand, bl as SIsMemberCommand, bn as SMIsMemberCommand, bm as SMembersCommand, bo as SMoveCommand, bp as SPopCommand, bq as SRandMemberCommand, br as SRemCommand, bs as SScanCommand, bu as SUnionCommand, bv as SUnionStoreCommand, b5 as ScanCommand, b6 as ScanCommandOptions, bE as ScoreMember, b8 as ScriptExistsCommand, b9 as ScriptFlushCommand, ba as ScriptLoadCommand, c5 as SearchIndexProps, bf as SetBitCommand, bd as SetCommand, be as SetCommandOptions, bg as SetExCommand, bh as SetNxCommand, bi as SetRangeCommand, bt as StrLenCommand, bw as TimeCommand, bx as TouchCommand, by as TtlCommand, bz as Type, bA as TypeCommand, bB as UnlinkCommand, U as UpstashRequest, d as UpstashResponse, bC as XAddCommand, bD as XRangeCommand, bG as ZAddCommand, bF as ZAddCommandOptions, bH as ZCardCommand, bI as ZCountCommand, bJ as ZDiffStoreCommand, bK as ZIncrByCommand, bL as ZInterStoreCommand, bM as ZInterStoreCommandOptions, bN as ZLexCountCommand, bO as ZMScoreCommand, bP as ZPopMaxCommand, bQ as ZPopMinCommand, bR as ZRangeCommand, bS as ZRangeCommandOptions, bT as ZRankCommand, bU as ZRemCommand, bV as ZRemRangeByLexCommand, bW as ZRemRangeByRankCommand, bX as ZRemRangeByScoreCommand, bY as ZRevRankCommand, bZ as ZScanCommand, b_ as ZScoreCommand, b$ as ZUnionCommand, c0 as ZUnionCommandOptions, c1 as ZUnionStoreCommand, c2 as ZUnionStoreCommandOptions, c3 as createSearchIndex, e as errors, c4 as getSearchIndex } from './zmscore-BVyzI3wx.js';
|
|
3
|
+
|
|
4
|
+
declare const BUILD: unique symbol;
|
|
5
|
+
declare class TextFieldBuilder<NoTokenize extends Record<"noTokenize", boolean> = {
|
|
6
|
+
noTokenize: false;
|
|
7
|
+
}, NoStem extends Record<"noStem", boolean> = {
|
|
8
|
+
noStem: false;
|
|
9
|
+
}> {
|
|
10
|
+
private _noTokenize;
|
|
11
|
+
private _noStem;
|
|
12
|
+
constructor(noTokenize?: NoTokenize, noStem?: NoStem);
|
|
13
|
+
noTokenize(): TextFieldBuilder<{
|
|
14
|
+
noTokenize: true;
|
|
15
|
+
}, NoStem>;
|
|
16
|
+
noStem(): TextFieldBuilder<NoTokenize, {
|
|
17
|
+
noStem: true;
|
|
18
|
+
}>;
|
|
19
|
+
[BUILD](): NoTokenize extends {
|
|
20
|
+
noTokenize: true;
|
|
21
|
+
} ? NoStem extends {
|
|
22
|
+
noStem: true;
|
|
23
|
+
} ? {
|
|
24
|
+
type: "TEXT";
|
|
25
|
+
noTokenize: true;
|
|
26
|
+
noStem: true;
|
|
27
|
+
} : {
|
|
28
|
+
type: "TEXT";
|
|
29
|
+
noTokenize: true;
|
|
30
|
+
} : NoStem extends {
|
|
31
|
+
noStem: true;
|
|
32
|
+
} ? {
|
|
33
|
+
type: "TEXT";
|
|
34
|
+
noStem: true;
|
|
35
|
+
} : "TEXT";
|
|
36
|
+
}
|
|
37
|
+
declare class NumericFieldBuilder<T extends "U64" | "I64" | "F64", Fast extends Record<"fast", boolean> = {
|
|
38
|
+
fast: false;
|
|
39
|
+
}> {
|
|
40
|
+
private _fast;
|
|
41
|
+
private type;
|
|
42
|
+
constructor(type: T, fast?: Fast);
|
|
43
|
+
fast(): NumericFieldBuilder<T, {
|
|
44
|
+
fast: true;
|
|
45
|
+
}>;
|
|
46
|
+
[BUILD](): Fast extends {
|
|
47
|
+
fast: true;
|
|
48
|
+
} ? {
|
|
49
|
+
type: T;
|
|
50
|
+
fast: true;
|
|
51
|
+
} : T;
|
|
52
|
+
}
|
|
53
|
+
declare class BoolFieldBuilder<Fast extends Record<"fast", boolean> = {
|
|
54
|
+
fast: false;
|
|
55
|
+
}> {
|
|
56
|
+
private _fast;
|
|
57
|
+
constructor(fast?: Fast);
|
|
58
|
+
fast(): BoolFieldBuilder<{
|
|
59
|
+
fast: true;
|
|
60
|
+
}>;
|
|
61
|
+
[BUILD](): Fast extends {
|
|
62
|
+
fast: true;
|
|
63
|
+
} ? {
|
|
64
|
+
type: "BOOL";
|
|
65
|
+
fast: true;
|
|
66
|
+
} : "BOOL";
|
|
67
|
+
}
|
|
68
|
+
declare class DateFieldBuilder<Fast extends Record<"fast", boolean> = {
|
|
69
|
+
fast: false;
|
|
70
|
+
}> {
|
|
71
|
+
private _fast;
|
|
72
|
+
constructor(fast?: Fast);
|
|
73
|
+
fast(): DateFieldBuilder<{
|
|
74
|
+
fast: true;
|
|
75
|
+
}>;
|
|
76
|
+
[BUILD](): Fast extends {
|
|
77
|
+
fast: true;
|
|
78
|
+
} ? {
|
|
79
|
+
type: "DATE";
|
|
80
|
+
fast: true;
|
|
81
|
+
} : "DATE";
|
|
82
|
+
}
|
|
83
|
+
type FieldBuilder = TextFieldBuilder<{
|
|
84
|
+
noTokenize: boolean;
|
|
85
|
+
}, {
|
|
86
|
+
noStem: boolean;
|
|
87
|
+
}> | NumericFieldBuilder<"U64" | "I64" | "F64", {
|
|
88
|
+
fast: boolean;
|
|
89
|
+
}> | BoolFieldBuilder<{
|
|
90
|
+
fast: boolean;
|
|
91
|
+
}> | DateFieldBuilder<{
|
|
92
|
+
fast: boolean;
|
|
93
|
+
}>;
|
|
94
|
+
declare const s: {
|
|
95
|
+
/**
|
|
96
|
+
* Full-text search field (TEXT)
|
|
97
|
+
* @example
|
|
98
|
+
* s.text() // Simple text field
|
|
99
|
+
* s.text().noTokenize() // Exact phrase matching
|
|
100
|
+
* s.text().noStem() // Disable stemming
|
|
101
|
+
*/
|
|
102
|
+
text(): TextFieldBuilder;
|
|
103
|
+
/**
|
|
104
|
+
* Unsigned 64-bit integer (U64)
|
|
105
|
+
* Range: 0 to 2^64-1
|
|
106
|
+
* @example
|
|
107
|
+
* s.unsigned() // Simple unsigned field
|
|
108
|
+
* s.unsigned().fast() // Enable sorting and range queries
|
|
109
|
+
*/
|
|
110
|
+
unsignedInteger(): NumericFieldBuilder<"U64">;
|
|
111
|
+
/**
|
|
112
|
+
* Signed 64-bit integer (I64)
|
|
113
|
+
* Range: -2^63 to 2^63-1
|
|
114
|
+
* @example
|
|
115
|
+
* s.integer() // Simple integer field
|
|
116
|
+
* s.integer().fast() // Enable sorting and range queries
|
|
117
|
+
*/
|
|
118
|
+
integer(): NumericFieldBuilder<"I64">;
|
|
119
|
+
/**
|
|
120
|
+
* 64-bit floating point (F64)
|
|
121
|
+
* @example
|
|
122
|
+
* s.float() // Simple float field
|
|
123
|
+
* s.float().fast() // Enable sorting and range queries
|
|
124
|
+
*/
|
|
125
|
+
float(): NumericFieldBuilder<"F64">;
|
|
126
|
+
/**
|
|
127
|
+
* Boolean field (BOOL)
|
|
128
|
+
* @example
|
|
129
|
+
* s.bool() // Simple boolean field
|
|
130
|
+
* s.bool().fast() // Enable efficient filtering
|
|
131
|
+
*/
|
|
132
|
+
bool(): BoolFieldBuilder;
|
|
133
|
+
/**
|
|
134
|
+
* ISO 8601 date field (DATE)
|
|
135
|
+
* @example
|
|
136
|
+
* s.date() // Simple date field
|
|
137
|
+
* s.date().fast() // Enable sorting and range queries
|
|
138
|
+
*/
|
|
139
|
+
date(): DateFieldBuilder;
|
|
140
|
+
/**
|
|
141
|
+
* Create a string/JSON index schema (supports nesting)
|
|
142
|
+
* @example
|
|
143
|
+
* s.object({
|
|
144
|
+
* name: s.text(),
|
|
145
|
+
* profile: s.object({
|
|
146
|
+
* age: s.unsigned(),
|
|
147
|
+
* city: s.text()
|
|
148
|
+
* })
|
|
149
|
+
* })
|
|
150
|
+
*/
|
|
151
|
+
object<T extends ObjectFieldRecord<T>>(fields: T): { [K in keyof T]: T[K] extends FieldBuilder ? ReturnType<T[K][typeof BUILD]> : T[K]; };
|
|
152
|
+
};
|
|
153
|
+
type ObjectFieldRecord<T> = {
|
|
154
|
+
[K in keyof T]: K extends string ? K extends `${infer _}.${infer _}` ? never : T[K] extends FieldBuilder | NestedIndexSchema ? T[K] : never : never;
|
|
155
|
+
};
|
|
3
156
|
|
|
4
157
|
/**
|
|
5
158
|
* Connection credentials for upstash redis.
|
|
@@ -78,4 +231,4 @@ declare class Redis extends Redis$1 {
|
|
|
78
231
|
static fromEnv(config?: Omit<RedisConfigNodejs, "url" | "token">): Redis;
|
|
79
232
|
}
|
|
80
233
|
|
|
81
|
-
export { Redis, type RedisConfigNodejs, Requester };
|
|
234
|
+
export { NestedIndexSchema, Redis, type RedisConfigNodejs, Requester, s };
|
package/nodejs.js
CHANGED
|
@@ -21,7 +21,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var nodejs_exports = {};
|
|
22
22
|
__export(nodejs_exports, {
|
|
23
23
|
Redis: () => Redis2,
|
|
24
|
-
|
|
24
|
+
createSearchIndex: () => createSearchIndex,
|
|
25
|
+
errors: () => error_exports,
|
|
26
|
+
getSearchIndex: () => getSearchIndex,
|
|
27
|
+
s: () => s
|
|
25
28
|
});
|
|
26
29
|
module.exports = __toCommonJS(nodejs_exports);
|
|
27
30
|
|
|
@@ -2488,6 +2491,352 @@ var ZUnionStoreCommand = class extends Command {
|
|
|
2488
2491
|
}
|
|
2489
2492
|
};
|
|
2490
2493
|
|
|
2494
|
+
// pkg/commands/search/types.ts
|
|
2495
|
+
var FIELD_TYPES = ["TEXT", "U64", "I64", "F64", "BOOL", "DATE"];
|
|
2496
|
+
|
|
2497
|
+
// pkg/commands/search/utils.ts
|
|
2498
|
+
function isFieldType(value) {
|
|
2499
|
+
return typeof value === "string" && FIELD_TYPES.includes(value);
|
|
2500
|
+
}
|
|
2501
|
+
function isDetailedField(value) {
|
|
2502
|
+
return typeof value === "object" && value !== null && "type" in value && isFieldType(value.type);
|
|
2503
|
+
}
|
|
2504
|
+
function isNestedSchema(value) {
|
|
2505
|
+
return typeof value === "object" && value !== null && !isDetailedField(value);
|
|
2506
|
+
}
|
|
2507
|
+
function flattenSchema(schema, pathPrefix = []) {
|
|
2508
|
+
const fields = [];
|
|
2509
|
+
for (const [key, value] of Object.entries(schema)) {
|
|
2510
|
+
const currentPath = [...pathPrefix, key];
|
|
2511
|
+
const pathString = currentPath.join(".");
|
|
2512
|
+
if (isFieldType(value)) {
|
|
2513
|
+
fields.push({
|
|
2514
|
+
path: pathString,
|
|
2515
|
+
type: value
|
|
2516
|
+
});
|
|
2517
|
+
} else if (isDetailedField(value)) {
|
|
2518
|
+
fields.push({
|
|
2519
|
+
path: pathString,
|
|
2520
|
+
type: value.type,
|
|
2521
|
+
fast: "fast" in value ? value.fast : void 0,
|
|
2522
|
+
noTokenize: "noTokenize" in value ? value.noTokenize : void 0,
|
|
2523
|
+
noStem: "noStem" in value ? value.noStem : void 0
|
|
2524
|
+
});
|
|
2525
|
+
} else if (isNestedSchema(value)) {
|
|
2526
|
+
const nestedFields = flattenSchema(value, currentPath);
|
|
2527
|
+
fields.push(...nestedFields);
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
return fields;
|
|
2531
|
+
}
|
|
2532
|
+
function parseQueryResponse(rawResponse, options) {
|
|
2533
|
+
const results = [];
|
|
2534
|
+
if (options && "noContent" in options && options.noContent) {
|
|
2535
|
+
for (const item of rawResponse) {
|
|
2536
|
+
results.push({
|
|
2537
|
+
key: item[0],
|
|
2538
|
+
score: item[1]
|
|
2539
|
+
});
|
|
2540
|
+
}
|
|
2541
|
+
} else {
|
|
2542
|
+
for (const item of rawResponse) {
|
|
2543
|
+
const fields = Array.isArray(item[2]) ? item[2].map((field) => ({
|
|
2544
|
+
[field[0]]: field[1]
|
|
2545
|
+
})) : [];
|
|
2546
|
+
results.push({
|
|
2547
|
+
key: item[0],
|
|
2548
|
+
score: item[1],
|
|
2549
|
+
fields
|
|
2550
|
+
});
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
return results;
|
|
2554
|
+
}
|
|
2555
|
+
function parseDescribeResponse(rawResponse) {
|
|
2556
|
+
return rawResponse;
|
|
2557
|
+
}
|
|
2558
|
+
function parseCountResponse(rawResponse) {
|
|
2559
|
+
return typeof rawResponse === "number" ? rawResponse : parseInt(rawResponse, 10);
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2562
|
+
// pkg/commands/search/command-builder.ts
|
|
2563
|
+
function buildQueryCommand(redisCommand, indexName, query, options) {
|
|
2564
|
+
const command = [redisCommand, indexName, query];
|
|
2565
|
+
if (options?.limit !== void 0) {
|
|
2566
|
+
command.push("LIMIT", options.limit.toString());
|
|
2567
|
+
}
|
|
2568
|
+
if (options?.offset !== void 0) {
|
|
2569
|
+
command.push("OFFSET", options.offset.toString());
|
|
2570
|
+
}
|
|
2571
|
+
if (options?.noContent) {
|
|
2572
|
+
command.push("NOCONTENT");
|
|
2573
|
+
}
|
|
2574
|
+
if (options?.sortBy) {
|
|
2575
|
+
command.push("SORTBY", options.sortBy.field);
|
|
2576
|
+
if (options.sortBy.direction) {
|
|
2577
|
+
command.push(options.sortBy.direction);
|
|
2578
|
+
}
|
|
2579
|
+
}
|
|
2580
|
+
if (options && "highlight" in options && options.highlight) {
|
|
2581
|
+
command.push(
|
|
2582
|
+
"HIGHLIGHT",
|
|
2583
|
+
"FIELDS",
|
|
2584
|
+
options.highlight.fields.length.toString(),
|
|
2585
|
+
...options.highlight.fields
|
|
2586
|
+
);
|
|
2587
|
+
if (options.highlight.preTag && options.highlight.postTag) {
|
|
2588
|
+
command.push("TAGS", options.highlight.preTag, options.highlight.postTag);
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
if (options && "returnFields" in options && options.returnFields && options.returnFields.length > 0) {
|
|
2592
|
+
command.push("RETURN", options.returnFields.length.toString(), ...options.returnFields);
|
|
2593
|
+
}
|
|
2594
|
+
return command;
|
|
2595
|
+
}
|
|
2596
|
+
function buildCreateIndexCommand(props) {
|
|
2597
|
+
const { indexName, schema, dataType, prefix, language } = props;
|
|
2598
|
+
const prefixArray = Array.isArray(prefix) ? prefix : [prefix];
|
|
2599
|
+
const payload = [
|
|
2600
|
+
indexName,
|
|
2601
|
+
"ON",
|
|
2602
|
+
dataType.toUpperCase(),
|
|
2603
|
+
"PREFIX",
|
|
2604
|
+
prefixArray.length.toString(),
|
|
2605
|
+
...prefixArray,
|
|
2606
|
+
...language ? ["LANGUAGE", language] : [],
|
|
2607
|
+
"SCHEMA"
|
|
2608
|
+
];
|
|
2609
|
+
const fields = flattenSchema(schema);
|
|
2610
|
+
for (const field of fields) {
|
|
2611
|
+
payload.push(field.path, field.type);
|
|
2612
|
+
if (field.fast) {
|
|
2613
|
+
payload.push("FAST");
|
|
2614
|
+
}
|
|
2615
|
+
if (field.noTokenize) {
|
|
2616
|
+
payload.push("NOTOKENIZE");
|
|
2617
|
+
}
|
|
2618
|
+
if (field.noStem) {
|
|
2619
|
+
payload.push("NOSTEM");
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2622
|
+
return ["SEARCH.CREATE", ...payload];
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2625
|
+
// pkg/commands/search/search.ts
|
|
2626
|
+
var SearchIndex = class {
|
|
2627
|
+
indexName;
|
|
2628
|
+
schema;
|
|
2629
|
+
client;
|
|
2630
|
+
constructor({ indexName, schema, client }) {
|
|
2631
|
+
this.indexName = indexName;
|
|
2632
|
+
this.schema = schema;
|
|
2633
|
+
this.client = client;
|
|
2634
|
+
}
|
|
2635
|
+
async waitIndexing() {
|
|
2636
|
+
let command = ["SEARCH.COMMIT", this.indexName];
|
|
2637
|
+
const result = await new ExecCommand(command).exec(
|
|
2638
|
+
this.client
|
|
2639
|
+
);
|
|
2640
|
+
return result;
|
|
2641
|
+
}
|
|
2642
|
+
async describe() {
|
|
2643
|
+
let command = ["SEARCH.DESCRIBE", this.indexName];
|
|
2644
|
+
const rawResult = await new ExecCommand(command).exec(
|
|
2645
|
+
this.client
|
|
2646
|
+
);
|
|
2647
|
+
return parseDescribeResponse(rawResult);
|
|
2648
|
+
}
|
|
2649
|
+
async query(filter, options) {
|
|
2650
|
+
const queryString = JSON.stringify(filter);
|
|
2651
|
+
const command = buildQueryCommand(
|
|
2652
|
+
"SEARCH.QUERY",
|
|
2653
|
+
this.indexName,
|
|
2654
|
+
queryString,
|
|
2655
|
+
options
|
|
2656
|
+
);
|
|
2657
|
+
const rawResult = await new ExecCommand(command).exec(
|
|
2658
|
+
this.client
|
|
2659
|
+
);
|
|
2660
|
+
return parseQueryResponse(rawResult, options);
|
|
2661
|
+
}
|
|
2662
|
+
async count(filter) {
|
|
2663
|
+
const queryString = JSON.stringify(filter);
|
|
2664
|
+
const command = buildQueryCommand("SEARCH.COUNT", this.indexName, queryString);
|
|
2665
|
+
const rawResult = await new ExecCommand(command).exec(
|
|
2666
|
+
this.client
|
|
2667
|
+
);
|
|
2668
|
+
return parseCountResponse(rawResult);
|
|
2669
|
+
}
|
|
2670
|
+
async drop() {
|
|
2671
|
+
let command = ["SEARCH.DROP", this.indexName];
|
|
2672
|
+
const result = await new ExecCommand(command).exec(
|
|
2673
|
+
this.client
|
|
2674
|
+
);
|
|
2675
|
+
return result;
|
|
2676
|
+
}
|
|
2677
|
+
};
|
|
2678
|
+
async function createSearchIndex(props) {
|
|
2679
|
+
const { indexName, schema, client } = props;
|
|
2680
|
+
const createIndexCommand = buildCreateIndexCommand(props);
|
|
2681
|
+
await new ExecCommand(createIndexCommand).exec(client);
|
|
2682
|
+
return getSearchIndex({ indexName, schema, client });
|
|
2683
|
+
}
|
|
2684
|
+
function getSearchIndex(props) {
|
|
2685
|
+
return new SearchIndex(props);
|
|
2686
|
+
}
|
|
2687
|
+
|
|
2688
|
+
// pkg/commands/search/schema-builder.ts
|
|
2689
|
+
var BUILD = Symbol("build");
|
|
2690
|
+
var TextFieldBuilder = class _TextFieldBuilder {
|
|
2691
|
+
_noTokenize;
|
|
2692
|
+
_noStem;
|
|
2693
|
+
constructor(noTokenize = { noTokenize: false }, noStem = { noStem: false }) {
|
|
2694
|
+
this._noTokenize = noTokenize;
|
|
2695
|
+
this._noStem = noStem;
|
|
2696
|
+
}
|
|
2697
|
+
noTokenize() {
|
|
2698
|
+
return new _TextFieldBuilder({ noTokenize: true }, this._noStem);
|
|
2699
|
+
}
|
|
2700
|
+
noStem() {
|
|
2701
|
+
return new _TextFieldBuilder(this._noTokenize, { noStem: true });
|
|
2702
|
+
}
|
|
2703
|
+
[BUILD]() {
|
|
2704
|
+
return this._noTokenize.noTokenize || this._noStem.noStem ? {
|
|
2705
|
+
type: "TEXT",
|
|
2706
|
+
...this._noTokenize.noTokenize ? { noTokenize: true } : {},
|
|
2707
|
+
...this._noStem.noStem ? { noStem: true } : {}
|
|
2708
|
+
} : "TEXT";
|
|
2709
|
+
}
|
|
2710
|
+
};
|
|
2711
|
+
var NumericFieldBuilder = class _NumericFieldBuilder {
|
|
2712
|
+
_fast;
|
|
2713
|
+
type;
|
|
2714
|
+
constructor(type, fast = { fast: false }) {
|
|
2715
|
+
this.type = type;
|
|
2716
|
+
this._fast = fast;
|
|
2717
|
+
}
|
|
2718
|
+
fast() {
|
|
2719
|
+
return new _NumericFieldBuilder(this.type, { fast: true });
|
|
2720
|
+
}
|
|
2721
|
+
[BUILD]() {
|
|
2722
|
+
return this._fast.fast ? {
|
|
2723
|
+
type: this.type,
|
|
2724
|
+
fast: true
|
|
2725
|
+
} : this.type;
|
|
2726
|
+
}
|
|
2727
|
+
};
|
|
2728
|
+
var BoolFieldBuilder = class _BoolFieldBuilder {
|
|
2729
|
+
_fast;
|
|
2730
|
+
constructor(fast = { fast: false }) {
|
|
2731
|
+
this._fast = fast;
|
|
2732
|
+
}
|
|
2733
|
+
fast() {
|
|
2734
|
+
return new _BoolFieldBuilder({ fast: true });
|
|
2735
|
+
}
|
|
2736
|
+
[BUILD]() {
|
|
2737
|
+
return this._fast.fast ? {
|
|
2738
|
+
type: "BOOL",
|
|
2739
|
+
fast: true
|
|
2740
|
+
} : "BOOL";
|
|
2741
|
+
}
|
|
2742
|
+
};
|
|
2743
|
+
var DateFieldBuilder = class _DateFieldBuilder {
|
|
2744
|
+
_fast;
|
|
2745
|
+
constructor(fast = { fast: false }) {
|
|
2746
|
+
this._fast = fast;
|
|
2747
|
+
}
|
|
2748
|
+
fast() {
|
|
2749
|
+
return new _DateFieldBuilder({ fast: true });
|
|
2750
|
+
}
|
|
2751
|
+
[BUILD]() {
|
|
2752
|
+
return this._fast.fast ? {
|
|
2753
|
+
type: "DATE",
|
|
2754
|
+
fast: true
|
|
2755
|
+
} : "DATE";
|
|
2756
|
+
}
|
|
2757
|
+
};
|
|
2758
|
+
var s = {
|
|
2759
|
+
/**
|
|
2760
|
+
* Full-text search field (TEXT)
|
|
2761
|
+
* @example
|
|
2762
|
+
* s.text() // Simple text field
|
|
2763
|
+
* s.text().noTokenize() // Exact phrase matching
|
|
2764
|
+
* s.text().noStem() // Disable stemming
|
|
2765
|
+
*/
|
|
2766
|
+
text() {
|
|
2767
|
+
return new TextFieldBuilder();
|
|
2768
|
+
},
|
|
2769
|
+
/**
|
|
2770
|
+
* Unsigned 64-bit integer (U64)
|
|
2771
|
+
* Range: 0 to 2^64-1
|
|
2772
|
+
* @example
|
|
2773
|
+
* s.unsigned() // Simple unsigned field
|
|
2774
|
+
* s.unsigned().fast() // Enable sorting and range queries
|
|
2775
|
+
*/
|
|
2776
|
+
unsignedInteger() {
|
|
2777
|
+
return new NumericFieldBuilder("U64");
|
|
2778
|
+
},
|
|
2779
|
+
/**
|
|
2780
|
+
* Signed 64-bit integer (I64)
|
|
2781
|
+
* Range: -2^63 to 2^63-1
|
|
2782
|
+
* @example
|
|
2783
|
+
* s.integer() // Simple integer field
|
|
2784
|
+
* s.integer().fast() // Enable sorting and range queries
|
|
2785
|
+
*/
|
|
2786
|
+
integer() {
|
|
2787
|
+
return new NumericFieldBuilder("I64");
|
|
2788
|
+
},
|
|
2789
|
+
/**
|
|
2790
|
+
* 64-bit floating point (F64)
|
|
2791
|
+
* @example
|
|
2792
|
+
* s.float() // Simple float field
|
|
2793
|
+
* s.float().fast() // Enable sorting and range queries
|
|
2794
|
+
*/
|
|
2795
|
+
float() {
|
|
2796
|
+
return new NumericFieldBuilder("F64");
|
|
2797
|
+
},
|
|
2798
|
+
/**
|
|
2799
|
+
* Boolean field (BOOL)
|
|
2800
|
+
* @example
|
|
2801
|
+
* s.bool() // Simple boolean field
|
|
2802
|
+
* s.bool().fast() // Enable efficient filtering
|
|
2803
|
+
*/
|
|
2804
|
+
bool() {
|
|
2805
|
+
return new BoolFieldBuilder();
|
|
2806
|
+
},
|
|
2807
|
+
/**
|
|
2808
|
+
* ISO 8601 date field (DATE)
|
|
2809
|
+
* @example
|
|
2810
|
+
* s.date() // Simple date field
|
|
2811
|
+
* s.date().fast() // Enable sorting and range queries
|
|
2812
|
+
*/
|
|
2813
|
+
date() {
|
|
2814
|
+
return new DateFieldBuilder();
|
|
2815
|
+
},
|
|
2816
|
+
/**
|
|
2817
|
+
* Create a string/JSON index schema (supports nesting)
|
|
2818
|
+
* @example
|
|
2819
|
+
* s.object({
|
|
2820
|
+
* name: s.text(),
|
|
2821
|
+
* profile: s.object({
|
|
2822
|
+
* age: s.unsigned(),
|
|
2823
|
+
* city: s.text()
|
|
2824
|
+
* })
|
|
2825
|
+
* })
|
|
2826
|
+
*/
|
|
2827
|
+
object(fields) {
|
|
2828
|
+
const result = {};
|
|
2829
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
2830
|
+
if (value && typeof value === "object" && BUILD in value) {
|
|
2831
|
+
result[key] = value[BUILD]();
|
|
2832
|
+
} else {
|
|
2833
|
+
result[key] = value;
|
|
2834
|
+
}
|
|
2835
|
+
}
|
|
2836
|
+
return result;
|
|
2837
|
+
}
|
|
2838
|
+
};
|
|
2839
|
+
|
|
2491
2840
|
// pkg/commands/psubscribe.ts
|
|
2492
2841
|
var PSubscribeCommand = class extends Command {
|
|
2493
2842
|
constructor(cmd, opts) {
|
|
@@ -3574,8 +3923,8 @@ var Script = class {
|
|
|
3574
3923
|
/**
|
|
3575
3924
|
* Compute the sha1 hash of the script and return its hex representation.
|
|
3576
3925
|
*/
|
|
3577
|
-
async digest(
|
|
3578
|
-
const data = new TextEncoder().encode(
|
|
3926
|
+
async digest(s2) {
|
|
3927
|
+
const data = new TextEncoder().encode(s2);
|
|
3579
3928
|
const hashBuffer = await import_uncrypto.subtle.digest("SHA-1", data);
|
|
3580
3929
|
const hashArray = [...new Uint8Array(hashBuffer)];
|
|
3581
3930
|
return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
@@ -3638,8 +3987,8 @@ var ScriptRO = class {
|
|
|
3638
3987
|
/**
|
|
3639
3988
|
* Compute the sha1 hash of the script and return its hex representation.
|
|
3640
3989
|
*/
|
|
3641
|
-
async digest(
|
|
3642
|
-
const data = new TextEncoder().encode(
|
|
3990
|
+
async digest(s2) {
|
|
3991
|
+
const data = new TextEncoder().encode(s2);
|
|
3643
3992
|
const hashBuffer = await import_uncrypto2.subtle.digest("SHA-1", data);
|
|
3644
3993
|
const hashArray = [...new Uint8Array(hashBuffer)];
|
|
3645
3994
|
return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
@@ -3824,6 +4173,18 @@ var Redis = class {
|
|
|
3824
4173
|
createScript(script, opts) {
|
|
3825
4174
|
return opts?.readonly ? new ScriptRO(this, script) : new Script(this, script);
|
|
3826
4175
|
}
|
|
4176
|
+
createSearchIndex = (props) => {
|
|
4177
|
+
return createSearchIndex({
|
|
4178
|
+
...props,
|
|
4179
|
+
client: this.client
|
|
4180
|
+
});
|
|
4181
|
+
};
|
|
4182
|
+
getSearchIndex = (props) => {
|
|
4183
|
+
return getSearchIndex({
|
|
4184
|
+
...props,
|
|
4185
|
+
client: this.client
|
|
4186
|
+
});
|
|
4187
|
+
};
|
|
3827
4188
|
/**
|
|
3828
4189
|
* Create a new pipeline that allows you to send requests in bulk.
|
|
3829
4190
|
*
|
|
@@ -4531,7 +4892,7 @@ var Redis = class {
|
|
|
4531
4892
|
};
|
|
4532
4893
|
|
|
4533
4894
|
// version.ts
|
|
4534
|
-
var VERSION = "v1.
|
|
4895
|
+
var VERSION = "v1.36.0-rc.1";
|
|
4535
4896
|
|
|
4536
4897
|
// platforms/nodejs.ts
|
|
4537
4898
|
if (typeof atob === "undefined") {
|
|
@@ -4589,20 +4950,18 @@ var Redis2 = class _Redis extends Redis {
|
|
|
4589
4950
|
keepAlive: configOrRequester.keepAlive,
|
|
4590
4951
|
readYourWrites: configOrRequester.readYourWrites
|
|
4591
4952
|
});
|
|
4592
|
-
const safeEnv = typeof process === "object" && process && typeof process.env === "object" && process.env ? process.env : {};
|
|
4593
4953
|
super(client, {
|
|
4594
4954
|
automaticDeserialization: configOrRequester.automaticDeserialization,
|
|
4595
|
-
enableTelemetry: configOrRequester.enableTelemetry ?? !
|
|
4955
|
+
enableTelemetry: configOrRequester.enableTelemetry ?? !process.env.UPSTASH_DISABLE_TELEMETRY,
|
|
4596
4956
|
latencyLogging: configOrRequester.latencyLogging,
|
|
4597
4957
|
enableAutoPipelining: configOrRequester.enableAutoPipelining
|
|
4598
4958
|
});
|
|
4599
|
-
const nodeVersion = typeof process === "object" && process ? process.version : void 0;
|
|
4600
4959
|
this.addTelemetry({
|
|
4601
4960
|
runtime: (
|
|
4602
4961
|
// @ts-expect-error to silence compiler
|
|
4603
|
-
typeof EdgeRuntime === "string" ? "edge-light" :
|
|
4962
|
+
typeof EdgeRuntime === "string" ? "edge-light" : `node@${process.version}`
|
|
4604
4963
|
),
|
|
4605
|
-
platform:
|
|
4964
|
+
platform: process.env.UPSTASH_CONSOLE ? "console" : process.env.VERCEL ? "vercel" : process.env.AWS_REGION ? "aws" : "unknown",
|
|
4606
4965
|
sdk: `@upstash/redis@${VERSION}`
|
|
4607
4966
|
});
|
|
4608
4967
|
if (this.enableAutoPipelining) {
|
|
@@ -4623,7 +4982,7 @@ var Redis2 = class _Redis extends Redis {
|
|
|
4623
4982
|
* that may use different naming conventions.
|
|
4624
4983
|
*/
|
|
4625
4984
|
static fromEnv(config) {
|
|
4626
|
-
if (
|
|
4985
|
+
if (process.env === void 0) {
|
|
4627
4986
|
throw new TypeError(
|
|
4628
4987
|
'[Upstash Redis] Unable to get environment variables, `process.env` is undefined. If you are deploying to cloudflare, please import from "@upstash/redis/cloudflare" instead'
|
|
4629
4988
|
);
|
|
@@ -4644,5 +5003,8 @@ var Redis2 = class _Redis extends Redis {
|
|
|
4644
5003
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4645
5004
|
0 && (module.exports = {
|
|
4646
5005
|
Redis,
|
|
4647
|
-
|
|
5006
|
+
createSearchIndex,
|
|
5007
|
+
errors,
|
|
5008
|
+
getSearchIndex,
|
|
5009
|
+
s
|
|
4648
5010
|
});
|
package/nodejs.mjs
CHANGED
|
@@ -2,8 +2,11 @@ import {
|
|
|
2
2
|
HttpClient,
|
|
3
3
|
Redis,
|
|
4
4
|
VERSION,
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
createSearchIndex,
|
|
6
|
+
error_exports,
|
|
7
|
+
getSearchIndex,
|
|
8
|
+
s
|
|
9
|
+
} from "./chunk-U5HO3NMB.mjs";
|
|
7
10
|
|
|
8
11
|
// platforms/nodejs.ts
|
|
9
12
|
if (typeof atob === "undefined") {
|
|
@@ -61,20 +64,18 @@ var Redis2 = class _Redis extends Redis {
|
|
|
61
64
|
keepAlive: configOrRequester.keepAlive,
|
|
62
65
|
readYourWrites: configOrRequester.readYourWrites
|
|
63
66
|
});
|
|
64
|
-
const safeEnv = typeof process === "object" && process && typeof process.env === "object" && process.env ? process.env : {};
|
|
65
67
|
super(client, {
|
|
66
68
|
automaticDeserialization: configOrRequester.automaticDeserialization,
|
|
67
|
-
enableTelemetry: configOrRequester.enableTelemetry ?? !
|
|
69
|
+
enableTelemetry: configOrRequester.enableTelemetry ?? !process.env.UPSTASH_DISABLE_TELEMETRY,
|
|
68
70
|
latencyLogging: configOrRequester.latencyLogging,
|
|
69
71
|
enableAutoPipelining: configOrRequester.enableAutoPipelining
|
|
70
72
|
});
|
|
71
|
-
const nodeVersion = typeof process === "object" && process ? process.version : void 0;
|
|
72
73
|
this.addTelemetry({
|
|
73
74
|
runtime: (
|
|
74
75
|
// @ts-expect-error to silence compiler
|
|
75
|
-
typeof EdgeRuntime === "string" ? "edge-light" :
|
|
76
|
+
typeof EdgeRuntime === "string" ? "edge-light" : `node@${process.version}`
|
|
76
77
|
),
|
|
77
|
-
platform:
|
|
78
|
+
platform: process.env.UPSTASH_CONSOLE ? "console" : process.env.VERCEL ? "vercel" : process.env.AWS_REGION ? "aws" : "unknown",
|
|
78
79
|
sdk: `@upstash/redis@${VERSION}`
|
|
79
80
|
});
|
|
80
81
|
if (this.enableAutoPipelining) {
|
|
@@ -95,7 +96,7 @@ var Redis2 = class _Redis extends Redis {
|
|
|
95
96
|
* that may use different naming conventions.
|
|
96
97
|
*/
|
|
97
98
|
static fromEnv(config) {
|
|
98
|
-
if (
|
|
99
|
+
if (process.env === void 0) {
|
|
99
100
|
throw new TypeError(
|
|
100
101
|
'[Upstash Redis] Unable to get environment variables, `process.env` is undefined. If you are deploying to cloudflare, please import from "@upstash/redis/cloudflare" instead'
|
|
101
102
|
);
|
|
@@ -115,5 +116,8 @@ var Redis2 = class _Redis extends Redis {
|
|
|
115
116
|
};
|
|
116
117
|
export {
|
|
117
118
|
Redis2 as Redis,
|
|
118
|
-
|
|
119
|
+
createSearchIndex,
|
|
120
|
+
error_exports as errors,
|
|
121
|
+
getSearchIndex,
|
|
122
|
+
s
|
|
119
123
|
};
|