@coasys/ad4m 0.8.0-fix → 0.8.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/README.md +229 -229
- package/jest.config.js +5 -5
- package/jsdoc.json +27 -27
- package/lib/index.cjs +4522 -4571
- package/lib/index.js +4522 -4571
- package/lib/shims/type-graphql.d.ts +32 -32
- package/lib/shims/type-graphql.js +70 -70
- package/lib/src/Ad4mClient.d.ts +26 -26
- package/lib/src/Ad4mClient.js +66 -66
- package/lib/src/Address.d.ts +1 -1
- package/lib/src/Address.js +1 -1
- package/lib/src/DID.d.ts +1 -1
- package/lib/src/DID.js +1 -1
- package/lib/src/Exception.d.ts +6 -6
- package/lib/src/Exception.js +7 -7
- package/lib/src/Literal.d.ts +7 -7
- package/lib/src/Literal.js +76 -76
- package/lib/src/PubSub.d.ts +14 -14
- package/lib/src/PubSub.js +14 -14
- package/lib/src/SmartLiteral.d.ts +12 -12
- package/lib/src/SmartLiteral.js +74 -74
- package/lib/src/agent/Agent.d.ts +104 -104
- package/lib/src/agent/Agent.js +337 -337
- package/lib/src/agent/AgentClient.d.ts +57 -57
- package/lib/src/agent/AgentClient.js +431 -431
- package/lib/src/agent/AgentResolver.d.ts +30 -30
- package/lib/src/agent/AgentResolver.js +325 -325
- package/lib/src/agent/AgentStatus.d.ts +8 -8
- package/lib/src/agent/AgentStatus.js +61 -61
- package/lib/src/buildSchema.d.ts +1 -1
- package/lib/src/buildSchema.js +36 -36
- package/lib/src/expression/Expression.d.ts +28 -28
- package/lib/src/expression/Expression.js +143 -143
- package/lib/src/expression/ExpressionClient.d.ts +13 -13
- package/lib/src/expression/ExpressionClient.js +102 -102
- package/lib/src/expression/ExpressionRef.d.ts +9 -9
- package/lib/src/expression/ExpressionRef.js +67 -67
- package/lib/src/expression/ExpressionResolver.d.ts +10 -10
- package/lib/src/expression/ExpressionResolver.js +106 -106
- package/lib/src/index.d.ts +30 -30
- package/lib/src/index.js +30 -30
- package/lib/src/jestSetup.d.ts +1 -1
- package/lib/src/jestSetup.js +1 -1
- package/lib/src/language/Icon.d.ts +4 -4
- package/lib/src/language/Icon.js +24 -24
- package/lib/src/language/Language.d.ts +195 -195
- package/lib/src/language/Language.js +79 -79
- package/lib/src/language/LanguageClient.d.ts +17 -17
- package/lib/src/language/LanguageClient.js +137 -137
- package/lib/src/language/LanguageContext.d.ts +37 -37
- package/lib/src/language/LanguageContext.js +2 -2
- package/lib/src/language/LanguageHandle.d.ts +9 -9
- package/lib/src/language/LanguageHandle.js +41 -41
- package/lib/src/language/LanguageMeta.d.ts +35 -35
- package/lib/src/language/LanguageMeta.js +89 -89
- package/lib/src/language/LanguageRef.d.ts +6 -6
- package/lib/src/language/LanguageRef.js +30 -30
- package/lib/src/language/LanguageResolver.d.ts +19 -19
- package/lib/src/language/LanguageResolver.js +143 -143
- package/lib/src/links/Links.d.ts +39 -39
- package/lib/src/links/Links.js +148 -148
- package/lib/src/links/Links.test.d.ts +1 -1
- package/lib/src/links/Links.test.js +33 -33
- package/lib/src/neighbourhood/Neighbourhood.d.ts +10 -10
- package/lib/src/neighbourhood/Neighbourhood.js +38 -38
- package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +25 -25
- package/lib/src/neighbourhood/NeighbourhoodClient.js +256 -256
- package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +19 -19
- package/lib/src/neighbourhood/NeighbourhoodProxy.js +54 -54
- package/lib/src/neighbourhood/NeighbourhoodResolver.d.ts +24 -24
- package/lib/src/neighbourhood/NeighbourhoodResolver.js +180 -180
- package/lib/src/perspectives/LinkQuery.d.ts +11 -11
- package/lib/src/perspectives/LinkQuery.js +80 -80
- package/lib/src/perspectives/Perspective.d.ts +38 -38
- package/lib/src/perspectives/Perspective.js +144 -144
- package/lib/src/perspectives/Perspective.test.d.ts +1 -1
- package/lib/src/perspectives/Perspective.test.js +20 -20
- package/lib/src/perspectives/PerspectiveClient.d.ts +55 -54
- package/lib/src/perspectives/PerspectiveClient.js +418 -410
- package/lib/src/perspectives/PerspectiveDiff.d.ts +9 -9
- package/lib/src/perspectives/PerspectiveDiff.js +33 -33
- package/lib/src/perspectives/PerspectiveHandle.d.ts +16 -16
- package/lib/src/perspectives/PerspectiveHandle.js +59 -59
- package/lib/src/perspectives/PerspectiveProxy.d.ts +178 -178
- package/lib/src/perspectives/PerspectiveProxy.js +501 -540
- package/lib/src/perspectives/PerspectiveResolver.d.ts +38 -37
- package/lib/src/perspectives/PerspectiveResolver.js +376 -362
- package/lib/src/runtime/RuntimeClient.d.ts +33 -33
- package/lib/src/runtime/RuntimeClient.js +263 -263
- package/lib/src/runtime/RuntimeResolver.d.ts +47 -47
- package/lib/src/runtime/RuntimeResolver.js +328 -328
- package/lib/src/schema.gql +1 -0
- package/lib/src/subject/SDNADecorators.d.ts +45 -45
- package/lib/src/subject/SDNADecorators.js +250 -250
- package/lib/src/subject/Subject.d.ts +7 -7
- package/lib/src/subject/Subject.js +160 -160
- package/lib/src/subject/SubjectEntity.d.ts +31 -31
- package/lib/src/subject/SubjectEntity.js +250 -250
- package/lib/src/subject/util.d.ts +12 -12
- package/lib/src/subject/util.js +73 -73
- package/lib/src/typeDefs.d.ts +1 -1
- package/lib/src/typeDefs.js +1 -0
- package/lib/src/unwrapApolloResult.d.ts +2 -2
- package/lib/src/unwrapApolloResult.js +14 -12
- package/lib/src/utils.d.ts +2 -2
- package/lib/src/utils.js +21 -21
- package/package.json +61 -61
- package/rollup.config.js +26 -26
- package/shims/type-graphql.ts +75 -75
- package/src/Ad4mClient.test.ts +1089 -1084
- package/src/Ad4mClient.ts +62 -62
- package/src/Address.ts +1 -1
- package/src/Exception.ts +6 -6
- package/src/Literal.test.ts +30 -30
- package/src/Literal.ts +80 -80
- package/src/PubSub.ts +13 -13
- package/src/SmartLiteral.ts +74 -74
- package/src/agent/Agent.ts +293 -293
- package/src/agent/AgentClient.ts +531 -531
- package/src/agent/AgentResolver.ts +263 -263
- package/src/agent/AgentStatus.ts +43 -43
- package/src/buildSchema.ts +41 -41
- package/src/expression/Expression.ts +99 -99
- package/src/expression/ExpressionClient.ts +98 -98
- package/src/expression/ExpressionRef.ts +62 -62
- package/src/expression/ExpressionResolver.ts +63 -63
- package/src/index.ts +30 -30
- package/src/language/Icon.ts +10 -10
- package/src/language/Language.ts +266 -266
- package/src/language/LanguageClient.ts +159 -159
- package/src/language/LanguageContext.ts +37 -37
- package/src/language/LanguageHandle.ts +23 -23
- package/src/language/LanguageMeta.ts +69 -69
- package/src/language/LanguageRef.ts +18 -18
- package/src/language/LanguageResolver.ts +98 -98
- package/src/links/Links.test.ts +39 -39
- package/src/links/Links.ts +107 -107
- package/src/neighbourhood/Neighbourhood.ts +22 -22
- package/src/neighbourhood/NeighbourhoodClient.ts +275 -275
- package/src/neighbourhood/NeighbourhoodProxy.ts +58 -58
- package/src/neighbourhood/NeighbourhoodResolver.ts +99 -99
- package/src/perspectives/LinkQuery.ts +65 -65
- package/src/perspectives/Perspective.test.ts +22 -22
- package/src/perspectives/Perspective.ts +118 -118
- package/src/perspectives/PerspectiveClient.ts +452 -443
- package/src/perspectives/PerspectiveDiff.ts +15 -15
- package/src/perspectives/PerspectiveHandle.ts +39 -39
- package/src/perspectives/PerspectiveProxy.ts +576 -610
- package/src/perspectives/PerspectiveResolver.ts +224 -219
- package/src/runtime/RuntimeClient.ts +282 -282
- package/src/runtime/RuntimeResolver.ts +192 -192
- package/src/subject/SDNADecorators.ts +333 -333
- package/src/subject/Subject.ts +152 -152
- package/src/subject/SubjectEntity.ts +291 -291
- package/src/subject/util.ts +84 -84
- package/src/typeDefs.ts +5 -5
- package/src/unwrapApolloResult.ts +15 -13
- package/src/utils.ts +25 -25
- package/tsconfig-browser.json +82 -82
- package/tsconfig.json +80 -80
- package/yarn-error.log +0 -22814
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
-
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");
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
|
-
var _ExpressionClient_apolloClient;
|
|
13
|
-
import { gql } from "@apollo/client/core";
|
|
14
|
-
import unwrapApolloResult from "../unwrapApolloResult";
|
|
15
|
-
export class ExpressionClient {
|
|
16
|
-
constructor(client) {
|
|
17
|
-
_ExpressionClient_apolloClient.set(this, void 0);
|
|
18
|
-
__classPrivateFieldSet(this, _ExpressionClient_apolloClient, client, "f");
|
|
19
|
-
}
|
|
20
|
-
async get(url) {
|
|
21
|
-
const { expression } = unwrapApolloResult(await __classPrivateFieldGet(this, _ExpressionClient_apolloClient, "f").query({
|
|
22
|
-
query: gql `query expression($url: String!) {
|
|
23
|
-
expression(url: $url) {
|
|
24
|
-
author
|
|
25
|
-
timestamp
|
|
26
|
-
data
|
|
27
|
-
language {
|
|
28
|
-
address
|
|
29
|
-
}
|
|
30
|
-
proof {
|
|
31
|
-
valid
|
|
32
|
-
invalid
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}`,
|
|
36
|
-
variables: { url }
|
|
37
|
-
}));
|
|
38
|
-
return expression;
|
|
39
|
-
}
|
|
40
|
-
async getMany(urls) {
|
|
41
|
-
const { expressionMany } = unwrapApolloResult(await __classPrivateFieldGet(this, _ExpressionClient_apolloClient, "f").query({
|
|
42
|
-
query: gql `query expressionMany($urls: [String!]!) {
|
|
43
|
-
expressionMany(urls: $urls) {
|
|
44
|
-
author
|
|
45
|
-
timestamp
|
|
46
|
-
data
|
|
47
|
-
language {
|
|
48
|
-
address
|
|
49
|
-
}
|
|
50
|
-
proof {
|
|
51
|
-
valid
|
|
52
|
-
invalid
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}`,
|
|
56
|
-
variables: { urls }
|
|
57
|
-
}));
|
|
58
|
-
return expressionMany;
|
|
59
|
-
}
|
|
60
|
-
async getRaw(url) {
|
|
61
|
-
const { expressionRaw } = unwrapApolloResult(await __classPrivateFieldGet(this, _ExpressionClient_apolloClient, "f").query({
|
|
62
|
-
query: gql `query expressionRaw($url: String!) {
|
|
63
|
-
expressionRaw(url: $url)
|
|
64
|
-
}`,
|
|
65
|
-
variables: { url }
|
|
66
|
-
}));
|
|
67
|
-
return expressionRaw;
|
|
68
|
-
}
|
|
69
|
-
async create(content, languageAddress) {
|
|
70
|
-
content = JSON.stringify(content);
|
|
71
|
-
const { expressionCreate } = unwrapApolloResult(await __classPrivateFieldGet(this, _ExpressionClient_apolloClient, "f").mutate({
|
|
72
|
-
mutation: gql `mutation expressionCreate($content: String!, $languageAddress: String!){
|
|
73
|
-
expressionCreate(content: $content, languageAddress: $languageAddress)
|
|
74
|
-
}`,
|
|
75
|
-
variables: { content, languageAddress }
|
|
76
|
-
}));
|
|
77
|
-
return expressionCreate;
|
|
78
|
-
}
|
|
79
|
-
async interactions(url) {
|
|
80
|
-
const { expressionInteractions } = unwrapApolloResult(await __classPrivateFieldGet(this, _ExpressionClient_apolloClient, "f").query({
|
|
81
|
-
query: gql `query expressionInteractions($url: String!) {
|
|
82
|
-
expressionInteractions(url: $url) {
|
|
83
|
-
label
|
|
84
|
-
name
|
|
85
|
-
parameters { name, type }
|
|
86
|
-
}
|
|
87
|
-
}`,
|
|
88
|
-
variables: { url }
|
|
89
|
-
}));
|
|
90
|
-
return expressionInteractions;
|
|
91
|
-
}
|
|
92
|
-
async interact(url, interactionCall) {
|
|
93
|
-
const { expressionInteract } = unwrapApolloResult(await __classPrivateFieldGet(this, _ExpressionClient_apolloClient, "f").mutate({
|
|
94
|
-
mutation: gql `mutation expressionInteract($url: String!, $interactionCall: InteractionCall!){
|
|
95
|
-
expressionInteract(url: $url, interactionCall: $interactionCall)
|
|
96
|
-
}`,
|
|
97
|
-
variables: { url, interactionCall }
|
|
98
|
-
}));
|
|
99
|
-
return expressionInteract;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
_ExpressionClient_apolloClient = new WeakMap();
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
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");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _ExpressionClient_apolloClient;
|
|
13
|
+
import { gql } from "@apollo/client/core";
|
|
14
|
+
import unwrapApolloResult from "../unwrapApolloResult";
|
|
15
|
+
export class ExpressionClient {
|
|
16
|
+
constructor(client) {
|
|
17
|
+
_ExpressionClient_apolloClient.set(this, void 0);
|
|
18
|
+
__classPrivateFieldSet(this, _ExpressionClient_apolloClient, client, "f");
|
|
19
|
+
}
|
|
20
|
+
async get(url) {
|
|
21
|
+
const { expression } = unwrapApolloResult(await __classPrivateFieldGet(this, _ExpressionClient_apolloClient, "f").query({
|
|
22
|
+
query: gql `query expression($url: String!) {
|
|
23
|
+
expression(url: $url) {
|
|
24
|
+
author
|
|
25
|
+
timestamp
|
|
26
|
+
data
|
|
27
|
+
language {
|
|
28
|
+
address
|
|
29
|
+
}
|
|
30
|
+
proof {
|
|
31
|
+
valid
|
|
32
|
+
invalid
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}`,
|
|
36
|
+
variables: { url }
|
|
37
|
+
}));
|
|
38
|
+
return expression;
|
|
39
|
+
}
|
|
40
|
+
async getMany(urls) {
|
|
41
|
+
const { expressionMany } = unwrapApolloResult(await __classPrivateFieldGet(this, _ExpressionClient_apolloClient, "f").query({
|
|
42
|
+
query: gql `query expressionMany($urls: [String!]!) {
|
|
43
|
+
expressionMany(urls: $urls) {
|
|
44
|
+
author
|
|
45
|
+
timestamp
|
|
46
|
+
data
|
|
47
|
+
language {
|
|
48
|
+
address
|
|
49
|
+
}
|
|
50
|
+
proof {
|
|
51
|
+
valid
|
|
52
|
+
invalid
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}`,
|
|
56
|
+
variables: { urls }
|
|
57
|
+
}));
|
|
58
|
+
return expressionMany;
|
|
59
|
+
}
|
|
60
|
+
async getRaw(url) {
|
|
61
|
+
const { expressionRaw } = unwrapApolloResult(await __classPrivateFieldGet(this, _ExpressionClient_apolloClient, "f").query({
|
|
62
|
+
query: gql `query expressionRaw($url: String!) {
|
|
63
|
+
expressionRaw(url: $url)
|
|
64
|
+
}`,
|
|
65
|
+
variables: { url }
|
|
66
|
+
}));
|
|
67
|
+
return expressionRaw;
|
|
68
|
+
}
|
|
69
|
+
async create(content, languageAddress) {
|
|
70
|
+
content = JSON.stringify(content);
|
|
71
|
+
const { expressionCreate } = unwrapApolloResult(await __classPrivateFieldGet(this, _ExpressionClient_apolloClient, "f").mutate({
|
|
72
|
+
mutation: gql `mutation expressionCreate($content: String!, $languageAddress: String!){
|
|
73
|
+
expressionCreate(content: $content, languageAddress: $languageAddress)
|
|
74
|
+
}`,
|
|
75
|
+
variables: { content, languageAddress }
|
|
76
|
+
}));
|
|
77
|
+
return expressionCreate;
|
|
78
|
+
}
|
|
79
|
+
async interactions(url) {
|
|
80
|
+
const { expressionInteractions } = unwrapApolloResult(await __classPrivateFieldGet(this, _ExpressionClient_apolloClient, "f").query({
|
|
81
|
+
query: gql `query expressionInteractions($url: String!) {
|
|
82
|
+
expressionInteractions(url: $url) {
|
|
83
|
+
label
|
|
84
|
+
name
|
|
85
|
+
parameters { name, type }
|
|
86
|
+
}
|
|
87
|
+
}`,
|
|
88
|
+
variables: { url }
|
|
89
|
+
}));
|
|
90
|
+
return expressionInteractions;
|
|
91
|
+
}
|
|
92
|
+
async interact(url, interactionCall) {
|
|
93
|
+
const { expressionInteract } = unwrapApolloResult(await __classPrivateFieldGet(this, _ExpressionClient_apolloClient, "f").mutate({
|
|
94
|
+
mutation: gql `mutation expressionInteract($url: String!, $interactionCall: InteractionCall!){
|
|
95
|
+
expressionInteract(url: $url, interactionCall: $interactionCall)
|
|
96
|
+
}`,
|
|
97
|
+
variables: { url, interactionCall }
|
|
98
|
+
}));
|
|
99
|
+
return expressionInteract;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
_ExpressionClient_apolloClient = new WeakMap();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Address } from '../Address';
|
|
2
|
-
import { LanguageRef } from '../language/LanguageRef';
|
|
3
|
-
export declare class ExpressionRef {
|
|
4
|
-
language: LanguageRef;
|
|
5
|
-
expression: Address;
|
|
6
|
-
constructor(lang: LanguageRef, expr: Address);
|
|
7
|
-
}
|
|
8
|
-
export declare function exprRef2String(ref: ExpressionRef): string;
|
|
9
|
-
export declare function parseExprUrl(url: string): ExpressionRef;
|
|
1
|
+
import type { Address } from '../Address';
|
|
2
|
+
import { LanguageRef } from '../language/LanguageRef';
|
|
3
|
+
export declare class ExpressionRef {
|
|
4
|
+
language: LanguageRef;
|
|
5
|
+
expression: Address;
|
|
6
|
+
constructor(lang: LanguageRef, expr: Address);
|
|
7
|
+
}
|
|
8
|
+
export declare function exprRef2String(ref: ExpressionRef): string;
|
|
9
|
+
export declare function parseExprUrl(url: string): ExpressionRef;
|
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
import { LanguageRef } from '../language/LanguageRef';
|
|
11
|
-
import { Field, ObjectType } from "type-graphql";
|
|
12
|
-
// Expression address + unique Language ID = global expression URL
|
|
13
|
-
let ExpressionRef = class ExpressionRef {
|
|
14
|
-
constructor(lang, expr) {
|
|
15
|
-
this.language = lang;
|
|
16
|
-
this.expression = expr;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
__decorate([
|
|
20
|
-
Field(),
|
|
21
|
-
__metadata("design:type", LanguageRef)
|
|
22
|
-
], ExpressionRef.prototype, "language", void 0);
|
|
23
|
-
__decorate([
|
|
24
|
-
Field(),
|
|
25
|
-
__metadata("design:type", String)
|
|
26
|
-
], ExpressionRef.prototype, "expression", void 0);
|
|
27
|
-
ExpressionRef = __decorate([
|
|
28
|
-
ObjectType(),
|
|
29
|
-
__metadata("design:paramtypes", [LanguageRef, String])
|
|
30
|
-
], ExpressionRef);
|
|
31
|
-
export { ExpressionRef };
|
|
32
|
-
// Creates unique expression URI like this:
|
|
33
|
-
// expr:Qm3490gfwe489hf34:Qm90ghjoaw4iehioefwe4ort
|
|
34
|
-
export function exprRef2String(ref) {
|
|
35
|
-
if (ref.language.address === 'did')
|
|
36
|
-
return ref.expression.toString();
|
|
37
|
-
else
|
|
38
|
-
return `${ref.language.address}://${ref.expression}`;
|
|
39
|
-
}
|
|
40
|
-
export function parseExprUrl(url) {
|
|
41
|
-
if (url.startsWith("literal://")) {
|
|
42
|
-
const languageRef = new LanguageRef();
|
|
43
|
-
languageRef.address = 'literal';
|
|
44
|
-
languageRef.name = 'literal';
|
|
45
|
-
const content = url.substring(10);
|
|
46
|
-
return new ExpressionRef(languageRef, content);
|
|
47
|
-
}
|
|
48
|
-
const URIregexp = /^([^:^\s]+):\/\/([\s\S]+)$/;
|
|
49
|
-
const URImatches = URIregexp.exec(url);
|
|
50
|
-
if (URImatches && URImatches.length == 3) {
|
|
51
|
-
const language = URImatches[1];
|
|
52
|
-
const expression = URImatches[2];
|
|
53
|
-
const languageRef = new LanguageRef();
|
|
54
|
-
languageRef.address = language;
|
|
55
|
-
const ref = new ExpressionRef(languageRef, expression);
|
|
56
|
-
return ref;
|
|
57
|
-
}
|
|
58
|
-
const DIDregexp = /^did:([^\s]+)$/;
|
|
59
|
-
const DIDmatches = DIDregexp.exec(url);
|
|
60
|
-
if (DIDmatches && DIDmatches.length == 2) {
|
|
61
|
-
const languageRef = new LanguageRef();
|
|
62
|
-
languageRef.address = 'did';
|
|
63
|
-
const ref = new ExpressionRef(languageRef, url);
|
|
64
|
-
return ref;
|
|
65
|
-
}
|
|
66
|
-
throw new Error("Couldn't parse string as expression URL or DID: " + url);
|
|
67
|
-
}
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { LanguageRef } from '../language/LanguageRef';
|
|
11
|
+
import { Field, ObjectType } from "type-graphql";
|
|
12
|
+
// Expression address + unique Language ID = global expression URL
|
|
13
|
+
let ExpressionRef = class ExpressionRef {
|
|
14
|
+
constructor(lang, expr) {
|
|
15
|
+
this.language = lang;
|
|
16
|
+
this.expression = expr;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
__decorate([
|
|
20
|
+
Field(),
|
|
21
|
+
__metadata("design:type", LanguageRef)
|
|
22
|
+
], ExpressionRef.prototype, "language", void 0);
|
|
23
|
+
__decorate([
|
|
24
|
+
Field(),
|
|
25
|
+
__metadata("design:type", String)
|
|
26
|
+
], ExpressionRef.prototype, "expression", void 0);
|
|
27
|
+
ExpressionRef = __decorate([
|
|
28
|
+
ObjectType(),
|
|
29
|
+
__metadata("design:paramtypes", [LanguageRef, String])
|
|
30
|
+
], ExpressionRef);
|
|
31
|
+
export { ExpressionRef };
|
|
32
|
+
// Creates unique expression URI like this:
|
|
33
|
+
// expr:Qm3490gfwe489hf34:Qm90ghjoaw4iehioefwe4ort
|
|
34
|
+
export function exprRef2String(ref) {
|
|
35
|
+
if (ref.language.address === 'did')
|
|
36
|
+
return ref.expression.toString();
|
|
37
|
+
else
|
|
38
|
+
return `${ref.language.address}://${ref.expression}`;
|
|
39
|
+
}
|
|
40
|
+
export function parseExprUrl(url) {
|
|
41
|
+
if (url.startsWith("literal://")) {
|
|
42
|
+
const languageRef = new LanguageRef();
|
|
43
|
+
languageRef.address = 'literal';
|
|
44
|
+
languageRef.name = 'literal';
|
|
45
|
+
const content = url.substring(10);
|
|
46
|
+
return new ExpressionRef(languageRef, content);
|
|
47
|
+
}
|
|
48
|
+
const URIregexp = /^([^:^\s]+):\/\/([\s\S]+)$/;
|
|
49
|
+
const URImatches = URIregexp.exec(url);
|
|
50
|
+
if (URImatches && URImatches.length == 3) {
|
|
51
|
+
const language = URImatches[1];
|
|
52
|
+
const expression = URImatches[2];
|
|
53
|
+
const languageRef = new LanguageRef();
|
|
54
|
+
languageRef.address = language;
|
|
55
|
+
const ref = new ExpressionRef(languageRef, expression);
|
|
56
|
+
return ref;
|
|
57
|
+
}
|
|
58
|
+
const DIDregexp = /^did:([^\s]+)$/;
|
|
59
|
+
const DIDmatches = DIDregexp.exec(url);
|
|
60
|
+
if (DIDmatches && DIDmatches.length == 2) {
|
|
61
|
+
const languageRef = new LanguageRef();
|
|
62
|
+
languageRef.address = 'did';
|
|
63
|
+
const ref = new ExpressionRef(languageRef, url);
|
|
64
|
+
return ref;
|
|
65
|
+
}
|
|
66
|
+
throw new Error("Couldn't parse string as expression URL or DID: " + url);
|
|
67
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ExpressionRendered } from "./Expression";
|
|
2
|
-
import { InteractionCall, InteractionMeta } from "../language/Language";
|
|
3
|
-
export default class ExpressionResolver {
|
|
4
|
-
expression(url: string): ExpressionRendered;
|
|
5
|
-
expressionMany(urls: string[]): (ExpressionRendered | null)[];
|
|
6
|
-
expressionRaw(url: string): string;
|
|
7
|
-
expressionCreate(content: string, languageAddress: string): string;
|
|
8
|
-
expressionInteractions(url: string): InteractionMeta[];
|
|
9
|
-
expressionInteract(url: string, interactionCall: InteractionCall): string | null;
|
|
10
|
-
}
|
|
1
|
+
import { ExpressionRendered } from "./Expression";
|
|
2
|
+
import { InteractionCall, InteractionMeta } from "../language/Language";
|
|
3
|
+
export default class ExpressionResolver {
|
|
4
|
+
expression(url: string): ExpressionRendered;
|
|
5
|
+
expressionMany(urls: string[]): (ExpressionRendered | null)[];
|
|
6
|
+
expressionRaw(url: string): string;
|
|
7
|
+
expressionCreate(content: string, languageAddress: string): string;
|
|
8
|
+
expressionInteractions(url: string): InteractionMeta[];
|
|
9
|
+
expressionInteract(url: string, interactionCall: InteractionCall): string | null;
|
|
10
|
+
}
|
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
-
};
|
|
13
|
-
import { Arg, Mutation, Query, Resolver } from "type-graphql";
|
|
14
|
-
import { LanguageRef } from "../language/LanguageRef";
|
|
15
|
-
import { ExpressionProof, ExpressionRendered } from "./Expression";
|
|
16
|
-
import { InteractionCall, InteractionMeta } from "../language/Language";
|
|
17
|
-
const e = new ExpressionRendered();
|
|
18
|
-
e.author = 'did:ad4m:test';
|
|
19
|
-
e.timestamp = Date.now().toString();
|
|
20
|
-
e.proof = new ExpressionProof('', '');
|
|
21
|
-
e.data = JSON.stringify({ type: 'test expression', content: 'test' });
|
|
22
|
-
e.language = new LanguageRef('test-language-address');
|
|
23
|
-
const testExpression = e;
|
|
24
|
-
let ExpressionResolver = class ExpressionResolver {
|
|
25
|
-
expression(url) {
|
|
26
|
-
if (url === 'neighbourhood://Qm123') {
|
|
27
|
-
return testExpression;
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
expressionMany(urls) {
|
|
34
|
-
return [testExpression, null];
|
|
35
|
-
}
|
|
36
|
-
expressionRaw(url) {
|
|
37
|
-
if (url === 'neighbourhood://Qm123') {
|
|
38
|
-
return JSON.stringify(testExpression);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
expressionCreate(content, languageAddress) {
|
|
45
|
-
return "Qm1234";
|
|
46
|
-
}
|
|
47
|
-
expressionInteractions(url) {
|
|
48
|
-
const interaction = {
|
|
49
|
-
label: "Add a comment",
|
|
50
|
-
name: "add_comment",
|
|
51
|
-
parameters: [{ name: 'comment', type: 'string' }]
|
|
52
|
-
};
|
|
53
|
-
return [interaction];
|
|
54
|
-
}
|
|
55
|
-
expressionInteract(url, interactionCall) {
|
|
56
|
-
return "test result";
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
__decorate([
|
|
60
|
-
Query(returns => ExpressionRendered, { nullable: true }),
|
|
61
|
-
__param(0, Arg('url')),
|
|
62
|
-
__metadata("design:type", Function),
|
|
63
|
-
__metadata("design:paramtypes", [String]),
|
|
64
|
-
__metadata("design:returntype", ExpressionRendered)
|
|
65
|
-
], ExpressionResolver.prototype, "expression", null);
|
|
66
|
-
__decorate([
|
|
67
|
-
Query(returns => [ExpressionRendered], { nullable: "items" }),
|
|
68
|
-
__param(0, Arg('urls', type => [String])),
|
|
69
|
-
__metadata("design:type", Function),
|
|
70
|
-
__metadata("design:paramtypes", [Array]),
|
|
71
|
-
__metadata("design:returntype", Array)
|
|
72
|
-
], ExpressionResolver.prototype, "expressionMany", null);
|
|
73
|
-
__decorate([
|
|
74
|
-
Query(returns => String, { nullable: true }),
|
|
75
|
-
__param(0, Arg('url')),
|
|
76
|
-
__metadata("design:type", Function),
|
|
77
|
-
__metadata("design:paramtypes", [String]),
|
|
78
|
-
__metadata("design:returntype", String)
|
|
79
|
-
], ExpressionResolver.prototype, "expressionRaw", null);
|
|
80
|
-
__decorate([
|
|
81
|
-
Mutation(returns => String),
|
|
82
|
-
__param(0, Arg('content')),
|
|
83
|
-
__param(1, Arg('languageAddress')),
|
|
84
|
-
__metadata("design:type", Function),
|
|
85
|
-
__metadata("design:paramtypes", [String, String]),
|
|
86
|
-
__metadata("design:returntype", String)
|
|
87
|
-
], ExpressionResolver.prototype, "expressionCreate", null);
|
|
88
|
-
__decorate([
|
|
89
|
-
Query(returns => [InteractionMeta]),
|
|
90
|
-
__param(0, Arg('url')),
|
|
91
|
-
__metadata("design:type", Function),
|
|
92
|
-
__metadata("design:paramtypes", [String]),
|
|
93
|
-
__metadata("design:returntype", Array)
|
|
94
|
-
], ExpressionResolver.prototype, "expressionInteractions", null);
|
|
95
|
-
__decorate([
|
|
96
|
-
Mutation(returns => String, { nullable: true }),
|
|
97
|
-
__param(0, Arg('url')),
|
|
98
|
-
__param(1, Arg('interactionCall')),
|
|
99
|
-
__metadata("design:type", Function),
|
|
100
|
-
__metadata("design:paramtypes", [String, InteractionCall]),
|
|
101
|
-
__metadata("design:returntype", String)
|
|
102
|
-
], ExpressionResolver.prototype, "expressionInteract", null);
|
|
103
|
-
ExpressionResolver = __decorate([
|
|
104
|
-
Resolver()
|
|
105
|
-
], ExpressionResolver);
|
|
106
|
-
export default ExpressionResolver;
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { Arg, Mutation, Query, Resolver } from "type-graphql";
|
|
14
|
+
import { LanguageRef } from "../language/LanguageRef";
|
|
15
|
+
import { ExpressionProof, ExpressionRendered } from "./Expression";
|
|
16
|
+
import { InteractionCall, InteractionMeta } from "../language/Language";
|
|
17
|
+
const e = new ExpressionRendered();
|
|
18
|
+
e.author = 'did:ad4m:test';
|
|
19
|
+
e.timestamp = Date.now().toString();
|
|
20
|
+
e.proof = new ExpressionProof('', '');
|
|
21
|
+
e.data = JSON.stringify({ type: 'test expression', content: 'test' });
|
|
22
|
+
e.language = new LanguageRef('test-language-address');
|
|
23
|
+
const testExpression = e;
|
|
24
|
+
let ExpressionResolver = class ExpressionResolver {
|
|
25
|
+
expression(url) {
|
|
26
|
+
if (url === 'neighbourhood://Qm123') {
|
|
27
|
+
return testExpression;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
expressionMany(urls) {
|
|
34
|
+
return [testExpression, null];
|
|
35
|
+
}
|
|
36
|
+
expressionRaw(url) {
|
|
37
|
+
if (url === 'neighbourhood://Qm123') {
|
|
38
|
+
return JSON.stringify(testExpression);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
expressionCreate(content, languageAddress) {
|
|
45
|
+
return "Qm1234";
|
|
46
|
+
}
|
|
47
|
+
expressionInteractions(url) {
|
|
48
|
+
const interaction = {
|
|
49
|
+
label: "Add a comment",
|
|
50
|
+
name: "add_comment",
|
|
51
|
+
parameters: [{ name: 'comment', type: 'string' }]
|
|
52
|
+
};
|
|
53
|
+
return [interaction];
|
|
54
|
+
}
|
|
55
|
+
expressionInteract(url, interactionCall) {
|
|
56
|
+
return "test result";
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
__decorate([
|
|
60
|
+
Query(returns => ExpressionRendered, { nullable: true }),
|
|
61
|
+
__param(0, Arg('url')),
|
|
62
|
+
__metadata("design:type", Function),
|
|
63
|
+
__metadata("design:paramtypes", [String]),
|
|
64
|
+
__metadata("design:returntype", ExpressionRendered)
|
|
65
|
+
], ExpressionResolver.prototype, "expression", null);
|
|
66
|
+
__decorate([
|
|
67
|
+
Query(returns => [ExpressionRendered], { nullable: "items" }),
|
|
68
|
+
__param(0, Arg('urls', type => [String])),
|
|
69
|
+
__metadata("design:type", Function),
|
|
70
|
+
__metadata("design:paramtypes", [Array]),
|
|
71
|
+
__metadata("design:returntype", Array)
|
|
72
|
+
], ExpressionResolver.prototype, "expressionMany", null);
|
|
73
|
+
__decorate([
|
|
74
|
+
Query(returns => String, { nullable: true }),
|
|
75
|
+
__param(0, Arg('url')),
|
|
76
|
+
__metadata("design:type", Function),
|
|
77
|
+
__metadata("design:paramtypes", [String]),
|
|
78
|
+
__metadata("design:returntype", String)
|
|
79
|
+
], ExpressionResolver.prototype, "expressionRaw", null);
|
|
80
|
+
__decorate([
|
|
81
|
+
Mutation(returns => String),
|
|
82
|
+
__param(0, Arg('content')),
|
|
83
|
+
__param(1, Arg('languageAddress')),
|
|
84
|
+
__metadata("design:type", Function),
|
|
85
|
+
__metadata("design:paramtypes", [String, String]),
|
|
86
|
+
__metadata("design:returntype", String)
|
|
87
|
+
], ExpressionResolver.prototype, "expressionCreate", null);
|
|
88
|
+
__decorate([
|
|
89
|
+
Query(returns => [InteractionMeta]),
|
|
90
|
+
__param(0, Arg('url')),
|
|
91
|
+
__metadata("design:type", Function),
|
|
92
|
+
__metadata("design:paramtypes", [String]),
|
|
93
|
+
__metadata("design:returntype", Array)
|
|
94
|
+
], ExpressionResolver.prototype, "expressionInteractions", null);
|
|
95
|
+
__decorate([
|
|
96
|
+
Mutation(returns => String, { nullable: true }),
|
|
97
|
+
__param(0, Arg('url')),
|
|
98
|
+
__param(1, Arg('interactionCall')),
|
|
99
|
+
__metadata("design:type", Function),
|
|
100
|
+
__metadata("design:paramtypes", [String, InteractionCall]),
|
|
101
|
+
__metadata("design:returntype", String)
|
|
102
|
+
], ExpressionResolver.prototype, "expressionInteract", null);
|
|
103
|
+
ExpressionResolver = __decorate([
|
|
104
|
+
Resolver()
|
|
105
|
+
], ExpressionResolver);
|
|
106
|
+
export default ExpressionResolver;
|