@zintrust/core 0.1.39 → 0.1.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (475) hide show
  1. package/bin/zintrust-main.d.ts.map +1 -1
  2. package/bin/zintrust-main.js +22 -1
  3. package/package.json +8 -4
  4. package/public/error-pages/404.html +2 -2
  5. package/src/auth/Auth.js +1 -1
  6. package/src/boot/Application.d.ts +1 -16
  7. package/src/boot/Application.d.ts.map +1 -1
  8. package/src/boot/Application.js +2 -262
  9. package/src/boot/Server.d.ts +1 -1
  10. package/src/boot/Server.d.ts.map +1 -1
  11. package/src/boot/bootstrap.js +23 -9
  12. package/src/boot/registry/registerRoute.d.ts +6 -0
  13. package/src/boot/registry/registerRoute.d.ts.map +1 -0
  14. package/src/boot/registry/registerRoute.js +96 -0
  15. package/src/boot/registry/runtime.d.ts +15 -0
  16. package/src/boot/registry/runtime.d.ts.map +1 -0
  17. package/src/boot/registry/runtime.js +353 -0
  18. package/src/boot/registry/type.d.ts +25 -0
  19. package/src/boot/registry/type.d.ts.map +1 -0
  20. package/src/boot/registry/type.js +1 -0
  21. package/src/boot/registry/worker.d.ts +6 -0
  22. package/src/boot/registry/worker.d.ts.map +1 -0
  23. package/src/boot/registry/worker.js +35 -0
  24. package/src/cache/drivers/KVRemoteDriver.d.ts.map +1 -1
  25. package/src/cache/drivers/KVRemoteDriver.js +14 -1
  26. package/src/cli/CLI.d.ts.map +1 -1
  27. package/src/cli/CLI.js +82 -34
  28. package/src/cli/ErrorHandler.js +1 -1
  29. package/src/cli/commands/ContainerProxiesCommand.d.ts +5 -0
  30. package/src/cli/commands/ContainerProxiesCommand.d.ts.map +1 -0
  31. package/src/cli/commands/ContainerProxiesCommand.js +77 -0
  32. package/src/cli/commands/ContainerWorkersCommand.d.ts +5 -0
  33. package/src/cli/commands/ContainerWorkersCommand.d.ts.map +1 -0
  34. package/src/cli/commands/ContainerWorkersCommand.js +57 -0
  35. package/src/cli/commands/DeployCommand.d.ts +16 -0
  36. package/src/cli/commands/DeployCommand.d.ts.map +1 -0
  37. package/src/cli/commands/DeployCommand.js +110 -0
  38. package/src/cli/commands/DeployContainerProxiesCommand.d.ts +5 -0
  39. package/src/cli/commands/DeployContainerProxiesCommand.d.ts.map +1 -0
  40. package/src/cli/commands/DeployContainerProxiesCommand.js +27 -0
  41. package/src/cli/commands/DeployContainerWorkersCommand.d.ts +5 -0
  42. package/src/cli/commands/DeployContainerWorkersCommand.d.ts.map +1 -0
  43. package/src/cli/commands/DeployContainerWorkersCommand.js +27 -0
  44. package/src/cli/commands/DockerComposeCommandUtils.d.ts +3 -0
  45. package/src/cli/commands/DockerComposeCommandUtils.d.ts.map +1 -0
  46. package/src/cli/commands/DockerComposeCommandUtils.js +34 -0
  47. package/src/cli/commands/DoctorArchitectureCommand.d.ts +5 -0
  48. package/src/cli/commands/DoctorArchitectureCommand.d.ts.map +1 -0
  49. package/src/cli/commands/DoctorArchitectureCommand.js +54 -0
  50. package/src/cli/commands/InitContainerCommand.d.ts +5 -0
  51. package/src/cli/commands/InitContainerCommand.d.ts.map +1 -0
  52. package/src/cli/commands/InitContainerCommand.js +216 -0
  53. package/src/cli/commands/InitProducerCommand.d.ts +5 -0
  54. package/src/cli/commands/InitProducerCommand.d.ts.map +1 -0
  55. package/src/cli/commands/InitProducerCommand.js +47 -0
  56. package/src/cli/commands/InitProxyCommand.d.ts +5 -0
  57. package/src/cli/commands/InitProxyCommand.d.ts.map +1 -0
  58. package/src/cli/commands/InitProxyCommand.js +442 -0
  59. package/src/cli/commands/MongoDBProxyCommand.d.ts +5 -0
  60. package/src/cli/commands/MongoDBProxyCommand.d.ts.map +1 -0
  61. package/src/cli/commands/MongoDBProxyCommand.js +98 -0
  62. package/src/cli/commands/MySqlProxyCommand.d.ts +6 -0
  63. package/src/cli/commands/MySqlProxyCommand.d.ts.map +1 -0
  64. package/src/cli/commands/MySqlProxyCommand.js +32 -0
  65. package/src/cli/commands/PostgresProxyCommand.d.ts +6 -0
  66. package/src/cli/commands/PostgresProxyCommand.d.ts.map +1 -0
  67. package/src/cli/commands/PostgresProxyCommand.js +32 -0
  68. package/src/cli/commands/ProxyCommand.d.ts +12 -0
  69. package/src/cli/commands/ProxyCommand.d.ts.map +1 -0
  70. package/src/cli/commands/ProxyCommand.js +80 -0
  71. package/src/cli/commands/ProxyCommandUtils.d.ts +6 -0
  72. package/src/cli/commands/ProxyCommandUtils.d.ts.map +1 -0
  73. package/src/cli/commands/ProxyCommandUtils.js +38 -0
  74. package/src/cli/commands/QueueRecoveryCommand.d.ts +6 -0
  75. package/src/cli/commands/QueueRecoveryCommand.d.ts.map +1 -0
  76. package/src/cli/commands/QueueRecoveryCommand.js +513 -0
  77. package/src/cli/commands/RedisProxyCommand.d.ts +6 -0
  78. package/src/cli/commands/RedisProxyCommand.d.ts.map +1 -0
  79. package/src/cli/commands/RedisProxyCommand.js +53 -0
  80. package/src/cli/commands/SmtpProxyCommand.d.ts +6 -0
  81. package/src/cli/commands/SmtpProxyCommand.d.ts.map +1 -0
  82. package/src/cli/commands/SmtpProxyCommand.js +56 -0
  83. package/src/cli/commands/SqlProxyCommandUtils.d.ts +46 -0
  84. package/src/cli/commands/SqlProxyCommandUtils.d.ts.map +1 -0
  85. package/src/cli/commands/SqlProxyCommandUtils.js +48 -0
  86. package/src/cli/commands/SqlServerProxyCommand.d.ts +5 -0
  87. package/src/cli/commands/SqlServerProxyCommand.d.ts.map +1 -0
  88. package/src/cli/commands/SqlServerProxyCommand.js +85 -0
  89. package/src/cli/commands/StartCommand.d.ts.map +1 -1
  90. package/src/cli/commands/StartCommand.js +145 -18
  91. package/src/cli/commands/WorkerCommands.d.ts +1 -0
  92. package/src/cli/commands/WorkerCommands.d.ts.map +1 -1
  93. package/src/cli/commands/WorkerCommands.js +140 -6
  94. package/src/cli/commands/index.d.ts +2 -0
  95. package/src/cli/commands/index.d.ts.map +1 -1
  96. package/src/cli/commands/index.js +2 -0
  97. package/src/cli/commands/runner/index.d.ts +2 -2
  98. package/src/cli/commands/runner/index.d.ts.map +1 -1
  99. package/src/cli/commands/runner/index.js +15 -4
  100. package/src/cli/d1/D1SqlMigrations.d.ts.map +1 -1
  101. package/src/cli/d1/D1SqlMigrations.js +3 -0
  102. package/src/cli/index.d.ts +4 -0
  103. package/src/cli/index.d.ts.map +1 -1
  104. package/src/cli/index.js +4 -0
  105. package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
  106. package/src/cli/scaffolding/ProjectScaffolder.js +2 -0
  107. package/src/cli/scaffolding/ServiceScaffolder.d.ts.map +1 -1
  108. package/src/cli/scaffolding/ServiceScaffolder.js +1 -0
  109. package/src/cli/utils/EnvFileLoader.d.ts +2 -1
  110. package/src/cli/utils/EnvFileLoader.d.ts.map +1 -1
  111. package/src/cli/utils/EnvFileLoader.js +22 -21
  112. package/src/cli/utils/spawn.d.ts.map +1 -1
  113. package/src/cli/utils/spawn.js +17 -10
  114. package/src/cli/workers/QueueWorkRunner.js +1 -1
  115. package/src/common/ExternalServiceUtils.d.ts.map +1 -1
  116. package/src/common/ExternalServiceUtils.js +7 -2
  117. package/src/common/HealthRoutes.d.ts.map +1 -1
  118. package/src/common/HealthRoutes.js +50 -2
  119. package/src/common/RemoteSignedJson.d.ts +1 -0
  120. package/src/common/RemoteSignedJson.d.ts.map +1 -1
  121. package/src/common/RemoteSignedJson.js +39 -13
  122. package/src/common/index.d.ts +1 -0
  123. package/src/common/index.d.ts.map +1 -1
  124. package/src/common/index.js +12 -1
  125. package/src/config/FileLogWriter.d.ts.map +1 -1
  126. package/src/config/FileLogWriter.js +21 -6
  127. package/src/config/app.d.ts +4 -0
  128. package/src/config/app.d.ts.map +1 -1
  129. package/src/config/app.js +4 -0
  130. package/src/config/cache.d.ts.map +1 -1
  131. package/src/config/cache.js +22 -2
  132. package/src/config/cloudflare.d.ts +5 -1
  133. package/src/config/cloudflare.d.ts.map +1 -1
  134. package/src/config/cloudflare.js +48 -0
  135. package/src/config/database.d.ts.map +1 -1
  136. package/src/config/database.js +48 -13
  137. package/src/config/env.d.ts +90 -2
  138. package/src/config/env.d.ts.map +1 -1
  139. package/src/config/env.js +160 -18
  140. package/src/config/index.d.ts +1 -0
  141. package/src/config/index.d.ts.map +1 -1
  142. package/src/config/logger.d.ts.map +1 -1
  143. package/src/config/logger.js +60 -16
  144. package/src/config/mail.d.ts.map +1 -1
  145. package/src/config/mail.js +16 -10
  146. package/src/config/middleware.d.ts +5 -0
  147. package/src/config/middleware.d.ts.map +1 -1
  148. package/src/config/middleware.js +19 -1
  149. package/src/config/queue.d.ts.map +1 -1
  150. package/src/config/queue.js +70 -9
  151. package/src/config/redis.d.ts.map +1 -1
  152. package/src/config/redis.js +48 -13
  153. package/src/config/storage.d.ts.map +1 -1
  154. package/src/config/storage.js +1 -0
  155. package/src/config/type.d.ts +19 -0
  156. package/src/config/type.d.ts.map +1 -1
  157. package/src/config/workers.d.ts.map +1 -1
  158. package/src/config/workers.js +122 -16
  159. package/src/functions/cloudflare.d.ts.map +1 -1
  160. package/src/functions/cloudflare.js +55 -1
  161. package/src/health/StartupHealthChecks.js +1 -1
  162. package/src/http/FileUpload.d.ts +3 -2
  163. package/src/http/FileUpload.d.ts.map +1 -1
  164. package/src/http/Kernel.d.ts.map +1 -1
  165. package/src/http/Kernel.js +2 -1
  166. package/src/http/error-pages/ErrorPageRenderer.d.ts +4 -0
  167. package/src/http/error-pages/ErrorPageRenderer.d.ts.map +1 -1
  168. package/src/http/error-pages/ErrorPageRenderer.js +141 -1
  169. package/src/http/middleware/BodyParsingMiddleware.d.ts.map +1 -1
  170. package/src/http/middleware/BodyParsingMiddleware.js +33 -6
  171. package/src/index.d.ts +25 -53
  172. package/src/index.d.ts.map +1 -1
  173. package/src/index.js +30 -14
  174. package/src/microservices/ServiceAuthMiddleware.d.ts.map +1 -1
  175. package/src/microservices/ServiceAuthMiddleware.js +12 -4
  176. package/src/middleware/CsrfMiddleware.d.ts.map +1 -1
  177. package/src/middleware/CsrfMiddleware.js +39 -10
  178. package/src/middleware/ErrorHandlerMiddleware.d.ts.map +1 -1
  179. package/src/middleware/ErrorHandlerMiddleware.js +2 -1
  180. package/src/migrations/MigrationLoader.js +1 -1
  181. package/src/migrations/schema/SchemaCompiler.d.ts.map +1 -1
  182. package/src/migrations/schema/SchemaCompiler.js +6 -3
  183. package/src/node-singletons/crypto.d.ts +1 -1
  184. package/src/node-singletons/crypto.d.ts.map +1 -1
  185. package/src/node-singletons/crypto.js +1 -1
  186. package/src/node-singletons/fs.d.ts +1 -1
  187. package/src/node-singletons/fs.d.ts.map +1 -1
  188. package/src/node-singletons/path.d.ts +1 -1
  189. package/src/node-singletons/path.d.ts.map +1 -1
  190. package/src/node-singletons/path.js +1 -1
  191. package/src/node-singletons/stream.d.ts +11 -0
  192. package/src/node-singletons/stream.d.ts.map +1 -0
  193. package/src/node-singletons/stream.js +8 -0
  194. package/src/observability/OpenTelemetry.d.ts +7 -0
  195. package/src/observability/OpenTelemetry.d.ts.map +1 -1
  196. package/src/observability/OpenTelemetry.js +49 -2
  197. package/src/orm/Database.d.ts +4 -0
  198. package/src/orm/Database.d.ts.map +1 -1
  199. package/src/orm/Database.js +80 -9
  200. package/src/orm/DatabaseRuntimeRegistration.d.ts.map +1 -1
  201. package/src/orm/DatabaseRuntimeRegistration.js +2 -0
  202. package/src/orm/QueryBuilder.d.ts +1 -0
  203. package/src/orm/QueryBuilder.d.ts.map +1 -1
  204. package/src/orm/QueryBuilder.js +33 -3
  205. package/src/orm/SchemaCompiler.d.ts.map +1 -1
  206. package/src/orm/SchemaCompiler.js +6 -3
  207. package/src/orm/adapters/D1RemoteAdapter.d.ts.map +1 -1
  208. package/src/orm/adapters/D1RemoteAdapter.js +14 -1
  209. package/src/orm/adapters/MongoDBProxyAdapter.d.ts +3 -0
  210. package/src/orm/adapters/MongoDBProxyAdapter.d.ts.map +1 -0
  211. package/src/orm/adapters/MongoDBProxyAdapter.js +128 -0
  212. package/src/orm/adapters/MySQLProxyAdapter.d.ts +11 -0
  213. package/src/orm/adapters/MySQLProxyAdapter.d.ts.map +1 -0
  214. package/src/orm/adapters/MySQLProxyAdapter.js +143 -0
  215. package/src/orm/adapters/PostgreSQLProxyAdapter.d.ts +11 -0
  216. package/src/orm/adapters/PostgreSQLProxyAdapter.d.ts.map +1 -0
  217. package/src/orm/adapters/PostgreSQLProxyAdapter.js +147 -0
  218. package/src/orm/adapters/ProxyCache.d.ts +9 -0
  219. package/src/orm/adapters/ProxyCache.d.ts.map +1 -0
  220. package/src/orm/adapters/ProxyCache.js +24 -0
  221. package/src/orm/adapters/ProxySignedRequest.d.ts +11 -0
  222. package/src/orm/adapters/ProxySignedRequest.d.ts.map +1 -0
  223. package/src/orm/adapters/ProxySignedRequest.js +30 -0
  224. package/src/orm/adapters/ProxySigningPath.d.ts +3 -0
  225. package/src/orm/adapters/ProxySigningPath.d.ts.map +1 -0
  226. package/src/orm/adapters/ProxySigningPath.js +25 -0
  227. package/src/orm/adapters/SqlProxyAdapterUtils.d.ts +19 -0
  228. package/src/orm/adapters/SqlProxyAdapterUtils.d.ts.map +1 -0
  229. package/src/orm/adapters/SqlProxyAdapterUtils.js +35 -0
  230. package/src/orm/adapters/SqlServerProxyAdapter.d.ts +3 -0
  231. package/src/orm/adapters/SqlServerProxyAdapter.d.ts.map +1 -0
  232. package/src/orm/adapters/SqlServerProxyAdapter.js +146 -0
  233. package/src/performance/Optimizer.d.ts +1 -0
  234. package/src/performance/Optimizer.d.ts.map +1 -1
  235. package/src/performance/Optimizer.js +21 -8
  236. package/src/proxy/ErrorHandler.d.ts +11 -0
  237. package/src/proxy/ErrorHandler.d.ts.map +1 -0
  238. package/src/proxy/ErrorHandler.js +7 -0
  239. package/src/proxy/PoolManager.d.ts +8 -0
  240. package/src/proxy/PoolManager.d.ts.map +1 -0
  241. package/src/proxy/PoolManager.js +18 -0
  242. package/src/proxy/ProxyBackend.d.ts +18 -0
  243. package/src/proxy/ProxyBackend.d.ts.map +1 -0
  244. package/src/proxy/ProxyBackend.js +1 -0
  245. package/src/proxy/ProxyConfig.d.ts +12 -0
  246. package/src/proxy/ProxyConfig.d.ts.map +1 -0
  247. package/src/proxy/ProxyConfig.js +1 -0
  248. package/src/proxy/ProxyRegistry.d.ts +10 -0
  249. package/src/proxy/ProxyRegistry.d.ts.map +1 -0
  250. package/src/proxy/ProxyRegistry.js +11 -0
  251. package/src/proxy/ProxyServer.d.ts +21 -0
  252. package/src/proxy/ProxyServer.d.ts.map +1 -0
  253. package/src/proxy/ProxyServer.js +84 -0
  254. package/src/proxy/ProxyServerUtils.d.ts +37 -0
  255. package/src/proxy/ProxyServerUtils.d.ts.map +1 -0
  256. package/src/proxy/ProxyServerUtils.js +42 -0
  257. package/src/proxy/ProxySigningConfigResolver.d.ts +22 -0
  258. package/src/proxy/ProxySigningConfigResolver.d.ts.map +1 -0
  259. package/src/proxy/ProxySigningConfigResolver.js +24 -0
  260. package/src/proxy/ProxySigningRequest.d.ts +12 -0
  261. package/src/proxy/ProxySigningRequest.d.ts.map +1 -0
  262. package/src/proxy/ProxySigningRequest.js +31 -0
  263. package/src/proxy/RequestValidator.d.ts +15 -0
  264. package/src/proxy/RequestValidator.d.ts.map +1 -0
  265. package/src/proxy/RequestValidator.js +25 -0
  266. package/src/proxy/SigningService.d.ts +39 -0
  267. package/src/proxy/SigningService.d.ts.map +1 -0
  268. package/src/proxy/SigningService.js +107 -0
  269. package/src/proxy/SqlPayloadValidator.d.ts +13 -0
  270. package/src/proxy/SqlPayloadValidator.d.ts.map +1 -0
  271. package/src/proxy/SqlPayloadValidator.js +14 -0
  272. package/src/proxy/d1/ZintrustD1Proxy.d.ts +2 -0
  273. package/src/proxy/d1/ZintrustD1Proxy.d.ts.map +1 -0
  274. package/src/proxy/d1/ZintrustD1Proxy.js +1 -0
  275. package/src/proxy/d1/register.d.ts +2 -0
  276. package/src/proxy/d1/register.d.ts.map +1 -0
  277. package/src/proxy/d1/register.js +5 -0
  278. package/src/proxy/kv/ZintrustKvProxy.d.ts +2 -0
  279. package/src/proxy/kv/ZintrustKvProxy.d.ts.map +1 -0
  280. package/src/proxy/kv/ZintrustKvProxy.js +1 -0
  281. package/src/proxy/kv/register.d.ts +2 -0
  282. package/src/proxy/kv/register.d.ts.map +1 -0
  283. package/src/proxy/kv/register.js +5 -0
  284. package/src/proxy/mongodb/MongoDBProxyServer.d.ts +33 -0
  285. package/src/proxy/mongodb/MongoDBProxyServer.d.ts.map +1 -0
  286. package/src/proxy/mongodb/MongoDBProxyServer.js +202 -0
  287. package/src/proxy/mongodb/register.d.ts +2 -0
  288. package/src/proxy/mongodb/register.d.ts.map +1 -0
  289. package/src/proxy/mongodb/register.js +5 -0
  290. package/src/proxy/mysql/MySqlProxyServer.d.ts +14 -0
  291. package/src/proxy/mysql/MySqlProxyServer.d.ts.map +1 -0
  292. package/src/proxy/mysql/MySqlProxyServer.js +169 -0
  293. package/src/proxy/mysql/register.d.ts +2 -0
  294. package/src/proxy/mysql/register.d.ts.map +1 -0
  295. package/src/proxy/mysql/register.js +5 -0
  296. package/src/proxy/postgres/PostgresProxyServer.d.ts +14 -0
  297. package/src/proxy/postgres/PostgresProxyServer.d.ts.map +1 -0
  298. package/src/proxy/postgres/PostgresProxyServer.js +140 -0
  299. package/src/proxy/postgres/register.d.ts +2 -0
  300. package/src/proxy/postgres/register.d.ts.map +1 -0
  301. package/src/proxy/postgres/register.js +5 -0
  302. package/src/proxy/redis/RedisProxyServer.d.ts +12 -0
  303. package/src/proxy/redis/RedisProxyServer.d.ts.map +1 -0
  304. package/src/proxy/redis/RedisProxyServer.js +192 -0
  305. package/src/proxy/redis/register.d.ts +2 -0
  306. package/src/proxy/redis/register.d.ts.map +1 -0
  307. package/src/proxy/redis/register.js +5 -0
  308. package/src/proxy/smtp/SmtpProxyServer.d.ts +19 -0
  309. package/src/proxy/smtp/SmtpProxyServer.d.ts.map +1 -0
  310. package/src/proxy/smtp/SmtpProxyServer.js +289 -0
  311. package/src/proxy/smtp/register.d.ts +2 -0
  312. package/src/proxy/smtp/register.d.ts.map +1 -0
  313. package/src/proxy/smtp/register.js +5 -0
  314. package/src/proxy/sqlserver/SqlServerProxyServer.d.ts +14 -0
  315. package/src/proxy/sqlserver/SqlServerProxyServer.d.ts.map +1 -0
  316. package/src/proxy/sqlserver/SqlServerProxyServer.js +168 -0
  317. package/src/proxy/sqlserver/register.d.ts +2 -0
  318. package/src/proxy/sqlserver/register.d.ts.map +1 -0
  319. package/src/proxy/sqlserver/register.js +5 -0
  320. package/src/routes/doc.d.ts.map +1 -1
  321. package/src/routes/doc.js +16 -2
  322. package/src/routes/error.d.ts +5 -4
  323. package/src/routes/error.d.ts.map +1 -1
  324. package/src/routes/error.js +15 -13
  325. package/src/routes/errorPages.d.ts +2 -0
  326. package/src/routes/errorPages.d.ts.map +1 -1
  327. package/src/routes/errorPages.js +144 -4
  328. package/src/runtime/PluginAutoImports.d.ts +1 -0
  329. package/src/runtime/PluginAutoImports.d.ts.map +1 -1
  330. package/src/runtime/PluginAutoImports.js +94 -9
  331. package/src/runtime/RuntimeAdapter.d.ts +8 -9
  332. package/src/runtime/RuntimeAdapter.d.ts.map +1 -1
  333. package/src/runtime/RuntimeAdapter.js +120 -34
  334. package/src/runtime/RuntimeServices.d.ts +47 -0
  335. package/src/runtime/RuntimeServices.d.ts.map +1 -0
  336. package/src/runtime/RuntimeServices.js +164 -0
  337. package/src/runtime/StartupConfigFileRegistry.d.ts +4 -4
  338. package/src/runtime/StartupConfigFileRegistry.d.ts.map +1 -1
  339. package/src/runtime/StartupConfigFileRegistry.js +12 -0
  340. package/src/runtime/WorkerAdapterImports.d.ts +5 -0
  341. package/src/runtime/WorkerAdapterImports.d.ts.map +1 -0
  342. package/src/runtime/WorkerAdapterImports.js +17 -0
  343. package/src/runtime/WorkersModule.d.ts +6 -0
  344. package/src/runtime/WorkersModule.d.ts.map +1 -0
  345. package/src/runtime/WorkersModule.js +278 -0
  346. package/src/runtime/adapters/CloudflareAdapter.d.ts.map +1 -1
  347. package/src/runtime/adapters/CloudflareAdapter.js +19 -2
  348. package/src/runtime/adapters/DenoAdapter.js +1 -0
  349. package/src/runtime/adapters/FargateAdapter.js +1 -1
  350. package/src/runtime/adapters/LambdaAdapter.js +1 -1
  351. package/src/runtime/adapters/NodeServerAdapter.js +1 -1
  352. package/src/runtime/detectRuntime.d.ts +10 -0
  353. package/src/runtime/detectRuntime.d.ts.map +1 -0
  354. package/src/runtime/detectRuntime.js +57 -0
  355. package/src/runtime/useFileLoader.d.ts.map +1 -1
  356. package/src/runtime/useFileLoader.js +16 -0
  357. package/src/scripts/TemplateImportsCheck.js +2 -2
  358. package/src/scripts/TemplateSync.js +3 -4
  359. package/src/security/CsrfTokenManager.d.ts +18 -9
  360. package/src/security/CsrfTokenManager.d.ts.map +1 -1
  361. package/src/security/CsrfTokenManager.js +204 -11
  362. package/src/security/Hash.d.ts +1 -1
  363. package/src/security/Hash.d.ts.map +1 -1
  364. package/src/security/Hash.js +31 -36
  365. package/src/seeders/SeederLoader.js +1 -1
  366. package/src/session/SessionManager.d.ts +3 -0
  367. package/src/session/SessionManager.d.ts.map +1 -1
  368. package/src/session/SessionManager.js +49 -10
  369. package/src/sockets/CloudflareSocket.d.ts +24 -0
  370. package/src/sockets/CloudflareSocket.d.ts.map +1 -0
  371. package/src/sockets/CloudflareSocket.js +259 -0
  372. package/src/start.d.ts.map +1 -1
  373. package/src/start.js +1 -8
  374. package/src/templates/project/basic/app/Middleware/index.ts.tpl +1 -1
  375. package/src/templates/project/basic/src/zintrust.plugins.wg.ts.tpl +8 -0
  376. package/src/toolkit/Secrets/providers/AwsSecretsManager.d.ts.map +1 -1
  377. package/src/toolkit/Secrets/providers/AwsSecretsManager.js +4 -2
  378. package/src/tools/mail/drivers/Smtp.d.ts.map +1 -1
  379. package/src/tools/mail/drivers/Smtp.js +223 -18
  380. package/src/tools/mail/index.d.ts.map +1 -1
  381. package/src/tools/mail/index.js +5 -4
  382. package/src/tools/mail/template-loader.d.ts.map +1 -1
  383. package/src/tools/mail/template-loader.js +197 -29
  384. package/src/tools/mail/templates/auth-password-reset.d.ts +3 -0
  385. package/src/tools/mail/templates/auth-password-reset.d.ts.map +1 -0
  386. package/src/tools/mail/templates/auth-password-reset.js +231 -0
  387. package/src/tools/mail/templates/auth-welcome.d.ts +3 -0
  388. package/src/tools/mail/templates/auth-welcome.d.ts.map +1 -0
  389. package/src/tools/mail/templates/auth-welcome.js +236 -0
  390. package/src/tools/mail/templates/general.d.ts +3 -0
  391. package/src/tools/mail/templates/general.d.ts.map +1 -0
  392. package/src/tools/mail/templates/general.js +109 -0
  393. package/src/tools/mail/templates/index.js +2 -2
  394. package/src/tools/mail/templates/job-completed.d.ts +3 -0
  395. package/src/tools/mail/templates/job-completed.d.ts.map +1 -0
  396. package/src/tools/mail/templates/job-completed.js +188 -0
  397. package/src/tools/mail/templates/notifications-new-comment.d.ts +3 -0
  398. package/src/tools/mail/templates/notifications-new-comment.d.ts.map +1 -0
  399. package/src/tools/mail/templates/notifications-new-comment.js +228 -0
  400. package/src/tools/mail/templates/password-reset.d.ts +3 -0
  401. package/src/tools/mail/templates/password-reset.d.ts.map +1 -0
  402. package/src/tools/mail/templates/password-reset.js +221 -0
  403. package/src/tools/mail/templates/performance-report.d.ts +3 -0
  404. package/src/tools/mail/templates/performance-report.d.ts.map +1 -0
  405. package/src/tools/mail/templates/performance-report.js +258 -0
  406. package/src/tools/mail/templates/welcome.d.ts +3 -0
  407. package/src/tools/mail/templates/welcome.d.ts.map +1 -0
  408. package/src/tools/mail/templates/welcome.js +187 -0
  409. package/src/tools/mail/templates/worker-alert.d.ts +3 -0
  410. package/src/tools/mail/templates/worker-alert.d.ts.map +1 -0
  411. package/src/tools/mail/templates/worker-alert.js +229 -0
  412. package/src/tools/notification/Notification.js +1 -1
  413. package/src/tools/notification/testingHelpers.js +6 -5
  414. package/src/tools/queue/AdvancedQueue.js +2 -6
  415. package/src/tools/queue/IdempotencyManager.d.ts +6 -0
  416. package/src/tools/queue/IdempotencyManager.d.ts.map +1 -0
  417. package/src/tools/queue/IdempotencyManager.js +36 -0
  418. package/src/tools/queue/JobHeartbeatStore.d.ts +16 -0
  419. package/src/tools/queue/JobHeartbeatStore.d.ts.map +1 -0
  420. package/src/tools/queue/JobHeartbeatStore.js +67 -0
  421. package/src/tools/queue/JobReconciliationRunner.d.ts +16 -0
  422. package/src/tools/queue/JobReconciliationRunner.d.ts.map +1 -0
  423. package/src/tools/queue/JobReconciliationRunner.js +88 -0
  424. package/src/tools/queue/JobRecoveryDaemon.d.ts +27 -0
  425. package/src/tools/queue/JobRecoveryDaemon.d.ts.map +1 -0
  426. package/src/tools/queue/JobRecoveryDaemon.js +205 -0
  427. package/src/tools/queue/JobStateTracker.d.ts +131 -0
  428. package/src/tools/queue/JobStateTracker.d.ts.map +1 -0
  429. package/src/tools/queue/JobStateTracker.js +387 -0
  430. package/src/tools/queue/JobStateTrackerDbPersistence.d.ts +12 -0
  431. package/src/tools/queue/JobStateTrackerDbPersistence.d.ts.map +1 -0
  432. package/src/tools/queue/JobStateTrackerDbPersistence.js +148 -0
  433. package/src/tools/queue/Queue.d.ts.map +1 -1
  434. package/src/tools/queue/Queue.js +160 -16
  435. package/src/tools/queue/QueueDataRedactor.d.ts +6 -0
  436. package/src/tools/queue/QueueDataRedactor.d.ts.map +1 -0
  437. package/src/tools/queue/QueueDataRedactor.js +45 -0
  438. package/src/tools/queue/QueueExtensions.d.ts.map +1 -1
  439. package/src/tools/queue/QueueExtensions.js +2 -1
  440. package/src/tools/queue/QueueReliabilityMetrics.d.ts +38 -0
  441. package/src/tools/queue/QueueReliabilityMetrics.d.ts.map +1 -0
  442. package/src/tools/queue/QueueReliabilityMetrics.js +131 -0
  443. package/src/tools/queue/QueueReliabilityOrchestrator.d.ts +7 -0
  444. package/src/tools/queue/QueueReliabilityOrchestrator.d.ts.map +1 -0
  445. package/src/tools/queue/QueueReliabilityOrchestrator.js +59 -0
  446. package/src/tools/queue/QueueRuntimeRegistration.d.ts +1 -9
  447. package/src/tools/queue/QueueRuntimeRegistration.d.ts.map +1 -1
  448. package/src/tools/queue/QueueRuntimeRegistration.js +75 -4
  449. package/src/tools/queue/QueueTracing.d.ts +32 -0
  450. package/src/tools/queue/QueueTracing.d.ts.map +1 -0
  451. package/src/tools/queue/QueueTracing.js +151 -0
  452. package/src/tools/queue/StalledJobMonitor.d.ts +5 -0
  453. package/src/tools/queue/StalledJobMonitor.d.ts.map +1 -0
  454. package/src/tools/queue/StalledJobMonitor.js +21 -0
  455. package/src/tools/queue/TimeoutManager.d.ts +14 -0
  456. package/src/tools/queue/TimeoutManager.d.ts.map +1 -0
  457. package/src/tools/queue/TimeoutManager.js +77 -0
  458. package/src/tools/queue/drivers/Redis.d.ts +1 -0
  459. package/src/tools/queue/drivers/Redis.d.ts.map +1 -1
  460. package/src/tools/queue/drivers/Redis.js +1 -0
  461. package/src/tools/queue/index.d.ts +10 -0
  462. package/src/tools/queue/index.d.ts.map +1 -1
  463. package/src/tools/queue/index.js +10 -0
  464. package/src/tools/redis/RedisKeyManager.d.ts +3 -0
  465. package/src/tools/redis/RedisKeyManager.d.ts.map +1 -1
  466. package/src/tools/redis/RedisKeyManager.js +15 -0
  467. package/src/tools/storage/drivers/R2.d.ts +13 -0
  468. package/src/tools/storage/drivers/R2.d.ts.map +1 -1
  469. package/src/tools/storage/drivers/R2.js +29 -0
  470. package/src/zintrust.plugins.d.ts +9 -0
  471. package/src/zintrust.plugins.d.ts.map +1 -0
  472. package/src/zintrust.plugins.js +7 -0
  473. package/src/zintrust.plugins.wg.d.ts +9 -0
  474. package/src/zintrust.plugins.wg.d.ts.map +1 -0
  475. package/src/zintrust.plugins.wg.js +7 -0
@@ -0,0 +1,353 @@
1
+ import * as RuntimeConfig from '../../config/index.js';
2
+ import { StartupHealthChecks } from '../../health/StartupHealthChecks.js';
3
+ import { loadQueueMonitorModule, loadWorkersModule } from '../../runtime/WorkersModule.js';
4
+ import { registerCachesFromRuntimeConfig } from '../../cache/CacheRuntimeRegistration.js';
5
+ import broadcastConfig from '../../config/broadcast.js';
6
+ import { Cloudflare } from '../../config/cloudflare.js';
7
+ import { FeatureFlags } from '../../config/features.js';
8
+ import { Logger } from '../../config/logger.js';
9
+ import notificationConfig from '../../config/notification.js';
10
+ import { StartupConfigValidator } from '../../config/StartupConfigValidator.js';
11
+ import { existsSync } from '../../node-singletons/fs.js';
12
+ import * as path from '../../node-singletons/path.js';
13
+ import { pathToFileURL } from '../../node-singletons/url.js';
14
+ import { registerDatabasesFromRuntimeConfig } from '../../orm/DatabaseRuntimeRegistration.js';
15
+ import { registerMasterRoutes, tryImportOptional } from './registerRoute.js';
16
+ import { registerWorkerShutdownHook } from './worker.js';
17
+ import { StartupConfigFile, StartupConfigFileRegistry } from '../../runtime/StartupConfigFileRegistry.js';
18
+ import { registerBroadcastersFromRuntimeConfig } from '../../tools/broadcast/BroadcastRuntimeRegistration.js';
19
+ import { registerNotificationChannelsFromRuntimeConfig } from '../../tools/notification/NotificationRuntimeRegistration.js';
20
+ import { registerQueuesFromRuntimeConfig } from '../../tools/queue/QueueRuntimeRegistration.js';
21
+ import { registerDisksFromRuntimeConfig } from '../../tools/storage/StorageRuntimeRegistration.js';
22
+ const loadRuntimeQueueConfig = async () => {
23
+ try {
24
+ const modulePath = '@runtime-config/queue';
25
+ const loaded = (await import(modulePath));
26
+ return loaded.default ?? queueConfig ?? undefined;
27
+ }
28
+ catch {
29
+ return queueConfig ?? undefined;
30
+ }
31
+ };
32
+ const readRuntimeConfig = (key, fallback) => {
33
+ try {
34
+ const value = RuntimeConfig[key];
35
+ return (value ?? fallback);
36
+ }
37
+ catch {
38
+ return fallback;
39
+ }
40
+ };
41
+ const appConfig = readRuntimeConfig('appConfig', { port: 7777, dockerWorker: false });
42
+ const cacheConfig = readRuntimeConfig('cacheConfig', RuntimeConfig.cacheConfig);
43
+ const databaseConfig = readRuntimeConfig('databaseConfig', {
44
+ default: 'sqlite',
45
+ connections: {},
46
+ });
47
+ const queueConfig = readRuntimeConfig('queueConfig', RuntimeConfig.queueConfig);
48
+ const storageConfig = readRuntimeConfig('storageConfig', RuntimeConfig.storageConfig);
49
+ // eslint-disable-next-line @typescript-eslint/require-await
50
+ const dbLoader = async () => {
51
+ registerDatabasesFromRuntimeConfig(databaseConfig);
52
+ };
53
+ const queuesLoader = async () => {
54
+ await registerQueuesFromRuntimeConfig(queueConfig);
55
+ };
56
+ // eslint-disable-next-line @typescript-eslint/require-await
57
+ const cachesLoader = async () => {
58
+ registerCachesFromRuntimeConfig(cacheConfig);
59
+ };
60
+ const registerFromRuntimeConfig = async () => {
61
+ await dbLoader();
62
+ await queuesLoader();
63
+ await cachesLoader();
64
+ registerBroadcastersFromRuntimeConfig({
65
+ default: broadcastConfig.default,
66
+ drivers: broadcastConfig.drivers,
67
+ });
68
+ registerDisksFromRuntimeConfig(storageConfig);
69
+ registerNotificationChannelsFromRuntimeConfig({
70
+ default: notificationConfig.default,
71
+ drivers: notificationConfig.drivers,
72
+ });
73
+ };
74
+ /**
75
+ * Helper: Register ConnectionManager shutdown hook
76
+ */
77
+ const registerConnectionManagerHook = (shutdownManager) => {
78
+ shutdownManager.add(async () => {
79
+ try {
80
+ const mod = await import('../../orm/ConnectionManager.js');
81
+ await mod.ConnectionManager.shutdownIfInitialized();
82
+ }
83
+ catch {
84
+ /* ignore import failures in restrictive runtimes */
85
+ }
86
+ });
87
+ };
88
+ /**
89
+ * Helper: Register Database reset hook
90
+ */
91
+ const registerDatabaseResetHook = (shutdownManager) => {
92
+ shutdownManager.add(async () => {
93
+ try {
94
+ const mod = await import('../../orm/Database.js');
95
+ mod.resetDatabase();
96
+ }
97
+ catch {
98
+ /* ignore import failures in restrictive runtimes */
99
+ }
100
+ });
101
+ };
102
+ /**
103
+ * Helper: Register generic reset hook for modules with reset() method
104
+ */
105
+ const registerResetHook = (shutdownManager, modulePath, exportName) => {
106
+ shutdownManager.add(async () => {
107
+ try {
108
+ const mod = (await import(modulePath));
109
+ const resetModule = mod[exportName];
110
+ if (resetModule?.reset) {
111
+ resetModule.reset();
112
+ }
113
+ }
114
+ catch {
115
+ /* ignore import failures in restrictive runtimes */
116
+ }
117
+ });
118
+ };
119
+ /**
120
+ * Helper: Register FileLogWriter flush hook
121
+ */
122
+ const registerFileLogFlushHook = (shutdownManager) => {
123
+ shutdownManager.add(async () => {
124
+ try {
125
+ const mod = await import('../../config/FileLogWriter.js');
126
+ mod.FileLogWriter.flush();
127
+ }
128
+ catch {
129
+ /* ignore import failures in restrictive runtimes */
130
+ }
131
+ });
132
+ };
133
+ export const registerFrameworkShutdownHooks = (shutdownManager) => {
134
+ // Register framework-level shutdown hooks for long-lived resources
135
+ registerConnectionManagerHook(shutdownManager);
136
+ // Ensure worker management system is asked to shutdown BEFORE databases are reset
137
+ registerWorkerShutdownHook(shutdownManager);
138
+ // Database and cache reset
139
+ registerDatabaseResetHook(shutdownManager);
140
+ registerResetHook(shutdownManager, '@cache/Cache', 'Cache');
141
+ // File logging
142
+ registerFileLogFlushHook(shutdownManager);
143
+ // Registry resets
144
+ registerResetHook(shutdownManager, '@broadcast/BroadcastRegistry', 'BroadcastRegistry');
145
+ registerResetHook(shutdownManager, '@storage/StorageDiskRegistry', 'StorageDiskRegistry');
146
+ registerResetHook(shutdownManager, '@notification/NotificationChannelRegistry', 'NotificationChannelRegistry');
147
+ registerResetHook(shutdownManager, '@mail/MailDriverRegistry', 'MailDriverRegistry');
148
+ registerResetHook(shutdownManager, '@tools/queue/Queue', 'Queue');
149
+ };
150
+ const initializeArtifactDirectories = async (resolvedBasePath) => {
151
+ if (resolvedBasePath === '')
152
+ return;
153
+ if (typeof process === 'undefined')
154
+ return;
155
+ const globalAny = globalThis;
156
+ if (globalAny.CF !== undefined)
157
+ return;
158
+ if (typeof globalAny.WebSocketPair === 'function')
159
+ return;
160
+ if (globalAny.caches !== undefined)
161
+ return;
162
+ let nodeFs;
163
+ try {
164
+ nodeFs = await import('../../node-singletons/fs.js');
165
+ }
166
+ catch {
167
+ return;
168
+ }
169
+ const dirs = ['logs', 'storage', 'tmp'];
170
+ for (const dir of dirs) {
171
+ const fullPath = path.join(resolvedBasePath, dir);
172
+ try {
173
+ if (!nodeFs.existsSync(fullPath)) {
174
+ nodeFs.mkdirSync(fullPath, { recursive: true });
175
+ Logger.info(`✓ Created directory: ${dir}`);
176
+ }
177
+ }
178
+ catch (error) {
179
+ Logger.warn(`Failed to create ${dir} directory`, error);
180
+ }
181
+ }
182
+ };
183
+ const extractRedisConfigFromQueueConfig = () => {
184
+ const redisConfig = queueConfig.drivers?.redis ?? {};
185
+ const redisHost = typeof redisConfig['host'] === 'string' ? redisConfig['host'] : '127.0.0.1';
186
+ const redisPort = typeof redisConfig['port'] === 'number' && Number.isFinite(redisConfig['port'])
187
+ ? redisConfig['port']
188
+ : 6379;
189
+ const redisPassword = typeof redisConfig['password'] === 'string' ? redisConfig['password'] : '';
190
+ const redisDb = typeof redisConfig['database'] === 'number' && Number.isFinite(redisConfig['database'])
191
+ ? redisConfig['database']
192
+ : 0;
193
+ return {
194
+ host: redisHost,
195
+ port: redisPort,
196
+ password: redisPassword,
197
+ db: redisDb,
198
+ };
199
+ };
200
+ const loadAndValidateQueueMonitorModule = async () => {
201
+ let workersModule;
202
+ try {
203
+ workersModule = (await loadQueueMonitorModule());
204
+ }
205
+ catch (error) {
206
+ Logger.warn('Failed to load Queue Monitor module', error);
207
+ return null;
208
+ }
209
+ if (!workersModule || !('QueueMonitor' in workersModule)) {
210
+ Logger.warn('Queue Monitor module not available');
211
+ return null;
212
+ }
213
+ const queueMonitorModule = workersModule;
214
+ const { QueueMonitor } = queueMonitorModule;
215
+ if (QueueMonitor === undefined || typeof QueueMonitor.create !== 'function') {
216
+ Logger.warn('Queue Monitor module does not expose QueueMonitor.create');
217
+ return null;
218
+ }
219
+ return queueMonitorModule;
220
+ };
221
+ const initializeQueueMonitor = async (router) => {
222
+ const runQueueConfig = await loadRuntimeQueueConfig();
223
+ const monitorConfig = runQueueConfig?.monitor;
224
+ if (monitorConfig === undefined) {
225
+ return;
226
+ }
227
+ if (monitorConfig.enabled === false) {
228
+ return;
229
+ }
230
+ const queueMonitorModule = await loadAndValidateQueueMonitorModule();
231
+ if (queueMonitorModule === null) {
232
+ Logger.debug('Queue Monitor is enabled in configuration but module failed to load or is invalid. Skipping Queue Monitor initialization.');
233
+ return;
234
+ }
235
+ const redisConfig = extractRedisConfigFromQueueConfig();
236
+ const { QueueMonitor } = queueMonitorModule;
237
+ const monitor = QueueMonitor.create({
238
+ ...monitorConfig,
239
+ redis: redisConfig,
240
+ });
241
+ try {
242
+ monitor.registerRoutes(router);
243
+ }
244
+ catch (error) {
245
+ Logger.error('Failed to register Queue Monitor routes', error);
246
+ }
247
+ Logger.info(`Queue Monitor routes registered at http://127.0.0.1:${appConfig.port}${monitorConfig.basePath ?? ''}`);
248
+ Logger.info(`Queue Monitor enqueue endpoint at http://127.0.0.1:${appConfig.port}/test/enqueue`);
249
+ };
250
+ const initializeWorkers = async (router) => {
251
+ const workers = await loadWorkersModule();
252
+ if (workers?.WorkerInit !== undefined && typeof workers.registerWorkerRoutes === 'function') {
253
+ workers.registerWorkerRoutes(router, undefined, { middleware: undefined });
254
+ }
255
+ };
256
+ const resolveLocalQueueRedisEntry = () => {
257
+ if (typeof process === 'undefined' || typeof process.cwd !== 'function')
258
+ return null;
259
+ const cwd = process.cwd();
260
+ if (cwd.trim() === '')
261
+ return null;
262
+ const localEntry = path.join(cwd, 'dist', 'packages', 'queue-redis', 'src', 'index.js');
263
+ return existsSync(localEntry) ? localEntry : null;
264
+ };
265
+ const loadQueueHttpGatewayModule = async () => {
266
+ try {
267
+ return (await import('@zintrust/queue-redis'));
268
+ }
269
+ catch {
270
+ const localEntry = resolveLocalQueueRedisEntry();
271
+ if (localEntry === null)
272
+ return undefined;
273
+ const url = pathToFileURL(localEntry).href;
274
+ return (await import(url));
275
+ }
276
+ };
277
+ const initializeQueueHttpGateway = async (router) => {
278
+ try {
279
+ const module = await loadQueueHttpGatewayModule();
280
+ if (module === undefined) {
281
+ Logger.warn('Queue HTTP gateway module is unavailable (@zintrust/queue-redis not found)');
282
+ return;
283
+ }
284
+ if (module.QueueHttpGateway === undefined ||
285
+ typeof module.QueueHttpGateway.create !== 'function') {
286
+ Logger.warn('Queue HTTP gateway module does not expose QueueHttpGateway.create');
287
+ return;
288
+ }
289
+ module.QueueHttpGateway.create().registerRoutes(router);
290
+ Logger.info('Queue HTTP gateway route registered at /api/_sys/queue/rpc');
291
+ }
292
+ catch (error) {
293
+ Logger.warn('Failed to register Queue HTTP gateway routes', error);
294
+ }
295
+ };
296
+ export const createLifecycle = (params) => {
297
+ const boot = async () => {
298
+ if (params.getBooted())
299
+ return;
300
+ Logger.info(`🚀 Booting ZinTrust Application in ${params.environment} mode...`);
301
+ if (params.environment === 'development') {
302
+ // Clear config registry cache to ensure fresh config loading in watch mode
303
+ // This fixes the issue where config/middleware.ts changes are ignored in watch mode
304
+ StartupConfigFileRegistry.clear();
305
+ }
306
+ StartupConfigValidator.assertValid();
307
+ // Preload project-owned config overrides that must be available synchronously.
308
+ await StartupConfigFileRegistry.preload([
309
+ StartupConfigFile.Middleware,
310
+ StartupConfigFile.Cache,
311
+ StartupConfigFile.Database,
312
+ StartupConfigFile.Queue,
313
+ StartupConfigFile.Storage,
314
+ StartupConfigFile.Mail,
315
+ StartupConfigFile.Broadcast,
316
+ StartupConfigFile.Notification,
317
+ ]);
318
+ FeatureFlags.initialize();
319
+ await StartupHealthChecks.assertHealthy();
320
+ await registerFromRuntimeConfig();
321
+ await initializeArtifactDirectories(params.resolvedBasePath);
322
+ await registerMasterRoutes(params.resolvedBasePath, params.router);
323
+ if (Cloudflare.getWorkersEnv() === null && appConfig.dockerWorker === false) {
324
+ await initializeWorkers(params.router);
325
+ await initializeQueueMonitor(params.router);
326
+ await initializeQueueHttpGateway(params.router);
327
+ }
328
+ // Register service providers
329
+ // Bootstrap services
330
+ Logger.info('✅ Application booted successfully');
331
+ params.setBooted(true);
332
+ };
333
+ const shutdown = async () => {
334
+ Logger.info('🛑 Shutting down application...');
335
+ try {
336
+ await params.shutdownManager.run();
337
+ }
338
+ catch (error) {
339
+ Logger.error('Shutdown hook failed:', error);
340
+ }
341
+ // Ensure FileLogWriter.flush is attempted even if dynamic registration failed.
342
+ try {
343
+ const fileLogWriter = await tryImportOptional('@config/FileLogWriter');
344
+ fileLogWriter?.FileLogWriter?.flush?.();
345
+ }
346
+ catch {
347
+ /* best-effort */
348
+ }
349
+ params.setBooted(false);
350
+ Logger.info('✅ Application shut down successfully');
351
+ };
352
+ return { boot, shutdown };
353
+ };
@@ -0,0 +1,25 @@
1
+ import type { IMiddlewareStack } from '../../middleware';
2
+ import type { IServiceContainer } from '../../container/ServiceContainer';
3
+ import type { IRouter } from '../../routes/Router';
4
+ export interface IApplication {
5
+ boot(): Promise<void>;
6
+ shutdown(): Promise<void>;
7
+ isBooted(): boolean;
8
+ isDevelopment(): boolean;
9
+ isProduction(): boolean;
10
+ isTesting(): boolean;
11
+ getEnvironment(): string;
12
+ getRouter(): IRouter;
13
+ getContainer(): IServiceContainer;
14
+ getMiddlewareStack(): IMiddlewareStack;
15
+ getBasePath(): string;
16
+ }
17
+ export type RoutesModule = {
18
+ registerRoutes?: (r: IRouter) => void;
19
+ };
20
+ export type ShutdownHook = () => void | Promise<void>;
21
+ export interface IShutdownManager {
22
+ add(hook: ShutdownHook): void;
23
+ run(): Promise<void>;
24
+ }
25
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../src/boot/registry/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,WAAW,YAAY;IAC3B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,QAAQ,IAAI,OAAO,CAAC;IACpB,aAAa,IAAI,OAAO,CAAC;IACzB,YAAY,IAAI,OAAO,CAAC;IACxB,SAAS,IAAI,OAAO,CAAC;IACrB,cAAc,IAAI,MAAM,CAAC;IACzB,SAAS,IAAI,OAAO,CAAC;IACrB,YAAY,IAAI,iBAAiB,CAAC;IAClC,kBAAkB,IAAI,gBAAgB,CAAC;IACvC,WAAW,IAAI,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,YAAY,GAAG;IAAE,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;CAAE,CAAC;AAErE,MAAM,MAAM,YAAY,GAAG,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEtD,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;IAC9B,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACtB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { IShutdownManager } from './type';
2
+ /**
3
+ * Helper: Register Worker management system shutdown hook
4
+ */
5
+ export declare const registerWorkerShutdownHook: (shutdownManager: IShutdownManager) => Promise<void>;
6
+ //# sourceMappingURL=worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../../src/boot/registry/worker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD;;GAEG;AACH,eAAO,MAAM,0BAA0B,GACrC,iBAAiB,gBAAgB,KAChC,OAAO,CAAC,IAAI,CA0Cd,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { appConfig } from '../../config/app.js';
2
+ import { Env } from '../../config/env.js';
3
+ import { loadWorkersModule } from '../../runtime/WorkersModule.js';
4
+ /**
5
+ * Helper: Register Worker management system shutdown hook
6
+ */
7
+ export const registerWorkerShutdownHook = async (shutdownManager) => {
8
+ if (Env.getBool('WORKER_SHUTDOWN_ON_APP_EXIT', true) === false ||
9
+ appConfig.dockerWorker === true) {
10
+ return Promise.resolve(); // NOSONAR - Skip worker shutdown hook registration
11
+ }
12
+ // Ensure worker management system is asked to shutdown BEFORE databases are reset.
13
+ // This prevents workers from trying to access DB connections that have already
14
+ // been closed by subsequent shutdown hooks.
15
+ shutdownManager.add(async () => {
16
+ try {
17
+ const mod = (await loadWorkersModule());
18
+ const isShuttingDown = typeof mod.WorkerShutdown.isShuttingDown === 'function'
19
+ ? mod.WorkerShutdown.isShuttingDown()
20
+ : (mod.WorkerShutdown.getShutdownState?.().isShuttingDown ?? false);
21
+ const completedAt = mod.WorkerShutdown.getShutdownState?.().completedAt ?? null;
22
+ if (isShuttingDown || completedAt !== null)
23
+ return;
24
+ await mod.WorkerShutdown.shutdown({
25
+ signal: 'APP_SHUTDOWN',
26
+ timeout: 5000,
27
+ forceExit: false,
28
+ });
29
+ }
30
+ catch {
31
+ /* ignore import failures in restrictive runtimes */
32
+ }
33
+ });
34
+ return Promise.resolve(); // NOSONAR
35
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"KVRemoteDriver.d.ts","sourceRoot":"","sources":["../../../../src/cache/drivers/KVRemoteDriver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAsBtD,eAAO,MAAM,cAAc;cACf,WAAW;EAiErB,CAAC;AAEH,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"KVRemoteDriver.d.ts","sourceRoot":"","sources":["../../../../src/cache/drivers/KVRemoteDriver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAiCtD,eAAO,MAAM,cAAc;cACf,WAAW;EAkErB,CAAC;AAEH,eAAe,cAAc,CAAC"}
@@ -6,13 +6,25 @@
6
6
  import { RemoteSignedJson } from '../../common/RemoteSignedJson.js';
7
7
  import { Env } from '../../config/env.js';
8
8
  import { Logger } from '../../config/logger.js';
9
+ const resolveSigningPrefix = (baseUrl) => {
10
+ try {
11
+ const parsed = new URL(baseUrl);
12
+ const path = parsed.pathname.endsWith('/') ? parsed.pathname.slice(0, -1) : parsed.pathname;
13
+ if (path === '' || path === '/')
14
+ return undefined;
15
+ return path;
16
+ }
17
+ catch {
18
+ return undefined;
19
+ }
20
+ };
9
21
  const normalizeNamespace = (defaultNamespace) => defaultNamespace.trim() === '' ? undefined : defaultNamespace;
10
22
  export const KVRemoteDriver = Object.freeze({
11
23
  create() {
12
24
  const settings = {
13
25
  baseUrl: Env.get('KV_REMOTE_URL'),
14
26
  keyId: Env.get('KV_REMOTE_KEY_ID'),
15
- secret: Env.get('KV_REMOTE_SECRET'),
27
+ secret: Env.get('KV_REMOTE_SECRET', Env.APP_KEY),
16
28
  defaultNamespace: Env.get('KV_REMOTE_NAMESPACE'),
17
29
  timeoutMs: Env.getInt('ZT_PROXY_TIMEOUT_MS', Env.REQUEST_TIMEOUT),
18
30
  };
@@ -21,6 +33,7 @@ export const KVRemoteDriver = Object.freeze({
21
33
  keyId: settings.keyId,
22
34
  secret: settings.secret,
23
35
  timeoutMs: settings.timeoutMs,
36
+ signaturePathPrefixToStrip: resolveSigningPrefix(settings.baseUrl),
24
37
  missingUrlMessage: 'KV remote proxy URL is missing (KV_REMOTE_URL)',
25
38
  missingCredentialsMessage: 'KV remote signing credentials are missing (KV_REMOTE_KEY_ID / KV_REMOTE_SECRET)',
26
39
  messages: {
@@ -1 +1 @@
1
- {"version":3,"file":"CLI.d.ts","sourceRoot":"","sources":["../../../src/cli/CLI.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA0CH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,MAAM,WAAW,IAAI;IACnB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,UAAU,IAAI,OAAO,CAAC;CACvB;AA2MD;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG;cACJ,IAAI;EAed,CAAC"}
1
+ {"version":3,"file":"CLI.d.ts","sourceRoot":"","sources":["../../../src/cli/CLI.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA2DH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,MAAM,WAAW,IAAI;IACnB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,UAAU,IAAI,OAAO,CAAC;CACvB;AAiPD;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG;cACJ,IAAI;EAed,CAAC"}
package/src/cli/CLI.js CHANGED
@@ -5,28 +5,45 @@
5
5
  import { AddCommand } from './commands/AddCommand.js';
6
6
  import { BroadcastWorkCommand } from './commands/BroadcastWorkCommand.js';
7
7
  import { ConfigCommand } from './commands/ConfigCommand.js';
8
+ import { ContainerProxiesCommand } from './commands/ContainerProxiesCommand.js';
9
+ import { ContainerWorkersCommand } from './commands/ContainerWorkersCommand.js';
8
10
  import { AddMigrationCommand, CreateCommand, CreateMigrationCommand, } from './commands/CreateCommand.js';
9
11
  import { D1MigrateCommand } from './commands/D1MigrateCommand.js';
10
12
  import { DbSeedCommand } from './commands/DbSeedCommand.js';
11
13
  import { DebugCommand } from './commands/DebugCommand.js';
14
+ import { DeployCommand } from './commands/DeployCommand.js';
15
+ import { DeployContainerProxiesCommand } from './commands/DeployContainerProxiesCommand.js';
16
+ import { DeployContainerWorkersCommand } from './commands/DeployContainerWorkersCommand.js';
17
+ import { DoctorArchitectureCommand } from './commands/DoctorArchitectureCommand.js';
12
18
  import { FixCommand } from './commands/FixCommand.js';
19
+ import { InitContainerCommand } from './commands/InitContainerCommand.js';
20
+ import { InitProducerCommand } from './commands/InitProducerCommand.js';
21
+ import { InitProxyCommand } from './commands/InitProxyCommand.js';
13
22
  import { JwtDevCommand } from './commands/JwtDevCommand.js';
14
23
  import { KeyGenerateCommand } from './commands/KeyGenerateCommand.js';
15
24
  import { MakeMailTemplateCommand } from './commands/MakeMailTemplateCommand.js';
16
25
  import { MakeNotificationTemplateCommand } from './commands/MakeNotificationTemplateCommand.js';
17
26
  import { MigrateCommand } from './commands/MigrateCommand.js';
18
27
  import { MigrateWorkerCommand } from './commands/MigrateWorkerCommand.js';
28
+ import { MongoDBProxyCommand } from './commands/MongoDBProxyCommand.js';
29
+ import { MySqlProxyCommand } from './commands/MySqlProxyCommand.js';
19
30
  import { NewCommand } from './commands/NewCommand.js';
20
31
  import { NotificationWorkCommand } from './commands/NotificationWorkCommand.js';
21
32
  import { PluginCommand } from './commands/PluginCommand.js';
33
+ import { PostgresProxyCommand } from './commands/PostgresProxyCommand.js';
22
34
  import { PrepareCommand } from './commands/PrepareCommand.js';
35
+ import { ProxyCommand } from './commands/ProxyCommand.js';
23
36
  import { PublishCommand } from './commands/PublishCommand.js';
24
37
  import { QACommand } from './commands/QACommand.js';
25
38
  import { QueueCommand } from './commands/QueueCommand.js';
39
+ import { QueueRecoveryCommand } from './commands/QueueRecoveryCommand.js';
40
+ import { RedisProxyCommand } from './commands/RedisProxyCommand.js';
26
41
  import { ResourceControlCommand } from './commands/ResourceControlCommand.js';
27
42
  import { RoutesCommand } from './commands/RoutesCommand.js';
28
43
  import { SecretsCommand } from './commands/SecretsCommand.js';
29
44
  import { SimulateCommand } from './commands/SimulateCommand.js';
45
+ import { SmtpProxyCommand } from './commands/SmtpProxyCommand.js';
46
+ import { SqlServerProxyCommand } from './commands/SqlServerProxyCommand.js';
30
47
  import { StartCommand } from './commands/StartCommand.js';
31
48
  import { TemplatesCommand } from './commands/TemplatesCommand.js';
32
49
  import { UpgradeCommand } from './commands/UpgradeCommand.js';
@@ -40,48 +57,28 @@ import { readFileSync } from '../node-singletons/fs.js';
40
57
  import { join } from '../node-singletons/path.js';
41
58
  import { Command } from 'commander';
42
59
  const __dirname = esmDirname(import.meta.url);
43
- /**
44
- * Load version from package.json
45
- */
46
- const loadVersion = () => {
47
- try {
48
- const packagePath = join(__dirname, '../../package.json');
49
- const packageJson = JSON.parse(readFileSync(packagePath, 'utf-8'));
50
- return typeof packageJson.version === 'string' ? packageJson.version : '1.0.0';
51
- }
52
- catch (error) {
53
- ErrorFactory.createCliError('Failed to load version from package.json', error);
54
- // Use default version if package.json not found
55
- return '1.0.0';
56
- }
57
- };
58
- /**
59
- * Setup program metadata
60
- */
61
- const setupProgram = (program, version) => {
62
- program
63
- .name('zintrust')
64
- .description('ZinTrust Framework CLI - Build production-grade TypeScript APIs')
65
- .version(version, '-v, --version', 'Output version number')
66
- .helpOption('-h, --help', 'Display help for command')
67
- .usage('[command] [options]');
68
- // Global error handling
69
- program.exitOverride();
60
+ const isCommandProvider = (command) => {
61
+ return (typeof command === 'object' &&
62
+ command !== null &&
63
+ 'getCommand' in command &&
64
+ typeof command.getCommand === 'function');
70
65
  };
71
- /**
72
- * Register all available commands
73
- */
74
- const registerCommands = (program) => {
75
- const commands = [
66
+ const buildCommandRegistry = () => {
67
+ return [
76
68
  NewCommand.create(),
77
69
  UpgradeCommand.create(),
78
70
  PrepareCommand,
71
+ InitContainerCommand.create(),
72
+ InitProxyCommand.create(),
73
+ InitProducerCommand.create(),
74
+ DoctorArchitectureCommand.create(),
79
75
  AddCommand.create(),
80
76
  CreateCommand.create(),
81
77
  CreateMigrationCommand.create(),
82
78
  AddMigrationCommand.create(),
83
79
  StartCommand.create(),
84
80
  QueueCommand.create(),
81
+ QueueRecoveryCommand.create(),
85
82
  BroadcastWorkCommand.create(),
86
83
  NotificationWorkCommand.create(),
87
84
  ResourceControlCommand,
@@ -92,8 +89,13 @@ const registerCommands = (program) => {
92
89
  DebugCommand.create(),
93
90
  SecretsCommand.create(),
94
91
  ConfigCommand.create(),
92
+ ContainerWorkersCommand.create(),
93
+ ContainerProxiesCommand.create(),
95
94
  PluginCommand.create(),
96
95
  PublishCommand.create(),
96
+ DeployCommand.create(),
97
+ DeployContainerWorkersCommand.create(),
98
+ DeployContainerProxiesCommand.create(),
97
99
  QACommand(),
98
100
  FixCommand.create(),
99
101
  KeyGenerateCommand.create(),
@@ -103,16 +105,62 @@ const registerCommands = (program) => {
103
105
  MakeNotificationTemplateCommand.create(),
104
106
  RoutesCommand.create(),
105
107
  JwtDevCommand,
106
- // Worker management commands
108
+ ProxyCommand.create(),
109
+ MySqlProxyCommand.create(),
110
+ PostgresProxyCommand.create(),
111
+ MongoDBProxyCommand.create(),
112
+ SqlServerProxyCommand.create(),
113
+ RedisProxyCommand.create(),
114
+ SmtpProxyCommand.create(),
107
115
  WorkerCommands.createWorkerListCommand(),
108
116
  WorkerCommands.createWorkerStatusCommand(),
109
117
  WorkerCommands.createWorkerStartCommand(),
118
+ WorkerCommands.createWorkerStartAllCommand(),
110
119
  WorkerCommands.createWorkerStopCommand(),
111
120
  WorkerCommands.createWorkerRestartCommand(),
112
121
  WorkerCommands.createWorkerSummaryCommand(),
113
122
  ];
123
+ };
124
+ /**
125
+ * Load version from package.json
126
+ */
127
+ const loadVersion = () => {
128
+ try {
129
+ const packagePath = join(__dirname, '../../package.json');
130
+ const packageJson = JSON.parse(readFileSync(packagePath, 'utf-8'));
131
+ return typeof packageJson.version === 'string' ? packageJson.version : '1.0.0';
132
+ }
133
+ catch (error) {
134
+ ErrorFactory.createCliError('Failed to load version from package.json', error);
135
+ // Use default version if package.json not found
136
+ return '1.0.0';
137
+ }
138
+ };
139
+ /**
140
+ * Setup program metadata
141
+ */
142
+ const setupProgram = (program, version) => {
143
+ program
144
+ .name('zintrust')
145
+ .description('ZinTrust Framework CLI - Build production-grade TypeScript APIs')
146
+ .version(version, '-v, --version', 'Output version number')
147
+ .helpOption('-h, --help', 'Display help for command')
148
+ .usage('[command] [options]');
149
+ // Global error handling
150
+ program.exitOverride();
151
+ };
152
+ /**
153
+ * Register all available commands
154
+ */
155
+ const registerCommands = (program) => {
156
+ const commands = buildCommandRegistry();
114
157
  for (const command of commands) {
115
- program.addCommand(command.getCommand());
158
+ if (isCommandProvider(command)) {
159
+ program.addCommand(command.getCommand());
160
+ }
161
+ else {
162
+ program.addCommand(command);
163
+ }
116
164
  }
117
165
  // Help command
118
166
  program
@@ -46,7 +46,7 @@ const displayBanner = (version) => {
46
46
  const framework = 'ZinTrust Framework';
47
47
  const bannerWidth = 46;
48
48
  const env = Env.NODE_ENV ?? 'development';
49
- const db = Env.DB_CONNECTION ?? 'sqlite';
49
+ const db = Env.DB_CONNECTION || 'sqlite';
50
50
  const border = chalk.cyanBright;
51
51
  const label = chalk.bold.white;
52
52
  const frameworkValue = chalk.bold.cyanBright;