@coasys/ad4m 0.8.0 → 0.8.2-prerelease
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 +29 -53
- package/lib/index.js +8085 -0
- package/lib/shims/reflect-metadata.js +0 -0
- package/lib/shims/type-graphql.js +70 -0
- package/lib/src/Ad4mClient.js +66 -0
- package/lib/src/Address.js +1 -0
- package/lib/src/DID.js +1 -0
- package/lib/src/Exception.js +7 -0
- package/lib/src/Literal.js +76 -0
- package/lib/src/PubSub.js +14 -0
- package/lib/src/SmartLiteral.js +74 -0
- package/lib/src/agent/Agent.js +337 -0
- package/lib/src/agent/AgentClient.js +431 -0
- package/lib/src/agent/AgentResolver.js +325 -0
- package/lib/src/agent/AgentStatus.js +61 -0
- package/lib/src/buildSchema.js +36 -0
- package/lib/src/expression/Expression.js +143 -0
- package/lib/src/expression/ExpressionClient.js +102 -0
- package/lib/src/expression/ExpressionRef.js +67 -0
- package/lib/src/expression/ExpressionResolver.js +106 -0
- package/lib/src/index.js +30 -0
- package/lib/src/jestSetup.js +1 -0
- package/lib/src/language/Icon.js +24 -0
- package/lib/src/language/Language.js +79 -0
- package/lib/src/language/LanguageClient.js +137 -0
- package/lib/src/language/LanguageContext.js +2 -0
- package/lib/src/language/LanguageHandle.js +41 -0
- package/lib/src/language/LanguageMeta.js +89 -0
- package/lib/src/language/LanguageRef.js +30 -0
- package/lib/src/language/LanguageResolver.js +143 -0
- package/lib/src/links/Links.js +148 -0
- package/lib/src/links/Links.test.js +33 -0
- package/lib/src/neighbourhood/Neighbourhood.js +38 -0
- package/lib/src/neighbourhood/NeighbourhoodClient.js +256 -0
- package/lib/src/neighbourhood/NeighbourhoodProxy.js +54 -0
- package/lib/src/neighbourhood/NeighbourhoodResolver.js +180 -0
- package/lib/src/perspectives/LinkQuery.js +80 -0
- package/lib/src/perspectives/Perspective.js +144 -0
- package/lib/src/perspectives/Perspective.test.js +20 -0
- package/lib/src/perspectives/PerspectiveClient.d.ts +1 -0
- package/lib/src/perspectives/PerspectiveClient.js +418 -0
- package/lib/src/perspectives/PerspectiveDiff.js +33 -0
- package/lib/src/perspectives/PerspectiveHandle.js +59 -0
- package/lib/src/perspectives/PerspectiveProxy.d.ts +8 -8
- package/lib/src/perspectives/PerspectiveProxy.js +501 -0
- package/lib/src/perspectives/PerspectiveResolver.d.ts +1 -0
- package/lib/src/perspectives/PerspectiveResolver.js +376 -0
- package/lib/src/runtime/RuntimeClient.js +263 -0
- package/lib/src/runtime/RuntimeResolver.js +328 -0
- package/lib/src/schema.gql +1 -0
- package/lib/src/subject/SDNADecorators.js +250 -0
- package/lib/src/subject/Subject.js +164 -0
- package/lib/src/subject/SubjectEntity.js +250 -0
- package/lib/src/subject/util.js +73 -0
- package/lib/src/typeDefs.js +380 -0
- package/lib/src/unwrapApolloResult.js +14 -0
- package/lib/src/utils.js +21 -0
- package/package.json +9 -2
- package/patches/graphql@15.7.2.patch +39 -0
- package/pnpm-workspace.yaml +19 -0
- package/src/Ad4mClient.test.ts +5 -0
- package/src/perspectives/PerspectiveClient.ts +9 -0
- package/src/perspectives/PerspectiveProxy.ts +22 -56
- package/src/perspectives/PerspectiveResolver.ts +5 -0
- package/src/subject/Subject.ts +9 -6
- package/src/unwrapApolloResult.ts +3 -1
package/lib/index.cjs
CHANGED
|
@@ -3223,7 +3223,9 @@ var extras = {
|
|
|
3223
3223
|
gql["default"] = gql;
|
|
3224
3224
|
|
|
3225
3225
|
function unwrapApolloResult(result) {
|
|
3226
|
-
|
|
3226
|
+
if (!result) {
|
|
3227
|
+
throw "Got no result from Apollo";
|
|
3228
|
+
}
|
|
3227
3229
|
//@ts-ignore
|
|
3228
3230
|
if (result.error) {
|
|
3229
3231
|
//@ts-ignore
|
|
@@ -4436,7 +4438,6 @@ class Subject {
|
|
|
4436
4438
|
}
|
|
4437
4439
|
let results = await __classPrivateFieldGet$a(this, _Subject_perspective, "f").infer(`subject_class("${__classPrivateFieldGet$a(this, _Subject_subjectClass, "f")}", C), property(C, Property)`);
|
|
4438
4440
|
let properties = results.map(result => result.Property);
|
|
4439
|
-
//console.log("Subject properties: " + properties)
|
|
4440
4441
|
for (let p of properties) {
|
|
4441
4442
|
const resolveExpressionURI = await __classPrivateFieldGet$a(this, _Subject_perspective, "f").infer(`subject_class("${__classPrivateFieldGet$a(this, _Subject_subjectClass, "f")}", C), property_resolve(C, "${p}")`);
|
|
4442
4443
|
Object.defineProperty(this, p, {
|
|
@@ -4447,12 +4448,17 @@ class Subject {
|
|
|
4447
4448
|
let expressionURI = results[0].Value;
|
|
4448
4449
|
if (resolveExpressionURI) {
|
|
4449
4450
|
try {
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4451
|
+
if (expressionURI) {
|
|
4452
|
+
const expression = await __classPrivateFieldGet$a(this, _Subject_perspective, "f").getExpression(expressionURI);
|
|
4453
|
+
try {
|
|
4454
|
+
return JSON.parse(expression.data);
|
|
4455
|
+
}
|
|
4456
|
+
catch (e) {
|
|
4457
|
+
return expression.data;
|
|
4458
|
+
}
|
|
4453
4459
|
}
|
|
4454
|
-
|
|
4455
|
-
return
|
|
4460
|
+
else {
|
|
4461
|
+
return expressionURI;
|
|
4456
4462
|
}
|
|
4457
4463
|
}
|
|
4458
4464
|
catch (err) {
|
|
@@ -4597,6 +4603,11 @@ class PerspectiveProxy {
|
|
|
4597
4603
|
__classPrivateFieldSet$9(this, _PerspectiveProxy_perspectiveSyncStateChangeCallbacks, [], "f");
|
|
4598
4604
|
__classPrivateFieldSet$9(this, _PerspectiveProxy_handle, handle, "f");
|
|
4599
4605
|
__classPrivateFieldSet$9(this, _PerspectiveProxy_client, ad4m, "f");
|
|
4606
|
+
this.uuid = __classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid;
|
|
4607
|
+
this.name = __classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").name;
|
|
4608
|
+
this.sharedUrl = __classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").sharedUrl;
|
|
4609
|
+
this.neighbourhood = __classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").neighbourhood;
|
|
4610
|
+
this.state = __classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").state;
|
|
4600
4611
|
__classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").addPerspectiveLinkAddedListener(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, __classPrivateFieldGet$9(this, _PerspectiveProxy_perspectiveLinkAddedCallbacks, "f"));
|
|
4601
4612
|
__classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").addPerspectiveLinkRemovedListener(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, __classPrivateFieldGet$9(this, _PerspectiveProxy_perspectiveLinkRemovedCallbacks, "f"));
|
|
4602
4613
|
__classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").addPerspectiveLinkUpdatedListener(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, __classPrivateFieldGet$9(this, _PerspectiveProxy_perspectiveLinkUpdatedCallbacks, "f"));
|
|
@@ -4653,26 +4664,6 @@ class PerspectiveProxy {
|
|
|
4653
4664
|
}
|
|
4654
4665
|
}
|
|
4655
4666
|
}
|
|
4656
|
-
/** Unique ID of the perspective */
|
|
4657
|
-
get uuid() {
|
|
4658
|
-
return __classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid;
|
|
4659
|
-
}
|
|
4660
|
-
/** Given name of the perspective */
|
|
4661
|
-
get name() {
|
|
4662
|
-
return __classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").name;
|
|
4663
|
-
}
|
|
4664
|
-
/** If the perspective is shared as a Neighbourhood, this is the Neighbourhood URL */
|
|
4665
|
-
get sharedUrl() {
|
|
4666
|
-
return __classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").sharedUrl;
|
|
4667
|
-
}
|
|
4668
|
-
/** If the perspective is shared as a Neighbourhood, this is the Neighbourhood Expression */
|
|
4669
|
-
get neighbourhood() {
|
|
4670
|
-
return __classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").neighbourhood;
|
|
4671
|
-
}
|
|
4672
|
-
/** Returns the state of the perspective **/
|
|
4673
|
-
get state() {
|
|
4674
|
-
return __classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").state;
|
|
4675
|
-
}
|
|
4676
4667
|
/** Returns all the links of this perspective that matches the LinkQuery */
|
|
4677
4668
|
async get(query) {
|
|
4678
4669
|
return await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").queryLinks(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, query);
|
|
@@ -4854,32 +4845,8 @@ class PerspectiveProxy {
|
|
|
4854
4845
|
return links.map(link => link.data.target).map(t => Literal.fromUrl(t).get());
|
|
4855
4846
|
}
|
|
4856
4847
|
/** Adds the given Social DNA code to the perspective's SDNA code */
|
|
4857
|
-
async addSdna(name, sdnaCode,
|
|
4858
|
-
|
|
4859
|
-
if (type === 'subject_class')
|
|
4860
|
-
predicate = "ad4m://has_subject_class";
|
|
4861
|
-
else if (type === 'flow')
|
|
4862
|
-
predicate = "ad4m://has_flow";
|
|
4863
|
-
const literalName = Literal.from(name).toUrl();
|
|
4864
|
-
const links = await this.get(new exports.LinkQuery({
|
|
4865
|
-
source: "ad4m://self",
|
|
4866
|
-
predicate,
|
|
4867
|
-
target: literalName
|
|
4868
|
-
}));
|
|
4869
|
-
const sdnaLinks = [];
|
|
4870
|
-
if (links.length === 0) {
|
|
4871
|
-
sdnaLinks.push(new exports.Link({
|
|
4872
|
-
source: "ad4m://self",
|
|
4873
|
-
predicate,
|
|
4874
|
-
target: literalName
|
|
4875
|
-
}));
|
|
4876
|
-
}
|
|
4877
|
-
sdnaLinks.push(new exports.Link({
|
|
4878
|
-
source: literalName,
|
|
4879
|
-
predicate: "ad4m://sdna",
|
|
4880
|
-
target: Literal.from(sdnaCode).toUrl()
|
|
4881
|
-
}));
|
|
4882
|
-
await this.addLinks(sdnaLinks);
|
|
4848
|
+
async addSdna(name, sdnaCode, sdnaType) {
|
|
4849
|
+
return __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").addSdna(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, name, sdnaCode, sdnaType);
|
|
4883
4850
|
}
|
|
4884
4851
|
/** Returns all the Subject classes defined in this perspectives SDNA */
|
|
4885
4852
|
async subjectClasses() {
|
|
@@ -5357,6 +5324,14 @@ class PerspectiveClient {
|
|
|
5357
5324
|
variables: { uuid, link }
|
|
5358
5325
|
}));
|
|
5359
5326
|
}
|
|
5327
|
+
async addSdna(uuid, name, sdnaCode, sdnaType) {
|
|
5328
|
+
return unwrapApolloResult(await __classPrivateFieldGet$8(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
5329
|
+
mutation: gql `mutation perspectiveAddSdna($uuid: String!, $name: String!, $sdnaCode: String!, $sdnaType: String!) {
|
|
5330
|
+
perspectiveAddSdna(uuid: $uuid, name: $name, sdnaCode: $sdnaCode, sdnaType: $sdnaType)
|
|
5331
|
+
}`,
|
|
5332
|
+
variables: { uuid, name, sdnaCode, sdnaType }
|
|
5333
|
+
})).perspectiveAddSdna;
|
|
5334
|
+
}
|
|
5360
5335
|
// ExpressionClient functions, needed for Subjects:
|
|
5361
5336
|
async getExpression(expressionURI) {
|
|
5362
5337
|
return await __classPrivateFieldGet$8(this, _PerspectiveClient_expressionClient, "f").get(expressionURI);
|
|
@@ -7708,6 +7683,7 @@ type Mutation {
|
|
|
7708
7683
|
perspectiveAddLink(link: LinkInput!, status: String = "shared", uuid: String!): LinkExpression!
|
|
7709
7684
|
perspectiveAddLinkExpression(link: LinkExpressionInput!, status: String, uuid: String!): LinkExpression!
|
|
7710
7685
|
perspectiveAddLinks(links: [LinkInput!]!, status: String, uuid: String!): [LinkExpression!]!
|
|
7686
|
+
perspectiveAddSdna(name: String!, sdnaCode: String!, sdnaType: String!, uuid: String!): Boolean!
|
|
7711
7687
|
perspectiveLinkMutations(mutations: LinkMutations!, status: String, uuid: String!): LinkExpressionMutations!
|
|
7712
7688
|
perspectivePublishSnapshot(uuid: String!): String
|
|
7713
7689
|
perspectiveRemove(uuid: String!): Boolean!
|