@upstash/redis 1.7.0 → 1.9.0-next.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.
@@ -0,0 +1,19 @@
1
+ import { Command } from "./command.js";
2
+ /**
3
+ * @see https://redis.io/commands/lpos
4
+ */
5
+ export class LPosCommand extends Command {
6
+ constructor(cmd, opts) {
7
+ const args = ["lpos", cmd[0], cmd[1]];
8
+ if (typeof cmd[2]?.rank === "number") {
9
+ args.push("rank", cmd[2].rank);
10
+ }
11
+ if (typeof cmd[2]?.count === "number") {
12
+ args.push("count", cmd[2].count);
13
+ }
14
+ if (typeof cmd[2]?.maxLen === "number") {
15
+ args.push("maxLen", cmd[2].maxLen);
16
+ }
17
+ super(args, opts);
18
+ }
19
+ }
@@ -42,6 +42,7 @@ export * from "./lindex.js";
42
42
  export * from "./linsert.js";
43
43
  export * from "./llen.js";
44
44
  export * from "./lpop.js";
45
+ export * from "./lpos.js";
45
46
  export * from "./lpush.js";
46
47
  export * from "./lpushx.js";
47
48
  export * from "./lrange.js";
@@ -1,4 +1,4 @@
1
- import { AppendCommand, BitCountCommand, BitOpCommand, BitPosCommand, DBSizeCommand, DecrByCommand, DecrCommand, DelCommand, EchoCommand, EvalCommand, EvalshaCommand, ExistsCommand, ExpireAtCommand, ExpireCommand, FlushAllCommand, FlushDBCommand, GetBitCommand, GetCommand, GetRangeCommand, GetSetCommand, HDelCommand, HExistsCommand, HGetAllCommand, HGetCommand, HIncrByCommand, HIncrByFloatCommand, HKeysCommand, HLenCommand, HMGetCommand, HMSetCommand, HScanCommand, HSetCommand, HSetNXCommand, HStrLenCommand, HValsCommand, IncrByCommand, IncrByFloatCommand, IncrCommand, KeysCommand, LIndexCommand, LInsertCommand, LLenCommand, LPopCommand, LPushCommand, LPushXCommand, LRangeCommand, LRemCommand, LSetCommand, LTrimCommand, MGetCommand, MSetCommand, MSetNXCommand, PersistCommand, PExpireAtCommand, PExpireCommand, PingCommand, PSetEXCommand, PTtlCommand, PublishCommand, RandomKeyCommand, RenameCommand, RenameNXCommand, RPopCommand, RPushCommand, RPushXCommand, SAddCommand, ScanCommand, SCardCommand, ScriptExistsCommand, ScriptFlushCommand, ScriptLoadCommand, SDiffCommand, SDiffStoreCommand, SetBitCommand, SetCommand, SetExCommand, SetNxCommand, SetRangeCommand, SInterCommand, SInterStoreCommand, SIsMemberCommand, SMembersCommand, SMoveCommand, SPopCommand, SRandMemberCommand, SRemCommand, SScanCommand, StrLenCommand, SUnionCommand, SUnionStoreCommand, TimeCommand, TouchCommand, TtlCommand, TypeCommand, UnlinkCommand, ZAddCommand, ZCardCommand, ZCountCommand, ZIncrByCommand, ZInterStoreCommand, ZLexCountCommand, ZPopMaxCommand, ZPopMinCommand, ZRangeCommand, ZRankCommand, ZRemCommand, ZRemRangeByLexCommand, ZRemRangeByRankCommand, ZRemRangeByScoreCommand, ZRevRankCommand, ZScanCommand, ZScoreCommand, ZUnionStoreCommand, } from "./commands/mod.js";
1
+ import { AppendCommand, BitCountCommand, BitOpCommand, BitPosCommand, DBSizeCommand, DecrByCommand, DecrCommand, DelCommand, EchoCommand, EvalCommand, EvalshaCommand, ExistsCommand, ExpireAtCommand, ExpireCommand, FlushAllCommand, FlushDBCommand, GetBitCommand, GetCommand, GetRangeCommand, GetSetCommand, HDelCommand, HExistsCommand, HGetAllCommand, HGetCommand, HIncrByCommand, HIncrByFloatCommand, HKeysCommand, HLenCommand, HMGetCommand, HMSetCommand, HScanCommand, HSetCommand, HSetNXCommand, HStrLenCommand, HValsCommand, IncrByCommand, IncrByFloatCommand, IncrCommand, KeysCommand, LIndexCommand, LInsertCommand, LLenCommand, LPopCommand, LPosCommand, LPushCommand, LPushXCommand, LRangeCommand, LRemCommand, LSetCommand, LTrimCommand, MGetCommand, MSetCommand, MSetNXCommand, PersistCommand, PExpireAtCommand, PExpireCommand, PingCommand, PSetEXCommand, PTtlCommand, PublishCommand, RandomKeyCommand, RenameCommand, RenameNXCommand, RPopCommand, RPushCommand, RPushXCommand, SAddCommand, ScanCommand, SCardCommand, ScriptExistsCommand, ScriptFlushCommand, ScriptLoadCommand, SDiffCommand, SDiffStoreCommand, SetBitCommand, SetCommand, SetExCommand, SetNxCommand, SetRangeCommand, SInterCommand, SInterStoreCommand, SIsMemberCommand, SMembersCommand, SMoveCommand, SPopCommand, SRandMemberCommand, SRemCommand, SScanCommand, StrLenCommand, SUnionCommand, SUnionStoreCommand, TimeCommand, TouchCommand, TtlCommand, TypeCommand, UnlinkCommand, ZAddCommand, ZCardCommand, ZCountCommand, ZIncrByCommand, ZInterStoreCommand, ZLexCountCommand, ZPopMaxCommand, ZPopMinCommand, ZRangeCommand, ZRankCommand, ZRemCommand, ZRemRangeByLexCommand, ZRemRangeByRankCommand, ZRemRangeByScoreCommand, ZRevRankCommand, ZScanCommand, ZScoreCommand, ZUnionStoreCommand, } from "./commands/mod.js";
2
2
  import { UpstashError } from "./error.js";
3
3
  /**
4
4
  * Upstash REST API supports command pipelining to send multiple commands in
@@ -475,6 +475,15 @@ export class Pipeline {
475
475
  writable: true,
476
476
  value: (...args) => this.chain(new LPopCommand(args, this.commandOptions))
477
477
  });
478
+ /**
479
+ * @see https://redis.io/commands/lpos
480
+ */
481
+ Object.defineProperty(this, "lpos", {
482
+ enumerable: true,
483
+ configurable: true,
484
+ writable: true,
485
+ value: (...args) => this.chain(new LPosCommand(args, this.commandOptions))
486
+ });
478
487
  /**
479
488
  * @see https://redis.io/commands/lpush
480
489
  */
package/esm/pkg/redis.js CHANGED
@@ -1,4 +1,4 @@
1
- import { AppendCommand, BitCountCommand, BitOpCommand, BitPosCommand, DBSizeCommand, DecrByCommand, DecrCommand, DelCommand, EchoCommand, EvalCommand, EvalshaCommand, ExistsCommand, ExpireAtCommand, ExpireCommand, FlushAllCommand, FlushDBCommand, GetBitCommand, GetCommand, GetRangeCommand, GetSetCommand, HDelCommand, HExistsCommand, HGetAllCommand, HGetCommand, HIncrByCommand, HIncrByFloatCommand, HKeysCommand, HLenCommand, HMGetCommand, HMSetCommand, HScanCommand, HSetCommand, HSetNXCommand, HStrLenCommand, HValsCommand, IncrByCommand, IncrByFloatCommand, IncrCommand, KeysCommand, LIndexCommand, LInsertCommand, LLenCommand, LPopCommand, LPushCommand, LPushXCommand, LRangeCommand, LRemCommand, LSetCommand, LTrimCommand, MGetCommand, MSetCommand, MSetNXCommand, PersistCommand, PExpireAtCommand, PExpireCommand, PingCommand, PSetEXCommand, PTtlCommand, PublishCommand, RandomKeyCommand, RenameCommand, RenameNXCommand, RPopCommand, RPushCommand, RPushXCommand, SAddCommand, ScanCommand, SCardCommand, ScriptExistsCommand, ScriptFlushCommand, ScriptLoadCommand, SDiffCommand, SDiffStoreCommand, SetBitCommand, SetCommand, SetExCommand, SetNxCommand, SetRangeCommand, SInterCommand, SInterStoreCommand, SIsMemberCommand, SMembersCommand, SMoveCommand, SPopCommand, SRandMemberCommand, SRemCommand, SScanCommand, StrLenCommand, SUnionCommand, SUnionStoreCommand, TimeCommand, TouchCommand, TtlCommand, TypeCommand, UnlinkCommand, ZAddCommand, ZCardCommand, ZCountCommand, ZIncrByCommand, ZInterStoreCommand, ZLexCountCommand, ZPopMaxCommand, ZPopMinCommand, ZRangeCommand, ZRankCommand, ZRemCommand, ZRemRangeByLexCommand, ZRemRangeByRankCommand, ZRemRangeByScoreCommand, ZRevRankCommand, ZScanCommand, ZScoreCommand, ZUnionStoreCommand, } from "./commands/mod.js";
1
+ import { AppendCommand, BitCountCommand, BitOpCommand, BitPosCommand, DBSizeCommand, DecrByCommand, DecrCommand, DelCommand, EchoCommand, EvalCommand, EvalshaCommand, ExistsCommand, ExpireAtCommand, ExpireCommand, FlushAllCommand, FlushDBCommand, GetBitCommand, GetCommand, GetRangeCommand, GetSetCommand, HDelCommand, HExistsCommand, HGetAllCommand, HGetCommand, HIncrByCommand, HIncrByFloatCommand, HKeysCommand, HLenCommand, HMGetCommand, HMSetCommand, HScanCommand, HSetCommand, HSetNXCommand, HStrLenCommand, HValsCommand, IncrByCommand, IncrByFloatCommand, IncrCommand, KeysCommand, LIndexCommand, LInsertCommand, LLenCommand, LPopCommand, LPosCommand, LPushCommand, LPushXCommand, LRangeCommand, LRemCommand, LSetCommand, LTrimCommand, MGetCommand, MSetCommand, MSetNXCommand, PersistCommand, PExpireAtCommand, PExpireCommand, PingCommand, PSetEXCommand, PTtlCommand, PublishCommand, RandomKeyCommand, RenameCommand, RenameNXCommand, RPopCommand, RPushCommand, RPushXCommand, SAddCommand, ScanCommand, SCardCommand, ScriptExistsCommand, ScriptFlushCommand, ScriptLoadCommand, SDiffCommand, SDiffStoreCommand, SetBitCommand, SetCommand, SetExCommand, SetNxCommand, SetRangeCommand, SInterCommand, SInterStoreCommand, SIsMemberCommand, SMembersCommand, SMoveCommand, SPopCommand, SRandMemberCommand, SRemCommand, SScanCommand, StrLenCommand, SUnionCommand, SUnionStoreCommand, TimeCommand, TouchCommand, TtlCommand, TypeCommand, UnlinkCommand, ZAddCommand, ZCardCommand, ZCountCommand, ZIncrByCommand, ZInterStoreCommand, ZLexCountCommand, ZPopMaxCommand, ZPopMinCommand, ZRangeCommand, ZRankCommand, ZRemCommand, ZRemRangeByLexCommand, ZRemRangeByRankCommand, ZRemRangeByScoreCommand, ZRevRankCommand, ZScanCommand, ZScoreCommand, ZUnionStoreCommand, } from "./commands/mod.js";
2
2
  import { Pipeline } from "./pipeline.js";
3
3
  /**
4
4
  * Serverless redis client for upstash.
@@ -426,6 +426,15 @@ export class Redis {
426
426
  writable: true,
427
427
  value: (...args) => new LPopCommand(args, this.opts).exec(this.client)
428
428
  });
429
+ /**
430
+ * @see https://redis.io/commands/lpos
431
+ */
432
+ Object.defineProperty(this, "lpos", {
433
+ enumerable: true,
434
+ configurable: true,
435
+ writable: true,
436
+ value: (...args) => new LPosCommand(args, this.opts).exec(this.client)
437
+ });
429
438
  /**
430
439
  * @see https://redis.io/commands/lpush
431
440
  */
package/package.json CHANGED
@@ -3,7 +3,6 @@
3
3
  "main": "./script/platforms/nodejs.js",
4
4
  "types": "./types/platforms/nodejs.d.ts",
5
5
  "name": "@upstash/redis",
6
- "version": "v1.7.0",
7
6
  "description": "An HTTP/REST based Redis client built on top of Upstash REST API.",
8
7
  "repository": {
9
8
  "type": "git",
@@ -97,5 +96,6 @@
97
96
  "require": "./script/platforms/node_with_fetch.js",
98
97
  "types": "./types/platforms/node_with_fetch.d.ts"
99
98
  }
100
- }
99
+ },
100
+ "version": "1.9.0-next.1"
101
101
  }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LPosCommand = void 0;
4
+ const command_js_1 = require("./command.js");
5
+ /**
6
+ * @see https://redis.io/commands/lpos
7
+ */
8
+ class LPosCommand extends command_js_1.Command {
9
+ constructor(cmd, opts) {
10
+ const args = ["lpos", cmd[0], cmd[1]];
11
+ if (typeof cmd[2]?.rank === "number") {
12
+ args.push("rank", cmd[2].rank);
13
+ }
14
+ if (typeof cmd[2]?.count === "number") {
15
+ args.push("count", cmd[2].count);
16
+ }
17
+ if (typeof cmd[2]?.maxLen === "number") {
18
+ args.push("maxLen", cmd[2].maxLen);
19
+ }
20
+ super(args, opts);
21
+ }
22
+ }
23
+ exports.LPosCommand = LPosCommand;
@@ -58,6 +58,7 @@ __exportStar(require("./lindex.js"), exports);
58
58
  __exportStar(require("./linsert.js"), exports);
59
59
  __exportStar(require("./llen.js"), exports);
60
60
  __exportStar(require("./lpop.js"), exports);
61
+ __exportStar(require("./lpos.js"), exports);
61
62
  __exportStar(require("./lpush.js"), exports);
62
63
  __exportStar(require("./lpushx.js"), exports);
63
64
  __exportStar(require("./lrange.js"), exports);
@@ -478,6 +478,15 @@ class Pipeline {
478
478
  writable: true,
479
479
  value: (...args) => this.chain(new mod_js_1.LPopCommand(args, this.commandOptions))
480
480
  });
481
+ /**
482
+ * @see https://redis.io/commands/lpos
483
+ */
484
+ Object.defineProperty(this, "lpos", {
485
+ enumerable: true,
486
+ configurable: true,
487
+ writable: true,
488
+ value: (...args) => this.chain(new mod_js_1.LPosCommand(args, this.commandOptions))
489
+ });
481
490
  /**
482
491
  * @see https://redis.io/commands/lpush
483
492
  */
@@ -429,6 +429,15 @@ class Redis {
429
429
  writable: true,
430
430
  value: (...args) => new mod_js_1.LPopCommand(args, this.opts).exec(this.client)
431
431
  });
432
+ /**
433
+ * @see https://redis.io/commands/lpos
434
+ */
435
+ Object.defineProperty(this, "lpos", {
436
+ enumerable: true,
437
+ configurable: true,
438
+ writable: true,
439
+ value: (...args) => new mod_js_1.LPosCommand(args, this.opts).exec(this.client)
440
+ });
432
441
  /**
433
442
  * @see https://redis.io/commands/lpush
434
443
  */
@@ -3,5 +3,5 @@ import { Command, CommandOptions } from "./command.js";
3
3
  * @see https://redis.io/commands/bitpos
4
4
  */
5
5
  export declare class BitPosCommand extends Command<number, number> {
6
- constructor(cmd: [key: string, start: number, end: number], opts?: CommandOptions<number, number>);
6
+ constructor(cmd: [key: string, bit: 0 | 1, start?: number, end?: number], opts?: CommandOptions<number, number>);
7
7
  }
@@ -3,5 +3,5 @@ import { Command, CommandOptions } from "./command.js";
3
3
  * @see https://redis.io/commands/lpop
4
4
  */
5
5
  export declare class LPopCommand<TData = string> extends Command<unknown | null, TData | null> {
6
- constructor(cmd: [key: string], opts?: CommandOptions<unknown | null, TData | null>);
6
+ constructor(cmd: [key: string, count?: number], opts?: CommandOptions<unknown | null, TData | null>);
7
7
  }
@@ -0,0 +1,15 @@
1
+ import { Command, CommandOptions } from "./command.js";
2
+ /**
3
+ * @see https://redis.io/commands/lpos
4
+ */
5
+ export declare class LPosCommand<TData = number> extends Command<TData, TData> {
6
+ constructor(cmd: [
7
+ key: string,
8
+ element: unknown,
9
+ opts?: {
10
+ rank?: number;
11
+ count?: number;
12
+ maxLen?: number;
13
+ }
14
+ ], opts?: CommandOptions<TData, TData>);
15
+ }
@@ -42,6 +42,7 @@ export * from "./lindex.js";
42
42
  export * from "./linsert.js";
43
43
  export * from "./llen.js";
44
44
  export * from "./lpop.js";
45
+ export * from "./lpos.js";
45
46
  export * from "./lpush.js";
46
47
  export * from "./lpushx.js";
47
48
  export * from "./lrange.js";
@@ -2,6 +2,6 @@ import { Command, CommandOptions } from "./command.js";
2
2
  /**
3
3
  * @see https://redis.io/commands/rpop
4
4
  */
5
- export declare class RPopCommand<TData = string> extends Command<unknown | null, TData | null> {
6
- constructor(cmd: [key: string], opts?: CommandOptions<unknown | null, TData | null>);
5
+ export declare class RPopCommand<TData extends unknown | unknown[] = string> extends Command<unknown | null, TData | null> {
6
+ constructor(cmd: [key: string, count?: number], opts?: CommandOptions<unknown | null, TData | null>);
7
7
  }
@@ -79,7 +79,7 @@ export declare class Pipeline {
79
79
  /**
80
80
  * @see https://redis.io/commands/bitpos
81
81
  */
82
- bitpos: (key: string, start: number, end: number) => this;
82
+ bitpos: (key: string, bit: 0 | 1, start?: number | undefined, end?: number | undefined) => this;
83
83
  /**
84
84
  * @see https://redis.io/commands/dbsize
85
85
  */
@@ -241,7 +241,15 @@ export declare class Pipeline {
241
241
  /**
242
242
  * @see https://redis.io/commands/lpop
243
243
  */
244
- lpop: <TData>(key: string) => this;
244
+ lpop: <TData>(key: string, count?: number | undefined) => this;
245
+ /**
246
+ * @see https://redis.io/commands/lpos
247
+ */
248
+ lpos: <TData>(key: string, element: unknown, opts?: {
249
+ rank?: number | undefined;
250
+ count?: number | undefined;
251
+ maxLen?: number | undefined;
252
+ } | undefined) => this;
245
253
  /**
246
254
  * @see https://redis.io/commands/lpush
247
255
  */
@@ -325,7 +333,7 @@ export declare class Pipeline {
325
333
  /**
326
334
  * @see https://redis.io/commands/rpop
327
335
  */
328
- rpop: <TData = string>(key: string) => this;
336
+ rpop: <TData = string>(key: string, count?: number | undefined) => this;
329
337
  /**
330
338
  * @see https://redis.io/commands/rpush
331
339
  */
@@ -52,7 +52,7 @@ export declare class Redis {
52
52
  /**
53
53
  * @see https://redis.io/commands/bitpos
54
54
  */
55
- bitpos: (key: string, start: number, end: number) => Promise<number>;
55
+ bitpos: (key: string, bit: 0 | 1, start?: number | undefined, end?: number | undefined) => Promise<number>;
56
56
  /**
57
57
  * @see https://redis.io/commands/dbsize
58
58
  */
@@ -214,7 +214,15 @@ export declare class Redis {
214
214
  /**
215
215
  * @see https://redis.io/commands/lpop
216
216
  */
217
- lpop: <TData>(key: string) => Promise<TData | null>;
217
+ lpop: <TData>(key: string, count?: number | undefined) => Promise<TData | null>;
218
+ /**
219
+ * @see https://redis.io/commands/lpos
220
+ */
221
+ lpos: <TData = number>(key: string, element: unknown, opts?: {
222
+ rank?: number | undefined;
223
+ count?: number | undefined;
224
+ maxLen?: number | undefined;
225
+ } | undefined) => Promise<TData>;
218
226
  /**
219
227
  * @see https://redis.io/commands/lpush
220
228
  */
@@ -298,7 +306,7 @@ export declare class Redis {
298
306
  /**
299
307
  * @see https://redis.io/commands/rpop
300
308
  */
301
- rpop: <TData = string>(key: string) => Promise<TData | null>;
309
+ rpop: <TData = string>(key: string, count?: number | undefined) => Promise<TData | null>;
302
310
  /**
303
311
  * @see https://redis.io/commands/rpush
304
312
  */