1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00
This commit is contained in:
Leibale
2023-10-23 15:05:16 -04:00
parent 42b05b025b
commit 817818aa91
29 changed files with 628 additions and 854 deletions

View File

@@ -1,8 +1,6 @@
- Does `close`/`destory` actually close the connection from the Redis POV? Works with OSS, but what about Redis Enterprie?
- "Isolation Pool" -> pool
- Cluster request response policies (either implement, or block "server" commands in cluster)
Docs:
- [v4 to v5](./v4-to-v5.md) - Legacy mode
- [Command Options](./command-options.md)
- [RESP](./RESP.md)

View File

@@ -77,7 +77,11 @@ legacyClient.set('key', 'value', (err, reply) => {
## Isolation Pool
TODO
[TODO](./blocking-commands.md).
```javascript
await client.get(client.commandOptions({ isolated: true }), 'key');
```
```javascript
await client.sendCommand(['GET', 'key']);
@@ -123,35 +127,47 @@ await cluster.multi()
## Commands
Some command arguments/replies have changed to align more closely to data types returned by Redis:
### Redis
- `ACL GETUSER`: `selectors`
- `COPY`: `destinationDb` -> `DB`, `replace` -> `REPLACE`, `boolean` -> `number` [^boolean-to-number]
- `CLIENT KILL`: `enum ClientKillFilters` -> `const CLIENT_KILL_FILTERS` [^enum-to-constants]
- `CLUSTER FAILOVER`: `enum FailoverModes` -> `const FAILOVER_MODES` [^enum-to-constants]
- `LCS IDX`: `length` has been changed to `len`, `matches` has been changed from `Array<{ key1: RangeReply; key2: RangeReply; }>` to `Array<[key1: RangeReply, key2: RangeReply]>`
- `CLIENT TRACKINGINFO`: `flags` in RESP2 - `Set<string>` -> `Array<string>` (to match RESP3 default type mapping)
- `CLUSETER SETSLOT`: `ClusterSlotStates` -> `CLUSTER_SLOT_STATES` [^enum-to-constants]
- `CLUSTER RESET`: the second argument is `{ mode: string; }` instead of `string` [^future-proofing]
- `CLUSTER FAILOVER`: `enum FailoverModes` -> `const FAILOVER_MODES` [^enum-to-constants], the second argument is `{ mode: string; }` instead of `string` [^future-proofing]
- `CLUSTER LINKS`: `createTime` -> `create-time`, `sendBufferAllocated` -> `send-buffer-allocated`, `sendBufferUsed` -> `send-buffer-used` [^map-keys]
- `CLUSTER NODES`, `CLUSTER REPLICAS`, `CLUSTER INFO`: returning the raw `VerbatimStringReply`
- `EXPIRE`: `boolean` -> `number` [^boolean-to-number]
- `EXPIREAT`: `boolean` -> `number` [^boolean-to-number]
- `HSCAN`: `tuples` has been renamed to `entries`
- `HEXISTS`: `boolean` -> `number` [^boolean-to-number]
- `HRANDFIELD_COUNT_WITHVALUES`: `Record<BlobString, BlobString>` -> `Array<{ field: BlobString; value: BlobString; }>` (it can return duplicates).
- `SCAN`, `HSCAN`, `SSCAN`, and `ZSCAN`: `cursor` type is `string | Buffer` instead of `number`
- `HSETNX`: `boolean` -> `number` [^boolean-to-number]
- `LCS IDX`: `length` has been changed to `len`, `matches` has been changed from `Array<{ key1: RangeReply; key2: RangeReply; }>` to `Array<[key1: RangeReply, key2: RangeReply]>`
- `ZINTER`: instead of `client.ZINTER('key', { WEIGHTS: [1] })` use `client.ZINTER({ key: 'key', weight: 1 }])`
- `ZINTER_WITHSCORES`: instead of `client.ZINTER_WITHSCORES('key', { WEIGHTS: [1] })` use `client.ZINTER_WITHSCORES({ key: 'key', weight: 1 }])`
- `ZUNION`: instead of `client.ZUNION('key', { WEIGHTS: [1] })` use `client.ZUNION({ key: 'key', weight: 1 }])`
- `ZUNION_WITHSCORES`: instead of `client.ZUNION_WITHSCORES('key', { WEIGHTS: [1] })` use `client.ZUNION_WITHSCORES({ key: 'key', weight: 1 }])`
- `SETNX`: `boolean` -> `number` [^boolean-to-number]
- `COPY`: `destinationDb` -> `DB`, `replace` -> `REPLACE`, `boolean` -> `number` [^boolean-to-number]
- `EXPIRE`: `boolean` -> `number` [^boolean-to-number]
- `EXPIREAT`: `boolean` -> `number` [^boolean-to-number]
- `ZMPOP`: `{ elements: Array<{ member: string; score: number; }>; }` -> `{ members: Array<{ value: string; score: number; }>; }` to match other sorted set commands (e.g. `ZRANGE`, `ZSCAN`)
- `MOVE`: `boolean` -> `number` [^boolean-to-number]
- `PEXPIRE`: `boolean` -> `number` [^boolean-to-number]
- `PEXPIREAT`: `boolean` -> `number` [^boolean-to-number]
- `RENAMENX`: `boolean` -> `number` [^boolean-to-number]
- `HSCAN`: `tuples` has been renamed to `entries`
- `PFADD`: `boolean` -> `number` [^boolean-to-number]
- `RENAMENX`: `boolean` -> `number` [^boolean-to-number]
- `SETNX`: `boolean` -> `number` [^boolean-to-number]
- `SCAN`, `HSCAN`, `SSCAN`, and `ZSCAN`: `reply.cursor` will not be converted to number to avoid issues when the number is bigger than `Number.MAX_SAFE_INTEGER`. See [here](https://github.com/redis/node-redis/issues/2561).
- `SCRIPT EXISTS`: `Array<boolean>` -> `Array<number>` [^boolean-to-number]
- `SISMEMBER`: `boolean` -> `number` [^boolean-to-number]
- `SMISMEMBER`: `Array<boolean>` -> `Array<number>` [^boolean-to-number]
- `SMOVE`: `boolean` -> `number` [^boolean-to-number]
- `TS.ADD`: `boolean` -> `number` [^boolean-to-number]
- `GEOSEARCH_WITH`/`GEORADIUS_WITH`: `GeoReplyWith` -> `GEO_REPLY_WITH` [^enum-to-constants]
- `GEORADIUSSTORE` -> `GEORADIUS_STORE`
- `GEORADIUSBYMEMBERSTORE` -> `GEORADIUSBYMEMBER_STORE`
@@ -161,34 +177,46 @@ Some command arguments/replies have changed to align more closely to data types
- `HELLO`: `protover` moved from the options object to it's own argument, `auth` -> `AUTH`, `clientName` -> `SETNAME`
- `MODULE LIST`: `version` -> `ver` [^map-keys]
- `MEMORY STATS`: [^map-keys]
- `CLIENT TRACKINGINFO`: `flags` in RESP2 - `Set<string>` -> `Array<string>` (to match RESP3 default type mapping)
- `CLUSETER SETSLOT`: `ClusterSlotStates` -> `CLUSTER_SLOT_STATES` [^enum-to-constants]
- `FUNCTION RESTORE`: the second argument is `{ mode: string; }` instead of `string` [^future-proofing]
- `FUNCTION STATS`: `runningScript` -> `running_script`, `durationMs` -> `duration_ms`, `librariesCount` -> `libraries_count`, `functionsCount` -> `functions_count` [^map-keys]
- `CLUSTER RESET`: the second argument is `{ mode: string; }` instead of `string` [^future-proofing]
- `CLUSTER FAILOVER`: `enum FailoverModes` -> `const FAILOVER_MODES` [^enum-to-constants], the second argument is `{ mode: string; }` instead of `string` [^future-proofing]
- `CLUSTER LINKS`: `createTime` -> `create-time`, `sendBufferAllocated` -> `send-buffer-allocated`, `sendBufferUsed` -> `send-buffer-used` [^map-keys]
- `TIME`: `Date` -> `[unixTimestamp: string, microseconds: string]`
- `ZMPOP`: `{ elements: Array<{ member: string; score: number; }>; }` -> `{ members: Array<{ value: string; score: number; }>; }` to match other sorted set commands (e.g. `ZRANGE`, `ZSCAN`)
- `XGROUP_CREATECONSUMER`: [^boolean-to-number]
- `XGROUP_DESTROY`: [^boolean-to-number]
- `XINFO GROUPS`: `lastDeliveredId` -> `last-delivered-id` [^map-keys]
- `XINFO STREAM`: `radixTreeKeys` -> `radix-tree-keys`, `radixTreeNodes` -> `radix-tree-nodes`, `lastGeneratedId` -> `last-generated-id`, `maxDeletedEntryId` -> `max-deleted-entry-id`, `entriesAdded` -> `entries-added`, `recordedFirstEntryId` -> `recorded-first-entry-id`, `firstEntry` -> `first-entry`, `lastEntry` -> `last-entry`
- `XAUTOCLAIM`, `XCLAIM`, `XRANGE`, `XREVRANGE`: `Array<{ name: string; messages: Array<{ id: string; message: Record<string, string> }>; }>` -> `Record<string, Array<{ id: string; message: Record<string, string> }>>`
- `FT.SUGDEL`: [^boolean-to-number]
- `COMMAND LIST`: `enum FilterBy` -> `const COMMAND_LIST_FILTER_BY` [^enum-to-constants], the filter argument has been moved from a "top level argument" into ` { FILTERBY: { type: <MODULE|ACLCAT|PATTERN>; value: <value> } }`
### Bloom
- `TOPK.QUERY`: `Array<number>` -> `Array<boolean>`
### Graph
- `GRAPH.SLOWLOG`: `timestamp` has been changed from `Date` to `number`
### JSON
- `JSON.ARRINDEX`: `start` and `end` arguments moved to `{ range: { start: number; end: number; }; }` [^future-proofing]
- `JSON.ARRPOP`: `path` and `index` arguments moved to `{ path: string; index: number; }` [^future-proofing]
- `JSON.ARRLEN`, `JSON.CLEAR`, `JSON.DEBUG MEMORY`, `JSON.DEL`, `JSON.FORGET`, `JSON.OBJKEYS`, `JSON.OBJLEN`, `JSON.STRAPPEND`, `JSON.STRLEN`, `JSON.TYPE`: `path` argument moved to `{ path: string; }` [^future-proofing]
### Search
- `FT.SUGDEL`: [^boolean-to-number]
### Time Series
- `TS.ADD`: `boolean` -> `number` [^boolean-to-number]
- `TS.[M][REV]RANGE`: `enum TimeSeriesBucketTimestamp` -> `const TIME_SERIES_BUCKET_TIMESTAMP` [^enum-to-constants], `enum TimeSeriesReducers` -> `const TIME_SERIES_REDUCERS` [^enum-to-constants], the `ALIGN` argument has been moved into `AGGREGRATION`
- `TS.SYNUPDATE`: `Array<string | Array<string>>` -> `Record<string, Array<string>>`
- `CLUSTER NODES`, `CLUSTER REPLICAS`, `CLUSTER INFO`: returning the raw `VerbatimStringReply`
- `TS.M[REV]RANGE[_WITHLABELS]`, `TS.MGET[_WITHLABELS]`: TODO
[^enum-to-constants]: TODO
[^boolean-to-number]: TODO
[^map-keys]: To avoid unnecessary transformations and confusion, map keys will not be transformed to "js friendly" names (i.e. `number-of-keys` will not be renamed to `numberOfKeys`). See [here](https://github.com/redis/node-redis/discussions/2506).
[^map-keys]: [TODO](https://github.com/redis/node-redis/discussions/2506)
[^future-proofing]: TODO
[^future-proofing]: TODO

260
package-lock.json generated
View File

@@ -11,15 +11,15 @@
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@tsconfig/node18": "^18.2.2",
"@types/mocha": "^10.0.1",
"@typescript-eslint/eslint-plugin": "^6.7.2",
"@typescript-eslint/parser": "^6.7.2",
"@types/mocha": "^10.0.3",
"@typescript-eslint/eslint-plugin": "^6.9.0",
"@typescript-eslint/parser": "^6.9.0",
"gh-pages": "^6.0.0",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.1",
"typedoc": "^0.25.1",
"typedoc": "^0.25.2",
"typescript": "^5.2.2"
}
},
@@ -131,18 +131,18 @@
}
},
"node_modules/@babel/compat-data": {
"version": "7.22.20",
"resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.22.20.tgz",
"integrity": "sha512-BQYjKbpXjoXwFW5jGqiizJQQT/aC7pFm9Ok1OWssonuguICi264lbgMzRp2ZMmRSlfkX6DsWDDcsrctK8Rwfiw==",
"version": "7.23.2",
"resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.23.2.tgz",
"integrity": "sha512-0S9TQMmDHlqAZ2ITT95irXKfxN9bncq8ZCoJhun3nHL/lLUxd2NKBJYoNGWH7S0hz6fRQwWlAWn/ILM0C70KZQ==",
"dev": true,
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/core": {
"version": "7.23.0",
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.0.tgz",
"integrity": "sha512-97z/ju/Jy1rZmDxybphrBuI+jtJjFVoz7Mr9yUQVVVi+DNZE333uFQeMOqcCIy1x3WYBIbWftUSLmbNXNT7qFQ==",
"version": "7.23.2",
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.2.tgz",
"integrity": "sha512-n7s51eWdaWZ3vGT2tD4T7J6eJs3QoBXydv7vkUM06Bf1cbVD2Kc2UrkzhiQwobfV7NwOnQXYL7UBJ5VPU+RGoQ==",
"dev": true,
"dependencies": {
"@ampproject/remapping": "^2.2.0",
@@ -150,10 +150,10 @@
"@babel/generator": "^7.23.0",
"@babel/helper-compilation-targets": "^7.22.15",
"@babel/helper-module-transforms": "^7.23.0",
"@babel/helpers": "^7.23.0",
"@babel/helpers": "^7.23.2",
"@babel/parser": "^7.23.0",
"@babel/template": "^7.22.15",
"@babel/traverse": "^7.23.0",
"@babel/traverse": "^7.23.2",
"@babel/types": "^7.23.0",
"convert-source-map": "^2.0.0",
"debug": "^4.1.0",
@@ -341,13 +341,13 @@
}
},
"node_modules/@babel/helpers": {
"version": "7.23.1",
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.23.1.tgz",
"integrity": "sha512-chNpneuK18yW5Oxsr+t553UZzzAs3aZnFm4bxhebsNTeshrC95yA7l5yl7GBAG+JG1rF0F7zzD2EixK9mWSDoA==",
"version": "7.23.2",
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.23.2.tgz",
"integrity": "sha512-lzchcp8SjTSVe/fPmLwtWVBFC7+Tbn8LGHDVfDp9JGxpAY5opSaEFgt8UQvrnECWOTdji2mOWMz1rOhkHscmGQ==",
"dev": true,
"dependencies": {
"@babel/template": "^7.22.15",
"@babel/traverse": "^7.23.0",
"@babel/traverse": "^7.23.2",
"@babel/types": "^7.23.0"
},
"engines": {
@@ -466,9 +466,9 @@
}
},
"node_modules/@babel/traverse": {
"version": "7.23.0",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.0.tgz",
"integrity": "sha512-t/QaEvyIoIkwzpiZ7aoSKK8kObQYeF7T2v+dazAYCb8SXtp58zEVkWW7zAnju8FNKNdr4ScAOEDmMItbyOmEYw==",
"version": "7.23.2",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz",
"integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==",
"dev": true,
"dependencies": {
"@babel/code-frame": "^7.22.13",
@@ -580,9 +580,9 @@
}
},
"node_modules/@eslint/js": {
"version": "8.50.0",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.50.0.tgz",
"integrity": "sha512-NCC3zz2+nvYd+Ckfh87rA47zfu2QsQpvc6k1yzTk+b9KzRj0wkGa8LSoGOXN6Zv4lRf/EIoZ80biDh9HOI+RNQ==",
"version": "8.51.0",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.51.0.tgz",
"integrity": "sha512-HxjQ8Qn+4SI3/AFv6sOrDB+g6PpUTDwSJiQqOrnneEk8L71161srI9gjzzZvYVbzHiVg/BvcH95+cK/zfIt4pg==",
"dev": true,
"peer": true,
"engines": {
@@ -934,34 +934,37 @@
"dev": true
},
"node_modules/@types/json-schema": {
"version": "7.0.13",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.13.tgz",
"integrity": "sha512-RbSSoHliUbnXj3ny0CNFOoxrIDV6SUGyStHsvDqosw6CkdPV8TtWGlfecuK4ToyMEAql6pzNxgCFKanovUzlgQ==",
"version": "7.0.14",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.14.tgz",
"integrity": "sha512-U3PUjAudAdJBeC2pgN8uTIKgxrb4nlDF3SF0++EldXQvQBGkpFZMSnwQiIoDU77tv45VgNkl/L4ouD+rEomujw==",
"dev": true
},
"node_modules/@types/mocha": {
"version": "10.0.2",
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.2.tgz",
"integrity": "sha512-NaHL0+0lLNhX6d9rs+NSt97WH/gIlRHmszXbQ/8/MV/eVcFNdeJ/GYhrFuUc8K7WuPhRhTSdMkCp8VMzhUq85w==",
"version": "10.0.3",
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.3.tgz",
"integrity": "sha512-RsOPImTriV/OE4A9qKjMtk2MnXiuLLbcO3nCXK+kvq4nr0iMfFgpjaX3MPLb6f7+EL1FGSelYvuJMV6REH+ZPQ==",
"dev": true
},
"node_modules/@types/node": {
"version": "20.8.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.0.tgz",
"integrity": "sha512-LzcWltT83s1bthcvjBmiBvGJiiUe84NWRHkw+ZV6Fr41z2FbIzvc815dk2nQ3RAKMuN2fkenM/z3Xv2QzEpYxQ==",
"version": "20.8.6",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.6.tgz",
"integrity": "sha512-eWO4K2Ji70QzKUqRy6oyJWUeB7+g2cRagT3T/nxYibYcT4y2BDL8lqolRXjTHmkZCdJfIPaY73KbJAZmcryxTQ==",
"dev": true,
"peer": true
"peer": true,
"dependencies": {
"undici-types": "~5.25.1"
}
},
"node_modules/@types/semver": {
"version": "7.5.3",
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.3.tgz",
"integrity": "sha512-OxepLK9EuNEIPxWNME+C6WwbRAOOI2o2BaQEGzz5Lu2e4Z5eDnEo+/aVEDMIXywoJitJ7xWd641wrGLZdtwRyw==",
"version": "7.5.4",
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.4.tgz",
"integrity": "sha512-MMzuxN3GdFwskAnb6fz0orFvhfqi752yjaXylr0Rp4oDg5H0Zn1IuyRhDVvYOwAXoJirx2xuS16I3WjxnAIHiQ==",
"dev": true
},
"node_modules/@types/sinon": {
"version": "10.0.17",
"resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.17.tgz",
"integrity": "sha512-+6ILpcixQ0Ma3dHMTLv4rSycbDXkDljgKL+E0nI2RUxxhYTFyPSjt6RVMxh7jUshvyVcBvicb0Ktj+lAJcjgeA==",
"version": "10.0.19",
"resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.19.tgz",
"integrity": "sha512-MWZNGPSchIdDfb5FL+VFi4zHsHbNOTQEgjqFQk7HazXSXwUU9PAX3z9XBqb3AJGYr9YwrtCtaSMsT3brYsN/jQ==",
"dev": true,
"dependencies": {
"@types/sinonjs__fake-timers": "*"
@@ -974,9 +977,9 @@
"dev": true
},
"node_modules/@types/yargs": {
"version": "17.0.26",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.26.tgz",
"integrity": "sha512-Y3vDy2X6zw/ZCumcwLpdhM5L7jmyGpmBCTYMHDLqT2IKVMYRRLdv6ZakA+wxhra6Z/3bwhNbNl9bDGXaFU+6rw==",
"version": "17.0.28",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.28.tgz",
"integrity": "sha512-N3e3fkS86hNhtk6BEnc0rj3zcehaxx8QWhCROJkqpl5Zaoi7nAic3jH8q94jVD3zu5LGk+PUB6KAiDmimYOEQw==",
"dev": true,
"dependencies": {
"@types/yargs-parser": "*"
@@ -989,16 +992,16 @@
"dev": true
},
"node_modules/@typescript-eslint/eslint-plugin": {
"version": "6.7.4",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.7.4.tgz",
"integrity": "sha512-DAbgDXwtX+pDkAHwiGhqP3zWUGpW49B7eqmgpPtg+BKJXwdct79ut9+ifqOFPJGClGKSHXn2PTBatCnldJRUoA==",
"version": "6.9.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.9.0.tgz",
"integrity": "sha512-lgX7F0azQwRPB7t7WAyeHWVfW1YJ9NIgd9mvGhfQpRY56X6AVf8mwM8Wol+0z4liE7XX3QOt8MN1rUKCfSjRIA==",
"dev": true,
"dependencies": {
"@eslint-community/regexpp": "^4.5.1",
"@typescript-eslint/scope-manager": "6.7.4",
"@typescript-eslint/type-utils": "6.7.4",
"@typescript-eslint/utils": "6.7.4",
"@typescript-eslint/visitor-keys": "6.7.4",
"@typescript-eslint/scope-manager": "6.9.0",
"@typescript-eslint/type-utils": "6.9.0",
"@typescript-eslint/utils": "6.9.0",
"@typescript-eslint/visitor-keys": "6.9.0",
"debug": "^4.3.4",
"graphemer": "^1.4.0",
"ignore": "^5.2.4",
@@ -1024,15 +1027,15 @@
}
},
"node_modules/@typescript-eslint/parser": {
"version": "6.7.4",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.7.4.tgz",
"integrity": "sha512-I5zVZFY+cw4IMZUeNCU7Sh2PO5O57F7Lr0uyhgCJmhN/BuTlnc55KxPonR4+EM3GBdfiCyGZye6DgMjtubQkmA==",
"version": "6.9.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.9.0.tgz",
"integrity": "sha512-GZmjMh4AJ/5gaH4XF2eXA8tMnHWP+Pm1mjQR2QN4Iz+j/zO04b9TOvJYOX2sCNIQHtRStKTxRY1FX7LhpJT4Gw==",
"dev": true,
"dependencies": {
"@typescript-eslint/scope-manager": "6.7.4",
"@typescript-eslint/types": "6.7.4",
"@typescript-eslint/typescript-estree": "6.7.4",
"@typescript-eslint/visitor-keys": "6.7.4",
"@typescript-eslint/scope-manager": "6.9.0",
"@typescript-eslint/types": "6.9.0",
"@typescript-eslint/typescript-estree": "6.9.0",
"@typescript-eslint/visitor-keys": "6.9.0",
"debug": "^4.3.4"
},
"engines": {
@@ -1052,13 +1055,13 @@
}
},
"node_modules/@typescript-eslint/scope-manager": {
"version": "6.7.4",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.7.4.tgz",
"integrity": "sha512-SdGqSLUPTXAXi7c3Ob7peAGVnmMoGzZ361VswK2Mqf8UOYcODiYvs8rs5ILqEdfvX1lE7wEZbLyELCW+Yrql1A==",
"version": "6.9.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.0.tgz",
"integrity": "sha512-1R8A9Mc39n4pCCz9o79qRO31HGNDvC7UhPhv26TovDsWPBDx+Sg3rOZdCELIA3ZmNoWAuxaMOT7aWtGRSYkQxw==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "6.7.4",
"@typescript-eslint/visitor-keys": "6.7.4"
"@typescript-eslint/types": "6.9.0",
"@typescript-eslint/visitor-keys": "6.9.0"
},
"engines": {
"node": "^16.0.0 || >=18.0.0"
@@ -1069,13 +1072,13 @@
}
},
"node_modules/@typescript-eslint/type-utils": {
"version": "6.7.4",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.7.4.tgz",
"integrity": "sha512-n+g3zi1QzpcAdHFP9KQF+rEFxMb2KxtnJGID3teA/nxKHOVi3ylKovaqEzGBbVY2pBttU6z85gp0D00ufLzViQ==",
"version": "6.9.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.9.0.tgz",
"integrity": "sha512-XXeahmfbpuhVbhSOROIzJ+b13krFmgtc4GlEuu1WBT+RpyGPIA4Y/eGnXzjbDj5gZLzpAXO/sj+IF/x2GtTMjQ==",
"dev": true,
"dependencies": {
"@typescript-eslint/typescript-estree": "6.7.4",
"@typescript-eslint/utils": "6.7.4",
"@typescript-eslint/typescript-estree": "6.9.0",
"@typescript-eslint/utils": "6.9.0",
"debug": "^4.3.4",
"ts-api-utils": "^1.0.1"
},
@@ -1096,9 +1099,9 @@
}
},
"node_modules/@typescript-eslint/types": {
"version": "6.7.4",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.7.4.tgz",
"integrity": "sha512-o9XWK2FLW6eSS/0r/tgjAGsYasLAnOWg7hvZ/dGYSSNjCh+49k5ocPN8OmG5aZcSJ8pclSOyVKP2x03Sj+RrCA==",
"version": "6.9.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.0.tgz",
"integrity": "sha512-+KB0lbkpxBkBSiVCuQvduqMJy+I1FyDbdwSpM3IoBS7APl4Bu15lStPjgBIdykdRqQNYqYNMa8Kuidax6phaEw==",
"dev": true,
"engines": {
"node": "^16.0.0 || >=18.0.0"
@@ -1109,13 +1112,13 @@
}
},
"node_modules/@typescript-eslint/typescript-estree": {
"version": "6.7.4",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.7.4.tgz",
"integrity": "sha512-ty8b5qHKatlNYd9vmpHooQz3Vki3gG+3PchmtsA4TgrZBKWHNjWfkQid7K7xQogBqqc7/BhGazxMD5vr6Ha+iQ==",
"version": "6.9.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.0.tgz",
"integrity": "sha512-NJM2BnJFZBEAbCfBP00zONKXvMqihZCrmwCaik0UhLr0vAgb6oguXxLX1k00oQyD+vZZ+CJn3kocvv2yxm4awQ==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "6.7.4",
"@typescript-eslint/visitor-keys": "6.7.4",
"@typescript-eslint/types": "6.9.0",
"@typescript-eslint/visitor-keys": "6.9.0",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
@@ -1136,17 +1139,17 @@
}
},
"node_modules/@typescript-eslint/utils": {
"version": "6.7.4",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.7.4.tgz",
"integrity": "sha512-PRQAs+HUn85Qdk+khAxsVV+oULy3VkbH3hQ8hxLRJXWBEd7iI+GbQxH5SEUSH7kbEoTp6oT1bOwyga24ELALTA==",
"version": "6.9.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.9.0.tgz",
"integrity": "sha512-5Wf+Jsqya7WcCO8me504FBigeQKVLAMPmUzYgDbWchINNh1KJbxCgVya3EQ2MjvJMVeXl3pofRmprqX6mfQkjQ==",
"dev": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.4.0",
"@types/json-schema": "^7.0.12",
"@types/semver": "^7.5.0",
"@typescript-eslint/scope-manager": "6.7.4",
"@typescript-eslint/types": "6.7.4",
"@typescript-eslint/typescript-estree": "6.7.4",
"@typescript-eslint/scope-manager": "6.9.0",
"@typescript-eslint/types": "6.9.0",
"@typescript-eslint/typescript-estree": "6.9.0",
"semver": "^7.5.4"
},
"engines": {
@@ -1161,12 +1164,12 @@
}
},
"node_modules/@typescript-eslint/visitor-keys": {
"version": "6.7.4",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.7.4.tgz",
"integrity": "sha512-pOW37DUhlTZbvph50x5zZCkFn3xzwkGtNoJHzIM3svpiSkJzwOYr/kVBaXmf+RAQiUDs1AHEZVNPg6UJCJpwRA==",
"version": "6.9.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.0.tgz",
"integrity": "sha512-dGtAfqjV6RFOtIP8I0B4ZTBRrlTT8NHHlZZSchQx3qReaoDeXhYM++M4So2AgFK9ZB0emRPA6JI1HkafzA2Ibg==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "6.7.4",
"@typescript-eslint/types": "6.9.0",
"eslint-visitor-keys": "^3.4.1"
},
"engines": {
@@ -1460,9 +1463,9 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001542",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001542.tgz",
"integrity": "sha512-UrtAXVcj1mvPBFQ4sKd38daP8dEcXXr5sQe6QNNinaPd0iA/cxg9/l3VrSdL73jgw5sKyuQ6jNgiKO12W3SsVA==",
"version": "1.0.30001549",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001549.tgz",
"integrity": "sha512-qRp48dPYSCYaP+KurZLhDYdVE+yEyht/3NlmcJgVQ2VMGt6JL36ndQ/7rgspdZsJuxDPFIo/OzBT2+GmIJ53BA==",
"dev": true,
"funding": [
{
@@ -1581,9 +1584,9 @@
"dev": true
},
"node_modules/commander": {
"version": "11.0.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-11.0.0.tgz",
"integrity": "sha512-9HMlXtt/BNoYr8ooyjjNRdIilOTkVJXB+GhxMTtOKwk0R4j4lS4NpjuqmRxroBfnfTSHQIHQB7wryHhXarNjmQ==",
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz",
"integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==",
"dev": true,
"engines": {
"node": ">=16"
@@ -1710,9 +1713,9 @@
}
},
"node_modules/electron-to-chromium": {
"version": "1.4.537",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.537.tgz",
"integrity": "sha512-W1+g9qs9hviII0HAwOdehGYkr+zt7KKdmCcJcjH0mYg6oL8+ioT3Skjmt7BLoAQqXhjf40AXd+HlR4oAWMlXjA==",
"version": "1.4.556",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.556.tgz",
"integrity": "sha512-6RPN0hHfzDU8D56E72YkDvnLw5Cj2NMXZGg3UkgyoHxjVhG99KZpsKgBWMmTy0Ei89xwan+rbRsVB9yzATmYzQ==",
"dev": true
},
"node_modules/email-addresses": {
@@ -1755,16 +1758,16 @@
}
},
"node_modules/eslint": {
"version": "8.50.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.50.0.tgz",
"integrity": "sha512-FOnOGSuFuFLv/Sa+FDVRZl4GGVAAFFi8LecRsI5a1tMO5HIE8nCm4ivAlzt4dT3ol/PaaGC0rJEEXQmHJBGoOg==",
"version": "8.51.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.51.0.tgz",
"integrity": "sha512-2WuxRZBrlwnXi+/vFSJyjMqrNjtJqiasMzehF0shoLaW7DzS3/9Yvrmq5JiT66+pNjiX4UBnLDiKHcWAr/OInA==",
"dev": true,
"peer": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.2.0",
"@eslint-community/regexpp": "^4.6.1",
"@eslint/eslintrc": "^2.1.2",
"@eslint/js": "8.50.0",
"@eslint/js": "8.51.0",
"@humanwhocodes/config-array": "^0.11.11",
"@humanwhocodes/module-importer": "^1.0.1",
"@nodelib/fs.walk": "^1.2.8",
@@ -2067,13 +2070,13 @@
}
},
"node_modules/flat-cache": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.1.0.tgz",
"integrity": "sha512-OHx4Qwrrt0E4jEIcI5/Xb+f+QmJYNj2rrK8wiIdQOIrB9WrrJL8cjZvXdXuBTkkEwEqLycb5BeZDV1o2i9bTew==",
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.1.1.tgz",
"integrity": "sha512-/qM2b3LUIaIgviBQovTLvijfyOQXPtSRnRK26ksj2J7rzPIecePUIpJsZ4T02Qg+xiAEKIs5K8dsHEd+VaKa/Q==",
"dev": true,
"peer": true,
"dependencies": {
"flatted": "^3.2.7",
"flatted": "^3.2.9",
"keyv": "^4.5.3",
"rimraf": "^3.0.2"
},
@@ -2274,9 +2277,9 @@
}
},
"node_modules/globals": {
"version": "13.22.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-13.22.0.tgz",
"integrity": "sha512-H1Ddc/PbZHTDVJSnj8kWptIRSD6AM3pK+mKytuIVF4uoBV7rshFlhhvA58ceJ5wp3Er58w6zj7bykMpYXt3ETw==",
"version": "13.23.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-13.23.0.tgz",
"integrity": "sha512-XAmF0RjlrjY23MA51q3HltdlGxUpXPvg0GioKiD9X6HD28iMjo2dKC8Vqwm7lne4GNr78+RHTfliktR6ZH09wA==",
"dev": true,
"peer": true,
"dependencies": {
@@ -2757,9 +2760,9 @@
"dev": true
},
"node_modules/keyv": {
"version": "4.5.3",
"resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.3.tgz",
"integrity": "sha512-QCiSav9WaX1PgETJ+SpNnx2PRRapJ/oRSXM4VO5OGYGSjrxbKPVFVhB3l2OCbLCk329N8qyAtsJjSjvVBWzEug==",
"version": "4.5.4",
"resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz",
"integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==",
"dev": true,
"peer": true,
"dependencies": {
@@ -3768,9 +3771,9 @@
}
},
"node_modules/shiki": {
"version": "0.14.4",
"resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.4.tgz",
"integrity": "sha512-IXCRip2IQzKwxArNNq1S+On4KPML3Yyn8Zzs/xRgcgOWIr8ntIK3IKzjFPfjy/7kt9ZMjc+FItfqHRBg8b6tNQ==",
"version": "0.14.5",
"resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.5.tgz",
"integrity": "sha512-1gCAYOcmCFONmErGTrS1fjzJLA7MGZmKzrBNX7apqSwhyITJg2O102uFzXUeBxNnEkDA9vHIKLyeKq0V083vIw==",
"dev": true,
"dependencies": {
"ansi-sequence-parser": "^1.1.0",
@@ -3786,9 +3789,9 @@
"dev": true
},
"node_modules/sinon": {
"version": "16.0.0",
"resolved": "https://registry.npmjs.org/sinon/-/sinon-16.0.0.tgz",
"integrity": "sha512-B8AaZZm9CT5pqe4l4uWJztfD/mOTa7dL8Qo0W4+s+t74xECOgSZDDQCBjNgIK3+n4kyxQrSTv2V5ul8K25qkiQ==",
"version": "16.1.0",
"resolved": "https://registry.npmjs.org/sinon/-/sinon-16.1.0.tgz",
"integrity": "sha512-ZSgzF0vwmoa8pq0GEynqfdnpEDyP1PkYmEChnkjW0Vyh8IDlyFEJ+fkMhCP0il6d5cJjPl2PUsnUSAuP5sttOQ==",
"dev": true,
"dependencies": {
"@sinonjs/commons": "^3.0.0",
@@ -4115,9 +4118,9 @@
}
},
"node_modules/typedoc": {
"version": "0.25.1",
"resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.25.1.tgz",
"integrity": "sha512-c2ye3YUtGIadxN2O6YwPEXgrZcvhlZ6HlhWZ8jQRNzwLPn2ylhdGqdR8HbyDRyALP8J6lmSANILCkkIdNPFxqA==",
"version": "0.25.2",
"resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.25.2.tgz",
"integrity": "sha512-286F7BeATBiWe/qC4PCOCKlSTwfnsLbC/4cZ68oGBbvAqb9vV33quEOXx7q176OXotD+JdEerdQ1OZGJ818lnA==",
"dev": true,
"dependencies": {
"lunr": "^2.3.9",
@@ -4172,6 +4175,13 @@
"node": ">=14.17"
}
},
"node_modules/undici-types": {
"version": "5.25.3",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.25.3.tgz",
"integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==",
"dev": true,
"peer": true
},
"node_modules/universalify": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
@@ -4467,31 +4477,13 @@
"license": "MIT",
"dependencies": {
"@redis/bloom": "1.2.0",
"@redis/client": "1.5.11",
"@redis/client": "2.0.0-next.2",
"@redis/graph": "1.1.0",
"@redis/json": "1.0.6",
"@redis/search": "1.1.5",
"@redis/time-series": "1.0.5"
}
},
"packages/redis/node_modules/@redis/client": {
"version": "1.5.11",
"resolved": "https://registry.npmjs.org/@redis/client/-/client-1.5.11.tgz",
"integrity": "sha512-cV7yHcOAtNQ5x/yQl7Yw1xf53kO0FNDTdDU6bFIMbW6ljB7U7ns0YRM+QIkpoqTAt6zK5k9Fq0QWlUbLcq9AvA==",
"dependencies": {
"cluster-key-slot": "1.1.2",
"generic-pool": "3.9.0",
"yallist": "4.0.0"
},
"engines": {
"node": ">=14"
}
},
"packages/redis/node_modules/yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
},
"packages/search": {
"name": "@redis/search",
"version": "1.1.5",

View File

@@ -6,22 +6,22 @@
],
"scripts": {
"test": "npm run test -ws --if-present",
"build": "tsc --build",
"build": "NODE_OPTIONS='--max-old-space-size=8192' tsc --build",
"documentation": "typedoc",
"gh-pages": "gh-pages -d ./documentation -e ./documentation -u 'documentation-bot <documentation@bot>'"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@tsconfig/node18": "^18.2.2",
"@types/mocha": "^10.0.1",
"@typescript-eslint/eslint-plugin": "^6.7.2",
"@typescript-eslint/parser": "^6.7.2",
"@types/mocha": "^10.0.3",
"@typescript-eslint/eslint-plugin": "^6.9.0",
"@typescript-eslint/parser": "^6.9.0",
"gh-pages": "^6.0.0",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.1",
"typedoc": "^0.25.1",
"typedoc": "^0.25.2",
"typescript": "^5.2.2"
}
}

View File

@@ -19,7 +19,7 @@ describe('CF.LOADCHUNK', () => {
]);
assert.equal(
await client.cf.loadChunk('destination', iterator, chunk),
await client.cf.loadChunk('destination', iterator, chunk!),
'OK'
);
}, {

View File

@@ -2,8 +2,8 @@
"name": "@redis/bloom",
"version": "1.2.0",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"main": "./dist/lib/index.js",
"types": "./dist/lib/index.d.ts",
"files": [
"dist/",
"!dist/tsconfig.tsbuildinfo"

View File

@@ -1,4 +1,4 @@
export { RedisModules, RedisFunctions, RedisScripts, RespVersions, TypeMapping/*, CommandPolicies*/ } from './lib/RESP/types';
export { RedisModules, RedisFunctions, RedisScripts, RespVersions, TypeMapping/*, CommandPolicies*/, RedisArgument } from './lib/RESP/types';
export { RESP_TYPES } from './lib/RESP/decoder';
export { VerbatimString } from './lib/RESP/verbatim-string';
export { defineScript } from './lib/lua-script';

View File

@@ -1,56 +1,62 @@
// import { strict as assert } from 'node:assert';
// import testUtils, { GLOBAL } from '../test-utils';
// import { transformArguments, FilterBy } from './COMMAND_LIST';
import { strict as assert } from 'node:assert';
import testUtils, { GLOBAL } from '../test-utils';
import COMMAND_LIST from './COMMAND_LIST';
// describe('COMMAND LIST', () => {
// testUtils.isVersionGreaterThanHook([7]);
describe('COMMAND LIST', () => {
testUtils.isVersionGreaterThanHook([7]);
// describe('transformArguments', () => {
// it('simple', () => {
// assert.deepEqual(
// transformArguments(),
// ['COMMAND', 'LIST']
// );
// });
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
COMMAND_LIST.transformArguments(),
['COMMAND', 'LIST']
);
});
// describe('with FILTERBY', () => {
// it('MODULE', () => {
// assert.deepEqual(
// transformArguments({
// filterBy: FilterBy.MODULE,
// value: 'json'
// }),
// ['COMMAND', 'LIST', 'FILTERBY', 'MODULE', 'json']
// );
// });
describe('with FILTERBY', () => {
it('MODULE', () => {
assert.deepEqual(
COMMAND_LIST.transformArguments({
FILTERBY: {
type: 'MODULE',
value: 'JSON'
}
}),
['COMMAND', 'LIST', 'FILTERBY', 'MODULE', 'JSON']
);
});
// it('ACLCAT', () => {
// assert.deepEqual(
// transformArguments({
// filterBy: FilterBy.ACLCAT,
// value: 'admin'
// }),
// ['COMMAND', 'LIST', 'FILTERBY', 'ACLCAT', 'admin']
// );
// });
it('ACLCAT', () => {
assert.deepEqual(
COMMAND_LIST.transformArguments({
FILTERBY: {
type: 'ACLCAT',
value: 'admin'
}
}),
['COMMAND', 'LIST', 'FILTERBY', 'ACLCAT', 'admin']
);
});
// it('PATTERN', () => {
// assert.deepEqual(
// transformArguments({
// filterBy: FilterBy.PATTERN,
// value: 'a*'
// }),
// ['COMMAND', 'LIST', 'FILTERBY', 'PATTERN', 'a*']
// );
// });
// });
// });
it('PATTERN', () => {
assert.deepEqual(
COMMAND_LIST.transformArguments({
FILTERBY: {
type: 'PATTERN',
value: 'a*'
}
}),
['COMMAND', 'LIST', 'FILTERBY', 'PATTERN', 'a*']
);
});
});
});
// testUtils.testWithClient('client.commandList', async client => {
// const commandList = await client.commandList();
// assert.ok(Array.isArray(commandList));
// for (const command of commandList) {
// assert.ok(typeof command === 'string');
// }
// }, GLOBAL.SERVERS.OPEN);
// });
testUtils.testWithClient('client.commandList', async client => {
const commandList = await client.commandList();
assert.ok(Array.isArray(commandList));
for (const command of commandList) {
assert.ok(typeof command === 'string');
}
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,31 +1,35 @@
// import { RedisCommandArguments } from '.';
import { RedisArgument, ArrayReply, BlobStringReply, Command } from '../RESP/types';
// export const IS_READ_ONLY = true;
export const COMMAND_LIST_FILTER_BY = {
MODULE: 'MODULE',
ACLCAT: 'ACLCAT',
PATTERN: 'PATTERN'
} as const;
// export enum FilterBy {
// MODULE = 'MODULE',
// ACLCAT = 'ACLCAT',
// PATTERN = 'PATTERN'
// }
export type CommandListFilterBy = typeof COMMAND_LIST_FILTER_BY[keyof typeof COMMAND_LIST_FILTER_BY];
// interface Filter {
// filterBy: FilterBy;
// value: string;
// }
export interface CommandListOptions {
FILTERBY?: {
type: CommandListFilterBy;
value: RedisArgument;
};
}
export default {
FIRST_KEY_INDEX: undefined,
IS_READ_ONLY: true,
transformArguments(options?: CommandListOptions) {
const args: Array<RedisArgument> = ['COMMAND', 'LIST'];
// export function transformArguments(filter?: Filter): RedisCommandArguments {
// const args = ['COMMAND', 'LIST'];
if (options?.FILTERBY) {
args.push(
'FILTERBY',
options.FILTERBY.type,
options.FILTERBY.value
);
}
// if (filter) {
// args.push(
// 'FILTERBY',
// filter.filterBy,
// filter.value
// );
// }
// return args;
// }
// export declare function transformReply(): Array<string>;
return args;
},
transformReply: undefined as unknown as () => ArrayReply<BlobStringReply>
} as const satisfies Command;

View File

@@ -2,7 +2,7 @@ import { RedisArgument, Command } from '../RESP/types';
import { transformSortedSetReply } from './generic-transformers';
export default {
FIRST_KEY_INDEX: undefined,
FIRST_KEY_INDEX: 1,
IS_READ_ONLY: false,
transformArguments(key: RedisArgument, count: number) {
return ['ZPOPMIN', key, count.toString()];

View File

@@ -73,7 +73,7 @@ import COMMAND_COUNT from './COMMAND_COUNT';
import COMMAND_GETKEYS from './COMMAND_GETKEYS';
import COMMAND_GETKEYSANDFLAGS from './COMMAND_GETKEYSANDFLAGS';
// import COMMAND_INFO from './COMMAND_INFO';
// import COMMAND_LIST from './COMMAND_LIST';
import COMMAND_LIST from './COMMAND_LIST';
// import COMMAND from './COMMAND';
import CONFIG_GET from './CONFIG_GET';
import CONFIG_RESETASTAT from './CONFIG_RESETSTAT';
@@ -483,8 +483,8 @@ export default {
commandGetKeysAndFlags: COMMAND_GETKEYSANDFLAGS,
// COMMAND_INFO,
// commandInfo: COMMAND_INFO,
// COMMAND_LIST,
// commandList: COMMAND_LIST,
COMMAND_LIST,
commandList: COMMAND_LIST,
// COMMAND,
// command: COMMAND,
CONFIG_GET,

View File

@@ -14,7 +14,7 @@ type QueryRawReply = TuplesReply<[
metadata: Metadata
]>;
type QueryParam = null | string | number | boolean | QueryParams | Array<QueryParam>;
type QueryParam = null | RedisArgument | number | boolean | QueryParams | Array<QueryParam>;
type QueryParams = {
[key: string]: QueryParam;

View File

@@ -5,7 +5,7 @@ import SLOWLOG from './SLOWLOG';
describe('GRAPH.SLOWLOG', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key'),
SLOWLOG.transformArguments('key'),
['GRAPH.SLOWLOG', 'key']
);
});

View File

@@ -7,7 +7,7 @@ import LIST from './LIST';
import PROFILE from './PROFILE';
import QUERY from './QUERY';
import RO_QUERY from './RO_QUERY';
// import SLOWLOG from './SLOWLOG';
import SLOWLOG from './SLOWLOG';
export default {
CONFIG_GET,
@@ -26,6 +26,6 @@ export default {
query: QUERY,
RO_QUERY,
roQuery: RO_QUERY,
// SLOWLOG,
// slowLog: SLOWLOG
SLOWLOG,
slowLog: SLOWLOG
} as const satisfies RedisCommands;

View File

@@ -2,8 +2,8 @@
"name": "@redis/graph",
"version": "1.1.0",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"main": "./dist/lib/index.js",
"types": "./dist/lib/index.d.ts",
"files": [
"dist/",
"!dist/tsconfig.tsbuildinfo"

View File

@@ -2,8 +2,8 @@
"name": "@redis/json",
"version": "1.0.6",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"main": "./dist/lib/index.js",
"types": "./dist/lib/index.d.ts",
"files": [
"dist/"
],

View File

@@ -2,12 +2,14 @@ import {
RedisModules,
RedisFunctions,
RedisScripts,
RespVersions,
TypeMapping,
createClient as _createClient,
RedisClientOptions,
RedisClientType as _RedisClientType,
createCluster as _createCluster,
RedisClusterOptions,
RedisClusterType as _RedisClusterType
RedisClusterType as _RedisClusterType,
} from '@redis/client';
import RedisBloomModules from '@redis/bloom';
import RedisGraph from '@redis/graph';
@@ -15,12 +17,12 @@ import RedisJSON from '@redis/json';
import RediSearch from '@redis/search';
import RedisTimeSeries from '@redis/time-series';
export * from '@redis/client';
export * from '@redis/bloom';
export * from '@redis/graph';
export * from '@redis/json';
export * from '@redis/search';
export * from '@redis/time-series';
// export * from '@redis/client';
// export * from '@redis/bloom';
// export * from '@redis/graph';
// export * from '@redis/json';
// export * from '@redis/search';
// export * from '@redis/time-series';
const modules = {
...RedisBloomModules,
@@ -34,17 +36,21 @@ export type RedisDefaultModules = typeof modules;
export type RedisClientType<
M extends RedisModules = RedisDefaultModules,
F extends RedisFunctions = Record<string, never>,
S extends RedisScripts = Record<string, never>
> = _RedisClientType<M, F, S>;
F extends RedisFunctions = {},
S extends RedisScripts = {},
RESP extends RespVersions = 2,
TYPE_MAPPING extends TypeMapping = {}
> = _RedisClientType<M, F, S, RESP, TYPE_MAPPING>;
export function createClient<
M extends RedisModules,
F extends RedisFunctions,
S extends RedisScripts
S extends RedisScripts,
RESP extends RespVersions,
TYPE_MAPPING extends TypeMapping
>(
options?: RedisClientOptions<M, F, S>
): _RedisClientType<RedisDefaultModules & M, F, S> {
options?: RedisClientOptions<M, F, S, RESP, TYPE_MAPPING>
): _RedisClientType<RedisDefaultModules & M, F, S, RESP, TYPE_MAPPING> {
return _createClient({
...options,
modules: {
@@ -56,17 +62,21 @@ export function createClient<
export type RedisClusterType<
M extends RedisModules = RedisDefaultModules,
F extends RedisFunctions = Record<string, never>,
S extends RedisScripts = Record<string, never>
> = _RedisClusterType<M, F, S>;
F extends RedisFunctions = {},
S extends RedisScripts = {},
RESP extends RespVersions = 2,
TYPE_MAPPING extends TypeMapping = {}
> = _RedisClusterType<M, F, S, RESP, TYPE_MAPPING>;
export function createCluster<
M extends RedisModules,
F extends RedisFunctions,
S extends RedisScripts
S extends RedisScripts,
RESP extends RespVersions,
TYPE_MAPPING extends TypeMapping
>(
options: RedisClusterOptions<M, F, S>
): RedisClusterType<RedisDefaultModules & M, F, S> {
options: RedisClusterOptions<M, F, S, RESP, TYPE_MAPPING>
): RedisClusterType<RedisDefaultModules & M, F, S, RESP, TYPE_MAPPING> {
return _createCluster({
...options,
modules: {

View File

@@ -10,7 +10,7 @@
],
"dependencies": {
"@redis/bloom": "1.2.0",
"@redis/client": "1.5.11",
"@redis/client": "2.0.0-next.2",
"@redis/graph": "1.1.0",
"@redis/json": "1.0.6",
"@redis/search": "1.1.5",

View File

@@ -1,6 +1,5 @@
import { strict as assert } from 'node:assert';
import testUtils, { GLOBAL } from '../test-utils';
import { SchemaFieldTypes } from '.';
import SPELLCHECK from './SPELLCHECK';
describe('FT.SPELLCHECK', () => {
@@ -63,7 +62,7 @@ describe('FT.SPELLCHECK', () => {
testUtils.testWithClient('client.ft.spellCheck', async client => {
const [,, reply] = await Promise.all([
client.ft.create('index', {
field: SchemaFieldTypes.TEXT
field: 'TEXT'
}),
client.hSet('key', 'field', 'query'),
client.ft.spellCheck('index', 'quer')

View File

@@ -14,8 +14,8 @@ import DICTADD from './DICTADD';
import DICTDEL from './DICTDEL';
import DICTDUMP from './DICTDUMP';
import DROPINDEX from './DROPINDEX';
import EXPLAIN from './EXPLAIN';
import EXPLAINCLI from './EXPLAINCLI';
// import EXPLAIN from './EXPLAIN';
// import EXPLAINCLI from './EXPLAINCLI';
// import INFO from './INFO';
// import PROFILESEARCH from './PROFILE_SEARCH';
// import PROFILEAGGREGATE from './PROFILE_AGGREGATE';
@@ -32,9 +32,9 @@ import SYNDUMP from './SYNDUMP';
import SYNUPDATE from './SYNUPDATE';
import TAGVALS from './TAGVALS';
// import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands';
import { pushOptionalVariadicArgument, pushVariadicArgument } from '@redis/client/dist/lib/commands/generic-transformers';
import { SearchOptions } from './SEARCH';
import { CommandArguments } from '@redis/client/dist/lib/RESP/types';
// import { pushOptionalVariadicArgument, pushVariadicArgument } from '@redis/client/dist/lib/commands/generic-transformers';
// import { SearchOptions } from './SEARCH';
// import { CommandArguments } from '@redis/client/dist/lib/RESP/types';
export default {
_LIST,
@@ -69,10 +69,10 @@ export default {
dictDump: DICTDUMP,
DROPINDEX,
dropIndex: DROPINDEX,
EXPLAIN,
explain: EXPLAIN,
EXPLAINCLI,
explainCli: EXPLAINCLI,
// EXPLAIN,
// explain: EXPLAIN,
// EXPLAINCLI,
// explainCli: EXPLAINCLI,
// INFO,
// info: INFO,
// PROFILESEARCH,
@@ -135,41 +135,41 @@ export default {
export type PropertyName = `${'@' | '$.'}${string}`;
export type SortByProperty = string | {
BY: string;
DIRECTION?: 'ASC' | 'DESC';
};
// export type SortByProperty = string | {
// BY: string;
// DIRECTION?: 'ASC' | 'DESC';
// };
export function pushSortByProperty(args: RedisCommandArguments, sortBy: SortByProperty): void {
if (typeof sortBy === 'string') {
args.push(sortBy);
} else {
args.push(sortBy.BY);
// export function pushSortByProperty(args: RedisCommandArguments, sortBy: SortByProperty): void {
// if (typeof sortBy === 'string') {
// args.push(sortBy);
// } else {
// args.push(sortBy.BY);
if (sortBy.DIRECTION) {
args.push(sortBy.DIRECTION);
}
}
}
// if (sortBy.DIRECTION) {
// args.push(sortBy.DIRECTION);
// }
// }
// }
export function pushSortByArguments(args: RedisCommandArguments, name: string, sortBy: SortByProperty | Array<SortByProperty>): RedisCommandArguments {
const lengthBefore = args.push(
name,
'' // will be overwritten
);
// export function pushSortByArguments(args: RedisCommandArguments, name: string, sortBy: SortByProperty | Array<SortByProperty>): RedisCommandArguments {
// const lengthBefore = args.push(
// name,
// '' // will be overwritten
// );
if (Array.isArray(sortBy)) {
for (const field of sortBy) {
pushSortByProperty(args, field);
}
} else {
pushSortByProperty(args, sortBy);
}
// if (Array.isArray(sortBy)) {
// for (const field of sortBy) {
// pushSortByProperty(args, field);
// }
// } else {
// pushSortByProperty(args, sortBy);
// }
args[lengthBefore - 1] = (args.length - lengthBefore).toString();
// args[lengthBefore - 1] = (args.length - lengthBefore).toString();
return args;
}
// return args;
// }
// export function pushArgumentsWithLength(args: CommandArguments, fn: (args: CommandArguments) => void) {
// const lengthIndex = args.push('') - 1;
@@ -375,268 +375,268 @@ export function pushSortByArguments(args: RedisCommandArguments, name: string, s
// }
// }
export type Params = Record<string, RedisCommandArgument | number>;
// export type Params = Record<string, RedisCommandArgument | number>;
export function pushParamsArgs(
args: RedisCommandArguments,
params?: Params
): RedisCommandArguments {
if (params) {
const enrties = Object.entries(params);
args.push('PARAMS', (enrties.length * 2).toString());
for (const [key, value] of enrties) {
args.push(key, typeof value === 'number' ? value.toString() : value);
}
}
// export function pushParamsArgs(
// args: RedisCommandArguments,
// params?: Params
// ): RedisCommandArguments {
// if (params) {
// const enrties = Object.entries(params);
// args.push('PARAMS', (enrties.length * 2).toString());
// for (const [key, value] of enrties) {
// args.push(key, typeof value === 'number' ? value.toString() : value);
// }
// }
return args;
}
// return args;
// }
export function pushSearchOptions(
args: RedisCommandArguments,
options?: SearchOptions
): RedisCommandArguments {
if (options?.VERBATIM) {
args.push('VERBATIM');
}
// export function pushSearchOptions(
// args: RedisCommandArguments,
// options?: SearchOptions
// ): RedisCommandArguments {
// if (options?.VERBATIM) {
// args.push('VERBATIM');
// }
if (options?.NOSTOPWORDS) {
args.push('NOSTOPWORDS');
}
// if (options?.NOSTOPWORDS) {
// args.push('NOSTOPWORDS');
// }
// if (options?.WITHSCORES) {
// args.push('WITHSCORES');
// }
// // if (options?.WITHSCORES) {
// // args.push('WITHSCORES');
// // }
// if (options?.WITHPAYLOADS) {
// args.push('WITHPAYLOADS');
// }
// // if (options?.WITHPAYLOADS) {
// // args.push('WITHPAYLOADS');
// // }
pushOptionalVariadicArgument(args, 'INKEYS', options?.INKEYS);
pushOptionalVariadicArgument(args, 'INFIELDS', options?.INFIELDS);
pushOptionalVariadicArgument(args, 'RETURN', options?.RETURN);
// pushOptionalVariadicArgument(args, 'INKEYS', options?.INKEYS);
// pushOptionalVariadicArgument(args, 'INFIELDS', options?.INFIELDS);
// pushOptionalVariadicArgument(args, 'RETURN', options?.RETURN);
if (options?.SUMMARIZE) {
args.push('SUMMARIZE');
// if (options?.SUMMARIZE) {
// args.push('SUMMARIZE');
if (typeof options.SUMMARIZE === 'object') {
if (options.SUMMARIZE.FIELDS) {
args.push('FIELDS');
pushVariadicArgument(args, options.SUMMARIZE.FIELDS);
}
// if (typeof options.SUMMARIZE === 'object') {
// if (options.SUMMARIZE.FIELDS) {
// args.push('FIELDS');
// pushVariadicArgument(args, options.SUMMARIZE.FIELDS);
// }
if (options.SUMMARIZE.FRAGS) {
args.push('FRAGS', options.SUMMARIZE.FRAGS.toString());
}
// if (options.SUMMARIZE.FRAGS) {
// args.push('FRAGS', options.SUMMARIZE.FRAGS.toString());
// }
if (options.SUMMARIZE.LEN) {
args.push('LEN', options.SUMMARIZE.LEN.toString());
}
// if (options.SUMMARIZE.LEN) {
// args.push('LEN', options.SUMMARIZE.LEN.toString());
// }
if (options.SUMMARIZE.SEPARATOR) {
args.push('SEPARATOR', options.SUMMARIZE.SEPARATOR);
}
}
}
// if (options.SUMMARIZE.SEPARATOR) {
// args.push('SEPARATOR', options.SUMMARIZE.SEPARATOR);
// }
// }
// }
if (options?.HIGHLIGHT) {
args.push('HIGHLIGHT');
// if (options?.HIGHLIGHT) {
// args.push('HIGHLIGHT');
if (typeof options.HIGHLIGHT === 'object') {
if (options.HIGHLIGHT.FIELDS) {
args.push('FIELDS');
pushVariadicArgument(args, options.HIGHLIGHT.FIELDS);
}
// if (typeof options.HIGHLIGHT === 'object') {
// if (options.HIGHLIGHT.FIELDS) {
// args.push('FIELDS');
// pushVariadicArgument(args, options.HIGHLIGHT.FIELDS);
// }
if (options.HIGHLIGHT.TAGS) {
args.push('TAGS', options.HIGHLIGHT.TAGS.open, options.HIGHLIGHT.TAGS.close);
}
}
}
// if (options.HIGHLIGHT.TAGS) {
// args.push('TAGS', options.HIGHLIGHT.TAGS.open, options.HIGHLIGHT.TAGS.close);
// }
// }
// }
if (options?.SLOP) {
args.push('SLOP', options.SLOP.toString());
}
// if (options?.SLOP) {
// args.push('SLOP', options.SLOP.toString());
// }
if (options?.INORDER) {
args.push('INORDER');
}
// if (options?.INORDER) {
// args.push('INORDER');
// }
if (options?.LANGUAGE) {
args.push('LANGUAGE', options.LANGUAGE);
}
// if (options?.LANGUAGE) {
// args.push('LANGUAGE', options.LANGUAGE);
// }
if (options?.EXPANDER) {
args.push('EXPANDER', options.EXPANDER);
}
// if (options?.EXPANDER) {
// args.push('EXPANDER', options.EXPANDER);
// }
if (options?.SCORER) {
args.push('SCORER', options.SCORER);
}
// if (options?.SCORER) {
// args.push('SCORER', options.SCORER);
// }
// if (options?.EXPLAINSCORE) {
// args.push('EXPLAINSCORE');
// }
// // if (options?.EXPLAINSCORE) {
// // args.push('EXPLAINSCORE');
// // }
// if (options?.PAYLOAD) {
// args.push('PAYLOAD', options.PAYLOAD);
// }
// // if (options?.PAYLOAD) {
// // args.push('PAYLOAD', options.PAYLOAD);
// // }
if (options?.SORTBY) {
args.push('SORTBY');
pushSortByProperty(args, options.SORTBY);
}
// if (options?.SORTBY) {
// args.push('SORTBY');
// pushSortByProperty(args, options.SORTBY);
// }
// if (options?.MSORTBY) {
// pushSortByArguments(args, 'MSORTBY', options.MSORTBY);
// }
// // if (options?.MSORTBY) {
// // pushSortByArguments(args, 'MSORTBY', options.MSORTBY);
// // }
if (options?.LIMIT) {
args.push(
'LIMIT',
options.LIMIT.from.toString(),
options.LIMIT.size.toString()
);
}
// if (options?.LIMIT) {
// args.push(
// 'LIMIT',
// options.LIMIT.from.toString(),
// options.LIMIT.size.toString()
// );
// }
if (options?.PARAMS) {
pushParamsArgs(args, options.PARAMS);
}
// if (options?.PARAMS) {
// pushParamsArgs(args, options.PARAMS);
// }
if (options?.DIALECT) {
args.push('DIALECT', options.DIALECT.toString());
}
// if (options?.DIALECT) {
// args.push('DIALECT', options.DIALECT.toString());
// }
if (options?.RETURN?.length === 0) {
args.preserve = true;
}
// if (options?.RETURN?.length === 0) {
// args.preserve = true;
// }
if (options?.TIMEOUT !== undefined) {
args.push('TIMEOUT', options.TIMEOUT.toString());
}
// if (options?.TIMEOUT !== undefined) {
// args.push('TIMEOUT', options.TIMEOUT.toString());
// }
return args;
}
// return args;
// }
interface SearchDocumentValue {
[key: string]: string | number | null | Array<SearchDocumentValue> | SearchDocumentValue;
}
// interface SearchDocumentValue {
// [key: string]: string | number | null | Array<SearchDocumentValue> | SearchDocumentValue;
// }
export interface SearchReply {
total: number;
documents: Array<{
id: string;
value: SearchDocumentValue;
}>;
}
// export interface SearchReply {
// total: number;
// documents: Array<{
// id: string;
// value: SearchDocumentValue;
// }>;
// }
export interface ProfileOptions {
LIMITED?: true;
}
// export interface ProfileOptions {
// LIMITED?: true;
// }
export type ProfileRawReply<T> = [
results: T,
profile: [
_: string,
TotalProfileTime: string,
_: string,
ParsingTime: string,
_: string,
PipelineCreationTime: string,
_: string,
IteratorsProfile: Array<any>
]
];
// export type ProfileRawReply<T> = [
// results: T,
// profile: [
// _: string,
// TotalProfileTime: string,
// _: string,
// ParsingTime: string,
// _: string,
// PipelineCreationTime: string,
// _: string,
// IteratorsProfile: Array<any>
// ]
// ];
export interface ProfileReply {
results: SearchReply | AGGREGATE.AggregateReply;
profile: ProfileData;
}
// export interface ProfileReply {
// results: SearchReply | AGGREGATE.AggregateReply;
// profile: ProfileData;
// }
interface ChildIterator {
type?: string,
counter?: number,
term?: string,
size?: number,
time?: string,
childIterators?: Array<ChildIterator>
}
// interface ChildIterator {
// type?: string,
// counter?: number,
// term?: string,
// size?: number,
// time?: string,
// childIterators?: Array<ChildIterator>
// }
interface IteratorsProfile {
type?: string,
counter?: number,
queryType?: string,
time?: string,
childIterators?: Array<ChildIterator>
}
// interface IteratorsProfile {
// type?: string,
// counter?: number,
// queryType?: string,
// time?: string,
// childIterators?: Array<ChildIterator>
// }
interface ProfileData {
totalProfileTime: string,
parsingTime: string,
pipelineCreationTime: string,
iteratorsProfile: IteratorsProfile
}
// interface ProfileData {
// totalProfileTime: string,
// parsingTime: string,
// pipelineCreationTime: string,
// iteratorsProfile: IteratorsProfile
// }
export function transformProfile(reply: Array<any>): ProfileData {
return {
totalProfileTime: reply[0][1],
parsingTime: reply[1][1],
pipelineCreationTime: reply[2][1],
iteratorsProfile: transformIterators(reply[3][1])
};
}
// export function transformProfile(reply: Array<any>): ProfileData {
// return {
// totalProfileTime: reply[0][1],
// parsingTime: reply[1][1],
// pipelineCreationTime: reply[2][1],
// iteratorsProfile: transformIterators(reply[3][1])
// };
// }
function transformIterators(IteratorsProfile: Array<any>): IteratorsProfile {
var res: IteratorsProfile = {};
for (let i = 0; i < IteratorsProfile.length; i += 2) {
const value = IteratorsProfile[i + 1];
switch (IteratorsProfile[i]) {
case 'Type':
res.type = value;
break;
case 'Counter':
res.counter = value;
break;
case 'Time':
res.time = value;
break;
case 'Query type':
res.queryType = value;
break;
case 'Child iterators':
res.childIterators = value.map(transformChildIterators);
break;
}
}
// function transformIterators(IteratorsProfile: Array<any>): IteratorsProfile {
// var res: IteratorsProfile = {};
// for (let i = 0; i < IteratorsProfile.length; i += 2) {
// const value = IteratorsProfile[i + 1];
// switch (IteratorsProfile[i]) {
// case 'Type':
// res.type = value;
// break;
// case 'Counter':
// res.counter = value;
// break;
// case 'Time':
// res.time = value;
// break;
// case 'Query type':
// res.queryType = value;
// break;
// case 'Child iterators':
// res.childIterators = value.map(transformChildIterators);
// break;
// }
// }
return res;
}
// return res;
// }
function transformChildIterators(IteratorsProfile: Array<any>): ChildIterator {
var res: ChildIterator = {};
for (let i = 1; i < IteratorsProfile.length; i += 2) {
const value = IteratorsProfile[i + 1];
switch (IteratorsProfile[i]) {
case 'Type':
res.type = value;
break;
case 'Counter':
res.counter = value;
break;
case 'Time':
res.time = value;
break;
case 'Size':
res.size = value;
break;
case 'Term':
res.term = value;
break;
case 'Child iterators':
res.childIterators = value.map(transformChildIterators);
break;
}
}
// function transformChildIterators(IteratorsProfile: Array<any>): ChildIterator {
// var res: ChildIterator = {};
// for (let i = 1; i < IteratorsProfile.length; i += 2) {
// const value = IteratorsProfile[i + 1];
// switch (IteratorsProfile[i]) {
// case 'Type':
// res.type = value;
// break;
// case 'Counter':
// res.counter = value;
// break;
// case 'Time':
// res.time = value;
// break;
// case 'Size':
// res.size = value;
// break;
// case 'Term':
// res.term = value;
// break;
// case 'Child iterators':
// res.childIterators = value.map(transformChildIterators);
// break;
// }
// }
return res;
}
// return res;
// }

View File

@@ -1,5 +1,7 @@
export { default } from './commands';
export { RediSearchSchema, SchemaFieldTypes, SchemaTextFieldPhonetics, SearchReply, VectorAlgorithms } from './commands';
export { AggregateSteps, AggregateGroupByReducers } from './commands/AGGREGATE';
export { SearchOptions } from './commands/SEARCH';
export { SCHEMA_FIELD_TYPE, SchemaFieldType } from './commands/CREATE';
// export { RediSearchSchema, SchemaFieldTypes, SchemaTextFieldPhonetics, SearchReply, VectorAlgorithms } from './commands';
// export { AggregateSteps, AggregateGroupByReducers } from './commands/AGGREGATE';
// export { SearchOptions } from './commands/SEARCH';

View File

@@ -2,8 +2,8 @@
"name": "@redis/search",
"version": "1.1.5",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"main": "./dist/lib/index.js",
"types": "./dist/lib/index.d.ts",
"files": [
"dist/",
"!dist/tsconfig.tsbuildinfo"

View File

@@ -1,5 +1,5 @@
import { RedisArgument, Command, CommandArguments } from '@redis/client/dist/lib/RESP/types';
import { RedisVariadicArgument, pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers';
import { RedisVariadicArgument } from '@redis/client/dist/lib/commands/generic-transformers';
import { Timestamp } from '.';
import { TsRangeOptions, pushRangeArguments } from './RANGE';
import { pushFilterArgument } from './MGET';
@@ -63,6 +63,5 @@ export default {
IS_READ_ONLY: true,
transformArguments: transformMRangeArguments.bind(undefined, 'TS.MRANGE'),
// TODO
// export { transformMRangeReply as transformReply } from '.';
transformReply: undefined as unknown as () => any
} as const satisfies Command;

View File

@@ -27,6 +27,5 @@ export default {
IS_READ_ONLY: true,
transformArguments: transformMRangeWithLabelsArguments.bind(undefined, 'TS.MRANGE'),
// TODO
// export { transformMRangeWithLabelsReply as transformReply } from '.';
transformReply: undefined as unknown as () => any
} as const satisfies Command;

View File

@@ -1,11 +1,9 @@
import { Command } from '@redis/client/dist/lib/RESP/types';
import { transformMRangeWithLabelsArguments } from './MRANGE_WITHLABELS';
import MRANGE_WITHLABELS, { transformMRangeWithLabelsArguments } from './MRANGE_WITHLABELS';
export default {
FIRST_KEY_INDEX: undefined,
IS_READ_ONLY: true,
FIRST_KEY_INDEX: MRANGE_WITHLABELS.FIRST_KEY_INDEX,
IS_READ_ONLY: MRANGE_WITHLABELS.IS_READ_ONLY,
transformArguments: transformMRangeWithLabelsArguments.bind(undefined, 'TS.MREVRANGE'),
// TODO
// export { transformMRangeWithLabelsReply as transformReply } from '.';
transformReply: undefined as unknown as () => any
transformReply: MRANGE_WITHLABELS.transformReply
} as const satisfies Command;

View File

@@ -1,5 +1,5 @@
import { CommandArguments, RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
import { Timestamp, transformTimestampArgument } from '.';
import { CommandArguments, RedisArgument, ArrayReply, UnwrapReply, Command } from '@redis/client/dist/lib/RESP/types';
import { Timestamp, transformTimestampArgument, SampleRawReply, transformSampleReply } from '.';
import { TimeSeriesAggregationType } from './CREATERULE';
export const TIME_SERIES_BUCKET_TIMESTAMP = {
@@ -107,11 +107,13 @@ export default {
FIRST_KEY_INDEX: 1,
IS_READ_ONLY: true,
transformArguments: transformRangeArguments.bind(undefined, 'TS.RANGE'),
// TODO
// import { SampleReply, transformRangeReply } from '.';
// export function transformReply(reply: Array<SampleRawReply>): Array<SampleReply> {
// return transformRangeReply(reply);
// }
transformReply: undefined as unknown as () => any
transformReply: {
2(reply: UnwrapReply<ArrayReply<SampleRawReply[2]>>) {
return reply.map(sample => transformSampleReply['2'](sample));
},
3(reply: UnwrapReply<ArrayReply<SampleRawReply[3]>>) {
return reply.map(sample => transformSampleReply['3'](sample));
}
}
} as const satisfies Command;

View File

@@ -1,94 +1,33 @@
import { strict as assert } from 'node:assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './REVRANGE';
import { TimeSeriesAggregationType } from '.';
import REVRANGE from './REVRANGE';
import { TIME_SERIES_AGGREGATION_TYPE } from '../index';
describe('TS.REVRANGE', () => {
describe('transformArguments', () => {
it('without options', () => {
assert.deepEqual(
transformArguments('key', '-', '+'),
['TS.REVRANGE', 'key', '-', '+']
);
});
it('with FILTER_BY_TS', () => {
assert.deepEqual(
transformArguments('key', '-', '+', {
FILTER_BY_TS: [0]
}),
['TS.REVRANGE', 'key', '-', '+', 'FILTER_BY_TS', '0']
);
});
it('with FILTER_BY_VALUE', () => {
assert.deepEqual(
transformArguments('key', '-', '+', {
FILTER_BY_VALUE: {
min: 1,
max: 2
}
}),
['TS.REVRANGE', 'key', '-', '+', 'FILTER_BY_VALUE', '1', '2']
);
});
it('with COUNT', () => {
assert.deepEqual(
transformArguments('key', '-', '+', {
COUNT: 1
}),
['TS.REVRANGE', 'key', '-', '+', 'COUNT', '1']
);
});
it('with ALIGN', () => {
assert.deepEqual(
transformArguments('key', '-', '+', {
ALIGN: '-'
}),
['TS.REVRANGE', 'key', '-', '+', 'ALIGN', '-']
);
});
it('with AGGREGATION', () => {
assert.deepEqual(
transformArguments('key', '-', '+', {
AGGREGATION: {
type: TimeSeriesAggregationType.AVERAGE,
timeBucket: 1
}
}),
['TS.REVRANGE', 'key', '-', '+', 'AGGREGATION', 'AVG', '1']
);
});
it('with FILTER_BY_TS, FILTER_BY_VALUE, COUNT, ALIGN, AGGREGATION', () => {
assert.deepEqual(
transformArguments('key', '-', '+', {
FILTER_BY_TS: [0],
FILTER_BY_VALUE: {
min: 1,
max: 2
},
COUNT: 1,
ALIGN: '-',
AGGREGATION: {
type: TimeSeriesAggregationType.AVERAGE,
timeBucket: 1
}
}),
[
'TS.REVRANGE', 'key', '-', '+', 'FILTER_BY_TS', '0', 'FILTER_BY_VALUE',
'1', '2', 'COUNT', '1', 'ALIGN', '-', 'AGGREGATION', 'AVG', '1'
]
);
});
it('transformArguments', () => {
assert.deepEqual(
REVRANGE.transformArguments('key', '-', '+', {
FILTER_BY_TS: [0],
FILTER_BY_VALUE: {
min: 1,
max: 2
},
COUNT: 1,
ALIGN: '-',
AGGREGATION: {
type: TIME_SERIES_AGGREGATION_TYPE.AVG,
timeBucket: 1
}
}),
[
'TS.REVRANGE', 'key', '-', '+', 'FILTER_BY_TS', '0', 'FILTER_BY_VALUE',
'1', '2', 'COUNT', '1', 'ALIGN', '-', 'AGGREGATION', 'AVG', '1'
]
);
});
testUtils.testWithClient('client.ts.revRange', async client => {
const [, , reply] = await Promise.all([
client.ts.add('key', 0, 1),
const [, reply] = await Promise.all([
client.ts.add('key', 1, 2),
client.ts.revRange('key', '-', '+')
]);
@@ -96,9 +35,6 @@ describe('TS.REVRANGE', () => {
assert.deepEqual(reply, [{
timestamp: 1,
value: 2
}, {
timestamp: 0,
value: 1
}]);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -137,27 +137,20 @@ export function pushLabelsArgument(args: Array<RedisArgument>, labels?: Labels)
return args;
}
// export type RawLabelsReply = ArrayReply<TuplesReply<[BlobStringReply, BlobStringReply]>>;
// export function transformLablesReply(reply: RawLabelsReply) {
// const labels: Record<string, BlobStringReply> = {};
// for (const [key, value] of reply) {
// labels[key.toString()] = value;
// }
// return labels
// }
export type SampleRawReply = {
2: TuplesReply<[timestamp: NumberReply, value: BlobStringReply]>;
3: TuplesReply<[timestamp: NumberReply, value: DoubleReply]>;
};
export const transformSampleReply = {
2(reply: TuplesReply<[timestamp: NumberReply, value: BlobStringReply]>) {
2(reply: SampleRawReply[2]) {
const [timestamp, value] = reply as unknown as UnwrapReply<typeof reply>;
return {
timestamp,
value: Number(value)
};
},
3(reply: TuplesReply<[timestamp: NumberReply, value: DoubleReply]>) {
3(reply: SampleRawReply[3]) {
const [timestamp, value] = reply as unknown as UnwrapReply<typeof reply>;
return {
timestamp,
@@ -166,136 +159,6 @@ export const transformSampleReply = {
}
};
// export enum TimeSeriesBucketTimestamp {
// LOW = '-',
// HIGH = '+',
// MID = '~'
// }
// export interface RangeOptions {
// LATEST?: boolean;
// FILTER_BY_TS?: Array<Timestamp>;
// FILTER_BY_VALUE?: {
// min: number;
// max: number;
// };
// COUNT?: number;
// ALIGN?: Timestamp;
// AGGREGATION?: {
// type: TimeSeriesAggregationType;
// timeBucket: Timestamp;
// BUCKETTIMESTAMP?: TimeSeriesBucketTimestamp;
// EMPTY?: boolean;
// };
// }
// export function pushRangeArguments(
// args: RedisCommandArguments,
// fromTimestamp: Timestamp,
// toTimestamp: Timestamp,
// options?: RangeOptions
// ): RedisCommandArguments {
// args.push(
// transformTimestampArgument(fromTimestamp),
// transformTimestampArgument(toTimestamp)
// );
// pushLatestArgument(args, options?.LATEST);
// if (options?.FILTER_BY_TS) {
// args.push('FILTER_BY_TS');
// for (const ts of options.FILTER_BY_TS) {
// args.push(transformTimestampArgument(ts));
// }
// }
// if (options?.FILTER_BY_VALUE) {
// args.push(
// 'FILTER_BY_VALUE',
// options.FILTER_BY_VALUE.min.toString(),
// options.FILTER_BY_VALUE.max.toString()
// );
// }
// if (options?.COUNT) {
// args.push(
// 'COUNT',
// options.COUNT.toString()
// );
// }
// if (options?.ALIGN) {
// args.push(
// 'ALIGN',
// transformTimestampArgument(options.ALIGN)
// );
// }
// if (options?.AGGREGATION) {
// args.push(
// 'AGGREGATION',
// options.AGGREGATION.type,
// transformTimestampArgument(options.AGGREGATION.timeBucket)
// );
// if (options.AGGREGATION.BUCKETTIMESTAMP) {
// args.push(
// 'BUCKETTIMESTAMP',
// options.AGGREGATION.BUCKETTIMESTAMP
// );
// }
// if (options.AGGREGATION.EMPTY) {
// args.push('EMPTY');
// }
// }
// return args;
// }
// interface MRangeGroupBy {
// label: string;
// reducer: TimeSeriesReducers;
// }
// export function pushMRangeGroupByArguments(args: RedisCommandArguments, groupBy?: MRangeGroupBy): RedisCommandArguments {
// if (groupBy) {
// args.push(
// 'GROUPBY',
// groupBy.label,
// 'REDUCE',
// groupBy.reducer
// );
// }
// return args;
// }
// export type Filter = string | Array<string>;
// export function pushFilterArgument(args: RedisCommandArguments, filter: string | Array<string>): RedisCommandArguments {
// args.push('FILTER');
// return pushVariadicArguments(args, filter);
// }
// export interface MRangeOptions extends RangeOptions {
// GROUPBY?: MRangeGroupBy;
// }
// export function pushMRangeArguments(
// args: RedisCommandArguments,
// fromTimestamp: Timestamp,
// toTimestamp: Timestamp,
// filter: Filter,
// options?: MRangeOptions
// ): RedisCommandArguments {
// args = pushRangeArguments(args, fromTimestamp, toTimestamp, options);
// args = pushFilterArgument(args, filter);
// return pushMRangeGroupByArguments(args, options?.GROUPBY);
// }
// export type SelectedLabels = string | Array<string>;
export function pushWithLabelsArgument(args: CommandArguments, selectedLabels?: RedisVariadicArgument) {
if (!selectedLabels) {
args.push('WITHLABELS');
@@ -305,65 +168,3 @@ export function pushWithLabelsArgument(args: CommandArguments, selectedLabels?:
return pushVariadicArguments(args, selectedLabels);
}
}
// export interface MRangeWithLabelsOptions extends MRangeOptions {
// SELECTED_LABELS?: SelectedLabels;
// }
// export function pushMRangeWithLabelsArguments(
// args: RedisCommandArguments,
// fromTimestamp: Timestamp,
// toTimestamp: Timestamp,
// filter: Filter,
// options?: MRangeWithLabelsOptions
// ): RedisCommandArguments {
// args = pushRangeArguments(args, fromTimestamp, toTimestamp, options);
// args = pushWithLabelsArgument(args, options?.SELECTED_LABELS);
// args = pushFilterArgument(args, filter);
// return pushMRangeGroupByArguments(args, options?.GROUPBY);
// }
// export function transformRangeReply(reply: Array<SampleRawReply>): Array<SampleReply> {
// return reply.map(transformSampleReply);
// }
// type MRangeRawReply = Array<[
// key: string,
// labels: RawLabels,
// samples: Array<SampleRawReply>
// ]>;
// interface MRangeReplyItem {
// key: string;
// samples: Array<SampleReply>;
// }
// export function transformMRangeReply(reply: MRangeRawReply): Array<MRangeReplyItem> {
// const args = [];
// for (const [key, _, sample] of reply) {
// args.push({
// key,
// samples: sample.map(transformSampleReply)
// });
// }
// return args;
// }
// export interface MRangeWithLabelsReplyItem extends MRangeReplyItem {
// labels: Labels;
// }
// export function transformMRangeWithLabelsReply(reply: MRangeRawReply): Array<MRangeWithLabelsReplyItem> {
// const args = [];
// for (const [key, labels, samples] of reply) {
// args.push({
// key,
// labels: transformLablesReply(labels),
// samples: samples.map(transformSampleReply)
// });
// }
// return args;
// }

View File

@@ -2,8 +2,8 @@
"name": "@redis/time-series",
"version": "1.0.5",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"main": "./dist/lib/index.js",
"types": "./dist/lib/index.d.ts",
"files": [
"dist/",
"!dist/tsconfig.tsbuildinfo"