@coasys/ad4m 0.9.0 → 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/index.cjs
CHANGED
|
@@ -4638,55 +4638,7 @@ class PerspectiveProxy {
|
|
|
4638
4638
|
__classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").addPerspectiveSyncStateChangeListener(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, __classPrivateFieldGet$9(this, _PerspectiveProxy_perspectiveSyncStateChangeCallbacks, "f"));
|
|
4639
4639
|
}
|
|
4640
4640
|
async executeAction(actions, expression, parameters) {
|
|
4641
|
-
|
|
4642
|
-
if (input) {
|
|
4643
|
-
if (input === 'this') {
|
|
4644
|
-
return expression;
|
|
4645
|
-
}
|
|
4646
|
-
else {
|
|
4647
|
-
return input;
|
|
4648
|
-
}
|
|
4649
|
-
}
|
|
4650
|
-
else {
|
|
4651
|
-
return undefined;
|
|
4652
|
-
}
|
|
4653
|
-
};
|
|
4654
|
-
const replaceParameters = (input) => {
|
|
4655
|
-
if (parameters) {
|
|
4656
|
-
let output = input;
|
|
4657
|
-
for (const parameter of parameters) {
|
|
4658
|
-
output = output.replace(parameter.name, parameter.value);
|
|
4659
|
-
}
|
|
4660
|
-
return output;
|
|
4661
|
-
}
|
|
4662
|
-
else
|
|
4663
|
-
return input;
|
|
4664
|
-
};
|
|
4665
|
-
for (let command of actions) {
|
|
4666
|
-
let source = replaceThis(replaceParameters(command.source));
|
|
4667
|
-
let predicate = replaceThis(replaceParameters(command.predicate));
|
|
4668
|
-
let target = replaceThis(replaceParameters(command.target));
|
|
4669
|
-
let local = command?.local ?? false;
|
|
4670
|
-
switch (command.action) {
|
|
4671
|
-
case 'addLink':
|
|
4672
|
-
await this.add(new exports.Link({ source, predicate, target }), local ? 'local' : 'shared');
|
|
4673
|
-
break;
|
|
4674
|
-
case 'removeLink':
|
|
4675
|
-
const linkExpressions = await this.get(new exports.LinkQuery({ source, predicate, target }));
|
|
4676
|
-
for (const linkExpression of linkExpressions) {
|
|
4677
|
-
await this.remove(linkExpression);
|
|
4678
|
-
}
|
|
4679
|
-
break;
|
|
4680
|
-
case 'setSingleTarget':
|
|
4681
|
-
await this.setSingleTarget(new exports.Link({ source, predicate, target }), local ? 'local' : 'shared');
|
|
4682
|
-
break;
|
|
4683
|
-
case 'collectionSetter':
|
|
4684
|
-
const links = await this.get(new exports.LinkQuery({ source, predicate }));
|
|
4685
|
-
await this.removeLinks(links);
|
|
4686
|
-
await this.addLinks(parameters.map(p => new exports.Link({ source, predicate, target: p.value })), local ? 'local' : 'shared');
|
|
4687
|
-
break;
|
|
4688
|
-
}
|
|
4689
|
-
}
|
|
4641
|
+
return await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").executeCommands(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify(actions), expression, JSON.stringify(parameters));
|
|
4690
4642
|
}
|
|
4691
4643
|
/** Returns all the links of this perspective that matches the LinkQuery */
|
|
4692
4644
|
async get(query) {
|
|
@@ -4905,15 +4857,24 @@ class PerspectiveProxy {
|
|
|
4905
4857
|
* @param exprAddr The address of the expression to be turned into a subject instance
|
|
4906
4858
|
*/
|
|
4907
4859
|
async createSubject(subjectClass, exprAddr) {
|
|
4908
|
-
let className
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4860
|
+
let className;
|
|
4861
|
+
if (typeof subjectClass === "string") {
|
|
4862
|
+
className = subjectClass;
|
|
4863
|
+
await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").createSubject(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({ className }), exprAddr);
|
|
4864
|
+
}
|
|
4865
|
+
else {
|
|
4866
|
+
let query = this.buildQueryFromTemplate(subjectClass);
|
|
4867
|
+
await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").createSubject(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({ query }), exprAddr);
|
|
4912
4868
|
}
|
|
4913
|
-
let actions = result.map(x => eval(x.Actions));
|
|
4914
|
-
await this.executeAction(actions[0], exprAddr, undefined);
|
|
4915
4869
|
return this.getSubjectProxy(exprAddr, subjectClass);
|
|
4916
4870
|
}
|
|
4871
|
+
async getSubjectData(subjectClass, exprAddr) {
|
|
4872
|
+
if (typeof subjectClass === "string") {
|
|
4873
|
+
return JSON.parse(await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").getSubjectData(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({ className: subjectClass }), exprAddr));
|
|
4874
|
+
}
|
|
4875
|
+
let query = this.buildQueryFromTemplate(subjectClass);
|
|
4876
|
+
return JSON.parse(await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").getSubjectData(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({ query }), exprAddr));
|
|
4877
|
+
}
|
|
4917
4878
|
/** Removes a subject instance by running its (SDNA defined) destructor,
|
|
4918
4879
|
* which means removing links around the given expression address
|
|
4919
4880
|
*
|
|
@@ -4999,18 +4960,7 @@ class PerspectiveProxy {
|
|
|
4999
4960
|
}
|
|
5000
4961
|
return instances;
|
|
5001
4962
|
}
|
|
5002
|
-
|
|
5003
|
-
* This function looks at the properties of the template object and
|
|
5004
|
-
* its setters and collections to create a Prolog query that finds
|
|
5005
|
-
* all subject classes that would be converted to a proxy object
|
|
5006
|
-
* with exactly the same properties and collections.
|
|
5007
|
-
*
|
|
5008
|
-
* Since there could be multiple subject classes that match the given
|
|
5009
|
-
* criteria, this function returns a list of class names.
|
|
5010
|
-
*
|
|
5011
|
-
* @param obj The template object
|
|
5012
|
-
*/
|
|
5013
|
-
async subjectClassesByTemplate(obj) {
|
|
4963
|
+
buildQueryFromTemplate(obj) {
|
|
5014
4964
|
// Collect all string properties of the object in a list
|
|
5015
4965
|
let properties = [];
|
|
5016
4966
|
// Collect all collections of the object in a list
|
|
@@ -5069,6 +5019,21 @@ class PerspectiveProxy {
|
|
|
5069
5019
|
query += `, collection_setter(C, "${collectionSetterToName(setCollectionFunction)}", _)`;
|
|
5070
5020
|
}
|
|
5071
5021
|
query += ".";
|
|
5022
|
+
return query;
|
|
5023
|
+
}
|
|
5024
|
+
/** Returns all subject classes that match the given template object.
|
|
5025
|
+
* This function looks at the properties of the template object and
|
|
5026
|
+
* its setters and collections to create a Prolog query that finds
|
|
5027
|
+
* all subject classes that would be converted to a proxy object
|
|
5028
|
+
* with exactly the same properties and collections.
|
|
5029
|
+
*
|
|
5030
|
+
* Since there could be multiple subject classes that match the given
|
|
5031
|
+
* criteria, this function returns a list of class names.
|
|
5032
|
+
*
|
|
5033
|
+
* @param obj The template object
|
|
5034
|
+
*/
|
|
5035
|
+
async subjectClassesByTemplate(obj) {
|
|
5036
|
+
const query = this.buildQueryFromTemplate(obj);
|
|
5072
5037
|
let result = await this.infer(query);
|
|
5073
5038
|
if (!result) {
|
|
5074
5039
|
return [];
|
|
@@ -5361,6 +5326,30 @@ class PerspectiveClient {
|
|
|
5361
5326
|
variables: { uuid, name, sdnaCode, sdnaType }
|
|
5362
5327
|
})).perspectiveAddSdna;
|
|
5363
5328
|
}
|
|
5329
|
+
async executeCommands(uuid, commands, expression, parameters) {
|
|
5330
|
+
return unwrapApolloResult(await __classPrivateFieldGet$8(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
5331
|
+
mutation: gql `mutation perspectiveExecuteCommands($uuid: String!, $commands: String!, $expression: String!, $parameters: String) {
|
|
5332
|
+
perspectiveExecuteCommands(uuid: $uuid, commands: $commands, expression: $expression, parameters: $parameters)
|
|
5333
|
+
}`,
|
|
5334
|
+
variables: { uuid, commands, expression, parameters }
|
|
5335
|
+
})).perspectiveExecuteCommands;
|
|
5336
|
+
}
|
|
5337
|
+
async createSubject(uuid, subjectClass, expressionAddress) {
|
|
5338
|
+
return unwrapApolloResult(await __classPrivateFieldGet$8(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
5339
|
+
mutation: gql `mutation perspectiveCreateSubject($uuid: String!, $subjectClass: String!, $expressionAddress: String!) {
|
|
5340
|
+
perspectiveCreateSubject(uuid: $uuid, subjectClass: $subjectClass, expressionAddress: $expressionAddress)
|
|
5341
|
+
}`,
|
|
5342
|
+
variables: { uuid, subjectClass, expressionAddress }
|
|
5343
|
+
})).perspectiveCreateSubject;
|
|
5344
|
+
}
|
|
5345
|
+
async getSubjectData(uuid, subjectClass, expressionAddress) {
|
|
5346
|
+
return unwrapApolloResult(await __classPrivateFieldGet$8(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
5347
|
+
mutation: gql `mutation perspectiveGetSubjectData($uuid: String!, $subjectClass: String!, $expressionAddress: String!) {
|
|
5348
|
+
perspectiveGetSubjectData(uuid: $uuid, subjectClass: $subjectClass, expressionAddress: $expressionAddress)
|
|
5349
|
+
}`,
|
|
5350
|
+
variables: { uuid, subjectClass, expressionAddress }
|
|
5351
|
+
})).perspectiveGetSubjectData;
|
|
5352
|
+
}
|
|
5364
5353
|
// ExpressionClient functions, needed for Subjects:
|
|
5365
5354
|
async getExpression(expressionURI) {
|
|
5366
5355
|
return await __classPrivateFieldGet$8(this, _PerspectiveClient_expressionClient, "f").get(expressionURI);
|
|
@@ -6341,7 +6330,7 @@ var __classPrivateFieldGet$4 = (undefined && undefined.__classPrivateFieldGet) |
|
|
|
6341
6330
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
6342
6331
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6343
6332
|
};
|
|
6344
|
-
var _RuntimeClient_apolloClient, _RuntimeClient_messageReceivedCallbacks, _RuntimeClient_exceptionOccurredCallbacks;
|
|
6333
|
+
var _RuntimeClient_apolloClient, _RuntimeClient_messageReceivedCallbacks, _RuntimeClient_exceptionOccurredCallbacks, _RuntimeClient_notificationTriggeredCallbacks, _RuntimeClient_notificationRequestedCallbacks;
|
|
6345
6334
|
const PERSPECTIVE_EXPRESSION_FIELDS = `
|
|
6346
6335
|
author
|
|
6347
6336
|
timestamp
|
|
@@ -6355,17 +6344,43 @@ data {
|
|
|
6355
6344
|
}
|
|
6356
6345
|
proof { valid, invalid, signature, key }
|
|
6357
6346
|
`;
|
|
6347
|
+
const NOTIFICATION_DEFINITION_FIELDS = `
|
|
6348
|
+
description
|
|
6349
|
+
appName
|
|
6350
|
+
appUrl
|
|
6351
|
+
appIconPath
|
|
6352
|
+
trigger
|
|
6353
|
+
perspectiveIds
|
|
6354
|
+
webhookUrl
|
|
6355
|
+
webhookAuth
|
|
6356
|
+
`;
|
|
6357
|
+
const NOTIFICATION_FIELDS = `
|
|
6358
|
+
id
|
|
6359
|
+
granted
|
|
6360
|
+
${NOTIFICATION_DEFINITION_FIELDS}
|
|
6361
|
+
`;
|
|
6362
|
+
const TRIGGERED_NOTIFICATION_FIELDS = `
|
|
6363
|
+
notification { ${NOTIFICATION_FIELDS} }
|
|
6364
|
+
perspectiveId
|
|
6365
|
+
triggerMatch
|
|
6366
|
+
`;
|
|
6358
6367
|
class RuntimeClient {
|
|
6359
6368
|
constructor(client, subscribe = true) {
|
|
6360
6369
|
_RuntimeClient_apolloClient.set(this, void 0);
|
|
6361
6370
|
_RuntimeClient_messageReceivedCallbacks.set(this, void 0);
|
|
6362
6371
|
_RuntimeClient_exceptionOccurredCallbacks.set(this, void 0);
|
|
6372
|
+
_RuntimeClient_notificationTriggeredCallbacks.set(this, void 0);
|
|
6373
|
+
_RuntimeClient_notificationRequestedCallbacks.set(this, void 0);
|
|
6363
6374
|
__classPrivateFieldSet$4(this, _RuntimeClient_apolloClient, client, "f");
|
|
6364
6375
|
__classPrivateFieldSet$4(this, _RuntimeClient_messageReceivedCallbacks, [], "f");
|
|
6365
6376
|
__classPrivateFieldSet$4(this, _RuntimeClient_exceptionOccurredCallbacks, [], "f");
|
|
6377
|
+
__classPrivateFieldSet$4(this, _RuntimeClient_notificationTriggeredCallbacks, [], "f");
|
|
6378
|
+
__classPrivateFieldSet$4(this, _RuntimeClient_notificationRequestedCallbacks, [], "f");
|
|
6366
6379
|
if (subscribe) {
|
|
6367
6380
|
this.subscribeMessageReceived();
|
|
6368
6381
|
this.subscribeExceptionOccurred();
|
|
6382
|
+
this.subscribeNotificationTriggered();
|
|
6383
|
+
this.subscribeNotificationRequested();
|
|
6369
6384
|
}
|
|
6370
6385
|
}
|
|
6371
6386
|
async info() {
|
|
@@ -6549,6 +6564,86 @@ class RuntimeClient {
|
|
|
6549
6564
|
}));
|
|
6550
6565
|
return runtimeMessageOutbox;
|
|
6551
6566
|
}
|
|
6567
|
+
async requestInstallNotification(notification) {
|
|
6568
|
+
const { runtimeRequestInstallNotification } = unwrapApolloResult(await __classPrivateFieldGet$4(this, _RuntimeClient_apolloClient, "f").mutate({
|
|
6569
|
+
mutation: gql `mutation runtimeRequestInstallNotification($notification: NotificationInput!) {
|
|
6570
|
+
runtimeRequestInstallNotification(notification: $notification)
|
|
6571
|
+
}`,
|
|
6572
|
+
variables: { notification }
|
|
6573
|
+
}));
|
|
6574
|
+
return runtimeRequestInstallNotification;
|
|
6575
|
+
}
|
|
6576
|
+
async grantNotification(id) {
|
|
6577
|
+
const { runtimeGrantNotification } = unwrapApolloResult(await __classPrivateFieldGet$4(this, _RuntimeClient_apolloClient, "f").mutate({
|
|
6578
|
+
mutation: gql `mutation runtimeGrantNotification($id: String!) {
|
|
6579
|
+
runtimeGrantNotification(id: $id)
|
|
6580
|
+
}`,
|
|
6581
|
+
variables: { id }
|
|
6582
|
+
}));
|
|
6583
|
+
return runtimeGrantNotification;
|
|
6584
|
+
}
|
|
6585
|
+
async notifications() {
|
|
6586
|
+
const { runtimeNotifications } = unwrapApolloResult(await __classPrivateFieldGet$4(this, _RuntimeClient_apolloClient, "f").query({
|
|
6587
|
+
query: gql `query runtimeNotifications {
|
|
6588
|
+
runtimeNotifications { ${NOTIFICATION_FIELDS} }
|
|
6589
|
+
}`,
|
|
6590
|
+
}));
|
|
6591
|
+
return runtimeNotifications;
|
|
6592
|
+
}
|
|
6593
|
+
async updateNotification(id, notification) {
|
|
6594
|
+
const { runtimeUpdateNotification } = unwrapApolloResult(await __classPrivateFieldGet$4(this, _RuntimeClient_apolloClient, "f").mutate({
|
|
6595
|
+
mutation: gql `mutation runtimeUpdateNotification($id: String!, $notification: NotificationInput!) {
|
|
6596
|
+
runtimeUpdateNotification(id: $id, notification: $notification)
|
|
6597
|
+
}`,
|
|
6598
|
+
variables: { id, notification }
|
|
6599
|
+
}));
|
|
6600
|
+
return runtimeUpdateNotification;
|
|
6601
|
+
}
|
|
6602
|
+
async removeNotification(id) {
|
|
6603
|
+
const { runtimeRemoveNotification } = unwrapApolloResult(await __classPrivateFieldGet$4(this, _RuntimeClient_apolloClient, "f").mutate({
|
|
6604
|
+
mutation: gql `mutation runtimeRemoveNotification($id: String!) {
|
|
6605
|
+
runtimeRemoveNotification(id: $id)
|
|
6606
|
+
}`,
|
|
6607
|
+
variables: { id }
|
|
6608
|
+
}));
|
|
6609
|
+
return runtimeRemoveNotification;
|
|
6610
|
+
}
|
|
6611
|
+
addNotificationTriggeredCallback(cb) {
|
|
6612
|
+
__classPrivateFieldGet$4(this, _RuntimeClient_notificationTriggeredCallbacks, "f").push(cb);
|
|
6613
|
+
}
|
|
6614
|
+
addNotificationRequestedCallback(cb) {
|
|
6615
|
+
__classPrivateFieldGet$4(this, _RuntimeClient_notificationRequestedCallbacks, "f").push(cb);
|
|
6616
|
+
}
|
|
6617
|
+
subscribeNotificationTriggered() {
|
|
6618
|
+
__classPrivateFieldGet$4(this, _RuntimeClient_apolloClient, "f").subscribe({
|
|
6619
|
+
query: gql ` subscription {
|
|
6620
|
+
runtimeNotificationTriggered { ${TRIGGERED_NOTIFICATION_FIELDS} }
|
|
6621
|
+
}
|
|
6622
|
+
`
|
|
6623
|
+
}).subscribe({
|
|
6624
|
+
next: result => {
|
|
6625
|
+
__classPrivateFieldGet$4(this, _RuntimeClient_notificationTriggeredCallbacks, "f").forEach(cb => {
|
|
6626
|
+
cb(result.data.runtimeNotificationTriggered);
|
|
6627
|
+
});
|
|
6628
|
+
},
|
|
6629
|
+
error: (e) => console.error(e)
|
|
6630
|
+
});
|
|
6631
|
+
}
|
|
6632
|
+
subscribeNotificationRequested() {
|
|
6633
|
+
__classPrivateFieldGet$4(this, _RuntimeClient_apolloClient, "f").subscribe({
|
|
6634
|
+
query: gql ` subscription {
|
|
6635
|
+
runtimeNotificationRequested { ${NOTIFICATION_FIELDS} }
|
|
6636
|
+
}
|
|
6637
|
+
`
|
|
6638
|
+
}).subscribe({
|
|
6639
|
+
next: result => {
|
|
6640
|
+
__classPrivateFieldGet$4(this, _RuntimeClient_notificationRequestedCallbacks, "f").forEach(cb => {
|
|
6641
|
+
cb(result.data.runtimeNotificationRequested);
|
|
6642
|
+
});
|
|
6643
|
+
},
|
|
6644
|
+
error: (e) => console.error(e)
|
|
6645
|
+
});
|
|
6646
|
+
}
|
|
6552
6647
|
addMessageCallback(cb) {
|
|
6553
6648
|
__classPrivateFieldGet$4(this, _RuntimeClient_messageReceivedCallbacks, "f").push(cb);
|
|
6554
6649
|
}
|
|
@@ -6590,7 +6685,7 @@ class RuntimeClient {
|
|
|
6590
6685
|
});
|
|
6591
6686
|
}
|
|
6592
6687
|
}
|
|
6593
|
-
_RuntimeClient_apolloClient = new WeakMap(), _RuntimeClient_messageReceivedCallbacks = new WeakMap(), _RuntimeClient_exceptionOccurredCallbacks = new WeakMap();
|
|
6688
|
+
_RuntimeClient_apolloClient = new WeakMap(), _RuntimeClient_messageReceivedCallbacks = new WeakMap(), _RuntimeClient_exceptionOccurredCallbacks = new WeakMap(), _RuntimeClient_notificationTriggeredCallbacks = new WeakMap(), _RuntimeClient_notificationRequestedCallbacks = new WeakMap();
|
|
6594
6689
|
|
|
6595
6690
|
var __classPrivateFieldSet$3 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
6596
6691
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
@@ -6760,6 +6855,7 @@ exports.ExceptionType = void 0;
|
|
|
6760
6855
|
ExceptionType["ExpressionIsNotVerified"] = "EXPRESSION_IS_NOT_VERIFIED";
|
|
6761
6856
|
ExceptionType["AgentIsUntrusted"] = "AGENT_IS_UNTRUSTED";
|
|
6762
6857
|
ExceptionType["CapabilityRequested"] = "CAPABILITY_REQUESTED";
|
|
6858
|
+
ExceptionType["InstallNotificationRequest"] = "INSTALL_NOTIFICATION_REQUEST";
|
|
6763
6859
|
})(exports.ExceptionType || (exports.ExceptionType = {}));
|
|
6764
6860
|
|
|
6765
6861
|
var __decorate$6 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
@@ -7824,6 +7920,9 @@ type Mutation {
|
|
|
7824
7920
|
perspectiveAddLinkExpression(link: LinkExpressionInput!, status: String, uuid: String!): LinkExpression!
|
|
7825
7921
|
perspectiveAddLinks(links: [LinkInput!]!, status: String, uuid: String!): [LinkExpression!]!
|
|
7826
7922
|
perspectiveAddSdna(name: String!, sdnaCode: String!, sdnaType: String!, uuid: String!): Boolean!
|
|
7923
|
+
perspectiveCreateSubject(expressionAddress: String!, subjectClass: String!, uuid: String!): Boolean!
|
|
7924
|
+
perspectiveExecuteCommands(commands: String!, expression: String!, parameters: String, uuid: String!): Boolean!
|
|
7925
|
+
perspectiveGetSubjectData(expressionAddress: String!, subjectClass: String!, uuid: String!): String!
|
|
7827
7926
|
perspectiveLinkMutations(mutations: LinkMutations!, status: String, uuid: String!): LinkExpressionMutations!
|
|
7828
7927
|
perspectivePublishSnapshot(uuid: String!): String
|
|
7829
7928
|
perspectiveRemove(uuid: String!): Boolean!
|
|
@@ -7834,12 +7933,16 @@ type Mutation {
|
|
|
7834
7933
|
runtimeAddFriends(dids: [String!]!): [String!]!
|
|
7835
7934
|
runtimeAddKnownLinkLanguageTemplates(addresses: [String!]!): [String!]!
|
|
7836
7935
|
runtimeFriendSendMessage(did: String!, message: PerspectiveInput!): Boolean!
|
|
7936
|
+
runtimeGrantNotification(id: String!): Boolean!
|
|
7837
7937
|
runtimeHcAddAgentInfos(agentInfos: String!): Boolean!
|
|
7838
7938
|
runtimeOpenLink(url: String!): Boolean!
|
|
7839
7939
|
runtimeQuit: Boolean!
|
|
7840
7940
|
runtimeRemoveFriends(dids: [String!]!): [String!]!
|
|
7841
7941
|
runtimeRemoveKnownLinkLanguageTemplates(addresses: [String!]!): [String!]!
|
|
7942
|
+
runtimeRemoveNotification(id: String!): Boolean!
|
|
7943
|
+
runtimeRequestInstallNotification(notification: NotificationInput!): String!
|
|
7842
7944
|
runtimeSetStatus(status: PerspectiveInput!): Boolean!
|
|
7945
|
+
runtimeUpdateNotification(id: String!, notification: NotificationInput!): Boolean!
|
|
7843
7946
|
}
|
|
7844
7947
|
|
|
7845
7948
|
type Neighbourhood {
|
|
@@ -7854,6 +7957,30 @@ type NeighbourhoodExpression {
|
|
|
7854
7957
|
timestamp: String!
|
|
7855
7958
|
}
|
|
7856
7959
|
|
|
7960
|
+
type Notification {
|
|
7961
|
+
appIconPath: String!
|
|
7962
|
+
appName: String!
|
|
7963
|
+
appUrl: String!
|
|
7964
|
+
description: String!
|
|
7965
|
+
granted: Boolean!
|
|
7966
|
+
id: String!
|
|
7967
|
+
perspectiveIds: [String!]!
|
|
7968
|
+
trigger: String!
|
|
7969
|
+
webhookAuth: String!
|
|
7970
|
+
webhookUrl: String!
|
|
7971
|
+
}
|
|
7972
|
+
|
|
7973
|
+
input NotificationInput {
|
|
7974
|
+
appIconPath: String!
|
|
7975
|
+
appName: String!
|
|
7976
|
+
appUrl: String!
|
|
7977
|
+
description: String!
|
|
7978
|
+
perspectiveIds: [String!]!
|
|
7979
|
+
trigger: String!
|
|
7980
|
+
webhookAuth: String!
|
|
7981
|
+
webhookUrl: String!
|
|
7982
|
+
}
|
|
7983
|
+
|
|
7857
7984
|
type OnlineAgent {
|
|
7858
7985
|
did: String!
|
|
7859
7986
|
status: PerspectiveExpression!
|
|
@@ -7917,6 +8044,7 @@ type Query {
|
|
|
7917
8044
|
runtimeKnownLinkLanguageTemplates: [String!]!
|
|
7918
8045
|
runtimeMessageInbox(filter: String): [PerspectiveExpression!]!
|
|
7919
8046
|
runtimeMessageOutbox(filter: String): [SentMessage!]!
|
|
8047
|
+
runtimeNotifications: [Notification!]!
|
|
7920
8048
|
runtimeVerifyStringSignedByDid(data: String!, did: String!, didSigningKeyId: String!, signedData: String!): Boolean!
|
|
7921
8049
|
}
|
|
7922
8050
|
|
|
@@ -7955,6 +8083,14 @@ type Subscription {
|
|
|
7955
8083
|
perspectiveSyncStateChange(uuid: String!): String!
|
|
7956
8084
|
perspectiveUpdated: PerspectiveHandle
|
|
7957
8085
|
runtimeMessageReceived: PerspectiveExpression
|
|
8086
|
+
runtimeNotificationRequested: Notification
|
|
8087
|
+
runtimeNotificationTriggered: TriggeredNotification
|
|
8088
|
+
}
|
|
8089
|
+
|
|
8090
|
+
type TriggeredNotification {
|
|
8091
|
+
notification: Notification!
|
|
8092
|
+
perspectiveId: String!
|
|
8093
|
+
triggerMatch: String!
|
|
7958
8094
|
}
|
|
7959
8095
|
`;
|
|
7960
8096
|
|
|
@@ -8019,61 +8155,10 @@ class SubjectEntity {
|
|
|
8019
8155
|
}
|
|
8020
8156
|
async getData(id) {
|
|
8021
8157
|
const tempId = id ?? __classPrivateFieldGet(this, _SubjectEntity_baseExpression, "f");
|
|
8022
|
-
|
|
8023
|
-
|
|
8024
|
-
|
|
8025
|
-
|
|
8026
|
-
let results = await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").infer(`subject_class("${__classPrivateFieldGet(this, _SubjectEntity_subjectClass, "f")}", C), property(C, Property)`);
|
|
8027
|
-
let properties = results.map(result => result.Property);
|
|
8028
|
-
for (let p of properties) {
|
|
8029
|
-
const resolveExpressionURI = await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").infer(`subject_class("${__classPrivateFieldGet(this, _SubjectEntity_subjectClass, "f")}", C), property_resolve(C, "${p}")`);
|
|
8030
|
-
const getProperty = async () => {
|
|
8031
|
-
let results = await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").infer(`subject_class("${__classPrivateFieldGet(this, _SubjectEntity_subjectClass, "f")}", C), property_getter(C, "${tempId}", "${p}", Value)`);
|
|
8032
|
-
if (results && results.length > 0) {
|
|
8033
|
-
let expressionURI = results[0].Value;
|
|
8034
|
-
if (resolveExpressionURI) {
|
|
8035
|
-
try {
|
|
8036
|
-
const expression = await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").getExpression(expressionURI);
|
|
8037
|
-
try {
|
|
8038
|
-
return JSON.parse(expression.data);
|
|
8039
|
-
}
|
|
8040
|
-
catch (e) {
|
|
8041
|
-
return expression.data;
|
|
8042
|
-
}
|
|
8043
|
-
}
|
|
8044
|
-
catch (err) {
|
|
8045
|
-
return expressionURI;
|
|
8046
|
-
}
|
|
8047
|
-
}
|
|
8048
|
-
else {
|
|
8049
|
-
return expressionURI;
|
|
8050
|
-
}
|
|
8051
|
-
}
|
|
8052
|
-
else if (results) {
|
|
8053
|
-
return results;
|
|
8054
|
-
}
|
|
8055
|
-
else {
|
|
8056
|
-
return undefined;
|
|
8057
|
-
}
|
|
8058
|
-
};
|
|
8059
|
-
this[p] = await getProperty();
|
|
8060
|
-
}
|
|
8061
|
-
let results2 = await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").infer(`subject_class("${__classPrivateFieldGet(this, _SubjectEntity_subjectClass, "f")}", C), collection(C, Collection)`);
|
|
8062
|
-
if (!results2)
|
|
8063
|
-
results2 = [];
|
|
8064
|
-
let collections = results2.map(result => result.Collection);
|
|
8065
|
-
for (let c of collections) {
|
|
8066
|
-
const getProperty = async () => {
|
|
8067
|
-
let results = await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").infer(`subject_class("${__classPrivateFieldGet(this, _SubjectEntity_subjectClass, "f")}", C), collection_getter(C, "${tempId}", "${c}", Value)`);
|
|
8068
|
-
if (results && results.length > 0 && results[0].Value) {
|
|
8069
|
-
return eval(results[0].Value);
|
|
8070
|
-
}
|
|
8071
|
-
else {
|
|
8072
|
-
return [];
|
|
8073
|
-
}
|
|
8074
|
-
};
|
|
8075
|
-
this[c] = await getProperty();
|
|
8076
|
-
}
|
|
8158
|
+
console.log("SubjectEntity: getData");
|
|
8159
|
+
let data = await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").getSubjectData(__classPrivateFieldGet(this, _SubjectEntity_subjectClass, "f"), tempId);
|
|
8160
|
+
console.log("SubjectEntity got data:", data);
|
|
8161
|
+
Object.assign(this, data);
|
|
8077
8162
|
__classPrivateFieldSet(this, _SubjectEntity_baseExpression, tempId, "f");
|
|
8078
8163
|
return this;
|
|
8079
8164
|
}
|