-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
4,668 additions
and
1,069 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ | |
"typescript": "^5.4.2" | ||
}, | ||
"dependencies": { | ||
"redis": "^4.6.13" | ||
"redis": "^4.6.13", | ||
"@redis/client": "*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 './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 Promise.all([ | ||
client.graph.query('key', 'RETURN 0'), // make sure to create a graph first | ||
client.graph.explain('key', 'RETURN 0') | ||
]); | ||
assert.ok(Array.isArray(reply)); | ||
assert.ok(!reply.find(x => typeof x !== 'string')); | ||
}, GLOBAL.SERVERS.OPEN); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { strict as assert } from 'assert'; | ||
import testUtils, { GLOBAL } from '../test-utils'; | ||
import { transformArguments } from './INFO'; | ||
|
||
describe('INFO', () => { | ||
it('transformArguments', () => { | ||
assert.deepEqual( | ||
transformArguments(), | ||
['GRAPH.INFO'] | ||
); | ||
}); | ||
|
||
testUtils.testWithClient('client.graph.info', async client => { | ||
assert.deepEqual( | ||
await client.graph.info(), | ||
[ | ||
"# Running queries", | ||
[], | ||
"# Waiting queries", | ||
[], | ||
|
||
] | ||
); | ||
}, GLOBAL.SERVERS.OPEN); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export const IS_READ_ONLY = true; | ||
|
||
export function transformArguments(section?: string): Array<string> { | ||
const args = ['GRAPH.INFO']; | ||
|
||
if (section) { | ||
args.push(section); | ||
} | ||
|
||
return args; | ||
} | ||
|
||
export declare function transformReply(): Array<string | Array<string>>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 './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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const IS_READ_ONLY = true; | ||
|
||
export function transformArguments(): Array<string> { | ||
return ['GRAPH.LIST']; | ||
} | ||
|
||
export declare function transformReply(): Array<string>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 './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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { strict as assert } from 'assert'; | ||
import testUtils, { GLOBAL } from '../test-utils'; | ||
import { transformArguments } from './QUERY'; | ||
|
||
describe('QUERY', () => { | ||
it('transformArguments', () => { | ||
assert.deepEqual( | ||
transformArguments('key', 'query'), | ||
['GRAPH.QUERY', 'key', 'query'] | ||
); | ||
}); | ||
|
||
testUtils.testWithClient('client.graph.query', async client => { | ||
const { data } = await client.graph.query('key', 'RETURN 0'); | ||
assert.deepEqual(data, [[0]]); | ||
}, GLOBAL.SERVERS.OPEN); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands'; | ||
import { pushQueryArguments, QueryOptionsBackwardCompatible } from '.'; | ||
|
||
export const FIRST_KEY_INDEX = 1; | ||
|
||
export function transformArguments( | ||
graph: RedisCommandArgument, | ||
query: RedisCommandArgument, | ||
options?: QueryOptionsBackwardCompatible, | ||
compact?: boolean | ||
): RedisCommandArguments { | ||
return pushQueryArguments( | ||
['GRAPH.QUERY'], | ||
graph, | ||
query, | ||
options, | ||
compact | ||
); | ||
} | ||
|
||
type Headers = Array<string>; | ||
|
||
type Data = Array<string | number | null | Data>; | ||
|
||
type Metadata = Array<string>; | ||
|
||
type QueryRawReply = [ | ||
headers: Headers, | ||
data: Data, | ||
metadata: Metadata | ||
] | [ | ||
metadata: Metadata | ||
]; | ||
|
||
export type QueryReply = { | ||
headers: undefined; | ||
data: undefined; | ||
metadata: Metadata; | ||
} | { | ||
headers: Headers; | ||
data: Data; | ||
metadata: Metadata; | ||
}; | ||
|
||
export function transformReply(reply: QueryRawReply): QueryReply { | ||
return reply.length === 1 ? { | ||
headers: undefined, | ||
data: undefined, | ||
metadata: reply[0] | ||
} : { | ||
headers: reply[0], | ||
data: reply[1], | ||
metadata: reply[2] | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { strict as assert } from 'assert'; | ||
import testUtils, { GLOBAL } from '../test-utils'; | ||
import { transformArguments } from './RO_QUERY'; | ||
|
||
describe('RO_QUERY', () => { | ||
it('transformArguments', () => { | ||
assert.deepEqual( | ||
transformArguments('key', 'query'), | ||
['GRAPH.RO_QUERY', 'key', 'query'] | ||
); | ||
}); | ||
|
||
testUtils.testWithClient('client.graph.roQuery', async client => { | ||
const [, { data }] = await Promise.all([ | ||
client.graph.query('key', 'RETURN 0'), // make sure to create a graph first | ||
client.graph.roQuery('key', 'RETURN 0') | ||
]); | ||
assert.deepEqual(data, [[0]]); | ||
}, GLOBAL.SERVERS.OPEN); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands'; | ||
import { pushQueryArguments, QueryOptionsBackwardCompatible } from '.'; | ||
|
||
export { FIRST_KEY_INDEX } from './QUERY'; | ||
|
||
export const IS_READ_ONLY = true; | ||
|
||
export function transformArguments( | ||
graph: RedisCommandArgument, | ||
query: RedisCommandArgument, | ||
options?: QueryOptionsBackwardCompatible, | ||
compact?: boolean | ||
): RedisCommandArguments { | ||
return pushQueryArguments( | ||
['GRAPH.RO_QUERY'], | ||
graph, | ||
query, | ||
options, | ||
compact | ||
); | ||
} | ||
|
||
export { transformReply } from './QUERY'; |
Oops, something went wrong.