@or-sdk/graph 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/README.md +190 -7
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.3.1](https://gitlab.internal.onereach.io/onereach/platform/or-sdk-next/compare/@or-sdk/graph@1.3.0...@or-sdk/graph@1.3.1) (2023-04-07)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **@or-sdk/graphs:** Improve docs ([5b1cbd5](https://gitlab.internal.onereach.io/onereach/platform/or-sdk-next/commit/5b1cbd5d405419f1160e2bdd84641dd1a61dbfc5))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
6
15
|
## [1.3.0](https://gitlab.internal.onereach.io/onereach/platform/or-sdk-next/compare/@or-sdk/graph@1.1.1...@or-sdk/graph@1.3.0) (2023-03-29)
|
|
7
16
|
|
|
8
17
|
|
package/README.md
CHANGED
|
@@ -1,21 +1,204 @@
|
|
|
1
|
-
##
|
|
1
|
+
## Overview
|
|
2
|
+
|
|
3
|
+
The `@or-sdk/graph` package provides a client for working with the graphs in OneReach.ai. With this client, you can perform operations such as querying graphs, creating new graphs and managing saved queries.
|
|
4
|
+
|
|
5
|
+
The OneReach.ai Graphs application is a graph-based database that allows you to store and manipulate data using nodes and edges. You can use it to model complex relationships between entities and perform complex queries on them.
|
|
6
|
+
|
|
7
|
+
The database implements the openCypher query language, which is a declarative SQL-like language for querying graph databases. You can learn more about openCypher by visiting the [official documentation](https://redis.io/docs/stack/graph/cypher_support/).
|
|
8
|
+
|
|
9
|
+
The OneReach.ai Graphs application is built on top of RedisGraph, which is a graph database that uses the Redis store as its underlying storage engine.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
To install the package, run the following command:
|
|
14
|
+
|
|
2
15
|
```
|
|
3
|
-
$ npm
|
|
16
|
+
$ npm install @or-sdk/graph
|
|
4
17
|
```
|
|
5
18
|
|
|
6
|
-
## Usage
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
To use the `Graphs` client, you need to create an instance of the class with the appropriate configuration options. You can either provide the direct API URL or the service discovery URL. Here is an example:
|
|
22
|
+
|
|
7
23
|
```typescript
|
|
8
|
-
import {
|
|
24
|
+
import { Graphs } from '@or-sdk/graph';
|
|
9
25
|
|
|
10
26
|
// with direct api url
|
|
11
|
-
const graph = new
|
|
27
|
+
const graph = new Graphs({
|
|
12
28
|
token: 'my-account-token-string',
|
|
13
29
|
graphUrl: 'http://example.graph/endpoint'
|
|
14
30
|
});
|
|
15
31
|
|
|
16
32
|
// with service discovery(slower)
|
|
17
|
-
const graph = new
|
|
33
|
+
const graph = new Graphs({
|
|
18
34
|
token: 'my-account-token-string',
|
|
19
35
|
discoveryUrl: 'http://example.graph/endpoint'
|
|
20
36
|
});
|
|
21
|
-
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Once you have an instance of the `Graphs`
|
|
40
|
+
client, you can use its methods to interact with the OneReach.ai Graphs application. The available methods are:
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### `query`
|
|
44
|
+
Executes a query on a graph and returns the results.
|
|
45
|
+
|
|
46
|
+
#### Params
|
|
47
|
+
- `[0].query: string` - Cypher Query to execute
|
|
48
|
+
- `[0].query: graph` - Graph name to execute the query in
|
|
49
|
+
- `[0].params?: Object` - Optional substitution params.
|
|
50
|
+
|
|
51
|
+
#### Example
|
|
52
|
+
```typescript
|
|
53
|
+
type Place = Node<{ name: string; description: string; lat: number; lng: number }>
|
|
54
|
+
|
|
55
|
+
const res = await graph.query<{ p: Place }>({
|
|
56
|
+
graph: 'places',
|
|
57
|
+
query: 'MATCH (p: Place) WHERE p.name = $name RETURN p',
|
|
58
|
+
params: { name: 'CoffeePlace' }
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
console.log(res[0].n.name)
|
|
62
|
+
// Outputs: "CoffeePlace"
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### `listGraphs`
|
|
67
|
+
Lists all graphs available to the authenticated user.
|
|
68
|
+
|
|
69
|
+
#### Params
|
|
70
|
+
- `[0]?: string` - Optional name of graph to search for.
|
|
71
|
+
|
|
72
|
+
#### Example
|
|
73
|
+
```typescript
|
|
74
|
+
const graphs = await graph.listGraphs();
|
|
75
|
+
|
|
76
|
+
console.log(graphs.items);
|
|
77
|
+
// Outputs: Array<Graph>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### `getGraphInfo`
|
|
81
|
+
Gets detailed information about a specific graph.
|
|
82
|
+
|
|
83
|
+
#### Params
|
|
84
|
+
- `[0]: string` - Name of graph to get info for.
|
|
85
|
+
|
|
86
|
+
#### Example
|
|
87
|
+
```typescript
|
|
88
|
+
const result = await graph.getGraphInfo('graph-name');
|
|
89
|
+
|
|
90
|
+
console.log(result);
|
|
91
|
+
// Outputs: GraphInfo object
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### `createGraph`
|
|
95
|
+
Creates a new graph.
|
|
96
|
+
|
|
97
|
+
#### Params
|
|
98
|
+
- `[0]: Graph` - New graph to create.
|
|
99
|
+
|
|
100
|
+
#### Example
|
|
101
|
+
```typescript
|
|
102
|
+
const result = await graph.createGraph({
|
|
103
|
+
name: 'graph-name',
|
|
104
|
+
description: 'First steps in graphs',
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
console.log(result);
|
|
108
|
+
// Outputs: WriteResponse object
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### `updateGraph`
|
|
112
|
+
Updates an existing graph.
|
|
113
|
+
|
|
114
|
+
#### Params
|
|
115
|
+
- `[0]: Graph` - Graph to update.
|
|
116
|
+
|
|
117
|
+
#### Example
|
|
118
|
+
```typescript
|
|
119
|
+
const result = await graph.updateGraph({
|
|
120
|
+
name: 'graph-name',
|
|
121
|
+
description: 'First steps in graphs',
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
console.log(result);
|
|
125
|
+
// Outputs: WriteResponse object
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### `deleteGraph`
|
|
129
|
+
Deletes an existing graph.
|
|
130
|
+
|
|
131
|
+
#### Params
|
|
132
|
+
- `[0]: string` - Name of graph to delete.
|
|
133
|
+
|
|
134
|
+
#### Example
|
|
135
|
+
```typescript
|
|
136
|
+
const result = await graph.deleteGraph('graph-name');
|
|
137
|
+
|
|
138
|
+
console.log(result);
|
|
139
|
+
// Outputs: WriteResponse object
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### `saveQuery`
|
|
143
|
+
Saves a new Cypher query for future reuse.
|
|
144
|
+
|
|
145
|
+
#### Params
|
|
146
|
+
- `[0]: string` - Graph name to save query for.
|
|
147
|
+
- `[1]: Query` - Query to save.
|
|
148
|
+
|
|
149
|
+
#### Example
|
|
150
|
+
```typescript
|
|
151
|
+
const result = await graph.saveQuery('graph-name', {
|
|
152
|
+
name: 'query-name',
|
|
153
|
+
query: 'MATCH (p: Place) WHERE p.name = $name RETURN p',
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
console.log(result);
|
|
157
|
+
// Outputs: WriteResponse object
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### `listQueries`
|
|
161
|
+
Lists all saved queries for a graph.
|
|
162
|
+
|
|
163
|
+
#### Params
|
|
164
|
+
- `[0]: string` - Name of graph to list queries for.
|
|
165
|
+
- `[1]?: string` - Optional name of query to search for.
|
|
166
|
+
|
|
167
|
+
#### Example
|
|
168
|
+
```typescript
|
|
169
|
+
const queries = await graph.listQueries('graph-name');
|
|
170
|
+
|
|
171
|
+
console.log(queries.items);
|
|
172
|
+
// Outputs: Array<Query> object
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### `getQuery`
|
|
176
|
+
Gets detailed information about a specific saved query.
|
|
177
|
+
|
|
178
|
+
#### Params
|
|
179
|
+
- `[0]: string` - Name of graph the query belongs to.
|
|
180
|
+
- `[1]: string` - Name of query to get info for.
|
|
181
|
+
|
|
182
|
+
#### Example
|
|
183
|
+
```typescript
|
|
184
|
+
const result = await graph.getQuery('graph-name', 'query-name');
|
|
185
|
+
|
|
186
|
+
console.log(result);
|
|
187
|
+
// Outputs: Query object
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### `deleteQuery`
|
|
191
|
+
Deletes a saved query.
|
|
192
|
+
|
|
193
|
+
#### Params
|
|
194
|
+
- `[0]: string` - Name of graph the query belongs to.
|
|
195
|
+
- `[1]: string` - Name of query to delete.
|
|
196
|
+
|
|
197
|
+
#### Example
|
|
198
|
+
```typescript
|
|
199
|
+
const result = await graph.deleteQuery('graph-name', 'query-name');
|
|
200
|
+
|
|
201
|
+
console.log(result);
|
|
202
|
+
// Outputs: WriteResponse object
|
|
203
|
+
```
|
|
204
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@or-sdk/graph",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "fdf5a567d2f342106696085f8aa004657bb75b37"
|
|
32
32
|
}
|