@upstash/redis 1.36.0-rc.7 → 1.36.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.
@@ -77,8 +77,18 @@ 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
91
+ var MAX_BUFFER_SIZE = 1024 * 1024;
82
92
  var HttpClient = class {
83
93
  baseUrl;
84
94
  headers;
@@ -202,11 +212,16 @@ var HttpClient = class {
202
212
  const decoder = new TextDecoder();
203
213
  (async () => {
204
214
  try {
215
+ let buffer = "";
205
216
  while (true) {
206
217
  const { value, done } = await reader.read();
207
218
  if (done) break;
208
- const chunk = decoder.decode(value);
209
- const lines = chunk.split("\n");
219
+ buffer += decoder.decode(value, { stream: true });
220
+ const lines = buffer.split("\n");
221
+ buffer = lines.pop() || "";
222
+ if (buffer.length > MAX_BUFFER_SIZE) {
223
+ throw new Error("Buffer size exceeded (1MB)");
224
+ }
210
225
  for (const line of lines) {
211
226
  if (line.startsWith("data: ")) {
212
227
  const data = line.slice(6);
@@ -378,362 +393,6 @@ var Command = class {
378
393
  }
379
394
  };
380
395
 
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) {
428
- return rawResponse.map((itemRaw) => {
429
- const raw = itemRaw;
430
- const key = raw[0];
431
- const score = raw[1];
432
- const rawFields = raw[2];
433
- if (rawFields === void 0) {
434
- return { key, score };
435
- }
436
- if (!Array.isArray(rawFields) || rawFields.length === 0) {
437
- return { key, score, data: {} };
438
- }
439
- let data = {};
440
- for (const fieldRaw of rawFields) {
441
- const key2 = fieldRaw[0];
442
- const value = fieldRaw[1];
443
- const pathParts = key2.split(".");
444
- if (pathParts.length == 1) {
445
- data[key2] = value;
446
- } else {
447
- let currentObj = data;
448
- for (let i = 0; i < pathParts.length - 1; i++) {
449
- const pathPart = pathParts[i];
450
- if (!(pathPart in currentObj)) {
451
- currentObj[pathPart] = {};
452
- }
453
- currentObj = currentObj[pathPart];
454
- }
455
- currentObj[pathParts.at(-1)] = value;
456
- }
457
- }
458
- if ("$" in data) {
459
- data = data["$"];
460
- }
461
- return { key, score, data };
462
- });
463
- }
464
- function deserializeDescribeResponse(rawResponse) {
465
- const description = {};
466
- for (let i = 0; i < rawResponse.length; i += 2) {
467
- const descriptor = rawResponse[i];
468
- switch (descriptor) {
469
- case "name": {
470
- description["name"] = rawResponse[i + 1];
471
- break;
472
- }
473
- case "type": {
474
- description["dataType"] = rawResponse[i + 1].toLowerCase();
475
- break;
476
- }
477
- case "prefixes": {
478
- description["prefixes"] = rawResponse[i + 1];
479
- break;
480
- }
481
- case "language": {
482
- description["language"] = rawResponse[i + 1];
483
- break;
484
- }
485
- case "schema": {
486
- const schema = {};
487
- for (const fieldDescription of rawResponse[i + 1]) {
488
- const fieldName = fieldDescription[0];
489
- const fieldInfo = { type: fieldDescription[1] };
490
- if (fieldDescription.length > 2) {
491
- for (let j = 2; j < fieldDescription.length; j++) {
492
- const fieldOption = fieldDescription[j];
493
- switch (fieldOption) {
494
- case "NOSTEM": {
495
- fieldInfo.noStem = true;
496
- break;
497
- }
498
- case "NOTOKENIZE": {
499
- fieldInfo.noTokenize = true;
500
- break;
501
- }
502
- case "FAST": {
503
- fieldInfo.fast = true;
504
- break;
505
- }
506
- }
507
- }
508
- }
509
- schema[fieldName] = fieldInfo;
510
- }
511
- description["schema"] = schema;
512
- break;
513
- }
514
- }
515
- }
516
- return description;
517
- }
518
- function parseCountResponse(rawResponse) {
519
- return typeof rawResponse === "number" ? rawResponse : Number.parseInt(rawResponse, 10);
520
- }
521
-
522
- // pkg/commands/search/command-builder.ts
523
- function buildQueryCommand(redisCommand, name, options) {
524
- const query = JSON.stringify(options?.filter ?? {});
525
- const command = [redisCommand, name, query];
526
- if (options?.limit !== void 0) {
527
- command.push("LIMIT", options.limit.toString());
528
- }
529
- if (options?.offset !== void 0) {
530
- command.push("OFFSET", options.offset.toString());
531
- }
532
- if (options?.select && Object.keys(options.select).length === 0) {
533
- command.push("NOCONTENT");
534
- }
535
- if (options?.orderBy) {
536
- command.push("SORTBY");
537
- for (const [field, direction] of Object.entries(options.orderBy)) {
538
- command.push(field, direction);
539
- }
540
- }
541
- if (options?.highlight) {
542
- command.push(
543
- "HIGHLIGHT",
544
- "FIELDS",
545
- options.highlight.fields.length.toString(),
546
- ...options.highlight.fields
547
- );
548
- if (options.highlight.preTag && options.highlight.postTag) {
549
- command.push("TAGS", options.highlight.preTag, options.highlight.postTag);
550
- }
551
- }
552
- if (options?.select && Object.keys(options.select).length > 0) {
553
- command.push(
554
- "RETURN",
555
- Object.keys(options.select).length.toString(),
556
- ...Object.keys(options.select)
557
- );
558
- }
559
- return command;
560
- }
561
- function buildCreateIndexCommand(props) {
562
- const { name, schema, dataType, prefix, language } = props;
563
- const prefixArray = Array.isArray(prefix) ? prefix : [prefix];
564
- const payload = [
565
- name,
566
- "ON",
567
- dataType.toUpperCase(),
568
- "PREFIX",
569
- prefixArray.length.toString(),
570
- ...prefixArray,
571
- ...language ? ["LANGUAGE", language] : [],
572
- "SCHEMA"
573
- ];
574
- const fields = flattenSchema(schema);
575
- for (const field of fields) {
576
- payload.push(field.path, field.type);
577
- if (field.fast) {
578
- payload.push("FAST");
579
- }
580
- if (field.noTokenize) {
581
- payload.push("NOTOKENIZE");
582
- }
583
- if (field.noStem) {
584
- payload.push("NOSTEM");
585
- }
586
- }
587
- return ["SEARCH.CREATE", ...payload];
588
- }
589
-
590
- // pkg/commands/search/search.ts
591
- var SearchIndex = class {
592
- name;
593
- schema;
594
- client;
595
- constructor({ name, schema, client }) {
596
- this.name = name;
597
- this.schema = schema;
598
- this.client = client;
599
- }
600
- async waitIndexing() {
601
- const command = ["SEARCH.WAITINDEXING", this.name];
602
- const result = await new ExecCommand(command).exec(
603
- this.client
604
- );
605
- return result;
606
- }
607
- async describe() {
608
- const command = ["SEARCH.DESCRIBE", this.name];
609
- const rawResult = await new ExecCommand(command).exec(
610
- this.client
611
- );
612
- return deserializeDescribeResponse(rawResult);
613
- }
614
- async query(options) {
615
- const command = buildQueryCommand("SEARCH.QUERY", this.name, options);
616
- const rawResult = await new ExecCommand(command).exec(
617
- this.client
618
- );
619
- return deserializeQueryResponse(rawResult);
620
- }
621
- async count({ filter }) {
622
- const command = buildQueryCommand("SEARCH.COUNT", this.name, { filter });
623
- const rawResult = await new ExecCommand(command).exec(
624
- this.client
625
- );
626
- return { count: parseCountResponse(rawResult) };
627
- }
628
- async drop() {
629
- const command = ["SEARCH.DROP", this.name];
630
- const result = await new ExecCommand(command).exec(
631
- this.client
632
- );
633
- return result;
634
- }
635
- };
636
- async function createIndex(props) {
637
- const { name, schema, client } = props;
638
- const createIndexCommand = buildCreateIndexCommand(props);
639
- await new ExecCommand(createIndexCommand).exec(client);
640
- return index(client, name, schema);
641
- }
642
- function index(client, name, schema) {
643
- return new SearchIndex({ name, schema, client });
644
- }
645
-
646
- // pkg/commands/search/schema-builder.ts
647
- var BUILD = Symbol("build");
648
- var TextFieldBuilder = class _TextFieldBuilder {
649
- _noTokenize;
650
- _noStem;
651
- constructor(noTokenize = { noTokenize: false }, noStem = { noStem: false }) {
652
- this._noTokenize = noTokenize;
653
- this._noStem = noStem;
654
- }
655
- noTokenize() {
656
- return new _TextFieldBuilder({ noTokenize: true }, this._noStem);
657
- }
658
- noStem() {
659
- return new _TextFieldBuilder(this._noTokenize, { noStem: true });
660
- }
661
- [BUILD]() {
662
- return this._noTokenize.noTokenize || this._noStem.noStem ? {
663
- type: "TEXT",
664
- ...this._noTokenize.noTokenize ? { noTokenize: true } : {},
665
- ...this._noStem.noStem ? { noStem: true } : {}
666
- } : "TEXT";
667
- }
668
- };
669
- var NumericFieldBuilder = class {
670
- type;
671
- constructor(type) {
672
- this.type = type;
673
- }
674
- [BUILD]() {
675
- return {
676
- type: this.type,
677
- fast: true
678
- };
679
- }
680
- };
681
- var BoolFieldBuilder = class _BoolFieldBuilder {
682
- _fast;
683
- constructor(fast = { fast: false }) {
684
- this._fast = fast;
685
- }
686
- fast() {
687
- return new _BoolFieldBuilder({ fast: true });
688
- }
689
- [BUILD]() {
690
- return this._fast.fast ? {
691
- type: "BOOL",
692
- fast: true
693
- } : "BOOL";
694
- }
695
- };
696
- var DateFieldBuilder = class _DateFieldBuilder {
697
- _fast;
698
- constructor(fast = { fast: false }) {
699
- this._fast = fast;
700
- }
701
- fast() {
702
- return new _DateFieldBuilder({ fast: true });
703
- }
704
- [BUILD]() {
705
- return this._fast.fast ? {
706
- type: "DATE",
707
- fast: true
708
- } : "DATE";
709
- }
710
- };
711
- var s = {
712
- string() {
713
- return new TextFieldBuilder();
714
- },
715
- number(type = "F64") {
716
- return new NumericFieldBuilder(type);
717
- },
718
- boolean() {
719
- return new BoolFieldBuilder();
720
- },
721
- date() {
722
- return new DateFieldBuilder();
723
- },
724
- object(fields) {
725
- const result = {};
726
- for (const [key, value] of Object.entries(fields)) {
727
- if (value && typeof value === "object" && BUILD in value) {
728
- result[key] = value[BUILD]();
729
- } else {
730
- result[key] = value;
731
- }
732
- }
733
- return result;
734
- }
735
- };
736
-
737
396
  // pkg/commands/hrandfield.ts
738
397
  function deserialize(result) {
739
398
  if (result.length === 0) {
@@ -912,6 +571,14 @@ var EvalshaCommand = class extends Command {
912
571
  }
913
572
  };
914
573
 
574
+ // pkg/commands/exec.ts
575
+ var ExecCommand = class extends Command {
576
+ constructor(cmd, opts) {
577
+ const normalizedCmd = cmd.map((arg) => typeof arg === "string" ? arg : String(arg));
578
+ super(normalizedCmd, opts);
579
+ }
580
+ };
581
+
915
582
  // pkg/commands/exists.ts
916
583
  var ExistsCommand = class extends Command {
917
584
  constructor(cmd, opts) {
@@ -933,6 +600,23 @@ var ExpireAtCommand = class extends Command {
933
600
  }
934
601
  };
935
602
 
603
+ // pkg/commands/fcall.ts
604
+ var FCallCommand = class extends Command {
605
+ constructor([functionName, keys, args], opts) {
606
+ super(["fcall", functionName, ...keys ? [keys.length, ...keys] : [0], ...args ?? []], opts);
607
+ }
608
+ };
609
+
610
+ // pkg/commands/fcall_ro.ts
611
+ var FCallRoCommand = class extends Command {
612
+ constructor([functionName, keys, args], opts) {
613
+ super(
614
+ ["fcall_ro", functionName, ...keys ? [keys.length, ...keys] : [0], ...args ?? []],
615
+ opts
616
+ );
617
+ }
618
+ };
619
+
936
620
  // pkg/commands/flushall.ts
937
621
  var FlushAllCommand = class extends Command {
938
622
  constructor(args, opts) {
@@ -955,6 +639,85 @@ var FlushDBCommand = class extends Command {
955
639
  }
956
640
  };
957
641
 
642
+ // pkg/commands/function_delete.ts
643
+ var FunctionDeleteCommand = class extends Command {
644
+ constructor([libraryName], opts) {
645
+ super(["function", "delete", libraryName], opts);
646
+ }
647
+ };
648
+
649
+ // pkg/commands/function_flush.ts
650
+ var FunctionFlushCommand = class extends Command {
651
+ constructor(opts) {
652
+ super(["function", "flush"], opts);
653
+ }
654
+ };
655
+
656
+ // pkg/commands/function_list.ts
657
+ var FunctionListCommand = class extends Command {
658
+ constructor([args], opts) {
659
+ const command = ["function", "list"];
660
+ if (args?.libraryName) {
661
+ command.push("libraryname", args.libraryName);
662
+ }
663
+ if (args?.withCode) {
664
+ command.push("withcode");
665
+ }
666
+ super(command, { deserialize: deserialize2, ...opts });
667
+ }
668
+ };
669
+ function deserialize2(result) {
670
+ if (!Array.isArray(result)) return [];
671
+ return result.map((libRaw) => {
672
+ const lib = kvArrayToObject(libRaw);
673
+ const functionsParsed = lib.functions.map(
674
+ (fnRaw) => kvArrayToObject(fnRaw)
675
+ );
676
+ return {
677
+ libraryName: lib.library_name,
678
+ engine: lib.engine,
679
+ functions: functionsParsed.map((fn) => ({
680
+ name: fn.name,
681
+ description: fn.description ?? void 0,
682
+ flags: fn.flags
683
+ })),
684
+ libraryCode: lib.library_code
685
+ };
686
+ });
687
+ }
688
+
689
+ // pkg/commands/function_load.ts
690
+ var FunctionLoadCommand = class extends Command {
691
+ constructor([args], opts) {
692
+ super(["function", "load", ...args.replace ? ["replace"] : [], args.code], opts);
693
+ }
694
+ };
695
+
696
+ // pkg/commands/function_stats.ts
697
+ var FunctionStatsCommand = class extends Command {
698
+ constructor(opts) {
699
+ super(["function", "stats"], { deserialize: deserialize3, ...opts });
700
+ }
701
+ };
702
+ function deserialize3(result) {
703
+ const rawEngines = kvArrayToObject(kvArrayToObject(result).engines);
704
+ const parsedEngines = Object.fromEntries(
705
+ Object.entries(rawEngines).map(([key, value]) => [key, kvArrayToObject(value)])
706
+ );
707
+ const final = {
708
+ engines: Object.fromEntries(
709
+ Object.entries(parsedEngines).map(([key, value]) => [
710
+ key,
711
+ {
712
+ librariesCount: value.libraries_count,
713
+ functionsCount: value.functions_count
714
+ }
715
+ ])
716
+ )
717
+ };
718
+ return final;
719
+ }
720
+
958
721
  // pkg/commands/geo_add.ts
959
722
  var GeoAddCommand = class extends Command {
960
723
  constructor([key, arg1, ...arg2], opts) {
@@ -1301,7 +1064,7 @@ var HGetCommand = class extends Command {
1301
1064
  };
1302
1065
 
1303
1066
  // pkg/commands/hgetall.ts
1304
- function deserialize2(result) {
1067
+ function deserialize4(result) {
1305
1068
  if (result.length === 0) {
1306
1069
  return null;
1307
1070
  }
@@ -1321,7 +1084,7 @@ function deserialize2(result) {
1321
1084
  var HGetAllCommand = class extends Command {
1322
1085
  constructor(cmd, opts) {
1323
1086
  super(["hgetall", ...cmd], {
1324
- deserialize: (result) => deserialize2(result),
1087
+ deserialize: (result) => deserialize4(result),
1325
1088
  ...opts
1326
1089
  });
1327
1090
  }
@@ -1356,7 +1119,7 @@ var HLenCommand = class extends Command {
1356
1119
  };
1357
1120
 
1358
1121
  // pkg/commands/hmget.ts
1359
- function deserialize3(fields, result) {
1122
+ function deserialize5(fields, result) {
1360
1123
  if (result.every((field) => field === null)) {
1361
1124
  return null;
1362
1125
  }
@@ -1373,7 +1136,7 @@ function deserialize3(fields, result) {
1373
1136
  var HMGetCommand = class extends Command {
1374
1137
  constructor([key, ...fields], opts) {
1375
1138
  super(["hmget", key, ...fields], {
1376
- deserialize: (result) => deserialize3(fields, result),
1139
+ deserialize: (result) => deserialize5(fields, result),
1377
1140
  ...opts
1378
1141
  });
1379
1142
  }
@@ -2350,7 +2113,7 @@ var XPendingCommand = class extends Command {
2350
2113
  };
2351
2114
 
2352
2115
  // pkg/commands/xrange.ts
2353
- function deserialize4(result) {
2116
+ function deserialize6(result) {
2354
2117
  const obj = {};
2355
2118
  for (const e of result) {
2356
2119
  for (let i = 0; i < e.length; i += 2) {
@@ -2379,7 +2142,7 @@ var XRangeCommand = class extends Command {
2379
2142
  command.push("COUNT", count);
2380
2143
  }
2381
2144
  super(command, {
2382
- deserialize: (result) => deserialize4(result),
2145
+ deserialize: (result) => deserialize6(result),
2383
2146
  ...opts
2384
2147
  });
2385
2148
  }
@@ -2442,12 +2205,12 @@ var XRevRangeCommand = class extends Command {
2442
2205
  command.push("COUNT", count);
2443
2206
  }
2444
2207
  super(command, {
2445
- deserialize: (result) => deserialize5(result),
2208
+ deserialize: (result) => deserialize7(result),
2446
2209
  ...opts
2447
2210
  });
2448
2211
  }
2449
2212
  };
2450
- function deserialize5(result) {
2213
+ function deserialize7(result) {
2451
2214
  const obj = {};
2452
2215
  for (const e of result) {
2453
2216
  for (let i = 0; i < e.length; i += 2) {
@@ -3104,7 +2867,7 @@ var Pipeline = class {
3104
2867
  /**
3105
2868
  * @see https://redis.io/commands/lset
3106
2869
  */
3107
- lset = (key, index2, value) => this.chain(new LSetCommand([key, index2, value], this.commandOptions));
2870
+ lset = (key, index, value) => this.chain(new LSetCommand([key, index, value], this.commandOptions));
3108
2871
  /**
3109
2872
  * @see https://redis.io/commands/ltrim
3110
2873
  */
@@ -3556,6 +3319,38 @@ var Pipeline = class {
3556
3319
  type: (...args) => this.chain(new JsonTypeCommand(args, this.commandOptions))
3557
3320
  };
3558
3321
  }
3322
+ get functions() {
3323
+ return {
3324
+ /**
3325
+ * @see https://redis.io/docs/latest/commands/function-load/
3326
+ */
3327
+ load: (...args) => this.chain(new FunctionLoadCommand(args, this.commandOptions)),
3328
+ /**
3329
+ * @see https://redis.io/docs/latest/commands/function-list/
3330
+ */
3331
+ list: (...args) => this.chain(new FunctionListCommand(args, this.commandOptions)),
3332
+ /**
3333
+ * @see https://redis.io/docs/latest/commands/function-delete/
3334
+ */
3335
+ delete: (...args) => this.chain(new FunctionDeleteCommand(args, this.commandOptions)),
3336
+ /**
3337
+ * @see https://redis.io/docs/latest/commands/function-flush/
3338
+ */
3339
+ flush: () => this.chain(new FunctionFlushCommand(this.commandOptions)),
3340
+ /**
3341
+ * @see https://redis.io/docs/latest/commands/function-stats/
3342
+ */
3343
+ stats: () => this.chain(new FunctionStatsCommand(this.commandOptions)),
3344
+ /**
3345
+ * @see https://redis.io/docs/latest/commands/fcall/
3346
+ */
3347
+ call: (...args) => this.chain(new FCallCommand(args, this.commandOptions)),
3348
+ /**
3349
+ * @see https://redis.io/docs/latest/commands/fcall_ro/
3350
+ */
3351
+ callRo: (...args) => this.chain(new FCallRoCommand(args, this.commandOptions))
3352
+ };
3353
+ }
3559
3354
  };
3560
3355
 
3561
3356
  // pkg/auto-pipeline.ts
@@ -3577,7 +3372,7 @@ var EXCLUDE_COMMANDS = /* @__PURE__ */ new Set([
3577
3372
  "zrange",
3578
3373
  "exec"
3579
3374
  ]);
3580
- function createAutoPipelineProxy(_redis, json) {
3375
+ function createAutoPipelineProxy(_redis, namespace = "root") {
3581
3376
  const redis = _redis;
3582
3377
  if (!redis.autoPipelineExecutor) {
3583
3378
  redis.autoPipelineExecutor = new AutoPipelineExecutor(redis);
@@ -3587,29 +3382,31 @@ function createAutoPipelineProxy(_redis, json) {
3587
3382
  if (command === "pipelineCounter") {
3588
3383
  return redis2.autoPipelineExecutor.pipelineCounter;
3589
3384
  }
3590
- if (command === "json") {
3591
- return createAutoPipelineProxy(redis2, true);
3385
+ if (namespace === "root" && command === "json") {
3386
+ return createAutoPipelineProxy(redis2, "json");
3592
3387
  }
3593
- const commandInRedisButNotPipeline = command in redis2 && !(command in redis2.autoPipelineExecutor.pipeline);
3594
- const isCommandExcluded = EXCLUDE_COMMANDS.has(command);
3595
- if (commandInRedisButNotPipeline || isCommandExcluded) {
3596
- return redis2[command];
3388
+ if (namespace === "root" && command === "functions") {
3389
+ return createAutoPipelineProxy(redis2, "functions");
3597
3390
  }
3598
- const isFunction = json ? typeof redis2.autoPipelineExecutor.pipeline.json[command] === "function" : typeof redis2.autoPipelineExecutor.pipeline[command] === "function";
3391
+ if (namespace === "root") {
3392
+ const commandInRedisButNotPipeline = command in redis2 && !(command in redis2.autoPipelineExecutor.pipeline);
3393
+ const isCommandExcluded = EXCLUDE_COMMANDS.has(command);
3394
+ if (commandInRedisButNotPipeline || isCommandExcluded) {
3395
+ return redis2[command];
3396
+ }
3397
+ }
3398
+ const pipeline = redis2.autoPipelineExecutor.pipeline;
3399
+ const targetFunction = namespace === "json" ? pipeline.json[command] : namespace === "functions" ? pipeline.functions[command] : pipeline[command];
3400
+ const isFunction = typeof targetFunction === "function";
3599
3401
  if (isFunction) {
3600
3402
  return (...args) => {
3601
- return redis2.autoPipelineExecutor.withAutoPipeline((pipeline) => {
3602
- if (json) {
3603
- pipeline.json[command](
3604
- ...args
3605
- );
3606
- } else {
3607
- pipeline[command](...args);
3608
- }
3403
+ return redis2.autoPipelineExecutor.withAutoPipeline((pipeline2) => {
3404
+ const targetFunction2 = namespace === "json" ? pipeline2.json[command] : namespace === "functions" ? pipeline2.functions[command] : pipeline2[command];
3405
+ targetFunction2(...args);
3609
3406
  });
3610
3407
  };
3611
3408
  }
3612
- return redis2.autoPipelineExecutor.pipeline[command];
3409
+ return targetFunction;
3613
3410
  }
3614
3411
  });
3615
3412
  }
@@ -3632,7 +3429,7 @@ var AutoPipelineExecutor = class {
3632
3429
  this.activePipeline = pipeline;
3633
3430
  this.indexInCurrentPipeline = 0;
3634
3431
  }
3635
- const index2 = this.indexInCurrentPipeline++;
3432
+ const index = this.indexInCurrentPipeline++;
3636
3433
  executeWithPipeline(pipeline);
3637
3434
  const pipelineDone = this.deferExecution().then(() => {
3638
3435
  if (!this.pipelinePromises.has(pipeline)) {
@@ -3644,7 +3441,7 @@ var AutoPipelineExecutor = class {
3644
3441
  return this.pipelinePromises.get(pipeline);
3645
3442
  });
3646
3443
  const results = await pipelineDone;
3647
- const commandResult = results[index2];
3444
+ const commandResult = results[index];
3648
3445
  if (commandResult.error) {
3649
3446
  throw new UpstashError(`Command failed: ${commandResult.error}`);
3650
3447
  }
@@ -3901,8 +3698,8 @@ var Script = class {
3901
3698
  /**
3902
3699
  * Compute the sha1 hash of the script and return its hex representation.
3903
3700
  */
3904
- async digest(s2) {
3905
- const data = new TextEncoder().encode(s2);
3701
+ async digest(s) {
3702
+ const data = new TextEncoder().encode(s);
3906
3703
  const hashBuffer = await subtle.digest("SHA-1", data);
3907
3704
  const hashArray = [...new Uint8Array(hashBuffer)];
3908
3705
  return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
@@ -3965,8 +3762,8 @@ var ScriptRO = class {
3965
3762
  /**
3966
3763
  * Compute the sha1 hash of the script and return its hex representation.
3967
3764
  */
3968
- async digest(s2) {
3969
- const data = new TextEncoder().encode(s2);
3765
+ async digest(s) {
3766
+ const data = new TextEncoder().encode(s);
3970
3767
  const hashBuffer = await subtle2.digest("SHA-1", data);
3971
3768
  const hashArray = [...new Uint8Array(hashBuffer)];
3972
3769
  return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
@@ -4101,6 +3898,40 @@ var Redis = class {
4101
3898
  type: (...args) => new JsonTypeCommand(args, this.opts).exec(this.client)
4102
3899
  };
4103
3900
  }
3901
+ get functions() {
3902
+ return {
3903
+ /**
3904
+ * @see https://redis.io/docs/latest/commands/function-load/
3905
+ */
3906
+ load: (...args) => new FunctionLoadCommand(args, this.opts).exec(this.client),
3907
+ /**
3908
+ * @see https://redis.io/docs/latest/commands/function-list/
3909
+ */
3910
+ list: (...args) => new FunctionListCommand(args, this.opts).exec(this.client),
3911
+ /**
3912
+ * @see https://redis.io/docs/latest/commands/function-delete/
3913
+ */
3914
+ delete: (...args) => new FunctionDeleteCommand(args, this.opts).exec(this.client),
3915
+ /**
3916
+ * @see https://redis.io/docs/latest/commands/function-flush/
3917
+ */
3918
+ flush: () => new FunctionFlushCommand(this.opts).exec(this.client),
3919
+ /**
3920
+ * @see https://redis.io/docs/latest/commands/function-stats/
3921
+ *
3922
+ * Note: `running_script` field is not supported and therefore not included in the type.
3923
+ */
3924
+ stats: () => new FunctionStatsCommand(this.opts).exec(this.client),
3925
+ /**
3926
+ * @see https://redis.io/docs/latest/commands/fcall/
3927
+ */
3928
+ call: (...args) => new FCallCommand(args, this.opts).exec(this.client),
3929
+ /**
3930
+ * @see https://redis.io/docs/latest/commands/fcall_ro/
3931
+ */
3932
+ callRo: (...args) => new FCallRoCommand(args, this.opts).exec(this.client)
3933
+ };
3934
+ }
4104
3935
  /**
4105
3936
  * Wrap a new middleware around the HTTP client.
4106
3937
  */
@@ -4151,19 +3982,6 @@ var Redis = class {
4151
3982
  createScript(script, opts) {
4152
3983
  return opts?.readonly ? new ScriptRO(this, script) : new Script(this, script);
4153
3984
  }
4154
- get search() {
4155
- return {
4156
- createIndex: (props) => {
4157
- return createIndex({
4158
- ...props,
4159
- client: this.client
4160
- });
4161
- },
4162
- index: (name, schema) => {
4163
- return index(this.client, name, schema);
4164
- }
4165
- };
4166
- }
4167
3985
  /**
4168
3986
  * Create a new pipeline that allows you to send requests in bulk.
4169
3987
  *
@@ -4500,7 +4318,7 @@ var Redis = class {
4500
4318
  /**
4501
4319
  * @see https://redis.io/commands/lset
4502
4320
  */
4503
- lset = (key, index2, value) => new LSetCommand([key, index2, value], this.opts).exec(this.client);
4321
+ lset = (key, index, value) => new LSetCommand([key, index, value], this.opts).exec(this.client);
4504
4322
  /**
4505
4323
  * @see https://redis.io/commands/ltrim
4506
4324
  */
@@ -4871,14 +4689,11 @@ var Redis = class {
4871
4689
  };
4872
4690
 
4873
4691
  // version.ts
4874
- var VERSION = "v1.36.0-rc.7";
4692
+ var VERSION = "v1.36.1";
4875
4693
 
4876
4694
  export {
4877
4695
  error_exports,
4878
4696
  HttpClient,
4879
- createIndex,
4880
- index,
4881
- s,
4882
4697
  Redis,
4883
4698
  VERSION
4884
4699
  };