@upstash/redis 1.10.1 → 1.11.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.
@@ -6,17 +6,29 @@ export class SetCommand extends Command {
6
6
  constructor([key, value, opts], cmdOpts) {
7
7
  const command = ["set", key, value];
8
8
  if (opts) {
9
+ if ("nx" in opts && opts.nx) {
10
+ command.push("nx");
11
+ }
12
+ else if ("xx" in opts && opts.xx) {
13
+ command.push("xx");
14
+ }
15
+ if ("get" in opts && opts.get) {
16
+ command.push("get");
17
+ }
9
18
  if ("ex" in opts && typeof opts.ex === "number") {
10
19
  command.push("ex", opts.ex);
11
20
  }
12
21
  else if ("px" in opts && typeof opts.px === "number") {
13
22
  command.push("px", opts.px);
14
23
  }
15
- if ("nx" in opts && opts.nx) {
16
- command.push("nx");
24
+ else if ("exat" in opts && typeof opts.exat === "number") {
25
+ command.push("exat", opts.exat);
17
26
  }
18
- else if ("xx" in opts && opts.xx) {
19
- command.push("xx");
27
+ else if ("pxat" in opts && typeof opts.pxat === "number") {
28
+ command.push("pxat", opts.pxat);
29
+ }
30
+ else if ("keepTtl" in opts && opts.keepTtl) {
31
+ command.push("keepTtl", opts.keepTtl);
20
32
  }
21
33
  }
22
34
  super(command, cmdOpts);
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "main": "./script/platforms/nodejs.js",
4
4
  "types": "./types/platforms/nodejs.d.ts",
5
5
  "name": "@upstash/redis",
6
- "version": "v1.10.1",
6
+ "version": "v1.11.0",
7
7
  "description": "An HTTP/REST based Redis client built on top of Upstash REST API.",
8
8
  "repository": {
9
9
  "type": "git",
@@ -9,17 +9,29 @@ class SetCommand extends command_js_1.Command {
9
9
  constructor([key, value, opts], cmdOpts) {
10
10
  const command = ["set", key, value];
11
11
  if (opts) {
12
+ if ("nx" in opts && opts.nx) {
13
+ command.push("nx");
14
+ }
15
+ else if ("xx" in opts && opts.xx) {
16
+ command.push("xx");
17
+ }
18
+ if ("get" in opts && opts.get) {
19
+ command.push("get");
20
+ }
12
21
  if ("ex" in opts && typeof opts.ex === "number") {
13
22
  command.push("ex", opts.ex);
14
23
  }
15
24
  else if ("px" in opts && typeof opts.px === "number") {
16
25
  command.push("px", opts.px);
17
26
  }
18
- if ("nx" in opts && opts.nx) {
19
- command.push("nx");
27
+ else if ("exat" in opts && typeof opts.exat === "number") {
28
+ command.push("exat", opts.exat);
20
29
  }
21
- else if ("xx" in opts && opts.xx) {
22
- command.push("xx");
30
+ else if ("pxat" in opts && typeof opts.pxat === "number") {
31
+ command.push("pxat", opts.pxat);
32
+ }
33
+ else if ("keepTtl" in opts && opts.keepTtl) {
34
+ command.push("keepTtl", opts.keepTtl);
23
35
  }
24
36
  }
25
37
  super(command, cmdOpts);
@@ -6,7 +6,6 @@ export declare class BitOpCommand extends Command<number, number> {
6
6
  constructor(cmd: [
7
7
  op: "and" | "or" | "xor",
8
8
  destinationKey: string,
9
- sourceKey: string,
10
9
  ...sourceKeys: string[]
11
10
  ], opts?: CommandOptions<number, number>);
12
11
  constructor(cmd: [op: "not", destinationKey: string, sourceKey: string], opts?: CommandOptions<number, number>);
@@ -3,5 +3,5 @@ import { Command, CommandOptions } from "./command.js";
3
3
  * @see https://redis.io/commands/mget
4
4
  */
5
5
  export declare class MGetCommand<TData extends unknown[]> extends Command<(string | null)[], TData> {
6
- constructor(cmd: [...keys: [string, ...string[]]], opts?: CommandOptions<(string | null)[], TData>);
6
+ constructor(cmd: [...keys: string[]], opts?: CommandOptions<(string | null)[], TData>);
7
7
  }
@@ -1,13 +1,42 @@
1
1
  import { Command, CommandOptions } from "./command.js";
2
- export declare type SetCommandOptions = ({
2
+ export declare type SetCommandOptions = {
3
+ get: boolean;
4
+ } | ({
3
5
  ex: number;
4
6
  px?: never;
7
+ exat?: never;
8
+ pxat?: never;
9
+ keepTtl?: never;
5
10
  } | {
6
11
  ex?: never;
7
12
  px: number;
13
+ exat?: never;
14
+ pxat?: never;
15
+ keepTtl?: never;
8
16
  } | {
9
17
  ex?: never;
10
18
  px?: never;
19
+ exat: number;
20
+ pxat?: never;
21
+ keepTtl?: never;
22
+ } | {
23
+ ex?: never;
24
+ px?: never;
25
+ exat?: never;
26
+ pxat: number;
27
+ keepTtl?: never;
28
+ } | {
29
+ ex?: never;
30
+ px?: never;
31
+ exat?: never;
32
+ pxat?: never;
33
+ keepTtl: true;
34
+ } | {
35
+ ex?: never;
36
+ px?: never;
37
+ exat?: never;
38
+ pxat?: never;
39
+ keepTtl?: never;
11
40
  }) & ({
12
41
  nx: true;
13
42
  xx?: never;
@@ -21,6 +50,6 @@ export declare type SetCommandOptions = ({
21
50
  /**
22
51
  * @see https://redis.io/commands/set
23
52
  */
24
- export declare class SetCommand<TData, TResult = "OK"> extends Command<TResult, TData> {
53
+ export declare class SetCommand<TData, TResult = TData | "OK" | null> extends Command<TResult, TData | "OK" | null> {
25
54
  constructor([key, value, opts]: [key: string, value: TData, opts?: SetCommandOptions], cmdOpts?: CommandOptions<TResult, TData>);
26
55
  }
@@ -30,6 +30,6 @@ export declare class ZAddCommand<TData = string> extends Command<number | null,
30
30
  constructor(cmd: [
31
31
  key: string,
32
32
  opts: ZAddCommandOptions | ZAddCommandOptionsWithIncr,
33
- ...scoreMemberPairs: [ScoreMember<TData>, ...ScoreMember<TData>[]]
33
+ ...scoreMemberPairs: ScoreMember<TData>[]
34
34
  ], opts?: CommandOptions<number | null, number | null>);
35
35
  }
@@ -1,4 +1,4 @@
1
- import { DelCommand, ExistsCommand, FlushAllCommand, PingCommand, ScoreMember, ScriptExistsCommand, SetCommandOptions, TouchCommand, UnlinkCommand, ZAddCommandOptions, ZAddCommandOptionsWithIncr, ZRangeCommandOptions } from "./commands/mod.js";
1
+ import { DelCommand, ExistsCommand, FlushAllCommand, MGetCommand, PingCommand, ScoreMember, ScriptExistsCommand, SetCommandOptions, TouchCommand, UnlinkCommand, ZAddCommandOptions, ZAddCommandOptionsWithIncr, ZRangeCommandOptions } from "./commands/mod.js";
2
2
  import { CommandOptions } from "./commands/command.js";
3
3
  import { Requester } from "./http.js";
4
4
  import { CommandArgs } from "./types.js";
@@ -277,7 +277,7 @@ export declare class Pipeline {
277
277
  /**
278
278
  * @see https://redis.io/commands/mget
279
279
  */
280
- mget: <TData extends unknown[]>(args_0: string, ...args_1: string[]) => this;
280
+ mget: <TData extends unknown[]>(...args: CommandArgs<typeof MGetCommand>) => this;
281
281
  /**
282
282
  * @see https://redis.io/commands/mset
283
283
  */
@@ -1,4 +1,4 @@
1
- import { CommandOptions, DelCommand, ExistsCommand, FlushAllCommand, PingCommand, ScoreMember, ScriptExistsCommand, SetCommandOptions, TouchCommand, UnlinkCommand, ZAddCommandOptions, ZAddCommandOptionsWithIncr, ZRangeCommandOptions } from "./commands/mod.js";
1
+ import { CommandOptions, DelCommand, ExistsCommand, FlushAllCommand, MGetCommand, PingCommand, ScoreMember, ScriptExistsCommand, SetCommandOptions, TouchCommand, UnlinkCommand, ZAddCommandOptions, ZAddCommandOptionsWithIncr, ZRangeCommandOptions } from "./commands/mod.js";
2
2
  import { Requester, UpstashRequest, UpstashResponse } from "./http.js";
3
3
  import { Pipeline } from "./pipeline.js";
4
4
  import type { CommandArgs } from "./types.js";
@@ -254,7 +254,7 @@ export declare class Redis {
254
254
  /**
255
255
  * @see https://redis.io/commands/mget
256
256
  */
257
- mget: <TData extends unknown[]>(args_0: string, ...args_1: string[]) => Promise<TData>;
257
+ mget: <TData extends unknown[]>(...args: CommandArgs<typeof MGetCommand>) => Promise<TData>;
258
258
  /**
259
259
  * @see https://redis.io/commands/mset
260
260
  */
@@ -354,7 +354,7 @@ export declare class Redis {
354
354
  /**
355
355
  * @see https://redis.io/commands/set
356
356
  */
357
- set: <TData>(key: string, value: TData, opts?: SetCommandOptions | undefined) => Promise<TData>;
357
+ set: <TData>(key: string, value: TData, opts?: SetCommandOptions | undefined) => Promise<"OK" | TData | null>;
358
358
  /**
359
359
  * @see https://redis.io/commands/setbit
360
360
  */