@coasys/ad4m 0.12.0-rc1-dev.2 → 0.12.0-rc1-dev.3
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 +6872 -5886
- package/lib/index.js +6868 -5874
- 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 +3737 -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 +4361 -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/model/util.d.ts
CHANGED
|
@@ -3,10 +3,10 @@ export declare function propertyNameToSetterName(property: string): string;
|
|
|
3
3
|
export declare function setterNameToPropertyName(setter: string): string;
|
|
4
4
|
export declare function singularToPlural(singular: string): string;
|
|
5
5
|
export declare function pluralToSingular(plural: string): string;
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function
|
|
6
|
+
export declare function relationToAdderName(relation: string): string;
|
|
7
|
+
export declare function relationAdderToName(adderName: string): string;
|
|
8
|
+
export declare function relationToRemoverName(relation: string): string;
|
|
9
|
+
export declare function relationRemoverToName(removerName: string): string;
|
|
10
|
+
export declare function relationSetterToName(setterName: string): string;
|
|
11
|
+
export declare function relationToSetterName(relation: string): string;
|
|
12
12
|
export declare function stringifyObjectLiteral(obj: any): any;
|
package/lib/src/model/util.js
CHANGED
|
@@ -29,36 +29,36 @@ export function pluralToSingular(plural) {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
// e.g. "comments" -> "addComment"
|
|
32
|
-
export function
|
|
33
|
-
return `add${capitalize(pluralToSingular(
|
|
32
|
+
export function relationToAdderName(relation) {
|
|
33
|
+
return `add${capitalize(pluralToSingular(relation))}`;
|
|
34
34
|
}
|
|
35
35
|
// e.g. "addComments" -> "comments"
|
|
36
|
-
export function
|
|
37
|
-
// Extract the
|
|
38
|
-
// The method name already has the plural
|
|
39
|
-
let
|
|
40
|
-
return
|
|
36
|
+
export function relationAdderToName(adderName) {
|
|
37
|
+
// Extract the relation name after "add" and lowercase first char
|
|
38
|
+
// The method name already has the plural relation name (e.g., "addComments")
|
|
39
|
+
let relationName = adderName.substring(3);
|
|
40
|
+
return relationName.charAt(0).toLowerCase() + relationName.slice(1);
|
|
41
41
|
}
|
|
42
42
|
// e.g. "comments" -> "removeComment"
|
|
43
|
-
export function
|
|
44
|
-
return `remove${capitalize(pluralToSingular(
|
|
43
|
+
export function relationToRemoverName(relation) {
|
|
44
|
+
return `remove${capitalize(pluralToSingular(relation))}`;
|
|
45
45
|
}
|
|
46
|
-
// e.g. "removeComments" -> "comments"
|
|
47
|
-
export function
|
|
48
|
-
// Extract the
|
|
49
|
-
// The method name already has the plural
|
|
50
|
-
let
|
|
51
|
-
return
|
|
46
|
+
// e.g. "removeComments" -> "comments"
|
|
47
|
+
export function relationRemoverToName(removerName) {
|
|
48
|
+
// Extract the relation name after "remove" and lowercase first char
|
|
49
|
+
// The method name already has the plural relation name (e.g., "removeComments")
|
|
50
|
+
let relationName = removerName.substring(6);
|
|
51
|
+
return relationName.charAt(0).toLowerCase() + relationName.slice(1);
|
|
52
52
|
}
|
|
53
|
-
export function
|
|
54
|
-
// Extract the
|
|
55
|
-
// The method name has the plural
|
|
56
|
-
let
|
|
57
|
-
return
|
|
53
|
+
export function relationSetterToName(setterName) {
|
|
54
|
+
// Extract the relation name after "set" and lowercase first char
|
|
55
|
+
// The method name already has the plural relation name (e.g., "setComments")
|
|
56
|
+
let relationName = setterName.substring(3);
|
|
57
|
+
return relationName.charAt(0).toLowerCase() + relationName.slice(1);
|
|
58
58
|
}
|
|
59
|
-
// e.g. "comments" -> "
|
|
60
|
-
export function
|
|
61
|
-
return `set${capitalize(
|
|
59
|
+
// e.g. "comments" -> "setComments"
|
|
60
|
+
export function relationToSetterName(relation) {
|
|
61
|
+
return `set${capitalize(relation)}`;
|
|
62
62
|
}
|
|
63
63
|
export function stringifyObjectLiteral(obj) {
|
|
64
64
|
if (Array.isArray(obj)) {
|
|
@@ -72,5 +72,5 @@ export function stringifyObjectLiteral(obj) {
|
|
|
72
72
|
const keyValuePairString = `${key}: ${valueString}`;
|
|
73
73
|
stringifiedPairs.push(keyValuePairString);
|
|
74
74
|
}
|
|
75
|
-
return `{${stringifiedPairs.join(
|
|
75
|
+
return `{${stringifiedPairs.join(', ')}}`;
|
|
76
76
|
}
|
|
@@ -5,9 +5,7 @@ import { OnlineAgent, TelepresenceSignalCallback } from "../language/Language";
|
|
|
5
5
|
import { Perspective, PerspectiveUnsignedInput } from "../perspectives/Perspective";
|
|
6
6
|
import { PerspectiveHandle } from "../perspectives/PerspectiveHandle";
|
|
7
7
|
export declare class NeighbourhoodClient {
|
|
8
|
-
private
|
|
9
|
-
private _signalHandlers;
|
|
10
|
-
private _signalSubscriptions;
|
|
8
|
+
#private;
|
|
11
9
|
constructor(client: ApolloClient<any>);
|
|
12
10
|
publishFromPerspective(perspectiveUUID: string, linkLanguage: Address, meta: Perspective): Promise<string>;
|
|
13
11
|
joinFromUrl(url: string): Promise<PerspectiveHandle>;
|
|
@@ -24,6 +22,4 @@ export declare class NeighbourhoodClient {
|
|
|
24
22
|
subscribeToSignals(perspectiveUUID: string): Promise<void>;
|
|
25
23
|
addSignalHandler(perspectiveUUID: string, handler: TelepresenceSignalCallback): Promise<void>;
|
|
26
24
|
removeSignalHandler(perspectiveUUID: string, handler: TelepresenceSignalCallback): void;
|
|
27
|
-
/** Fully tears down the Apollo subscription for a perspective UUID. */
|
|
28
|
-
unsubscribeFromPerspective(perspectiveUUID: string): void;
|
|
29
25
|
}
|
|
@@ -1,246 +1,211 @@
|
|
|
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 _NeighbourhoodClient_apolloClient, _NeighbourhoodClient_signalHandlers;
|
|
1
13
|
import { gql } from "@apollo/client/core";
|
|
2
14
|
import unwrapApolloResult from "../unwrapApolloResult";
|
|
3
|
-
import { isSocketCloseError } from "../utils";
|
|
4
15
|
export class NeighbourhoodClient {
|
|
5
16
|
constructor(client) {
|
|
6
|
-
this
|
|
7
|
-
this
|
|
8
|
-
this
|
|
17
|
+
_NeighbourhoodClient_apolloClient.set(this, void 0);
|
|
18
|
+
_NeighbourhoodClient_signalHandlers.set(this, new Map());
|
|
19
|
+
__classPrivateFieldSet(this, _NeighbourhoodClient_apolloClient, client, "f");
|
|
9
20
|
}
|
|
10
21
|
async publishFromPerspective(perspectiveUUID, linkLanguage, meta) {
|
|
11
|
-
const { neighbourhoodPublishFromPerspective } = unwrapApolloResult(await this.
|
|
12
|
-
mutation: gql `
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
`,
|
|
25
|
-
variables: { perspectiveUUID, linkLanguage, meta: meta },
|
|
22
|
+
const { neighbourhoodPublishFromPerspective } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
|
|
23
|
+
mutation: gql `mutation neighbourhoodPublishFromPerspective(
|
|
24
|
+
$linkLanguage: String!,
|
|
25
|
+
$meta: PerspectiveInput!,
|
|
26
|
+
$perspectiveUUID: String!
|
|
27
|
+
) {
|
|
28
|
+
neighbourhoodPublishFromPerspective(
|
|
29
|
+
linkLanguage: $linkLanguage,
|
|
30
|
+
meta: $meta,
|
|
31
|
+
perspectiveUUID: $perspectiveUUID
|
|
32
|
+
)
|
|
33
|
+
}`,
|
|
34
|
+
variables: { perspectiveUUID, linkLanguage, meta: meta }
|
|
26
35
|
}));
|
|
27
36
|
return neighbourhoodPublishFromPerspective;
|
|
28
37
|
}
|
|
29
38
|
async joinFromUrl(url) {
|
|
30
|
-
const { neighbourhoodJoinFromUrl } = unwrapApolloResult(await this.
|
|
31
|
-
mutation: gql `
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
valid
|
|
52
|
-
invalid
|
|
53
|
-
signature
|
|
54
|
-
key
|
|
55
|
-
}
|
|
39
|
+
const { neighbourhoodJoinFromUrl } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
|
|
40
|
+
mutation: gql `mutation neighbourhoodJoinFromUrl($url: String!) {
|
|
41
|
+
neighbourhoodJoinFromUrl(url: $url) {
|
|
42
|
+
uuid
|
|
43
|
+
name
|
|
44
|
+
sharedUrl
|
|
45
|
+
state
|
|
46
|
+
neighbourhood {
|
|
47
|
+
data {
|
|
48
|
+
linkLanguage
|
|
49
|
+
meta {
|
|
50
|
+
links
|
|
51
|
+
{
|
|
52
|
+
author
|
|
53
|
+
timestamp
|
|
54
|
+
data { source, predicate, target }
|
|
55
|
+
proof { valid, invalid, signature, key }
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
author
|
|
56
60
|
}
|
|
57
|
-
}
|
|
58
61
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
`,
|
|
64
|
-
variables: { url },
|
|
62
|
+
}`,
|
|
63
|
+
variables: { url }
|
|
65
64
|
}));
|
|
66
65
|
return neighbourhoodJoinFromUrl;
|
|
67
66
|
}
|
|
68
67
|
async otherAgents(perspectiveUUID) {
|
|
69
|
-
const { neighbourhoodOtherAgents } = unwrapApolloResult(await this.
|
|
70
|
-
query: gql `
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
`,
|
|
75
|
-
variables: { perspectiveUUID },
|
|
68
|
+
const { neighbourhoodOtherAgents } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").query({
|
|
69
|
+
query: gql `query neighbourhoodOtherAgents($perspectiveUUID: String!) {
|
|
70
|
+
neighbourhoodOtherAgents(perspectiveUUID: $perspectiveUUID)
|
|
71
|
+
}`,
|
|
72
|
+
variables: { perspectiveUUID }
|
|
76
73
|
}));
|
|
77
74
|
return neighbourhoodOtherAgents;
|
|
78
75
|
}
|
|
79
76
|
async hasTelepresenceAdapter(perspectiveUUID) {
|
|
80
|
-
const { neighbourhoodHasTelepresenceAdapter } = unwrapApolloResult(await this.
|
|
81
|
-
query: gql `
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
)
|
|
86
|
-
}
|
|
87
|
-
`,
|
|
88
|
-
variables: { perspectiveUUID },
|
|
77
|
+
const { neighbourhoodHasTelepresenceAdapter } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").query({
|
|
78
|
+
query: gql `query neighbourhoodHasTelepresenceAdapter($perspectiveUUID: String!) {
|
|
79
|
+
neighbourhoodHasTelepresenceAdapter(perspectiveUUID: $perspectiveUUID)
|
|
80
|
+
}`,
|
|
81
|
+
variables: { perspectiveUUID }
|
|
89
82
|
}));
|
|
90
83
|
return neighbourhoodHasTelepresenceAdapter;
|
|
91
84
|
}
|
|
92
85
|
async onlineAgents(perspectiveUUID) {
|
|
93
|
-
const { neighbourhoodOnlineAgents } = unwrapApolloResult(await this.
|
|
94
|
-
query: gql `
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
86
|
+
const { neighbourhoodOnlineAgents } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").query({
|
|
87
|
+
query: gql `query neighbourhoodOnlineAgents($perspectiveUUID: String!) {
|
|
88
|
+
neighbourhoodOnlineAgents(perspectiveUUID: $perspectiveUUID) {
|
|
89
|
+
did
|
|
90
|
+
status {
|
|
91
|
+
author
|
|
92
|
+
timestamp
|
|
93
|
+
data {
|
|
94
|
+
links {
|
|
95
|
+
author
|
|
96
|
+
timestamp
|
|
97
|
+
data { source, predicate, target }
|
|
98
|
+
proof { valid, invalid, signature, key }
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
proof { valid, invalid, signature, key }
|
|
109
102
|
}
|
|
110
|
-
proof {
|
|
111
|
-
valid
|
|
112
|
-
invalid
|
|
113
|
-
signature
|
|
114
|
-
key
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
proof {
|
|
119
|
-
valid
|
|
120
|
-
invalid
|
|
121
|
-
signature
|
|
122
|
-
key
|
|
123
103
|
}
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
`,
|
|
128
|
-
variables: { perspectiveUUID },
|
|
104
|
+
}`,
|
|
105
|
+
variables: { perspectiveUUID }
|
|
129
106
|
}));
|
|
130
107
|
return neighbourhoodOnlineAgents;
|
|
131
108
|
}
|
|
132
109
|
async setOnlineStatus(perspectiveUUID, status) {
|
|
133
|
-
const { neighbourhoodSetOnlineStatus } = unwrapApolloResult(await this.
|
|
134
|
-
mutation: gql `
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
`,
|
|
145
|
-
variables: { perspectiveUUID, status },
|
|
110
|
+
const { neighbourhoodSetOnlineStatus } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
|
|
111
|
+
mutation: gql `mutation neighbourhoodSetOnlineStatus(
|
|
112
|
+
$perspectiveUUID: String!,
|
|
113
|
+
$status: PerspectiveInput!
|
|
114
|
+
) {
|
|
115
|
+
neighbourhoodSetOnlineStatus(
|
|
116
|
+
perspectiveUUID: $perspectiveUUID,
|
|
117
|
+
status: $status
|
|
118
|
+
)
|
|
119
|
+
}`,
|
|
120
|
+
variables: { perspectiveUUID, status }
|
|
146
121
|
}));
|
|
147
122
|
return neighbourhoodSetOnlineStatus;
|
|
148
123
|
}
|
|
149
124
|
async setOnlineStatusU(perspectiveUUID, status) {
|
|
150
|
-
const { neighbourhoodSetOnlineStatusU } = unwrapApolloResult(await this.
|
|
151
|
-
mutation: gql `
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
`,
|
|
162
|
-
variables: { perspectiveUUID, status },
|
|
125
|
+
const { neighbourhoodSetOnlineStatusU } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
|
|
126
|
+
mutation: gql `mutation neighbourhoodSetOnlineStatusU(
|
|
127
|
+
$perspectiveUUID: String!,
|
|
128
|
+
$status: PerspectiveUnsignedInput!
|
|
129
|
+
) {
|
|
130
|
+
neighbourhoodSetOnlineStatusU(
|
|
131
|
+
perspectiveUUID: $perspectiveUUID,
|
|
132
|
+
status: $status
|
|
133
|
+
)
|
|
134
|
+
}`,
|
|
135
|
+
variables: { perspectiveUUID, status }
|
|
163
136
|
}));
|
|
164
137
|
return neighbourhoodSetOnlineStatusU;
|
|
165
138
|
}
|
|
166
139
|
async sendSignal(perspectiveUUID, remoteAgentDid, payload) {
|
|
167
|
-
const { neighbourhoodSendSignal } = unwrapApolloResult(await this.
|
|
168
|
-
mutation: gql `
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
`,
|
|
181
|
-
variables: { perspectiveUUID, remoteAgentDid, payload },
|
|
140
|
+
const { neighbourhoodSendSignal } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
|
|
141
|
+
mutation: gql `mutation neighbourhoodSendSignal(
|
|
142
|
+
$perspectiveUUID: String!,
|
|
143
|
+
$remoteAgentDid: String!,
|
|
144
|
+
$payload: PerspectiveInput!
|
|
145
|
+
) {
|
|
146
|
+
neighbourhoodSendSignal(
|
|
147
|
+
perspectiveUUID: $perspectiveUUID,
|
|
148
|
+
remoteAgentDid: $remoteAgentDid,
|
|
149
|
+
payload: $payload
|
|
150
|
+
)
|
|
151
|
+
}`,
|
|
152
|
+
variables: { perspectiveUUID, remoteAgentDid, payload }
|
|
182
153
|
}));
|
|
183
154
|
return neighbourhoodSendSignal;
|
|
184
155
|
}
|
|
185
156
|
async sendSignalU(perspectiveUUID, remoteAgentDid, payload) {
|
|
186
|
-
const { neighbourhoodSendSignalU } = unwrapApolloResult(await this.
|
|
187
|
-
mutation: gql `
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
`,
|
|
200
|
-
variables: { perspectiveUUID, remoteAgentDid, payload },
|
|
157
|
+
const { neighbourhoodSendSignalU } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
|
|
158
|
+
mutation: gql `mutation neighbourhoodSendSignalU(
|
|
159
|
+
$perspectiveUUID: String!,
|
|
160
|
+
$remoteAgentDid: String!,
|
|
161
|
+
$payload: PerspectiveUnsignedInput!
|
|
162
|
+
) {
|
|
163
|
+
neighbourhoodSendSignalU(
|
|
164
|
+
perspectiveUUID: $perspectiveUUID,
|
|
165
|
+
remoteAgentDid: $remoteAgentDid,
|
|
166
|
+
payload: $payload
|
|
167
|
+
)
|
|
168
|
+
}`,
|
|
169
|
+
variables: { perspectiveUUID, remoteAgentDid, payload }
|
|
201
170
|
}));
|
|
202
171
|
return neighbourhoodSendSignalU;
|
|
203
172
|
}
|
|
204
173
|
async sendBroadcast(perspectiveUUID, payload, loopback = false) {
|
|
205
|
-
const { neighbourhoodSendBroadcast } = unwrapApolloResult(await this.
|
|
206
|
-
mutation: gql `
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
`,
|
|
219
|
-
variables: { perspectiveUUID, payload, loopback },
|
|
174
|
+
const { neighbourhoodSendBroadcast } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
|
|
175
|
+
mutation: gql `mutation neighbourhoodSendBroadcast(
|
|
176
|
+
$perspectiveUUID: String!,
|
|
177
|
+
$payload: PerspectiveInput!,
|
|
178
|
+
$loopback: Boolean
|
|
179
|
+
) {
|
|
180
|
+
neighbourhoodSendBroadcast(
|
|
181
|
+
perspectiveUUID: $perspectiveUUID,
|
|
182
|
+
payload: $payload,
|
|
183
|
+
loopback: $loopback
|
|
184
|
+
)
|
|
185
|
+
}`,
|
|
186
|
+
variables: { perspectiveUUID, payload, loopback }
|
|
220
187
|
}));
|
|
221
188
|
return neighbourhoodSendBroadcast;
|
|
222
189
|
}
|
|
223
190
|
async sendBroadcastU(perspectiveUUID, payload, loopback = false) {
|
|
224
|
-
const { neighbourhoodSendBroadcastU } = unwrapApolloResult(await this.
|
|
225
|
-
mutation: gql `
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
`,
|
|
238
|
-
variables: { perspectiveUUID, payload, loopback },
|
|
191
|
+
const { neighbourhoodSendBroadcastU } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
|
|
192
|
+
mutation: gql `mutation neighbourhoodSendBroadcastU(
|
|
193
|
+
$perspectiveUUID: String!,
|
|
194
|
+
$payload: PerspectiveUnsignedInput!,
|
|
195
|
+
$loopback: Boolean
|
|
196
|
+
) {
|
|
197
|
+
neighbourhoodSendBroadcastU(
|
|
198
|
+
perspectiveUUID: $perspectiveUUID,
|
|
199
|
+
payload: $payload,
|
|
200
|
+
loopback: $loopback
|
|
201
|
+
)
|
|
202
|
+
}`,
|
|
203
|
+
variables: { perspectiveUUID, payload, loopback }
|
|
239
204
|
}));
|
|
240
205
|
return neighbourhoodSendBroadcastU;
|
|
241
206
|
}
|
|
242
207
|
dispatchSignal(perspectiveUUID, signal) {
|
|
243
|
-
const handlers = this.
|
|
208
|
+
const handlers = __classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
|
|
244
209
|
if (handlers) {
|
|
245
210
|
for (const handler of handlers) {
|
|
246
211
|
try {
|
|
@@ -254,42 +219,25 @@ export class NeighbourhoodClient {
|
|
|
254
219
|
}
|
|
255
220
|
async subscribeToSignals(perspectiveUUID) {
|
|
256
221
|
const that = this;
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
273
|
-
proof {
|
|
274
|
-
valid
|
|
275
|
-
invalid
|
|
276
|
-
signature
|
|
277
|
-
key
|
|
278
|
-
}
|
|
222
|
+
__classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").subscribe({
|
|
223
|
+
query: gql `subscription neighbourhoodSignal($perspectiveUUID: String!) {
|
|
224
|
+
neighbourhoodSignal(perspectiveUUID: $perspectiveUUID) {
|
|
225
|
+
author
|
|
226
|
+
timestamp
|
|
227
|
+
data {
|
|
228
|
+
links
|
|
229
|
+
{
|
|
230
|
+
author
|
|
231
|
+
timestamp
|
|
232
|
+
data { source, predicate, target }
|
|
233
|
+
proof { valid, invalid, signature, key }
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
proof { valid, invalid, signature, key }
|
|
279
237
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
invalid
|
|
284
|
-
signature
|
|
285
|
-
key
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
`,
|
|
290
|
-
variables: { perspectiveUUID },
|
|
291
|
-
})
|
|
292
|
-
.subscribe({
|
|
238
|
+
}`,
|
|
239
|
+
variables: { perspectiveUUID }
|
|
240
|
+
}).subscribe({
|
|
293
241
|
next: (result) => {
|
|
294
242
|
try {
|
|
295
243
|
const { neighbourhoodSignal } = unwrapApolloResult(result);
|
|
@@ -299,18 +247,16 @@ export class NeighbourhoodClient {
|
|
|
299
247
|
console.error("Error in signal subscription:", e);
|
|
300
248
|
}
|
|
301
249
|
},
|
|
302
|
-
error: (
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
},
|
|
250
|
+
error: (err) => {
|
|
251
|
+
console.error("Signal subscription error for perspective", perspectiveUUID, err);
|
|
252
|
+
}
|
|
306
253
|
});
|
|
307
|
-
this._signalSubscriptions.set(perspectiveUUID, sub);
|
|
308
254
|
}
|
|
309
255
|
async addSignalHandler(perspectiveUUID, handler) {
|
|
310
|
-
let handlersForPerspective = this.
|
|
256
|
+
let handlersForPerspective = __classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
|
|
311
257
|
if (!handlersForPerspective) {
|
|
312
258
|
handlersForPerspective = [];
|
|
313
|
-
this.
|
|
259
|
+
__classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").set(perspectiveUUID, handlersForPerspective);
|
|
314
260
|
// Push handler BEFORE subscribing so it's available when signals arrive
|
|
315
261
|
handlersForPerspective.push(handler);
|
|
316
262
|
await this.subscribeToSignals(perspectiveUUID);
|
|
@@ -320,22 +266,13 @@ export class NeighbourhoodClient {
|
|
|
320
266
|
}
|
|
321
267
|
}
|
|
322
268
|
removeSignalHandler(perspectiveUUID, handler) {
|
|
323
|
-
const handlersForPerspective = this.
|
|
269
|
+
const handlersForPerspective = __classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
|
|
324
270
|
if (handlersForPerspective) {
|
|
325
271
|
const index = handlersForPerspective.indexOf(handler);
|
|
326
272
|
if (index > -1) {
|
|
327
273
|
handlersForPerspective.splice(index, 1);
|
|
328
274
|
}
|
|
329
|
-
// Intentionally keep the Apollo subscription and the handlers-map entry alive
|
|
330
|
-
// even when the array becomes empty. This prevents an unnecessary re-subscription
|
|
331
|
-
// if a new handler is added shortly after (the empty array makes addSignalHandler
|
|
332
|
-
// skip subscribeToSignals). For explicit teardown use unsubscribeFromPerspective().
|
|
333
275
|
}
|
|
334
276
|
}
|
|
335
|
-
/** Fully tears down the Apollo subscription for a perspective UUID. */
|
|
336
|
-
unsubscribeFromPerspective(perspectiveUUID) {
|
|
337
|
-
this._signalSubscriptions.get(perspectiveUUID)?.unsubscribe();
|
|
338
|
-
this._signalSubscriptions.delete(perspectiveUUID);
|
|
339
|
-
this._signalHandlers.delete(perspectiveUUID);
|
|
340
|
-
}
|
|
341
277
|
}
|
|
278
|
+
_NeighbourhoodClient_apolloClient = new WeakMap(), _NeighbourhoodClient_signalHandlers = new WeakMap();
|
|
@@ -3,8 +3,7 @@ import { OnlineAgent } from "../language/Language";
|
|
|
3
3
|
import { Perspective, PerspectiveExpression, PerspectiveUnsignedInput } from "../perspectives/Perspective";
|
|
4
4
|
import { NeighbourhoodClient } from "./NeighbourhoodClient";
|
|
5
5
|
export declare class NeighbourhoodProxy {
|
|
6
|
-
private
|
|
7
|
-
private _pID;
|
|
6
|
+
#private;
|
|
8
7
|
constructor(client: NeighbourhoodClient, pID: string);
|
|
9
8
|
otherAgents(): Promise<DID[]>;
|
|
10
9
|
hasTelepresenceAdapter(): Promise<boolean>;
|