@olane/o-core 0.6.13 → 0.7.2

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 (257) hide show
  1. package/README.md +490 -140
  2. package/dist/src/connection/index.d.ts +8 -0
  3. package/dist/src/connection/index.d.ts.map +1 -0
  4. package/dist/src/connection/index.js +7 -0
  5. package/dist/src/connection/interfaces/connection-manager.config.d.ts +3 -0
  6. package/dist/src/connection/interfaces/connection-manager.config.d.ts.map +1 -0
  7. package/dist/src/connection/interfaces/connection-send-params.interface.d.ts.map +1 -0
  8. package/dist/src/connection/interfaces/connection.config.d.ts +7 -0
  9. package/dist/src/connection/interfaces/connection.config.d.ts.map +1 -0
  10. package/dist/src/connection/interfaces/index.d.ts +5 -0
  11. package/dist/src/connection/interfaces/index.d.ts.map +1 -0
  12. package/dist/src/connection/interfaces/index.js +4 -0
  13. package/dist/src/connection/interfaces/request-state.enum.d.ts +7 -0
  14. package/dist/src/connection/interfaces/request-state.enum.d.ts.map +1 -0
  15. package/dist/src/connection/interfaces/request-state.enum.js +7 -0
  16. package/dist/src/connection/o-connection-manager.d.ts +19 -0
  17. package/dist/src/connection/o-connection-manager.d.ts.map +1 -0
  18. package/dist/src/connection/o-connection-manager.js +27 -0
  19. package/dist/src/connection/o-connection.d.ts +20 -0
  20. package/dist/src/connection/o-connection.d.ts.map +1 -0
  21. package/dist/src/connection/o-connection.js +45 -0
  22. package/dist/src/{core/lib → connection}/o-request.d.ts +5 -1
  23. package/dist/src/connection/o-request.d.ts.map +1 -0
  24. package/dist/src/{core/lib → connection}/o-request.js +8 -1
  25. package/dist/src/connection/o-response.d.ts.map +1 -0
  26. package/dist/src/core/defaults/config.d.ts +1 -1
  27. package/dist/src/core/defaults/config.d.ts.map +1 -1
  28. package/dist/src/core/defaults/config.js +1 -1
  29. package/dist/src/core/graceful-shutdown.d.ts +1 -1
  30. package/dist/src/core/graceful-shutdown.d.ts.map +1 -1
  31. package/dist/src/core/graceful-shutdown.js +1 -1
  32. package/dist/src/core/index.d.ts +3 -5
  33. package/dist/src/core/index.d.ts.map +1 -1
  34. package/dist/src/core/index.js +3 -5
  35. package/dist/src/core/interfaces/index.d.ts +1 -2
  36. package/dist/src/core/interfaces/index.d.ts.map +1 -1
  37. package/dist/src/core/interfaces/index.js +1 -2
  38. package/dist/src/core/interfaces/{core-config.interface.d.ts → o-core.config.d.ts} +4 -5
  39. package/dist/src/core/interfaces/o-core.config.d.ts.map +1 -0
  40. package/dist/src/core/interfaces/o-core.interface.d.ts +18 -0
  41. package/dist/src/core/interfaces/o-core.interface.d.ts.map +1 -0
  42. package/dist/src/core/lib/index.d.ts +3 -7
  43. package/dist/src/core/lib/index.d.ts.map +1 -1
  44. package/dist/src/core/lib/index.js +3 -7
  45. package/dist/src/core/lib/o-hierarchy.manager.d.ts +24 -0
  46. package/dist/src/core/lib/o-hierarchy.manager.d.ts.map +1 -0
  47. package/dist/src/core/lib/o-hierarchy.manager.js +57 -0
  48. package/dist/src/core/lib/o-metrics.d.ts +5 -0
  49. package/dist/src/core/lib/o-metrics.d.ts.map +1 -0
  50. package/dist/src/core/lib/o-metrics.js +6 -0
  51. package/dist/src/core/lib/o-request.manager.d.ts +10 -0
  52. package/dist/src/core/lib/o-request.manager.d.ts.map +1 -0
  53. package/dist/src/core/lib/o-request.manager.js +18 -0
  54. package/dist/src/core/o-core.d.ts +190 -0
  55. package/dist/src/core/o-core.d.ts.map +1 -0
  56. package/dist/src/core/o-core.js +334 -0
  57. package/dist/src/core/o-object.d.ts +7 -0
  58. package/dist/src/core/o-object.d.ts.map +1 -0
  59. package/dist/src/core/o-object.js +10 -0
  60. package/dist/src/error/enums/codes.error.d.ts +16 -14
  61. package/dist/src/error/enums/codes.error.d.ts.map +1 -1
  62. package/dist/src/error/enums/codes.error.js +18 -16
  63. package/dist/src/error/index.d.ts +1 -1
  64. package/dist/src/error/index.d.ts.map +1 -1
  65. package/dist/src/error/index.js +1 -1
  66. package/dist/src/error/interfaces/o-error.interface.d.ts +6 -0
  67. package/dist/src/error/interfaces/o-error.interface.d.ts.map +1 -0
  68. package/dist/src/error/o-error.d.ts +15 -0
  69. package/dist/src/error/o-error.d.ts.map +1 -0
  70. package/dist/src/error/{tool.error.js → o-error.js} +4 -4
  71. package/dist/src/index.d.ts +3 -3
  72. package/dist/src/index.d.ts.map +1 -1
  73. package/dist/src/index.js +3 -3
  74. package/dist/src/router/enums/restricted-addresses.enum.d.ts +8 -0
  75. package/dist/src/router/enums/restricted-addresses.enum.d.ts.map +1 -0
  76. package/dist/src/router/enums/restricted-addresses.enum.js +13 -0
  77. package/dist/src/router/index.d.ts +9 -0
  78. package/dist/src/router/index.d.ts.map +1 -0
  79. package/dist/src/router/index.js +8 -0
  80. package/dist/src/router/interfaces/resolve.request.d.ts +10 -0
  81. package/dist/src/router/interfaces/resolve.request.d.ts.map +1 -0
  82. package/dist/src/router/interfaces/route.response.d.ts +8 -0
  83. package/dist/src/router/interfaces/route.response.d.ts.map +1 -0
  84. package/dist/src/router/o-address-resolution.d.ts +12 -0
  85. package/dist/src/router/o-address-resolution.d.ts.map +1 -0
  86. package/dist/src/router/o-address-resolution.js +42 -0
  87. package/dist/src/router/o-address-resolver.d.ts +14 -0
  88. package/dist/src/router/o-address-resolver.d.ts.map +1 -0
  89. package/dist/src/router/o-address-resolver.js +19 -0
  90. package/dist/src/router/o-address.d.ts +33 -0
  91. package/dist/src/router/o-address.d.ts.map +1 -0
  92. package/dist/src/router/o-address.js +101 -0
  93. package/dist/src/router/o-request.router.d.ts +18 -0
  94. package/dist/src/router/o-request.router.d.ts.map +1 -0
  95. package/dist/src/router/o-request.router.js +12 -0
  96. package/dist/src/router/o-router.d.ts +19 -0
  97. package/dist/src/router/o-router.d.ts.map +1 -0
  98. package/dist/src/router/o-router.js +14 -0
  99. package/dist/src/transports/custom.transport.d.ts +6 -0
  100. package/dist/src/transports/custom.transport.d.ts.map +1 -0
  101. package/dist/src/transports/custom.transport.js +10 -0
  102. package/dist/src/transports/index.d.ts +4 -0
  103. package/dist/src/transports/index.d.ts.map +1 -0
  104. package/dist/src/transports/index.js +3 -0
  105. package/dist/src/transports/interfaces/transport-type.enum.d.ts +5 -0
  106. package/dist/src/transports/interfaces/transport-type.enum.d.ts.map +1 -0
  107. package/dist/src/transports/interfaces/transport-type.enum.js +5 -0
  108. package/dist/src/transports/o-transport.d.ts +10 -0
  109. package/dist/src/transports/o-transport.d.ts.map +1 -0
  110. package/dist/src/transports/o-transport.js +16 -0
  111. package/dist/src/{core/utils → utils}/core.utils.d.ts +4 -3
  112. package/dist/src/utils/core.utils.d.ts.map +1 -0
  113. package/dist/src/{core/utils → utils}/core.utils.js +17 -2
  114. package/dist/src/utils/index.d.ts +2 -0
  115. package/dist/src/utils/index.d.ts.map +1 -1
  116. package/dist/src/utils/index.js +2 -0
  117. package/dist/src/{core/utils → utils}/logger.d.ts +1 -0
  118. package/dist/src/utils/logger.d.ts.map +1 -0
  119. package/dist/src/{core/utils → utils}/logger.js +4 -1
  120. package/dist/test/server/in-process.spec.js +2 -14
  121. package/package.json +3 -3
  122. package/dist/src/core/core.node.d.ts +0 -79
  123. package/dist/src/core/core.node.d.ts.map +0 -1
  124. package/dist/src/core/core.node.js +0 -304
  125. package/dist/src/core/interfaces/connection-manager.config.d.ts +0 -7
  126. package/dist/src/core/interfaces/connection-manager.config.d.ts.map +0 -1
  127. package/dist/src/core/interfaces/connection-send-params.interface.d.ts.map +0 -1
  128. package/dist/src/core/interfaces/core-config.interface.d.ts.map +0 -1
  129. package/dist/src/core/interfaces/restricted-addresses.enum.d.ts +0 -13
  130. package/dist/src/core/interfaces/restricted-addresses.enum.d.ts.map +0 -1
  131. package/dist/src/core/interfaces/restricted-addresses.enum.js +0 -18
  132. package/dist/src/core/lib/o-address-resolution.d.ts +0 -9
  133. package/dist/src/core/lib/o-address-resolution.d.ts.map +0 -1
  134. package/dist/src/core/lib/o-address-resolution.js +0 -24
  135. package/dist/src/core/lib/o-address-resolver.d.ts +0 -17
  136. package/dist/src/core/lib/o-address-resolver.d.ts.map +0 -1
  137. package/dist/src/core/lib/o-address-resolver.js +0 -36
  138. package/dist/src/core/lib/o-connection-manager.d.ts +0 -22
  139. package/dist/src/core/lib/o-connection-manager.d.ts.map +0 -1
  140. package/dist/src/core/lib/o-connection-manager.js +0 -65
  141. package/dist/src/core/lib/o-connection.d.ts +0 -27
  142. package/dist/src/core/lib/o-connection.d.ts.map +0 -1
  143. package/dist/src/core/lib/o-connection.js +0 -84
  144. package/dist/src/core/lib/o-request.d.ts.map +0 -1
  145. package/dist/src/core/lib/o-response.d.ts.map +0 -1
  146. package/dist/src/core/lib/resolvers/anything.resolver.d.ts +0 -8
  147. package/dist/src/core/lib/resolvers/anything.resolver.d.ts.map +0 -1
  148. package/dist/src/core/lib/resolvers/anything.resolver.js +0 -15
  149. package/dist/src/core/lib/resolvers/index.d.ts +0 -5
  150. package/dist/src/core/lib/resolvers/index.d.ts.map +0 -1
  151. package/dist/src/core/lib/resolvers/index.js +0 -4
  152. package/dist/src/core/lib/resolvers/method.resolver.d.ts +0 -8
  153. package/dist/src/core/lib/resolvers/method.resolver.d.ts.map +0 -1
  154. package/dist/src/core/lib/resolvers/method.resolver.js +0 -18
  155. package/dist/src/core/lib/resolvers/next-hop.resolver.d.ts +0 -10
  156. package/dist/src/core/lib/resolvers/next-hop.resolver.d.ts.map +0 -1
  157. package/dist/src/core/lib/resolvers/next-hop.resolver.js +0 -59
  158. package/dist/src/core/lib/resolvers/storage.resolver.d.ts +0 -6
  159. package/dist/src/core/lib/resolvers/storage.resolver.d.ts.map +0 -1
  160. package/dist/src/core/lib/resolvers/storage.resolver.js +0 -10
  161. package/dist/src/core/o-address.d.ts +0 -20
  162. package/dist/src/core/o-address.d.ts.map +0 -1
  163. package/dist/src/core/o-address.js +0 -47
  164. package/dist/src/core/utils/core.utils.d.ts.map +0 -1
  165. package/dist/src/core/utils/index.d.ts +0 -4
  166. package/dist/src/core/utils/index.d.ts.map +0 -1
  167. package/dist/src/core/utils/index.js +0 -3
  168. package/dist/src/core/utils/logger.d.ts.map +0 -1
  169. package/dist/src/core/utils/network.utils.d.ts +0 -16
  170. package/dist/src/core/utils/network.utils.d.ts.map +0 -1
  171. package/dist/src/core/utils/network.utils.js +0 -35
  172. package/dist/src/error/tool.error.d.ts +0 -19
  173. package/dist/src/error/tool.error.d.ts.map +0 -1
  174. package/dist/src/node/index.d.ts +0 -4
  175. package/dist/src/node/index.d.ts.map +0 -1
  176. package/dist/src/node/index.js +0 -3
  177. package/dist/src/node/interfaces/route.request.d.ts +0 -14
  178. package/dist/src/node/interfaces/route.request.d.ts.map +0 -1
  179. package/dist/src/node/lib/local-search.lib.d.ts +0 -6
  180. package/dist/src/node/lib/local-search.lib.d.ts.map +0 -1
  181. package/dist/src/node/lib/local-search.lib.js +0 -10
  182. package/dist/src/node/lib/network-activity.lib.d.ts +0 -12
  183. package/dist/src/node/lib/network-activity.lib.d.ts.map +0 -1
  184. package/dist/src/node/lib/network-activity.lib.js +0 -29
  185. package/dist/src/node/node.d.ts +0 -45
  186. package/dist/src/node/node.d.ts.map +0 -1
  187. package/dist/src/node/node.js +0 -359
  188. package/dist/src/node-virtual/index.d.ts +0 -2
  189. package/dist/src/node-virtual/index.d.ts.map +0 -1
  190. package/dist/src/node-virtual/index.js +0 -1
  191. package/dist/src/node-virtual/virtual.node.d.ts +0 -10
  192. package/dist/src/node-virtual/virtual.node.d.ts.map +0 -1
  193. package/dist/src/node-virtual/virtual.node.js +0 -12
  194. package/dist/src/plan/agent.plan.d.ts +0 -28
  195. package/dist/src/plan/agent.plan.d.ts.map +0 -1
  196. package/dist/src/plan/agent.plan.js +0 -187
  197. package/dist/src/plan/index.d.ts +0 -5
  198. package/dist/src/plan/index.d.ts.map +0 -1
  199. package/dist/src/plan/index.js +0 -4
  200. package/dist/src/plan/interfaces/configure.result.d.ts +0 -6
  201. package/dist/src/plan/interfaces/configure.result.d.ts.map +0 -1
  202. package/dist/src/plan/interfaces/handshake.result.d.ts +0 -14
  203. package/dist/src/plan/interfaces/handshake.result.d.ts.map +0 -1
  204. package/dist/src/plan/interfaces/plan-config.interface.d.ts +0 -16
  205. package/dist/src/plan/interfaces/plan-config.interface.d.ts.map +0 -1
  206. package/dist/src/plan/interfaces/plan-result.interface.d.ts +0 -6
  207. package/dist/src/plan/interfaces/plan-result.interface.d.ts.map +0 -1
  208. package/dist/src/plan/interfaces/plan-type.enum.d.ts +0 -8
  209. package/dist/src/plan/interfaces/plan-type.enum.d.ts.map +0 -1
  210. package/dist/src/plan/interfaces/plan-type.enum.js +0 -8
  211. package/dist/src/plan/interfaces/plan.result.d.ts +0 -15
  212. package/dist/src/plan/interfaces/plan.result.d.ts.map +0 -1
  213. package/dist/src/plan/interfaces/plan.result.js +0 -1
  214. package/dist/src/plan/interfaces/query.config.d.ts +0 -6
  215. package/dist/src/plan/interfaces/query.config.d.ts.map +0 -1
  216. package/dist/src/plan/interfaces/query.config.js +0 -1
  217. package/dist/src/plan/interfaces/task.config.d.ts +0 -10
  218. package/dist/src/plan/interfaces/task.config.d.ts.map +0 -1
  219. package/dist/src/plan/interfaces/task.config.js +0 -1
  220. package/dist/src/plan/o-plan.d.ts +0 -36
  221. package/dist/src/plan/o-plan.d.ts.map +0 -1
  222. package/dist/src/plan/o-plan.js +0 -202
  223. package/dist/src/plan/plan.context.d.ts +0 -10
  224. package/dist/src/plan/plan.context.d.ts.map +0 -1
  225. package/dist/src/plan/plan.context.js +0 -28
  226. package/dist/src/plan/prompts/agent.prompt.d.ts +0 -2
  227. package/dist/src/plan/prompts/agent.prompt.d.ts.map +0 -1
  228. package/dist/src/plan/prompts/agent.prompt.js +0 -112
  229. package/dist/src/plan/prompts/configure.prompt.d.ts +0 -2
  230. package/dist/src/plan/prompts/configure.prompt.d.ts.map +0 -1
  231. package/dist/src/plan/prompts/configure.prompt.js +0 -40
  232. package/dist/src/plan/prompts/custom.prompt.d.ts +0 -2
  233. package/dist/src/plan/prompts/custom.prompt.d.ts.map +0 -1
  234. package/dist/src/plan/prompts/custom.prompt.js +0 -80
  235. package/dist/src/plan/search/prompts/search-analysis.prompt.d.ts +0 -2
  236. package/dist/src/plan/search/prompts/search-analysis.prompt.d.ts.map +0 -1
  237. package/dist/src/plan/search/prompts/search-analysis.prompt.js +0 -14
  238. package/dist/src/plan/search/search.plan.d.ts +0 -21
  239. package/dist/src/plan/search/search.plan.d.ts.map +0 -1
  240. package/dist/src/plan/search/search.plan.js +0 -53
  241. package/dist/src/plan/use/index.d.ts +0 -2
  242. package/dist/src/plan/use/index.d.ts.map +0 -1
  243. package/dist/src/plan/use/index.js +0 -1
  244. package/dist/src/plan/use/use.plan.d.ts +0 -16
  245. package/dist/src/plan/use/use.plan.d.ts.map +0 -1
  246. package/dist/src/plan/use/use.plan.js +0 -149
  247. /package/dist/src/{core → connection}/interfaces/connection-manager.config.js +0 -0
  248. /package/dist/src/{core → connection}/interfaces/connection-send-params.interface.d.ts +0 -0
  249. /package/dist/src/{core → connection}/interfaces/connection-send-params.interface.js +0 -0
  250. /package/dist/src/{core/interfaces/core-config.interface.js → connection/interfaces/connection.config.js} +0 -0
  251. /package/dist/src/{core/lib → connection}/o-response.d.ts +0 -0
  252. /package/dist/src/{core/lib → connection}/o-response.js +0 -0
  253. /package/dist/src/{node/interfaces/route.request.js → core/interfaces/o-core.config.js} +0 -0
  254. /package/dist/src/{plan/interfaces/configure.result.js → core/interfaces/o-core.interface.js} +0 -0
  255. /package/dist/src/{plan/interfaces/handshake.result.js → error/interfaces/o-error.interface.js} +0 -0
  256. /package/dist/src/{plan/interfaces/plan-config.interface.js → router/interfaces/resolve.request.js} +0 -0
  257. /package/dist/src/{plan/interfaces/plan-result.interface.js → router/interfaces/route.response.js} +0 -0
@@ -0,0 +1,190 @@
1
+ import { oCoreConfig } from './interfaces/o-core.config.js';
2
+ import { NodeState } from './interfaces/state.enum.js';
3
+ import { oAddress } from '../router/o-address.js';
4
+ import { NodeType } from './interfaces/node-type.enum.js';
5
+ import { oConnectionManager } from '../connection/o-connection-manager.js';
6
+ import { oResponse } from '../connection/o-response.js';
7
+ import { oConnection } from '../connection/o-connection.js';
8
+ import { oMethod } from '@olane/o-protocol';
9
+ import { oDependency } from './o-dependency.js';
10
+ import { oObject } from './o-object.js';
11
+ import { oMetrics } from './lib/o-metrics.js';
12
+ import { oHierarchyManager } from './lib/o-hierarchy.manager.js';
13
+ import { oRequestManager } from './lib/o-request.manager.js';
14
+ import { oTransport } from '../transports/o-transport.js';
15
+ import { oRouter } from '../router/o-router.js';
16
+ import { oRequest } from '../connection/o-request.js';
17
+ export declare abstract class oCore extends oObject {
18
+ readonly config: oCoreConfig;
19
+ address: oAddress;
20
+ state: NodeState;
21
+ errors: Error[];
22
+ connectionManager: oConnectionManager;
23
+ hierarchyManager: oHierarchyManager;
24
+ metrics: oMetrics;
25
+ requestManager: oRequestManager;
26
+ router: oRouter;
27
+ constructor(config: oCoreConfig);
28
+ get isLeader(): boolean;
29
+ get leader(): oAddress | null;
30
+ abstract configureTransports(): any[];
31
+ /**
32
+ * Sends a request to a remote node in the O-Lane network using the specified address and optional data payload.
33
+ *
34
+ * This method handles the complete communication flow:
35
+ * 1. Validates the target address format
36
+ * 2. Resolves the routing path through the network
37
+ * 3. Establishes a connection to the target node
38
+ * 4. Sends the request payload and waits for response
39
+ * 5. Handles errors and throws them as oError instances
40
+ *
41
+ * @param address - The target node address in O-Lane format (must start with 'o://')
42
+ * @param data - Optional request data containing method, parameters, and request ID
43
+ * @param data.method - The method name to invoke on the target node
44
+ * @param data.params - Key-value pairs of parameters to pass to the method
45
+ * @param data.id - Unique identifier for the request (for tracking purposes)
46
+ * @returns Promise that resolves to an oResponse containing the result from the target node
47
+ * @throws {Error} When the address is invalid (doesn't pass validation)
48
+ * @throws {oError} When the target node returns an error response
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * // Basic usage - call a method on a remote node
53
+ * const response = await node.use(
54
+ * new oAddress('o://calculator/add'),
55
+ * {
56
+ * method: 'add',
57
+ * params: { a: 5, b: 3 },
58
+ * id: 'calc-001'
59
+ * }
60
+ * );
61
+ * console.log(response.result); // { result: 8 }
62
+ *
63
+ * // Minimal usage - just specify the address
64
+ * const response = await node.use(
65
+ * new oAddress('o://status/health')
66
+ * );
67
+ * console.log(response.result); // { status: 'healthy' }
68
+ *
69
+ * // Error handling
70
+ * try {
71
+ * const response = await node.use(
72
+ * new oAddress('o://calculator/divide'),
73
+ * { method: 'divide', params: { a: 10, b: 0 } }
74
+ * );
75
+ * } catch (error) {
76
+ * if (error instanceof oError) {
77
+ * console.error(`Node error ${error.code}: ${error.message}`);
78
+ * } else {
79
+ * console.error('Invalid address or connection error:', error.message);
80
+ * }
81
+ * }
82
+ * ```
83
+ */
84
+ use(address: oAddress, data?: {
85
+ method?: string;
86
+ params?: {
87
+ [key: string]: any;
88
+ };
89
+ id?: string;
90
+ }): Promise<oResponse>;
91
+ abstract execute(request: oRequest): Promise<any>;
92
+ useSelf(data?: {
93
+ method?: string;
94
+ params?: {
95
+ [key: string]: any;
96
+ };
97
+ id?: string;
98
+ }): Promise<oResponse>;
99
+ useChild(childAddress: oAddress, data?: {
100
+ method?: string;
101
+ params?: {
102
+ [key: string]: any;
103
+ };
104
+ id?: string;
105
+ }): Promise<oResponse>;
106
+ addChildNode(node: oCore): void;
107
+ removeChildNode(node: oCore): void;
108
+ abstract connect(nextHopAddress: oAddress, targetAddress: oAddress): Promise<oConnection>;
109
+ abstract initializeRouter(): void;
110
+ abstract unregister(): Promise<void>;
111
+ abstract register(): Promise<void>;
112
+ initialize(): Promise<void>;
113
+ get isRunning(): boolean;
114
+ /**
115
+ * Starts the node by transitioning through initialization and registration phases.
116
+ *
117
+ * This method performs the following operations in sequence:
118
+ * 1. Validates that the node is in STOPPED state
119
+ * 2. Sets state to STARTING
120
+ * 3. Calls initialize() to set up the node's core components
121
+ * 4. Attempts registration with the network (registration errors are logged but don't fail startup)
122
+ * 5. Sets state to RUNNING on success
123
+ *
124
+ * @throws {Error} If the node is not in STOPPED state or initialization fails
125
+ * @returns {Promise<void>} Resolves when the node is successfully started and running
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * const node = new oNode(config);
130
+ * try {
131
+ * await node.start();
132
+ * console.log('Node is now running');
133
+ * } catch (error) {
134
+ * console.error('Failed to start node:', error);
135
+ * }
136
+ * ```
137
+ *
138
+ * @remarks
139
+ * - If the node is already running or starting, the method will log a warning and return early
140
+ * - Registration failures are logged but do not prevent the node from starting
141
+ * - On any initialization error, the node state is set to ERROR and teardown() is called
142
+ * - The node must be in STOPPED state before calling this method
143
+ */
144
+ start(): Promise<void>;
145
+ /**
146
+ * Stops the node by performing cleanup and transitioning to a stopped state.
147
+ *
148
+ * This method performs the following operations in sequence:
149
+ * 1. Sets state to STOPPING
150
+ * 2. Calls teardown() to clean up node resources and connections
151
+ * 3. Sets state to STOPPED on successful completion
152
+ *
153
+ * @throws {Error} If teardown operations fail, the node state will be set to ERROR
154
+ * @returns {Promise<void>} Resolves when the node is successfully stopped
155
+ *
156
+ * @example
157
+ * ```typescript
158
+ * const node = new oNode(config);
159
+ * await node.start();
160
+ *
161
+ * // Later, when shutting down
162
+ * try {
163
+ * await node.stop();
164
+ * console.log('Node stopped successfully');
165
+ * } catch (error) {
166
+ * console.error('Failed to stop node:', error);
167
+ * }
168
+ * ```
169
+ *
170
+ * @remarks
171
+ * - This method can be called from any node state
172
+ * - If teardown fails, errors are logged and the node state is set to ERROR
173
+ * - All cleanup operations are performed through the teardown() method
174
+ * - The method will attempt to stop gracefully even if the node is in an error state
175
+ */
176
+ stop(): Promise<void>;
177
+ teardown(): Promise<void>;
178
+ get dependencies(): oDependency[];
179
+ get methods(): {
180
+ [key: string]: oMethod;
181
+ };
182
+ get description(): string;
183
+ get staticAddress(): oAddress;
184
+ get type(): NodeType;
185
+ get transports(): oTransport[];
186
+ get parent(): oAddress | null;
187
+ get parentTransports(): oTransport[];
188
+ whoami(): Promise<any>;
189
+ }
190
+ //# sourceMappingURL=o-core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"o-core.d.ts","sourceRoot":"","sources":["../../../src/core/o-core.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,334 @@
1
+ import { NodeState } from './interfaces/state.enum.js';
2
+ import { oAddress } from '../router/o-address.js';
3
+ import { NodeType } from './interfaces/node-type.enum.js';
4
+ import { oDependency } from './o-dependency.js';
5
+ import { oError } from '../error/o-error.js';
6
+ import { oObject } from './o-object.js';
7
+ import { oMetrics } from './lib/o-metrics.js';
8
+ import { oHierarchyManager } from './lib/o-hierarchy.manager.js';
9
+ import { oRequestManager } from './lib/o-request.manager.js';
10
+ import { CoreUtils } from '../utils/core.utils.js';
11
+ import { oErrorCodes } from '../error/index.js';
12
+ import { oRequest } from '../connection/o-request.js';
13
+ export class oCore extends oObject {
14
+ constructor(config) {
15
+ super((config.name ? `:${config.name}` : '') + ':' + config.address.toString());
16
+ this.config = config;
17
+ this.state = NodeState.STOPPED;
18
+ this.errors = [];
19
+ this.metrics = new oMetrics();
20
+ this.requestManager = new oRequestManager();
21
+ this.address = config.address || new oAddress('o://node');
22
+ this.hierarchyManager = new oHierarchyManager({
23
+ leaders: this.config.leader ? [this.config.leader] : [],
24
+ parents: this.config.parent ? [this.config.parent] : [],
25
+ });
26
+ }
27
+ get isLeader() {
28
+ return this.config.type === NodeType.LEADER;
29
+ }
30
+ get leader() {
31
+ return this.isLeader ? this.address : this.config?.leader || null;
32
+ }
33
+ /**
34
+ * Sends a request to a remote node in the O-Lane network using the specified address and optional data payload.
35
+ *
36
+ * This method handles the complete communication flow:
37
+ * 1. Validates the target address format
38
+ * 2. Resolves the routing path through the network
39
+ * 3. Establishes a connection to the target node
40
+ * 4. Sends the request payload and waits for response
41
+ * 5. Handles errors and throws them as oError instances
42
+ *
43
+ * @param address - The target node address in O-Lane format (must start with 'o://')
44
+ * @param data - Optional request data containing method, parameters, and request ID
45
+ * @param data.method - The method name to invoke on the target node
46
+ * @param data.params - Key-value pairs of parameters to pass to the method
47
+ * @param data.id - Unique identifier for the request (for tracking purposes)
48
+ * @returns Promise that resolves to an oResponse containing the result from the target node
49
+ * @throws {Error} When the address is invalid (doesn't pass validation)
50
+ * @throws {oError} When the target node returns an error response
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * // Basic usage - call a method on a remote node
55
+ * const response = await node.use(
56
+ * new oAddress('o://calculator/add'),
57
+ * {
58
+ * method: 'add',
59
+ * params: { a: 5, b: 3 },
60
+ * id: 'calc-001'
61
+ * }
62
+ * );
63
+ * console.log(response.result); // { result: 8 }
64
+ *
65
+ * // Minimal usage - just specify the address
66
+ * const response = await node.use(
67
+ * new oAddress('o://status/health')
68
+ * );
69
+ * console.log(response.result); // { status: 'healthy' }
70
+ *
71
+ * // Error handling
72
+ * try {
73
+ * const response = await node.use(
74
+ * new oAddress('o://calculator/divide'),
75
+ * { method: 'divide', params: { a: 10, b: 0 } }
76
+ * );
77
+ * } catch (error) {
78
+ * if (error instanceof oError) {
79
+ * console.error(`Node error ${error.code}: ${error.message}`);
80
+ * } else {
81
+ * console.error('Invalid address or connection error:', error.message);
82
+ * }
83
+ * }
84
+ * ```
85
+ */
86
+ async use(address, data) {
87
+ if (!this.isRunning) {
88
+ throw new Error('Node is not running');
89
+ }
90
+ if (!address.validate()) {
91
+ throw new Error('Invalid address');
92
+ }
93
+ this.logger.debug('Using address: ', address.toString());
94
+ if (address.toStaticAddress().equals(this.address.toStaticAddress())) {
95
+ return this.useSelf(data);
96
+ }
97
+ const { nextHopAddress, targetAddress } = await this.router.translate(address, this);
98
+ if (nextHopAddress.toStaticAddress().equals(this.address.toStaticAddress())) {
99
+ return this.useSelf(data);
100
+ }
101
+ const connection = await this.connect(nextHopAddress, targetAddress);
102
+ // communicate the payload to the target node
103
+ const response = await connection.send({
104
+ address: targetAddress?.toString() || '',
105
+ payload: data || {},
106
+ id: data?.id,
107
+ });
108
+ // if there is an error, throw it to continue to bubble up
109
+ if (response.result.error) {
110
+ this.logger.error('response.result.error', JSON.stringify(response.result.error, null, 2));
111
+ throw oError.fromJSON(response.result.error);
112
+ }
113
+ return response;
114
+ }
115
+ async useSelf(data) {
116
+ if (!this.isRunning) {
117
+ throw new Error('Node is not running');
118
+ }
119
+ // let's call our own tool
120
+ this.logger.debug('Calling ourselves, skipping...', data);
121
+ const request = new oRequest({
122
+ method: data?.method,
123
+ params: {
124
+ _connectionId: 0,
125
+ _requestMethod: data?.method,
126
+ ...data?.params,
127
+ },
128
+ id: 0,
129
+ });
130
+ let success = true;
131
+ const result = await this.execute(request).catch((error) => {
132
+ this.logger.error('Error executing tool: ', error);
133
+ success = false;
134
+ const responseError = error instanceof oError
135
+ ? error
136
+ : new oError(oErrorCodes.UNKNOWN, error.message);
137
+ return {
138
+ error: responseError.toJSON(),
139
+ };
140
+ });
141
+ if (success) {
142
+ this.metrics.successCount++;
143
+ }
144
+ else {
145
+ this.metrics.errorCount++;
146
+ }
147
+ return CoreUtils.buildResponse(request, result, result?.error);
148
+ }
149
+ async useChild(childAddress, data) {
150
+ if (!this.isRunning) {
151
+ throw new Error('Node is not running');
152
+ }
153
+ if (!childAddress.transports) {
154
+ this.logger.warn('Child address has no transports, this might break!');
155
+ }
156
+ const connection = await this.connect(childAddress, childAddress);
157
+ // communicate the payload to the target node
158
+ const response = await connection.send({
159
+ address: childAddress?.toString() || '',
160
+ payload: data || {},
161
+ id: data?.id,
162
+ });
163
+ // if there is an error, throw it to continue to bubble up
164
+ if (response.result.error) {
165
+ this.logger.error('response.result.error', JSON.stringify(response.result.error, null, 2));
166
+ throw oError.fromJSON(response.result.error);
167
+ }
168
+ return response;
169
+ }
170
+ // hierarchy
171
+ addChildNode(node) {
172
+ this.logger.debug('Adding virtual node: ' + node.address.toString());
173
+ this.hierarchyManager.addChild(node.address);
174
+ }
175
+ removeChildNode(node) {
176
+ this.hierarchyManager.removeChild(node.address);
177
+ }
178
+ // initialize
179
+ async initialize() { }
180
+ get isRunning() {
181
+ return this.state < NodeState.STOPPING;
182
+ }
183
+ /**
184
+ * Starts the node by transitioning through initialization and registration phases.
185
+ *
186
+ * This method performs the following operations in sequence:
187
+ * 1. Validates that the node is in STOPPED state
188
+ * 2. Sets state to STARTING
189
+ * 3. Calls initialize() to set up the node's core components
190
+ * 4. Attempts registration with the network (registration errors are logged but don't fail startup)
191
+ * 5. Sets state to RUNNING on success
192
+ *
193
+ * @throws {Error} If the node is not in STOPPED state or initialization fails
194
+ * @returns {Promise<void>} Resolves when the node is successfully started and running
195
+ *
196
+ * @example
197
+ * ```typescript
198
+ * const node = new oNode(config);
199
+ * try {
200
+ * await node.start();
201
+ * console.log('Node is now running');
202
+ * } catch (error) {
203
+ * console.error('Failed to start node:', error);
204
+ * }
205
+ * ```
206
+ *
207
+ * @remarks
208
+ * - If the node is already running or starting, the method will log a warning and return early
209
+ * - Registration failures are logged but do not prevent the node from starting
210
+ * - On any initialization error, the node state is set to ERROR and teardown() is called
211
+ * - The node must be in STOPPED state before calling this method
212
+ */
213
+ async start() {
214
+ if (this.state !== NodeState.STOPPED) {
215
+ this.logger.warn('Node is not stopped, skipping start');
216
+ return;
217
+ }
218
+ this.state = NodeState.STARTING;
219
+ try {
220
+ await this.initialize();
221
+ await this.register().catch((error) => {
222
+ this.logger.error('Failed to register node', error);
223
+ });
224
+ this.state = NodeState.RUNNING;
225
+ }
226
+ catch (error) {
227
+ this.logger.error('Failed to start node', error);
228
+ this.errors.push(error);
229
+ this.state = NodeState.ERROR;
230
+ await this.teardown();
231
+ }
232
+ }
233
+ /**
234
+ * Stops the node by performing cleanup and transitioning to a stopped state.
235
+ *
236
+ * This method performs the following operations in sequence:
237
+ * 1. Sets state to STOPPING
238
+ * 2. Calls teardown() to clean up node resources and connections
239
+ * 3. Sets state to STOPPED on successful completion
240
+ *
241
+ * @throws {Error} If teardown operations fail, the node state will be set to ERROR
242
+ * @returns {Promise<void>} Resolves when the node is successfully stopped
243
+ *
244
+ * @example
245
+ * ```typescript
246
+ * const node = new oNode(config);
247
+ * await node.start();
248
+ *
249
+ * // Later, when shutting down
250
+ * try {
251
+ * await node.stop();
252
+ * console.log('Node stopped successfully');
253
+ * } catch (error) {
254
+ * console.error('Failed to stop node:', error);
255
+ * }
256
+ * ```
257
+ *
258
+ * @remarks
259
+ * - This method can be called from any node state
260
+ * - If teardown fails, errors are logged and the node state is set to ERROR
261
+ * - All cleanup operations are performed through the teardown() method
262
+ * - The method will attempt to stop gracefully even if the node is in an error state
263
+ */
264
+ async stop() {
265
+ this.logger.debug('Stop node called...');
266
+ if (this.state !== NodeState.RUNNING) {
267
+ this.logger.warn('Node is not running, skipping stop');
268
+ return;
269
+ }
270
+ this.state = NodeState.STOPPING;
271
+ try {
272
+ await this.teardown();
273
+ this.state = NodeState.STOPPED;
274
+ this.logger.debug('Node stopped!');
275
+ }
276
+ catch (error) {
277
+ this.errors.push(error);
278
+ this.state = NodeState.ERROR;
279
+ this.logger.error('Node failed to stop', error);
280
+ }
281
+ }
282
+ async teardown() {
283
+ this.logger.debug('Tearing down node...');
284
+ this.state = NodeState.STOPPING;
285
+ for (const child of this.hierarchyManager.children) {
286
+ this.logger.debug('Stopping child: ' + child.toString());
287
+ await this.useChild(child, {
288
+ method: 'stop',
289
+ params: {},
290
+ }).catch((error) => {
291
+ if (error.message === 'No data received') {
292
+ // ignore
293
+ }
294
+ else {
295
+ this.logger.error('Potential error stopping child', error);
296
+ }
297
+ });
298
+ this.logger.debug('Child stopped: ' + child.toString());
299
+ }
300
+ this.hierarchyManager.clear();
301
+ }
302
+ get dependencies() {
303
+ return this.config.dependencies?.map((d) => new oDependency(d)) || [];
304
+ }
305
+ get methods() {
306
+ return this.config.methods || {};
307
+ }
308
+ get description() {
309
+ return this.config.description || '';
310
+ }
311
+ get staticAddress() {
312
+ return this.config.address;
313
+ }
314
+ get type() {
315
+ return this.config.type || NodeType.UNKNOWN;
316
+ }
317
+ get transports() {
318
+ return [];
319
+ }
320
+ get parent() {
321
+ return this.config.parent || null;
322
+ }
323
+ get parentTransports() {
324
+ return this.parent?.transports || [];
325
+ }
326
+ async whoami() {
327
+ return {
328
+ address: this.address.toString(),
329
+ type: this.type,
330
+ description: this.description,
331
+ methods: this.methods,
332
+ };
333
+ }
334
+ }
@@ -0,0 +1,7 @@
1
+ import { Logger } from '../utils/logger.js';
2
+ export declare class oObject {
3
+ logger: Logger;
4
+ constructor(name?: string);
5
+ static log(...args: any[]): void;
6
+ }
7
+ //# sourceMappingURL=o-object.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"o-object.d.ts","sourceRoot":"","sources":["../../../src/core/o-object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,qBAAa,OAAO;IACX,MAAM,EAAE,MAAM,CAAC;gBACV,IAAI,CAAC,EAAE,MAAM;IAIzB,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;CAI1B"}
@@ -0,0 +1,10 @@
1
+ import { Logger } from '../utils/logger.js';
2
+ export class oObject {
3
+ constructor(name) {
4
+ this.logger = new Logger(this.constructor.name + (name ? `:${name}` : ''));
5
+ }
6
+ static log(...args) {
7
+ const l = new Logger(this.constructor.name);
8
+ l.debug(...args);
9
+ }
10
+ }
@@ -1,16 +1,18 @@
1
- export declare enum oToolErrorCodes {
2
- TOOL_ERROR = 1001,
3
- TOOL_NOT_FOUND = 1002,
4
- TOOL_NOT_IMPLEMENTED = 1003,
5
- TOOL_NOT_CONFIGURED = 1004,
6
- TOOL_NOT_AUTHORIZED = 1005,
7
- TOOL_MISSING_PARAMETERS = 1006,
8
- TOOL_INVALID_PARAMETERS = 1007,
9
- TOOL_INVALID_RESPONSE = 1008,
10
- TOOL_INVALID_REQUEST = 1009,
11
- TOOL_INVALID_STATE = 1010,
12
- TOOL_INVALID_ACTION = 1011,
13
- TOOL_INVALID_CREDENTIALS = 1012,
14
- TOOL_TRANSPORT_NOT_SUPPORTED = 1013
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
15
17
  }
16
18
  //# sourceMappingURL=codes.error.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codes.error.d.ts","sourceRoot":"","sources":["../../../../src/error/enums/codes.error.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe;IACzB,UAAU,OAAO;IACjB,cAAc,OAAO;IACrB,oBAAoB,OAAO;IAC3B,mBAAmB,OAAO;IAC1B,mBAAmB,OAAO;IAC1B,uBAAuB,OAAO;IAC9B,uBAAuB,OAAO;IAC9B,qBAAqB,OAAO;IAC5B,oBAAoB,OAAO;IAC3B,kBAAkB,OAAO;IACzB,mBAAmB,OAAO;IAC1B,wBAAwB,OAAO;IAC/B,4BAA4B,OAAO;CACpC"}
1
+ {"version":3,"file":"codes.error.d.ts","sourceRoot":"","sources":["../../../../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;CAC1B"}
@@ -1,16 +1,18 @@
1
- export var oToolErrorCodes;
2
- (function (oToolErrorCodes) {
3
- oToolErrorCodes[oToolErrorCodes["TOOL_ERROR"] = 1001] = "TOOL_ERROR";
4
- oToolErrorCodes[oToolErrorCodes["TOOL_NOT_FOUND"] = 1002] = "TOOL_NOT_FOUND";
5
- oToolErrorCodes[oToolErrorCodes["TOOL_NOT_IMPLEMENTED"] = 1003] = "TOOL_NOT_IMPLEMENTED";
6
- oToolErrorCodes[oToolErrorCodes["TOOL_NOT_CONFIGURED"] = 1004] = "TOOL_NOT_CONFIGURED";
7
- oToolErrorCodes[oToolErrorCodes["TOOL_NOT_AUTHORIZED"] = 1005] = "TOOL_NOT_AUTHORIZED";
8
- oToolErrorCodes[oToolErrorCodes["TOOL_MISSING_PARAMETERS"] = 1006] = "TOOL_MISSING_PARAMETERS";
9
- oToolErrorCodes[oToolErrorCodes["TOOL_INVALID_PARAMETERS"] = 1007] = "TOOL_INVALID_PARAMETERS";
10
- oToolErrorCodes[oToolErrorCodes["TOOL_INVALID_RESPONSE"] = 1008] = "TOOL_INVALID_RESPONSE";
11
- oToolErrorCodes[oToolErrorCodes["TOOL_INVALID_REQUEST"] = 1009] = "TOOL_INVALID_REQUEST";
12
- oToolErrorCodes[oToolErrorCodes["TOOL_INVALID_STATE"] = 1010] = "TOOL_INVALID_STATE";
13
- oToolErrorCodes[oToolErrorCodes["TOOL_INVALID_ACTION"] = 1011] = "TOOL_INVALID_ACTION";
14
- oToolErrorCodes[oToolErrorCodes["TOOL_INVALID_CREDENTIALS"] = 1012] = "TOOL_INVALID_CREDENTIALS";
15
- oToolErrorCodes[oToolErrorCodes["TOOL_TRANSPORT_NOT_SUPPORTED"] = 1013] = "TOOL_TRANSPORT_NOT_SUPPORTED";
16
- })(oToolErrorCodes || (oToolErrorCodes = {}));
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 = {}));
@@ -1,3 +1,3 @@
1
- export * from './tool.error.js';
1
+ export * from './o-error.js';
2
2
  export * from './enums/codes.error.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/error/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/error/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC"}
@@ -1,2 +1,2 @@
1
- export * from './tool.error.js';
1
+ export * from './o-error.js';
2
2
  export * from './enums/codes.error.js';
@@ -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":["../../../../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"}