@coasys/ad4m 0.10.1-release-candidate-4-debug-strings → 0.10.1-release-candidate-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/lib/index.cjs CHANGED
@@ -7004,9 +7004,6 @@ class NeighbourhoodClient {
7004
7004
  const index = handlersForPerspective.indexOf(handler);
7005
7005
  if (index > -1) {
7006
7006
  handlersForPerspective.splice(index, 1);
7007
- if (!handlersForPerspective.length) {
7008
- __classPrivateFieldGet$6(this, _NeighbourhoodClient_signalHandlers, "f").delete(perspectiveUUID);
7009
- }
7010
7007
  }
7011
7008
  }
7012
7009
  }
@@ -7196,20 +7193,6 @@ class RuntimeClient {
7196
7193
  }));
7197
7194
  return runtimeGetNetworkMetrics;
7198
7195
  }
7199
- async debugStrings(neighbourhoodUrl) {
7200
- const { runtimeDebugStrings } = unwrapApolloResult(await __classPrivateFieldGet$5(this, _RuntimeClient_apolloClient, "f").query({
7201
- query: gql `query runtimeDebugStrings($neighbourhoodUrl: String) {
7202
- runtimeDebugStrings(neighbourhoodUrl: $neighbourhoodUrl) {
7203
- neighbourhoodUrl
7204
- debugString
7205
- operation
7206
- timestamp
7207
- }
7208
- }`,
7209
- variables: { neighbourhoodUrl }
7210
- }));
7211
- return runtimeDebugStrings;
7212
- }
7213
7196
  async restartHolochain() {
7214
7197
  const { runtimeRestartHolochain } = unwrapApolloResult(await __classPrivateFieldGet$5(this, _RuntimeClient_apolloClient, "f").mutate({
7215
7198
  mutation: gql `mutation runtimeRestartHolochain {
@@ -16383,13 +16366,6 @@ input CapabilityInput {
16383
16366
 
16384
16367
  scalar DateTime
16385
16368
 
16386
- type DebugStringEntry {
16387
- debugString: String!
16388
- neighbourhoodUrl: String!
16389
- operation: String!
16390
- timestamp: String!
16391
- }
16392
-
16393
16369
  type EntanglementProof {
16394
16370
  deviceKey: String!
16395
16371
  deviceKeySignedByDid: String!
@@ -16766,7 +16742,6 @@ type Query {
16766
16742
  perspectiveQueryProlog(query: String!, uuid: String!): String!
16767
16743
  perspectiveSnapshot(uuid: String!): Perspective
16768
16744
  perspectives: [PerspectiveHandle!]!
16769
- runtimeDebugStrings(neighbourhoodUrl: String): [DebugStringEntry!]!
16770
16745
  runtimeFriendStatus(did: String!): PerspectiveExpression
16771
16746
  runtimeFriends: [String!]!
16772
16747
  runtimeGetNetworkMetrics: String!
@@ -17056,27 +17031,6 @@ __decorate([
17056
17031
  exports.TriggeredNotification = __decorate([
17057
17032
  ObjectType()
17058
17033
  ], exports.TriggeredNotification);
17059
- exports.DebugStringEntry = class DebugStringEntry {
17060
- };
17061
- __decorate([
17062
- Field(),
17063
- __metadata("design:type", String)
17064
- ], exports.DebugStringEntry.prototype, "neighbourhoodUrl", void 0);
17065
- __decorate([
17066
- Field(),
17067
- __metadata("design:type", String)
17068
- ], exports.DebugStringEntry.prototype, "debugString", void 0);
17069
- __decorate([
17070
- Field(),
17071
- __metadata("design:type", String)
17072
- ], exports.DebugStringEntry.prototype, "operation", void 0);
17073
- __decorate([
17074
- Field(),
17075
- __metadata("design:type", String)
17076
- ], exports.DebugStringEntry.prototype, "timestamp", void 0);
17077
- exports.DebugStringEntry = __decorate([
17078
- ObjectType()
17079
- ], exports.DebugStringEntry);
17080
17034
  exports.ImportStats = class ImportStats {
17081
17035
  };
17082
17036
  __decorate([
@@ -17183,10 +17137,6 @@ let RuntimeResolver = class RuntimeResolver {
17183
17137
  runtimeKnownLinkLanguageTemplates() {
17184
17138
  return ["Qm12345abcdef"];
17185
17139
  }
17186
- runtimeDebugStrings(neighbourhoodUrl) {
17187
- // Real implementation will be provided by the executor
17188
- return [];
17189
- }
17190
17140
  runtimeAddKnownLinkLanguageTemplates(addresses) {
17191
17141
  return addresses;
17192
17142
  }
@@ -17350,13 +17300,6 @@ __decorate([
17350
17300
  __metadata("design:paramtypes", []),
17351
17301
  __metadata("design:returntype", Array)
17352
17302
  ], RuntimeResolver.prototype, "runtimeKnownLinkLanguageTemplates", null);
17353
- __decorate([
17354
- Query(),
17355
- __param(0, Arg()),
17356
- __metadata("design:type", Function),
17357
- __metadata("design:paramtypes", [String]),
17358
- __metadata("design:returntype", Array)
17359
- ], RuntimeResolver.prototype, "runtimeDebugStrings", null);
17360
17303
  __decorate([
17361
17304
  Mutation(),
17362
17305
  __param(0, Arg()),
@@ -17864,7 +17807,14 @@ class Ad4mModel {
17864
17807
  if (resolve) {
17865
17808
  let resolvedExpression = await perspective.getExpression(value);
17866
17809
  if (resolvedExpression) {
17867
- finalValue = resolvedExpression.data;
17810
+ try {
17811
+ // Attempt to parse the data as JSON
17812
+ finalValue = JSON.parse(resolvedExpression.data);
17813
+ }
17814
+ catch (error) {
17815
+ // If parsing fails, keep the original data
17816
+ finalValue = resolvedExpression.data;
17817
+ }
17868
17818
  }
17869
17819
  }
17870
17820
  // Apply transform function if it exists
package/lib/index.js CHANGED
@@ -7000,9 +7000,6 @@ class NeighbourhoodClient {
7000
7000
  const index = handlersForPerspective.indexOf(handler);
7001
7001
  if (index > -1) {
7002
7002
  handlersForPerspective.splice(index, 1);
7003
- if (!handlersForPerspective.length) {
7004
- __classPrivateFieldGet$6(this, _NeighbourhoodClient_signalHandlers, "f").delete(perspectiveUUID);
7005
- }
7006
7003
  }
7007
7004
  }
7008
7005
  }
@@ -7192,20 +7189,6 @@ class RuntimeClient {
7192
7189
  }));
7193
7190
  return runtimeGetNetworkMetrics;
7194
7191
  }
7195
- async debugStrings(neighbourhoodUrl) {
7196
- const { runtimeDebugStrings } = unwrapApolloResult(await __classPrivateFieldGet$5(this, _RuntimeClient_apolloClient, "f").query({
7197
- query: gql `query runtimeDebugStrings($neighbourhoodUrl: String) {
7198
- runtimeDebugStrings(neighbourhoodUrl: $neighbourhoodUrl) {
7199
- neighbourhoodUrl
7200
- debugString
7201
- operation
7202
- timestamp
7203
- }
7204
- }`,
7205
- variables: { neighbourhoodUrl }
7206
- }));
7207
- return runtimeDebugStrings;
7208
- }
7209
7192
  async restartHolochain() {
7210
7193
  const { runtimeRestartHolochain } = unwrapApolloResult(await __classPrivateFieldGet$5(this, _RuntimeClient_apolloClient, "f").mutate({
7211
7194
  mutation: gql `mutation runtimeRestartHolochain {
@@ -16379,13 +16362,6 @@ input CapabilityInput {
16379
16362
 
16380
16363
  scalar DateTime
16381
16364
 
16382
- type DebugStringEntry {
16383
- debugString: String!
16384
- neighbourhoodUrl: String!
16385
- operation: String!
16386
- timestamp: String!
16387
- }
16388
-
16389
16365
  type EntanglementProof {
16390
16366
  deviceKey: String!
16391
16367
  deviceKeySignedByDid: String!
@@ -16762,7 +16738,6 @@ type Query {
16762
16738
  perspectiveQueryProlog(query: String!, uuid: String!): String!
16763
16739
  perspectiveSnapshot(uuid: String!): Perspective
16764
16740
  perspectives: [PerspectiveHandle!]!
16765
- runtimeDebugStrings(neighbourhoodUrl: String): [DebugStringEntry!]!
16766
16741
  runtimeFriendStatus(did: String!): PerspectiveExpression
16767
16742
  runtimeFriends: [String!]!
16768
16743
  runtimeGetNetworkMetrics: String!
@@ -17052,27 +17027,6 @@ __decorate([
17052
17027
  TriggeredNotification = __decorate([
17053
17028
  ObjectType()
17054
17029
  ], TriggeredNotification);
17055
- let DebugStringEntry = class DebugStringEntry {
17056
- };
17057
- __decorate([
17058
- Field(),
17059
- __metadata("design:type", String)
17060
- ], DebugStringEntry.prototype, "neighbourhoodUrl", void 0);
17061
- __decorate([
17062
- Field(),
17063
- __metadata("design:type", String)
17064
- ], DebugStringEntry.prototype, "debugString", void 0);
17065
- __decorate([
17066
- Field(),
17067
- __metadata("design:type", String)
17068
- ], DebugStringEntry.prototype, "operation", void 0);
17069
- __decorate([
17070
- Field(),
17071
- __metadata("design:type", String)
17072
- ], DebugStringEntry.prototype, "timestamp", void 0);
17073
- DebugStringEntry = __decorate([
17074
- ObjectType()
17075
- ], DebugStringEntry);
17076
17030
  let ImportStats = class ImportStats {
17077
17031
  };
17078
17032
  __decorate([
@@ -17179,10 +17133,6 @@ let RuntimeResolver = class RuntimeResolver {
17179
17133
  runtimeKnownLinkLanguageTemplates() {
17180
17134
  return ["Qm12345abcdef"];
17181
17135
  }
17182
- runtimeDebugStrings(neighbourhoodUrl) {
17183
- // Real implementation will be provided by the executor
17184
- return [];
17185
- }
17186
17136
  runtimeAddKnownLinkLanguageTemplates(addresses) {
17187
17137
  return addresses;
17188
17138
  }
@@ -17346,13 +17296,6 @@ __decorate([
17346
17296
  __metadata("design:paramtypes", []),
17347
17297
  __metadata("design:returntype", Array)
17348
17298
  ], RuntimeResolver.prototype, "runtimeKnownLinkLanguageTemplates", null);
17349
- __decorate([
17350
- Query(),
17351
- __param(0, Arg()),
17352
- __metadata("design:type", Function),
17353
- __metadata("design:paramtypes", [String]),
17354
- __metadata("design:returntype", Array)
17355
- ], RuntimeResolver.prototype, "runtimeDebugStrings", null);
17356
17299
  __decorate([
17357
17300
  Mutation(),
17358
17301
  __param(0, Arg()),
@@ -17860,7 +17803,14 @@ class Ad4mModel {
17860
17803
  if (resolve) {
17861
17804
  let resolvedExpression = await perspective.getExpression(value);
17862
17805
  if (resolvedExpression) {
17863
- finalValue = resolvedExpression.data;
17806
+ try {
17807
+ // Attempt to parse the data as JSON
17808
+ finalValue = JSON.parse(resolvedExpression.data);
17809
+ }
17810
+ catch (error) {
17811
+ // If parsing fails, keep the original data
17812
+ finalValue = resolvedExpression.data;
17813
+ }
17864
17814
  }
17865
17815
  }
17866
17816
  // Apply transform function if it exists
@@ -18632,4 +18582,4 @@ class ModelQueryBuilder {
18632
18582
  }
18633
18583
  }
18634
18584
 
18635
- export { AIClient, AIModelLoadingStatus, AIPromptExamples, AIPromptExamplesInput, AITask, AITaskInput, Ad4mClient, Ad4mModel, Agent, AgentClient, AgentExpression, AgentSignature, AgentStatus, Apps, AuthInfo, AuthInfoInput, Capability, CapabilityInput, Collection, DebugStringEntry, Dna, EntanglementProof, EntanglementProofInput, ExceptionInfo, ExceptionType, Expression, ExpressionGeneric, ExpressionGenericInput, ExpressionProof, ExpressionProofInput, ExpressionRef, ExpressionRendered, Flag, Icon, ImportResult, ImportStats, InstanceQuery, InteractionCall, InteractionMeta, InteractionParameter, LanguageExpression, LanguageHandle, LanguageLanguageInput, LanguageMeta, LanguageMetaInput, LanguageMetaInternal, LanguageRef, Link, LinkExpression, LinkExpressionInput, LinkExpressionMutations, LinkExpressionUpdated, LinkInput, LinkMutations, LinkQuery, Literal, ModelOptions, ModelQueryBuilder, Neighbourhood, NeighbourhoodExpression, NeighbourhoodProxy, Notification, NotificationInput, OnlineAgent, Optional, Perspective, PerspectiveAction, PerspectiveDiff, PerspectiveDiffExpression, PerspectiveExpression, PerspectiveHandle, PerspectiveInput, PerspectiveProxy, PerspectiveState, PerspectiveUnsignedInput, Property, QuerySubscriptionProxy, ReadOnly, Resource, ResourceInput, RuntimeInfo, SMART_LITERAL_CONTENT_PREDICATE, SentMessage, SmartLiteral, Subject, TriggeredNotification, addLink, capSentence, exprRef2String, formatList, hasLink, isExpression, isLink, linkEqual, makeRandomPrologAtom, parseExprUrl, typeDefsString };
18585
+ export { AIClient, AIModelLoadingStatus, AIPromptExamples, AIPromptExamplesInput, AITask, AITaskInput, Ad4mClient, Ad4mModel, Agent, AgentClient, AgentExpression, AgentSignature, AgentStatus, Apps, AuthInfo, AuthInfoInput, Capability, CapabilityInput, Collection, Dna, EntanglementProof, EntanglementProofInput, ExceptionInfo, ExceptionType, Expression, ExpressionGeneric, ExpressionGenericInput, ExpressionProof, ExpressionProofInput, ExpressionRef, ExpressionRendered, Flag, Icon, ImportResult, ImportStats, InstanceQuery, InteractionCall, InteractionMeta, InteractionParameter, LanguageExpression, LanguageHandle, LanguageLanguageInput, LanguageMeta, LanguageMetaInput, LanguageMetaInternal, LanguageRef, Link, LinkExpression, LinkExpressionInput, LinkExpressionMutations, LinkExpressionUpdated, LinkInput, LinkMutations, LinkQuery, Literal, ModelOptions, ModelQueryBuilder, Neighbourhood, NeighbourhoodExpression, NeighbourhoodProxy, Notification, NotificationInput, OnlineAgent, Optional, Perspective, PerspectiveAction, PerspectiveDiff, PerspectiveDiffExpression, PerspectiveExpression, PerspectiveHandle, PerspectiveInput, PerspectiveProxy, PerspectiveState, PerspectiveUnsignedInput, Property, QuerySubscriptionProxy, ReadOnly, Resource, ResourceInput, RuntimeInfo, SMART_LITERAL_CONTENT_PREDICATE, SentMessage, SmartLiteral, Subject, TriggeredNotification, addLink, capSentence, exprRef2String, formatList, hasLink, isExpression, isLink, linkEqual, makeRandomPrologAtom, parseExprUrl, typeDefsString };
@@ -118,7 +118,6 @@ export interface GetAllAdapter {
118
118
  }
119
119
  export type PerspectiveDiffObserver = (diff: PerspectiveDiff) => void;
120
120
  export type SyncStateChangeObserver = (state: PerspectiveState) => void;
121
- export type DebugStringObserver = (debugString: string, operation: string) => void;
122
121
  /** Interface for "Link Languages" that facilitate the synchronization
123
122
  * between agents' local Perspectives inside a Neighbourhood.
124
123
  * The assumption is that every version of the shared Perspective
@@ -149,8 +148,6 @@ export interface LinkSyncAdapter {
149
148
  addCallback(callback: PerspectiveDiffObserver): any;
150
149
  /** Add a sync state callback method */
151
150
  addSyncStateChangeCallback(callback: SyncStateChangeObserver): any;
152
- /** Add a debug string callback method for capturing internal debug information */
153
- addDebugStringCallback?(callback: DebugStringObserver): any;
154
151
  }
155
152
  export type MessageCallback = (message: PerspectiveExpression) => void;
156
153
  export type StatusCallback = (caller: DID) => Perspective;
@@ -318,7 +318,14 @@ export class Ad4mModel {
318
318
  if (resolve) {
319
319
  let resolvedExpression = await perspective.getExpression(value);
320
320
  if (resolvedExpression) {
321
- finalValue = resolvedExpression.data;
321
+ try {
322
+ // Attempt to parse the data as JSON
323
+ finalValue = JSON.parse(resolvedExpression.data);
324
+ }
325
+ catch (error) {
326
+ // If parsing fails, keep the original data
327
+ finalValue = resolvedExpression.data;
328
+ }
322
329
  }
323
330
  }
324
331
  // Apply transform function if it exists
@@ -252,9 +252,6 @@ export class NeighbourhoodClient {
252
252
  const index = handlersForPerspective.indexOf(handler);
253
253
  if (index > -1) {
254
254
  handlersForPerspective.splice(index, 1);
255
- if (!handlersForPerspective.length) {
256
- __classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").delete(perspectiveUUID);
257
- }
258
255
  }
259
256
  }
260
257
  }
@@ -28,4 +28,46 @@ describe("NeighbourhoodProxy", () => {
28
28
  neighbourhoodClient.dispatchSignal(neighbourhoodURI, true);
29
29
  expect(callbacks).toBe(2);
30
30
  });
31
+ it("should not add multiple subscriptions when removing and adding another signal handler", async () => {
32
+ const neighbourhoodURI = "did://123";
33
+ const subscriptions = [];
34
+ const subscribe = (args) => {
35
+ subscriptions.push(args);
36
+ new Promise((resolve) => {
37
+ setTimeout(() => {
38
+ resolve({});
39
+ }, 10);
40
+ });
41
+ };
42
+ const mockApolloClient = {
43
+ subscribe: () => ({
44
+ subscribe,
45
+ }),
46
+ };
47
+ const neighbourhoodClient = new NeighbourhoodClient(mockApolloClient);
48
+ const neighbourhoodProxy = new NeighbourhoodProxy(neighbourhoodClient, neighbourhoodURI);
49
+ let callbacks1 = 0;
50
+ let callbacks2 = 0;
51
+ const handler1 = () => {
52
+ callbacks1++;
53
+ };
54
+ const handler2 = () => {
55
+ callbacks2++;
56
+ };
57
+ // Add signal handler 1
58
+ await neighbourhoodProxy.addSignalHandler(handler1);
59
+ // Remove signal handler 2
60
+ neighbourhoodProxy.removeSignalHandler(handler1);
61
+ // Add signal handler 2
62
+ await neighbourhoodProxy.addSignalHandler(handler2);
63
+ // Check that only one subscription was added
64
+ expect(subscriptions.length).toBe(1);
65
+ // mock trigger signal event
66
+ for (const subscription of subscriptions) {
67
+ subscription.next({ data: { signal: { neighbourhoodSignal: true } } });
68
+ }
69
+ // Check that only our second callback was called
70
+ expect(callbacks1).toBe(0);
71
+ expect(callbacks2).toBe(1);
72
+ });
31
73
  });
@@ -20,10 +20,9 @@ export declare class RuntimeClient {
20
20
  addFriends(dids: string[]): Promise<string[]>;
21
21
  removeFriends(dids: string[]): Promise<string[]>;
22
22
  friends(): Promise<string[]>;
23
- hcAgentInfos(): Promise<String>;
24
- getNetworkMetrics(): Promise<String>;
25
- debugStrings(neighbourhoodUrl?: string): Promise<any[]>;
26
- restartHolochain(): Promise<Boolean>;
23
+ hcAgentInfos(): Promise<string>;
24
+ getNetworkMetrics(): Promise<string>;
25
+ restartHolochain(): Promise<boolean>;
27
26
  hcAddAgentInfos(agentInfos: String): Promise<void>;
28
27
  verifyStringSignedByDid(did: string, didSigningKeyId: string, data: string, signedData: string): Promise<boolean>;
29
28
  setStatus(perspective: Perspective): Promise<boolean>;
@@ -183,20 +183,6 @@ export class RuntimeClient {
183
183
  }));
184
184
  return runtimeGetNetworkMetrics;
185
185
  }
186
- async debugStrings(neighbourhoodUrl) {
187
- const { runtimeDebugStrings } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
188
- query: gql `query runtimeDebugStrings($neighbourhoodUrl: String) {
189
- runtimeDebugStrings(neighbourhoodUrl: $neighbourhoodUrl) {
190
- neighbourhoodUrl
191
- debugString
192
- operation
193
- timestamp
194
- }
195
- }`,
196
- variables: { neighbourhoodUrl }
197
- }));
198
- return runtimeDebugStrings;
199
- }
200
186
  async restartHolochain() {
201
187
  const { runtimeRestartHolochain } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
202
188
  mutation: gql `mutation runtimeRestartHolochain {
@@ -42,12 +42,6 @@ export declare class TriggeredNotification {
42
42
  perspectiveId: string;
43
43
  triggerMatch: string;
44
44
  }
45
- export declare class DebugStringEntry {
46
- neighbourhoodUrl: string;
47
- debugString: string;
48
- operation: string;
49
- timestamp: string;
50
- }
51
45
  export declare class ImportStats {
52
46
  total: number;
53
47
  imported: number;
@@ -82,15 +76,14 @@ export default class RuntimeResolver {
82
76
  deleteTrustedAgents(agents: string[]): string[];
83
77
  getTrustedAgents(): string[];
84
78
  runtimeKnownLinkLanguageTemplates(): string[];
85
- runtimeDebugStrings(neighbourhoodUrl?: string): DebugStringEntry[];
86
79
  runtimeAddKnownLinkLanguageTemplates(addresses: string[]): string[];
87
80
  runtimeRemoveKnownLinkLanguageTemplates(addresses: string[]): string[];
88
81
  runtimeFriends(): string[];
89
82
  runtimeAddFriends(dids: string[]): string[];
90
83
  runtimeRemoveFriends(dids: string[]): string[];
91
- runtimeHcAgentInfos(): String;
92
- runtimeGetNetworkMetrics(): String;
93
- runtimeRestartHolochain(): Boolean;
84
+ runtimeHcAgentInfos(): string;
85
+ runtimeGetNetworkMetrics(): string;
86
+ runtimeRestartHolochain(): boolean;
94
87
  runtimeHcAddAgentInfos(agentInfos: any): boolean;
95
88
  runtimeVerifyStringSignedByDid(did: string, didSigningKeyId: string, data: string, signedData: string): boolean;
96
89
  runtimeSetStatus(status: Perspective): boolean;
@@ -194,28 +194,6 @@ TriggeredNotification = __decorate([
194
194
  ObjectType()
195
195
  ], TriggeredNotification);
196
196
  export { TriggeredNotification };
197
- let DebugStringEntry = class DebugStringEntry {
198
- };
199
- __decorate([
200
- Field(),
201
- __metadata("design:type", String)
202
- ], DebugStringEntry.prototype, "neighbourhoodUrl", void 0);
203
- __decorate([
204
- Field(),
205
- __metadata("design:type", String)
206
- ], DebugStringEntry.prototype, "debugString", void 0);
207
- __decorate([
208
- Field(),
209
- __metadata("design:type", String)
210
- ], DebugStringEntry.prototype, "operation", void 0);
211
- __decorate([
212
- Field(),
213
- __metadata("design:type", String)
214
- ], DebugStringEntry.prototype, "timestamp", void 0);
215
- DebugStringEntry = __decorate([
216
- ObjectType()
217
- ], DebugStringEntry);
218
- export { DebugStringEntry };
219
197
  let ImportStats = class ImportStats {
220
198
  };
221
199
  __decorate([
@@ -324,10 +302,6 @@ let RuntimeResolver = class RuntimeResolver {
324
302
  runtimeKnownLinkLanguageTemplates() {
325
303
  return ["Qm12345abcdef"];
326
304
  }
327
- runtimeDebugStrings(neighbourhoodUrl) {
328
- // Real implementation will be provided by the executor
329
- return [];
330
- }
331
305
  runtimeAddKnownLinkLanguageTemplates(addresses) {
332
306
  return addresses;
333
307
  }
@@ -491,13 +465,6 @@ __decorate([
491
465
  __metadata("design:paramtypes", []),
492
466
  __metadata("design:returntype", Array)
493
467
  ], RuntimeResolver.prototype, "runtimeKnownLinkLanguageTemplates", null);
494
- __decorate([
495
- Query(returns => [DebugStringEntry]),
496
- __param(0, Arg("neighbourhoodUrl", type => String, { nullable: true })),
497
- __metadata("design:type", Function),
498
- __metadata("design:paramtypes", [String]),
499
- __metadata("design:returntype", Array)
500
- ], RuntimeResolver.prototype, "runtimeDebugStrings", null);
501
468
  __decorate([
502
469
  Mutation(returns => [String]),
503
470
  __param(0, Arg("addresses", type => [String])),
@@ -96,13 +96,6 @@ input CapabilityInput {
96
96
  # The javascript `Date` as string. Type represents date and time as the ISO Date string.
97
97
  scalar DateTime
98
98
 
99
- type DebugStringEntry {
100
- debugString: String!
101
- neighbourhoodUrl: String!
102
- operation: String!
103
- timestamp: String!
104
- }
105
-
106
99
  type EntanglementProof {
107
100
  deviceKey: String!
108
101
  deviceKeySignedByDid: String!
@@ -479,7 +472,6 @@ type Query {
479
472
  perspectiveQueryProlog(query: String!, uuid: String!): String!
480
473
  perspectiveSnapshot(uuid: String!): Perspective
481
474
  perspectives: [PerspectiveHandle!]!
482
- runtimeDebugStrings(neighbourhoodUrl: String): [DebugStringEntry!]!
483
475
  runtimeFriendStatus(did: String!): PerspectiveExpression
484
476
  runtimeFriends: [String!]!
485
477
  runtimeGetNetworkMetrics: String!
@@ -92,13 +92,6 @@ input CapabilityInput {
92
92
 
93
93
  scalar DateTime
94
94
 
95
- type DebugStringEntry {
96
- debugString: String!
97
- neighbourhoodUrl: String!
98
- operation: String!
99
- timestamp: String!
100
- }
101
-
102
95
  type EntanglementProof {
103
96
  deviceKey: String!
104
97
  deviceKeySignedByDid: String!
@@ -475,7 +468,6 @@ type Query {
475
468
  perspectiveQueryProlog(query: String!, uuid: String!): String!
476
469
  perspectiveSnapshot(uuid: String!): Perspective
477
470
  perspectives: [PerspectiveHandle!]!
478
- runtimeDebugStrings(neighbourhoodUrl: String): [DebugStringEntry!]!
479
471
  runtimeFriendStatus(did: String!): PerspectiveExpression
480
472
  runtimeFriends: [String!]!
481
473
  runtimeGetNetworkMetrics: String!
package/package.json CHANGED
@@ -5,6 +5,7 @@
5
5
  "module": "lib/index.js",
6
6
  "types": "lib/src/index.d.ts",
7
7
  "type": "module",
8
+ "private": false,
8
9
  "scripts": {
9
10
  "build": "patch-package && tsc && pnpm run buildSchema && pnpm run bundle",
10
11
  "buildSchema": "node --es-module-specifier-resolution=node lib/src/buildSchema.js",
@@ -68,5 +69,5 @@
68
69
  "graphql@15.7.2": "patches/graphql@15.7.2.patch"
69
70
  }
70
71
  },
71
- "version": "0.10.1-release-candidate-4-debug-strings"
72
+ "version": "0.10.1-release-candidate-4"
72
73
  }
@@ -148,9 +148,8 @@ export interface GetAllAdapter {
148
148
  getAll(filter: any, count: number, page: number): Promise<Expression[] | null>;
149
149
  }
150
150
 
151
- export type PerspectiveDiffObserver = (diff: PerspectiveDiff) => void;
152
- export type SyncStateChangeObserver = (state: PerspectiveState) => void;
153
- export type DebugStringObserver = (debugString: string, operation: string) => void;
151
+ export type PerspectiveDiffObserver = (diff: PerspectiveDiff)=>void;
152
+ export type SyncStateChangeObserver = (state: PerspectiveState)=>void;
154
153
 
155
154
  /** Interface for "Link Languages" that facilitate the synchronization
156
155
  * between agents' local Perspectives inside a Neighbourhood.
@@ -188,9 +187,6 @@ export interface LinkSyncAdapter {
188
187
 
189
188
  /** Add a sync state callback method */
190
189
  addSyncStateChangeCallback(callback: SyncStateChangeObserver);
191
-
192
- /** Add a debug string callback method for capturing internal debug information */
193
- addDebugStringCallback?(callback: DebugStringObserver);
194
190
  }
195
191
 
196
192
  export type MessageCallback = (message: PerspectiveExpression) => void;
@@ -345,11 +345,7 @@ export class Ad4mModel {
345
345
  return this.#perspective;
346
346
  }
347
347
 
348
- public static async assignValuesToInstance(
349
- perspective: PerspectiveProxy,
350
- instance: Ad4mModel,
351
- values: ValueTuple[]
352
- ) {
348
+ public static async assignValuesToInstance(perspective: PerspectiveProxy, instance: Ad4mModel, values: ValueTuple[]) {
353
349
  // Map properties to object
354
350
  const propsObject = Object.fromEntries(
355
351
  await Promise.all(
@@ -359,7 +355,13 @@ export class Ad4mModel {
359
355
  if (resolve) {
360
356
  let resolvedExpression = await perspective.getExpression(value);
361
357
  if (resolvedExpression) {
362
- finalValue = resolvedExpression.data;
358
+ try {
359
+ // Attempt to parse the data as JSON
360
+ finalValue = JSON.parse(resolvedExpression.data);
361
+ } catch (error) {
362
+ // If parsing fails, keep the original data
363
+ finalValue = resolvedExpression.data;
364
+ }
363
365
  }
364
366
  }
365
367
  // Apply transform function if it exists
@@ -273,9 +273,6 @@ export class NeighbourhoodClient {
273
273
  const index = handlersForPerspective.indexOf(handler)
274
274
  if (index > -1) {
275
275
  handlersForPerspective.splice(index, 1)
276
- if (!handlersForPerspective.length) {
277
- this.#signalHandlers.delete(perspectiveUUID)
278
- }
279
276
  }
280
277
  }
281
278
  }
@@ -1,5 +1,3 @@
1
- import { ApolloClient } from "@apollo/client";
2
- import { LinkExpression } from "../links/Links";
3
1
  import { NeighbourhoodClient } from "./NeighbourhoodClient";
4
2
  import { NeighbourhoodProxy } from "./NeighbourhoodProxy";
5
3
 
@@ -42,4 +40,61 @@ describe("NeighbourhoodProxy", () => {
42
40
 
43
41
  expect(callbacks).toBe(2);
44
42
  });
43
+
44
+ it("should not add multiple subscriptions when removing and adding another signal handler", async () => {
45
+ const neighbourhoodURI = "did://123";
46
+
47
+ const subscriptions = [];
48
+ const subscribe = (args: { next: (result: any) => void }) => {
49
+ subscriptions.push(args);
50
+ new Promise((resolve) => {
51
+ setTimeout(() => {
52
+ resolve({});
53
+ }, 10);
54
+ });
55
+ };
56
+
57
+ const mockApolloClient = {
58
+ subscribe: () => ({
59
+ subscribe,
60
+ }),
61
+ } as any;
62
+
63
+ const neighbourhoodClient = new NeighbourhoodClient(mockApolloClient);
64
+ const neighbourhoodProxy = new NeighbourhoodProxy(
65
+ neighbourhoodClient,
66
+ neighbourhoodURI
67
+ );
68
+
69
+ let callbacks1 = 0;
70
+ let callbacks2 = 0;
71
+
72
+ const handler1 = () => {
73
+ callbacks1++;
74
+ };
75
+ const handler2 = () => {
76
+ callbacks2++;
77
+ };
78
+
79
+ // Add signal handler 1
80
+ await neighbourhoodProxy.addSignalHandler(handler1);
81
+
82
+ // Remove signal handler 2
83
+ neighbourhoodProxy.removeSignalHandler(handler1);
84
+
85
+ // Add signal handler 2
86
+ await neighbourhoodProxy.addSignalHandler(handler2);
87
+
88
+ // Check that only one subscription was added
89
+ expect(subscriptions.length).toBe(1);
90
+
91
+ // mock trigger signal event
92
+ for (const subscription of subscriptions) {
93
+ subscription.next({ data: { signal: { neighbourhoodSignal: true } } });
94
+ }
95
+
96
+ // Check that only our second callback was called
97
+ expect(callbacks1).toBe(0);
98
+ expect(callbacks2).toBe(1);
99
+ });
45
100
  });
@@ -183,7 +183,7 @@ export class RuntimeClient {
183
183
  return runtimeFriends
184
184
  }
185
185
 
186
- async hcAgentInfos(): Promise<String> {
186
+ async hcAgentInfos(): Promise<string> {
187
187
  const { runtimeHcAgentInfos } = unwrapApolloResult(await this.#apolloClient.query({
188
188
  query: gql`query runtimeHcAgentInfos {
189
189
  runtimeHcAgentInfos
@@ -192,7 +192,7 @@ export class RuntimeClient {
192
192
  return runtimeHcAgentInfos
193
193
  }
194
194
 
195
- async getNetworkMetrics(): Promise<String> {
195
+ async getNetworkMetrics(): Promise<string> {
196
196
  const { runtimeGetNetworkMetrics } = unwrapApolloResult(await this.#apolloClient.query({
197
197
  query: gql`query runtimeGetNetworkMetrics {
198
198
  runtimeGetNetworkMetrics
@@ -201,22 +201,7 @@ export class RuntimeClient {
201
201
  return runtimeGetNetworkMetrics
202
202
  }
203
203
 
204
- async debugStrings(neighbourhoodUrl?: string): Promise<any[]> {
205
- const { runtimeDebugStrings } = unwrapApolloResult(await this.#apolloClient.query({
206
- query: gql`query runtimeDebugStrings($neighbourhoodUrl: String) {
207
- runtimeDebugStrings(neighbourhoodUrl: $neighbourhoodUrl) {
208
- neighbourhoodUrl
209
- debugString
210
- operation
211
- timestamp
212
- }
213
- }`,
214
- variables: { neighbourhoodUrl }
215
- }))
216
- return runtimeDebugStrings
217
- }
218
-
219
- async restartHolochain(): Promise<Boolean> {
204
+ async restartHolochain(): Promise<boolean> {
220
205
  const { runtimeRestartHolochain } = unwrapApolloResult(await this.#apolloClient.mutate({
221
206
  mutation: gql`mutation runtimeRestartHolochain {
222
207
  runtimeRestartHolochain
@@ -138,21 +138,6 @@ export class TriggeredNotification {
138
138
  triggerMatch: string;
139
139
  }
140
140
 
141
- @ObjectType()
142
- export class DebugStringEntry {
143
- @Field()
144
- neighbourhoodUrl: string;
145
-
146
- @Field()
147
- debugString: string;
148
-
149
- @Field()
150
- operation: string;
151
-
152
- @Field()
153
- timestamp: string;
154
- }
155
-
156
141
  @ObjectType()
157
142
  export class ImportStats {
158
143
  @Field()
@@ -254,12 +239,6 @@ export default class RuntimeResolver {
254
239
  return ["Qm12345abcdef"]
255
240
  }
256
241
 
257
- @Query(returns => [DebugStringEntry])
258
- runtimeDebugStrings(@Arg("neighbourhoodUrl", type => String, {nullable: true}) neighbourhoodUrl?: string): DebugStringEntry[] {
259
- // Real implementation will be provided by the executor
260
- return []
261
- }
262
-
263
242
  @Mutation(returns => [String])
264
243
  runtimeAddKnownLinkLanguageTemplates(@Arg("addresses", type => [String]) addresses: string[]): string[] {
265
244
  return addresses
@@ -286,12 +265,12 @@ export default class RuntimeResolver {
286
265
  }
287
266
 
288
267
  @Query()
289
- runtimeHcAgentInfos(): String {
268
+ runtimeHcAgentInfos(): string {
290
269
  return JSON.stringify([{"agent":{"type":"Buffer","data":[9,191,231,58,255,107,202,55,206,57,9,103,17,34,206,195,207,114,5,73,77,198,56,136,17,227,242,231,194,135,128,48,170,189,119,186]},"signature":{"type":"Buffer","data":[195,143,170,36,234,123,255,85,188,138,124,2,91,18,53,231,44,41,240,8,80,131,100,150,165,125,146,90,17,200,190,129,114,211,11,146,150,128,198,199,79,118,157,101,194,68,58,245,98,182,79,139,140,41,143,129,8,136,87,77,180,231,218,11]},"agent_info":{"type":"Buffer","data":[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,9,191,231,58,255,107,202,55,206,57,9,103,17,34,206,195,207,114,5,73,77,198,56,136,17,227,242,231,194,135,128,48,170,189,119,186,164,117,114,108,115,145,217,99,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,101,83,52,86,112,54,109,118,80,48,122,116,85,101,104,114,117,113,89,52,102,66,53,101,69,98,121,48,69,66,100,89,84,50,95,67,48,69,112,77,111,76,111,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,57,50,46,49,54,56,46,49,55,56,46,54,48,47,112,47,55,55,52,52,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,104,189,50,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}},{"agent":{"type":"Buffer","data":[98,187,145,48,115,209,94,143,31,153,102,69,138,29,133,213,34,52,39,164,157,139,178,111,23,33,118,250,28,155,78,246,128,49,179,38]},"signature":{"type":"Buffer","data":[233,192,38,3,59,248,124,231,57,255,40,154,50,60,119,252,68,198,154,109,175,155,106,217,211,155,109,223,249,91,221,210,17,132,72,230,11,230,247,119,72,244,145,91,75,7,67,5,130,151,44,231,52,220,28,154,212,82,58,90,203,211,236,4]},"agent_info":{"type":"Buffer","data":[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,98,187,145,48,115,209,94,143,31,153,102,69,138,29,133,213,34,52,39,164,157,139,178,111,23,33,118,250,28,155,78,246,128,49,179,38,164,117,114,108,115,145,217,99,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,55,101,77,106,48,73,83,72,56,56,81,56,45,89,51,74,89,70,53,76,72,57,83,54,68,119,71,73,49,88,45,115,87,53,68,104,66,87,121,71,119,78,115,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,57,50,46,49,54,56,46,49,55,56,46,54,48,47,112,47,55,55,52,52,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,103,45,197,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}},{"agent":{"type":"Buffer","data":[181,101,115,45,214,127,198,153,159,184,30,87,67,224,208,184,203,176,130,158,236,127,153,125,243,183,188,167,154,25,118,254,101,145,210,109]},"signature":{"type":"Buffer","data":[88,189,229,122,44,171,194,156,90,79,148,49,207,224,34,199,219,88,24,243,103,127,123,41,87,171,127,92,6,216,198,171,26,226,237,217,122,78,98,146,55,255,68,240,202,83,58,140,147,185,3,66,15,216,210,22,99,197,73,234,120,17,74,1]},"agent_info":{"type":"Buffer","data":[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,181,101,115,45,214,127,198,153,159,184,30,87,67,224,208,184,203,176,130,158,236,127,153,125,243,183,188,167,154,25,118,254,101,145,210,109,164,117,114,108,115,145,217,99,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,114,70,71,83,100,113,104,101,68,107,70,70,56,69,102,109,45,69,116,55,119,81,101,120,83,88,55,65,112,69,51,89,86,99,45,120,102,52,104,106,77,115,77,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,57,50,46,49,54,56,46,49,55,56,46,54,48,47,112,47,55,55,52,52,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,113,23,220,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}},{"agent":{"type":"Buffer","data":[3,171,237,107,186,245,165,47,237,235,211,49,245,62,113,53,255,252,223,226,75,118,148,187,23,53,70,174,160,184,64,63,94,210,227,56]},"signature":{"type":"Buffer","data":[129,12,55,104,239,121,138,2,86,106,136,51,219,79,170,8,195,69,81,188,225,192,247,196,54,39,164,110,75,39,240,56,245,189,154,77,72,11,97,250,202,149,242,97,128,28,47,164,236,104,136,82,212,246,44,143,132,119,255,135,112,11,20,13]},"agent_info":{"type":"Buffer","data":[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,3,171,237,107,186,245,165,47,237,235,211,49,245,62,113,53,255,252,223,226,75,118,148,187,23,53,70,174,160,184,64,63,94,210,227,56,164,117,114,108,115,145,217,97,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,104,121,112,115,86,121,103,117,80,84,115,53,118,73,80,65,102,97,112,90,88,113,117,84,115,79,80,100,67,81,79,79,117,103,57,51,82,103,106,95,114,85,73,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,54,53,46,50,50,46,51,50,46,49,49,47,112,47,53,55,55,57,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,113,188,123,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}}])
291
270
  }
292
271
 
293
272
  @Query()
294
- runtimeGetNetworkMetrics(): String {
273
+ runtimeGetNetworkMetrics(): string {
295
274
  return JSON.stringify({
296
275
  "metrics": {},
297
276
  "stats": {}
@@ -299,7 +278,7 @@ export default class RuntimeResolver {
299
278
  }
300
279
 
301
280
  @Mutation(returns => Boolean)
302
- runtimeRestartHolochain(): Boolean {
281
+ runtimeRestartHolochain(): boolean {
303
282
  return true
304
283
  }
305
284