@coasys/ad4m 0.8.0-fix

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 (167) hide show
  1. package/README.md +229 -0
  2. package/jest-setup.ts +1 -0
  3. package/jest.config.js +6 -0
  4. package/jsdoc.json +28 -0
  5. package/lib/index.cjs +8165 -0
  6. package/lib/index.js +8130 -0
  7. package/lib/shims/reflect-metadata.d.ts +0 -0
  8. package/lib/shims/reflect-metadata.js +0 -0
  9. package/lib/shims/type-graphql.d.ts +32 -0
  10. package/lib/shims/type-graphql.js +70 -0
  11. package/lib/src/Ad4mClient.d.ts +26 -0
  12. package/lib/src/Ad4mClient.js +66 -0
  13. package/lib/src/Address.d.ts +1 -0
  14. package/lib/src/Address.js +1 -0
  15. package/lib/src/DID.d.ts +1 -0
  16. package/lib/src/DID.js +1 -0
  17. package/lib/src/Exception.d.ts +6 -0
  18. package/lib/src/Exception.js +7 -0
  19. package/lib/src/Literal.d.ts +7 -0
  20. package/lib/src/Literal.js +76 -0
  21. package/lib/src/PubSub.d.ts +14 -0
  22. package/lib/src/PubSub.js +14 -0
  23. package/lib/src/SmartLiteral.d.ts +12 -0
  24. package/lib/src/SmartLiteral.js +74 -0
  25. package/lib/src/agent/Agent.d.ts +104 -0
  26. package/lib/src/agent/Agent.js +337 -0
  27. package/lib/src/agent/AgentClient.d.ts +57 -0
  28. package/lib/src/agent/AgentClient.js +431 -0
  29. package/lib/src/agent/AgentResolver.d.ts +30 -0
  30. package/lib/src/agent/AgentResolver.js +325 -0
  31. package/lib/src/agent/AgentStatus.d.ts +8 -0
  32. package/lib/src/agent/AgentStatus.js +61 -0
  33. package/lib/src/buildSchema.d.ts +1 -0
  34. package/lib/src/buildSchema.js +36 -0
  35. package/lib/src/expression/Expression.d.ts +28 -0
  36. package/lib/src/expression/Expression.js +143 -0
  37. package/lib/src/expression/ExpressionClient.d.ts +13 -0
  38. package/lib/src/expression/ExpressionClient.js +102 -0
  39. package/lib/src/expression/ExpressionRef.d.ts +9 -0
  40. package/lib/src/expression/ExpressionRef.js +67 -0
  41. package/lib/src/expression/ExpressionResolver.d.ts +10 -0
  42. package/lib/src/expression/ExpressionResolver.js +106 -0
  43. package/lib/src/index.d.ts +30 -0
  44. package/lib/src/index.js +30 -0
  45. package/lib/src/jestSetup.d.ts +1 -0
  46. package/lib/src/jestSetup.js +1 -0
  47. package/lib/src/language/Icon.d.ts +4 -0
  48. package/lib/src/language/Icon.js +24 -0
  49. package/lib/src/language/Language.d.ts +195 -0
  50. package/lib/src/language/Language.js +79 -0
  51. package/lib/src/language/LanguageClient.d.ts +17 -0
  52. package/lib/src/language/LanguageClient.js +137 -0
  53. package/lib/src/language/LanguageContext.d.ts +37 -0
  54. package/lib/src/language/LanguageContext.js +2 -0
  55. package/lib/src/language/LanguageHandle.d.ts +9 -0
  56. package/lib/src/language/LanguageHandle.js +41 -0
  57. package/lib/src/language/LanguageMeta.d.ts +35 -0
  58. package/lib/src/language/LanguageMeta.js +89 -0
  59. package/lib/src/language/LanguageRef.d.ts +6 -0
  60. package/lib/src/language/LanguageRef.js +30 -0
  61. package/lib/src/language/LanguageResolver.d.ts +19 -0
  62. package/lib/src/language/LanguageResolver.js +143 -0
  63. package/lib/src/links/Links.d.ts +39 -0
  64. package/lib/src/links/Links.js +148 -0
  65. package/lib/src/links/Links.test.d.ts +1 -0
  66. package/lib/src/links/Links.test.js +33 -0
  67. package/lib/src/neighbourhood/Neighbourhood.d.ts +10 -0
  68. package/lib/src/neighbourhood/Neighbourhood.js +38 -0
  69. package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +25 -0
  70. package/lib/src/neighbourhood/NeighbourhoodClient.js +256 -0
  71. package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +19 -0
  72. package/lib/src/neighbourhood/NeighbourhoodProxy.js +54 -0
  73. package/lib/src/neighbourhood/NeighbourhoodResolver.d.ts +24 -0
  74. package/lib/src/neighbourhood/NeighbourhoodResolver.js +180 -0
  75. package/lib/src/perspectives/LinkQuery.d.ts +11 -0
  76. package/lib/src/perspectives/LinkQuery.js +80 -0
  77. package/lib/src/perspectives/Perspective.d.ts +38 -0
  78. package/lib/src/perspectives/Perspective.js +144 -0
  79. package/lib/src/perspectives/Perspective.test.d.ts +1 -0
  80. package/lib/src/perspectives/Perspective.test.js +20 -0
  81. package/lib/src/perspectives/PerspectiveClient.d.ts +54 -0
  82. package/lib/src/perspectives/PerspectiveClient.js +410 -0
  83. package/lib/src/perspectives/PerspectiveDiff.d.ts +9 -0
  84. package/lib/src/perspectives/PerspectiveDiff.js +33 -0
  85. package/lib/src/perspectives/PerspectiveHandle.d.ts +16 -0
  86. package/lib/src/perspectives/PerspectiveHandle.js +59 -0
  87. package/lib/src/perspectives/PerspectiveProxy.d.ts +178 -0
  88. package/lib/src/perspectives/PerspectiveProxy.js +540 -0
  89. package/lib/src/perspectives/PerspectiveResolver.d.ts +37 -0
  90. package/lib/src/perspectives/PerspectiveResolver.js +362 -0
  91. package/lib/src/runtime/RuntimeClient.d.ts +33 -0
  92. package/lib/src/runtime/RuntimeClient.js +263 -0
  93. package/lib/src/runtime/RuntimeResolver.d.ts +47 -0
  94. package/lib/src/runtime/RuntimeResolver.js +328 -0
  95. package/lib/src/schema.gql +382 -0
  96. package/lib/src/subject/SDNADecorators.d.ts +45 -0
  97. package/lib/src/subject/SDNADecorators.js +250 -0
  98. package/lib/src/subject/Subject.d.ts +7 -0
  99. package/lib/src/subject/Subject.js +160 -0
  100. package/lib/src/subject/SubjectEntity.d.ts +31 -0
  101. package/lib/src/subject/SubjectEntity.js +250 -0
  102. package/lib/src/subject/util.d.ts +12 -0
  103. package/lib/src/subject/util.js +73 -0
  104. package/lib/src/typeDefs.d.ts +1 -0
  105. package/lib/src/typeDefs.js +379 -0
  106. package/lib/src/unwrapApolloResult.d.ts +2 -0
  107. package/lib/src/unwrapApolloResult.js +12 -0
  108. package/lib/src/utils.d.ts +2 -0
  109. package/lib/src/utils.js +21 -0
  110. package/package.json +61 -0
  111. package/rollup.config.js +27 -0
  112. package/shims/reflect-metadata.ts +0 -0
  113. package/shims/type-graphql.ts +75 -0
  114. package/src/Ad4mClient.test.ts +1085 -0
  115. package/src/Ad4mClient.ts +63 -0
  116. package/src/Address.ts +1 -0
  117. package/src/DID.ts +1 -0
  118. package/src/Exception.ts +6 -0
  119. package/src/Literal.test.ts +31 -0
  120. package/src/Literal.ts +81 -0
  121. package/src/PubSub.ts +14 -0
  122. package/src/SmartLiteral.ts +75 -0
  123. package/src/agent/Agent.ts +293 -0
  124. package/src/agent/AgentClient.ts +531 -0
  125. package/src/agent/AgentResolver.ts +263 -0
  126. package/src/agent/AgentStatus.ts +44 -0
  127. package/src/buildSchema.ts +41 -0
  128. package/src/expression/Expression.ts +99 -0
  129. package/src/expression/ExpressionClient.ts +99 -0
  130. package/src/expression/ExpressionRef.ts +63 -0
  131. package/src/expression/ExpressionResolver.ts +64 -0
  132. package/src/index.ts +30 -0
  133. package/src/jestSetup.ts +1 -0
  134. package/src/language/Icon.ts +11 -0
  135. package/src/language/Language.ts +266 -0
  136. package/src/language/LanguageClient.ts +160 -0
  137. package/src/language/LanguageContext.ts +37 -0
  138. package/src/language/LanguageHandle.ts +23 -0
  139. package/src/language/LanguageMeta.ts +70 -0
  140. package/src/language/LanguageRef.ts +18 -0
  141. package/src/language/LanguageResolver.ts +98 -0
  142. package/src/links/Links.test.ts +40 -0
  143. package/src/links/Links.ts +107 -0
  144. package/src/neighbourhood/Neighbourhood.ts +22 -0
  145. package/src/neighbourhood/NeighbourhoodClient.ts +276 -0
  146. package/src/neighbourhood/NeighbourhoodProxy.ts +58 -0
  147. package/src/neighbourhood/NeighbourhoodResolver.ts +100 -0
  148. package/src/perspectives/LinkQuery.ts +66 -0
  149. package/src/perspectives/Perspective.test.ts +23 -0
  150. package/src/perspectives/Perspective.ts +118 -0
  151. package/src/perspectives/PerspectiveClient.ts +444 -0
  152. package/src/perspectives/PerspectiveDiff.ts +15 -0
  153. package/src/perspectives/PerspectiveHandle.ts +39 -0
  154. package/src/perspectives/PerspectiveProxy.ts +611 -0
  155. package/src/perspectives/PerspectiveResolver.ts +220 -0
  156. package/src/runtime/RuntimeClient.ts +283 -0
  157. package/src/runtime/RuntimeResolver.ts +193 -0
  158. package/src/subject/SDNADecorators.ts +334 -0
  159. package/src/subject/Subject.ts +153 -0
  160. package/src/subject/SubjectEntity.ts +292 -0
  161. package/src/subject/util.ts +85 -0
  162. package/src/typeDefs.ts +6 -0
  163. package/src/unwrapApolloResult.ts +14 -0
  164. package/src/utils.ts +25 -0
  165. package/tsconfig-browser.json +82 -0
  166. package/tsconfig.json +80 -0
  167. package/yarn-error.log +22814 -0
@@ -0,0 +1,410 @@
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();
@@ -0,0 +1,9 @@
1
+ import { LinkExpression } from "../links/Links";
2
+ export declare class PerspectiveDiff {
3
+ additions: LinkExpression[];
4
+ removals: LinkExpression[];
5
+ }
6
+ declare const PerspectiveDiffExpression_base: any;
7
+ export declare class PerspectiveDiffExpression extends PerspectiveDiffExpression_base {
8
+ }
9
+ export {};
@@ -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,16 @@
1
+ import { NeighbourhoodExpression } from "../neighbourhood/Neighbourhood";
2
+ export declare enum PerspectiveState {
3
+ Private = "Private",
4
+ NeighbourhoodJoinInitiated = "NeighbourhoodJoinInitiated",
5
+ LinkLanguageFailedToInstall = "LinkLanguageFailedToInstall",
6
+ LinkLanguageInstalledButNotSynced = "LinkLanguageInstalledButNotSynced",
7
+ Synced = "Synced"
8
+ }
9
+ export declare class PerspectiveHandle {
10
+ uuid: string;
11
+ name: string;
12
+ state: PerspectiveState;
13
+ sharedUrl?: string;
14
+ neighbourhood?: NeighbourhoodExpression;
15
+ constructor(uuid?: string, name?: string, state?: PerspectiveState);
16
+ }
@@ -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 };