@coasys/ad4m 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/lib/index.cjs +19 -47
  2. package/lib/index.js +8081 -0
  3. package/lib/shims/reflect-metadata.js +0 -0
  4. package/lib/shims/type-graphql.js +70 -0
  5. package/lib/src/Ad4mClient.js +66 -0
  6. package/lib/src/Address.js +1 -0
  7. package/lib/src/DID.js +1 -0
  8. package/lib/src/Exception.js +7 -0
  9. package/lib/src/Literal.js +76 -0
  10. package/lib/src/PubSub.js +14 -0
  11. package/lib/src/SmartLiteral.js +74 -0
  12. package/lib/src/agent/Agent.js +337 -0
  13. package/lib/src/agent/AgentClient.js +431 -0
  14. package/lib/src/agent/AgentResolver.js +325 -0
  15. package/lib/src/agent/AgentStatus.js +61 -0
  16. package/lib/src/buildSchema.js +36 -0
  17. package/lib/src/expression/Expression.js +143 -0
  18. package/lib/src/expression/ExpressionClient.js +102 -0
  19. package/lib/src/expression/ExpressionRef.js +67 -0
  20. package/lib/src/expression/ExpressionResolver.js +106 -0
  21. package/lib/src/index.js +30 -0
  22. package/lib/src/jestSetup.js +1 -0
  23. package/lib/src/language/Icon.js +24 -0
  24. package/lib/src/language/Language.js +79 -0
  25. package/lib/src/language/LanguageClient.js +137 -0
  26. package/lib/src/language/LanguageContext.js +2 -0
  27. package/lib/src/language/LanguageHandle.js +41 -0
  28. package/lib/src/language/LanguageMeta.js +89 -0
  29. package/lib/src/language/LanguageRef.js +30 -0
  30. package/lib/src/language/LanguageResolver.js +143 -0
  31. package/lib/src/links/Links.js +148 -0
  32. package/lib/src/links/Links.test.js +33 -0
  33. package/lib/src/neighbourhood/Neighbourhood.js +38 -0
  34. package/lib/src/neighbourhood/NeighbourhoodClient.js +256 -0
  35. package/lib/src/neighbourhood/NeighbourhoodProxy.js +54 -0
  36. package/lib/src/neighbourhood/NeighbourhoodResolver.js +180 -0
  37. package/lib/src/perspectives/LinkQuery.js +80 -0
  38. package/lib/src/perspectives/Perspective.js +144 -0
  39. package/lib/src/perspectives/Perspective.test.js +20 -0
  40. package/lib/src/perspectives/PerspectiveClient.d.ts +1 -0
  41. package/lib/src/perspectives/PerspectiveClient.js +418 -0
  42. package/lib/src/perspectives/PerspectiveDiff.js +33 -0
  43. package/lib/src/perspectives/PerspectiveHandle.js +59 -0
  44. package/lib/src/perspectives/PerspectiveProxy.d.ts +8 -8
  45. package/lib/src/perspectives/PerspectiveProxy.js +501 -0
  46. package/lib/src/perspectives/PerspectiveResolver.d.ts +1 -0
  47. package/lib/src/perspectives/PerspectiveResolver.js +376 -0
  48. package/lib/src/runtime/RuntimeClient.js +263 -0
  49. package/lib/src/runtime/RuntimeResolver.js +328 -0
  50. package/lib/src/schema.gql +1 -0
  51. package/lib/src/subject/SDNADecorators.js +250 -0
  52. package/lib/src/subject/Subject.js +160 -0
  53. package/lib/src/subject/SubjectEntity.js +250 -0
  54. package/lib/src/subject/util.js +73 -0
  55. package/lib/src/typeDefs.js +380 -0
  56. package/lib/src/unwrapApolloResult.js +14 -0
  57. package/lib/src/utils.js +21 -0
  58. package/package.json +2 -1
  59. package/src/Ad4mClient.test.ts +5 -0
  60. package/src/perspectives/PerspectiveClient.ts +9 -0
  61. package/src/perspectives/PerspectiveProxy.ts +22 -56
  62. package/src/perspectives/PerspectiveResolver.ts +5 -0
  63. package/src/unwrapApolloResult.ts +3 -1
@@ -0,0 +1,418 @@
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;
13
+ import { gql } from "@apollo/client/core";
14
+ import { NeighbourhoodProxy } from "../neighbourhood/NeighbourhoodProxy";
15
+ import unwrapApolloResult from "../unwrapApolloResult";
16
+ import { PerspectiveProxy } from './PerspectiveProxy';
17
+ const LINK_EXPRESSION_FIELDS = `
18
+ author
19
+ timestamp
20
+ status
21
+ data { source, predicate, target }
22
+ proof { valid, invalid, signature, key }
23
+ `;
24
+ const PERSPECTIVE_HANDLE_FIELDS = `
25
+ uuid
26
+ name
27
+ sharedUrl
28
+ state
29
+ neighbourhood {
30
+ data {
31
+ linkLanguage
32
+ meta {
33
+ links
34
+ {
35
+ author
36
+ timestamp
37
+ data { source, predicate, target }
38
+ proof { valid, invalid, signature, key }
39
+ }
40
+ }
41
+ }
42
+ author
43
+ }
44
+ `;
45
+ export class PerspectiveClient {
46
+ constructor(client, subscribe = true) {
47
+ _PerspectiveClient_apolloClient.set(this, void 0);
48
+ _PerspectiveClient_perspectiveAddedCallbacks.set(this, void 0);
49
+ _PerspectiveClient_perspectiveUpdatedCallbacks.set(this, void 0);
50
+ _PerspectiveClient_perspectiveRemovedCallbacks.set(this, void 0);
51
+ _PerspectiveClient_perspectiveSyncStateChangeCallbacks.set(this, void 0);
52
+ _PerspectiveClient_expressionClient.set(this, void 0);
53
+ _PerspectiveClient_neighbourhoodClient.set(this, void 0);
54
+ __classPrivateFieldSet(this, _PerspectiveClient_apolloClient, client, "f");
55
+ __classPrivateFieldSet(this, _PerspectiveClient_perspectiveAddedCallbacks, [], "f");
56
+ __classPrivateFieldSet(this, _PerspectiveClient_perspectiveUpdatedCallbacks, [], "f");
57
+ __classPrivateFieldSet(this, _PerspectiveClient_perspectiveRemovedCallbacks, [], "f");
58
+ __classPrivateFieldSet(this, _PerspectiveClient_perspectiveSyncStateChangeCallbacks, [], "f");
59
+ if (subscribe) {
60
+ this.subscribePerspectiveAdded();
61
+ this.subscribePerspectiveUpdated();
62
+ this.subscribePerspectiveRemoved();
63
+ }
64
+ }
65
+ setExpressionClient(client) {
66
+ __classPrivateFieldSet(this, _PerspectiveClient_expressionClient, client, "f");
67
+ }
68
+ setNeighbourhoodClient(client) {
69
+ __classPrivateFieldSet(this, _PerspectiveClient_neighbourhoodClient, client, "f");
70
+ }
71
+ async all() {
72
+ const { perspectives } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").query({
73
+ query: gql `query perspectives {
74
+ perspectives {
75
+ ${PERSPECTIVE_HANDLE_FIELDS}
76
+ }
77
+ }`
78
+ }));
79
+ return perspectives.map(handle => new PerspectiveProxy(handle, this));
80
+ }
81
+ async byUUID(uuid) {
82
+ const { perspective } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").query({
83
+ query: gql `query perspective($uuid: String!) {
84
+ perspective(uuid: $uuid) {
85
+ ${PERSPECTIVE_HANDLE_FIELDS}
86
+ }
87
+ }`,
88
+ variables: { uuid }
89
+ }));
90
+ if (!perspective)
91
+ return null;
92
+ return new PerspectiveProxy(perspective, this);
93
+ }
94
+ async snapshotByUUID(uuid) {
95
+ const { perspectiveSnapshot } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").query({
96
+ query: gql `query perspectiveSnapshot($uuid: String!) {
97
+ perspectiveSnapshot(uuid: $uuid) {
98
+ links { ${LINK_EXPRESSION_FIELDS} }
99
+ }
100
+ }`,
101
+ variables: { uuid }
102
+ }));
103
+ return perspectiveSnapshot;
104
+ }
105
+ async publishSnapshotByUUID(uuid) {
106
+ const { perspectivePublishSnapshot } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
107
+ mutation: gql `mutation perspectivePublishSnapshot($uuid: String!) {
108
+ perspectivePublishSnapshot(uuid: $uuid)
109
+ }`,
110
+ variables: { uuid }
111
+ }));
112
+ return perspectivePublishSnapshot;
113
+ }
114
+ async queryLinks(uuid, query) {
115
+ const { perspectiveQueryLinks } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").query({
116
+ query: gql `query perspectiveQueryLinks($uuid: String!, $query: LinkQuery!) {
117
+ perspectiveQueryLinks(query: $query, uuid: $uuid) {
118
+ ${LINK_EXPRESSION_FIELDS}
119
+ }
120
+ }`,
121
+ variables: { uuid, query }
122
+ }));
123
+ return perspectiveQueryLinks;
124
+ }
125
+ async queryProlog(uuid, query) {
126
+ const { perspectiveQueryProlog } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").query({
127
+ query: gql `query perspectiveQueryProlog($uuid: String!, $query: String!) {
128
+ perspectiveQueryProlog(uuid: $uuid, query: $query)
129
+ }`,
130
+ variables: { uuid, query }
131
+ }));
132
+ return JSON.parse(perspectiveQueryProlog);
133
+ }
134
+ async add(name) {
135
+ const { perspectiveAdd } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
136
+ mutation: gql `mutation perspectiveAdd($name: String!) {
137
+ perspectiveAdd(name: $name) {
138
+ ${PERSPECTIVE_HANDLE_FIELDS}
139
+ }
140
+ }`,
141
+ variables: { name }
142
+ }));
143
+ return new PerspectiveProxy(perspectiveAdd, this);
144
+ }
145
+ async update(uuid, name) {
146
+ const { perspectiveUpdate } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
147
+ mutation: gql `mutation perspectiveUpdate($uuid: String!, $name: String!) {
148
+ perspectiveUpdate(uuid: $uuid, name: $name) {
149
+ ${PERSPECTIVE_HANDLE_FIELDS}
150
+ }
151
+ }`,
152
+ variables: { uuid, name }
153
+ }));
154
+ return new PerspectiveProxy(perspectiveUpdate, this);
155
+ }
156
+ async remove(uuid) {
157
+ return unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
158
+ mutation: gql `mutation perspectiveRemove($uuid: String!) {
159
+ perspectiveRemove(uuid: $uuid)
160
+ }`,
161
+ variables: { uuid }
162
+ }));
163
+ }
164
+ async addLink(uuid, link, status) {
165
+ const { perspectiveAddLink } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
166
+ mutation: gql `mutation perspectiveAddLink($uuid: String!, $link: LinkInput!, $status: String){
167
+ perspectiveAddLink(link: $link, uuid: $uuid, status: $status) {
168
+ ${LINK_EXPRESSION_FIELDS}
169
+ }
170
+ }`,
171
+ variables: { uuid, link, status }
172
+ }));
173
+ return perspectiveAddLink;
174
+ }
175
+ async addLinks(uuid, links, status) {
176
+ const { perspectiveAddLinks } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
177
+ mutation: gql `mutation perspectiveAddLinks($uuid: String!, $links: [LinkInput!]!, $status: String){
178
+ perspectiveAddLinks(links: $links, uuid: $uuid, status: $status) {
179
+ ${LINK_EXPRESSION_FIELDS}
180
+ }
181
+ }`,
182
+ variables: { uuid, links, status }
183
+ }));
184
+ return perspectiveAddLinks;
185
+ }
186
+ async removeLinks(uuid, links) {
187
+ const { perspectiveRemoveLinks } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
188
+ mutation: gql `mutation perspectiveRemoveLinks($uuid: String!, $links: [LinkExpressionInput!]!){
189
+ perspectiveRemoveLinks(links: $links, uuid: $uuid) {
190
+ ${LINK_EXPRESSION_FIELDS}
191
+ }
192
+ }`,
193
+ variables: { uuid, links }
194
+ }));
195
+ return perspectiveRemoveLinks;
196
+ }
197
+ async linkMutations(uuid, mutations, status) {
198
+ const { perspectiveLinkMutations } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
199
+ mutation: gql `mutation perspectiveLinkMutations($uuid: String!, $mutations: LinkMutations!, $status: String){
200
+ perspectiveLinkMutations(mutations: $mutations, uuid: $uuid, status: $status) {
201
+ additions {
202
+ ${LINK_EXPRESSION_FIELDS}
203
+ }
204
+ removals {
205
+ ${LINK_EXPRESSION_FIELDS}
206
+ }
207
+ }
208
+ }`,
209
+ variables: { uuid, mutations, status }
210
+ }));
211
+ return perspectiveLinkMutations;
212
+ }
213
+ async addLinkExpression(uuid, link, status) {
214
+ const { perspectiveAddLinkExpression } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
215
+ mutation: gql `mutation perspectiveAddLinkExpression($uuid: String!, $link: LinkExpressionInput!, $status: String){
216
+ perspectiveAddLinkExpression(link: $link, uuid: $uuid, status: $status) {
217
+ ${LINK_EXPRESSION_FIELDS}
218
+ }
219
+ }`,
220
+ variables: { uuid, link }
221
+ }));
222
+ return perspectiveAddLinkExpression;
223
+ }
224
+ async updateLink(uuid, oldLink, newLink) {
225
+ delete oldLink.__typename;
226
+ delete oldLink.data.__typename;
227
+ delete oldLink.proof.__typename;
228
+ const { perspectiveUpdateLink } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
229
+ mutation: gql `mutation perspectiveUpdateLink(
230
+ $uuid: String!,
231
+ $newLink: LinkInput!
232
+ $oldLink: LinkExpressionInput!
233
+ ){
234
+ perspectiveUpdateLink(
235
+ newLink: $newLink,
236
+ oldLink: $oldLink,
237
+ uuid: $uuid
238
+ ) {
239
+ ${LINK_EXPRESSION_FIELDS}
240
+ }
241
+ }`,
242
+ variables: { uuid, oldLink, newLink }
243
+ }));
244
+ if (!perspectiveUpdateLink.status) {
245
+ delete perspectiveUpdateLink.status;
246
+ }
247
+ return perspectiveUpdateLink;
248
+ }
249
+ async removeLink(uuid, link) {
250
+ delete link.__typename;
251
+ delete link.data.__typename;
252
+ delete link.proof.__typename;
253
+ delete link.status;
254
+ return unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
255
+ mutation: gql `mutation perspectiveRemoveLink($link: LinkExpressionInput!, $uuid: String!) {
256
+ perspectiveRemoveLink(link: $link, uuid: $uuid)
257
+ }`,
258
+ variables: { uuid, link }
259
+ }));
260
+ }
261
+ async addSdna(uuid, name, sdnaCode, sdnaType) {
262
+ return unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
263
+ mutation: gql `mutation perspectiveAddSdna($uuid: String!, $name: String!, $sdnaCode: String!, $sdnaType: String!) {
264
+ perspectiveAddSdna(uuid: $uuid, name: $name, sdnaCode: $sdnaCode, sdnaType: $sdnaType)
265
+ }`,
266
+ variables: { uuid, name, sdnaCode, sdnaType }
267
+ })).perspectiveAddSdna;
268
+ }
269
+ // ExpressionClient functions, needed for Subjects:
270
+ async getExpression(expressionURI) {
271
+ return await __classPrivateFieldGet(this, _PerspectiveClient_expressionClient, "f").get(expressionURI);
272
+ }
273
+ async createExpression(content, languageAddress) {
274
+ return await __classPrivateFieldGet(this, _PerspectiveClient_expressionClient, "f").create(content, languageAddress);
275
+ }
276
+ // Subscriptions:
277
+ addPerspectiveAddedListener(cb) {
278
+ __classPrivateFieldGet(this, _PerspectiveClient_perspectiveAddedCallbacks, "f").push(cb);
279
+ }
280
+ subscribePerspectiveAdded() {
281
+ __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").subscribe({
282
+ query: gql ` subscription {
283
+ perspectiveAdded { ${PERSPECTIVE_HANDLE_FIELDS} }
284
+ }
285
+ `
286
+ }).subscribe({
287
+ next: result => {
288
+ __classPrivateFieldGet(this, _PerspectiveClient_perspectiveAddedCallbacks, "f").forEach(cb => {
289
+ cb(result.data.perspectiveAdded);
290
+ });
291
+ },
292
+ error: (e) => console.error(e)
293
+ });
294
+ }
295
+ addPerspectiveUpdatedListener(cb) {
296
+ __classPrivateFieldGet(this, _PerspectiveClient_perspectiveUpdatedCallbacks, "f").push(cb);
297
+ }
298
+ subscribePerspectiveUpdated() {
299
+ __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").subscribe({
300
+ query: gql ` subscription {
301
+ perspectiveUpdated { ${PERSPECTIVE_HANDLE_FIELDS} }
302
+ }
303
+ `
304
+ }).subscribe({
305
+ next: result => {
306
+ __classPrivateFieldGet(this, _PerspectiveClient_perspectiveUpdatedCallbacks, "f").forEach(cb => {
307
+ cb(result.data.perspectiveUpdated);
308
+ });
309
+ },
310
+ error: (e) => console.error(e)
311
+ });
312
+ }
313
+ addPerspectiveSyncedListener(cb) {
314
+ __classPrivateFieldGet(this, _PerspectiveClient_perspectiveSyncStateChangeCallbacks, "f").push(cb);
315
+ }
316
+ async addPerspectiveSyncStateChangeListener(uuid, cb) {
317
+ __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").subscribe({
318
+ query: gql ` subscription {
319
+ perspectiveSyncStateChange(uuid: "${uuid}")
320
+ }
321
+ `
322
+ }).subscribe({
323
+ next: result => {
324
+ cb.forEach(c => {
325
+ c(result.data.perspectiveSyncStateChange);
326
+ });
327
+ },
328
+ error: (e) => console.error(e)
329
+ });
330
+ await new Promise(resolve => setTimeout(resolve, 500));
331
+ }
332
+ addPerspectiveRemovedListener(cb) {
333
+ __classPrivateFieldGet(this, _PerspectiveClient_perspectiveRemovedCallbacks, "f").push(cb);
334
+ }
335
+ subscribePerspectiveRemoved() {
336
+ __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").subscribe({
337
+ query: gql ` subscription {
338
+ perspectiveRemoved
339
+ }
340
+ `
341
+ }).subscribe({
342
+ next: result => {
343
+ __classPrivateFieldGet(this, _PerspectiveClient_perspectiveRemovedCallbacks, "f").forEach(cb => {
344
+ cb(result.data.perspectiveRemoved);
345
+ });
346
+ },
347
+ error: (e) => console.error(e)
348
+ });
349
+ }
350
+ async addPerspectiveLinkAddedListener(uuid, cb) {
351
+ __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").subscribe({
352
+ query: gql ` subscription {
353
+ perspectiveLinkAdded(uuid: "${uuid}") { ${LINK_EXPRESSION_FIELDS} }
354
+ }
355
+ `
356
+ }).subscribe({
357
+ next: result => {
358
+ cb.forEach(c => {
359
+ c(result.data.perspectiveLinkAdded);
360
+ });
361
+ },
362
+ error: (e) => console.error(e)
363
+ });
364
+ await new Promise(resolve => setTimeout(resolve, 500));
365
+ }
366
+ async addPerspectiveLinkRemovedListener(uuid, cb) {
367
+ __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").subscribe({
368
+ query: gql ` subscription {
369
+ perspectiveLinkRemoved(uuid: "${uuid}") { ${LINK_EXPRESSION_FIELDS} }
370
+ }
371
+ `
372
+ }).subscribe({
373
+ next: result => {
374
+ cb.forEach(c => {
375
+ if (!result.data.perspectiveLinkRemoved.status) {
376
+ delete result.data.perspectiveLinkRemoved.status;
377
+ }
378
+ c(result.data.perspectiveLinkRemoved);
379
+ });
380
+ },
381
+ error: (e) => console.error(e)
382
+ });
383
+ await new Promise(resolve => setTimeout(resolve, 500));
384
+ }
385
+ async addPerspectiveLinkUpdatedListener(uuid, cb) {
386
+ __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").subscribe({
387
+ query: gql ` subscription {
388
+ perspectiveLinkUpdated(uuid: "${uuid}") {
389
+ oldLink {
390
+ ${LINK_EXPRESSION_FIELDS}
391
+ }
392
+ newLink {
393
+ ${LINK_EXPRESSION_FIELDS}
394
+ }
395
+ }
396
+ }
397
+ `
398
+ }).subscribe({
399
+ next: result => {
400
+ cb.forEach(c => {
401
+ if (!result.data.perspectiveLinkUpdated.newLink.status) {
402
+ delete result.data.perspectiveLinkUpdated.newLink.status;
403
+ }
404
+ if (!result.data.perspectiveLinkUpdated.oldLink.status) {
405
+ delete result.data.perspectiveLinkUpdated.oldLink.status;
406
+ }
407
+ c(result.data.perspectiveLinkUpdated);
408
+ });
409
+ },
410
+ error: (e) => console.error(e)
411
+ });
412
+ await new Promise(resolve => setTimeout(resolve, 500));
413
+ }
414
+ getNeighbourhoodProxy(uuid) {
415
+ return new NeighbourhoodProxy(__classPrivateFieldGet(this, _PerspectiveClient_neighbourhoodClient, "f"), uuid);
416
+ }
417
+ }
418
+ _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();
@@ -0,0 +1,33 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Field, ObjectType } from "type-graphql";
11
+ import { ExpressionGeneric } from "../expression/Expression";
12
+ import { LinkExpression } from "../links/Links";
13
+ let PerspectiveDiff = class PerspectiveDiff {
14
+ };
15
+ __decorate([
16
+ Field(type => [LinkExpression]),
17
+ __metadata("design:type", Array)
18
+ ], PerspectiveDiff.prototype, "additions", void 0);
19
+ __decorate([
20
+ Field(type => [LinkExpression]),
21
+ __metadata("design:type", Array)
22
+ ], PerspectiveDiff.prototype, "removals", void 0);
23
+ PerspectiveDiff = __decorate([
24
+ ObjectType()
25
+ ], PerspectiveDiff);
26
+ export { PerspectiveDiff };
27
+ let PerspectiveDiffExpression = class PerspectiveDiffExpression extends ExpressionGeneric(PerspectiveDiff) {
28
+ };
29
+ PerspectiveDiffExpression = __decorate([
30
+ ObjectType()
31
+ ], PerspectiveDiffExpression);
32
+ export { PerspectiveDiffExpression };
33
+ ;
@@ -0,0 +1,59 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Field, ObjectType } from "type-graphql";
11
+ import { NeighbourhoodExpression } from "../neighbourhood/Neighbourhood";
12
+ export var PerspectiveState;
13
+ (function (PerspectiveState) {
14
+ PerspectiveState["Private"] = "Private";
15
+ PerspectiveState["NeighbourhoodJoinInitiated"] = "NeighbourhoodJoinInitiated";
16
+ PerspectiveState["LinkLanguageFailedToInstall"] = "LinkLanguageFailedToInstall";
17
+ PerspectiveState["LinkLanguageInstalledButNotSynced"] = "LinkLanguageInstalledButNotSynced";
18
+ PerspectiveState["Synced"] = "Synced";
19
+ })(PerspectiveState || (PerspectiveState = {}));
20
+ // This type is used in the GraphQL interface to reference a mutable
21
+ // prespective that is implemented locally by the Ad4m runtime.
22
+ // The UUID is used in mutations to identify the perspective that gets mutated.
23
+ let PerspectiveHandle = class PerspectiveHandle {
24
+ constructor(uuid, name, state) {
25
+ this.uuid = uuid;
26
+ this.name = name;
27
+ if (state) {
28
+ this.state = state;
29
+ }
30
+ else {
31
+ this.state = PerspectiveState.Private;
32
+ }
33
+ }
34
+ };
35
+ __decorate([
36
+ Field(),
37
+ __metadata("design:type", String)
38
+ ], PerspectiveHandle.prototype, "uuid", void 0);
39
+ __decorate([
40
+ Field(),
41
+ __metadata("design:type", String)
42
+ ], PerspectiveHandle.prototype, "name", void 0);
43
+ __decorate([
44
+ Field(),
45
+ __metadata("design:type", String)
46
+ ], PerspectiveHandle.prototype, "state", void 0);
47
+ __decorate([
48
+ Field(type => String, { nullable: true }),
49
+ __metadata("design:type", String)
50
+ ], PerspectiveHandle.prototype, "sharedUrl", void 0);
51
+ __decorate([
52
+ Field(type => NeighbourhoodExpression, { nullable: true }),
53
+ __metadata("design:type", NeighbourhoodExpression)
54
+ ], PerspectiveHandle.prototype, "neighbourhood", void 0);
55
+ PerspectiveHandle = __decorate([
56
+ ObjectType(),
57
+ __metadata("design:paramtypes", [String, String, String])
58
+ ], PerspectiveHandle);
59
+ export { PerspectiveHandle };
@@ -20,18 +20,18 @@ interface Parameter {
20
20
  */
21
21
  export declare class PerspectiveProxy {
22
22
  #private;
23
- constructor(handle: PerspectiveHandle, ad4m: PerspectiveClient);
24
- executeAction(actions: any, expression: any, parameters: Parameter[]): Promise<void>;
25
23
  /** Unique ID of the perspective */
26
- get uuid(): string;
24
+ uuid: string;
27
25
  /** Given name of the perspective */
28
- get name(): string;
26
+ name: string;
29
27
  /** If the perspective is shared as a Neighbourhood, this is the Neighbourhood URL */
30
- get sharedUrl(): string | void;
28
+ sharedUrl: string | null;
31
29
  /** If the perspective is shared as a Neighbourhood, this is the Neighbourhood Expression */
32
- get neighbourhood(): NeighbourhoodExpression | void;
30
+ neighbourhood: NeighbourhoodExpression | null;
33
31
  /** Returns the state of the perspective **/
34
- get state(): PerspectiveState;
32
+ state: PerspectiveState | null;
33
+ constructor(handle: PerspectiveHandle, ad4m: PerspectiveClient);
34
+ executeAction(actions: any, expression: any, parameters: Parameter[]): Promise<void>;
35
35
  /** Returns all the links of this perspective that matches the LinkQuery */
36
36
  get(query: LinkQuery): Promise<LinkExpression[]>;
37
37
  /** Runs a Prolog query on the perspective's Prolog engine */
@@ -107,7 +107,7 @@ export declare class PerspectiveProxy {
107
107
  */
108
108
  getSdna(): Promise<string[]>;
109
109
  /** Adds the given Social DNA code to the perspective's SDNA code */
110
- addSdna(name: string, sdnaCode: string, type: "subject_class" | "flow" | "custom"): Promise<void>;
110
+ addSdna(name: string, sdnaCode: string, sdnaType: "subject_class" | "flow" | "custom"): Promise<boolean>;
111
111
  /** Returns all the Subject classes defined in this perspectives SDNA */
112
112
  subjectClasses(): Promise<string[]>;
113
113
  stringOrTemplateObjectToSubjectClass<T>(subjectClass: T): Promise<string>;