@olane/o-core 0.7.12-alpha.4 → 0.7.12-alpha.41

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 (91) hide show
  1. package/dist/src/connection/interfaces/connection-manager.config.d.ts +12 -0
  2. package/dist/src/connection/interfaces/connection-manager.config.d.ts.map +1 -1
  3. package/dist/src/connection/interfaces/connection-send-params.interface.d.ts +1 -0
  4. package/dist/src/connection/interfaces/connection-send-params.interface.d.ts.map +1 -1
  5. package/dist/src/connection/interfaces/connection.config.d.ts +12 -0
  6. package/dist/src/connection/interfaces/connection.config.d.ts.map +1 -1
  7. package/dist/src/connection/o-connection-manager.d.ts +0 -1
  8. package/dist/src/connection/o-connection-manager.d.ts.map +1 -1
  9. package/dist/src/connection/o-connection-manager.js +1 -15
  10. package/dist/src/connection/o-connection.d.ts +4 -0
  11. package/dist/src/connection/o-connection.d.ts.map +1 -1
  12. package/dist/src/connection/o-connection.js +10 -2
  13. package/dist/src/connection/o-response.d.ts +1 -0
  14. package/dist/src/connection/o-response.d.ts.map +1 -1
  15. package/dist/src/connection/o-response.js +7 -0
  16. package/dist/src/core/interfaces/index.d.ts +3 -0
  17. package/dist/src/core/interfaces/index.d.ts.map +1 -1
  18. package/dist/src/core/interfaces/index.js +3 -0
  19. package/dist/src/core/interfaces/use-options.interface.d.ts +10 -0
  20. package/dist/src/core/interfaces/use-options.interface.d.ts.map +1 -0
  21. package/dist/src/core/interfaces/use-options.interface.js +1 -0
  22. package/dist/src/core/interfaces/use-stream-options.interface.d.ts +4 -0
  23. package/dist/src/core/interfaces/use-stream-options.interface.d.ts.map +1 -0
  24. package/dist/src/core/interfaces/use-stream-options.interface.js +1 -0
  25. package/dist/src/core/lib/events/connection-events.d.ts +31 -0
  26. package/dist/src/core/lib/events/connection-events.d.ts.map +1 -0
  27. package/dist/src/core/lib/events/connection-events.js +46 -0
  28. package/dist/src/core/lib/events/hierarchy-events.d.ts +69 -0
  29. package/dist/src/core/lib/events/hierarchy-events.d.ts.map +1 -0
  30. package/dist/src/core/lib/events/hierarchy-events.js +100 -0
  31. package/dist/src/core/lib/events/index.d.ts +6 -0
  32. package/dist/src/core/lib/events/index.d.ts.map +1 -0
  33. package/dist/src/core/lib/events/index.js +5 -0
  34. package/dist/src/core/lib/events/node-events.d.ts +40 -0
  35. package/dist/src/core/lib/events/node-events.d.ts.map +1 -0
  36. package/dist/src/core/lib/events/node-events.js +58 -0
  37. package/dist/src/core/lib/events/o-notification-event.d.ts +26 -0
  38. package/dist/src/core/lib/events/o-notification-event.d.ts.map +1 -0
  39. package/dist/src/core/lib/events/o-notification-event.js +30 -0
  40. package/dist/src/core/lib/index.d.ts +4 -0
  41. package/dist/src/core/lib/index.d.ts.map +1 -1
  42. package/dist/src/core/lib/index.js +4 -0
  43. package/dist/src/core/lib/interfaces/notification-types.d.ts +49 -0
  44. package/dist/src/core/lib/interfaces/notification-types.d.ts.map +1 -0
  45. package/dist/src/core/lib/interfaces/notification-types.js +1 -0
  46. package/dist/src/core/lib/o-notification.manager.d.ts +58 -0
  47. package/dist/src/core/lib/o-notification.manager.d.ts.map +1 -0
  48. package/dist/src/core/lib/o-notification.manager.js +159 -0
  49. package/dist/src/core/lib/utils/event-filters.d.ts +38 -0
  50. package/dist/src/core/lib/utils/event-filters.d.ts.map +1 -0
  51. package/dist/src/core/lib/utils/event-filters.js +159 -0
  52. package/dist/src/core/o-core.d.ts +46 -2
  53. package/dist/src/core/o-core.d.ts.map +1 -1
  54. package/dist/src/core/o-core.js +122 -43
  55. package/dist/src/error/enums/codes.error.d.ts +2 -1
  56. package/dist/src/error/enums/codes.error.d.ts.map +1 -1
  57. package/dist/src/error/enums/codes.error.js +1 -0
  58. package/dist/src/index.d.ts +1 -0
  59. package/dist/src/index.d.ts.map +1 -1
  60. package/dist/src/index.js +1 -0
  61. package/dist/src/response/index.d.ts +2 -0
  62. package/dist/src/response/index.d.ts.map +1 -0
  63. package/dist/src/response/index.js +1 -0
  64. package/dist/src/response/response-builder.d.ts +140 -0
  65. package/dist/src/response/response-builder.d.ts.map +1 -0
  66. package/dist/src/response/response-builder.js +190 -0
  67. package/dist/src/streaming/index.d.ts +11 -0
  68. package/dist/src/streaming/index.d.ts.map +1 -0
  69. package/dist/src/streaming/index.js +14 -0
  70. package/dist/src/streaming/protocol-builder.d.ts +62 -0
  71. package/dist/src/streaming/protocol-builder.d.ts.map +1 -0
  72. package/dist/src/streaming/protocol-builder.js +93 -0
  73. package/dist/src/streaming/stream-config.d.ts +36 -0
  74. package/dist/src/streaming/stream-config.d.ts.map +1 -0
  75. package/dist/src/streaming/stream-config.js +19 -0
  76. package/dist/src/streaming/stream-handler.base.d.ts +85 -0
  77. package/dist/src/streaming/stream-handler.base.d.ts.map +1 -0
  78. package/dist/src/streaming/stream-handler.base.js +112 -0
  79. package/dist/src/streaming/stream-transport.interface.d.ts +61 -0
  80. package/dist/src/streaming/stream-transport.interface.d.ts.map +1 -0
  81. package/dist/src/streaming/stream-transport.interface.js +10 -0
  82. package/dist/src/utils/core.utils.d.ts +7 -4
  83. package/dist/src/utils/core.utils.d.ts.map +1 -1
  84. package/dist/src/utils/core.utils.js +26 -16
  85. package/dist/src/utils/logger.d.ts +2 -0
  86. package/dist/src/utils/logger.d.ts.map +1 -1
  87. package/dist/src/utils/logger.js +7 -2
  88. package/dist/src/utils/streaming.utils.d.ts +22 -0
  89. package/dist/src/utils/streaming.utils.d.ts.map +1 -0
  90. package/dist/src/utils/streaming.utils.js +45 -0
  91. package/package.json +11 -3
@@ -1,3 +1,15 @@
1
1
  export interface oConnectionManagerConfig {
2
+ /**
3
+ * Default timeout in milliseconds for reading response data from a stream.
4
+ * Can be overridden per connection.
5
+ * Default: 120000 (2 minutes)
6
+ */
7
+ defaultReadTimeoutMs?: number;
8
+ /**
9
+ * Default timeout in milliseconds for waiting for stream buffer to drain when backpressure occurs.
10
+ * Can be overridden per connection.
11
+ * Default: 30000 (30 seconds)
12
+ */
13
+ defaultDrainTimeoutMs?: number;
2
14
  }
3
15
  //# sourceMappingURL=connection-manager.config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"connection-manager.config.d.ts","sourceRoot":"","sources":["../../../../src/connection/interfaces/connection-manager.config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,wBAAwB;CAAG"}
1
+ {"version":3,"file":"connection-manager.config.d.ts","sourceRoot":"","sources":["../../../../src/connection/interfaces/connection-manager.config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC"}
@@ -4,5 +4,6 @@ export interface ConnectionSendParams {
4
4
  [key: string]: unknown;
5
5
  };
6
6
  id?: string;
7
+ isStream?: boolean;
7
8
  }
8
9
  //# sourceMappingURL=connection-send-params.interface.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"connection-send-params.interface.d.ts","sourceRoot":"","sources":["../../../../src/connection/interfaces/connection-send-params.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE;QACP,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,EAAE,CAAC,EAAE,MAAM,CAAC;CACb"}
1
+ {"version":3,"file":"connection-send-params.interface.d.ts","sourceRoot":"","sources":["../../../../src/connection/interfaces/connection-send-params.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE;QACP,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
@@ -3,5 +3,17 @@ export interface oConnectionConfig {
3
3
  nextHopAddress: oAddress;
4
4
  callerAddress?: oAddress;
5
5
  address: oAddress;
6
+ /**
7
+ * Timeout in milliseconds for reading response data from a stream.
8
+ * Default: 120000 (2 minutes)
9
+ */
10
+ readTimeoutMs?: number;
11
+ /**
12
+ * Timeout in milliseconds for waiting for stream buffer to drain when backpressure occurs.
13
+ * Default: 30000 (30 seconds)
14
+ */
15
+ drainTimeoutMs?: number;
16
+ isStream?: boolean;
17
+ abortSignal?: AbortSignal;
6
18
  }
7
19
  //# sourceMappingURL=connection.config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"connection.config.d.ts","sourceRoot":"","sources":["../../../../src/connection/interfaces/connection.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,QAAQ,CAAC;IACzB,aAAa,CAAC,EAAE,QAAQ,CAAC;IACzB,OAAO,EAAE,QAAQ,CAAC;CACnB"}
1
+ {"version":3,"file":"connection.config.d.ts","sourceRoot":"","sources":["../../../../src/connection/interfaces/connection.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,QAAQ,CAAC;IACzB,aAAa,CAAC,EAAE,QAAQ,CAAC;IACzB,OAAO,EAAE,QAAQ,CAAC;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B"}
@@ -5,7 +5,6 @@ import { oObject } from '../core/o-object.js';
5
5
  import { oConnectionConfig } from './interfaces/connection.config.js';
6
6
  export declare abstract class oConnectionManager extends oObject {
7
7
  readonly config: oConnectionManagerConfig;
8
- protected cache: Map<string, oConnection>;
9
8
  constructor(config: oConnectionManagerConfig);
10
9
  /**
11
10
  * Connect to a given address
@@ -1 +1 @@
1
- {"version":3,"file":"o-connection-manager.d.ts","sourceRoot":"","sources":["../../../src/connection/o-connection-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AACrF,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,8BAAsB,kBAAmB,SAAQ,OAAO;IAG1C,QAAQ,CAAC,MAAM,EAAE,wBAAwB;IAFrD,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAa;gBAEjC,MAAM,EAAE,wBAAwB;IAIrD;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;IAEjE,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO;IAIpC,mBAAmB,CAAC,OAAO,EAAE,QAAQ,GAAG,WAAW,GAAG,IAAI;CAe3D"}
1
+ {"version":3,"file":"o-connection-manager.d.ts","sourceRoot":"","sources":["../../../src/connection/o-connection-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AACrF,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,8BAAsB,kBAAmB,SAAQ,OAAO;IAC1C,QAAQ,CAAC,MAAM,EAAE,wBAAwB;gBAAhC,MAAM,EAAE,wBAAwB;IAIrD;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;IAEjE,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO;IAIpC,mBAAmB,CAAC,OAAO,EAAE,QAAQ,GAAG,WAAW,GAAG,IAAI;CAG3D"}
@@ -3,25 +3,11 @@ export class oConnectionManager extends oObject {
3
3
  constructor(config) {
4
4
  super();
5
5
  this.config = config;
6
- this.cache = new Map();
7
6
  }
8
7
  isCached(address) {
9
- return this.cache.has(address.toString());
8
+ return false;
10
9
  }
11
10
  getCachedConnection(address) {
12
- const key = address.toString();
13
- try {
14
- const connection = this.cache.get(key);
15
- if (!connection) {
16
- throw new Error('Connection not found in cache');
17
- }
18
- connection.validate();
19
- return connection;
20
- }
21
- catch (error) {
22
- this.cache.delete(key);
23
- this.logger.error('Error getting cached connection:', error);
24
- }
25
11
  return null;
26
12
  }
27
13
  }
@@ -4,13 +4,17 @@ import { oResponse } from './o-response.js';
4
4
  import { ConnectionSendParams } from './interfaces/connection-send-params.interface.js';
5
5
  import { oObject } from '../core/o-object.js';
6
6
  import { oConnectionConfig } from './interfaces/connection.config.js';
7
+ import { EventEmitter } from 'events';
7
8
  export declare abstract class oConnection extends oObject {
8
9
  protected readonly config: oConnectionConfig;
9
10
  readonly id: string;
10
11
  readonly address: oAddress;
11
12
  readonly nextHopAddress: oAddress;
12
13
  readonly callerAddress: oAddress | undefined;
14
+ protected readonly emitter: EventEmitter;
13
15
  constructor(config: oConnectionConfig);
16
+ get abortSignal(): AbortSignal | undefined;
17
+ onChunk(listener: (response: oResponse) => void): void;
14
18
  validate(): void;
15
19
  createRequest(method: string, params: ConnectionSendParams): oRequest;
16
20
  abstract transmit(request: oRequest): Promise<oResponse>;
@@ -1 +1 @@
1
- {"version":3,"file":"o-connection.d.ts","sourceRoot":"","sources":["../../../src/connection/o-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAC;AAExF,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,8BAAsB,WAAY,SAAQ,OAAO;IAMnC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,iBAAiB;IALxD,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,SAAgB,OAAO,EAAE,QAAQ,CAAC;IAClC,SAAgB,cAAc,EAAE,QAAQ,CAAC;IACzC,SAAgB,aAAa,EAAE,QAAQ,GAAG,SAAS,CAAC;gBAErB,MAAM,EAAE,iBAAiB;IAgBxD,QAAQ,IAAI,IAAI;IAMhB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,GAAG,QAAQ;IAarE,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;IAElD,IAAI,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,SAAS,CAAC;IAOpD,KAAK;CAGZ"}
1
+ {"version":3,"file":"o-connection.d.ts","sourceRoot":"","sources":["../../../src/connection/o-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAC;AAExF,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,8BAAsB,WAAY,SAAQ,OAAO;IAOnC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,iBAAiB;IANxD,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,SAAgB,OAAO,EAAE,QAAQ,CAAC;IAClC,SAAgB,cAAc,EAAE,QAAQ,CAAC;IACzC,SAAgB,aAAa,EAAE,QAAQ,GAAG,SAAS,CAAC;IACpD,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAsB;gBAE/B,MAAM,EAAE,iBAAiB;IAgBxD,IAAI,WAAW,IAAI,WAAW,GAAG,SAAS,CAEzC;IAED,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,SAAS,KAAK,IAAI;IAI/C,QAAQ,IAAI,IAAI;IAMhB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,GAAG,QAAQ;IAcrE,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;IAElD,IAAI,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,SAAS,CAAC;IAMpD,KAAK;CAGZ"}
@@ -2,10 +2,12 @@ import { oRequest } from './o-request.js';
2
2
  import { oProtocolMethods } from '@olane/o-protocol';
3
3
  import { v4 as uuidv4 } from 'uuid';
4
4
  import { oObject } from '../core/o-object.js';
5
+ import { EventEmitter } from 'events';
5
6
  export class oConnection extends oObject {
6
7
  constructor(config) {
7
8
  super();
8
9
  this.config = config;
10
+ this.emitter = new EventEmitter();
9
11
  this.id = uuidv4();
10
12
  this.address = config.address;
11
13
  this.nextHopAddress = config.nextHopAddress;
@@ -17,6 +19,12 @@ export class oConnection extends oObject {
17
19
  ']:' +
18
20
  this.id);
19
21
  }
22
+ get abortSignal() {
23
+ return this.config.abortSignal;
24
+ }
25
+ onChunk(listener) {
26
+ this.emitter.addListener('chunk', listener);
27
+ }
20
28
  validate() {
21
29
  if (!this.address || !this.nextHopAddress || !this.callerAddress) {
22
30
  throw new Error('Connection configuration is invalid');
@@ -29,6 +37,7 @@ export class oConnection extends oObject {
29
37
  _connectionId: this.id,
30
38
  _requestMethod: method,
31
39
  _callerAddress: this.callerAddress?.value,
40
+ _isStreaming: this.config.isStream ?? false,
32
41
  ...params,
33
42
  },
34
43
  id: params.id || uuidv4(),
@@ -37,8 +46,7 @@ export class oConnection extends oObject {
37
46
  async send(data) {
38
47
  // proxy through the router tool
39
48
  const request = this.createRequest(oProtocolMethods.ROUTE, data);
40
- const result = await this.transmit(request);
41
- return result;
49
+ return this.transmit(request);
42
50
  }
43
51
  async close() {
44
52
  this.logger.debug('Closing connection...');
@@ -8,5 +8,6 @@ export declare class oResponse implements Response {
8
8
  });
9
9
  toJSON(): any;
10
10
  toString(): string;
11
+ static fromJSON(json: any): oResponse;
11
12
  }
12
13
  //# sourceMappingURL=o-response.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"o-response.d.ts","sourceRoot":"","sources":["../../../src/connection/o-response.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,SAAS,EACT,SAAS,IAAI,QAAQ,EACrB,MAAM,EACP,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,SAAU,YAAW,QAAQ;IACxC,OAAO,EAAE,OAAO,eAAe,CAAC;IAChC,EAAE,EAAE,SAAS,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;gBAEH,MAAM,EAAE,MAAM,GAAG;QAAE,EAAE,EAAE,SAAS,CAAA;KAAE;IAM9C,MAAM,IAAI,GAAG;IAQb,QAAQ,IAAI,MAAM;CAGnB"}
1
+ {"version":3,"file":"o-response.d.ts","sourceRoot":"","sources":["../../../src/connection/o-response.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,SAAS,EACT,SAAS,IAAI,QAAQ,EACrB,MAAM,EACP,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,SAAU,YAAW,QAAQ;IACxC,OAAO,EAAE,OAAO,eAAe,CAAC;IAChC,EAAE,EAAE,SAAS,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;gBAEH,MAAM,EAAE,MAAM,GAAG;QAAE,EAAE,EAAE,SAAS,CAAA;KAAE;IAM9C,MAAM,IAAI,GAAG;IAQb,QAAQ,IAAI,MAAM;IAIlB,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,GAAG,SAAS;CAOtC"}
@@ -15,4 +15,11 @@ export class oResponse {
15
15
  toString() {
16
16
  return JSON.stringify(this);
17
17
  }
18
+ static fromJSON(json) {
19
+ return new oResponse({
20
+ ...json.result,
21
+ _connectionId: json.result?._connectionId,
22
+ _requestMethod: json.result?._requestMethod,
23
+ });
24
+ }
18
25
  }
@@ -1,4 +1,7 @@
1
1
  export * from './o-core.config.js';
2
2
  export * from './node-type.enum.js';
3
3
  export * from './state.enum.js';
4
+ export * from './use-options.interface.js';
5
+ export * from './o-core.interface.js';
6
+ export * from './use-stream-options.interface.js';
4
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,mCAAmC,CAAC"}
@@ -1,3 +1,6 @@
1
1
  export * from './o-core.config.js';
2
2
  export * from './node-type.enum.js';
3
3
  export * from './state.enum.js';
4
+ export * from './use-options.interface.js';
5
+ export * from './o-core.interface.js';
6
+ export * from './use-stream-options.interface.js';
@@ -0,0 +1,10 @@
1
+ import { oResponse } from '../../connection/o-response.js';
2
+ export interface UseOptions {
3
+ readTimeoutMs?: number;
4
+ drainTimeoutMs?: number;
5
+ isStream?: boolean;
6
+ onChunk?: (chunk: oResponse) => void;
7
+ noRouting?: boolean;
8
+ abortSignal?: AbortSignal;
9
+ }
10
+ //# sourceMappingURL=use-options.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-options.interface.d.ts","sourceRoot":"","sources":["../../../../src/core/interfaces/use-options.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,MAAM,WAAW,UAAU;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IACrC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { UseOptions } from './use-options.interface';
2
+ export interface UseStreamOptions extends Omit<UseOptions, 'isStream'> {
3
+ }
4
+ //# sourceMappingURL=use-stream-options.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-stream-options.interface.d.ts","sourceRoot":"","sources":["../../../../src/core/interfaces/use-stream-options.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC;CAAG"}
@@ -0,0 +1,31 @@
1
+ import { oAddress } from '../../../router/o-address.js';
2
+ import { oNotificationEvent } from './o-notification-event.js';
3
+ /**
4
+ * Emitted when a connection becomes degraded (some pings failing)
5
+ */
6
+ export declare class ConnectionDegradedEvent extends oNotificationEvent {
7
+ readonly targetAddress: oAddress;
8
+ readonly role: 'parent' | 'child';
9
+ readonly consecutiveFailures: number;
10
+ constructor(config: {
11
+ source: oAddress;
12
+ targetAddress: oAddress;
13
+ role: 'parent' | 'child';
14
+ consecutiveFailures: number;
15
+ });
16
+ protected getEventData(): Record<string, any>;
17
+ }
18
+ /**
19
+ * Emitted when a degraded connection recovers
20
+ */
21
+ export declare class ConnectionRecoveredEvent extends oNotificationEvent {
22
+ readonly targetAddress: oAddress;
23
+ readonly role: 'parent' | 'child';
24
+ constructor(config: {
25
+ source: oAddress;
26
+ targetAddress: oAddress;
27
+ role: 'parent' | 'child';
28
+ });
29
+ protected getEventData(): Record<string, any>;
30
+ }
31
+ //# sourceMappingURL=connection-events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection-events.d.ts","sourceRoot":"","sources":["../../../../../src/core/lib/events/connection-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EACL,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;AAEnC;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,kBAAkB;IAC7D,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC;IAClC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;gBAEzB,MAAM,EAAE;QAClB,MAAM,EAAE,QAAQ,CAAC;QACjB,aAAa,EAAE,QAAQ,CAAC;QACxB,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC;QACzB,mBAAmB,EAAE,MAAM,CAAC;KAC7B;IAcD,SAAS,CAAC,YAAY,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAO9C;AAED;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,kBAAkB;IAC9D,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC;gBAEtB,MAAM,EAAE;QAClB,MAAM,EAAE,QAAQ,CAAC;QACjB,aAAa,EAAE,QAAQ,CAAC;QACxB,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC;KAC1B;IAUD,SAAS,CAAC,YAAY,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAM9C"}
@@ -0,0 +1,46 @@
1
+ import { oNotificationEvent, } from './o-notification-event.js';
2
+ /**
3
+ * Emitted when a connection becomes degraded (some pings failing)
4
+ */
5
+ export class ConnectionDegradedEvent extends oNotificationEvent {
6
+ constructor(config) {
7
+ super({
8
+ type: 'connection:degraded',
9
+ source: config.source,
10
+ metadata: {
11
+ role: config.role,
12
+ consecutiveFailures: config.consecutiveFailures,
13
+ },
14
+ });
15
+ this.targetAddress = config.targetAddress;
16
+ this.role = config.role;
17
+ this.consecutiveFailures = config.consecutiveFailures;
18
+ }
19
+ getEventData() {
20
+ return {
21
+ targetAddress: this.targetAddress.toString(),
22
+ role: this.role,
23
+ consecutiveFailures: this.consecutiveFailures,
24
+ };
25
+ }
26
+ }
27
+ /**
28
+ * Emitted when a degraded connection recovers
29
+ */
30
+ export class ConnectionRecoveredEvent extends oNotificationEvent {
31
+ constructor(config) {
32
+ super({
33
+ type: 'connection:recovered',
34
+ source: config.source,
35
+ metadata: { role: config.role },
36
+ });
37
+ this.targetAddress = config.targetAddress;
38
+ this.role = config.role;
39
+ }
40
+ getEventData() {
41
+ return {
42
+ targetAddress: this.targetAddress.toString(),
43
+ role: this.role,
44
+ };
45
+ }
46
+ }
@@ -0,0 +1,69 @@
1
+ import { oAddress } from '../../../router/o-address.js';
2
+ import { oNotificationEvent } from './o-notification-event.js';
3
+ /**
4
+ * Emitted when a child node joins the hierarchy (registers with parent)
5
+ */
6
+ export declare class ChildJoinedEvent extends oNotificationEvent {
7
+ readonly childAddress: oAddress;
8
+ readonly parentAddress: oAddress;
9
+ constructor(config: {
10
+ source: oAddress;
11
+ childAddress: oAddress;
12
+ parentAddress: oAddress;
13
+ });
14
+ protected getEventData(): Record<string, any>;
15
+ }
16
+ /**
17
+ * Emitted when a child node leaves the hierarchy (unregisters or disconnects)
18
+ */
19
+ export declare class ChildLeftEvent extends oNotificationEvent {
20
+ readonly childAddress: oAddress;
21
+ readonly parentAddress: oAddress;
22
+ readonly reason?: string;
23
+ constructor(config: {
24
+ source: oAddress;
25
+ childAddress: oAddress;
26
+ parentAddress: oAddress;
27
+ reason?: string;
28
+ });
29
+ protected getEventData(): Record<string, any>;
30
+ }
31
+ /**
32
+ * Emitted when a parent connection is established
33
+ */
34
+ export declare class ParentConnectedEvent extends oNotificationEvent {
35
+ readonly parentAddress: oAddress;
36
+ constructor(config: {
37
+ source: oAddress;
38
+ parentAddress: oAddress;
39
+ });
40
+ protected getEventData(): Record<string, any>;
41
+ }
42
+ /**
43
+ * Emitted when a parent connection is lost
44
+ */
45
+ export declare class ParentDisconnectedEvent extends oNotificationEvent {
46
+ readonly parentAddress: oAddress;
47
+ readonly reason?: string;
48
+ constructor(config: {
49
+ source: oAddress;
50
+ parentAddress: oAddress;
51
+ reason?: string;
52
+ });
53
+ protected getEventData(): Record<string, any>;
54
+ }
55
+ /**
56
+ * Emitted when connection to leader is lost (CRITICAL)
57
+ * This is a catastrophic failure - node cannot function without leader
58
+ */
59
+ export declare class LeaderDisconnectedEvent extends oNotificationEvent {
60
+ readonly leaderAddress: oAddress;
61
+ readonly reason?: string;
62
+ constructor(config: {
63
+ source: oAddress;
64
+ leaderAddress: oAddress;
65
+ reason?: string;
66
+ });
67
+ protected getEventData(): Record<string, any>;
68
+ }
69
+ //# sourceMappingURL=hierarchy-events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hierarchy-events.d.ts","sourceRoot":"","sources":["../../../../../src/core/lib/events/hierarchy-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EACL,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;AAEnC;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,kBAAkB;IACtD,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC;IAChC,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC;gBAErB,MAAM,EAAE;QAClB,MAAM,EAAE,QAAQ,CAAC;QACjB,YAAY,EAAE,QAAQ,CAAC;QACvB,aAAa,EAAE,QAAQ,CAAC;KACzB;IASD,SAAS,CAAC,YAAY,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAM9C;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,kBAAkB;IACpD,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC;IAChC,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;gBAEb,MAAM,EAAE;QAClB,MAAM,EAAE,QAAQ,CAAC;QACjB,YAAY,EAAE,QAAQ,CAAC;QACvB,aAAa,EAAE,QAAQ,CAAC;QACxB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAWD,SAAS,CAAC,YAAY,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAO9C;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,kBAAkB;IAC1D,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC;gBAErB,MAAM,EAAE;QAAE,MAAM,EAAE,QAAQ,CAAC;QAAC,aAAa,EAAE,QAAQ,CAAA;KAAE;IAQjE,SAAS,CAAC,YAAY,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAK9C;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,kBAAkB;IAC7D,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;gBAEb,MAAM,EAAE;QAClB,MAAM,EAAE,QAAQ,CAAC;QACjB,aAAa,EAAE,QAAQ,CAAC;QACxB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAUD,SAAS,CAAC,YAAY,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAM9C;AAED;;;GAGG;AACH,qBAAa,uBAAwB,SAAQ,kBAAkB;IAC7D,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;gBAEb,MAAM,EAAE;QAClB,MAAM,EAAE,QAAQ,CAAC;QACjB,aAAa,EAAE,QAAQ,CAAC;QACxB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAUD,SAAS,CAAC,YAAY,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAM9C"}
@@ -0,0 +1,100 @@
1
+ import { oNotificationEvent, } from './o-notification-event.js';
2
+ /**
3
+ * Emitted when a child node joins the hierarchy (registers with parent)
4
+ */
5
+ export class ChildJoinedEvent extends oNotificationEvent {
6
+ constructor(config) {
7
+ super({
8
+ type: 'child:joined',
9
+ source: config.source,
10
+ });
11
+ this.childAddress = config.childAddress;
12
+ this.parentAddress = config.parentAddress;
13
+ }
14
+ getEventData() {
15
+ return {
16
+ childAddress: this.childAddress.toString(),
17
+ parentAddress: this.parentAddress.toString(),
18
+ };
19
+ }
20
+ }
21
+ /**
22
+ * Emitted when a child node leaves the hierarchy (unregisters or disconnects)
23
+ */
24
+ export class ChildLeftEvent extends oNotificationEvent {
25
+ constructor(config) {
26
+ super({
27
+ type: 'child:left',
28
+ source: config.source,
29
+ metadata: { reason: config.reason },
30
+ });
31
+ this.childAddress = config.childAddress;
32
+ this.parentAddress = config.parentAddress;
33
+ this.reason = config.reason;
34
+ }
35
+ getEventData() {
36
+ return {
37
+ childAddress: this.childAddress.toString(),
38
+ parentAddress: this.parentAddress.toString(),
39
+ reason: this.reason,
40
+ };
41
+ }
42
+ }
43
+ /**
44
+ * Emitted when a parent connection is established
45
+ */
46
+ export class ParentConnectedEvent extends oNotificationEvent {
47
+ constructor(config) {
48
+ super({
49
+ type: 'parent:connected',
50
+ source: config.source,
51
+ });
52
+ this.parentAddress = config.parentAddress;
53
+ }
54
+ getEventData() {
55
+ return {
56
+ parentAddress: this.parentAddress.toString(),
57
+ };
58
+ }
59
+ }
60
+ /**
61
+ * Emitted when a parent connection is lost
62
+ */
63
+ export class ParentDisconnectedEvent extends oNotificationEvent {
64
+ constructor(config) {
65
+ super({
66
+ type: 'parent:disconnected',
67
+ source: config.source,
68
+ metadata: { reason: config.reason },
69
+ });
70
+ this.parentAddress = config.parentAddress;
71
+ this.reason = config.reason;
72
+ }
73
+ getEventData() {
74
+ return {
75
+ parentAddress: this.parentAddress.toString(),
76
+ reason: this.reason,
77
+ };
78
+ }
79
+ }
80
+ /**
81
+ * Emitted when connection to leader is lost (CRITICAL)
82
+ * This is a catastrophic failure - node cannot function without leader
83
+ */
84
+ export class LeaderDisconnectedEvent extends oNotificationEvent {
85
+ constructor(config) {
86
+ super({
87
+ type: 'leader:disconnected',
88
+ source: config.source,
89
+ metadata: { reason: config.reason },
90
+ });
91
+ this.leaderAddress = config.leaderAddress;
92
+ this.reason = config.reason;
93
+ }
94
+ getEventData() {
95
+ return {
96
+ leaderAddress: this.leaderAddress.toString(),
97
+ reason: this.reason,
98
+ };
99
+ }
100
+ }
@@ -0,0 +1,6 @@
1
+ export * from './o-notification-event.js';
2
+ export * from './node-events.js';
3
+ export * from './hierarchy-events.js';
4
+ export * from './connection-events.js';
5
+ export * from '../interfaces/notification-types.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/lib/events/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qCAAqC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './o-notification-event.js';
2
+ export * from './node-events.js';
3
+ export * from './hierarchy-events.js';
4
+ export * from './connection-events.js';
5
+ export * from '../interfaces/notification-types.js';
@@ -0,0 +1,40 @@
1
+ import { oAddress } from '../../../router/o-address.js';
2
+ import { oNotificationEvent } from './o-notification-event.js';
3
+ /**
4
+ * Emitted when a node establishes a connection (transport-agnostic)
5
+ */
6
+ export declare class NodeConnectedEvent extends oNotificationEvent {
7
+ readonly nodeAddress: oAddress;
8
+ readonly connectionMetadata: Record<string, any>;
9
+ constructor(config: {
10
+ source: oAddress;
11
+ nodeAddress: oAddress;
12
+ connectionMetadata?: Record<string, any>;
13
+ });
14
+ protected getEventData(): Record<string, any>;
15
+ }
16
+ /**
17
+ * Emitted when a node disconnects (transport-agnostic)
18
+ */
19
+ export declare class NodeDisconnectedEvent extends oNotificationEvent {
20
+ readonly nodeAddress: oAddress;
21
+ readonly reason?: string;
22
+ constructor(config: {
23
+ source: oAddress;
24
+ nodeAddress: oAddress;
25
+ reason?: string;
26
+ });
27
+ protected getEventData(): Record<string, any>;
28
+ }
29
+ /**
30
+ * Emitted when a node is discovered but not yet connected
31
+ */
32
+ export declare class NodeDiscoveredEvent extends oNotificationEvent {
33
+ readonly nodeAddress: oAddress;
34
+ constructor(config: {
35
+ source: oAddress;
36
+ nodeAddress: oAddress;
37
+ });
38
+ protected getEventData(): Record<string, any>;
39
+ }
40
+ //# sourceMappingURL=node-events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-events.d.ts","sourceRoot":"","sources":["../../../../../src/core/lib/events/node-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EACL,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;AAEnC;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,kBAAkB;IACxD,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC;IAC/B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;gBAErC,MAAM,EAAE;QAClB,MAAM,EAAE,QAAQ,CAAC;QACjB,WAAW,EAAE,QAAQ,CAAC;QACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC1C;IAUD,SAAS,CAAC,YAAY,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAM9C;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,kBAAkB;IAC3D,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC;IAC/B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;gBAEb,MAAM,EAAE;QAClB,MAAM,EAAE,QAAQ,CAAC;QACjB,WAAW,EAAE,QAAQ,CAAC;QACtB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAUD,SAAS,CAAC,YAAY,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAM9C;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,kBAAkB;IACzD,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC;gBAEnB,MAAM,EAAE;QAAE,MAAM,EAAE,QAAQ,CAAC;QAAC,WAAW,EAAE,QAAQ,CAAA;KAAE;IAQ/D,SAAS,CAAC,YAAY,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAK9C"}
@@ -0,0 +1,58 @@
1
+ import { oNotificationEvent, } from './o-notification-event.js';
2
+ /**
3
+ * Emitted when a node establishes a connection (transport-agnostic)
4
+ */
5
+ export class NodeConnectedEvent extends oNotificationEvent {
6
+ constructor(config) {
7
+ super({
8
+ type: 'node:connected',
9
+ source: config.source,
10
+ metadata: config.connectionMetadata || {},
11
+ });
12
+ this.nodeAddress = config.nodeAddress;
13
+ this.connectionMetadata = config.connectionMetadata || {};
14
+ }
15
+ getEventData() {
16
+ return {
17
+ nodeAddress: this.nodeAddress.toString(),
18
+ connectionMetadata: this.connectionMetadata,
19
+ };
20
+ }
21
+ }
22
+ /**
23
+ * Emitted when a node disconnects (transport-agnostic)
24
+ */
25
+ export class NodeDisconnectedEvent extends oNotificationEvent {
26
+ constructor(config) {
27
+ super({
28
+ type: 'node:disconnected',
29
+ source: config.source,
30
+ metadata: { reason: config.reason },
31
+ });
32
+ this.nodeAddress = config.nodeAddress;
33
+ this.reason = config.reason;
34
+ }
35
+ getEventData() {
36
+ return {
37
+ nodeAddress: this.nodeAddress.toString(),
38
+ reason: this.reason,
39
+ };
40
+ }
41
+ }
42
+ /**
43
+ * Emitted when a node is discovered but not yet connected
44
+ */
45
+ export class NodeDiscoveredEvent extends oNotificationEvent {
46
+ constructor(config) {
47
+ super({
48
+ type: 'node:discovered',
49
+ source: config.source,
50
+ });
51
+ this.nodeAddress = config.nodeAddress;
52
+ }
53
+ getEventData() {
54
+ return {
55
+ nodeAddress: this.nodeAddress.toString(),
56
+ };
57
+ }
58
+ }