@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
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import type { NestedIndexSchema, NumericField } from "./types";
|
|
2
|
+
|
|
3
|
+
type TextFieldBuild<
|
|
4
|
+
TNoTokenize extends Record<"noTokenize", boolean>,
|
|
5
|
+
TNoStem extends Record<"noStem", boolean>,
|
|
6
|
+
TFrom extends Record<"from", string | null>,
|
|
7
|
+
> = TNoTokenize["noTokenize"] extends true
|
|
8
|
+
? { type: "TEXT"; noTokenize: true } & (TNoStem["noStem"] extends true
|
|
9
|
+
? { noStem: true }
|
|
10
|
+
: // eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
11
|
+
{}) &
|
|
12
|
+
(TFrom["from"] extends string
|
|
13
|
+
? { from: TFrom["from"] }
|
|
14
|
+
: // eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
15
|
+
{})
|
|
16
|
+
: TNoStem["noStem"] extends true
|
|
17
|
+
? { type: "TEXT"; noStem: true } & (TFrom["from"] extends string
|
|
18
|
+
? { from: TFrom["from"] }
|
|
19
|
+
: // eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
20
|
+
{})
|
|
21
|
+
: TFrom["from"] extends string
|
|
22
|
+
? { type: "TEXT"; from: TFrom["from"] }
|
|
23
|
+
: { type: "TEXT" };
|
|
24
|
+
|
|
25
|
+
// Internal symbol for build method
|
|
26
|
+
const BUILD = Symbol("build");
|
|
27
|
+
|
|
28
|
+
// Field builders with chainable options
|
|
29
|
+
class TextFieldBuilder<
|
|
30
|
+
TNoTokenize extends Record<"noTokenize", boolean> = { noTokenize: false },
|
|
31
|
+
TNoStem extends Record<"noStem", boolean> = { noStem: false },
|
|
32
|
+
TFrom extends Record<"from", string | null> = { from: null },
|
|
33
|
+
> {
|
|
34
|
+
private _noTokenize: TNoTokenize;
|
|
35
|
+
private _noStem: TNoStem;
|
|
36
|
+
private _from: TFrom;
|
|
37
|
+
|
|
38
|
+
constructor(
|
|
39
|
+
noTokenize = { noTokenize: false } as TNoTokenize,
|
|
40
|
+
noStem = { noStem: false } as TNoStem,
|
|
41
|
+
from = { from: null } as TFrom
|
|
42
|
+
) {
|
|
43
|
+
this._noTokenize = noTokenize;
|
|
44
|
+
this._noStem = noStem;
|
|
45
|
+
this._from = from;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
noTokenize(): TextFieldBuilder<{ noTokenize: true }, TNoStem, TFrom> {
|
|
49
|
+
return new TextFieldBuilder({ noTokenize: true }, this._noStem, this._from);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
noStem(): TextFieldBuilder<TNoTokenize, { noStem: true }, TFrom> {
|
|
53
|
+
return new TextFieldBuilder(this._noTokenize, { noStem: true }, this._from);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
from(field: string): TextFieldBuilder<TNoTokenize, TNoStem, { from: string }> {
|
|
57
|
+
return new TextFieldBuilder(this._noTokenize, this._noStem, { from: field } as {
|
|
58
|
+
from: string;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
[BUILD](): TextFieldBuild<TNoTokenize, TNoStem, TFrom> {
|
|
63
|
+
return {
|
|
64
|
+
type: "TEXT",
|
|
65
|
+
...(this._noTokenize.noTokenize ? { noTokenize: true } : {}),
|
|
66
|
+
...(this._noStem.noStem ? { noStem: true } : {}),
|
|
67
|
+
...(this._from.from ? { from: this._from.from } : {}),
|
|
68
|
+
} as any;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
class NumericFieldBuilder<
|
|
73
|
+
T extends NumericField["type"],
|
|
74
|
+
TFrom extends Record<"from", string | null> = { from: null },
|
|
75
|
+
> {
|
|
76
|
+
private type: T;
|
|
77
|
+
private _from: TFrom;
|
|
78
|
+
|
|
79
|
+
constructor(type: T, from = { from: null } as TFrom) {
|
|
80
|
+
this.type = type;
|
|
81
|
+
this._from = from;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
from(field: string): NumericFieldBuilder<T, { from: string }> {
|
|
85
|
+
return new NumericFieldBuilder(this.type, { from: field } as { from: string });
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
[BUILD](): TFrom["from"] extends string
|
|
89
|
+
? { type: T; fast: true; from: TFrom["from"] }
|
|
90
|
+
: { type: T; fast: true } {
|
|
91
|
+
return this._from.from
|
|
92
|
+
? ({
|
|
93
|
+
type: this.type,
|
|
94
|
+
fast: true,
|
|
95
|
+
from: this._from.from,
|
|
96
|
+
} as any)
|
|
97
|
+
: ({
|
|
98
|
+
type: this.type,
|
|
99
|
+
fast: true,
|
|
100
|
+
} as any);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
class BoolFieldBuilder<
|
|
105
|
+
Fast extends Record<"fast", boolean> = { fast: false },
|
|
106
|
+
TFrom extends Record<"from", string | null> = { from: null },
|
|
107
|
+
> {
|
|
108
|
+
private _fast: Fast;
|
|
109
|
+
private _from: TFrom;
|
|
110
|
+
|
|
111
|
+
constructor(fast = { fast: false } as Fast, from = { from: null } as TFrom) {
|
|
112
|
+
this._fast = fast;
|
|
113
|
+
this._from = from;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
fast(): BoolFieldBuilder<{ fast: true }, TFrom> {
|
|
117
|
+
return new BoolFieldBuilder({ fast: true }, this._from);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
from(field: string): BoolFieldBuilder<Fast, { from: string }> {
|
|
121
|
+
return new BoolFieldBuilder(this._fast, { from: field } as { from: string });
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
[BUILD](): Fast extends { fast: true }
|
|
125
|
+
? TFrom["from"] extends string
|
|
126
|
+
? { type: "BOOL"; fast: true; from: TFrom["from"] }
|
|
127
|
+
: { type: "BOOL"; fast: true }
|
|
128
|
+
: TFrom["from"] extends string
|
|
129
|
+
? { type: "BOOL"; from: TFrom["from"] }
|
|
130
|
+
: { type: "BOOL" } {
|
|
131
|
+
const hasFast = this._fast.fast;
|
|
132
|
+
const hasFrom = Boolean(this._from.from);
|
|
133
|
+
|
|
134
|
+
if (hasFast && hasFrom) {
|
|
135
|
+
return {
|
|
136
|
+
type: "BOOL",
|
|
137
|
+
fast: true,
|
|
138
|
+
from: this._from.from,
|
|
139
|
+
} as any;
|
|
140
|
+
}
|
|
141
|
+
if (hasFast) {
|
|
142
|
+
return {
|
|
143
|
+
type: "BOOL",
|
|
144
|
+
fast: true,
|
|
145
|
+
} as any;
|
|
146
|
+
}
|
|
147
|
+
if (hasFrom) {
|
|
148
|
+
return {
|
|
149
|
+
type: "BOOL",
|
|
150
|
+
from: this._from.from,
|
|
151
|
+
} as any;
|
|
152
|
+
}
|
|
153
|
+
return { type: "BOOL" } as any;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
class DateFieldBuilder<
|
|
158
|
+
Fast extends Record<"fast", boolean> = { fast: false },
|
|
159
|
+
TFrom extends Record<"from", string | null> = { from: null },
|
|
160
|
+
> {
|
|
161
|
+
private _fast: Fast;
|
|
162
|
+
private _from: TFrom;
|
|
163
|
+
|
|
164
|
+
constructor(fast = { fast: false } as Fast, from = { from: null } as TFrom) {
|
|
165
|
+
this._fast = fast;
|
|
166
|
+
this._from = from;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
fast(): DateFieldBuilder<{ fast: true }, TFrom> {
|
|
170
|
+
return new DateFieldBuilder({ fast: true }, this._from);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
from(field: string): DateFieldBuilder<Fast, { from: string }> {
|
|
174
|
+
return new DateFieldBuilder(this._fast, { from: field } as { from: string });
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
[BUILD](): Fast extends { fast: true }
|
|
178
|
+
? TFrom["from"] extends string
|
|
179
|
+
? { type: "DATE"; fast: true; from: TFrom["from"] }
|
|
180
|
+
: { type: "DATE"; fast: true }
|
|
181
|
+
: TFrom["from"] extends string
|
|
182
|
+
? { type: "DATE"; from: TFrom["from"] }
|
|
183
|
+
: { type: "DATE" } {
|
|
184
|
+
const hasFast = this._fast.fast;
|
|
185
|
+
const hasFrom = Boolean(this._from.from);
|
|
186
|
+
|
|
187
|
+
if (hasFast && hasFrom) {
|
|
188
|
+
return {
|
|
189
|
+
type: "DATE",
|
|
190
|
+
fast: true,
|
|
191
|
+
from: this._from.from,
|
|
192
|
+
} as any;
|
|
193
|
+
}
|
|
194
|
+
if (hasFast) {
|
|
195
|
+
return {
|
|
196
|
+
type: "DATE",
|
|
197
|
+
fast: true,
|
|
198
|
+
} as any;
|
|
199
|
+
}
|
|
200
|
+
if (hasFrom) {
|
|
201
|
+
return {
|
|
202
|
+
type: "DATE",
|
|
203
|
+
from: this._from.from,
|
|
204
|
+
} as any;
|
|
205
|
+
}
|
|
206
|
+
return { type: "DATE" } as any;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
class HybridFieldBuilder<
|
|
211
|
+
TNoStem extends Record<"noStem", boolean> = { noStem: false },
|
|
212
|
+
TFrom extends Record<"from", string | null> = { from: null },
|
|
213
|
+
> {
|
|
214
|
+
private _noStem: TNoStem;
|
|
215
|
+
private _from: TFrom;
|
|
216
|
+
|
|
217
|
+
constructor(noStem = { noStem: false } as TNoStem, from = { from: null } as TFrom) {
|
|
218
|
+
this._noStem = noStem;
|
|
219
|
+
this._from = from;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
noStem(): HybridFieldBuilder<{ noStem: true }, TFrom> {
|
|
223
|
+
return new HybridFieldBuilder({ noStem: true }, this._from);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
from(field: string): HybridFieldBuilder<TNoStem, { from: string }> {
|
|
227
|
+
return new HybridFieldBuilder(this._noStem, { from: field } as { from: string });
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
[BUILD](): { type: "HYBRID" } & (TNoStem["noStem"] extends true
|
|
231
|
+
? { noStem: true }
|
|
232
|
+
: // eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
233
|
+
{}) &
|
|
234
|
+
(TFrom["from"] extends string
|
|
235
|
+
? { from: TFrom["from"] }
|
|
236
|
+
: // eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
237
|
+
{}) {
|
|
238
|
+
return {
|
|
239
|
+
type: "HYBRID",
|
|
240
|
+
...(this._noStem.noStem ? { noStem: true } : {}),
|
|
241
|
+
...(this._from.from ? { from: this._from.from } : {}),
|
|
242
|
+
} as any;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
class KeywordFieldBuilder {
|
|
247
|
+
[BUILD](): { type: "KEYWORD" } {
|
|
248
|
+
return { type: "KEYWORD" } as const;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
class FacetFieldBuilder {
|
|
253
|
+
[BUILD](): { type: "FACET" } {
|
|
254
|
+
return { type: "FACET" } as const;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
type FieldBuilder =
|
|
259
|
+
| TextFieldBuilder<{ noTokenize: boolean }, { noStem: boolean }, { from: string | null }>
|
|
260
|
+
| NumericFieldBuilder<NumericField["type"], { from: string | null }>
|
|
261
|
+
| BoolFieldBuilder<{ fast: boolean }, { from: string | null }>
|
|
262
|
+
| DateFieldBuilder<{ fast: boolean }, { from: string | null }>
|
|
263
|
+
| HybridFieldBuilder<{ noStem: boolean }, { from: string | null }>
|
|
264
|
+
| KeywordFieldBuilder
|
|
265
|
+
| FacetFieldBuilder;
|
|
266
|
+
|
|
267
|
+
export const s = {
|
|
268
|
+
string(): TextFieldBuilder {
|
|
269
|
+
return new TextFieldBuilder();
|
|
270
|
+
},
|
|
271
|
+
number<T extends NumericField["type"] = "F64">(type: T = "F64" as T): NumericFieldBuilder<T> {
|
|
272
|
+
return new NumericFieldBuilder(type);
|
|
273
|
+
},
|
|
274
|
+
boolean(): BoolFieldBuilder {
|
|
275
|
+
return new BoolFieldBuilder();
|
|
276
|
+
},
|
|
277
|
+
date(): DateFieldBuilder {
|
|
278
|
+
return new DateFieldBuilder();
|
|
279
|
+
},
|
|
280
|
+
/**
|
|
281
|
+
* A TEXT field that is also embedded for semantic search with `$ann`.
|
|
282
|
+
*
|
|
283
|
+
* @see https://upstash.com/docs/redis/search/hybrid-search
|
|
284
|
+
*/
|
|
285
|
+
hybrid(): HybridFieldBuilder {
|
|
286
|
+
return new HybridFieldBuilder();
|
|
287
|
+
},
|
|
288
|
+
keyword(): KeywordFieldBuilder {
|
|
289
|
+
return new KeywordFieldBuilder();
|
|
290
|
+
},
|
|
291
|
+
facet(): FacetFieldBuilder {
|
|
292
|
+
return new FacetFieldBuilder();
|
|
293
|
+
},
|
|
294
|
+
object<T extends ObjectFieldRecord<T>>(fields: T) {
|
|
295
|
+
const result: any = {};
|
|
296
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
297
|
+
// eslint-disable-next-line unicorn/prefer-ternary
|
|
298
|
+
if (value && typeof value === "object" && BUILD in value) {
|
|
299
|
+
// It's a field builder
|
|
300
|
+
result[key] = (value as any)[BUILD]();
|
|
301
|
+
} else {
|
|
302
|
+
// It's a nested object/schema
|
|
303
|
+
result[key] = value;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return result as {
|
|
307
|
+
[K in keyof T]: T[K] extends FieldBuilder ? ReturnType<T[K][typeof BUILD]> : T[K];
|
|
308
|
+
};
|
|
309
|
+
},
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
type ObjectFieldRecord<T> = {
|
|
313
|
+
[K in keyof T]: K extends string
|
|
314
|
+
? K extends `${infer _}.${infer _}`
|
|
315
|
+
? never
|
|
316
|
+
: T[K] extends FieldBuilder | NestedIndexSchema
|
|
317
|
+
? T[K]
|
|
318
|
+
: never
|
|
319
|
+
: never;
|
|
320
|
+
};
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AggregateOptions,
|
|
3
|
+
AggregateResult,
|
|
4
|
+
CountRetriever,
|
|
5
|
+
FlatIndexSchema,
|
|
6
|
+
IndexDescription,
|
|
7
|
+
Language,
|
|
8
|
+
NestedIndexSchema,
|
|
9
|
+
QueryOptions,
|
|
10
|
+
QueryResult,
|
|
11
|
+
RootQueryFilter,
|
|
12
|
+
} from "./types";
|
|
13
|
+
import type { Requester } from "../../http";
|
|
14
|
+
import { ExecCommand } from "../exec";
|
|
15
|
+
import {
|
|
16
|
+
buildAggregateCommand,
|
|
17
|
+
buildCreateIndexCommand,
|
|
18
|
+
buildQueryCommand,
|
|
19
|
+
} from "./command-builder";
|
|
20
|
+
import {
|
|
21
|
+
deserializeAggregateResponse,
|
|
22
|
+
deserializeDescribeResponse,
|
|
23
|
+
deserializeQueryResponse,
|
|
24
|
+
parseCountResponse,
|
|
25
|
+
} from "./utils";
|
|
26
|
+
|
|
27
|
+
export type CreateIndexParameters<TSchema extends NestedIndexSchema | FlatIndexSchema> = {
|
|
28
|
+
name: string;
|
|
29
|
+
language?: Language;
|
|
30
|
+
skipInitialScan?: boolean;
|
|
31
|
+
existsOk?: boolean;
|
|
32
|
+
} & (
|
|
33
|
+
| {
|
|
34
|
+
dataType: "string";
|
|
35
|
+
prefix: string | string[];
|
|
36
|
+
schema: TSchema extends NestedIndexSchema ? TSchema : never;
|
|
37
|
+
}
|
|
38
|
+
| {
|
|
39
|
+
dataType: "json";
|
|
40
|
+
prefix: string | string[];
|
|
41
|
+
schema: TSchema extends NestedIndexSchema ? TSchema : never;
|
|
42
|
+
}
|
|
43
|
+
| {
|
|
44
|
+
dataType: "hash";
|
|
45
|
+
prefix: string | string[];
|
|
46
|
+
schema: TSchema extends FlatIndexSchema ? TSchema : never;
|
|
47
|
+
}
|
|
48
|
+
| {
|
|
49
|
+
/**
|
|
50
|
+
* Index the entries of a single Redis stream. Each entry becomes a document whose key is
|
|
51
|
+
* the entry ID and whose fields are the entry's fields.
|
|
52
|
+
*
|
|
53
|
+
* @see https://upstash.com/docs/redis/search/streams
|
|
54
|
+
*/
|
|
55
|
+
dataType: "stream";
|
|
56
|
+
/**
|
|
57
|
+
* Exact key of the stream to index. The stream does not need to exist yet.
|
|
58
|
+
*/
|
|
59
|
+
stream: string;
|
|
60
|
+
prefix?: never;
|
|
61
|
+
schema: TSchema extends FlatIndexSchema ? TSchema : never;
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
export type InitIndexParameters<TSchema extends NestedIndexSchema | FlatIndexSchema> = {
|
|
66
|
+
name: string;
|
|
67
|
+
schema?: TSchema;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export type SearchIndexParameters<TSchema extends NestedIndexSchema | FlatIndexSchema> = {
|
|
71
|
+
name: string;
|
|
72
|
+
client: Requester;
|
|
73
|
+
schema?: TSchema;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export class SearchIndex<TSchema extends NestedIndexSchema | FlatIndexSchema> {
|
|
77
|
+
readonly name: SearchIndexParameters<TSchema>["name"];
|
|
78
|
+
readonly schema?: TSchema;
|
|
79
|
+
private client: Requester;
|
|
80
|
+
|
|
81
|
+
constructor({ name, schema, client }: SearchIndexParameters<TSchema>) {
|
|
82
|
+
this.name = name;
|
|
83
|
+
this.schema = schema;
|
|
84
|
+
this.client = client;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async waitIndexing(): Promise<0 | 1> {
|
|
88
|
+
const command = ["SEARCH.WAITINDEXING", this.name];
|
|
89
|
+
return await new ExecCommand<0 | 1>(command as [string, ...string[]]).exec(this.client);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async describe(): Promise<IndexDescription<TSchema> | null> {
|
|
93
|
+
const command = ["SEARCH.DESCRIBE", this.name];
|
|
94
|
+
const rawResult = await new ExecCommand<any>(command as [string, ...string[]]).exec(
|
|
95
|
+
this.client
|
|
96
|
+
);
|
|
97
|
+
if (!rawResult) return null;
|
|
98
|
+
return deserializeDescribeResponse<TSchema>(rawResult);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async query<TOpts extends QueryOptions<TSchema>>(
|
|
102
|
+
options?: TOpts
|
|
103
|
+
): Promise<QueryResult<TSchema, TOpts>[]> {
|
|
104
|
+
const command = buildQueryCommand<TSchema>("SEARCH.QUERY", this.name, options);
|
|
105
|
+
const rawResult = await new ExecCommand<string[]>(command as [string, ...string[]]).exec(
|
|
106
|
+
this.client
|
|
107
|
+
);
|
|
108
|
+
if (!rawResult) return rawResult;
|
|
109
|
+
return deserializeQueryResponse<TSchema, TOpts>(rawResult);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async aggregate<TOpts extends AggregateOptions<TSchema>>(
|
|
113
|
+
options: TOpts
|
|
114
|
+
): Promise<AggregateResult<TSchema, TOpts>> {
|
|
115
|
+
const command = buildAggregateCommand(this.name, options);
|
|
116
|
+
const rawResult = await new ExecCommand<(string | number)[]>(
|
|
117
|
+
command as [string, ...string[]]
|
|
118
|
+
).exec(this.client);
|
|
119
|
+
return deserializeAggregateResponse(rawResult);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async count({
|
|
123
|
+
filter,
|
|
124
|
+
}: {
|
|
125
|
+
filter: RootQueryFilter<TSchema> | CountRetriever<TSchema>;
|
|
126
|
+
}): Promise<{ count: number }> {
|
|
127
|
+
const command = buildQueryCommand<TSchema>("SEARCH.COUNT", this.name, {
|
|
128
|
+
filter,
|
|
129
|
+
} as QueryOptions<TSchema>);
|
|
130
|
+
const rawResult = await new ExecCommand<any>(command as [string, ...string[]]).exec(
|
|
131
|
+
this.client
|
|
132
|
+
);
|
|
133
|
+
return { count: parseCountResponse(rawResult) };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
async drop(): Promise<1 | 0> {
|
|
137
|
+
const command = ["SEARCH.DROP", this.name];
|
|
138
|
+
const result = await new ExecCommand<1 | 0>(command as [string, ...string[]]).exec(this.client);
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async addAlias({ alias }: { alias: string }): Promise<1> {
|
|
143
|
+
const command = ["SEARCH.ALIASADD", alias, this.name];
|
|
144
|
+
const result = await new ExecCommand<1>(command as [string, ...string[]]).exec(this.client);
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export async function createIndex<TSchema extends NestedIndexSchema | FlatIndexSchema>(
|
|
150
|
+
client: Requester,
|
|
151
|
+
params: CreateIndexParameters<TSchema>
|
|
152
|
+
): Promise<SearchIndex<TSchema>> {
|
|
153
|
+
const { name, schema } = params;
|
|
154
|
+
const createIndexCommand = buildCreateIndexCommand<TSchema>(params);
|
|
155
|
+
await new ExecCommand<string>(createIndexCommand as [string, ...string[]]).exec(client);
|
|
156
|
+
|
|
157
|
+
return initIndex(client, { name, schema: schema as TSchema });
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export function initIndex(
|
|
161
|
+
client: Requester,
|
|
162
|
+
params: Pick<InitIndexParameters<any>, "name">
|
|
163
|
+
): SearchIndex<any>;
|
|
164
|
+
export function initIndex<TSchema extends NestedIndexSchema | FlatIndexSchema>(
|
|
165
|
+
client: Requester,
|
|
166
|
+
params: InitIndexParameters<TSchema>
|
|
167
|
+
): SearchIndex<TSchema>;
|
|
168
|
+
export function initIndex<TSchema extends NestedIndexSchema | FlatIndexSchema>(
|
|
169
|
+
client: Requester,
|
|
170
|
+
params: InitIndexParameters<TSchema>
|
|
171
|
+
): SearchIndex<TSchema> {
|
|
172
|
+
const { name, schema } = params;
|
|
173
|
+
return new SearchIndex<TSchema>({ name, schema, client });
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export type InferFilterFromSchema<TSchema extends NestedIndexSchema | FlatIndexSchema> =
|
|
177
|
+
NonNullable<NonNullable<Parameters<SearchIndex<TSchema>["query"]>[0]>["filter"]>;
|
|
178
|
+
|
|
179
|
+
export async function listAliases(client: Requester): Promise<Record<string, string>> {
|
|
180
|
+
const command = ["SEARCH.LISTALIASES"];
|
|
181
|
+
const rawResult = await new ExecCommand<any>(command as [string, ...string[]]).exec(client);
|
|
182
|
+
|
|
183
|
+
// Handle empty case - might be 0 or an empty array
|
|
184
|
+
if (rawResult === 0 || (Array.isArray(rawResult) && rawResult.length === 0)) {
|
|
185
|
+
return {};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// Parse the response: [[alias1, index1], [alias2, index2], ...]
|
|
189
|
+
if (!Array.isArray(rawResult)) {
|
|
190
|
+
return {};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const aliases: Record<string, string> = {};
|
|
194
|
+
|
|
195
|
+
for (const pair of rawResult) {
|
|
196
|
+
if (Array.isArray(pair) && pair.length === 2) {
|
|
197
|
+
const [alias, index] = pair;
|
|
198
|
+
aliases[alias] = index;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return aliases;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export async function addAlias(
|
|
206
|
+
client: Requester,
|
|
207
|
+
{ indexName, alias }: { indexName: string; alias: string }
|
|
208
|
+
): Promise<1 | 2> {
|
|
209
|
+
const command = ["SEARCH.ALIASADD", alias, indexName];
|
|
210
|
+
const result = await new ExecCommand<1 | 2>(command as [string, ...string[]]).exec(client);
|
|
211
|
+
return result;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export async function delAlias(client: Requester, { alias }: { alias: string }): Promise<0 | 1> {
|
|
215
|
+
const command = ["SEARCH.ALIASDEL", alias];
|
|
216
|
+
const result = await new ExecCommand<0 | 1>(command as [string, ...string[]]).exec(client);
|
|
217
|
+
return result;
|
|
218
|
+
}
|