@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
|
@@ -184,35 +184,39 @@ export class NeighbourhoodClient {
|
|
|
184
184
|
return neighbourhoodSendSignalU
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
async sendBroadcast(perspectiveUUID: string, payload: Perspective): Promise<boolean> {
|
|
187
|
+
async sendBroadcast(perspectiveUUID: string, payload: Perspective, loopback: boolean = false): Promise<boolean> {
|
|
188
188
|
const { neighbourhoodSendBroadcast } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
189
189
|
mutation: gql`mutation neighbourhoodSendBroadcast(
|
|
190
190
|
$perspectiveUUID: String!,
|
|
191
|
-
$payload: PerspectiveInput
|
|
191
|
+
$payload: PerspectiveInput!,
|
|
192
|
+
$loopback: Boolean
|
|
192
193
|
) {
|
|
193
194
|
neighbourhoodSendBroadcast(
|
|
194
195
|
perspectiveUUID: $perspectiveUUID,
|
|
195
|
-
payload: $payload
|
|
196
|
+
payload: $payload,
|
|
197
|
+
loopback: $loopback
|
|
196
198
|
)
|
|
197
199
|
}`,
|
|
198
|
-
variables: { perspectiveUUID, payload }
|
|
200
|
+
variables: { perspectiveUUID, payload, loopback }
|
|
199
201
|
}))
|
|
200
202
|
|
|
201
203
|
return neighbourhoodSendBroadcast
|
|
202
204
|
}
|
|
203
205
|
|
|
204
|
-
async sendBroadcastU(perspectiveUUID: string, payload: PerspectiveUnsignedInput): Promise<boolean> {
|
|
206
|
+
async sendBroadcastU(perspectiveUUID: string, payload: PerspectiveUnsignedInput, loopback: boolean = false): Promise<boolean> {
|
|
205
207
|
const { neighbourhoodSendBroadcastU } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
206
208
|
mutation: gql`mutation neighbourhoodSendBroadcastU(
|
|
207
209
|
$perspectiveUUID: String!,
|
|
208
|
-
$payload: PerspectiveUnsignedInput
|
|
210
|
+
$payload: PerspectiveUnsignedInput!,
|
|
211
|
+
$loopback: Boolean
|
|
209
212
|
) {
|
|
210
213
|
neighbourhoodSendBroadcastU(
|
|
211
214
|
perspectiveUUID: $perspectiveUUID,
|
|
212
|
-
payload: $payload
|
|
215
|
+
payload: $payload,
|
|
216
|
+
loopback: $loopback
|
|
213
217
|
)
|
|
214
218
|
}`,
|
|
215
|
-
variables: { perspectiveUUID, payload }
|
|
219
|
+
variables: { perspectiveUUID, payload, loopback }
|
|
216
220
|
}))
|
|
217
221
|
|
|
218
222
|
return neighbourhoodSendBroadcastU
|
|
@@ -257,10 +261,10 @@ export class NeighbourhoodClient {
|
|
|
257
261
|
let handlersForPerspective = this.#signalHandlers.get(perspectiveUUID)
|
|
258
262
|
if (!handlersForPerspective) {
|
|
259
263
|
handlersForPerspective = []
|
|
264
|
+
this.#signalHandlers.set(perspectiveUUID, handlersForPerspective)
|
|
260
265
|
await this.subscribeToSignals(perspectiveUUID)
|
|
261
266
|
}
|
|
262
267
|
handlersForPerspective.push(handler)
|
|
263
|
-
this.#signalHandlers.set(perspectiveUUID, handlersForPerspective)
|
|
264
268
|
}
|
|
265
269
|
|
|
266
270
|
removeSignalHandler(perspectiveUUID: string, handler: TelepresenceSignalCallback): void {
|
|
@@ -269,8 +273,10 @@ export class NeighbourhoodClient {
|
|
|
269
273
|
const index = handlersForPerspective.indexOf(handler)
|
|
270
274
|
if (index > -1) {
|
|
271
275
|
handlersForPerspective.splice(index, 1)
|
|
276
|
+
if (!handlersForPerspective.length) {
|
|
277
|
+
this.#signalHandlers.delete(perspectiveUUID)
|
|
278
|
+
}
|
|
272
279
|
}
|
|
273
280
|
}
|
|
274
|
-
this.#signalHandlers.set(perspectiveUUID, handlersForPerspective)
|
|
275
281
|
}
|
|
276
282
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ApolloClient } from "@apollo/client";
|
|
2
|
+
import { LinkExpression } from "../links/Links";
|
|
3
|
+
import { NeighbourhoodClient } from "./NeighbourhoodClient";
|
|
4
|
+
import { NeighbourhoodProxy } from "./NeighbourhoodProxy";
|
|
5
|
+
|
|
6
|
+
describe("NeighbourhoodProxy", () => {
|
|
7
|
+
it("should add multiple signal handlers", async () => {
|
|
8
|
+
const neighbourhoodURI = "did://123";
|
|
9
|
+
|
|
10
|
+
const mockApolloClient = {
|
|
11
|
+
subscribe: () => ({
|
|
12
|
+
subscribe: () =>
|
|
13
|
+
new Promise((resolve) => {
|
|
14
|
+
setTimeout(() => {
|
|
15
|
+
resolve({});
|
|
16
|
+
}, 10);
|
|
17
|
+
}),
|
|
18
|
+
}),
|
|
19
|
+
} as any;
|
|
20
|
+
|
|
21
|
+
const neighbourhoodClient = new NeighbourhoodClient(mockApolloClient);
|
|
22
|
+
const neighbourhoodProxy = new NeighbourhoodProxy(
|
|
23
|
+
neighbourhoodClient,
|
|
24
|
+
neighbourhoodURI
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
let callbacks = 0;
|
|
28
|
+
|
|
29
|
+
const handler1 = () => {
|
|
30
|
+
callbacks++;
|
|
31
|
+
};
|
|
32
|
+
const handler2 = () => {
|
|
33
|
+
callbacks++;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Add multiple signal handlers in paralell
|
|
37
|
+
const promise = neighbourhoodProxy.addSignalHandler(handler1);
|
|
38
|
+
neighbourhoodProxy.addSignalHandler(handler2);
|
|
39
|
+
await promise;
|
|
40
|
+
|
|
41
|
+
neighbourhoodClient.dispatchSignal(neighbourhoodURI, true);
|
|
42
|
+
|
|
43
|
+
expect(callbacks).toBe(2);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -40,12 +40,12 @@ export class NeighbourhoodProxy {
|
|
|
40
40
|
return await this.#client.sendSignalU(this.#pID, remoteAgentDid, payload)
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
async sendBroadcast(payload: Perspective): Promise<boolean> {
|
|
44
|
-
return await this.#client.sendBroadcast(this.#pID, payload)
|
|
43
|
+
async sendBroadcast(payload: Perspective, loopback: boolean = false): Promise<boolean> {
|
|
44
|
+
return await this.#client.sendBroadcast(this.#pID, payload, loopback)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
async sendBroadcastU(payload: PerspectiveUnsignedInput): Promise<boolean> {
|
|
48
|
-
return await this.#client.sendBroadcastU(this.#pID, payload)
|
|
47
|
+
async sendBroadcastU(payload: PerspectiveUnsignedInput, loopback: boolean = false): Promise<boolean> {
|
|
48
|
+
return await this.#client.sendBroadcastU(this.#pID, payload, loopback)
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
async addSignalHandler(handler: (payload: PerspectiveExpression) => void): Promise<void> {
|
|
@@ -84,12 +84,12 @@ export default class NeighbourhoodResolver {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
@Mutation()
|
|
87
|
-
neighbourhoodSendBroadcast(@Arg('perspectiveUUID') perspectiveUUID: string, @Arg('payload') signal: PerspectiveInput): boolean {
|
|
87
|
+
neighbourhoodSendBroadcast(@Arg('perspectiveUUID') perspectiveUUID: string, @Arg('payload') signal: PerspectiveInput, @Arg('loopback', { nullable: true }) loopback?: boolean): boolean {
|
|
88
88
|
return true
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
@Mutation()
|
|
92
|
-
neighbourhoodSendBroadcastU(@Arg('perspectiveUUID') perspectiveUUID: string, @Arg('payload') signal: PerspectiveUnsignedInput): boolean {
|
|
92
|
+
neighbourhoodSendBroadcastU(@Arg('perspectiveUUID') perspectiveUUID: string, @Arg('payload') signal: PerspectiveUnsignedInput, @Arg('loopback', { nullable: true }) loopback?: boolean): boolean {
|
|
93
93
|
return true
|
|
94
94
|
}
|
|
95
95
|
|
|
@@ -10,6 +10,7 @@ import { Perspective } from "./Perspective";
|
|
|
10
10
|
import { PerspectiveHandle, PerspectiveState } from "./PerspectiveHandle";
|
|
11
11
|
import { LinkStatus, PerspectiveProxy } from './PerspectiveProxy';
|
|
12
12
|
import { AIClient } from "../ai/AIClient";
|
|
13
|
+
import { AllInstancesResult } from "../model/Ad4mModel";
|
|
13
14
|
|
|
14
15
|
const LINK_EXPRESSION_FIELDS = `
|
|
15
16
|
author
|
|
@@ -154,6 +155,65 @@ export class PerspectiveClient {
|
|
|
154
155
|
return JSON.parse(perspectiveQueryProlog)
|
|
155
156
|
}
|
|
156
157
|
|
|
158
|
+
async subscribeQuery(uuid: string, query: string): Promise<{ subscriptionId: string, result: AllInstancesResult }> {
|
|
159
|
+
const { perspectiveSubscribeQuery } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
160
|
+
mutation: gql`mutation perspectiveSubscribeQuery($uuid: String!, $query: String!) {
|
|
161
|
+
perspectiveSubscribeQuery(uuid: $uuid, query: $query) {
|
|
162
|
+
subscriptionId
|
|
163
|
+
result
|
|
164
|
+
}
|
|
165
|
+
}`,
|
|
166
|
+
variables: { uuid, query }
|
|
167
|
+
}))
|
|
168
|
+
const { subscriptionId, result } = perspectiveSubscribeQuery
|
|
169
|
+
let finalResult = result;
|
|
170
|
+
try {
|
|
171
|
+
finalResult = JSON.parse(result)
|
|
172
|
+
} catch (e) {
|
|
173
|
+
console.error('Error parsing perspectiveSubscribeQuery result:', e)
|
|
174
|
+
}
|
|
175
|
+
return { subscriptionId, result: finalResult }
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
subscribeToQueryUpdates(subscriptionId: string, onData: (result: AllInstancesResult) => void): () => void {
|
|
179
|
+
const subscription = this.#apolloClient.subscribe({
|
|
180
|
+
query: gql`
|
|
181
|
+
subscription perspectiveQuerySubscription($subscriptionId: String!) {
|
|
182
|
+
perspectiveQuerySubscription(subscriptionId: $subscriptionId)
|
|
183
|
+
}
|
|
184
|
+
`,
|
|
185
|
+
variables: {
|
|
186
|
+
subscriptionId
|
|
187
|
+
}
|
|
188
|
+
}).subscribe({
|
|
189
|
+
next: (result) => {
|
|
190
|
+
if (result.data && result.data.perspectiveQuerySubscription) {
|
|
191
|
+
let finalResult = result.data.perspectiveQuerySubscription;
|
|
192
|
+
try {
|
|
193
|
+
finalResult = JSON.parse(result.data.perspectiveQuerySubscription)
|
|
194
|
+
} catch (e) {
|
|
195
|
+
console.error('Error parsing perspectiveQuerySubscription:', e)
|
|
196
|
+
}
|
|
197
|
+
onData(finalResult);
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
error: (e) => console.error('Error in query subscription:', e)
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
return () => subscription.unsubscribe();
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
async keepAliveQuery(uuid: string, subscriptionId: string): Promise<boolean> {
|
|
207
|
+
const { perspectiveKeepAliveQuery } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
208
|
+
mutation: gql`mutation perspectiveKeepAliveQuery($uuid: String!, $subscriptionId: String!) {
|
|
209
|
+
perspectiveKeepAliveQuery(uuid: $uuid, subscriptionId: $subscriptionId)
|
|
210
|
+
}`,
|
|
211
|
+
variables: { uuid, subscriptionId }
|
|
212
|
+
}))
|
|
213
|
+
|
|
214
|
+
return perspectiveKeepAliveQuery
|
|
215
|
+
}
|
|
216
|
+
|
|
157
217
|
async add(name: string): Promise<PerspectiveProxy> {
|
|
158
218
|
const { perspectiveAdd } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
159
219
|
mutation: gql`mutation perspectiveAdd($name: String!) {
|
|
@@ -187,38 +247,38 @@ export class PerspectiveClient {
|
|
|
187
247
|
}))
|
|
188
248
|
}
|
|
189
249
|
|
|
190
|
-
async addLink(uuid: string, link: Link, status?:
|
|
250
|
+
async addLink(uuid: string, link: Link, status: LinkStatus = 'shared', batchId?: string): Promise<LinkExpression> {
|
|
191
251
|
const { perspectiveAddLink } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
192
|
-
mutation: gql`mutation perspectiveAddLink($uuid: String!, $link: LinkInput!, $status: String){
|
|
193
|
-
perspectiveAddLink(link: $link,
|
|
252
|
+
mutation: gql`mutation perspectiveAddLink($uuid: String!, $link: LinkInput!, $status: String!, $batchId: String) {
|
|
253
|
+
perspectiveAddLink(uuid: $uuid, link: $link, status: $status, batchId: $batchId) {
|
|
194
254
|
${LINK_EXPRESSION_FIELDS}
|
|
195
255
|
}
|
|
196
256
|
}`,
|
|
197
|
-
variables: { uuid, link, status }
|
|
257
|
+
variables: { uuid, link, status, batchId }
|
|
198
258
|
}))
|
|
199
259
|
return perspectiveAddLink
|
|
200
260
|
}
|
|
201
261
|
|
|
202
|
-
async addLinks(uuid: string, links: Link[], status?:
|
|
262
|
+
async addLinks(uuid: string, links: Link[], status: LinkStatus = 'shared', batchId?: string): Promise<LinkExpression[]> {
|
|
203
263
|
const { perspectiveAddLinks } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
204
|
-
mutation: gql`mutation perspectiveAddLinks($uuid: String!, $links: [LinkInput!]!, $status: String){
|
|
205
|
-
perspectiveAddLinks(links: $links,
|
|
264
|
+
mutation: gql`mutation perspectiveAddLinks($uuid: String!, $links: [LinkInput!]!, $status: String!, $batchId: String) {
|
|
265
|
+
perspectiveAddLinks(uuid: $uuid, links: $links, status: $status, batchId: $batchId) {
|
|
206
266
|
${LINK_EXPRESSION_FIELDS}
|
|
207
267
|
}
|
|
208
268
|
}`,
|
|
209
|
-
variables: { uuid, links, status }
|
|
269
|
+
variables: { uuid, links, status, batchId }
|
|
210
270
|
}))
|
|
211
271
|
return perspectiveAddLinks
|
|
212
272
|
}
|
|
213
273
|
|
|
214
|
-
async removeLinks(uuid: string, links: LinkExpressionInput[]): Promise<LinkExpression[]> {
|
|
274
|
+
async removeLinks(uuid: string, links: LinkExpressionInput[], batchId?: string): Promise<LinkExpression[]> {
|
|
215
275
|
const { perspectiveRemoveLinks } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
216
|
-
mutation: gql`mutation perspectiveRemoveLinks($uuid: String!, $links: [LinkExpressionInput!]
|
|
217
|
-
perspectiveRemoveLinks(links: $links,
|
|
276
|
+
mutation: gql`mutation perspectiveRemoveLinks($uuid: String!, $links: [LinkExpressionInput!]!, $batchId: String) {
|
|
277
|
+
perspectiveRemoveLinks(uuid: $uuid, links: $links, batchId: $batchId) {
|
|
218
278
|
${LINK_EXPRESSION_FIELDS}
|
|
219
279
|
}
|
|
220
280
|
}`,
|
|
221
|
-
variables: { uuid, links }
|
|
281
|
+
variables: { uuid, links, batchId }
|
|
222
282
|
}))
|
|
223
283
|
return perspectiveRemoveLinks
|
|
224
284
|
}
|
|
@@ -240,83 +300,67 @@ export class PerspectiveClient {
|
|
|
240
300
|
return perspectiveLinkMutations
|
|
241
301
|
}
|
|
242
302
|
|
|
243
|
-
async addLinkExpression(uuid: string, link:
|
|
303
|
+
async addLinkExpression(uuid: string, link: LinkExpression, status: LinkStatus = 'shared', batchId?: string): Promise<LinkExpression> {
|
|
244
304
|
const { perspectiveAddLinkExpression } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
245
|
-
mutation: gql`mutation perspectiveAddLinkExpression($uuid: String!, $link: LinkExpressionInput!, $status: String){
|
|
246
|
-
perspectiveAddLinkExpression(link: $link,
|
|
305
|
+
mutation: gql`mutation perspectiveAddLinkExpression($uuid: String!, $link: LinkExpressionInput!, $status: String!, $batchId: String) {
|
|
306
|
+
perspectiveAddLinkExpression(uuid: $uuid, link: $link, status: $status, batchId: $batchId) {
|
|
247
307
|
${LINK_EXPRESSION_FIELDS}
|
|
248
308
|
}
|
|
249
309
|
}`,
|
|
250
|
-
variables: { uuid, link }
|
|
310
|
+
variables: { uuid, link, status, batchId }
|
|
251
311
|
}))
|
|
252
312
|
return perspectiveAddLinkExpression
|
|
253
313
|
}
|
|
254
314
|
|
|
255
|
-
async updateLink(uuid: string, oldLink: LinkExpressionInput, newLink:
|
|
256
|
-
delete oldLink.__typename
|
|
257
|
-
delete oldLink.data.__typename
|
|
258
|
-
delete oldLink.proof.__typename
|
|
315
|
+
async updateLink(uuid: string, oldLink: LinkExpressionInput, newLink: Link, batchId?: string): Promise<LinkExpression> {
|
|
259
316
|
const { perspectiveUpdateLink } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
260
|
-
mutation: gql`mutation perspectiveUpdateLink(
|
|
261
|
-
$uuid:
|
|
262
|
-
$newLink: LinkInput!
|
|
263
|
-
$oldLink: LinkExpressionInput!
|
|
264
|
-
){
|
|
265
|
-
perspectiveUpdateLink(
|
|
266
|
-
newLink: $newLink,
|
|
267
|
-
oldLink: $oldLink,
|
|
268
|
-
uuid: $uuid
|
|
269
|
-
) {
|
|
317
|
+
mutation: gql`mutation perspectiveUpdateLink($uuid: String!, $oldLink: LinkExpressionInput!, $newLink: LinkInput!, $batchId: String) {
|
|
318
|
+
perspectiveUpdateLink(uuid: $uuid, oldLink: $oldLink, newLink: $newLink, batchId: $batchId) {
|
|
270
319
|
${LINK_EXPRESSION_FIELDS}
|
|
271
320
|
}
|
|
272
321
|
}`,
|
|
273
|
-
variables: { uuid, oldLink, newLink }
|
|
322
|
+
variables: { uuid, oldLink, newLink, batchId }
|
|
274
323
|
}))
|
|
275
|
-
|
|
276
|
-
if (!perspectiveUpdateLink.status) {
|
|
277
|
-
delete perspectiveUpdateLink.status
|
|
278
|
-
}
|
|
279
|
-
|
|
280
324
|
return perspectiveUpdateLink
|
|
281
325
|
}
|
|
282
326
|
|
|
283
|
-
async removeLink(uuid: string, link: LinkExpressionInput): Promise<
|
|
327
|
+
async removeLink(uuid: string, link: LinkExpressionInput, batchId?: string): Promise<boolean> {
|
|
284
328
|
delete link.__typename
|
|
285
329
|
delete link.data.__typename
|
|
286
330
|
delete link.proof.__typename
|
|
287
331
|
delete link.status
|
|
288
|
-
|
|
289
|
-
mutation: gql`mutation perspectiveRemoveLink($link: LinkExpressionInput!, $uuid: String
|
|
290
|
-
perspectiveRemoveLink(link: $link, uuid: $uuid)
|
|
332
|
+
const { perspectiveRemoveLink } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
333
|
+
mutation: gql`mutation perspectiveRemoveLink($link: LinkExpressionInput!, $uuid: String!, $batchId: String) {
|
|
334
|
+
perspectiveRemoveLink(link: $link, uuid: $uuid, batchId: $batchId)
|
|
291
335
|
}`,
|
|
292
|
-
variables: { uuid, link }
|
|
336
|
+
variables: { uuid, link, batchId }
|
|
293
337
|
}))
|
|
338
|
+
return perspectiveRemoveLink
|
|
294
339
|
}
|
|
295
340
|
|
|
296
341
|
async addSdna(uuid: string, name: string, sdnaCode: string, sdnaType: "subject_class" | "flow" | "custom"): Promise<boolean> {
|
|
297
342
|
return unwrapApolloResult(await this.#apolloClient.mutate({
|
|
298
343
|
mutation: gql`mutation perspectiveAddSdna($uuid: String!, $name: String!, $sdnaCode: String!, $sdnaType: String!) {
|
|
299
344
|
perspectiveAddSdna(uuid: $uuid, name: $name, sdnaCode: $sdnaCode, sdnaType: $sdnaType)
|
|
300
|
-
}`,
|
|
301
|
-
variables: { uuid, name, sdnaCode, sdnaType }
|
|
345
|
+
}`, variables: { uuid, name, sdnaCode, sdnaType }
|
|
302
346
|
})).perspectiveAddSdna
|
|
303
347
|
}
|
|
304
348
|
|
|
305
|
-
async executeCommands(uuid: string, commands: string, expression: string, parameters: string): Promise<boolean> {
|
|
349
|
+
async executeCommands(uuid: string, commands: string, expression: string, parameters: string, batchId?: string): Promise<boolean> {
|
|
306
350
|
return unwrapApolloResult(await this.#apolloClient.mutate({
|
|
307
|
-
mutation: gql`mutation perspectiveExecuteCommands($uuid: String!, $commands: String!, $expression: String!, $parameters: String) {
|
|
308
|
-
perspectiveExecuteCommands(uuid: $uuid, commands: $commands, expression: $expression, parameters: $parameters)
|
|
351
|
+
mutation: gql`mutation perspectiveExecuteCommands($uuid: String!, $commands: String!, $expression: String!, $parameters: String, $batchId: String) {
|
|
352
|
+
perspectiveExecuteCommands(uuid: $uuid, commands: $commands, expression: $expression, parameters: $parameters, batchId: $batchId)
|
|
309
353
|
}`,
|
|
310
|
-
variables: { uuid, commands, expression, parameters }
|
|
354
|
+
variables: { uuid, commands, expression, parameters, batchId }
|
|
311
355
|
})).perspectiveExecuteCommands
|
|
312
356
|
}
|
|
313
357
|
|
|
314
|
-
async createSubject(uuid: string, subjectClass: string, expressionAddress: string): Promise<boolean> {
|
|
358
|
+
async createSubject(uuid: string, subjectClass: string, expressionAddress: string, initialValues?: string, batchId?: string): Promise<boolean> {
|
|
315
359
|
return unwrapApolloResult(await this.#apolloClient.mutate({
|
|
316
|
-
mutation: gql`mutation perspectiveCreateSubject($uuid: String!, $subjectClass: String!, $expressionAddress: String
|
|
317
|
-
perspectiveCreateSubject(uuid: $uuid, subjectClass: $subjectClass, expressionAddress: $expressionAddress)
|
|
360
|
+
mutation: gql`mutation perspectiveCreateSubject($uuid: String!, $subjectClass: String!, $expressionAddress: String!, $initialValues: String, $batchId: String) {
|
|
361
|
+
perspectiveCreateSubject(uuid: $uuid, subjectClass: $subjectClass, expressionAddress: $expressionAddress, initialValues: $initialValues, batchId: $batchId)
|
|
318
362
|
}`,
|
|
319
|
-
variables: { uuid, subjectClass, expressionAddress }
|
|
363
|
+
variables: { uuid, subjectClass, expressionAddress, initialValues, batchId }
|
|
320
364
|
})).perspectiveCreateSubject
|
|
321
365
|
}
|
|
322
366
|
|
|
@@ -487,4 +531,31 @@ export class PerspectiveClient {
|
|
|
487
531
|
getNeighbourhoodProxy(uuid: string): NeighbourhoodProxy {
|
|
488
532
|
return new NeighbourhoodProxy(this.#neighbourhoodClient, uuid)
|
|
489
533
|
}
|
|
534
|
+
|
|
535
|
+
async createBatch(uuid: string): Promise<string> {
|
|
536
|
+
const { perspectiveCreateBatch } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
537
|
+
mutation: gql`mutation perspectiveCreateBatch($uuid: String!) {
|
|
538
|
+
perspectiveCreateBatch(uuid: $uuid)
|
|
539
|
+
}`,
|
|
540
|
+
variables: { uuid }
|
|
541
|
+
}))
|
|
542
|
+
return perspectiveCreateBatch
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
async commitBatch(uuid: string, batchId: string): Promise<LinkExpressionMutations> {
|
|
546
|
+
const { perspectiveCommitBatch } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
547
|
+
mutation: gql`mutation perspectiveCommitBatch($uuid: String!, $batchId: String!) {
|
|
548
|
+
perspectiveCommitBatch(uuid: $uuid, batchId: $batchId) {
|
|
549
|
+
additions {
|
|
550
|
+
${LINK_EXPRESSION_FIELDS}
|
|
551
|
+
}
|
|
552
|
+
removals {
|
|
553
|
+
${LINK_EXPRESSION_FIELDS}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}`,
|
|
557
|
+
variables: { uuid, batchId }
|
|
558
|
+
}))
|
|
559
|
+
return perspectiveCommitBatch
|
|
560
|
+
}
|
|
490
561
|
}
|