@zudojs/core 0.1.0 → 1.1.0

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 (485) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +141 -7
  3. package/dist/application/application.d.ts +43 -2
  4. package/dist/application/application.js +111 -13
  5. package/dist/application/applicationContext.context.d.ts +27 -1
  6. package/dist/application/applicationContext.context.js +22 -2
  7. package/dist/application/createApplication.d.ts +78 -0
  8. package/dist/application/createApplication.js +109 -0
  9. package/dist/application/index.d.ts +2 -1
  10. package/dist/application/index.js +2 -1
  11. package/dist/configuration/configurationManager.manager.d.ts +42 -0
  12. package/dist/configuration/configurationManager.manager.js +104 -7
  13. package/dist/configuration/core/configuration.d.ts +60 -15
  14. package/dist/configuration/core/configuration.js +248 -51
  15. package/dist/configuration/core/configurationKey.key.d.ts +4 -2
  16. package/dist/configuration/core/configurationKey.key.js +2 -13
  17. package/dist/configuration/core/configurationPath.path.d.ts +17 -0
  18. package/dist/configuration/core/configurationPath.path.js +33 -0
  19. package/dist/configuration/core/index.d.ts +7 -1
  20. package/dist/configuration/core/index.js +1 -0
  21. package/dist/configuration/error/configurationError.error.d.ts +11 -0
  22. package/dist/configuration/error/configurationError.error.js +29 -1
  23. package/dist/configuration/error/configurationRedactor.redactor.d.ts +16 -0
  24. package/dist/configuration/error/configurationRedactor.redactor.js +83 -5
  25. package/dist/configuration/error/index.d.ts +2 -1
  26. package/dist/configuration/error/index.js +2 -1
  27. package/dist/configuration/index.d.ts +1 -1
  28. package/dist/configuration/loader/configurationLoader.loader.d.ts +47 -9
  29. package/dist/configuration/loader/configurationLoader.loader.js +107 -26
  30. package/dist/configuration/loader/index.d.ts +1 -1
  31. package/dist/configuration/loader/index.js +1 -1
  32. package/dist/configuration/registry/configurationProvider.provider.d.ts +26 -1
  33. package/dist/configuration/registry/configurationProvider.provider.js +33 -7
  34. package/dist/configuration/registry/configurationRegistry.registry.js +2 -1
  35. package/dist/configuration/schema/configurationSchema.schema.d.ts +0 -4
  36. package/dist/configuration/schema/configurationSchema.schema.js +11 -32
  37. package/dist/configuration/schema/configurationValidation.validator.d.ts +14 -2
  38. package/dist/configuration/schema/configurationValidation.validator.js +55 -7
  39. package/dist/configuration/schema/index.d.ts +1 -1
  40. package/dist/configuration/schema/index.js +1 -1
  41. package/dist/container/container.d.ts +51 -5
  42. package/dist/container/container.js +104 -33
  43. package/dist/container/index.d.ts +1 -1
  44. package/dist/container/index.js +1 -1
  45. package/dist/container/scope.d.ts +7 -6
  46. package/dist/context/core/contextAliases.deprecated.d.ts +32 -0
  47. package/dist/context/core/contextAliases.deprecated.js +6 -0
  48. package/dist/context/core/executionContext.context.d.ts +8 -0
  49. package/dist/context/core/executionContext.context.js +38 -15
  50. package/dist/context/core/index.d.ts +2 -2
  51. package/dist/context/core/index.js +2 -2
  52. package/dist/context/index.d.ts +20 -0
  53. package/dist/context/index.js +20 -0
  54. package/dist/context/provider/contextProvider.provider.d.ts +7 -4
  55. package/dist/context/provider/contextProvider.provider.js +9 -6
  56. package/dist/context/provider/contextStorage.storage.d.ts +47 -7
  57. package/dist/context/provider/contextStorage.storage.js +54 -12
  58. package/dist/context/provider/defaultContextStorage.storage.d.ts +18 -0
  59. package/dist/context/provider/defaultContextStorage.storage.js +20 -0
  60. package/dist/context/provider/index.d.ts +2 -1
  61. package/dist/context/provider/index.js +1 -0
  62. package/dist/errors/exceptions.d.ts +22 -0
  63. package/dist/errors/exceptions.js +38 -1
  64. package/dist/errors/frameworkError.error.d.ts +6 -9
  65. package/dist/errors/index.d.ts +1 -1
  66. package/dist/errors/index.js +1 -1
  67. package/dist/index.d.ts +4 -0
  68. package/dist/index.js +14 -0
  69. package/dist/lifecycle/core/index.d.ts +1 -1
  70. package/dist/lifecycle/core/index.js +1 -1
  71. package/dist/lifecycle/core/lifecycle.d.ts +47 -2
  72. package/dist/lifecycle/core/lifecycle.js +251 -85
  73. package/dist/lifecycle/core/lifecycleRegistry.registry.d.ts +8 -0
  74. package/dist/lifecycle/core/lifecycleRegistry.registry.js +20 -1
  75. package/dist/lifecycle/manager/lifecycleManager.manager.d.ts +21 -2
  76. package/dist/lifecycle/manager/lifecycleManager.manager.js +62 -99
  77. package/dist/lifecycle/scope/lifecycleScope.scope.d.ts +22 -1
  78. package/dist/lifecycle/scope/lifecycleScope.scope.js +85 -17
  79. package/dist/logging/console/consoleLogger.logger.d.ts +20 -1
  80. package/dist/logging/console/consoleLogger.logger.js +77 -11
  81. package/dist/logging/console/loggerFactory.factory.d.ts +6 -5
  82. package/dist/logging/console/loggerFactory.factory.js +1 -7
  83. package/dist/logging/core/index.d.ts +4 -3
  84. package/dist/logging/core/index.js +4 -3
  85. package/dist/logging/core/logEntry.entry.d.ts +41 -3
  86. package/dist/logging/core/logEntry.entry.js +125 -4
  87. package/dist/logging/core/logLevel.level.d.ts +18 -0
  88. package/dist/logging/core/logLevel.level.js +25 -1
  89. package/dist/logging/core/logRedaction.redaction.d.ts +38 -0
  90. package/dist/logging/core/logRedaction.redaction.js +19 -0
  91. package/dist/logging/core/logger.d.ts +14 -11
  92. package/dist/logging/core/logger.js +31 -6
  93. package/dist/logging/core/loggerContext.context.d.ts +12 -0
  94. package/dist/logging/core/loggerContext.context.js +19 -0
  95. package/dist/logging/core/loggerOptions.options.d.ts +17 -0
  96. package/dist/modules/index.d.ts +0 -1
  97. package/dist/modules/index.js +0 -6
  98. package/dist/modules/module.d.ts +7 -1
  99. package/dist/modules/moduleContext.context.d.ts +41 -7
  100. package/dist/modules/moduleContext.context.js +31 -8
  101. package/dist/modules/moduleDefinition.definition.d.ts +11 -7
  102. package/dist/modules/moduleDefinition.definition.js +41 -8
  103. package/dist/modules/moduleDependency/index.d.ts +2 -2
  104. package/dist/modules/moduleDependency/index.js +1 -1
  105. package/dist/modules/moduleDependency/moduleDependency.graph.d.ts +19 -2
  106. package/dist/modules/moduleDependency/moduleDependency.graph.js +122 -8
  107. package/dist/modules/moduleDependency/moduleDependency.ordering.d.ts +8 -0
  108. package/dist/modules/moduleDependency/moduleDependency.ordering.js +85 -57
  109. package/dist/modules/moduleDependency/moduleDependency.type.d.ts +28 -1
  110. package/dist/modules/moduleError/index.d.ts +1 -1
  111. package/dist/modules/moduleError/index.js +1 -1
  112. package/dist/modules/moduleError/moduleError.dependency.d.ts +11 -0
  113. package/dist/modules/moduleError/moduleError.dependency.js +15 -0
  114. package/dist/modules/moduleLifecycle/index.d.ts +5 -2
  115. package/dist/modules/moduleLifecycle/index.js +4 -1
  116. package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.d.ts +73 -10
  117. package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.js +204 -19
  118. package/dist/modules/moduleLifecycle/moduleLifecycle.stateMachine.d.ts +30 -5
  119. package/dist/modules/moduleLifecycle/moduleLifecycle.stateMachine.js +130 -10
  120. package/dist/modules/moduleLifecycle/moduleLifecycle.type.d.ts +78 -28
  121. package/dist/modules/moduleLifecycle/moduleLifecycle.type.js +15 -4
  122. package/dist/modules/moduleLoader/moduleLoader.loader.d.ts +39 -5
  123. package/dist/modules/moduleLoader/moduleLoader.loader.js +168 -59
  124. package/dist/modules/moduleLoader/moduleLoader.type.d.ts +4 -2
  125. package/dist/modules/moduleLoader/moduleLoader.type.js +10 -3
  126. package/dist/modules/moduleMetadata.metadata.js +15 -5
  127. package/dist/modules/moduleRegistry/index.d.ts +1 -1
  128. package/dist/modules/moduleRegistry/moduleRegistry.registry.d.ts +2 -2
  129. package/dist/modules/moduleRegistry/moduleRegistry.registry.js +38 -6
  130. package/dist/modules/moduleRegistry/moduleRegistry.type.d.ts +18 -1
  131. package/dist/runtime/index.d.ts +17 -15
  132. package/dist/runtime/index.js +14 -10
  133. package/dist/runtime/runtime.d.ts +135 -33
  134. package/dist/runtime/runtime.js +344 -114
  135. package/dist/runtime/runtimeBootstrap/index.d.ts +2 -1
  136. package/dist/runtime/runtimeBootstrap/index.js +1 -1
  137. package/dist/runtime/runtimeBootstrap/pipeline/index.d.ts +2 -2
  138. package/dist/runtime/runtimeBootstrap/pipeline/index.js +1 -2
  139. package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.pipeline.d.ts +41 -15
  140. package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.pipeline.js +111 -76
  141. package/dist/runtime/runtimeBootstrap/runtimeBootstrap.core.d.ts +7 -4
  142. package/dist/runtime/runtimeBootstrap/runtimeBootstrap.core.js +87 -59
  143. package/dist/runtime/runtimeBootstrap/runtimeBootstrap.type.d.ts +10 -4
  144. package/dist/runtime/runtimeContext/index.d.ts +3 -5
  145. package/dist/runtime/runtimeContext/index.js +2 -4
  146. package/dist/runtime/runtimeContext/runtimeContext.factory.d.ts +10 -4
  147. package/dist/runtime/runtimeContext/runtimeContext.factory.js +30 -7
  148. package/dist/runtime/runtimeContext/runtimeContext.type.d.ts +36 -47
  149. package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.env.d.ts +5 -0
  150. package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.env.js +6 -4
  151. package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.os.d.ts +4 -0
  152. package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.os.js +7 -9
  153. package/dist/runtime/runtimeEnvironment/index.d.ts +2 -2
  154. package/dist/runtime/runtimeEnvironment/index.js +1 -1
  155. package/dist/runtime/runtimeEnvironment/runtimeEnvironment.core.d.ts +20 -17
  156. package/dist/runtime/runtimeEnvironment/runtimeEnvironment.core.js +20 -13
  157. package/dist/runtime/runtimeEnvironment/runtimeEnvironment.type.d.ts +12 -1
  158. package/dist/runtime/runtimeError/index.d.ts +3 -3
  159. package/dist/runtime/runtimeError/index.js +1 -1
  160. package/dist/runtime/runtimeError/runtimeError.base.d.ts +15 -18
  161. package/dist/runtime/runtimeError/runtimeError.base.js +38 -36
  162. package/dist/runtime/runtimeError/runtimeError.lifecycle.d.ts +23 -8
  163. package/dist/runtime/runtimeError/runtimeError.lifecycle.js +31 -7
  164. package/dist/runtime/runtimeError/runtimeError.specialized.d.ts +1 -1
  165. package/dist/runtime/runtimeError/runtimeError.specialized.js +1 -1
  166. package/dist/runtime/runtimeError/runtimeError.type.d.ts +5 -9
  167. package/dist/runtime/runtimeLogger.d.ts +2 -2
  168. package/dist/runtime/runtimeLogger.js +3 -3
  169. package/dist/runtime/runtimeOptions/index.d.ts +1 -1
  170. package/dist/runtime/runtimeOptions/runtimeOptions.defaults.d.ts +1 -1
  171. package/dist/runtime/runtimeOptions/runtimeOptions.defaults.js +2 -0
  172. package/dist/runtime/runtimeOptions/runtimeOptions.resolver.js +13 -2
  173. package/dist/runtime/runtimeOptions/runtimeOptions.type.d.ts +45 -16
  174. package/dist/runtime/runtimeOptions/runtimeOptions.validation.js +0 -1
  175. package/dist/runtime/runtimeShutdown/index.d.ts +3 -2
  176. package/dist/runtime/runtimeShutdown/index.js +2 -2
  177. package/dist/runtime/runtimeShutdown/pipeline/index.d.ts +2 -1
  178. package/dist/runtime/runtimeShutdown/pipeline/index.js +1 -1
  179. package/dist/runtime/runtimeShutdown/pipeline/runtimeShutdown.pipeline.d.ts +37 -7
  180. package/dist/runtime/runtimeShutdown/pipeline/runtimeShutdown.pipeline.js +85 -51
  181. package/dist/runtime/runtimeShutdown/runtimeShutdown.core.d.ts +8 -16
  182. package/dist/runtime/runtimeShutdown/runtimeShutdown.core.js +85 -87
  183. package/dist/runtime/runtimeShutdown/runtimeShutdown.type.d.ts +9 -5
  184. package/dist/runtime/runtimeSignals/index.d.ts +8 -0
  185. package/dist/runtime/runtimeSignals/index.js +7 -0
  186. package/dist/runtime/runtimeSignals/runtimeSignals.d.ts +93 -0
  187. package/dist/runtime/runtimeSignals/runtimeSignals.js +149 -0
  188. package/dist/runtime/runtimeState.state.d.ts +32 -14
  189. package/dist/runtime/runtimeState.state.js +34 -27
  190. package/dist/runtime/runtimeTimeout.d.ts +40 -0
  191. package/dist/runtime/runtimeTimeout.js +42 -0
  192. package/package.json +25 -15
  193. package/dist/.tsbuildinfo +0 -1
  194. package/dist/application/application.d.ts.map +0 -1
  195. package/dist/application/application.js.map +0 -1
  196. package/dist/application/applicationContext.context.d.ts.map +0 -1
  197. package/dist/application/applicationContext.context.js.map +0 -1
  198. package/dist/application/applicationState.state.d.ts.map +0 -1
  199. package/dist/application/applicationState.state.js.map +0 -1
  200. package/dist/application/index.d.ts.map +0 -1
  201. package/dist/application/index.js.map +0 -1
  202. package/dist/configuration/configurationManager.manager.d.ts.map +0 -1
  203. package/dist/configuration/configurationManager.manager.js.map +0 -1
  204. package/dist/configuration/core/configuration.d.ts.map +0 -1
  205. package/dist/configuration/core/configuration.js.map +0 -1
  206. package/dist/configuration/core/configurationKey.key.d.ts.map +0 -1
  207. package/dist/configuration/core/configurationKey.key.js.map +0 -1
  208. package/dist/configuration/core/configurationSource.source.d.ts.map +0 -1
  209. package/dist/configuration/core/configurationSource.source.js.map +0 -1
  210. package/dist/configuration/core/index.d.ts.map +0 -1
  211. package/dist/configuration/core/index.js.map +0 -1
  212. package/dist/configuration/error/configurationError.error.d.ts.map +0 -1
  213. package/dist/configuration/error/configurationError.error.js.map +0 -1
  214. package/dist/configuration/error/configurationRedactor.redactor.d.ts.map +0 -1
  215. package/dist/configuration/error/configurationRedactor.redactor.js.map +0 -1
  216. package/dist/configuration/error/index.d.ts.map +0 -1
  217. package/dist/configuration/error/index.js.map +0 -1
  218. package/dist/configuration/events/configurationEvents.events.d.ts.map +0 -1
  219. package/dist/configuration/events/configurationEvents.events.js.map +0 -1
  220. package/dist/configuration/events/index.d.ts.map +0 -1
  221. package/dist/configuration/events/index.js.map +0 -1
  222. package/dist/configuration/index.d.ts.map +0 -1
  223. package/dist/configuration/index.js.map +0 -1
  224. package/dist/configuration/loader/configurationLoader.loader.d.ts.map +0 -1
  225. package/dist/configuration/loader/configurationLoader.loader.js.map +0 -1
  226. package/dist/configuration/loader/index.d.ts.map +0 -1
  227. package/dist/configuration/loader/index.js.map +0 -1
  228. package/dist/configuration/registry/configurationProvider.provider.d.ts.map +0 -1
  229. package/dist/configuration/registry/configurationProvider.provider.js.map +0 -1
  230. package/dist/configuration/registry/configurationRegistry.registry.d.ts.map +0 -1
  231. package/dist/configuration/registry/configurationRegistry.registry.js.map +0 -1
  232. package/dist/configuration/registry/index.d.ts.map +0 -1
  233. package/dist/configuration/registry/index.js.map +0 -1
  234. package/dist/configuration/schema/configurationSchema.schema.d.ts.map +0 -1
  235. package/dist/configuration/schema/configurationSchema.schema.js.map +0 -1
  236. package/dist/configuration/schema/configurationValidation.validator.d.ts.map +0 -1
  237. package/dist/configuration/schema/configurationValidation.validator.js.map +0 -1
  238. package/dist/configuration/schema/index.d.ts.map +0 -1
  239. package/dist/configuration/schema/index.js.map +0 -1
  240. package/dist/container/container.d.ts.map +0 -1
  241. package/dist/container/container.js.map +0 -1
  242. package/dist/container/index.d.ts.map +0 -1
  243. package/dist/container/index.js.map +0 -1
  244. package/dist/container/provider.d.ts.map +0 -1
  245. package/dist/container/provider.js.map +0 -1
  246. package/dist/container/scope.d.ts.map +0 -1
  247. package/dist/container/scope.js.map +0 -1
  248. package/dist/container/token.d.ts.map +0 -1
  249. package/dist/container/token.js.map +0 -1
  250. package/dist/context/core/context.d.ts +0 -95
  251. package/dist/context/core/context.d.ts.map +0 -1
  252. package/dist/context/core/context.js +0 -103
  253. package/dist/context/core/context.js.map +0 -1
  254. package/dist/context/core/contextKey.key.d.ts.map +0 -1
  255. package/dist/context/core/contextKey.key.js.map +0 -1
  256. package/dist/context/core/executionContext.context.d.ts.map +0 -1
  257. package/dist/context/core/executionContext.context.js.map +0 -1
  258. package/dist/context/core/index.d.ts.map +0 -1
  259. package/dist/context/core/index.js.map +0 -1
  260. package/dist/context/index.d.ts.map +0 -1
  261. package/dist/context/index.js.map +0 -1
  262. package/dist/context/provider/contextProvider.provider.d.ts.map +0 -1
  263. package/dist/context/provider/contextProvider.provider.js.map +0 -1
  264. package/dist/context/provider/contextStorage.storage.d.ts.map +0 -1
  265. package/dist/context/provider/contextStorage.storage.js.map +0 -1
  266. package/dist/context/provider/index.d.ts.map +0 -1
  267. package/dist/context/provider/index.js.map +0 -1
  268. package/dist/context/snapshot/contextSnapshot.snapshot.d.ts.map +0 -1
  269. package/dist/context/snapshot/contextSnapshot.snapshot.js.map +0 -1
  270. package/dist/context/snapshot/index.d.ts.map +0 -1
  271. package/dist/context/snapshot/index.js.map +0 -1
  272. package/dist/context/values/contextValues.values.d.ts.map +0 -1
  273. package/dist/context/values/contextValues.values.js.map +0 -1
  274. package/dist/context/values/index.d.ts.map +0 -1
  275. package/dist/context/values/index.js.map +0 -1
  276. package/dist/contracts/adapter.d.ts.map +0 -1
  277. package/dist/contracts/adapter.js.map +0 -1
  278. package/dist/contracts/disposable.d.ts.map +0 -1
  279. package/dist/contracts/disposable.js.map +0 -1
  280. package/dist/contracts/handler.d.ts.map +0 -1
  281. package/dist/contracts/handler.js.map +0 -1
  282. package/dist/contracts/index.d.ts.map +0 -1
  283. package/dist/contracts/index.js.map +0 -1
  284. package/dist/errors/errorCode.code.d.ts.map +0 -1
  285. package/dist/errors/errorCode.code.js.map +0 -1
  286. package/dist/errors/exceptions.d.ts.map +0 -1
  287. package/dist/errors/exceptions.js.map +0 -1
  288. package/dist/errors/frameworkError.error.d.ts.map +0 -1
  289. package/dist/errors/frameworkError.error.js.map +0 -1
  290. package/dist/errors/index.d.ts.map +0 -1
  291. package/dist/errors/index.js.map +0 -1
  292. package/dist/index.d.ts.map +0 -1
  293. package/dist/index.js.map +0 -1
  294. package/dist/lifecycle/core/index.d.ts.map +0 -1
  295. package/dist/lifecycle/core/index.js.map +0 -1
  296. package/dist/lifecycle/core/lifecycle.d.ts.map +0 -1
  297. package/dist/lifecycle/core/lifecycle.js.map +0 -1
  298. package/dist/lifecycle/core/lifecycleHook.hook.d.ts.map +0 -1
  299. package/dist/lifecycle/core/lifecycleHook.hook.js.map +0 -1
  300. package/dist/lifecycle/core/lifecycleRegistry.registry.d.ts.map +0 -1
  301. package/dist/lifecycle/core/lifecycleRegistry.registry.js.map +0 -1
  302. package/dist/lifecycle/core/lifecycleState.state.d.ts +0 -2
  303. package/dist/lifecycle/core/lifecycleState.state.d.ts.map +0 -1
  304. package/dist/lifecycle/core/lifecycleState.state.js +0 -2
  305. package/dist/lifecycle/core/lifecycleState.state.js.map +0 -1
  306. package/dist/lifecycle/index.d.ts.map +0 -1
  307. package/dist/lifecycle/index.js.map +0 -1
  308. package/dist/lifecycle/manager/index.d.ts.map +0 -1
  309. package/dist/lifecycle/manager/index.js.map +0 -1
  310. package/dist/lifecycle/manager/lifecycleManager.manager.d.ts.map +0 -1
  311. package/dist/lifecycle/manager/lifecycleManager.manager.js.map +0 -1
  312. package/dist/lifecycle/scope/index.d.ts.map +0 -1
  313. package/dist/lifecycle/scope/index.js.map +0 -1
  314. package/dist/lifecycle/scope/lifecycleScope.scope.d.ts.map +0 -1
  315. package/dist/lifecycle/scope/lifecycleScope.scope.js.map +0 -1
  316. package/dist/logging/console/consoleLogger.logger.d.ts.map +0 -1
  317. package/dist/logging/console/consoleLogger.logger.js.map +0 -1
  318. package/dist/logging/console/index.d.ts.map +0 -1
  319. package/dist/logging/console/index.js.map +0 -1
  320. package/dist/logging/console/loggerFactory.factory.d.ts.map +0 -1
  321. package/dist/logging/console/loggerFactory.factory.js.map +0 -1
  322. package/dist/logging/core/index.d.ts.map +0 -1
  323. package/dist/logging/core/index.js.map +0 -1
  324. package/dist/logging/core/logEntry.entry.d.ts.map +0 -1
  325. package/dist/logging/core/logEntry.entry.js.map +0 -1
  326. package/dist/logging/core/logLevel.level.d.ts.map +0 -1
  327. package/dist/logging/core/logLevel.level.js.map +0 -1
  328. package/dist/logging/core/logger.d.ts.map +0 -1
  329. package/dist/logging/core/logger.js.map +0 -1
  330. package/dist/logging/core/loggerContext.context.d.ts.map +0 -1
  331. package/dist/logging/core/loggerContext.context.js.map +0 -1
  332. package/dist/logging/core/loggerOptions.options.d.ts.map +0 -1
  333. package/dist/logging/core/loggerOptions.options.js.map +0 -1
  334. package/dist/logging/index.d.ts.map +0 -1
  335. package/dist/logging/index.js.map +0 -1
  336. package/dist/modules/index.d.ts.map +0 -1
  337. package/dist/modules/index.js.map +0 -1
  338. package/dist/modules/module.d.ts.map +0 -1
  339. package/dist/modules/module.js.map +0 -1
  340. package/dist/modules/moduleContext.context.d.ts.map +0 -1
  341. package/dist/modules/moduleContext.context.js.map +0 -1
  342. package/dist/modules/moduleDefinition.definition.d.ts.map +0 -1
  343. package/dist/modules/moduleDefinition.definition.js.map +0 -1
  344. package/dist/modules/moduleDependency/index.d.ts.map +0 -1
  345. package/dist/modules/moduleDependency/index.js.map +0 -1
  346. package/dist/modules/moduleDependency/moduleDependency.graph.d.ts.map +0 -1
  347. package/dist/modules/moduleDependency/moduleDependency.graph.js.map +0 -1
  348. package/dist/modules/moduleDependency/moduleDependency.ordering.d.ts.map +0 -1
  349. package/dist/modules/moduleDependency/moduleDependency.ordering.js.map +0 -1
  350. package/dist/modules/moduleDependency/moduleDependency.type.d.ts.map +0 -1
  351. package/dist/modules/moduleDependency/moduleDependency.type.js.map +0 -1
  352. package/dist/modules/moduleError/index.d.ts.map +0 -1
  353. package/dist/modules/moduleError/index.js.map +0 -1
  354. package/dist/modules/moduleError/moduleError.base.d.ts.map +0 -1
  355. package/dist/modules/moduleError/moduleError.base.js.map +0 -1
  356. package/dist/modules/moduleError/moduleError.dependency.d.ts.map +0 -1
  357. package/dist/modules/moduleError/moduleError.dependency.js.map +0 -1
  358. package/dist/modules/moduleError/moduleError.helpers.d.ts.map +0 -1
  359. package/dist/modules/moduleError/moduleError.helpers.js.map +0 -1
  360. package/dist/modules/moduleError/moduleError.lifecycle.d.ts.map +0 -1
  361. package/dist/modules/moduleError/moduleError.lifecycle.js.map +0 -1
  362. package/dist/modules/moduleError/moduleError.registration.d.ts.map +0 -1
  363. package/dist/modules/moduleError/moduleError.registration.js.map +0 -1
  364. package/dist/modules/moduleLifecycle/index.d.ts.map +0 -1
  365. package/dist/modules/moduleLifecycle/index.js.map +0 -1
  366. package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.d.ts.map +0 -1
  367. package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.js.map +0 -1
  368. package/dist/modules/moduleLifecycle/moduleLifecycle.stateMachine.d.ts.map +0 -1
  369. package/dist/modules/moduleLifecycle/moduleLifecycle.stateMachine.js.map +0 -1
  370. package/dist/modules/moduleLifecycle/moduleLifecycle.type.d.ts.map +0 -1
  371. package/dist/modules/moduleLifecycle/moduleLifecycle.type.js.map +0 -1
  372. package/dist/modules/moduleLoader/index.d.ts.map +0 -1
  373. package/dist/modules/moduleLoader/index.js.map +0 -1
  374. package/dist/modules/moduleLoader/moduleLoader.loader.d.ts.map +0 -1
  375. package/dist/modules/moduleLoader/moduleLoader.loader.js.map +0 -1
  376. package/dist/modules/moduleLoader/moduleLoader.type.d.ts.map +0 -1
  377. package/dist/modules/moduleLoader/moduleLoader.type.js.map +0 -1
  378. package/dist/modules/moduleMetadata.metadata.d.ts.map +0 -1
  379. package/dist/modules/moduleMetadata.metadata.js.map +0 -1
  380. package/dist/modules/moduleRegistry/index.d.ts.map +0 -1
  381. package/dist/modules/moduleRegistry/index.js.map +0 -1
  382. package/dist/modules/moduleRegistry/moduleRegistry.registry.d.ts.map +0 -1
  383. package/dist/modules/moduleRegistry/moduleRegistry.registry.js.map +0 -1
  384. package/dist/modules/moduleRegistry/moduleRegistry.type.d.ts.map +0 -1
  385. package/dist/modules/moduleRegistry/moduleRegistry.type.js.map +0 -1
  386. package/dist/runtime/index.d.ts.map +0 -1
  387. package/dist/runtime/index.js.map +0 -1
  388. package/dist/runtime/runtime.d.ts.map +0 -1
  389. package/dist/runtime/runtime.js.map +0 -1
  390. package/dist/runtime/runtimeBootstrap/index.d.ts.map +0 -1
  391. package/dist/runtime/runtimeBootstrap/index.js.map +0 -1
  392. package/dist/runtime/runtimeBootstrap/pipeline/index.d.ts.map +0 -1
  393. package/dist/runtime/runtimeBootstrap/pipeline/index.js.map +0 -1
  394. package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.invoke.d.ts +0 -6
  395. package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.invoke.d.ts.map +0 -1
  396. package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.invoke.js +0 -27
  397. package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.invoke.js.map +0 -1
  398. package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.pipeline.d.ts.map +0 -1
  399. package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.pipeline.js.map +0 -1
  400. package/dist/runtime/runtimeBootstrap/runtimeBootstrap.core.d.ts.map +0 -1
  401. package/dist/runtime/runtimeBootstrap/runtimeBootstrap.core.js.map +0 -1
  402. package/dist/runtime/runtimeBootstrap/runtimeBootstrap.type.d.ts.map +0 -1
  403. package/dist/runtime/runtimeBootstrap/runtimeBootstrap.type.js.map +0 -1
  404. package/dist/runtime/runtimeContext/index.d.ts.map +0 -1
  405. package/dist/runtime/runtimeContext/index.js.map +0 -1
  406. package/dist/runtime/runtimeContext/runtimeContext.core.d.ts +0 -38
  407. package/dist/runtime/runtimeContext/runtimeContext.core.d.ts.map +0 -1
  408. package/dist/runtime/runtimeContext/runtimeContext.core.js +0 -99
  409. package/dist/runtime/runtimeContext/runtimeContext.core.js.map +0 -1
  410. package/dist/runtime/runtimeContext/runtimeContext.factory.d.ts.map +0 -1
  411. package/dist/runtime/runtimeContext/runtimeContext.factory.js.map +0 -1
  412. package/dist/runtime/runtimeContext/runtimeContext.type.d.ts.map +0 -1
  413. package/dist/runtime/runtimeContext/runtimeContext.type.js.map +0 -1
  414. package/dist/runtime/runtimeEnvironment/detection/index.d.ts.map +0 -1
  415. package/dist/runtime/runtimeEnvironment/detection/index.js.map +0 -1
  416. package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.detection.d.ts.map +0 -1
  417. package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.detection.js.map +0 -1
  418. package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.env.d.ts.map +0 -1
  419. package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.env.js.map +0 -1
  420. package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.os.d.ts.map +0 -1
  421. package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.os.js.map +0 -1
  422. package/dist/runtime/runtimeEnvironment/index.d.ts.map +0 -1
  423. package/dist/runtime/runtimeEnvironment/index.js.map +0 -1
  424. package/dist/runtime/runtimeEnvironment/runtimeEnvironment.core.d.ts.map +0 -1
  425. package/dist/runtime/runtimeEnvironment/runtimeEnvironment.core.js.map +0 -1
  426. package/dist/runtime/runtimeEnvironment/runtimeEnvironment.type.d.ts.map +0 -1
  427. package/dist/runtime/runtimeEnvironment/runtimeEnvironment.type.js.map +0 -1
  428. package/dist/runtime/runtimeError/index.d.ts.map +0 -1
  429. package/dist/runtime/runtimeError/index.js.map +0 -1
  430. package/dist/runtime/runtimeError/runtimeError.base.d.ts.map +0 -1
  431. package/dist/runtime/runtimeError/runtimeError.base.js.map +0 -1
  432. package/dist/runtime/runtimeError/runtimeError.lifecycle.d.ts.map +0 -1
  433. package/dist/runtime/runtimeError/runtimeError.lifecycle.js.map +0 -1
  434. package/dist/runtime/runtimeError/runtimeError.specialized.d.ts.map +0 -1
  435. package/dist/runtime/runtimeError/runtimeError.specialized.js.map +0 -1
  436. package/dist/runtime/runtimeError/runtimeError.type.d.ts.map +0 -1
  437. package/dist/runtime/runtimeError/runtimeError.type.js.map +0 -1
  438. package/dist/runtime/runtimeLogger.d.ts.map +0 -1
  439. package/dist/runtime/runtimeLogger.js.map +0 -1
  440. package/dist/runtime/runtimeManager/index.d.ts +0 -12
  441. package/dist/runtime/runtimeManager/index.d.ts.map +0 -1
  442. package/dist/runtime/runtimeManager/index.js +0 -11
  443. package/dist/runtime/runtimeManager/index.js.map +0 -1
  444. package/dist/runtime/runtimeManager/runtimeManager.core.d.ts +0 -31
  445. package/dist/runtime/runtimeManager/runtimeManager.core.d.ts.map +0 -1
  446. package/dist/runtime/runtimeManager/runtimeManager.core.js +0 -136
  447. package/dist/runtime/runtimeManager/runtimeManager.core.js.map +0 -1
  448. package/dist/runtime/runtimeManager/runtimeManager.error.d.ts +0 -14
  449. package/dist/runtime/runtimeManager/runtimeManager.error.d.ts.map +0 -1
  450. package/dist/runtime/runtimeManager/runtimeManager.error.js +0 -21
  451. package/dist/runtime/runtimeManager/runtimeManager.error.js.map +0 -1
  452. package/dist/runtime/runtimeManager/runtimeManager.factory.d.ts +0 -7
  453. package/dist/runtime/runtimeManager/runtimeManager.factory.d.ts.map +0 -1
  454. package/dist/runtime/runtimeManager/runtimeManager.factory.js +0 -8
  455. package/dist/runtime/runtimeManager/runtimeManager.factory.js.map +0 -1
  456. package/dist/runtime/runtimeManager/runtimeManager.lifecycle.d.ts +0 -16
  457. package/dist/runtime/runtimeManager/runtimeManager.lifecycle.d.ts.map +0 -1
  458. package/dist/runtime/runtimeManager/runtimeManager.lifecycle.js +0 -49
  459. package/dist/runtime/runtimeManager/runtimeManager.lifecycle.js.map +0 -1
  460. package/dist/runtime/runtimeManager/runtimeManager.type.d.ts +0 -54
  461. package/dist/runtime/runtimeManager/runtimeManager.type.d.ts.map +0 -1
  462. package/dist/runtime/runtimeManager/runtimeManager.type.js +0 -2
  463. package/dist/runtime/runtimeManager/runtimeManager.type.js.map +0 -1
  464. package/dist/runtime/runtimeOptions/index.d.ts.map +0 -1
  465. package/dist/runtime/runtimeOptions/index.js.map +0 -1
  466. package/dist/runtime/runtimeOptions/runtimeOptions.defaults.d.ts.map +0 -1
  467. package/dist/runtime/runtimeOptions/runtimeOptions.defaults.js.map +0 -1
  468. package/dist/runtime/runtimeOptions/runtimeOptions.resolver.d.ts.map +0 -1
  469. package/dist/runtime/runtimeOptions/runtimeOptions.resolver.js.map +0 -1
  470. package/dist/runtime/runtimeOptions/runtimeOptions.type.d.ts.map +0 -1
  471. package/dist/runtime/runtimeOptions/runtimeOptions.type.js.map +0 -1
  472. package/dist/runtime/runtimeOptions/runtimeOptions.validation.d.ts.map +0 -1
  473. package/dist/runtime/runtimeOptions/runtimeOptions.validation.js.map +0 -1
  474. package/dist/runtime/runtimeShutdown/index.d.ts.map +0 -1
  475. package/dist/runtime/runtimeShutdown/index.js.map +0 -1
  476. package/dist/runtime/runtimeShutdown/pipeline/index.d.ts.map +0 -1
  477. package/dist/runtime/runtimeShutdown/pipeline/index.js.map +0 -1
  478. package/dist/runtime/runtimeShutdown/pipeline/runtimeShutdown.pipeline.d.ts.map +0 -1
  479. package/dist/runtime/runtimeShutdown/pipeline/runtimeShutdown.pipeline.js.map +0 -1
  480. package/dist/runtime/runtimeShutdown/runtimeShutdown.core.d.ts.map +0 -1
  481. package/dist/runtime/runtimeShutdown/runtimeShutdown.core.js.map +0 -1
  482. package/dist/runtime/runtimeShutdown/runtimeShutdown.type.d.ts.map +0 -1
  483. package/dist/runtime/runtimeShutdown/runtimeShutdown.type.js.map +0 -1
  484. package/dist/runtime/runtimeState.state.d.ts.map +0 -1
  485. package/dist/runtime/runtimeState.state.js.map +0 -1
@@ -1,29 +1,53 @@
1
1
  import { RuntimeErrorCode } from "./runtimeError.type.js";
2
2
  import { RuntimeError } from "./runtimeError.base.js";
3
3
  /**
4
- * Error thrown when runtime state transitions are invalid.
4
+ * Error thrown when an operation is attempted while the runtime is
5
+ * in a state that does not permit it (for example starting a runtime
6
+ * that is stopping, or stopping one that is still bootstrapping).
5
7
  */
6
- export class RuntimeStateError extends RuntimeError {
8
+ export class InvalidRuntimeStateError extends RuntimeError {
9
+ /**
10
+ * The runtime state in which the operation was rejected.
11
+ */
12
+ state;
13
+ constructor(message, options = {}) {
14
+ const { state, ...rest } = options;
15
+ super(message, {
16
+ ...rest,
17
+ code: RuntimeErrorCode.INVALID_STATE_TRANSITION,
18
+ metadata: {
19
+ ...(rest.metadata ?? {}),
20
+ ...(state !== undefined && { state }),
21
+ },
22
+ });
23
+ this.name = "InvalidRuntimeStateError";
24
+ this.state = state;
25
+ }
26
+ }
27
+ /**
28
+ * Error thrown when a runtime state transition is not allowed by the
29
+ * runtime state table.
30
+ */
31
+ export class InvalidRuntimeTransitionError extends RuntimeError {
7
32
  from;
8
33
  to;
9
34
  constructor(from, to, options = {}) {
10
35
  super(`Invalid runtime state transition from "${from}" to "${to}".`, {
11
36
  ...options,
12
37
  code: RuntimeErrorCode.INVALID_STATE_TRANSITION,
13
- operation: options.operation ?? "run",
14
38
  metadata: {
15
39
  ...(options.metadata ?? {}),
16
40
  from,
17
41
  to,
18
42
  },
19
43
  });
20
- this.name = "RuntimeStateError";
44
+ this.name = "InvalidRuntimeTransitionError";
21
45
  this.from = from;
22
46
  this.to = to;
23
47
  }
24
48
  }
25
49
  /**
26
- * Error thrown when runtime startup fails.
50
+ * Error thrown when runtime startup (bootstrap) fails.
27
51
  */
28
52
  export class RuntimeStartError extends RuntimeError {
29
53
  constructor(message, options = {}) {
@@ -49,7 +73,7 @@ export class RuntimeStopError extends RuntimeError {
49
73
  }
50
74
  }
51
75
  /**
52
- * Error thrown when runtime initialization fails.
76
+ * Error thrown when module initialization fails during bootstrap.
53
77
  */
54
78
  export class RuntimeInitializationError extends RuntimeError {
55
79
  constructor(message, options = {}) {
@@ -62,7 +86,7 @@ export class RuntimeInitializationError extends RuntimeError {
62
86
  }
63
87
  }
64
88
  /**
65
- * Error thrown when runtime loading fails.
89
+ * Error thrown when module loading fails during bootstrap.
66
90
  */
67
91
  export class RuntimeLoadError extends RuntimeError {
68
92
  constructor(message, options = {}) {
@@ -5,7 +5,7 @@ import { RuntimeError } from "./runtimeError.base.js";
5
5
  */
6
6
  export declare class RuntimeTimeoutError extends RuntimeError {
7
7
  readonly timeoutMs: number;
8
- constructor(message: string, timeoutMs: number, options?: Omit<RuntimeErrorOptions, "code">);
8
+ constructor(message: string, timeoutMs: number, options?: RuntimeErrorOptions);
9
9
  }
10
10
  /**
11
11
  * Error thrown when a runtime dependency is unavailable.
@@ -8,7 +8,7 @@ export class RuntimeTimeoutError extends RuntimeError {
8
8
  constructor(message, timeoutMs, options = {}) {
9
9
  super(message, {
10
10
  ...options,
11
- code: RuntimeErrorCode.OPERATION_TIMEOUT,
11
+ code: options.code ?? RuntimeErrorCode.OPERATION_TIMEOUT,
12
12
  metadata: {
13
13
  ...(options.metadata ?? {}),
14
14
  timeoutMs,
@@ -1,3 +1,4 @@
1
+ import type { SerializedBaseError } from "@zudojs/errors";
1
2
  /**
2
3
  * Runtime lifecycle operations.
3
4
  */
@@ -57,18 +58,13 @@ export interface RuntimeErrorOptions {
57
58
  /**
58
59
  * Serializable representation of RuntimeError.
59
60
  */
60
- export interface RuntimeErrorJSON {
61
- readonly name: string;
62
- readonly message: string;
63
- readonly code: string;
64
- readonly operation?: RuntimeOperation;
65
- readonly phase?: RuntimeErrorPhase;
61
+ export type RuntimeErrorJSON = SerializedBaseError & {
62
+ readonly operation?: string;
63
+ readonly phase?: string;
66
64
  readonly runtimeId?: string;
67
65
  readonly runtimeName?: string;
68
66
  readonly moduleName?: string;
69
67
  readonly errorMetadata: RuntimeErrorMetadata;
70
68
  readonly recoverable: boolean;
71
- readonly details?: unknown;
72
- readonly status?: number;
73
- }
69
+ };
74
70
  //# sourceMappingURL=runtimeError.type.d.ts.map
@@ -1,5 +1,5 @@
1
- import type { RuntimeContext } from "./runtimeContext/index.js";
1
+ import type { RuntimeIdentity } from "./runtimeContext/index.js";
2
2
  import type { RuntimeEnvironment } from "./runtimeEnvironment/index.js";
3
3
  import type { Logger } from "../logging/core/logger.js";
4
- export declare function logRuntimeEvent(logger: Logger, context: RuntimeContext, environment: RuntimeEnvironment, level: "debug" | "info" | "warn" | "error", message: string, metadata?: Record<string, unknown>): void;
4
+ export declare function logRuntimeEvent(logger: Logger, identity: RuntimeIdentity, environment: RuntimeEnvironment, level: "debug" | "info" | "warn" | "error", message: string, metadata?: Record<string, unknown>): void;
5
5
  //# sourceMappingURL=runtimeLogger.d.ts.map
@@ -1,11 +1,11 @@
1
- export function logRuntimeEvent(logger, context, environment, level, message, metadata) {
1
+ export function logRuntimeEvent(logger, identity, environment, level, message, metadata) {
2
2
  try {
3
3
  const log = logger;
4
4
  const method = log[level];
5
5
  if (typeof method === "function") {
6
6
  method.call(logger, message, {
7
- runtimeId: context.identity.id,
8
- runtimeName: context.identity.name,
7
+ runtimeId: identity.id,
8
+ runtimeName: identity.name,
9
9
  environment: environment.engine,
10
10
  ...metadata,
11
11
  });
@@ -6,5 +6,5 @@
6
6
  export { DEFAULT_RUNTIME_OPTIONS } from "./runtimeOptions.defaults.js";
7
7
  export { resolveRuntimeOptions, validateRuntimeOptions, } from "./runtimeOptions.resolver.js";
8
8
  export { isRuntimeMode, isRuntimeRole, assertRuntimeMode, assertRuntimeRole, } from "./runtimeOptions.validation.js";
9
- export type { RuntimeMode, RuntimeRole, RuntimeStartupOptions, RuntimeShutdownOptions, RuntimeSignalOptions, RuntimeDiagnosticsOptions, RuntimeInfrastructure, RuntimeOptions, ResolvedRuntimeOptions, } from "./runtimeOptions.type.js";
9
+ export type { RuntimeMode, RuntimeRole, RuntimeStartupOptions, RuntimeShutdownOptions, RuntimeSignalOptions, RuntimeDiagnosticsOptions, RuntimeEnvironmentOverrides, RuntimeOptions, ResolvedRuntimeOptions, } from "./runtimeOptions.type.js";
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -2,5 +2,5 @@ import type { ResolvedRuntimeOptions } from "./runtimeOptions.type.js";
2
2
  /**
3
3
  * Default runtime configuration.
4
4
  */
5
- export declare const DEFAULT_RUNTIME_OPTIONS: Readonly<Omit<ResolvedRuntimeOptions, "infrastructure" | "metadata">>;
5
+ export declare const DEFAULT_RUNTIME_OPTIONS: Readonly<Omit<ResolvedRuntimeOptions, "environment" | "metadata">>;
6
6
  //# sourceMappingURL=runtimeOptions.defaults.d.ts.map
@@ -26,6 +26,8 @@ export const DEFAULT_RUNTIME_OPTIONS = Object.freeze({
26
26
  handleSighup: false,
27
27
  handleUncaughtException: true,
28
28
  handleUnhandledRejection: true,
29
+ forceExitOnSecondSignal: false,
30
+ forceExitCode: 1,
29
31
  },
30
32
  diagnostics: {
31
33
  startupLogging: true,
@@ -8,6 +8,14 @@ export function resolveRuntimeOptions(options = {}) {
8
8
  const shutdown = options.shutdown ?? {};
9
9
  const signals = options.signals ?? {};
10
10
  const diagnostics = options.diagnostics ?? {};
11
+ /*
12
+ * Mode and role are validated here, not only in
13
+ * validateRuntimeOptions(): an unknown mode would otherwise be
14
+ * accepted silently and make the environment report neither
15
+ * production, development, nor test.
16
+ */
17
+ assertRuntimeMode(options.mode ?? DEFAULT_RUNTIME_OPTIONS.mode);
18
+ assertRuntimeRole(options.role ?? DEFAULT_RUNTIME_OPTIONS.role);
11
19
  validateRuntimeName(options.name);
12
20
  validateRuntimeTimeout(startup.timeoutMs, "startup");
13
21
  validateRuntimeTimeout(shutdown.timeoutMs, "shutdown");
@@ -47,6 +55,9 @@ export function resolveRuntimeOptions(options = {}) {
47
55
  DEFAULT_RUNTIME_OPTIONS.signals.handleUncaughtException,
48
56
  handleUnhandledRejection: signals.handleUnhandledRejection ??
49
57
  DEFAULT_RUNTIME_OPTIONS.signals.handleUnhandledRejection,
58
+ forceExitOnSecondSignal: signals.forceExitOnSecondSignal ??
59
+ DEFAULT_RUNTIME_OPTIONS.signals.forceExitOnSecondSignal,
60
+ forceExitCode: signals.forceExitCode ?? DEFAULT_RUNTIME_OPTIONS.signals.forceExitCode,
50
61
  },
51
62
  diagnostics: {
52
63
  startupLogging: diagnostics.startupLogging ??
@@ -58,8 +69,8 @@ export function resolveRuntimeOptions(options = {}) {
58
69
  includeModules: diagnostics.includeModules ??
59
70
  DEFAULT_RUNTIME_OPTIONS.diagnostics.includeModules,
60
71
  },
61
- infrastructure: Object.freeze({
62
- ...options.infrastructure,
72
+ environment: Object.freeze({
73
+ ...options.environment,
63
74
  }),
64
75
  metadata: Object.freeze({
65
76
  ...options.metadata,
@@ -1,9 +1,4 @@
1
- import type { ApplicationContext } from "../../application/applicationContext.context.js";
2
- import type { ConfigurationManager } from "../../configuration/configurationManager.manager.js";
3
- import type { Logger } from "../../logging/core/logger.js";
4
- import type { ModuleLoader } from "../../modules/moduleLoader/index.js";
5
- import type { ModuleLifecycleManager } from "../../modules/moduleLifecycle/index.js";
6
- import type { ModuleRegistry } from "../../modules/moduleRegistry/index.js";
1
+ import type { RuntimeEnvironmentVariables } from "../runtimeEnvironment/runtimeEnvironment.type.js";
7
2
  /**
8
3
  * Runtime execution mode.
9
4
  */
@@ -19,8 +14,19 @@ export interface RuntimeStartupOptions {
19
14
  readonly autoLoadModules?: boolean;
20
15
  readonly autoInitializeModules?: boolean;
21
16
  readonly autoStartModules?: boolean;
17
+ /**
18
+ * Continue bootstrapping when one or more modules fail to
19
+ * initialize. The runtime still becomes READY but the bootstrap
20
+ * result reports `success: false` with the failures listed.
21
+ */
22
22
  readonly continueOnInitializeError?: boolean;
23
+ /**
24
+ * Continue bootstrapping when one or more modules fail to start.
25
+ */
23
26
  readonly continueOnStartError?: boolean;
27
+ /**
28
+ * Bootstrap timeout in milliseconds. 0 disables the timeout.
29
+ */
24
30
  readonly timeoutMs?: number;
25
31
  }
26
32
  /**
@@ -31,37 +37,60 @@ export interface RuntimeShutdownOptions {
31
37
  readonly autoDestroyModules?: boolean;
32
38
  readonly continueOnStopError?: boolean;
33
39
  readonly continueOnDestroyError?: boolean;
40
+ /**
41
+ * Shutdown timeout in milliseconds. 0 disables the timeout.
42
+ */
34
43
  readonly timeoutMs?: number;
35
44
  }
36
45
  /**
37
46
  * Options related to runtime process signals.
47
+ *
48
+ * Handlers are registered when the runtime starts and removed when it
49
+ * stops, fails, or is disposed. The runtime never calls
50
+ * `process.exit()` unless `forceExitOnSecondSignal` is explicitly on.
38
51
  */
39
52
  export interface RuntimeSignalOptions {
53
+ /** Stop the runtime gracefully on SIGINT. */
40
54
  readonly handleSigint?: boolean;
55
+ /** Stop the runtime gracefully on SIGTERM. */
41
56
  readonly handleSigterm?: boolean;
57
+ /** Stop the runtime gracefully on SIGHUP. */
42
58
  readonly handleSighup?: boolean;
59
+ /** Mark the runtime failed and stop it on uncaughtException. */
43
60
  readonly handleUncaughtException?: boolean;
61
+ /** Mark the runtime failed and stop it on unhandledRejection. */
44
62
  readonly handleUnhandledRejection?: boolean;
63
+ /**
64
+ * When a second termination signal arrives while a graceful stop is
65
+ * already in progress, exit the process immediately with
66
+ * `forceExitCode`. Off by default: the second signal is logged and
67
+ * ignored.
68
+ */
69
+ readonly forceExitOnSecondSignal?: boolean;
70
+ /** Exit code used by `forceExitOnSecondSignal`. Defaults to 1. */
71
+ readonly forceExitCode?: number;
45
72
  }
46
73
  /**
47
74
  * Options controlling runtime diagnostics.
48
75
  */
49
76
  export interface RuntimeDiagnosticsOptions {
77
+ /** Emit info-level logs for bootstrap start/completion. */
50
78
  readonly startupLogging?: boolean;
79
+ /** Emit info-level logs for shutdown start/completion. */
51
80
  readonly shutdownLogging?: boolean;
81
+ /** Include the pipeline phase in bootstrap/shutdown logs. */
52
82
  readonly includeState?: boolean;
83
+ /** Include loaded module ids in bootstrap/shutdown logs. */
53
84
  readonly includeModules?: boolean;
54
85
  }
55
86
  /**
56
- * Dependencies that can be supplied to the runtime.
87
+ * Overrides for runtime environment detection. Useful for tests and
88
+ * for hosts that already know their environment.
57
89
  */
58
- export interface RuntimeInfrastructure {
59
- readonly application: ApplicationContext;
60
- readonly configuration: ConfigurationManager;
61
- readonly logger: Logger;
62
- readonly moduleRegistry: ModuleRegistry;
63
- readonly moduleLoader: ModuleLoader;
64
- readonly moduleLifecycle: ModuleLifecycleManager;
90
+ export interface RuntimeEnvironmentOverrides {
91
+ readonly variables?: RuntimeEnvironmentVariables;
92
+ readonly isCI?: boolean;
93
+ readonly isContainer?: boolean;
65
94
  }
66
95
  /**
67
96
  * Complete runtime options.
@@ -74,7 +103,7 @@ export interface RuntimeOptions {
74
103
  readonly shutdown?: RuntimeShutdownOptions;
75
104
  readonly signals?: RuntimeSignalOptions;
76
105
  readonly diagnostics?: RuntimeDiagnosticsOptions;
77
- readonly infrastructure?: Partial<RuntimeInfrastructure>;
106
+ readonly environment?: RuntimeEnvironmentOverrides;
78
107
  readonly metadata?: Readonly<Record<string, unknown>>;
79
108
  }
80
109
  /**
@@ -88,7 +117,7 @@ export interface ResolvedRuntimeOptions {
88
117
  readonly shutdown: Required<RuntimeShutdownOptions>;
89
118
  readonly signals: Required<RuntimeSignalOptions>;
90
119
  readonly diagnostics: Required<RuntimeDiagnosticsOptions>;
91
- readonly infrastructure: Partial<RuntimeInfrastructure>;
120
+ readonly environment: RuntimeEnvironmentOverrides;
92
121
  readonly metadata: Readonly<Record<string, unknown>>;
93
122
  }
94
123
  //# sourceMappingURL=runtimeOptions.type.d.ts.map
@@ -1,4 +1,3 @@
1
- import { DEFAULT_RUNTIME_OPTIONS } from "./runtimeOptions.defaults.js";
2
1
  /**
3
2
  * Validates a runtime mode.
4
3
  */
@@ -4,7 +4,8 @@
4
4
  * Handles the shutdown pipeline for stopping and
5
5
  * destroying runtime modules.
6
6
  */
7
- export { DefaultRuntimeShutdown, RuntimeShutdownError, withShutdownTimeout, createShutdownResult, } from "./runtimeShutdown.core.js";
8
- export { executeShutdownPipeline } from "./pipeline/index.js";
7
+ export { DefaultRuntimeShutdown } from "./runtimeShutdown.core.js";
8
+ export { executeShutdownPipeline, createShutdownPipelineState, createShutdownResult, } from "./pipeline/index.js";
9
+ export type { ShutdownCounters, ShutdownPipelineState, } from "./pipeline/index.js";
9
10
  export type { RuntimeShutdownDependencies, RuntimeShutdownConfig, RuntimeShutdownPhase, RuntimeShutdownErrorInfo, RuntimeShutdownResult, RuntimeShutdown, ResolvedShutdownOptions, } from "./runtimeShutdown.type.js";
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -4,6 +4,6 @@
4
4
  * Handles the shutdown pipeline for stopping and
5
5
  * destroying runtime modules.
6
6
  */
7
- export { DefaultRuntimeShutdown, RuntimeShutdownError, withShutdownTimeout, createShutdownResult, } from "./runtimeShutdown.core.js";
8
- export { executeShutdownPipeline } from "./pipeline/index.js";
7
+ export { DefaultRuntimeShutdown } from "./runtimeShutdown.core.js";
8
+ export { executeShutdownPipeline, createShutdownPipelineState, createShutdownResult, } from "./pipeline/index.js";
9
9
  //# sourceMappingURL=index.js.map
@@ -3,5 +3,6 @@
3
3
  *
4
4
  * Module stopping and destruction stages.
5
5
  */
6
- export { executeShutdownPipeline } from "./runtimeShutdown.pipeline.js";
6
+ export { executeShutdownPipeline, createShutdownPipelineState, createShutdownResult, } from "./runtimeShutdown.pipeline.js";
7
+ export type { ShutdownCounters, ShutdownLogFn, ShutdownPipelineServices, ShutdownPipelineState, } from "./runtimeShutdown.pipeline.js";
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -3,5 +3,5 @@
3
3
  *
4
4
  * Module stopping and destruction stages.
5
5
  */
6
- export { executeShutdownPipeline } from "./runtimeShutdown.pipeline.js";
6
+ export { executeShutdownPipeline, createShutdownPipelineState, createShutdownResult, } from "./runtimeShutdown.pipeline.js";
7
7
  //# sourceMappingURL=index.js.map
@@ -1,9 +1,39 @@
1
1
  import type { ModuleLifecycleManager } from "../../../modules/moduleLifecycle/index.js";
2
- import type { RuntimeShutdownPhase, RuntimeShutdownErrorInfo, ResolvedShutdownOptions } from "../runtimeShutdown.type.js";
3
- type LogFn = (level: "debug" | "info" | "warn" | "error", message: string, metadata?: Record<string, unknown>) => void;
4
- export declare function executeShutdownPipeline(options: ResolvedShutdownOptions, errors: RuntimeShutdownErrorInfo[], counters: {
5
- incrementStopped(): void;
6
- incrementDestroyed(): void;
7
- }, moduleLifecycle: ModuleLifecycleManager, setPhase: (phase: RuntimeShutdownPhase) => void, log: LogFn): Promise<void>;
8
- export {};
2
+ import type { RuntimeShutdownPhase, RuntimeShutdownErrorInfo, RuntimeShutdownResult, ResolvedShutdownOptions } from "../runtimeShutdown.type.js";
3
+ export type ShutdownLogFn = (level: "debug" | "info" | "warn" | "error", message: string, metadata?: Record<string, unknown>) => void;
4
+ /**
5
+ * Module counts produced by the shutdown pipeline.
6
+ */
7
+ export interface ShutdownCounters {
8
+ stoppedModules: number;
9
+ destroyedModules: number;
10
+ }
11
+ /**
12
+ * Mutable pipeline state shared with the caller so that counts and
13
+ * recorded errors survive a thrown failure.
14
+ */
15
+ export interface ShutdownPipelineState {
16
+ readonly counters: ShutdownCounters;
17
+ readonly errors: RuntimeShutdownErrorInfo[];
18
+ }
19
+ export declare function createShutdownPipelineState(): ShutdownPipelineState;
20
+ /**
21
+ * Executes the stop → destroy pipeline.
22
+ *
23
+ * Mirrors the bootstrap pipeline contract: module-level failures are
24
+ * recorded once per module; a phase whose continueOn*Error flag is
25
+ * false throws (and the caller records that error once); aborted
26
+ * runs stop publishing phase changes.
27
+ */
28
+ /**
29
+ * Services the shutdown pipeline drives.
30
+ */
31
+ export interface ShutdownPipelineServices {
32
+ readonly moduleLifecycle: ModuleLifecycleManager;
33
+ /** Identity attached to every error the pipeline raises. */
34
+ readonly runtimeId?: string;
35
+ readonly runtimeName?: string;
36
+ }
37
+ export declare function executeShutdownPipeline(options: ResolvedShutdownOptions, services: ShutdownPipelineServices, state: ShutdownPipelineState, signal: AbortSignal, setPhase: (phase: RuntimeShutdownPhase) => void, log: ShutdownLogFn): Promise<void>;
38
+ export declare function createShutdownResult(success: boolean, phase: RuntimeShutdownPhase, counters: ShutdownCounters, errors: readonly RuntimeShutdownErrorInfo[], startedAt: Date, completedAt: Date): RuntimeShutdownResult;
9
39
  //# sourceMappingURL=runtimeShutdown.pipeline.d.ts.map
@@ -1,67 +1,101 @@
1
- import { RuntimeShutdownError } from "../runtimeShutdown.core.js";
2
- async function stopModules(errors, counters, continueOnError, moduleLifecycle, setPhase, log) {
3
- setPhase("stopping");
4
- log("debug", "Stopping runtime modules.");
5
- try {
6
- await invokeStopModules(moduleLifecycle);
7
- setPhase("stopped");
8
- counters.incrementStopped();
9
- log("debug", "Runtime modules stopped.");
1
+ import { RuntimeStopError } from "../../runtimeError/runtimeError.lifecycle.js";
2
+ import { RuntimeErrorCode } from "../../runtimeError/runtimeError.type.js";
3
+ export function createShutdownPipelineState() {
4
+ return {
5
+ counters: { stoppedModules: 0, destroyedModules: 0 },
6
+ errors: [],
7
+ };
8
+ }
9
+ export async function executeShutdownPipeline(options, services, state, signal, setPhase, log) {
10
+ const publish = (phase) => {
11
+ if (!signal.aborted)
12
+ setPhase(phase);
13
+ };
14
+ const { moduleLifecycle } = services;
15
+ const identity = {
16
+ runtimeId: services.runtimeId,
17
+ runtimeName: services.runtimeName,
18
+ };
19
+ if (options.stopModules) {
20
+ await runShutdownPhase("stopping", "stopped", () => moduleLifecycle.stop(phaseOptions(options.continueOnStopError)), moduleLifecycle, options.continueOnStopError, (count) => {
21
+ state.counters.stoppedModules = count;
22
+ }, RuntimeErrorCode.MODULE_STOP_FAILED, identity, state, publish, log);
10
23
  }
11
- catch (error) {
12
- errors.push({ phase: "stopping", error });
13
- if (!continueOnError) {
14
- throw new RuntimeShutdownError("Failed to stop runtime modules.", "MODULE_STOP_FAILED", error);
15
- }
16
- log("warn", "Runtime module shutdown reported an error. Continuing.", {
17
- error,
18
- });
24
+ if (options.destroyModules) {
25
+ await runShutdownPhase("destroying", "destroyed", () => moduleLifecycle.destroy(phaseOptions(options.continueOnDestroyError)), moduleLifecycle, options.continueOnDestroyError, (count) => {
26
+ state.counters.destroyedModules = count;
27
+ }, RuntimeErrorCode.MODULE_DESTROY_FAILED, identity, state, publish, log);
19
28
  }
20
29
  }
21
- async function destroyModules(errors, counters, continueOnError, moduleLifecycle, setPhase, log) {
22
- setPhase("destroying");
23
- log("debug", "Destroying runtime modules.");
30
+ /**
31
+ * Per-phase options for the ModuleLifecycleManager: the runtime flag
32
+ * relaxes the manager when on and leaves its own setting when off
33
+ * (see the bootstrap pipeline for the rationale).
34
+ */
35
+ function phaseOptions(continueOnError) {
36
+ return continueOnError ? { continueOnError: true } : {};
37
+ }
38
+ async function runShutdownPhase(phase, donePhase, run, moduleLifecycle, continueOnError, setCount, code, identity, state, publish, log) {
39
+ publish(phase);
40
+ log("debug", `Runtime modules ${phase}.`);
41
+ let result;
24
42
  try {
25
- await invokeDestroyModules(moduleLifecycle);
26
- setPhase("destroyed");
27
- counters.incrementDestroyed();
28
- log("debug", "Runtime modules destroyed.");
43
+ result = await run();
29
44
  }
30
45
  catch (error) {
31
- errors.push({ phase: "destroying", error });
32
46
  if (!continueOnError) {
33
- throw new RuntimeShutdownError("Failed to destroy runtime modules.", "MODULE_DESTROY_FAILED", error);
47
+ throw new RuntimeStopError(`Runtime module ${phase} failed.`, {
48
+ ...identity,
49
+ code,
50
+ phase,
51
+ cause: error,
52
+ });
34
53
  }
35
- log("warn", "Runtime module destruction reported an error. Continuing.", {
54
+ state.errors.push({ phase, error });
55
+ log("warn", `Runtime module ${phase} reported an error. Continuing.`, {
36
56
  error,
37
57
  });
38
- }
39
- }
40
- async function invokeStopModules(moduleLifecycle) {
41
- if (typeof moduleLifecycle.stop === "function") {
42
- await moduleLifecycle.stop();
43
58
  return;
44
59
  }
45
- throw new RuntimeShutdownError("ModuleLifecycleManager does not expose a supported stop method.", "MODULE_STOP_METHOD_NOT_FOUND");
46
- }
47
- async function invokeDestroyModules(moduleLifecycle) {
48
- if (typeof moduleLifecycle.destroy === "function") {
49
- await moduleLifecycle.destroy();
50
- return;
51
- }
52
- throw new RuntimeShutdownError("ModuleLifecycleManager does not expose a supported destroy method.", "MODULE_DESTROY_METHOD_NOT_FOUND");
53
- }
54
- export async function executeShutdownPipeline(options, errors, counters, moduleLifecycle, setPhase, log) {
55
- if (options.stopModules) {
56
- await stopModules(errors, counters, options.continueOnStopError, moduleLifecycle, setPhase, log);
57
- }
58
- if (options.destroyModules) {
59
- await destroyModules(errors, counters, options.continueOnDestroyError, moduleLifecycle, setPhase, log);
60
+ setCount(result.completed.length);
61
+ for (const moduleId of result.failed) {
62
+ state.errors.push({
63
+ phase,
64
+ moduleName: moduleId,
65
+ error: moduleLifecycle.getState(moduleId)?.error ??
66
+ new Error(`Module "${moduleId}" failed during ${phase}.`),
67
+ });
60
68
  }
61
- if (errors.length > 0 &&
62
- !options.continueOnStopError &&
63
- !options.continueOnDestroyError) {
64
- throw new RuntimeShutdownError("Runtime shutdown completed with module errors.", "SHUTDOWN_MODULE_ERRORS", errors);
69
+ if (result.failed.length > 0) {
70
+ if (!continueOnError) {
71
+ throw new RuntimeStopError(`${result.failed.length} module(s) failed during ${phase}: ${result.failed.join(", ")}.`, {
72
+ ...identity,
73
+ code,
74
+ phase,
75
+ metadata: { modules: result.failed.join(",") },
76
+ });
77
+ }
78
+ log("warn", `Runtime module ${phase} completed with failures. Continuing.`, {
79
+ failed: [...result.failed],
80
+ });
65
81
  }
82
+ publish(donePhase);
83
+ log("debug", `Runtime modules ${donePhase}.`, {
84
+ completed: result.completed.length,
85
+ failed: result.failed.length,
86
+ skipped: result.skipped.length,
87
+ });
88
+ }
89
+ export function createShutdownResult(success, phase, counters, errors, startedAt, completedAt) {
90
+ return Object.freeze({
91
+ success,
92
+ phase,
93
+ stoppedModules: counters.stoppedModules,
94
+ destroyedModules: counters.destroyedModules,
95
+ errors: Object.freeze([...errors]),
96
+ startedAt,
97
+ completedAt,
98
+ durationMs: completedAt.getTime() - startedAt.getTime(),
99
+ });
66
100
  }
67
101
  //# sourceMappingURL=runtimeShutdown.pipeline.js.map
@@ -1,19 +1,12 @@
1
1
  import type { ResolvedRuntimeOptions } from "../runtimeOptions/index.js";
2
- import type { RuntimeShutdownDependencies, RuntimeShutdownConfig, RuntimeShutdownPhase, RuntimeShutdownResult, RuntimeShutdown, RuntimeShutdownErrorInfo } from "./runtimeShutdown.type.js";
3
- import { Context } from "../../context/core/context.js";
4
- import { RuntimeError } from "@zudojs/errors";
5
- export type RuntimeShutdownErrorCode = "SHUTDOWN_ALREADY_RUNNING" | "SHUTDOWN_ALREADY_COMPLETED" | "SHUTDOWN_FAILED" | "SHUTDOWN_TIMEOUT" | "SHUTDOWN_MODULE_ERRORS" | "SHUTDOWN_RESET_WHILE_RUNNING" | "MODULE_STOP_FAILED" | "MODULE_DESTROY_FAILED" | "MODULE_STOP_METHOD_NOT_FOUND" | "MODULE_DESTROY_METHOD_NOT_FOUND";
6
- export declare class RuntimeShutdownError extends RuntimeError {
7
- readonly name = "RuntimeShutdownError";
8
- readonly shutdownCode: RuntimeShutdownErrorCode;
9
- constructor(message: string, code: RuntimeShutdownErrorCode, cause?: unknown);
10
- }
11
- export declare function withShutdownTimeout(operation: Promise<void>, timeoutMs: number): Promise<void>;
12
- export declare function createShutdownResult(success: boolean, phase: RuntimeShutdownPhase, stoppedModules: number, destroyedModules: number, errors: readonly RuntimeShutdownErrorInfo[], startedAt: Date, completedAt: Date): RuntimeShutdownResult;
2
+ import type { RuntimeShutdownDependencies, RuntimeShutdownConfig, RuntimeShutdownPhase, RuntimeShutdownResult, RuntimeShutdown } from "./runtimeShutdown.type.js";
3
+ /**
4
+ * Default shutdown service: stops and destroys modules according to
5
+ * the runtime's shutdown options.
6
+ */
13
7
  export declare class DefaultRuntimeShutdown implements RuntimeShutdown {
14
- private readonly _context;
8
+ private readonly _identity;
15
9
  private readonly _environment;
16
- private readonly _application;
17
10
  private readonly _moduleRegistry;
18
11
  private readonly _moduleLifecycle;
19
12
  private readonly _logger;
@@ -21,15 +14,14 @@ export declare class DefaultRuntimeShutdown implements RuntimeShutdown {
21
14
  private _running;
22
15
  private _phase;
23
16
  private _lastResult;
24
- private _shutdownContext?;
25
17
  constructor(dependencies: RuntimeShutdownDependencies, runtimeOptions: ResolvedRuntimeOptions);
26
18
  get running(): boolean;
27
19
  get phase(): RuntimeShutdownPhase;
28
20
  shutdown(options?: RuntimeShutdownConfig): Promise<RuntimeShutdownResult>;
29
- private resolveOptions;
30
21
  getLastResult(): RuntimeShutdownResult | undefined;
31
- getShutdownContext(): Context | undefined;
32
22
  reset(): void;
23
+ private resolveOptions;
24
+ private errorContext;
33
25
  private log;
34
26
  }
35
27
  //# sourceMappingURL=runtimeShutdown.core.d.ts.map