@coasys/ad4m 0.10.0 → 0.10.1-multi-user-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/lib/index.cjs +3730 -906
  2. package/lib/index.js +3722 -902
  3. package/lib/src/Ad4mClient.js +2 -1
  4. package/lib/src/Literal.js +4 -1
  5. package/lib/src/agent/Agent.d.ts +12 -0
  6. package/lib/src/agent/Agent.js +48 -0
  7. package/lib/src/agent/AgentClient.d.ts +3 -1
  8. package/lib/src/agent/AgentClient.js +23 -0
  9. package/lib/src/ai/AIClient.d.ts +8 -2
  10. package/lib/src/ai/AIClient.js +25 -14
  11. package/lib/src/ai/AIResolver.d.ts +25 -6
  12. package/lib/src/ai/AIResolver.js +102 -18
  13. package/lib/src/index.d.ts +4 -3
  14. package/lib/src/index.js +4 -3
  15. package/lib/src/language/Language.d.ts +12 -1
  16. package/lib/src/model/Ad4mModel.d.ts +622 -0
  17. package/lib/src/model/Ad4mModel.js +1118 -0
  18. package/lib/src/{subject → model}/Subject.d.ts +2 -2
  19. package/lib/src/{subject → model}/Subject.js +18 -18
  20. package/lib/src/model/decorators.d.ts +502 -0
  21. package/lib/src/model/decorators.js +683 -0
  22. package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +2 -2
  23. package/lib/src/neighbourhood/NeighbourhoodClient.js +13 -10
  24. package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +2 -2
  25. package/lib/src/neighbourhood/NeighbourhoodProxy.js +4 -4
  26. package/lib/src/neighbourhood/NeighbourhoodProxy.test.d.ts +1 -0
  27. package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +73 -0
  28. package/lib/src/neighbourhood/NeighbourhoodResolver.d.ts +2 -2
  29. package/lib/src/neighbourhood/NeighbourhoodResolver.js +6 -4
  30. package/lib/src/perspectives/PerspectiveClient.d.ts +23 -11
  31. package/lib/src/perspectives/PerspectiveClient.js +147 -51
  32. package/lib/src/perspectives/PerspectiveProxy.d.ts +494 -54
  33. package/lib/src/perspectives/PerspectiveProxy.js +684 -67
  34. package/lib/src/perspectives/PerspectiveResolver.d.ts +24 -9
  35. package/lib/src/perspectives/PerspectiveResolver.js +151 -46
  36. package/lib/src/runtime/RuntimeClient.d.ts +11 -2
  37. package/lib/src/runtime/RuntimeClient.js +94 -0
  38. package/lib/src/runtime/RuntimeResolver.d.ts +36 -1
  39. package/lib/src/runtime/RuntimeResolver.js +193 -0
  40. package/lib/src/schema.gql +65 -16
  41. package/lib/src/typeDefs.js +65 -16
  42. package/package.json +4 -3
  43. package/src/Ad4mClient.test.ts +51 -19
  44. package/src/Ad4mClient.ts +3 -1
  45. package/src/Literal.ts +4 -1
  46. package/src/agent/Agent.ts +36 -0
  47. package/src/agent/AgentClient.ts +30 -0
  48. package/src/ai/AIClient.ts +35 -14
  49. package/src/ai/AIResolver.ts +78 -16
  50. package/src/index.ts +4 -3
  51. package/src/language/Language.ts +16 -4
  52. package/src/model/Ad4mModel.ts +1279 -0
  53. package/src/{subject → model}/Subject.ts +16 -16
  54. package/src/{subject/SDNADecorators.ts → model/decorators.ts} +384 -50
  55. package/src/neighbourhood/NeighbourhoodClient.ts +13 -10
  56. package/src/neighbourhood/NeighbourhoodProxy.test.ts +100 -0
  57. package/src/neighbourhood/NeighbourhoodProxy.ts +4 -4
  58. package/src/neighbourhood/NeighbourhoodResolver.ts +2 -2
  59. package/src/perspectives/PerspectiveClient.ts +156 -51
  60. package/src/perspectives/PerspectiveProxy.ts +766 -82
  61. package/src/perspectives/PerspectiveResolver.ts +134 -23
  62. package/src/runtime/RuntimeClient.ts +104 -2
  63. package/src/runtime/RuntimeResolver.ts +126 -1
  64. package/lib/src/subject/SDNADecorators.d.ts +0 -188
  65. package/lib/src/subject/SDNADecorators.js +0 -360
  66. package/lib/src/subject/SubjectEntity.d.ts +0 -102
  67. package/lib/src/subject/SubjectEntity.js +0 -267
  68. package/src/subject/SubjectEntity.ts +0 -315
  69. package/yarn-error.log +0 -90
  70. /package/lib/src/{subject → model}/util.d.ts +0 -0
  71. /package/lib/src/{subject → model}/util.js +0 -0
  72. /package/src/{subject → model}/util.ts +0 -0
@@ -1,4 +1,4 @@
1
- import { Arg, Mutation, PubSub, Query, Resolver, Subscription } from "type-graphql";
1
+ import { Arg, Mutation, PubSub, Query, Resolver, Root, Subscription, ObjectType, Field } from "type-graphql";
2
2
  import { LinkExpression, LinkExpressionInput, LinkExpressionMutations, LinkExpressionUpdated, LinkInput, LinkMutations } from "../links/Links";
3
3
  import { Neighbourhood, NeighbourhoodExpression } from "../neighbourhood/Neighbourhood";
4
4
  import { LinkQuery } from "./LinkQuery";
@@ -20,6 +20,17 @@ testLink.proof = {
20
20
  valid: true
21
21
  }
22
22
 
23
+ export const PERSPECTIVE_QUERY_SUBSCRIPTION = "PERSPECTIVE_QUERY_SUBSCRIPTION"
24
+
25
+ @ObjectType()
26
+ export class QuerySubscription {
27
+ @Field()
28
+ subscriptionId: string;
29
+
30
+ @Field()
31
+ result: string;
32
+ }
33
+
23
34
  /**
24
35
  * Resolver classes are used here to define the GraphQL schema
25
36
  * (through the type-graphql annotations)
@@ -72,10 +83,25 @@ export default class PerspectiveResolver {
72
83
  }
73
84
 
74
85
  @Query(returns => String)
75
- perspectiveQueryProlog(@Arg('uuid') uuid: string, @Arg('query') query: String): string {
86
+ async perspectiveQueryProlog(
87
+ @Arg('uuid') uuid: string,
88
+ @Arg('query') query: string
89
+ ): Promise<string> {
76
90
  return `[{"X": 1}]`
77
91
  }
78
92
 
93
+ @Mutation(returns => QuerySubscription)
94
+ async perspectiveSubscribeQuery(
95
+ @Arg('uuid') uuid: string,
96
+ @Arg('query') query: string
97
+ ): Promise<QuerySubscription> {
98
+ const result = `[{"X": 1}]`
99
+ return {
100
+ subscriptionId: "test-subscription-id",
101
+ result: result
102
+ }
103
+ }
104
+
79
105
  @Mutation(returns => PerspectiveHandle)
80
106
  perspectiveAdd(@Arg('name') name: string, @PubSub() pubSub: any): PerspectiveHandle {
81
107
  const perspective = new PerspectiveHandle('00006', name);
@@ -97,8 +123,28 @@ export default class PerspectiveResolver {
97
123
  return true
98
124
  }
99
125
 
126
+ @Mutation(returns => String)
127
+ async perspectiveCreateBatch(@Arg('uuid') uuid: string): Promise<string> {
128
+ const perspective = new PerspectiveHandle(uuid)
129
+ return uuid + '-batch-' + Date.now()
130
+ }
131
+
132
+ @Mutation(returns => LinkExpressionMutations)
133
+ async perspectiveCommitBatch(
134
+ @Arg('uuid') uuid: string,
135
+ @Arg('batchId') batchId: string
136
+ ): Promise<LinkExpressionMutations> {
137
+ return new LinkExpressionMutations([], [])
138
+ }
139
+
100
140
  @Mutation(returns => LinkExpression)
101
- perspectiveAddLink(@Arg('uuid') uuid: string, @Arg('link') link: LinkInput, @Arg('status', { nullable: true, defaultValue: 'shared'}) status: LinkStatus, @PubSub() pubSub: any): LinkExpression {
141
+ perspectiveAddLink(
142
+ @Arg('uuid') uuid: string,
143
+ @Arg('link') link: LinkInput,
144
+ @Arg('status', { nullable: true, defaultValue: 'shared' }) status: LinkStatus,
145
+ @Arg('batchId', { nullable: true }) batchId: string,
146
+ @PubSub() pubSub: any
147
+ ): LinkExpression {
102
148
  const l = new LinkExpression()
103
149
  l.author = 'did:ad4m:test'
104
150
  l.timestamp = Date.now()
@@ -112,26 +158,55 @@ export default class PerspectiveResolver {
112
158
  }
113
159
 
114
160
  @Mutation(returns => [LinkExpression])
115
- perspectiveAddLinks(@Arg('uuid') uuid: string, @Arg('links', type => [LinkInput]) links: LinkInput[], @Arg('status', { nullable: true}) status: string, @PubSub() pubSub: any): LinkExpression[] {
161
+ perspectiveAddLinks(
162
+ @Arg('uuid') uuid: string,
163
+ @Arg('links', type => [LinkInput]) links: LinkInput[],
164
+ @Arg('status', { nullable: true, defaultValue: 'shared' }) status: LinkStatus,
165
+ @Arg('batchId', { nullable: true }) batchId: string,
166
+ @PubSub() pubSub: any
167
+ ): LinkExpression[] {
116
168
  const l = new LinkExpression()
117
169
  l.author = 'did:ad4m:test'
118
170
  l.timestamp = Date.now()
119
171
  l.proof = testLink.proof
120
172
  l.data = links[0]
173
+ l.status = status
121
174
 
122
175
  const l2 = new LinkExpression()
123
176
  l2.author = 'did:ad4m:test'
124
177
  l2.timestamp = Date.now()
125
178
  l2.proof = testLink.proof
126
179
  l2.data = links[0]
180
+ l2.status = status
127
181
 
128
182
  pubSub.publish(LINK_ADDED_TOPIC, { link: l })
129
183
  pubSub.publish(LINK_ADDED_TOPIC, { link: l2 })
130
184
  return [l, l2]
131
185
  }
132
186
 
187
+ @Mutation(returns => Boolean)
188
+ perspectiveRemoveLink(
189
+ @Arg('uuid') uuid: string,
190
+ @Arg('link') link: LinkExpressionInput,
191
+ @Arg('batchId', { nullable: true }) batchId: string,
192
+ @PubSub() pubSub: any
193
+ ): Boolean {
194
+ const l = new LinkExpression()
195
+ l.author = 'did:ad4m:test'
196
+ l.timestamp = Date.now()
197
+ l.proof = testLink.proof
198
+ l.data = link.data
199
+ pubSub.publish(LINK_REMOVED_TOPIC, { link: l })
200
+ return true
201
+ }
202
+
133
203
  @Mutation(returns => [LinkExpression])
134
- perspectiveRemoveLinks(@Arg('uuid') uuid: string, @Arg('links', type => [LinkExpressionInput]) links: LinkExpressionInput[], @PubSub() pubSub: any): LinkExpression[] {
204
+ perspectiveRemoveLinks(
205
+ @Arg('uuid') uuid: string,
206
+ @Arg('links', type => [LinkExpressionInput]) links: LinkExpressionInput[],
207
+ @Arg('batchId', { nullable: true }) batchId: string,
208
+ @PubSub() pubSub: any
209
+ ): LinkExpression[] {
135
210
  const l = new LinkExpression()
136
211
  l.author = 'did:ad4m:test'
137
212
  l.timestamp = Date.now()
@@ -151,35 +226,40 @@ export default class PerspectiveResolver {
151
226
 
152
227
  @Mutation(returns => LinkExpressionMutations)
153
228
  perspectiveLinkMutations(@Arg('uuid') uuid: string, @Arg('mutations') mutations: LinkMutations, @Arg('status', { nullable: true}) status: LinkStatus, @PubSub() pubSub: any): LinkExpressionMutations {
154
- const perspectiveAddLinks = this.perspectiveAddLinks(uuid, mutations.additions, status, pubSub);
155
- const perspectiveRemoveLinks = this.perspectiveRemoveLinks(uuid, mutations.removals, pubSub);
229
+ const perspectiveAddLinks = this.perspectiveAddLinks(uuid, mutations.additions, status, null, pubSub);
230
+ const perspectiveRemoveLinks = this.perspectiveRemoveLinks(uuid, mutations.removals, null, pubSub);
156
231
  return new LinkExpressionMutations(perspectiveAddLinks, perspectiveRemoveLinks)
157
232
  }
158
233
 
159
234
  @Mutation(returns => LinkExpression)
160
- perspectiveAddLinkExpression(@Arg('uuid') uuid: string, @Arg('link') link: LinkExpressionInput, @Arg('status', { nullable: true}) status: LinkStatus, @PubSub() pubSub: any): LinkExpression {
161
- pubSub.publish(LINK_ADDED_TOPIC, { link })
162
- link.status = status;
163
- return link as LinkExpression
164
- }
165
-
166
- @Mutation(returns => LinkExpression)
167
- perspectiveUpdateLink(@Arg('uuid') uuid: string, @Arg('oldLink') oldlink: LinkExpressionInput, @Arg('newLink') newlink: LinkInput, @PubSub() pubSub: any): LinkExpression {
235
+ perspectiveUpdateLink(
236
+ @Arg('uuid') uuid: string,
237
+ @Arg('oldLink') oldLink: LinkExpressionInput,
238
+ @Arg('newLink') newLink: LinkInput,
239
+ @Arg('batchId', { nullable: true }) batchId: string,
240
+ @PubSub() pubSub: any
241
+ ): LinkExpression {
168
242
  const l = new LinkExpression()
169
243
  l.author = 'did:ad4m:test'
170
244
  l.timestamp = Date.now()
171
245
  l.proof = testLink.proof
172
- l.data = newlink
246
+ l.data = newLink
173
247
 
174
248
  pubSub.publish(LINK_REMOVED_TOPIC, { link: l })
175
-
176
249
  return l
177
250
  }
178
251
 
179
- @Mutation(returns => Boolean)
180
- perspectiveRemoveLink(@Arg('uuid') uuid: string, @Arg('link') link: LinkExpressionInput, @PubSub() pubSub: any): Boolean {
181
- pubSub.publish(LINK_REMOVED_TOPIC)
182
- return true
252
+ @Mutation(returns => LinkExpression)
253
+ perspectiveAddLinkExpression(
254
+ @Arg('uuid') uuid: string,
255
+ @Arg('link') link: LinkExpressionInput,
256
+ @Arg('status', { nullable: true, defaultValue: 'shared' }) status: LinkStatus,
257
+ @Arg('batchId', { nullable: true }) batchId: string,
258
+ @PubSub() pubSub: any
259
+ ): LinkExpression {
260
+ pubSub.publish(LINK_ADDED_TOPIC, { link })
261
+ link.status = status;
262
+ return link as LinkExpression
183
263
  }
184
264
 
185
265
  @Mutation(returns => Boolean)
@@ -192,7 +272,8 @@ export default class PerspectiveResolver {
192
272
  @Arg('uuid') uuid: string,
193
273
  @Arg('commands') commands: string,
194
274
  @Arg('expression') expression: string,
195
- @Arg('parameters', type => String, {nullable: true}) parameters: string
275
+ @Arg('parameters', type => String, {nullable: true}) parameters: string,
276
+ @Arg('batchId', { nullable: true }) batchId?: string,
196
277
  ): Boolean {
197
278
  return true
198
279
  }
@@ -201,7 +282,9 @@ export default class PerspectiveResolver {
201
282
  perspectiveCreateSubject(
202
283
  @Arg('uuid') uuid: string,
203
284
  @Arg('subjectClass') SubjectClass: string,
204
- @Arg('expressionAddress') expressionAddress: string
285
+ @Arg('expressionAddress') expressionAddress: string,
286
+ @Arg('initialValues', { nullable: true }) initialValues?: string,
287
+ @Arg('batchId', { nullable: true }) batchId?: string,
205
288
  ): Boolean {
206
289
  return true
207
290
  }
@@ -250,4 +333,32 @@ export default class PerspectiveResolver {
250
333
  perspectiveSyncStateChange(@Arg('uuid') uuid: string): PerspectiveState {
251
334
  return PerspectiveState.Synced
252
335
  }
336
+
337
+ @Mutation(returns => Boolean)
338
+ perspectiveKeepAliveQuery(
339
+ @Arg('uuid') uuid: string,
340
+ @Arg('subscriptionId') subscriptionId: string
341
+ ): boolean {
342
+ return true
343
+ }
344
+
345
+ @Subscription({
346
+ topics: PERSPECTIVE_QUERY_SUBSCRIPTION,
347
+ filter: ({ payload, args }) =>
348
+ payload.subscriptionId === args.subscriptionId
349
+ })
350
+ perspectiveQuerySubscription(
351
+ @Arg('subscriptionId') subscriptionId: string,
352
+ @Root() payload: { subscriptionId: string, uuid: string, result: string }
353
+ ): string {
354
+ return payload.result
355
+ }
356
+
357
+ @Mutation(returns => Boolean)
358
+ async perspectiveDisposeQuerySubscription(
359
+ @Arg('uuid') uuid: string,
360
+ @Arg('subscriptionId') subscriptionId: string
361
+ ): Promise<boolean> {
362
+ return true
363
+ }
253
364
  }
@@ -1,7 +1,7 @@
1
1
  import { ApolloClient, gql } from "@apollo/client/core"
2
2
  import { Perspective, PerspectiveExpression } from "../perspectives/Perspective"
3
3
  import unwrapApolloResult from "../unwrapApolloResult"
4
- import { RuntimeInfo, ExceptionInfo, SentMessage, NotificationInput, Notification, TriggeredNotification } from "./RuntimeResolver"
4
+ import { RuntimeInfo, ExceptionInfo, SentMessage, NotificationInput, Notification, TriggeredNotification, ImportResult, UserStatistics } from "./RuntimeResolver"
5
5
 
6
6
  const PERSPECTIVE_EXPRESSION_FIELDS = `
7
7
  author
@@ -183,7 +183,7 @@ export class RuntimeClient {
183
183
  return runtimeFriends
184
184
  }
185
185
 
186
- async hcAgentInfos(): Promise<String> {
186
+ async hcAgentInfos(): Promise<string> {
187
187
  const { runtimeHcAgentInfos } = unwrapApolloResult(await this.#apolloClient.query({
188
188
  query: gql`query runtimeHcAgentInfos {
189
189
  runtimeHcAgentInfos
@@ -192,6 +192,24 @@ export class RuntimeClient {
192
192
  return runtimeHcAgentInfos
193
193
  }
194
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
+
195
213
  async hcAddAgentInfos(agentInfos: String): Promise<void> {
196
214
  const { runtimeHcAddAgentInfos } = unwrapApolloResult(await this.#apolloClient.mutate({
197
215
  mutation: gql`mutation runtimeHcAddAgentInfos($agentInfos: String!) {
@@ -287,6 +305,38 @@ export class RuntimeClient {
287
305
  return runtimeGrantNotification
288
306
  }
289
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
+
290
340
  async notifications(): Promise<Notification[]> {
291
341
  const { runtimeNotifications } = unwrapApolloResult(await this.#apolloClient.query({
292
342
  query: gql`query runtimeNotifications {
@@ -316,6 +366,58 @@ export class RuntimeClient {
316
366
  return runtimeRemoveNotification
317
367
  }
318
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
+ }
319
421
 
320
422
  addNotificationTriggeredCallback(cb: NotificationTriggeredCallback) {
321
423
  this.#notificationTriggeredCallbacks.push(cb)
@@ -138,6 +138,75 @@ export class TriggeredNotification {
138
138
  triggerMatch: string;
139
139
  }
140
140
 
141
+ @ObjectType()
142
+ export class ImportStats {
143
+ @Field()
144
+ total: number;
145
+
146
+ @Field()
147
+ imported: number;
148
+
149
+ @Field()
150
+ failed: number;
151
+
152
+ @Field()
153
+ omitted: number;
154
+
155
+ @Field(type => [String])
156
+ errors: string[];
157
+ }
158
+
159
+ @ObjectType()
160
+ export class ImportResult {
161
+ @Field()
162
+ perspectives: ImportStats;
163
+
164
+ @Field()
165
+ links: ImportStats;
166
+
167
+ @Field()
168
+ expressions: ImportStats;
169
+
170
+ @Field()
171
+ perspectiveDiffs: ImportStats;
172
+
173
+ @Field()
174
+ notifications: ImportStats;
175
+
176
+ @Field()
177
+ models: ImportStats;
178
+
179
+ @Field()
180
+ defaultModels: ImportStats;
181
+
182
+ @Field()
183
+ tasks: ImportStats;
184
+
185
+ @Field()
186
+ friends: ImportStats;
187
+
188
+ @Field()
189
+ trustedAgents: ImportStats;
190
+
191
+ @Field()
192
+ knownLinkLanguages: ImportStats;
193
+ }
194
+
195
+ @ObjectType()
196
+ export class UserStatistics {
197
+ @Field()
198
+ email: string;
199
+
200
+ @Field()
201
+ did: string;
202
+
203
+ @Field({nullable: true})
204
+ lastSeen?: string;
205
+
206
+ @Field(type => Int)
207
+ perspectiveCount: number;
208
+ }
209
+
141
210
  /**
142
211
  * Resolver classes are used here to define the GraphQL schema
143
212
  * (through the type-graphql annotations)
@@ -211,10 +280,23 @@ export default class RuntimeResolver {
211
280
  }
212
281
 
213
282
  @Query()
214
- runtimeHcAgentInfos(): String {
283
+ runtimeHcAgentInfos(): string {
215
284
  return JSON.stringify([{"agent":{"type":"Buffer","data":[9,191,231,58,255,107,202,55,206,57,9,103,17,34,206,195,207,114,5,73,77,198,56,136,17,227,242,231,194,135,128,48,170,189,119,186]},"signature":{"type":"Buffer","data":[195,143,170,36,234,123,255,85,188,138,124,2,91,18,53,231,44,41,240,8,80,131,100,150,165,125,146,90,17,200,190,129,114,211,11,146,150,128,198,199,79,118,157,101,194,68,58,245,98,182,79,139,140,41,143,129,8,136,87,77,180,231,218,11]},"agent_info":{"type":"Buffer","data":[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,9,191,231,58,255,107,202,55,206,57,9,103,17,34,206,195,207,114,5,73,77,198,56,136,17,227,242,231,194,135,128,48,170,189,119,186,164,117,114,108,115,145,217,99,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,101,83,52,86,112,54,109,118,80,48,122,116,85,101,104,114,117,113,89,52,102,66,53,101,69,98,121,48,69,66,100,89,84,50,95,67,48,69,112,77,111,76,111,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,57,50,46,49,54,56,46,49,55,56,46,54,48,47,112,47,55,55,52,52,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,104,189,50,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}},{"agent":{"type":"Buffer","data":[98,187,145,48,115,209,94,143,31,153,102,69,138,29,133,213,34,52,39,164,157,139,178,111,23,33,118,250,28,155,78,246,128,49,179,38]},"signature":{"type":"Buffer","data":[233,192,38,3,59,248,124,231,57,255,40,154,50,60,119,252,68,198,154,109,175,155,106,217,211,155,109,223,249,91,221,210,17,132,72,230,11,230,247,119,72,244,145,91,75,7,67,5,130,151,44,231,52,220,28,154,212,82,58,90,203,211,236,4]},"agent_info":{"type":"Buffer","data":[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,98,187,145,48,115,209,94,143,31,153,102,69,138,29,133,213,34,52,39,164,157,139,178,111,23,33,118,250,28,155,78,246,128,49,179,38,164,117,114,108,115,145,217,99,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,55,101,77,106,48,73,83,72,56,56,81,56,45,89,51,74,89,70,53,76,72,57,83,54,68,119,71,73,49,88,45,115,87,53,68,104,66,87,121,71,119,78,115,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,57,50,46,49,54,56,46,49,55,56,46,54,48,47,112,47,55,55,52,52,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,103,45,197,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}},{"agent":{"type":"Buffer","data":[181,101,115,45,214,127,198,153,159,184,30,87,67,224,208,184,203,176,130,158,236,127,153,125,243,183,188,167,154,25,118,254,101,145,210,109]},"signature":{"type":"Buffer","data":[88,189,229,122,44,171,194,156,90,79,148,49,207,224,34,199,219,88,24,243,103,127,123,41,87,171,127,92,6,216,198,171,26,226,237,217,122,78,98,146,55,255,68,240,202,83,58,140,147,185,3,66,15,216,210,22,99,197,73,234,120,17,74,1]},"agent_info":{"type":"Buffer","data":[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,181,101,115,45,214,127,198,153,159,184,30,87,67,224,208,184,203,176,130,158,236,127,153,125,243,183,188,167,154,25,118,254,101,145,210,109,164,117,114,108,115,145,217,99,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,114,70,71,83,100,113,104,101,68,107,70,70,56,69,102,109,45,69,116,55,119,81,101,120,83,88,55,65,112,69,51,89,86,99,45,120,102,52,104,106,77,115,77,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,57,50,46,49,54,56,46,49,55,56,46,54,48,47,112,47,55,55,52,52,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,113,23,220,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}},{"agent":{"type":"Buffer","data":[3,171,237,107,186,245,165,47,237,235,211,49,245,62,113,53,255,252,223,226,75,118,148,187,23,53,70,174,160,184,64,63,94,210,227,56]},"signature":{"type":"Buffer","data":[129,12,55,104,239,121,138,2,86,106,136,51,219,79,170,8,195,69,81,188,225,192,247,196,54,39,164,110,75,39,240,56,245,189,154,77,72,11,97,250,202,149,242,97,128,28,47,164,236,104,136,82,212,246,44,143,132,119,255,135,112,11,20,13]},"agent_info":{"type":"Buffer","data":[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,3,171,237,107,186,245,165,47,237,235,211,49,245,62,113,53,255,252,223,226,75,118,148,187,23,53,70,174,160,184,64,63,94,210,227,56,164,117,114,108,115,145,217,97,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,104,121,112,115,86,121,103,117,80,84,115,53,118,73,80,65,102,97,112,90,88,113,117,84,115,79,80,100,67,81,79,79,117,103,57,51,82,103,106,95,114,85,73,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,54,53,46,50,50,46,51,50,46,49,49,47,112,47,53,55,55,57,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,113,188,123,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}}])
216
285
  }
217
286
 
287
+ @Query()
288
+ runtimeGetNetworkMetrics(): string {
289
+ return JSON.stringify({
290
+ "metrics": {},
291
+ "stats": {}
292
+ })
293
+ }
294
+
295
+ @Mutation(returns => Boolean)
296
+ runtimeRestartHolochain(): boolean {
297
+ return true
298
+ }
299
+
218
300
  @Mutation(returns => Boolean)
219
301
  runtimeHcAddAgentInfos(@Arg("agentInfos", type => String) agentInfos): boolean {
220
302
  return true
@@ -336,5 +418,48 @@ export default class RuntimeResolver {
336
418
  }
337
419
  }
338
420
  }
421
+
422
+ @Mutation()
423
+ runtimeExportDb(@Arg("filePath", type => String) filePath: string): boolean {
424
+ return true
425
+ }
426
+
427
+ @Mutation()
428
+ runtimeImportDb(@Arg("filePath", type => String) filePath: string): boolean {
429
+ return true
430
+ }
431
+
432
+ @Mutation()
433
+ runtimeExportPerspective(
434
+ @Arg("perspectiveUuid", type => String) perspectiveUuid: string,
435
+ @Arg("filePath", type => String) filePath: string
436
+ ): boolean {
437
+ return true
438
+ }
439
+
440
+ @Mutation()
441
+ runtimeImportPerspective(@Arg("filePath", type => String) filePath: string): boolean {
442
+ return true
443
+ }
444
+
445
+ @Query(returns => Boolean)
446
+ runtimeMultiUserEnabled(): boolean {
447
+ return false
448
+ }
449
+
450
+ @Mutation(returns => Boolean)
451
+ runtimeSetMultiUserEnabled(@Arg("enabled") enabled: boolean): boolean {
452
+ return enabled
453
+ }
454
+
455
+ @Query(returns => [UserStatistics])
456
+ runtimeListUsers(): UserStatistics[] {
457
+ return [{
458
+ email: "test@example.com",
459
+ did: "did:key:test123",
460
+ lastSeen: new Date().toISOString(),
461
+ perspectiveCount: 5
462
+ }]
463
+ }
339
464
  }
340
465