@coasys/ad4m 0.8.0 → 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/lib/index.cjs +19 -47
- package/lib/index.js +8081 -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 +160 -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 +2 -1
- 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/unwrapApolloResult.ts +3 -1
|
File without changes
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*
|
|
2
|
+
This "shim" can be used on the frontend to prevent from errors on undefined decorators,
|
|
3
|
+
when you are sharing same classes across backend and frontend.
|
|
4
|
+
|
|
5
|
+
To use this shim, simply set up your Webpack configuration
|
|
6
|
+
to use this file instead of a normal TypeGraphQL module.
|
|
7
|
+
|
|
8
|
+
```js
|
|
9
|
+
plugins: [
|
|
10
|
+
// ...here are any other existing plugins that you already have
|
|
11
|
+
new webpack.NormalModuleReplacementPlugin(/type-graphql$/, resource => {
|
|
12
|
+
resource.request = resource.request.replace(/type-graphql/, "type-graphql/dist/browser-shim");
|
|
13
|
+
}),
|
|
14
|
+
]
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
However, in some TypeScript projects like the ones using Angular,
|
|
18
|
+
which AoT compiler requires that a full `*.ts` file is provided
|
|
19
|
+
instead of just a `*.js` and `*.d.ts` files, to use this shim
|
|
20
|
+
we have to simply set up our TypeScript configuration in `tsconfig.json`
|
|
21
|
+
to use this file instead of a normal TypeGraphQL module:
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"compilerOptions": {
|
|
26
|
+
"baseUrl": ".",
|
|
27
|
+
"paths": {
|
|
28
|
+
"type-graphql": [
|
|
29
|
+
"./node_modules/type-graphql/dist/browser-shim.ts"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
*/
|
|
36
|
+
export const dummyValue = "";
|
|
37
|
+
export function dummyFn() {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
export function dummyDecorator() {
|
|
41
|
+
return dummyFn;
|
|
42
|
+
}
|
|
43
|
+
export const Arg = dummyDecorator;
|
|
44
|
+
export const Args = dummyDecorator;
|
|
45
|
+
export const ArgsType = dummyDecorator;
|
|
46
|
+
export const Authorized = dummyDecorator;
|
|
47
|
+
export const Ctx = dummyDecorator;
|
|
48
|
+
export const registerEnumType = dummyFn;
|
|
49
|
+
export const Field = dummyDecorator;
|
|
50
|
+
export const FieldResolver = dummyDecorator;
|
|
51
|
+
export const Info = dummyDecorator;
|
|
52
|
+
export const InputType = dummyDecorator;
|
|
53
|
+
export const InterfaceType = dummyDecorator;
|
|
54
|
+
export const Mutation = dummyDecorator;
|
|
55
|
+
export const ObjectType = dummyDecorator;
|
|
56
|
+
export const PubSub = dummyDecorator;
|
|
57
|
+
export const Query = dummyDecorator;
|
|
58
|
+
export const Resolver = dummyDecorator;
|
|
59
|
+
export const Root = dummyDecorator;
|
|
60
|
+
export const Subscription = dummyDecorator;
|
|
61
|
+
export const createUnionType = dummyFn;
|
|
62
|
+
export const UseMiddleware = dummyDecorator;
|
|
63
|
+
export const PubSubEngine = dummyDecorator;
|
|
64
|
+
export class ClassType {
|
|
65
|
+
}
|
|
66
|
+
export const Int = dummyValue;
|
|
67
|
+
export const Float = dummyValue;
|
|
68
|
+
export const ID = dummyValue;
|
|
69
|
+
export const GraphQLISODateTime = dummyValue;
|
|
70
|
+
export const GraphQLTimestamp = dummyValue;
|
|
@@ -0,0 +1,66 @@
|
|
|
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 _Ad4mClient_apolloClient, _Ad4mClient_agentClient, _Ad4mClient_expressionClient, _Ad4mClient_languageClient, _Ad4mClient_neighbourhoodClient, _Ad4mClient_perspectiveClient, _Ad4mClient_runtimeClient;
|
|
13
|
+
import { AgentClient } from './agent/AgentClient';
|
|
14
|
+
import { LanguageClient } from './language/LanguageClient';
|
|
15
|
+
import { NeighbourhoodClient } from './neighbourhood/NeighbourhoodClient';
|
|
16
|
+
import { PerspectiveClient } from './perspectives/PerspectiveClient';
|
|
17
|
+
import { RuntimeClient } from './runtime/RuntimeClient';
|
|
18
|
+
import { ExpressionClient } from './expression/ExpressionClient';
|
|
19
|
+
/**
|
|
20
|
+
* Client for the Ad4m interface wrapping GraphQL queryies
|
|
21
|
+
* for convenient use in user facing code.
|
|
22
|
+
*
|
|
23
|
+
* Aggregates the six sub-clients:
|
|
24
|
+
* AgentClient, ExpressionClient, LanguageClient,
|
|
25
|
+
* NeighbourhoodClient, PerspectiveClient and RuntimeClient
|
|
26
|
+
* for the respective functionality.
|
|
27
|
+
*/
|
|
28
|
+
export class Ad4mClient {
|
|
29
|
+
constructor(client, subscribe = true) {
|
|
30
|
+
_Ad4mClient_apolloClient.set(this, void 0);
|
|
31
|
+
_Ad4mClient_agentClient.set(this, void 0);
|
|
32
|
+
_Ad4mClient_expressionClient.set(this, void 0);
|
|
33
|
+
_Ad4mClient_languageClient.set(this, void 0);
|
|
34
|
+
_Ad4mClient_neighbourhoodClient.set(this, void 0);
|
|
35
|
+
_Ad4mClient_perspectiveClient.set(this, void 0);
|
|
36
|
+
_Ad4mClient_runtimeClient.set(this, void 0);
|
|
37
|
+
__classPrivateFieldSet(this, _Ad4mClient_apolloClient, client, "f");
|
|
38
|
+
__classPrivateFieldSet(this, _Ad4mClient_agentClient, new AgentClient(__classPrivateFieldGet(this, _Ad4mClient_apolloClient, "f"), subscribe), "f");
|
|
39
|
+
__classPrivateFieldSet(this, _Ad4mClient_expressionClient, new ExpressionClient(__classPrivateFieldGet(this, _Ad4mClient_apolloClient, "f")), "f");
|
|
40
|
+
__classPrivateFieldSet(this, _Ad4mClient_languageClient, new LanguageClient(__classPrivateFieldGet(this, _Ad4mClient_apolloClient, "f")), "f");
|
|
41
|
+
__classPrivateFieldSet(this, _Ad4mClient_neighbourhoodClient, new NeighbourhoodClient(__classPrivateFieldGet(this, _Ad4mClient_apolloClient, "f")), "f");
|
|
42
|
+
__classPrivateFieldSet(this, _Ad4mClient_perspectiveClient, new PerspectiveClient(__classPrivateFieldGet(this, _Ad4mClient_apolloClient, "f"), subscribe), "f");
|
|
43
|
+
__classPrivateFieldGet(this, _Ad4mClient_perspectiveClient, "f").setExpressionClient(__classPrivateFieldGet(this, _Ad4mClient_expressionClient, "f"));
|
|
44
|
+
__classPrivateFieldGet(this, _Ad4mClient_perspectiveClient, "f").setNeighbourhoodClient(__classPrivateFieldGet(this, _Ad4mClient_neighbourhoodClient, "f"));
|
|
45
|
+
__classPrivateFieldSet(this, _Ad4mClient_runtimeClient, new RuntimeClient(__classPrivateFieldGet(this, _Ad4mClient_apolloClient, "f"), subscribe), "f");
|
|
46
|
+
}
|
|
47
|
+
get agent() {
|
|
48
|
+
return __classPrivateFieldGet(this, _Ad4mClient_agentClient, "f");
|
|
49
|
+
}
|
|
50
|
+
get expression() {
|
|
51
|
+
return __classPrivateFieldGet(this, _Ad4mClient_expressionClient, "f");
|
|
52
|
+
}
|
|
53
|
+
get languages() {
|
|
54
|
+
return __classPrivateFieldGet(this, _Ad4mClient_languageClient, "f");
|
|
55
|
+
}
|
|
56
|
+
get neighbourhood() {
|
|
57
|
+
return __classPrivateFieldGet(this, _Ad4mClient_neighbourhoodClient, "f");
|
|
58
|
+
}
|
|
59
|
+
get perspective() {
|
|
60
|
+
return __classPrivateFieldGet(this, _Ad4mClient_perspectiveClient, "f");
|
|
61
|
+
}
|
|
62
|
+
get runtime() {
|
|
63
|
+
return __classPrivateFieldGet(this, _Ad4mClient_runtimeClient, "f");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
_Ad4mClient_apolloClient = new WeakMap(), _Ad4mClient_agentClient = new WeakMap(), _Ad4mClient_expressionClient = new WeakMap(), _Ad4mClient_languageClient = new WeakMap(), _Ad4mClient_neighbourhoodClient = new WeakMap(), _Ad4mClient_perspectiveClient = new WeakMap(), _Ad4mClient_runtimeClient = new WeakMap();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/src/DID.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var ExceptionType;
|
|
2
|
+
(function (ExceptionType) {
|
|
3
|
+
ExceptionType[ExceptionType["LanguageIsNotLoaded"] = 0] = "LanguageIsNotLoaded";
|
|
4
|
+
ExceptionType[ExceptionType["ExpressionIsNotVerified"] = 1] = "ExpressionIsNotVerified";
|
|
5
|
+
ExceptionType[ExceptionType["AgentIsUntrusted"] = 2] = "AgentIsUntrusted";
|
|
6
|
+
ExceptionType[ExceptionType["CapabilityRequested"] = 3] = "CapabilityRequested";
|
|
7
|
+
})(ExceptionType || (ExceptionType = {}));
|
|
@@ -0,0 +1,76 @@
|
|
|
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 _Literal_literal, _Literal_url;
|
|
13
|
+
function encodeRFC3986URIComponent(str) {
|
|
14
|
+
return encodeURIComponent(str)
|
|
15
|
+
.replace(/[!'()*]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
16
|
+
}
|
|
17
|
+
export class Literal {
|
|
18
|
+
constructor() {
|
|
19
|
+
_Literal_literal.set(this, void 0);
|
|
20
|
+
_Literal_url.set(this, void 0);
|
|
21
|
+
}
|
|
22
|
+
static fromUrl(url) {
|
|
23
|
+
if (!url || !url.startsWith("literal://"))
|
|
24
|
+
throw new Error("Can't create Literal from non-literal URL");
|
|
25
|
+
const l = new Literal();
|
|
26
|
+
__classPrivateFieldSet(l, _Literal_url, url, "f");
|
|
27
|
+
return l;
|
|
28
|
+
}
|
|
29
|
+
static from(literal) {
|
|
30
|
+
const l = new Literal();
|
|
31
|
+
__classPrivateFieldSet(l, _Literal_literal, literal, "f");
|
|
32
|
+
return l;
|
|
33
|
+
}
|
|
34
|
+
toUrl() {
|
|
35
|
+
if (__classPrivateFieldGet(this, _Literal_url, "f") && !__classPrivateFieldGet(this, _Literal_literal, "f"))
|
|
36
|
+
return __classPrivateFieldGet(this, _Literal_url, "f");
|
|
37
|
+
if (!__classPrivateFieldGet(this, _Literal_url, "f") && !__classPrivateFieldGet(this, _Literal_literal, "f"))
|
|
38
|
+
throw new Error("Can't turn empty Literal into URL");
|
|
39
|
+
let encoded;
|
|
40
|
+
switch (typeof __classPrivateFieldGet(this, _Literal_literal, "f")) {
|
|
41
|
+
case 'string':
|
|
42
|
+
encoded = `string:${encodeRFC3986URIComponent(__classPrivateFieldGet(this, _Literal_literal, "f"))}`;
|
|
43
|
+
break;
|
|
44
|
+
case 'number':
|
|
45
|
+
encoded = `number:${encodeRFC3986URIComponent(__classPrivateFieldGet(this, _Literal_literal, "f"))}`;
|
|
46
|
+
break;
|
|
47
|
+
case 'object':
|
|
48
|
+
encoded = `json:${encodeRFC3986URIComponent(JSON.stringify(__classPrivateFieldGet(this, _Literal_literal, "f")))}`;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
return `literal://${encoded}`;
|
|
52
|
+
}
|
|
53
|
+
get() {
|
|
54
|
+
if (__classPrivateFieldGet(this, _Literal_literal, "f"))
|
|
55
|
+
return __classPrivateFieldGet(this, _Literal_literal, "f");
|
|
56
|
+
if (!__classPrivateFieldGet(this, _Literal_url, "f"))
|
|
57
|
+
throw new Error("Can't render empty Literal");
|
|
58
|
+
if (!__classPrivateFieldGet(this, _Literal_url, "f").startsWith("literal://"))
|
|
59
|
+
throw new Error("Can't render Literal from non-literal URL");
|
|
60
|
+
// get rid of "literal://"
|
|
61
|
+
const body = __classPrivateFieldGet(this, _Literal_url, "f").substring(10);
|
|
62
|
+
if (body.startsWith("string:")) {
|
|
63
|
+
return decodeURIComponent(body.substring(7));
|
|
64
|
+
}
|
|
65
|
+
if (body.startsWith("number:")) {
|
|
66
|
+
const numberString = body.substring(7);
|
|
67
|
+
return parseFloat(numberString);
|
|
68
|
+
}
|
|
69
|
+
if (body.startsWith("json:")) {
|
|
70
|
+
const json = body.substring(5);
|
|
71
|
+
return JSON.parse(decodeURIComponent(json));
|
|
72
|
+
}
|
|
73
|
+
throw new Error(`Can't parse unknown literal: ${body}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
_Literal_literal = new WeakMap(), _Literal_url = new WeakMap();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const AGENT_UPDATED = 'agent-updated-topic';
|
|
2
|
+
export const AGENT_STATUS_CHANGED = 'agent-status-changed-topic';
|
|
3
|
+
export const RUNTIME_MESSAGED_RECEIVED_TOPIC = 'runtime-messaged-received-topic';
|
|
4
|
+
export const PERSPECTIVE_ADDED_TOPIC = 'perspective-added-topic';
|
|
5
|
+
export const PERSPECTIVE_UPDATED_TOPIC = 'perspective-updated-topic';
|
|
6
|
+
export const PERSPECTIVE_REMOVED_TOPIC = 'perspective-removed-topic';
|
|
7
|
+
export const LINK_ADDED_TOPIC = 'link-added-topic';
|
|
8
|
+
export const LINK_REMOVED_TOPIC = 'link-removed-topic';
|
|
9
|
+
export const LINK_UDATED_TOPIC = 'link-updated-topic';
|
|
10
|
+
export const SIGNAL = "signal";
|
|
11
|
+
export const EXCEPTION_OCCURRED_TOPIC = "exception-occurred-topic";
|
|
12
|
+
export const NEIGHBOURHOOD_SIGNAL_RECEIVED_TOPIC = "neighbourhood-signal-received-topic";
|
|
13
|
+
export const PERSPECTIVE_SYNC_STATE_CHANGE = "perspective-sync-state-change";
|
|
14
|
+
export const APPS_CHANGED = "apps-changed";
|
|
@@ -0,0 +1,74 @@
|
|
|
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 _SmartLiteral_perspective, _SmartLiteral_base;
|
|
13
|
+
import { Link } from "./links/Links";
|
|
14
|
+
import { Literal } from "./Literal";
|
|
15
|
+
import { LinkQuery } from "./perspectives/LinkQuery";
|
|
16
|
+
export const SMART_LITERAL_CONTENT_PREDICATE = "smart_literal://content";
|
|
17
|
+
function makeRandomStringID(length) {
|
|
18
|
+
let result = '';
|
|
19
|
+
let characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
20
|
+
let charactersLength = characters.length;
|
|
21
|
+
for (let i = 0; i < length; i++) {
|
|
22
|
+
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
export class SmartLiteral {
|
|
27
|
+
constructor(perspective, base) {
|
|
28
|
+
_SmartLiteral_perspective.set(this, void 0);
|
|
29
|
+
_SmartLiteral_base.set(this, void 0);
|
|
30
|
+
__classPrivateFieldSet(this, _SmartLiteral_perspective, perspective, "f");
|
|
31
|
+
__classPrivateFieldSet(this, _SmartLiteral_base, base, "f");
|
|
32
|
+
}
|
|
33
|
+
get base() {
|
|
34
|
+
return __classPrivateFieldGet(this, _SmartLiteral_base, "f");
|
|
35
|
+
}
|
|
36
|
+
static async create(perspective, literal) {
|
|
37
|
+
const base = Literal.from(makeRandomStringID(10)).toUrl();
|
|
38
|
+
const smartLiteral = new SmartLiteral(perspective, base);
|
|
39
|
+
await smartLiteral.set(literal);
|
|
40
|
+
return smartLiteral;
|
|
41
|
+
}
|
|
42
|
+
static async isSmartLiteralBase(perspective, base) {
|
|
43
|
+
let links = await perspective.get(new LinkQuery({
|
|
44
|
+
source: base,
|
|
45
|
+
predicate: SMART_LITERAL_CONTENT_PREDICATE
|
|
46
|
+
}));
|
|
47
|
+
return links.length > 0;
|
|
48
|
+
}
|
|
49
|
+
static async getAllSmartLiterals(perspective) {
|
|
50
|
+
let links = await perspective.get(new LinkQuery({
|
|
51
|
+
predicate: SMART_LITERAL_CONTENT_PREDICATE
|
|
52
|
+
}));
|
|
53
|
+
return links.map(link => new SmartLiteral(perspective, link.data.source));
|
|
54
|
+
}
|
|
55
|
+
async get() {
|
|
56
|
+
let link = await __classPrivateFieldGet(this, _SmartLiteral_perspective, "f").getSingleTarget(new LinkQuery({
|
|
57
|
+
source: __classPrivateFieldGet(this, _SmartLiteral_base, "f"),
|
|
58
|
+
predicate: SMART_LITERAL_CONTENT_PREDICATE
|
|
59
|
+
}));
|
|
60
|
+
if (!link) {
|
|
61
|
+
throw `No content for smart literal ${__classPrivateFieldGet(this, _SmartLiteral_base, "f")}`;
|
|
62
|
+
}
|
|
63
|
+
return Literal.fromUrl(link).get();
|
|
64
|
+
}
|
|
65
|
+
async set(content) {
|
|
66
|
+
let literal = Literal.from(content);
|
|
67
|
+
await __classPrivateFieldGet(this, _SmartLiteral_perspective, "f").setSingleTarget(new Link({
|
|
68
|
+
source: __classPrivateFieldGet(this, _SmartLiteral_base, "f"),
|
|
69
|
+
predicate: SMART_LITERAL_CONTENT_PREDICATE,
|
|
70
|
+
target: literal.toUrl()
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
_SmartLiteral_perspective = new WeakMap(), _SmartLiteral_base = new WeakMap();
|
|
@@ -0,0 +1,337 @@
|
|
|
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 { Field, ObjectType, InputType } from "type-graphql";
|
|
11
|
+
import { Perspective } from "../perspectives/Perspective";
|
|
12
|
+
import { ExpressionGeneric } from "../expression/Expression";
|
|
13
|
+
/** AD4M's representation of an Agent
|
|
14
|
+
*
|
|
15
|
+
* AD4M Agents are build around DIDs, which are used to identify and authenticate the Agent.
|
|
16
|
+
* Conceptually, an Agent is regarded as something that can speak and that can listen.
|
|
17
|
+
*
|
|
18
|
+
* Agents speak by creating Expressions in AD4M Languages which are signed by the Agent's DID key,
|
|
19
|
+
* And they also speak (broadcast) by putting semantic statements into their public "Agent Perspective".
|
|
20
|
+
* They listen (can receive messages) through their "direct message Language".
|
|
21
|
+
*
|
|
22
|
+
* These three aspects are represented by the three fields of this class.
|
|
23
|
+
*
|
|
24
|
+
* This class is used as format for the Expressions in the Agent language.
|
|
25
|
+
* Since AD4M treats DID URIs as addresses for the Agent Language,
|
|
26
|
+
* DIDs are resolved to Expressions that are objects of this class.
|
|
27
|
+
* Thus, this is how agents see (other) agents.
|
|
28
|
+
*/
|
|
29
|
+
let Agent = class Agent {
|
|
30
|
+
constructor(did, perspective) {
|
|
31
|
+
this.did = did;
|
|
32
|
+
if (perspective) {
|
|
33
|
+
this.perspective = perspective;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this.perspective = new Perspective();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
__decorate([
|
|
41
|
+
Field(),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], Agent.prototype, "did", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
Field((type) => Perspective, { nullable: true }),
|
|
46
|
+
__metadata("design:type", Perspective)
|
|
47
|
+
], Agent.prototype, "perspective", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
Field({ nullable: true }),
|
|
50
|
+
__metadata("design:type", String)
|
|
51
|
+
], Agent.prototype, "directMessageLanguage", void 0);
|
|
52
|
+
Agent = __decorate([
|
|
53
|
+
ObjectType(),
|
|
54
|
+
__metadata("design:paramtypes", [String, Perspective])
|
|
55
|
+
], Agent);
|
|
56
|
+
export { Agent };
|
|
57
|
+
let AgentExpression = class AgentExpression extends ExpressionGeneric(Agent) {
|
|
58
|
+
};
|
|
59
|
+
AgentExpression = __decorate([
|
|
60
|
+
ObjectType()
|
|
61
|
+
], AgentExpression);
|
|
62
|
+
export { AgentExpression };
|
|
63
|
+
let EntanglementProof = class EntanglementProof {
|
|
64
|
+
constructor(did, didSigningKeyId, deviceKeyType, deviceKey, deviceKeySignedByDid, didSignedByDeviceKey) {
|
|
65
|
+
this.did = did;
|
|
66
|
+
this.didSigningKeyId = didSigningKeyId;
|
|
67
|
+
this.deviceKeyType = deviceKeyType;
|
|
68
|
+
this.deviceKey = deviceKey;
|
|
69
|
+
this.deviceKeySignedByDid = deviceKeySignedByDid;
|
|
70
|
+
this.didSignedByDeviceKey = didSignedByDeviceKey;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
__decorate([
|
|
74
|
+
Field(),
|
|
75
|
+
__metadata("design:type", String)
|
|
76
|
+
], EntanglementProof.prototype, "did", void 0);
|
|
77
|
+
__decorate([
|
|
78
|
+
Field(),
|
|
79
|
+
__metadata("design:type", String)
|
|
80
|
+
], EntanglementProof.prototype, "didSigningKeyId", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
Field(),
|
|
83
|
+
__metadata("design:type", String)
|
|
84
|
+
], EntanglementProof.prototype, "deviceKeyType", void 0);
|
|
85
|
+
__decorate([
|
|
86
|
+
Field(),
|
|
87
|
+
__metadata("design:type", String)
|
|
88
|
+
], EntanglementProof.prototype, "deviceKey", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
Field(),
|
|
91
|
+
__metadata("design:type", String)
|
|
92
|
+
], EntanglementProof.prototype, "deviceKeySignedByDid", void 0);
|
|
93
|
+
__decorate([
|
|
94
|
+
Field({ nullable: true }),
|
|
95
|
+
__metadata("design:type", String)
|
|
96
|
+
], EntanglementProof.prototype, "didSignedByDeviceKey", void 0);
|
|
97
|
+
EntanglementProof = __decorate([
|
|
98
|
+
ObjectType(),
|
|
99
|
+
__metadata("design:paramtypes", [String, String, String, String, String, String])
|
|
100
|
+
], EntanglementProof);
|
|
101
|
+
export { EntanglementProof };
|
|
102
|
+
let EntanglementProofInput = class EntanglementProofInput {
|
|
103
|
+
constructor(did, didSigningKeyId, deviceKeyType, deviceKey, deviceKeySignedByDid, didSignedByDeviceKey) {
|
|
104
|
+
this.did = did;
|
|
105
|
+
this.didSigningKeyId = didSigningKeyId;
|
|
106
|
+
this.deviceKeyType = deviceKeyType;
|
|
107
|
+
this.deviceKey = deviceKey;
|
|
108
|
+
this.deviceKeySignedByDid = deviceKeySignedByDid;
|
|
109
|
+
this.didSignedByDeviceKey = didSignedByDeviceKey;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
__decorate([
|
|
113
|
+
Field(),
|
|
114
|
+
__metadata("design:type", String)
|
|
115
|
+
], EntanglementProofInput.prototype, "did", void 0);
|
|
116
|
+
__decorate([
|
|
117
|
+
Field(),
|
|
118
|
+
__metadata("design:type", String)
|
|
119
|
+
], EntanglementProofInput.prototype, "didSigningKeyId", void 0);
|
|
120
|
+
__decorate([
|
|
121
|
+
Field(),
|
|
122
|
+
__metadata("design:type", String)
|
|
123
|
+
], EntanglementProofInput.prototype, "deviceKeyType", void 0);
|
|
124
|
+
__decorate([
|
|
125
|
+
Field(),
|
|
126
|
+
__metadata("design:type", String)
|
|
127
|
+
], EntanglementProofInput.prototype, "deviceKey", void 0);
|
|
128
|
+
__decorate([
|
|
129
|
+
Field(),
|
|
130
|
+
__metadata("design:type", String)
|
|
131
|
+
], EntanglementProofInput.prototype, "deviceKeySignedByDid", void 0);
|
|
132
|
+
__decorate([
|
|
133
|
+
Field(),
|
|
134
|
+
__metadata("design:type", String)
|
|
135
|
+
], EntanglementProofInput.prototype, "didSignedByDeviceKey", void 0);
|
|
136
|
+
EntanglementProofInput = __decorate([
|
|
137
|
+
InputType(),
|
|
138
|
+
__metadata("design:paramtypes", [String, String, String, String, String, String])
|
|
139
|
+
], EntanglementProofInput);
|
|
140
|
+
export { EntanglementProofInput };
|
|
141
|
+
let AgentSignature = class AgentSignature {
|
|
142
|
+
constructor(signature, publicKey) {
|
|
143
|
+
this.signature = signature;
|
|
144
|
+
this.publicKey = publicKey;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
__decorate([
|
|
148
|
+
Field(),
|
|
149
|
+
__metadata("design:type", String)
|
|
150
|
+
], AgentSignature.prototype, "signature", void 0);
|
|
151
|
+
__decorate([
|
|
152
|
+
Field(),
|
|
153
|
+
__metadata("design:type", String)
|
|
154
|
+
], AgentSignature.prototype, "publicKey", void 0);
|
|
155
|
+
AgentSignature = __decorate([
|
|
156
|
+
ObjectType(),
|
|
157
|
+
__metadata("design:paramtypes", [String, String])
|
|
158
|
+
], AgentSignature);
|
|
159
|
+
export { AgentSignature };
|
|
160
|
+
let Resource = class Resource {
|
|
161
|
+
constructor(domain, pointers) {
|
|
162
|
+
this.domain = domain;
|
|
163
|
+
this.pointers = pointers;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
__decorate([
|
|
167
|
+
Field(),
|
|
168
|
+
__metadata("design:type", String)
|
|
169
|
+
], Resource.prototype, "domain", void 0);
|
|
170
|
+
__decorate([
|
|
171
|
+
Field((type) => [String]),
|
|
172
|
+
__metadata("design:type", Array)
|
|
173
|
+
], Resource.prototype, "pointers", void 0);
|
|
174
|
+
Resource = __decorate([
|
|
175
|
+
ObjectType(),
|
|
176
|
+
__metadata("design:paramtypes", [String, Array])
|
|
177
|
+
], Resource);
|
|
178
|
+
export { Resource };
|
|
179
|
+
let Capability = class Capability {
|
|
180
|
+
constructor(withF, can) {
|
|
181
|
+
this.with = withF;
|
|
182
|
+
this.can = can;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
__decorate([
|
|
186
|
+
Field((type) => Resource),
|
|
187
|
+
__metadata("design:type", Resource)
|
|
188
|
+
], Capability.prototype, "with", void 0);
|
|
189
|
+
__decorate([
|
|
190
|
+
Field((type) => [String]),
|
|
191
|
+
__metadata("design:type", Array)
|
|
192
|
+
], Capability.prototype, "can", void 0);
|
|
193
|
+
Capability = __decorate([
|
|
194
|
+
ObjectType(),
|
|
195
|
+
__metadata("design:paramtypes", [Resource, Array])
|
|
196
|
+
], Capability);
|
|
197
|
+
export { Capability };
|
|
198
|
+
let AuthInfo = class AuthInfo {
|
|
199
|
+
constructor(appName, appDesc, appUrl, capabilities, appIconPath) {
|
|
200
|
+
this.appName = appName;
|
|
201
|
+
this.appDesc = appDesc;
|
|
202
|
+
this.appIconPath = appIconPath;
|
|
203
|
+
this.appUrl = appUrl;
|
|
204
|
+
this.capabilities = capabilities;
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
__decorate([
|
|
208
|
+
Field(),
|
|
209
|
+
__metadata("design:type", String)
|
|
210
|
+
], AuthInfo.prototype, "appName", void 0);
|
|
211
|
+
__decorate([
|
|
212
|
+
Field(),
|
|
213
|
+
__metadata("design:type", String)
|
|
214
|
+
], AuthInfo.prototype, "appDesc", void 0);
|
|
215
|
+
__decorate([
|
|
216
|
+
Field(),
|
|
217
|
+
__metadata("design:type", String)
|
|
218
|
+
], AuthInfo.prototype, "appUrl", void 0);
|
|
219
|
+
__decorate([
|
|
220
|
+
Field({ nullable: true }),
|
|
221
|
+
__metadata("design:type", String)
|
|
222
|
+
], AuthInfo.prototype, "appIconPath", void 0);
|
|
223
|
+
__decorate([
|
|
224
|
+
Field((type) => [Capability]),
|
|
225
|
+
__metadata("design:type", Array)
|
|
226
|
+
], AuthInfo.prototype, "capabilities", void 0);
|
|
227
|
+
AuthInfo = __decorate([
|
|
228
|
+
ObjectType(),
|
|
229
|
+
__metadata("design:paramtypes", [String, String, String, Array, String])
|
|
230
|
+
], AuthInfo);
|
|
231
|
+
export { AuthInfo };
|
|
232
|
+
let Apps = class Apps {
|
|
233
|
+
constructor(requestId, auth, token, revoked) {
|
|
234
|
+
this.requestId = requestId;
|
|
235
|
+
this.auth = auth;
|
|
236
|
+
this.token = token;
|
|
237
|
+
this.revoked = revoked;
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
__decorate([
|
|
241
|
+
Field(),
|
|
242
|
+
__metadata("design:type", String)
|
|
243
|
+
], Apps.prototype, "requestId", void 0);
|
|
244
|
+
__decorate([
|
|
245
|
+
Field(),
|
|
246
|
+
__metadata("design:type", String)
|
|
247
|
+
], Apps.prototype, "token", void 0);
|
|
248
|
+
__decorate([
|
|
249
|
+
Field({ nullable: true }),
|
|
250
|
+
__metadata("design:type", Boolean)
|
|
251
|
+
], Apps.prototype, "revoked", void 0);
|
|
252
|
+
__decorate([
|
|
253
|
+
Field(),
|
|
254
|
+
__metadata("design:type", AuthInfo)
|
|
255
|
+
], Apps.prototype, "auth", void 0);
|
|
256
|
+
Apps = __decorate([
|
|
257
|
+
ObjectType(),
|
|
258
|
+
__metadata("design:paramtypes", [String, AuthInfo, String, Boolean])
|
|
259
|
+
], Apps);
|
|
260
|
+
export { Apps };
|
|
261
|
+
let ResourceInput = class ResourceInput {
|
|
262
|
+
constructor(domain, pointers) {
|
|
263
|
+
this.domain = domain;
|
|
264
|
+
this.pointers = pointers;
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
__decorate([
|
|
268
|
+
Field(),
|
|
269
|
+
__metadata("design:type", String)
|
|
270
|
+
], ResourceInput.prototype, "domain", void 0);
|
|
271
|
+
__decorate([
|
|
272
|
+
Field((type) => [String]),
|
|
273
|
+
__metadata("design:type", Array)
|
|
274
|
+
], ResourceInput.prototype, "pointers", void 0);
|
|
275
|
+
ResourceInput = __decorate([
|
|
276
|
+
InputType(),
|
|
277
|
+
__metadata("design:paramtypes", [String, Array])
|
|
278
|
+
], ResourceInput);
|
|
279
|
+
export { ResourceInput };
|
|
280
|
+
let CapabilityInput = class CapabilityInput {
|
|
281
|
+
constructor(withF, can) {
|
|
282
|
+
this.with = withF;
|
|
283
|
+
this.can = can;
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
__decorate([
|
|
287
|
+
Field((type) => ResourceInput),
|
|
288
|
+
__metadata("design:type", ResourceInput)
|
|
289
|
+
], CapabilityInput.prototype, "with", void 0);
|
|
290
|
+
__decorate([
|
|
291
|
+
Field((type) => [String]),
|
|
292
|
+
__metadata("design:type", Array)
|
|
293
|
+
], CapabilityInput.prototype, "can", void 0);
|
|
294
|
+
CapabilityInput = __decorate([
|
|
295
|
+
InputType(),
|
|
296
|
+
__metadata("design:paramtypes", [ResourceInput, Array])
|
|
297
|
+
], CapabilityInput);
|
|
298
|
+
export { CapabilityInput };
|
|
299
|
+
let AuthInfoInput = class AuthInfoInput {
|
|
300
|
+
constructor(appName, appDesc, appDomain, appUrl, appIconPath, capabilities) {
|
|
301
|
+
this.appName = appName;
|
|
302
|
+
this.appDesc = appDesc;
|
|
303
|
+
this.appUrl = appUrl;
|
|
304
|
+
this.appDomain = appDomain;
|
|
305
|
+
this.capabilities = capabilities;
|
|
306
|
+
this.appIconPath = appIconPath;
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
__decorate([
|
|
310
|
+
Field(),
|
|
311
|
+
__metadata("design:type", String)
|
|
312
|
+
], AuthInfoInput.prototype, "appName", void 0);
|
|
313
|
+
__decorate([
|
|
314
|
+
Field(),
|
|
315
|
+
__metadata("design:type", String)
|
|
316
|
+
], AuthInfoInput.prototype, "appDesc", void 0);
|
|
317
|
+
__decorate([
|
|
318
|
+
Field(),
|
|
319
|
+
__metadata("design:type", String)
|
|
320
|
+
], AuthInfoInput.prototype, "appDomain", void 0);
|
|
321
|
+
__decorate([
|
|
322
|
+
Field({ nullable: true }),
|
|
323
|
+
__metadata("design:type", String)
|
|
324
|
+
], AuthInfoInput.prototype, "appUrl", void 0);
|
|
325
|
+
__decorate([
|
|
326
|
+
Field({ nullable: true }),
|
|
327
|
+
__metadata("design:type", String)
|
|
328
|
+
], AuthInfoInput.prototype, "appIconPath", void 0);
|
|
329
|
+
__decorate([
|
|
330
|
+
Field((type) => [CapabilityInput], { nullable: true }),
|
|
331
|
+
__metadata("design:type", Array)
|
|
332
|
+
], AuthInfoInput.prototype, "capabilities", void 0);
|
|
333
|
+
AuthInfoInput = __decorate([
|
|
334
|
+
InputType(),
|
|
335
|
+
__metadata("design:paramtypes", [String, String, String, String, String, Array])
|
|
336
|
+
], AuthInfoInput);
|
|
337
|
+
export { AuthInfoInput };
|