@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.
Files changed (153) hide show
  1. package/jest.config.js +10 -3
  2. package/lib/index.cjs +6872 -5886
  3. package/lib/index.js +6868 -5874
  4. package/lib/src/Ad4mClient.d.ts +9 -16
  5. package/lib/src/Ad4mClient.js +46 -25
  6. package/lib/src/Literal.d.ts +1 -2
  7. package/lib/src/Literal.js +38 -35
  8. package/lib/src/SmartLiteral.d.ts +1 -2
  9. package/lib/src/SmartLiteral.js +30 -15
  10. package/lib/src/agent/AgentClient.d.ts +1 -4
  11. package/lib/src/agent/AgentClient.js +79 -99
  12. package/lib/src/ai/AIClient.d.ts +1 -2
  13. package/lib/src/ai/AIClient.js +224 -220
  14. package/lib/src/expression/ExpressionClient.d.ts +1 -1
  15. package/lib/src/expression/ExpressionClient.js +73 -86
  16. package/lib/src/index.d.ts +1 -1
  17. package/lib/src/index.js +1 -1
  18. package/lib/src/language/LanguageClient.d.ts +1 -1
  19. package/lib/src/language/LanguageClient.js +52 -52
  20. package/lib/src/model/Ad4mModel.d.ts +1351 -144
  21. package/lib/src/model/Ad4mModel.js +3737 -228
  22. package/lib/src/model/Ad4mModel.test.js +522 -979
  23. package/lib/src/model/Subject.d.ts +3 -3
  24. package/lib/src/model/Subject.js +25 -25
  25. package/lib/src/model/decorators.d.ts +444 -100
  26. package/lib/src/model/decorators.js +686 -321
  27. package/lib/src/model/util.d.ts +6 -6
  28. package/lib/src/model/util.js +24 -24
  29. package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +1 -5
  30. package/lib/src/neighbourhood/NeighbourhoodClient.js +179 -242
  31. package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +1 -2
  32. package/lib/src/neighbourhood/NeighbourhoodProxy.js +28 -13
  33. package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +5 -1
  34. package/lib/src/perspectives/PerspectiveClient.d.ts +9 -9
  35. package/lib/src/perspectives/PerspectiveClient.js +240 -316
  36. package/lib/src/perspectives/PerspectiveProxy.d.ts +99 -61
  37. package/lib/src/perspectives/PerspectiveProxy.js +485 -832
  38. package/lib/src/runtime/RuntimeClient.d.ts +1 -5
  39. package/lib/src/runtime/RuntimeClient.js +238 -412
  40. package/lib/src/shacl/SHACLFlow.test.js +105 -164
  41. package/lib/src/shacl/SHACLShape.d.ts +12 -17
  42. package/lib/src/shacl/SHACLShape.js +115 -128
  43. package/lib/src/shacl/SHACLShape.test.js +176 -244
  44. package/lib/src/shims/reflect-metadata.d.ts +0 -0
  45. package/lib/src/shims/type-graphql.d.ts +32 -0
  46. package/lib/src/src/Ad4mClient.d.ts +28 -0
  47. package/lib/src/src/Address.d.ts +1 -0
  48. package/lib/src/src/DID.d.ts +1 -0
  49. package/lib/src/src/Exception.d.ts +7 -0
  50. package/lib/src/src/Literal.d.ts +7 -0
  51. package/lib/src/src/PubSub.d.ts +17 -0
  52. package/lib/src/src/SmartLiteral.d.ts +12 -0
  53. package/lib/src/src/agent/Agent.d.ts +110 -0
  54. package/lib/src/src/agent/AgentClient.d.ts +62 -0
  55. package/lib/src/src/agent/AgentResolver.d.ts +30 -0
  56. package/lib/src/src/agent/AgentStatus.d.ts +8 -0
  57. package/lib/src/src/ai/AIClient.d.ts +32 -0
  58. package/lib/src/src/ai/AIResolver.d.ts +75 -0
  59. package/lib/src/src/ai/Tasks.d.ts +37 -0
  60. package/lib/src/src/buildSchema.d.ts +1 -0
  61. package/lib/src/src/expression/Expression.d.ts +28 -0
  62. package/lib/src/src/expression/ExpressionClient.d.ts +13 -0
  63. package/lib/src/src/expression/ExpressionRef.d.ts +9 -0
  64. package/lib/src/src/expression/ExpressionResolver.d.ts +10 -0
  65. package/lib/src/src/index.d.ts +35 -0
  66. package/lib/src/src/jestSetup.d.ts +1 -0
  67. package/lib/src/src/language/Icon.d.ts +4 -0
  68. package/lib/src/src/language/Language.d.ts +206 -0
  69. package/lib/src/src/language/LanguageClient.d.ts +17 -0
  70. package/lib/src/src/language/LanguageContext.d.ts +37 -0
  71. package/lib/src/src/language/LanguageHandle.d.ts +9 -0
  72. package/lib/src/src/language/LanguageMeta.d.ts +35 -0
  73. package/lib/src/src/language/LanguageRef.d.ts +6 -0
  74. package/lib/src/src/language/LanguageResolver.d.ts +19 -0
  75. package/lib/src/src/links/Links.d.ts +39 -0
  76. package/lib/src/src/links/Links.test.d.ts +1 -0
  77. package/lib/src/src/model/Ad4mModel.d.ts +1438 -0
  78. package/lib/src/src/model/Ad4mModel.test.d.ts +1 -0
  79. package/lib/src/src/model/Subject.d.ts +25 -0
  80. package/lib/src/src/model/decorators.d.ts +545 -0
  81. package/lib/src/src/model/util.d.ts +12 -0
  82. package/lib/src/src/neighbourhood/Neighbourhood.d.ts +10 -0
  83. package/lib/src/src/neighbourhood/NeighbourhoodClient.d.ts +25 -0
  84. package/lib/src/src/neighbourhood/NeighbourhoodProxy.d.ts +19 -0
  85. package/lib/src/src/neighbourhood/NeighbourhoodProxy.test.d.ts +1 -0
  86. package/lib/src/src/neighbourhood/NeighbourhoodResolver.d.ts +24 -0
  87. package/lib/src/src/perspectives/LinkQuery.d.ts +11 -0
  88. package/lib/src/src/perspectives/Perspective.d.ts +38 -0
  89. package/lib/src/src/perspectives/Perspective.test.d.ts +1 -0
  90. package/lib/src/src/perspectives/PerspectiveClient.d.ts +97 -0
  91. package/lib/src/src/perspectives/PerspectiveDiff.d.ts +9 -0
  92. package/lib/src/src/perspectives/PerspectiveHandle.d.ts +18 -0
  93. package/lib/src/src/perspectives/PerspectiveProxy.d.ts +865 -0
  94. package/lib/src/src/perspectives/PerspectiveResolver.d.ts +57 -0
  95. package/lib/src/src/runtime/RuntimeClient.d.ts +56 -0
  96. package/lib/src/src/runtime/RuntimeResolver.d.ts +132 -0
  97. package/lib/src/src/shacl/SHACLFlow.d.ts +171 -0
  98. package/lib/src/src/shacl/SHACLFlow.test.d.ts +1 -0
  99. package/lib/src/src/shacl/SHACLShape.d.ts +117 -0
  100. package/lib/src/src/shacl/SHACLShape.test.d.ts +1 -0
  101. package/lib/src/src/typeDefs.d.ts +1 -0
  102. package/lib/src/src/unwrapApolloResult.d.ts +2 -0
  103. package/lib/src/src/utils.d.ts +25 -0
  104. package/lib/src/utils.d.ts +0 -8
  105. package/lib/src/utils.js +7 -21
  106. package/package.json +15 -14
  107. package/src/Ad4mClient.test.ts +1315 -1564
  108. package/src/Ad4mClient.ts +54 -55
  109. package/src/Literal.test.ts +26 -45
  110. package/src/Literal.ts +66 -82
  111. package/src/SmartLiteral.ts +58 -74
  112. package/src/agent/AgentClient.ts +99 -144
  113. package/src/ai/AIClient.ts +359 -409
  114. package/src/expression/ExpressionClient.ts +96 -142
  115. package/src/index.ts +1 -1
  116. package/src/language/LanguageClient.ts +113 -137
  117. package/src/model/Ad4mModel.test.ts +616 -1114
  118. package/src/model/Ad4mModel.ts +4361 -451
  119. package/src/model/Subject.ts +159 -0
  120. package/src/model/decorators.ts +1168 -667
  121. package/src/model/util.ts +54 -53
  122. package/src/neighbourhood/NeighbourhoodClient.ts +266 -392
  123. package/src/neighbourhood/NeighbourhoodProxy.test.ts +7 -3
  124. package/src/neighbourhood/NeighbourhoodProxy.ts +40 -58
  125. package/src/perspectives/PerspectiveClient.ts +540 -779
  126. package/src/perspectives/PerspectiveProxy.ts +2067 -2860
  127. package/src/runtime/RuntimeClient.ts +476 -775
  128. package/src/shacl/SHACLFlow.test.ts +129 -196
  129. package/src/shacl/SHACLShape.test.ts +190 -284
  130. package/src/shacl/SHACLShape.ts +200 -224
  131. package/src/utils.ts +17 -31
  132. package/tsconfig.json +10 -9
  133. package/src/model/IMPROVEMENTS.md +0 -482
  134. package/src/model/PREDICATE_COLLISION_FIX.md +0 -651
  135. package/src/model/README.md +0 -317
  136. package/src/model/SHACL_MUTATION_DECOUPLING.md +0 -356
  137. package/src/model/SUBSCRIPTION_STRATEGY.md +0 -317
  138. package/src/model/TC39_STAGE_3_DECORATORS.md +0 -609
  139. package/src/model/mutation.ts +0 -461
  140. package/src/model/parentUtils.ts +0 -91
  141. package/src/model/prolog/generatePrologFacts.ts +0 -176
  142. package/src/model/prolog/index.ts +0 -1
  143. package/src/model/query/ModelQueryBuilder.ts +0 -173
  144. package/src/model/query/fetchInstance.ts +0 -181
  145. package/src/model/query/hydration.ts +0 -273
  146. package/src/model/query/operations.ts +0 -510
  147. package/src/model/query/snapshot.ts +0 -126
  148. package/src/model/query/surrealCompiler.ts +0 -376
  149. package/src/model/schema/fromJSONSchema.ts +0 -411
  150. package/src/model/schema/metadata.ts +0 -148
  151. package/src/model/subscription.ts +0 -307
  152. package/src/model/transaction.ts +0 -60
  153. package/src/model/types.ts +0 -207
@@ -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 collectionToAdderName(collection: string): string;
7
- export declare function collectionAdderToName(adderName: string): string;
8
- export declare function collectionToRemoverName(collection: string): string;
9
- export declare function collectionRemoverToName(removerName: string): string;
10
- export declare function collectionSetterToName(setterName: string): string;
11
- export declare function collectionToSetterName(collection: string): string;
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;
@@ -29,36 +29,36 @@ export function pluralToSingular(plural) {
29
29
  }
30
30
  }
31
31
  // e.g. "comments" -> "addComment"
32
- export function collectionToAdderName(collection) {
33
- return `add${capitalize(pluralToSingular(collection))}`;
32
+ export function relationToAdderName(relation) {
33
+ return `add${capitalize(pluralToSingular(relation))}`;
34
34
  }
35
35
  // e.g. "addComments" -> "comments"
36
- export function collectionAdderToName(adderName) {
37
- // Extract the collection name after "add" and lowercase first char
38
- // The method name already has the plural collection name (e.g., "addComments")
39
- let collectionName = adderName.substring(3);
40
- return collectionName.charAt(0).toLowerCase() + collectionName.slice(1);
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 collectionToRemoverName(collection) {
44
- return `remove${capitalize(pluralToSingular(collection))}`;
43
+ export function relationToRemoverName(relation) {
44
+ return `remove${capitalize(pluralToSingular(relation))}`;
45
45
  }
46
- // e.g. "removeComments" -> "comments"
47
- export function collectionRemoverToName(removerName) {
48
- // Extract the collection name after "remove" and lowercase first char
49
- // The method name already has the plural collection name (e.g., "removeComments")
50
- let collectionName = removerName.substring(6);
51
- return collectionName.charAt(0).toLowerCase() + collectionName.slice(1);
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 collectionSetterToName(setterName) {
54
- // Extract the collection name after "set" and lowercase first char
55
- // The method name has the plural collection name (e.g., "setComments")
56
- let collectionName = setterName.substring(3);
57
- return collectionName.charAt(0).toLowerCase() + collectionName.slice(1);
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" -> "setComment"
60
- export function collectionToSetterName(collection) {
61
- return `set${capitalize(pluralToSingular(collection))}`;
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 _apolloClient;
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._signalHandlers = new Map();
7
- this._signalSubscriptions = new Map();
8
- this._apolloClient = client;
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._apolloClient.mutate({
12
- mutation: gql `
13
- mutation neighbourhoodPublishFromPerspective(
14
- $linkLanguage: String!
15
- $meta: PerspectiveInput!
16
- $perspectiveUUID: String!
17
- ) {
18
- neighbourhoodPublishFromPerspective(
19
- linkLanguage: $linkLanguage
20
- meta: $meta
21
- perspectiveUUID: $perspectiveUUID
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._apolloClient.mutate({
31
- mutation: gql `
32
- mutation neighbourhoodJoinFromUrl($url: String!) {
33
- neighbourhoodJoinFromUrl(url: $url) {
34
- uuid
35
- name
36
- sharedUrl
37
- state
38
- neighbourhood {
39
- data {
40
- linkLanguage
41
- meta {
42
- links {
43
- author
44
- timestamp
45
- data {
46
- source
47
- predicate
48
- target
49
- }
50
- proof {
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
- author
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._apolloClient.query({
70
- query: gql `
71
- query neighbourhoodOtherAgents($perspectiveUUID: String!) {
72
- neighbourhoodOtherAgents(perspectiveUUID: $perspectiveUUID)
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._apolloClient.query({
81
- query: gql `
82
- query neighbourhoodHasTelepresenceAdapter($perspectiveUUID: String!) {
83
- neighbourhoodHasTelepresenceAdapter(
84
- perspectiveUUID: $perspectiveUUID
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._apolloClient.query({
94
- query: gql `
95
- query neighbourhoodOnlineAgents($perspectiveUUID: String!) {
96
- neighbourhoodOnlineAgents(perspectiveUUID: $perspectiveUUID) {
97
- did
98
- status {
99
- author
100
- timestamp
101
- data {
102
- links {
103
- author
104
- timestamp
105
- data {
106
- source
107
- predicate
108
- target
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._apolloClient.mutate({
134
- mutation: gql `
135
- mutation neighbourhoodSetOnlineStatus(
136
- $perspectiveUUID: String!
137
- $status: PerspectiveInput!
138
- ) {
139
- neighbourhoodSetOnlineStatus(
140
- perspectiveUUID: $perspectiveUUID
141
- status: $status
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._apolloClient.mutate({
151
- mutation: gql `
152
- mutation neighbourhoodSetOnlineStatusU(
153
- $perspectiveUUID: String!
154
- $status: PerspectiveUnsignedInput!
155
- ) {
156
- neighbourhoodSetOnlineStatusU(
157
- perspectiveUUID: $perspectiveUUID
158
- status: $status
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._apolloClient.mutate({
168
- mutation: gql `
169
- mutation neighbourhoodSendSignal(
170
- $perspectiveUUID: String!
171
- $remoteAgentDid: String!
172
- $payload: PerspectiveInput!
173
- ) {
174
- neighbourhoodSendSignal(
175
- perspectiveUUID: $perspectiveUUID
176
- remoteAgentDid: $remoteAgentDid
177
- payload: $payload
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._apolloClient.mutate({
187
- mutation: gql `
188
- mutation neighbourhoodSendSignalU(
189
- $perspectiveUUID: String!
190
- $remoteAgentDid: String!
191
- $payload: PerspectiveUnsignedInput!
192
- ) {
193
- neighbourhoodSendSignalU(
194
- perspectiveUUID: $perspectiveUUID
195
- remoteAgentDid: $remoteAgentDid
196
- payload: $payload
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._apolloClient.mutate({
206
- mutation: gql `
207
- mutation neighbourhoodSendBroadcast(
208
- $perspectiveUUID: String!
209
- $payload: PerspectiveInput!
210
- $loopback: Boolean
211
- ) {
212
- neighbourhoodSendBroadcast(
213
- perspectiveUUID: $perspectiveUUID
214
- payload: $payload
215
- loopback: $loopback
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._apolloClient.mutate({
225
- mutation: gql `
226
- mutation neighbourhoodSendBroadcastU(
227
- $perspectiveUUID: String!
228
- $payload: PerspectiveUnsignedInput!
229
- $loopback: Boolean
230
- ) {
231
- neighbourhoodSendBroadcastU(
232
- perspectiveUUID: $perspectiveUUID
233
- payload: $payload
234
- loopback: $loopback
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._signalHandlers.get(perspectiveUUID);
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
- const sub = this._apolloClient
258
- .subscribe({
259
- query: gql `
260
- subscription neighbourhoodSignal($perspectiveUUID: String!) {
261
- neighbourhoodSignal(perspectiveUUID: $perspectiveUUID) {
262
- author
263
- timestamp
264
- data {
265
- links {
266
- author
267
- timestamp
268
- data {
269
- source
270
- predicate
271
- target
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
- proof {
282
- valid
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: (e) => {
303
- if (!isSocketCloseError(e))
304
- console.error("neighbourhoodSignal subscription error:", e);
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._signalHandlers.get(perspectiveUUID);
256
+ let handlersForPerspective = __classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
311
257
  if (!handlersForPerspective) {
312
258
  handlersForPerspective = [];
313
- this._signalHandlers.set(perspectiveUUID, handlersForPerspective);
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._signalHandlers.get(perspectiveUUID);
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 _client;
7
- private _pID;
6
+ #private;
8
7
  constructor(client: NeighbourhoodClient, pID: string);
9
8
  otherAgents(): Promise<DID[]>;
10
9
  hasTelepresenceAdapter(): Promise<boolean>;