@olane/o-node 0.7.12-alpha.22 → 0.7.12-alpha.23

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 (175) hide show
  1. package/dist/o-core/src/connection/o-response.d.ts +26 -0
  2. package/dist/o-core/src/connection/o-response.d.ts.map +1 -0
  3. package/dist/o-core/src/connection/o-response.js +45 -0
  4. package/dist/o-core/src/error/enums/codes.error.d.ts +20 -0
  5. package/dist/o-core/src/error/enums/codes.error.d.ts.map +1 -0
  6. package/dist/o-core/src/error/enums/codes.error.js +20 -0
  7. package/dist/o-core/src/error/interfaces/o-error.interface.d.ts +6 -0
  8. package/dist/o-core/src/error/interfaces/o-error.interface.d.ts.map +1 -0
  9. package/dist/o-core/src/error/interfaces/o-error.interface.js +1 -0
  10. package/dist/o-core/src/error/o-error.d.ts +15 -0
  11. package/dist/o-core/src/error/o-error.d.ts.map +1 -0
  12. package/dist/o-core/src/error/o-error.js +27 -0
  13. package/dist/o-core/src/streaming/index.d.ts +11 -0
  14. package/dist/o-core/src/streaming/index.d.ts.map +1 -0
  15. package/dist/o-core/src/streaming/index.js +14 -0
  16. package/dist/o-core/src/streaming/protocol-builder.d.ts +62 -0
  17. package/dist/o-core/src/streaming/protocol-builder.d.ts.map +1 -0
  18. package/dist/o-core/src/streaming/protocol-builder.js +93 -0
  19. package/dist/o-core/src/streaming/stream-config.d.ts +36 -0
  20. package/dist/o-core/src/streaming/stream-config.d.ts.map +1 -0
  21. package/dist/o-core/src/streaming/stream-config.js +19 -0
  22. package/dist/o-core/src/streaming/stream-handler.base.d.ts +85 -0
  23. package/dist/o-core/src/streaming/stream-handler.base.d.ts.map +1 -0
  24. package/dist/o-core/src/streaming/stream-handler.base.js +112 -0
  25. package/dist/o-core/src/streaming/stream-transport.interface.d.ts +61 -0
  26. package/dist/o-core/src/streaming/stream-transport.interface.d.ts.map +1 -0
  27. package/dist/o-core/src/streaming/stream-transport.interface.js +10 -0
  28. package/dist/o-core/src/utils/streaming.utils.d.ts +37 -0
  29. package/dist/o-core/src/utils/streaming.utils.d.ts.map +1 -0
  30. package/dist/o-core/src/utils/streaming.utils.js +71 -0
  31. package/dist/o-node/src/connection/index.d.ts +5 -0
  32. package/dist/o-node/src/connection/index.d.ts.map +1 -0
  33. package/dist/o-node/src/connection/index.js +4 -0
  34. package/dist/o-node/src/connection/interfaces/o-node-connection-manager.config.d.ts +6 -0
  35. package/dist/o-node/src/connection/interfaces/o-node-connection-manager.config.d.ts.map +1 -0
  36. package/dist/o-node/src/connection/interfaces/o-node-connection-manager.config.js +1 -0
  37. package/dist/o-node/src/connection/interfaces/o-node-connection.config.d.ts +6 -0
  38. package/dist/o-node/src/connection/interfaces/o-node-connection.config.d.ts.map +1 -0
  39. package/dist/o-node/src/connection/interfaces/o-node-connection.config.js +1 -0
  40. package/dist/o-node/src/connection/o-node-connection.d.ts +20 -0
  41. package/dist/o-node/src/connection/o-node-connection.d.ts.map +1 -0
  42. package/dist/o-node/src/connection/o-node-connection.js +146 -0
  43. package/dist/o-node/src/connection/o-node-connection.manager.d.ts +19 -0
  44. package/dist/o-node/src/connection/o-node-connection.manager.d.ts.map +1 -0
  45. package/dist/o-node/src/connection/o-node-connection.manager.js +92 -0
  46. package/dist/o-node/src/index.d.ts +10 -0
  47. package/dist/o-node/src/index.d.ts.map +1 -0
  48. package/dist/o-node/src/index.js +9 -0
  49. package/dist/o-node/src/interfaces/i-heartbeatable-node.d.ts +49 -0
  50. package/dist/o-node/src/interfaces/i-heartbeatable-node.d.ts.map +1 -0
  51. package/dist/o-node/src/interfaces/i-heartbeatable-node.js +1 -0
  52. package/dist/o-node/src/interfaces/i-reconnectable-node.d.ts +46 -0
  53. package/dist/o-node/src/interfaces/i-reconnectable-node.d.ts.map +1 -0
  54. package/dist/o-node/src/interfaces/i-reconnectable-node.js +1 -0
  55. package/dist/o-node/src/interfaces/o-node.config.d.ts +66 -0
  56. package/dist/o-node/src/interfaces/o-node.config.d.ts.map +1 -0
  57. package/dist/o-node/src/interfaces/o-node.config.js +1 -0
  58. package/dist/o-node/src/interfaces/o-node.tool-config.d.ts +4 -0
  59. package/dist/o-node/src/interfaces/o-node.tool-config.d.ts.map +1 -0
  60. package/dist/o-node/src/interfaces/o-node.tool-config.js +1 -0
  61. package/dist/o-node/src/lib/network-activity.lib.d.ts +1 -0
  62. package/dist/o-node/src/lib/network-activity.lib.d.ts.map +1 -0
  63. package/dist/o-node/src/lib/network-activity.lib.js +34 -0
  64. package/dist/o-node/src/managers/o-connection-heartbeat.manager.d.ts +62 -0
  65. package/dist/o-node/src/managers/o-connection-heartbeat.manager.d.ts.map +1 -0
  66. package/dist/o-node/src/managers/o-connection-heartbeat.manager.js +213 -0
  67. package/dist/o-node/src/managers/o-reconnection.manager.d.ts +51 -0
  68. package/dist/o-node/src/managers/o-reconnection.manager.d.ts.map +1 -0
  69. package/dist/o-node/src/managers/o-reconnection.manager.js +266 -0
  70. package/dist/o-node/src/nodes/client.node.d.ts +7 -0
  71. package/dist/o-node/src/nodes/client.node.d.ts.map +1 -0
  72. package/dist/o-node/src/nodes/client.node.js +16 -0
  73. package/dist/o-node/src/nodes/index.d.ts +4 -0
  74. package/dist/o-node/src/nodes/index.d.ts.map +1 -0
  75. package/dist/o-node/src/nodes/index.js +3 -0
  76. package/dist/o-node/src/nodes/server.node.d.ts +7 -0
  77. package/dist/o-node/src/nodes/server.node.d.ts.map +1 -0
  78. package/dist/o-node/src/nodes/server.node.js +20 -0
  79. package/dist/o-node/src/nodes/websocket.node.d.ts +7 -0
  80. package/dist/o-node/src/nodes/websocket.node.d.ts.map +1 -0
  81. package/dist/o-node/src/nodes/websocket.node.js +18 -0
  82. package/dist/o-node/src/o-node.d.ts +72 -0
  83. package/dist/o-node/src/o-node.d.ts.map +1 -0
  84. package/dist/o-node/src/o-node.hierarchy-manager.d.ts +15 -0
  85. package/dist/o-node/src/o-node.hierarchy-manager.d.ts.map +1 -0
  86. package/dist/o-node/src/o-node.hierarchy-manager.js +15 -0
  87. package/dist/o-node/src/o-node.js +420 -0
  88. package/dist/o-node/src/o-node.notification-manager.d.ts +52 -0
  89. package/dist/o-node/src/o-node.notification-manager.d.ts.map +1 -0
  90. package/dist/o-node/src/o-node.notification-manager.js +185 -0
  91. package/dist/o-node/src/o-node.tool.d.ts +18 -0
  92. package/dist/o-node/src/o-node.tool.d.ts.map +1 -0
  93. package/dist/o-node/src/o-node.tool.js +116 -0
  94. package/dist/o-node/src/router/index.d.ts +6 -0
  95. package/dist/o-node/src/router/index.d.ts.map +1 -0
  96. package/dist/o-node/src/router/index.js +5 -0
  97. package/dist/o-node/src/router/interfaces/o-node-router.config.d.ts +3 -0
  98. package/dist/o-node/src/router/interfaces/o-node-router.config.d.ts.map +1 -0
  99. package/dist/o-node/src/router/interfaces/o-node-router.config.js +1 -0
  100. package/dist/o-node/src/router/interfaces/o-node-router.response.d.ts +8 -0
  101. package/dist/o-node/src/router/interfaces/o-node-router.response.d.ts.map +1 -0
  102. package/dist/o-node/src/router/interfaces/o-node-router.response.js +1 -0
  103. package/dist/o-node/src/router/o-node.address.d.ts +18 -0
  104. package/dist/o-node/src/router/o-node.address.d.ts.map +1 -0
  105. package/dist/o-node/src/router/o-node.address.js +29 -0
  106. package/dist/o-node/src/router/o-node.router.d.ts +45 -0
  107. package/dist/o-node/src/router/o-node.router.d.ts.map +1 -0
  108. package/dist/o-node/src/router/o-node.router.js +125 -0
  109. package/dist/o-node/src/router/o-node.routing-policy.d.ts +30 -0
  110. package/dist/o-node/src/router/o-node.routing-policy.d.ts.map +1 -0
  111. package/dist/o-node/src/router/o-node.routing-policy.js +57 -0
  112. package/dist/o-node/src/router/o-node.transport.d.ts +11 -0
  113. package/dist/o-node/src/router/o-node.transport.d.ts.map +1 -0
  114. package/dist/o-node/src/router/o-node.transport.js +18 -0
  115. package/dist/o-node/src/router/resolvers/index.d.ts +4 -0
  116. package/dist/o-node/src/router/resolvers/index.d.ts.map +1 -0
  117. package/dist/o-node/src/router/resolvers/index.js +3 -0
  118. package/dist/o-node/src/router/resolvers/o-node.leader-resolver-fallback.d.ts +8 -0
  119. package/dist/o-node/src/router/resolvers/o-node.leader-resolver-fallback.d.ts.map +1 -0
  120. package/dist/o-node/src/router/resolvers/o-node.leader-resolver-fallback.js +35 -0
  121. package/dist/o-node/src/router/resolvers/o-node.resolver.d.ts +11 -0
  122. package/dist/o-node/src/router/resolvers/o-node.resolver.d.ts.map +1 -0
  123. package/dist/o-node/src/router/resolvers/o-node.resolver.js +41 -0
  124. package/dist/o-node/src/router/resolvers/o-node.search-resolver.d.ts +170 -0
  125. package/dist/o-node/src/router/resolvers/o-node.search-resolver.d.ts.map +1 -0
  126. package/dist/o-node/src/router/resolvers/o-node.search-resolver.js +285 -0
  127. package/dist/o-node/src/router/route.request.d.ts +14 -0
  128. package/dist/o-node/src/router/route.request.d.ts.map +1 -0
  129. package/dist/o-node/src/router/route.request.js +1 -0
  130. package/dist/o-node/src/streaming/index.d.ts +10 -0
  131. package/dist/o-node/src/streaming/index.d.ts.map +1 -0
  132. package/dist/o-node/src/streaming/index.js +12 -0
  133. package/dist/o-node/src/streaming/libp2p-stream-transport.d.ts +50 -0
  134. package/dist/o-node/src/streaming/libp2p-stream-transport.d.ts.map +1 -0
  135. package/dist/o-node/src/streaming/libp2p-stream-transport.js +137 -0
  136. package/dist/o-node/src/streaming/node-stream-handler.d.ts +65 -0
  137. package/dist/o-node/src/streaming/node-stream-handler.d.ts.map +1 -0
  138. package/dist/o-node/src/streaming/node-stream-handler.js +101 -0
  139. package/dist/o-node/src/utils/circuit-breaker.d.ts +107 -0
  140. package/dist/o-node/src/utils/circuit-breaker.d.ts.map +1 -0
  141. package/dist/o-node/src/utils/circuit-breaker.js +175 -0
  142. package/dist/o-node/src/utils/circuit-breaker.test.d.ts +2 -0
  143. package/dist/o-node/src/utils/circuit-breaker.test.d.ts.map +1 -0
  144. package/dist/o-node/src/utils/circuit-breaker.test.js +262 -0
  145. package/dist/o-node/src/utils/leader-request-wrapper.d.ts +66 -0
  146. package/dist/o-node/src/utils/leader-request-wrapper.d.ts.map +1 -0
  147. package/dist/o-node/src/utils/leader-request-wrapper.js +160 -0
  148. package/dist/o-node/src/utils/leader-request-wrapper.test.d.ts +1 -0
  149. package/dist/o-node/src/utils/leader-request-wrapper.test.d.ts.map +1 -0
  150. package/dist/o-node/src/utils/leader-request-wrapper.test.js +246 -0
  151. package/dist/o-node/src/utils/network.utils.d.ts +20 -0
  152. package/dist/o-node/src/utils/network.utils.d.ts.map +1 -0
  153. package/dist/o-node/src/utils/network.utils.js +74 -0
  154. package/dist/o-node/test/o-node.spec.d.ts +2 -0
  155. package/dist/o-node/test/o-node.spec.d.ts.map +1 -0
  156. package/dist/o-node/test/o-node.spec.js +20 -0
  157. package/dist/o-node/test/search-resolver.spec.d.ts +2 -0
  158. package/dist/o-node/test/search-resolver.spec.d.ts.map +1 -0
  159. package/dist/o-node/test/search-resolver.spec.js +693 -0
  160. package/dist/src/connection/o-node-connection.d.ts +7 -0
  161. package/dist/src/connection/o-node-connection.d.ts.map +1 -1
  162. package/dist/src/connection/o-node-connection.js +89 -2
  163. package/dist/src/connection/o-node-connection.manager.d.ts +2 -0
  164. package/dist/src/connection/o-node-connection.manager.d.ts.map +1 -1
  165. package/dist/src/connection/o-node-connection.manager.js +5 -1
  166. package/dist/src/interfaces/o-node.config.d.ts +16 -0
  167. package/dist/src/interfaces/o-node.config.d.ts.map +1 -1
  168. package/dist/src/o-node.d.ts +1 -1
  169. package/dist/src/o-node.d.ts.map +1 -1
  170. package/dist/src/o-node.js +5 -1
  171. package/dist/src/o-node.tool.d.ts.map +1 -1
  172. package/dist/src/o-node.tool.js +37 -7
  173. package/dist/src/router/resolvers/o-node.search-resolver.d.ts.map +1 -1
  174. package/dist/src/router/resolvers/o-node.search-resolver.js +8 -1
  175. package/package.json +6 -6
@@ -0,0 +1,26 @@
1
+ import { JSONRPC_VERSION, RequestId, oResponse as Response, Result } from '@olane/o-protocol';
2
+ export declare class oResponse implements Response {
3
+ jsonrpc: typeof JSONRPC_VERSION;
4
+ id: RequestId;
5
+ result: Result;
6
+ isStreaming?: boolean;
7
+ streamChunks?: unknown[];
8
+ constructor(config: Result & {
9
+ id: RequestId;
10
+ });
11
+ /**
12
+ * Check if a result is a streaming result
13
+ */
14
+ private isStreamingResult;
15
+ /**
16
+ * Add a chunk to a streaming response
17
+ */
18
+ addChunk(chunk: unknown): void;
19
+ /**
20
+ * Get all accumulated chunks for a streaming response
21
+ */
22
+ getChunks(): unknown[];
23
+ toJSON(): any;
24
+ toString(): string;
25
+ }
26
+ //# sourceMappingURL=o-response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"o-response.d.ts","sourceRoot":"","sources":["../../../../../o-core/src/connection/o-response.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,SAAS,EACT,SAAS,IAAI,QAAQ,EACrB,MAAM,EAEP,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,SAAU,YAAW,QAAQ;IACxC,OAAO,EAAE,OAAO,eAAe,CAAC;IAChC,EAAE,EAAE,SAAS,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IAGf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC;gBAEb,MAAM,EAAE,MAAM,GAAG;QAAE,EAAE,EAAE,SAAS,CAAA;KAAE;IAY9C;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAIzB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAQ9B;;OAEG;IACH,SAAS,IAAI,OAAO,EAAE;IAItB,MAAM,IAAI,GAAG;IAQb,QAAQ,IAAI,MAAM;CAGnB"}
@@ -0,0 +1,45 @@
1
+ import { JSONRPC_VERSION, } from '@olane/o-protocol';
2
+ export class oResponse {
3
+ constructor(config) {
4
+ this.jsonrpc = JSONRPC_VERSION;
5
+ this.id = config.id;
6
+ this.result = config;
7
+ // Check if this is a streaming result
8
+ if (this.isStreamingResult(config)) {
9
+ this.isStreaming = true;
10
+ this.streamChunks = [config._data];
11
+ }
12
+ }
13
+ /**
14
+ * Check if a result is a streaming result
15
+ */
16
+ isStreamingResult(result) {
17
+ return '_streaming' in result && result._streaming === true;
18
+ }
19
+ /**
20
+ * Add a chunk to a streaming response
21
+ */
22
+ addChunk(chunk) {
23
+ if (!this.isStreaming) {
24
+ this.isStreaming = true;
25
+ this.streamChunks = [];
26
+ }
27
+ this.streamChunks.push(chunk);
28
+ }
29
+ /**
30
+ * Get all accumulated chunks for a streaming response
31
+ */
32
+ getChunks() {
33
+ return this.streamChunks || [];
34
+ }
35
+ toJSON() {
36
+ return {
37
+ jsonrpc: this.jsonrpc,
38
+ id: this.id,
39
+ result: this.result,
40
+ };
41
+ }
42
+ toString() {
43
+ return JSON.stringify(this);
44
+ }
45
+ }
@@ -0,0 +1,20 @@
1
+ export declare enum oErrorCodes {
2
+ UNKNOWN = 1001,
3
+ NOT_FOUND = 1002,
4
+ NOT_IMPLEMENTED = 1003,
5
+ NOT_CONFIGURED = 1004,
6
+ NOT_AUTHORIZED = 1005,
7
+ MISSING_PARAMETERS = 1006,
8
+ INVALID_PARAMETERS = 1007,
9
+ INVALID_RESPONSE = 1008,
10
+ INVALID_REQUEST = 1009,
11
+ INVALID_STATE = 1010,
12
+ INVALID_ACTION = 1011,
13
+ INVALID_CREDENTIALS = 1012,
14
+ TRANSPORT_NOT_SUPPORTED = 1013,
15
+ FAILED_TO_DIAL_TARGET = 1014,
16
+ INVALID_CAPABILITY = 1015,
17
+ CONNECTION_LIMIT_REACHED = 1016,
18
+ TIMEOUT = 1017
19
+ }
20
+ //# sourceMappingURL=codes.error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codes.error.d.ts","sourceRoot":"","sources":["../../../../../../o-core/src/error/enums/codes.error.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,OAAO,OAAO;IACd,SAAS,OAAO;IAChB,eAAe,OAAO;IACtB,cAAc,OAAO;IACrB,cAAc,OAAO;IACrB,kBAAkB,OAAO;IACzB,kBAAkB,OAAO;IACzB,gBAAgB,OAAO;IACvB,eAAe,OAAO;IACtB,aAAa,OAAO;IACpB,cAAc,OAAO;IACrB,mBAAmB,OAAO;IAC1B,uBAAuB,OAAO;IAC9B,qBAAqB,OAAO;IAC5B,kBAAkB,OAAO;IACzB,wBAAwB,OAAO;IAC/B,OAAO,OAAO;CACf"}
@@ -0,0 +1,20 @@
1
+ export var oErrorCodes;
2
+ (function (oErrorCodes) {
3
+ oErrorCodes[oErrorCodes["UNKNOWN"] = 1001] = "UNKNOWN";
4
+ oErrorCodes[oErrorCodes["NOT_FOUND"] = 1002] = "NOT_FOUND";
5
+ oErrorCodes[oErrorCodes["NOT_IMPLEMENTED"] = 1003] = "NOT_IMPLEMENTED";
6
+ oErrorCodes[oErrorCodes["NOT_CONFIGURED"] = 1004] = "NOT_CONFIGURED";
7
+ oErrorCodes[oErrorCodes["NOT_AUTHORIZED"] = 1005] = "NOT_AUTHORIZED";
8
+ oErrorCodes[oErrorCodes["MISSING_PARAMETERS"] = 1006] = "MISSING_PARAMETERS";
9
+ oErrorCodes[oErrorCodes["INVALID_PARAMETERS"] = 1007] = "INVALID_PARAMETERS";
10
+ oErrorCodes[oErrorCodes["INVALID_RESPONSE"] = 1008] = "INVALID_RESPONSE";
11
+ oErrorCodes[oErrorCodes["INVALID_REQUEST"] = 1009] = "INVALID_REQUEST";
12
+ oErrorCodes[oErrorCodes["INVALID_STATE"] = 1010] = "INVALID_STATE";
13
+ oErrorCodes[oErrorCodes["INVALID_ACTION"] = 1011] = "INVALID_ACTION";
14
+ oErrorCodes[oErrorCodes["INVALID_CREDENTIALS"] = 1012] = "INVALID_CREDENTIALS";
15
+ oErrorCodes[oErrorCodes["TRANSPORT_NOT_SUPPORTED"] = 1013] = "TRANSPORT_NOT_SUPPORTED";
16
+ oErrorCodes[oErrorCodes["FAILED_TO_DIAL_TARGET"] = 1014] = "FAILED_TO_DIAL_TARGET";
17
+ oErrorCodes[oErrorCodes["INVALID_CAPABILITY"] = 1015] = "INVALID_CAPABILITY";
18
+ oErrorCodes[oErrorCodes["CONNECTION_LIMIT_REACHED"] = 1016] = "CONNECTION_LIMIT_REACHED";
19
+ oErrorCodes[oErrorCodes["TIMEOUT"] = 1017] = "TIMEOUT";
20
+ })(oErrorCodes || (oErrorCodes = {}));
@@ -0,0 +1,6 @@
1
+ export interface oErrorInterface {
2
+ code: number;
3
+ message: string;
4
+ details?: any;
5
+ }
6
+ //# sourceMappingURL=o-error.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"o-error.interface.d.ts","sourceRoot":"","sources":["../../../../../../o-core/src/error/interfaces/o-error.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,GAAG,CAAC;CACf"}
@@ -0,0 +1,15 @@
1
+ import { oErrorInterface } from './interfaces/o-error.interface.js';
2
+ export declare class oError extends Error implements oErrorInterface {
3
+ code: number;
4
+ details?: any;
5
+ message: string;
6
+ constructor(code: number, message: string, details?: any);
7
+ toJSON(): {
8
+ code: number;
9
+ message: string;
10
+ details: any;
11
+ };
12
+ static fromJSON(json: any): oError;
13
+ toString(): string;
14
+ }
15
+ //# sourceMappingURL=o-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"o-error.d.ts","sourceRoot":"","sources":["../../../../../o-core/src/error/o-error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAEpE,qBAAa,MAAO,SAAQ,KAAM,YAAW,eAAe;IAC1D,IAAI,EAAE,MAAM,CAAK;IACjB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,OAAO,EAAE,MAAM,CAAM;gBAET,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;IAOxD,MAAM;;;;;IAQN,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG;IAOzB,QAAQ;CAGT"}
@@ -0,0 +1,27 @@
1
+ import { oErrorCodes } from './enums/codes.error.js';
2
+ export class oError extends Error {
3
+ constructor(code, message, details) {
4
+ super(message);
5
+ this.code = 0;
6
+ this.message = '';
7
+ this.code = code;
8
+ this.message = message;
9
+ this.details = details;
10
+ }
11
+ toJSON() {
12
+ return {
13
+ code: this.code,
14
+ message: this.message,
15
+ details: this.details,
16
+ };
17
+ }
18
+ static fromJSON(json) {
19
+ if (json?.code && json?.message) {
20
+ return new oError(json.code, json.message, json.details);
21
+ }
22
+ return new oError(oErrorCodes.UNKNOWN, json, json?.details);
23
+ }
24
+ toString() {
25
+ return `OLANE ERROR CODE: ${this.code}\nMESSAGE: ${this.message}\n-----\nDETAILS: ${this.details}`;
26
+ }
27
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Streaming functionality for o-core
3
+ *
4
+ * This module provides transport-agnostic abstractions for streaming operations
5
+ * that can be used by o-node, o-client, o-browser, and other implementations.
6
+ */
7
+ export { IStreamTransport, StreamStatus, StreamTransportConfig, } from './stream-transport.interface.js';
8
+ export { StreamConfig, DEFAULT_STREAM_CONFIG, mergeStreamConfig, } from './stream-config.js';
9
+ export { ProtocolBuilder, ParsedStreamChunk, } from './protocol-builder.js';
10
+ export { StreamHandlerBase, StreamHandlerState, StreamHandlerOptions, } from './stream-handler.base.js';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../o-core/src/streaming/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,qBAAqB,GACtB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,eAAe,EACf,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Streaming functionality for o-core
3
+ *
4
+ * This module provides transport-agnostic abstractions for streaming operations
5
+ * that can be used by o-node, o-client, o-browser, and other implementations.
6
+ */
7
+ // Stream transport interface and types
8
+ export { StreamStatus, } from './stream-transport.interface.js';
9
+ // Stream configuration
10
+ export { DEFAULT_STREAM_CONFIG, mergeStreamConfig, } from './stream-config.js';
11
+ // Protocol builder for JSON-RPC streaming messages
12
+ export { ProtocolBuilder, } from './protocol-builder.js';
13
+ // Base stream handler class
14
+ export { StreamHandlerBase, StreamHandlerState, } from './stream-handler.base.js';
@@ -0,0 +1,62 @@
1
+ import { JSONRPCStreamChunk, RequestId, ConnectionId, oRequest } from '@olane/o-protocol';
2
+ /**
3
+ * Parsed streaming chunk data
4
+ */
5
+ export interface ParsedStreamChunk {
6
+ data: unknown;
7
+ sequence: number;
8
+ isLast: boolean;
9
+ connectionId: ConnectionId;
10
+ requestMethod: string;
11
+ }
12
+ /**
13
+ * Builder class for constructing and parsing JSON-RPC streaming protocol messages.
14
+ * Provides type-safe message construction and parsing for streaming responses.
15
+ */
16
+ export declare class ProtocolBuilder {
17
+ /**
18
+ * Build a JSON-RPC streaming chunk message
19
+ * @param data - The data payload for this chunk
20
+ * @param sequence - The sequence number of this chunk (starts at 1)
21
+ * @param isLast - Whether this is the final chunk in the stream
22
+ * @param requestId - The JSON-RPC request ID this chunk is responding to
23
+ * @param connectionId - The connection ID from the original request
24
+ * @param requestMethod - The method name from the original request
25
+ * @returns A complete JSON-RPC streaming chunk message
26
+ */
27
+ static buildStreamChunk(data: unknown, sequence: number, isLast: boolean, requestId: RequestId, connectionId: ConnectionId, requestMethod: string): JSONRPCStreamChunk;
28
+ /**
29
+ * Build a streaming chunk from an oRequest object
30
+ * @param data - The data payload for this chunk
31
+ * @param sequence - The sequence number of this chunk
32
+ * @param isLast - Whether this is the final chunk
33
+ * @param request - The original oRequest
34
+ * @returns A complete JSON-RPC streaming chunk message
35
+ */
36
+ static buildStreamChunkFromRequest(data: unknown, sequence: number, isLast: boolean, request: oRequest): JSONRPCStreamChunk;
37
+ /**
38
+ * Parse a JSON-RPC response to extract streaming chunk data
39
+ * @param message - The parsed JSON-RPC message
40
+ * @returns Parsed chunk data if this is a streaming response, null otherwise
41
+ */
42
+ static parseStreamChunk(message: any): ParsedStreamChunk | null;
43
+ /**
44
+ * Check if a message is a streaming response
45
+ * @param message - The message to check
46
+ * @returns true if the message is a streaming response
47
+ */
48
+ static isStreamingResponse(message: any): boolean;
49
+ /**
50
+ * Encode a message to UTF-8 bytes for transmission
51
+ * @param message - The message to encode
52
+ * @returns UTF-8 encoded bytes
53
+ */
54
+ static encodeMessage(message: JSONRPCStreamChunk): Uint8Array;
55
+ /**
56
+ * Decode UTF-8 bytes to a JSON message
57
+ * @param data - The UTF-8 encoded data
58
+ * @returns Parsed JSON message
59
+ */
60
+ static decodeMessage(data: Uint8Array): any;
61
+ }
62
+ //# sourceMappingURL=protocol-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol-builder.d.ts","sourceRoot":"","sources":["../../../../../o-core/src/streaming/protocol-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAElB,SAAS,EACT,YAAY,EAEZ,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,qBAAa,eAAe;IAC1B;;;;;;;;;OASG;WACW,gBAAgB,CAC5B,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,MAAM,GACpB,kBAAkB;IAiBrB;;;;;;;OAOG;WACW,2BAA2B,CACvC,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,QAAQ,GAChB,kBAAkB;IAWrB;;;;OAIG;WACW,gBAAgB,CAAC,OAAO,EAAE,GAAG,GAAG,iBAAiB,GAAG,IAAI;IAgBtE;;;;OAIG;WACW,mBAAmB,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO;IAaxD;;;;OAIG;WACW,aAAa,CAAC,OAAO,EAAE,kBAAkB,GAAG,UAAU;IAIpE;;;;OAIG;WACW,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,GAAG;CAInD"}
@@ -0,0 +1,93 @@
1
+ import { JSONRPC_VERSION, } from '@olane/o-protocol';
2
+ /**
3
+ * Builder class for constructing and parsing JSON-RPC streaming protocol messages.
4
+ * Provides type-safe message construction and parsing for streaming responses.
5
+ */
6
+ export class ProtocolBuilder {
7
+ /**
8
+ * Build a JSON-RPC streaming chunk message
9
+ * @param data - The data payload for this chunk
10
+ * @param sequence - The sequence number of this chunk (starts at 1)
11
+ * @param isLast - Whether this is the final chunk in the stream
12
+ * @param requestId - The JSON-RPC request ID this chunk is responding to
13
+ * @param connectionId - The connection ID from the original request
14
+ * @param requestMethod - The method name from the original request
15
+ * @returns A complete JSON-RPC streaming chunk message
16
+ */
17
+ static buildStreamChunk(data, sequence, isLast, requestId, connectionId, requestMethod) {
18
+ const result = {
19
+ _connectionId: connectionId,
20
+ _requestMethod: requestMethod,
21
+ _streaming: true,
22
+ _sequence: sequence,
23
+ _isLast: isLast,
24
+ _data: data,
25
+ };
26
+ return {
27
+ jsonrpc: JSONRPC_VERSION,
28
+ id: requestId,
29
+ result,
30
+ };
31
+ }
32
+ /**
33
+ * Build a streaming chunk from an oRequest object
34
+ * @param data - The data payload for this chunk
35
+ * @param sequence - The sequence number of this chunk
36
+ * @param isLast - Whether this is the final chunk
37
+ * @param request - The original oRequest
38
+ * @returns A complete JSON-RPC streaming chunk message
39
+ */
40
+ static buildStreamChunkFromRequest(data, sequence, isLast, request) {
41
+ return this.buildStreamChunk(data, sequence, isLast, request.id, request.params._connectionId, request.method);
42
+ }
43
+ /**
44
+ * Parse a JSON-RPC response to extract streaming chunk data
45
+ * @param message - The parsed JSON-RPC message
46
+ * @returns Parsed chunk data if this is a streaming response, null otherwise
47
+ */
48
+ static parseStreamChunk(message) {
49
+ if (!this.isStreamingResponse(message)) {
50
+ return null;
51
+ }
52
+ const result = message.result;
53
+ return {
54
+ data: result._data,
55
+ sequence: result._sequence,
56
+ isLast: result._isLast,
57
+ connectionId: result._connectionId,
58
+ requestMethod: result._requestMethod,
59
+ };
60
+ }
61
+ /**
62
+ * Check if a message is a streaming response
63
+ * @param message - The message to check
64
+ * @returns true if the message is a streaming response
65
+ */
66
+ static isStreamingResponse(message) {
67
+ return (message &&
68
+ typeof message === 'object' &&
69
+ message.result &&
70
+ typeof message.result === 'object' &&
71
+ message.result._streaming === true &&
72
+ typeof message.result._sequence === 'number' &&
73
+ typeof message.result._isLast === 'boolean' &&
74
+ '_data' in message.result);
75
+ }
76
+ /**
77
+ * Encode a message to UTF-8 bytes for transmission
78
+ * @param message - The message to encode
79
+ * @returns UTF-8 encoded bytes
80
+ */
81
+ static encodeMessage(message) {
82
+ return new TextEncoder().encode(JSON.stringify(message));
83
+ }
84
+ /**
85
+ * Decode UTF-8 bytes to a JSON message
86
+ * @param data - The UTF-8 encoded data
87
+ * @returns Parsed JSON message
88
+ */
89
+ static decodeMessage(data) {
90
+ const text = new TextDecoder().decode(data);
91
+ return JSON.parse(text);
92
+ }
93
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Configuration options for streaming operations
3
+ */
4
+ export interface StreamConfig {
5
+ /**
6
+ * Timeout in milliseconds for waiting to read the first chunk
7
+ * @default 120000 (2 minutes)
8
+ */
9
+ readTimeoutMs: number;
10
+ /**
11
+ * Timeout in milliseconds for drain operations when handling backpressure
12
+ * @default 30000 (30 seconds)
13
+ */
14
+ drainTimeoutMs: number;
15
+ /**
16
+ * Maximum size of a single chunk in bytes (optional)
17
+ * If not set, chunks can be any size
18
+ */
19
+ maxChunkSize?: number;
20
+ /**
21
+ * Enable metrics tracking for streaming operations
22
+ * @default true
23
+ */
24
+ enableMetrics?: boolean;
25
+ }
26
+ /**
27
+ * Default configuration for streaming operations
28
+ */
29
+ export declare const DEFAULT_STREAM_CONFIG: StreamConfig;
30
+ /**
31
+ * Merge user config with defaults
32
+ * @param userConfig - Partial user configuration
33
+ * @returns Complete configuration with defaults applied
34
+ */
35
+ export declare function mergeStreamConfig(userConfig?: Partial<StreamConfig>): StreamConfig;
36
+ //# sourceMappingURL=stream-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream-config.d.ts","sourceRoot":"","sources":["../../../../../o-core/src/streaming/stream-config.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,YAInC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GACjC,YAAY,CAKd"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Default configuration for streaming operations
3
+ */
4
+ export const DEFAULT_STREAM_CONFIG = {
5
+ readTimeoutMs: 120000, // 2 minutes
6
+ drainTimeoutMs: 30000, // 30 seconds
7
+ enableMetrics: true,
8
+ };
9
+ /**
10
+ * Merge user config with defaults
11
+ * @param userConfig - Partial user configuration
12
+ * @returns Complete configuration with defaults applied
13
+ */
14
+ export function mergeStreamConfig(userConfig) {
15
+ return {
16
+ ...DEFAULT_STREAM_CONFIG,
17
+ ...userConfig,
18
+ };
19
+ }
@@ -0,0 +1,85 @@
1
+ import { oError } from '../error/o-error.js';
2
+ import { oRequest } from '@olane/o-protocol';
3
+ /**
4
+ * State machine states for streaming operations
5
+ */
6
+ export declare enum StreamHandlerState {
7
+ IDLE = "idle",
8
+ STREAMING = "streaming",
9
+ COMPLETED = "completed",
10
+ ERROR = "error"
11
+ }
12
+ /**
13
+ * Options for stream handler operations
14
+ */
15
+ export interface StreamHandlerOptions {
16
+ /**
17
+ * Enable metrics tracking
18
+ */
19
+ enableMetrics?: boolean;
20
+ }
21
+ /**
22
+ * Abstract base class for handling streaming operations.
23
+ * Provides transport-agnostic AsyncGenerator iteration, chunk sequencing,
24
+ * error handling, and state management.
25
+ *
26
+ * Implementations must provide the sendChunk method for transport-specific
27
+ * chunk transmission.
28
+ */
29
+ export declare abstract class StreamHandlerBase {
30
+ protected state: StreamHandlerState;
31
+ protected currentSequence: number;
32
+ protected options: StreamHandlerOptions;
33
+ constructor(options?: StreamHandlerOptions);
34
+ /**
35
+ * Get the current state of the stream handler
36
+ */
37
+ getState(): StreamHandlerState;
38
+ /**
39
+ * Get the current sequence number
40
+ */
41
+ getCurrentSequence(): number;
42
+ /**
43
+ * Abstract method that implementations must provide to send a chunk.
44
+ * This method should handle the actual transmission using the specific transport.
45
+ *
46
+ * @param chunk - The data chunk to send
47
+ * @param sequence - The sequence number of this chunk
48
+ * @param isLast - Whether this is the final chunk
49
+ * @param request - The original request
50
+ */
51
+ protected abstract sendChunk(chunk: unknown, sequence: number, isLast: boolean, request: oRequest): Promise<void>;
52
+ /**
53
+ * Optional hook called when streaming starts
54
+ */
55
+ protected onStreamStart?(request: oRequest): void;
56
+ /**
57
+ * Optional hook called when streaming completes successfully
58
+ */
59
+ protected onStreamComplete?(request: oRequest, totalChunks: number): void;
60
+ /**
61
+ * Optional hook called when streaming encounters an error
62
+ */
63
+ protected onStreamError?(request: oRequest, error: oError): void;
64
+ /**
65
+ * Handle streaming of an AsyncGenerator.
66
+ * Iterates through the generator, sends each chunk with proper sequencing,
67
+ * and handles errors appropriately.
68
+ *
69
+ * @param generator - The AsyncGenerator to stream
70
+ * @param request - The original request
71
+ * @returns Promise that resolves when streaming is complete
72
+ */
73
+ handleStream(generator: AsyncGenerator<any>, request: oRequest): Promise<void>;
74
+ /**
75
+ * Convert any error to an oError instance
76
+ * @param error - The error to convert
77
+ * @returns An oError instance
78
+ */
79
+ protected convertToOError(error: unknown): oError;
80
+ /**
81
+ * Reset the handler state for reuse
82
+ */
83
+ reset(): void;
84
+ }
85
+ //# sourceMappingURL=stream-handler.base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream-handler.base.d.ts","sourceRoot":"","sources":["../../../../../o-core/src/streaming/stream-handler.base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C;;GAEG;AACH,oBAAY,kBAAkB;IAC5B,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,KAAK,UAAU;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,8BAAsB,iBAAiB;IACrC,SAAS,CAAC,KAAK,EAAE,kBAAkB,CAA2B;IAC9D,SAAS,CAAC,eAAe,EAAE,MAAM,CAAK;IACtC,SAAS,CAAC,OAAO,EAAE,oBAAoB,CAAC;gBAE5B,OAAO,GAAE,oBAAyB;IAO9C;;OAEG;IACI,QAAQ,IAAI,kBAAkB;IAIrC;;OAEG;IACI,kBAAkB,IAAI,MAAM;IAInC;;;;;;;;OAQG;IACH,SAAS,CAAC,QAAQ,CAAC,SAAS,CAC1B,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,QAAQ,GAChB,OAAO,CAAC,IAAI,CAAC;IAEhB;;OAEG;IACH,SAAS,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI;IAEjD;;OAEG;IACH,SAAS,CAAC,gBAAgB,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;IAEzE;;OAEG;IACH,SAAS,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAEhE;;;;;;;;OAQG;IACU,YAAY,CACvB,SAAS,EAAE,cAAc,CAAC,GAAG,CAAC,EAC9B,OAAO,EAAE,QAAQ,GAChB,OAAO,CAAC,IAAI,CAAC;IAqDhB;;;;OAIG;IACH,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM;IAoBjD;;OAEG;IACI,KAAK,IAAI,IAAI;CAIrB"}
@@ -0,0 +1,112 @@
1
+ import { oError } from '../error/o-error.js';
2
+ import { oErrorCodes } from '../error/enums/codes.error.js';
3
+ /**
4
+ * State machine states for streaming operations
5
+ */
6
+ export var StreamHandlerState;
7
+ (function (StreamHandlerState) {
8
+ StreamHandlerState["IDLE"] = "idle";
9
+ StreamHandlerState["STREAMING"] = "streaming";
10
+ StreamHandlerState["COMPLETED"] = "completed";
11
+ StreamHandlerState["ERROR"] = "error";
12
+ })(StreamHandlerState || (StreamHandlerState = {}));
13
+ /**
14
+ * Abstract base class for handling streaming operations.
15
+ * Provides transport-agnostic AsyncGenerator iteration, chunk sequencing,
16
+ * error handling, and state management.
17
+ *
18
+ * Implementations must provide the sendChunk method for transport-specific
19
+ * chunk transmission.
20
+ */
21
+ export class StreamHandlerBase {
22
+ constructor(options = {}) {
23
+ this.state = StreamHandlerState.IDLE;
24
+ this.currentSequence = 0;
25
+ this.options = {
26
+ enableMetrics: true,
27
+ ...options,
28
+ };
29
+ }
30
+ /**
31
+ * Get the current state of the stream handler
32
+ */
33
+ getState() {
34
+ return this.state;
35
+ }
36
+ /**
37
+ * Get the current sequence number
38
+ */
39
+ getCurrentSequence() {
40
+ return this.currentSequence;
41
+ }
42
+ /**
43
+ * Handle streaming of an AsyncGenerator.
44
+ * Iterates through the generator, sends each chunk with proper sequencing,
45
+ * and handles errors appropriately.
46
+ *
47
+ * @param generator - The AsyncGenerator to stream
48
+ * @param request - The original request
49
+ * @returns Promise that resolves when streaming is complete
50
+ */
51
+ async handleStream(generator, request) {
52
+ this.state = StreamHandlerState.STREAMING;
53
+ this.currentSequence = 0;
54
+ // Call optional hook
55
+ if (this.onStreamStart) {
56
+ this.onStreamStart(request);
57
+ }
58
+ try {
59
+ // Iterate through the generator and send each chunk
60
+ for await (const chunk of generator) {
61
+ this.currentSequence++;
62
+ await this.sendChunk(chunk, this.currentSequence, false, request);
63
+ }
64
+ // Send final empty chunk to signal completion
65
+ await this.sendChunk(null, this.currentSequence, true, request);
66
+ this.state = StreamHandlerState.COMPLETED;
67
+ // Call optional hook
68
+ if (this.onStreamComplete) {
69
+ this.onStreamComplete(request, this.currentSequence);
70
+ }
71
+ }
72
+ catch (error) {
73
+ this.state = StreamHandlerState.ERROR;
74
+ // Convert error to oError if needed
75
+ const oErrorInstance = this.convertToOError(error);
76
+ // Call optional hook
77
+ if (this.onStreamError) {
78
+ this.onStreamError(request, oErrorInstance);
79
+ }
80
+ // Send error as final chunk
81
+ try {
82
+ await this.sendChunk(oErrorInstance.toJSON(), this.currentSequence, true, request);
83
+ }
84
+ catch (sendError) {
85
+ console.error('Failed to send error chunk:', sendError);
86
+ throw oErrorInstance;
87
+ }
88
+ throw oErrorInstance;
89
+ }
90
+ }
91
+ /**
92
+ * Convert any error to an oError instance
93
+ * @param error - The error to convert
94
+ * @returns An oError instance
95
+ */
96
+ convertToOError(error) {
97
+ if (error instanceof oError) {
98
+ return error;
99
+ }
100
+ if (error instanceof Error) {
101
+ return new oError(oErrorCodes.UNKNOWN, error.message, { stack: error.stack });
102
+ }
103
+ return new oError(oErrorCodes.UNKNOWN, String(error), { originalError: error });
104
+ }
105
+ /**
106
+ * Reset the handler state for reuse
107
+ */
108
+ reset() {
109
+ this.state = StreamHandlerState.IDLE;
110
+ this.currentSequence = 0;
111
+ }
112
+ }