@upstash/redis 1.34.5 → 1.34.7
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-NAQE7K3X.mjs → chunk-TA73MYTP.mjs} +170 -21
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +170 -21
- package/cloudflare.mjs +1 -1
- package/fastly.d.mts +2 -2
- package/fastly.d.ts +2 -2
- package/fastly.js +170 -21
- package/fastly.mjs +1 -1
- package/nodejs.d.mts +2 -2
- package/nodejs.d.ts +2 -2
- package/nodejs.js +170 -21
- package/nodejs.mjs +1 -1
- package/package.json +1 -1
- package/{zmscore-BdNsMd17.d.mts → zmscore-hRk-rDLY.d.mts} +152 -18
- package/{zmscore-BdNsMd17.d.ts → zmscore-hRk-rDLY.d.ts} +152 -18
package/nodejs.js
CHANGED
|
@@ -456,6 +456,26 @@ var Command = class {
|
|
|
456
456
|
}
|
|
457
457
|
};
|
|
458
458
|
|
|
459
|
+
// pkg/commands/hexpire.ts
|
|
460
|
+
var HExpireCommand = class extends Command {
|
|
461
|
+
constructor(cmd, opts) {
|
|
462
|
+
const [key, fields, seconds, option] = cmd;
|
|
463
|
+
const fieldArray = Array.isArray(fields) ? fields : [fields];
|
|
464
|
+
super(
|
|
465
|
+
[
|
|
466
|
+
"hexpire",
|
|
467
|
+
key,
|
|
468
|
+
seconds,
|
|
469
|
+
...option ? [option] : [],
|
|
470
|
+
"FIELDS",
|
|
471
|
+
fieldArray.length,
|
|
472
|
+
...fieldArray
|
|
473
|
+
],
|
|
474
|
+
opts
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
|
|
459
479
|
// pkg/commands/append.ts
|
|
460
480
|
var AppendCommand = class extends Command {
|
|
461
481
|
constructor(cmd, opts) {
|
|
@@ -572,6 +592,13 @@ var EchoCommand = class extends Command {
|
|
|
572
592
|
}
|
|
573
593
|
};
|
|
574
594
|
|
|
595
|
+
// pkg/commands/evalRo.ts
|
|
596
|
+
var EvalROCommand = class extends Command {
|
|
597
|
+
constructor([script, keys, args], opts) {
|
|
598
|
+
super(["eval_ro", script, keys.length, ...keys, ...args ?? []], opts);
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
|
|
575
602
|
// pkg/commands/eval.ts
|
|
576
603
|
var EvalCommand = class extends Command {
|
|
577
604
|
constructor([script, keys, args], opts) {
|
|
@@ -579,6 +606,13 @@ var EvalCommand = class extends Command {
|
|
|
579
606
|
}
|
|
580
607
|
};
|
|
581
608
|
|
|
609
|
+
// pkg/commands/evalshaRo.ts
|
|
610
|
+
var EvalshaROCommand = class extends Command {
|
|
611
|
+
constructor([sha, keys, args], opts) {
|
|
612
|
+
super(["evalsha_ro", sha, keys.length, ...keys, ...args ?? []], opts);
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
|
|
582
616
|
// pkg/commands/evalsha.ts
|
|
583
617
|
var EvalshaCommand = class extends Command {
|
|
584
618
|
constructor([sha, keys, args], opts) {
|
|
@@ -872,9 +906,9 @@ function deserialize(result) {
|
|
|
872
906
|
return null;
|
|
873
907
|
}
|
|
874
908
|
const obj = {};
|
|
875
|
-
|
|
876
|
-
const key = result
|
|
877
|
-
const value = result
|
|
909
|
+
for (let i = 0; i < result.length; i += 2) {
|
|
910
|
+
const key = result[i];
|
|
911
|
+
const value = result[i + 1];
|
|
878
912
|
try {
|
|
879
913
|
const valueIsNumberAndNotSafeInteger = !Number.isNaN(Number(value)) && !Number.isSafeInteger(Number(value));
|
|
880
914
|
obj[key] = valueIsNumberAndNotSafeInteger ? value : JSON.parse(value);
|
|
@@ -958,9 +992,9 @@ function deserialize3(result) {
|
|
|
958
992
|
return null;
|
|
959
993
|
}
|
|
960
994
|
const obj = {};
|
|
961
|
-
|
|
962
|
-
const key = result
|
|
963
|
-
const value = result
|
|
995
|
+
for (let i = 0; i < result.length; i += 2) {
|
|
996
|
+
const key = result[i];
|
|
997
|
+
const value = result[i + 1];
|
|
964
998
|
try {
|
|
965
999
|
obj[key] = JSON.parse(value);
|
|
966
1000
|
} catch {
|
|
@@ -1143,6 +1177,14 @@ var JsonGetCommand = class extends Command {
|
|
|
1143
1177
|
}
|
|
1144
1178
|
};
|
|
1145
1179
|
|
|
1180
|
+
// pkg/commands/json_merge.ts
|
|
1181
|
+
var JsonMergeCommand = class extends Command {
|
|
1182
|
+
constructor(cmd, opts) {
|
|
1183
|
+
const command = ["JSON.MERGE", ...cmd];
|
|
1184
|
+
super(command, opts);
|
|
1185
|
+
}
|
|
1186
|
+
};
|
|
1187
|
+
|
|
1146
1188
|
// pkg/commands/json_mget.ts
|
|
1147
1189
|
var JsonMGetCommand = class extends Command {
|
|
1148
1190
|
constructor(cmd, opts) {
|
|
@@ -1933,15 +1975,15 @@ var XPendingCommand = class extends Command {
|
|
|
1933
1975
|
function deserialize4(result) {
|
|
1934
1976
|
const obj = {};
|
|
1935
1977
|
for (const e of result) {
|
|
1936
|
-
|
|
1937
|
-
const streamId = e
|
|
1938
|
-
const entries = e
|
|
1978
|
+
for (let i = 0; i < e.length; i += 2) {
|
|
1979
|
+
const streamId = e[i];
|
|
1980
|
+
const entries = e[i + 1];
|
|
1939
1981
|
if (!(streamId in obj)) {
|
|
1940
1982
|
obj[streamId] = {};
|
|
1941
1983
|
}
|
|
1942
|
-
|
|
1943
|
-
const field = entries
|
|
1944
|
-
const value = entries
|
|
1984
|
+
for (let j = 0; j < entries.length; j += 2) {
|
|
1985
|
+
const field = entries[j];
|
|
1986
|
+
const value = entries[j + 1];
|
|
1945
1987
|
try {
|
|
1946
1988
|
obj[streamId][field] = JSON.parse(value);
|
|
1947
1989
|
} catch {
|
|
@@ -2030,15 +2072,15 @@ var XRevRangeCommand = class extends Command {
|
|
|
2030
2072
|
function deserialize5(result) {
|
|
2031
2073
|
const obj = {};
|
|
2032
2074
|
for (const e of result) {
|
|
2033
|
-
|
|
2034
|
-
const streamId = e
|
|
2035
|
-
const entries = e
|
|
2075
|
+
for (let i = 0; i < e.length; i += 2) {
|
|
2076
|
+
const streamId = e[i];
|
|
2077
|
+
const entries = e[i + 1];
|
|
2036
2078
|
if (!(streamId in obj)) {
|
|
2037
2079
|
obj[streamId] = {};
|
|
2038
2080
|
}
|
|
2039
|
-
|
|
2040
|
-
const field = entries
|
|
2041
|
-
const value = entries
|
|
2081
|
+
for (let j = 0; j < entries.length; j += 2) {
|
|
2082
|
+
const field = entries[j];
|
|
2083
|
+
const value = entries[j + 1];
|
|
2042
2084
|
try {
|
|
2043
2085
|
obj[streamId][field] = JSON.parse(value);
|
|
2044
2086
|
} catch {
|
|
@@ -2614,10 +2656,18 @@ var Pipeline = class {
|
|
|
2614
2656
|
* @see https://redis.io/commands/echo
|
|
2615
2657
|
*/
|
|
2616
2658
|
echo = (...args) => this.chain(new EchoCommand(args, this.commandOptions));
|
|
2659
|
+
/**
|
|
2660
|
+
* @see https://redis.io/commands/eval_ro
|
|
2661
|
+
*/
|
|
2662
|
+
evalRo = (...args) => this.chain(new EvalROCommand(args, this.commandOptions));
|
|
2617
2663
|
/**
|
|
2618
2664
|
* @see https://redis.io/commands/eval
|
|
2619
2665
|
*/
|
|
2620
2666
|
eval = (...args) => this.chain(new EvalCommand(args, this.commandOptions));
|
|
2667
|
+
/**
|
|
2668
|
+
* @see https://redis.io/commands/evalsha_ro
|
|
2669
|
+
*/
|
|
2670
|
+
evalshaRo = (...args) => this.chain(new EvalshaROCommand(args, this.commandOptions));
|
|
2621
2671
|
/**
|
|
2622
2672
|
* @see https://redis.io/commands/evalsha
|
|
2623
2673
|
*/
|
|
@@ -2698,6 +2748,10 @@ var Pipeline = class {
|
|
|
2698
2748
|
* @see https://redis.io/commands/hexists
|
|
2699
2749
|
*/
|
|
2700
2750
|
hexists = (...args) => this.chain(new HExistsCommand(args, this.commandOptions));
|
|
2751
|
+
/**
|
|
2752
|
+
* @see https://redis.io/commands/hexpire
|
|
2753
|
+
*/
|
|
2754
|
+
hexpire = (...args) => this.chain(new HExpireCommand(args, this.commandOptions));
|
|
2701
2755
|
/**
|
|
2702
2756
|
* @see https://redis.io/commands/hget
|
|
2703
2757
|
*/
|
|
@@ -3215,6 +3269,10 @@ var Pipeline = class {
|
|
|
3215
3269
|
* @see https://redis.io/commands/json.get
|
|
3216
3270
|
*/
|
|
3217
3271
|
get: (...args) => this.chain(new JsonGetCommand(args, this.commandOptions)),
|
|
3272
|
+
/**
|
|
3273
|
+
* @see https://redis.io/commands/json.merge
|
|
3274
|
+
*/
|
|
3275
|
+
merge: (...args) => this.chain(new JsonMergeCommand(args, this.commandOptions)),
|
|
3218
3276
|
/**
|
|
3219
3277
|
* @see https://redis.io/commands/json.mget
|
|
3220
3278
|
*/
|
|
@@ -3314,6 +3372,53 @@ var Script = class {
|
|
|
3314
3372
|
}
|
|
3315
3373
|
};
|
|
3316
3374
|
|
|
3375
|
+
// pkg/scriptRo.ts
|
|
3376
|
+
var import_enc_hex2 = __toESM(require("crypto-js/enc-hex.js"));
|
|
3377
|
+
var import_sha12 = __toESM(require("crypto-js/sha1.js"));
|
|
3378
|
+
var ScriptRO = class {
|
|
3379
|
+
script;
|
|
3380
|
+
sha1;
|
|
3381
|
+
redis;
|
|
3382
|
+
constructor(redis, script) {
|
|
3383
|
+
this.redis = redis;
|
|
3384
|
+
this.sha1 = this.digest(script);
|
|
3385
|
+
this.script = script;
|
|
3386
|
+
}
|
|
3387
|
+
/**
|
|
3388
|
+
* Send an `EVAL_RO` command to redis.
|
|
3389
|
+
*/
|
|
3390
|
+
async evalRo(keys, args) {
|
|
3391
|
+
return await this.redis.evalRo(this.script, keys, args);
|
|
3392
|
+
}
|
|
3393
|
+
/**
|
|
3394
|
+
* Calculates the sha1 hash of the script and then calls `EVALSHA_RO`.
|
|
3395
|
+
*/
|
|
3396
|
+
async evalshaRo(keys, args) {
|
|
3397
|
+
return await this.redis.evalshaRo(this.sha1, keys, args);
|
|
3398
|
+
}
|
|
3399
|
+
/**
|
|
3400
|
+
* Optimistically try to run `EVALSHA_RO` first.
|
|
3401
|
+
* If the script is not loaded in redis, it will fall back and try again with `EVAL_RO`.
|
|
3402
|
+
*
|
|
3403
|
+
* Following calls will be able to use the cached script
|
|
3404
|
+
*/
|
|
3405
|
+
async exec(keys, args) {
|
|
3406
|
+
const res = await this.redis.evalshaRo(this.sha1, keys, args).catch(async (error) => {
|
|
3407
|
+
if (error instanceof Error && error.message.toLowerCase().includes("noscript")) {
|
|
3408
|
+
return await this.redis.evalRo(this.script, keys, args);
|
|
3409
|
+
}
|
|
3410
|
+
throw error;
|
|
3411
|
+
});
|
|
3412
|
+
return res;
|
|
3413
|
+
}
|
|
3414
|
+
/**
|
|
3415
|
+
* Compute the sha1 hash of the script and return its hex representation.
|
|
3416
|
+
*/
|
|
3417
|
+
digest(s) {
|
|
3418
|
+
return import_enc_hex2.default.stringify((0, import_sha12.default)(s));
|
|
3419
|
+
}
|
|
3420
|
+
};
|
|
3421
|
+
|
|
3317
3422
|
// pkg/redis.ts
|
|
3318
3423
|
var Redis = class {
|
|
3319
3424
|
client;
|
|
@@ -3388,6 +3493,10 @@ var Redis = class {
|
|
|
3388
3493
|
* @see https://redis.io/commands/json.get
|
|
3389
3494
|
*/
|
|
3390
3495
|
get: (...args) => new JsonGetCommand(args, this.opts).exec(this.client),
|
|
3496
|
+
/**
|
|
3497
|
+
* @see https://redis.io/commands/json.merge
|
|
3498
|
+
*/
|
|
3499
|
+
merge: (...args) => new JsonMergeCommand(args, this.opts).exec(this.client),
|
|
3391
3500
|
/**
|
|
3392
3501
|
* @see https://redis.io/commands/json.mget
|
|
3393
3502
|
*/
|
|
@@ -3457,8 +3566,36 @@ var Redis = class {
|
|
|
3457
3566
|
} catch {
|
|
3458
3567
|
}
|
|
3459
3568
|
};
|
|
3460
|
-
|
|
3461
|
-
|
|
3569
|
+
/**
|
|
3570
|
+
* Creates a new script.
|
|
3571
|
+
*
|
|
3572
|
+
* Scripts offer the ability to optimistically try to execute a script without having to send the
|
|
3573
|
+
* entire script to the server. If the script is loaded on the server, it tries again by sending
|
|
3574
|
+
* the entire script. Afterwards, the script is cached on the server.
|
|
3575
|
+
*
|
|
3576
|
+
* @param script - The script to create
|
|
3577
|
+
* @param opts - Optional options to pass to the script `{ readonly?: boolean }`
|
|
3578
|
+
* @returns A new script
|
|
3579
|
+
*
|
|
3580
|
+
* @example
|
|
3581
|
+
* ```ts
|
|
3582
|
+
* const redis = new Redis({...})
|
|
3583
|
+
*
|
|
3584
|
+
* const script = redis.createScript<string>("return ARGV[1];")
|
|
3585
|
+
* const arg1 = await script.eval([], ["Hello World"])
|
|
3586
|
+
* expect(arg1, "Hello World")
|
|
3587
|
+
* ```
|
|
3588
|
+
* @example
|
|
3589
|
+
* ```ts
|
|
3590
|
+
* const redis = new Redis({...})
|
|
3591
|
+
*
|
|
3592
|
+
* const script = redis.createScript<string>("return ARGV[1];", { readonly: true })
|
|
3593
|
+
* const arg1 = await script.evalRo([], ["Hello World"])
|
|
3594
|
+
* expect(arg1, "Hello World")
|
|
3595
|
+
* ```
|
|
3596
|
+
*/
|
|
3597
|
+
createScript(script, opts) {
|
|
3598
|
+
return opts?.readonly ? new ScriptRO(this, script) : new Script(this, script);
|
|
3462
3599
|
}
|
|
3463
3600
|
/**
|
|
3464
3601
|
* Create a new pipeline that allows you to send requests in bulk.
|
|
@@ -3545,10 +3682,18 @@ var Redis = class {
|
|
|
3545
3682
|
* @see https://redis.io/commands/echo
|
|
3546
3683
|
*/
|
|
3547
3684
|
echo = (...args) => new EchoCommand(args, this.opts).exec(this.client);
|
|
3685
|
+
/**
|
|
3686
|
+
* @see https://redis.io/commands/eval_ro
|
|
3687
|
+
*/
|
|
3688
|
+
evalRo = (...args) => new EvalROCommand(args, this.opts).exec(this.client);
|
|
3548
3689
|
/**
|
|
3549
3690
|
* @see https://redis.io/commands/eval
|
|
3550
3691
|
*/
|
|
3551
3692
|
eval = (...args) => new EvalCommand(args, this.opts).exec(this.client);
|
|
3693
|
+
/**
|
|
3694
|
+
* @see https://redis.io/commands/evalsha_ro
|
|
3695
|
+
*/
|
|
3696
|
+
evalshaRo = (...args) => new EvalshaROCommand(args, this.opts).exec(this.client);
|
|
3552
3697
|
/**
|
|
3553
3698
|
* @see https://redis.io/commands/evalsha
|
|
3554
3699
|
*/
|
|
@@ -3633,6 +3778,10 @@ var Redis = class {
|
|
|
3633
3778
|
* @see https://redis.io/commands/hexists
|
|
3634
3779
|
*/
|
|
3635
3780
|
hexists = (...args) => new HExistsCommand(args, this.opts).exec(this.client);
|
|
3781
|
+
/**
|
|
3782
|
+
* @see https://redis.io/commands/hexpire
|
|
3783
|
+
*/
|
|
3784
|
+
hexpire = (...args) => new HExpireCommand(args, this.opts).exec(this.client);
|
|
3636
3785
|
/**
|
|
3637
3786
|
* @see https://redis.io/commands/hget
|
|
3638
3787
|
*/
|
|
@@ -4124,7 +4273,7 @@ var Redis = class {
|
|
|
4124
4273
|
};
|
|
4125
4274
|
|
|
4126
4275
|
// version.ts
|
|
4127
|
-
var VERSION = "v1.34.
|
|
4276
|
+
var VERSION = "v1.34.7";
|
|
4128
4277
|
|
|
4129
4278
|
// platforms/nodejs.ts
|
|
4130
4279
|
if (typeof atob === "undefined") {
|
package/nodejs.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@upstash/redis","version":"v1.34.
|
|
1
|
+
{"name":"@upstash/redis","version":"v1.34.7","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","@types/crypto-js":"^4.1.3","@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":{"crypto-js":"^4.2.0"}}
|