@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,256 +1,256 @@
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 _NeighbourhoodClient_apolloClient, _NeighbourhoodClient_signalHandlers;
13
- import { gql } from "@apollo/client/core";
14
- import unwrapApolloResult from "../unwrapApolloResult";
15
- export class NeighbourhoodClient {
16
- constructor(client) {
17
- _NeighbourhoodClient_apolloClient.set(this, void 0);
18
- _NeighbourhoodClient_signalHandlers.set(this, new Map());
19
- __classPrivateFieldSet(this, _NeighbourhoodClient_apolloClient, client, "f");
20
- }
21
- async publishFromPerspective(perspectiveUUID, linkLanguage, meta) {
22
- const { neighbourhoodPublishFromPerspective } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
23
- mutation: gql `mutation neighbourhoodPublishFromPerspective(
24
- $linkLanguage: String!,
25
- $meta: PerspectiveInput!,
26
- $perspectiveUUID: String!
27
- ) {
28
- neighbourhoodPublishFromPerspective(
29
- linkLanguage: $linkLanguage,
30
- meta: $meta,
31
- perspectiveUUID: $perspectiveUUID
32
- )
33
- }`,
34
- variables: { perspectiveUUID, linkLanguage, meta: meta }
35
- }));
36
- return neighbourhoodPublishFromPerspective;
37
- }
38
- async joinFromUrl(url) {
39
- const { neighbourhoodJoinFromUrl } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
40
- mutation: gql `mutation neighbourhoodJoinFromUrl($url: String!) {
41
- neighbourhoodJoinFromUrl(url: $url) {
42
- uuid
43
- name
44
- sharedUrl
45
- state
46
- neighbourhood {
47
- data {
48
- linkLanguage
49
- meta {
50
- links
51
- {
52
- author
53
- timestamp
54
- data { source, predicate, target }
55
- proof { valid, invalid, signature, key }
56
- }
57
- }
58
- }
59
- author
60
- }
61
- }
62
- }`,
63
- variables: { url }
64
- }));
65
- return neighbourhoodJoinFromUrl;
66
- }
67
- async otherAgents(perspectiveUUID) {
68
- const { neighbourhoodOtherAgents } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").query({
69
- query: gql `query neighbourhoodOtherAgents($perspectiveUUID: String!) {
70
- neighbourhoodOtherAgents(perspectiveUUID: $perspectiveUUID)
71
- }`,
72
- variables: { perspectiveUUID }
73
- }));
74
- return neighbourhoodOtherAgents;
75
- }
76
- async hasTelepresenceAdapter(perspectiveUUID) {
77
- const { neighbourhoodHasTelepresenceAdapter } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").query({
78
- query: gql `query neighbourhoodHasTelepresenceAdapter($perspectiveUUID: String!) {
79
- neighbourhoodHasTelepresenceAdapter(perspectiveUUID: $perspectiveUUID)
80
- }`,
81
- variables: { perspectiveUUID }
82
- }));
83
- return neighbourhoodHasTelepresenceAdapter;
84
- }
85
- async onlineAgents(perspectiveUUID) {
86
- const { neighbourhoodOnlineAgents } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").query({
87
- query: gql `query neighbourhoodOnlineAgents($perspectiveUUID: String!) {
88
- neighbourhoodOnlineAgents(perspectiveUUID: $perspectiveUUID) {
89
- did
90
- status {
91
- author
92
- timestamp
93
- data {
94
- links {
95
- author
96
- timestamp
97
- data { source, predicate, target }
98
- proof { valid, invalid, signature, key }
99
- }
100
- }
101
- proof { valid, invalid, signature, key }
102
- }
103
- }
104
- }`,
105
- variables: { perspectiveUUID }
106
- }));
107
- return neighbourhoodOnlineAgents;
108
- }
109
- async setOnlineStatus(perspectiveUUID, status) {
110
- const { neighbourhoodSetOnlineStatus } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
111
- mutation: gql `mutation neighbourhoodSetOnlineStatus(
112
- $perspectiveUUID: String!,
113
- $status: PerspectiveInput!
114
- ) {
115
- neighbourhoodSetOnlineStatus(
116
- perspectiveUUID: $perspectiveUUID,
117
- status: $status
118
- )
119
- }`,
120
- variables: { perspectiveUUID, status }
121
- }));
122
- return neighbourhoodSetOnlineStatus;
123
- }
124
- async setOnlineStatusU(perspectiveUUID, status) {
125
- const { neighbourhoodSetOnlineStatusU } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
126
- mutation: gql `mutation neighbourhoodSetOnlineStatusU(
127
- $perspectiveUUID: String!,
128
- $status: PerspectiveUnsignedInput!
129
- ) {
130
- neighbourhoodSetOnlineStatusU(
131
- perspectiveUUID: $perspectiveUUID,
132
- status: $status
133
- )
134
- }`,
135
- variables: { perspectiveUUID, status }
136
- }));
137
- return neighbourhoodSetOnlineStatusU;
138
- }
139
- async sendSignal(perspectiveUUID, remoteAgentDid, payload) {
140
- const { neighbourhoodSendSignal } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
141
- mutation: gql `mutation neighbourhoodSendSignal(
142
- $perspectiveUUID: String!,
143
- $remoteAgentDid: String!,
144
- $payload: PerspectiveInput!
145
- ) {
146
- neighbourhoodSendSignal(
147
- perspectiveUUID: $perspectiveUUID,
148
- remoteAgentDid: $remoteAgentDid,
149
- payload: $payload
150
- )
151
- }`,
152
- variables: { perspectiveUUID, remoteAgentDid, payload }
153
- }));
154
- return neighbourhoodSendSignal;
155
- }
156
- async sendSignalU(perspectiveUUID, remoteAgentDid, payload) {
157
- const { neighbourhoodSendSignalU } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
158
- mutation: gql `mutation neighbourhoodSendSignalU(
159
- $perspectiveUUID: String!,
160
- $remoteAgentDid: String!,
161
- $payload: PerspectiveUnsignedInput!
162
- ) {
163
- neighbourhoodSendSignalU(
164
- perspectiveUUID: $perspectiveUUID,
165
- remoteAgentDid: $remoteAgentDid,
166
- payload: $payload
167
- )
168
- }`,
169
- variables: { perspectiveUUID, remoteAgentDid, payload }
170
- }));
171
- return neighbourhoodSendSignalU;
172
- }
173
- async sendBroadcast(perspectiveUUID, payload) {
174
- const { neighbourhoodSendBroadcast } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
175
- mutation: gql `mutation neighbourhoodSendBroadcast(
176
- $perspectiveUUID: String!,
177
- $payload: PerspectiveInput!
178
- ) {
179
- neighbourhoodSendBroadcast(
180
- perspectiveUUID: $perspectiveUUID,
181
- payload: $payload
182
- )
183
- }`,
184
- variables: { perspectiveUUID, payload }
185
- }));
186
- return neighbourhoodSendBroadcast;
187
- }
188
- async sendBroadcastU(perspectiveUUID, payload) {
189
- const { neighbourhoodSendBroadcastU } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
190
- mutation: gql `mutation neighbourhoodSendBroadcastU(
191
- $perspectiveUUID: String!,
192
- $payload: PerspectiveUnsignedInput!
193
- ) {
194
- neighbourhoodSendBroadcastU(
195
- perspectiveUUID: $perspectiveUUID,
196
- payload: $payload
197
- )
198
- }`,
199
- variables: { perspectiveUUID, payload }
200
- }));
201
- return neighbourhoodSendBroadcastU;
202
- }
203
- dispatchSignal(perspectiveUUID, signal) {
204
- const handlers = __classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
205
- if (handlers) {
206
- handlers.forEach(handler => handler(signal));
207
- }
208
- }
209
- async subscribeToSignals(perspectiveUUID) {
210
- const that = this;
211
- await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").subscribe({
212
- query: gql `subscription neighbourhoodSignal($perspectiveUUID: String!) {
213
- neighbourhoodSignal(perspectiveUUID: $perspectiveUUID) {
214
- author
215
- timestamp
216
- data {
217
- links
218
- {
219
- author
220
- timestamp
221
- data { source, predicate, target }
222
- proof { valid, invalid, signature, key }
223
- }
224
- }
225
- proof { valid, invalid, signature, key }
226
- }
227
- }`,
228
- variables: { perspectiveUUID }
229
- }).subscribe({
230
- next: (result) => {
231
- const { neighbourhoodSignal } = unwrapApolloResult(result);
232
- that.dispatchSignal(perspectiveUUID, neighbourhoodSignal);
233
- }
234
- });
235
- }
236
- async addSignalHandler(perspectiveUUID, handler) {
237
- let handlersForPerspective = __classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
238
- if (!handlersForPerspective) {
239
- handlersForPerspective = [];
240
- await this.subscribeToSignals(perspectiveUUID);
241
- }
242
- handlersForPerspective.push(handler);
243
- __classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").set(perspectiveUUID, handlersForPerspective);
244
- }
245
- removeSignalHandler(perspectiveUUID, handler) {
246
- const handlersForPerspective = __classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
247
- if (handlersForPerspective) {
248
- const index = handlersForPerspective.indexOf(handler);
249
- if (index > -1) {
250
- handlersForPerspective.splice(index, 1);
251
- }
252
- }
253
- __classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").set(perspectiveUUID, handlersForPerspective);
254
- }
255
- }
256
- _NeighbourhoodClient_apolloClient = new WeakMap(), _NeighbourhoodClient_signalHandlers = 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 _NeighbourhoodClient_apolloClient, _NeighbourhoodClient_signalHandlers;
13
+ import { gql } from "@apollo/client/core";
14
+ import unwrapApolloResult from "../unwrapApolloResult";
15
+ export class NeighbourhoodClient {
16
+ constructor(client) {
17
+ _NeighbourhoodClient_apolloClient.set(this, void 0);
18
+ _NeighbourhoodClient_signalHandlers.set(this, new Map());
19
+ __classPrivateFieldSet(this, _NeighbourhoodClient_apolloClient, client, "f");
20
+ }
21
+ async publishFromPerspective(perspectiveUUID, linkLanguage, meta) {
22
+ const { neighbourhoodPublishFromPerspective } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
23
+ mutation: gql `mutation neighbourhoodPublishFromPerspective(
24
+ $linkLanguage: String!,
25
+ $meta: PerspectiveInput!,
26
+ $perspectiveUUID: String!
27
+ ) {
28
+ neighbourhoodPublishFromPerspective(
29
+ linkLanguage: $linkLanguage,
30
+ meta: $meta,
31
+ perspectiveUUID: $perspectiveUUID
32
+ )
33
+ }`,
34
+ variables: { perspectiveUUID, linkLanguage, meta: meta }
35
+ }));
36
+ return neighbourhoodPublishFromPerspective;
37
+ }
38
+ async joinFromUrl(url) {
39
+ const { neighbourhoodJoinFromUrl } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
40
+ mutation: gql `mutation neighbourhoodJoinFromUrl($url: String!) {
41
+ neighbourhoodJoinFromUrl(url: $url) {
42
+ uuid
43
+ name
44
+ sharedUrl
45
+ state
46
+ neighbourhood {
47
+ data {
48
+ linkLanguage
49
+ meta {
50
+ links
51
+ {
52
+ author
53
+ timestamp
54
+ data { source, predicate, target }
55
+ proof { valid, invalid, signature, key }
56
+ }
57
+ }
58
+ }
59
+ author
60
+ }
61
+ }
62
+ }`,
63
+ variables: { url }
64
+ }));
65
+ return neighbourhoodJoinFromUrl;
66
+ }
67
+ async otherAgents(perspectiveUUID) {
68
+ const { neighbourhoodOtherAgents } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").query({
69
+ query: gql `query neighbourhoodOtherAgents($perspectiveUUID: String!) {
70
+ neighbourhoodOtherAgents(perspectiveUUID: $perspectiveUUID)
71
+ }`,
72
+ variables: { perspectiveUUID }
73
+ }));
74
+ return neighbourhoodOtherAgents;
75
+ }
76
+ async hasTelepresenceAdapter(perspectiveUUID) {
77
+ const { neighbourhoodHasTelepresenceAdapter } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").query({
78
+ query: gql `query neighbourhoodHasTelepresenceAdapter($perspectiveUUID: String!) {
79
+ neighbourhoodHasTelepresenceAdapter(perspectiveUUID: $perspectiveUUID)
80
+ }`,
81
+ variables: { perspectiveUUID }
82
+ }));
83
+ return neighbourhoodHasTelepresenceAdapter;
84
+ }
85
+ async onlineAgents(perspectiveUUID) {
86
+ const { neighbourhoodOnlineAgents } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").query({
87
+ query: gql `query neighbourhoodOnlineAgents($perspectiveUUID: String!) {
88
+ neighbourhoodOnlineAgents(perspectiveUUID: $perspectiveUUID) {
89
+ did
90
+ status {
91
+ author
92
+ timestamp
93
+ data {
94
+ links {
95
+ author
96
+ timestamp
97
+ data { source, predicate, target }
98
+ proof { valid, invalid, signature, key }
99
+ }
100
+ }
101
+ proof { valid, invalid, signature, key }
102
+ }
103
+ }
104
+ }`,
105
+ variables: { perspectiveUUID }
106
+ }));
107
+ return neighbourhoodOnlineAgents;
108
+ }
109
+ async setOnlineStatus(perspectiveUUID, status) {
110
+ const { neighbourhoodSetOnlineStatus } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
111
+ mutation: gql `mutation neighbourhoodSetOnlineStatus(
112
+ $perspectiveUUID: String!,
113
+ $status: PerspectiveInput!
114
+ ) {
115
+ neighbourhoodSetOnlineStatus(
116
+ perspectiveUUID: $perspectiveUUID,
117
+ status: $status
118
+ )
119
+ }`,
120
+ variables: { perspectiveUUID, status }
121
+ }));
122
+ return neighbourhoodSetOnlineStatus;
123
+ }
124
+ async setOnlineStatusU(perspectiveUUID, status) {
125
+ const { neighbourhoodSetOnlineStatusU } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
126
+ mutation: gql `mutation neighbourhoodSetOnlineStatusU(
127
+ $perspectiveUUID: String!,
128
+ $status: PerspectiveUnsignedInput!
129
+ ) {
130
+ neighbourhoodSetOnlineStatusU(
131
+ perspectiveUUID: $perspectiveUUID,
132
+ status: $status
133
+ )
134
+ }`,
135
+ variables: { perspectiveUUID, status }
136
+ }));
137
+ return neighbourhoodSetOnlineStatusU;
138
+ }
139
+ async sendSignal(perspectiveUUID, remoteAgentDid, payload) {
140
+ const { neighbourhoodSendSignal } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
141
+ mutation: gql `mutation neighbourhoodSendSignal(
142
+ $perspectiveUUID: String!,
143
+ $remoteAgentDid: String!,
144
+ $payload: PerspectiveInput!
145
+ ) {
146
+ neighbourhoodSendSignal(
147
+ perspectiveUUID: $perspectiveUUID,
148
+ remoteAgentDid: $remoteAgentDid,
149
+ payload: $payload
150
+ )
151
+ }`,
152
+ variables: { perspectiveUUID, remoteAgentDid, payload }
153
+ }));
154
+ return neighbourhoodSendSignal;
155
+ }
156
+ async sendSignalU(perspectiveUUID, remoteAgentDid, payload) {
157
+ const { neighbourhoodSendSignalU } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
158
+ mutation: gql `mutation neighbourhoodSendSignalU(
159
+ $perspectiveUUID: String!,
160
+ $remoteAgentDid: String!,
161
+ $payload: PerspectiveUnsignedInput!
162
+ ) {
163
+ neighbourhoodSendSignalU(
164
+ perspectiveUUID: $perspectiveUUID,
165
+ remoteAgentDid: $remoteAgentDid,
166
+ payload: $payload
167
+ )
168
+ }`,
169
+ variables: { perspectiveUUID, remoteAgentDid, payload }
170
+ }));
171
+ return neighbourhoodSendSignalU;
172
+ }
173
+ async sendBroadcast(perspectiveUUID, payload) {
174
+ const { neighbourhoodSendBroadcast } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
175
+ mutation: gql `mutation neighbourhoodSendBroadcast(
176
+ $perspectiveUUID: String!,
177
+ $payload: PerspectiveInput!
178
+ ) {
179
+ neighbourhoodSendBroadcast(
180
+ perspectiveUUID: $perspectiveUUID,
181
+ payload: $payload
182
+ )
183
+ }`,
184
+ variables: { perspectiveUUID, payload }
185
+ }));
186
+ return neighbourhoodSendBroadcast;
187
+ }
188
+ async sendBroadcastU(perspectiveUUID, payload) {
189
+ const { neighbourhoodSendBroadcastU } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
190
+ mutation: gql `mutation neighbourhoodSendBroadcastU(
191
+ $perspectiveUUID: String!,
192
+ $payload: PerspectiveUnsignedInput!
193
+ ) {
194
+ neighbourhoodSendBroadcastU(
195
+ perspectiveUUID: $perspectiveUUID,
196
+ payload: $payload
197
+ )
198
+ }`,
199
+ variables: { perspectiveUUID, payload }
200
+ }));
201
+ return neighbourhoodSendBroadcastU;
202
+ }
203
+ dispatchSignal(perspectiveUUID, signal) {
204
+ const handlers = __classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
205
+ if (handlers) {
206
+ handlers.forEach(handler => handler(signal));
207
+ }
208
+ }
209
+ async subscribeToSignals(perspectiveUUID) {
210
+ const that = this;
211
+ await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").subscribe({
212
+ query: gql `subscription neighbourhoodSignal($perspectiveUUID: String!) {
213
+ neighbourhoodSignal(perspectiveUUID: $perspectiveUUID) {
214
+ author
215
+ timestamp
216
+ data {
217
+ links
218
+ {
219
+ author
220
+ timestamp
221
+ data { source, predicate, target }
222
+ proof { valid, invalid, signature, key }
223
+ }
224
+ }
225
+ proof { valid, invalid, signature, key }
226
+ }
227
+ }`,
228
+ variables: { perspectiveUUID }
229
+ }).subscribe({
230
+ next: (result) => {
231
+ const { neighbourhoodSignal } = unwrapApolloResult(result);
232
+ that.dispatchSignal(perspectiveUUID, neighbourhoodSignal);
233
+ }
234
+ });
235
+ }
236
+ async addSignalHandler(perspectiveUUID, handler) {
237
+ let handlersForPerspective = __classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
238
+ if (!handlersForPerspective) {
239
+ handlersForPerspective = [];
240
+ await this.subscribeToSignals(perspectiveUUID);
241
+ }
242
+ handlersForPerspective.push(handler);
243
+ __classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").set(perspectiveUUID, handlersForPerspective);
244
+ }
245
+ removeSignalHandler(perspectiveUUID, handler) {
246
+ const handlersForPerspective = __classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
247
+ if (handlersForPerspective) {
248
+ const index = handlersForPerspective.indexOf(handler);
249
+ if (index > -1) {
250
+ handlersForPerspective.splice(index, 1);
251
+ }
252
+ }
253
+ __classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").set(perspectiveUUID, handlersForPerspective);
254
+ }
255
+ }
256
+ _NeighbourhoodClient_apolloClient = new WeakMap(), _NeighbourhoodClient_signalHandlers = new WeakMap();
@@ -1,19 +1,19 @@
1
- import { DID } from "../DID";
2
- import { OnlineAgent } from "../language/Language";
3
- import { Perspective, PerspectiveExpression, PerspectiveUnsignedInput } from "../perspectives/Perspective";
4
- import { NeighbourhoodClient } from "./NeighbourhoodClient";
5
- export declare class NeighbourhoodProxy {
6
- #private;
7
- constructor(client: NeighbourhoodClient, pID: string);
8
- otherAgents(): Promise<DID[]>;
9
- hasTelepresenceAdapter(): Promise<boolean>;
10
- onlineAgents(): Promise<OnlineAgent[]>;
11
- setOnlineStatus(status: Perspective): Promise<boolean>;
12
- setOnlineStatusU(status: PerspectiveUnsignedInput): Promise<boolean>;
13
- sendSignal(remoteAgentDid: string, payload: Perspective): Promise<boolean>;
14
- sendSignalU(remoteAgentDid: string, payload: PerspectiveUnsignedInput): Promise<boolean>;
15
- sendBroadcast(payload: Perspective): Promise<boolean>;
16
- sendBroadcastU(payload: PerspectiveUnsignedInput): Promise<boolean>;
17
- addSignalHandler(handler: (payload: PerspectiveExpression) => void): Promise<void>;
18
- removeSignalHandler(handler: (payload: PerspectiveExpression) => void): void;
19
- }
1
+ import { DID } from "../DID";
2
+ import { OnlineAgent } from "../language/Language";
3
+ import { Perspective, PerspectiveExpression, PerspectiveUnsignedInput } from "../perspectives/Perspective";
4
+ import { NeighbourhoodClient } from "./NeighbourhoodClient";
5
+ export declare class NeighbourhoodProxy {
6
+ #private;
7
+ constructor(client: NeighbourhoodClient, pID: string);
8
+ otherAgents(): Promise<DID[]>;
9
+ hasTelepresenceAdapter(): Promise<boolean>;
10
+ onlineAgents(): Promise<OnlineAgent[]>;
11
+ setOnlineStatus(status: Perspective): Promise<boolean>;
12
+ setOnlineStatusU(status: PerspectiveUnsignedInput): Promise<boolean>;
13
+ sendSignal(remoteAgentDid: string, payload: Perspective): Promise<boolean>;
14
+ sendSignalU(remoteAgentDid: string, payload: PerspectiveUnsignedInput): Promise<boolean>;
15
+ sendBroadcast(payload: Perspective): Promise<boolean>;
16
+ sendBroadcastU(payload: PerspectiveUnsignedInput): Promise<boolean>;
17
+ addSignalHandler(handler: (payload: PerspectiveExpression) => void): Promise<void>;
18
+ removeSignalHandler(handler: (payload: PerspectiveExpression) => void): void;
19
+ }