@coasys/ad4m 0.10.1-release-candidate-4-debug-strings-2 → 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(languageAddress) {
7200
- const { runtimeDebugStrings } = unwrapApolloResult(await __classPrivateFieldGet$5(this, _RuntimeClient_apolloClient, "f").query({
7201
- query: gql `query runtimeDebugStrings($languageAddress: String) {
7202
- runtimeDebugStrings(languageAddress: $languageAddress) {
7203
- languageAddress
7204
- operation
7205
- debugString
7206
- timestamp
7207
- }
7208
- }`,
7209
- variables: { languageAddress }
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 {
@@ -15461,12 +15444,12 @@ var __metadata$2 = (undefined && undefined.__metadata) || function (k, v) {
15461
15444
  };
15462
15445
  exports.PerspectiveState = void 0;
15463
15446
  (function (PerspectiveState) {
15464
- PerspectiveState["Private"] = "Private";
15465
- PerspectiveState["NeighboudhoodCreationInitiated"] = "NeighboudhoodCreationInitiated";
15466
- PerspectiveState["NeighbourhoodJoinInitiated"] = "NeighbourhoodJoinInitiated";
15467
- PerspectiveState["LinkLanguageFailedToInstall"] = "LinkLanguageFailedToInstall";
15468
- PerspectiveState["LinkLanguageInstalledButNotSynced"] = "LinkLanguageInstalledButNotSynced";
15469
- PerspectiveState["Synced"] = "Synced";
15447
+ PerspectiveState["Private"] = "PRIVATE";
15448
+ PerspectiveState["NeighboudhoodCreationInitiated"] = "NEIGHBOURHOOD_CREATION_INITIATED";
15449
+ PerspectiveState["NeighbourhoodJoinInitiated"] = "NEIGHBOURHOOD_JOIN_INITIATED";
15450
+ PerspectiveState["LinkLanguageFailedToInstall"] = "LINK_LANGUAGE_FAILED_TO_INSTALL";
15451
+ PerspectiveState["LinkLanguageInstalledButNotSynced"] = "LINK_LANGUAGE_INSTALLED_BUT_NOT_SYNCED";
15452
+ PerspectiveState["Synced"] = "SYNCED";
15470
15453
  })(exports.PerspectiveState || (exports.PerspectiveState = {}));
15471
15454
  // This type is used in the GraphQL interface to reference a mutable
15472
15455
  // prespective that is implemented locally by the Ad4m runtime.
@@ -16383,13 +16366,6 @@ input CapabilityInput {
16383
16366
 
16384
16367
  scalar DateTime
16385
16368
 
16386
- type DebugStringEntry {
16387
- debugString: String!
16388
- languageAddress: 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(languageAddress: 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, "languageAddress", 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,15 +17137,6 @@ let RuntimeResolver = class RuntimeResolver {
17183
17137
  runtimeKnownLinkLanguageTemplates() {
17184
17138
  return ["Qm12345abcdef"];
17185
17139
  }
17186
- runtimeDebugStrings(languageAddress) {
17187
- // Mock data for testing - in real implementation this would come from stored debug strings
17188
- return [{
17189
- languageAddress: "Qm123example",
17190
- debugString: "Debug string content",
17191
- operation: "merge",
17192
- timestamp: new Date().toISOString()
17193
- }];
17194
- }
17195
17140
  runtimeAddKnownLinkLanguageTemplates(addresses) {
17196
17141
  return addresses;
17197
17142
  }
@@ -17355,13 +17300,6 @@ __decorate([
17355
17300
  __metadata("design:paramtypes", []),
17356
17301
  __metadata("design:returntype", Array)
17357
17302
  ], RuntimeResolver.prototype, "runtimeKnownLinkLanguageTemplates", null);
17358
- __decorate([
17359
- Query(),
17360
- __param(0, Arg()),
17361
- __metadata("design:type", Function),
17362
- __metadata("design:paramtypes", [String]),
17363
- __metadata("design:returntype", Array)
17364
- ], RuntimeResolver.prototype, "runtimeDebugStrings", null);
17365
17303
  __decorate([
17366
17304
  Mutation(),
17367
17305
  __param(0, Arg()),
@@ -17869,7 +17807,14 @@ class Ad4mModel {
17869
17807
  if (resolve) {
17870
17808
  let resolvedExpression = await perspective.getExpression(value);
17871
17809
  if (resolvedExpression) {
17872
- 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
+ }
17873
17818
  }
17874
17819
  }
17875
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(languageAddress) {
7196
- const { runtimeDebugStrings } = unwrapApolloResult(await __classPrivateFieldGet$5(this, _RuntimeClient_apolloClient, "f").query({
7197
- query: gql `query runtimeDebugStrings($languageAddress: String) {
7198
- runtimeDebugStrings(languageAddress: $languageAddress) {
7199
- languageAddress
7200
- operation
7201
- debugString
7202
- timestamp
7203
- }
7204
- }`,
7205
- variables: { languageAddress }
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 {
@@ -15457,12 +15440,12 @@ var __metadata$2 = (undefined && undefined.__metadata) || function (k, v) {
15457
15440
  };
15458
15441
  var PerspectiveState;
15459
15442
  (function (PerspectiveState) {
15460
- PerspectiveState["Private"] = "Private";
15461
- PerspectiveState["NeighboudhoodCreationInitiated"] = "NeighboudhoodCreationInitiated";
15462
- PerspectiveState["NeighbourhoodJoinInitiated"] = "NeighbourhoodJoinInitiated";
15463
- PerspectiveState["LinkLanguageFailedToInstall"] = "LinkLanguageFailedToInstall";
15464
- PerspectiveState["LinkLanguageInstalledButNotSynced"] = "LinkLanguageInstalledButNotSynced";
15465
- PerspectiveState["Synced"] = "Synced";
15443
+ PerspectiveState["Private"] = "PRIVATE";
15444
+ PerspectiveState["NeighboudhoodCreationInitiated"] = "NEIGHBOURHOOD_CREATION_INITIATED";
15445
+ PerspectiveState["NeighbourhoodJoinInitiated"] = "NEIGHBOURHOOD_JOIN_INITIATED";
15446
+ PerspectiveState["LinkLanguageFailedToInstall"] = "LINK_LANGUAGE_FAILED_TO_INSTALL";
15447
+ PerspectiveState["LinkLanguageInstalledButNotSynced"] = "LINK_LANGUAGE_INSTALLED_BUT_NOT_SYNCED";
15448
+ PerspectiveState["Synced"] = "SYNCED";
15466
15449
  })(PerspectiveState || (PerspectiveState = {}));
15467
15450
  // This type is used in the GraphQL interface to reference a mutable
15468
15451
  // prespective that is implemented locally by the Ad4m runtime.
@@ -16379,13 +16362,6 @@ input CapabilityInput {
16379
16362
 
16380
16363
  scalar DateTime
16381
16364
 
16382
- type DebugStringEntry {
16383
- debugString: String!
16384
- languageAddress: 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(languageAddress: 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, "languageAddress", 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,15 +17133,6 @@ let RuntimeResolver = class RuntimeResolver {
17179
17133
  runtimeKnownLinkLanguageTemplates() {
17180
17134
  return ["Qm12345abcdef"];
17181
17135
  }
17182
- runtimeDebugStrings(languageAddress) {
17183
- // Mock data for testing - in real implementation this would come from stored debug strings
17184
- return [{
17185
- languageAddress: "Qm123example",
17186
- debugString: "Debug string content",
17187
- operation: "merge",
17188
- timestamp: new Date().toISOString()
17189
- }];
17190
- }
17191
17136
  runtimeAddKnownLinkLanguageTemplates(addresses) {
17192
17137
  return addresses;
17193
17138
  }
@@ -17351,13 +17296,6 @@ __decorate([
17351
17296
  __metadata("design:paramtypes", []),
17352
17297
  __metadata("design:returntype", Array)
17353
17298
  ], RuntimeResolver.prototype, "runtimeKnownLinkLanguageTemplates", null);
17354
- __decorate([
17355
- Query(),
17356
- __param(0, Arg()),
17357
- __metadata("design:type", Function),
17358
- __metadata("design:paramtypes", [String]),
17359
- __metadata("design:returntype", Array)
17360
- ], RuntimeResolver.prototype, "runtimeDebugStrings", null);
17361
17299
  __decorate([
17362
17300
  Mutation(),
17363
17301
  __param(0, Arg()),
@@ -17865,7 +17803,14 @@ class Ad4mModel {
17865
17803
  if (resolve) {
17866
17804
  let resolvedExpression = await perspective.getExpression(value);
17867
17805
  if (resolvedExpression) {
17868
- 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
+ }
17869
17814
  }
17870
17815
  }
17871
17816
  // Apply transform function if it exists
@@ -18637,4 +18582,4 @@ class ModelQueryBuilder {
18637
18582
  }
18638
18583
  }
18639
18584
 
18640
- 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
  });
@@ -1,11 +1,11 @@
1
1
  import { NeighbourhoodExpression } from "../neighbourhood/Neighbourhood";
2
2
  export declare enum PerspectiveState {
3
- Private = "Private",
4
- NeighboudhoodCreationInitiated = "NeighboudhoodCreationInitiated",
5
- NeighbourhoodJoinInitiated = "NeighbourhoodJoinInitiated",
6
- LinkLanguageFailedToInstall = "LinkLanguageFailedToInstall",
7
- LinkLanguageInstalledButNotSynced = "LinkLanguageInstalledButNotSynced",
8
- Synced = "Synced"
3
+ Private = "PRIVATE",
4
+ NeighboudhoodCreationInitiated = "NEIGHBOURHOOD_CREATION_INITIATED",
5
+ NeighbourhoodJoinInitiated = "NEIGHBOURHOOD_JOIN_INITIATED",
6
+ LinkLanguageFailedToInstall = "LINK_LANGUAGE_FAILED_TO_INSTALL",
7
+ LinkLanguageInstalledButNotSynced = "LINK_LANGUAGE_INSTALLED_BUT_NOT_SYNCED",
8
+ Synced = "SYNCED"
9
9
  }
10
10
  export declare class PerspectiveHandle {
11
11
  uuid: string;
@@ -11,12 +11,12 @@ import { Field, ObjectType } from "type-graphql";
11
11
  import { NeighbourhoodExpression } from "../neighbourhood/Neighbourhood";
12
12
  export var PerspectiveState;
13
13
  (function (PerspectiveState) {
14
- PerspectiveState["Private"] = "Private";
15
- PerspectiveState["NeighboudhoodCreationInitiated"] = "NeighboudhoodCreationInitiated";
16
- PerspectiveState["NeighbourhoodJoinInitiated"] = "NeighbourhoodJoinInitiated";
17
- PerspectiveState["LinkLanguageFailedToInstall"] = "LinkLanguageFailedToInstall";
18
- PerspectiveState["LinkLanguageInstalledButNotSynced"] = "LinkLanguageInstalledButNotSynced";
19
- PerspectiveState["Synced"] = "Synced";
14
+ PerspectiveState["Private"] = "PRIVATE";
15
+ PerspectiveState["NeighboudhoodCreationInitiated"] = "NEIGHBOURHOOD_CREATION_INITIATED";
16
+ PerspectiveState["NeighbourhoodJoinInitiated"] = "NEIGHBOURHOOD_JOIN_INITIATED";
17
+ PerspectiveState["LinkLanguageFailedToInstall"] = "LINK_LANGUAGE_FAILED_TO_INSTALL";
18
+ PerspectiveState["LinkLanguageInstalledButNotSynced"] = "LINK_LANGUAGE_INSTALLED_BUT_NOT_SYNCED";
19
+ PerspectiveState["Synced"] = "SYNCED";
20
20
  })(PerspectiveState || (PerspectiveState = {}));
21
21
  // This type is used in the GraphQL interface to reference a mutable
22
22
  // prespective that is implemented locally by the Ad4m runtime.
@@ -22,7 +22,6 @@ export declare class RuntimeClient {
22
22
  friends(): Promise<string[]>;
23
23
  hcAgentInfos(): Promise<string>;
24
24
  getNetworkMetrics(): Promise<string>;
25
- debugStrings(languageAddress?: string): Promise<any[]>;
26
25
  restartHolochain(): Promise<boolean>;
27
26
  hcAddAgentInfos(agentInfos: String): Promise<void>;
28
27
  verifyStringSignedByDid(did: string, didSigningKeyId: string, data: string, signedData: string): Promise<boolean>;
@@ -183,20 +183,6 @@ export class RuntimeClient {
183
183
  }));
184
184
  return runtimeGetNetworkMetrics;
185
185
  }
186
- async debugStrings(languageAddress) {
187
- const { runtimeDebugStrings } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
188
- query: gql `query runtimeDebugStrings($languageAddress: String) {
189
- runtimeDebugStrings(languageAddress: $languageAddress) {
190
- languageAddress
191
- operation
192
- debugString
193
- timestamp
194
- }
195
- }`,
196
- variables: { languageAddress }
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
- languageAddress: 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,7 +76,6 @@ export default class RuntimeResolver {
82
76
  deleteTrustedAgents(agents: string[]): string[];
83
77
  getTrustedAgents(): string[];
84
78
  runtimeKnownLinkLanguageTemplates(): string[];
85
- runtimeDebugStrings(languageAddress?: string): DebugStringEntry[];
86
79
  runtimeAddKnownLinkLanguageTemplates(addresses: string[]): string[];
87
80
  runtimeRemoveKnownLinkLanguageTemplates(addresses: string[]): string[];
88
81
  runtimeFriends(): string[];
@@ -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, "languageAddress", 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,15 +302,6 @@ let RuntimeResolver = class RuntimeResolver {
324
302
  runtimeKnownLinkLanguageTemplates() {
325
303
  return ["Qm12345abcdef"];
326
304
  }
327
- runtimeDebugStrings(languageAddress) {
328
- // Mock data for testing - in real implementation this would come from stored debug strings
329
- return [{
330
- languageAddress: "Qm123example",
331
- debugString: "Debug string content",
332
- operation: "merge",
333
- timestamp: new Date().toISOString()
334
- }];
335
- }
336
305
  runtimeAddKnownLinkLanguageTemplates(addresses) {
337
306
  return addresses;
338
307
  }
@@ -496,13 +465,6 @@ __decorate([
496
465
  __metadata("design:paramtypes", []),
497
466
  __metadata("design:returntype", Array)
498
467
  ], RuntimeResolver.prototype, "runtimeKnownLinkLanguageTemplates", null);
499
- __decorate([
500
- Query(returns => [DebugStringEntry]),
501
- __param(0, Arg("languageAddress", type => String, { nullable: true })),
502
- __metadata("design:type", Function),
503
- __metadata("design:paramtypes", [String]),
504
- __metadata("design:returntype", Array)
505
- ], RuntimeResolver.prototype, "runtimeDebugStrings", null);
506
468
  __decorate([
507
469
  Mutation(returns => [String]),
508
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
- languageAddress: 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(languageAddress: 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
- languageAddress: 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(languageAddress: String): [DebugStringEntry!]!
479
471
  runtimeFriendStatus(did: String!): PerspectiveExpression
480
472
  runtimeFriends: [String!]!
481
473
  runtimeGetNetworkMetrics: String!
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "module": "lib/index.js",
6
6
  "types": "lib/src/index.d.ts",
7
7
  "type": "module",
8
-
8
+ "private": false,
9
9
  "scripts": {
10
10
  "build": "patch-package && tsc && pnpm run buildSchema && pnpm run bundle",
11
11
  "buildSchema": "node --es-module-specifier-resolution=node lib/src/buildSchema.js",
@@ -69,5 +69,5 @@
69
69
  "graphql@15.7.2": "patches/graphql@15.7.2.patch"
70
70
  }
71
71
  },
72
- "version": "0.10.1-release-candidate-4-debug-strings-2"
72
+ "version": "0.10.1-release-candidate-4"
73
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
  });
@@ -2,12 +2,12 @@ import { Field, ObjectType } from "type-graphql";
2
2
  import { NeighbourhoodExpression } from "../neighbourhood/Neighbourhood";
3
3
 
4
4
  export enum PerspectiveState {
5
- Private = "Private",
6
- NeighboudhoodCreationInitiated = "NeighboudhoodCreationInitiated",
7
- NeighbourhoodJoinInitiated = "NeighbourhoodJoinInitiated",
8
- LinkLanguageFailedToInstall = "LinkLanguageFailedToInstall",
9
- LinkLanguageInstalledButNotSynced = "LinkLanguageInstalledButNotSynced",
10
- Synced = "Synced",
5
+ Private = "PRIVATE",
6
+ NeighboudhoodCreationInitiated = "NEIGHBOURHOOD_CREATION_INITIATED",
7
+ NeighbourhoodJoinInitiated = "NEIGHBOURHOOD_JOIN_INITIATED",
8
+ LinkLanguageFailedToInstall = "LINK_LANGUAGE_FAILED_TO_INSTALL",
9
+ LinkLanguageInstalledButNotSynced = "LINK_LANGUAGE_INSTALLED_BUT_NOT_SYNCED",
10
+ Synced = "SYNCED",
11
11
  }
12
12
  // This type is used in the GraphQL interface to reference a mutable
13
13
  // prespective that is implemented locally by the Ad4m runtime.
@@ -201,21 +201,6 @@ export class RuntimeClient {
201
201
  return runtimeGetNetworkMetrics
202
202
  }
203
203
 
204
- async debugStrings(languageAddress?: string): Promise<any[]> {
205
- const { runtimeDebugStrings } = unwrapApolloResult(await this.#apolloClient.query({
206
- query: gql`query runtimeDebugStrings($languageAddress: String) {
207
- runtimeDebugStrings(languageAddress: $languageAddress) {
208
- languageAddress
209
- operation
210
- debugString
211
- timestamp
212
- }
213
- }`,
214
- variables: { languageAddress }
215
- }))
216
- return runtimeDebugStrings
217
- }
218
-
219
204
  async restartHolochain(): Promise<boolean> {
220
205
  const { runtimeRestartHolochain } = unwrapApolloResult(await this.#apolloClient.mutate({
221
206
  mutation: gql`mutation 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
- languageAddress: 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,17 +239,6 @@ export default class RuntimeResolver {
254
239
  return ["Qm12345abcdef"]
255
240
  }
256
241
 
257
- @Query(returns => [DebugStringEntry])
258
- runtimeDebugStrings(@Arg("languageAddress", type => String, {nullable: true}) languageAddress?: string): DebugStringEntry[] {
259
- // Mock data for testing - in real implementation this would come from stored debug strings
260
- return [{
261
- languageAddress: "Qm123example",
262
- debugString: "Debug string content",
263
- operation: "merge",
264
- timestamp: new Date().toISOString()
265
- }]
266
- }
267
-
268
242
  @Mutation(returns => [String])
269
243
  runtimeAddKnownLinkLanguageTemplates(@Arg("addresses", type => [String]) addresses: string[]): string[] {
270
244
  return addresses