@coasys/ad4m 0.10.0 → 0.10.1-dev-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 (64) hide show
  1. package/lib/index.cjs +3785 -843
  2. package/lib/index.js +3777 -839
  3. package/lib/src/Ad4mClient.js +2 -1
  4. package/lib/src/Literal.js +4 -1
  5. package/lib/src/ai/AIClient.d.ts +8 -2
  6. package/lib/src/ai/AIClient.js +25 -14
  7. package/lib/src/ai/AIResolver.d.ts +25 -6
  8. package/lib/src/ai/AIResolver.js +102 -18
  9. package/lib/src/index.d.ts +4 -3
  10. package/lib/src/index.js +4 -3
  11. package/lib/src/model/Ad4mModel.d.ts +730 -0
  12. package/lib/src/model/Ad4mModel.js +1399 -0
  13. package/lib/src/{subject → model}/Subject.d.ts +2 -2
  14. package/lib/src/{subject → model}/Subject.js +18 -18
  15. package/lib/src/model/decorators.d.ts +502 -0
  16. package/lib/src/model/decorators.js +683 -0
  17. package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +2 -2
  18. package/lib/src/neighbourhood/NeighbourhoodClient.js +13 -10
  19. package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +2 -2
  20. package/lib/src/neighbourhood/NeighbourhoodProxy.js +4 -4
  21. package/lib/src/neighbourhood/NeighbourhoodProxy.test.d.ts +1 -0
  22. package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +73 -0
  23. package/lib/src/neighbourhood/NeighbourhoodResolver.d.ts +2 -2
  24. package/lib/src/neighbourhood/NeighbourhoodResolver.js +6 -4
  25. package/lib/src/perspectives/PerspectiveClient.d.ts +23 -11
  26. package/lib/src/perspectives/PerspectiveClient.js +147 -51
  27. package/lib/src/perspectives/PerspectiveProxy.d.ts +494 -54
  28. package/lib/src/perspectives/PerspectiveProxy.js +684 -67
  29. package/lib/src/perspectives/PerspectiveResolver.d.ts +24 -9
  30. package/lib/src/perspectives/PerspectiveResolver.js +151 -46
  31. package/lib/src/runtime/RuntimeClient.d.ts +8 -2
  32. package/lib/src/runtime/RuntimeClient.js +64 -0
  33. package/lib/src/runtime/RuntimeResolver.d.ts +27 -1
  34. package/lib/src/runtime/RuntimeResolver.js +138 -0
  35. package/lib/src/schema.gql +55 -16
  36. package/lib/src/typeDefs.js +55 -16
  37. package/package.json +4 -3
  38. package/src/Ad4mClient.test.ts +51 -19
  39. package/src/Ad4mClient.ts +3 -1
  40. package/src/Literal.ts +4 -1
  41. package/src/ai/AIClient.ts +35 -14
  42. package/src/ai/AIResolver.ts +78 -16
  43. package/src/index.ts +4 -3
  44. package/src/model/Ad4mModel.ts +1651 -0
  45. package/src/{subject → model}/Subject.ts +16 -16
  46. package/src/{subject/SDNADecorators.ts → model/decorators.ts} +384 -50
  47. package/src/neighbourhood/NeighbourhoodClient.ts +13 -10
  48. package/src/neighbourhood/NeighbourhoodProxy.test.ts +100 -0
  49. package/src/neighbourhood/NeighbourhoodProxy.ts +4 -4
  50. package/src/neighbourhood/NeighbourhoodResolver.ts +2 -2
  51. package/src/perspectives/PerspectiveClient.ts +156 -51
  52. package/src/perspectives/PerspectiveProxy.ts +766 -82
  53. package/src/perspectives/PerspectiveResolver.ts +134 -23
  54. package/src/runtime/RuntimeClient.ts +71 -2
  55. package/src/runtime/RuntimeResolver.ts +91 -1
  56. package/lib/src/subject/SDNADecorators.d.ts +0 -188
  57. package/lib/src/subject/SDNADecorators.js +0 -360
  58. package/lib/src/subject/SubjectEntity.d.ts +0 -102
  59. package/lib/src/subject/SubjectEntity.js +0 -267
  60. package/src/subject/SubjectEntity.ts +0 -315
  61. package/yarn-error.log +0 -90
  62. /package/lib/src/{subject → model}/util.d.ts +0 -0
  63. /package/lib/src/{subject → model}/util.js +0 -0
  64. /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 } 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,25 @@ 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
+ }
319
388
 
320
389
  addNotificationTriggeredCallback(cb: NotificationTriggeredCallback) {
321
390
  this.#notificationTriggeredCallbacks.push(cb)
@@ -138,6 +138,60 @@ 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
+
141
195
  /**
142
196
  * Resolver classes are used here to define the GraphQL schema
143
197
  * (through the type-graphql annotations)
@@ -211,10 +265,23 @@ export default class RuntimeResolver {
211
265
  }
212
266
 
213
267
  @Query()
214
- runtimeHcAgentInfos(): String {
268
+ runtimeHcAgentInfos(): string {
215
269
  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
270
  }
217
271
 
272
+ @Query()
273
+ runtimeGetNetworkMetrics(): string {
274
+ return JSON.stringify({
275
+ "metrics": {},
276
+ "stats": {}
277
+ })
278
+ }
279
+
280
+ @Mutation(returns => Boolean)
281
+ runtimeRestartHolochain(): boolean {
282
+ return true
283
+ }
284
+
218
285
  @Mutation(returns => Boolean)
219
286
  runtimeHcAddAgentInfos(@Arg("agentInfos", type => String) agentInfos): boolean {
220
287
  return true
@@ -336,5 +403,28 @@ export default class RuntimeResolver {
336
403
  }
337
404
  }
338
405
  }
406
+
407
+ @Mutation()
408
+ runtimeExportDb(@Arg("filePath", type => String) filePath: string): boolean {
409
+ return true
410
+ }
411
+
412
+ @Mutation()
413
+ runtimeImportDb(@Arg("filePath", type => String) filePath: string): boolean {
414
+ return true
415
+ }
416
+
417
+ @Mutation()
418
+ runtimeExportPerspective(
419
+ @Arg("perspectiveUuid", type => String) perspectiveUuid: string,
420
+ @Arg("filePath", type => String) filePath: string
421
+ ): boolean {
422
+ return true
423
+ }
424
+
425
+ @Mutation()
426
+ runtimeImportPerspective(@Arg("filePath", type => String) filePath: string): boolean {
427
+ return true
428
+ }
339
429
  }
340
430
 
@@ -1,188 +0,0 @@
1
- export declare class PerspectiveAction {
2
- action: string;
3
- source: string;
4
- predicate: string;
5
- target: string;
6
- }
7
- export declare function addLink(source: string, predicate: string, target: string): PerspectiveAction;
8
- export declare function hasLink(predicate: string): string;
9
- export interface InstanceQueryParams {
10
- /**
11
- * An object representing the WHERE clause of the query.
12
- */
13
- where?: object;
14
- /**
15
- * A string representing the condition clause of the query.
16
- */
17
- condition?: string;
18
- }
19
- /**
20
- * Decorator for querying instances of a subject class.
21
- *
22
- * @category Decorators
23
- *
24
- * @description
25
- * NOTE: Only works on methods that return a promise and will throw an error if not used on a method that returns a promise.
26
- * This will allow you to query for instances of a subject class with custom clauses within the instance clauses.
27
- *
28
- * @example
29
- * // Usage with where clause
30
- * InstanceQuery({ where: { name: "John" }}) // this will return all the properties of the subject class with the name "John"
31
- *
32
- * @example
33
- * // Usage with condition clause
34
- * InstanceQuery({ condition: "triple(Instance, 'age', Age), Age > 18" }) // this will return all the properties of the subject class with the age greater than 18
35
- *
36
- * @param {Object} [options] - Query options.
37
- */
38
- export declare function InstanceQuery(options?: InstanceQueryParams): <T>(target: T, key: keyof T, descriptor: PropertyDescriptor) => void;
39
- export interface PropertyOptions {
40
- /**
41
- * The predicate of the property. All properties must have this option.
42
- */
43
- through?: string;
44
- /**
45
- * The initial value of the property. Required if the property is marked as required.
46
- */
47
- initial?: string;
48
- /**
49
- * Indicates whether the property is required. If true, an initial value must be provided.
50
- */
51
- required?: boolean;
52
- /**
53
- * Indicates whether the property is writable. If true, a setter will be available in the prolog engine.
54
- */
55
- writable?: boolean;
56
- /**
57
- * The language used to store the property. Can be the default `Literal` Language or a custom language address.
58
- */
59
- resolveLanguage?: string;
60
- /**
61
- * Custom getter to get the value of the property in the prolog engine. If not provided, the default getter will be used.
62
- */
63
- getter?: string;
64
- /**
65
- * Custom setter to set the value of the property in the prolog engine. Only available if the property is writable.
66
- */
67
- setter?: string;
68
- /**
69
- * Indicates whether the property is stored locally in the perspective and not in the network. Useful for properties that are not meant to be shared with the network.
70
- */
71
- local?: boolean;
72
- }
73
- /**
74
- * Decorator for defining properties of a subject class.
75
- *
76
- * @category Decorators
77
- *
78
- * @description
79
- * This will allow you to define properties with different conditions and how they would be defined in proflog engine.
80
- *
81
- * - All properties must have a `through` option which is the predicate of the property.
82
- * -e If the property is required, it must have an `initial` option which is the initial value of the property.
83
- * - If the property is writable, it will have a setter in prolog engine. A custom setter can be defined with the `setter` option.
84
- * - If resolveLanguage is defined, you can use the default `Literal` Language or use your custom language address that can be used to store the property.
85
- * - If a custom getter is defined, it will be used to get the value of the property in prolog engine. If not, the default getter will be used.
86
- * - If local is defined, the property will be stored locally in the perspective and not in the network. This is useful for properties that are not meant to be shared with the network
87
- *
88
- * @example
89
- * // Usage
90
- * SubjectProperty({ through: "ad4m://name", initial: "John", required: true }) // this will define a property with the name "ad4m://name" and the initial value "John"
91
- *
92
- * @param {PropertyOptions} [opts] - Property options.
93
- */
94
- export declare function SubjectProperty(opts: PropertyOptions): <T>(target: T, key: keyof T) => void;
95
- export interface FlagOptions {
96
- /**
97
- * The predicate of the property. All properties must have this option.
98
- */
99
- through: string;
100
- /**
101
- * The value of the property.
102
- */
103
- value: string;
104
- }
105
- /**
106
- * Decorator for defining flags of a subject class
107
- *
108
- * @category Decorators
109
- *
110
- * @description
111
- * The idea behind flag decorator is to define a property that is required and has an initial value.
112
- * This will allow you to define a strict instance query. This behaviour can also be achieved with the `SubjectProperty` decorator but the `SubjectFlag` decorator is a shorthand for that.
113
- *
114
- * NOTE: Use of Flag is discouraged and should be used only when necessary.
115
- *
116
- * - All properties must have a `through` & `initial` option which is the predicate of the property.
117
- *
118
- * @example
119
- * // Usage
120
- * SubjectFlag({ through: "ad4m://name", value: "John" }) // this will define a flag with the name "ad4m://name" and the initial value "John"
121
- *
122
- * @param {FlagOptions} [opts] Flag options.
123
- */
124
- export declare function SubjectFlag(opts: FlagOptions): <T>(target: T, key: keyof T) => void;
125
- interface WhereOptions {
126
- isInstance?: any;
127
- condition?: string;
128
- }
129
- export interface CollectionOptions {
130
- /**
131
- * The predicate of the property. All properties must have this option.
132
- */
133
- through: string;
134
- /**
135
- * An object representing the WHERE clause of the query.
136
- */
137
- where?: WhereOptions;
138
- /**
139
- * Indicates whether the property is stored locally in the perspective and not in the network. Useful for properties that are not meant to be shared with the network.
140
- */
141
- local?: boolean;
142
- }
143
- /**
144
- * Decorator for defining collections of a subject class.
145
- *
146
- * @category Decorators
147
- *
148
- * @description
149
- * This will allow you to define collections with different conditions and how they would be defined in proflog engine.
150
- *
151
- * NOTE: The property needs to be an array for it to picked up during the initialization phase.
152
- *
153
- * - All collections must have a `through` option which is the predicate of the collection.
154
- * - If the collection has a `where` option, it can be used to define a custom condition for the collection.
155
- * - If the collection has a `local` option, the collection will be stored locally in the perspective and not in the network. This is useful for collections that are not meant to be shared with the network.
156
- *
157
- * @example
158
- * // Usage
159
- * SubjectCollection({ through: "ad4m://friends" }) // this will define a collection with the name "ad4m://friends"
160
- *
161
- * @param opts Collection options.
162
- */
163
- export declare function SubjectCollection(opts: CollectionOptions): <T>(target: T, key: keyof T) => void;
164
- export declare function makeRandomPrologAtom(length: number): string;
165
- export interface SDNAClassOptions {
166
- /**
167
- * The name of the entity.
168
- */
169
- name: string;
170
- }
171
- /**
172
- * Decorator for defining an SDNA class.
173
- *
174
- * @category Decorators
175
- *
176
- * @description
177
- * This will create a new SDNA class with the given name and add custom methods to generate the SDNA for the class, for this to work the class need to have the properties defined using the decorators like `SubjectProperty`.
178
- *
179
- * Note: This decorator is required for the class to be picked up during the initialization phase.
180
- *
181
- * @example
182
- * // Usage
183
- * SDNAClass({ name: "Person" }) // this will create a new SDNA class with the name "Person"
184
- *
185
- * @param opts SDNA class options.
186
- */
187
- export declare function SDNAClass(opts: SDNAClassOptions): (target: any) => void;
188
- export {};