@coasys/ad4m 0.12.0-rc1-dev.2 → 0.12.0-rc1-dev.4

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 (153) hide show
  1. package/jest.config.js +10 -3
  2. package/lib/index.cjs +6893 -5884
  3. package/lib/index.js +6889 -5872
  4. package/lib/src/Ad4mClient.d.ts +9 -16
  5. package/lib/src/Ad4mClient.js +46 -25
  6. package/lib/src/Literal.d.ts +1 -2
  7. package/lib/src/Literal.js +38 -35
  8. package/lib/src/SmartLiteral.d.ts +1 -2
  9. package/lib/src/SmartLiteral.js +30 -15
  10. package/lib/src/agent/AgentClient.d.ts +1 -4
  11. package/lib/src/agent/AgentClient.js +79 -99
  12. package/lib/src/ai/AIClient.d.ts +1 -2
  13. package/lib/src/ai/AIClient.js +224 -220
  14. package/lib/src/expression/ExpressionClient.d.ts +1 -1
  15. package/lib/src/expression/ExpressionClient.js +73 -86
  16. package/lib/src/index.d.ts +1 -1
  17. package/lib/src/index.js +1 -1
  18. package/lib/src/language/LanguageClient.d.ts +1 -1
  19. package/lib/src/language/LanguageClient.js +52 -52
  20. package/lib/src/model/Ad4mModel.d.ts +1351 -144
  21. package/lib/src/model/Ad4mModel.js +3760 -228
  22. package/lib/src/model/Ad4mModel.test.js +522 -979
  23. package/lib/src/model/Subject.d.ts +3 -3
  24. package/lib/src/model/Subject.js +25 -25
  25. package/lib/src/model/decorators.d.ts +444 -100
  26. package/lib/src/model/decorators.js +686 -321
  27. package/lib/src/model/util.d.ts +6 -6
  28. package/lib/src/model/util.js +24 -24
  29. package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +1 -5
  30. package/lib/src/neighbourhood/NeighbourhoodClient.js +179 -242
  31. package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +1 -2
  32. package/lib/src/neighbourhood/NeighbourhoodProxy.js +28 -13
  33. package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +5 -1
  34. package/lib/src/perspectives/PerspectiveClient.d.ts +9 -9
  35. package/lib/src/perspectives/PerspectiveClient.js +240 -316
  36. package/lib/src/perspectives/PerspectiveProxy.d.ts +99 -61
  37. package/lib/src/perspectives/PerspectiveProxy.js +485 -832
  38. package/lib/src/runtime/RuntimeClient.d.ts +1 -5
  39. package/lib/src/runtime/RuntimeClient.js +238 -412
  40. package/lib/src/shacl/SHACLFlow.test.js +105 -164
  41. package/lib/src/shacl/SHACLShape.d.ts +12 -17
  42. package/lib/src/shacl/SHACLShape.js +115 -128
  43. package/lib/src/shacl/SHACLShape.test.js +176 -244
  44. package/lib/src/shims/reflect-metadata.d.ts +0 -0
  45. package/lib/src/shims/type-graphql.d.ts +32 -0
  46. package/lib/src/src/Ad4mClient.d.ts +28 -0
  47. package/lib/src/src/Address.d.ts +1 -0
  48. package/lib/src/src/DID.d.ts +1 -0
  49. package/lib/src/src/Exception.d.ts +7 -0
  50. package/lib/src/src/Literal.d.ts +7 -0
  51. package/lib/src/src/PubSub.d.ts +17 -0
  52. package/lib/src/src/SmartLiteral.d.ts +12 -0
  53. package/lib/src/src/agent/Agent.d.ts +110 -0
  54. package/lib/src/src/agent/AgentClient.d.ts +62 -0
  55. package/lib/src/src/agent/AgentResolver.d.ts +30 -0
  56. package/lib/src/src/agent/AgentStatus.d.ts +8 -0
  57. package/lib/src/src/ai/AIClient.d.ts +32 -0
  58. package/lib/src/src/ai/AIResolver.d.ts +75 -0
  59. package/lib/src/src/ai/Tasks.d.ts +37 -0
  60. package/lib/src/src/buildSchema.d.ts +1 -0
  61. package/lib/src/src/expression/Expression.d.ts +28 -0
  62. package/lib/src/src/expression/ExpressionClient.d.ts +13 -0
  63. package/lib/src/src/expression/ExpressionRef.d.ts +9 -0
  64. package/lib/src/src/expression/ExpressionResolver.d.ts +10 -0
  65. package/lib/src/src/index.d.ts +35 -0
  66. package/lib/src/src/jestSetup.d.ts +1 -0
  67. package/lib/src/src/language/Icon.d.ts +4 -0
  68. package/lib/src/src/language/Language.d.ts +206 -0
  69. package/lib/src/src/language/LanguageClient.d.ts +17 -0
  70. package/lib/src/src/language/LanguageContext.d.ts +37 -0
  71. package/lib/src/src/language/LanguageHandle.d.ts +9 -0
  72. package/lib/src/src/language/LanguageMeta.d.ts +35 -0
  73. package/lib/src/src/language/LanguageRef.d.ts +6 -0
  74. package/lib/src/src/language/LanguageResolver.d.ts +19 -0
  75. package/lib/src/src/links/Links.d.ts +39 -0
  76. package/lib/src/src/links/Links.test.d.ts +1 -0
  77. package/lib/src/src/model/Ad4mModel.d.ts +1438 -0
  78. package/lib/src/src/model/Ad4mModel.test.d.ts +1 -0
  79. package/lib/src/src/model/Subject.d.ts +25 -0
  80. package/lib/src/src/model/decorators.d.ts +545 -0
  81. package/lib/src/src/model/util.d.ts +12 -0
  82. package/lib/src/src/neighbourhood/Neighbourhood.d.ts +10 -0
  83. package/lib/src/src/neighbourhood/NeighbourhoodClient.d.ts +25 -0
  84. package/lib/src/src/neighbourhood/NeighbourhoodProxy.d.ts +19 -0
  85. package/lib/src/src/neighbourhood/NeighbourhoodProxy.test.d.ts +1 -0
  86. package/lib/src/src/neighbourhood/NeighbourhoodResolver.d.ts +24 -0
  87. package/lib/src/src/perspectives/LinkQuery.d.ts +11 -0
  88. package/lib/src/src/perspectives/Perspective.d.ts +38 -0
  89. package/lib/src/src/perspectives/Perspective.test.d.ts +1 -0
  90. package/lib/src/src/perspectives/PerspectiveClient.d.ts +97 -0
  91. package/lib/src/src/perspectives/PerspectiveDiff.d.ts +9 -0
  92. package/lib/src/src/perspectives/PerspectiveHandle.d.ts +18 -0
  93. package/lib/src/src/perspectives/PerspectiveProxy.d.ts +865 -0
  94. package/lib/src/src/perspectives/PerspectiveResolver.d.ts +57 -0
  95. package/lib/src/src/runtime/RuntimeClient.d.ts +56 -0
  96. package/lib/src/src/runtime/RuntimeResolver.d.ts +132 -0
  97. package/lib/src/src/shacl/SHACLFlow.d.ts +171 -0
  98. package/lib/src/src/shacl/SHACLFlow.test.d.ts +1 -0
  99. package/lib/src/src/shacl/SHACLShape.d.ts +117 -0
  100. package/lib/src/src/shacl/SHACLShape.test.d.ts +1 -0
  101. package/lib/src/src/typeDefs.d.ts +1 -0
  102. package/lib/src/src/unwrapApolloResult.d.ts +2 -0
  103. package/lib/src/src/utils.d.ts +25 -0
  104. package/lib/src/utils.d.ts +0 -8
  105. package/lib/src/utils.js +7 -21
  106. package/package.json +15 -14
  107. package/src/Ad4mClient.test.ts +1315 -1564
  108. package/src/Ad4mClient.ts +54 -55
  109. package/src/Literal.test.ts +26 -45
  110. package/src/Literal.ts +66 -82
  111. package/src/SmartLiteral.ts +58 -74
  112. package/src/agent/AgentClient.ts +99 -144
  113. package/src/ai/AIClient.ts +359 -409
  114. package/src/expression/ExpressionClient.ts +96 -142
  115. package/src/index.ts +1 -1
  116. package/src/language/LanguageClient.ts +113 -137
  117. package/src/model/Ad4mModel.test.ts +616 -1114
  118. package/src/model/Ad4mModel.ts +4386 -451
  119. package/src/model/Subject.ts +159 -0
  120. package/src/model/decorators.ts +1168 -667
  121. package/src/model/util.ts +54 -53
  122. package/src/neighbourhood/NeighbourhoodClient.ts +266 -392
  123. package/src/neighbourhood/NeighbourhoodProxy.test.ts +7 -3
  124. package/src/neighbourhood/NeighbourhoodProxy.ts +40 -58
  125. package/src/perspectives/PerspectiveClient.ts +540 -779
  126. package/src/perspectives/PerspectiveProxy.ts +2067 -2860
  127. package/src/runtime/RuntimeClient.ts +476 -775
  128. package/src/shacl/SHACLFlow.test.ts +129 -196
  129. package/src/shacl/SHACLShape.test.ts +190 -284
  130. package/src/shacl/SHACLShape.ts +200 -224
  131. package/src/utils.ts +17 -31
  132. package/tsconfig.json +10 -9
  133. package/src/model/IMPROVEMENTS.md +0 -482
  134. package/src/model/PREDICATE_COLLISION_FIX.md +0 -651
  135. package/src/model/README.md +0 -317
  136. package/src/model/SHACL_MUTATION_DECOUPLING.md +0 -356
  137. package/src/model/SUBSCRIPTION_STRATEGY.md +0 -317
  138. package/src/model/TC39_STAGE_3_DECORATORS.md +0 -609
  139. package/src/model/mutation.ts +0 -461
  140. package/src/model/parentUtils.ts +0 -91
  141. package/src/model/prolog/generatePrologFacts.ts +0 -176
  142. package/src/model/prolog/index.ts +0 -1
  143. package/src/model/query/ModelQueryBuilder.ts +0 -173
  144. package/src/model/query/fetchInstance.ts +0 -181
  145. package/src/model/query/hydration.ts +0 -273
  146. package/src/model/query/operations.ts +0 -510
  147. package/src/model/query/snapshot.ts +0 -126
  148. package/src/model/query/surrealCompiler.ts +0 -376
  149. package/src/model/schema/fromJSONSchema.ts +0 -411
  150. package/src/model/schema/metadata.ts +0 -148
  151. package/src/model/subscription.ts +0 -307
  152. package/src/model/transaction.ts +0 -60
  153. package/src/model/types.ts +0 -207
@@ -1,20 +1,7 @@
1
- import { ApolloClient, gql } from "@apollo/client/core";
2
- import {
3
- Perspective,
4
- PerspectiveExpression,
5
- } from "../perspectives/Perspective";
6
- import unwrapApolloResult from "../unwrapApolloResult";
7
- import { isSocketCloseError } from "../utils";
8
- import {
9
- RuntimeInfo,
10
- ExceptionInfo,
11
- SentMessage,
12
- NotificationInput,
13
- Notification,
14
- TriggeredNotification,
15
- ImportResult,
16
- UserStatistics,
17
- } from "./RuntimeResolver";
1
+ import { ApolloClient, gql } from "@apollo/client/core"
2
+ import { Perspective, PerspectiveExpression } from "../perspectives/Perspective"
3
+ import unwrapApolloResult from "../unwrapApolloResult"
4
+ import { RuntimeInfo, ExceptionInfo, SentMessage, NotificationInput, Notification, TriggeredNotification, ImportResult, UserStatistics } from "./RuntimeResolver"
18
5
 
19
6
  const PERSPECTIVE_EXPRESSION_FIELDS = `
20
7
  author
@@ -28,7 +15,7 @@ data {
28
15
  }
29
16
  }
30
17
  proof { valid, invalid, signature, key }
31
- `;
18
+ `
32
19
 
33
20
  const NOTIFICATION_DEFINITION_FIELDS = `
34
21
  description
@@ -39,364 +26,253 @@ trigger
39
26
  perspectiveIds
40
27
  webhookUrl
41
28
  webhookAuth
42
- `;
29
+ `
43
30
 
44
31
  const NOTIFICATION_FIELDS = `
45
32
  id
46
33
  granted
47
34
  ${NOTIFICATION_DEFINITION_FIELDS}
48
- `;
35
+ `
49
36
 
50
37
  const TRIGGERED_NOTIFICATION_FIELDS = `
51
38
  notification { ${NOTIFICATION_FIELDS} }
52
39
  perspectiveId
53
40
  triggerMatch
54
- `;
41
+ `
55
42
 
56
- export type MessageCallback = (message: PerspectiveExpression) => null;
57
- export type ExceptionCallback = (info: ExceptionInfo) => null;
58
- export type NotificationTriggeredCallback = (
59
- notification: TriggeredNotification,
60
- ) => null;
61
- export type NotificationRequestedCallback = (
62
- notification: Notification,
63
- ) => null;
43
+ export type MessageCallback = (message: PerspectiveExpression) => null
44
+ export type ExceptionCallback = (info: ExceptionInfo) => null
45
+ export type NotificationTriggeredCallback = (notification: TriggeredNotification) => null
46
+ export type NotificationRequestedCallback = (notification: Notification) => null
64
47
 
65
48
  export class RuntimeClient {
66
- private _apolloClient: ApolloClient<any>;
67
- private _messageReceivedCallbacks: MessageCallback[];
68
- private _exceptionOccurredCallbacks: ExceptionCallback[];
69
- private _notificationTriggeredCallbacks: NotificationTriggeredCallback[];
70
- private _notificationRequestedCallbacks: NotificationRequestedCallback[];
71
-
72
- constructor(client: ApolloClient<any>, subscribe: boolean = true) {
73
- this._apolloClient = client;
74
- this._messageReceivedCallbacks = [];
75
- this._exceptionOccurredCallbacks = [];
76
- this._notificationTriggeredCallbacks = [];
77
-
78
- if (subscribe) {
79
- this.subscribeMessageReceived();
80
- this.subscribeExceptionOccurred();
81
- this.subscribeNotificationTriggered();
82
- }
83
- }
84
-
85
- async info(): Promise<RuntimeInfo> {
86
- const { runtimeInfo } = unwrapApolloResult(
87
- await this._apolloClient.query({
88
- query: gql`
89
- query runtimeInfo {
90
- runtimeInfo {
91
- ad4mExecutorVersion
92
- isInitialized
93
- isUnlocked
94
- }
95
- }
96
- `,
97
- }),
98
- );
99
- return runtimeInfo;
100
- }
101
-
102
- async quit(): Promise<Boolean> {
103
- const result = unwrapApolloResult(
104
- await this._apolloClient.mutate({
105
- mutation: gql`
106
- mutation runtimeQuit {
107
- runtimeQuit
108
- }
109
- `,
110
- }),
111
- );
112
-
113
- return result.runtimeQuit;
114
- }
115
-
116
- async openLink(url: string): Promise<Boolean> {
117
- const { runtimeOpenLink } = unwrapApolloResult(
118
- await this._apolloClient.mutate({
119
- mutation: gql`
120
- mutation runtimeOpenLink($url: String!) {
121
- runtimeOpenLink(url: $url)
122
- }
123
- `,
124
- variables: { url },
125
- }),
126
- );
127
- return runtimeOpenLink;
128
- }
129
-
130
- async addTrustedAgents(agents: string[]): Promise<string[]> {
131
- const { addTrustedAgents } = unwrapApolloResult(
132
- await this._apolloClient.mutate({
133
- mutation: gql`
134
- mutation addTrustedAgents($agents: [String!]!) {
135
- addTrustedAgents(agents: $agents)
136
- }
137
- `,
138
- variables: { agents },
139
- }),
140
- );
141
- return addTrustedAgents;
142
- }
143
-
144
- async deleteTrustedAgents(agents: string[]): Promise<string[]> {
145
- const { deleteTrustedAgents } = unwrapApolloResult(
146
- await this._apolloClient.mutate({
147
- mutation: gql`
148
- mutation deleteTrustedAgents($agents: [String!]!) {
149
- deleteTrustedAgents(agents: $agents)
150
- }
151
- `,
152
- variables: { agents },
153
- }),
154
- );
155
- return deleteTrustedAgents;
156
- }
157
-
158
- async getTrustedAgents(): Promise<string[]> {
159
- const { getTrustedAgents } = unwrapApolloResult(
160
- await this._apolloClient.query({
161
- query: gql`
162
- query getTrustedAgents {
163
- getTrustedAgents
164
- }
165
- `,
166
- }),
167
- );
168
- return getTrustedAgents;
169
- }
170
-
171
- async addKnownLinkLanguageTemplates(addresses: string[]): Promise<string[]> {
172
- const { runtimeAddKnownLinkLanguageTemplates } = unwrapApolloResult(
173
- await this._apolloClient.mutate({
174
- mutation: gql`
175
- mutation runtimeAddKnownLinkLanguageTemplates(
176
- $addresses: [String!]!
177
- ) {
178
- runtimeAddKnownLinkLanguageTemplates(addresses: $addresses)
179
- }
180
- `,
181
- variables: { addresses },
182
- }),
183
- );
184
- return runtimeAddKnownLinkLanguageTemplates;
185
- }
186
-
187
- async removeKnownLinkLanguageTemplates(
188
- addresses: string[],
189
- ): Promise<string[]> {
190
- const { runtimeRemoveKnownLinkLanguageTemplates } = unwrapApolloResult(
191
- await this._apolloClient.mutate({
192
- mutation: gql`
193
- mutation runtimeRemoveKnownLinkLanguageTemplates(
194
- $addresses: [String!]!
195
- ) {
196
- runtimeRemoveKnownLinkLanguageTemplates(addresses: $addresses)
197
- }
198
- `,
199
- variables: { addresses },
200
- }),
201
- );
202
- return runtimeRemoveKnownLinkLanguageTemplates;
203
- }
204
-
205
- async knownLinkLanguageTemplates(): Promise<string[]> {
206
- const { runtimeKnownLinkLanguageTemplates } = unwrapApolloResult(
207
- await this._apolloClient.query({
208
- query: gql`
209
- query runtimeKnownLinkLanguageTemplates {
210
- runtimeKnownLinkLanguageTemplates
211
- }
212
- `,
213
- }),
214
- );
215
- return runtimeKnownLinkLanguageTemplates;
216
- }
217
-
218
- async addFriends(dids: string[]): Promise<string[]> {
219
- const { runtimeAddFriends } = unwrapApolloResult(
220
- await this._apolloClient.mutate({
221
- mutation: gql`
222
- mutation runtimeAddFriends($dids: [String!]!) {
223
- runtimeAddFriends(dids: $dids)
224
- }
225
- `,
226
- variables: { dids },
227
- }),
228
- );
229
- return runtimeAddFriends;
230
- }
231
-
232
- async removeFriends(dids: string[]): Promise<string[]> {
233
- const { runtimeRemoveFriends } = unwrapApolloResult(
234
- await this._apolloClient.mutate({
235
- mutation: gql`
236
- mutation runtimeRemoveFriends($dids: [String!]!) {
237
- runtimeRemoveFriends(dids: $dids)
238
- }
239
- `,
240
- variables: { dids },
241
- }),
242
- );
243
- return runtimeRemoveFriends;
244
- }
245
-
246
- async friends(): Promise<string[]> {
247
- const { runtimeFriends } = unwrapApolloResult(
248
- await this._apolloClient.query({
249
- query: gql`
250
- query runtimeFriends {
251
- runtimeFriends
252
- }
253
- `,
254
- }),
255
- );
256
- return runtimeFriends;
257
- }
258
-
259
- async hcAgentInfos(): Promise<string> {
260
- const { runtimeHcAgentInfos } = unwrapApolloResult(
261
- await this._apolloClient.query({
262
- query: gql`
263
- query runtimeHcAgentInfos {
264
- runtimeHcAgentInfos
265
- }
266
- `,
267
- }),
268
- );
269
- return runtimeHcAgentInfos;
270
- }
271
-
272
- async getNetworkMetrics(): Promise<string> {
273
- const { runtimeGetNetworkMetrics } = unwrapApolloResult(
274
- await this._apolloClient.query({
275
- query: gql`
276
- query runtimeGetNetworkMetrics {
277
- runtimeGetNetworkMetrics
278
- }
279
- `,
280
- }),
281
- );
282
- return runtimeGetNetworkMetrics;
283
- }
284
-
285
- async restartHolochain(): Promise<boolean> {
286
- const { runtimeRestartHolochain } = unwrapApolloResult(
287
- await this._apolloClient.mutate({
288
- mutation: gql`
289
- mutation runtimeRestartHolochain {
290
- runtimeRestartHolochain
291
- }
292
- `,
293
- }),
294
- );
295
- return runtimeRestartHolochain;
296
- }
297
-
298
- async hcAddAgentInfos(agentInfos: String): Promise<void> {
299
- const { runtimeHcAddAgentInfos } = unwrapApolloResult(
300
- await this._apolloClient.mutate({
301
- mutation: gql`
302
- mutation runtimeHcAddAgentInfos($agentInfos: String!) {
303
- runtimeHcAddAgentInfos(agentInfos: $agentInfos)
304
- }
305
- `,
306
- variables: { agentInfos },
307
- }),
308
- );
309
- return runtimeHcAddAgentInfos;
310
- }
311
-
312
- async verifyStringSignedByDid(
313
- did: string,
314
- didSigningKeyId: string,
315
- data: string,
316
- signedData: string,
317
- ): Promise<boolean> {
318
- const { runtimeVerifyStringSignedByDid } = unwrapApolloResult(
319
- await this._apolloClient.mutate({
320
- mutation: gql`
321
- query runtimeVerifyStringSignedByDid(
322
- $did: String!
323
- $didSigningKeyId: String!
324
- $data: String!
325
- $signedData: String!
326
- ) {
327
- runtimeVerifyStringSignedByDid(
328
- did: $did
329
- didSigningKeyId: $didSigningKeyId
330
- data: $data
331
- signedData: $signedData
332
- )
333
- }
334
- `,
335
- variables: { did, didSigningKeyId, data, signedData },
336
- }),
337
- );
338
- return runtimeVerifyStringSignedByDid;
339
- }
340
-
341
- async setStatus(perspective: Perspective): Promise<boolean> {
342
- const { runtimeSetStatus } = unwrapApolloResult(
343
- await this._apolloClient.mutate({
344
- mutation: gql`
345
- mutation runtimeSetStatus($status: PerspectiveInput!) {
346
- runtimeSetStatus(status: $status)
347
- }
348
- `,
349
- variables: { status: perspective },
350
- }),
351
- );
352
- return runtimeSetStatus;
353
- }
354
-
355
- async friendStatus(did: string): Promise<PerspectiveExpression> {
356
- const { runtimeFriendStatus } = unwrapApolloResult(
357
- await this._apolloClient.query({
358
- query: gql`query runtimeFriendStatus($did: String!) {
49
+ #apolloClient: ApolloClient<any>
50
+ #messageReceivedCallbacks: MessageCallback[]
51
+ #exceptionOccurredCallbacks: ExceptionCallback[]
52
+ #notificationTriggeredCallbacks: NotificationTriggeredCallback[]
53
+ #notificationRequestedCallbacks: NotificationRequestedCallback[]
54
+
55
+ constructor(client: ApolloClient<any>, subscribe: boolean = true) {
56
+ this.#apolloClient = client
57
+ this.#messageReceivedCallbacks = []
58
+ this.#exceptionOccurredCallbacks = []
59
+ this.#notificationTriggeredCallbacks = []
60
+
61
+ if(subscribe) {
62
+ this.subscribeMessageReceived()
63
+ this.subscribeExceptionOccurred()
64
+ this.subscribeNotificationTriggered()
65
+ }
66
+ }
67
+
68
+ async info(): Promise<RuntimeInfo> {
69
+ const { runtimeInfo } = unwrapApolloResult(await this.#apolloClient.query({
70
+ query: gql`query runtimeInfo {
71
+ runtimeInfo {
72
+ ad4mExecutorVersion,
73
+ isInitialized,
74
+ isUnlocked
75
+ }
76
+ }`,
77
+ }));
78
+ return runtimeInfo
79
+ }
80
+
81
+ async quit(): Promise<Boolean> {
82
+ const result = unwrapApolloResult(await this.#apolloClient.mutate({
83
+ mutation: gql`mutation runtimeQuit { runtimeQuit }`
84
+ }))
85
+
86
+ return result.runtimeQuit
87
+ }
88
+
89
+ async openLink(url: string): Promise<Boolean> {
90
+ const { runtimeOpenLink } = unwrapApolloResult(await this.#apolloClient.mutate({
91
+ mutation: gql`mutation runtimeOpenLink($url: String!) {
92
+ runtimeOpenLink(url: $url)
93
+ }`,
94
+ variables: { url }
95
+ }))
96
+ return runtimeOpenLink
97
+ }
98
+
99
+ async addTrustedAgents(agents: string[]): Promise<string[]> {
100
+ const { addTrustedAgents } = unwrapApolloResult(await this.#apolloClient.mutate({
101
+ mutation: gql`mutation addTrustedAgents($agents: [String!]!) {
102
+ addTrustedAgents(agents: $agents)
103
+ }`,
104
+ variables: { agents }
105
+ }))
106
+ return addTrustedAgents
107
+ }
108
+
109
+ async deleteTrustedAgents(agents: string[]): Promise<string[]> {
110
+ const { deleteTrustedAgents } = unwrapApolloResult(await this.#apolloClient.mutate({
111
+ mutation: gql`mutation deleteTrustedAgents($agents: [String!]!) {
112
+ deleteTrustedAgents(agents: $agents)
113
+ }`,
114
+ variables: { agents }
115
+ }))
116
+ return deleteTrustedAgents
117
+ }
118
+
119
+ async getTrustedAgents(): Promise<string[]> {
120
+ const { getTrustedAgents } = unwrapApolloResult(await this.#apolloClient.query({
121
+ query: gql`query getTrustedAgents {
122
+ getTrustedAgents
123
+ }`,
124
+ }))
125
+ return getTrustedAgents
126
+ }
127
+
128
+ async addKnownLinkLanguageTemplates(addresses: string[]): Promise<string[]> {
129
+ const { runtimeAddKnownLinkLanguageTemplates } = unwrapApolloResult(await this.#apolloClient.mutate({
130
+ mutation: gql`mutation runtimeAddKnownLinkLanguageTemplates($addresses: [String!]!) {
131
+ runtimeAddKnownLinkLanguageTemplates(addresses: $addresses)
132
+ }`,
133
+ variables: { addresses }
134
+ }))
135
+ return runtimeAddKnownLinkLanguageTemplates
136
+ }
137
+
138
+ async removeKnownLinkLanguageTemplates(addresses: string[]): Promise<string[]> {
139
+ const { runtimeRemoveKnownLinkLanguageTemplates } = unwrapApolloResult(await this.#apolloClient.mutate({
140
+ mutation: gql`mutation runtimeRemoveKnownLinkLanguageTemplates($addresses: [String!]!) {
141
+ runtimeRemoveKnownLinkLanguageTemplates(addresses: $addresses)
142
+ }`,
143
+ variables: { addresses }
144
+ }))
145
+ return runtimeRemoveKnownLinkLanguageTemplates
146
+ }
147
+
148
+ async knownLinkLanguageTemplates(): Promise<string[]> {
149
+ const { runtimeKnownLinkLanguageTemplates } = unwrapApolloResult(await this.#apolloClient.query({
150
+ query: gql`query runtimeKnownLinkLanguageTemplates {
151
+ runtimeKnownLinkLanguageTemplates
152
+ }`,
153
+ }))
154
+ return runtimeKnownLinkLanguageTemplates
155
+ }
156
+
157
+ async addFriends(dids: string[]): Promise<string[]> {
158
+ const { runtimeAddFriends } = unwrapApolloResult(await this.#apolloClient.mutate({
159
+ mutation: gql`mutation runtimeAddFriends($dids: [String!]!) {
160
+ runtimeAddFriends(dids: $dids)
161
+ }`,
162
+ variables: { dids }
163
+ }))
164
+ return runtimeAddFriends
165
+ }
166
+
167
+ async removeFriends(dids: string[]): Promise<string[]> {
168
+ const { runtimeRemoveFriends } = unwrapApolloResult(await this.#apolloClient.mutate({
169
+ mutation: gql`mutation runtimeRemoveFriends($dids: [String!]!) {
170
+ runtimeRemoveFriends(dids: $dids)
171
+ }`,
172
+ variables: { dids }
173
+ }))
174
+ return runtimeRemoveFriends
175
+ }
176
+
177
+ async friends(): Promise<string[]> {
178
+ const { runtimeFriends } = unwrapApolloResult(await this.#apolloClient.query({
179
+ query: gql`query runtimeFriends {
180
+ runtimeFriends
181
+ }`,
182
+ }))
183
+ return runtimeFriends
184
+ }
185
+
186
+ async hcAgentInfos(): Promise<string> {
187
+ const { runtimeHcAgentInfos } = unwrapApolloResult(await this.#apolloClient.query({
188
+ query: gql`query runtimeHcAgentInfos {
189
+ runtimeHcAgentInfos
190
+ }`,
191
+ }))
192
+ return runtimeHcAgentInfos
193
+ }
194
+
195
+ async getNetworkMetrics(): Promise<string> {
196
+ const { runtimeGetNetworkMetrics } = unwrapApolloResult(await this.#apolloClient.query({
197
+ query: gql`query runtimeGetNetworkMetrics {
198
+ runtimeGetNetworkMetrics
199
+ }`,
200
+ }))
201
+ return runtimeGetNetworkMetrics
202
+ }
203
+
204
+ async restartHolochain(): Promise<boolean> {
205
+ const { runtimeRestartHolochain } = unwrapApolloResult(await this.#apolloClient.mutate({
206
+ mutation: gql`mutation runtimeRestartHolochain {
207
+ runtimeRestartHolochain
208
+ }`,
209
+ }))
210
+ return runtimeRestartHolochain
211
+ }
212
+
213
+ async hcAddAgentInfos(agentInfos: String): Promise<void> {
214
+ const { runtimeHcAddAgentInfos } = unwrapApolloResult(await this.#apolloClient.mutate({
215
+ mutation: gql`mutation runtimeHcAddAgentInfos($agentInfos: String!) {
216
+ runtimeHcAddAgentInfos(agentInfos: $agentInfos)
217
+ }`,
218
+ variables: { agentInfos }
219
+ }))
220
+ return runtimeHcAddAgentInfos
221
+ }
222
+
223
+ async verifyStringSignedByDid(did: string, didSigningKeyId: string, data: string, signedData: string): Promise<boolean> {
224
+ const { runtimeVerifyStringSignedByDid } = unwrapApolloResult(await this.#apolloClient.mutate({
225
+ mutation: gql`query runtimeVerifyStringSignedByDid($did: String!, $didSigningKeyId: String!, $data: String!, $signedData: String!) {
226
+ runtimeVerifyStringSignedByDid(did: $did, didSigningKeyId: $didSigningKeyId, data: $data, signedData: $signedData)
227
+ }`,
228
+ variables: { did, didSigningKeyId, data, signedData }
229
+ }))
230
+ return runtimeVerifyStringSignedByDid
231
+ }
232
+
233
+ async setStatus(perspective: Perspective): Promise<boolean> {
234
+ const { runtimeSetStatus } = unwrapApolloResult(await this.#apolloClient.mutate({
235
+ mutation: gql`mutation runtimeSetStatus($status: PerspectiveInput!) {
236
+ runtimeSetStatus(status: $status)
237
+ }`,
238
+ variables: { status: perspective }
239
+ }))
240
+ return runtimeSetStatus
241
+ }
242
+
243
+ async friendStatus(did: string): Promise<PerspectiveExpression> {
244
+ const { runtimeFriendStatus } = unwrapApolloResult(await this.#apolloClient.query({
245
+ query: gql`query runtimeFriendStatus($did: String!) {
359
246
  runtimeFriendStatus(did: $did) { ${PERSPECTIVE_EXPRESSION_FIELDS} }
360
247
  }`,
361
- variables: { did },
362
- }),
363
- );
364
- return runtimeFriendStatus;
365
- }
366
-
367
- async friendSendMessage(did: string, message: Perspective): Promise<boolean> {
368
- const { runtimeFriendSendMessage } = unwrapApolloResult(
369
- await this._apolloClient.mutate({
370
- mutation: gql`
371
- mutation runtimeFriendSendMessage(
372
- $did: String!
373
- $message: PerspectiveInput!
374
- ) {
375
- runtimeFriendSendMessage(did: $did, message: $message)
376
- }
377
- `,
378
- variables: { did, message },
379
- }),
380
- );
381
- return runtimeFriendSendMessage;
382
- }
383
-
384
- async messageInbox(filter?: string): Promise<PerspectiveExpression[]> {
385
- const { runtimeMessageInbox } = unwrapApolloResult(
386
- await this._apolloClient.query({
387
- query: gql`query runtimeMessageInbox($filter: String) {
248
+ variables: { did }
249
+ }))
250
+ return runtimeFriendStatus
251
+ }
252
+
253
+ async friendSendMessage(did: string, message: Perspective): Promise<boolean> {
254
+ const { runtimeFriendSendMessage } = unwrapApolloResult(await this.#apolloClient.mutate({
255
+ mutation: gql`mutation runtimeFriendSendMessage($did: String!, $message: PerspectiveInput!) {
256
+ runtimeFriendSendMessage(did: $did, message: $message)
257
+ }`,
258
+ variables: { did, message }
259
+ }))
260
+ return runtimeFriendSendMessage
261
+ }
262
+
263
+ async messageInbox(filter?: string): Promise<PerspectiveExpression[]> {
264
+ const { runtimeMessageInbox } = unwrapApolloResult(await this.#apolloClient.query({
265
+ query: gql`query runtimeMessageInbox($filter: String) {
388
266
  runtimeMessageInbox(filter: $filter) { ${PERSPECTIVE_EXPRESSION_FIELDS} }
389
267
  }`,
390
- variables: { filter },
391
- }),
392
- );
393
- return runtimeMessageInbox;
394
- }
268
+ variables: { filter }
269
+ }))
270
+ return runtimeMessageInbox
271
+ }
395
272
 
396
- async messageOutbox(filter?: string): Promise<SentMessage[]> {
397
- const { runtimeMessageOutbox } = unwrapApolloResult(
398
- await this._apolloClient.query({
399
- query: gql`query runtimeMessageOutbox($filter: String) {
273
+ async messageOutbox(filter?: string): Promise<SentMessage[]> {
274
+ const { runtimeMessageOutbox } = unwrapApolloResult(await this.#apolloClient.query({
275
+ query: gql`query runtimeMessageOutbox($filter: String) {
400
276
  runtimeMessageOutbox(filter: $filter) {
401
277
  recipient,
402
278
  message {
@@ -404,426 +280,251 @@ export class RuntimeClient {
404
280
  }
405
281
  }
406
282
  }`,
407
- variables: { filter },
408
- }),
409
- );
410
- return runtimeMessageOutbox;
411
- }
412
-
413
- async requestInstallNotification(notification: NotificationInput) {
414
- const { runtimeRequestInstallNotification } = unwrapApolloResult(
415
- await this._apolloClient.mutate({
416
- mutation: gql`
417
- mutation runtimeRequestInstallNotification(
418
- $notification: NotificationInput!
419
- ) {
420
- runtimeRequestInstallNotification(notification: $notification)
421
- }
422
- `,
423
- variables: { notification },
424
- }),
425
- );
426
- return runtimeRequestInstallNotification;
427
- }
428
-
429
- async grantNotification(id: string): Promise<boolean> {
430
- const { runtimeGrantNotification } = unwrapApolloResult(
431
- await this._apolloClient.mutate({
432
- mutation: gql`
433
- mutation runtimeGrantNotification($id: String!) {
434
- runtimeGrantNotification(id: $id)
435
- }
436
- `,
437
- variables: { id },
438
- }),
439
- );
440
- return runtimeGrantNotification;
441
- }
442
-
443
- async exportDb(filePath: string): Promise<boolean> {
444
- const { runtimeExportDb } = unwrapApolloResult(
445
- await this._apolloClient.mutate({
446
- mutation: gql`
447
- mutation runtimeExportDb($filePath: String!) {
448
- runtimeExportDb(filePath: $filePath)
449
- }
450
- `,
451
- variables: { filePath },
452
- }),
453
- );
454
- return runtimeExportDb;
455
- }
456
-
457
- async importDb(filePath: string): Promise<ImportResult> {
458
- const { runtimeImportDb } = unwrapApolloResult(
459
- await this._apolloClient.mutate({
460
- mutation: gql`
461
- mutation runtimeImportDb($filePath: String!) {
462
- runtimeImportDb(filePath: $filePath) {
463
- perspectives {
464
- total
465
- imported
466
- failed
467
- omitted
468
- errors
469
- }
470
- links {
471
- total
472
- imported
473
- failed
474
- omitted
475
- errors
476
- }
477
- expressions {
478
- total
479
- imported
480
- failed
481
- omitted
482
- errors
483
- }
484
- perspectiveDiffs {
485
- total
486
- imported
487
- failed
488
- omitted
489
- errors
490
- }
491
- notifications {
492
- total
493
- imported
494
- failed
495
- omitted
496
- errors
497
- }
498
- models {
499
- total
500
- imported
501
- failed
502
- omitted
503
- errors
504
- }
505
- defaultModels {
506
- total
507
- imported
508
- failed
509
- omitted
510
- errors
511
- }
512
- tasks {
513
- total
514
- imported
515
- failed
516
- omitted
517
- errors
518
- }
519
- friends {
520
- total
521
- imported
522
- failed
523
- omitted
524
- errors
525
- }
526
- trustedAgents {
527
- total
528
- imported
529
- failed
530
- omitted
531
- errors
532
- }
533
- knownLinkLanguages {
534
- total
535
- imported
536
- failed
537
- omitted
538
- errors
539
- }
540
- }
541
- }
542
- `,
543
- variables: { filePath },
544
- }),
545
- );
546
- return runtimeImportDb;
547
- }
548
-
549
- async notifications(): Promise<Notification[]> {
550
- const { runtimeNotifications } = unwrapApolloResult(
551
- await this._apolloClient.query({
552
- query: gql`query runtimeNotifications {
283
+ variables: { filter }
284
+ }))
285
+ return runtimeMessageOutbox
286
+ }
287
+
288
+ async requestInstallNotification(notification: NotificationInput) {
289
+ const { runtimeRequestInstallNotification } = unwrapApolloResult(await this.#apolloClient.mutate({
290
+ mutation: gql`mutation runtimeRequestInstallNotification($notification: NotificationInput!) {
291
+ runtimeRequestInstallNotification(notification: $notification)
292
+ }`,
293
+ variables: { notification }
294
+ }))
295
+ return runtimeRequestInstallNotification
296
+ }
297
+
298
+ async grantNotification(id: string): Promise<boolean> {
299
+ const { runtimeGrantNotification } = unwrapApolloResult(await this.#apolloClient.mutate({
300
+ mutation: gql`mutation runtimeGrantNotification($id: String!) {
301
+ runtimeGrantNotification(id: $id)
302
+ }`,
303
+ variables: { id }
304
+ }))
305
+ return runtimeGrantNotification
306
+ }
307
+
308
+ async exportDb(filePath: string): Promise<boolean> {
309
+ const { runtimeExportDb } = unwrapApolloResult(await this.#apolloClient.mutate({
310
+ mutation: gql`mutation runtimeExportDb($filePath: String!) {
311
+ runtimeExportDb(filePath: $filePath)
312
+ }`,
313
+ variables: { filePath }
314
+ }))
315
+ return runtimeExportDb
316
+ }
317
+
318
+ async importDb(filePath: string): Promise<ImportResult> {
319
+ const { runtimeImportDb } = unwrapApolloResult(await this.#apolloClient.mutate({
320
+ mutation: gql`mutation runtimeImportDb($filePath: String!) {
321
+ runtimeImportDb(filePath: $filePath) {
322
+ perspectives { total imported failed omitted errors }
323
+ links { total imported failed omitted errors }
324
+ expressions { total imported failed omitted errors }
325
+ perspectiveDiffs { total imported failed omitted errors }
326
+ notifications { total imported failed omitted errors }
327
+ models { total imported failed omitted errors }
328
+ defaultModels { total imported failed omitted errors }
329
+ tasks { total imported failed omitted errors }
330
+ friends { total imported failed omitted errors }
331
+ trustedAgents { total imported failed omitted errors }
332
+ knownLinkLanguages { total imported failed omitted errors }
333
+ }
334
+ }`,
335
+ variables: { filePath }
336
+ }))
337
+ return runtimeImportDb
338
+ }
339
+
340
+ async notifications(): Promise<Notification[]> {
341
+ const { runtimeNotifications } = unwrapApolloResult(await this.#apolloClient.query({
342
+ query: gql`query runtimeNotifications {
553
343
  runtimeNotifications { ${NOTIFICATION_FIELDS} }
554
344
  }`,
555
- }),
556
- );
557
- return runtimeNotifications;
558
- }
559
-
560
- async updateNotification(
561
- id: string,
562
- notification: NotificationInput,
563
- ): Promise<boolean> {
564
- const { runtimeUpdateNotification } = unwrapApolloResult(
565
- await this._apolloClient.mutate({
566
- mutation: gql`
567
- mutation runtimeUpdateNotification(
568
- $id: String!
569
- $notification: NotificationInput!
570
- ) {
571
- runtimeUpdateNotification(id: $id, notification: $notification)
572
- }
573
- `,
574
- variables: { id, notification },
575
- }),
576
- );
577
- return runtimeUpdateNotification;
578
- }
579
-
580
- async removeNotification(id: string): Promise<boolean> {
581
- const { runtimeRemoveNotification } = unwrapApolloResult(
582
- await this._apolloClient.mutate({
583
- mutation: gql`
584
- mutation runtimeRemoveNotification($id: String!) {
585
- runtimeRemoveNotification(id: $id)
586
- }
587
- `,
588
- variables: { id },
589
- }),
590
- );
591
- return runtimeRemoveNotification;
592
- }
593
-
594
- async exportPerspective(uuid: string, filePath: string): Promise<boolean> {
595
- const { runtimeExportPerspective } = unwrapApolloResult(
596
- await this._apolloClient.mutate({
597
- mutation: gql`
598
- mutation runtimeExportPerspective(
599
- $perspectiveUuid: String!
600
- $filePath: String!
601
- ) {
602
- runtimeExportPerspective(
603
- perspectiveUuid: $perspectiveUuid
604
- filePath: $filePath
605
- )
606
- }
607
- `,
608
- variables: { perspectiveUuid: uuid, filePath },
609
- }),
610
- );
611
- return runtimeExportPerspective;
612
- }
613
-
614
- async importPerspective(filePath: string): Promise<boolean> {
615
- const { runtimeImportPerspective } = unwrapApolloResult(
616
- await this._apolloClient.mutate({
617
- mutation: gql`
618
- mutation runtimeImportPerspective($filePath: String!) {
619
- runtimeImportPerspective(filePath: $filePath)
620
- }
621
- `,
622
- variables: { filePath },
623
- }),
624
- );
625
- return runtimeImportPerspective;
626
- }
627
-
628
- async multiUserEnabled(): Promise<boolean> {
629
- const { runtimeMultiUserEnabled } = unwrapApolloResult(
630
- await this._apolloClient.query({
631
- query: gql`
632
- query runtimeMultiUserEnabled {
633
- runtimeMultiUserEnabled
634
- }
635
- `,
636
- }),
637
- );
638
- return runtimeMultiUserEnabled;
639
- }
640
-
641
- async setMultiUserEnabled(enabled: boolean): Promise<boolean> {
642
- const { runtimeSetMultiUserEnabled } = unwrapApolloResult(
643
- await this._apolloClient.mutate({
644
- mutation: gql`
645
- mutation runtimeSetMultiUserEnabled($enabled: Boolean!) {
646
- runtimeSetMultiUserEnabled(enabled: $enabled)
647
- }
648
- `,
649
- variables: { enabled },
650
- }),
651
- );
652
- return runtimeSetMultiUserEnabled;
653
- }
654
-
655
- async listUsers(): Promise<UserStatistics[]> {
656
- const { runtimeListUsers } = unwrapApolloResult(
657
- await this._apolloClient.query({
658
- query: gql`
659
- query runtimeListUsers {
660
- runtimeListUsers {
661
- email
662
- did
663
- lastSeen
664
- perspectiveCount
665
- }
666
- }
667
- `,
668
- }),
669
- );
670
- return runtimeListUsers;
671
- }
672
-
673
- async emailTestModeEnable(): Promise<boolean> {
674
- const { runtimeEmailTestModeEnable } = unwrapApolloResult(
675
- await this._apolloClient.mutate({
676
- mutation: gql`
677
- mutation runtimeEmailTestModeEnable {
678
- runtimeEmailTestModeEnable
679
- }
680
- `,
681
- }),
682
- );
683
- return runtimeEmailTestModeEnable;
684
- }
685
-
686
- async emailTestModeDisable(): Promise<boolean> {
687
- const { runtimeEmailTestModeDisable } = unwrapApolloResult(
688
- await this._apolloClient.mutate({
689
- mutation: gql`
690
- mutation runtimeEmailTestModeDisable {
691
- runtimeEmailTestModeDisable
692
- }
693
- `,
694
- }),
695
- );
696
- return runtimeEmailTestModeDisable;
697
- }
698
-
699
- async emailTestGetCode(email: string): Promise<string | null> {
700
- const { runtimeEmailTestGetCode } = unwrapApolloResult(
701
- await this._apolloClient.mutate({
702
- mutation: gql`
703
- mutation runtimeEmailTestGetCode($email: String!) {
704
- runtimeEmailTestGetCode(email: $email)
705
- }
706
- `,
707
- variables: { email },
708
- }),
709
- );
710
- return runtimeEmailTestGetCode;
711
- }
712
-
713
- async emailTestClearCodes(): Promise<boolean> {
714
- const { runtimeEmailTestClearCodes } = unwrapApolloResult(
715
- await this._apolloClient.mutate({
716
- mutation: gql`
717
- mutation runtimeEmailTestClearCodes {
718
- runtimeEmailTestClearCodes
719
- }
720
- `,
721
- }),
722
- );
723
- return runtimeEmailTestClearCodes;
724
- }
725
-
726
- async emailTestSetExpiry(
727
- email: string,
728
- verificationType: string,
729
- expiresAt: number,
730
- ): Promise<boolean> {
731
- const { runtimeEmailTestSetExpiry } = unwrapApolloResult(
732
- await this._apolloClient.mutate({
733
- mutation: gql`
734
- mutation runtimeEmailTestSetExpiry(
735
- $email: String!
736
- $verificationType: String!
737
- $expiresAt: Int!
738
- ) {
739
- runtimeEmailTestSetExpiry(
740
- email: $email
741
- verificationType: $verificationType
742
- expiresAt: $expiresAt
743
- )
744
- }
745
- `,
746
- variables: { email, verificationType, expiresAt },
747
- }),
748
- );
749
- return runtimeEmailTestSetExpiry;
750
- }
751
-
752
- addNotificationTriggeredCallback(cb: NotificationTriggeredCallback) {
753
- this._notificationTriggeredCallbacks.push(cb);
754
- }
755
-
756
- subscribeNotificationTriggered() {
757
- this._apolloClient
758
- .subscribe({
759
- query: gql` subscription {
345
+ }))
346
+ return runtimeNotifications
347
+ }
348
+
349
+ async updateNotification(id: string, notification: NotificationInput): Promise<boolean> {
350
+ const { runtimeUpdateNotification } = unwrapApolloResult(await this.#apolloClient.mutate({
351
+ mutation: gql`mutation runtimeUpdateNotification($id: String!, $notification: NotificationInput!) {
352
+ runtimeUpdateNotification(id: $id, notification: $notification)
353
+ }`,
354
+ variables: { id, notification }
355
+ }))
356
+ return runtimeUpdateNotification
357
+ }
358
+
359
+ async removeNotification(id: string): Promise<boolean> {
360
+ const { runtimeRemoveNotification } = unwrapApolloResult(await this.#apolloClient.mutate({
361
+ mutation: gql`mutation runtimeRemoveNotification($id: String!) {
362
+ runtimeRemoveNotification(id: $id)
363
+ }`,
364
+ variables: { id }
365
+ }))
366
+ return runtimeRemoveNotification
367
+ }
368
+
369
+ async exportPerspective(uuid: string, filePath: string): Promise<boolean> {
370
+ const { runtimeExportPerspective } = unwrapApolloResult(await this.#apolloClient.mutate({
371
+ mutation: gql`mutation runtimeExportPerspective($perspectiveUuid: String!, $filePath: String!) {
372
+ runtimeExportPerspective(perspectiveUuid: $perspectiveUuid, filePath: $filePath)
373
+ }`,
374
+ variables: { perspectiveUuid: uuid, filePath }
375
+ }))
376
+ return runtimeExportPerspective
377
+ }
378
+
379
+ async importPerspective(filePath: string): Promise<boolean> {
380
+ const { runtimeImportPerspective } = unwrapApolloResult(await this.#apolloClient.mutate({
381
+ mutation: gql`mutation runtimeImportPerspective($filePath: String!) {
382
+ runtimeImportPerspective(filePath: $filePath)
383
+ }`,
384
+ variables: { filePath }
385
+ }))
386
+ return runtimeImportPerspective
387
+ }
388
+
389
+ async multiUserEnabled(): Promise<boolean> {
390
+ const { runtimeMultiUserEnabled } = unwrapApolloResult(await this.#apolloClient.query({
391
+ query: gql`query runtimeMultiUserEnabled {
392
+ runtimeMultiUserEnabled
393
+ }`,
394
+ }))
395
+ return runtimeMultiUserEnabled
396
+ }
397
+
398
+ async setMultiUserEnabled(enabled: boolean): Promise<boolean> {
399
+ const { runtimeSetMultiUserEnabled } = unwrapApolloResult(await this.#apolloClient.mutate({
400
+ mutation: gql`mutation runtimeSetMultiUserEnabled($enabled: Boolean!) {
401
+ runtimeSetMultiUserEnabled(enabled: $enabled)
402
+ }`,
403
+ variables: { enabled }
404
+ }))
405
+ return runtimeSetMultiUserEnabled
406
+ }
407
+
408
+ async listUsers(): Promise<UserStatistics[]> {
409
+ const { runtimeListUsers } = unwrapApolloResult(await this.#apolloClient.query({
410
+ query: gql`query runtimeListUsers {
411
+ runtimeListUsers {
412
+ email
413
+ did
414
+ lastSeen
415
+ perspectiveCount
416
+ }
417
+ }`
418
+ }))
419
+ return runtimeListUsers
420
+ }
421
+
422
+ async emailTestModeEnable(): Promise<boolean> {
423
+ const { runtimeEmailTestModeEnable } = unwrapApolloResult(await this.#apolloClient.mutate({
424
+ mutation: gql`mutation runtimeEmailTestModeEnable {
425
+ runtimeEmailTestModeEnable
426
+ }`
427
+ }))
428
+ return runtimeEmailTestModeEnable
429
+ }
430
+
431
+ async emailTestModeDisable(): Promise<boolean> {
432
+ const { runtimeEmailTestModeDisable } = unwrapApolloResult(await this.#apolloClient.mutate({
433
+ mutation: gql`mutation runtimeEmailTestModeDisable {
434
+ runtimeEmailTestModeDisable
435
+ }`
436
+ }))
437
+ return runtimeEmailTestModeDisable
438
+ }
439
+
440
+ async emailTestGetCode(email: string): Promise<string | null> {
441
+ const { runtimeEmailTestGetCode } = unwrapApolloResult(await this.#apolloClient.mutate({
442
+ mutation: gql`mutation runtimeEmailTestGetCode($email: String!) {
443
+ runtimeEmailTestGetCode(email: $email)
444
+ }`,
445
+ variables: { email }
446
+ }))
447
+ return runtimeEmailTestGetCode
448
+ }
449
+
450
+ async emailTestClearCodes(): Promise<boolean> {
451
+ const { runtimeEmailTestClearCodes } = unwrapApolloResult(await this.#apolloClient.mutate({
452
+ mutation: gql`mutation runtimeEmailTestClearCodes {
453
+ runtimeEmailTestClearCodes
454
+ }`
455
+ }))
456
+ return runtimeEmailTestClearCodes
457
+ }
458
+
459
+ async emailTestSetExpiry(email: string, verificationType: string, expiresAt: number): Promise<boolean> {
460
+ const { runtimeEmailTestSetExpiry } = unwrapApolloResult(await this.#apolloClient.mutate({
461
+ mutation: gql`mutation runtimeEmailTestSetExpiry($email: String!, $verificationType: String!, $expiresAt: Int!) {
462
+ runtimeEmailTestSetExpiry(email: $email, verificationType: $verificationType, expiresAt: $expiresAt)
463
+ }`,
464
+ variables: { email, verificationType, expiresAt }
465
+ }))
466
+ return runtimeEmailTestSetExpiry
467
+ }
468
+
469
+ addNotificationTriggeredCallback(cb: NotificationTriggeredCallback) {
470
+ this.#notificationTriggeredCallbacks.push(cb)
471
+ }
472
+
473
+ subscribeNotificationTriggered() {
474
+ this.#apolloClient.subscribe({
475
+ query: gql` subscription {
760
476
  runtimeNotificationTriggered { ${TRIGGERED_NOTIFICATION_FIELDS} }
761
477
  }
762
- `,
763
- })
764
- .subscribe({
765
- next: (result) => {
766
- this._notificationTriggeredCallbacks.forEach((cb) => {
767
- cb(result.data.runtimeNotificationTriggered);
768
- });
769
- },
770
- error: (e) => {
771
- if (!isSocketCloseError(e)) console.error(e);
772
- },
773
- });
774
- }
775
-
776
- addMessageCallback(cb: MessageCallback) {
777
- this._messageReceivedCallbacks.push(cb);
778
- }
779
-
780
- subscribeMessageReceived() {
781
- this._apolloClient
782
- .subscribe({
783
- query: gql` subscription {
478
+ `}).subscribe({
479
+ next: result => {
480
+ this.#notificationTriggeredCallbacks.forEach(cb => {
481
+ cb(result.data.runtimeNotificationTriggered)
482
+ })
483
+ },
484
+ error: (e) => console.error(e)
485
+ })
486
+ }
487
+
488
+ addMessageCallback(cb: MessageCallback) {
489
+ this.#messageReceivedCallbacks.push(cb)
490
+ }
491
+
492
+ subscribeMessageReceived() {
493
+ this.#apolloClient.subscribe({
494
+ query: gql` subscription {
784
495
  runtimeMessageReceived { ${PERSPECTIVE_EXPRESSION_FIELDS} }
785
496
  }
786
- `,
787
- })
788
- .subscribe({
789
- next: (result) => {
790
- this._messageReceivedCallbacks.forEach((cb) => {
791
- cb(result.data.runtimeMessageReceived);
792
- });
793
- },
794
- error: (e) => {
795
- if (!isSocketCloseError(e)) console.error(e);
796
- },
797
- });
798
- }
799
-
800
- addExceptionCallback(cb: ExceptionCallback) {
801
- this._exceptionOccurredCallbacks.push(cb);
802
- }
803
-
804
- subscribeExceptionOccurred() {
805
- this._apolloClient
806
- .subscribe({
807
- query: gql`
808
- subscription {
809
- exceptionOccurred {
810
- title
811
- message
812
- type
813
- addon
814
- }
815
- }
816
- `,
817
- })
818
- .subscribe({
819
- next: (result) => {
820
- this._exceptionOccurredCallbacks.forEach((cb) => {
821
- cb(result.data.exceptionOccurred);
822
- });
823
- },
824
- error: (e) => {
825
- if (!isSocketCloseError(e)) console.error(e);
826
- },
827
- });
828
- }
829
- }
497
+ `}).subscribe({
498
+ next: result => {
499
+ this.#messageReceivedCallbacks.forEach(cb => {
500
+ cb(result.data.runtimeMessageReceived)
501
+ })
502
+ },
503
+ error: (e) => console.error(e)
504
+ })
505
+ }
506
+
507
+ addExceptionCallback(cb: ExceptionCallback) {
508
+ this.#exceptionOccurredCallbacks.push(cb)
509
+ }
510
+
511
+ subscribeExceptionOccurred() {
512
+ this.#apolloClient.subscribe({
513
+ query: gql` subscription {
514
+ exceptionOccurred {
515
+ title
516
+ message
517
+ type
518
+ addon
519
+ }
520
+ }`
521
+ }).subscribe({
522
+ next: result => {
523
+ this.#exceptionOccurredCallbacks.forEach(cb => {
524
+ cb(result.data.exceptionOccurred)
525
+ })
526
+ },
527
+ error: (e) => console.error(e)
528
+ })
529
+ }
530
+ }