@coasys/ad4m 0.12.0-rc1-dev → 0.12.0-rc1-dev.2
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/jest.config.js +4 -4
- package/lib/index.cjs +5999 -6044
- package/lib/index.js +5977 -6038
- package/lib/src/Ad4mClient.d.ts +16 -9
- package/lib/src/Ad4mClient.js +25 -46
- package/lib/src/Ad4mClient.test.d.ts +1 -0
- package/lib/src/Ad4mClient.test.js +1204 -0
- package/lib/src/Literal.d.ts +2 -1
- package/lib/src/Literal.js +35 -38
- package/lib/src/Literal.test.d.ts +1 -0
- package/lib/src/Literal.test.js +41 -0
- package/lib/src/SmartLiteral.d.ts +2 -1
- package/lib/src/SmartLiteral.js +15 -30
- package/lib/src/agent/AgentClient.d.ts +4 -1
- package/lib/src/agent/AgentClient.js +99 -79
- package/lib/src/ai/AIClient.d.ts +2 -1
- package/lib/src/ai/AIClient.js +220 -224
- package/lib/src/expression/ExpressionClient.d.ts +1 -1
- package/lib/src/expression/ExpressionClient.js +86 -73
- package/lib/src/index.d.ts +1 -1
- package/lib/src/index.js +1 -1
- package/lib/src/language/LanguageClient.d.ts +1 -1
- package/lib/src/language/LanguageClient.js +52 -52
- package/lib/src/model/Ad4mModel.d.ts +157 -937
- package/lib/src/model/Ad4mModel.js +212 -2797
- package/lib/src/model/Ad4mModel.test.js +1002 -561
- package/lib/src/model/decorators.d.ts +94 -426
- package/lib/src/model/decorators.js +333 -741
- package/lib/src/model/mutation.d.ts +81 -0
- package/lib/src/model/mutation.js +317 -0
- package/lib/src/model/parentUtils.d.ts +32 -0
- package/lib/src/model/parentUtils.js +64 -0
- package/lib/src/model/prolog/generatePrologFacts.d.ts +36 -0
- package/lib/src/model/prolog/generatePrologFacts.js +139 -0
- package/lib/src/model/prolog/index.d.ts +1 -0
- package/lib/src/model/prolog/index.js +1 -0
- package/lib/src/model/query/ModelQueryBuilder.d.ts +82 -0
- package/lib/src/model/query/ModelQueryBuilder.js +115 -0
- package/lib/src/model/query/QueryBuilder.d.ts +101 -0
- package/lib/src/model/query/QueryBuilder.js +193 -0
- package/lib/src/model/query/SurrealQueryBuilder.d.ts +48 -0
- package/lib/src/model/query/SurrealQueryBuilder.js +371 -0
- package/lib/src/model/query/fetchInstance.d.ts +24 -0
- package/lib/src/model/query/fetchInstance.js +144 -0
- package/lib/src/model/query/hydration.d.ts +54 -0
- package/lib/src/model/query/hydration.js +214 -0
- package/lib/src/model/query/operations.d.ts +59 -0
- package/lib/src/model/query/operations.js +384 -0
- package/lib/src/model/query/snapshot.d.ts +59 -0
- package/lib/src/model/query/snapshot.js +106 -0
- package/lib/src/model/query/surrealCompiler.d.ts +42 -0
- package/lib/src/model/query/surrealCompiler.js +304 -0
- package/lib/src/model/schema/fromJSONSchema.d.ts +67 -0
- package/lib/src/model/schema/fromJSONSchema.js +264 -0
- package/lib/src/model/schema/metadata.d.ts +15 -0
- package/lib/src/model/schema/metadata.js +112 -0
- package/lib/src/model/subscription.d.ts +47 -0
- package/lib/src/model/subscription.js +231 -0
- package/lib/src/model/transaction.d.ts +27 -0
- package/lib/src/model/transaction.js +32 -0
- package/lib/src/model/types.d.ts +195 -0
- package/lib/src/model/types.js +8 -0
- package/lib/src/model/util.js +7 -7
- package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +5 -1
- package/lib/src/neighbourhood/NeighbourhoodClient.js +263 -181
- package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +2 -1
- package/lib/src/neighbourhood/NeighbourhoodProxy.js +13 -28
- package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +1 -5
- package/lib/src/perspectives/PerspectiveClient.d.ts +9 -9
- package/lib/src/perspectives/PerspectiveClient.js +316 -240
- package/lib/src/perspectives/PerspectiveProxy.d.ts +54 -92
- package/lib/src/perspectives/PerspectiveProxy.js +803 -444
- package/lib/src/runtime/RuntimeClient.d.ts +5 -1
- package/lib/src/runtime/RuntimeClient.js +412 -238
- package/lib/src/shacl/SHACLFlow.test.js +164 -105
- package/lib/src/shacl/SHACLShape.d.ts +17 -3
- package/lib/src/shacl/SHACLShape.js +127 -90
- package/lib/src/shacl/SHACLShape.test.js +244 -176
- package/lib/src/utils.d.ts +8 -0
- package/lib/src/utils.js +21 -7
- package/package.json +8 -13
- package/src/Ad4mClient.test.ts +1564 -1315
- package/src/Ad4mClient.ts +55 -54
- package/src/Literal.test.ts +45 -26
- package/src/Literal.ts +82 -66
- package/src/SmartLiteral.ts +74 -58
- package/src/agent/AgentClient.ts +144 -99
- package/src/ai/AIClient.ts +409 -359
- package/src/expression/ExpressionClient.ts +142 -96
- package/src/index.ts +1 -1
- package/src/language/LanguageClient.ts +137 -113
- package/src/model/Ad4mModel.test.ts +1128 -647
- package/src/model/Ad4mModel.ts +485 -3247
- package/src/model/IMPROVEMENTS.md +482 -0
- package/src/model/PREDICATE_COLLISION_FIX.md +651 -0
- package/src/model/README.md +317 -0
- package/src/model/SHACL_MUTATION_DECOUPLING.md +356 -0
- package/src/model/SUBSCRIPTION_STRATEGY.md +317 -0
- package/src/model/TC39_STAGE_3_DECORATORS.md +609 -0
- package/src/model/decorators.ts +689 -1046
- package/src/model/mutation.ts +461 -0
- package/src/model/parentUtils.ts +91 -0
- package/src/model/prolog/generatePrologFacts.ts +176 -0
- package/src/model/prolog/index.ts +1 -0
- package/src/model/query/ModelQueryBuilder.ts +173 -0
- package/src/model/query/fetchInstance.ts +181 -0
- package/src/model/query/hydration.ts +273 -0
- package/src/model/query/operations.ts +510 -0
- package/src/model/query/snapshot.ts +126 -0
- package/src/model/query/surrealCompiler.ts +376 -0
- package/src/model/schema/fromJSONSchema.ts +411 -0
- package/src/model/schema/metadata.ts +148 -0
- package/src/model/subscription.ts +307 -0
- package/src/model/transaction.ts +60 -0
- package/src/model/types.ts +207 -0
- package/src/model/util.ts +47 -48
- package/src/neighbourhood/NeighbourhoodClient.ts +393 -251
- package/src/neighbourhood/NeighbourhoodProxy.test.ts +3 -7
- package/src/neighbourhood/NeighbourhoodProxy.ts +58 -40
- package/src/perspectives/PerspectiveClient.ts +779 -540
- package/src/perspectives/PerspectiveProxy.ts +2860 -2053
- package/src/runtime/RuntimeClient.ts +775 -476
- package/src/shacl/SHACLFlow.test.ts +196 -129
- package/src/shacl/SHACLShape.test.ts +284 -190
- package/src/shacl/SHACLShape.ts +225 -172
- package/src/utils.ts +31 -17
- package/tsconfig.json +9 -10
- package/src/model/Subject.ts +0 -159
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
|
-
var _PerspectiveClient_apolloClient, _PerspectiveClient_perspectiveAddedCallbacks, _PerspectiveClient_perspectiveUpdatedCallbacks, _PerspectiveClient_perspectiveRemovedCallbacks, _PerspectiveClient_perspectiveSyncStateChangeCallbacks, _PerspectiveClient_expressionClient, _PerspectiveClient_neighbourhoodClient, _PerspectiveClient_aiClient;
|
|
13
1
|
import { gql } from "@apollo/client/core";
|
|
14
2
|
import { NeighbourhoodProxy } from "../neighbourhood/NeighbourhoodProxy";
|
|
15
3
|
import unwrapApolloResult from "../unwrapApolloResult";
|
|
16
|
-
import { PerspectiveProxy } from
|
|
4
|
+
import { PerspectiveProxy } from "./PerspectiveProxy";
|
|
5
|
+
import { isSocketCloseError } from "../utils";
|
|
17
6
|
const LINK_EXPRESSION_FIELDS = `
|
|
18
7
|
author
|
|
19
8
|
timestamp
|
|
@@ -45,19 +34,11 @@ neighbourhood {
|
|
|
45
34
|
`;
|
|
46
35
|
export class PerspectiveClient {
|
|
47
36
|
constructor(client, subscribe = true) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
_PerspectiveClient_expressionClient.set(this, void 0);
|
|
54
|
-
_PerspectiveClient_neighbourhoodClient.set(this, void 0);
|
|
55
|
-
_PerspectiveClient_aiClient.set(this, void 0);
|
|
56
|
-
__classPrivateFieldSet(this, _PerspectiveClient_apolloClient, client, "f");
|
|
57
|
-
__classPrivateFieldSet(this, _PerspectiveClient_perspectiveAddedCallbacks, [], "f");
|
|
58
|
-
__classPrivateFieldSet(this, _PerspectiveClient_perspectiveUpdatedCallbacks, [], "f");
|
|
59
|
-
__classPrivateFieldSet(this, _PerspectiveClient_perspectiveRemovedCallbacks, [], "f");
|
|
60
|
-
__classPrivateFieldSet(this, _PerspectiveClient_perspectiveSyncStateChangeCallbacks, [], "f");
|
|
37
|
+
this._apolloClient = client;
|
|
38
|
+
this._perspectiveAddedCallbacks = [];
|
|
39
|
+
this._perspectiveUpdatedCallbacks = [];
|
|
40
|
+
this._perspectiveRemovedCallbacks = [];
|
|
41
|
+
this._perspectiveSyncStateChangeCallbacks = [];
|
|
61
42
|
if (subscribe) {
|
|
62
43
|
this.subscribePerspectiveAdded();
|
|
63
44
|
this.subscribePerspectiveUpdated();
|
|
@@ -65,77 +46,81 @@ export class PerspectiveClient {
|
|
|
65
46
|
}
|
|
66
47
|
}
|
|
67
48
|
setExpressionClient(client) {
|
|
68
|
-
|
|
49
|
+
this._expressionClient = client;
|
|
69
50
|
}
|
|
70
51
|
setNeighbourhoodClient(client) {
|
|
71
|
-
|
|
52
|
+
this._neighbourhoodClient = client;
|
|
72
53
|
}
|
|
73
54
|
setAIClient(client) {
|
|
74
|
-
|
|
55
|
+
this._aiClient = client;
|
|
75
56
|
}
|
|
76
57
|
get aiClient() {
|
|
77
|
-
return
|
|
58
|
+
return this._aiClient;
|
|
78
59
|
}
|
|
79
60
|
async all() {
|
|
80
|
-
const { perspectives } = unwrapApolloResult(await
|
|
61
|
+
const { perspectives } = unwrapApolloResult(await this._apolloClient.query({
|
|
81
62
|
query: gql `query perspectives {
|
|
82
63
|
perspectives {
|
|
83
64
|
${PERSPECTIVE_HANDLE_FIELDS}
|
|
84
65
|
}
|
|
85
|
-
}
|
|
66
|
+
}`,
|
|
86
67
|
}));
|
|
87
|
-
return perspectives.map(handle => new PerspectiveProxy(handle, this));
|
|
68
|
+
return perspectives.map((handle) => new PerspectiveProxy(handle, this));
|
|
88
69
|
}
|
|
89
70
|
async byUUID(uuid) {
|
|
90
|
-
const { perspective } = unwrapApolloResult(await
|
|
71
|
+
const { perspective } = unwrapApolloResult(await this._apolloClient.query({
|
|
91
72
|
query: gql `query perspective($uuid: String!) {
|
|
92
73
|
perspective(uuid: $uuid) {
|
|
93
74
|
${PERSPECTIVE_HANDLE_FIELDS}
|
|
94
75
|
}
|
|
95
76
|
}`,
|
|
96
|
-
variables: { uuid }
|
|
77
|
+
variables: { uuid },
|
|
97
78
|
}));
|
|
98
79
|
if (!perspective)
|
|
99
80
|
return null;
|
|
100
81
|
return new PerspectiveProxy(perspective, this);
|
|
101
82
|
}
|
|
102
83
|
async snapshotByUUID(uuid) {
|
|
103
|
-
const { perspectiveSnapshot } = unwrapApolloResult(await
|
|
84
|
+
const { perspectiveSnapshot } = unwrapApolloResult(await this._apolloClient.query({
|
|
104
85
|
query: gql `query perspectiveSnapshot($uuid: String!) {
|
|
105
86
|
perspectiveSnapshot(uuid: $uuid) {
|
|
106
87
|
links { ${LINK_EXPRESSION_FIELDS} }
|
|
107
88
|
}
|
|
108
89
|
}`,
|
|
109
|
-
variables: { uuid }
|
|
90
|
+
variables: { uuid },
|
|
110
91
|
}));
|
|
111
92
|
return perspectiveSnapshot;
|
|
112
93
|
}
|
|
113
94
|
async publishSnapshotByUUID(uuid) {
|
|
114
|
-
const { perspectivePublishSnapshot } = unwrapApolloResult(await
|
|
115
|
-
mutation: gql `
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
95
|
+
const { perspectivePublishSnapshot } = unwrapApolloResult(await this._apolloClient.mutate({
|
|
96
|
+
mutation: gql `
|
|
97
|
+
mutation perspectivePublishSnapshot($uuid: String!) {
|
|
98
|
+
perspectivePublishSnapshot(uuid: $uuid)
|
|
99
|
+
}
|
|
100
|
+
`,
|
|
101
|
+
variables: { uuid },
|
|
119
102
|
}));
|
|
120
103
|
return perspectivePublishSnapshot;
|
|
121
104
|
}
|
|
122
105
|
async queryLinks(uuid, query) {
|
|
123
|
-
const { perspectiveQueryLinks } = unwrapApolloResult(await
|
|
106
|
+
const { perspectiveQueryLinks } = unwrapApolloResult(await this._apolloClient.query({
|
|
124
107
|
query: gql `query perspectiveQueryLinks($uuid: String!, $query: LinkQuery!) {
|
|
125
108
|
perspectiveQueryLinks(query: $query, uuid: $uuid) {
|
|
126
109
|
${LINK_EXPRESSION_FIELDS}
|
|
127
110
|
}
|
|
128
111
|
}`,
|
|
129
|
-
variables: { uuid, query }
|
|
112
|
+
variables: { uuid, query },
|
|
130
113
|
}));
|
|
131
114
|
return perspectiveQueryLinks;
|
|
132
115
|
}
|
|
133
116
|
async queryProlog(uuid, query) {
|
|
134
|
-
const { perspectiveQueryProlog } = unwrapApolloResult(await
|
|
135
|
-
query: gql `
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
117
|
+
const { perspectiveQueryProlog } = unwrapApolloResult(await this._apolloClient.query({
|
|
118
|
+
query: gql `
|
|
119
|
+
query perspectiveQueryProlog($uuid: String!, $query: String!) {
|
|
120
|
+
perspectiveQueryProlog(uuid: $uuid, query: $query)
|
|
121
|
+
}
|
|
122
|
+
`,
|
|
123
|
+
variables: { uuid, query },
|
|
139
124
|
}));
|
|
140
125
|
return JSON.parse(perspectiveQueryProlog);
|
|
141
126
|
}
|
|
@@ -149,23 +134,27 @@ export class PerspectiveClient {
|
|
|
149
134
|
* as generated from Rust method "perspective_query_surreal_db"
|
|
150
135
|
*/
|
|
151
136
|
async querySurrealDB(uuid, query) {
|
|
152
|
-
const { perspectiveQuerySurrealDb } = unwrapApolloResult(await
|
|
153
|
-
query: gql `
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
137
|
+
const { perspectiveQuerySurrealDb } = unwrapApolloResult(await this._apolloClient.query({
|
|
138
|
+
query: gql `
|
|
139
|
+
query perspectiveQuerySurrealDb($uuid: String!, $query: String!) {
|
|
140
|
+
perspectiveQuerySurrealDb(uuid: $uuid, query: $query)
|
|
141
|
+
}
|
|
142
|
+
`,
|
|
143
|
+
variables: { uuid, query },
|
|
157
144
|
}));
|
|
158
145
|
return JSON.parse(perspectiveQuerySurrealDb);
|
|
159
146
|
}
|
|
160
147
|
async subscribeQuery(uuid, query) {
|
|
161
|
-
const { perspectiveSubscribeQuery } = unwrapApolloResult(await
|
|
162
|
-
mutation: gql `
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
|
|
148
|
+
const { perspectiveSubscribeQuery } = unwrapApolloResult(await this._apolloClient.mutate({
|
|
149
|
+
mutation: gql `
|
|
150
|
+
mutation perspectiveSubscribeQuery($uuid: String!, $query: String!) {
|
|
151
|
+
perspectiveSubscribeQuery(uuid: $uuid, query: $query) {
|
|
152
|
+
subscriptionId
|
|
153
|
+
result
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
`,
|
|
157
|
+
variables: { uuid, query },
|
|
169
158
|
}));
|
|
170
159
|
const { subscriptionId, result } = perspectiveSubscribeQuery;
|
|
171
160
|
let finalResult = result;
|
|
@@ -178,64 +167,23 @@ export class PerspectiveClient {
|
|
|
178
167
|
finalResult = JSON.parse(finalResult);
|
|
179
168
|
}
|
|
180
169
|
catch (e) {
|
|
181
|
-
console.error(
|
|
170
|
+
console.error("Error parsing perspectiveSubscribeQuery result:", e);
|
|
182
171
|
}
|
|
183
172
|
return { subscriptionId, result: finalResult, isInit };
|
|
184
173
|
}
|
|
185
|
-
async perspectiveSubscribeSurrealQuery(uuid, query) {
|
|
186
|
-
const { perspectiveSubscribeSurrealQuery } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
187
|
-
mutation: gql `mutation perspectiveSubscribeSurrealQuery($uuid: String!, $query: String!) {
|
|
188
|
-
perspectiveSubscribeSurrealQuery(uuid: $uuid, query: $query) {
|
|
189
|
-
subscriptionId
|
|
190
|
-
result
|
|
191
|
-
}
|
|
192
|
-
}`,
|
|
193
|
-
variables: { uuid, query }
|
|
194
|
-
}));
|
|
195
|
-
const { subscriptionId, result } = perspectiveSubscribeSurrealQuery;
|
|
196
|
-
let finalResult = result;
|
|
197
|
-
let isInit = false;
|
|
198
|
-
if (finalResult.startsWith("#init#")) {
|
|
199
|
-
finalResult = finalResult.substring(6);
|
|
200
|
-
isInit = true;
|
|
201
|
-
}
|
|
202
|
-
try {
|
|
203
|
-
finalResult = JSON.parse(finalResult);
|
|
204
|
-
}
|
|
205
|
-
catch (e) {
|
|
206
|
-
console.error('Error parsing perspectiveSubscribeSurrealQuery result:', e);
|
|
207
|
-
}
|
|
208
|
-
return { subscriptionId, result: finalResult, isInit };
|
|
209
|
-
}
|
|
210
|
-
async perspectiveKeepAliveSurrealQuery(uuid, subscriptionId) {
|
|
211
|
-
const { perspectiveKeepAliveSurrealQuery } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
212
|
-
mutation: gql `mutation perspectiveKeepAliveSurrealQuery($uuid: String!, $subscriptionId: String!) {
|
|
213
|
-
perspectiveKeepAliveSurrealQuery(uuid: $uuid, subscriptionId: $subscriptionId)
|
|
214
|
-
}`,
|
|
215
|
-
variables: { uuid, subscriptionId }
|
|
216
|
-
}));
|
|
217
|
-
return perspectiveKeepAliveSurrealQuery;
|
|
218
|
-
}
|
|
219
|
-
async perspectiveDisposeSurrealQuerySubscription(uuid, subscriptionId) {
|
|
220
|
-
const { perspectiveDisposeSurrealQuerySubscription } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
221
|
-
mutation: gql `mutation perspectiveDisposeSurrealQuerySubscription($uuid: String!, $subscriptionId: String!) {
|
|
222
|
-
perspectiveDisposeSurrealQuerySubscription(uuid: $uuid, subscriptionId: $subscriptionId)
|
|
223
|
-
}`,
|
|
224
|
-
variables: { uuid, subscriptionId }
|
|
225
|
-
}));
|
|
226
|
-
return perspectiveDisposeSurrealQuerySubscription;
|
|
227
|
-
}
|
|
228
174
|
subscribeToQueryUpdates(subscriptionId, onData) {
|
|
229
|
-
const subscription =
|
|
175
|
+
const subscription = this._apolloClient
|
|
176
|
+
.subscribe({
|
|
230
177
|
query: gql `
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
178
|
+
subscription perspectiveQuerySubscription($subscriptionId: String!) {
|
|
179
|
+
perspectiveQuerySubscription(subscriptionId: $subscriptionId)
|
|
180
|
+
}
|
|
181
|
+
`,
|
|
235
182
|
variables: {
|
|
236
|
-
subscriptionId
|
|
237
|
-
}
|
|
238
|
-
})
|
|
183
|
+
subscriptionId,
|
|
184
|
+
},
|
|
185
|
+
})
|
|
186
|
+
.subscribe({
|
|
239
187
|
next: (result) => {
|
|
240
188
|
if (result.data && result.data.perspectiveQuerySubscription) {
|
|
241
189
|
let finalResult = result.data.perspectiveQuerySubscription;
|
|
@@ -246,103 +194,124 @@ export class PerspectiveClient {
|
|
|
246
194
|
}
|
|
247
195
|
try {
|
|
248
196
|
finalResult = JSON.parse(finalResult);
|
|
249
|
-
if (isInit && typeof finalResult ===
|
|
197
|
+
if (isInit && typeof finalResult === "object") {
|
|
250
198
|
finalResult.isInit = true;
|
|
251
199
|
}
|
|
252
200
|
}
|
|
253
201
|
catch (e) {
|
|
254
|
-
console.error(
|
|
202
|
+
console.error("Error parsing perspectiveQuerySubscription:", e);
|
|
255
203
|
}
|
|
256
204
|
onData(finalResult);
|
|
257
205
|
}
|
|
258
206
|
},
|
|
259
|
-
error: (e) =>
|
|
207
|
+
error: (e) => {
|
|
208
|
+
if (!isSocketCloseError(e))
|
|
209
|
+
console.error("Error in query subscription:", e);
|
|
210
|
+
},
|
|
260
211
|
});
|
|
261
212
|
return () => subscription.unsubscribe();
|
|
262
213
|
}
|
|
263
214
|
async keepAliveQuery(uuid, subscriptionId) {
|
|
264
|
-
const { perspectiveKeepAliveQuery } = unwrapApolloResult(await
|
|
265
|
-
mutation: gql `
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
215
|
+
const { perspectiveKeepAliveQuery } = unwrapApolloResult(await this._apolloClient.mutate({
|
|
216
|
+
mutation: gql `
|
|
217
|
+
mutation perspectiveKeepAliveQuery(
|
|
218
|
+
$uuid: String!
|
|
219
|
+
$subscriptionId: String!
|
|
220
|
+
) {
|
|
221
|
+
perspectiveKeepAliveQuery(
|
|
222
|
+
uuid: $uuid
|
|
223
|
+
subscriptionId: $subscriptionId
|
|
224
|
+
)
|
|
225
|
+
}
|
|
226
|
+
`,
|
|
227
|
+
variables: { uuid, subscriptionId },
|
|
269
228
|
}));
|
|
270
229
|
return perspectiveKeepAliveQuery;
|
|
271
230
|
}
|
|
272
231
|
async disposeQuerySubscription(uuid, subscriptionId) {
|
|
273
|
-
const { perspectiveDisposeQuerySubscription } = unwrapApolloResult(await
|
|
274
|
-
mutation: gql `
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
232
|
+
const { perspectiveDisposeQuerySubscription } = unwrapApolloResult(await this._apolloClient.mutate({
|
|
233
|
+
mutation: gql `
|
|
234
|
+
mutation perspectiveDisposeQuerySubscription(
|
|
235
|
+
$uuid: String!
|
|
236
|
+
$subscriptionId: String!
|
|
237
|
+
) {
|
|
238
|
+
perspectiveDisposeQuerySubscription(
|
|
239
|
+
uuid: $uuid
|
|
240
|
+
subscriptionId: $subscriptionId
|
|
241
|
+
)
|
|
242
|
+
}
|
|
243
|
+
`,
|
|
244
|
+
variables: { uuid, subscriptionId },
|
|
278
245
|
}));
|
|
279
246
|
return perspectiveDisposeQuerySubscription;
|
|
280
247
|
}
|
|
281
248
|
async add(name) {
|
|
282
|
-
const { perspectiveAdd } = unwrapApolloResult(await
|
|
249
|
+
const { perspectiveAdd } = unwrapApolloResult(await this._apolloClient.mutate({
|
|
283
250
|
mutation: gql `mutation perspectiveAdd($name: String!) {
|
|
284
251
|
perspectiveAdd(name: $name) {
|
|
285
252
|
${PERSPECTIVE_HANDLE_FIELDS}
|
|
286
253
|
}
|
|
287
254
|
}`,
|
|
288
|
-
variables: { name }
|
|
255
|
+
variables: { name },
|
|
289
256
|
}));
|
|
290
257
|
return new PerspectiveProxy(perspectiveAdd, this);
|
|
291
258
|
}
|
|
292
259
|
async update(uuid, name) {
|
|
293
|
-
const { perspectiveUpdate } = unwrapApolloResult(await
|
|
260
|
+
const { perspectiveUpdate } = unwrapApolloResult(await this._apolloClient.mutate({
|
|
294
261
|
mutation: gql `mutation perspectiveUpdate($uuid: String!, $name: String!) {
|
|
295
262
|
perspectiveUpdate(uuid: $uuid, name: $name) {
|
|
296
263
|
${PERSPECTIVE_HANDLE_FIELDS}
|
|
297
264
|
}
|
|
298
265
|
}`,
|
|
299
|
-
variables: { uuid, name }
|
|
266
|
+
variables: { uuid, name },
|
|
300
267
|
}));
|
|
301
268
|
return new PerspectiveProxy(perspectiveUpdate, this);
|
|
302
269
|
}
|
|
303
270
|
async remove(uuid) {
|
|
304
|
-
return unwrapApolloResult(await
|
|
305
|
-
mutation: gql `
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
271
|
+
return unwrapApolloResult(await this._apolloClient.mutate({
|
|
272
|
+
mutation: gql `
|
|
273
|
+
mutation perspectiveRemove($uuid: String!) {
|
|
274
|
+
perspectiveRemove(uuid: $uuid)
|
|
275
|
+
}
|
|
276
|
+
`,
|
|
277
|
+
variables: { uuid },
|
|
309
278
|
}));
|
|
310
279
|
}
|
|
311
|
-
async addLink(uuid, link, status =
|
|
312
|
-
const { perspectiveAddLink } = unwrapApolloResult(await
|
|
280
|
+
async addLink(uuid, link, status = "shared", batchId) {
|
|
281
|
+
const { perspectiveAddLink } = unwrapApolloResult(await this._apolloClient.mutate({
|
|
313
282
|
mutation: gql `mutation perspectiveAddLink($uuid: String!, $link: LinkInput!, $status: String!, $batchId: String) {
|
|
314
283
|
perspectiveAddLink(uuid: $uuid, link: $link, status: $status, batchId: $batchId) {
|
|
315
284
|
${LINK_EXPRESSION_FIELDS}
|
|
316
285
|
}
|
|
317
286
|
}`,
|
|
318
|
-
variables: { uuid, link, status, batchId }
|
|
287
|
+
variables: { uuid, link, status, batchId },
|
|
319
288
|
}));
|
|
320
289
|
return perspectiveAddLink;
|
|
321
290
|
}
|
|
322
|
-
async addLinks(uuid, links, status =
|
|
323
|
-
const { perspectiveAddLinks } = unwrapApolloResult(await
|
|
291
|
+
async addLinks(uuid, links, status = "shared", batchId) {
|
|
292
|
+
const { perspectiveAddLinks } = unwrapApolloResult(await this._apolloClient.mutate({
|
|
324
293
|
mutation: gql `mutation perspectiveAddLinks($uuid: String!, $links: [LinkInput!]!, $status: String!, $batchId: String) {
|
|
325
294
|
perspectiveAddLinks(uuid: $uuid, links: $links, status: $status, batchId: $batchId) {
|
|
326
295
|
${LINK_EXPRESSION_FIELDS}
|
|
327
296
|
}
|
|
328
297
|
}`,
|
|
329
|
-
variables: { uuid, links, status, batchId }
|
|
298
|
+
variables: { uuid, links, status, batchId },
|
|
330
299
|
}));
|
|
331
300
|
return perspectiveAddLinks;
|
|
332
301
|
}
|
|
333
302
|
async removeLinks(uuid, links, batchId) {
|
|
334
|
-
const { perspectiveRemoveLinks } = unwrapApolloResult(await
|
|
303
|
+
const { perspectiveRemoveLinks } = unwrapApolloResult(await this._apolloClient.mutate({
|
|
335
304
|
mutation: gql `mutation perspectiveRemoveLinks($uuid: String!, $links: [LinkExpressionInput!]!, $batchId: String) {
|
|
336
305
|
perspectiveRemoveLinks(uuid: $uuid, links: $links, batchId: $batchId) {
|
|
337
306
|
${LINK_EXPRESSION_FIELDS}
|
|
338
307
|
}
|
|
339
308
|
}`,
|
|
340
|
-
variables: { uuid, links, batchId }
|
|
309
|
+
variables: { uuid, links, batchId },
|
|
341
310
|
}));
|
|
342
311
|
return perspectiveRemoveLinks;
|
|
343
312
|
}
|
|
344
313
|
async linkMutations(uuid, mutations, status) {
|
|
345
|
-
const { perspectiveLinkMutations } = unwrapApolloResult(await
|
|
314
|
+
const { perspectiveLinkMutations } = unwrapApolloResult(await this._apolloClient.mutate({
|
|
346
315
|
mutation: gql `mutation perspectiveLinkMutations($uuid: String!, $mutations: LinkMutations!, $status: String){
|
|
347
316
|
perspectiveLinkMutations(mutations: $mutations, uuid: $uuid, status: $status) {
|
|
348
317
|
additions {
|
|
@@ -353,29 +322,29 @@ export class PerspectiveClient {
|
|
|
353
322
|
}
|
|
354
323
|
}
|
|
355
324
|
}`,
|
|
356
|
-
variables: { uuid, mutations, status }
|
|
325
|
+
variables: { uuid, mutations, status },
|
|
357
326
|
}));
|
|
358
327
|
return perspectiveLinkMutations;
|
|
359
328
|
}
|
|
360
|
-
async addLinkExpression(uuid, link, status =
|
|
361
|
-
const { perspectiveAddLinkExpression } = unwrapApolloResult(await
|
|
329
|
+
async addLinkExpression(uuid, link, status = "shared", batchId) {
|
|
330
|
+
const { perspectiveAddLinkExpression } = unwrapApolloResult(await this._apolloClient.mutate({
|
|
362
331
|
mutation: gql `mutation perspectiveAddLinkExpression($uuid: String!, $link: LinkExpressionInput!, $status: String!, $batchId: String) {
|
|
363
332
|
perspectiveAddLinkExpression(uuid: $uuid, link: $link, status: $status, batchId: $batchId) {
|
|
364
333
|
${LINK_EXPRESSION_FIELDS}
|
|
365
334
|
}
|
|
366
335
|
}`,
|
|
367
|
-
variables: { uuid, link, status, batchId }
|
|
336
|
+
variables: { uuid, link, status, batchId },
|
|
368
337
|
}));
|
|
369
338
|
return perspectiveAddLinkExpression;
|
|
370
339
|
}
|
|
371
340
|
async updateLink(uuid, oldLink, newLink, batchId) {
|
|
372
|
-
const { perspectiveUpdateLink } = unwrapApolloResult(await
|
|
341
|
+
const { perspectiveUpdateLink } = unwrapApolloResult(await this._apolloClient.mutate({
|
|
373
342
|
mutation: gql `mutation perspectiveUpdateLink($uuid: String!, $oldLink: LinkExpressionInput!, $newLink: LinkInput!, $batchId: String) {
|
|
374
343
|
perspectiveUpdateLink(uuid: $uuid, oldLink: $oldLink, newLink: $newLink, batchId: $batchId) {
|
|
375
344
|
${LINK_EXPRESSION_FIELDS}
|
|
376
345
|
}
|
|
377
346
|
}`,
|
|
378
|
-
variables: { uuid, oldLink, newLink, batchId }
|
|
347
|
+
variables: { uuid, oldLink, newLink, batchId },
|
|
379
348
|
}));
|
|
380
349
|
return perspectiveUpdateLink;
|
|
381
350
|
}
|
|
@@ -384,11 +353,17 @@ export class PerspectiveClient {
|
|
|
384
353
|
delete link.data.__typename;
|
|
385
354
|
delete link.proof.__typename;
|
|
386
355
|
delete link.status;
|
|
387
|
-
const { perspectiveRemoveLink } = unwrapApolloResult(await
|
|
388
|
-
mutation: gql `
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
356
|
+
const { perspectiveRemoveLink } = unwrapApolloResult(await this._apolloClient.mutate({
|
|
357
|
+
mutation: gql `
|
|
358
|
+
mutation perspectiveRemoveLink(
|
|
359
|
+
$link: LinkExpressionInput!
|
|
360
|
+
$uuid: String!
|
|
361
|
+
$batchId: String
|
|
362
|
+
) {
|
|
363
|
+
perspectiveRemoveLink(link: $link, uuid: $uuid, batchId: $batchId)
|
|
364
|
+
}
|
|
365
|
+
`,
|
|
366
|
+
variables: { uuid, link, batchId },
|
|
392
367
|
}));
|
|
393
368
|
return perspectiveRemoveLink;
|
|
394
369
|
}
|
|
@@ -403,155 +378,251 @@ export class PerspectiveClient {
|
|
|
403
378
|
* @param shaclJson - SHACL JSON string from SHACLShape.toJSON() (recommended)
|
|
404
379
|
*/
|
|
405
380
|
async addSdna(uuid, name, sdnaCode, sdnaType, shaclJson) {
|
|
406
|
-
return unwrapApolloResult(await
|
|
407
|
-
mutation: gql `
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
381
|
+
return unwrapApolloResult(await this._apolloClient.mutate({
|
|
382
|
+
mutation: gql `
|
|
383
|
+
mutation perspectiveAddSdna(
|
|
384
|
+
$uuid: String!
|
|
385
|
+
$name: String!
|
|
386
|
+
$sdnaCode: String
|
|
387
|
+
$sdnaType: String!
|
|
388
|
+
$shaclJson: String
|
|
389
|
+
) {
|
|
390
|
+
perspectiveAddSdna(
|
|
391
|
+
uuid: $uuid
|
|
392
|
+
name: $name
|
|
393
|
+
sdnaCode: $sdnaCode
|
|
394
|
+
sdnaType: $sdnaType
|
|
395
|
+
shaclJson: $shaclJson
|
|
396
|
+
)
|
|
397
|
+
}
|
|
398
|
+
`,
|
|
399
|
+
variables: {
|
|
400
|
+
uuid,
|
|
401
|
+
name,
|
|
402
|
+
sdnaCode: sdnaCode || "",
|
|
403
|
+
sdnaType,
|
|
404
|
+
shaclJson,
|
|
405
|
+
},
|
|
411
406
|
})).perspectiveAddSdna;
|
|
412
407
|
}
|
|
413
408
|
async executeCommands(uuid, commands, expression, parameters, batchId) {
|
|
414
|
-
return unwrapApolloResult(await
|
|
415
|
-
mutation: gql `
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
409
|
+
return unwrapApolloResult(await this._apolloClient.mutate({
|
|
410
|
+
mutation: gql `
|
|
411
|
+
mutation perspectiveExecuteCommands(
|
|
412
|
+
$uuid: String!
|
|
413
|
+
$commands: String!
|
|
414
|
+
$expression: String!
|
|
415
|
+
$parameters: String
|
|
416
|
+
$batchId: String
|
|
417
|
+
) {
|
|
418
|
+
perspectiveExecuteCommands(
|
|
419
|
+
uuid: $uuid
|
|
420
|
+
commands: $commands
|
|
421
|
+
expression: $expression
|
|
422
|
+
parameters: $parameters
|
|
423
|
+
batchId: $batchId
|
|
424
|
+
)
|
|
425
|
+
}
|
|
426
|
+
`,
|
|
427
|
+
variables: { uuid, commands, expression, parameters, batchId },
|
|
419
428
|
})).perspectiveExecuteCommands;
|
|
420
429
|
}
|
|
421
430
|
async createSubject(uuid, subjectClass, expressionAddress, initialValues, batchId) {
|
|
422
|
-
return unwrapApolloResult(await
|
|
423
|
-
mutation: gql `
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
431
|
+
return unwrapApolloResult(await this._apolloClient.mutate({
|
|
432
|
+
mutation: gql `
|
|
433
|
+
mutation perspectiveCreateSubject(
|
|
434
|
+
$uuid: String!
|
|
435
|
+
$subjectClass: String!
|
|
436
|
+
$expressionAddress: String!
|
|
437
|
+
$initialValues: String
|
|
438
|
+
$batchId: String
|
|
439
|
+
) {
|
|
440
|
+
perspectiveCreateSubject(
|
|
441
|
+
uuid: $uuid
|
|
442
|
+
subjectClass: $subjectClass
|
|
443
|
+
expressionAddress: $expressionAddress
|
|
444
|
+
initialValues: $initialValues
|
|
445
|
+
batchId: $batchId
|
|
446
|
+
)
|
|
447
|
+
}
|
|
448
|
+
`,
|
|
449
|
+
variables: {
|
|
450
|
+
uuid,
|
|
451
|
+
subjectClass,
|
|
452
|
+
expressionAddress,
|
|
453
|
+
initialValues,
|
|
454
|
+
batchId,
|
|
455
|
+
},
|
|
427
456
|
})).perspectiveCreateSubject;
|
|
428
457
|
}
|
|
429
458
|
async getSubjectData(uuid, subjectClass, expressionAddress) {
|
|
430
|
-
return unwrapApolloResult(await
|
|
431
|
-
mutation: gql `
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
459
|
+
return unwrapApolloResult(await this._apolloClient.mutate({
|
|
460
|
+
mutation: gql `
|
|
461
|
+
mutation perspectiveGetSubjectData(
|
|
462
|
+
$uuid: String!
|
|
463
|
+
$subjectClass: String!
|
|
464
|
+
$expressionAddress: String!
|
|
465
|
+
) {
|
|
466
|
+
perspectiveGetSubjectData(
|
|
467
|
+
uuid: $uuid
|
|
468
|
+
subjectClass: $subjectClass
|
|
469
|
+
expressionAddress: $expressionAddress
|
|
470
|
+
)
|
|
471
|
+
}
|
|
472
|
+
`,
|
|
473
|
+
variables: { uuid, subjectClass, expressionAddress },
|
|
435
474
|
})).perspectiveGetSubjectData;
|
|
436
475
|
}
|
|
437
476
|
// ExpressionClient functions, needed for Subjects:
|
|
438
477
|
async getExpression(expressionURI) {
|
|
439
|
-
return await
|
|
478
|
+
return await this._expressionClient.get(expressionURI);
|
|
440
479
|
}
|
|
441
480
|
async createExpression(content, languageAddress) {
|
|
442
|
-
return await
|
|
481
|
+
return await this._expressionClient.create(content, languageAddress);
|
|
443
482
|
}
|
|
444
483
|
// Subscriptions:
|
|
445
484
|
addPerspectiveAddedListener(cb) {
|
|
446
|
-
|
|
485
|
+
this._perspectiveAddedCallbacks.push(cb);
|
|
447
486
|
}
|
|
448
487
|
subscribePerspectiveAdded() {
|
|
449
|
-
|
|
488
|
+
this._apolloClient
|
|
489
|
+
.subscribe({
|
|
450
490
|
query: gql ` subscription {
|
|
451
491
|
perspectiveAdded { ${PERSPECTIVE_HANDLE_FIELDS} }
|
|
452
492
|
}
|
|
453
|
-
|
|
454
|
-
})
|
|
455
|
-
|
|
456
|
-
|
|
493
|
+
`,
|
|
494
|
+
})
|
|
495
|
+
.subscribe({
|
|
496
|
+
next: (result) => {
|
|
497
|
+
this._perspectiveAddedCallbacks.forEach((cb) => {
|
|
457
498
|
cb(result.data.perspectiveAdded);
|
|
458
499
|
});
|
|
459
500
|
},
|
|
460
|
-
error: (e) =>
|
|
501
|
+
error: (e) => {
|
|
502
|
+
if (!isSocketCloseError(e))
|
|
503
|
+
console.error(e);
|
|
504
|
+
},
|
|
461
505
|
});
|
|
462
506
|
}
|
|
463
507
|
addPerspectiveUpdatedListener(cb) {
|
|
464
|
-
|
|
508
|
+
this._perspectiveUpdatedCallbacks.push(cb);
|
|
465
509
|
}
|
|
466
510
|
subscribePerspectiveUpdated() {
|
|
467
|
-
|
|
511
|
+
this._apolloClient
|
|
512
|
+
.subscribe({
|
|
468
513
|
query: gql ` subscription {
|
|
469
514
|
perspectiveUpdated { ${PERSPECTIVE_HANDLE_FIELDS} }
|
|
470
515
|
}
|
|
471
|
-
|
|
472
|
-
})
|
|
473
|
-
|
|
474
|
-
|
|
516
|
+
`,
|
|
517
|
+
})
|
|
518
|
+
.subscribe({
|
|
519
|
+
next: (result) => {
|
|
520
|
+
this._perspectiveUpdatedCallbacks.forEach((cb) => {
|
|
475
521
|
cb(result.data.perspectiveUpdated);
|
|
476
522
|
});
|
|
477
523
|
},
|
|
478
|
-
error: (e) =>
|
|
524
|
+
error: (e) => {
|
|
525
|
+
if (!isSocketCloseError(e))
|
|
526
|
+
console.error(e);
|
|
527
|
+
},
|
|
479
528
|
});
|
|
480
529
|
}
|
|
481
530
|
addPerspectiveSyncedListener(cb) {
|
|
482
|
-
|
|
531
|
+
this._perspectiveSyncStateChangeCallbacks.push(cb);
|
|
483
532
|
}
|
|
484
533
|
async addPerspectiveSyncStateChangeListener(uuid, cb) {
|
|
485
|
-
|
|
534
|
+
this._apolloClient
|
|
535
|
+
.subscribe({
|
|
486
536
|
query: gql ` subscription {
|
|
487
537
|
perspectiveSyncStateChange(uuid: "${uuid}")
|
|
488
538
|
}
|
|
489
|
-
|
|
490
|
-
})
|
|
491
|
-
|
|
492
|
-
|
|
539
|
+
`,
|
|
540
|
+
})
|
|
541
|
+
.subscribe({
|
|
542
|
+
next: (result) => {
|
|
543
|
+
cb.forEach((c) => {
|
|
493
544
|
c(result.data.perspectiveSyncStateChange);
|
|
494
545
|
});
|
|
495
546
|
},
|
|
496
|
-
error: (e) =>
|
|
547
|
+
error: (e) => {
|
|
548
|
+
if (!isSocketCloseError(e))
|
|
549
|
+
console.error(e);
|
|
550
|
+
},
|
|
497
551
|
});
|
|
498
|
-
await new Promise(resolve => setTimeout(resolve, 500));
|
|
552
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
499
553
|
}
|
|
500
554
|
addPerspectiveRemovedListener(cb) {
|
|
501
|
-
|
|
555
|
+
this._perspectiveRemovedCallbacks.push(cb);
|
|
502
556
|
}
|
|
503
557
|
subscribePerspectiveRemoved() {
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
558
|
+
this._apolloClient
|
|
559
|
+
.subscribe({
|
|
560
|
+
query: gql `
|
|
561
|
+
subscription {
|
|
562
|
+
perspectiveRemoved
|
|
563
|
+
}
|
|
564
|
+
`,
|
|
565
|
+
})
|
|
566
|
+
.subscribe({
|
|
567
|
+
next: (result) => {
|
|
568
|
+
this._perspectiveRemovedCallbacks.forEach((cb) => {
|
|
512
569
|
cb(result.data.perspectiveRemoved);
|
|
513
570
|
});
|
|
514
571
|
},
|
|
515
|
-
error: (e) =>
|
|
572
|
+
error: (e) => {
|
|
573
|
+
if (!isSocketCloseError(e))
|
|
574
|
+
console.error(e);
|
|
575
|
+
},
|
|
516
576
|
});
|
|
517
577
|
}
|
|
518
578
|
async addPerspectiveLinkAddedListener(uuid, cb) {
|
|
519
|
-
|
|
579
|
+
this._apolloClient
|
|
580
|
+
.subscribe({
|
|
520
581
|
query: gql ` subscription {
|
|
521
582
|
perspectiveLinkAdded(uuid: "${uuid}") { ${LINK_EXPRESSION_FIELDS} }
|
|
522
583
|
}
|
|
523
|
-
|
|
524
|
-
})
|
|
525
|
-
|
|
526
|
-
|
|
584
|
+
`,
|
|
585
|
+
})
|
|
586
|
+
.subscribe({
|
|
587
|
+
next: (result) => {
|
|
588
|
+
cb.forEach((c) => {
|
|
527
589
|
c(result.data.perspectiveLinkAdded);
|
|
528
590
|
});
|
|
529
591
|
},
|
|
530
|
-
error: (e) =>
|
|
592
|
+
error: (e) => {
|
|
593
|
+
if (!isSocketCloseError(e))
|
|
594
|
+
console.error(e);
|
|
595
|
+
},
|
|
531
596
|
});
|
|
532
|
-
await new Promise(resolve => setTimeout(resolve, 500));
|
|
597
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
533
598
|
}
|
|
534
599
|
async addPerspectiveLinkRemovedListener(uuid, cb) {
|
|
535
|
-
|
|
600
|
+
this._apolloClient
|
|
601
|
+
.subscribe({
|
|
536
602
|
query: gql ` subscription {
|
|
537
603
|
perspectiveLinkRemoved(uuid: "${uuid}") { ${LINK_EXPRESSION_FIELDS} }
|
|
538
604
|
}
|
|
539
|
-
|
|
540
|
-
})
|
|
541
|
-
|
|
542
|
-
|
|
605
|
+
`,
|
|
606
|
+
})
|
|
607
|
+
.subscribe({
|
|
608
|
+
next: (result) => {
|
|
609
|
+
cb.forEach((c) => {
|
|
543
610
|
if (!result.data.perspectiveLinkRemoved.status) {
|
|
544
611
|
delete result.data.perspectiveLinkRemoved.status;
|
|
545
612
|
}
|
|
546
613
|
c(result.data.perspectiveLinkRemoved);
|
|
547
614
|
});
|
|
548
615
|
},
|
|
549
|
-
error: (e) =>
|
|
616
|
+
error: (e) => {
|
|
617
|
+
if (!isSocketCloseError(e))
|
|
618
|
+
console.error(e);
|
|
619
|
+
},
|
|
550
620
|
});
|
|
551
|
-
await new Promise(resolve => setTimeout(resolve, 500));
|
|
621
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
552
622
|
}
|
|
553
623
|
async addPerspectiveLinkUpdatedListener(uuid, cb) {
|
|
554
|
-
|
|
624
|
+
this._apolloClient
|
|
625
|
+
.subscribe({
|
|
555
626
|
query: gql ` subscription {
|
|
556
627
|
perspectiveLinkUpdated(uuid: "${uuid}") {
|
|
557
628
|
oldLink {
|
|
@@ -562,10 +633,11 @@ export class PerspectiveClient {
|
|
|
562
633
|
}
|
|
563
634
|
}
|
|
564
635
|
}
|
|
565
|
-
|
|
566
|
-
})
|
|
567
|
-
|
|
568
|
-
|
|
636
|
+
`,
|
|
637
|
+
})
|
|
638
|
+
.subscribe({
|
|
639
|
+
next: (result) => {
|
|
640
|
+
cb.forEach((c) => {
|
|
569
641
|
if (!result.data.perspectiveLinkUpdated.newLink.status) {
|
|
570
642
|
delete result.data.perspectiveLinkUpdated.newLink.status;
|
|
571
643
|
}
|
|
@@ -575,24 +647,29 @@ export class PerspectiveClient {
|
|
|
575
647
|
c(result.data.perspectiveLinkUpdated);
|
|
576
648
|
});
|
|
577
649
|
},
|
|
578
|
-
error: (e) =>
|
|
650
|
+
error: (e) => {
|
|
651
|
+
if (!isSocketCloseError(e))
|
|
652
|
+
console.error(e);
|
|
653
|
+
},
|
|
579
654
|
});
|
|
580
|
-
await new Promise(resolve => setTimeout(resolve, 500));
|
|
655
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
581
656
|
}
|
|
582
657
|
getNeighbourhoodProxy(uuid) {
|
|
583
|
-
return new NeighbourhoodProxy(
|
|
658
|
+
return new NeighbourhoodProxy(this._neighbourhoodClient, uuid);
|
|
584
659
|
}
|
|
585
660
|
async createBatch(uuid) {
|
|
586
|
-
const { perspectiveCreateBatch } = unwrapApolloResult(await
|
|
587
|
-
mutation: gql `
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
661
|
+
const { perspectiveCreateBatch } = unwrapApolloResult(await this._apolloClient.mutate({
|
|
662
|
+
mutation: gql `
|
|
663
|
+
mutation perspectiveCreateBatch($uuid: String!) {
|
|
664
|
+
perspectiveCreateBatch(uuid: $uuid)
|
|
665
|
+
}
|
|
666
|
+
`,
|
|
667
|
+
variables: { uuid },
|
|
591
668
|
}));
|
|
592
669
|
return perspectiveCreateBatch;
|
|
593
670
|
}
|
|
594
671
|
async commitBatch(uuid, batchId) {
|
|
595
|
-
const { perspectiveCommitBatch } = unwrapApolloResult(await
|
|
672
|
+
const { perspectiveCommitBatch } = unwrapApolloResult(await this._apolloClient.mutate({
|
|
596
673
|
mutation: gql `mutation perspectiveCommitBatch($uuid: String!, $batchId: String!) {
|
|
597
674
|
perspectiveCommitBatch(uuid: $uuid, batchId: $batchId) {
|
|
598
675
|
additions {
|
|
@@ -603,9 +680,8 @@ export class PerspectiveClient {
|
|
|
603
680
|
}
|
|
604
681
|
}
|
|
605
682
|
}`,
|
|
606
|
-
variables: { uuid, batchId }
|
|
683
|
+
variables: { uuid, batchId },
|
|
607
684
|
}));
|
|
608
685
|
return perspectiveCommitBatch;
|
|
609
686
|
}
|
|
610
687
|
}
|
|
611
|
-
_PerspectiveClient_apolloClient = new WeakMap(), _PerspectiveClient_perspectiveAddedCallbacks = new WeakMap(), _PerspectiveClient_perspectiveUpdatedCallbacks = new WeakMap(), _PerspectiveClient_perspectiveRemovedCallbacks = new WeakMap(), _PerspectiveClient_perspectiveSyncStateChangeCallbacks = new WeakMap(), _PerspectiveClient_expressionClient = new WeakMap(), _PerspectiveClient_neighbourhoodClient = new WeakMap(), _PerspectiveClient_aiClient = new WeakMap();
|