@coasys/ad4m 0.9.1-prerelease → 0.9.1-prerelease.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.
- package/lib/index.cjs +209 -124
- package/lib/index.js +209 -124
- package/lib/src/Exception.d.ts +2 -1
- package/lib/src/Exception.js +1 -0
- package/lib/src/PubSub.d.ts +2 -0
- package/lib/src/PubSub.js +2 -0
- package/lib/src/perspectives/PerspectiveClient.d.ts +3 -0
- package/lib/src/perspectives/PerspectiveClient.js +24 -0
- package/lib/src/perspectives/PerspectiveProxy.d.ts +3 -1
- package/lib/src/perspectives/PerspectiveProxy.js +32 -68
- package/lib/src/perspectives/PerspectiveResolver.d.ts +3 -0
- package/lib/src/perspectives/PerspectiveResolver.js +37 -0
- package/lib/src/runtime/RuntimeClient.d.ts +12 -1
- package/lib/src/runtime/RuntimeClient.js +108 -2
- package/lib/src/runtime/RuntimeResolver.d.ts +34 -0
- package/lib/src/runtime/RuntimeResolver.js +214 -2
- package/lib/src/schema.gql +40 -0
- package/lib/src/subject/SubjectEntity.js +4 -55
- package/lib/src/typeDefs.js +40 -0
- package/package.json +7 -13
- package/src/Ad4mClient.test.ts +95 -32
- package/src/Exception.ts +1 -0
- package/src/PubSub.ts +2 -0
- package/src/perspectives/PerspectiveClient.ts +27 -0
- package/src/perspectives/PerspectiveProxy.ts +36 -67
- package/src/perspectives/PerspectiveResolver.ts +29 -1
- package/src/runtime/RuntimeClient.ts +120 -1
- package/src/runtime/RuntimeResolver.ts +167 -3
- package/src/subject/SubjectEntity.ts +4 -56
package/lib/src/schema.gql
CHANGED
|
@@ -249,6 +249,9 @@ type Mutation {
|
|
|
249
249
|
perspectiveAddLinkExpression(link: LinkExpressionInput!, status: String, uuid: String!): LinkExpression!
|
|
250
250
|
perspectiveAddLinks(links: [LinkInput!]!, status: String, uuid: String!): [LinkExpression!]!
|
|
251
251
|
perspectiveAddSdna(name: String!, sdnaCode: String!, sdnaType: String!, uuid: String!): Boolean!
|
|
252
|
+
perspectiveCreateSubject(expressionAddress: String!, subjectClass: String!, uuid: String!): Boolean!
|
|
253
|
+
perspectiveExecuteCommands(commands: String!, expression: String!, parameters: String, uuid: String!): Boolean!
|
|
254
|
+
perspectiveGetSubjectData(expressionAddress: String!, subjectClass: String!, uuid: String!): String!
|
|
252
255
|
perspectiveLinkMutations(mutations: LinkMutations!, status: String, uuid: String!): LinkExpressionMutations!
|
|
253
256
|
perspectivePublishSnapshot(uuid: String!): String
|
|
254
257
|
perspectiveRemove(uuid: String!): Boolean!
|
|
@@ -259,12 +262,16 @@ type Mutation {
|
|
|
259
262
|
runtimeAddFriends(dids: [String!]!): [String!]!
|
|
260
263
|
runtimeAddKnownLinkLanguageTemplates(addresses: [String!]!): [String!]!
|
|
261
264
|
runtimeFriendSendMessage(did: String!, message: PerspectiveInput!): Boolean!
|
|
265
|
+
runtimeGrantNotification(id: String!): Boolean!
|
|
262
266
|
runtimeHcAddAgentInfos(agentInfos: String!): Boolean!
|
|
263
267
|
runtimeOpenLink(url: String!): Boolean!
|
|
264
268
|
runtimeQuit: Boolean!
|
|
265
269
|
runtimeRemoveFriends(dids: [String!]!): [String!]!
|
|
266
270
|
runtimeRemoveKnownLinkLanguageTemplates(addresses: [String!]!): [String!]!
|
|
271
|
+
runtimeRemoveNotification(id: String!): Boolean!
|
|
272
|
+
runtimeRequestInstallNotification(notification: NotificationInput!): String!
|
|
267
273
|
runtimeSetStatus(status: PerspectiveInput!): Boolean!
|
|
274
|
+
runtimeUpdateNotification(id: String!, notification: NotificationInput!): Boolean!
|
|
268
275
|
}
|
|
269
276
|
|
|
270
277
|
type Neighbourhood {
|
|
@@ -279,6 +286,30 @@ type NeighbourhoodExpression {
|
|
|
279
286
|
timestamp: String!
|
|
280
287
|
}
|
|
281
288
|
|
|
289
|
+
type Notification {
|
|
290
|
+
appIconPath: String!
|
|
291
|
+
appName: String!
|
|
292
|
+
appUrl: String!
|
|
293
|
+
description: String!
|
|
294
|
+
granted: Boolean!
|
|
295
|
+
id: String!
|
|
296
|
+
perspectiveIds: [String!]!
|
|
297
|
+
trigger: String!
|
|
298
|
+
webhookAuth: String!
|
|
299
|
+
webhookUrl: String!
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
input NotificationInput {
|
|
303
|
+
appIconPath: String!
|
|
304
|
+
appName: String!
|
|
305
|
+
appUrl: String!
|
|
306
|
+
description: String!
|
|
307
|
+
perspectiveIds: [String!]!
|
|
308
|
+
trigger: String!
|
|
309
|
+
webhookAuth: String!
|
|
310
|
+
webhookUrl: String!
|
|
311
|
+
}
|
|
312
|
+
|
|
282
313
|
type OnlineAgent {
|
|
283
314
|
did: String!
|
|
284
315
|
status: PerspectiveExpression!
|
|
@@ -342,6 +373,7 @@ type Query {
|
|
|
342
373
|
runtimeKnownLinkLanguageTemplates: [String!]!
|
|
343
374
|
runtimeMessageInbox(filter: String): [PerspectiveExpression!]!
|
|
344
375
|
runtimeMessageOutbox(filter: String): [SentMessage!]!
|
|
376
|
+
runtimeNotifications: [Notification!]!
|
|
345
377
|
runtimeVerifyStringSignedByDid(data: String!, did: String!, didSigningKeyId: String!, signedData: String!): Boolean!
|
|
346
378
|
}
|
|
347
379
|
|
|
@@ -380,4 +412,12 @@ type Subscription {
|
|
|
380
412
|
perspectiveSyncStateChange(uuid: String!): String!
|
|
381
413
|
perspectiveUpdated: PerspectiveHandle
|
|
382
414
|
runtimeMessageReceived: PerspectiveExpression
|
|
415
|
+
runtimeNotificationRequested: Notification
|
|
416
|
+
runtimeNotificationTriggered: TriggeredNotification
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
type TriggeredNotification {
|
|
420
|
+
notification: Notification!
|
|
421
|
+
perspectiveId: String!
|
|
422
|
+
triggerMatch: String!
|
|
383
423
|
}
|
|
@@ -42,61 +42,10 @@ export class SubjectEntity {
|
|
|
42
42
|
}
|
|
43
43
|
async getData(id) {
|
|
44
44
|
const tempId = id ?? __classPrivateFieldGet(this, _SubjectEntity_baseExpression, "f");
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
let results = await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").infer(`subject_class("${__classPrivateFieldGet(this, _SubjectEntity_subjectClass, "f")}", C), property(C, Property)`);
|
|
50
|
-
let properties = results.map(result => result.Property);
|
|
51
|
-
for (let p of properties) {
|
|
52
|
-
const resolveExpressionURI = await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").infer(`subject_class("${__classPrivateFieldGet(this, _SubjectEntity_subjectClass, "f")}", C), property_resolve(C, "${p}")`);
|
|
53
|
-
const getProperty = async () => {
|
|
54
|
-
let results = await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").infer(`subject_class("${__classPrivateFieldGet(this, _SubjectEntity_subjectClass, "f")}", C), property_getter(C, "${tempId}", "${p}", Value)`);
|
|
55
|
-
if (results && results.length > 0) {
|
|
56
|
-
let expressionURI = results[0].Value;
|
|
57
|
-
if (resolveExpressionURI) {
|
|
58
|
-
try {
|
|
59
|
-
const expression = await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").getExpression(expressionURI);
|
|
60
|
-
try {
|
|
61
|
-
return JSON.parse(expression.data);
|
|
62
|
-
}
|
|
63
|
-
catch (e) {
|
|
64
|
-
return expression.data;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
catch (err) {
|
|
68
|
-
return expressionURI;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
return expressionURI;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
else if (results) {
|
|
76
|
-
return results;
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
return undefined;
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
this[p] = await getProperty();
|
|
83
|
-
}
|
|
84
|
-
let results2 = await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").infer(`subject_class("${__classPrivateFieldGet(this, _SubjectEntity_subjectClass, "f")}", C), collection(C, Collection)`);
|
|
85
|
-
if (!results2)
|
|
86
|
-
results2 = [];
|
|
87
|
-
let collections = results2.map(result => result.Collection);
|
|
88
|
-
for (let c of collections) {
|
|
89
|
-
const getProperty = async () => {
|
|
90
|
-
let results = await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").infer(`subject_class("${__classPrivateFieldGet(this, _SubjectEntity_subjectClass, "f")}", C), collection_getter(C, "${tempId}", "${c}", Value)`);
|
|
91
|
-
if (results && results.length > 0 && results[0].Value) {
|
|
92
|
-
return eval(results[0].Value);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
return [];
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
this[c] = await getProperty();
|
|
99
|
-
}
|
|
45
|
+
console.log("SubjectEntity: getData");
|
|
46
|
+
let data = await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").getSubjectData(__classPrivateFieldGet(this, _SubjectEntity_subjectClass, "f"), tempId);
|
|
47
|
+
console.log("SubjectEntity got data:", data);
|
|
48
|
+
Object.assign(this, data);
|
|
100
49
|
__classPrivateFieldSet(this, _SubjectEntity_baseExpression, tempId, "f");
|
|
101
50
|
return this;
|
|
102
51
|
}
|
package/lib/src/typeDefs.js
CHANGED
|
@@ -245,6 +245,9 @@ type Mutation {
|
|
|
245
245
|
perspectiveAddLinkExpression(link: LinkExpressionInput!, status: String, uuid: String!): LinkExpression!
|
|
246
246
|
perspectiveAddLinks(links: [LinkInput!]!, status: String, uuid: String!): [LinkExpression!]!
|
|
247
247
|
perspectiveAddSdna(name: String!, sdnaCode: String!, sdnaType: String!, uuid: String!): Boolean!
|
|
248
|
+
perspectiveCreateSubject(expressionAddress: String!, subjectClass: String!, uuid: String!): Boolean!
|
|
249
|
+
perspectiveExecuteCommands(commands: String!, expression: String!, parameters: String, uuid: String!): Boolean!
|
|
250
|
+
perspectiveGetSubjectData(expressionAddress: String!, subjectClass: String!, uuid: String!): String!
|
|
248
251
|
perspectiveLinkMutations(mutations: LinkMutations!, status: String, uuid: String!): LinkExpressionMutations!
|
|
249
252
|
perspectivePublishSnapshot(uuid: String!): String
|
|
250
253
|
perspectiveRemove(uuid: String!): Boolean!
|
|
@@ -255,12 +258,16 @@ type Mutation {
|
|
|
255
258
|
runtimeAddFriends(dids: [String!]!): [String!]!
|
|
256
259
|
runtimeAddKnownLinkLanguageTemplates(addresses: [String!]!): [String!]!
|
|
257
260
|
runtimeFriendSendMessage(did: String!, message: PerspectiveInput!): Boolean!
|
|
261
|
+
runtimeGrantNotification(id: String!): Boolean!
|
|
258
262
|
runtimeHcAddAgentInfos(agentInfos: String!): Boolean!
|
|
259
263
|
runtimeOpenLink(url: String!): Boolean!
|
|
260
264
|
runtimeQuit: Boolean!
|
|
261
265
|
runtimeRemoveFriends(dids: [String!]!): [String!]!
|
|
262
266
|
runtimeRemoveKnownLinkLanguageTemplates(addresses: [String!]!): [String!]!
|
|
267
|
+
runtimeRemoveNotification(id: String!): Boolean!
|
|
268
|
+
runtimeRequestInstallNotification(notification: NotificationInput!): String!
|
|
263
269
|
runtimeSetStatus(status: PerspectiveInput!): Boolean!
|
|
270
|
+
runtimeUpdateNotification(id: String!, notification: NotificationInput!): Boolean!
|
|
264
271
|
}
|
|
265
272
|
|
|
266
273
|
type Neighbourhood {
|
|
@@ -275,6 +282,30 @@ type NeighbourhoodExpression {
|
|
|
275
282
|
timestamp: String!
|
|
276
283
|
}
|
|
277
284
|
|
|
285
|
+
type Notification {
|
|
286
|
+
appIconPath: String!
|
|
287
|
+
appName: String!
|
|
288
|
+
appUrl: String!
|
|
289
|
+
description: String!
|
|
290
|
+
granted: Boolean!
|
|
291
|
+
id: String!
|
|
292
|
+
perspectiveIds: [String!]!
|
|
293
|
+
trigger: String!
|
|
294
|
+
webhookAuth: String!
|
|
295
|
+
webhookUrl: String!
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
input NotificationInput {
|
|
299
|
+
appIconPath: String!
|
|
300
|
+
appName: String!
|
|
301
|
+
appUrl: String!
|
|
302
|
+
description: String!
|
|
303
|
+
perspectiveIds: [String!]!
|
|
304
|
+
trigger: String!
|
|
305
|
+
webhookAuth: String!
|
|
306
|
+
webhookUrl: String!
|
|
307
|
+
}
|
|
308
|
+
|
|
278
309
|
type OnlineAgent {
|
|
279
310
|
did: String!
|
|
280
311
|
status: PerspectiveExpression!
|
|
@@ -338,6 +369,7 @@ type Query {
|
|
|
338
369
|
runtimeKnownLinkLanguageTemplates: [String!]!
|
|
339
370
|
runtimeMessageInbox(filter: String): [PerspectiveExpression!]!
|
|
340
371
|
runtimeMessageOutbox(filter: String): [SentMessage!]!
|
|
372
|
+
runtimeNotifications: [Notification!]!
|
|
341
373
|
runtimeVerifyStringSignedByDid(data: String!, did: String!, didSigningKeyId: String!, signedData: String!): Boolean!
|
|
342
374
|
}
|
|
343
375
|
|
|
@@ -376,5 +408,13 @@ type Subscription {
|
|
|
376
408
|
perspectiveSyncStateChange(uuid: String!): String!
|
|
377
409
|
perspectiveUpdated: PerspectiveHandle
|
|
378
410
|
runtimeMessageReceived: PerspectiveExpression
|
|
411
|
+
runtimeNotificationRequested: Notification
|
|
412
|
+
runtimeNotificationTriggered: TriggeredNotification
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
type TriggeredNotification {
|
|
416
|
+
notification: Notification!
|
|
417
|
+
perspectiveId: String!
|
|
418
|
+
triggerMatch: String!
|
|
379
419
|
}
|
|
380
420
|
`
|
package/package.json
CHANGED
|
@@ -5,13 +5,6 @@
|
|
|
5
5
|
"module": "lib/index.js",
|
|
6
6
|
"types": "lib/src/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"private": false,
|
|
9
|
-
"scripts": {
|
|
10
|
-
"build": "patch-package && tsc && pnpm run buildSchema && pnpm run bundle",
|
|
11
|
-
"buildSchema": "node --es-module-specifier-resolution=node lib/src/buildSchema.js",
|
|
12
|
-
"bundle": "rollup -c rollup.config.js",
|
|
13
|
-
"test": "jest --forceExit"
|
|
14
|
-
},
|
|
15
8
|
"repository": {
|
|
16
9
|
"type": "git",
|
|
17
10
|
"url": "git+https://github.com/perspect3vism/ad4m.git"
|
|
@@ -60,10 +53,11 @@
|
|
|
60
53
|
"@types/yargs": "*"
|
|
61
54
|
},
|
|
62
55
|
"patchedDependencies": {},
|
|
63
|
-
"version": "0.9.1-prerelease",
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
|
|
67
|
-
|
|
56
|
+
"version": "0.9.1-prerelease.1",
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "patch-package && tsc && pnpm run buildSchema && pnpm run bundle",
|
|
59
|
+
"buildSchema": "node --es-module-specifier-resolution=node lib/src/buildSchema.js",
|
|
60
|
+
"bundle": "rollup -c rollup.config.js",
|
|
61
|
+
"test": "jest --forceExit"
|
|
68
62
|
}
|
|
69
|
-
}
|
|
63
|
+
}
|
package/src/Ad4mClient.test.ts
CHANGED
|
@@ -34,9 +34,9 @@ jest.setTimeout(15000)
|
|
|
34
34
|
async function createGqlServer(port: number) {
|
|
35
35
|
const schema = await buildSchema({
|
|
36
36
|
resolvers: [
|
|
37
|
-
AgentResolver,
|
|
37
|
+
AgentResolver,
|
|
38
38
|
ExpressionResolver,
|
|
39
|
-
LanguageResolver,
|
|
39
|
+
LanguageResolver,
|
|
40
40
|
NeighbourhoodResolver,
|
|
41
41
|
PerspectiveResolver,
|
|
42
42
|
RuntimeResolver
|
|
@@ -87,7 +87,7 @@ async function createGqlServer(port: number) {
|
|
|
87
87
|
describe('Ad4mClient', () => {
|
|
88
88
|
let ad4mClient
|
|
89
89
|
let apolloClient
|
|
90
|
-
|
|
90
|
+
|
|
91
91
|
beforeAll(async () => {
|
|
92
92
|
let port = await createGqlServer(4000);
|
|
93
93
|
|
|
@@ -98,7 +98,7 @@ describe('Ad4mClient', () => {
|
|
|
98
98
|
webSocketImpl: Websocket
|
|
99
99
|
}));
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
|
|
102
102
|
|
|
103
103
|
apolloClient = new ApolloClient({
|
|
104
104
|
link: wsLink,
|
|
@@ -254,9 +254,9 @@ describe('Ad4mClient', () => {
|
|
|
254
254
|
appDesc: "demo-desc",
|
|
255
255
|
appDomain: "demo.test.org",
|
|
256
256
|
appUrl: "https://demo-link",
|
|
257
|
-
appIconPath: "/some/image/path",
|
|
257
|
+
appIconPath: "/some/image/path",
|
|
258
258
|
capabilities: [
|
|
259
|
-
{
|
|
259
|
+
{
|
|
260
260
|
with: {
|
|
261
261
|
"domain":"agent",
|
|
262
262
|
"pointers":["*"]
|
|
@@ -267,7 +267,7 @@ describe('Ad4mClient', () => {
|
|
|
267
267
|
expect(requestId).toBe("test-request-id")
|
|
268
268
|
})
|
|
269
269
|
|
|
270
|
-
|
|
270
|
+
|
|
271
271
|
it('agentGetApps() smoke tests', async () => {
|
|
272
272
|
const apps = await ad4mClient.agent.getApps()
|
|
273
273
|
expect(apps.length).toBe(0)
|
|
@@ -705,7 +705,7 @@ describe('Ad4mClient', () => {
|
|
|
705
705
|
|
|
706
706
|
it('addListener() smoke test', async () => {
|
|
707
707
|
let perspective = await ad4mClient.perspective.byUUID('00004')
|
|
708
|
-
|
|
708
|
+
|
|
709
709
|
const testLink = new LinkExpression()
|
|
710
710
|
testLink.author = "did:ad4m:test"
|
|
711
711
|
testLink.timestamp = Date.now().toString()
|
|
@@ -726,7 +726,7 @@ describe('Ad4mClient', () => {
|
|
|
726
726
|
const link = new LinkExpressionInput()
|
|
727
727
|
link.source = 'root'
|
|
728
728
|
link.target = 'perspective://Qm34589a3ccc0'
|
|
729
|
-
await perspective.add(link)
|
|
729
|
+
await perspective.add(link)
|
|
730
730
|
|
|
731
731
|
expect(linkAdded).toBeCalledTimes(1)
|
|
732
732
|
expect(linkRemoved).toBeCalledTimes(0)
|
|
@@ -734,7 +734,7 @@ describe('Ad4mClient', () => {
|
|
|
734
734
|
perspective = await ad4mClient.perspective.byUUID('00004')
|
|
735
735
|
|
|
736
736
|
await perspective.addListener('link-removed', linkRemoved)
|
|
737
|
-
await perspective.remove(testLink)
|
|
737
|
+
await perspective.remove(testLink)
|
|
738
738
|
|
|
739
739
|
expect(linkAdded).toBeCalledTimes(1)
|
|
740
740
|
expect(linkRemoved).toBeCalledTimes(1)
|
|
@@ -742,20 +742,20 @@ describe('Ad4mClient', () => {
|
|
|
742
742
|
|
|
743
743
|
it('removeListener() smoke test', async () => {
|
|
744
744
|
let perspective = await ad4mClient.perspective.byUUID('00004')
|
|
745
|
-
|
|
745
|
+
|
|
746
746
|
const linkAdded = jest.fn()
|
|
747
747
|
|
|
748
748
|
await perspective.addListener('link-added', linkAdded)
|
|
749
|
-
await perspective.add({source: 'root', target: 'neighbourhood://Qm12345'})
|
|
749
|
+
await perspective.add({source: 'root', target: 'neighbourhood://Qm12345'})
|
|
750
750
|
|
|
751
751
|
expect(linkAdded).toBeCalledTimes(1)
|
|
752
752
|
|
|
753
753
|
linkAdded.mockClear();
|
|
754
|
-
|
|
754
|
+
|
|
755
755
|
perspective = await ad4mClient.perspective.byUUID('00004')
|
|
756
756
|
|
|
757
757
|
await perspective.removeListener('link-added', linkAdded)
|
|
758
|
-
await perspective.add({source: 'root', target: 'neighbourhood://Qm123456'})
|
|
758
|
+
await perspective.add({source: 'root', target: 'neighbourhood://Qm123456'})
|
|
759
759
|
|
|
760
760
|
expect(linkAdded).toBeCalledTimes(1)
|
|
761
761
|
})
|
|
@@ -774,7 +774,7 @@ describe('Ad4mClient', () => {
|
|
|
774
774
|
|
|
775
775
|
it('updateLink() smoke test', async () => {
|
|
776
776
|
const link = await ad4mClient.perspective.updateLink(
|
|
777
|
-
'00001',
|
|
777
|
+
'00001',
|
|
778
778
|
{author: '', timestamp: '', proof: {signature: '', key: ''}, data:{source: 'root', target: 'none'}},
|
|
779
779
|
{source: 'root', target: 'lang://Qm123', predicate: 'p'})
|
|
780
780
|
expect(link.author).toBe('did:ad4m:test')
|
|
@@ -792,6 +792,30 @@ describe('Ad4mClient', () => {
|
|
|
792
792
|
const r = await ad4mClient.perspective.addSdna('00001', "Test", 'subject_class("Test", test)', 'subject_class');
|
|
793
793
|
expect(r).toBeTruthy()
|
|
794
794
|
})
|
|
795
|
+
|
|
796
|
+
it('executeCommands() smoke test', async () => {
|
|
797
|
+
const result = await ad4mClient.perspective.executeCommands(
|
|
798
|
+
'00001',
|
|
799
|
+
'command1; command2',
|
|
800
|
+
'expression1',
|
|
801
|
+
'param1, param2'
|
|
802
|
+
);
|
|
803
|
+
expect(result).toBeTruthy();
|
|
804
|
+
})
|
|
805
|
+
|
|
806
|
+
it('getSubjectData() smoke test', async () => {
|
|
807
|
+
const result = await ad4mClient.perspective.getSubjectData('00001', 'Test', 'test');
|
|
808
|
+
expect(result).toBe("");
|
|
809
|
+
});
|
|
810
|
+
|
|
811
|
+
it('createSubject() smoke test', async () => {
|
|
812
|
+
const result = await ad4mClient.perspective.createSubject(
|
|
813
|
+
'00001',
|
|
814
|
+
'command1; command2',
|
|
815
|
+
'expression1',
|
|
816
|
+
);
|
|
817
|
+
expect(result).toBeTruthy();
|
|
818
|
+
})
|
|
795
819
|
})
|
|
796
820
|
|
|
797
821
|
describe('.runtime', () => {
|
|
@@ -804,7 +828,7 @@ describe('Ad4mClient', () => {
|
|
|
804
828
|
const r = await ad4mClient.runtime.openLink('https://ad4m.dev')
|
|
805
829
|
expect(r).toBeTruthy()
|
|
806
830
|
})
|
|
807
|
-
|
|
831
|
+
|
|
808
832
|
it('addTrustedAgents() smoke test', async () => {
|
|
809
833
|
const r = await ad4mClient.runtime.addTrustedAgents(["agentPubKey"]);
|
|
810
834
|
expect(r).toStrictEqual([ 'agentPubKey' ])
|
|
@@ -866,7 +890,7 @@ describe('Ad4mClient', () => {
|
|
|
866
890
|
const verify = await ad4mClient.runtime.verifyStringSignedByDid("did", "didSigningKeyId", "data", "signedData")
|
|
867
891
|
expect(verify).toBe(true)
|
|
868
892
|
})
|
|
869
|
-
|
|
893
|
+
|
|
870
894
|
it('setStatus smoke test', async () => {
|
|
871
895
|
const link = new LinkExpression()
|
|
872
896
|
link.author = 'did:method:12345'
|
|
@@ -924,6 +948,45 @@ describe('Ad4mClient', () => {
|
|
|
924
948
|
expect(runtimeInfo.isInitialized).toBe(true);
|
|
925
949
|
expect(runtimeInfo.isUnlocked).toBe(true);
|
|
926
950
|
})
|
|
951
|
+
|
|
952
|
+
it('requestInstallNotification smoke test', async () => {
|
|
953
|
+
await ad4mClient.runtime.requestInstallNotification({
|
|
954
|
+
description: "Test description",
|
|
955
|
+
appName: "Test app name",
|
|
956
|
+
appUrl: "https://example.com",
|
|
957
|
+
appIconPath: "https://example.com/icon",
|
|
958
|
+
trigger: "triple(X, ad4m://has_type, flux://message)",
|
|
959
|
+
perspectiveIds: ["u983ud-jdhh38d"],
|
|
960
|
+
webhookUrl: "https://example.com/webhook",
|
|
961
|
+
webhookAuth: "test-auth",
|
|
962
|
+
});
|
|
963
|
+
})
|
|
964
|
+
|
|
965
|
+
it('grantNotification smoke test', async () => {
|
|
966
|
+
await ad4mClient.runtime.grantNotification("test-notification");
|
|
967
|
+
})
|
|
968
|
+
|
|
969
|
+
it('notifications smoke test', async () => {
|
|
970
|
+
const notifications = await ad4mClient.runtime.notifications();
|
|
971
|
+
expect(notifications.length).toBe(1);
|
|
972
|
+
})
|
|
973
|
+
|
|
974
|
+
it('updateNotification smoke test', async () => {
|
|
975
|
+
await ad4mClient.runtime.updateNotification("test-notification", {
|
|
976
|
+
description: "Test description",
|
|
977
|
+
appName: "Test app name",
|
|
978
|
+
appUrl: "https://example.com",
|
|
979
|
+
appIconPath: "https://example.com/icon",
|
|
980
|
+
trigger: "triple(X, ad4m://has_type, flux://message)",
|
|
981
|
+
perspectiveIds: ["u983ud-jdhh38d"],
|
|
982
|
+
webhookUrl: "https://example.com/webhook",
|
|
983
|
+
webhookAuth: "test-auth",
|
|
984
|
+
});
|
|
985
|
+
})
|
|
986
|
+
|
|
987
|
+
it('removeNotification smoke test', async () => {
|
|
988
|
+
await ad4mClient.runtime.removeNotification("test-notification");
|
|
989
|
+
})
|
|
927
990
|
})
|
|
928
991
|
|
|
929
992
|
describe('Ad4mClient subscriptions', () => {
|
|
@@ -945,13 +1008,13 @@ describe('Ad4mClient', () => {
|
|
|
945
1008
|
await ad4mClientWithoutSubscription.agent.updateDirectMessageLanguage("lang://test");
|
|
946
1009
|
expect(agentUpdatedCallback).toBeCalledTimes(1)
|
|
947
1010
|
})
|
|
948
|
-
|
|
1011
|
+
|
|
949
1012
|
it('agent subscribeAgentStatusChanged smoke test', async () => {
|
|
950
1013
|
const agentStatusChangedCallback = jest.fn()
|
|
951
1014
|
ad4mClientWithoutSubscription.agent.addAgentStatusChangedListener(agentStatusChangedCallback)
|
|
952
1015
|
await new Promise<void>(resolve => setTimeout(resolve, 100))
|
|
953
1016
|
expect(agentStatusChangedCallback).toBeCalledTimes(0)
|
|
954
|
-
|
|
1017
|
+
|
|
955
1018
|
ad4mClientWithoutSubscription.agent.subscribeAgentStatusChanged()
|
|
956
1019
|
await new Promise<void>(resolve => setTimeout(resolve, 100))
|
|
957
1020
|
await ad4mClientWithoutSubscription.agent.unlock("test", false);
|
|
@@ -963,13 +1026,13 @@ describe('Ad4mClient', () => {
|
|
|
963
1026
|
ad4mClientWithoutSubscription.agent.addAppChangedListener(appsChangedCallback)
|
|
964
1027
|
await new Promise<void>(resolve => setTimeout(resolve, 100))
|
|
965
1028
|
expect(appsChangedCallback).toBeCalledTimes(0)
|
|
966
|
-
|
|
1029
|
+
|
|
967
1030
|
ad4mClientWithoutSubscription.agent.subscribeAppsChanged()
|
|
968
1031
|
await new Promise<void>(resolve => setTimeout(resolve, 100))
|
|
969
1032
|
await ad4mClientWithoutSubscription.agent.removeApp("test");
|
|
970
1033
|
expect(appsChangedCallback).toBeCalledTimes(1)
|
|
971
1034
|
})
|
|
972
|
-
|
|
1035
|
+
|
|
973
1036
|
it('perspective subscribePerspectiveAdded smoke test', async () => {
|
|
974
1037
|
const perspectiveAddedCallback = jest.fn()
|
|
975
1038
|
ad4mClientWithoutSubscription.perspective.addPerspectiveAddedListener(perspectiveAddedCallback)
|
|
@@ -982,7 +1045,7 @@ describe('Ad4mClient', () => {
|
|
|
982
1045
|
await new Promise<void>(resolve => setTimeout(resolve, 100))
|
|
983
1046
|
expect(perspectiveAddedCallback).toBeCalledTimes(1)
|
|
984
1047
|
})
|
|
985
|
-
|
|
1048
|
+
|
|
986
1049
|
it('perspective subscribePerspectiveUpdated smoke test', async () => {
|
|
987
1050
|
const perspectiveUpdatedCallback = jest.fn()
|
|
988
1051
|
ad4mClientWithoutSubscription.perspective.addPerspectiveUpdatedListener(perspectiveUpdatedCallback)
|
|
@@ -995,7 +1058,7 @@ describe('Ad4mClient', () => {
|
|
|
995
1058
|
await new Promise<void>(resolve => setTimeout(resolve, 100))
|
|
996
1059
|
expect(perspectiveUpdatedCallback).toBeCalledTimes(1)
|
|
997
1060
|
})
|
|
998
|
-
|
|
1061
|
+
|
|
999
1062
|
it('perspective subscribePerspectiveRemoved smoke test', async () => {
|
|
1000
1063
|
const perspectiveRemovedCallback = jest.fn()
|
|
1001
1064
|
ad4mClientWithoutSubscription.perspective.addPerspectiveRemovedListener(perspectiveRemovedCallback)
|
|
@@ -1012,7 +1075,7 @@ describe('Ad4mClient', () => {
|
|
|
1012
1075
|
|
|
1013
1076
|
describe('ad4mClient with subscription', () => {
|
|
1014
1077
|
let ad4mClientWithSubscription
|
|
1015
|
-
|
|
1078
|
+
|
|
1016
1079
|
beforeEach(() => {
|
|
1017
1080
|
ad4mClientWithSubscription = new Ad4mClient(apolloClient, true)
|
|
1018
1081
|
})
|
|
@@ -1022,18 +1085,18 @@ describe('Ad4mClient', () => {
|
|
|
1022
1085
|
ad4mClientWithSubscription.agent.addUpdatedListener(agentUpdatedCallback)
|
|
1023
1086
|
await new Promise<void>(resolve => setTimeout(resolve, 100))
|
|
1024
1087
|
expect(agentUpdatedCallback).toBeCalledTimes(0)
|
|
1025
|
-
|
|
1088
|
+
|
|
1026
1089
|
await new Promise<void>(resolve => setTimeout(resolve, 100))
|
|
1027
1090
|
await ad4mClientWithSubscription.agent.updateDirectMessageLanguage("lang://test");
|
|
1028
1091
|
expect(agentUpdatedCallback).toBeCalledTimes(1)
|
|
1029
1092
|
})
|
|
1030
|
-
|
|
1093
|
+
|
|
1031
1094
|
it('agent subscribeAgentStatusChanged smoke test', async () => {
|
|
1032
1095
|
const agentStatusChangedCallback = jest.fn()
|
|
1033
1096
|
ad4mClientWithSubscription.agent.addAgentStatusChangedListener(agentStatusChangedCallback)
|
|
1034
1097
|
await new Promise<void>(resolve => setTimeout(resolve, 100))
|
|
1035
1098
|
expect(agentStatusChangedCallback).toBeCalledTimes(0)
|
|
1036
|
-
|
|
1099
|
+
|
|
1037
1100
|
await new Promise<void>(resolve => setTimeout(resolve, 100))
|
|
1038
1101
|
await ad4mClientWithSubscription.agent.unlock("test", false);
|
|
1039
1102
|
expect(agentStatusChangedCallback).toBeCalledTimes(1)
|
|
@@ -1044,12 +1107,12 @@ describe('Ad4mClient', () => {
|
|
|
1044
1107
|
ad4mClientWithSubscription.agent.addAppChangedListener(appsChangedCallback)
|
|
1045
1108
|
await new Promise<void>(resolve => setTimeout(resolve, 100))
|
|
1046
1109
|
expect(appsChangedCallback).toBeCalledTimes(0)
|
|
1047
|
-
|
|
1110
|
+
|
|
1048
1111
|
await new Promise<void>(resolve => setTimeout(resolve, 100))
|
|
1049
1112
|
await ad4mClientWithSubscription.agent.removeApp("test");
|
|
1050
1113
|
expect(appsChangedCallback).toBeCalledTimes(1)
|
|
1051
1114
|
})
|
|
1052
|
-
|
|
1115
|
+
|
|
1053
1116
|
it('perspective subscribePerspectiveAdded smoke test', async () => {
|
|
1054
1117
|
const perspectiveAddedCallback = jest.fn()
|
|
1055
1118
|
ad4mClientWithSubscription.perspective.addPerspectiveAddedListener(perspectiveAddedCallback)
|
|
@@ -1061,7 +1124,7 @@ describe('Ad4mClient', () => {
|
|
|
1061
1124
|
await new Promise<void>(resolve => setTimeout(resolve, 100))
|
|
1062
1125
|
expect(perspectiveAddedCallback).toBeCalledTimes(1)
|
|
1063
1126
|
})
|
|
1064
|
-
|
|
1127
|
+
|
|
1065
1128
|
it('perspective subscribePerspectiveUpdated smoke test', async () => {
|
|
1066
1129
|
const perspectiveUpdatedCallback = jest.fn()
|
|
1067
1130
|
ad4mClientWithSubscription.perspective.addPerspectiveUpdatedListener(perspectiveUpdatedCallback)
|
|
@@ -1073,13 +1136,13 @@ describe('Ad4mClient', () => {
|
|
|
1073
1136
|
await new Promise<void>(resolve => setTimeout(resolve, 100))
|
|
1074
1137
|
expect(perspectiveUpdatedCallback).toBeCalledTimes(1)
|
|
1075
1138
|
})
|
|
1076
|
-
|
|
1139
|
+
|
|
1077
1140
|
it('perspective subscribePerspectiveRemoved smoke test', async () => {
|
|
1078
1141
|
const perspectiveRemovedCallback = jest.fn()
|
|
1079
1142
|
ad4mClientWithSubscription.perspective.addPerspectiveRemovedListener(perspectiveRemovedCallback)
|
|
1080
1143
|
await new Promise<void>(resolve => setTimeout(resolve, 100))
|
|
1081
1144
|
expect(perspectiveRemovedCallback).toBeCalledTimes(0)
|
|
1082
|
-
|
|
1145
|
+
|
|
1083
1146
|
await new Promise<void>(resolve => setTimeout(resolve, 100))
|
|
1084
1147
|
await ad4mClientWithSubscription.perspective.remove('00006');
|
|
1085
1148
|
await new Promise<void>(resolve => setTimeout(resolve, 100))
|
package/src/Exception.ts
CHANGED
package/src/PubSub.ts
CHANGED
|
@@ -9,6 +9,8 @@ export const LINK_REMOVED_TOPIC = 'link-removed-topic'
|
|
|
9
9
|
export const LINK_UDATED_TOPIC = 'link-updated-topic'
|
|
10
10
|
export const SIGNAL = "signal"
|
|
11
11
|
export const EXCEPTION_OCCURRED_TOPIC = "exception-occurred-topic"
|
|
12
|
+
export const RUNTIME_NOTIFICATION_REQUESTED_TOPIC = "runtime-notification-requested-topic"
|
|
13
|
+
export const RUNTIME_NOTIFICATION_TRIGGERED_TOPIC = "runtime-notification-triggered-topic"
|
|
12
14
|
export const NEIGHBOURHOOD_SIGNAL_RECEIVED_TOPIC = "neighbourhood-signal-received-topic"
|
|
13
15
|
export const PERSPECTIVE_SYNC_STATE_CHANGE = "perspective-sync-state-change"
|
|
14
16
|
export const APPS_CHANGED = "apps-changed"
|
|
@@ -292,6 +292,33 @@ export class PerspectiveClient {
|
|
|
292
292
|
})).perspectiveAddSdna
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
+
async executeCommands(uuid: string, commands: string, expression: string, parameters: string): Promise<boolean> {
|
|
296
|
+
return unwrapApolloResult(await this.#apolloClient.mutate({
|
|
297
|
+
mutation: gql`mutation perspectiveExecuteCommands($uuid: String!, $commands: String!, $expression: String!, $parameters: String) {
|
|
298
|
+
perspectiveExecuteCommands(uuid: $uuid, commands: $commands, expression: $expression, parameters: $parameters)
|
|
299
|
+
}`,
|
|
300
|
+
variables: { uuid, commands, expression, parameters }
|
|
301
|
+
})).perspectiveExecuteCommands
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
async createSubject(uuid: string, subjectClass: string, expressionAddress: string): Promise<boolean> {
|
|
305
|
+
return unwrapApolloResult(await this.#apolloClient.mutate({
|
|
306
|
+
mutation: gql`mutation perspectiveCreateSubject($uuid: String!, $subjectClass: String!, $expressionAddress: String!) {
|
|
307
|
+
perspectiveCreateSubject(uuid: $uuid, subjectClass: $subjectClass, expressionAddress: $expressionAddress)
|
|
308
|
+
}`,
|
|
309
|
+
variables: { uuid, subjectClass, expressionAddress }
|
|
310
|
+
})).perspectiveCreateSubject
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
async getSubjectData(uuid: string, subjectClass: string, expressionAddress: string): Promise<string> {
|
|
314
|
+
return unwrapApolloResult(await this.#apolloClient.mutate({
|
|
315
|
+
mutation: gql`mutation perspectiveGetSubjectData($uuid: String!, $subjectClass: String!, $expressionAddress: String!) {
|
|
316
|
+
perspectiveGetSubjectData(uuid: $uuid, subjectClass: $subjectClass, expressionAddress: $expressionAddress)
|
|
317
|
+
}`,
|
|
318
|
+
variables: { uuid, subjectClass, expressionAddress }
|
|
319
|
+
})).perspectiveGetSubjectData
|
|
320
|
+
}
|
|
321
|
+
|
|
295
322
|
// ExpressionClient functions, needed for Subjects:
|
|
296
323
|
async getExpression(expressionURI: string): Promise<ExpressionRendered> {
|
|
297
324
|
return await this.#expressionClient.get(expressionURI)
|