@coasys/ad4m 0.8.0-fix → 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 (161) hide show
  1. package/README.md +229 -229
  2. package/jest.config.js +5 -5
  3. package/jsdoc.json +27 -27
  4. package/lib/index.cjs +4522 -4571
  5. package/lib/index.js +4522 -4571
  6. package/lib/shims/type-graphql.d.ts +32 -32
  7. package/lib/shims/type-graphql.js +70 -70
  8. package/lib/src/Ad4mClient.d.ts +26 -26
  9. package/lib/src/Ad4mClient.js +66 -66
  10. package/lib/src/Address.d.ts +1 -1
  11. package/lib/src/Address.js +1 -1
  12. package/lib/src/DID.d.ts +1 -1
  13. package/lib/src/DID.js +1 -1
  14. package/lib/src/Exception.d.ts +6 -6
  15. package/lib/src/Exception.js +7 -7
  16. package/lib/src/Literal.d.ts +7 -7
  17. package/lib/src/Literal.js +76 -76
  18. package/lib/src/PubSub.d.ts +14 -14
  19. package/lib/src/PubSub.js +14 -14
  20. package/lib/src/SmartLiteral.d.ts +12 -12
  21. package/lib/src/SmartLiteral.js +74 -74
  22. package/lib/src/agent/Agent.d.ts +104 -104
  23. package/lib/src/agent/Agent.js +337 -337
  24. package/lib/src/agent/AgentClient.d.ts +57 -57
  25. package/lib/src/agent/AgentClient.js +431 -431
  26. package/lib/src/agent/AgentResolver.d.ts +30 -30
  27. package/lib/src/agent/AgentResolver.js +325 -325
  28. package/lib/src/agent/AgentStatus.d.ts +8 -8
  29. package/lib/src/agent/AgentStatus.js +61 -61
  30. package/lib/src/buildSchema.d.ts +1 -1
  31. package/lib/src/buildSchema.js +36 -36
  32. package/lib/src/expression/Expression.d.ts +28 -28
  33. package/lib/src/expression/Expression.js +143 -143
  34. package/lib/src/expression/ExpressionClient.d.ts +13 -13
  35. package/lib/src/expression/ExpressionClient.js +102 -102
  36. package/lib/src/expression/ExpressionRef.d.ts +9 -9
  37. package/lib/src/expression/ExpressionRef.js +67 -67
  38. package/lib/src/expression/ExpressionResolver.d.ts +10 -10
  39. package/lib/src/expression/ExpressionResolver.js +106 -106
  40. package/lib/src/index.d.ts +30 -30
  41. package/lib/src/index.js +30 -30
  42. package/lib/src/jestSetup.d.ts +1 -1
  43. package/lib/src/jestSetup.js +1 -1
  44. package/lib/src/language/Icon.d.ts +4 -4
  45. package/lib/src/language/Icon.js +24 -24
  46. package/lib/src/language/Language.d.ts +195 -195
  47. package/lib/src/language/Language.js +79 -79
  48. package/lib/src/language/LanguageClient.d.ts +17 -17
  49. package/lib/src/language/LanguageClient.js +137 -137
  50. package/lib/src/language/LanguageContext.d.ts +37 -37
  51. package/lib/src/language/LanguageContext.js +2 -2
  52. package/lib/src/language/LanguageHandle.d.ts +9 -9
  53. package/lib/src/language/LanguageHandle.js +41 -41
  54. package/lib/src/language/LanguageMeta.d.ts +35 -35
  55. package/lib/src/language/LanguageMeta.js +89 -89
  56. package/lib/src/language/LanguageRef.d.ts +6 -6
  57. package/lib/src/language/LanguageRef.js +30 -30
  58. package/lib/src/language/LanguageResolver.d.ts +19 -19
  59. package/lib/src/language/LanguageResolver.js +143 -143
  60. package/lib/src/links/Links.d.ts +39 -39
  61. package/lib/src/links/Links.js +148 -148
  62. package/lib/src/links/Links.test.d.ts +1 -1
  63. package/lib/src/links/Links.test.js +33 -33
  64. package/lib/src/neighbourhood/Neighbourhood.d.ts +10 -10
  65. package/lib/src/neighbourhood/Neighbourhood.js +38 -38
  66. package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +25 -25
  67. package/lib/src/neighbourhood/NeighbourhoodClient.js +256 -256
  68. package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +19 -19
  69. package/lib/src/neighbourhood/NeighbourhoodProxy.js +54 -54
  70. package/lib/src/neighbourhood/NeighbourhoodResolver.d.ts +24 -24
  71. package/lib/src/neighbourhood/NeighbourhoodResolver.js +180 -180
  72. package/lib/src/perspectives/LinkQuery.d.ts +11 -11
  73. package/lib/src/perspectives/LinkQuery.js +80 -80
  74. package/lib/src/perspectives/Perspective.d.ts +38 -38
  75. package/lib/src/perspectives/Perspective.js +144 -144
  76. package/lib/src/perspectives/Perspective.test.d.ts +1 -1
  77. package/lib/src/perspectives/Perspective.test.js +20 -20
  78. package/lib/src/perspectives/PerspectiveClient.d.ts +55 -54
  79. package/lib/src/perspectives/PerspectiveClient.js +418 -410
  80. package/lib/src/perspectives/PerspectiveDiff.d.ts +9 -9
  81. package/lib/src/perspectives/PerspectiveDiff.js +33 -33
  82. package/lib/src/perspectives/PerspectiveHandle.d.ts +16 -16
  83. package/lib/src/perspectives/PerspectiveHandle.js +59 -59
  84. package/lib/src/perspectives/PerspectiveProxy.d.ts +178 -178
  85. package/lib/src/perspectives/PerspectiveProxy.js +501 -540
  86. package/lib/src/perspectives/PerspectiveResolver.d.ts +38 -37
  87. package/lib/src/perspectives/PerspectiveResolver.js +376 -362
  88. package/lib/src/runtime/RuntimeClient.d.ts +33 -33
  89. package/lib/src/runtime/RuntimeClient.js +263 -263
  90. package/lib/src/runtime/RuntimeResolver.d.ts +47 -47
  91. package/lib/src/runtime/RuntimeResolver.js +328 -328
  92. package/lib/src/schema.gql +1 -0
  93. package/lib/src/subject/SDNADecorators.d.ts +45 -45
  94. package/lib/src/subject/SDNADecorators.js +250 -250
  95. package/lib/src/subject/Subject.d.ts +7 -7
  96. package/lib/src/subject/Subject.js +160 -160
  97. package/lib/src/subject/SubjectEntity.d.ts +31 -31
  98. package/lib/src/subject/SubjectEntity.js +250 -250
  99. package/lib/src/subject/util.d.ts +12 -12
  100. package/lib/src/subject/util.js +73 -73
  101. package/lib/src/typeDefs.d.ts +1 -1
  102. package/lib/src/typeDefs.js +1 -0
  103. package/lib/src/unwrapApolloResult.d.ts +2 -2
  104. package/lib/src/unwrapApolloResult.js +14 -12
  105. package/lib/src/utils.d.ts +2 -2
  106. package/lib/src/utils.js +21 -21
  107. package/package.json +61 -61
  108. package/rollup.config.js +26 -26
  109. package/shims/type-graphql.ts +75 -75
  110. package/src/Ad4mClient.test.ts +1089 -1084
  111. package/src/Ad4mClient.ts +62 -62
  112. package/src/Address.ts +1 -1
  113. package/src/Exception.ts +6 -6
  114. package/src/Literal.test.ts +30 -30
  115. package/src/Literal.ts +80 -80
  116. package/src/PubSub.ts +13 -13
  117. package/src/SmartLiteral.ts +74 -74
  118. package/src/agent/Agent.ts +293 -293
  119. package/src/agent/AgentClient.ts +531 -531
  120. package/src/agent/AgentResolver.ts +263 -263
  121. package/src/agent/AgentStatus.ts +43 -43
  122. package/src/buildSchema.ts +41 -41
  123. package/src/expression/Expression.ts +99 -99
  124. package/src/expression/ExpressionClient.ts +98 -98
  125. package/src/expression/ExpressionRef.ts +62 -62
  126. package/src/expression/ExpressionResolver.ts +63 -63
  127. package/src/index.ts +30 -30
  128. package/src/language/Icon.ts +10 -10
  129. package/src/language/Language.ts +266 -266
  130. package/src/language/LanguageClient.ts +159 -159
  131. package/src/language/LanguageContext.ts +37 -37
  132. package/src/language/LanguageHandle.ts +23 -23
  133. package/src/language/LanguageMeta.ts +69 -69
  134. package/src/language/LanguageRef.ts +18 -18
  135. package/src/language/LanguageResolver.ts +98 -98
  136. package/src/links/Links.test.ts +39 -39
  137. package/src/links/Links.ts +107 -107
  138. package/src/neighbourhood/Neighbourhood.ts +22 -22
  139. package/src/neighbourhood/NeighbourhoodClient.ts +275 -275
  140. package/src/neighbourhood/NeighbourhoodProxy.ts +58 -58
  141. package/src/neighbourhood/NeighbourhoodResolver.ts +99 -99
  142. package/src/perspectives/LinkQuery.ts +65 -65
  143. package/src/perspectives/Perspective.test.ts +22 -22
  144. package/src/perspectives/Perspective.ts +118 -118
  145. package/src/perspectives/PerspectiveClient.ts +452 -443
  146. package/src/perspectives/PerspectiveDiff.ts +15 -15
  147. package/src/perspectives/PerspectiveHandle.ts +39 -39
  148. package/src/perspectives/PerspectiveProxy.ts +576 -610
  149. package/src/perspectives/PerspectiveResolver.ts +224 -219
  150. package/src/runtime/RuntimeClient.ts +282 -282
  151. package/src/runtime/RuntimeResolver.ts +192 -192
  152. package/src/subject/SDNADecorators.ts +333 -333
  153. package/src/subject/Subject.ts +152 -152
  154. package/src/subject/SubjectEntity.ts +291 -291
  155. package/src/subject/util.ts +84 -84
  156. package/src/typeDefs.ts +5 -5
  157. package/src/unwrapApolloResult.ts +15 -13
  158. package/src/utils.ts +25 -25
  159. package/tsconfig-browser.json +82 -82
  160. package/tsconfig.json +80 -80
  161. package/yarn-error.log +0 -22814
@@ -1,410 +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
- // ExpressionClient functions, needed for Subjects:
262
- async getExpression(expressionURI) {
263
- return await __classPrivateFieldGet(this, _PerspectiveClient_expressionClient, "f").get(expressionURI);
264
- }
265
- async createExpression(content, languageAddress) {
266
- return await __classPrivateFieldGet(this, _PerspectiveClient_expressionClient, "f").create(content, languageAddress);
267
- }
268
- // Subscriptions:
269
- addPerspectiveAddedListener(cb) {
270
- __classPrivateFieldGet(this, _PerspectiveClient_perspectiveAddedCallbacks, "f").push(cb);
271
- }
272
- subscribePerspectiveAdded() {
273
- __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").subscribe({
274
- query: gql ` subscription {
275
- perspectiveAdded { ${PERSPECTIVE_HANDLE_FIELDS} }
276
- }
277
- `
278
- }).subscribe({
279
- next: result => {
280
- __classPrivateFieldGet(this, _PerspectiveClient_perspectiveAddedCallbacks, "f").forEach(cb => {
281
- cb(result.data.perspectiveAdded);
282
- });
283
- },
284
- error: (e) => console.error(e)
285
- });
286
- }
287
- addPerspectiveUpdatedListener(cb) {
288
- __classPrivateFieldGet(this, _PerspectiveClient_perspectiveUpdatedCallbacks, "f").push(cb);
289
- }
290
- subscribePerspectiveUpdated() {
291
- __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").subscribe({
292
- query: gql ` subscription {
293
- perspectiveUpdated { ${PERSPECTIVE_HANDLE_FIELDS} }
294
- }
295
- `
296
- }).subscribe({
297
- next: result => {
298
- __classPrivateFieldGet(this, _PerspectiveClient_perspectiveUpdatedCallbacks, "f").forEach(cb => {
299
- cb(result.data.perspectiveUpdated);
300
- });
301
- },
302
- error: (e) => console.error(e)
303
- });
304
- }
305
- addPerspectiveSyncedListener(cb) {
306
- __classPrivateFieldGet(this, _PerspectiveClient_perspectiveSyncStateChangeCallbacks, "f").push(cb);
307
- }
308
- async addPerspectiveSyncStateChangeListener(uuid, cb) {
309
- __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").subscribe({
310
- query: gql ` subscription {
311
- perspectiveSyncStateChange(uuid: "${uuid}")
312
- }
313
- `
314
- }).subscribe({
315
- next: result => {
316
- cb.forEach(c => {
317
- c(result.data.perspectiveSyncStateChange);
318
- });
319
- },
320
- error: (e) => console.error(e)
321
- });
322
- await new Promise(resolve => setTimeout(resolve, 500));
323
- }
324
- addPerspectiveRemovedListener(cb) {
325
- __classPrivateFieldGet(this, _PerspectiveClient_perspectiveRemovedCallbacks, "f").push(cb);
326
- }
327
- subscribePerspectiveRemoved() {
328
- __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").subscribe({
329
- query: gql ` subscription {
330
- perspectiveRemoved
331
- }
332
- `
333
- }).subscribe({
334
- next: result => {
335
- __classPrivateFieldGet(this, _PerspectiveClient_perspectiveRemovedCallbacks, "f").forEach(cb => {
336
- cb(result.data.perspectiveRemoved);
337
- });
338
- },
339
- error: (e) => console.error(e)
340
- });
341
- }
342
- async addPerspectiveLinkAddedListener(uuid, cb) {
343
- __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").subscribe({
344
- query: gql ` subscription {
345
- perspectiveLinkAdded(uuid: "${uuid}") { ${LINK_EXPRESSION_FIELDS} }
346
- }
347
- `
348
- }).subscribe({
349
- next: result => {
350
- cb.forEach(c => {
351
- c(result.data.perspectiveLinkAdded);
352
- });
353
- },
354
- error: (e) => console.error(e)
355
- });
356
- await new Promise(resolve => setTimeout(resolve, 500));
357
- }
358
- async addPerspectiveLinkRemovedListener(uuid, cb) {
359
- __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").subscribe({
360
- query: gql ` subscription {
361
- perspectiveLinkRemoved(uuid: "${uuid}") { ${LINK_EXPRESSION_FIELDS} }
362
- }
363
- `
364
- }).subscribe({
365
- next: result => {
366
- cb.forEach(c => {
367
- if (!result.data.perspectiveLinkRemoved.status) {
368
- delete result.data.perspectiveLinkRemoved.status;
369
- }
370
- c(result.data.perspectiveLinkRemoved);
371
- });
372
- },
373
- error: (e) => console.error(e)
374
- });
375
- await new Promise(resolve => setTimeout(resolve, 500));
376
- }
377
- async addPerspectiveLinkUpdatedListener(uuid, cb) {
378
- __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").subscribe({
379
- query: gql ` subscription {
380
- perspectiveLinkUpdated(uuid: "${uuid}") {
381
- oldLink {
382
- ${LINK_EXPRESSION_FIELDS}
383
- }
384
- newLink {
385
- ${LINK_EXPRESSION_FIELDS}
386
- }
387
- }
388
- }
389
- `
390
- }).subscribe({
391
- next: result => {
392
- cb.forEach(c => {
393
- if (!result.data.perspectiveLinkUpdated.newLink.status) {
394
- delete result.data.perspectiveLinkUpdated.newLink.status;
395
- }
396
- if (!result.data.perspectiveLinkUpdated.oldLink.status) {
397
- delete result.data.perspectiveLinkUpdated.oldLink.status;
398
- }
399
- c(result.data.perspectiveLinkUpdated);
400
- });
401
- },
402
- error: (e) => console.error(e)
403
- });
404
- await new Promise(resolve => setTimeout(resolve, 500));
405
- }
406
- getNeighbourhoodProxy(uuid) {
407
- return new NeighbourhoodProxy(__classPrivateFieldGet(this, _PerspectiveClient_neighbourhoodClient, "f"), uuid);
408
- }
409
- }
410
- _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();
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();