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

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 (128) hide show
  1. package/jest.config.js +4 -4
  2. package/lib/index.cjs +5999 -6046
  3. package/lib/index.js +5977 -6040
  4. package/lib/src/Ad4mClient.d.ts +16 -9
  5. package/lib/src/Ad4mClient.js +25 -46
  6. package/lib/src/Ad4mClient.test.d.ts +1 -0
  7. package/lib/src/Ad4mClient.test.js +1204 -0
  8. package/lib/src/Literal.d.ts +2 -1
  9. package/lib/src/Literal.js +35 -38
  10. package/lib/src/Literal.test.d.ts +1 -0
  11. package/lib/src/Literal.test.js +41 -0
  12. package/lib/src/SmartLiteral.d.ts +2 -1
  13. package/lib/src/SmartLiteral.js +15 -30
  14. package/lib/src/agent/AgentClient.d.ts +4 -1
  15. package/lib/src/agent/AgentClient.js +99 -79
  16. package/lib/src/ai/AIClient.d.ts +2 -1
  17. package/lib/src/ai/AIClient.js +220 -224
  18. package/lib/src/expression/ExpressionClient.d.ts +1 -1
  19. package/lib/src/expression/ExpressionClient.js +86 -73
  20. package/lib/src/index.d.ts +1 -1
  21. package/lib/src/index.js +1 -1
  22. package/lib/src/language/LanguageClient.d.ts +1 -1
  23. package/lib/src/language/LanguageClient.js +52 -52
  24. package/lib/src/model/Ad4mModel.d.ts +157 -937
  25. package/lib/src/model/Ad4mModel.js +212 -2799
  26. package/lib/src/model/Ad4mModel.test.js +1002 -561
  27. package/lib/src/model/decorators.d.ts +94 -426
  28. package/lib/src/model/decorators.js +333 -741
  29. package/lib/src/model/mutation.d.ts +81 -0
  30. package/lib/src/model/mutation.js +317 -0
  31. package/lib/src/model/parentUtils.d.ts +32 -0
  32. package/lib/src/model/parentUtils.js +64 -0
  33. package/lib/src/model/prolog/generatePrologFacts.d.ts +36 -0
  34. package/lib/src/model/prolog/generatePrologFacts.js +139 -0
  35. package/lib/src/model/prolog/index.d.ts +1 -0
  36. package/lib/src/model/prolog/index.js +1 -0
  37. package/lib/src/model/query/ModelQueryBuilder.d.ts +82 -0
  38. package/lib/src/model/query/ModelQueryBuilder.js +115 -0
  39. package/lib/src/model/query/QueryBuilder.d.ts +101 -0
  40. package/lib/src/model/query/QueryBuilder.js +193 -0
  41. package/lib/src/model/query/SurrealQueryBuilder.d.ts +48 -0
  42. package/lib/src/model/query/SurrealQueryBuilder.js +371 -0
  43. package/lib/src/model/query/fetchInstance.d.ts +24 -0
  44. package/lib/src/model/query/fetchInstance.js +144 -0
  45. package/lib/src/model/query/hydration.d.ts +54 -0
  46. package/lib/src/model/query/hydration.js +214 -0
  47. package/lib/src/model/query/operations.d.ts +59 -0
  48. package/lib/src/model/query/operations.js +384 -0
  49. package/lib/src/model/query/snapshot.d.ts +59 -0
  50. package/lib/src/model/query/snapshot.js +106 -0
  51. package/lib/src/model/query/surrealCompiler.d.ts +42 -0
  52. package/lib/src/model/query/surrealCompiler.js +304 -0
  53. package/lib/src/model/schema/fromJSONSchema.d.ts +67 -0
  54. package/lib/src/model/schema/fromJSONSchema.js +264 -0
  55. package/lib/src/model/schema/metadata.d.ts +15 -0
  56. package/lib/src/model/schema/metadata.js +112 -0
  57. package/lib/src/model/subscription.d.ts +47 -0
  58. package/lib/src/model/subscription.js +231 -0
  59. package/lib/src/model/transaction.d.ts +27 -0
  60. package/lib/src/model/transaction.js +32 -0
  61. package/lib/src/model/types.d.ts +195 -0
  62. package/lib/src/model/types.js +8 -0
  63. package/lib/src/model/util.js +7 -7
  64. package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +5 -1
  65. package/lib/src/neighbourhood/NeighbourhoodClient.js +263 -181
  66. package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +2 -1
  67. package/lib/src/neighbourhood/NeighbourhoodProxy.js +13 -28
  68. package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +1 -5
  69. package/lib/src/perspectives/PerspectiveClient.d.ts +9 -9
  70. package/lib/src/perspectives/PerspectiveClient.js +316 -240
  71. package/lib/src/perspectives/PerspectiveProxy.d.ts +54 -92
  72. package/lib/src/perspectives/PerspectiveProxy.js +803 -444
  73. package/lib/src/runtime/RuntimeClient.d.ts +5 -1
  74. package/lib/src/runtime/RuntimeClient.js +412 -238
  75. package/lib/src/shacl/SHACLFlow.test.js +164 -105
  76. package/lib/src/shacl/SHACLShape.d.ts +17 -3
  77. package/lib/src/shacl/SHACLShape.js +127 -90
  78. package/lib/src/shacl/SHACLShape.test.js +244 -176
  79. package/lib/src/utils.d.ts +8 -0
  80. package/lib/src/utils.js +21 -7
  81. package/package.json +8 -13
  82. package/src/Ad4mClient.test.ts +1564 -1315
  83. package/src/Ad4mClient.ts +55 -54
  84. package/src/Literal.test.ts +45 -26
  85. package/src/Literal.ts +82 -66
  86. package/src/SmartLiteral.ts +74 -58
  87. package/src/agent/AgentClient.ts +144 -99
  88. package/src/ai/AIClient.ts +409 -359
  89. package/src/expression/ExpressionClient.ts +142 -96
  90. package/src/index.ts +1 -1
  91. package/src/language/LanguageClient.ts +137 -113
  92. package/src/model/Ad4mModel.test.ts +1128 -647
  93. package/src/model/Ad4mModel.ts +485 -3249
  94. package/src/model/IMPROVEMENTS.md +482 -0
  95. package/src/model/PREDICATE_COLLISION_FIX.md +651 -0
  96. package/src/model/README.md +317 -0
  97. package/src/model/SHACL_MUTATION_DECOUPLING.md +356 -0
  98. package/src/model/SUBSCRIPTION_STRATEGY.md +317 -0
  99. package/src/model/TC39_STAGE_3_DECORATORS.md +609 -0
  100. package/src/model/decorators.ts +689 -1046
  101. package/src/model/mutation.ts +461 -0
  102. package/src/model/parentUtils.ts +91 -0
  103. package/src/model/prolog/generatePrologFacts.ts +176 -0
  104. package/src/model/prolog/index.ts +1 -0
  105. package/src/model/query/ModelQueryBuilder.ts +173 -0
  106. package/src/model/query/fetchInstance.ts +181 -0
  107. package/src/model/query/hydration.ts +273 -0
  108. package/src/model/query/operations.ts +510 -0
  109. package/src/model/query/snapshot.ts +126 -0
  110. package/src/model/query/surrealCompiler.ts +376 -0
  111. package/src/model/schema/fromJSONSchema.ts +411 -0
  112. package/src/model/schema/metadata.ts +148 -0
  113. package/src/model/subscription.ts +307 -0
  114. package/src/model/transaction.ts +60 -0
  115. package/src/model/types.ts +207 -0
  116. package/src/model/util.ts +47 -48
  117. package/src/neighbourhood/NeighbourhoodClient.ts +393 -251
  118. package/src/neighbourhood/NeighbourhoodProxy.test.ts +3 -7
  119. package/src/neighbourhood/NeighbourhoodProxy.ts +58 -40
  120. package/src/perspectives/PerspectiveClient.ts +779 -540
  121. package/src/perspectives/PerspectiveProxy.ts +2860 -2053
  122. package/src/runtime/RuntimeClient.ts +775 -476
  123. package/src/shacl/SHACLFlow.test.ts +196 -129
  124. package/src/shacl/SHACLShape.test.ts +284 -190
  125. package/src/shacl/SHACLShape.ts +225 -172
  126. package/src/utils.ts +31 -17
  127. package/tsconfig.json +9 -10
  128. package/src/model/Subject.ts +0 -159
@@ -1,7 +1,20 @@
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"
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";
5
18
 
6
19
  const PERSPECTIVE_EXPRESSION_FIELDS = `
7
20
  author
@@ -15,7 +28,7 @@ data {
15
28
  }
16
29
  }
17
30
  proof { valid, invalid, signature, key }
18
- `
31
+ `;
19
32
 
20
33
  const NOTIFICATION_DEFINITION_FIELDS = `
21
34
  description
@@ -26,253 +39,364 @@ trigger
26
39
  perspectiveIds
27
40
  webhookUrl
28
41
  webhookAuth
29
- `
42
+ `;
30
43
 
31
44
  const NOTIFICATION_FIELDS = `
32
45
  id
33
46
  granted
34
47
  ${NOTIFICATION_DEFINITION_FIELDS}
35
- `
48
+ `;
36
49
 
37
50
  const TRIGGERED_NOTIFICATION_FIELDS = `
38
51
  notification { ${NOTIFICATION_FIELDS} }
39
52
  perspectiveId
40
53
  triggerMatch
41
- `
54
+ `;
42
55
 
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
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;
47
64
 
48
65
  export class RuntimeClient {
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!) {
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!) {
246
359
  runtimeFriendStatus(did: $did) { ${PERSPECTIVE_EXPRESSION_FIELDS} }
247
360
  }`,
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) {
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) {
266
388
  runtimeMessageInbox(filter: $filter) { ${PERSPECTIVE_EXPRESSION_FIELDS} }
267
389
  }`,
268
- variables: { filter }
269
- }))
270
- return runtimeMessageInbox
271
- }
390
+ variables: { filter },
391
+ }),
392
+ );
393
+ return runtimeMessageInbox;
394
+ }
272
395
 
273
- async messageOutbox(filter?: string): Promise<SentMessage[]> {
274
- const { runtimeMessageOutbox } = unwrapApolloResult(await this.#apolloClient.query({
275
- query: gql`query runtimeMessageOutbox($filter: String) {
396
+ async messageOutbox(filter?: string): Promise<SentMessage[]> {
397
+ const { runtimeMessageOutbox } = unwrapApolloResult(
398
+ await this._apolloClient.query({
399
+ query: gql`query runtimeMessageOutbox($filter: String) {
276
400
  runtimeMessageOutbox(filter: $filter) {
277
401
  recipient,
278
402
  message {
@@ -280,251 +404,426 @@ export class RuntimeClient {
280
404
  }
281
405
  }
282
406
  }`,
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 {
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 {
343
553
  runtimeNotifications { ${NOTIFICATION_FIELDS} }
344
554
  }`,
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 {
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 {
476
760
  runtimeNotificationTriggered { ${TRIGGERED_NOTIFICATION_FIELDS} }
477
761
  }
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 {
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 {
495
784
  runtimeMessageReceived { ${PERSPECTIVE_EXPRESSION_FIELDS} }
496
785
  }
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
- }
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
+ }