@coasys/ad4m 0.12.0-rc1-dev → 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 -6044
  3. package/lib/index.js +5977 -6038
  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 -2797
  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 -3247
  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,17 +1,6 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _RuntimeClient_apolloClient, _RuntimeClient_messageReceivedCallbacks, _RuntimeClient_exceptionOccurredCallbacks, _RuntimeClient_notificationTriggeredCallbacks, _RuntimeClient_notificationRequestedCallbacks;
13
1
  import { gql } from "@apollo/client/core";
14
2
  import unwrapApolloResult from "../unwrapApolloResult";
3
+ import { isSocketCloseError } from "../utils";
15
4
  const PERSPECTIVE_EXPRESSION_FIELDS = `
16
5
  author
17
6
  timestamp
@@ -47,15 +36,10 @@ triggerMatch
47
36
  `;
48
37
  export class RuntimeClient {
49
38
  constructor(client, subscribe = true) {
50
- _RuntimeClient_apolloClient.set(this, void 0);
51
- _RuntimeClient_messageReceivedCallbacks.set(this, void 0);
52
- _RuntimeClient_exceptionOccurredCallbacks.set(this, void 0);
53
- _RuntimeClient_notificationTriggeredCallbacks.set(this, void 0);
54
- _RuntimeClient_notificationRequestedCallbacks.set(this, void 0);
55
- __classPrivateFieldSet(this, _RuntimeClient_apolloClient, client, "f");
56
- __classPrivateFieldSet(this, _RuntimeClient_messageReceivedCallbacks, [], "f");
57
- __classPrivateFieldSet(this, _RuntimeClient_exceptionOccurredCallbacks, [], "f");
58
- __classPrivateFieldSet(this, _RuntimeClient_notificationTriggeredCallbacks, [], "f");
39
+ this._apolloClient = client;
40
+ this._messageReceivedCallbacks = [];
41
+ this._exceptionOccurredCallbacks = [];
42
+ this._notificationTriggeredCallbacks = [];
59
43
  if (subscribe) {
60
44
  this.subscribeMessageReceived();
61
45
  this.subscribeExceptionOccurred();
@@ -63,190 +47,247 @@ export class RuntimeClient {
63
47
  }
64
48
  }
65
49
  async info() {
66
- const { runtimeInfo } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
67
- query: gql `query runtimeInfo {
68
- runtimeInfo {
69
- ad4mExecutorVersion,
70
- isInitialized,
71
- isUnlocked
72
- }
73
- }`,
50
+ const { runtimeInfo } = unwrapApolloResult(await this._apolloClient.query({
51
+ query: gql `
52
+ query runtimeInfo {
53
+ runtimeInfo {
54
+ ad4mExecutorVersion
55
+ isInitialized
56
+ isUnlocked
57
+ }
58
+ }
59
+ `,
74
60
  }));
75
61
  return runtimeInfo;
76
62
  }
77
63
  async quit() {
78
- const result = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
79
- mutation: gql `mutation runtimeQuit { runtimeQuit }`
64
+ const result = unwrapApolloResult(await this._apolloClient.mutate({
65
+ mutation: gql `
66
+ mutation runtimeQuit {
67
+ runtimeQuit
68
+ }
69
+ `,
80
70
  }));
81
71
  return result.runtimeQuit;
82
72
  }
83
73
  async openLink(url) {
84
- const { runtimeOpenLink } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
85
- mutation: gql `mutation runtimeOpenLink($url: String!) {
86
- runtimeOpenLink(url: $url)
87
- }`,
88
- variables: { url }
74
+ const { runtimeOpenLink } = unwrapApolloResult(await this._apolloClient.mutate({
75
+ mutation: gql `
76
+ mutation runtimeOpenLink($url: String!) {
77
+ runtimeOpenLink(url: $url)
78
+ }
79
+ `,
80
+ variables: { url },
89
81
  }));
90
82
  return runtimeOpenLink;
91
83
  }
92
84
  async addTrustedAgents(agents) {
93
- const { addTrustedAgents } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
94
- mutation: gql `mutation addTrustedAgents($agents: [String!]!) {
95
- addTrustedAgents(agents: $agents)
96
- }`,
97
- variables: { agents }
85
+ const { addTrustedAgents } = unwrapApolloResult(await this._apolloClient.mutate({
86
+ mutation: gql `
87
+ mutation addTrustedAgents($agents: [String!]!) {
88
+ addTrustedAgents(agents: $agents)
89
+ }
90
+ `,
91
+ variables: { agents },
98
92
  }));
99
93
  return addTrustedAgents;
100
94
  }
101
95
  async deleteTrustedAgents(agents) {
102
- const { deleteTrustedAgents } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
103
- mutation: gql `mutation deleteTrustedAgents($agents: [String!]!) {
104
- deleteTrustedAgents(agents: $agents)
105
- }`,
106
- variables: { agents }
96
+ const { deleteTrustedAgents } = unwrapApolloResult(await this._apolloClient.mutate({
97
+ mutation: gql `
98
+ mutation deleteTrustedAgents($agents: [String!]!) {
99
+ deleteTrustedAgents(agents: $agents)
100
+ }
101
+ `,
102
+ variables: { agents },
107
103
  }));
108
104
  return deleteTrustedAgents;
109
105
  }
110
106
  async getTrustedAgents() {
111
- const { getTrustedAgents } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
112
- query: gql `query getTrustedAgents {
113
- getTrustedAgents
114
- }`,
107
+ const { getTrustedAgents } = unwrapApolloResult(await this._apolloClient.query({
108
+ query: gql `
109
+ query getTrustedAgents {
110
+ getTrustedAgents
111
+ }
112
+ `,
115
113
  }));
116
114
  return getTrustedAgents;
117
115
  }
118
116
  async addKnownLinkLanguageTemplates(addresses) {
119
- const { runtimeAddKnownLinkLanguageTemplates } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
120
- mutation: gql `mutation runtimeAddKnownLinkLanguageTemplates($addresses: [String!]!) {
121
- runtimeAddKnownLinkLanguageTemplates(addresses: $addresses)
122
- }`,
123
- variables: { addresses }
117
+ const { runtimeAddKnownLinkLanguageTemplates } = unwrapApolloResult(await this._apolloClient.mutate({
118
+ mutation: gql `
119
+ mutation runtimeAddKnownLinkLanguageTemplates(
120
+ $addresses: [String!]!
121
+ ) {
122
+ runtimeAddKnownLinkLanguageTemplates(addresses: $addresses)
123
+ }
124
+ `,
125
+ variables: { addresses },
124
126
  }));
125
127
  return runtimeAddKnownLinkLanguageTemplates;
126
128
  }
127
129
  async removeKnownLinkLanguageTemplates(addresses) {
128
- const { runtimeRemoveKnownLinkLanguageTemplates } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
129
- mutation: gql `mutation runtimeRemoveKnownLinkLanguageTemplates($addresses: [String!]!) {
130
- runtimeRemoveKnownLinkLanguageTemplates(addresses: $addresses)
131
- }`,
132
- variables: { addresses }
130
+ const { runtimeRemoveKnownLinkLanguageTemplates } = unwrapApolloResult(await this._apolloClient.mutate({
131
+ mutation: gql `
132
+ mutation runtimeRemoveKnownLinkLanguageTemplates(
133
+ $addresses: [String!]!
134
+ ) {
135
+ runtimeRemoveKnownLinkLanguageTemplates(addresses: $addresses)
136
+ }
137
+ `,
138
+ variables: { addresses },
133
139
  }));
134
140
  return runtimeRemoveKnownLinkLanguageTemplates;
135
141
  }
136
142
  async knownLinkLanguageTemplates() {
137
- const { runtimeKnownLinkLanguageTemplates } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
138
- query: gql `query runtimeKnownLinkLanguageTemplates {
139
- runtimeKnownLinkLanguageTemplates
140
- }`,
143
+ const { runtimeKnownLinkLanguageTemplates } = unwrapApolloResult(await this._apolloClient.query({
144
+ query: gql `
145
+ query runtimeKnownLinkLanguageTemplates {
146
+ runtimeKnownLinkLanguageTemplates
147
+ }
148
+ `,
141
149
  }));
142
150
  return runtimeKnownLinkLanguageTemplates;
143
151
  }
144
152
  async addFriends(dids) {
145
- const { runtimeAddFriends } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
146
- mutation: gql `mutation runtimeAddFriends($dids: [String!]!) {
147
- runtimeAddFriends(dids: $dids)
148
- }`,
149
- variables: { dids }
153
+ const { runtimeAddFriends } = unwrapApolloResult(await this._apolloClient.mutate({
154
+ mutation: gql `
155
+ mutation runtimeAddFriends($dids: [String!]!) {
156
+ runtimeAddFriends(dids: $dids)
157
+ }
158
+ `,
159
+ variables: { dids },
150
160
  }));
151
161
  return runtimeAddFriends;
152
162
  }
153
163
  async removeFriends(dids) {
154
- const { runtimeRemoveFriends } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
155
- mutation: gql `mutation runtimeRemoveFriends($dids: [String!]!) {
156
- runtimeRemoveFriends(dids: $dids)
157
- }`,
158
- variables: { dids }
164
+ const { runtimeRemoveFriends } = unwrapApolloResult(await this._apolloClient.mutate({
165
+ mutation: gql `
166
+ mutation runtimeRemoveFriends($dids: [String!]!) {
167
+ runtimeRemoveFriends(dids: $dids)
168
+ }
169
+ `,
170
+ variables: { dids },
159
171
  }));
160
172
  return runtimeRemoveFriends;
161
173
  }
162
174
  async friends() {
163
- const { runtimeFriends } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
164
- query: gql `query runtimeFriends {
165
- runtimeFriends
166
- }`,
175
+ const { runtimeFriends } = unwrapApolloResult(await this._apolloClient.query({
176
+ query: gql `
177
+ query runtimeFriends {
178
+ runtimeFriends
179
+ }
180
+ `,
167
181
  }));
168
182
  return runtimeFriends;
169
183
  }
170
184
  async hcAgentInfos() {
171
- const { runtimeHcAgentInfos } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
172
- query: gql `query runtimeHcAgentInfos {
173
- runtimeHcAgentInfos
174
- }`,
185
+ const { runtimeHcAgentInfos } = unwrapApolloResult(await this._apolloClient.query({
186
+ query: gql `
187
+ query runtimeHcAgentInfos {
188
+ runtimeHcAgentInfos
189
+ }
190
+ `,
175
191
  }));
176
192
  return runtimeHcAgentInfos;
177
193
  }
178
194
  async getNetworkMetrics() {
179
- const { runtimeGetNetworkMetrics } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
180
- query: gql `query runtimeGetNetworkMetrics {
181
- runtimeGetNetworkMetrics
182
- }`,
195
+ const { runtimeGetNetworkMetrics } = unwrapApolloResult(await this._apolloClient.query({
196
+ query: gql `
197
+ query runtimeGetNetworkMetrics {
198
+ runtimeGetNetworkMetrics
199
+ }
200
+ `,
183
201
  }));
184
202
  return runtimeGetNetworkMetrics;
185
203
  }
186
204
  async restartHolochain() {
187
- const { runtimeRestartHolochain } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
188
- mutation: gql `mutation runtimeRestartHolochain {
189
- runtimeRestartHolochain
190
- }`,
205
+ const { runtimeRestartHolochain } = unwrapApolloResult(await this._apolloClient.mutate({
206
+ mutation: gql `
207
+ mutation runtimeRestartHolochain {
208
+ runtimeRestartHolochain
209
+ }
210
+ `,
191
211
  }));
192
212
  return runtimeRestartHolochain;
193
213
  }
194
214
  async hcAddAgentInfos(agentInfos) {
195
- const { runtimeHcAddAgentInfos } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
196
- mutation: gql `mutation runtimeHcAddAgentInfos($agentInfos: String!) {
197
- runtimeHcAddAgentInfos(agentInfos: $agentInfos)
198
- }`,
199
- variables: { agentInfos }
215
+ const { runtimeHcAddAgentInfos } = unwrapApolloResult(await this._apolloClient.mutate({
216
+ mutation: gql `
217
+ mutation runtimeHcAddAgentInfos($agentInfos: String!) {
218
+ runtimeHcAddAgentInfos(agentInfos: $agentInfos)
219
+ }
220
+ `,
221
+ variables: { agentInfos },
200
222
  }));
201
223
  return runtimeHcAddAgentInfos;
202
224
  }
203
225
  async verifyStringSignedByDid(did, didSigningKeyId, data, signedData) {
204
- const { runtimeVerifyStringSignedByDid } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
205
- mutation: gql `query runtimeVerifyStringSignedByDid($did: String!, $didSigningKeyId: String!, $data: String!, $signedData: String!) {
206
- runtimeVerifyStringSignedByDid(did: $did, didSigningKeyId: $didSigningKeyId, data: $data, signedData: $signedData)
207
- }`,
208
- variables: { did, didSigningKeyId, data, signedData }
226
+ const { runtimeVerifyStringSignedByDid } = unwrapApolloResult(await this._apolloClient.mutate({
227
+ mutation: gql `
228
+ query runtimeVerifyStringSignedByDid(
229
+ $did: String!
230
+ $didSigningKeyId: String!
231
+ $data: String!
232
+ $signedData: String!
233
+ ) {
234
+ runtimeVerifyStringSignedByDid(
235
+ did: $did
236
+ didSigningKeyId: $didSigningKeyId
237
+ data: $data
238
+ signedData: $signedData
239
+ )
240
+ }
241
+ `,
242
+ variables: { did, didSigningKeyId, data, signedData },
209
243
  }));
210
244
  return runtimeVerifyStringSignedByDid;
211
245
  }
212
246
  async setStatus(perspective) {
213
- const { runtimeSetStatus } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
214
- mutation: gql `mutation runtimeSetStatus($status: PerspectiveInput!) {
215
- runtimeSetStatus(status: $status)
216
- }`,
217
- variables: { status: perspective }
247
+ const { runtimeSetStatus } = unwrapApolloResult(await this._apolloClient.mutate({
248
+ mutation: gql `
249
+ mutation runtimeSetStatus($status: PerspectiveInput!) {
250
+ runtimeSetStatus(status: $status)
251
+ }
252
+ `,
253
+ variables: { status: perspective },
218
254
  }));
219
255
  return runtimeSetStatus;
220
256
  }
221
257
  async friendStatus(did) {
222
- const { runtimeFriendStatus } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
258
+ const { runtimeFriendStatus } = unwrapApolloResult(await this._apolloClient.query({
223
259
  query: gql `query runtimeFriendStatus($did: String!) {
224
260
  runtimeFriendStatus(did: $did) { ${PERSPECTIVE_EXPRESSION_FIELDS} }
225
261
  }`,
226
- variables: { did }
262
+ variables: { did },
227
263
  }));
228
264
  return runtimeFriendStatus;
229
265
  }
230
266
  async friendSendMessage(did, message) {
231
- const { runtimeFriendSendMessage } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
232
- mutation: gql `mutation runtimeFriendSendMessage($did: String!, $message: PerspectiveInput!) {
233
- runtimeFriendSendMessage(did: $did, message: $message)
234
- }`,
235
- variables: { did, message }
267
+ const { runtimeFriendSendMessage } = unwrapApolloResult(await this._apolloClient.mutate({
268
+ mutation: gql `
269
+ mutation runtimeFriendSendMessage(
270
+ $did: String!
271
+ $message: PerspectiveInput!
272
+ ) {
273
+ runtimeFriendSendMessage(did: $did, message: $message)
274
+ }
275
+ `,
276
+ variables: { did, message },
236
277
  }));
237
278
  return runtimeFriendSendMessage;
238
279
  }
239
280
  async messageInbox(filter) {
240
- const { runtimeMessageInbox } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
281
+ const { runtimeMessageInbox } = unwrapApolloResult(await this._apolloClient.query({
241
282
  query: gql `query runtimeMessageInbox($filter: String) {
242
283
  runtimeMessageInbox(filter: $filter) { ${PERSPECTIVE_EXPRESSION_FIELDS} }
243
284
  }`,
244
- variables: { filter }
285
+ variables: { filter },
245
286
  }));
246
287
  return runtimeMessageInbox;
247
288
  }
248
289
  async messageOutbox(filter) {
249
- const { runtimeMessageOutbox } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
290
+ const { runtimeMessageOutbox } = unwrapApolloResult(await this._apolloClient.query({
250
291
  query: gql `query runtimeMessageOutbox($filter: String) {
251
292
  runtimeMessageOutbox(filter: $filter) {
252
293
  recipient,
@@ -255,60 +296,136 @@ export class RuntimeClient {
255
296
  }
256
297
  }
257
298
  }`,
258
- variables: { filter }
299
+ variables: { filter },
259
300
  }));
260
301
  return runtimeMessageOutbox;
261
302
  }
262
303
  async requestInstallNotification(notification) {
263
- const { runtimeRequestInstallNotification } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
264
- mutation: gql `mutation runtimeRequestInstallNotification($notification: NotificationInput!) {
265
- runtimeRequestInstallNotification(notification: $notification)
266
- }`,
267
- variables: { notification }
304
+ const { runtimeRequestInstallNotification } = unwrapApolloResult(await this._apolloClient.mutate({
305
+ mutation: gql `
306
+ mutation runtimeRequestInstallNotification(
307
+ $notification: NotificationInput!
308
+ ) {
309
+ runtimeRequestInstallNotification(notification: $notification)
310
+ }
311
+ `,
312
+ variables: { notification },
268
313
  }));
269
314
  return runtimeRequestInstallNotification;
270
315
  }
271
316
  async grantNotification(id) {
272
- const { runtimeGrantNotification } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
273
- mutation: gql `mutation runtimeGrantNotification($id: String!) {
274
- runtimeGrantNotification(id: $id)
275
- }`,
276
- variables: { id }
317
+ const { runtimeGrantNotification } = unwrapApolloResult(await this._apolloClient.mutate({
318
+ mutation: gql `
319
+ mutation runtimeGrantNotification($id: String!) {
320
+ runtimeGrantNotification(id: $id)
321
+ }
322
+ `,
323
+ variables: { id },
277
324
  }));
278
325
  return runtimeGrantNotification;
279
326
  }
280
327
  async exportDb(filePath) {
281
- const { runtimeExportDb } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
282
- mutation: gql `mutation runtimeExportDb($filePath: String!) {
283
- runtimeExportDb(filePath: $filePath)
284
- }`,
285
- variables: { filePath }
328
+ const { runtimeExportDb } = unwrapApolloResult(await this._apolloClient.mutate({
329
+ mutation: gql `
330
+ mutation runtimeExportDb($filePath: String!) {
331
+ runtimeExportDb(filePath: $filePath)
332
+ }
333
+ `,
334
+ variables: { filePath },
286
335
  }));
287
336
  return runtimeExportDb;
288
337
  }
289
338
  async importDb(filePath) {
290
- const { runtimeImportDb } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
291
- mutation: gql `mutation runtimeImportDb($filePath: String!) {
292
- runtimeImportDb(filePath: $filePath) {
293
- perspectives { total imported failed omitted errors }
294
- links { total imported failed omitted errors }
295
- expressions { total imported failed omitted errors }
296
- perspectiveDiffs { total imported failed omitted errors }
297
- notifications { total imported failed omitted errors }
298
- models { total imported failed omitted errors }
299
- defaultModels { total imported failed omitted errors }
300
- tasks { total imported failed omitted errors }
301
- friends { total imported failed omitted errors }
302
- trustedAgents { total imported failed omitted errors }
303
- knownLinkLanguages { total imported failed omitted errors }
304
- }
305
- }`,
306
- variables: { filePath }
339
+ const { runtimeImportDb } = unwrapApolloResult(await this._apolloClient.mutate({
340
+ mutation: gql `
341
+ mutation runtimeImportDb($filePath: String!) {
342
+ runtimeImportDb(filePath: $filePath) {
343
+ perspectives {
344
+ total
345
+ imported
346
+ failed
347
+ omitted
348
+ errors
349
+ }
350
+ links {
351
+ total
352
+ imported
353
+ failed
354
+ omitted
355
+ errors
356
+ }
357
+ expressions {
358
+ total
359
+ imported
360
+ failed
361
+ omitted
362
+ errors
363
+ }
364
+ perspectiveDiffs {
365
+ total
366
+ imported
367
+ failed
368
+ omitted
369
+ errors
370
+ }
371
+ notifications {
372
+ total
373
+ imported
374
+ failed
375
+ omitted
376
+ errors
377
+ }
378
+ models {
379
+ total
380
+ imported
381
+ failed
382
+ omitted
383
+ errors
384
+ }
385
+ defaultModels {
386
+ total
387
+ imported
388
+ failed
389
+ omitted
390
+ errors
391
+ }
392
+ tasks {
393
+ total
394
+ imported
395
+ failed
396
+ omitted
397
+ errors
398
+ }
399
+ friends {
400
+ total
401
+ imported
402
+ failed
403
+ omitted
404
+ errors
405
+ }
406
+ trustedAgents {
407
+ total
408
+ imported
409
+ failed
410
+ omitted
411
+ errors
412
+ }
413
+ knownLinkLanguages {
414
+ total
415
+ imported
416
+ failed
417
+ omitted
418
+ errors
419
+ }
420
+ }
421
+ }
422
+ `,
423
+ variables: { filePath },
307
424
  }));
308
425
  return runtimeImportDb;
309
426
  }
310
427
  async notifications() {
311
- const { runtimeNotifications } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
428
+ const { runtimeNotifications } = unwrapApolloResult(await this._apolloClient.query({
312
429
  query: gql `query runtimeNotifications {
313
430
  runtimeNotifications { ${NOTIFICATION_FIELDS} }
314
431
  }`,
@@ -316,170 +433,227 @@ export class RuntimeClient {
316
433
  return runtimeNotifications;
317
434
  }
318
435
  async updateNotification(id, notification) {
319
- const { runtimeUpdateNotification } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
320
- mutation: gql `mutation runtimeUpdateNotification($id: String!, $notification: NotificationInput!) {
321
- runtimeUpdateNotification(id: $id, notification: $notification)
322
- }`,
323
- variables: { id, notification }
436
+ const { runtimeUpdateNotification } = unwrapApolloResult(await this._apolloClient.mutate({
437
+ mutation: gql `
438
+ mutation runtimeUpdateNotification(
439
+ $id: String!
440
+ $notification: NotificationInput!
441
+ ) {
442
+ runtimeUpdateNotification(id: $id, notification: $notification)
443
+ }
444
+ `,
445
+ variables: { id, notification },
324
446
  }));
325
447
  return runtimeUpdateNotification;
326
448
  }
327
449
  async removeNotification(id) {
328
- const { runtimeRemoveNotification } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
329
- mutation: gql `mutation runtimeRemoveNotification($id: String!) {
330
- runtimeRemoveNotification(id: $id)
331
- }`,
332
- variables: { id }
450
+ const { runtimeRemoveNotification } = unwrapApolloResult(await this._apolloClient.mutate({
451
+ mutation: gql `
452
+ mutation runtimeRemoveNotification($id: String!) {
453
+ runtimeRemoveNotification(id: $id)
454
+ }
455
+ `,
456
+ variables: { id },
333
457
  }));
334
458
  return runtimeRemoveNotification;
335
459
  }
336
460
  async exportPerspective(uuid, filePath) {
337
- const { runtimeExportPerspective } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
338
- mutation: gql `mutation runtimeExportPerspective($perspectiveUuid: String!, $filePath: String!) {
339
- runtimeExportPerspective(perspectiveUuid: $perspectiveUuid, filePath: $filePath)
340
- }`,
341
- variables: { perspectiveUuid: uuid, filePath }
461
+ const { runtimeExportPerspective } = unwrapApolloResult(await this._apolloClient.mutate({
462
+ mutation: gql `
463
+ mutation runtimeExportPerspective(
464
+ $perspectiveUuid: String!
465
+ $filePath: String!
466
+ ) {
467
+ runtimeExportPerspective(
468
+ perspectiveUuid: $perspectiveUuid
469
+ filePath: $filePath
470
+ )
471
+ }
472
+ `,
473
+ variables: { perspectiveUuid: uuid, filePath },
342
474
  }));
343
475
  return runtimeExportPerspective;
344
476
  }
345
477
  async importPerspective(filePath) {
346
- const { runtimeImportPerspective } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
347
- mutation: gql `mutation runtimeImportPerspective($filePath: String!) {
348
- runtimeImportPerspective(filePath: $filePath)
349
- }`,
350
- variables: { filePath }
478
+ const { runtimeImportPerspective } = unwrapApolloResult(await this._apolloClient.mutate({
479
+ mutation: gql `
480
+ mutation runtimeImportPerspective($filePath: String!) {
481
+ runtimeImportPerspective(filePath: $filePath)
482
+ }
483
+ `,
484
+ variables: { filePath },
351
485
  }));
352
486
  return runtimeImportPerspective;
353
487
  }
354
488
  async multiUserEnabled() {
355
- const { runtimeMultiUserEnabled } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
356
- query: gql `query runtimeMultiUserEnabled {
357
- runtimeMultiUserEnabled
358
- }`,
489
+ const { runtimeMultiUserEnabled } = unwrapApolloResult(await this._apolloClient.query({
490
+ query: gql `
491
+ query runtimeMultiUserEnabled {
492
+ runtimeMultiUserEnabled
493
+ }
494
+ `,
359
495
  }));
360
496
  return runtimeMultiUserEnabled;
361
497
  }
362
498
  async setMultiUserEnabled(enabled) {
363
- const { runtimeSetMultiUserEnabled } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
364
- mutation: gql `mutation runtimeSetMultiUserEnabled($enabled: Boolean!) {
365
- runtimeSetMultiUserEnabled(enabled: $enabled)
366
- }`,
367
- variables: { enabled }
499
+ const { runtimeSetMultiUserEnabled } = unwrapApolloResult(await this._apolloClient.mutate({
500
+ mutation: gql `
501
+ mutation runtimeSetMultiUserEnabled($enabled: Boolean!) {
502
+ runtimeSetMultiUserEnabled(enabled: $enabled)
503
+ }
504
+ `,
505
+ variables: { enabled },
368
506
  }));
369
507
  return runtimeSetMultiUserEnabled;
370
508
  }
371
509
  async listUsers() {
372
- const { runtimeListUsers } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
373
- query: gql `query runtimeListUsers {
374
- runtimeListUsers {
375
- email
376
- did
377
- lastSeen
378
- perspectiveCount
379
- }
380
- }`
510
+ const { runtimeListUsers } = unwrapApolloResult(await this._apolloClient.query({
511
+ query: gql `
512
+ query runtimeListUsers {
513
+ runtimeListUsers {
514
+ email
515
+ did
516
+ lastSeen
517
+ perspectiveCount
518
+ }
519
+ }
520
+ `,
381
521
  }));
382
522
  return runtimeListUsers;
383
523
  }
384
524
  async emailTestModeEnable() {
385
- const { runtimeEmailTestModeEnable } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
386
- mutation: gql `mutation runtimeEmailTestModeEnable {
387
- runtimeEmailTestModeEnable
388
- }`
525
+ const { runtimeEmailTestModeEnable } = unwrapApolloResult(await this._apolloClient.mutate({
526
+ mutation: gql `
527
+ mutation runtimeEmailTestModeEnable {
528
+ runtimeEmailTestModeEnable
529
+ }
530
+ `,
389
531
  }));
390
532
  return runtimeEmailTestModeEnable;
391
533
  }
392
534
  async emailTestModeDisable() {
393
- const { runtimeEmailTestModeDisable } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
394
- mutation: gql `mutation runtimeEmailTestModeDisable {
395
- runtimeEmailTestModeDisable
396
- }`
535
+ const { runtimeEmailTestModeDisable } = unwrapApolloResult(await this._apolloClient.mutate({
536
+ mutation: gql `
537
+ mutation runtimeEmailTestModeDisable {
538
+ runtimeEmailTestModeDisable
539
+ }
540
+ `,
397
541
  }));
398
542
  return runtimeEmailTestModeDisable;
399
543
  }
400
544
  async emailTestGetCode(email) {
401
- const { runtimeEmailTestGetCode } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
402
- mutation: gql `mutation runtimeEmailTestGetCode($email: String!) {
403
- runtimeEmailTestGetCode(email: $email)
404
- }`,
405
- variables: { email }
545
+ const { runtimeEmailTestGetCode } = unwrapApolloResult(await this._apolloClient.mutate({
546
+ mutation: gql `
547
+ mutation runtimeEmailTestGetCode($email: String!) {
548
+ runtimeEmailTestGetCode(email: $email)
549
+ }
550
+ `,
551
+ variables: { email },
406
552
  }));
407
553
  return runtimeEmailTestGetCode;
408
554
  }
409
555
  async emailTestClearCodes() {
410
- const { runtimeEmailTestClearCodes } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
411
- mutation: gql `mutation runtimeEmailTestClearCodes {
412
- runtimeEmailTestClearCodes
413
- }`
556
+ const { runtimeEmailTestClearCodes } = unwrapApolloResult(await this._apolloClient.mutate({
557
+ mutation: gql `
558
+ mutation runtimeEmailTestClearCodes {
559
+ runtimeEmailTestClearCodes
560
+ }
561
+ `,
414
562
  }));
415
563
  return runtimeEmailTestClearCodes;
416
564
  }
417
565
  async emailTestSetExpiry(email, verificationType, expiresAt) {
418
- const { runtimeEmailTestSetExpiry } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
419
- mutation: gql `mutation runtimeEmailTestSetExpiry($email: String!, $verificationType: String!, $expiresAt: Int!) {
420
- runtimeEmailTestSetExpiry(email: $email, verificationType: $verificationType, expiresAt: $expiresAt)
421
- }`,
422
- variables: { email, verificationType, expiresAt }
566
+ const { runtimeEmailTestSetExpiry } = unwrapApolloResult(await this._apolloClient.mutate({
567
+ mutation: gql `
568
+ mutation runtimeEmailTestSetExpiry(
569
+ $email: String!
570
+ $verificationType: String!
571
+ $expiresAt: Int!
572
+ ) {
573
+ runtimeEmailTestSetExpiry(
574
+ email: $email
575
+ verificationType: $verificationType
576
+ expiresAt: $expiresAt
577
+ )
578
+ }
579
+ `,
580
+ variables: { email, verificationType, expiresAt },
423
581
  }));
424
582
  return runtimeEmailTestSetExpiry;
425
583
  }
426
584
  addNotificationTriggeredCallback(cb) {
427
- __classPrivateFieldGet(this, _RuntimeClient_notificationTriggeredCallbacks, "f").push(cb);
585
+ this._notificationTriggeredCallbacks.push(cb);
428
586
  }
429
587
  subscribeNotificationTriggered() {
430
- __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").subscribe({
588
+ this._apolloClient
589
+ .subscribe({
431
590
  query: gql ` subscription {
432
591
  runtimeNotificationTriggered { ${TRIGGERED_NOTIFICATION_FIELDS} }
433
592
  }
434
- `
435
- }).subscribe({
436
- next: result => {
437
- __classPrivateFieldGet(this, _RuntimeClient_notificationTriggeredCallbacks, "f").forEach(cb => {
593
+ `,
594
+ })
595
+ .subscribe({
596
+ next: (result) => {
597
+ this._notificationTriggeredCallbacks.forEach((cb) => {
438
598
  cb(result.data.runtimeNotificationTriggered);
439
599
  });
440
600
  },
441
- error: (e) => console.error(e)
601
+ error: (e) => {
602
+ if (!isSocketCloseError(e))
603
+ console.error(e);
604
+ },
442
605
  });
443
606
  }
444
607
  addMessageCallback(cb) {
445
- __classPrivateFieldGet(this, _RuntimeClient_messageReceivedCallbacks, "f").push(cb);
608
+ this._messageReceivedCallbacks.push(cb);
446
609
  }
447
610
  subscribeMessageReceived() {
448
- __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").subscribe({
611
+ this._apolloClient
612
+ .subscribe({
449
613
  query: gql ` subscription {
450
614
  runtimeMessageReceived { ${PERSPECTIVE_EXPRESSION_FIELDS} }
451
615
  }
452
- `
453
- }).subscribe({
454
- next: result => {
455
- __classPrivateFieldGet(this, _RuntimeClient_messageReceivedCallbacks, "f").forEach(cb => {
616
+ `,
617
+ })
618
+ .subscribe({
619
+ next: (result) => {
620
+ this._messageReceivedCallbacks.forEach((cb) => {
456
621
  cb(result.data.runtimeMessageReceived);
457
622
  });
458
623
  },
459
- error: (e) => console.error(e)
624
+ error: (e) => {
625
+ if (!isSocketCloseError(e))
626
+ console.error(e);
627
+ },
460
628
  });
461
629
  }
462
630
  addExceptionCallback(cb) {
463
- __classPrivateFieldGet(this, _RuntimeClient_exceptionOccurredCallbacks, "f").push(cb);
631
+ this._exceptionOccurredCallbacks.push(cb);
464
632
  }
465
633
  subscribeExceptionOccurred() {
466
- __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").subscribe({
467
- query: gql ` subscription {
468
- exceptionOccurred {
469
- title
470
- message
471
- type
472
- addon
473
- }
474
- }`
475
- }).subscribe({
476
- next: result => {
477
- __classPrivateFieldGet(this, _RuntimeClient_exceptionOccurredCallbacks, "f").forEach(cb => {
634
+ this._apolloClient
635
+ .subscribe({
636
+ query: gql `
637
+ subscription {
638
+ exceptionOccurred {
639
+ title
640
+ message
641
+ type
642
+ addon
643
+ }
644
+ }
645
+ `,
646
+ })
647
+ .subscribe({
648
+ next: (result) => {
649
+ this._exceptionOccurredCallbacks.forEach((cb) => {
478
650
  cb(result.data.exceptionOccurred);
479
651
  });
480
652
  },
481
- error: (e) => console.error(e)
653
+ error: (e) => {
654
+ if (!isSocketCloseError(e))
655
+ console.error(e);
656
+ },
482
657
  });
483
658
  }
484
659
  }
485
- _RuntimeClient_apolloClient = new WeakMap(), _RuntimeClient_messageReceivedCallbacks = new WeakMap(), _RuntimeClient_exceptionOccurredCallbacks = new WeakMap(), _RuntimeClient_notificationTriggeredCallbacks = new WeakMap(), _RuntimeClient_notificationRequestedCallbacks = new WeakMap();