@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
package/lib/src/PubSub.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export declare const AGENT_UPDATED = "agent-updated-topic";
|
|
2
|
-
export declare const AGENT_STATUS_CHANGED = "agent-status-changed-topic";
|
|
3
|
-
export declare const RUNTIME_MESSAGED_RECEIVED_TOPIC = "runtime-messaged-received-topic";
|
|
4
|
-
export declare const PERSPECTIVE_ADDED_TOPIC = "perspective-added-topic";
|
|
5
|
-
export declare const PERSPECTIVE_UPDATED_TOPIC = "perspective-updated-topic";
|
|
6
|
-
export declare const PERSPECTIVE_REMOVED_TOPIC = "perspective-removed-topic";
|
|
7
|
-
export declare const LINK_ADDED_TOPIC = "link-added-topic";
|
|
8
|
-
export declare const LINK_REMOVED_TOPIC = "link-removed-topic";
|
|
9
|
-
export declare const LINK_UDATED_TOPIC = "link-updated-topic";
|
|
10
|
-
export declare const SIGNAL = "signal";
|
|
11
|
-
export declare const EXCEPTION_OCCURRED_TOPIC = "exception-occurred-topic";
|
|
12
|
-
export declare const NEIGHBOURHOOD_SIGNAL_RECEIVED_TOPIC = "neighbourhood-signal-received-topic";
|
|
13
|
-
export declare const PERSPECTIVE_SYNC_STATE_CHANGE = "perspective-sync-state-change";
|
|
14
|
-
export declare const APPS_CHANGED = "apps-changed";
|
|
1
|
+
export declare const AGENT_UPDATED = "agent-updated-topic";
|
|
2
|
+
export declare const AGENT_STATUS_CHANGED = "agent-status-changed-topic";
|
|
3
|
+
export declare const RUNTIME_MESSAGED_RECEIVED_TOPIC = "runtime-messaged-received-topic";
|
|
4
|
+
export declare const PERSPECTIVE_ADDED_TOPIC = "perspective-added-topic";
|
|
5
|
+
export declare const PERSPECTIVE_UPDATED_TOPIC = "perspective-updated-topic";
|
|
6
|
+
export declare const PERSPECTIVE_REMOVED_TOPIC = "perspective-removed-topic";
|
|
7
|
+
export declare const LINK_ADDED_TOPIC = "link-added-topic";
|
|
8
|
+
export declare const LINK_REMOVED_TOPIC = "link-removed-topic";
|
|
9
|
+
export declare const LINK_UDATED_TOPIC = "link-updated-topic";
|
|
10
|
+
export declare const SIGNAL = "signal";
|
|
11
|
+
export declare const EXCEPTION_OCCURRED_TOPIC = "exception-occurred-topic";
|
|
12
|
+
export declare const NEIGHBOURHOOD_SIGNAL_RECEIVED_TOPIC = "neighbourhood-signal-received-topic";
|
|
13
|
+
export declare const PERSPECTIVE_SYNC_STATE_CHANGE = "perspective-sync-state-change";
|
|
14
|
+
export declare const APPS_CHANGED = "apps-changed";
|
package/lib/src/PubSub.js
CHANGED
|
@@ -1,14 +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";
|
|
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";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { PerspectiveProxy } from "./perspectives/PerspectiveProxy";
|
|
2
|
-
export declare const SMART_LITERAL_CONTENT_PREDICATE = "smart_literal://content";
|
|
3
|
-
export declare class SmartLiteral {
|
|
4
|
-
#private;
|
|
5
|
-
constructor(perspective: PerspectiveProxy, base: string);
|
|
6
|
-
get base(): string;
|
|
7
|
-
static create(perspective: PerspectiveProxy, literal: any): Promise<SmartLiteral>;
|
|
8
|
-
static isSmartLiteralBase(perspective: PerspectiveProxy, base: string): Promise<boolean>;
|
|
9
|
-
static getAllSmartLiterals(perspective: PerspectiveProxy): Promise<SmartLiteral[]>;
|
|
10
|
-
get(): Promise<any>;
|
|
11
|
-
set(content: any): Promise<void>;
|
|
12
|
-
}
|
|
1
|
+
import { PerspectiveProxy } from "./perspectives/PerspectiveProxy";
|
|
2
|
+
export declare const SMART_LITERAL_CONTENT_PREDICATE = "smart_literal://content";
|
|
3
|
+
export declare class SmartLiteral {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(perspective: PerspectiveProxy, base: string);
|
|
6
|
+
get base(): string;
|
|
7
|
+
static create(perspective: PerspectiveProxy, literal: any): Promise<SmartLiteral>;
|
|
8
|
+
static isSmartLiteralBase(perspective: PerspectiveProxy, base: string): Promise<boolean>;
|
|
9
|
+
static getAllSmartLiterals(perspective: PerspectiveProxy): Promise<SmartLiteral[]>;
|
|
10
|
+
get(): Promise<any>;
|
|
11
|
+
set(content: any): Promise<void>;
|
|
12
|
+
}
|
package/lib/src/SmartLiteral.js
CHANGED
|
@@ -1,74 +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();
|
|
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();
|
package/lib/src/agent/Agent.d.ts
CHANGED
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
import { Perspective } from "../perspectives/Perspective";
|
|
2
|
-
/** AD4M's representation of an Agent
|
|
3
|
-
*
|
|
4
|
-
* AD4M Agents are build around DIDs, which are used to identify and authenticate the Agent.
|
|
5
|
-
* Conceptually, an Agent is regarded as something that can speak and that can listen.
|
|
6
|
-
*
|
|
7
|
-
* Agents speak by creating Expressions in AD4M Languages which are signed by the Agent's DID key,
|
|
8
|
-
* And they also speak (broadcast) by putting semantic statements into their public "Agent Perspective".
|
|
9
|
-
* They listen (can receive messages) through their "direct message Language".
|
|
10
|
-
*
|
|
11
|
-
* These three aspects are represented by the three fields of this class.
|
|
12
|
-
*
|
|
13
|
-
* This class is used as format for the Expressions in the Agent language.
|
|
14
|
-
* Since AD4M treats DID URIs as addresses for the Agent Language,
|
|
15
|
-
* DIDs are resolved to Expressions that are objects of this class.
|
|
16
|
-
* Thus, this is how agents see (other) agents.
|
|
17
|
-
*/
|
|
18
|
-
export declare class Agent {
|
|
19
|
-
/** The DID of the Agent
|
|
20
|
-
* All epxressions authored by them are signed with the keys mentioned
|
|
21
|
-
* in the DID document behind this DID URI.
|
|
22
|
-
*/
|
|
23
|
-
did: string;
|
|
24
|
-
/** The Perspective that holds the public-facing semantics/statements of the Agent
|
|
25
|
-
* Holds and shares a Perspective that links all information
|
|
26
|
-
* this agent wants to offer as public-facing semantics.
|
|
27
|
-
* This should be used for any kind of user profile information.
|
|
28
|
-
*/
|
|
29
|
-
perspective?: Perspective;
|
|
30
|
-
/** Address of the Language by which the Agent will receive DMs */
|
|
31
|
-
directMessageLanguage?: string;
|
|
32
|
-
constructor(did: string, perspective?: Perspective);
|
|
33
|
-
}
|
|
34
|
-
declare const AgentExpression_base: any;
|
|
35
|
-
export declare class AgentExpression extends AgentExpression_base {
|
|
36
|
-
}
|
|
37
|
-
export declare class EntanglementProof {
|
|
38
|
-
did: string;
|
|
39
|
-
didSigningKeyId: string;
|
|
40
|
-
deviceKeyType: string;
|
|
41
|
-
deviceKey: string;
|
|
42
|
-
deviceKeySignedByDid: string;
|
|
43
|
-
didSignedByDeviceKey?: string;
|
|
44
|
-
constructor(did: string, didSigningKeyId: string, deviceKeyType: string, deviceKey: string, deviceKeySignedByDid: string, didSignedByDeviceKey?: string);
|
|
45
|
-
}
|
|
46
|
-
export declare class EntanglementProofInput {
|
|
47
|
-
did: string;
|
|
48
|
-
didSigningKeyId: string;
|
|
49
|
-
deviceKeyType: string;
|
|
50
|
-
deviceKey: string;
|
|
51
|
-
deviceKeySignedByDid: string;
|
|
52
|
-
didSignedByDeviceKey: string;
|
|
53
|
-
constructor(did: string, didSigningKeyId: string, deviceKeyType: string, deviceKey: string, deviceKeySignedByDid: string, didSignedByDeviceKey: string);
|
|
54
|
-
}
|
|
55
|
-
export declare class AgentSignature {
|
|
56
|
-
signature: string;
|
|
57
|
-
publicKey: string;
|
|
58
|
-
constructor(signature: string, publicKey: string);
|
|
59
|
-
}
|
|
60
|
-
export declare class Resource {
|
|
61
|
-
domain: string;
|
|
62
|
-
pointers: string[];
|
|
63
|
-
constructor(domain: string, pointers: string[]);
|
|
64
|
-
}
|
|
65
|
-
export declare class Capability {
|
|
66
|
-
with: Resource;
|
|
67
|
-
can: string[];
|
|
68
|
-
constructor(withF: Resource, can: string[]);
|
|
69
|
-
}
|
|
70
|
-
export declare class AuthInfo {
|
|
71
|
-
appName: string;
|
|
72
|
-
appDesc: string;
|
|
73
|
-
appUrl: string;
|
|
74
|
-
appIconPath?: string;
|
|
75
|
-
capabilities: Capability[];
|
|
76
|
-
constructor(appName: string, appDesc: string, appUrl: string, capabilities: Capability[], appIconPath?: string);
|
|
77
|
-
}
|
|
78
|
-
export declare class Apps {
|
|
79
|
-
requestId: string;
|
|
80
|
-
token: string;
|
|
81
|
-
revoked?: boolean;
|
|
82
|
-
auth: AuthInfo;
|
|
83
|
-
constructor(requestId: string, auth: AuthInfo, token: string, revoked?: boolean);
|
|
84
|
-
}
|
|
85
|
-
export declare class ResourceInput {
|
|
86
|
-
domain: string;
|
|
87
|
-
pointers: string[];
|
|
88
|
-
constructor(domain: string, pointers: string[]);
|
|
89
|
-
}
|
|
90
|
-
export declare class CapabilityInput {
|
|
91
|
-
with: ResourceInput;
|
|
92
|
-
can: string[];
|
|
93
|
-
constructor(withF: ResourceInput, can: string[]);
|
|
94
|
-
}
|
|
95
|
-
export declare class AuthInfoInput {
|
|
96
|
-
appName: string;
|
|
97
|
-
appDesc: string;
|
|
98
|
-
appDomain: string;
|
|
99
|
-
appUrl?: string;
|
|
100
|
-
appIconPath?: string;
|
|
101
|
-
capabilities?: CapabilityInput[];
|
|
102
|
-
constructor(appName: string, appDesc: string, appDomain: string, appUrl?: string, appIconPath?: string, capabilities?: CapabilityInput[]);
|
|
103
|
-
}
|
|
104
|
-
export {};
|
|
1
|
+
import { Perspective } from "../perspectives/Perspective";
|
|
2
|
+
/** AD4M's representation of an Agent
|
|
3
|
+
*
|
|
4
|
+
* AD4M Agents are build around DIDs, which are used to identify and authenticate the Agent.
|
|
5
|
+
* Conceptually, an Agent is regarded as something that can speak and that can listen.
|
|
6
|
+
*
|
|
7
|
+
* Agents speak by creating Expressions in AD4M Languages which are signed by the Agent's DID key,
|
|
8
|
+
* And they also speak (broadcast) by putting semantic statements into their public "Agent Perspective".
|
|
9
|
+
* They listen (can receive messages) through their "direct message Language".
|
|
10
|
+
*
|
|
11
|
+
* These three aspects are represented by the three fields of this class.
|
|
12
|
+
*
|
|
13
|
+
* This class is used as format for the Expressions in the Agent language.
|
|
14
|
+
* Since AD4M treats DID URIs as addresses for the Agent Language,
|
|
15
|
+
* DIDs are resolved to Expressions that are objects of this class.
|
|
16
|
+
* Thus, this is how agents see (other) agents.
|
|
17
|
+
*/
|
|
18
|
+
export declare class Agent {
|
|
19
|
+
/** The DID of the Agent
|
|
20
|
+
* All epxressions authored by them are signed with the keys mentioned
|
|
21
|
+
* in the DID document behind this DID URI.
|
|
22
|
+
*/
|
|
23
|
+
did: string;
|
|
24
|
+
/** The Perspective that holds the public-facing semantics/statements of the Agent
|
|
25
|
+
* Holds and shares a Perspective that links all information
|
|
26
|
+
* this agent wants to offer as public-facing semantics.
|
|
27
|
+
* This should be used for any kind of user profile information.
|
|
28
|
+
*/
|
|
29
|
+
perspective?: Perspective;
|
|
30
|
+
/** Address of the Language by which the Agent will receive DMs */
|
|
31
|
+
directMessageLanguage?: string;
|
|
32
|
+
constructor(did: string, perspective?: Perspective);
|
|
33
|
+
}
|
|
34
|
+
declare const AgentExpression_base: any;
|
|
35
|
+
export declare class AgentExpression extends AgentExpression_base {
|
|
36
|
+
}
|
|
37
|
+
export declare class EntanglementProof {
|
|
38
|
+
did: string;
|
|
39
|
+
didSigningKeyId: string;
|
|
40
|
+
deviceKeyType: string;
|
|
41
|
+
deviceKey: string;
|
|
42
|
+
deviceKeySignedByDid: string;
|
|
43
|
+
didSignedByDeviceKey?: string;
|
|
44
|
+
constructor(did: string, didSigningKeyId: string, deviceKeyType: string, deviceKey: string, deviceKeySignedByDid: string, didSignedByDeviceKey?: string);
|
|
45
|
+
}
|
|
46
|
+
export declare class EntanglementProofInput {
|
|
47
|
+
did: string;
|
|
48
|
+
didSigningKeyId: string;
|
|
49
|
+
deviceKeyType: string;
|
|
50
|
+
deviceKey: string;
|
|
51
|
+
deviceKeySignedByDid: string;
|
|
52
|
+
didSignedByDeviceKey: string;
|
|
53
|
+
constructor(did: string, didSigningKeyId: string, deviceKeyType: string, deviceKey: string, deviceKeySignedByDid: string, didSignedByDeviceKey: string);
|
|
54
|
+
}
|
|
55
|
+
export declare class AgentSignature {
|
|
56
|
+
signature: string;
|
|
57
|
+
publicKey: string;
|
|
58
|
+
constructor(signature: string, publicKey: string);
|
|
59
|
+
}
|
|
60
|
+
export declare class Resource {
|
|
61
|
+
domain: string;
|
|
62
|
+
pointers: string[];
|
|
63
|
+
constructor(domain: string, pointers: string[]);
|
|
64
|
+
}
|
|
65
|
+
export declare class Capability {
|
|
66
|
+
with: Resource;
|
|
67
|
+
can: string[];
|
|
68
|
+
constructor(withF: Resource, can: string[]);
|
|
69
|
+
}
|
|
70
|
+
export declare class AuthInfo {
|
|
71
|
+
appName: string;
|
|
72
|
+
appDesc: string;
|
|
73
|
+
appUrl: string;
|
|
74
|
+
appIconPath?: string;
|
|
75
|
+
capabilities: Capability[];
|
|
76
|
+
constructor(appName: string, appDesc: string, appUrl: string, capabilities: Capability[], appIconPath?: string);
|
|
77
|
+
}
|
|
78
|
+
export declare class Apps {
|
|
79
|
+
requestId: string;
|
|
80
|
+
token: string;
|
|
81
|
+
revoked?: boolean;
|
|
82
|
+
auth: AuthInfo;
|
|
83
|
+
constructor(requestId: string, auth: AuthInfo, token: string, revoked?: boolean);
|
|
84
|
+
}
|
|
85
|
+
export declare class ResourceInput {
|
|
86
|
+
domain: string;
|
|
87
|
+
pointers: string[];
|
|
88
|
+
constructor(domain: string, pointers: string[]);
|
|
89
|
+
}
|
|
90
|
+
export declare class CapabilityInput {
|
|
91
|
+
with: ResourceInput;
|
|
92
|
+
can: string[];
|
|
93
|
+
constructor(withF: ResourceInput, can: string[]);
|
|
94
|
+
}
|
|
95
|
+
export declare class AuthInfoInput {
|
|
96
|
+
appName: string;
|
|
97
|
+
appDesc: string;
|
|
98
|
+
appDomain: string;
|
|
99
|
+
appUrl?: string;
|
|
100
|
+
appIconPath?: string;
|
|
101
|
+
capabilities?: CapabilityInput[];
|
|
102
|
+
constructor(appName: string, appDesc: string, appDomain: string, appUrl?: string, appIconPath?: string, capabilities?: CapabilityInput[]);
|
|
103
|
+
}
|
|
104
|
+
export {};
|