@upstash/redis 1.1.0-alpha.0 → 1.2.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/README.md CHANGED
@@ -77,11 +77,26 @@ const redis = new Redis({
77
77
  url: <UPSTASH_REDIS_REST_URL>,
78
78
  token: <UPSTASH_REDIS_REST_TOKEN>,
79
79
  })
80
- // or load directly from env
80
+
81
+
82
+ // or load directly from global env
83
+
84
+ // service worker
81
85
  const redis = Redis.fromEnv()
86
+
87
+
88
+ // module worker
89
+ export default {
90
+ async fetch(request: Request, env: Bindings) {
91
+ const redis = Redis.fromEnv(env)
92
+ // ...
93
+ }
94
+ }
95
+
82
96
  ```
83
97
 
84
- - [Code example](https://github.com/upstash/upstash-redis/tree/main/examples/cloudflare-workers)
98
+ - [Code example service worker](https://github.com/upstash/upstash-redis/tree/main/examples/cloudflare-workers)
99
+ - [Code example module worker](https://github.com/upstash/upstash-redis/tree/main/examples/cloudflare-workers-modules)
85
100
  - [Documentation](https://docs.upstash.com/redis/tutorials/cloudflare_workers_with_redis)
86
101
 
87
102
  #### Fastly
@@ -55,6 +55,7 @@ import {
55
55
  PTtlCommand,
56
56
  PersistCommand,
57
57
  PingCommand,
58
+ PublishCommand,
58
59
  RPopCommand,
59
60
  RPushCommand,
60
61
  RPushXCommand,
@@ -106,7 +107,7 @@ import {
106
107
  ZScanCommand,
107
108
  ZScoreCommand,
108
109
  ZUnionStoreCommand
109
- } from "./chunk-3O2RMOYK.mjs";
110
+ } from "./chunk-HZBBCLMC.mjs";
110
111
  import {
111
112
  UpstashError
112
113
  } from "./chunk-7YUZYRJS.mjs";
@@ -185,6 +186,7 @@ var Pipeline = class {
185
186
  this.ping = (...args) => this.chain(new PingCommand(...args));
186
187
  this.psetex = (key, ttl, value) => this.chain(new PSetEXCommand(key, ttl, value));
187
188
  this.pttl = (...args) => this.chain(new PTtlCommand(...args));
189
+ this.publish = (...args) => this.chain(new PublishCommand(...args));
188
190
  this.randomkey = () => this.chain(new RandomKeyCommand());
189
191
  this.rename = (...args) => this.chain(new RenameCommand(...args));
190
192
  this.renamenx = (...args) => this.chain(new RenameNXCommand(...args));
@@ -310,6 +312,7 @@ var Redis = class {
310
312
  this.ping = (...args) => new PingCommand(...args).exec(this.client);
311
313
  this.psetex = (key, ttl, value) => new PSetEXCommand(key, ttl, value).exec(this.client);
312
314
  this.pttl = (...args) => new PTtlCommand(...args).exec(this.client);
315
+ this.publish = (...args) => new PublishCommand(...args).exec(this.client);
313
316
  this.randomkey = () => new RandomKeyCommand().exec(this.client);
314
317
  this.rename = (...args) => new RenameCommand(...args).exec(this.client);
315
318
  this.renamenx = (...args) => new RenameNXCommand(...args).exec(this.client);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Redis
3
- } from "./chunk-45MG55KM.mjs";
3
+ } from "./chunk-256N7RVN.mjs";
4
4
  import {
5
5
  HttpClient
6
6
  } from "./chunk-HIDCSH5S.mjs";
@@ -495,6 +495,13 @@ var PTtlCommand = class extends Command {
495
495
  }
496
496
  };
497
497
 
498
+ // pkg/commands/publish.ts
499
+ var PublishCommand = class extends Command {
500
+ constructor(channel, message) {
501
+ super(["publish", channel, message]);
502
+ }
503
+ };
504
+
498
505
  // pkg/commands/randomkey.ts
499
506
  var RandomKeyCommand = class extends Command {
500
507
  constructor() {
@@ -1018,6 +1025,7 @@ export {
1018
1025
  PingCommand,
1019
1026
  PSetEXCommand,
1020
1027
  PTtlCommand,
1028
+ PublishCommand,
1021
1029
  RandomKeyCommand,
1022
1030
  RenameCommand,
1023
1031
  RenameNXCommand,
package/cloudflare.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { R as Redis$1 } from './redis-a5141bfc';
1
+ import { R as Redis$1 } from './redis-a9efcf58';
2
2
  import './http';
3
3
  import './zunionstore-342168a6';
4
4
 
@@ -32,7 +32,10 @@ declare class Redis extends Redis$1 {
32
32
  * ```
33
33
  */
34
34
  constructor(config: RedisConfigCloudflare);
35
- static fromEnv(): Redis;
35
+ static fromEnv(env?: {
36
+ UPSTASH_REDIS_REST_URL: string;
37
+ UPSTASH_REDIS_REST_TOKEN: string;
38
+ }): Redis;
36
39
  }
37
40
 
38
41
  export { Redis, RedisConfigCloudflare };
package/cloudflare.js CHANGED
@@ -49,6 +49,34 @@ var UpstashError = class extends Error {
49
49
  }
50
50
  };
51
51
 
52
+ // pkg/http.ts
53
+ var HttpClient = class {
54
+ constructor(config) {
55
+ this.baseUrl = config.baseUrl.replace(/\/$/, "");
56
+ this.headers = __spreadValues({
57
+ "Content-Type": "application/json"
58
+ }, config.headers);
59
+ this.options = config.options;
60
+ }
61
+ async request(req) {
62
+ var _a;
63
+ if (!req.path) {
64
+ req.path = [];
65
+ }
66
+ const res = await fetch([this.baseUrl, ...req.path].join("/"), {
67
+ method: "POST",
68
+ headers: this.headers,
69
+ body: JSON.stringify(req.body),
70
+ backend: (_a = this.options) == null ? void 0 : _a.backend
71
+ });
72
+ const body = await res.json();
73
+ if (!res.ok) {
74
+ throw new UpstashError(body.error);
75
+ }
76
+ return body;
77
+ }
78
+ };
79
+
52
80
  // pkg/util.ts
53
81
  function parseRecursive(obj) {
54
82
  const parsed = Array.isArray(obj) ? obj.map((o) => {
@@ -542,6 +570,13 @@ var PTtlCommand = class extends Command {
542
570
  }
543
571
  };
544
572
 
573
+ // pkg/commands/publish.ts
574
+ var PublishCommand = class extends Command {
575
+ constructor(channel, message) {
576
+ super(["publish", channel, message]);
577
+ }
578
+ };
579
+
545
580
  // pkg/commands/randomkey.ts
546
581
  var RandomKeyCommand = class extends Command {
547
582
  constructor() {
@@ -1081,6 +1116,7 @@ var Pipeline = class {
1081
1116
  this.ping = (...args) => this.chain(new PingCommand(...args));
1082
1117
  this.psetex = (key, ttl, value) => this.chain(new PSetEXCommand(key, ttl, value));
1083
1118
  this.pttl = (...args) => this.chain(new PTtlCommand(...args));
1119
+ this.publish = (...args) => this.chain(new PublishCommand(...args));
1084
1120
  this.randomkey = () => this.chain(new RandomKeyCommand());
1085
1121
  this.rename = (...args) => this.chain(new RenameCommand(...args));
1086
1122
  this.renamenx = (...args) => this.chain(new RenameNXCommand(...args));
@@ -1206,6 +1242,7 @@ var Redis = class {
1206
1242
  this.ping = (...args) => new PingCommand(...args).exec(this.client);
1207
1243
  this.psetex = (key, ttl, value) => new PSetEXCommand(key, ttl, value).exec(this.client);
1208
1244
  this.pttl = (...args) => new PTtlCommand(...args).exec(this.client);
1245
+ this.publish = (...args) => new PublishCommand(...args).exec(this.client);
1209
1246
  this.randomkey = () => new RandomKeyCommand().exec(this.client);
1210
1247
  this.rename = (...args) => new RenameCommand(...args).exec(this.client);
1211
1248
  this.renamenx = (...args) => new RenameNXCommand(...args).exec(this.client);
@@ -1266,34 +1303,6 @@ var Redis = class {
1266
1303
  }
1267
1304
  };
1268
1305
 
1269
- // pkg/http.ts
1270
- var HttpClient = class {
1271
- constructor(config) {
1272
- this.baseUrl = config.baseUrl.replace(/\/$/, "");
1273
- this.headers = __spreadValues({
1274
- "Content-Type": "application/json"
1275
- }, config.headers);
1276
- this.options = config.options;
1277
- }
1278
- async request(req) {
1279
- var _a;
1280
- if (!req.path) {
1281
- req.path = [];
1282
- }
1283
- const res = await fetch([this.baseUrl, ...req.path].join("/"), {
1284
- method: "POST",
1285
- headers: this.headers,
1286
- body: JSON.stringify(req.body),
1287
- backend: (_a = this.options) == null ? void 0 : _a.backend
1288
- });
1289
- const body = await res.json();
1290
- if (!res.ok) {
1291
- throw new UpstashError(body.error);
1292
- }
1293
- return body;
1294
- }
1295
- };
1296
-
1297
1306
  // pkg/cloudflare.ts
1298
1307
  var Redis2 = class extends Redis {
1299
1308
  constructor(config) {
@@ -1305,9 +1314,10 @@ var Redis2 = class extends Redis {
1305
1314
  });
1306
1315
  super(client);
1307
1316
  }
1308
- static fromEnv() {
1309
- const url = UPSTASH_REDIS_REST_URL;
1310
- const token = UPSTASH_REDIS_REST_TOKEN;
1317
+ static fromEnv(env) {
1318
+ var _a, _b;
1319
+ const url = (_a = env == null ? void 0 : env.UPSTASH_REDIS_REST_URL) != null ? _a : UPSTASH_REDIS_REST_URL;
1320
+ const token = (_b = env == null ? void 0 : env.UPSTASH_REDIS_REST_TOKEN) != null ? _b : UPSTASH_REDIS_REST_TOKEN;
1311
1321
  if (!url) {
1312
1322
  throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_URL`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_URL`");
1313
1323
  }
package/cloudflare.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Redis
3
- } from "./chunk-45MG55KM.mjs";
4
- import "./chunk-3O2RMOYK.mjs";
3
+ } from "./chunk-256N7RVN.mjs";
4
+ import "./chunk-HZBBCLMC.mjs";
5
5
  import {
6
6
  HttpClient
7
7
  } from "./chunk-HIDCSH5S.mjs";
@@ -18,9 +18,10 @@ var Redis2 = class extends Redis {
18
18
  });
19
19
  super(client);
20
20
  }
21
- static fromEnv() {
22
- const url = UPSTASH_REDIS_REST_URL;
23
- const token = UPSTASH_REDIS_REST_TOKEN;
21
+ static fromEnv(env) {
22
+ var _a, _b;
23
+ const url = (_a = env == null ? void 0 : env.UPSTASH_REDIS_REST_URL) != null ? _a : UPSTASH_REDIS_REST_URL;
24
+ const token = (_b = env == null ? void 0 : env.UPSTASH_REDIS_REST_TOKEN) != null ? _b : UPSTASH_REDIS_REST_TOKEN;
24
25
  if (!url) {
25
26
  throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_URL`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_URL`");
26
27
  }
package/commands.d.ts CHANGED
@@ -404,6 +404,13 @@ declare class PTtlCommand extends Command<number, number> {
404
404
  constructor(key: string);
405
405
  }
406
406
 
407
+ /**
408
+ * @see https://redis.io/commands/publish
409
+ */
410
+ declare class PublishCommand<TMessage = unknown> extends Command<number, number> {
411
+ constructor(channel: string, message: TMessage);
412
+ }
413
+
407
414
  /**
408
415
  * @see https://redis.io/commands/randomkey
409
416
  */
@@ -717,4 +724,4 @@ declare class ZScoreCommand<TData> extends Command<number | null, string | null>
717
724
  constructor(key: string, member: TData);
718
725
  }
719
726
 
720
- export { AppendCommand, BitCountCommand, BitOpCommand, BitPosCommand, DBSizeCommand, DecrByCommand, DecrCommand, DelCommand, EchoCommand, 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, PExpireAtCommand, PExpireCommand, PSetEXCommand, PTtlCommand, PersistCommand, PingCommand, RPopCommand, RPushCommand, RPushXCommand, RandomKeyCommand, RenameCommand, RenameNXCommand, SAddCommand, SCardCommand, SDiffCommand, SDiffStoreCommand, SInterCommand, SInterStoreCommand, SIsMemberCommand, SMembersCommand, SMoveCommand, SPopCommand, SRandMemberCommand, SRemCommand, SScanCommand, SUnionCommand, SUnionStoreCommand, SetBitCommand, SetExCommand, SetNxCommand, SetRangeCommand, StrLenCommand, TimeCommand, TouchCommand, TtlCommand, ZCardCommand, ZCountCommand, ZIncrByComand, ZLexCountCommand, ZPopMaxCommand, ZPopMinCommand, ZRankCommand, ZRemCommand, ZRemRangeByLexCommand, ZRemRangeByRankCommand, ZRemRangeByScoreCommand, ZRevRankCommand, ZScanCommand, ZScoreCommand };
727
+ export { AppendCommand, BitCountCommand, BitOpCommand, BitPosCommand, DBSizeCommand, DecrByCommand, DecrCommand, DelCommand, EchoCommand, 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, PExpireAtCommand, PExpireCommand, PSetEXCommand, PTtlCommand, PersistCommand, PingCommand, PublishCommand, RPopCommand, RPushCommand, RPushXCommand, RandomKeyCommand, RenameCommand, RenameNXCommand, SAddCommand, SCardCommand, SDiffCommand, SDiffStoreCommand, SInterCommand, SInterStoreCommand, SIsMemberCommand, SMembersCommand, SMoveCommand, SPopCommand, SRandMemberCommand, SRemCommand, SScanCommand, SUnionCommand, SUnionStoreCommand, SetBitCommand, SetExCommand, SetNxCommand, SetRangeCommand, StrLenCommand, TimeCommand, TouchCommand, TtlCommand, ZCardCommand, ZCountCommand, ZIncrByComand, ZLexCountCommand, ZPopMaxCommand, ZPopMinCommand, ZRankCommand, ZRemCommand, ZRemRangeByLexCommand, ZRemRangeByRankCommand, ZRemRangeByScoreCommand, ZRevRankCommand, ZScanCommand, ZScoreCommand };
package/commands.js CHANGED
@@ -81,6 +81,7 @@ __export(commands_exports, {
81
81
  PTtlCommand: () => PTtlCommand,
82
82
  PersistCommand: () => PersistCommand,
83
83
  PingCommand: () => PingCommand,
84
+ PublishCommand: () => PublishCommand,
84
85
  RPopCommand: () => RPopCommand,
85
86
  RPushCommand: () => RPushCommand,
86
87
  RPushXCommand: () => RPushXCommand,
@@ -635,6 +636,13 @@ var PTtlCommand = class extends Command {
635
636
  }
636
637
  };
637
638
 
639
+ // pkg/commands/publish.ts
640
+ var PublishCommand = class extends Command {
641
+ constructor(channel, message) {
642
+ super(["publish", channel, message]);
643
+ }
644
+ };
645
+
638
646
  // pkg/commands/randomkey.ts
639
647
  var RandomKeyCommand = class extends Command {
640
648
  constructor() {
@@ -1159,6 +1167,7 @@ module.exports = __toCommonJS(commands_exports);
1159
1167
  PTtlCommand,
1160
1168
  PersistCommand,
1161
1169
  PingCommand,
1170
+ PublishCommand,
1162
1171
  RPopCommand,
1163
1172
  RPushCommand,
1164
1173
  RPushXCommand,
package/commands.mjs CHANGED
@@ -56,6 +56,7 @@ import {
56
56
  PTtlCommand,
57
57
  PersistCommand,
58
58
  PingCommand,
59
+ PublishCommand,
59
60
  RPopCommand,
60
61
  RPushCommand,
61
62
  RPushXCommand,
@@ -107,7 +108,7 @@ import {
107
108
  ZScanCommand,
108
109
  ZScoreCommand,
109
110
  ZUnionStoreCommand
110
- } from "./chunk-3O2RMOYK.mjs";
111
+ } from "./chunk-HZBBCLMC.mjs";
111
112
  import "./chunk-7YUZYRJS.mjs";
112
113
  export {
113
114
  AppendCommand,
@@ -167,6 +168,7 @@ export {
167
168
  PTtlCommand,
168
169
  PersistCommand,
169
170
  PingCommand,
171
+ PublishCommand,
170
172
  RPopCommand,
171
173
  RPushCommand,
172
174
  RPushXCommand,
package/fastly.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { R as Redis$1 } from './redis-a5141bfc';
1
+ import { R as Redis$1 } from './redis-a9efcf58';
2
2
  import './http';
3
3
  import './zunionstore-342168a6';
4
4
 
package/fastly.js CHANGED
@@ -49,6 +49,34 @@ var UpstashError = class extends Error {
49
49
  }
50
50
  };
51
51
 
52
+ // pkg/http.ts
53
+ var HttpClient = class {
54
+ constructor(config) {
55
+ this.baseUrl = config.baseUrl.replace(/\/$/, "");
56
+ this.headers = __spreadValues({
57
+ "Content-Type": "application/json"
58
+ }, config.headers);
59
+ this.options = config.options;
60
+ }
61
+ async request(req) {
62
+ var _a;
63
+ if (!req.path) {
64
+ req.path = [];
65
+ }
66
+ const res = await fetch([this.baseUrl, ...req.path].join("/"), {
67
+ method: "POST",
68
+ headers: this.headers,
69
+ body: JSON.stringify(req.body),
70
+ backend: (_a = this.options) == null ? void 0 : _a.backend
71
+ });
72
+ const body = await res.json();
73
+ if (!res.ok) {
74
+ throw new UpstashError(body.error);
75
+ }
76
+ return body;
77
+ }
78
+ };
79
+
52
80
  // pkg/util.ts
53
81
  function parseRecursive(obj) {
54
82
  const parsed = Array.isArray(obj) ? obj.map((o) => {
@@ -542,6 +570,13 @@ var PTtlCommand = class extends Command {
542
570
  }
543
571
  };
544
572
 
573
+ // pkg/commands/publish.ts
574
+ var PublishCommand = class extends Command {
575
+ constructor(channel, message) {
576
+ super(["publish", channel, message]);
577
+ }
578
+ };
579
+
545
580
  // pkg/commands/randomkey.ts
546
581
  var RandomKeyCommand = class extends Command {
547
582
  constructor() {
@@ -1081,6 +1116,7 @@ var Pipeline = class {
1081
1116
  this.ping = (...args) => this.chain(new PingCommand(...args));
1082
1117
  this.psetex = (key, ttl, value) => this.chain(new PSetEXCommand(key, ttl, value));
1083
1118
  this.pttl = (...args) => this.chain(new PTtlCommand(...args));
1119
+ this.publish = (...args) => this.chain(new PublishCommand(...args));
1084
1120
  this.randomkey = () => this.chain(new RandomKeyCommand());
1085
1121
  this.rename = (...args) => this.chain(new RenameCommand(...args));
1086
1122
  this.renamenx = (...args) => this.chain(new RenameNXCommand(...args));
@@ -1206,6 +1242,7 @@ var Redis = class {
1206
1242
  this.ping = (...args) => new PingCommand(...args).exec(this.client);
1207
1243
  this.psetex = (key, ttl, value) => new PSetEXCommand(key, ttl, value).exec(this.client);
1208
1244
  this.pttl = (...args) => new PTtlCommand(...args).exec(this.client);
1245
+ this.publish = (...args) => new PublishCommand(...args).exec(this.client);
1209
1246
  this.randomkey = () => new RandomKeyCommand().exec(this.client);
1210
1247
  this.rename = (...args) => new RenameCommand(...args).exec(this.client);
1211
1248
  this.renamenx = (...args) => new RenameNXCommand(...args).exec(this.client);
@@ -1266,34 +1303,6 @@ var Redis = class {
1266
1303
  }
1267
1304
  };
1268
1305
 
1269
- // pkg/http.ts
1270
- var HttpClient = class {
1271
- constructor(config) {
1272
- this.baseUrl = config.baseUrl.replace(/\/$/, "");
1273
- this.headers = __spreadValues({
1274
- "Content-Type": "application/json"
1275
- }, config.headers);
1276
- this.options = config.options;
1277
- }
1278
- async request(req) {
1279
- var _a;
1280
- if (!req.path) {
1281
- req.path = [];
1282
- }
1283
- const res = await fetch([this.baseUrl, ...req.path].join("/"), {
1284
- method: "POST",
1285
- headers: this.headers,
1286
- body: JSON.stringify(req.body),
1287
- backend: (_a = this.options) == null ? void 0 : _a.backend
1288
- });
1289
- const body = await res.json();
1290
- if (!res.ok) {
1291
- throw new UpstashError(body.error);
1292
- }
1293
- return body;
1294
- }
1295
- };
1296
-
1297
1306
  // pkg/fastly.ts
1298
1307
  var Redis2 = class extends Redis {
1299
1308
  constructor(config) {
package/fastly.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Redis
3
- } from "./chunk-45MG55KM.mjs";
4
- import "./chunk-3O2RMOYK.mjs";
3
+ } from "./chunk-256N7RVN.mjs";
4
+ import "./chunk-HZBBCLMC.mjs";
5
5
  import {
6
6
  HttpClient
7
7
  } from "./chunk-HIDCSH5S.mjs";
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { Redis, RedisConfigNodejs } from './nodejs';
2
- import './redis-a5141bfc';
2
+ import './redis-a9efcf58';
3
3
  import './http';
4
4
  import './zunionstore-342168a6';
5
5
 
package/index.js CHANGED
@@ -543,6 +543,13 @@ var PTtlCommand = class extends Command {
543
543
  }
544
544
  };
545
545
 
546
+ // pkg/commands/publish.ts
547
+ var PublishCommand = class extends Command {
548
+ constructor(channel, message) {
549
+ super(["publish", channel, message]);
550
+ }
551
+ };
552
+
546
553
  // pkg/commands/randomkey.ts
547
554
  var RandomKeyCommand = class extends Command {
548
555
  constructor() {
@@ -1082,6 +1089,7 @@ var Pipeline = class {
1082
1089
  this.ping = (...args) => this.chain(new PingCommand(...args));
1083
1090
  this.psetex = (key, ttl, value) => this.chain(new PSetEXCommand(key, ttl, value));
1084
1091
  this.pttl = (...args) => this.chain(new PTtlCommand(...args));
1092
+ this.publish = (...args) => this.chain(new PublishCommand(...args));
1085
1093
  this.randomkey = () => this.chain(new RandomKeyCommand());
1086
1094
  this.rename = (...args) => this.chain(new RenameCommand(...args));
1087
1095
  this.renamenx = (...args) => this.chain(new RenameNXCommand(...args));
@@ -1207,6 +1215,7 @@ var Redis = class {
1207
1215
  this.ping = (...args) => new PingCommand(...args).exec(this.client);
1208
1216
  this.psetex = (key, ttl, value) => new PSetEXCommand(key, ttl, value).exec(this.client);
1209
1217
  this.pttl = (...args) => new PTtlCommand(...args).exec(this.client);
1218
+ this.publish = (...args) => new PublishCommand(...args).exec(this.client);
1210
1219
  this.randomkey = () => new RandomKeyCommand().exec(this.client);
1211
1220
  this.rename = (...args) => new RenameCommand(...args).exec(this.client);
1212
1221
  this.renamenx = (...args) => new RenameNXCommand(...args).exec(this.client);
package/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  Redis
3
- } from "./chunk-5GTJT4CY.mjs";
4
- import "./chunk-45MG55KM.mjs";
5
- import "./chunk-3O2RMOYK.mjs";
3
+ } from "./chunk-FR62Y7XB.mjs";
4
+ import "./chunk-256N7RVN.mjs";
5
+ import "./chunk-HZBBCLMC.mjs";
6
6
  import "./chunk-HIDCSH5S.mjs";
7
7
  import {
8
8
  UpstashError
package/nodejs.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { R as Redis$1 } from './redis-a5141bfc';
1
+ import { R as Redis$1 } from './redis-a9efcf58';
2
2
  import './http';
3
3
  import './zunionstore-342168a6';
4
4
 
package/nodejs.js CHANGED
@@ -542,6 +542,13 @@ var PTtlCommand = class extends Command {
542
542
  }
543
543
  };
544
544
 
545
+ // pkg/commands/publish.ts
546
+ var PublishCommand = class extends Command {
547
+ constructor(channel, message) {
548
+ super(["publish", channel, message]);
549
+ }
550
+ };
551
+
545
552
  // pkg/commands/randomkey.ts
546
553
  var RandomKeyCommand = class extends Command {
547
554
  constructor() {
@@ -1081,6 +1088,7 @@ var Pipeline = class {
1081
1088
  this.ping = (...args) => this.chain(new PingCommand(...args));
1082
1089
  this.psetex = (key, ttl, value) => this.chain(new PSetEXCommand(key, ttl, value));
1083
1090
  this.pttl = (...args) => this.chain(new PTtlCommand(...args));
1091
+ this.publish = (...args) => this.chain(new PublishCommand(...args));
1084
1092
  this.randomkey = () => this.chain(new RandomKeyCommand());
1085
1093
  this.rename = (...args) => this.chain(new RenameCommand(...args));
1086
1094
  this.renamenx = (...args) => this.chain(new RenameNXCommand(...args));
@@ -1206,6 +1214,7 @@ var Redis = class {
1206
1214
  this.ping = (...args) => new PingCommand(...args).exec(this.client);
1207
1215
  this.psetex = (key, ttl, value) => new PSetEXCommand(key, ttl, value).exec(this.client);
1208
1216
  this.pttl = (...args) => new PTtlCommand(...args).exec(this.client);
1217
+ this.publish = (...args) => new PublishCommand(...args).exec(this.client);
1209
1218
  this.randomkey = () => new RandomKeyCommand().exec(this.client);
1210
1219
  this.rename = (...args) => new RenameCommand(...args).exec(this.client);
1211
1220
  this.renamenx = (...args) => new RenameNXCommand(...args).exec(this.client);
package/nodejs.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  Redis
3
- } from "./chunk-5GTJT4CY.mjs";
4
- import "./chunk-45MG55KM.mjs";
5
- import "./chunk-3O2RMOYK.mjs";
3
+ } from "./chunk-FR62Y7XB.mjs";
4
+ import "./chunk-256N7RVN.mjs";
5
+ import "./chunk-HZBBCLMC.mjs";
6
6
  import "./chunk-HIDCSH5S.mjs";
7
7
  import "./chunk-7YUZYRJS.mjs";
8
8
  export {
package/package.json CHANGED
@@ -1 +1 @@
1
- { "name": "@upstash/redis", "version": "v1.1.0-alpha.0", "engines": { "node": ">=10" }, "description": "An HTTP/REST based Redis client built on top of Upstash REST API.", "main": "./index.js", "module": "./index.mjs", "types": "./index.d.ts", "scripts": { "test": "jest -i", "fmt": "pnpm lint && pnpm prettier --write .", "lint": "eslint --ext .ts --fix --ignore-path .gitignore .", "build": "tsup && cp package.json ./dist/ && pnpm size-limit" }, "repository": { "type": "git", "url": "git+https://github.com/upstash/upstash-redis.git" }, "keywords": [ "redis", "database", "serverless", "edge", "upstash" ], "author": "Andreas Thomas <andreas.thomas@chronark.com>", "license": "MIT", "bugs": { "url": "https://github.com/upstash/upstash-redis/issues" }, "homepage": "https://github.com/upstash/upstash-redis#readme", "directories": { "examples": "examples" }, "devDependencies": { "@jest/globals": "^27.4.6", "@size-limit/preset-small-lib": "^7.0.8", "@trivago/prettier-plugin-sort-imports": "^3.2.0", "@types/jest": "^27.4.0", "@types/node": "^17.0.8", "@typescript-eslint/eslint-plugin": "^5.9.1", "@typescript-eslint/parser": "^5.9.1", "dotenv": "^12.0.3", "eslint": "^8.6.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.0.0", "jest": "^27.4.7", "prettier": "^2.5.1", "size-limit": "^7.0.8", "ts-jest": "^27.1.3", "tsup": "^5.11.11", "typescript": "^4.5.5" }, "dependencies": { "isomorphic-fetch": "^3.0.0" }, "browser": { "isomorphic-fetch": false }, "size-limit": [ { "path": "dist/index.js", "limit": "5 KB" }, { "path": "dist/index.mjs", "limit": "5 KB" }, { "path": "dist/cloudflare.js", "limit": "5 KB" }, { "path": "dist/cloudflare.mjs", "limit": "5 KB" }, { "path": "dist/nodejs.js", "limit": "5 KB" }, { "path": "dist/nodejs.mjs", "limit": "5 KB" }, { "path": "dist/fastly.js", "limit": "5 KB" }, { "path": "dist/fastly.mjs", "limit": "5 KB" } ] }
1
+ { "name": "@upstash/redis", "version": "v1.2.0", "engines": { "node": ">=10" }, "description": "An HTTP/REST based Redis client built on top of Upstash REST API.", "main": "./index.js", "module": "./index.mjs", "types": "./index.d.ts", "scripts": { "test": "jest -i", "fmt": "pnpm lint && pnpm prettier --write .", "lint": "eslint --ext .ts --fix --ignore-path .gitignore .", "build": "tsup && cp package.json ./dist/ && pnpm size-limit" }, "repository": { "type": "git", "url": "git+https://github.com/upstash/upstash-redis.git" }, "keywords": [ "redis", "database", "serverless", "edge", "upstash" ], "author": "Andreas Thomas <andreas.thomas@chronark.com>", "license": "MIT", "bugs": { "url": "https://github.com/upstash/upstash-redis/issues" }, "homepage": "https://github.com/upstash/upstash-redis#readme", "directories": { "examples": "examples" }, "devDependencies": { "@jest/globals": "^27.4.6", "@size-limit/preset-small-lib": "^7.0.8", "@trivago/prettier-plugin-sort-imports": "^3.2.0", "@types/jest": "^27.4.0", "@types/node": "^17.0.8", "@typescript-eslint/eslint-plugin": "^5.9.1", "@typescript-eslint/parser": "^5.9.1", "dotenv": "^12.0.3", "eslint": "^8.6.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.0.0", "jest": "^27.4.7", "prettier": "^2.5.1", "size-limit": "^7.0.8", "ts-jest": "^27.1.3", "tsup": "^5.11.11", "typescript": "^4.5.5" }, "dependencies": { "isomorphic-fetch": "^3.0.0" }, "browser": { "isomorphic-fetch": false }, "size-limit": [ { "path": "dist/index.js", "limit": "5 KB" }, { "path": "dist/index.mjs", "limit": "5 KB" }, { "path": "dist/cloudflare.js", "limit": "5 KB" }, { "path": "dist/cloudflare.mjs", "limit": "5 KB" }, { "path": "dist/nodejs.js", "limit": "5 KB" }, { "path": "dist/nodejs.mjs", "limit": "5 KB" }, { "path": "dist/fastly.js", "limit": "5 KB" }, { "path": "dist/fastly.mjs", "limit": "5 KB" } ] }
@@ -299,6 +299,10 @@ declare class Pipeline {
299
299
  * @see https://redis.io/commands/pttl
300
300
  */
301
301
  pttl: (key: string) => this;
302
+ /**
303
+ * @see https://redis.io/commands/publish
304
+ */
305
+ publish: (channel: string, message: unknown) => this;
302
306
  /**
303
307
  * @see https://redis.io/commands/randomkey
304
308
  */
@@ -781,6 +785,10 @@ declare class Redis {
781
785
  * @see https://redis.io/commands/pttl
782
786
  */
783
787
  pttl: (key: string) => Promise<number>;
788
+ /**
789
+ * @see https://redis.io/commands/publish
790
+ */
791
+ publish: (channel: string, message: unknown) => Promise<number>;
784
792
  /**
785
793
  * @see https://redis.io/commands/randomkey
786
794
  */