@upstash/redis 0.0.0-ci.ec2c4106-20221122 → 0.0.0-ci.ed40a9ac-20230414
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 +9 -2
- package/esm/pkg/commands/command.js +12 -3
- package/esm/pkg/commands/hgetall.js +0 -4
- package/esm/pkg/commands/hrandfield.js +39 -0
- package/esm/pkg/commands/json_arrappend.js +9 -0
- package/esm/pkg/commands/json_arrindex.js +9 -0
- package/esm/pkg/commands/json_arrinsert.js +9 -0
- package/esm/pkg/commands/json_arrlen.js +9 -0
- package/esm/pkg/commands/json_arrpop.js +9 -0
- package/esm/pkg/commands/json_arrtrim.js +12 -0
- package/esm/pkg/commands/json_clear.js +9 -0
- package/esm/pkg/commands/json_del.js +9 -0
- package/esm/pkg/commands/json_forget.js +9 -0
- package/esm/pkg/commands/json_get.js +30 -0
- package/esm/pkg/commands/json_mget.js +9 -0
- package/esm/pkg/commands/json_numincrby.js +9 -0
- package/esm/pkg/commands/json_nummultby.js +9 -0
- package/esm/pkg/commands/json_objkeys.js +9 -0
- package/esm/pkg/commands/json_objlen.js +9 -0
- package/esm/pkg/commands/json_resp.js +9 -0
- package/esm/pkg/commands/json_set.js +18 -0
- package/esm/pkg/commands/json_strappend.js +9 -0
- package/esm/pkg/commands/json_strlen.js +9 -0
- package/esm/pkg/commands/json_toggle.js +9 -0
- package/esm/pkg/commands/json_type.js +9 -0
- package/esm/pkg/commands/lmove.js +9 -0
- package/esm/pkg/commands/mod.js +25 -1
- package/esm/pkg/commands/smismember.js +9 -0
- package/esm/pkg/commands/zdiffstore.js +9 -0
- package/esm/pkg/http.js +27 -18
- package/esm/pkg/pipeline.js +131 -1
- package/esm/pkg/redis.js +155 -1
- package/esm/platforms/cloudflare.js +6 -6
- package/esm/platforms/fastly.js +5 -0
- package/esm/platforms/node_with_fetch.js +23 -11
- package/esm/platforms/nodejs.js +19 -11
- package/esm/version.js +1 -1
- package/package.json +41 -16
- package/script/pkg/commands/command.js +12 -3
- package/script/pkg/commands/hgetall.js +0 -4
- package/script/pkg/commands/hrandfield.js +43 -0
- package/script/pkg/commands/json_arrappend.js +13 -0
- package/script/pkg/commands/json_arrindex.js +13 -0
- package/script/pkg/commands/json_arrinsert.js +13 -0
- package/script/pkg/commands/json_arrlen.js +13 -0
- package/script/pkg/commands/json_arrpop.js +13 -0
- package/script/pkg/commands/json_arrtrim.js +16 -0
- package/script/pkg/commands/json_clear.js +13 -0
- package/script/pkg/commands/json_del.js +13 -0
- package/script/pkg/commands/json_forget.js +13 -0
- package/script/pkg/commands/json_get.js +34 -0
- package/script/pkg/commands/json_mget.js +13 -0
- package/script/pkg/commands/json_numincrby.js +13 -0
- package/script/pkg/commands/json_nummultby.js +13 -0
- package/script/pkg/commands/json_objkeys.js +13 -0
- package/script/pkg/commands/json_objlen.js +13 -0
- package/script/pkg/commands/json_resp.js +13 -0
- package/script/pkg/commands/json_set.js +22 -0
- package/script/pkg/commands/json_strappend.js +13 -0
- package/script/pkg/commands/json_strlen.js +13 -0
- package/script/pkg/commands/json_toggle.js +13 -0
- package/script/pkg/commands/json_type.js +13 -0
- package/script/pkg/commands/lmove.js +13 -0
- package/script/pkg/commands/mod.js +25 -1
- package/script/pkg/commands/smismember.js +13 -0
- package/script/pkg/commands/zdiffstore.js +13 -0
- package/script/pkg/http.js +27 -18
- package/script/pkg/pipeline.js +130 -0
- package/script/pkg/redis.js +154 -0
- package/script/platforms/cloudflare.js +6 -6
- package/script/platforms/fastly.js +5 -0
- package/script/platforms/node_with_fetch.js +23 -11
- package/script/platforms/nodejs.js +19 -11
- package/script/version.js +1 -1
- package/types/pkg/commands/command.d.ts +5 -5
- package/types/pkg/commands/hrandfield.d.ts +9 -0
- package/types/pkg/commands/json_arrappend.d.ts +7 -0
- package/types/pkg/commands/json_arrindex.d.ts +13 -0
- package/types/pkg/commands/json_arrinsert.d.ts +7 -0
- package/types/pkg/commands/json_arrlen.d.ts +7 -0
- package/types/pkg/commands/json_arrpop.d.ts +7 -0
- package/types/pkg/commands/json_arrtrim.d.ts +7 -0
- package/types/pkg/commands/json_clear.d.ts +7 -0
- package/types/pkg/commands/json_del.d.ts +7 -0
- package/types/pkg/commands/json_forget.d.ts +7 -0
- package/types/pkg/commands/json_get.d.ts +15 -0
- package/types/pkg/commands/json_mget.d.ts +7 -0
- package/types/pkg/commands/json_numincrby.d.ts +7 -0
- package/types/pkg/commands/json_nummultby.d.ts +7 -0
- package/types/pkg/commands/json_objkeys.d.ts +7 -0
- package/types/pkg/commands/json_objlen.d.ts +7 -0
- package/types/pkg/commands/json_resp.d.ts +7 -0
- package/types/pkg/commands/json_set.d.ts +18 -0
- package/types/pkg/commands/json_strappend.d.ts +7 -0
- package/types/pkg/commands/json_strlen.d.ts +7 -0
- package/types/pkg/commands/json_toggle.d.ts +7 -0
- package/types/pkg/commands/json_type.d.ts +7 -0
- package/types/pkg/commands/lmove.d.ts +12 -0
- package/types/pkg/commands/mod.d.ts +25 -1
- package/types/pkg/commands/scan.d.ts +1 -1
- package/types/pkg/commands/script_flush.d.ts +1 -1
- package/types/pkg/commands/set.d.ts +1 -1
- package/types/pkg/commands/smembers.d.ts +2 -2
- package/types/pkg/commands/smismember.d.ts +7 -0
- package/types/pkg/commands/type.d.ts +1 -1
- package/types/pkg/commands/zadd.d.ts +3 -3
- package/types/pkg/commands/zdiffstore.d.ts +7 -0
- package/types/pkg/commands/zinterstore.d.ts +1 -1
- package/types/pkg/commands/zrange.d.ts +1 -1
- package/types/pkg/commands/zunionstore.d.ts +1 -1
- package/types/pkg/http.d.ts +13 -24
- package/types/pkg/pipeline.d.ts +44 -2
- package/types/pkg/redis.d.ts +120 -10
- package/types/pkg/types.d.ts +27 -1
- package/types/platforms/cloudflare.d.ts +2 -2
- package/types/platforms/fastly.d.ts +1 -1
- package/types/platforms/node_with_fetch.d.ts +1 -1
- package/types/platforms/nodejs.d.ts +1 -1
- package/types/version.d.ts +1 -1
package/esm/pkg/pipeline.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { AppendCommand, BitCountCommand, BitOpCommand, BitPosCommand, DBSizeCommand, DecrByCommand, DecrCommand, DelCommand, EchoCommand, EvalCommand, EvalshaCommand, ExistsCommand, ExpireAtCommand, ExpireCommand, FlushAllCommand, FlushDBCommand, GetBitCommand, GetCommand, GetDelCommand, 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";
|
|
1
|
+
import { AppendCommand, BitCountCommand, BitOpCommand, BitPosCommand, DBSizeCommand, DecrByCommand, DecrCommand, DelCommand, EchoCommand, EvalCommand, EvalshaCommand, ExistsCommand, ExpireAtCommand, ExpireCommand, FlushAllCommand, FlushDBCommand, GetBitCommand, GetCommand, GetDelCommand, GetRangeCommand, GetSetCommand, HDelCommand, HExistsCommand, HGetAllCommand, HGetCommand, HIncrByCommand, HIncrByFloatCommand, HKeysCommand, HLenCommand, HMGetCommand, HMSetCommand, HScanCommand, HSetCommand, HSetNXCommand, HStrLenCommand, HValsCommand, IncrByCommand, IncrByFloatCommand, IncrCommand, JsonArrAppendCommand, JsonArrIndexCommand, JsonArrInsertCommand, JsonArrLenCommand, JsonArrPopCommand, JsonArrTrimCommand, JsonClearCommand, JsonDelCommand, JsonForgetCommand, JsonGetCommand, JsonMGetCommand, JsonNumIncrByCommand, JsonNumMultByCommand, JsonObjKeysCommand, JsonObjLenCommand, JsonRespCommand, JsonSetCommand, JsonStrAppendCommand, JsonStrLenCommand, JsonToggleCommand, JsonTypeCommand, KeysCommand, LIndexCommand, LInsertCommand, LLenCommand, LMoveCommand, 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, SMIsMemberCommand, 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
|
import { ZMScoreCommand } from "./commands/zmscore.js";
|
|
4
|
+
import { HRandFieldCommand } from "./commands/hrandfield.js";
|
|
5
|
+
import { ZDiffStoreCommand } from "./commands/zdiffstore.js";
|
|
4
6
|
/**
|
|
5
7
|
* Upstash REST API supports command pipelining to send multiple commands in
|
|
6
8
|
* batch, instead of sending each command one by one and waiting for a response.
|
|
@@ -132,6 +134,15 @@ export class Pipeline {
|
|
|
132
134
|
writable: true,
|
|
133
135
|
value: (...args) => this.chain(new BitPosCommand(args, this.commandOptions))
|
|
134
136
|
});
|
|
137
|
+
/**
|
|
138
|
+
* @see https://redis.io/commands/zdiffstore
|
|
139
|
+
*/
|
|
140
|
+
Object.defineProperty(this, "zdiffstore", {
|
|
141
|
+
enumerable: true,
|
|
142
|
+
configurable: true,
|
|
143
|
+
writable: true,
|
|
144
|
+
value: (...args) => this.chain(new ZDiffStoreCommand(args, this.commandOptions))
|
|
145
|
+
});
|
|
135
146
|
/**
|
|
136
147
|
* @see https://redis.io/commands/dbsize
|
|
137
148
|
*/
|
|
@@ -375,6 +386,15 @@ export class Pipeline {
|
|
|
375
386
|
writable: true,
|
|
376
387
|
value: (key, kv) => this.chain(new HMSetCommand([key, kv], this.commandOptions))
|
|
377
388
|
});
|
|
389
|
+
/**
|
|
390
|
+
* @see https://redis.io/commands/hrandfield
|
|
391
|
+
*/
|
|
392
|
+
Object.defineProperty(this, "hrandfield", {
|
|
393
|
+
enumerable: true,
|
|
394
|
+
configurable: true,
|
|
395
|
+
writable: true,
|
|
396
|
+
value: (key, count, withValues) => this.chain(new HRandFieldCommand([key, count, withValues], this.commandOptions))
|
|
397
|
+
});
|
|
378
398
|
/**
|
|
379
399
|
* @see https://redis.io/commands/hscan
|
|
380
400
|
*/
|
|
@@ -483,6 +503,15 @@ export class Pipeline {
|
|
|
483
503
|
writable: true,
|
|
484
504
|
value: (...args) => this.chain(new LLenCommand(args, this.commandOptions))
|
|
485
505
|
});
|
|
506
|
+
/**
|
|
507
|
+
* @see https://redis.io/commands/lmove
|
|
508
|
+
*/
|
|
509
|
+
Object.defineProperty(this, "lmove", {
|
|
510
|
+
enumerable: true,
|
|
511
|
+
configurable: true,
|
|
512
|
+
writable: true,
|
|
513
|
+
value: (...args) => this.chain(new LMoveCommand(args, this.commandOptions))
|
|
514
|
+
});
|
|
486
515
|
/**
|
|
487
516
|
* @see https://redis.io/commands/lpop
|
|
488
517
|
*/
|
|
@@ -852,6 +881,15 @@ export class Pipeline {
|
|
|
852
881
|
writable: true,
|
|
853
882
|
value: (...args) => this.chain(new SMembersCommand(args, this.commandOptions))
|
|
854
883
|
});
|
|
884
|
+
/**
|
|
885
|
+
* @see https://redis.io/commands/smismember
|
|
886
|
+
*/
|
|
887
|
+
Object.defineProperty(this, "smismember", {
|
|
888
|
+
enumerable: true,
|
|
889
|
+
configurable: true,
|
|
890
|
+
writable: true,
|
|
891
|
+
value: (key, members) => this.chain(new SMIsMemberCommand([key, members], this.commandOptions))
|
|
892
|
+
});
|
|
855
893
|
/**
|
|
856
894
|
* @see https://redis.io/commands/smove
|
|
857
895
|
*/
|
|
@@ -1158,4 +1196,96 @@ export class Pipeline {
|
|
|
1158
1196
|
this.commands.push(command);
|
|
1159
1197
|
return this;
|
|
1160
1198
|
}
|
|
1199
|
+
/**
|
|
1200
|
+
* @see https://redis.io/commands/?group=json
|
|
1201
|
+
*/
|
|
1202
|
+
get json() {
|
|
1203
|
+
// For some reason we needed to define the types manually, otherwise Deno wouldn't build it
|
|
1204
|
+
return {
|
|
1205
|
+
/**
|
|
1206
|
+
* @see https://redis.io/commands/json.arrappend
|
|
1207
|
+
*/
|
|
1208
|
+
arrappend: (...args) => this.chain(new JsonArrAppendCommand(args, this.commandOptions)),
|
|
1209
|
+
/**
|
|
1210
|
+
* @see https://redis.io/commands/json.arrindex
|
|
1211
|
+
*/
|
|
1212
|
+
arrindex: (...args) => this.chain(new JsonArrIndexCommand(args, this.commandOptions)),
|
|
1213
|
+
/**
|
|
1214
|
+
* @see https://redis.io/commands/json.arrinsert
|
|
1215
|
+
*/
|
|
1216
|
+
arrinsert: (...args) => this.chain(new JsonArrInsertCommand(args, this.commandOptions)),
|
|
1217
|
+
/**
|
|
1218
|
+
* @see https://redis.io/commands/json.arrlen
|
|
1219
|
+
*/
|
|
1220
|
+
arrlen: (...args) => this.chain(new JsonArrLenCommand(args, this.commandOptions)),
|
|
1221
|
+
/**
|
|
1222
|
+
* @see https://redis.io/commands/json.arrpop
|
|
1223
|
+
*/
|
|
1224
|
+
arrpop: (...args) => this.chain(new JsonArrPopCommand(args, this.commandOptions)),
|
|
1225
|
+
/**
|
|
1226
|
+
* @see https://redis.io/commands/json.arrtrim
|
|
1227
|
+
*/
|
|
1228
|
+
arrtrim: (...args) => this.chain(new JsonArrTrimCommand(args, this.commandOptions)),
|
|
1229
|
+
/**
|
|
1230
|
+
* @see https://redis.io/commands/json.clear
|
|
1231
|
+
*/
|
|
1232
|
+
clear: (...args) => this.chain(new JsonClearCommand(args, this.commandOptions)),
|
|
1233
|
+
/**
|
|
1234
|
+
* @see https://redis.io/commands/json.del
|
|
1235
|
+
*/
|
|
1236
|
+
del: (...args) => this.chain(new JsonDelCommand(args, this.commandOptions)),
|
|
1237
|
+
/**
|
|
1238
|
+
* @see https://redis.io/commands/json.forget
|
|
1239
|
+
*/
|
|
1240
|
+
forget: (...args) => this.chain(new JsonForgetCommand(args, this.commandOptions)),
|
|
1241
|
+
/**
|
|
1242
|
+
* @see https://redis.io/commands/json.get
|
|
1243
|
+
*/
|
|
1244
|
+
get: (...args) => this.chain(new JsonGetCommand(args, this.commandOptions)),
|
|
1245
|
+
/**
|
|
1246
|
+
* @see https://redis.io/commands/json.mget
|
|
1247
|
+
*/
|
|
1248
|
+
mget: (...args) => this.chain(new JsonMGetCommand(args, this.commandOptions)),
|
|
1249
|
+
/**
|
|
1250
|
+
* @see https://redis.io/commands/json.numincrby
|
|
1251
|
+
*/
|
|
1252
|
+
numincrby: (...args) => this.chain(new JsonNumIncrByCommand(args, this.commandOptions)),
|
|
1253
|
+
/**
|
|
1254
|
+
* @see https://redis.io/commands/json.nummultby
|
|
1255
|
+
*/
|
|
1256
|
+
nummultby: (...args) => this.chain(new JsonNumMultByCommand(args, this.commandOptions)),
|
|
1257
|
+
/**
|
|
1258
|
+
* @see https://redis.io/commands/json.objkeys
|
|
1259
|
+
*/
|
|
1260
|
+
objkeys: (...args) => this.chain(new JsonObjKeysCommand(args, this.commandOptions)),
|
|
1261
|
+
/**
|
|
1262
|
+
* @see https://redis.io/commands/json.objlen
|
|
1263
|
+
*/
|
|
1264
|
+
objlen: (...args) => this.chain(new JsonObjLenCommand(args, this.commandOptions)),
|
|
1265
|
+
/**
|
|
1266
|
+
* @see https://redis.io/commands/json.resp
|
|
1267
|
+
*/
|
|
1268
|
+
resp: (...args) => this.chain(new JsonRespCommand(args, this.commandOptions)),
|
|
1269
|
+
/**
|
|
1270
|
+
* @see https://redis.io/commands/json.set
|
|
1271
|
+
*/
|
|
1272
|
+
set: (...args) => this.chain(new JsonSetCommand(args, this.commandOptions)),
|
|
1273
|
+
/**
|
|
1274
|
+
* @see https://redis.io/commands/json.strappend
|
|
1275
|
+
*/
|
|
1276
|
+
strappend: (...args) => this.chain(new JsonStrAppendCommand(args, this.commandOptions)),
|
|
1277
|
+
/**
|
|
1278
|
+
* @see https://redis.io/commands/json.strlen
|
|
1279
|
+
*/
|
|
1280
|
+
strlen: (...args) => this.chain(new JsonStrLenCommand(args, this.commandOptions)),
|
|
1281
|
+
/**
|
|
1282
|
+
* @see https://redis.io/commands/json.toggle
|
|
1283
|
+
*/
|
|
1284
|
+
toggle: (...args) => this.chain(new JsonToggleCommand(args, this.commandOptions)),
|
|
1285
|
+
/**
|
|
1286
|
+
* @see https://redis.io/commands/json.type
|
|
1287
|
+
*/
|
|
1288
|
+
type: (...args) => this.chain(new JsonTypeCommand(args, this.commandOptions)),
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1161
1291
|
}
|
package/esm/pkg/redis.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { AppendCommand, BitCountCommand, BitOpCommand, BitPosCommand, DBSizeCommand, DecrByCommand, DecrCommand, DelCommand, EchoCommand, EvalCommand, EvalshaCommand, ExistsCommand, ExpireAtCommand, ExpireCommand, FlushAllCommand, FlushDBCommand, GetBitCommand, GetCommand, GetDelCommand, 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";
|
|
1
|
+
import { AppendCommand, BitCountCommand, BitOpCommand, BitPosCommand, DBSizeCommand, DecrByCommand, DecrCommand, DelCommand, EchoCommand, EvalCommand, EvalshaCommand, ExistsCommand, ExpireAtCommand, ExpireCommand, FlushAllCommand, FlushDBCommand, GetBitCommand, GetCommand, GetDelCommand, GetRangeCommand, GetSetCommand, HDelCommand, HExistsCommand, HGetAllCommand, HGetCommand, HIncrByCommand, HIncrByFloatCommand, HKeysCommand, HLenCommand, HMGetCommand, HMSetCommand, HRandFieldCommand, HScanCommand, HSetCommand, HSetNXCommand, HStrLenCommand, HValsCommand, IncrByCommand, IncrByFloatCommand, IncrCommand, JsonArrAppendCommand, JsonArrIndexCommand, JsonArrInsertCommand, JsonArrLenCommand, JsonArrPopCommand, JsonArrTrimCommand, JsonClearCommand, JsonDelCommand, JsonForgetCommand, JsonGetCommand, JsonMGetCommand, JsonNumIncrByCommand, JsonNumMultByCommand, JsonObjKeysCommand, JsonObjLenCommand, JsonRespCommand, JsonSetCommand, JsonStrAppendCommand, JsonStrLenCommand, JsonToggleCommand, JsonTypeCommand, KeysCommand, LIndexCommand, LInsertCommand, LLenCommand, LMoveCommand, 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, SMIsMemberCommand, 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
|
import { Script } from "./script.js";
|
|
4
4
|
import { ZMScoreCommand } from "./commands/zmscore.js";
|
|
5
|
+
import { ZDiffStoreCommand } from "./commands/zdiffstore.js";
|
|
5
6
|
/**
|
|
6
7
|
* Serverless redis client for upstash.
|
|
7
8
|
*/
|
|
@@ -30,6 +31,12 @@ export class Redis {
|
|
|
30
31
|
writable: true,
|
|
31
32
|
value: void 0
|
|
32
33
|
});
|
|
34
|
+
Object.defineProperty(this, "enableTelemetry", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true,
|
|
38
|
+
value: void 0
|
|
39
|
+
});
|
|
33
40
|
/**
|
|
34
41
|
* Wrap a new middleware around the HTTP client.
|
|
35
42
|
*/
|
|
@@ -42,6 +49,27 @@ export class Redis {
|
|
|
42
49
|
this.client.request = (req) => middleware(req, makeRequest);
|
|
43
50
|
}
|
|
44
51
|
});
|
|
52
|
+
/**
|
|
53
|
+
* Technically this is not private, we can hide it from intellisense by doing this
|
|
54
|
+
*/
|
|
55
|
+
Object.defineProperty(this, "addTelemetry", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
configurable: true,
|
|
58
|
+
writable: true,
|
|
59
|
+
value: (telemetry) => {
|
|
60
|
+
if (!this.enableTelemetry) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
// @ts-ignore - The `Requester` interface does not know about this method but it will be there
|
|
65
|
+
// as long as the user uses the standard HttpClient
|
|
66
|
+
this.client.mergeTelemetry(telemetry);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// ignore
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
45
73
|
/**
|
|
46
74
|
* Create a new pipeline that allows you to send requests in bulk.
|
|
47
75
|
*
|
|
@@ -355,6 +383,16 @@ export class Redis {
|
|
|
355
383
|
writable: true,
|
|
356
384
|
value: (key, kv) => new HMSetCommand([key, kv], this.opts).exec(this.client)
|
|
357
385
|
});
|
|
386
|
+
/**
|
|
387
|
+
* @see https://redis.io/commands/hrandfield
|
|
388
|
+
*/
|
|
389
|
+
Object.defineProperty(this, "hrandfield", {
|
|
390
|
+
enumerable: true,
|
|
391
|
+
configurable: true,
|
|
392
|
+
writable: true,
|
|
393
|
+
value: (key, count, withValues) => new HRandFieldCommand([key, count, withValues], this.opts)
|
|
394
|
+
.exec(this.client)
|
|
395
|
+
});
|
|
358
396
|
/**
|
|
359
397
|
* @see https://redis.io/commands/hscan
|
|
360
398
|
*/
|
|
@@ -463,6 +501,15 @@ export class Redis {
|
|
|
463
501
|
writable: true,
|
|
464
502
|
value: (...args) => new LLenCommand(args, this.opts).exec(this.client)
|
|
465
503
|
});
|
|
504
|
+
/**
|
|
505
|
+
* @see https://redis.io/commands/lmove
|
|
506
|
+
*/
|
|
507
|
+
Object.defineProperty(this, "lmove", {
|
|
508
|
+
enumerable: true,
|
|
509
|
+
configurable: true,
|
|
510
|
+
writable: true,
|
|
511
|
+
value: (...args) => new LMoveCommand(args, this.opts).exec(this.client)
|
|
512
|
+
});
|
|
466
513
|
/**
|
|
467
514
|
* @see https://redis.io/commands/lpop
|
|
468
515
|
*/
|
|
@@ -823,6 +870,15 @@ export class Redis {
|
|
|
823
870
|
writable: true,
|
|
824
871
|
value: (key, member) => new SIsMemberCommand([key, member], this.opts).exec(this.client)
|
|
825
872
|
});
|
|
873
|
+
/**
|
|
874
|
+
* @see https://redis.io/commands/smismember
|
|
875
|
+
*/
|
|
876
|
+
Object.defineProperty(this, "smismember", {
|
|
877
|
+
enumerable: true,
|
|
878
|
+
configurable: true,
|
|
879
|
+
writable: true,
|
|
880
|
+
value: (key, members) => new SMIsMemberCommand([key, members], this.opts).exec(this.client)
|
|
881
|
+
});
|
|
826
882
|
/**
|
|
827
883
|
* @see https://redis.io/commands/smembers
|
|
828
884
|
*/
|
|
@@ -981,6 +1037,15 @@ export class Redis {
|
|
|
981
1037
|
writable: true,
|
|
982
1038
|
value: (...args) => new ZCountCommand(args, this.opts).exec(this.client)
|
|
983
1039
|
});
|
|
1040
|
+
/**
|
|
1041
|
+
* @see https://redis.io/commands/zdiffstore
|
|
1042
|
+
*/
|
|
1043
|
+
Object.defineProperty(this, "zdiffstore", {
|
|
1044
|
+
enumerable: true,
|
|
1045
|
+
configurable: true,
|
|
1046
|
+
writable: true,
|
|
1047
|
+
value: (...args) => new ZDiffStoreCommand(args, this.opts).exec(this.client)
|
|
1048
|
+
});
|
|
984
1049
|
/**
|
|
985
1050
|
* @see https://redis.io/commands/zincrby
|
|
986
1051
|
*/
|
|
@@ -1127,6 +1192,95 @@ export class Redis {
|
|
|
1127
1192
|
});
|
|
1128
1193
|
this.client = client;
|
|
1129
1194
|
this.opts = opts;
|
|
1195
|
+
this.enableTelemetry = opts?.enableTelemetry ?? true;
|
|
1196
|
+
}
|
|
1197
|
+
get json() {
|
|
1198
|
+
return {
|
|
1199
|
+
/**
|
|
1200
|
+
* @see https://redis.io/commands/json.arrappend
|
|
1201
|
+
*/
|
|
1202
|
+
arrappend: (...args) => new JsonArrAppendCommand(args, this.opts).exec(this.client),
|
|
1203
|
+
/**
|
|
1204
|
+
* @see https://redis.io/commands/json.arrindex
|
|
1205
|
+
*/
|
|
1206
|
+
arrindex: (...args) => new JsonArrIndexCommand(args, this.opts).exec(this.client),
|
|
1207
|
+
/**
|
|
1208
|
+
* @see https://redis.io/commands/json.arrinsert
|
|
1209
|
+
*/
|
|
1210
|
+
arrinsert: (...args) => new JsonArrInsertCommand(args, this.opts).exec(this.client),
|
|
1211
|
+
/**
|
|
1212
|
+
* @see https://redis.io/commands/json.arrlen
|
|
1213
|
+
*/
|
|
1214
|
+
arrlen: (...args) => new JsonArrLenCommand(args, this.opts).exec(this.client),
|
|
1215
|
+
/**
|
|
1216
|
+
* @see https://redis.io/commands/json.arrpop
|
|
1217
|
+
*/
|
|
1218
|
+
arrpop: (...args) => new JsonArrPopCommand(args, this.opts).exec(this.client),
|
|
1219
|
+
/**
|
|
1220
|
+
* @see https://redis.io/commands/json.arrtrim
|
|
1221
|
+
*/
|
|
1222
|
+
arrtrim: (...args) => new JsonArrTrimCommand(args, this.opts).exec(this.client),
|
|
1223
|
+
/**
|
|
1224
|
+
* @see https://redis.io/commands/json.clear
|
|
1225
|
+
*/
|
|
1226
|
+
clear: (...args) => new JsonClearCommand(args, this.opts).exec(this.client),
|
|
1227
|
+
/**
|
|
1228
|
+
* @see https://redis.io/commands/json.del
|
|
1229
|
+
*/
|
|
1230
|
+
del: (...args) => new JsonDelCommand(args, this.opts).exec(this.client),
|
|
1231
|
+
/**
|
|
1232
|
+
* @see https://redis.io/commands/json.forget
|
|
1233
|
+
*/
|
|
1234
|
+
forget: (...args) => new JsonForgetCommand(args, this.opts).exec(this.client),
|
|
1235
|
+
/**
|
|
1236
|
+
* @see https://redis.io/commands/json.get
|
|
1237
|
+
*/
|
|
1238
|
+
get: (...args) => new JsonGetCommand(args, this.opts).exec(this.client),
|
|
1239
|
+
/**
|
|
1240
|
+
* @see https://redis.io/commands/json.mget
|
|
1241
|
+
*/
|
|
1242
|
+
mget: (...args) => new JsonMGetCommand(args, this.opts).exec(this.client),
|
|
1243
|
+
/**
|
|
1244
|
+
* @see https://redis.io/commands/json.numincrby
|
|
1245
|
+
*/
|
|
1246
|
+
numincrby: (...args) => new JsonNumIncrByCommand(args, this.opts).exec(this.client),
|
|
1247
|
+
/**
|
|
1248
|
+
* @see https://redis.io/commands/json.nummultby
|
|
1249
|
+
*/
|
|
1250
|
+
nummultby: (...args) => new JsonNumMultByCommand(args, this.opts).exec(this.client),
|
|
1251
|
+
/**
|
|
1252
|
+
* @see https://redis.io/commands/json.objkeys
|
|
1253
|
+
*/
|
|
1254
|
+
objkeys: (...args) => new JsonObjKeysCommand(args, this.opts).exec(this.client),
|
|
1255
|
+
/**
|
|
1256
|
+
* @see https://redis.io/commands/json.objlen
|
|
1257
|
+
*/
|
|
1258
|
+
objlen: (...args) => new JsonObjLenCommand(args, this.opts).exec(this.client),
|
|
1259
|
+
/**
|
|
1260
|
+
* @see https://redis.io/commands/json.resp
|
|
1261
|
+
*/
|
|
1262
|
+
resp: (...args) => new JsonRespCommand(args, this.opts).exec(this.client),
|
|
1263
|
+
/**
|
|
1264
|
+
* @see https://redis.io/commands/json.set
|
|
1265
|
+
*/
|
|
1266
|
+
set: (...args) => new JsonSetCommand(args, this.opts).exec(this.client),
|
|
1267
|
+
/**
|
|
1268
|
+
* @see https://redis.io/commands/json.strappend
|
|
1269
|
+
*/
|
|
1270
|
+
strappend: (...args) => new JsonStrAppendCommand(args, this.opts).exec(this.client),
|
|
1271
|
+
/**
|
|
1272
|
+
* @see https://redis.io/commands/json.strlen
|
|
1273
|
+
*/
|
|
1274
|
+
strlen: (...args) => new JsonStrLenCommand(args, this.opts).exec(this.client),
|
|
1275
|
+
/**
|
|
1276
|
+
* @see https://redis.io/commands/json.toggle
|
|
1277
|
+
*/
|
|
1278
|
+
toggle: (...args) => new JsonToggleCommand(args, this.opts).exec(this.client),
|
|
1279
|
+
/**
|
|
1280
|
+
* @see https://redis.io/commands/json.type
|
|
1281
|
+
*/
|
|
1282
|
+
type: (...args) => new JsonTypeCommand(args, this.opts).exec(this.client),
|
|
1283
|
+
};
|
|
1130
1284
|
}
|
|
1131
1285
|
createScript(script) {
|
|
1132
1286
|
return new Script(this, script);
|
|
@@ -27,21 +27,21 @@ export class Redis extends core.Redis {
|
|
|
27
27
|
/\r|\n/.test(config.token)) {
|
|
28
28
|
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
29
29
|
}
|
|
30
|
-
const telemetry = {};
|
|
31
|
-
if (!env?.UPSTASH_DISABLE_TELEMETRY) {
|
|
32
|
-
telemetry.platform = "cloudflare";
|
|
33
|
-
telemetry.sdk = `@upstash/redis@${VERSION}`;
|
|
34
|
-
}
|
|
35
30
|
const client = new HttpClient({
|
|
36
31
|
retry: config.retry,
|
|
37
32
|
baseUrl: config.url,
|
|
38
33
|
headers: { authorization: `Bearer ${config.token}` },
|
|
39
34
|
responseEncoding: config.responseEncoding,
|
|
40
|
-
telemetry,
|
|
41
35
|
});
|
|
42
36
|
super(client, {
|
|
37
|
+
enableTelemetry: !env?.UPSTASH_DISABLE_TELEMETRY,
|
|
43
38
|
automaticDeserialization: config.automaticDeserialization,
|
|
44
39
|
});
|
|
40
|
+
// This is only added of the user has not disabled telemetry
|
|
41
|
+
this.addTelemetry({
|
|
42
|
+
platform: "cloudflare",
|
|
43
|
+
sdk: `@upstash/redis@${VERSION}`,
|
|
44
|
+
});
|
|
45
45
|
}
|
|
46
46
|
/*
|
|
47
47
|
* Create a new Upstash Redis instance from environment variables on cloudflare.
|
package/esm/platforms/fastly.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as core from "../pkg/redis.js";
|
|
2
2
|
import { HttpClient } from "../pkg/http.js";
|
|
3
|
+
import { VERSION } from "../version.js";
|
|
3
4
|
/**
|
|
4
5
|
* Serverless redis client for upstash.
|
|
5
6
|
*/
|
|
@@ -37,5 +38,9 @@ export class Redis extends core.Redis {
|
|
|
37
38
|
super(client, {
|
|
38
39
|
automaticDeserialization: config.automaticDeserialization,
|
|
39
40
|
});
|
|
41
|
+
this.addTelemetry({
|
|
42
|
+
sdk: `@upstash/redis@${VERSION}`,
|
|
43
|
+
platform: "fastly",
|
|
44
|
+
});
|
|
40
45
|
}
|
|
41
46
|
}
|
|
@@ -3,6 +3,19 @@ import * as core from "../pkg/redis.js";
|
|
|
3
3
|
import { HttpClient, } from "../pkg/http.js";
|
|
4
4
|
import { VERSION } from "../version.js";
|
|
5
5
|
import "isomorphic-fetch";
|
|
6
|
+
// @ts-ignore Deno can't compile
|
|
7
|
+
// import https from "https";
|
|
8
|
+
// @ts-ignore Deno can't compile
|
|
9
|
+
// import http from "http";
|
|
10
|
+
// import "isomorphic-fetch";
|
|
11
|
+
/**
|
|
12
|
+
* Workaround for nodejs 14, where atob is not included in the standardlib
|
|
13
|
+
*/
|
|
14
|
+
if (typeof atob === "undefined") {
|
|
15
|
+
global.atob = function (b64) {
|
|
16
|
+
return Buffer.from(b64, "base64").toString("utf-8");
|
|
17
|
+
};
|
|
18
|
+
}
|
|
6
19
|
/**
|
|
7
20
|
* Serverless redis client for upstash.
|
|
8
21
|
*/
|
|
@@ -22,26 +35,25 @@ export class Redis extends core.Redis {
|
|
|
22
35
|
/\r|\n/.test(configOrRequester.token)) {
|
|
23
36
|
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
24
37
|
}
|
|
25
|
-
const telemetry = {};
|
|
26
|
-
if (!process.env.UPSTASH_DISABLE_TELEMETRY) {
|
|
27
|
-
telemetry.runtime = `node@${process.version}`;
|
|
28
|
-
telemetry.platform = process.env.VERCEL
|
|
29
|
-
? "vercel"
|
|
30
|
-
: process.env.AWS_REGION
|
|
31
|
-
? "aws"
|
|
32
|
-
: "unknown";
|
|
33
|
-
telemetry.sdk = `@upstash/redis@${VERSION}`;
|
|
34
|
-
}
|
|
35
38
|
const client = new HttpClient({
|
|
36
39
|
baseUrl: configOrRequester.url,
|
|
37
40
|
retry: configOrRequester.retry,
|
|
38
41
|
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
39
42
|
// agent: configOrRequester.agent,
|
|
40
43
|
responseEncoding: configOrRequester.responseEncoding,
|
|
41
|
-
telemetry,
|
|
42
44
|
});
|
|
43
45
|
super(client, {
|
|
44
46
|
automaticDeserialization: configOrRequester.automaticDeserialization,
|
|
47
|
+
enableTelemetry: !process.env.UPSTASH_DISABLE_TELEMETRY,
|
|
48
|
+
});
|
|
49
|
+
this.addTelemetry({
|
|
50
|
+
runtime: `node@${process.version}`,
|
|
51
|
+
platform: process.env.VERCEL
|
|
52
|
+
? "vercel"
|
|
53
|
+
: process.env.AWS_REGION
|
|
54
|
+
? "aws"
|
|
55
|
+
: "unknown",
|
|
56
|
+
sdk: `@upstash/redis@${VERSION}`,
|
|
45
57
|
});
|
|
46
58
|
}
|
|
47
59
|
/**
|
package/esm/platforms/nodejs.js
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
import * as core from "../pkg/redis.js";
|
|
3
3
|
import { HttpClient, } from "../pkg/http.js";
|
|
4
4
|
import { VERSION } from "../version.js";
|
|
5
|
+
/**
|
|
6
|
+
* Workaround for nodejs 14, where atob is not included in the standardlib
|
|
7
|
+
*/
|
|
8
|
+
if (typeof atob === "undefined") {
|
|
9
|
+
global.atob = function (b64) {
|
|
10
|
+
return Buffer.from(b64, "base64").toString("utf-8");
|
|
11
|
+
};
|
|
12
|
+
}
|
|
5
13
|
/**
|
|
6
14
|
* Serverless redis client for upstash.
|
|
7
15
|
*/
|
|
@@ -21,26 +29,26 @@ export class Redis extends core.Redis {
|
|
|
21
29
|
/\r|\n/.test(configOrRequester.token)) {
|
|
22
30
|
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
23
31
|
}
|
|
24
|
-
const telemetry = {};
|
|
25
|
-
if (!process.env.UPSTASH_DISABLE_TELEMETRY) {
|
|
26
|
-
telemetry.runtime = `node@${process.version}`;
|
|
27
|
-
telemetry.platform = process.env.VERCEL
|
|
28
|
-
? "vercel"
|
|
29
|
-
: process.env.AWS_REGION
|
|
30
|
-
? "aws"
|
|
31
|
-
: "unknown";
|
|
32
|
-
telemetry.sdk = `@upstash/redis@${VERSION}`;
|
|
33
|
-
}
|
|
34
32
|
const client = new HttpClient({
|
|
35
33
|
baseUrl: configOrRequester.url,
|
|
36
34
|
retry: configOrRequester.retry,
|
|
37
35
|
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
38
36
|
agent: configOrRequester.agent,
|
|
39
37
|
responseEncoding: configOrRequester.responseEncoding,
|
|
40
|
-
|
|
38
|
+
cache: "no-store",
|
|
41
39
|
});
|
|
42
40
|
super(client, {
|
|
43
41
|
automaticDeserialization: configOrRequester.automaticDeserialization,
|
|
42
|
+
enableTelemetry: !process.env.UPSTASH_DISABLE_TELEMETRY,
|
|
43
|
+
});
|
|
44
|
+
this.addTelemetry({
|
|
45
|
+
runtime: `node@${process.version}`,
|
|
46
|
+
platform: process.env.VERCEL
|
|
47
|
+
? "vercel"
|
|
48
|
+
: process.env.AWS_REGION
|
|
49
|
+
? "aws"
|
|
50
|
+
: "unknown",
|
|
51
|
+
sdk: `@upstash/redis@${VERSION}`,
|
|
44
52
|
});
|
|
45
53
|
}
|
|
46
54
|
/**
|
package/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "v0.0.0-ci.
|
|
1
|
+
export const VERSION = "v0.0.0-ci.ed40a9ac-20230414";
|
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": "v0.0.0-ci.
|
|
6
|
+
"version": "v0.0.0-ci.ed40a9ac-20230414",
|
|
7
7
|
"description": "An HTTP/REST based Redis client built on top of Upstash REST API.",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -35,29 +35,54 @@
|
|
|
35
35
|
},
|
|
36
36
|
"exports": {
|
|
37
37
|
".": {
|
|
38
|
-
"import":
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
"import": {
|
|
39
|
+
"types": "./types/platforms/nodejs.d.ts",
|
|
40
|
+
"default": "./esm/platforms/nodejs.js"
|
|
41
|
+
},
|
|
42
|
+
"require": {
|
|
43
|
+
"types": "./types/platforms/nodejs.d.ts",
|
|
44
|
+
"default": "./script/platforms/nodejs.js"
|
|
45
|
+
}
|
|
41
46
|
},
|
|
42
47
|
"./nodejs": {
|
|
43
|
-
"import":
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
"import": {
|
|
49
|
+
"types": "./types/platforms/nodejs.d.ts",
|
|
50
|
+
"default": "./esm/platforms/nodejs.js"
|
|
51
|
+
},
|
|
52
|
+
"require": {
|
|
53
|
+
"types": "./types/platforms/nodejs.d.ts",
|
|
54
|
+
"default": "./script/platforms/nodejs.js"
|
|
55
|
+
}
|
|
46
56
|
},
|
|
47
57
|
"./cloudflare": {
|
|
48
|
-
"import":
|
|
49
|
-
|
|
50
|
-
|
|
58
|
+
"import": {
|
|
59
|
+
"types": "./types/platforms/cloudflare.d.ts",
|
|
60
|
+
"default": "./esm/platforms/cloudflare.js"
|
|
61
|
+
},
|
|
62
|
+
"require": {
|
|
63
|
+
"types": "./types/platforms/cloudflare.d.ts",
|
|
64
|
+
"default": "./script/platforms/cloudflare.js"
|
|
65
|
+
}
|
|
51
66
|
},
|
|
52
67
|
"./fastly": {
|
|
53
|
-
"import":
|
|
54
|
-
|
|
55
|
-
|
|
68
|
+
"import": {
|
|
69
|
+
"types": "./types/platforms/fastly.d.ts",
|
|
70
|
+
"default": "./esm/platforms/fastly.js"
|
|
71
|
+
},
|
|
72
|
+
"require": {
|
|
73
|
+
"types": "./types/platforms/fastly.d.ts",
|
|
74
|
+
"default": "./script/platforms/fastly.js"
|
|
75
|
+
}
|
|
56
76
|
},
|
|
57
77
|
"./with-fetch": {
|
|
58
|
-
"import":
|
|
59
|
-
|
|
60
|
-
|
|
78
|
+
"import": {
|
|
79
|
+
"types": "./types/platforms/node_with_fetch.d.ts",
|
|
80
|
+
"default": "./esm/platforms/node_with_fetch.js"
|
|
81
|
+
},
|
|
82
|
+
"require": {
|
|
83
|
+
"types": "./types/platforms/node_with_fetch.d.ts",
|
|
84
|
+
"default": "./script/platforms/node_with_fetch.js"
|
|
85
|
+
}
|
|
61
86
|
}
|
|
62
87
|
}
|
|
63
88
|
}
|
|
@@ -3,7 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Command = void 0;
|
|
4
4
|
const error_js_1 = require("../error.js");
|
|
5
5
|
const util_js_1 = require("../util.js");
|
|
6
|
-
const defaultSerializer = (c) =>
|
|
6
|
+
const defaultSerializer = (c) => {
|
|
7
|
+
switch (typeof c) {
|
|
8
|
+
case "string":
|
|
9
|
+
case "number":
|
|
10
|
+
case "boolean":
|
|
11
|
+
return c;
|
|
12
|
+
default:
|
|
13
|
+
return JSON.stringify(c);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
7
16
|
/**
|
|
8
17
|
* Command offers default (de)serialization and the exec method to all commands.
|
|
9
18
|
*
|
|
@@ -40,7 +49,7 @@ class Command {
|
|
|
40
49
|
opts.automaticDeserialization
|
|
41
50
|
? opts?.deserialize ?? util_js_1.parseResponse
|
|
42
51
|
: (x) => x;
|
|
43
|
-
this.command = command.map(this.serialize);
|
|
52
|
+
this.command = command.map((c) => this.serialize(c));
|
|
44
53
|
}
|
|
45
54
|
/**
|
|
46
55
|
* Execute the command using a client.
|
|
@@ -53,7 +62,7 @@ class Command {
|
|
|
53
62
|
throw new error_js_1.UpstashError(error);
|
|
54
63
|
}
|
|
55
64
|
if (typeof result === "undefined") {
|
|
56
|
-
throw new Error(
|
|
65
|
+
throw new Error("Request did not return a result");
|
|
57
66
|
}
|
|
58
67
|
return this.deserialize(result);
|
|
59
68
|
}
|