@coasys/ad4m 0.10.1-rc9-dev → 0.10.1-release-candidate-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/lib/index.cjs +3179 -811
- package/lib/index.js +3171 -807
- package/lib/src/Literal.js +4 -1
- package/lib/src/ai/AIClient.d.ts +1 -1
- package/lib/src/ai/AIClient.js +6 -6
- package/lib/src/ai/AIResolver.d.ts +1 -1
- package/lib/src/ai/AIResolver.js +7 -4
- package/lib/src/index.d.ts +4 -3
- package/lib/src/index.js +4 -3
- package/lib/src/model/Ad4mModel.d.ts +609 -0
- package/lib/src/model/Ad4mModel.js +1048 -0
- package/lib/src/{subject → model}/Subject.d.ts +2 -2
- package/lib/src/{subject → model}/Subject.js +18 -18
- package/lib/src/model/decorators.d.ts +502 -0
- package/lib/src/model/decorators.js +683 -0
- package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +2 -2
- package/lib/src/neighbourhood/NeighbourhoodClient.js +16 -10
- package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +2 -2
- package/lib/src/neighbourhood/NeighbourhoodProxy.js +4 -4
- package/lib/src/neighbourhood/NeighbourhoodProxy.test.d.ts +1 -0
- package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +31 -0
- package/lib/src/neighbourhood/NeighbourhoodResolver.d.ts +2 -2
- package/lib/src/neighbourhood/NeighbourhoodResolver.js +6 -4
- package/lib/src/perspectives/PerspectiveClient.d.ts +18 -11
- package/lib/src/perspectives/PerspectiveClient.js +116 -49
- package/lib/src/perspectives/PerspectiveProxy.d.ts +471 -54
- package/lib/src/perspectives/PerspectiveProxy.js +579 -64
- package/lib/src/perspectives/PerspectiveResolver.d.ts +23 -9
- package/lib/src/perspectives/PerspectiveResolver.js +140 -46
- package/lib/src/runtime/RuntimeClient.d.ts +5 -1
- package/lib/src/runtime/RuntimeClient.js +48 -0
- package/lib/src/runtime/RuntimeResolver.d.ts +24 -0
- package/lib/src/runtime/RuntimeResolver.js +117 -0
- package/lib/src/schema.gql +25 -11
- package/lib/src/typeDefs.js +25 -11
- package/package.json +2 -1
- package/src/Literal.ts +4 -1
- package/src/ai/AIClient.ts +6 -6
- package/src/ai/AIResolver.ts +6 -3
- package/src/index.ts +4 -3
- package/src/model/Ad4mModel.ts +1206 -0
- package/src/{subject → model}/Subject.ts +16 -16
- package/src/{subject/SDNADecorators.ts → model/decorators.ts} +384 -50
- package/src/neighbourhood/NeighbourhoodClient.ts +16 -10
- package/src/neighbourhood/NeighbourhoodProxy.test.ts +45 -0
- package/src/neighbourhood/NeighbourhoodProxy.ts +4 -4
- package/src/neighbourhood/NeighbourhoodResolver.ts +2 -2
- package/src/perspectives/PerspectiveClient.ts +122 -51
- package/src/perspectives/PerspectiveProxy.ts +642 -77
- package/src/perspectives/PerspectiveResolver.ts +126 -23
- package/src/runtime/RuntimeClient.ts +52 -1
- package/src/runtime/RuntimeResolver.ts +77 -0
- package/lib/src/subject/SDNADecorators.d.ts +0 -188
- package/lib/src/subject/SDNADecorators.js +0 -360
- package/lib/src/subject/SubjectEntity.d.ts +0 -110
- package/lib/src/subject/SubjectEntity.js +0 -288
- package/src/subject/SubjectEntity.ts +0 -336
- package/yarn-error.log +0 -90
- /package/lib/src/{subject → model}/util.d.ts +0 -0
- /package/lib/src/{subject → model}/util.js +0 -0
- /package/src/{subject → model}/util.ts +0 -0
|
@@ -170,33 +170,37 @@ export class NeighbourhoodClient {
|
|
|
170
170
|
}));
|
|
171
171
|
return neighbourhoodSendSignalU;
|
|
172
172
|
}
|
|
173
|
-
async sendBroadcast(perspectiveUUID, payload) {
|
|
173
|
+
async sendBroadcast(perspectiveUUID, payload, loopback = false) {
|
|
174
174
|
const { neighbourhoodSendBroadcast } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
|
|
175
175
|
mutation: gql `mutation neighbourhoodSendBroadcast(
|
|
176
176
|
$perspectiveUUID: String!,
|
|
177
|
-
$payload: PerspectiveInput
|
|
177
|
+
$payload: PerspectiveInput!,
|
|
178
|
+
$loopback: Boolean
|
|
178
179
|
) {
|
|
179
180
|
neighbourhoodSendBroadcast(
|
|
180
181
|
perspectiveUUID: $perspectiveUUID,
|
|
181
|
-
payload: $payload
|
|
182
|
+
payload: $payload,
|
|
183
|
+
loopback: $loopback
|
|
182
184
|
)
|
|
183
185
|
}`,
|
|
184
|
-
variables: { perspectiveUUID, payload }
|
|
186
|
+
variables: { perspectiveUUID, payload, loopback }
|
|
185
187
|
}));
|
|
186
188
|
return neighbourhoodSendBroadcast;
|
|
187
189
|
}
|
|
188
|
-
async sendBroadcastU(perspectiveUUID, payload) {
|
|
190
|
+
async sendBroadcastU(perspectiveUUID, payload, loopback = false) {
|
|
189
191
|
const { neighbourhoodSendBroadcastU } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
|
|
190
192
|
mutation: gql `mutation neighbourhoodSendBroadcastU(
|
|
191
193
|
$perspectiveUUID: String!,
|
|
192
|
-
$payload: PerspectiveUnsignedInput
|
|
194
|
+
$payload: PerspectiveUnsignedInput!,
|
|
195
|
+
$loopback: Boolean
|
|
193
196
|
) {
|
|
194
197
|
neighbourhoodSendBroadcastU(
|
|
195
198
|
perspectiveUUID: $perspectiveUUID,
|
|
196
|
-
payload: $payload
|
|
199
|
+
payload: $payload,
|
|
200
|
+
loopback: $loopback
|
|
197
201
|
)
|
|
198
202
|
}`,
|
|
199
|
-
variables: { perspectiveUUID, payload }
|
|
203
|
+
variables: { perspectiveUUID, payload, loopback }
|
|
200
204
|
}));
|
|
201
205
|
return neighbourhoodSendBroadcastU;
|
|
202
206
|
}
|
|
@@ -237,10 +241,10 @@ export class NeighbourhoodClient {
|
|
|
237
241
|
let handlersForPerspective = __classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
|
|
238
242
|
if (!handlersForPerspective) {
|
|
239
243
|
handlersForPerspective = [];
|
|
244
|
+
__classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").set(perspectiveUUID, handlersForPerspective);
|
|
240
245
|
await this.subscribeToSignals(perspectiveUUID);
|
|
241
246
|
}
|
|
242
247
|
handlersForPerspective.push(handler);
|
|
243
|
-
__classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").set(perspectiveUUID, handlersForPerspective);
|
|
244
248
|
}
|
|
245
249
|
removeSignalHandler(perspectiveUUID, handler) {
|
|
246
250
|
const handlersForPerspective = __classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
|
|
@@ -248,9 +252,11 @@ export class NeighbourhoodClient {
|
|
|
248
252
|
const index = handlersForPerspective.indexOf(handler);
|
|
249
253
|
if (index > -1) {
|
|
250
254
|
handlersForPerspective.splice(index, 1);
|
|
255
|
+
if (!handlersForPerspective.length) {
|
|
256
|
+
__classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").delete(perspectiveUUID);
|
|
257
|
+
}
|
|
251
258
|
}
|
|
252
259
|
}
|
|
253
|
-
__classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").set(perspectiveUUID, handlersForPerspective);
|
|
254
260
|
}
|
|
255
261
|
}
|
|
256
262
|
_NeighbourhoodClient_apolloClient = new WeakMap(), _NeighbourhoodClient_signalHandlers = new WeakMap();
|
|
@@ -12,8 +12,8 @@ export declare class NeighbourhoodProxy {
|
|
|
12
12
|
setOnlineStatusU(status: PerspectiveUnsignedInput): Promise<boolean>;
|
|
13
13
|
sendSignal(remoteAgentDid: string, payload: Perspective): Promise<boolean>;
|
|
14
14
|
sendSignalU(remoteAgentDid: string, payload: PerspectiveUnsignedInput): Promise<boolean>;
|
|
15
|
-
sendBroadcast(payload: Perspective): Promise<boolean>;
|
|
16
|
-
sendBroadcastU(payload: PerspectiveUnsignedInput): Promise<boolean>;
|
|
15
|
+
sendBroadcast(payload: Perspective, loopback?: boolean): Promise<boolean>;
|
|
16
|
+
sendBroadcastU(payload: PerspectiveUnsignedInput, loopback?: boolean): Promise<boolean>;
|
|
17
17
|
addSignalHandler(handler: (payload: PerspectiveExpression) => void): Promise<void>;
|
|
18
18
|
removeSignalHandler(handler: (payload: PerspectiveExpression) => void): void;
|
|
19
19
|
}
|
|
@@ -38,11 +38,11 @@ export class NeighbourhoodProxy {
|
|
|
38
38
|
async sendSignalU(remoteAgentDid, payload) {
|
|
39
39
|
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sendSignalU(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"), remoteAgentDid, payload);
|
|
40
40
|
}
|
|
41
|
-
async sendBroadcast(payload) {
|
|
42
|
-
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sendBroadcast(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"), payload);
|
|
41
|
+
async sendBroadcast(payload, loopback = false) {
|
|
42
|
+
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sendBroadcast(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"), payload, loopback);
|
|
43
43
|
}
|
|
44
|
-
async sendBroadcastU(payload) {
|
|
45
|
-
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sendBroadcastU(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"), payload);
|
|
44
|
+
async sendBroadcastU(payload, loopback = false) {
|
|
45
|
+
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sendBroadcastU(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"), payload, loopback);
|
|
46
46
|
}
|
|
47
47
|
async addSignalHandler(handler) {
|
|
48
48
|
await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").addSignalHandler(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"), handler);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { NeighbourhoodClient } from "./NeighbourhoodClient";
|
|
2
|
+
import { NeighbourhoodProxy } from "./NeighbourhoodProxy";
|
|
3
|
+
describe("NeighbourhoodProxy", () => {
|
|
4
|
+
it("should add multiple signal handlers", async () => {
|
|
5
|
+
const neighbourhoodURI = "did://123";
|
|
6
|
+
const mockApolloClient = {
|
|
7
|
+
subscribe: () => ({
|
|
8
|
+
subscribe: () => new Promise((resolve) => {
|
|
9
|
+
setTimeout(() => {
|
|
10
|
+
resolve({});
|
|
11
|
+
}, 10);
|
|
12
|
+
}),
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
15
|
+
const neighbourhoodClient = new NeighbourhoodClient(mockApolloClient);
|
|
16
|
+
const neighbourhoodProxy = new NeighbourhoodProxy(neighbourhoodClient, neighbourhoodURI);
|
|
17
|
+
let callbacks = 0;
|
|
18
|
+
const handler1 = () => {
|
|
19
|
+
callbacks++;
|
|
20
|
+
};
|
|
21
|
+
const handler2 = () => {
|
|
22
|
+
callbacks++;
|
|
23
|
+
};
|
|
24
|
+
// Add multiple signal handlers in paralell
|
|
25
|
+
const promise = neighbourhoodProxy.addSignalHandler(handler1);
|
|
26
|
+
neighbourhoodProxy.addSignalHandler(handler2);
|
|
27
|
+
await promise;
|
|
28
|
+
neighbourhoodClient.dispatchSignal(neighbourhoodURI, true);
|
|
29
|
+
expect(callbacks).toBe(2);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -18,7 +18,7 @@ export default class NeighbourhoodResolver {
|
|
|
18
18
|
neighbourhoodSetOnlineStatusU(perspectiveUUID: string, status: PerspectiveUnsignedInput): boolean;
|
|
19
19
|
neighbourhoodSendSignal(perspectiveUUID: string, recipient: DID, signal: PerspectiveInput): boolean;
|
|
20
20
|
neighbourhoodSendSignalU(perspectiveUUID: string, recipient: DID, signal: PerspectiveUnsignedInput): boolean;
|
|
21
|
-
neighbourhoodSendBroadcast(perspectiveUUID: string, signal: PerspectiveInput): boolean;
|
|
22
|
-
neighbourhoodSendBroadcastU(perspectiveUUID: string, signal: PerspectiveUnsignedInput): boolean;
|
|
21
|
+
neighbourhoodSendBroadcast(perspectiveUUID: string, signal: PerspectiveInput, loopback?: boolean): boolean;
|
|
22
|
+
neighbourhoodSendBroadcastU(perspectiveUUID: string, signal: PerspectiveUnsignedInput, loopback?: boolean): boolean;
|
|
23
23
|
neighbourhoodSignal(pID: string): PerspectiveExpression;
|
|
24
24
|
}
|
|
@@ -69,10 +69,10 @@ let NeighbourhoodResolver = class NeighbourhoodResolver {
|
|
|
69
69
|
neighbourhoodSendSignalU(perspectiveUUID, recipient, signal) {
|
|
70
70
|
return true;
|
|
71
71
|
}
|
|
72
|
-
neighbourhoodSendBroadcast(perspectiveUUID, signal) {
|
|
72
|
+
neighbourhoodSendBroadcast(perspectiveUUID, signal, loopback) {
|
|
73
73
|
return true;
|
|
74
74
|
}
|
|
75
|
-
neighbourhoodSendBroadcastU(perspectiveUUID, signal) {
|
|
75
|
+
neighbourhoodSendBroadcastU(perspectiveUUID, signal, loopback) {
|
|
76
76
|
return true;
|
|
77
77
|
}
|
|
78
78
|
neighbourhoodSignal(pID) {
|
|
@@ -155,16 +155,18 @@ __decorate([
|
|
|
155
155
|
Mutation(),
|
|
156
156
|
__param(0, Arg('perspectiveUUID')),
|
|
157
157
|
__param(1, Arg('payload')),
|
|
158
|
+
__param(2, Arg('loopback', { nullable: true })),
|
|
158
159
|
__metadata("design:type", Function),
|
|
159
|
-
__metadata("design:paramtypes", [String, PerspectiveInput]),
|
|
160
|
+
__metadata("design:paramtypes", [String, PerspectiveInput, Boolean]),
|
|
160
161
|
__metadata("design:returntype", Boolean)
|
|
161
162
|
], NeighbourhoodResolver.prototype, "neighbourhoodSendBroadcast", null);
|
|
162
163
|
__decorate([
|
|
163
164
|
Mutation(),
|
|
164
165
|
__param(0, Arg('perspectiveUUID')),
|
|
165
166
|
__param(1, Arg('payload')),
|
|
167
|
+
__param(2, Arg('loopback', { nullable: true })),
|
|
166
168
|
__metadata("design:type", Function),
|
|
167
|
-
__metadata("design:paramtypes", [String, PerspectiveUnsignedInput]),
|
|
169
|
+
__metadata("design:paramtypes", [String, PerspectiveUnsignedInput, Boolean]),
|
|
168
170
|
__metadata("design:returntype", Boolean)
|
|
169
171
|
], NeighbourhoodResolver.prototype, "neighbourhoodSendBroadcastU", null);
|
|
170
172
|
__decorate([
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ApolloClient } from "@apollo/client/core";
|
|
2
2
|
import { ExpressionRendered } from "../expression/Expression";
|
|
3
3
|
import { ExpressionClient } from "../expression/ExpressionClient";
|
|
4
|
-
import { Link, LinkExpressionInput, LinkExpression,
|
|
4
|
+
import { Link, LinkExpressionInput, LinkExpression, LinkMutations, LinkExpressionMutations } from "../links/Links";
|
|
5
5
|
import { NeighbourhoodClient } from "../neighbourhood/NeighbourhoodClient";
|
|
6
6
|
import { NeighbourhoodProxy } from "../neighbourhood/NeighbourhoodProxy";
|
|
7
7
|
import { LinkQuery } from "./LinkQuery";
|
|
@@ -9,6 +9,7 @@ import { Perspective } from "./Perspective";
|
|
|
9
9
|
import { PerspectiveHandle, PerspectiveState } from "./PerspectiveHandle";
|
|
10
10
|
import { LinkStatus, PerspectiveProxy } from './PerspectiveProxy';
|
|
11
11
|
import { AIClient } from "../ai/AIClient";
|
|
12
|
+
import { AllInstancesResult } from "../model/Ad4mModel";
|
|
12
13
|
export type PerspectiveHandleCallback = (perspective: PerspectiveHandle) => null;
|
|
13
14
|
export type UuidCallback = (uuid: string) => null;
|
|
14
15
|
export type LinkCallback = (link: LinkExpression) => null;
|
|
@@ -26,23 +27,27 @@ export declare class PerspectiveClient {
|
|
|
26
27
|
publishSnapshotByUUID(uuid: string): Promise<string | null>;
|
|
27
28
|
queryLinks(uuid: string, query: LinkQuery): Promise<LinkExpression[]>;
|
|
28
29
|
queryProlog(uuid: string, query: string): Promise<any>;
|
|
30
|
+
subscribeQuery(uuid: string, query: string): Promise<{
|
|
31
|
+
subscriptionId: string;
|
|
32
|
+
result: AllInstancesResult;
|
|
33
|
+
}>;
|
|
34
|
+
subscribeToQueryUpdates(subscriptionId: string, onData: (result: AllInstancesResult) => void): () => void;
|
|
35
|
+
keepAliveQuery(uuid: string, subscriptionId: string): Promise<boolean>;
|
|
29
36
|
add(name: string): Promise<PerspectiveProxy>;
|
|
30
37
|
update(uuid: string, name: string): Promise<PerspectiveProxy>;
|
|
31
38
|
remove(uuid: string): Promise<{
|
|
32
39
|
perspectiveRemove: boolean;
|
|
33
40
|
}>;
|
|
34
|
-
addLink(uuid: string, link: Link, status?: LinkStatus): Promise<LinkExpression>;
|
|
35
|
-
addLinks(uuid: string, links: Link[], status?: LinkStatus): Promise<LinkExpression[]>;
|
|
36
|
-
removeLinks(uuid: string, links: LinkExpressionInput[]): Promise<LinkExpression[]>;
|
|
41
|
+
addLink(uuid: string, link: Link, status?: LinkStatus, batchId?: string): Promise<LinkExpression>;
|
|
42
|
+
addLinks(uuid: string, links: Link[], status?: LinkStatus, batchId?: string): Promise<LinkExpression[]>;
|
|
43
|
+
removeLinks(uuid: string, links: LinkExpressionInput[], batchId?: string): Promise<LinkExpression[]>;
|
|
37
44
|
linkMutations(uuid: string, mutations: LinkMutations, status?: LinkStatus): Promise<LinkExpressionMutations>;
|
|
38
|
-
addLinkExpression(uuid: string, link:
|
|
39
|
-
updateLink(uuid: string, oldLink: LinkExpressionInput, newLink:
|
|
40
|
-
removeLink(uuid: string, link: LinkExpressionInput): Promise<
|
|
41
|
-
perspectiveRemoveLink: boolean;
|
|
42
|
-
}>;
|
|
45
|
+
addLinkExpression(uuid: string, link: LinkExpression, status?: LinkStatus, batchId?: string): Promise<LinkExpression>;
|
|
46
|
+
updateLink(uuid: string, oldLink: LinkExpressionInput, newLink: Link, batchId?: string): Promise<LinkExpression>;
|
|
47
|
+
removeLink(uuid: string, link: LinkExpressionInput, batchId?: string): Promise<boolean>;
|
|
43
48
|
addSdna(uuid: string, name: string, sdnaCode: string, sdnaType: "subject_class" | "flow" | "custom"): Promise<boolean>;
|
|
44
|
-
executeCommands(uuid: string, commands: string, expression: string, parameters: string): Promise<boolean>;
|
|
45
|
-
createSubject(uuid: string, subjectClass: string, expressionAddress: string): Promise<boolean>;
|
|
49
|
+
executeCommands(uuid: string, commands: string, expression: string, parameters: string, batchId?: string): Promise<boolean>;
|
|
50
|
+
createSubject(uuid: string, subjectClass: string, expressionAddress: string, initialValues?: string, batchId?: string): Promise<boolean>;
|
|
46
51
|
getSubjectData(uuid: string, subjectClass: string, expressionAddress: string): Promise<string>;
|
|
47
52
|
getExpression(expressionURI: string): Promise<ExpressionRendered>;
|
|
48
53
|
createExpression(content: any, languageAddress: string): Promise<string>;
|
|
@@ -58,4 +63,6 @@ export declare class PerspectiveClient {
|
|
|
58
63
|
addPerspectiveLinkRemovedListener(uuid: String, cb: LinkCallback[]): Promise<void>;
|
|
59
64
|
addPerspectiveLinkUpdatedListener(uuid: String, cb: LinkCallback[]): Promise<void>;
|
|
60
65
|
getNeighbourhoodProxy(uuid: string): NeighbourhoodProxy;
|
|
66
|
+
createBatch(uuid: string): Promise<string>;
|
|
67
|
+
commitBatch(uuid: string, batchId: string): Promise<LinkExpressionMutations>;
|
|
61
68
|
}
|
|
@@ -138,6 +138,62 @@ export class PerspectiveClient {
|
|
|
138
138
|
}));
|
|
139
139
|
return JSON.parse(perspectiveQueryProlog);
|
|
140
140
|
}
|
|
141
|
+
async subscribeQuery(uuid, query) {
|
|
142
|
+
const { perspectiveSubscribeQuery } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
143
|
+
mutation: gql `mutation perspectiveSubscribeQuery($uuid: String!, $query: String!) {
|
|
144
|
+
perspectiveSubscribeQuery(uuid: $uuid, query: $query) {
|
|
145
|
+
subscriptionId
|
|
146
|
+
result
|
|
147
|
+
}
|
|
148
|
+
}`,
|
|
149
|
+
variables: { uuid, query }
|
|
150
|
+
}));
|
|
151
|
+
const { subscriptionId, result } = perspectiveSubscribeQuery;
|
|
152
|
+
let finalResult = result;
|
|
153
|
+
try {
|
|
154
|
+
finalResult = JSON.parse(result);
|
|
155
|
+
}
|
|
156
|
+
catch (e) {
|
|
157
|
+
console.error('Error parsing perspectiveSubscribeQuery result:', e);
|
|
158
|
+
}
|
|
159
|
+
return { subscriptionId, result: finalResult };
|
|
160
|
+
}
|
|
161
|
+
subscribeToQueryUpdates(subscriptionId, onData) {
|
|
162
|
+
const subscription = __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").subscribe({
|
|
163
|
+
query: gql `
|
|
164
|
+
subscription perspectiveQuerySubscription($subscriptionId: String!) {
|
|
165
|
+
perspectiveQuerySubscription(subscriptionId: $subscriptionId)
|
|
166
|
+
}
|
|
167
|
+
`,
|
|
168
|
+
variables: {
|
|
169
|
+
subscriptionId
|
|
170
|
+
}
|
|
171
|
+
}).subscribe({
|
|
172
|
+
next: (result) => {
|
|
173
|
+
if (result.data && result.data.perspectiveQuerySubscription) {
|
|
174
|
+
let finalResult = result.data.perspectiveQuerySubscription;
|
|
175
|
+
try {
|
|
176
|
+
finalResult = JSON.parse(result.data.perspectiveQuerySubscription);
|
|
177
|
+
}
|
|
178
|
+
catch (e) {
|
|
179
|
+
console.error('Error parsing perspectiveQuerySubscription:', e);
|
|
180
|
+
}
|
|
181
|
+
onData(finalResult);
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
error: (e) => console.error('Error in query subscription:', e)
|
|
185
|
+
});
|
|
186
|
+
return () => subscription.unsubscribe();
|
|
187
|
+
}
|
|
188
|
+
async keepAliveQuery(uuid, subscriptionId) {
|
|
189
|
+
const { perspectiveKeepAliveQuery } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
190
|
+
mutation: gql `mutation perspectiveKeepAliveQuery($uuid: String!, $subscriptionId: String!) {
|
|
191
|
+
perspectiveKeepAliveQuery(uuid: $uuid, subscriptionId: $subscriptionId)
|
|
192
|
+
}`,
|
|
193
|
+
variables: { uuid, subscriptionId }
|
|
194
|
+
}));
|
|
195
|
+
return perspectiveKeepAliveQuery;
|
|
196
|
+
}
|
|
141
197
|
async add(name) {
|
|
142
198
|
const { perspectiveAdd } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
143
199
|
mutation: gql `mutation perspectiveAdd($name: String!) {
|
|
@@ -168,36 +224,36 @@ export class PerspectiveClient {
|
|
|
168
224
|
variables: { uuid }
|
|
169
225
|
}));
|
|
170
226
|
}
|
|
171
|
-
async addLink(uuid, link, status) {
|
|
227
|
+
async addLink(uuid, link, status = 'shared', batchId) {
|
|
172
228
|
const { perspectiveAddLink } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
173
|
-
mutation: gql `mutation perspectiveAddLink($uuid: String!, $link: LinkInput!, $status: String){
|
|
174
|
-
perspectiveAddLink(link: $link,
|
|
229
|
+
mutation: gql `mutation perspectiveAddLink($uuid: String!, $link: LinkInput!, $status: String!, $batchId: String) {
|
|
230
|
+
perspectiveAddLink(uuid: $uuid, link: $link, status: $status, batchId: $batchId) {
|
|
175
231
|
${LINK_EXPRESSION_FIELDS}
|
|
176
232
|
}
|
|
177
233
|
}`,
|
|
178
|
-
variables: { uuid, link, status }
|
|
234
|
+
variables: { uuid, link, status, batchId }
|
|
179
235
|
}));
|
|
180
236
|
return perspectiveAddLink;
|
|
181
237
|
}
|
|
182
|
-
async addLinks(uuid, links, status) {
|
|
238
|
+
async addLinks(uuid, links, status = 'shared', batchId) {
|
|
183
239
|
const { perspectiveAddLinks } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
184
|
-
mutation: gql `mutation perspectiveAddLinks($uuid: String!, $links: [LinkInput!]!, $status: String){
|
|
185
|
-
perspectiveAddLinks(links: $links,
|
|
240
|
+
mutation: gql `mutation perspectiveAddLinks($uuid: String!, $links: [LinkInput!]!, $status: String!, $batchId: String) {
|
|
241
|
+
perspectiveAddLinks(uuid: $uuid, links: $links, status: $status, batchId: $batchId) {
|
|
186
242
|
${LINK_EXPRESSION_FIELDS}
|
|
187
243
|
}
|
|
188
244
|
}`,
|
|
189
|
-
variables: { uuid, links, status }
|
|
245
|
+
variables: { uuid, links, status, batchId }
|
|
190
246
|
}));
|
|
191
247
|
return perspectiveAddLinks;
|
|
192
248
|
}
|
|
193
|
-
async removeLinks(uuid, links) {
|
|
249
|
+
async removeLinks(uuid, links, batchId) {
|
|
194
250
|
const { perspectiveRemoveLinks } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
195
|
-
mutation: gql `mutation perspectiveRemoveLinks($uuid: String!, $links: [LinkExpressionInput!]
|
|
196
|
-
perspectiveRemoveLinks(links: $links,
|
|
251
|
+
mutation: gql `mutation perspectiveRemoveLinks($uuid: String!, $links: [LinkExpressionInput!]!, $batchId: String) {
|
|
252
|
+
perspectiveRemoveLinks(uuid: $uuid, links: $links, batchId: $batchId) {
|
|
197
253
|
${LINK_EXPRESSION_FIELDS}
|
|
198
254
|
}
|
|
199
255
|
}`,
|
|
200
|
-
variables: { uuid, links }
|
|
256
|
+
variables: { uuid, links, batchId }
|
|
201
257
|
}));
|
|
202
258
|
return perspectiveRemoveLinks;
|
|
203
259
|
}
|
|
@@ -217,76 +273,62 @@ export class PerspectiveClient {
|
|
|
217
273
|
}));
|
|
218
274
|
return perspectiveLinkMutations;
|
|
219
275
|
}
|
|
220
|
-
async addLinkExpression(uuid, link, status) {
|
|
276
|
+
async addLinkExpression(uuid, link, status = 'shared', batchId) {
|
|
221
277
|
const { perspectiveAddLinkExpression } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
222
|
-
mutation: gql `mutation perspectiveAddLinkExpression($uuid: String!, $link: LinkExpressionInput!, $status: String){
|
|
223
|
-
perspectiveAddLinkExpression(link: $link,
|
|
278
|
+
mutation: gql `mutation perspectiveAddLinkExpression($uuid: String!, $link: LinkExpressionInput!, $status: String!, $batchId: String) {
|
|
279
|
+
perspectiveAddLinkExpression(uuid: $uuid, link: $link, status: $status, batchId: $batchId) {
|
|
224
280
|
${LINK_EXPRESSION_FIELDS}
|
|
225
281
|
}
|
|
226
282
|
}`,
|
|
227
|
-
variables: { uuid, link }
|
|
283
|
+
variables: { uuid, link, status, batchId }
|
|
228
284
|
}));
|
|
229
285
|
return perspectiveAddLinkExpression;
|
|
230
286
|
}
|
|
231
|
-
async updateLink(uuid, oldLink, newLink) {
|
|
232
|
-
delete oldLink.__typename;
|
|
233
|
-
delete oldLink.data.__typename;
|
|
234
|
-
delete oldLink.proof.__typename;
|
|
287
|
+
async updateLink(uuid, oldLink, newLink, batchId) {
|
|
235
288
|
const { perspectiveUpdateLink } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
236
|
-
mutation: gql `mutation perspectiveUpdateLink(
|
|
237
|
-
$uuid:
|
|
238
|
-
$newLink: LinkInput!
|
|
239
|
-
$oldLink: LinkExpressionInput!
|
|
240
|
-
){
|
|
241
|
-
perspectiveUpdateLink(
|
|
242
|
-
newLink: $newLink,
|
|
243
|
-
oldLink: $oldLink,
|
|
244
|
-
uuid: $uuid
|
|
245
|
-
) {
|
|
289
|
+
mutation: gql `mutation perspectiveUpdateLink($uuid: String!, $oldLink: LinkExpressionInput!, $newLink: LinkInput!, $batchId: String) {
|
|
290
|
+
perspectiveUpdateLink(uuid: $uuid, oldLink: $oldLink, newLink: $newLink, batchId: $batchId) {
|
|
246
291
|
${LINK_EXPRESSION_FIELDS}
|
|
247
292
|
}
|
|
248
293
|
}`,
|
|
249
|
-
variables: { uuid, oldLink, newLink }
|
|
294
|
+
variables: { uuid, oldLink, newLink, batchId }
|
|
250
295
|
}));
|
|
251
|
-
if (!perspectiveUpdateLink.status) {
|
|
252
|
-
delete perspectiveUpdateLink.status;
|
|
253
|
-
}
|
|
254
296
|
return perspectiveUpdateLink;
|
|
255
297
|
}
|
|
256
|
-
async removeLink(uuid, link) {
|
|
298
|
+
async removeLink(uuid, link, batchId) {
|
|
257
299
|
delete link.__typename;
|
|
258
300
|
delete link.data.__typename;
|
|
259
301
|
delete link.proof.__typename;
|
|
260
302
|
delete link.status;
|
|
261
|
-
|
|
262
|
-
mutation: gql `mutation perspectiveRemoveLink($link: LinkExpressionInput!, $uuid: String
|
|
263
|
-
perspectiveRemoveLink(link: $link, uuid: $uuid)
|
|
303
|
+
const { perspectiveRemoveLink } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
304
|
+
mutation: gql `mutation perspectiveRemoveLink($link: LinkExpressionInput!, $uuid: String!, $batchId: String) {
|
|
305
|
+
perspectiveRemoveLink(link: $link, uuid: $uuid, batchId: $batchId)
|
|
264
306
|
}`,
|
|
265
|
-
variables: { uuid, link }
|
|
307
|
+
variables: { uuid, link, batchId }
|
|
266
308
|
}));
|
|
309
|
+
return perspectiveRemoveLink;
|
|
267
310
|
}
|
|
268
311
|
async addSdna(uuid, name, sdnaCode, sdnaType) {
|
|
269
312
|
return unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
270
313
|
mutation: gql `mutation perspectiveAddSdna($uuid: String!, $name: String!, $sdnaCode: String!, $sdnaType: String!) {
|
|
271
314
|
perspectiveAddSdna(uuid: $uuid, name: $name, sdnaCode: $sdnaCode, sdnaType: $sdnaType)
|
|
272
|
-
}`,
|
|
273
|
-
variables: { uuid, name, sdnaCode, sdnaType }
|
|
315
|
+
}`, variables: { uuid, name, sdnaCode, sdnaType }
|
|
274
316
|
})).perspectiveAddSdna;
|
|
275
317
|
}
|
|
276
|
-
async executeCommands(uuid, commands, expression, parameters) {
|
|
318
|
+
async executeCommands(uuid, commands, expression, parameters, batchId) {
|
|
277
319
|
return unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
278
|
-
mutation: gql `mutation perspectiveExecuteCommands($uuid: String!, $commands: String!, $expression: String!, $parameters: String) {
|
|
279
|
-
perspectiveExecuteCommands(uuid: $uuid, commands: $commands, expression: $expression, parameters: $parameters)
|
|
320
|
+
mutation: gql `mutation perspectiveExecuteCommands($uuid: String!, $commands: String!, $expression: String!, $parameters: String, $batchId: String) {
|
|
321
|
+
perspectiveExecuteCommands(uuid: $uuid, commands: $commands, expression: $expression, parameters: $parameters, batchId: $batchId)
|
|
280
322
|
}`,
|
|
281
|
-
variables: { uuid, commands, expression, parameters }
|
|
323
|
+
variables: { uuid, commands, expression, parameters, batchId }
|
|
282
324
|
})).perspectiveExecuteCommands;
|
|
283
325
|
}
|
|
284
|
-
async createSubject(uuid, subjectClass, expressionAddress) {
|
|
326
|
+
async createSubject(uuid, subjectClass, expressionAddress, initialValues, batchId) {
|
|
285
327
|
return unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
286
|
-
mutation: gql `mutation perspectiveCreateSubject($uuid: String!, $subjectClass: String!, $expressionAddress: String
|
|
287
|
-
perspectiveCreateSubject(uuid: $uuid, subjectClass: $subjectClass, expressionAddress: $expressionAddress)
|
|
328
|
+
mutation: gql `mutation perspectiveCreateSubject($uuid: String!, $subjectClass: String!, $expressionAddress: String!, $initialValues: String, $batchId: String) {
|
|
329
|
+
perspectiveCreateSubject(uuid: $uuid, subjectClass: $subjectClass, expressionAddress: $expressionAddress, initialValues: $initialValues, batchId: $batchId)
|
|
288
330
|
}`,
|
|
289
|
-
variables: { uuid, subjectClass, expressionAddress }
|
|
331
|
+
variables: { uuid, subjectClass, expressionAddress, initialValues, batchId }
|
|
290
332
|
})).perspectiveCreateSubject;
|
|
291
333
|
}
|
|
292
334
|
async getSubjectData(uuid, subjectClass, expressionAddress) {
|
|
@@ -445,5 +487,30 @@ export class PerspectiveClient {
|
|
|
445
487
|
getNeighbourhoodProxy(uuid) {
|
|
446
488
|
return new NeighbourhoodProxy(__classPrivateFieldGet(this, _PerspectiveClient_neighbourhoodClient, "f"), uuid);
|
|
447
489
|
}
|
|
490
|
+
async createBatch(uuid) {
|
|
491
|
+
const { perspectiveCreateBatch } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
492
|
+
mutation: gql `mutation perspectiveCreateBatch($uuid: String!) {
|
|
493
|
+
perspectiveCreateBatch(uuid: $uuid)
|
|
494
|
+
}`,
|
|
495
|
+
variables: { uuid }
|
|
496
|
+
}));
|
|
497
|
+
return perspectiveCreateBatch;
|
|
498
|
+
}
|
|
499
|
+
async commitBatch(uuid, batchId) {
|
|
500
|
+
const { perspectiveCommitBatch } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
501
|
+
mutation: gql `mutation perspectiveCommitBatch($uuid: String!, $batchId: String!) {
|
|
502
|
+
perspectiveCommitBatch(uuid: $uuid, batchId: $batchId) {
|
|
503
|
+
additions {
|
|
504
|
+
${LINK_EXPRESSION_FIELDS}
|
|
505
|
+
}
|
|
506
|
+
removals {
|
|
507
|
+
${LINK_EXPRESSION_FIELDS}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}`,
|
|
511
|
+
variables: { uuid, batchId }
|
|
512
|
+
}));
|
|
513
|
+
return perspectiveCommitBatch;
|
|
514
|
+
}
|
|
448
515
|
}
|
|
449
516
|
_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();
|