@coasys/ad4m 0.10.1-rc9-dev → 0.10.1-release-candidate-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.
- package/lib/index.cjs +3179 -811
- package/lib/index.js +3171 -807
- package/lib/src/Literal.js +4 -1
- package/lib/src/ai/AIClient.d.ts +1 -1
- package/lib/src/ai/AIClient.js +6 -6
- package/lib/src/ai/AIResolver.d.ts +1 -1
- package/lib/src/ai/AIResolver.js +7 -4
- package/lib/src/index.d.ts +4 -3
- package/lib/src/index.js +4 -3
- package/lib/src/model/Ad4mModel.d.ts +609 -0
- package/lib/src/model/Ad4mModel.js +1048 -0
- package/lib/src/{subject → model}/Subject.d.ts +2 -2
- package/lib/src/{subject → model}/Subject.js +18 -18
- package/lib/src/model/decorators.d.ts +502 -0
- package/lib/src/model/decorators.js +683 -0
- package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +2 -2
- package/lib/src/neighbourhood/NeighbourhoodClient.js +16 -10
- package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +2 -2
- package/lib/src/neighbourhood/NeighbourhoodProxy.js +4 -4
- package/lib/src/neighbourhood/NeighbourhoodProxy.test.d.ts +1 -0
- package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +31 -0
- package/lib/src/neighbourhood/NeighbourhoodResolver.d.ts +2 -2
- package/lib/src/neighbourhood/NeighbourhoodResolver.js +6 -4
- package/lib/src/perspectives/PerspectiveClient.d.ts +18 -11
- package/lib/src/perspectives/PerspectiveClient.js +116 -49
- package/lib/src/perspectives/PerspectiveProxy.d.ts +471 -54
- package/lib/src/perspectives/PerspectiveProxy.js +579 -64
- package/lib/src/perspectives/PerspectiveResolver.d.ts +23 -9
- package/lib/src/perspectives/PerspectiveResolver.js +140 -46
- package/lib/src/runtime/RuntimeClient.d.ts +5 -1
- package/lib/src/runtime/RuntimeClient.js +48 -0
- package/lib/src/runtime/RuntimeResolver.d.ts +24 -0
- package/lib/src/runtime/RuntimeResolver.js +117 -0
- package/lib/src/schema.gql +25 -11
- package/lib/src/typeDefs.js +25 -11
- package/package.json +2 -1
- package/src/Literal.ts +4 -1
- package/src/ai/AIClient.ts +6 -6
- package/src/ai/AIResolver.ts +6 -3
- package/src/index.ts +4 -3
- package/src/model/Ad4mModel.ts +1206 -0
- package/src/{subject → model}/Subject.ts +16 -16
- package/src/{subject/SDNADecorators.ts → model/decorators.ts} +384 -50
- package/src/neighbourhood/NeighbourhoodClient.ts +16 -10
- package/src/neighbourhood/NeighbourhoodProxy.test.ts +45 -0
- package/src/neighbourhood/NeighbourhoodProxy.ts +4 -4
- package/src/neighbourhood/NeighbourhoodResolver.ts +2 -2
- package/src/perspectives/PerspectiveClient.ts +122 -51
- package/src/perspectives/PerspectiveProxy.ts +642 -77
- package/src/perspectives/PerspectiveResolver.ts +126 -23
- package/src/runtime/RuntimeClient.ts +52 -1
- package/src/runtime/RuntimeResolver.ts +77 -0
- package/lib/src/subject/SDNADecorators.d.ts +0 -188
- package/lib/src/subject/SDNADecorators.js +0 -360
- package/lib/src/subject/SubjectEntity.d.ts +0 -110
- package/lib/src/subject/SubjectEntity.js +0 -288
- package/src/subject/SubjectEntity.ts +0 -336
- package/yarn-error.log +0 -90
- /package/lib/src/{subject → model}/util.d.ts +0 -0
- /package/lib/src/{subject → model}/util.js +0 -0
- /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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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 =
|
|
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 =>
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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,24 @@ 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
|
+
}
|
|
253
356
|
}
|
|
@@ -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
|
|
@@ -287,6 +287,38 @@ export class RuntimeClient {
|
|
|
287
287
|
return runtimeGrantNotification
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
+
async exportDb(filePath: string): Promise<boolean> {
|
|
291
|
+
const { runtimeExportDb } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
292
|
+
mutation: gql`mutation runtimeExportDb($filePath: String!) {
|
|
293
|
+
runtimeExportDb(filePath: $filePath)
|
|
294
|
+
}`,
|
|
295
|
+
variables: { filePath }
|
|
296
|
+
}))
|
|
297
|
+
return runtimeExportDb
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
async importDb(filePath: string): Promise<ImportResult> {
|
|
301
|
+
const { runtimeImportDb } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
302
|
+
mutation: gql`mutation runtimeImportDb($filePath: String!) {
|
|
303
|
+
runtimeImportDb(filePath: $filePath) {
|
|
304
|
+
perspectives { total imported failed omitted errors }
|
|
305
|
+
links { total imported failed omitted errors }
|
|
306
|
+
expressions { total imported failed omitted errors }
|
|
307
|
+
perspectiveDiffs { total imported failed omitted errors }
|
|
308
|
+
notifications { total imported failed omitted errors }
|
|
309
|
+
models { total imported failed omitted errors }
|
|
310
|
+
defaultModels { total imported failed omitted errors }
|
|
311
|
+
tasks { total imported failed omitted errors }
|
|
312
|
+
friends { total imported failed omitted errors }
|
|
313
|
+
trustedAgents { total imported failed omitted errors }
|
|
314
|
+
knownLinkLanguages { total imported failed omitted errors }
|
|
315
|
+
}
|
|
316
|
+
}`,
|
|
317
|
+
variables: { filePath }
|
|
318
|
+
}))
|
|
319
|
+
return runtimeImportDb
|
|
320
|
+
}
|
|
321
|
+
|
|
290
322
|
async notifications(): Promise<Notification[]> {
|
|
291
323
|
const { runtimeNotifications } = unwrapApolloResult(await this.#apolloClient.query({
|
|
292
324
|
query: gql`query runtimeNotifications {
|
|
@@ -316,6 +348,25 @@ export class RuntimeClient {
|
|
|
316
348
|
return runtimeRemoveNotification
|
|
317
349
|
}
|
|
318
350
|
|
|
351
|
+
async exportPerspective(uuid: string, filePath: string): Promise<boolean> {
|
|
352
|
+
const { runtimeExportPerspective } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
353
|
+
mutation: gql`mutation runtimeExportPerspective($perspectiveUuid: String!, $filePath: String!) {
|
|
354
|
+
runtimeExportPerspective(perspectiveUuid: $perspectiveUuid, filePath: $filePath)
|
|
355
|
+
}`,
|
|
356
|
+
variables: { perspectiveUuid: uuid, filePath }
|
|
357
|
+
}))
|
|
358
|
+
return runtimeExportPerspective
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
async importPerspective(filePath: string): Promise<boolean> {
|
|
362
|
+
const { runtimeImportPerspective } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
363
|
+
mutation: gql`mutation runtimeImportPerspective($filePath: String!) {
|
|
364
|
+
runtimeImportPerspective(filePath: $filePath)
|
|
365
|
+
}`,
|
|
366
|
+
variables: { filePath }
|
|
367
|
+
}))
|
|
368
|
+
return runtimeImportPerspective
|
|
369
|
+
}
|
|
319
370
|
|
|
320
371
|
addNotificationTriggeredCallback(cb: NotificationTriggeredCallback) {
|
|
321
372
|
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)
|
|
@@ -336,5 +390,28 @@ export default class RuntimeResolver {
|
|
|
336
390
|
}
|
|
337
391
|
}
|
|
338
392
|
}
|
|
393
|
+
|
|
394
|
+
@Mutation()
|
|
395
|
+
runtimeExportDb(@Arg("filePath", type => String) filePath: string): boolean {
|
|
396
|
+
return true
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
@Mutation()
|
|
400
|
+
runtimeImportDb(@Arg("filePath", type => String) filePath: string): boolean {
|
|
401
|
+
return true
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
@Mutation()
|
|
405
|
+
runtimeExportPerspective(
|
|
406
|
+
@Arg("perspectiveUuid", type => String) perspectiveUuid: string,
|
|
407
|
+
@Arg("filePath", type => String) filePath: string
|
|
408
|
+
): boolean {
|
|
409
|
+
return true
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
@Mutation()
|
|
413
|
+
runtimeImportPerspective(@Arg("filePath", type => String) filePath: string): boolean {
|
|
414
|
+
return true
|
|
415
|
+
}
|
|
339
416
|
}
|
|
340
417
|
|
|
@@ -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 {};
|