1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00
* init

* implement graph commands

* add graph to packages table

* fix ts.infoDebug

* fix redisearch tests

* Update INFO_DEBUG.ts

* fix INFO.spec.ts

* test QUERY and SLOWLOG

Co-authored-by: Avital-Fine <avital.fine@redis.com>
This commit is contained in:
Leibale Eidelman
2022-01-31 12:52:19 -05:00
committed by GitHub
parent 46b831c922
commit 3547b20293
46 changed files with 563 additions and 39 deletions

View File

@@ -11,11 +11,12 @@ node-redis is a modern, high performance [Redis](https://redis.io) client for No
## Packages
| Name | Description |
| Name | Description |
|---------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [redis](./) | [![Downloads](https://img.shields.io/npm/dm/redis.svg)](https://www.npmjs.com/package/redis) [![Version](https://img.shields.io/npm/v/redis.svg)](https://www.npmjs.com/package/redis) |
| [@node-redis/client](./packages/client) | [![Downloads](https://img.shields.io/npm/dm/@node-redis/client.svg)](https://www.npmjs.com/package/@node-redis/client) [![Version](https://img.shields.io/npm/v/@node-redis/client.svg)](https://www.npmjs.com/package/@node-redis/client) [![Docs](https://img.shields.io/badge/-documentation-dc382c)](https://redis.js.org/documentation/client/) |
| [@node-redis/bloom](./packages/bloom) | [![Downloads](https://img.shields.io/npm/dm/@node-redis/bloom.svg)](https://www.npmjs.com/package/@node-redis/bloom) [![Version](https://img.shields.io/npm/v/@node-redis/bloom.svg)](https://www.npmjs.com/package/@node-redis/bloom) [![Docs](https://img.shields.io/badge/-documentation-dc382c)](https://redis.js.org/documentation/bloom/) [Redis Bloom](https://oss.redis.com/redisbloom/) commands |
| [@node-redis/graph](./packages/graph) | [![Downloads](https://img.shields.io/npm/dm/@node-redis/graph.svg)](https://www.npmjs.com/package/@node-redis/graph) [![Version](https://img.shields.io/npm/v/@node-redis/graph.svg)](https://www.npmjs.com/package/@node-redis/graph) [![Docs](https://img.shields.io/badge/-documentation-dc382c)](https://redis.js.org/documentation/graph/) [Redis Graph](https://oss.redis.com/redisgraph/) commands |
| [@node-redis/json](./packages/json) | [![Downloads](https://img.shields.io/npm/dm/@node-redis/json.svg)](https://www.npmjs.com/package/@node-redis/json) [![Version](https://img.shields.io/npm/v/@node-redis/json.svg)](https://www.npmjs.com/package/@node-redis/json) [![Docs](https://img.shields.io/badge/-documentation-dc382c)](https://redis.js.org/documentation/json/) [Redis JSON](https://oss.redis.com/redisjson/) commands |
| [@node-redis/search](./packages/search) | [![Downloads](https://img.shields.io/npm/dm/@node-redis/search.svg)](https://www.npmjs.com/package/@node-redis/search) [![Version](https://img.shields.io/npm/v/@node-redis/search.svg)](https://www.npmjs.com/package/@node-redis/search) [![Docs](https://img.shields.io/badge/-documentation-dc382c)](https://redis.js.org/documentation/search/) [Redis Search](https://oss.redis.com/redisearch/) commands |
| [@node-redis/time-series](./packages/time-series) | [![Downloads](https://img.shields.io/npm/dm/@node-redis/time-series.svg)](https://www.npmjs.com/package/@node-redis/time-series) [![Version](https://img.shields.io/npm/v/@node-redis/time-series.svg)](https://www.npmjs.com/package/@node-redis/time-series) [![Docs](https://img.shields.io/badge/-documentation-dc382c)](https://redis.js.org/documentation/time-series/) [Redis Time-Series](https://oss.redis.com/redistimeseries/) commands |

View File

@@ -1,18 +1,21 @@
import { createClient as _createClient, createCluster as _createCluster, RedisClientOptions, RedisClientType, RedisClusterOptions, RedisClusterType } from '@node-redis/client';
import { RedisScripts } from '@node-redis/client/dist/lib/commands';
import RedisBloomModules from '@node-redis/bloom';
import RedisGraph from '@node-redis/graph';
import RedisJSON from '@node-redis/json';
import RediSearch from '@node-redis/search';
import RedisTimeSeries from '@node-redis/time-series';
export * from '@node-redis/client';
export * from '@node-redis/bloom';
export * from '@node-redis/graph';
export * from '@node-redis/json';
export * from '@node-redis/search';
export * from '@node-redis/time-series';
const modules = {
...RedisBloomModules,
graph: RedisGraph,
json: RedisJSON,
ft: RediSearch,
ts: RedisTimeSeries

73
package-lock.json generated
View File

@@ -570,6 +570,10 @@
"resolved": "packages/client",
"link": true
},
"node_modules/@node-redis/graph": {
"resolved": "packages/graph",
"link": true
},
"node_modules/@node-redis/json": {
"resolved": "packages/json",
"link": true
@@ -876,9 +880,9 @@
"dev": true
},
"node_modules/@types/node": {
"version": "17.0.10",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.10.tgz",
"integrity": "sha512-S/3xB4KzyFxYGCppyDt68yzBU9ysL88lSdIah4D6cptdcltc4NCPCAMc0+PCpg/lLIyC7IPvj2Z52OJWeIUkog==",
"version": "17.0.13",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.13.tgz",
"integrity": "sha512-Y86MAxASe25hNzlDbsviXl8jQHb0RDvKt4c40ZJQ1Don0AAL0STLZSs4N+6gLEO55pedy7r2cLwS+ZDxPm/2Bw==",
"dev": true
},
"node_modules/@types/parse-json": {
@@ -6434,7 +6438,7 @@
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@node-redis/test-utils": "*",
"@types/node": "^17.0.10",
"@types/node": "^17.0.12",
"nyc": "^15.1.0",
"release-it": "^14.12.4",
"source-map-support": "^0.5.21",
@@ -6459,7 +6463,7 @@
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@node-redis/test-utils": "*",
"@types/node": "^17.0.10",
"@types/node": "^17.0.12",
"@types/redis-parser": "^3.0.0",
"@types/sinon": "^10.0.8",
"@types/yallist": "^4.0.1",
@@ -6478,6 +6482,25 @@
"node": ">=12"
}
},
"packages/graph": {
"name": "@node-redis/graph",
"version": "1.0.0-rc",
"license": "MIT",
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@node-redis/test-utils": "*",
"@types/node": "^17.0.12",
"nyc": "^15.1.0",
"release-it": "^14.12.4",
"source-map-support": "^0.5.21",
"ts-node": "^10.4.0",
"typedoc": "^0.22.11",
"typescript": "^4.5.5"
},
"peerDependencies": {
"@node-redis/client": "^1.0.0"
}
},
"packages/json": {
"name": "@node-redis/json",
"version": "1.0.2",
@@ -6485,7 +6508,7 @@
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@node-redis/test-utils": "*",
"@types/node": "^17.0.10",
"@types/node": "^17.0.12",
"nyc": "^15.1.0",
"release-it": "^14.12.4",
"source-map-support": "^0.5.21",
@@ -6504,7 +6527,7 @@
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@node-redis/test-utils": "*",
"@types/node": "^17.0.10",
"@types/node": "^17.0.12",
"nyc": "^15.1.0",
"release-it": "^14.12.4",
"source-map-support": "^0.5.21",
@@ -6521,7 +6544,7 @@
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@types/mocha": "^9.1.0",
"@types/node": "^17.0.10",
"@types/node": "^17.0.12",
"@types/yargs": "^17.0.8",
"mocha": "^9.2.0",
"nyc": "^15.1.0",
@@ -6541,7 +6564,7 @@
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@node-redis/test-utils": "*",
"@types/node": "^17.0.10",
"@types/node": "^17.0.12",
"nyc": "^15.1.0",
"release-it": "^14.12.4",
"source-map-support": "^0.5.21",
@@ -6971,7 +6994,7 @@
"requires": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@node-redis/test-utils": "*",
"@types/node": "^17.0.10",
"@types/node": "^17.0.12",
"nyc": "^15.1.0",
"release-it": "^14.12.4",
"source-map-support": "^0.5.21",
@@ -6985,7 +7008,7 @@
"requires": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@node-redis/test-utils": "*",
"@types/node": "^17.0.10",
"@types/node": "^17.0.12",
"@types/redis-parser": "^3.0.0",
"@types/sinon": "^10.0.8",
"@types/yallist": "^4.0.1",
@@ -7005,12 +7028,26 @@
"yallist": "4.0.0"
}
},
"@node-redis/graph": {
"version": "file:packages/graph",
"requires": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@node-redis/test-utils": "*",
"@types/node": "^17.0.12",
"nyc": "^15.1.0",
"release-it": "^14.12.4",
"source-map-support": "^0.5.21",
"ts-node": "^10.4.0",
"typedoc": "^0.22.11",
"typescript": "^4.5.5"
}
},
"@node-redis/json": {
"version": "file:packages/json",
"requires": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@node-redis/test-utils": "*",
"@types/node": "^17.0.10",
"@types/node": "^17.0.12",
"nyc": "^15.1.0",
"release-it": "^14.12.4",
"source-map-support": "^0.5.21",
@@ -7024,7 +7061,7 @@
"requires": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@node-redis/test-utils": "*",
"@types/node": "^17.0.10",
"@types/node": "^17.0.12",
"nyc": "^15.1.0",
"release-it": "^14.12.4",
"source-map-support": "^0.5.21",
@@ -7038,7 +7075,7 @@
"requires": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@types/mocha": "^9.1.0",
"@types/node": "^17.0.10",
"@types/node": "^17.0.12",
"@types/yargs": "^17.0.8",
"mocha": "^9.2.0",
"nyc": "^15.1.0",
@@ -7053,7 +7090,7 @@
"requires": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@node-redis/test-utils": "*",
"@types/node": "^17.0.10",
"@types/node": "^17.0.12",
"nyc": "^15.1.0",
"release-it": "^14.12.4",
"source-map-support": "^0.5.21",
@@ -7326,9 +7363,9 @@
"dev": true
},
"@types/node": {
"version": "17.0.10",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.10.tgz",
"integrity": "sha512-S/3xB4KzyFxYGCppyDt68yzBU9ysL88lSdIah4D6cptdcltc4NCPCAMc0+PCpg/lLIyC7IPvj2Z52OJWeIUkog==",
"version": "17.0.13",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.13.tgz",
"integrity": "sha512-Y86MAxASe25hNzlDbsviXl8jQHb0RDvKt4c40ZJQ1Don0AAL0STLZSs4N+6gLEO55pedy7r2cLwS+ZDxPm/2Bw==",
"dev": true
},
"@types/parse-json": {

View File

@@ -18,7 +18,7 @@
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@node-redis/test-utils": "*",
"@types/node": "^17.0.10",
"@types/node": "^17.0.13",
"nyc": "^15.1.0",
"release-it": "^14.12.4",
"source-map-support": "^0.5.21",

View File

@@ -6,6 +6,10 @@
"include": [
"./lib/**/*.ts"
],
"exclude": [
"./lib/test-utils.ts",
"./lib/**/*.spec.ts"
],
"typedocOptions": {
"entryPoints": [
"./lib"

View File

@@ -22,9 +22,9 @@
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@node-redis/test-utils": "*",
"@types/node": "^17.0.10",
"@types/node": "^17.0.13",
"@types/redis-parser": "^3.0.0",
"@types/sinon": "^10.0.8",
"@types/sinon": "^10.0.9",
"@types/yallist": "^4.0.1",
"@typescript-eslint/eslint-plugin": "^5.10.1",
"@typescript-eslint/parser": "^5.10.1",

View File

@@ -0,0 +1,4 @@
{
"extends": "@istanbuljs/nyc-config-typescript",
"exclude": ["**/*.spec.ts", "lib/test-utils.ts"]
}

View File

@@ -0,0 +1,10 @@
{
"git": {
"tagName": "graph@${version}",
"commitMessage": "Release ${tagName}",
"tagAnnotation": "Release ${tagName}"
},
"npm": {
"publishArgs": ["--access", "public"]
}
}

1
packages/graph/README.md Normal file
View File

@@ -0,0 +1 @@
# @node-redis/graph

View File

@@ -0,0 +1,22 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './CONFIG_GET';
describe('CONFIG GET', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('TIMEOUT'),
['GRAPH.CONFIG', 'GET', 'TIMEOUT']
);
});
testUtils.testWithClient('client.graph.configGet', async client => {
assert.deepEqual(
await client.graph.configGet('TIMEOUT'),
[
'TIMEOUT',
0
]
);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -0,0 +1,12 @@
export const IS_READ_ONLY = true;
export function transformArguments(configKey: string): Array<string> {
return ['GRAPH.CONFIG', 'GET', configKey];
}
type ConfigItem = [
configKey: string,
value: number
];
export declare function transformReply(): ConfigItem | Array<ConfigItem>;

View File

@@ -0,0 +1,19 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './CONFIG_SET';
describe('CONFIG SET', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('TIMEOUT', 0),
['GRAPH.CONFIG', 'SET', 'TIMEOUT', '0']
);
});
testUtils.testWithClient('client.graph.configSet', async client => {
assert.equal(
await client.graph.configSet('TIMEOUT', 0),
'OK'
);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -0,0 +1,10 @@
export function transformArguments(configKey: string, value: number): Array<string> {
return [
'GRAPH.CONFIG',
'SET',
configKey,
value.toString()
];
}
export declare function transformReply(): 'OK';

View File

@@ -0,0 +1,21 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './DELETE';
describe('', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key'),
['GRAPH.DELETE', 'key']
);
});
testUtils.testWithClient('client.graph.delete', async client => {
await client.graph.query('key', 'RETURN 1');
assert.equal(
typeof await client.graph.delete('key'),
'string'
);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -0,0 +1,7 @@
export const FIRST_KEY_INDEX = 1;
export function transformArguments(key: string): Array<string> {
return ['GRAPH.DELETE', key];
}
export declare function transformReply(): string;

View File

@@ -0,0 +1,18 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './EXPLAIN';
describe('EXPLAIN', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key', 'RETURN 0'),
['GRAPH.EXPLAIN', 'key', 'RETURN 0']
);
});
testUtils.testWithClient('client.graph.explain', async client => {
const reply = await client.graph.explain('key', 'RETURN 0');
assert.ok(Array.isArray(reply));
assert.ok(!reply.find(x => typeof x !== 'string'));
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -0,0 +1,9 @@
export const FIRST_KEY_INDEX = 1;
export const IS_READ_ONLY = true;
export function transformArguments(key: string, query: string): Array<string> {
return ['GRAPH.EXPLAIN', key, query];
}
export declare function transfromReply(): Array<string>;

View File

@@ -0,0 +1,19 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LIST';
describe('LIST', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments(),
['GRAPH.LIST']
);
});
testUtils.testWithClient('client.graph.list', async client => {
assert.deepEqual(
await client.graph.list(),
[]
);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -0,0 +1,7 @@
export const IS_READ_ONLY = true;
export function transformArguments(): Array<string> {
return ['GRAPH.LIST'];
}
export declare function transformReply(): Array<string>;

View File

@@ -0,0 +1,18 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './PROFILE';
describe('PROFILE', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key', 'RETURN 0'),
['GRAPH.PROFILE', 'key', 'RETURN 0']
);
});
testUtils.testWithClient('client.graph.profile', async client => {
const reply = await client.graph.profile('key', 'RETURN 0');
assert.ok(Array.isArray(reply));
assert.ok(!reply.find(x => typeof x !== 'string'));
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -0,0 +1,9 @@
export const FIRST_KEY_INDEX = 1;
export const IS_READ_ONLY = true;
export function transformArguments(key: string, query: string): Array<string> {
return ['GRAPH.PROFILE', key, query];
}
export declare function transfromReply(): Array<string>;

View File

@@ -0,0 +1,22 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './QUERY';
describe('QUERY', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key', '*', 100),
['GRAPH.QUERY', 'key', '*', '100']
);
});
testUtils.testWithClient('client.graph.query', async client => {
await client.graph.query('key',
"CREATE (r:human {name:'roi', age:34}), (a:human {name:'amit', age:32}), (r)-[:knows]->(a)"
);
const reply = await client.graph.query('key',
"MATCH (r:human)-[:knows]->(a:human) RETURN r.age, r.name"
);
assert.equal(reply.data.length, 1);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -0,0 +1,43 @@
import { RedisCommandArgument, RedisCommandArguments } from '@node-redis/client/dist/lib/commands/index';
import { pushQueryArguments } from '.';
export const FIRST_KEY_INDEX = 1;
export function transformArguments(
graph: RedisCommandArgument,
query: RedisCommandArgument,
timeout?: number
): RedisCommandArguments {
return pushQueryArguments(
['GRAPH.QUERY'],
graph,
query,
timeout
);
}
type Headers = Array<string>;
type Data = Array<Array<string | number | null>>;
type Metadata = Array<string>;
type QueryRawReply = [
headers: Headers,
data: Data,
metadata: Metadata
];
interface QueryReply {
headers: Headers,
data: Data,
metadata: Metadata
};
export function transformReply(reply: QueryRawReply): QueryReply {
return {
headers: reply[0],
data: reply[1],
metadata: reply[2]
};
}

View File

@@ -0,0 +1,22 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './QUERY_RO';
describe('QUERY_RO', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key', '*', 100),
['GRAPH.RO_QUERY', 'key', '*', '100']
);
});
testUtils.testWithClient('client.graph.queryRo', async client => {
await client.graph.query('key',
"CREATE (r:human {name:'roi', age:34}), (a:human {name:'amit', age:32}), (r)-[:knows]->(a)"
);
const reply = await client.graph.queryRo('key',
"MATCH (r:human)-[:knows]->(a:human) RETURN r.age, r.name"
);
assert.equal(reply.data.length, 1);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -0,0 +1,21 @@
import { RedisCommandArgument, RedisCommandArguments } from '@node-redis/client/dist/lib/commands';
import { pushQueryArguments } from '.';
export { FIRST_KEY_INDEX } from './QUERY';
export const IS_READ_ONLY = true;
export function transformArguments(
graph: RedisCommandArgument,
query: RedisCommandArgument,
timeout?: number
): RedisCommandArguments {
return pushQueryArguments(
['GRAPH.RO_QUERY'],
graph,
query,
timeout
);
}
export { transformReply } from './QUERY';

View File

@@ -0,0 +1,18 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './SLOWLOG';
describe('SLOWLOG', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key'),
['GRAPH.SLOWLOG', 'key']
);
});
testUtils.testWithClient('client.graph.slowLog', async client => {
await client.graph.query('key', 'RETURN 1');
const reply = await client.graph.slowLog('key');
assert.equal(reply.length, 1);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -0,0 +1,30 @@
export const IS_READ_ONLY = true;
export const FIRST_KEY_INDEX = 1;
export function transformArguments(key: string) {
return ['GRAPH.SLOWLOG', key];
}
type SlowLogRawReply = Array<[
timestamp: string,
command: string,
query: string,
took: string
]>;
type SlowLogReply = Array<{
timestamp: Date;
command: string;
query: string;
took: number;
}>;
export function transformReply(logs: SlowLogRawReply): SlowLogReply {
return logs.map(([timestamp, command, query, took]) => ({
timestamp: new Date(Number(timestamp) * 1000),
command,
query,
took: Number(took)
}));
}

View File

@@ -0,0 +1,49 @@
import * as CONFIG_GET from './CONFIG_GET';
import * as CONFIG_SET from './CONFIG_SET';;
import * as DELETE from './DELETE';
import * as EXPLAIN from './EXPLAIN';
import * as LIST from './LIST';
import * as PROFILE from './PROFILE';
import * as QUERY_RO from './QUERY_RO';
import * as QUERY from './QUERY';
import * as SLOWLOG from './SLOWLOG';
import { RedisCommandArgument, RedisCommandArguments } from '@node-redis/client/dist/lib/commands';
export default {
CONFIG_GET,
configGet: CONFIG_GET,
CONFIG_SET,
configSet: CONFIG_SET,
DELETE,
delete: DELETE,
EXPLAIN,
explain: EXPLAIN,
LIST,
list: LIST,
PROFILE,
profile: PROFILE,
QUERY_RO,
queryRo: QUERY_RO,
QUERY,
query: QUERY,
SLOWLOG,
slowLog: SLOWLOG
};
export function pushQueryArguments(
args: RedisCommandArguments,
graph: RedisCommandArgument,
query: RedisCommandArgument,
timeout?: number
): RedisCommandArguments {
args.push(
graph,
query
);
if (timeout !== undefined) {
args.push(timeout.toString());
}
return args;
}

View File

@@ -0,0 +1 @@
export { default } from './commands';

View File

@@ -0,0 +1,21 @@
import TestUtils from '@node-redis/test-utils';
import RedisGraph from '.';
export default new TestUtils({
dockerImageName: 'redislabs/redisgraph',
dockerImageVersionArgument: 'redisgraph-version',
defaultDockerVersion: '2.8.7'
});
export const GLOBAL = {
SERVERS: {
OPEN: {
serverArguments: ['--loadmodule /usr/lib/redis/modules/redisgraph.so'],
clientOptions: {
modules: {
graph: RedisGraph
}
}
}
}
};

View File

@@ -0,0 +1,29 @@
{
"name": "@node-redis/graph",
"version": "1.0.0-rc",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist/"
],
"scripts": {
"test": "nyc -r text-summary -r lcov mocha -r source-map-support/register -r ts-node/register './lib/**/*.spec.ts'",
"build": "tsc",
"documentation": "typedoc"
},
"peerDependencies": {
"@node-redis/client": "^1.0.0"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@node-redis/test-utils": "*",
"@types/node": "^17.0.13",
"nyc": "^15.1.0",
"release-it": "^14.12.4",
"source-map-support": "^0.5.21",
"ts-node": "^10.4.0",
"typedoc": "^0.22.11",
"typescript": "^4.5.5"
}
}

View File

@@ -0,0 +1,20 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist"
},
"include": [
"./lib/**/*.ts"
],
"exclude": [
"./lib/test-utils.ts",
"./lib/**/*.spec.ts"
],
"typedocOptions": {
"entryPoints": [
"./lib"
],
"entryPointStrategy": "expand",
"out": "../../documentation/graph"
}
}

View File

@@ -4,7 +4,7 @@ import RedisJSON from '.';
export default new TestUtils({
dockerImageName: 'redislabs/rejson',
dockerImageVersionArgument: 'rejson-version',
defaultDockerVersion: '2.0.2'
defaultDockerVersion: '2.0.6'
});
export const GLOBAL = {

View File

@@ -18,7 +18,7 @@
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@node-redis/test-utils": "*",
"@types/node": "^17.0.10",
"@types/node": "^17.0.13",
"nyc": "^15.1.0",
"release-it": "^14.12.4",
"source-map-support": "^0.5.21",

View File

@@ -340,7 +340,7 @@ describe('CREATE', () => {
testUtils.testWithClient('client.ft.create', async client => {
assert.equal(
await client.ft.create('index', {
field: SchemaFieldTypes.TEXT // TODO: shouldn't be mandatory
field: SchemaFieldTypes.TEXT
}),
'OK'
);

View File

@@ -22,7 +22,7 @@ describe('DROPINDEX', () => {
testUtils.testWithClient('client.ft.dropIndex', async client => {
await client.ft.create('index', {
field: SchemaFieldTypes.TEXT // TODO: shouldn't be mandatory
field: SchemaFieldTypes.TEXT
});
assert.equal(

View File

@@ -1,4 +1,5 @@
import { strict as assert } from 'assert';
import { SchemaFieldTypes } from '.';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './INFO';
@@ -11,8 +12,8 @@ describe('INFO', () => {
});
testUtils.testWithClient('client.ft.info', async client => {
await client.ft.create('index', {}, {
ON: 'HASH' // TODO: shouldn't be mandatory
await client.ft.create('index', {
field: SchemaFieldTypes.TEXT
});
assert.deepEqual(
@@ -25,7 +26,16 @@ describe('INFO', () => {
keyType: 'HASH',
prefixes: ['']
},
attributes: [],
attributes: [[
'identifier',
'field',
'attribute',
'field',
'type',
'TEXT',
'WEIGHT',
'1'
]],
numDocs: '0',
maxDocId: '0',
numTerms: '0',

View File

@@ -1,6 +1,7 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './SYNDUMP';
import { SchemaFieldTypes } from '.';
describe('SYNDUMP', () => {
it('transformArguments', () => {
@@ -11,8 +12,8 @@ describe('SYNDUMP', () => {
});
testUtils.testWithClient('client.ft.synDump', async client => {
await client.ft.create('index', {}, {
ON: 'HASH' // TODO: shouldn't be mandatory
await client.ft.create('index', {
field: SchemaFieldTypes.TEXT
});
assert.deepEqual(

View File

@@ -1,6 +1,7 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './SYNUPDATE';
import { SchemaFieldTypes } from '.';
describe('SYNUPDATE', () => {
describe('transformArguments', () => {
@@ -27,8 +28,8 @@ describe('SYNUPDATE', () => {
});
testUtils.testWithClient('client.ft.synUpdate', async client => {
await client.ft.create('index', {}, {
ON: 'HASH' // TODO: shouldn't be mandatory
await client.ft.create('index', {
field: SchemaFieldTypes.TEXT
});
assert.equal(

View File

@@ -4,7 +4,7 @@ import RediSearch from '.';
export default new TestUtils({
dockerImageName: 'redislabs/redisearch',
dockerImageVersionArgument: 'redisearch-version',
defaultDockerVersion: '2.2.1'
defaultDockerVersion: '2.2.7'
});
export const GLOBAL = {

View File

@@ -18,7 +18,7 @@
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@node-redis/test-utils": "*",
"@types/node": "^17.0.10",
"@types/node": "^17.0.13",
"nyc": "^15.1.0",
"release-it": "^14.12.4",
"source-map-support": "^0.5.21",

View File

@@ -12,7 +12,7 @@
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@types/mocha": "^9.1.0",
"@types/node": "^17.0.10",
"@types/node": "^17.0.13",
"@types/yargs": "^17.0.8",
"mocha": "^9.2.0",
"nyc": "^15.1.0",

View File

@@ -44,6 +44,7 @@ describe('INFO_DEBUG', () => {
key: 'key2',
timeBucket: 5
}],
keySelfName: 'key',
chunks: [{
startTimestamp: 1,
endTimestamp: 1,

View File

@@ -16,6 +16,8 @@ export function transformArguments(key: string): Array<string> {
type InfoDebugRawReply = [
...infoArgs: InfoRawReply,
_: string,
keySelfName: string,
_: string,
chunks: Array<[
_: string,
startTimestamp: number,
@@ -31,6 +33,7 @@ type InfoDebugRawReply = [
]
interface InfoDebugReply extends InfoReply {
keySelfName: string;
chunks: Array<{
startTimestamp: number;
endTimestamp: number;
@@ -42,7 +45,8 @@ interface InfoDebugReply extends InfoReply {
export function transformReply(rawReply: InfoDebugRawReply): InfoDebugReply {
const reply = transformInfoReply(rawReply as unknown as InfoRawReply);
(reply as InfoDebugReply).chunks = rawReply[25].map(chunk => ({
(reply as InfoDebugReply).keySelfName = rawReply[25];
(reply as InfoDebugReply).chunks = rawReply[27].map(chunk => ({
startTimestamp: chunk[1],
endTimestamp: chunk[3],
samples: chunk[5],

View File

@@ -4,7 +4,7 @@ import TimeSeries from '.';
export default new TestUtils({
dockerImageName: 'redislabs/redistimeseries',
dockerImageVersionArgument: 'timeseries-version',
defaultDockerVersion: '1.6.0'
defaultDockerVersion: '1.6.8'
});
export const GLOBAL = {

View File

@@ -18,7 +18,7 @@
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@node-redis/test-utils": "*",
"@types/node": "^17.0.10",
"@types/node": "^17.0.13",
"nyc": "^15.1.0",
"release-it": "^14.12.4",
"source-map-support": "^0.5.21",