@or-sdk/graph 0.27.0 → 0.27.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 +0 -13
- package/dist/cjs/Graph.js +30 -45
- package/dist/cjs/Graph.js.map +1 -1
- package/dist/esm/Graph.js +23 -38
- package/dist/esm/Graph.js.map +1 -1
- package/dist/types/Graph.d.ts +13 -7
- package/dist/types/Graph.d.ts.map +1 -1
- package/dist/types/types.d.ts +8 -5
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +14 -15
- package/src/Graph.ts +32 -61
- package/src/types.ts +9 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,19 +3,6 @@
|
|
|
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
|
-
## [0.27.0](https://gitlab.com/onereach/platform/or-sdk-next/compare/@or-sdk/graph@0.26.8...@or-sdk/graph@0.27.0) (2023-02-09)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### ⚠ BREAKING CHANGES
|
|
10
|
-
|
|
11
|
-
* **@or-sdk/graph:** Remove accountId from URL. Pass graph database name as URL param. Pass `accountId` as query string param. Add database description and imageUrl to database DTOs. Search databases by name.
|
|
12
|
-
|
|
13
|
-
### Features
|
|
14
|
-
|
|
15
|
-
* **@or-sdk/graph:** Remove accountId from URL. Pass graph database name as URL param. Pass `accountId` as query string param. Add database description and imageUrl to database DTOs. Search databases by name. ([094fb70](https://gitlab.com/onereach/platform/or-sdk-next/commit/094fb705ff32c529ec23a3755ea3b6e56110e46d))
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
6
|
### [0.26.8](https://gitlab.com/onereach/platform/or-sdk-next/compare/@or-sdk/graph@0.26.7...@or-sdk/graph@0.26.8) (2022-12-27)
|
|
20
7
|
|
|
21
8
|
**Note:** Version bump only for package @or-sdk/graph
|
package/dist/cjs/Graph.js
CHANGED
|
@@ -50,17 +50,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
50
50
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
54
|
-
var t = {};
|
|
55
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
56
|
-
t[p] = s[p];
|
|
57
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
58
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
59
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
60
|
-
t[p[i]] = s[p[i]];
|
|
61
|
-
}
|
|
62
|
-
return t;
|
|
63
|
-
};
|
|
64
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
54
|
exports.Graph = void 0;
|
|
66
55
|
var base_1 = require("@or-sdk/base");
|
|
@@ -78,17 +67,23 @@ var Graph = (function (_super) {
|
|
|
78
67
|
serviceUrl: graphUrl,
|
|
79
68
|
}) || this;
|
|
80
69
|
}
|
|
70
|
+
Graph.prototype.makeApiUrl = function (data) {
|
|
71
|
+
return this.isCrossAccount
|
|
72
|
+
? "".concat(data.url, "/").concat(this.targetAccountId)
|
|
73
|
+
: "".concat(data.url, "/current");
|
|
74
|
+
};
|
|
81
75
|
Graph.prototype.executeQuery = function (_a) {
|
|
82
76
|
var query = _a.query, params = _a.params, database = _a.database;
|
|
83
77
|
return __awaiter(this, void 0, void 0, function () {
|
|
84
78
|
return __generator(this, function (_b) {
|
|
85
|
-
return [2, this.
|
|
79
|
+
return [2, this.callApi({
|
|
86
80
|
data: {
|
|
87
81
|
query: query,
|
|
88
82
|
params: params,
|
|
83
|
+
database: database,
|
|
89
84
|
},
|
|
90
85
|
method: 'POST',
|
|
91
|
-
route:
|
|
86
|
+
route: 'query',
|
|
92
87
|
})];
|
|
93
88
|
});
|
|
94
89
|
});
|
|
@@ -139,63 +134,53 @@ var Graph = (function (_super) {
|
|
|
139
134
|
});
|
|
140
135
|
});
|
|
141
136
|
};
|
|
142
|
-
Graph.prototype.listDatabases = function (
|
|
137
|
+
Graph.prototype.listDatabases = function () {
|
|
143
138
|
return __awaiter(this, void 0, void 0, function () {
|
|
144
139
|
var databases;
|
|
145
140
|
return __generator(this, function (_a) {
|
|
146
141
|
switch (_a.label) {
|
|
147
|
-
case 0: return [4, this.
|
|
142
|
+
case 0: return [4, this.callApi({
|
|
148
143
|
method: 'GET',
|
|
149
144
|
route: 'databases',
|
|
150
|
-
params: name ? { name: name } : {},
|
|
151
145
|
})];
|
|
152
146
|
case 1:
|
|
153
|
-
databases = _a.sent();
|
|
154
|
-
return [2, (0, base_1.makeList)(databases)];
|
|
147
|
+
databases = (_a.sent()).databases;
|
|
148
|
+
return [2, (0, base_1.makeList)(databases.map(function (database) { return database.name; }))];
|
|
155
149
|
}
|
|
156
150
|
});
|
|
157
151
|
});
|
|
158
152
|
};
|
|
159
|
-
Graph.prototype.
|
|
160
|
-
|
|
161
|
-
return __generator(this, function (_a) {
|
|
162
|
-
return [2, this.callApiV2({
|
|
163
|
-
method: 'GET',
|
|
164
|
-
route: "databases/".concat(name),
|
|
165
|
-
})];
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
};
|
|
169
|
-
Graph.prototype.createDatabase = function (database) {
|
|
153
|
+
Graph.prototype.createDatabase = function (_a) {
|
|
154
|
+
var database = _a.database;
|
|
170
155
|
return __awaiter(this, void 0, void 0, function () {
|
|
171
|
-
return __generator(this, function (
|
|
172
|
-
return [2, this.
|
|
173
|
-
data: database,
|
|
174
|
-
method: '
|
|
156
|
+
return __generator(this, function (_b) {
|
|
157
|
+
return [2, this.callApi({
|
|
158
|
+
data: { database: database },
|
|
159
|
+
method: 'PUT',
|
|
175
160
|
route: 'databases',
|
|
176
161
|
})];
|
|
177
162
|
});
|
|
178
163
|
});
|
|
179
164
|
};
|
|
180
|
-
Graph.prototype.
|
|
165
|
+
Graph.prototype.getDatabaseInfo = function (_a) {
|
|
166
|
+
var database = _a.database;
|
|
181
167
|
return __awaiter(this, void 0, void 0, function () {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
route: "databases/".concat(name),
|
|
187
|
-
method: 'PUT',
|
|
188
|
-
data: data,
|
|
168
|
+
return __generator(this, function (_b) {
|
|
169
|
+
return [2, this.callApi({
|
|
170
|
+
method: 'GET',
|
|
171
|
+
route: "databases/".concat(encodeURIComponent(database)),
|
|
189
172
|
})];
|
|
190
173
|
});
|
|
191
174
|
});
|
|
192
175
|
};
|
|
193
|
-
Graph.prototype.dropDatabase = function (
|
|
176
|
+
Graph.prototype.dropDatabase = function (_a) {
|
|
177
|
+
var database = _a.database;
|
|
194
178
|
return __awaiter(this, void 0, void 0, function () {
|
|
195
|
-
return __generator(this, function (
|
|
196
|
-
return [2, this.
|
|
179
|
+
return __generator(this, function (_b) {
|
|
180
|
+
return [2, this.callApi({
|
|
181
|
+
data: { database: database },
|
|
197
182
|
method: 'DELETE',
|
|
198
|
-
route:
|
|
183
|
+
route: 'databases',
|
|
199
184
|
})];
|
|
200
185
|
});
|
|
201
186
|
});
|
package/dist/cjs/Graph.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Graph.js","sourceRoot":"","sources":["../../src/Graph.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Graph.js","sourceRoot":"","sources":["../../src/Graph.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAoE;AAUpE,yCAA0C;AAC1C,iCAAqG;AAErG;IAA2B,yBAAI;IAE7B,eAAY,MAAmB;QACrB,IAAA,KAAK,GAAwC,MAAM,MAA9C,EAAE,YAAY,GAA0B,MAAM,aAAh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,QAAQ,CAAC,CAAE;qBACnD,CAAC,EAAC;;;KACJ;IAQY,4BAAY,GAAzB,UAA0B,EAAmC;YAAjC,QAAQ,cAAA;;;gBAClC,WAAO,IAAI,CAAC,OAAO,CAAuB;wBACxC,IAAI,EAAE,EAAE,QAAQ,UAAA,EAAE;wBAClB,MAAM,EAAE,QAAQ;wBAChB,KAAK,EAAE,WAAW;qBACnB,CAAC,EAAC;;;KACJ;IACH,YAAC;AAAD,CAAC,AAtKD,CAA2B,WAAI,GAsK9B;AAtKY,sBAAK"}
|
package/dist/esm/Graph.js
CHANGED
|
@@ -7,17 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
-
var t = {};
|
|
12
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
-
t[p] = s[p];
|
|
14
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
-
t[p[i]] = s[p[i]];
|
|
18
|
-
}
|
|
19
|
-
return t;
|
|
20
|
-
};
|
|
21
10
|
import { Base, makeList } from '@or-sdk/base';
|
|
22
11
|
import { SERVICE_KEY } from './constants';
|
|
23
12
|
import { getCreateNodeQuery, getMatchNodeQuery, getDeleteNodeQuery, getSetNodeQuery } from './utils';
|
|
@@ -32,15 +21,21 @@ export class Graph extends Base {
|
|
|
32
21
|
serviceUrl: graphUrl,
|
|
33
22
|
});
|
|
34
23
|
}
|
|
24
|
+
makeApiUrl(data) {
|
|
25
|
+
return this.isCrossAccount
|
|
26
|
+
? `${data.url}/${this.targetAccountId}`
|
|
27
|
+
: `${data.url}/current`;
|
|
28
|
+
}
|
|
35
29
|
executeQuery({ query, params, database }) {
|
|
36
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
return this.
|
|
31
|
+
return this.callApi({
|
|
38
32
|
data: {
|
|
39
33
|
query,
|
|
40
34
|
params,
|
|
35
|
+
database,
|
|
41
36
|
},
|
|
42
37
|
method: 'POST',
|
|
43
|
-
route:
|
|
38
|
+
route: 'query',
|
|
44
39
|
});
|
|
45
40
|
});
|
|
46
41
|
}
|
|
@@ -78,48 +73,38 @@ export class Graph extends Base {
|
|
|
78
73
|
});
|
|
79
74
|
});
|
|
80
75
|
}
|
|
81
|
-
listDatabases(
|
|
76
|
+
listDatabases() {
|
|
82
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
const databases = yield this.
|
|
78
|
+
const { databases } = yield this.callApi({
|
|
84
79
|
method: 'GET',
|
|
85
80
|
route: 'databases',
|
|
86
|
-
params: name ? { name } : {},
|
|
87
|
-
});
|
|
88
|
-
return makeList(databases);
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
getDatabaseInfo(name) {
|
|
92
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
return this.callApiV2({
|
|
94
|
-
method: 'GET',
|
|
95
|
-
route: `databases/${name}`,
|
|
96
81
|
});
|
|
82
|
+
return makeList(databases.map(database => database.name));
|
|
97
83
|
});
|
|
98
84
|
}
|
|
99
|
-
createDatabase(database) {
|
|
85
|
+
createDatabase({ database }) {
|
|
100
86
|
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
-
return this.
|
|
102
|
-
data: database,
|
|
103
|
-
method: '
|
|
87
|
+
return this.callApi({
|
|
88
|
+
data: { database },
|
|
89
|
+
method: 'PUT',
|
|
104
90
|
route: 'databases',
|
|
105
91
|
});
|
|
106
92
|
});
|
|
107
93
|
}
|
|
108
|
-
|
|
94
|
+
getDatabaseInfo({ database }) {
|
|
109
95
|
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
route: `databases/${
|
|
113
|
-
method: 'PUT',
|
|
114
|
-
data,
|
|
96
|
+
return this.callApi({
|
|
97
|
+
method: 'GET',
|
|
98
|
+
route: `databases/${encodeURIComponent(database)}`,
|
|
115
99
|
});
|
|
116
100
|
});
|
|
117
101
|
}
|
|
118
|
-
dropDatabase(
|
|
102
|
+
dropDatabase({ database }) {
|
|
119
103
|
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
-
return this.
|
|
104
|
+
return this.callApi({
|
|
105
|
+
data: { database },
|
|
121
106
|
method: 'DELETE',
|
|
122
|
-
route:
|
|
107
|
+
route: 'databases',
|
|
123
108
|
});
|
|
124
109
|
});
|
|
125
110
|
}
|
package/dist/esm/Graph.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Graph.js","sourceRoot":"","sources":["../../src/Graph.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Graph.js","sourceRoot":"","sources":["../../src/Graph.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAwB,QAAQ,EAAE,MAAM,cAAc,CAAC;AAUpE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAErG,MAAM,OAAO,KAAM,SAAQ,IAAI;IAE7B,YAAY,MAAmB;QAC7B,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;QAE5D,KAAK,CAAC;YACJ,KAAK;YACL,YAAY;YACZ,UAAU,EAAE,WAAW;YACvB,SAAS;YACT,UAAU,EAAE,QAAQ;SACrB,CAAC,CAAC;IACL,CAAC;IAED,UAAU,CAAC,IAAoB;QAC7B,OAAO,IAAI,CAAC,cAAc;YACxB,CAAC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AAQ;aACT,CAAC,CAAC;QACL,CAAC;KAAA;IAQY,aAAa;;YACxB,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAAuB;gBAC7D,MAAM,EAAE,KAAK;gBACb,KAAK,EAAE,WAAW;aACnB,CAAC,CAAC;YACH,OAAO,QAAQ,CAAS,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;QACpE,CAAC;KAAA;IAQY,cAAc,CAAC,EAAE,QAAQ,EAAyB;;YAC7D,OAAO,IAAI,CAAC,OAAO,CAAyB;gBAC1C,IAAI,EAAE,EAAE,QAAQ,EAAE;gBAClB,MAAM,EAAE,KAAK;gBACb,KAAK,EAAE,WAAW;aACnB,CAAC,CAAC;QACL,CAAC;KAAA;IAQY,eAAe,CAAC,EAAE,QAAQ,EAAyB;;YAC9D,OAAO,IAAI,CAAC,OAAO,CAA0B;gBAC3C,MAAM,EAAE,KAAK;gBACb,KAAK,EAAE,aAAa,kBAAkB,CAAC,QAAQ,CAAC,EAAE;aACnD,CAAC,CAAC;QACL,CAAC;KAAA;IAQY,YAAY,CAAC,EAAE,QAAQ,EAAyB;;YAC3D,OAAO,IAAI,CAAC,OAAO,CAAuB;gBACxC,IAAI,EAAE,EAAE,QAAQ,EAAE;gBAClB,MAAM,EAAE,QAAQ;gBAChB,KAAK,EAAE,WAAW;aACnB,CAAC,CAAC;QACL,CAAC;KAAA;CACF"}
|
package/dist/types/Graph.d.ts
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import { Base, List } from '@or-sdk/base';
|
|
2
|
-
import {
|
|
1
|
+
import { Base, MakeApiUrlData, List } from '@or-sdk/base';
|
|
2
|
+
import { CreateDatabaseResponse, CreateNodeArgs, DeleteNodeArgs, DropDatabaseResponse, ExecuteQueryArgs, ExecuteQueryResponse, GetDatabaseInfoResponse, GraphConfig, MatchNodeArgs, SetNodeArgs } from './types';
|
|
3
3
|
export declare class Graph extends Base {
|
|
4
4
|
constructor(params: GraphConfig);
|
|
5
|
+
makeApiUrl(data: MakeApiUrlData): string;
|
|
5
6
|
executeQuery({ query, params, database }: ExecuteQueryArgs): Promise<ExecuteQueryResponse>;
|
|
6
7
|
createNode({ label, data, database }: CreateNodeArgs): Promise<ExecuteQueryResponse>;
|
|
7
8
|
matchNode({ label, where, database }: MatchNodeArgs): Promise<ExecuteQueryResponse>;
|
|
8
9
|
deleteNode({ label, where, database }: DeleteNodeArgs): Promise<ExecuteQueryResponse>;
|
|
9
10
|
setNode({ label, data, where, database }: SetNodeArgs): Promise<ExecuteQueryResponse>;
|
|
10
|
-
listDatabases(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
listDatabases(): Promise<List<string>>;
|
|
12
|
+
createDatabase({ database }: {
|
|
13
|
+
database: string;
|
|
14
|
+
}): Promise<CreateDatabaseResponse>;
|
|
15
|
+
getDatabaseInfo({ database }: {
|
|
16
|
+
database: string;
|
|
17
|
+
}): Promise<GetDatabaseInfoResponse>;
|
|
18
|
+
dropDatabase({ database }: {
|
|
19
|
+
database: string;
|
|
20
|
+
}): Promise<DropDatabaseResponse>;
|
|
15
21
|
}
|
|
16
22
|
//# sourceMappingURL=Graph.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Graph.d.ts","sourceRoot":"","sources":["../../src/Graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAY,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"Graph.d.ts","sourceRoot":"","sources":["../../src/Graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAY,MAAM,cAAc,CAAC;AACpE,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,cAAc,EAAE,oBAAoB,EACpC,gBAAgB,EAAE,oBAAoB,EAAE,uBAAuB,EAC/D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
|
|
47
47
|
name: string;
|
|
48
|
-
description?: string;
|
|
49
|
-
imageUrl?: string;
|
|
50
48
|
};
|
|
51
|
-
export declare type ListDatabaseResponse =
|
|
52
|
-
|
|
49
|
+
export declare type ListDatabaseResponse = {
|
|
50
|
+
databases: Database[];
|
|
51
|
+
};
|
|
52
|
+
export declare type CreateDatabaseResponse = {
|
|
53
|
+
ok?: number;
|
|
54
|
+
};
|
|
55
|
+
export declare type DropDatabaseResponse = {
|
|
53
56
|
ok?: number;
|
|
54
57
|
};
|
|
55
|
-
export declare type GetDatabaseInfoResponse =
|
|
58
|
+
export declare type GetDatabaseInfoResponse = {
|
|
56
59
|
labels: string[];
|
|
57
60
|
relationships: string[];
|
|
58
61
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,oBAAY,WAAW,GAAG;IAIxB,KAAK,EAAE,KAAK,CAAC;IAKb,YAAY,CAAC,EAAE,MAAM,CAAC;IAKtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAKnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,oBAAY,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE;QACP,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,oBAAY,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,oBAAY,aAAa,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE;QACL,CAAC,GAAG,EAAE,M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AExC,oBAAY,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE;QACR,MAAM,EAAE,CAAC,CAAC;QACV,IAAI,EAAE,CAAC,CAAC;QACR,MAAM,EAAE,CAAC,CAAC;KACX,CAAC;CACH,CAAC;AAEF,oBAAY,oBAAoB,GAAG;IACjC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE;QACP,KAAK,EAAE,KAAK,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,QAAQ,CAAC;QACnB,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,IAAI,EAAE,OAAO,CAAC;QACd,OAAO,EAAE,OAAO,CAAC;QACjB,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;QAC/B,mBAAmB,EAAE,MAAM,CAAC;QAC5B,oBAAoB,EAAE,MAAM,CAAC;KAC9B,CAAC;CACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@or-sdk/graph",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.1",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"build": "pnpm clean && pnpm build:esm && pnpm build:cjs",
|
|
9
|
-
"build:cjs": "tsc --project tsconfig.json",
|
|
10
|
-
"build:esm": "tsc --project tsconfig.esm.json",
|
|
11
|
-
"build:types": "tsc --project tsconfig.types.json",
|
|
12
|
-
"build:watch": "concurrently -r --hide 1,2 \"pnpm build:watch:cjs\" \"pnpm build:watch:esm\" \"pnpm build:watch:types\"",
|
|
13
|
-
"build:watch:cjs": "tsc --project tsconfig.json -w",
|
|
14
|
-
"build:watch:esm": "tsc --project tsconfig.esm.json -w",
|
|
15
|
-
"build:watch:types": "tsc --project tsconfig.types.json -w",
|
|
16
|
-
"clean": "rm -rf ./dist",
|
|
17
|
-
"dev": "pnpm build:watch:esm"
|
|
18
|
-
},
|
|
19
7
|
"dependencies": {
|
|
20
8
|
"@or-sdk/base": "^0.28.0",
|
|
21
9
|
"lodash": "^4.17.21"
|
|
@@ -28,5 +16,16 @@
|
|
|
28
16
|
"publishConfig": {
|
|
29
17
|
"access": "public"
|
|
30
18
|
},
|
|
31
|
-
"
|
|
32
|
-
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "pnpm clean && pnpm build:esm && pnpm build:cjs",
|
|
21
|
+
"build:cjs": "tsc --project tsconfig.json",
|
|
22
|
+
"build:esm": "tsc --project tsconfig.esm.json",
|
|
23
|
+
"build:types": "tsc --project tsconfig.types.json",
|
|
24
|
+
"build:watch": "concurrently -r --hide 1,2 \"pnpm build:watch:cjs\" \"pnpm build:watch:esm\" \"pnpm build:watch:types\"",
|
|
25
|
+
"build:watch:cjs": "tsc --project tsconfig.json -w",
|
|
26
|
+
"build:watch:esm": "tsc --project tsconfig.esm.json -w",
|
|
27
|
+
"build:watch:types": "tsc --project tsconfig.types.json -w",
|
|
28
|
+
"clean": "rm -rf ./dist",
|
|
29
|
+
"dev": "pnpm build:watch:esm"
|
|
30
|
+
}
|
|
31
|
+
}
|
package/src/Graph.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { Base, List, makeList } from '@or-sdk/base';
|
|
1
|
+
import { Base, MakeApiUrlData, List, makeList } from '@or-sdk/base';
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
CreateDatabaseResponse,
|
|
4
4
|
CreateNodeArgs,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
ExecuteQueryResponse,
|
|
9
|
-
GetDatabaseInfoResponse,
|
|
10
|
-
GraphConfig,
|
|
11
|
-
ListDatabaseResponse,
|
|
5
|
+
DeleteNodeArgs, DropDatabaseResponse,
|
|
6
|
+
ExecuteQueryArgs, ExecuteQueryResponse, GetDatabaseInfoResponse,
|
|
7
|
+
GraphConfig, ListDatabaseResponse,
|
|
12
8
|
MatchNodeArgs,
|
|
13
9
|
SetNodeArgs,
|
|
14
10
|
} from './types';
|
|
@@ -29,11 +25,11 @@ export class Graph extends Base {
|
|
|
29
25
|
});
|
|
30
26
|
}
|
|
31
27
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
makeApiUrl(data: MakeApiUrlData): string {
|
|
29
|
+
return this.isCrossAccount
|
|
30
|
+
? `${data.url}/${this.targetAccountId}`
|
|
31
|
+
: `${data.url}/current`;
|
|
32
|
+
}
|
|
37
33
|
|
|
38
34
|
/**
|
|
39
35
|
* Execute query
|
|
@@ -45,13 +41,14 @@ export class Graph extends Base {
|
|
|
45
41
|
* ```
|
|
46
42
|
*/
|
|
47
43
|
public async executeQuery({ query, params, database }: ExecuteQueryArgs): Promise<ExecuteQueryResponse> {
|
|
48
|
-
return this.
|
|
44
|
+
return this.callApi<ExecuteQueryResponse>({
|
|
49
45
|
data: {
|
|
50
46
|
query,
|
|
51
47
|
params,
|
|
48
|
+
database,
|
|
52
49
|
},
|
|
53
50
|
method: 'POST',
|
|
54
|
-
route:
|
|
51
|
+
route: 'query',
|
|
55
52
|
});
|
|
56
53
|
}
|
|
57
54
|
|
|
@@ -128,82 +125,56 @@ export class Graph extends Base {
|
|
|
128
125
|
|
|
129
126
|
/**
|
|
130
127
|
* List databases
|
|
131
|
-
* @param {string} [name] Database name to search for.
|
|
132
128
|
* ```typescript
|
|
133
129
|
* const databaseList = await graph.listDatabases();
|
|
134
130
|
* ```
|
|
135
131
|
*/
|
|
136
|
-
public async listDatabases(
|
|
137
|
-
const databases = await this.
|
|
132
|
+
public async listDatabases(): Promise<List<string>> {
|
|
133
|
+
const { databases } = await this.callApi<ListDatabaseResponse>({
|
|
138
134
|
method: 'GET',
|
|
139
135
|
route: 'databases',
|
|
140
|
-
params: name ? { name } : {},
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
return makeList<Database>(databases);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Get database info
|
|
148
|
-
* @param {string} [name] Database name
|
|
149
|
-
* ```typescript
|
|
150
|
-
* const result = await graph.getDatabaseInfo('db-name');
|
|
151
|
-
* ```
|
|
152
|
-
*/
|
|
153
|
-
public async getDatabaseInfo(name: string): Promise<GetDatabaseInfoResponse> {
|
|
154
|
-
return this.callApiV2<GetDatabaseInfoResponse>({
|
|
155
|
-
method: 'GET',
|
|
156
|
-
route: `databases/${name}`,
|
|
157
136
|
});
|
|
137
|
+
return makeList<string>(databases.map(database => database.name));
|
|
158
138
|
}
|
|
159
139
|
|
|
160
140
|
/**
|
|
161
141
|
* Create database
|
|
162
142
|
* ```typescript
|
|
163
|
-
* const result = await graph.createDatabase({
|
|
164
|
-
* name: 'db-name',
|
|
165
|
-
* description: 'First steps in graphs',
|
|
166
|
-
* });
|
|
143
|
+
* const result = await graph.createDatabase({ database: 'db-name' });
|
|
167
144
|
* ```
|
|
168
145
|
*/
|
|
169
|
-
public async createDatabase(database:
|
|
170
|
-
return this.
|
|
171
|
-
data: database,
|
|
172
|
-
method: '
|
|
146
|
+
public async createDatabase({ database }: { database: string; }): Promise<CreateDatabaseResponse> {
|
|
147
|
+
return this.callApi<CreateDatabaseResponse>({
|
|
148
|
+
data: { database },
|
|
149
|
+
method: 'PUT',
|
|
173
150
|
route: 'databases',
|
|
174
151
|
});
|
|
175
152
|
}
|
|
176
153
|
|
|
177
154
|
/**
|
|
178
|
-
*
|
|
155
|
+
* Get database info
|
|
179
156
|
* ```typescript
|
|
180
|
-
* const result = await graph.
|
|
181
|
-
* name: 'db-name',
|
|
182
|
-
* description: 'First steps in graphs'
|
|
183
|
-
* });
|
|
157
|
+
* const result = await graph.getDatabaseInfo({ database: 'db-name' });
|
|
184
158
|
* ```
|
|
185
159
|
*/
|
|
186
|
-
public async
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
route: `databases/${name}`,
|
|
191
|
-
method: 'PUT',
|
|
192
|
-
data,
|
|
160
|
+
public async getDatabaseInfo({ database }: { database: string; }): Promise<GetDatabaseInfoResponse> {
|
|
161
|
+
return this.callApi<GetDatabaseInfoResponse>({
|
|
162
|
+
method: 'GET',
|
|
163
|
+
route: `databases/${encodeURIComponent(database)}`,
|
|
193
164
|
});
|
|
194
165
|
}
|
|
195
166
|
|
|
196
167
|
/**
|
|
197
168
|
* Drop database
|
|
198
|
-
* @param {string} name Database name to drop
|
|
199
169
|
* ```typescript
|
|
200
|
-
* const result = await graph.dropDatabase('db-name');
|
|
170
|
+
* const result = await graph.dropDatabase({ database: 'db-name' });
|
|
201
171
|
* ```
|
|
202
172
|
*/
|
|
203
|
-
public async dropDatabase(
|
|
204
|
-
return this.
|
|
173
|
+
public async dropDatabase({ database }: { database: string; }): Promise<DropDatabaseResponse> {
|
|
174
|
+
return this.callApi<DropDatabaseResponse>({
|
|
175
|
+
data: { database },
|
|
205
176
|
method: 'DELETE',
|
|
206
|
-
route:
|
|
177
|
+
route: 'databases',
|
|
207
178
|
});
|
|
208
179
|
}
|
|
209
180
|
}
|
package/src/types.ts
CHANGED
|
@@ -67,17 +67,21 @@ export type SetNodeArgs = {
|
|
|
67
67
|
|
|
68
68
|
export type Database = {
|
|
69
69
|
name: string;
|
|
70
|
-
description?: string;
|
|
71
|
-
imageUrl?: string;
|
|
72
70
|
};
|
|
73
71
|
|
|
74
|
-
export type ListDatabaseResponse =
|
|
72
|
+
export type ListDatabaseResponse = {
|
|
73
|
+
databases: Database[];
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export type CreateDatabaseResponse = {
|
|
77
|
+
ok?: number;
|
|
78
|
+
};
|
|
75
79
|
|
|
76
|
-
export type
|
|
80
|
+
export type DropDatabaseResponse = {
|
|
77
81
|
ok?: number;
|
|
78
82
|
};
|
|
79
83
|
|
|
80
|
-
export type GetDatabaseInfoResponse =
|
|
84
|
+
export type GetDatabaseInfoResponse = {
|
|
81
85
|
labels: string[];
|
|
82
86
|
relationships: string[];
|
|
83
87
|
};
|