@upstash/redis 1.40.0 → 1.41.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 +5 -0
- package/{chunk-RLVWMRRX.mjs → chunk-CGMWROAN.mjs} +557 -4
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +557 -4
- package/cloudflare.mjs +1 -1
- package/docs/advanced.mdx +83 -0
- package/docs/commands/array/arcount.mdx +28 -0
- package/docs/commands/array/ardel.mdx +30 -0
- package/docs/commands/array/ardelrange.mdx +32 -0
- package/docs/commands/array/arget.mdx +33 -0
- package/docs/commands/array/argetrange.mdx +38 -0
- package/docs/commands/array/argrep.mdx +69 -0
- package/docs/commands/array/arinfo.mdx +49 -0
- package/docs/commands/array/arinsert.mdx +32 -0
- package/docs/commands/array/arlastitems.mdx +40 -0
- package/docs/commands/array/arlen.mdx +28 -0
- package/docs/commands/array/armget.mdx +31 -0
- package/docs/commands/array/armset.mdx +31 -0
- package/docs/commands/array/arnext.mdx +25 -0
- package/docs/commands/array/arop.mdx +44 -0
- package/docs/commands/array/arring.mdx +36 -0
- package/docs/commands/array/arscan.mdx +42 -0
- package/docs/commands/array/arseek.mdx +34 -0
- package/docs/commands/array/arset.mdx +35 -0
- package/docs/commands/auth/echo.mdx +24 -0
- package/docs/commands/auth/ping.mdx +21 -0
- package/docs/commands/bitmap/bitcount.mdx +39 -0
- package/docs/commands/bitmap/bitop.mdx +142 -0
- package/docs/commands/bitmap/bitpos.mdx +39 -0
- package/docs/commands/bitmap/getbit.mdx +28 -0
- package/docs/commands/bitmap/setbit.mdx +31 -0
- package/docs/commands/connection/client_setinfo.mdx +91 -0
- package/docs/commands/functions/call.mdx +72 -0
- package/docs/commands/functions/call_ro.mdx +57 -0
- package/docs/commands/functions/delete.mdx +22 -0
- package/docs/commands/functions/flush.mdx +16 -0
- package/docs/commands/functions/list.mdx +72 -0
- package/docs/commands/functions/load.mdx +64 -0
- package/docs/commands/functions/stats.mdx +46 -0
- package/docs/commands/generic/del.mdx +29 -0
- package/docs/commands/generic/exists.mdx +26 -0
- package/docs/commands/generic/expire.mdx +29 -0
- package/docs/commands/generic/expireat.mdx +29 -0
- package/docs/commands/generic/keys.mdx +32 -0
- package/docs/commands/generic/persist.mdx +23 -0
- package/docs/commands/generic/pexpire.mdx +28 -0
- package/docs/commands/generic/pexpireat.mdx +29 -0
- package/docs/commands/generic/pttl.mdx +23 -0
- package/docs/commands/generic/randomkey.mdx +21 -0
- package/docs/commands/generic/rename.mdx +28 -0
- package/docs/commands/generic/renamenx.mdx +28 -0
- package/docs/commands/generic/scan.mdx +38 -0
- package/docs/commands/generic/touch.mdx +23 -0
- package/docs/commands/generic/ttl.mdx +23 -0
- package/docs/commands/generic/type.mdx +27 -0
- package/docs/commands/generic/unlink.mdx +29 -0
- package/docs/commands/hash/hdel.mdx +28 -0
- package/docs/commands/hash/hexists.mdx +30 -0
- package/docs/commands/hash/hexpire.mdx +49 -0
- package/docs/commands/hash/hexpireat.mdx +48 -0
- package/docs/commands/hash/hexpiretime.mdx +35 -0
- package/docs/commands/hash/hget.mdx +29 -0
- package/docs/commands/hash/hgetall.mdx +27 -0
- package/docs/commands/hash/hgetdel.mdx +67 -0
- package/docs/commands/hash/hgetex.mdx +123 -0
- package/docs/commands/hash/hincrby.mdx +34 -0
- package/docs/commands/hash/hincrbyfloat.mdx +34 -0
- package/docs/commands/hash/hkeys.mdx +28 -0
- package/docs/commands/hash/hlen.mdx +28 -0
- package/docs/commands/hash/hmget.mdx +33 -0
- package/docs/commands/hash/hpersist.mdx +37 -0
- package/docs/commands/hash/hpexpire.mdx +50 -0
- package/docs/commands/hash/hpexpireat.mdx +48 -0
- package/docs/commands/hash/hpexpiretime.mdx +35 -0
- package/docs/commands/hash/hpttl.mdx +35 -0
- package/docs/commands/hash/hrandfield.mdx +57 -0
- package/docs/commands/hash/hscan.mdx +65 -0
- package/docs/commands/hash/hset.mdx +32 -0
- package/docs/commands/hash/hsetex.mdx +186 -0
- package/docs/commands/hash/hsetnx.mdx +30 -0
- package/docs/commands/hash/hstrlen.mdx +28 -0
- package/docs/commands/hash/httl.mdx +35 -0
- package/docs/commands/hash/hvals.mdx +29 -0
- package/docs/commands/json/arrappend.mdx +35 -0
- package/docs/commands/json/arrindex.mdx +37 -0
- package/docs/commands/json/arrinsert.mdx +34 -0
- package/docs/commands/json/arrlen.mdx +26 -0
- package/docs/commands/json/arrpop.mdx +36 -0
- package/docs/commands/json/arrtrim.mdx +34 -0
- package/docs/commands/json/clear.mdx +30 -0
- package/docs/commands/json/del.mdx +26 -0
- package/docs/commands/json/forget.mdx +26 -0
- package/docs/commands/json/get.mdx +53 -0
- package/docs/commands/json/merge.mdx +32 -0
- package/docs/commands/json/mget.mdx +27 -0
- package/docs/commands/json/mset.mdx +26 -0
- package/docs/commands/json/numincrby.mdx +33 -0
- package/docs/commands/json/nummultby.mdx +33 -0
- package/docs/commands/json/objkeys.mdx +27 -0
- package/docs/commands/json/objlen.mdx +27 -0
- package/docs/commands/json/set.mdx +42 -0
- package/docs/commands/json/strappend.mdx +32 -0
- package/docs/commands/json/strlen.mdx +26 -0
- package/docs/commands/json/toggle.mdx +28 -0
- package/docs/commands/json/type.mdx +28 -0
- package/docs/commands/list/lindex.mdx +32 -0
- package/docs/commands/list/linsert.mdx +41 -0
- package/docs/commands/list/llen.mdx +26 -0
- package/docs/commands/list/lmove.mdx +34 -0
- package/docs/commands/list/lpop.mdx +37 -0
- package/docs/commands/list/lpos.mdx +56 -0
- package/docs/commands/list/lpush.mdx +32 -0
- package/docs/commands/list/lpushx.mdx +38 -0
- package/docs/commands/list/lrange.mdx +37 -0
- package/docs/commands/list/lrem.mdx +33 -0
- package/docs/commands/list/lset.mdx +34 -0
- package/docs/commands/list/ltrim.mdx +33 -0
- package/docs/commands/list/rpop.mdx +37 -0
- package/docs/commands/list/rpush.mdx +32 -0
- package/docs/commands/list/rpushx.mdx +38 -0
- package/docs/commands/overview.mdx +692 -0
- package/docs/commands/pubsub/psubscribe.mdx +36 -0
- package/docs/commands/pubsub/publish.mdx +27 -0
- package/docs/commands/pubsub/subscribe.mdx +28 -0
- package/docs/commands/scripts/eval.mdx +36 -0
- package/docs/commands/scripts/eval_ro.mdx +36 -0
- package/docs/commands/scripts/evalsha.mdx +36 -0
- package/docs/commands/scripts/evalsha_ro.mdx +36 -0
- package/docs/commands/scripts/script_exists.mdx +26 -0
- package/docs/commands/scripts/script_flush.mdx +28 -0
- package/docs/commands/scripts/script_load.mdx +28 -0
- package/docs/commands/server/dbsize.mdx +22 -0
- package/docs/commands/server/flushall.mdx +25 -0
- package/docs/commands/server/flushdb.mdx +25 -0
- package/docs/commands/set/sadd.mdx +32 -0
- package/docs/commands/set/scard.mdx +26 -0
- package/docs/commands/set/sdiff.mdx +27 -0
- package/docs/commands/set/sdiffstore.mdx +32 -0
- package/docs/commands/set/sinter.mdx +27 -0
- package/docs/commands/set/sinterstore.mdx +33 -0
- package/docs/commands/set/sismember.mdx +30 -0
- package/docs/commands/set/smembers.mdx +25 -0
- package/docs/commands/set/smismember.mdx +31 -0
- package/docs/commands/set/smove.mdx +34 -0
- package/docs/commands/set/spop.mdx +36 -0
- package/docs/commands/set/srandmember.mdx +36 -0
- package/docs/commands/set/srem.mdx +29 -0
- package/docs/commands/set/sscan.mdx +39 -0
- package/docs/commands/set/sunion.mdx +27 -0
- package/docs/commands/set/sunionstore.mdx +33 -0
- package/docs/commands/stream/xack.mdx +37 -0
- package/docs/commands/stream/xackdel.mdx +211 -0
- package/docs/commands/stream/xadd.mdx +137 -0
- package/docs/commands/stream/xautoclaim.mdx +80 -0
- package/docs/commands/stream/xclaim.mdx +84 -0
- package/docs/commands/stream/xdel.mdx +34 -0
- package/docs/commands/stream/xdelex.mdx +119 -0
- package/docs/commands/stream/xgroup.mdx +141 -0
- package/docs/commands/stream/xinfo.mdx +77 -0
- package/docs/commands/stream/xlen.mdx +22 -0
- package/docs/commands/stream/xpending.mdx +75 -0
- package/docs/commands/stream/xrange.mdx +59 -0
- package/docs/commands/stream/xread.mdx +65 -0
- package/docs/commands/stream/xreadgroup.mdx +87 -0
- package/docs/commands/stream/xrevrange.mdx +65 -0
- package/docs/commands/stream/xtrim.mdx +75 -0
- package/docs/commands/string/append.mdx +28 -0
- package/docs/commands/string/decr.mdx +27 -0
- package/docs/commands/string/decrby.mdx +30 -0
- package/docs/commands/string/get.mdx +34 -0
- package/docs/commands/string/getdel.mdx +29 -0
- package/docs/commands/string/getrange.mdx +34 -0
- package/docs/commands/string/getset.mdx +28 -0
- package/docs/commands/string/incr.mdx +27 -0
- package/docs/commands/string/incrby.mdx +30 -0
- package/docs/commands/string/incrbyfloat.mdx +30 -0
- package/docs/commands/string/mget.mdx +31 -0
- package/docs/commands/string/mset.mdx +32 -0
- package/docs/commands/string/msetnx.mdx +29 -0
- package/docs/commands/string/set.mdx +79 -0
- package/docs/commands/string/setrange.mdx +38 -0
- package/docs/commands/string/strlen.mdx +26 -0
- package/docs/commands/transaction.mdx +22 -0
- package/docs/commands/zset/zadd.mdx +102 -0
- package/docs/commands/zset/zcard.mdx +31 -0
- package/docs/commands/zset/zcount.mdx +47 -0
- package/docs/commands/zset/zdiffstore.mdx +33 -0
- package/docs/commands/zset/zincrby.mdx +37 -0
- package/docs/commands/zset/zinterstore.mdx +98 -0
- package/docs/commands/zset/zlexcount.mdx +43 -0
- package/docs/commands/zset/zmscore.mdx +34 -0
- package/docs/commands/zset/zpopmax.mdx +25 -0
- package/docs/commands/zset/zpopmin.mdx +25 -0
- package/docs/commands/zset/zrange.mdx +85 -0
- package/docs/commands/zset/zrank.mdx +29 -0
- package/docs/commands/zset/zrem.mdx +33 -0
- package/docs/commands/zset/zremrangebylex.mdx +32 -0
- package/docs/commands/zset/zremrangebyrank.mdx +32 -0
- package/docs/commands/zset/zremrangebyscore.mdx +32 -0
- package/docs/commands/zset/zrevrank.mdx +29 -0
- package/docs/commands/zset/zscan.mdx +58 -0
- package/docs/commands/zset/zscore.mdx +34 -0
- package/docs/commands/zset/zunionstore.mdx +98 -0
- package/docs/deployment.mdx +117 -0
- package/docs/developing.mdx +118 -0
- package/docs/getstarted.mdx +68 -0
- package/docs/overview.mdx +29 -0
- package/docs/pipelining/auto-pipeline.mdx +108 -0
- package/docs/pipelining/pipeline-transaction.mdx +65 -0
- package/docs/retries.mdx +24 -0
- package/docs/troubleshooting.mdx +80 -0
- package/{error-BNzLTXJG.d.mts → error-4e36-PC0.d.mts} +838 -8
- package/{error-BNzLTXJG.d.ts → error-4e36-PC0.d.ts} +838 -8
- package/fastly.d.mts +2 -2
- package/fastly.d.ts +2 -2
- package/fastly.js +557 -4
- package/fastly.mjs +1 -1
- package/nodejs.d.mts +34 -2
- package/nodejs.d.ts +34 -2
- package/nodejs.js +586 -4
- package/nodejs.mjs +30 -1
- package/package.json +16 -5
- package/src/pkg/auto-pipeline.ts +284 -0
- package/src/pkg/commands/append.ts +12 -0
- package/src/pkg/commands/arcount.ts +14 -0
- package/src/pkg/commands/ardel.ts +19 -0
- package/src/pkg/commands/ardelrange.ts +19 -0
- package/src/pkg/commands/arget.ts +17 -0
- package/src/pkg/commands/argetrange.ts +20 -0
- package/src/pkg/commands/argrep.ts +109 -0
- package/src/pkg/commands/arinfo.ts +88 -0
- package/src/pkg/commands/arinsert.ts +24 -0
- package/src/pkg/commands/arlastitems.ts +29 -0
- package/src/pkg/commands/arlen.ts +23 -0
- package/src/pkg/commands/armget.ts +18 -0
- package/src/pkg/commands/armset.ts +26 -0
- package/src/pkg/commands/arnext.ts +20 -0
- package/src/pkg/commands/arop.ts +48 -0
- package/src/pkg/commands/arring.ts +23 -0
- package/src/pkg/commands/arscan.ts +44 -0
- package/src/pkg/commands/arseek.ts +17 -0
- package/src/pkg/commands/arset.ts +20 -0
- package/src/pkg/commands/bitcount.ts +30 -0
- package/src/pkg/commands/bitfield.ts +50 -0
- package/src/pkg/commands/bitop.ts +35 -0
- package/src/pkg/commands/bitpos.ts +15 -0
- package/src/pkg/commands/client_setinfo.ts +17 -0
- package/src/pkg/commands/command.ts +142 -0
- package/src/pkg/commands/copy.ts +22 -0
- package/src/pkg/commands/dbsize.ts +12 -0
- package/src/pkg/commands/decr.ts +12 -0
- package/src/pkg/commands/decrby.ts +12 -0
- package/src/pkg/commands/del.ts +12 -0
- package/src/pkg/commands/echo.ts +12 -0
- package/src/pkg/commands/eval.ts +18 -0
- package/src/pkg/commands/evalRo.ts +18 -0
- package/src/pkg/commands/evalsha.ts +18 -0
- package/src/pkg/commands/evalshaRo.ts +18 -0
- package/src/pkg/commands/exec.ts +23 -0
- package/src/pkg/commands/exists.ts +12 -0
- package/src/pkg/commands/expire.ts +13 -0
- package/src/pkg/commands/expireat.ts +16 -0
- package/src/pkg/commands/fcall.ts +15 -0
- package/src/pkg/commands/fcall_ro.ts +18 -0
- package/src/pkg/commands/flushall.ts +15 -0
- package/src/pkg/commands/flushdb.ts +15 -0
- package/src/pkg/commands/function_delete.ts +12 -0
- package/src/pkg/commands/function_flush.ts +12 -0
- package/src/pkg/commands/function_list.ts +77 -0
- package/src/pkg/commands/function_load.ts +31 -0
- package/src/pkg/commands/function_stats.ts +42 -0
- package/src/pkg/commands/geo_add.ts +54 -0
- package/src/pkg/commands/geo_dist.ts +19 -0
- package/src/pkg/commands/geo_hash.ts +23 -0
- package/src/pkg/commands/geo_pos.ts +39 -0
- package/src/pkg/commands/geo_search.ts +140 -0
- package/src/pkg/commands/geo_search_store.ts +69 -0
- package/src/pkg/commands/get.ts +15 -0
- package/src/pkg/commands/getbit.ts +12 -0
- package/src/pkg/commands/getdel.ts +15 -0
- package/src/pkg/commands/getex.ts +36 -0
- package/src/pkg/commands/getrange.ts +15 -0
- package/src/pkg/commands/getset.ts +15 -0
- package/src/pkg/commands/hdel.ts +12 -0
- package/src/pkg/commands/hexists.ts +12 -0
- package/src/pkg/commands/hexpire.ts +30 -0
- package/src/pkg/commands/hexpireat.ts +30 -0
- package/src/pkg/commands/hexpiretime.ts +13 -0
- package/src/pkg/commands/hget.ts +18 -0
- package/src/pkg/commands/hgetall.ts +44 -0
- package/src/pkg/commands/hgetdel.ts +30 -0
- package/src/pkg/commands/hgetex.ts +56 -0
- package/src/pkg/commands/hincrby.ts +15 -0
- package/src/pkg/commands/hincrbyfloat.ts +15 -0
- package/src/pkg/commands/hkeys.ts +12 -0
- package/src/pkg/commands/hlen.ts +12 -0
- package/src/pkg/commands/hmget.ts +53 -0
- package/src/pkg/commands/hmset.ts +14 -0
- package/src/pkg/commands/hpersist.ts +13 -0
- package/src/pkg/commands/hpexpire.ts +30 -0
- package/src/pkg/commands/hpexpireat.ts +30 -0
- package/src/pkg/commands/hpexpiretime.ts +13 -0
- package/src/pkg/commands/hpttl.ts +13 -0
- package/src/pkg/commands/hrandfield.ts +52 -0
- package/src/pkg/commands/hscan.ts +31 -0
- package/src/pkg/commands/hset.ts +15 -0
- package/src/pkg/commands/hsetex.ts +59 -0
- package/src/pkg/commands/hsetnx.ts +15 -0
- package/src/pkg/commands/hstrlen.ts +12 -0
- package/src/pkg/commands/httl.ts +13 -0
- package/src/pkg/commands/hvals.ts +12 -0
- package/src/pkg/commands/incr.ts +12 -0
- package/src/pkg/commands/incrby.ts +12 -0
- package/src/pkg/commands/incrbyfloat.ts +12 -0
- package/src/pkg/commands/json_arrappend.ts +18 -0
- package/src/pkg/commands/json_arrindex.ts +15 -0
- package/src/pkg/commands/json_arrinsert.ts +18 -0
- package/src/pkg/commands/json_arrlen.ts +15 -0
- package/src/pkg/commands/json_arrpop.ts +15 -0
- package/src/pkg/commands/json_arrtrim.ts +19 -0
- package/src/pkg/commands/json_clear.ts +12 -0
- package/src/pkg/commands/json_del.ts +12 -0
- package/src/pkg/commands/json_forget.ts +12 -0
- package/src/pkg/commands/json_get.ts +45 -0
- package/src/pkg/commands/json_merge.ts +18 -0
- package/src/pkg/commands/json_mget.ts +12 -0
- package/src/pkg/commands/json_mset.ts +27 -0
- package/src/pkg/commands/json_numincrby.ts +15 -0
- package/src/pkg/commands/json_nummultby.ts +15 -0
- package/src/pkg/commands/json_objkeys.ts +15 -0
- package/src/pkg/commands/json_objlen.ts +15 -0
- package/src/pkg/commands/json_resp.ts +11 -0
- package/src/pkg/commands/json_set.ts +35 -0
- package/src/pkg/commands/json_strappend.ts +15 -0
- package/src/pkg/commands/json_strlen.ts +15 -0
- package/src/pkg/commands/json_toggle.ts +12 -0
- package/src/pkg/commands/json_type.ts +12 -0
- package/src/pkg/commands/keys.ts +12 -0
- package/src/pkg/commands/lindex.ts +11 -0
- package/src/pkg/commands/linsert.ts +10 -0
- package/src/pkg/commands/llen.ts +12 -0
- package/src/pkg/commands/lmove.ts +20 -0
- package/src/pkg/commands/lmpop.ts +19 -0
- package/src/pkg/commands/lpop.ts +18 -0
- package/src/pkg/commands/lpos.ts +26 -0
- package/src/pkg/commands/lpush.ts +12 -0
- package/src/pkg/commands/lpushx.ts +12 -0
- package/src/pkg/commands/lrange.ts +11 -0
- package/src/pkg/commands/lrem.ts +10 -0
- package/src/pkg/commands/lset.ts +8 -0
- package/src/pkg/commands/ltrim.ts +8 -0
- package/src/pkg/commands/mget.ts +15 -0
- package/src/pkg/commands/mod.ts +222 -0
- package/src/pkg/commands/mset.ts +12 -0
- package/src/pkg/commands/msetnx.ts +12 -0
- package/src/pkg/commands/persist.ts +12 -0
- package/src/pkg/commands/pexpire.ts +16 -0
- package/src/pkg/commands/pexpireat.ts +16 -0
- package/src/pkg/commands/pfadd.ts +11 -0
- package/src/pkg/commands/pfcount.ts +11 -0
- package/src/pkg/commands/pfmerge.ts +11 -0
- package/src/pkg/commands/ping.ts +15 -0
- package/src/pkg/commands/psetex.ts +14 -0
- package/src/pkg/commands/psubscribe.ts +26 -0
- package/src/pkg/commands/pttl.ts +12 -0
- package/src/pkg/commands/publish.ts +12 -0
- package/src/pkg/commands/randomkey.ts +12 -0
- package/src/pkg/commands/rename.ts +12 -0
- package/src/pkg/commands/renamenx.ts +12 -0
- package/src/pkg/commands/rpop.ts +21 -0
- package/src/pkg/commands/rpush.ts +12 -0
- package/src/pkg/commands/rpushx.ts +12 -0
- package/src/pkg/commands/sadd.ts +15 -0
- package/src/pkg/commands/scan.ts +63 -0
- package/src/pkg/commands/scard.ts +11 -0
- package/src/pkg/commands/script_exists.ts +15 -0
- package/src/pkg/commands/script_flush.ts +22 -0
- package/src/pkg/commands/script_load.ts +12 -0
- package/src/pkg/commands/sdiff.ts +11 -0
- package/src/pkg/commands/sdiffstore.ts +14 -0
- package/src/pkg/commands/search/command-builder.ts +162 -0
- package/src/pkg/commands/search/index.ts +4 -0
- package/src/pkg/commands/search/schema-builder.ts +320 -0
- package/src/pkg/commands/search/search.ts +218 -0
- package/src/pkg/commands/search/types.ts +1029 -0
- package/src/pkg/commands/search/utils.ts +275 -0
- package/src/pkg/commands/set.ts +52 -0
- package/src/pkg/commands/setbit.ts +15 -0
- package/src/pkg/commands/setex.ts +11 -0
- package/src/pkg/commands/setnx.ts +11 -0
- package/src/pkg/commands/setrange.ts +15 -0
- package/src/pkg/commands/sinter.ts +11 -0
- package/src/pkg/commands/sintercard.ts +19 -0
- package/src/pkg/commands/sinterstore.ts +14 -0
- package/src/pkg/commands/sismember.ts +11 -0
- package/src/pkg/commands/smembers.ts +12 -0
- package/src/pkg/commands/smismember.ts +17 -0
- package/src/pkg/commands/smove.ts +14 -0
- package/src/pkg/commands/spop.ts +18 -0
- package/src/pkg/commands/srandmember.ts +18 -0
- package/src/pkg/commands/srem.ts +11 -0
- package/src/pkg/commands/sscan.ts +31 -0
- package/src/pkg/commands/strlen.ts +12 -0
- package/src/pkg/commands/subscribe.ts +254 -0
- package/src/pkg/commands/sunion.ts +12 -0
- package/src/pkg/commands/sunionstore.ts +15 -0
- package/src/pkg/commands/time.ts +10 -0
- package/src/pkg/commands/touch.ts +12 -0
- package/src/pkg/commands/ttl.ts +12 -0
- package/src/pkg/commands/type.ts +13 -0
- package/src/pkg/commands/types.ts +201 -0
- package/src/pkg/commands/unlink.ts +12 -0
- package/src/pkg/commands/vector/index.ts +11 -0
- package/src/pkg/commands/vector/types.ts +63 -0
- package/src/pkg/commands/vector/utils.ts +67 -0
- package/src/pkg/commands/vector/vector.ts +131 -0
- package/src/pkg/commands/vector_add.ts +18 -0
- package/src/pkg/commands/vector_count.ts +11 -0
- package/src/pkg/commands/vector_create.ts +28 -0
- package/src/pkg/commands/vector_del.ts +13 -0
- package/src/pkg/commands/vector_drop.ts +13 -0
- package/src/pkg/commands/vector_get.ts +18 -0
- package/src/pkg/commands/vector_info.ts +25 -0
- package/src/pkg/commands/vector_query.ts +24 -0
- package/src/pkg/commands/xack.ts +16 -0
- package/src/pkg/commands/xackdel.ts +21 -0
- package/src/pkg/commands/xadd.ts +70 -0
- package/src/pkg/commands/xautoclaim.ts +31 -0
- package/src/pkg/commands/xclaim.ts +56 -0
- package/src/pkg/commands/xdel.ts +16 -0
- package/src/pkg/commands/xdelex.ts +25 -0
- package/src/pkg/commands/xgroup.ts +101 -0
- package/src/pkg/commands/xinfo.ts +28 -0
- package/src/pkg/commands/xlen.ts +12 -0
- package/src/pkg/commands/xpending.ts +44 -0
- package/src/pkg/commands/xrange.ts +49 -0
- package/src/pkg/commands/xread.ts +78 -0
- package/src/pkg/commands/xreadgroup.ts +74 -0
- package/src/pkg/commands/xrevrange.ts +48 -0
- package/src/pkg/commands/xtrim.ts +25 -0
- package/src/pkg/commands/zadd.ts +54 -0
- package/src/pkg/commands/zcard.ts +12 -0
- package/src/pkg/commands/zcount.ts +14 -0
- package/src/pkg/commands/zdiffstore.ts +15 -0
- package/src/pkg/commands/zincrby.ts +14 -0
- package/src/pkg/commands/zinterstore.ts +51 -0
- package/src/pkg/commands/zlexcount.ts +11 -0
- package/src/pkg/commands/zmscore.ts +16 -0
- package/src/pkg/commands/zpopmax.ts +18 -0
- package/src/pkg/commands/zpopmin.ts +18 -0
- package/src/pkg/commands/zrange.ts +72 -0
- package/src/pkg/commands/zrank.ts +14 -0
- package/src/pkg/commands/zrem.ts +11 -0
- package/src/pkg/commands/zremrangebylex.ts +11 -0
- package/src/pkg/commands/zremrangebyrank.ts +14 -0
- package/src/pkg/commands/zremrangebyscore.ts +18 -0
- package/src/pkg/commands/zrevrank.ts +14 -0
- package/src/pkg/commands/zscan.ts +31 -0
- package/src/pkg/commands/zscore.ts +15 -0
- package/src/pkg/commands/zunion.ts +54 -0
- package/src/pkg/commands/zunionstore.ts +52 -0
- package/src/pkg/error.ts +28 -0
- package/src/pkg/http.ts +458 -0
- package/src/pkg/index.ts +1 -0
- package/src/pkg/pipeline.ts +2041 -0
- package/src/pkg/redis.ts +2130 -0
- package/src/pkg/script.ts +100 -0
- package/src/pkg/scriptRo.ts +98 -0
- package/src/pkg/types.ts +35 -0
- package/src/pkg/util.ts +115 -0
- package/src/platforms/cloudflare.ts +162 -0
- package/src/platforms/fastly.ts +105 -0
- package/src/platforms/nodejs.ts +231 -0
- package/src/version.ts +1 -0
package/src/pkg/http.ts
ADDED
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
import { UpstashError, UpstashJSONParseError, UrlError } from "./error";
|
|
2
|
+
import type { Telemetry } from "./types";
|
|
3
|
+
import { mergeHeaders } from "./util";
|
|
4
|
+
|
|
5
|
+
type CacheSetting =
|
|
6
|
+
| "default"
|
|
7
|
+
| "force-cache"
|
|
8
|
+
| "no-cache"
|
|
9
|
+
| "no-store"
|
|
10
|
+
| "only-if-cached"
|
|
11
|
+
| "reload";
|
|
12
|
+
|
|
13
|
+
const MAX_BUFFER_SIZE = 1024 * 1024;
|
|
14
|
+
|
|
15
|
+
export type UpstashRequest = {
|
|
16
|
+
path?: string[];
|
|
17
|
+
/**
|
|
18
|
+
* Request body will be serialized to json
|
|
19
|
+
*/
|
|
20
|
+
body?: unknown;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Additional headers for the request
|
|
24
|
+
*/
|
|
25
|
+
headers?: Record<string, string>;
|
|
26
|
+
|
|
27
|
+
upstashSyncToken?: string;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Callback for handling streaming messages
|
|
31
|
+
*/
|
|
32
|
+
onMessage?: (data: string) => void;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Whether this request expects a streaming response
|
|
36
|
+
*/
|
|
37
|
+
isStreaming?: boolean;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Abort signal for the request
|
|
41
|
+
*/
|
|
42
|
+
signal?: AbortSignal;
|
|
43
|
+
};
|
|
44
|
+
export type UpstashResponse<TResult> = { result?: TResult; error?: string };
|
|
45
|
+
|
|
46
|
+
export interface Requester {
|
|
47
|
+
/**
|
|
48
|
+
* When this flag is enabled, any subsequent commands issued by this client are guaranteed to observe the effects of all earlier writes submitted by the same client.
|
|
49
|
+
*/
|
|
50
|
+
readYourWrites?: boolean;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* This token is used to ensure that the client is in sync with the server. On each request, we send this token in the header, and the server will return a new token.
|
|
54
|
+
*/
|
|
55
|
+
upstashSyncToken?: string;
|
|
56
|
+
request: <TResult = unknown>(req: UpstashRequest) => Promise<UpstashResponse<TResult>>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
type ResultError = {
|
|
60
|
+
result?: string | number | null | (string | number | null)[];
|
|
61
|
+
error?: string;
|
|
62
|
+
};
|
|
63
|
+
export type RetryConfig =
|
|
64
|
+
| false
|
|
65
|
+
| {
|
|
66
|
+
/**
|
|
67
|
+
* The number of retries to attempt before giving up.
|
|
68
|
+
*
|
|
69
|
+
* @default 5
|
|
70
|
+
*/
|
|
71
|
+
retries?: number;
|
|
72
|
+
/**
|
|
73
|
+
* A backoff function receives the current retry count and returns a number in milliseconds to wait before retrying.
|
|
74
|
+
*
|
|
75
|
+
* @default
|
|
76
|
+
* ```ts
|
|
77
|
+
* Math.exp(retryCount) * 50
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
backoff?: (retryCount: number) => number;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export type Options = {
|
|
84
|
+
backend?: string;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export type RequesterConfig = {
|
|
88
|
+
/**
|
|
89
|
+
* Configure the retry behaviour in case of network errors
|
|
90
|
+
*/
|
|
91
|
+
retry?: RetryConfig;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Response encoding requested from the server.
|
|
95
|
+
*
|
|
96
|
+
* By default the server returns string values as plain JSON strings. Set this to "base64" to have
|
|
97
|
+
* the server base64-encode string values, which the client decodes as utf8. This increases the
|
|
98
|
+
* response size by about 33%.
|
|
99
|
+
*
|
|
100
|
+
* @default false
|
|
101
|
+
*/
|
|
102
|
+
responseEncoding?: false | "base64";
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Configure the cache behaviour
|
|
106
|
+
* @default "no-store"
|
|
107
|
+
*/
|
|
108
|
+
cache?: CacheSetting;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export type HttpClientConfig = {
|
|
112
|
+
headers?: Record<string, string>;
|
|
113
|
+
baseUrl: string;
|
|
114
|
+
options?: Options;
|
|
115
|
+
retry?: RetryConfig;
|
|
116
|
+
agent?: any;
|
|
117
|
+
signal?: AbortSignal | (() => AbortSignal);
|
|
118
|
+
keepAlive?: boolean;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* When this flag is enabled, any subsequent commands issued by this client are guaranteed to observe the effects of all earlier writes submitted by the same client.
|
|
122
|
+
*/
|
|
123
|
+
readYourWrites?: boolean;
|
|
124
|
+
} & RequesterConfig;
|
|
125
|
+
|
|
126
|
+
export class HttpClient implements Requester {
|
|
127
|
+
public baseUrl: string;
|
|
128
|
+
public headers: Record<string, string>;
|
|
129
|
+
|
|
130
|
+
public readonly options: {
|
|
131
|
+
backend?: string;
|
|
132
|
+
agent: any;
|
|
133
|
+
signal?: HttpClientConfig["signal"];
|
|
134
|
+
responseEncoding?: false | "base64";
|
|
135
|
+
cache?: CacheSetting;
|
|
136
|
+
keepAlive: boolean;
|
|
137
|
+
};
|
|
138
|
+
public readYourWrites: boolean;
|
|
139
|
+
public upstashSyncToken = "";
|
|
140
|
+
private hasCredentials: boolean;
|
|
141
|
+
|
|
142
|
+
public readonly retry: {
|
|
143
|
+
attempts: number;
|
|
144
|
+
backoff: (retryCount: number) => number;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
public constructor(config: HttpClientConfig) {
|
|
148
|
+
this.options = {
|
|
149
|
+
backend: config.options?.backend,
|
|
150
|
+
agent: config.agent,
|
|
151
|
+
responseEncoding: config.responseEncoding ?? false,
|
|
152
|
+
cache: config.cache,
|
|
153
|
+
signal: config.signal,
|
|
154
|
+
keepAlive: config.keepAlive ?? true,
|
|
155
|
+
};
|
|
156
|
+
this.upstashSyncToken = "";
|
|
157
|
+
this.readYourWrites = config.readYourWrites ?? true;
|
|
158
|
+
|
|
159
|
+
this.baseUrl = (config.baseUrl || "").replace(/\/$/, "");
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* regex to check if the baseUrl starts with http:// or https://
|
|
163
|
+
* - `^` asserts the position at the start of the string.
|
|
164
|
+
* - `[^\s/$.?#]` makes sure that the domain starts correctly;
|
|
165
|
+
* without white space, '/', '$', '.', '?' or '#'
|
|
166
|
+
* - `.` matches any character except new line
|
|
167
|
+
* - `[^\s]*` matches anything except white space
|
|
168
|
+
* - `$` asserts the position at the end of the string.
|
|
169
|
+
*/
|
|
170
|
+
const urlRegex = /^https?:\/\/[^\s#$./?].\S*$/;
|
|
171
|
+
if (this.baseUrl && !urlRegex.test(this.baseUrl)) {
|
|
172
|
+
throw new UrlError(this.baseUrl);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
this.headers = {
|
|
176
|
+
"Content-Type": "application/json",
|
|
177
|
+
|
|
178
|
+
...config.headers,
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
this.hasCredentials = Boolean(this.baseUrl && this.headers.authorization.split(" ")[1]);
|
|
182
|
+
|
|
183
|
+
if (this.options.responseEncoding === "base64") {
|
|
184
|
+
this.headers["Upstash-Encoding"] = "base64";
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
this.retry =
|
|
188
|
+
typeof config.retry === "boolean" && !config.retry
|
|
189
|
+
? {
|
|
190
|
+
attempts: 1,
|
|
191
|
+
backoff: () => 0,
|
|
192
|
+
}
|
|
193
|
+
: {
|
|
194
|
+
attempts: config.retry?.retries ?? 5,
|
|
195
|
+
backoff: config.retry?.backoff ?? ((retryCount) => Math.exp(retryCount) * 50),
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
public mergeTelemetry(telemetry: Telemetry): void {
|
|
200
|
+
this.headers = merge(this.headers, "Upstash-Telemetry-Runtime", telemetry.runtime);
|
|
201
|
+
this.headers = merge(this.headers, "Upstash-Telemetry-Platform", telemetry.platform);
|
|
202
|
+
this.headers = merge(this.headers, "Upstash-Telemetry-Sdk", telemetry.sdk);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
public async request<TResult>(req: UpstashRequest): Promise<UpstashResponse<TResult>> {
|
|
206
|
+
/**
|
|
207
|
+
* We've received a new `upstash-sync-token` in the previous response. We use it in the next
|
|
208
|
+
* request to observe the effects of previous requests.
|
|
209
|
+
*
|
|
210
|
+
* This has to happen *before* the headers are merged below: `mergeHeaders` copies
|
|
211
|
+
* `this.headers`, so writing the token afterwards would only reach the request after this one.
|
|
212
|
+
*/
|
|
213
|
+
if (this.readYourWrites) {
|
|
214
|
+
this.headers["upstash-sync-token"] = this.upstashSyncToken;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const requestHeaders = mergeHeaders(this.headers, req.headers ?? {});
|
|
218
|
+
const requestUrl = [this.baseUrl, ...(req.path ?? [])].join("/");
|
|
219
|
+
const isEventStream = requestHeaders.Accept === "text/event-stream";
|
|
220
|
+
|
|
221
|
+
const signal = req.signal ?? this.options.signal;
|
|
222
|
+
const isSignalFunction = typeof signal === "function";
|
|
223
|
+
|
|
224
|
+
const requestOptions: RequestInit & { backend?: string; agent?: any } = {
|
|
225
|
+
cache: this.options.cache,
|
|
226
|
+
method: "POST",
|
|
227
|
+
headers: requestHeaders,
|
|
228
|
+
body: JSON.stringify(req.body),
|
|
229
|
+
keepalive: this.options.keepAlive,
|
|
230
|
+
agent: this.options.agent,
|
|
231
|
+
signal: isSignalFunction ? signal() : signal,
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Fastly specific
|
|
235
|
+
*/
|
|
236
|
+
backend: this.options.backend,
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
if (!this.hasCredentials) {
|
|
240
|
+
console.warn(
|
|
241
|
+
"[Upstash Redis] Redis client was initialized without url or token." +
|
|
242
|
+
" Failed to execute command."
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
let res: Response | null = null;
|
|
247
|
+
let error: Error | null = null;
|
|
248
|
+
for (let i = 0; i <= this.retry.attempts; i++) {
|
|
249
|
+
if (i > 0 && requestHeaders["Upstash-Telemetry-Sdk"]) {
|
|
250
|
+
// Mark retried attempts with the retry count so the server can track how often clients retry.
|
|
251
|
+
requestHeaders["Upstash-Telemetry-Retry"] = String(i);
|
|
252
|
+
}
|
|
253
|
+
try {
|
|
254
|
+
res = await fetch(requestUrl, requestOptions);
|
|
255
|
+
break;
|
|
256
|
+
} catch (error_) {
|
|
257
|
+
if (requestOptions.signal?.aborted && isSignalFunction) {
|
|
258
|
+
throw error_;
|
|
259
|
+
} else if (requestOptions.signal?.aborted) {
|
|
260
|
+
const reason: unknown = requestOptions.signal.reason;
|
|
261
|
+
const myBlob = new Blob([
|
|
262
|
+
// Error reasons (e.g. the default DOMException) would serialize to an empty object
|
|
263
|
+
JSON.stringify({ result: reason instanceof Error ? null : (reason ?? null) }),
|
|
264
|
+
]);
|
|
265
|
+
const myOptions = {
|
|
266
|
+
status: 200,
|
|
267
|
+
statusText: "Aborted",
|
|
268
|
+
};
|
|
269
|
+
res = new Response(myBlob, myOptions);
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
error = error_ as Error;
|
|
273
|
+
|
|
274
|
+
// Only sleep if this is not the last attempt
|
|
275
|
+
if (i < this.retry.attempts) {
|
|
276
|
+
await new Promise((r) => setTimeout(r, this.retry.backoff(i)));
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (!res) {
|
|
281
|
+
throw error ?? new Error("Exhausted all retries");
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if (!res.ok) {
|
|
285
|
+
let body: UpstashResponse<string>;
|
|
286
|
+
const rawBody = await res.text();
|
|
287
|
+
try {
|
|
288
|
+
body = JSON.parse(rawBody) as UpstashResponse<string>;
|
|
289
|
+
} catch (error) {
|
|
290
|
+
throw new UpstashJSONParseError(rawBody, { cause: error });
|
|
291
|
+
}
|
|
292
|
+
throw new UpstashError(`${body.error}, command was: ${JSON.stringify(req.body)}`);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (this.readYourWrites) {
|
|
296
|
+
const headers = res.headers;
|
|
297
|
+
this.upstashSyncToken = headers.get("upstash-sync-token") ?? "";
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (isEventStream && req && req.onMessage && res.body) {
|
|
301
|
+
const reader = res.body.getReader();
|
|
302
|
+
const decoder = new TextDecoder();
|
|
303
|
+
|
|
304
|
+
// Start reading the stream in the background
|
|
305
|
+
(async () => {
|
|
306
|
+
try {
|
|
307
|
+
let buffer = "";
|
|
308
|
+
|
|
309
|
+
while (true) {
|
|
310
|
+
const { value, done } = await reader.read();
|
|
311
|
+
if (done) break;
|
|
312
|
+
|
|
313
|
+
buffer += decoder.decode(value, { stream: true });
|
|
314
|
+
const lines = buffer.split("\n");
|
|
315
|
+
buffer = lines.pop() || "";
|
|
316
|
+
|
|
317
|
+
if (buffer.length > MAX_BUFFER_SIZE) {
|
|
318
|
+
throw new Error("Buffer size exceeded (1MB)");
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
for (const line of lines) {
|
|
322
|
+
if (line.startsWith("data: ")) {
|
|
323
|
+
const data = line.slice(6);
|
|
324
|
+
req.onMessage?.(data);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
} catch (error) {
|
|
329
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
330
|
+
// Expected error during unsubscribe, ignore
|
|
331
|
+
} else {
|
|
332
|
+
console.error("Stream reading error:", error);
|
|
333
|
+
}
|
|
334
|
+
} finally {
|
|
335
|
+
try {
|
|
336
|
+
await reader.cancel();
|
|
337
|
+
} catch {
|
|
338
|
+
//ignore
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
})();
|
|
342
|
+
|
|
343
|
+
// Return success for streaming requests
|
|
344
|
+
return { result: 1 as TResult };
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
let body: UpstashResponse<string>;
|
|
348
|
+
const rawBody = await res.text();
|
|
349
|
+
try {
|
|
350
|
+
body = JSON.parse(rawBody) as UpstashResponse<string>;
|
|
351
|
+
} catch (error) {
|
|
352
|
+
throw new UpstashJSONParseError(rawBody, { cause: error });
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* We save the new `upstash-sync-token` in the response header to use it in the next request.
|
|
357
|
+
*/
|
|
358
|
+
if (this.readYourWrites) {
|
|
359
|
+
const headers = res.headers;
|
|
360
|
+
this.upstashSyncToken = headers.get("upstash-sync-token") ?? "";
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (this.options.responseEncoding === "base64") {
|
|
364
|
+
if (Array.isArray(body)) {
|
|
365
|
+
return body.map(({ result, error }) => ({
|
|
366
|
+
result: decode(result),
|
|
367
|
+
error,
|
|
368
|
+
})) as UpstashResponse<TResult>;
|
|
369
|
+
}
|
|
370
|
+
const result = decode(body.result) as any;
|
|
371
|
+
return { result, error: body.error };
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
return body as UpstashResponse<TResult>;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function base64decode(b64: string): string {
|
|
379
|
+
let dec = "";
|
|
380
|
+
try {
|
|
381
|
+
/**
|
|
382
|
+
* Using only atob() is not enough because it doesn't work with unicode characters
|
|
383
|
+
*/
|
|
384
|
+
const binString = atob(b64);
|
|
385
|
+
const size = binString.length;
|
|
386
|
+
const bytes = new Uint8Array(size);
|
|
387
|
+
for (let i = 0; i < size; i++) {
|
|
388
|
+
// eslint-disable-next-line unicorn/prefer-code-point
|
|
389
|
+
bytes[i] = binString.charCodeAt(i);
|
|
390
|
+
}
|
|
391
|
+
dec = new TextDecoder().decode(bytes);
|
|
392
|
+
} catch {
|
|
393
|
+
dec = b64;
|
|
394
|
+
}
|
|
395
|
+
return dec;
|
|
396
|
+
// try {
|
|
397
|
+
// return decodeURIComponent(dec);
|
|
398
|
+
// } catch {
|
|
399
|
+
// return dec;
|
|
400
|
+
// }
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function decode(raw: ResultError["result"]): ResultError["result"] {
|
|
404
|
+
let result: any = undefined;
|
|
405
|
+
switch (typeof raw) {
|
|
406
|
+
case "undefined": {
|
|
407
|
+
return raw;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
case "number": {
|
|
411
|
+
result = raw;
|
|
412
|
+
break;
|
|
413
|
+
}
|
|
414
|
+
case "object": {
|
|
415
|
+
// eslint-disable-next-line unicorn/prefer-ternary
|
|
416
|
+
if (Array.isArray(raw)) {
|
|
417
|
+
result = raw.map((v) =>
|
|
418
|
+
typeof v === "string"
|
|
419
|
+
? base64decode(v)
|
|
420
|
+
: Array.isArray(v)
|
|
421
|
+
? v.map((element) => decode(element))
|
|
422
|
+
: v
|
|
423
|
+
);
|
|
424
|
+
} else {
|
|
425
|
+
// If it's not an array it must be null
|
|
426
|
+
// Apparently null is an object in javascript
|
|
427
|
+
result = null;
|
|
428
|
+
}
|
|
429
|
+
break;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
case "string": {
|
|
433
|
+
result = raw === "OK" ? "OK" : base64decode(raw);
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
default: {
|
|
438
|
+
break;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
return result;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
function merge(obj: Record<string, string>, key: string, value?: string): Record<string, string> {
|
|
446
|
+
if (!value) {
|
|
447
|
+
return obj;
|
|
448
|
+
}
|
|
449
|
+
if (!obj[key]) {
|
|
450
|
+
obj[key] = value;
|
|
451
|
+
return obj;
|
|
452
|
+
}
|
|
453
|
+
const values = obj[key].split(",").map((v) => v.trim());
|
|
454
|
+
if (!values.includes(value.trim())) {
|
|
455
|
+
obj[key] = [obj[key], value].join(",");
|
|
456
|
+
}
|
|
457
|
+
return obj;
|
|
458
|
+
}
|
package/src/pkg/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./error";
|