Skip to content

Commit

Permalink
Graph (#1887)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
leibale and Avital-Fine authored Jan 31, 2022
1 parent 46b831c commit 3547b20
Show file tree
Hide file tree
Showing 46 changed files with 563 additions and 39 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
3 changes: 3 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
73 changes: 55 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/bloom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions packages/bloom/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"include": [
"./lib/**/*.ts"
],
"exclude": [
"./lib/test-utils.ts",
"./lib/**/*.spec.ts"
],
"typedocOptions": {
"entryPoints": [
"./lib"
Expand Down
4 changes: 2 additions & 2 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions packages/graph/.nycrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "@istanbuljs/nyc-config-typescript",
"exclude": ["**/*.spec.ts", "lib/test-utils.ts"]
}
10 changes: 10 additions & 0 deletions packages/graph/.release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"git": {
"tagName": "graph@${version}",
"commitMessage": "Release ${tagName}",
"tagAnnotation": "Release ${tagName}"
},
"npm": {
"publishArgs": ["--access", "public"]
}
}
1 change: 1 addition & 0 deletions packages/graph/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# @node-redis/graph
22 changes: 22 additions & 0 deletions packages/graph/lib/commands/CONFIG_GET.spec.ts
Original file line number Diff line number Diff line change
@@ -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);
});
12 changes: 12 additions & 0 deletions packages/graph/lib/commands/CONFIG_GET.ts
Original file line number Diff line number Diff line change
@@ -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>;
19 changes: 19 additions & 0 deletions packages/graph/lib/commands/CONFIG_SET.spec.ts
Original file line number Diff line number Diff line change
@@ -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);
});
10 changes: 10 additions & 0 deletions packages/graph/lib/commands/CONFIG_SET.ts
Original file line number Diff line number Diff line change
@@ -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';
21 changes: 21 additions & 0 deletions packages/graph/lib/commands/DELETE.spec.ts
Original file line number Diff line number Diff line change
@@ -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);
});
7 changes: 7 additions & 0 deletions packages/graph/lib/commands/DELETE.ts
Original file line number Diff line number Diff line change
@@ -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;
18 changes: 18 additions & 0 deletions packages/graph/lib/commands/EXPLAIN.spec.ts
Original file line number Diff line number Diff line change
@@ -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);
});
Loading

0 comments on commit 3547b20

Please sign in to comment.