@upstash/redis 1.37.0-rc.9 → 1.37.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/nodejs.js CHANGED
@@ -165,7 +165,6 @@ var HttpClient = class {
165
165
  const signal = req.signal ?? this.options.signal;
166
166
  const isSignalFunction = typeof signal === "function";
167
167
  const requestOptions = {
168
- //@ts-expect-error this should throw due to bun regression
169
168
  cache: this.options.cache,
170
169
  method: "POST",
171
170
  headers: requestHeaders,
@@ -2003,6 +2002,18 @@ var SInterCommand = class extends Command {
2003
2002
  }
2004
2003
  };
2005
2004
 
2005
+ // pkg/commands/sintercard.ts
2006
+ var SInterCardCommand = class extends Command {
2007
+ constructor(cmd, cmdOpts) {
2008
+ const [keys, opts] = cmd;
2009
+ const command = ["sintercard", keys.length, ...keys];
2010
+ if (opts?.limit !== void 0) {
2011
+ command.push("LIMIT", opts.limit);
2012
+ }
2013
+ super(command, cmdOpts);
2014
+ }
2015
+ };
2016
+
2006
2017
  // pkg/commands/sinterstore.ts
2007
2018
  var SInterStoreCommand = class extends Command {
2008
2019
  constructor(cmd, opts) {
@@ -2152,8 +2163,7 @@ var XAckCommand = class extends Command {
2152
2163
  var XAckDelCommand = class extends Command {
2153
2164
  constructor([key, group, opts, ...ids], cmdOpts) {
2154
2165
  const command = ["XACKDEL", key, group];
2155
- command.push(opts.toUpperCase());
2156
- command.push("IDS", ids.length, ...ids);
2166
+ command.push(opts.toUpperCase(), "IDS", ids.length, ...ids);
2157
2167
  super(command, cmdOpts);
2158
2168
  }
2159
2169
  };
@@ -2695,7 +2705,16 @@ var ZUnionStoreCommand = class extends Command {
2695
2705
  };
2696
2706
 
2697
2707
  // pkg/commands/search/types.ts
2698
- var FIELD_TYPES = ["TEXT", "U64", "I64", "F64", "BOOL", "DATE", "KEYWORD"];
2708
+ var FIELD_TYPES = [
2709
+ "TEXT",
2710
+ "U64",
2711
+ "I64",
2712
+ "F64",
2713
+ "BOOL",
2714
+ "DATE",
2715
+ "KEYWORD",
2716
+ "FACET"
2717
+ ];
2699
2718
 
2700
2719
  // pkg/commands/search/utils.ts
2701
2720
  function isFieldType(value) {
@@ -2750,7 +2769,7 @@ function deserializeQueryResponse(rawResponse) {
2750
2769
  const key2 = fieldRaw[0];
2751
2770
  const value = fieldRaw[1];
2752
2771
  const pathParts = key2.split(".");
2753
- if (pathParts.length == 1) {
2772
+ if (pathParts.length === 1) {
2754
2773
  data[key2] = value;
2755
2774
  } else {
2756
2775
  let currentObj = data;
@@ -2812,6 +2831,10 @@ function deserializeDescribeResponse(rawResponse) {
2812
2831
  fieldInfo.fast = true;
2813
2832
  break;
2814
2833
  }
2834
+ case "FROM": {
2835
+ fieldInfo.from = fieldDescription[++j];
2836
+ break;
2837
+ }
2815
2838
  }
2816
2839
  }
2817
2840
  }
@@ -2827,16 +2850,8 @@ function deserializeDescribeResponse(rawResponse) {
2827
2850
  function parseCountResponse(rawResponse) {
2828
2851
  return typeof rawResponse === "number" ? rawResponse : Number.parseInt(rawResponse, 10);
2829
2852
  }
2830
- function deserializeAggregateResponse(rawResponse, hasLimit) {
2831
- if (hasLimit && rawResponse.length === 2 && Array.isArray(rawResponse[0]) && Array.isArray(rawResponse[1])) {
2832
- const aggregationResult = parseAggregationArray(rawResponse[0]);
2833
- const searchResults = deserializeQueryResponse(rawResponse[1]);
2834
- return [aggregationResult, searchResults];
2835
- }
2836
- if (Array.isArray(rawResponse) && rawResponse.length === 1 && Array.isArray(rawResponse[0])) {
2837
- return parseAggregationArray(rawResponse[0]);
2838
- }
2839
- return rawResponse;
2853
+ function deserializeAggregateResponse(rawResponse) {
2854
+ return parseAggregationArray(rawResponse);
2840
2855
  }
2841
2856
  function parseAggregationArray(arr) {
2842
2857
  const result = {};
@@ -2855,6 +2870,12 @@ function parseAggregationArray(arr) {
2855
2870
  }
2856
2871
  return result;
2857
2872
  }
2873
+ function coerceNumericString(value) {
2874
+ if (typeof value === "string" && value !== "" && !Number.isNaN(Number(value))) {
2875
+ return Number(value);
2876
+ }
2877
+ return value;
2878
+ }
2858
2879
  function parseStatsValue(arr) {
2859
2880
  const result = {};
2860
2881
  for (let i = 0; i < arr.length; i += 2) {
@@ -2869,14 +2890,14 @@ function parseStatsValue(arr) {
2869
2890
  result[key] = value;
2870
2891
  }
2871
2892
  } else {
2872
- result[key] = value;
2893
+ result[key] = coerceNumericString(value);
2873
2894
  }
2874
2895
  }
2875
2896
  return result;
2876
2897
  }
2877
2898
  function parseBucketsValue(arr) {
2878
2899
  if (arr[0] === "buckets" && Array.isArray(arr[1])) {
2879
- return {
2900
+ const result = {
2880
2901
  buckets: arr[1].map((bucket) => {
2881
2902
  const bucketObj = {};
2882
2903
  for (let i = 0; i < bucket.length; i += 2) {
@@ -2887,6 +2908,10 @@ function parseBucketsValue(arr) {
2887
2908
  return bucketObj;
2888
2909
  })
2889
2910
  };
2911
+ for (let i = 2; i < arr.length; i += 2) {
2912
+ result[arr[i]] = arr[i + 1];
2913
+ }
2914
+ return result;
2890
2915
  }
2891
2916
  return arr;
2892
2917
  }
@@ -3010,11 +3035,7 @@ function buildCreateIndexCommand(params) {
3010
3035
  function buildAggregateCommand(name, options) {
3011
3036
  const query = JSON.stringify(options?.filter ?? {});
3012
3037
  const aggregations = JSON.stringify(options.aggregations);
3013
- const command = ["SEARCH.AGGREGATE", name, query, aggregations];
3014
- if (options?.limit !== void 0) {
3015
- command.push("LIMIT", options.limit.toString());
3016
- }
3017
- return command;
3038
+ return ["SEARCH.AGGREGATE", name, query, aggregations];
3018
3039
  }
3019
3040
 
3020
3041
  // pkg/commands/search/search.ts
@@ -3029,7 +3050,7 @@ var SearchIndex = class {
3029
3050
  }
3030
3051
  async waitIndexing() {
3031
3052
  const command = ["SEARCH.WAITINDEXING", this.name];
3032
- await new ExecCommand(command).exec(this.client);
3053
+ return await new ExecCommand(command).exec(this.client);
3033
3054
  }
3034
3055
  async describe() {
3035
3056
  const command = ["SEARCH.DESCRIBE", this.name];
@@ -3044,7 +3065,7 @@ var SearchIndex = class {
3044
3065
  const rawResult = await new ExecCommand(command).exec(
3045
3066
  this.client
3046
3067
  );
3047
- if (!rawResult) return [];
3068
+ if (!rawResult) return rawResult;
3048
3069
  return deserializeQueryResponse(rawResult);
3049
3070
  }
3050
3071
  async aggregate(options) {
@@ -3052,7 +3073,7 @@ var SearchIndex = class {
3052
3073
  const rawResult = await new ExecCommand(
3053
3074
  command
3054
3075
  ).exec(this.client);
3055
- return deserializeAggregateResponse(rawResult, Boolean(options.limit));
3076
+ return deserializeAggregateResponse(rawResult);
3056
3077
  }
3057
3078
  async count({ filter }) {
3058
3079
  const command = buildQueryCommand("SEARCH.COUNT", this.name, { filter });
@@ -3837,6 +3858,10 @@ var Pipeline = class {
3837
3858
  * @see https://redis.io/commands/sinter
3838
3859
  */
3839
3860
  sinter = (...args) => this.chain(new SInterCommand(args, this.commandOptions));
3861
+ /**
3862
+ * @see https://redis.io/commands/sintercard
3863
+ */
3864
+ sintercard = (...args) => this.chain(new SInterCardCommand(args, this.commandOptions));
3840
3865
  /**
3841
3866
  * @see https://redis.io/commands/sinterstore
3842
3867
  */
@@ -4206,6 +4231,7 @@ var Script = class {
4206
4231
  * future major release.
4207
4232
  */
4208
4233
  sha1;
4234
+ initPromise;
4209
4235
  redis;
4210
4236
  constructor(redis, script) {
4211
4237
  this.redis = redis;
@@ -4216,9 +4242,13 @@ var Script = class {
4216
4242
  /**
4217
4243
  * Initialize the script by computing its SHA-1 hash.
4218
4244
  */
4219
- async init(script) {
4220
- if (this.sha1) return;
4221
- this.sha1 = await this.digest(script);
4245
+ init(script) {
4246
+ if (!this.initPromise) {
4247
+ this.initPromise = this.digest(script).then((sha1) => {
4248
+ this.sha1 = sha1;
4249
+ });
4250
+ }
4251
+ return this.initPromise;
4222
4252
  }
4223
4253
  /**
4224
4254
  * Send an `EVAL` command to redis.
@@ -4273,6 +4303,7 @@ var ScriptRO = class {
4273
4303
  * future major release.
4274
4304
  */
4275
4305
  sha1;
4306
+ initPromise;
4276
4307
  redis;
4277
4308
  constructor(redis, script) {
4278
4309
  this.redis = redis;
@@ -4280,9 +4311,13 @@ var ScriptRO = class {
4280
4311
  this.script = script;
4281
4312
  void this.init(script);
4282
4313
  }
4283
- async init(script) {
4284
- if (this.sha1) return;
4285
- this.sha1 = await this.digest(script);
4314
+ init(script) {
4315
+ if (!this.initPromise) {
4316
+ this.initPromise = this.digest(script).then((sha1) => {
4317
+ this.sha1 = sha1;
4318
+ });
4319
+ }
4320
+ return this.initPromise;
4286
4321
  }
4287
4322
  /**
4288
4323
  * Send an `EVAL_RO` command to redis.
@@ -5053,6 +5088,10 @@ var Redis = class {
5053
5088
  * @see https://redis.io/commands/sinter
5054
5089
  */
5055
5090
  sinter = (...args) => new SInterCommand(args, this.opts).exec(this.client);
5091
+ /**
5092
+ * @see https://redis.io/commands/sintercard
5093
+ */
5094
+ sintercard = (...args) => new SInterCardCommand(args, this.opts).exec(this.client);
5056
5095
  /**
5057
5096
  * @see https://redis.io/commands/sinterstore
5058
5097
  */
@@ -5289,10 +5328,10 @@ var Redis = class {
5289
5328
  };
5290
5329
 
5291
5330
  // version.ts
5292
- var VERSION = "v1.37.0-rc.9";
5331
+ var VERSION = "v1.30.2";
5293
5332
 
5294
5333
  // pkg/commands/search/schema-builder.ts
5295
- var BUILD = Symbol("build");
5334
+ var BUILD = /* @__PURE__ */ Symbol("build");
5296
5335
  var TextFieldBuilder = class _TextFieldBuilder {
5297
5336
  _noTokenize;
5298
5337
  _noStem;
@@ -5422,6 +5461,11 @@ var KeywordFieldBuilder = class {
5422
5461
  return { type: "KEYWORD" };
5423
5462
  }
5424
5463
  };
5464
+ var FacetFieldBuilder = class {
5465
+ [BUILD]() {
5466
+ return { type: "FACET" };
5467
+ }
5468
+ };
5425
5469
  var s = {
5426
5470
  string() {
5427
5471
  return new TextFieldBuilder();
@@ -5438,6 +5482,9 @@ var s = {
5438
5482
  keyword() {
5439
5483
  return new KeywordFieldBuilder();
5440
5484
  },
5485
+ facet() {
5486
+ return new FacetFieldBuilder();
5487
+ },
5441
5488
  object(fields) {
5442
5489
  const result = {};
5443
5490
  for (const [key, value] of Object.entries(fields)) {
package/nodejs.mjs CHANGED
@@ -4,10 +4,10 @@ import {
4
4
  SearchIndex,
5
5
  VERSION,
6
6
  error_exports
7
- } from "./chunk-36LGI43F.mjs";
7
+ } from "./chunk-IH7W44G6.mjs";
8
8
 
9
9
  // pkg/commands/search/schema-builder.ts
10
- var BUILD = Symbol("build");
10
+ var BUILD = /* @__PURE__ */ Symbol("build");
11
11
  var TextFieldBuilder = class _TextFieldBuilder {
12
12
  _noTokenize;
13
13
  _noStem;
@@ -137,6 +137,11 @@ var KeywordFieldBuilder = class {
137
137
  return { type: "KEYWORD" };
138
138
  }
139
139
  };
140
+ var FacetFieldBuilder = class {
141
+ [BUILD]() {
142
+ return { type: "FACET" };
143
+ }
144
+ };
140
145
  var s = {
141
146
  string() {
142
147
  return new TextFieldBuilder();
@@ -153,6 +158,9 @@ var s = {
153
158
  keyword() {
154
159
  return new KeywordFieldBuilder();
155
160
  },
161
+ facet() {
162
+ return new FacetFieldBuilder();
163
+ },
156
164
  object(fields) {
157
165
  const result = {};
158
166
  for (const [key, value] of Object.entries(fields)) {
package/package.json CHANGED
@@ -1 +1,78 @@
1
- {"name":"@upstash/redis","version":"v1.37.0-rc.9","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@github.com:upstash/redis-js.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"}}
1
+ {
2
+ "name": "@upstash/redis",
3
+ "version": "1.37.0",
4
+ "main": "./nodejs.js",
5
+ "module": "./nodejs.mjs",
6
+ "types": "./nodejs.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./nodejs.mjs",
10
+ "require": "./nodejs.js"
11
+ },
12
+ "./node": {
13
+ "import": "./nodejs.mjs",
14
+ "require": "./nodejs.js"
15
+ },
16
+ "./cloudflare": {
17
+ "import": "./cloudflare.mjs",
18
+ "require": "./cloudflare.js"
19
+ },
20
+ "./cloudflare.js": {
21
+ "import": "./cloudflare.mjs",
22
+ "require": "./cloudflare.js"
23
+ },
24
+ "./cloudflare.mjs": {
25
+ "import": "./cloudflare.mjs",
26
+ "require": "./cloudflare.js"
27
+ },
28
+ "./fastly": {
29
+ "import": "./fastly.mjs",
30
+ "require": "./fastly.js"
31
+ },
32
+ "./fastly.js": {
33
+ "import": "./fastly.mjs",
34
+ "require": "./fastly.js"
35
+ },
36
+ "./fastly.mjs": {
37
+ "import": "./fastly.mjs",
38
+ "require": "./fastly.js"
39
+ }
40
+ },
41
+ "description": "An HTTP/REST based Redis client built on top of Upstash REST API.",
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git@github.com:upstash/redis-js.git"
45
+ },
46
+ "keywords": [
47
+ "redis",
48
+ "database",
49
+ "serverless",
50
+ "edge",
51
+ "upstash"
52
+ ],
53
+ "files": [
54
+ "./*"
55
+ ],
56
+ "scripts": {
57
+ "build": "tsup && cp package.json README.md ../../LICENSE dist/",
58
+ "test": "bun test pkg --bail --timeout 20000",
59
+ "check-exports": "bun run build && cd dist && attw -P"
60
+ },
61
+ "publishConfig": {
62
+ "access": "public"
63
+ },
64
+ "author": "Andreas Thomas <dev@chronark.com>",
65
+ "license": "MIT",
66
+ "bugs": {
67
+ "url": "https://github.com/upstash/upstash-redis/issues"
68
+ },
69
+ "homepage": "https://github.com/upstash/upstash-redis#readme",
70
+ "devDependencies": {
71
+ "@types/bun": "1.3.6",
72
+ "tsup": "^8.2.3",
73
+ "typescript": "latest"
74
+ },
75
+ "dependencies": {
76
+ "uncrypto": "^0.1.3"
77
+ }
78
+ }