@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.
Files changed (61) hide show
  1. package/lib/index.cjs +3179 -811
  2. package/lib/index.js +3171 -807
  3. package/lib/src/Literal.js +4 -1
  4. package/lib/src/ai/AIClient.d.ts +1 -1
  5. package/lib/src/ai/AIClient.js +6 -6
  6. package/lib/src/ai/AIResolver.d.ts +1 -1
  7. package/lib/src/ai/AIResolver.js +7 -4
  8. package/lib/src/index.d.ts +4 -3
  9. package/lib/src/index.js +4 -3
  10. package/lib/src/model/Ad4mModel.d.ts +609 -0
  11. package/lib/src/model/Ad4mModel.js +1048 -0
  12. package/lib/src/{subject → model}/Subject.d.ts +2 -2
  13. package/lib/src/{subject → model}/Subject.js +18 -18
  14. package/lib/src/model/decorators.d.ts +502 -0
  15. package/lib/src/model/decorators.js +683 -0
  16. package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +2 -2
  17. package/lib/src/neighbourhood/NeighbourhoodClient.js +16 -10
  18. package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +2 -2
  19. package/lib/src/neighbourhood/NeighbourhoodProxy.js +4 -4
  20. package/lib/src/neighbourhood/NeighbourhoodProxy.test.d.ts +1 -0
  21. package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +31 -0
  22. package/lib/src/neighbourhood/NeighbourhoodResolver.d.ts +2 -2
  23. package/lib/src/neighbourhood/NeighbourhoodResolver.js +6 -4
  24. package/lib/src/perspectives/PerspectiveClient.d.ts +18 -11
  25. package/lib/src/perspectives/PerspectiveClient.js +116 -49
  26. package/lib/src/perspectives/PerspectiveProxy.d.ts +471 -54
  27. package/lib/src/perspectives/PerspectiveProxy.js +579 -64
  28. package/lib/src/perspectives/PerspectiveResolver.d.ts +23 -9
  29. package/lib/src/perspectives/PerspectiveResolver.js +140 -46
  30. package/lib/src/runtime/RuntimeClient.d.ts +5 -1
  31. package/lib/src/runtime/RuntimeClient.js +48 -0
  32. package/lib/src/runtime/RuntimeResolver.d.ts +24 -0
  33. package/lib/src/runtime/RuntimeResolver.js +117 -0
  34. package/lib/src/schema.gql +25 -11
  35. package/lib/src/typeDefs.js +25 -11
  36. package/package.json +2 -1
  37. package/src/Literal.ts +4 -1
  38. package/src/ai/AIClient.ts +6 -6
  39. package/src/ai/AIResolver.ts +6 -3
  40. package/src/index.ts +4 -3
  41. package/src/model/Ad4mModel.ts +1206 -0
  42. package/src/{subject → model}/Subject.ts +16 -16
  43. package/src/{subject/SDNADecorators.ts → model/decorators.ts} +384 -50
  44. package/src/neighbourhood/NeighbourhoodClient.ts +16 -10
  45. package/src/neighbourhood/NeighbourhoodProxy.test.ts +45 -0
  46. package/src/neighbourhood/NeighbourhoodProxy.ts +4 -4
  47. package/src/neighbourhood/NeighbourhoodResolver.ts +2 -2
  48. package/src/perspectives/PerspectiveClient.ts +122 -51
  49. package/src/perspectives/PerspectiveProxy.ts +642 -77
  50. package/src/perspectives/PerspectiveResolver.ts +126 -23
  51. package/src/runtime/RuntimeClient.ts +52 -1
  52. package/src/runtime/RuntimeResolver.ts +77 -0
  53. package/lib/src/subject/SDNADecorators.d.ts +0 -188
  54. package/lib/src/subject/SDNADecorators.js +0 -360
  55. package/lib/src/subject/SubjectEntity.d.ts +0 -110
  56. package/lib/src/subject/SubjectEntity.js +0 -288
  57. package/src/subject/SubjectEntity.ts +0 -336
  58. package/yarn-error.log +0 -90
  59. /package/lib/src/{subject → model}/util.d.ts +0 -0
  60. /package/lib/src/{subject → model}/util.js +0 -0
  61. /package/src/{subject → model}/util.ts +0 -0
@@ -4,6 +4,11 @@ import { Perspective } from "./Perspective";
4
4
  import { LinkStatus } from "./PerspectiveProxy";
5
5
  import { PerspectiveHandle, PerspectiveState } from "./PerspectiveHandle";
6
6
  export declare const testLink: LinkExpression;
7
+ export declare const PERSPECTIVE_QUERY_SUBSCRIPTION = "PERSPECTIVE_QUERY_SUBSCRIPTION";
8
+ export declare class QuerySubscription {
9
+ subscriptionId: string;
10
+ result: string;
11
+ }
7
12
  /**
8
13
  * Resolver classes are used here to define the GraphQL schema
9
14
  * (through the type-graphql annotations)
@@ -16,20 +21,23 @@ export default class PerspectiveResolver {
16
21
  perspectiveSnapshot(uuid: string): Perspective | null;
17
22
  perspectivePublishSnapshot(uuid: string): String | null;
18
23
  perspectiveQueryLinks(uuid: string, query: LinkQuery): LinkExpression[];
19
- perspectiveQueryProlog(uuid: string, query: String): string;
24
+ perspectiveQueryProlog(uuid: string, query: string): Promise<string>;
25
+ perspectiveSubscribeQuery(uuid: string, query: string): Promise<QuerySubscription>;
20
26
  perspectiveAdd(name: string, pubSub: any): PerspectiveHandle;
21
27
  perspectiveUpdate(uuid: string, name: string, pubSub: any): PerspectiveHandle;
22
28
  perspectiveRemove(uuid: string, pubSub: any): boolean;
23
- perspectiveAddLink(uuid: string, link: LinkInput, status: LinkStatus, pubSub: any): LinkExpression;
24
- perspectiveAddLinks(uuid: string, links: LinkInput[], status: string, pubSub: any): LinkExpression[];
25
- perspectiveRemoveLinks(uuid: string, links: LinkExpressionInput[], pubSub: any): LinkExpression[];
29
+ perspectiveCreateBatch(uuid: string): Promise<string>;
30
+ perspectiveCommitBatch(uuid: string, batchId: string): Promise<LinkExpressionMutations>;
31
+ perspectiveAddLink(uuid: string, link: LinkInput, status: LinkStatus, batchId: string, pubSub: any): LinkExpression;
32
+ perspectiveAddLinks(uuid: string, links: LinkInput[], status: LinkStatus, batchId: string, pubSub: any): LinkExpression[];
33
+ perspectiveRemoveLink(uuid: string, link: LinkExpressionInput, batchId: string, pubSub: any): Boolean;
34
+ perspectiveRemoveLinks(uuid: string, links: LinkExpressionInput[], batchId: string, pubSub: any): LinkExpression[];
26
35
  perspectiveLinkMutations(uuid: string, mutations: LinkMutations, status: LinkStatus, pubSub: any): LinkExpressionMutations;
27
- perspectiveAddLinkExpression(uuid: string, link: LinkExpressionInput, status: LinkStatus, pubSub: any): LinkExpression;
28
- perspectiveUpdateLink(uuid: string, oldlink: LinkExpressionInput, newlink: LinkInput, pubSub: any): LinkExpression;
29
- perspectiveRemoveLink(uuid: string, link: LinkExpressionInput, pubSub: any): Boolean;
36
+ perspectiveUpdateLink(uuid: string, oldLink: LinkExpressionInput, newLink: LinkInput, batchId: string, pubSub: any): LinkExpression;
37
+ perspectiveAddLinkExpression(uuid: string, link: LinkExpressionInput, status: LinkStatus, batchId: string, pubSub: any): LinkExpression;
30
38
  perspectiveAddSdna(uuid: string, name: string, sdnaCode: string, sdnaType: string, pubSub: any): Boolean;
31
- perspectiveExecuteCommands(uuid: string, commands: string, expression: string, parameters: string): Boolean;
32
- perspectiveCreateSubject(uuid: string, SubjectClass: string, expressionAddress: string): Boolean;
39
+ perspectiveExecuteCommands(uuid: string, commands: string, expression: string, parameters: string, batchId?: string): Boolean;
40
+ perspectiveCreateSubject(uuid: string, SubjectClass: string, expressionAddress: string, initialValues?: string, batchId?: string): Boolean;
33
41
  perspectiveGetSubjectData(uuid: string, SubjectClass: string, expressionAddress: string): String;
34
42
  perspectiveAdded(): PerspectiveHandle;
35
43
  perspectiveUpdated(): PerspectiveHandle;
@@ -38,4 +46,10 @@ export default class PerspectiveResolver {
38
46
  perspectiveLinkRemoved(uuid: string): LinkExpression;
39
47
  perspectiveLinkUpdated(uuid: string): LinkExpressionUpdated;
40
48
  perspectiveSyncStateChange(uuid: string): PerspectiveState;
49
+ perspectiveKeepAliveQuery(uuid: string, subscriptionId: string): boolean;
50
+ perspectiveQuerySubscription(subscriptionId: string, payload: {
51
+ subscriptionId: string;
52
+ uuid: string;
53
+ result: string;
54
+ }): string;
41
55
  }
@@ -10,7 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  var __param = (this && this.__param) || function (paramIndex, decorator) {
11
11
  return function (target, key) { decorator(target, key, paramIndex); }
12
12
  };
13
- import { Arg, Mutation, PubSub, Query, Resolver, Subscription } from "type-graphql";
13
+ import { Arg, Mutation, PubSub, Query, Resolver, Root, Subscription, ObjectType, Field } from "type-graphql";
14
14
  import { LinkExpression, LinkExpressionInput, LinkExpressionMutations, LinkExpressionUpdated, LinkInput, LinkMutations } from "../links/Links";
15
15
  import { Neighbourhood, NeighbourhoodExpression } from "../neighbourhood/Neighbourhood";
16
16
  import { LinkQuery } from "./LinkQuery";
@@ -29,6 +29,21 @@ testLink.proof = {
29
29
  key: '',
30
30
  valid: true
31
31
  };
32
+ export const PERSPECTIVE_QUERY_SUBSCRIPTION = "PERSPECTIVE_QUERY_SUBSCRIPTION";
33
+ let QuerySubscription = class QuerySubscription {
34
+ };
35
+ __decorate([
36
+ Field(),
37
+ __metadata("design:type", String)
38
+ ], QuerySubscription.prototype, "subscriptionId", void 0);
39
+ __decorate([
40
+ Field(),
41
+ __metadata("design:type", String)
42
+ ], QuerySubscription.prototype, "result", void 0);
43
+ QuerySubscription = __decorate([
44
+ ObjectType()
45
+ ], QuerySubscription);
46
+ export { QuerySubscription };
32
47
  /**
33
48
  * Resolver classes are used here to define the GraphQL schema
34
49
  * (through the type-graphql annotations)
@@ -69,9 +84,16 @@ let PerspectiveResolver = class PerspectiveResolver {
69
84
  perspectiveQueryLinks(uuid, query) {
70
85
  return [testLink];
71
86
  }
72
- perspectiveQueryProlog(uuid, query) {
87
+ async perspectiveQueryProlog(uuid, query) {
73
88
  return `[{"X": 1}]`;
74
89
  }
90
+ async perspectiveSubscribeQuery(uuid, query) {
91
+ const result = `[{"X": 1}]`;
92
+ return {
93
+ subscriptionId: "test-subscription-id",
94
+ result: result
95
+ };
96
+ }
75
97
  perspectiveAdd(name, pubSub) {
76
98
  const perspective = new PerspectiveHandle('00006', name);
77
99
  pubSub.publish(PERSPECTIVE_ADDED_TOPIC, { perspective });
@@ -87,7 +109,14 @@ let PerspectiveResolver = class PerspectiveResolver {
87
109
  pubSub.publish(PERSPECTIVE_REMOVED_TOPIC, { perspective });
88
110
  return true;
89
111
  }
90
- perspectiveAddLink(uuid, link, status, pubSub) {
112
+ async perspectiveCreateBatch(uuid) {
113
+ const perspective = new PerspectiveHandle(uuid);
114
+ return uuid + '-batch-' + Date.now();
115
+ }
116
+ async perspectiveCommitBatch(uuid, batchId) {
117
+ return new LinkExpressionMutations([], []);
118
+ }
119
+ perspectiveAddLink(uuid, link, status, batchId, pubSub) {
91
120
  const l = new LinkExpression();
92
121
  l.author = 'did:ad4m:test';
93
122
  l.timestamp = Date.now();
@@ -98,22 +127,33 @@ let PerspectiveResolver = class PerspectiveResolver {
98
127
  pubSub.publish(PERSPECTIVE_SYNC_STATE_CHANGE, PerspectiveState.LinkLanguageInstalledButNotSynced);
99
128
  return l;
100
129
  }
101
- perspectiveAddLinks(uuid, links, status, pubSub) {
130
+ perspectiveAddLinks(uuid, links, status, batchId, pubSub) {
102
131
  const l = new LinkExpression();
103
132
  l.author = 'did:ad4m:test';
104
133
  l.timestamp = Date.now();
105
134
  l.proof = testLink.proof;
106
135
  l.data = links[0];
136
+ l.status = status;
107
137
  const l2 = new LinkExpression();
108
138
  l2.author = 'did:ad4m:test';
109
139
  l2.timestamp = Date.now();
110
140
  l2.proof = testLink.proof;
111
141
  l2.data = links[0];
142
+ l2.status = status;
112
143
  pubSub.publish(LINK_ADDED_TOPIC, { link: l });
113
144
  pubSub.publish(LINK_ADDED_TOPIC, { link: l2 });
114
145
  return [l, l2];
115
146
  }
116
- perspectiveRemoveLinks(uuid, links, pubSub) {
147
+ perspectiveRemoveLink(uuid, link, batchId, pubSub) {
148
+ const l = new LinkExpression();
149
+ l.author = 'did:ad4m:test';
150
+ l.timestamp = Date.now();
151
+ l.proof = testLink.proof;
152
+ l.data = link.data;
153
+ pubSub.publish(LINK_REMOVED_TOPIC, { link: l });
154
+ return true;
155
+ }
156
+ perspectiveRemoveLinks(uuid, links, batchId, pubSub) {
117
157
  const l = new LinkExpression();
118
158
  l.author = 'did:ad4m:test';
119
159
  l.timestamp = Date.now();
@@ -129,35 +169,31 @@ let PerspectiveResolver = class PerspectiveResolver {
129
169
  return [l, l2];
130
170
  }
131
171
  perspectiveLinkMutations(uuid, mutations, status, pubSub) {
132
- const perspectiveAddLinks = this.perspectiveAddLinks(uuid, mutations.additions, status, pubSub);
133
- const perspectiveRemoveLinks = this.perspectiveRemoveLinks(uuid, mutations.removals, pubSub);
172
+ const perspectiveAddLinks = this.perspectiveAddLinks(uuid, mutations.additions, status, null, pubSub);
173
+ const perspectiveRemoveLinks = this.perspectiveRemoveLinks(uuid, mutations.removals, null, pubSub);
134
174
  return new LinkExpressionMutations(perspectiveAddLinks, perspectiveRemoveLinks);
135
175
  }
136
- perspectiveAddLinkExpression(uuid, link, status, pubSub) {
137
- pubSub.publish(LINK_ADDED_TOPIC, { link });
138
- link.status = status;
139
- return link;
140
- }
141
- perspectiveUpdateLink(uuid, oldlink, newlink, pubSub) {
176
+ perspectiveUpdateLink(uuid, oldLink, newLink, batchId, pubSub) {
142
177
  const l = new LinkExpression();
143
178
  l.author = 'did:ad4m:test';
144
179
  l.timestamp = Date.now();
145
180
  l.proof = testLink.proof;
146
- l.data = newlink;
181
+ l.data = newLink;
147
182
  pubSub.publish(LINK_REMOVED_TOPIC, { link: l });
148
183
  return l;
149
184
  }
150
- perspectiveRemoveLink(uuid, link, pubSub) {
151
- pubSub.publish(LINK_REMOVED_TOPIC);
152
- return true;
185
+ perspectiveAddLinkExpression(uuid, link, status, batchId, pubSub) {
186
+ pubSub.publish(LINK_ADDED_TOPIC, { link });
187
+ link.status = status;
188
+ return link;
153
189
  }
154
190
  perspectiveAddSdna(uuid, name, sdnaCode, sdnaType, pubSub) {
155
191
  return true;
156
192
  }
157
- perspectiveExecuteCommands(uuid, commands, expression, parameters) {
193
+ perspectiveExecuteCommands(uuid, commands, expression, parameters, batchId) {
158
194
  return true;
159
195
  }
160
- perspectiveCreateSubject(uuid, SubjectClass, expressionAddress) {
196
+ perspectiveCreateSubject(uuid, SubjectClass, expressionAddress, initialValues, batchId) {
161
197
  return true;
162
198
  }
163
199
  perspectiveGetSubjectData(uuid, SubjectClass, expressionAddress) {
@@ -185,6 +221,12 @@ let PerspectiveResolver = class PerspectiveResolver {
185
221
  perspectiveSyncStateChange(uuid) {
186
222
  return PerspectiveState.Synced;
187
223
  }
224
+ perspectiveKeepAliveQuery(uuid, subscriptionId) {
225
+ return true;
226
+ }
227
+ perspectiveQuerySubscription(subscriptionId, payload) {
228
+ return payload.result;
229
+ }
188
230
  };
189
231
  __decorate([
190
232
  Query(returns => [PerspectiveHandle]),
@@ -227,8 +269,16 @@ __decorate([
227
269
  __param(1, Arg('query')),
228
270
  __metadata("design:type", Function),
229
271
  __metadata("design:paramtypes", [String, String]),
230
- __metadata("design:returntype", String)
272
+ __metadata("design:returntype", Promise)
231
273
  ], PerspectiveResolver.prototype, "perspectiveQueryProlog", null);
274
+ __decorate([
275
+ Mutation(returns => QuerySubscription),
276
+ __param(0, Arg('uuid')),
277
+ __param(1, Arg('query')),
278
+ __metadata("design:type", Function),
279
+ __metadata("design:paramtypes", [String, String]),
280
+ __metadata("design:returntype", Promise)
281
+ ], PerspectiveResolver.prototype, "perspectiveSubscribeQuery", null);
232
282
  __decorate([
233
283
  Mutation(returns => PerspectiveHandle),
234
284
  __param(0, Arg('name')),
@@ -254,33 +304,61 @@ __decorate([
254
304
  __metadata("design:paramtypes", [String, Object]),
255
305
  __metadata("design:returntype", Boolean)
256
306
  ], PerspectiveResolver.prototype, "perspectiveRemove", null);
307
+ __decorate([
308
+ Mutation(returns => String),
309
+ __param(0, Arg('uuid')),
310
+ __metadata("design:type", Function),
311
+ __metadata("design:paramtypes", [String]),
312
+ __metadata("design:returntype", Promise)
313
+ ], PerspectiveResolver.prototype, "perspectiveCreateBatch", null);
314
+ __decorate([
315
+ Mutation(returns => LinkExpressionMutations),
316
+ __param(0, Arg('uuid')),
317
+ __param(1, Arg('batchId')),
318
+ __metadata("design:type", Function),
319
+ __metadata("design:paramtypes", [String, String]),
320
+ __metadata("design:returntype", Promise)
321
+ ], PerspectiveResolver.prototype, "perspectiveCommitBatch", null);
257
322
  __decorate([
258
323
  Mutation(returns => LinkExpression),
259
324
  __param(0, Arg('uuid')),
260
325
  __param(1, Arg('link')),
261
326
  __param(2, Arg('status', { nullable: true, defaultValue: 'shared' })),
262
- __param(3, PubSub()),
327
+ __param(3, Arg('batchId', { nullable: true })),
328
+ __param(4, PubSub()),
263
329
  __metadata("design:type", Function),
264
- __metadata("design:paramtypes", [String, LinkInput, String, Object]),
330
+ __metadata("design:paramtypes", [String, LinkInput, String, String, Object]),
265
331
  __metadata("design:returntype", LinkExpression)
266
332
  ], PerspectiveResolver.prototype, "perspectiveAddLink", null);
267
333
  __decorate([
268
334
  Mutation(returns => [LinkExpression]),
269
335
  __param(0, Arg('uuid')),
270
336
  __param(1, Arg('links', type => [LinkInput])),
271
- __param(2, Arg('status', { nullable: true })),
272
- __param(3, PubSub()),
337
+ __param(2, Arg('status', { nullable: true, defaultValue: 'shared' })),
338
+ __param(3, Arg('batchId', { nullable: true })),
339
+ __param(4, PubSub()),
273
340
  __metadata("design:type", Function),
274
- __metadata("design:paramtypes", [String, Array, String, Object]),
341
+ __metadata("design:paramtypes", [String, Array, String, String, Object]),
275
342
  __metadata("design:returntype", Array)
276
343
  ], PerspectiveResolver.prototype, "perspectiveAddLinks", null);
344
+ __decorate([
345
+ Mutation(returns => Boolean),
346
+ __param(0, Arg('uuid')),
347
+ __param(1, Arg('link')),
348
+ __param(2, Arg('batchId', { nullable: true })),
349
+ __param(3, PubSub()),
350
+ __metadata("design:type", Function),
351
+ __metadata("design:paramtypes", [String, LinkExpressionInput, String, Object]),
352
+ __metadata("design:returntype", Boolean)
353
+ ], PerspectiveResolver.prototype, "perspectiveRemoveLink", null);
277
354
  __decorate([
278
355
  Mutation(returns => [LinkExpression]),
279
356
  __param(0, Arg('uuid')),
280
357
  __param(1, Arg('links', type => [LinkExpressionInput])),
281
- __param(2, PubSub()),
358
+ __param(2, Arg('batchId', { nullable: true })),
359
+ __param(3, PubSub()),
282
360
  __metadata("design:type", Function),
283
- __metadata("design:paramtypes", [String, Array, Object]),
361
+ __metadata("design:paramtypes", [String, Array, String, Object]),
284
362
  __metadata("design:returntype", Array)
285
363
  ], PerspectiveResolver.prototype, "perspectiveRemoveLinks", null);
286
364
  __decorate([
@@ -293,35 +371,29 @@ __decorate([
293
371
  __metadata("design:paramtypes", [String, LinkMutations, String, Object]),
294
372
  __metadata("design:returntype", LinkExpressionMutations)
295
373
  ], PerspectiveResolver.prototype, "perspectiveLinkMutations", null);
296
- __decorate([
297
- Mutation(returns => LinkExpression),
298
- __param(0, Arg('uuid')),
299
- __param(1, Arg('link')),
300
- __param(2, Arg('status', { nullable: true })),
301
- __param(3, PubSub()),
302
- __metadata("design:type", Function),
303
- __metadata("design:paramtypes", [String, LinkExpressionInput, String, Object]),
304
- __metadata("design:returntype", LinkExpression)
305
- ], PerspectiveResolver.prototype, "perspectiveAddLinkExpression", null);
306
374
  __decorate([
307
375
  Mutation(returns => LinkExpression),
308
376
  __param(0, Arg('uuid')),
309
377
  __param(1, Arg('oldLink')),
310
378
  __param(2, Arg('newLink')),
311
- __param(3, PubSub()),
379
+ __param(3, Arg('batchId', { nullable: true })),
380
+ __param(4, PubSub()),
312
381
  __metadata("design:type", Function),
313
- __metadata("design:paramtypes", [String, LinkExpressionInput, LinkInput, Object]),
382
+ __metadata("design:paramtypes", [String, LinkExpressionInput,
383
+ LinkInput, String, Object]),
314
384
  __metadata("design:returntype", LinkExpression)
315
385
  ], PerspectiveResolver.prototype, "perspectiveUpdateLink", null);
316
386
  __decorate([
317
- Mutation(returns => Boolean),
387
+ Mutation(returns => LinkExpression),
318
388
  __param(0, Arg('uuid')),
319
389
  __param(1, Arg('link')),
320
- __param(2, PubSub()),
390
+ __param(2, Arg('status', { nullable: true, defaultValue: 'shared' })),
391
+ __param(3, Arg('batchId', { nullable: true })),
392
+ __param(4, PubSub()),
321
393
  __metadata("design:type", Function),
322
- __metadata("design:paramtypes", [String, LinkExpressionInput, Object]),
323
- __metadata("design:returntype", Boolean)
324
- ], PerspectiveResolver.prototype, "perspectiveRemoveLink", null);
394
+ __metadata("design:paramtypes", [String, LinkExpressionInput, String, String, Object]),
395
+ __metadata("design:returntype", LinkExpression)
396
+ ], PerspectiveResolver.prototype, "perspectiveAddLinkExpression", null);
325
397
  __decorate([
326
398
  Mutation(returns => Boolean),
327
399
  __param(0, Arg('uuid')),
@@ -339,8 +411,9 @@ __decorate([
339
411
  __param(1, Arg('commands')),
340
412
  __param(2, Arg('expression')),
341
413
  __param(3, Arg('parameters', type => String, { nullable: true })),
414
+ __param(4, Arg('batchId', { nullable: true })),
342
415
  __metadata("design:type", Function),
343
- __metadata("design:paramtypes", [String, String, String, String]),
416
+ __metadata("design:paramtypes", [String, String, String, String, String]),
344
417
  __metadata("design:returntype", Boolean)
345
418
  ], PerspectiveResolver.prototype, "perspectiveExecuteCommands", null);
346
419
  __decorate([
@@ -348,8 +421,10 @@ __decorate([
348
421
  __param(0, Arg('uuid')),
349
422
  __param(1, Arg('subjectClass')),
350
423
  __param(2, Arg('expressionAddress')),
424
+ __param(3, Arg('initialValues', { nullable: true })),
425
+ __param(4, Arg('batchId', { nullable: true })),
351
426
  __metadata("design:type", Function),
352
- __metadata("design:paramtypes", [String, String, String]),
427
+ __metadata("design:paramtypes", [String, String, String, String, String]),
353
428
  __metadata("design:returntype", Boolean)
354
429
  ], PerspectiveResolver.prototype, "perspectiveCreateSubject", null);
355
430
  __decorate([
@@ -407,6 +482,25 @@ __decorate([
407
482
  __metadata("design:paramtypes", [String]),
408
483
  __metadata("design:returntype", String)
409
484
  ], PerspectiveResolver.prototype, "perspectiveSyncStateChange", null);
485
+ __decorate([
486
+ Mutation(returns => Boolean),
487
+ __param(0, Arg('uuid')),
488
+ __param(1, Arg('subscriptionId')),
489
+ __metadata("design:type", Function),
490
+ __metadata("design:paramtypes", [String, String]),
491
+ __metadata("design:returntype", Boolean)
492
+ ], PerspectiveResolver.prototype, "perspectiveKeepAliveQuery", null);
493
+ __decorate([
494
+ Subscription({
495
+ topics: PERSPECTIVE_QUERY_SUBSCRIPTION,
496
+ filter: ({ payload, args }) => payload.subscriptionId === args.subscriptionId
497
+ }),
498
+ __param(0, Arg('subscriptionId')),
499
+ __param(1, Root()),
500
+ __metadata("design:type", Function),
501
+ __metadata("design:paramtypes", [String, Object]),
502
+ __metadata("design:returntype", String)
503
+ ], PerspectiveResolver.prototype, "perspectiveQuerySubscription", null);
410
504
  PerspectiveResolver = __decorate([
411
505
  Resolver()
412
506
  ], PerspectiveResolver);
@@ -1,6 +1,6 @@
1
1
  import { ApolloClient } from "@apollo/client/core";
2
2
  import { Perspective, PerspectiveExpression } from "../perspectives/Perspective";
3
- import { RuntimeInfo, ExceptionInfo, SentMessage, NotificationInput, Notification, TriggeredNotification } from "./RuntimeResolver";
3
+ import { RuntimeInfo, ExceptionInfo, SentMessage, NotificationInput, Notification, TriggeredNotification, ImportResult } from "./RuntimeResolver";
4
4
  export type MessageCallback = (message: PerspectiveExpression) => null;
5
5
  export type ExceptionCallback = (info: ExceptionInfo) => null;
6
6
  export type NotificationTriggeredCallback = (notification: TriggeredNotification) => null;
@@ -30,9 +30,13 @@ export declare class RuntimeClient {
30
30
  messageOutbox(filter?: string): Promise<SentMessage[]>;
31
31
  requestInstallNotification(notification: NotificationInput): Promise<any>;
32
32
  grantNotification(id: string): Promise<boolean>;
33
+ exportDb(filePath: string): Promise<boolean>;
34
+ importDb(filePath: string): Promise<ImportResult>;
33
35
  notifications(): Promise<Notification[]>;
34
36
  updateNotification(id: string, notification: NotificationInput): Promise<boolean>;
35
37
  removeNotification(id: string): Promise<boolean>;
38
+ exportPerspective(uuid: string, filePath: string): Promise<boolean>;
39
+ importPerspective(filePath: string): Promise<boolean>;
36
40
  addNotificationTriggeredCallback(cb: NotificationTriggeredCallback): void;
37
41
  subscribeNotificationTriggered(): void;
38
42
  addMessageCallback(cb: MessageCallback): void;
@@ -261,6 +261,36 @@ export class RuntimeClient {
261
261
  }));
262
262
  return runtimeGrantNotification;
263
263
  }
264
+ async exportDb(filePath) {
265
+ const { runtimeExportDb } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
266
+ mutation: gql `mutation runtimeExportDb($filePath: String!) {
267
+ runtimeExportDb(filePath: $filePath)
268
+ }`,
269
+ variables: { filePath }
270
+ }));
271
+ return runtimeExportDb;
272
+ }
273
+ async importDb(filePath) {
274
+ const { runtimeImportDb } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
275
+ mutation: gql `mutation runtimeImportDb($filePath: String!) {
276
+ runtimeImportDb(filePath: $filePath) {
277
+ perspectives { total imported failed omitted errors }
278
+ links { total imported failed omitted errors }
279
+ expressions { total imported failed omitted errors }
280
+ perspectiveDiffs { total imported failed omitted errors }
281
+ notifications { total imported failed omitted errors }
282
+ models { total imported failed omitted errors }
283
+ defaultModels { total imported failed omitted errors }
284
+ tasks { total imported failed omitted errors }
285
+ friends { total imported failed omitted errors }
286
+ trustedAgents { total imported failed omitted errors }
287
+ knownLinkLanguages { total imported failed omitted errors }
288
+ }
289
+ }`,
290
+ variables: { filePath }
291
+ }));
292
+ return runtimeImportDb;
293
+ }
264
294
  async notifications() {
265
295
  const { runtimeNotifications } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
266
296
  query: gql `query runtimeNotifications {
@@ -287,6 +317,24 @@ export class RuntimeClient {
287
317
  }));
288
318
  return runtimeRemoveNotification;
289
319
  }
320
+ async exportPerspective(uuid, filePath) {
321
+ const { runtimeExportPerspective } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
322
+ mutation: gql `mutation runtimeExportPerspective($perspectiveUuid: String!, $filePath: String!) {
323
+ runtimeExportPerspective(perspectiveUuid: $perspectiveUuid, filePath: $filePath)
324
+ }`,
325
+ variables: { perspectiveUuid: uuid, filePath }
326
+ }));
327
+ return runtimeExportPerspective;
328
+ }
329
+ async importPerspective(filePath) {
330
+ const { runtimeImportPerspective } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
331
+ mutation: gql `mutation runtimeImportPerspective($filePath: String!) {
332
+ runtimeImportPerspective(filePath: $filePath)
333
+ }`,
334
+ variables: { filePath }
335
+ }));
336
+ return runtimeImportPerspective;
337
+ }
290
338
  addNotificationTriggeredCallback(cb) {
291
339
  __classPrivateFieldGet(this, _RuntimeClient_notificationTriggeredCallbacks, "f").push(cb);
292
340
  }
@@ -42,6 +42,26 @@ export declare class TriggeredNotification {
42
42
  perspectiveId: string;
43
43
  triggerMatch: string;
44
44
  }
45
+ export declare class ImportStats {
46
+ total: number;
47
+ imported: number;
48
+ failed: number;
49
+ omitted: number;
50
+ errors: string[];
51
+ }
52
+ export declare class ImportResult {
53
+ perspectives: ImportStats;
54
+ links: ImportStats;
55
+ expressions: ImportStats;
56
+ perspectiveDiffs: ImportStats;
57
+ notifications: ImportStats;
58
+ models: ImportStats;
59
+ defaultModels: ImportStats;
60
+ tasks: ImportStats;
61
+ friends: ImportStats;
62
+ trustedAgents: ImportStats;
63
+ knownLinkLanguages: ImportStats;
64
+ }
45
65
  /**
46
66
  * Resolver classes are used here to define the GraphQL schema
47
67
  * (through the type-graphql annotations)
@@ -77,4 +97,8 @@ export default class RuntimeResolver {
77
97
  runtimeRemoveNotification(id: string): boolean;
78
98
  runtimeGrantNotification(id: string): boolean;
79
99
  runtimeNotificationTriggered(): TriggeredNotification;
100
+ runtimeExportDb(filePath: string): boolean;
101
+ runtimeImportDb(filePath: string): boolean;
102
+ runtimeExportPerspective(perspectiveUuid: string, filePath: string): boolean;
103
+ runtimeImportPerspective(filePath: string): boolean;
80
104
  }
@@ -194,6 +194,82 @@ TriggeredNotification = __decorate([
194
194
  ObjectType()
195
195
  ], TriggeredNotification);
196
196
  export { TriggeredNotification };
197
+ let ImportStats = class ImportStats {
198
+ };
199
+ __decorate([
200
+ Field(),
201
+ __metadata("design:type", Number)
202
+ ], ImportStats.prototype, "total", void 0);
203
+ __decorate([
204
+ Field(),
205
+ __metadata("design:type", Number)
206
+ ], ImportStats.prototype, "imported", void 0);
207
+ __decorate([
208
+ Field(),
209
+ __metadata("design:type", Number)
210
+ ], ImportStats.prototype, "failed", void 0);
211
+ __decorate([
212
+ Field(),
213
+ __metadata("design:type", Number)
214
+ ], ImportStats.prototype, "omitted", void 0);
215
+ __decorate([
216
+ Field(type => [String]),
217
+ __metadata("design:type", Array)
218
+ ], ImportStats.prototype, "errors", void 0);
219
+ ImportStats = __decorate([
220
+ ObjectType()
221
+ ], ImportStats);
222
+ export { ImportStats };
223
+ let ImportResult = class ImportResult {
224
+ };
225
+ __decorate([
226
+ Field(),
227
+ __metadata("design:type", ImportStats)
228
+ ], ImportResult.prototype, "perspectives", void 0);
229
+ __decorate([
230
+ Field(),
231
+ __metadata("design:type", ImportStats)
232
+ ], ImportResult.prototype, "links", void 0);
233
+ __decorate([
234
+ Field(),
235
+ __metadata("design:type", ImportStats)
236
+ ], ImportResult.prototype, "expressions", void 0);
237
+ __decorate([
238
+ Field(),
239
+ __metadata("design:type", ImportStats)
240
+ ], ImportResult.prototype, "perspectiveDiffs", void 0);
241
+ __decorate([
242
+ Field(),
243
+ __metadata("design:type", ImportStats)
244
+ ], ImportResult.prototype, "notifications", void 0);
245
+ __decorate([
246
+ Field(),
247
+ __metadata("design:type", ImportStats)
248
+ ], ImportResult.prototype, "models", void 0);
249
+ __decorate([
250
+ Field(),
251
+ __metadata("design:type", ImportStats)
252
+ ], ImportResult.prototype, "defaultModels", void 0);
253
+ __decorate([
254
+ Field(),
255
+ __metadata("design:type", ImportStats)
256
+ ], ImportResult.prototype, "tasks", void 0);
257
+ __decorate([
258
+ Field(),
259
+ __metadata("design:type", ImportStats)
260
+ ], ImportResult.prototype, "friends", void 0);
261
+ __decorate([
262
+ Field(),
263
+ __metadata("design:type", ImportStats)
264
+ ], ImportResult.prototype, "trustedAgents", void 0);
265
+ __decorate([
266
+ Field(),
267
+ __metadata("design:type", ImportStats)
268
+ ], ImportResult.prototype, "knownLinkLanguages", void 0);
269
+ ImportResult = __decorate([
270
+ ObjectType()
271
+ ], ImportResult);
272
+ export { ImportResult };
197
273
  /**
198
274
  * Resolver classes are used here to define the GraphQL schema
199
275
  * (through the type-graphql annotations)
@@ -322,6 +398,18 @@ let RuntimeResolver = class RuntimeResolver {
322
398
  }
323
399
  };
324
400
  }
401
+ runtimeExportDb(filePath) {
402
+ return true;
403
+ }
404
+ runtimeImportDb(filePath) {
405
+ return true;
406
+ }
407
+ runtimeExportPerspective(perspectiveUuid, filePath) {
408
+ return true;
409
+ }
410
+ runtimeImportPerspective(filePath) {
411
+ return true;
412
+ }
325
413
  };
326
414
  __decorate([
327
415
  Mutation(returns => Boolean),
@@ -514,6 +602,35 @@ __decorate([
514
602
  __metadata("design:paramtypes", []),
515
603
  __metadata("design:returntype", TriggeredNotification)
516
604
  ], RuntimeResolver.prototype, "runtimeNotificationTriggered", null);
605
+ __decorate([
606
+ Mutation(),
607
+ __param(0, Arg("filePath", type => String)),
608
+ __metadata("design:type", Function),
609
+ __metadata("design:paramtypes", [String]),
610
+ __metadata("design:returntype", Boolean)
611
+ ], RuntimeResolver.prototype, "runtimeExportDb", null);
612
+ __decorate([
613
+ Mutation(),
614
+ __param(0, Arg("filePath", type => String)),
615
+ __metadata("design:type", Function),
616
+ __metadata("design:paramtypes", [String]),
617
+ __metadata("design:returntype", Boolean)
618
+ ], RuntimeResolver.prototype, "runtimeImportDb", null);
619
+ __decorate([
620
+ Mutation(),
621
+ __param(0, Arg("perspectiveUuid", type => String)),
622
+ __param(1, Arg("filePath", type => String)),
623
+ __metadata("design:type", Function),
624
+ __metadata("design:paramtypes", [String, String]),
625
+ __metadata("design:returntype", Boolean)
626
+ ], RuntimeResolver.prototype, "runtimeExportPerspective", null);
627
+ __decorate([
628
+ Mutation(),
629
+ __param(0, Arg("filePath", type => String)),
630
+ __metadata("design:type", Function),
631
+ __metadata("design:paramtypes", [String]),
632
+ __metadata("design:returntype", Boolean)
633
+ ], RuntimeResolver.prototype, "runtimeImportPerspective", null);
517
634
  RuntimeResolver = __decorate([
518
635
  Resolver()
519
636
  ], RuntimeResolver);