@coasys/ad4m 0.12.0-rc1-dev.2 → 0.12.0-rc1-dev.4
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/jest.config.js +10 -3
- package/lib/index.cjs +6893 -5884
- package/lib/index.js +6889 -5872
- package/lib/src/Ad4mClient.d.ts +9 -16
- package/lib/src/Ad4mClient.js +46 -25
- package/lib/src/Literal.d.ts +1 -2
- package/lib/src/Literal.js +38 -35
- package/lib/src/SmartLiteral.d.ts +1 -2
- package/lib/src/SmartLiteral.js +30 -15
- package/lib/src/agent/AgentClient.d.ts +1 -4
- package/lib/src/agent/AgentClient.js +79 -99
- package/lib/src/ai/AIClient.d.ts +1 -2
- package/lib/src/ai/AIClient.js +224 -220
- package/lib/src/expression/ExpressionClient.d.ts +1 -1
- package/lib/src/expression/ExpressionClient.js +73 -86
- package/lib/src/index.d.ts +1 -1
- package/lib/src/index.js +1 -1
- package/lib/src/language/LanguageClient.d.ts +1 -1
- package/lib/src/language/LanguageClient.js +52 -52
- package/lib/src/model/Ad4mModel.d.ts +1351 -144
- package/lib/src/model/Ad4mModel.js +3760 -228
- package/lib/src/model/Ad4mModel.test.js +522 -979
- package/lib/src/model/Subject.d.ts +3 -3
- package/lib/src/model/Subject.js +25 -25
- package/lib/src/model/decorators.d.ts +444 -100
- package/lib/src/model/decorators.js +686 -321
- package/lib/src/model/util.d.ts +6 -6
- package/lib/src/model/util.js +24 -24
- package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +1 -5
- package/lib/src/neighbourhood/NeighbourhoodClient.js +179 -242
- package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +1 -2
- package/lib/src/neighbourhood/NeighbourhoodProxy.js +28 -13
- package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +5 -1
- package/lib/src/perspectives/PerspectiveClient.d.ts +9 -9
- package/lib/src/perspectives/PerspectiveClient.js +240 -316
- package/lib/src/perspectives/PerspectiveProxy.d.ts +99 -61
- package/lib/src/perspectives/PerspectiveProxy.js +485 -832
- package/lib/src/runtime/RuntimeClient.d.ts +1 -5
- package/lib/src/runtime/RuntimeClient.js +238 -412
- package/lib/src/shacl/SHACLFlow.test.js +105 -164
- package/lib/src/shacl/SHACLShape.d.ts +12 -17
- package/lib/src/shacl/SHACLShape.js +115 -128
- package/lib/src/shacl/SHACLShape.test.js +176 -244
- package/lib/src/shims/reflect-metadata.d.ts +0 -0
- package/lib/src/shims/type-graphql.d.ts +32 -0
- package/lib/src/src/Ad4mClient.d.ts +28 -0
- package/lib/src/src/Address.d.ts +1 -0
- package/lib/src/src/DID.d.ts +1 -0
- package/lib/src/src/Exception.d.ts +7 -0
- package/lib/src/src/Literal.d.ts +7 -0
- package/lib/src/src/PubSub.d.ts +17 -0
- package/lib/src/src/SmartLiteral.d.ts +12 -0
- package/lib/src/src/agent/Agent.d.ts +110 -0
- package/lib/src/src/agent/AgentClient.d.ts +62 -0
- package/lib/src/src/agent/AgentResolver.d.ts +30 -0
- package/lib/src/src/agent/AgentStatus.d.ts +8 -0
- package/lib/src/src/ai/AIClient.d.ts +32 -0
- package/lib/src/src/ai/AIResolver.d.ts +75 -0
- package/lib/src/src/ai/Tasks.d.ts +37 -0
- package/lib/src/src/buildSchema.d.ts +1 -0
- package/lib/src/src/expression/Expression.d.ts +28 -0
- package/lib/src/src/expression/ExpressionClient.d.ts +13 -0
- package/lib/src/src/expression/ExpressionRef.d.ts +9 -0
- package/lib/src/src/expression/ExpressionResolver.d.ts +10 -0
- package/lib/src/src/index.d.ts +35 -0
- package/lib/src/src/jestSetup.d.ts +1 -0
- package/lib/src/src/language/Icon.d.ts +4 -0
- package/lib/src/src/language/Language.d.ts +206 -0
- package/lib/src/src/language/LanguageClient.d.ts +17 -0
- package/lib/src/src/language/LanguageContext.d.ts +37 -0
- package/lib/src/src/language/LanguageHandle.d.ts +9 -0
- package/lib/src/src/language/LanguageMeta.d.ts +35 -0
- package/lib/src/src/language/LanguageRef.d.ts +6 -0
- package/lib/src/src/language/LanguageResolver.d.ts +19 -0
- package/lib/src/src/links/Links.d.ts +39 -0
- package/lib/src/src/links/Links.test.d.ts +1 -0
- package/lib/src/src/model/Ad4mModel.d.ts +1438 -0
- package/lib/src/src/model/Ad4mModel.test.d.ts +1 -0
- package/lib/src/src/model/Subject.d.ts +25 -0
- package/lib/src/src/model/decorators.d.ts +545 -0
- package/lib/src/src/model/util.d.ts +12 -0
- package/lib/src/src/neighbourhood/Neighbourhood.d.ts +10 -0
- package/lib/src/src/neighbourhood/NeighbourhoodClient.d.ts +25 -0
- package/lib/src/src/neighbourhood/NeighbourhoodProxy.d.ts +19 -0
- package/lib/src/src/neighbourhood/NeighbourhoodProxy.test.d.ts +1 -0
- package/lib/src/src/neighbourhood/NeighbourhoodResolver.d.ts +24 -0
- package/lib/src/src/perspectives/LinkQuery.d.ts +11 -0
- package/lib/src/src/perspectives/Perspective.d.ts +38 -0
- package/lib/src/src/perspectives/Perspective.test.d.ts +1 -0
- package/lib/src/src/perspectives/PerspectiveClient.d.ts +97 -0
- package/lib/src/src/perspectives/PerspectiveDiff.d.ts +9 -0
- package/lib/src/src/perspectives/PerspectiveHandle.d.ts +18 -0
- package/lib/src/src/perspectives/PerspectiveProxy.d.ts +865 -0
- package/lib/src/src/perspectives/PerspectiveResolver.d.ts +57 -0
- package/lib/src/src/runtime/RuntimeClient.d.ts +56 -0
- package/lib/src/src/runtime/RuntimeResolver.d.ts +132 -0
- package/lib/src/src/shacl/SHACLFlow.d.ts +171 -0
- package/lib/src/src/shacl/SHACLFlow.test.d.ts +1 -0
- package/lib/src/src/shacl/SHACLShape.d.ts +117 -0
- package/lib/src/src/shacl/SHACLShape.test.d.ts +1 -0
- package/lib/src/src/typeDefs.d.ts +1 -0
- package/lib/src/src/unwrapApolloResult.d.ts +2 -0
- package/lib/src/src/utils.d.ts +25 -0
- package/lib/src/utils.d.ts +0 -8
- package/lib/src/utils.js +7 -21
- package/package.json +15 -14
- package/src/Ad4mClient.test.ts +1315 -1564
- package/src/Ad4mClient.ts +54 -55
- package/src/Literal.test.ts +26 -45
- package/src/Literal.ts +66 -82
- package/src/SmartLiteral.ts +58 -74
- package/src/agent/AgentClient.ts +99 -144
- package/src/ai/AIClient.ts +359 -409
- package/src/expression/ExpressionClient.ts +96 -142
- package/src/index.ts +1 -1
- package/src/language/LanguageClient.ts +113 -137
- package/src/model/Ad4mModel.test.ts +616 -1114
- package/src/model/Ad4mModel.ts +4386 -451
- package/src/model/Subject.ts +159 -0
- package/src/model/decorators.ts +1168 -667
- package/src/model/util.ts +54 -53
- package/src/neighbourhood/NeighbourhoodClient.ts +266 -392
- package/src/neighbourhood/NeighbourhoodProxy.test.ts +7 -3
- package/src/neighbourhood/NeighbourhoodProxy.ts +40 -58
- package/src/perspectives/PerspectiveClient.ts +540 -779
- package/src/perspectives/PerspectiveProxy.ts +2067 -2860
- package/src/runtime/RuntimeClient.ts +476 -775
- package/src/shacl/SHACLFlow.test.ts +129 -196
- package/src/shacl/SHACLShape.test.ts +190 -284
- package/src/shacl/SHACLShape.ts +200 -224
- package/src/utils.ts +17 -31
- package/tsconfig.json +10 -9
- package/src/model/IMPROVEMENTS.md +0 -482
- package/src/model/PREDICATE_COLLISION_FIX.md +0 -651
- package/src/model/README.md +0 -317
- package/src/model/SHACL_MUTATION_DECOUPLING.md +0 -356
- package/src/model/SUBSCRIPTION_STRATEGY.md +0 -317
- package/src/model/TC39_STAGE_3_DECORATORS.md +0 -609
- package/src/model/mutation.ts +0 -461
- package/src/model/parentUtils.ts +0 -91
- package/src/model/prolog/generatePrologFacts.ts +0 -176
- package/src/model/prolog/index.ts +0 -1
- package/src/model/query/ModelQueryBuilder.ts +0 -173
- package/src/model/query/fetchInstance.ts +0 -181
- package/src/model/query/hydration.ts +0 -273
- package/src/model/query/operations.ts +0 -510
- package/src/model/query/snapshot.ts +0 -126
- package/src/model/query/surrealCompiler.ts +0 -376
- package/src/model/schema/fromJSONSchema.ts +0 -411
- package/src/model/schema/metadata.ts +0 -148
- package/src/model/subscription.ts +0 -307
- package/src/model/transaction.ts +0 -60
- package/src/model/types.ts +0 -207
package/lib/src/Ad4mClient.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ApolloClient } from
|
|
2
|
-
import { AgentClient } from
|
|
3
|
-
import { LanguageClient } from
|
|
4
|
-
import { NeighbourhoodClient } from
|
|
5
|
-
import { PerspectiveClient } from
|
|
6
|
-
import { RuntimeClient } from
|
|
7
|
-
import { ExpressionClient } from
|
|
8
|
-
import { AIClient } from
|
|
1
|
+
import { ApolloClient } from '@apollo/client/core';
|
|
2
|
+
import { AgentClient } from './agent/AgentClient';
|
|
3
|
+
import { LanguageClient } from './language/LanguageClient';
|
|
4
|
+
import { NeighbourhoodClient } from './neighbourhood/NeighbourhoodClient';
|
|
5
|
+
import { PerspectiveClient } from './perspectives/PerspectiveClient';
|
|
6
|
+
import { RuntimeClient } from './runtime/RuntimeClient';
|
|
7
|
+
import { ExpressionClient } from './expression/ExpressionClient';
|
|
8
|
+
import { AIClient } from './ai/AIClient';
|
|
9
9
|
/**
|
|
10
10
|
* Client for the Ad4m interface wrapping GraphQL queryies
|
|
11
11
|
* for convenient use in user facing code.
|
|
@@ -16,14 +16,7 @@ import { AIClient } from "./ai/AIClient";
|
|
|
16
16
|
* for the respective functionality.
|
|
17
17
|
*/
|
|
18
18
|
export declare class Ad4mClient {
|
|
19
|
-
private
|
|
20
|
-
private _agentClient;
|
|
21
|
-
private _expressionClient;
|
|
22
|
-
private _languageClient;
|
|
23
|
-
private _neighbourhoodClient;
|
|
24
|
-
private _perspectiveClient;
|
|
25
|
-
private _runtimeClient;
|
|
26
|
-
private _aiClient;
|
|
19
|
+
#private;
|
|
27
20
|
constructor(client: ApolloClient<any>, subscribe?: boolean);
|
|
28
21
|
get agent(): AgentClient;
|
|
29
22
|
get expression(): ExpressionClient;
|
package/lib/src/Ad4mClient.js
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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, _Ad4mClient_aiClient;
|
|
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
|
+
import { AIClient } from './ai/AIClient';
|
|
8
20
|
/**
|
|
9
21
|
* Client for the Ad4m interface wrapping GraphQL queryies
|
|
10
22
|
* for convenient use in user facing code.
|
|
@@ -16,37 +28,46 @@ import { AIClient } from "./ai/AIClient";
|
|
|
16
28
|
*/
|
|
17
29
|
export class Ad4mClient {
|
|
18
30
|
constructor(client, subscribe = true) {
|
|
19
|
-
this
|
|
20
|
-
|
|
21
|
-
this
|
|
22
|
-
this
|
|
23
|
-
this
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this
|
|
29
|
-
this
|
|
31
|
+
_Ad4mClient_apolloClient.set(this, void 0);
|
|
32
|
+
_Ad4mClient_agentClient.set(this, void 0);
|
|
33
|
+
_Ad4mClient_expressionClient.set(this, void 0);
|
|
34
|
+
_Ad4mClient_languageClient.set(this, void 0);
|
|
35
|
+
_Ad4mClient_neighbourhoodClient.set(this, void 0);
|
|
36
|
+
_Ad4mClient_perspectiveClient.set(this, void 0);
|
|
37
|
+
_Ad4mClient_runtimeClient.set(this, void 0);
|
|
38
|
+
_Ad4mClient_aiClient.set(this, void 0);
|
|
39
|
+
__classPrivateFieldSet(this, _Ad4mClient_apolloClient, client, "f");
|
|
40
|
+
__classPrivateFieldSet(this, _Ad4mClient_agentClient, new AgentClient(__classPrivateFieldGet(this, _Ad4mClient_apolloClient, "f"), subscribe), "f");
|
|
41
|
+
__classPrivateFieldSet(this, _Ad4mClient_expressionClient, new ExpressionClient(__classPrivateFieldGet(this, _Ad4mClient_apolloClient, "f")), "f");
|
|
42
|
+
__classPrivateFieldSet(this, _Ad4mClient_languageClient, new LanguageClient(__classPrivateFieldGet(this, _Ad4mClient_apolloClient, "f")), "f");
|
|
43
|
+
__classPrivateFieldSet(this, _Ad4mClient_neighbourhoodClient, new NeighbourhoodClient(__classPrivateFieldGet(this, _Ad4mClient_apolloClient, "f")), "f");
|
|
44
|
+
__classPrivateFieldSet(this, _Ad4mClient_aiClient, new AIClient(__classPrivateFieldGet(this, _Ad4mClient_apolloClient, "f"), subscribe), "f");
|
|
45
|
+
__classPrivateFieldSet(this, _Ad4mClient_perspectiveClient, new PerspectiveClient(__classPrivateFieldGet(this, _Ad4mClient_apolloClient, "f"), subscribe), "f");
|
|
46
|
+
__classPrivateFieldGet(this, _Ad4mClient_perspectiveClient, "f").setExpressionClient(__classPrivateFieldGet(this, _Ad4mClient_expressionClient, "f"));
|
|
47
|
+
__classPrivateFieldGet(this, _Ad4mClient_perspectiveClient, "f").setNeighbourhoodClient(__classPrivateFieldGet(this, _Ad4mClient_neighbourhoodClient, "f"));
|
|
48
|
+
__classPrivateFieldGet(this, _Ad4mClient_perspectiveClient, "f").setAIClient(__classPrivateFieldGet(this, _Ad4mClient_aiClient, "f"));
|
|
49
|
+
__classPrivateFieldSet(this, _Ad4mClient_runtimeClient, new RuntimeClient(__classPrivateFieldGet(this, _Ad4mClient_apolloClient, "f"), subscribe), "f");
|
|
30
50
|
}
|
|
31
51
|
get agent() {
|
|
32
|
-
return this
|
|
52
|
+
return __classPrivateFieldGet(this, _Ad4mClient_agentClient, "f");
|
|
33
53
|
}
|
|
34
54
|
get expression() {
|
|
35
|
-
return this
|
|
55
|
+
return __classPrivateFieldGet(this, _Ad4mClient_expressionClient, "f");
|
|
36
56
|
}
|
|
37
57
|
get languages() {
|
|
38
|
-
return this
|
|
58
|
+
return __classPrivateFieldGet(this, _Ad4mClient_languageClient, "f");
|
|
39
59
|
}
|
|
40
60
|
get neighbourhood() {
|
|
41
|
-
return this
|
|
61
|
+
return __classPrivateFieldGet(this, _Ad4mClient_neighbourhoodClient, "f");
|
|
42
62
|
}
|
|
43
63
|
get perspective() {
|
|
44
|
-
return this
|
|
64
|
+
return __classPrivateFieldGet(this, _Ad4mClient_perspectiveClient, "f");
|
|
45
65
|
}
|
|
46
66
|
get runtime() {
|
|
47
|
-
return this
|
|
67
|
+
return __classPrivateFieldGet(this, _Ad4mClient_runtimeClient, "f");
|
|
48
68
|
}
|
|
49
69
|
get ai() {
|
|
50
|
-
return this
|
|
70
|
+
return __classPrivateFieldGet(this, _Ad4mClient_aiClient, "f");
|
|
51
71
|
}
|
|
52
72
|
}
|
|
73
|
+
_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(), _Ad4mClient_aiClient = new WeakMap();
|
package/lib/src/Literal.d.ts
CHANGED
package/lib/src/Literal.js
CHANGED
|
@@ -1,57 +1,67 @@
|
|
|
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;
|
|
1
13
|
function encodeRFC3986URIComponent(str) {
|
|
2
|
-
return encodeURIComponent(str)
|
|
14
|
+
return encodeURIComponent(str)
|
|
15
|
+
.replace(/[!'()*]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
3
16
|
}
|
|
4
17
|
export class Literal {
|
|
18
|
+
constructor() {
|
|
19
|
+
_Literal_literal.set(this, void 0);
|
|
20
|
+
_Literal_url.set(this, void 0);
|
|
21
|
+
}
|
|
5
22
|
static fromUrl(url) {
|
|
6
23
|
if (!url || !url.startsWith("literal://"))
|
|
7
24
|
throw new Error("Can't create Literal from non-literal URL");
|
|
8
25
|
const l = new Literal();
|
|
9
|
-
l
|
|
26
|
+
__classPrivateFieldSet(l, _Literal_url, url, "f");
|
|
10
27
|
return l;
|
|
11
28
|
}
|
|
12
29
|
static from(literal) {
|
|
13
30
|
const l = new Literal();
|
|
14
|
-
l
|
|
31
|
+
__classPrivateFieldSet(l, _Literal_literal, literal, "f");
|
|
15
32
|
return l;
|
|
16
33
|
}
|
|
17
34
|
toUrl() {
|
|
18
|
-
if (this
|
|
19
|
-
return this
|
|
20
|
-
if (!this
|
|
21
|
-
(this._literal === undefined ||
|
|
22
|
-
this._literal === "" ||
|
|
23
|
-
this._literal === null))
|
|
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") === undefined || __classPrivateFieldGet(this, _Literal_literal, "f") === "" || __classPrivateFieldGet(this, _Literal_literal, "f") === null))
|
|
24
38
|
throw new Error("Can't turn empty Literal into URL");
|
|
25
39
|
let encoded;
|
|
26
|
-
switch (typeof this
|
|
27
|
-
case
|
|
28
|
-
encoded = `string:${encodeRFC3986URIComponent(this
|
|
40
|
+
switch (typeof __classPrivateFieldGet(this, _Literal_literal, "f")) {
|
|
41
|
+
case 'string':
|
|
42
|
+
encoded = `string:${encodeRFC3986URIComponent(__classPrivateFieldGet(this, _Literal_literal, "f"))}`;
|
|
29
43
|
break;
|
|
30
|
-
case
|
|
31
|
-
encoded = `number:${encodeRFC3986URIComponent(this
|
|
44
|
+
case 'number':
|
|
45
|
+
encoded = `number:${encodeRFC3986URIComponent(__classPrivateFieldGet(this, _Literal_literal, "f"))}`;
|
|
32
46
|
break;
|
|
33
|
-
case
|
|
34
|
-
encoded = `boolean:${encodeRFC3986URIComponent(this
|
|
47
|
+
case 'boolean':
|
|
48
|
+
encoded = `boolean:${encodeRFC3986URIComponent(__classPrivateFieldGet(this, _Literal_literal, "f"))}`;
|
|
35
49
|
break;
|
|
36
|
-
case
|
|
37
|
-
encoded = `json:${encodeRFC3986URIComponent(JSON.stringify(this
|
|
50
|
+
case 'object':
|
|
51
|
+
encoded = `json:${encodeRFC3986URIComponent(JSON.stringify(__classPrivateFieldGet(this, _Literal_literal, "f")))}`;
|
|
38
52
|
break;
|
|
39
|
-
default:
|
|
40
|
-
throw new Error(`Literal.toUrl(): unsupported type "${typeof this._literal}" (value: ${String(this._literal)})`);
|
|
41
53
|
}
|
|
42
54
|
return `literal://${encoded}`;
|
|
43
55
|
}
|
|
44
56
|
get() {
|
|
45
|
-
if (this
|
|
46
|
-
this
|
|
47
|
-
|
|
48
|
-
return this._literal;
|
|
49
|
-
if (!this._url)
|
|
57
|
+
if (__classPrivateFieldGet(this, _Literal_literal, "f"))
|
|
58
|
+
return __classPrivateFieldGet(this, _Literal_literal, "f");
|
|
59
|
+
if (!__classPrivateFieldGet(this, _Literal_url, "f"))
|
|
50
60
|
throw new Error("Can't render empty Literal");
|
|
51
|
-
if (!this.
|
|
61
|
+
if (!__classPrivateFieldGet(this, _Literal_url, "f").startsWith("literal://"))
|
|
52
62
|
throw new Error("Can't render Literal from non-literal URL");
|
|
53
63
|
// get rid of "literal://"
|
|
54
|
-
const body = this.
|
|
64
|
+
const body = __classPrivateFieldGet(this, _Literal_url, "f").substring(10);
|
|
55
65
|
if (body.startsWith("string:")) {
|
|
56
66
|
return decodeURIComponent(body.substring(7));
|
|
57
67
|
}
|
|
@@ -59,14 +69,6 @@ export class Literal {
|
|
|
59
69
|
const numberString = body.substring(7);
|
|
60
70
|
return parseFloat(numberString);
|
|
61
71
|
}
|
|
62
|
-
if (body.startsWith("boolean:")) {
|
|
63
|
-
const boolStr = body.substring(8).trim();
|
|
64
|
-
if (boolStr === "true")
|
|
65
|
-
return true;
|
|
66
|
-
if (boolStr === "false")
|
|
67
|
-
return false;
|
|
68
|
-
throw new Error(`Literal.get(): malformed boolean payload "${boolStr}" — expected "true" or "false"`);
|
|
69
|
-
}
|
|
70
72
|
if (body.startsWith("json:")) {
|
|
71
73
|
const json = body.substring(5);
|
|
72
74
|
return JSON.parse(decodeURIComponent(json));
|
|
@@ -74,3 +76,4 @@ export class Literal {
|
|
|
74
76
|
throw new Error(`Can't parse unknown literal: ${body}`);
|
|
75
77
|
}
|
|
76
78
|
}
|
|
79
|
+
_Literal_literal = new WeakMap(), _Literal_url = new WeakMap();
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { PerspectiveProxy } from "./perspectives/PerspectiveProxy";
|
|
2
2
|
export declare const SMART_LITERAL_CONTENT_PREDICATE = "smart_literal://content";
|
|
3
3
|
export declare class SmartLiteral {
|
|
4
|
-
private
|
|
5
|
-
private _base;
|
|
4
|
+
#private;
|
|
6
5
|
constructor(perspective: PerspectiveProxy, base: string);
|
|
7
6
|
get base(): string;
|
|
8
7
|
static create(perspective: PerspectiveProxy, literal: any): Promise<SmartLiteral>;
|
package/lib/src/SmartLiteral.js
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
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;
|
|
1
13
|
import { Link } from "./links/Links";
|
|
2
14
|
import { Literal } from "./Literal";
|
|
3
15
|
import { LinkQuery } from "./perspectives/LinkQuery";
|
|
4
16
|
export const SMART_LITERAL_CONTENT_PREDICATE = "smart_literal://content";
|
|
5
17
|
function makeRandomStringID(length) {
|
|
6
|
-
let result =
|
|
7
|
-
let characters =
|
|
18
|
+
let result = '';
|
|
19
|
+
let characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
8
20
|
let charactersLength = characters.length;
|
|
9
21
|
for (let i = 0; i < length; i++) {
|
|
10
22
|
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
@@ -13,11 +25,13 @@ function makeRandomStringID(length) {
|
|
|
13
25
|
}
|
|
14
26
|
export class SmartLiteral {
|
|
15
27
|
constructor(perspective, base) {
|
|
16
|
-
this
|
|
17
|
-
this
|
|
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");
|
|
18
32
|
}
|
|
19
33
|
get base() {
|
|
20
|
-
return this
|
|
34
|
+
return __classPrivateFieldGet(this, _SmartLiteral_base, "f");
|
|
21
35
|
}
|
|
22
36
|
static async create(perspective, literal) {
|
|
23
37
|
const base = Literal.from(makeRandomStringID(10)).toUrl();
|
|
@@ -28,32 +42,33 @@ export class SmartLiteral {
|
|
|
28
42
|
static async isSmartLiteralBase(perspective, base) {
|
|
29
43
|
let links = await perspective.get(new LinkQuery({
|
|
30
44
|
source: base,
|
|
31
|
-
predicate: SMART_LITERAL_CONTENT_PREDICATE
|
|
45
|
+
predicate: SMART_LITERAL_CONTENT_PREDICATE
|
|
32
46
|
}));
|
|
33
47
|
return links.length > 0;
|
|
34
48
|
}
|
|
35
49
|
static async getAllSmartLiterals(perspective) {
|
|
36
50
|
let links = await perspective.get(new LinkQuery({
|
|
37
|
-
predicate: SMART_LITERAL_CONTENT_PREDICATE
|
|
51
|
+
predicate: SMART_LITERAL_CONTENT_PREDICATE
|
|
38
52
|
}));
|
|
39
|
-
return links.map(
|
|
53
|
+
return links.map(link => new SmartLiteral(perspective, link.data.source));
|
|
40
54
|
}
|
|
41
55
|
async get() {
|
|
42
|
-
let link = await this.
|
|
43
|
-
source: this
|
|
44
|
-
predicate: SMART_LITERAL_CONTENT_PREDICATE
|
|
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
|
|
45
59
|
}));
|
|
46
60
|
if (!link) {
|
|
47
|
-
throw `No content for smart literal ${this
|
|
61
|
+
throw `No content for smart literal ${__classPrivateFieldGet(this, _SmartLiteral_base, "f")}`;
|
|
48
62
|
}
|
|
49
63
|
return Literal.fromUrl(link).get();
|
|
50
64
|
}
|
|
51
65
|
async set(content) {
|
|
52
66
|
let literal = Literal.from(content);
|
|
53
|
-
await this.
|
|
54
|
-
source: this
|
|
67
|
+
await __classPrivateFieldGet(this, _SmartLiteral_perspective, "f").setSingleTarget(new Link({
|
|
68
|
+
source: __classPrivateFieldGet(this, _SmartLiteral_base, "f"),
|
|
55
69
|
predicate: SMART_LITERAL_CONTENT_PREDICATE,
|
|
56
|
-
target: literal.toUrl()
|
|
70
|
+
target: literal.toUrl()
|
|
57
71
|
}));
|
|
58
72
|
}
|
|
59
73
|
}
|
|
74
|
+
_SmartLiteral_perspective = new WeakMap(), _SmartLiteral_base = new WeakMap();
|
|
@@ -19,10 +19,7 @@ export type AgentAppsUpdatedCallback = () => null;
|
|
|
19
19
|
* as well as updating the publicly shared Agent expression.
|
|
20
20
|
*/
|
|
21
21
|
export declare class AgentClient {
|
|
22
|
-
private
|
|
23
|
-
private _appsChangedCallback;
|
|
24
|
-
private _updatedCallbacks;
|
|
25
|
-
private _agentStatusChangedCallbacks;
|
|
22
|
+
#private;
|
|
26
23
|
constructor(client: ApolloClient<any>, subscribe?: boolean);
|
|
27
24
|
/**
|
|
28
25
|
* Returns the Agent expression of the local agent as it is shared
|