@upstash/redis 1.36.0-rc.4 → 1.36.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/{chunk-P45C5Z47.mjs → chunk-4AG3JMXU.mjs} +215 -404
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +222 -379
- package/cloudflare.mjs +14 -10
- package/fastly.d.mts +2 -2
- package/fastly.d.ts +2 -2
- package/fastly.js +209 -370
- package/fastly.mjs +1 -1
- package/nodejs.d.mts +3 -94
- package/nodejs.d.ts +3 -94
- package/nodejs.js +217 -407
- package/nodejs.mjs +9 -13
- package/package.json +1 -1
- package/{zmscore-BfRVhSFL.d.mts → zmscore-0SAuWM0q.d.mts} +125 -319
- package/{zmscore-BfRVhSFL.d.ts → zmscore-0SAuWM0q.d.ts} +125 -319
|
@@ -77,6 +77,15 @@ function mergeHeaders(...headers) {
|
|
|
77
77
|
}
|
|
78
78
|
return merged;
|
|
79
79
|
}
|
|
80
|
+
function kvArrayToObject(v) {
|
|
81
|
+
if (typeof v === "object" && v !== null && !Array.isArray(v)) return v;
|
|
82
|
+
if (!Array.isArray(v)) return {};
|
|
83
|
+
const obj = {};
|
|
84
|
+
for (let i = 0; i < v.length; i += 2) {
|
|
85
|
+
if (typeof v[i] === "string") obj[v[i]] = v[i + 1];
|
|
86
|
+
}
|
|
87
|
+
return obj;
|
|
88
|
+
}
|
|
80
89
|
|
|
81
90
|
// pkg/http.ts
|
|
82
91
|
var HttpClient = class {
|
|
@@ -378,360 +387,6 @@ var Command = class {
|
|
|
378
387
|
}
|
|
379
388
|
};
|
|
380
389
|
|
|
381
|
-
// pkg/commands/exec.ts
|
|
382
|
-
var ExecCommand = class extends Command {
|
|
383
|
-
constructor(cmd, opts) {
|
|
384
|
-
const normalizedCmd = cmd.map((arg) => typeof arg === "string" ? arg : String(arg));
|
|
385
|
-
super(normalizedCmd, opts);
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
// pkg/commands/search/types.ts
|
|
390
|
-
var FIELD_TYPES = ["TEXT", "U64", "I64", "F64", "BOOL", "DATE"];
|
|
391
|
-
|
|
392
|
-
// pkg/commands/search/utils.ts
|
|
393
|
-
function isFieldType(value) {
|
|
394
|
-
return typeof value === "string" && FIELD_TYPES.includes(value);
|
|
395
|
-
}
|
|
396
|
-
function isDetailedField(value) {
|
|
397
|
-
return typeof value === "object" && value !== null && "type" in value && isFieldType(value.type);
|
|
398
|
-
}
|
|
399
|
-
function isNestedSchema(value) {
|
|
400
|
-
return typeof value === "object" && value !== null && !isDetailedField(value);
|
|
401
|
-
}
|
|
402
|
-
function flattenSchema(schema, pathPrefix = []) {
|
|
403
|
-
const fields = [];
|
|
404
|
-
for (const [key, value] of Object.entries(schema)) {
|
|
405
|
-
const currentPath = [...pathPrefix, key];
|
|
406
|
-
const pathString = currentPath.join(".");
|
|
407
|
-
if (isFieldType(value)) {
|
|
408
|
-
fields.push({
|
|
409
|
-
path: pathString,
|
|
410
|
-
type: value
|
|
411
|
-
});
|
|
412
|
-
} else if (isDetailedField(value)) {
|
|
413
|
-
fields.push({
|
|
414
|
-
path: pathString,
|
|
415
|
-
type: value.type,
|
|
416
|
-
fast: "fast" in value ? value.fast : void 0,
|
|
417
|
-
noTokenize: "noTokenize" in value ? value.noTokenize : void 0,
|
|
418
|
-
noStem: "noStem" in value ? value.noStem : void 0
|
|
419
|
-
});
|
|
420
|
-
} else if (isNestedSchema(value)) {
|
|
421
|
-
const nestedFields = flattenSchema(value, currentPath);
|
|
422
|
-
fields.push(...nestedFields);
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
return fields;
|
|
426
|
-
}
|
|
427
|
-
function deserializeQueryResponse(rawResponse, options) {
|
|
428
|
-
const hasEmptySelect = options?.select && Object.keys(options.select).length === 0;
|
|
429
|
-
return rawResponse.map((itemRaw) => {
|
|
430
|
-
const raw = itemRaw;
|
|
431
|
-
const key = raw[0];
|
|
432
|
-
const score = raw[1];
|
|
433
|
-
const rawFields = raw[2];
|
|
434
|
-
if (hasEmptySelect) {
|
|
435
|
-
return { key, score };
|
|
436
|
-
}
|
|
437
|
-
if (!Array.isArray(rawFields) || rawFields.length === 0) {
|
|
438
|
-
return { key, score, data: {} };
|
|
439
|
-
}
|
|
440
|
-
const mergedFields = {};
|
|
441
|
-
for (const fieldRaw of rawFields) {
|
|
442
|
-
const fieldObj = kvArrayToObject(fieldRaw);
|
|
443
|
-
Object.assign(mergedFields, fieldObj);
|
|
444
|
-
}
|
|
445
|
-
if ("$" in mergedFields) {
|
|
446
|
-
const data2 = mergedFields["$"];
|
|
447
|
-
return { key, score, data: data2 };
|
|
448
|
-
}
|
|
449
|
-
const data = dotNotationToNested(mergedFields);
|
|
450
|
-
return { key, score, data };
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
function parseFieldInfo(fieldRaw) {
|
|
454
|
-
const fieldType = fieldRaw[1];
|
|
455
|
-
const options = fieldRaw.slice(2);
|
|
456
|
-
const fieldInfo = { type: fieldType };
|
|
457
|
-
for (const option of options) {
|
|
458
|
-
switch (option.toUpperCase()) {
|
|
459
|
-
case "NOTOKENIZE":
|
|
460
|
-
fieldInfo.noTokenize = true;
|
|
461
|
-
break;
|
|
462
|
-
case "NOSTEM":
|
|
463
|
-
fieldInfo.noStem = true;
|
|
464
|
-
break;
|
|
465
|
-
case "FAST":
|
|
466
|
-
fieldInfo.fast = true;
|
|
467
|
-
break;
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
return fieldInfo;
|
|
471
|
-
}
|
|
472
|
-
function deserializeDescribeResponse(rawResponse) {
|
|
473
|
-
const raw = kvArrayToObject(rawResponse);
|
|
474
|
-
const schema = {};
|
|
475
|
-
if (Array.isArray(raw.schema)) {
|
|
476
|
-
for (const fieldRaw of raw.schema) {
|
|
477
|
-
if (Array.isArray(fieldRaw) && fieldRaw.length >= 2) {
|
|
478
|
-
const fieldName = fieldRaw[0];
|
|
479
|
-
schema[fieldName] = parseFieldInfo(fieldRaw);
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
return {
|
|
484
|
-
name: raw.name,
|
|
485
|
-
dataType: raw.type.toLowerCase(),
|
|
486
|
-
prefixes: raw.prefixes,
|
|
487
|
-
...raw.language && { language: raw.language },
|
|
488
|
-
schema
|
|
489
|
-
};
|
|
490
|
-
}
|
|
491
|
-
function parseCountResponse(rawResponse) {
|
|
492
|
-
return typeof rawResponse === "number" ? rawResponse : parseInt(rawResponse, 10);
|
|
493
|
-
}
|
|
494
|
-
function kvArrayToObject(v) {
|
|
495
|
-
if (typeof v === "object" && v !== null && !Array.isArray(v)) return v;
|
|
496
|
-
if (!Array.isArray(v)) return {};
|
|
497
|
-
const obj = {};
|
|
498
|
-
for (let i = 0; i < v.length; i += 2) {
|
|
499
|
-
if (typeof v[i] === "string") obj[v[i]] = v[i + 1];
|
|
500
|
-
}
|
|
501
|
-
return obj;
|
|
502
|
-
}
|
|
503
|
-
function dotNotationToNested(obj) {
|
|
504
|
-
const result = {};
|
|
505
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
506
|
-
const parts = key.split(".");
|
|
507
|
-
let current = result;
|
|
508
|
-
for (let i = 0; i < parts.length - 1; i++) {
|
|
509
|
-
const part = parts[i];
|
|
510
|
-
if (!(part in current)) {
|
|
511
|
-
current[part] = {};
|
|
512
|
-
}
|
|
513
|
-
current = current[part];
|
|
514
|
-
}
|
|
515
|
-
current[parts[parts.length - 1]] = value;
|
|
516
|
-
}
|
|
517
|
-
return result;
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
// pkg/commands/search/command-builder.ts
|
|
521
|
-
function buildQueryCommand(redisCommand, name, options) {
|
|
522
|
-
const query = JSON.stringify(options?.filter);
|
|
523
|
-
const command = [redisCommand, name, query];
|
|
524
|
-
if (options?.limit !== void 0) {
|
|
525
|
-
command.push("LIMIT", options.limit.toString());
|
|
526
|
-
}
|
|
527
|
-
if (options?.offset !== void 0) {
|
|
528
|
-
command.push("OFFSET", options.offset.toString());
|
|
529
|
-
}
|
|
530
|
-
if (options?.select && Object.keys(options.select).length === 0) {
|
|
531
|
-
command.push("NOCONTENT");
|
|
532
|
-
}
|
|
533
|
-
if (options?.orderBy) {
|
|
534
|
-
command.push("SORTBY");
|
|
535
|
-
Object.entries(options.orderBy).forEach(([field, direction]) => {
|
|
536
|
-
command.push(field, direction);
|
|
537
|
-
});
|
|
538
|
-
}
|
|
539
|
-
if (options?.highlight) {
|
|
540
|
-
command.push(
|
|
541
|
-
"HIGHLIGHT",
|
|
542
|
-
"FIELDS",
|
|
543
|
-
options.highlight.fields.length.toString(),
|
|
544
|
-
...options.highlight.fields
|
|
545
|
-
);
|
|
546
|
-
if (options.highlight.preTag && options.highlight.postTag) {
|
|
547
|
-
command.push("TAGS", options.highlight.preTag, options.highlight.postTag);
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
if (options?.select && Object.keys(options.select).length > 0) {
|
|
551
|
-
command.push(
|
|
552
|
-
"RETURN",
|
|
553
|
-
Object.keys(options.select).length.toString(),
|
|
554
|
-
...Object.keys(options.select)
|
|
555
|
-
);
|
|
556
|
-
}
|
|
557
|
-
return command;
|
|
558
|
-
}
|
|
559
|
-
function buildCreateIndexCommand(props) {
|
|
560
|
-
const { name, schema, dataType, prefix, language } = props;
|
|
561
|
-
const prefixArray = Array.isArray(prefix) ? prefix : [prefix];
|
|
562
|
-
const payload = [
|
|
563
|
-
name,
|
|
564
|
-
"ON",
|
|
565
|
-
dataType.toUpperCase(),
|
|
566
|
-
"PREFIX",
|
|
567
|
-
prefixArray.length.toString(),
|
|
568
|
-
...prefixArray,
|
|
569
|
-
...language ? ["LANGUAGE", language] : [],
|
|
570
|
-
"SCHEMA"
|
|
571
|
-
];
|
|
572
|
-
const fields = flattenSchema(schema);
|
|
573
|
-
for (const field of fields) {
|
|
574
|
-
payload.push(field.path, field.type);
|
|
575
|
-
if (field.fast) {
|
|
576
|
-
payload.push("FAST");
|
|
577
|
-
}
|
|
578
|
-
if (field.noTokenize) {
|
|
579
|
-
payload.push("NOTOKENIZE");
|
|
580
|
-
}
|
|
581
|
-
if (field.noStem) {
|
|
582
|
-
payload.push("NOSTEM");
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
return ["SEARCH.CREATE", ...payload];
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
// pkg/commands/search/search.ts
|
|
589
|
-
var SearchIndex = class {
|
|
590
|
-
name;
|
|
591
|
-
schema;
|
|
592
|
-
client;
|
|
593
|
-
constructor({ name, schema, client }) {
|
|
594
|
-
this.name = name;
|
|
595
|
-
this.schema = schema;
|
|
596
|
-
this.client = client;
|
|
597
|
-
}
|
|
598
|
-
async waitIndexing() {
|
|
599
|
-
const command = ["SEARCH.COMMIT", this.name];
|
|
600
|
-
const result = await new ExecCommand(command).exec(
|
|
601
|
-
this.client
|
|
602
|
-
);
|
|
603
|
-
return result;
|
|
604
|
-
}
|
|
605
|
-
async describe() {
|
|
606
|
-
const command = ["SEARCH.DESCRIBE", this.name];
|
|
607
|
-
const rawResult = await new ExecCommand(command).exec(
|
|
608
|
-
this.client
|
|
609
|
-
);
|
|
610
|
-
return deserializeDescribeResponse(rawResult);
|
|
611
|
-
}
|
|
612
|
-
async query(options) {
|
|
613
|
-
const command = buildQueryCommand("SEARCH.QUERY", this.name, options);
|
|
614
|
-
const rawResult = await new ExecCommand(command).exec(
|
|
615
|
-
this.client
|
|
616
|
-
);
|
|
617
|
-
return deserializeQueryResponse(rawResult, options);
|
|
618
|
-
}
|
|
619
|
-
async count({ filter }) {
|
|
620
|
-
const command = buildQueryCommand("SEARCH.COUNT", this.name, { filter });
|
|
621
|
-
const rawResult = await new ExecCommand(command).exec(
|
|
622
|
-
this.client
|
|
623
|
-
);
|
|
624
|
-
return { count: parseCountResponse(rawResult) };
|
|
625
|
-
}
|
|
626
|
-
async drop() {
|
|
627
|
-
const command = ["SEARCH.DROP", this.name];
|
|
628
|
-
const result = await new ExecCommand(command).exec(
|
|
629
|
-
this.client
|
|
630
|
-
);
|
|
631
|
-
return result;
|
|
632
|
-
}
|
|
633
|
-
};
|
|
634
|
-
async function createIndex(props) {
|
|
635
|
-
const { name, schema, client } = props;
|
|
636
|
-
const createIndexCommand = buildCreateIndexCommand(props);
|
|
637
|
-
await new ExecCommand(createIndexCommand).exec(client);
|
|
638
|
-
return index(client, name, schema);
|
|
639
|
-
}
|
|
640
|
-
function index(client, name, schema) {
|
|
641
|
-
return new SearchIndex({ name, schema, client });
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
// pkg/commands/search/schema-builder.ts
|
|
645
|
-
var BUILD = Symbol("build");
|
|
646
|
-
var TextFieldBuilder = class _TextFieldBuilder {
|
|
647
|
-
_noTokenize;
|
|
648
|
-
_noStem;
|
|
649
|
-
constructor(noTokenize = { noTokenize: false }, noStem = { noStem: false }) {
|
|
650
|
-
this._noTokenize = noTokenize;
|
|
651
|
-
this._noStem = noStem;
|
|
652
|
-
}
|
|
653
|
-
noTokenize() {
|
|
654
|
-
return new _TextFieldBuilder({ noTokenize: true }, this._noStem);
|
|
655
|
-
}
|
|
656
|
-
noStem() {
|
|
657
|
-
return new _TextFieldBuilder(this._noTokenize, { noStem: true });
|
|
658
|
-
}
|
|
659
|
-
[BUILD]() {
|
|
660
|
-
return this._noTokenize.noTokenize || this._noStem.noStem ? {
|
|
661
|
-
type: "TEXT",
|
|
662
|
-
...this._noTokenize.noTokenize ? { noTokenize: true } : {},
|
|
663
|
-
...this._noStem.noStem ? { noStem: true } : {}
|
|
664
|
-
} : "TEXT";
|
|
665
|
-
}
|
|
666
|
-
};
|
|
667
|
-
var NumericFieldBuilder = class {
|
|
668
|
-
type;
|
|
669
|
-
constructor(type) {
|
|
670
|
-
this.type = type;
|
|
671
|
-
}
|
|
672
|
-
[BUILD]() {
|
|
673
|
-
return {
|
|
674
|
-
type: this.type,
|
|
675
|
-
fast: true
|
|
676
|
-
};
|
|
677
|
-
}
|
|
678
|
-
};
|
|
679
|
-
var BoolFieldBuilder = class _BoolFieldBuilder {
|
|
680
|
-
_fast;
|
|
681
|
-
constructor(fast = { fast: false }) {
|
|
682
|
-
this._fast = fast;
|
|
683
|
-
}
|
|
684
|
-
fast() {
|
|
685
|
-
return new _BoolFieldBuilder({ fast: true });
|
|
686
|
-
}
|
|
687
|
-
[BUILD]() {
|
|
688
|
-
return this._fast.fast ? {
|
|
689
|
-
type: "BOOL",
|
|
690
|
-
fast: true
|
|
691
|
-
} : "BOOL";
|
|
692
|
-
}
|
|
693
|
-
};
|
|
694
|
-
var DateFieldBuilder = class _DateFieldBuilder {
|
|
695
|
-
_fast;
|
|
696
|
-
constructor(fast = { fast: false }) {
|
|
697
|
-
this._fast = fast;
|
|
698
|
-
}
|
|
699
|
-
fast() {
|
|
700
|
-
return new _DateFieldBuilder({ fast: true });
|
|
701
|
-
}
|
|
702
|
-
[BUILD]() {
|
|
703
|
-
return this._fast.fast ? {
|
|
704
|
-
type: "DATE",
|
|
705
|
-
fast: true
|
|
706
|
-
} : "DATE";
|
|
707
|
-
}
|
|
708
|
-
};
|
|
709
|
-
var s = {
|
|
710
|
-
string() {
|
|
711
|
-
return new TextFieldBuilder();
|
|
712
|
-
},
|
|
713
|
-
number(type = "F64") {
|
|
714
|
-
return new NumericFieldBuilder(type);
|
|
715
|
-
},
|
|
716
|
-
boolean() {
|
|
717
|
-
return new BoolFieldBuilder();
|
|
718
|
-
},
|
|
719
|
-
date() {
|
|
720
|
-
return new DateFieldBuilder();
|
|
721
|
-
},
|
|
722
|
-
object(fields) {
|
|
723
|
-
const result = {};
|
|
724
|
-
for (const [key, value] of Object.entries(fields)) {
|
|
725
|
-
if (value && typeof value === "object" && BUILD in value) {
|
|
726
|
-
result[key] = value[BUILD]();
|
|
727
|
-
} else {
|
|
728
|
-
result[key] = value;
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
return result;
|
|
732
|
-
}
|
|
733
|
-
};
|
|
734
|
-
|
|
735
390
|
// pkg/commands/hrandfield.ts
|
|
736
391
|
function deserialize(result) {
|
|
737
392
|
if (result.length === 0) {
|
|
@@ -910,6 +565,14 @@ var EvalshaCommand = class extends Command {
|
|
|
910
565
|
}
|
|
911
566
|
};
|
|
912
567
|
|
|
568
|
+
// pkg/commands/exec.ts
|
|
569
|
+
var ExecCommand = class extends Command {
|
|
570
|
+
constructor(cmd, opts) {
|
|
571
|
+
const normalizedCmd = cmd.map((arg) => typeof arg === "string" ? arg : String(arg));
|
|
572
|
+
super(normalizedCmd, opts);
|
|
573
|
+
}
|
|
574
|
+
};
|
|
575
|
+
|
|
913
576
|
// pkg/commands/exists.ts
|
|
914
577
|
var ExistsCommand = class extends Command {
|
|
915
578
|
constructor(cmd, opts) {
|
|
@@ -931,6 +594,23 @@ var ExpireAtCommand = class extends Command {
|
|
|
931
594
|
}
|
|
932
595
|
};
|
|
933
596
|
|
|
597
|
+
// pkg/commands/fcall.ts
|
|
598
|
+
var FCallCommand = class extends Command {
|
|
599
|
+
constructor([functionName, keys, args], opts) {
|
|
600
|
+
super(["fcall", functionName, ...keys ? [keys.length, ...keys] : [0], ...args ?? []], opts);
|
|
601
|
+
}
|
|
602
|
+
};
|
|
603
|
+
|
|
604
|
+
// pkg/commands/fcall_ro.ts
|
|
605
|
+
var FCallRoCommand = class extends Command {
|
|
606
|
+
constructor([functionName, keys, args], opts) {
|
|
607
|
+
super(
|
|
608
|
+
["fcall_ro", functionName, ...keys ? [keys.length, ...keys] : [0], ...args ?? []],
|
|
609
|
+
opts
|
|
610
|
+
);
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
|
|
934
614
|
// pkg/commands/flushall.ts
|
|
935
615
|
var FlushAllCommand = class extends Command {
|
|
936
616
|
constructor(args, opts) {
|
|
@@ -953,6 +633,85 @@ var FlushDBCommand = class extends Command {
|
|
|
953
633
|
}
|
|
954
634
|
};
|
|
955
635
|
|
|
636
|
+
// pkg/commands/function_delete.ts
|
|
637
|
+
var FunctionDeleteCommand = class extends Command {
|
|
638
|
+
constructor([libraryName], opts) {
|
|
639
|
+
super(["function", "delete", libraryName], opts);
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
|
|
643
|
+
// pkg/commands/function_flush.ts
|
|
644
|
+
var FunctionFlushCommand = class extends Command {
|
|
645
|
+
constructor(opts) {
|
|
646
|
+
super(["function", "flush"], opts);
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
|
|
650
|
+
// pkg/commands/function_list.ts
|
|
651
|
+
var FunctionListCommand = class extends Command {
|
|
652
|
+
constructor([args], opts) {
|
|
653
|
+
const command = ["function", "list"];
|
|
654
|
+
if (args?.libraryName) {
|
|
655
|
+
command.push("libraryname", args.libraryName);
|
|
656
|
+
}
|
|
657
|
+
if (args?.withCode) {
|
|
658
|
+
command.push("withcode");
|
|
659
|
+
}
|
|
660
|
+
super(command, { deserialize: deserialize2, ...opts });
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
function deserialize2(result) {
|
|
664
|
+
if (!Array.isArray(result)) return [];
|
|
665
|
+
return result.map((libRaw) => {
|
|
666
|
+
const lib = kvArrayToObject(libRaw);
|
|
667
|
+
const functionsParsed = lib.functions.map(
|
|
668
|
+
(fnRaw) => kvArrayToObject(fnRaw)
|
|
669
|
+
);
|
|
670
|
+
return {
|
|
671
|
+
libraryName: lib.library_name,
|
|
672
|
+
engine: lib.engine,
|
|
673
|
+
functions: functionsParsed.map((fn) => ({
|
|
674
|
+
name: fn.name,
|
|
675
|
+
description: fn.description ?? void 0,
|
|
676
|
+
flags: fn.flags
|
|
677
|
+
})),
|
|
678
|
+
libraryCode: lib.library_code
|
|
679
|
+
};
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
// pkg/commands/function_load.ts
|
|
684
|
+
var FunctionLoadCommand = class extends Command {
|
|
685
|
+
constructor([args], opts) {
|
|
686
|
+
super(["function", "load", ...args.replace ? ["replace"] : [], args.code], opts);
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
|
|
690
|
+
// pkg/commands/function_stats.ts
|
|
691
|
+
var FunctionStatsCommand = class extends Command {
|
|
692
|
+
constructor(opts) {
|
|
693
|
+
super(["function", "stats"], { deserialize: deserialize3, ...opts });
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
function deserialize3(result) {
|
|
697
|
+
const rawEngines = kvArrayToObject(kvArrayToObject(result).engines);
|
|
698
|
+
const parsedEngines = Object.fromEntries(
|
|
699
|
+
Object.entries(rawEngines).map(([key, value]) => [key, kvArrayToObject(value)])
|
|
700
|
+
);
|
|
701
|
+
const final = {
|
|
702
|
+
engines: Object.fromEntries(
|
|
703
|
+
Object.entries(parsedEngines).map(([key, value]) => [
|
|
704
|
+
key,
|
|
705
|
+
{
|
|
706
|
+
librariesCount: value.libraries_count,
|
|
707
|
+
functionsCount: value.functions_count
|
|
708
|
+
}
|
|
709
|
+
])
|
|
710
|
+
)
|
|
711
|
+
};
|
|
712
|
+
return final;
|
|
713
|
+
}
|
|
714
|
+
|
|
956
715
|
// pkg/commands/geo_add.ts
|
|
957
716
|
var GeoAddCommand = class extends Command {
|
|
958
717
|
constructor([key, arg1, ...arg2], opts) {
|
|
@@ -1299,7 +1058,7 @@ var HGetCommand = class extends Command {
|
|
|
1299
1058
|
};
|
|
1300
1059
|
|
|
1301
1060
|
// pkg/commands/hgetall.ts
|
|
1302
|
-
function
|
|
1061
|
+
function deserialize4(result) {
|
|
1303
1062
|
if (result.length === 0) {
|
|
1304
1063
|
return null;
|
|
1305
1064
|
}
|
|
@@ -1319,7 +1078,7 @@ function deserialize2(result) {
|
|
|
1319
1078
|
var HGetAllCommand = class extends Command {
|
|
1320
1079
|
constructor(cmd, opts) {
|
|
1321
1080
|
super(["hgetall", ...cmd], {
|
|
1322
|
-
deserialize: (result) =>
|
|
1081
|
+
deserialize: (result) => deserialize4(result),
|
|
1323
1082
|
...opts
|
|
1324
1083
|
});
|
|
1325
1084
|
}
|
|
@@ -1354,7 +1113,7 @@ var HLenCommand = class extends Command {
|
|
|
1354
1113
|
};
|
|
1355
1114
|
|
|
1356
1115
|
// pkg/commands/hmget.ts
|
|
1357
|
-
function
|
|
1116
|
+
function deserialize5(fields, result) {
|
|
1358
1117
|
if (result.every((field) => field === null)) {
|
|
1359
1118
|
return null;
|
|
1360
1119
|
}
|
|
@@ -1371,7 +1130,7 @@ function deserialize3(fields, result) {
|
|
|
1371
1130
|
var HMGetCommand = class extends Command {
|
|
1372
1131
|
constructor([key, ...fields], opts) {
|
|
1373
1132
|
super(["hmget", key, ...fields], {
|
|
1374
|
-
deserialize: (result) =>
|
|
1133
|
+
deserialize: (result) => deserialize5(fields, result),
|
|
1375
1134
|
...opts
|
|
1376
1135
|
});
|
|
1377
1136
|
}
|
|
@@ -2348,7 +2107,7 @@ var XPendingCommand = class extends Command {
|
|
|
2348
2107
|
};
|
|
2349
2108
|
|
|
2350
2109
|
// pkg/commands/xrange.ts
|
|
2351
|
-
function
|
|
2110
|
+
function deserialize6(result) {
|
|
2352
2111
|
const obj = {};
|
|
2353
2112
|
for (const e of result) {
|
|
2354
2113
|
for (let i = 0; i < e.length; i += 2) {
|
|
@@ -2377,7 +2136,7 @@ var XRangeCommand = class extends Command {
|
|
|
2377
2136
|
command.push("COUNT", count);
|
|
2378
2137
|
}
|
|
2379
2138
|
super(command, {
|
|
2380
|
-
deserialize: (result) =>
|
|
2139
|
+
deserialize: (result) => deserialize6(result),
|
|
2381
2140
|
...opts
|
|
2382
2141
|
});
|
|
2383
2142
|
}
|
|
@@ -2440,12 +2199,12 @@ var XRevRangeCommand = class extends Command {
|
|
|
2440
2199
|
command.push("COUNT", count);
|
|
2441
2200
|
}
|
|
2442
2201
|
super(command, {
|
|
2443
|
-
deserialize: (result) =>
|
|
2202
|
+
deserialize: (result) => deserialize7(result),
|
|
2444
2203
|
...opts
|
|
2445
2204
|
});
|
|
2446
2205
|
}
|
|
2447
2206
|
};
|
|
2448
|
-
function
|
|
2207
|
+
function deserialize7(result) {
|
|
2449
2208
|
const obj = {};
|
|
2450
2209
|
for (const e of result) {
|
|
2451
2210
|
for (let i = 0; i < e.length; i += 2) {
|
|
@@ -3102,7 +2861,7 @@ var Pipeline = class {
|
|
|
3102
2861
|
/**
|
|
3103
2862
|
* @see https://redis.io/commands/lset
|
|
3104
2863
|
*/
|
|
3105
|
-
lset = (key,
|
|
2864
|
+
lset = (key, index, value) => this.chain(new LSetCommand([key, index, value], this.commandOptions));
|
|
3106
2865
|
/**
|
|
3107
2866
|
* @see https://redis.io/commands/ltrim
|
|
3108
2867
|
*/
|
|
@@ -3554,6 +3313,38 @@ var Pipeline = class {
|
|
|
3554
3313
|
type: (...args) => this.chain(new JsonTypeCommand(args, this.commandOptions))
|
|
3555
3314
|
};
|
|
3556
3315
|
}
|
|
3316
|
+
get functions() {
|
|
3317
|
+
return {
|
|
3318
|
+
/**
|
|
3319
|
+
* @see https://redis.io/docs/latest/commands/function-load/
|
|
3320
|
+
*/
|
|
3321
|
+
load: (...args) => this.chain(new FunctionLoadCommand(args, this.commandOptions)),
|
|
3322
|
+
/**
|
|
3323
|
+
* @see https://redis.io/docs/latest/commands/function-list/
|
|
3324
|
+
*/
|
|
3325
|
+
list: (...args) => this.chain(new FunctionListCommand(args, this.commandOptions)),
|
|
3326
|
+
/**
|
|
3327
|
+
* @see https://redis.io/docs/latest/commands/function-delete/
|
|
3328
|
+
*/
|
|
3329
|
+
delete: (...args) => this.chain(new FunctionDeleteCommand(args, this.commandOptions)),
|
|
3330
|
+
/**
|
|
3331
|
+
* @see https://redis.io/docs/latest/commands/function-flush/
|
|
3332
|
+
*/
|
|
3333
|
+
flush: () => this.chain(new FunctionFlushCommand(this.commandOptions)),
|
|
3334
|
+
/**
|
|
3335
|
+
* @see https://redis.io/docs/latest/commands/function-stats/
|
|
3336
|
+
*/
|
|
3337
|
+
stats: () => this.chain(new FunctionStatsCommand(this.commandOptions)),
|
|
3338
|
+
/**
|
|
3339
|
+
* @see https://redis.io/docs/latest/commands/fcall/
|
|
3340
|
+
*/
|
|
3341
|
+
call: (...args) => this.chain(new FCallCommand(args, this.commandOptions)),
|
|
3342
|
+
/**
|
|
3343
|
+
* @see https://redis.io/docs/latest/commands/fcall_ro/
|
|
3344
|
+
*/
|
|
3345
|
+
callRo: (...args) => this.chain(new FCallRoCommand(args, this.commandOptions))
|
|
3346
|
+
};
|
|
3347
|
+
}
|
|
3557
3348
|
};
|
|
3558
3349
|
|
|
3559
3350
|
// pkg/auto-pipeline.ts
|
|
@@ -3575,7 +3366,7 @@ var EXCLUDE_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
3575
3366
|
"zrange",
|
|
3576
3367
|
"exec"
|
|
3577
3368
|
]);
|
|
3578
|
-
function createAutoPipelineProxy(_redis,
|
|
3369
|
+
function createAutoPipelineProxy(_redis, namespace = "root") {
|
|
3579
3370
|
const redis = _redis;
|
|
3580
3371
|
if (!redis.autoPipelineExecutor) {
|
|
3581
3372
|
redis.autoPipelineExecutor = new AutoPipelineExecutor(redis);
|
|
@@ -3585,29 +3376,31 @@ function createAutoPipelineProxy(_redis, json) {
|
|
|
3585
3376
|
if (command === "pipelineCounter") {
|
|
3586
3377
|
return redis2.autoPipelineExecutor.pipelineCounter;
|
|
3587
3378
|
}
|
|
3588
|
-
if (command === "json") {
|
|
3589
|
-
return createAutoPipelineProxy(redis2,
|
|
3379
|
+
if (namespace === "root" && command === "json") {
|
|
3380
|
+
return createAutoPipelineProxy(redis2, "json");
|
|
3381
|
+
}
|
|
3382
|
+
if (namespace === "root" && command === "functions") {
|
|
3383
|
+
return createAutoPipelineProxy(redis2, "functions");
|
|
3590
3384
|
}
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3385
|
+
if (namespace === "root") {
|
|
3386
|
+
const commandInRedisButNotPipeline = command in redis2 && !(command in redis2.autoPipelineExecutor.pipeline);
|
|
3387
|
+
const isCommandExcluded = EXCLUDE_COMMANDS.has(command);
|
|
3388
|
+
if (commandInRedisButNotPipeline || isCommandExcluded) {
|
|
3389
|
+
return redis2[command];
|
|
3390
|
+
}
|
|
3595
3391
|
}
|
|
3596
|
-
const
|
|
3392
|
+
const pipeline = redis2.autoPipelineExecutor.pipeline;
|
|
3393
|
+
const targetFunction = namespace === "json" ? pipeline.json[command] : namespace === "functions" ? pipeline.functions[command] : pipeline[command];
|
|
3394
|
+
const isFunction = typeof targetFunction === "function";
|
|
3597
3395
|
if (isFunction) {
|
|
3598
3396
|
return (...args) => {
|
|
3599
|
-
return redis2.autoPipelineExecutor.withAutoPipeline((
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
...args
|
|
3603
|
-
);
|
|
3604
|
-
} else {
|
|
3605
|
-
pipeline[command](...args);
|
|
3606
|
-
}
|
|
3397
|
+
return redis2.autoPipelineExecutor.withAutoPipeline((pipeline2) => {
|
|
3398
|
+
const targetFunction2 = namespace === "json" ? pipeline2.json[command] : namespace === "functions" ? pipeline2.functions[command] : pipeline2[command];
|
|
3399
|
+
targetFunction2(...args);
|
|
3607
3400
|
});
|
|
3608
3401
|
};
|
|
3609
3402
|
}
|
|
3610
|
-
return
|
|
3403
|
+
return targetFunction;
|
|
3611
3404
|
}
|
|
3612
3405
|
});
|
|
3613
3406
|
}
|
|
@@ -3630,7 +3423,7 @@ var AutoPipelineExecutor = class {
|
|
|
3630
3423
|
this.activePipeline = pipeline;
|
|
3631
3424
|
this.indexInCurrentPipeline = 0;
|
|
3632
3425
|
}
|
|
3633
|
-
const
|
|
3426
|
+
const index = this.indexInCurrentPipeline++;
|
|
3634
3427
|
executeWithPipeline(pipeline);
|
|
3635
3428
|
const pipelineDone = this.deferExecution().then(() => {
|
|
3636
3429
|
if (!this.pipelinePromises.has(pipeline)) {
|
|
@@ -3642,7 +3435,7 @@ var AutoPipelineExecutor = class {
|
|
|
3642
3435
|
return this.pipelinePromises.get(pipeline);
|
|
3643
3436
|
});
|
|
3644
3437
|
const results = await pipelineDone;
|
|
3645
|
-
const commandResult = results[
|
|
3438
|
+
const commandResult = results[index];
|
|
3646
3439
|
if (commandResult.error) {
|
|
3647
3440
|
throw new UpstashError(`Command failed: ${commandResult.error}`);
|
|
3648
3441
|
}
|
|
@@ -3899,8 +3692,8 @@ var Script = class {
|
|
|
3899
3692
|
/**
|
|
3900
3693
|
* Compute the sha1 hash of the script and return its hex representation.
|
|
3901
3694
|
*/
|
|
3902
|
-
async digest(
|
|
3903
|
-
const data = new TextEncoder().encode(
|
|
3695
|
+
async digest(s) {
|
|
3696
|
+
const data = new TextEncoder().encode(s);
|
|
3904
3697
|
const hashBuffer = await subtle.digest("SHA-1", data);
|
|
3905
3698
|
const hashArray = [...new Uint8Array(hashBuffer)];
|
|
3906
3699
|
return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
@@ -3963,8 +3756,8 @@ var ScriptRO = class {
|
|
|
3963
3756
|
/**
|
|
3964
3757
|
* Compute the sha1 hash of the script and return its hex representation.
|
|
3965
3758
|
*/
|
|
3966
|
-
async digest(
|
|
3967
|
-
const data = new TextEncoder().encode(
|
|
3759
|
+
async digest(s) {
|
|
3760
|
+
const data = new TextEncoder().encode(s);
|
|
3968
3761
|
const hashBuffer = await subtle2.digest("SHA-1", data);
|
|
3969
3762
|
const hashArray = [...new Uint8Array(hashBuffer)];
|
|
3970
3763
|
return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
@@ -4099,6 +3892,40 @@ var Redis = class {
|
|
|
4099
3892
|
type: (...args) => new JsonTypeCommand(args, this.opts).exec(this.client)
|
|
4100
3893
|
};
|
|
4101
3894
|
}
|
|
3895
|
+
get functions() {
|
|
3896
|
+
return {
|
|
3897
|
+
/**
|
|
3898
|
+
* @see https://redis.io/docs/latest/commands/function-load/
|
|
3899
|
+
*/
|
|
3900
|
+
load: (...args) => new FunctionLoadCommand(args, this.opts).exec(this.client),
|
|
3901
|
+
/**
|
|
3902
|
+
* @see https://redis.io/docs/latest/commands/function-list/
|
|
3903
|
+
*/
|
|
3904
|
+
list: (...args) => new FunctionListCommand(args, this.opts).exec(this.client),
|
|
3905
|
+
/**
|
|
3906
|
+
* @see https://redis.io/docs/latest/commands/function-delete/
|
|
3907
|
+
*/
|
|
3908
|
+
delete: (...args) => new FunctionDeleteCommand(args, this.opts).exec(this.client),
|
|
3909
|
+
/**
|
|
3910
|
+
* @see https://redis.io/docs/latest/commands/function-flush/
|
|
3911
|
+
*/
|
|
3912
|
+
flush: () => new FunctionFlushCommand(this.opts).exec(this.client),
|
|
3913
|
+
/**
|
|
3914
|
+
* @see https://redis.io/docs/latest/commands/function-stats/
|
|
3915
|
+
*
|
|
3916
|
+
* Note: `running_script` field is not supported and therefore not included in the type.
|
|
3917
|
+
*/
|
|
3918
|
+
stats: () => new FunctionStatsCommand(this.opts).exec(this.client),
|
|
3919
|
+
/**
|
|
3920
|
+
* @see https://redis.io/docs/latest/commands/fcall/
|
|
3921
|
+
*/
|
|
3922
|
+
call: (...args) => new FCallCommand(args, this.opts).exec(this.client),
|
|
3923
|
+
/**
|
|
3924
|
+
* @see https://redis.io/docs/latest/commands/fcall_ro/
|
|
3925
|
+
*/
|
|
3926
|
+
callRo: (...args) => new FCallRoCommand(args, this.opts).exec(this.client)
|
|
3927
|
+
};
|
|
3928
|
+
}
|
|
4102
3929
|
/**
|
|
4103
3930
|
* Wrap a new middleware around the HTTP client.
|
|
4104
3931
|
*/
|
|
@@ -4149,19 +3976,6 @@ var Redis = class {
|
|
|
4149
3976
|
createScript(script, opts) {
|
|
4150
3977
|
return opts?.readonly ? new ScriptRO(this, script) : new Script(this, script);
|
|
4151
3978
|
}
|
|
4152
|
-
get search() {
|
|
4153
|
-
return {
|
|
4154
|
-
createIndex: (props) => {
|
|
4155
|
-
return createIndex({
|
|
4156
|
-
...props,
|
|
4157
|
-
client: this.client
|
|
4158
|
-
});
|
|
4159
|
-
},
|
|
4160
|
-
index: (name, schema) => {
|
|
4161
|
-
return index(this.client, name, schema);
|
|
4162
|
-
}
|
|
4163
|
-
};
|
|
4164
|
-
}
|
|
4165
3979
|
/**
|
|
4166
3980
|
* Create a new pipeline that allows you to send requests in bulk.
|
|
4167
3981
|
*
|
|
@@ -4498,7 +4312,7 @@ var Redis = class {
|
|
|
4498
4312
|
/**
|
|
4499
4313
|
* @see https://redis.io/commands/lset
|
|
4500
4314
|
*/
|
|
4501
|
-
lset = (key,
|
|
4315
|
+
lset = (key, index, value) => new LSetCommand([key, index, value], this.opts).exec(this.client);
|
|
4502
4316
|
/**
|
|
4503
4317
|
* @see https://redis.io/commands/ltrim
|
|
4504
4318
|
*/
|
|
@@ -4869,14 +4683,11 @@ var Redis = class {
|
|
|
4869
4683
|
};
|
|
4870
4684
|
|
|
4871
4685
|
// version.ts
|
|
4872
|
-
var VERSION = "v1.36.0
|
|
4686
|
+
var VERSION = "v1.36.0";
|
|
4873
4687
|
|
|
4874
4688
|
export {
|
|
4875
4689
|
error_exports,
|
|
4876
4690
|
HttpClient,
|
|
4877
|
-
createIndex,
|
|
4878
|
-
index,
|
|
4879
|
-
s,
|
|
4880
4691
|
Redis,
|
|
4881
4692
|
VERSION
|
|
4882
4693
|
};
|