@zintrust/core 0.1.1 → 0.1.3

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 (487) hide show
  1. package/README.md +3 -3
  2. package/bin/zintrust.d.ts.map +1 -1
  3. package/bin/zintrust.js +18 -1
  4. package/package.json +15 -1
  5. package/src/boot/Application.d.ts.map +1 -1
  6. package/src/boot/Application.js +46 -3
  7. package/src/boot/Server.d.ts.map +1 -1
  8. package/src/boot/Server.js +3 -4
  9. package/src/boot/bootstrap.js +77 -6
  10. package/src/builder/BundleOptimizer.d.ts.map +1 -1
  11. package/src/builder/BundleOptimizer.js +6 -4
  12. package/src/cache/drivers/KVDriver.d.ts.map +1 -1
  13. package/src/cache/drivers/KVDriver.js +6 -6
  14. package/src/cache/drivers/RedisDriver.js +1 -1
  15. package/src/cli/BaseCommand.d.ts +2 -2
  16. package/src/cli/BaseCommand.d.ts.map +1 -1
  17. package/src/cli/BaseCommand.js +2 -1
  18. package/src/cli/CLI.d.ts.map +1 -1
  19. package/src/cli/CLI.js +11 -4
  20. package/src/cli/commands/AddCommand.js +1 -1
  21. package/src/cli/commands/ConfigCommand.d.ts.map +1 -1
  22. package/src/cli/commands/ConfigCommand.js +34 -4
  23. package/src/cli/commands/D1MigrateCommand.d.ts +4 -0
  24. package/src/cli/commands/D1MigrateCommand.d.ts.map +1 -1
  25. package/src/cli/commands/D1MigrateCommand.js +4 -3
  26. package/src/cli/commands/FixCommand.d.ts.map +1 -1
  27. package/src/cli/commands/FixCommand.js +3 -16
  28. package/src/cli/commands/LogsCleanupCommand.d.ts +6 -0
  29. package/src/cli/commands/LogsCleanupCommand.d.ts.map +1 -0
  30. package/src/cli/commands/LogsCleanupCommand.js +20 -0
  31. package/src/cli/commands/LogsCommand.d.ts.map +1 -1
  32. package/src/cli/commands/LogsCommand.js +1 -1
  33. package/src/cli/commands/MakeMailTemplateCommand.d.ts +10 -0
  34. package/src/cli/commands/MakeMailTemplateCommand.d.ts.map +1 -0
  35. package/src/cli/commands/MakeMailTemplateCommand.js +74 -0
  36. package/src/cli/commands/MakeNotificationTemplateCommand.d.ts +10 -0
  37. package/src/cli/commands/MakeNotificationTemplateCommand.d.ts.map +1 -0
  38. package/src/cli/commands/MakeNotificationTemplateCommand.js +113 -0
  39. package/src/cli/commands/NewCommand.d.ts +4 -0
  40. package/src/cli/commands/NewCommand.d.ts.map +1 -1
  41. package/src/cli/commands/NewCommand.js +33 -20
  42. package/src/cli/commands/PluginCommand.d.ts.map +1 -1
  43. package/src/cli/commands/PluginCommand.js +8 -4
  44. package/src/cli/commands/PrepareCommand.d.ts.map +1 -1
  45. package/src/cli/commands/PrepareCommand.js +1 -1
  46. package/src/cli/commands/QACommand.d.ts.map +1 -1
  47. package/src/cli/commands/QACommand.js +11 -20
  48. package/src/cli/commands/SecretsCommand.d.ts +16 -0
  49. package/src/cli/commands/SecretsCommand.d.ts.map +1 -0
  50. package/src/cli/commands/SecretsCommand.js +91 -0
  51. package/src/cli/commands/StartCommand.d.ts.map +1 -1
  52. package/src/cli/commands/StartCommand.js +2 -2
  53. package/src/cli/commands/TemplatesCommand.d.ts +3 -0
  54. package/src/cli/commands/TemplatesCommand.d.ts.map +1 -0
  55. package/src/cli/commands/TemplatesCommand.js +65 -0
  56. package/src/cli/commands/index.d.ts +5 -0
  57. package/src/cli/commands/index.d.ts.map +1 -1
  58. package/src/cli/commands/index.js +5 -0
  59. package/src/cli/config/ConfigManager.js +1 -1
  60. package/src/cli/index.d.ts +2 -1
  61. package/src/cli/index.d.ts.map +1 -1
  62. package/src/cli/index.js +2 -1
  63. package/src/cli/scaffolding/ControllerGenerator.js +1 -1
  64. package/src/cli/scaffolding/FeatureScaffolder.js +4 -4
  65. package/src/cli/scaffolding/FileGenerator.js +1 -1
  66. package/src/cli/scaffolding/ModelGenerator.js +1 -1
  67. package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
  68. package/src/cli/scaffolding/ProjectScaffolder.js +61 -11
  69. package/src/cli/scaffolding/ResponseFactoryGenerator.d.ts.map +1 -1
  70. package/src/cli/scaffolding/ResponseFactoryGenerator.js +3 -2
  71. package/src/cli/scaffolding/RouteGenerator.js +1 -1
  72. package/src/cli/scaffolding/ServiceIntegrationTestGenerator.js +1 -1
  73. package/src/cli/scaffolding/ServiceScaffolder.js +2 -2
  74. package/src/cli/scaffolding/TemplateGenerator.d.ts +40 -0
  75. package/src/cli/scaffolding/TemplateGenerator.d.ts.map +1 -0
  76. package/src/cli/scaffolding/TemplateGenerator.js +172 -0
  77. package/src/cli/scaffolding/index.d.ts +1 -0
  78. package/src/cli/scaffolding/index.d.ts.map +1 -1
  79. package/src/cli/scaffolding/index.js +1 -0
  80. package/src/cli/utils/spawn.js +1 -1
  81. package/src/common/AwsSigV4.d.ts +41 -0
  82. package/src/common/AwsSigV4.d.ts.map +1 -0
  83. package/src/common/AwsSigV4.js +69 -0
  84. package/src/common/index.d.ts +39 -0
  85. package/src/common/index.d.ts.map +1 -1
  86. package/src/common/index.js +101 -8
  87. package/src/common/uuid.d.ts +3 -0
  88. package/src/common/uuid.d.ts.map +1 -0
  89. package/src/common/uuid.js +30 -0
  90. package/src/config/FileLogWriter.d.ts +22 -0
  91. package/src/config/FileLogWriter.d.ts.map +1 -0
  92. package/src/config/FileLogWriter.js +192 -0
  93. package/src/config/SecretsManager.d.ts.map +1 -1
  94. package/src/config/SecretsManager.js +37 -11
  95. package/src/config/StartupConfigValidator.d.ts +15 -0
  96. package/src/config/StartupConfigValidator.d.ts.map +1 -0
  97. package/src/config/StartupConfigValidator.js +86 -0
  98. package/src/config/app.d.ts +2 -1
  99. package/src/config/app.d.ts.map +1 -1
  100. package/src/config/app.js +65 -15
  101. package/src/config/broadcast.d.ts +47 -0
  102. package/src/config/broadcast.d.ts.map +1 -0
  103. package/src/config/broadcast.js +54 -0
  104. package/src/config/cache.d.ts +13 -17
  105. package/src/config/cache.d.ts.map +1 -1
  106. package/src/config/cache.js +9 -11
  107. package/src/config/cloudflare.d.ts +26 -0
  108. package/src/config/cloudflare.d.ts.map +1 -0
  109. package/src/config/cloudflare.js +38 -0
  110. package/src/config/env.d.ts +6 -0
  111. package/src/config/env.d.ts.map +1 -1
  112. package/src/config/env.js +6 -0
  113. package/src/config/index.d.ts +52 -28
  114. package/src/config/index.d.ts.map +1 -1
  115. package/src/config/index.js +3 -0
  116. package/src/config/logger.d.ts +2 -0
  117. package/src/config/logger.d.ts.map +1 -1
  118. package/src/config/logger.js +270 -11
  119. package/src/config/logging/HttpLogger.d.ts +23 -0
  120. package/src/config/logging/HttpLogger.d.ts.map +1 -0
  121. package/src/config/logging/HttpLogger.js +93 -0
  122. package/src/config/logging/KvLogger.d.ts +22 -0
  123. package/src/config/logging/KvLogger.d.ts.map +1 -0
  124. package/src/config/logging/KvLogger.js +143 -0
  125. package/src/config/logging/SlackLogger.d.ts +23 -0
  126. package/src/config/logging/SlackLogger.d.ts.map +1 -0
  127. package/src/config/logging/SlackLogger.js +119 -0
  128. package/src/config/mail.d.ts +81 -0
  129. package/src/config/mail.d.ts.map +1 -0
  130. package/src/config/mail.js +73 -0
  131. package/src/config/middleware.d.ts +8 -0
  132. package/src/config/middleware.d.ts.map +1 -0
  133. package/src/config/middleware.js +18 -0
  134. package/src/config/notification.d.ts +62 -0
  135. package/src/config/notification.d.ts.map +1 -0
  136. package/src/config/notification.js +43 -0
  137. package/src/config/security.d.ts.map +1 -1
  138. package/src/config/security.js +2 -2
  139. package/src/config/startup.d.ts +23 -0
  140. package/src/config/startup.d.ts.map +1 -0
  141. package/src/config/startup.js +15 -0
  142. package/src/config/storage.d.ts +21 -35
  143. package/src/config/storage.d.ts.map +1 -1
  144. package/src/config/storage.js +57 -37
  145. package/src/database/migrations/index.d.ts +1 -1
  146. package/src/database/migrations/index.d.ts.map +1 -1
  147. package/src/database/migrations/index.js +2 -1
  148. package/src/features/Queue.js +1 -25
  149. package/src/health/RuntimeHealthProbes.d.ts +13 -0
  150. package/src/health/RuntimeHealthProbes.d.ts.map +1 -0
  151. package/src/health/RuntimeHealthProbes.js +62 -0
  152. package/src/health/StartupHealthChecks.d.ts +26 -0
  153. package/src/health/StartupHealthChecks.d.ts.map +1 -0
  154. package/src/health/StartupHealthChecks.js +124 -0
  155. package/src/http/ErrorResponse.d.ts +28 -0
  156. package/src/http/ErrorResponse.d.ts.map +1 -0
  157. package/src/http/ErrorResponse.js +42 -0
  158. package/src/http/Kernel.d.ts +5 -0
  159. package/src/http/Kernel.d.ts.map +1 -1
  160. package/src/http/Kernel.js +96 -30
  161. package/src/http/RequestContext.d.ts +20 -0
  162. package/src/http/RequestContext.d.ts.map +1 -0
  163. package/src/http/RequestContext.js +77 -0
  164. package/src/index.d.ts +9 -1
  165. package/src/index.d.ts.map +1 -1
  166. package/src/index.js +8 -2
  167. package/src/microservices/MicroserviceManager.d.ts.map +1 -1
  168. package/src/microservices/MicroserviceManager.js +9 -6
  169. package/src/microservices/PostgresAdapter.d.ts.map +1 -1
  170. package/src/microservices/PostgresAdapter.js +3 -1
  171. package/src/microservices/ServiceBundler.d.ts.map +1 -1
  172. package/src/microservices/ServiceBundler.js +6 -4
  173. package/src/microservices/ServiceHealthMonitor.js +2 -2
  174. package/src/middleware/CsrfMiddleware.d.ts.map +1 -1
  175. package/src/middleware/CsrfMiddleware.js +2 -19
  176. package/src/middleware/ErrorHandlerMiddleware.d.ts +6 -0
  177. package/src/middleware/ErrorHandlerMiddleware.d.ts.map +1 -0
  178. package/src/middleware/ErrorHandlerMiddleware.js +33 -0
  179. package/src/middleware/LoggingMiddleware.d.ts +9 -0
  180. package/src/middleware/LoggingMiddleware.d.ts.map +1 -0
  181. package/src/middleware/LoggingMiddleware.js +36 -0
  182. package/src/middleware/index.d.ts +2 -0
  183. package/src/middleware/index.d.ts.map +1 -1
  184. package/src/middleware/index.js +2 -0
  185. package/src/node-singletons/async_hooks.d.ts +9 -0
  186. package/src/node-singletons/async_hooks.d.ts.map +1 -0
  187. package/src/node-singletons/async_hooks.js +8 -0
  188. package/src/node-singletons/fs.d.ts +2 -2
  189. package/src/node-singletons/fs.d.ts.map +1 -1
  190. package/src/node-singletons/fs.js +2 -2
  191. package/src/node-singletons/http.d.ts +1 -1
  192. package/src/node-singletons/http.d.ts.map +1 -1
  193. package/src/node-singletons/http.js +1 -1
  194. package/src/node-singletons/index.d.ts +4 -0
  195. package/src/node-singletons/index.d.ts.map +1 -1
  196. package/src/node-singletons/index.js +4 -0
  197. package/src/node-singletons/net.d.ts +9 -0
  198. package/src/node-singletons/net.d.ts.map +1 -0
  199. package/src/node-singletons/net.js +8 -0
  200. package/src/node-singletons/os.d.ts +3 -3
  201. package/src/node-singletons/os.d.ts.map +1 -1
  202. package/src/node-singletons/os.js +3 -4
  203. package/src/node-singletons/path.d.ts +3 -1
  204. package/src/node-singletons/path.d.ts.map +1 -1
  205. package/src/node-singletons/path.js +3 -1
  206. package/src/node-singletons/perf-hooks.d.ts +3 -1
  207. package/src/node-singletons/perf-hooks.d.ts.map +1 -1
  208. package/src/node-singletons/perf-hooks.js +3 -1
  209. package/src/node-singletons/process.d.ts +23 -0
  210. package/src/node-singletons/process.d.ts.map +1 -0
  211. package/src/node-singletons/process.js +8 -0
  212. package/src/node-singletons/readline.d.ts +3 -3
  213. package/src/node-singletons/readline.d.ts.map +1 -1
  214. package/src/node-singletons/readline.js +3 -4
  215. package/src/node-singletons/tls.d.ts +9 -0
  216. package/src/node-singletons/tls.d.ts.map +1 -0
  217. package/src/node-singletons/tls.js +8 -0
  218. package/src/node-singletons/url.d.ts +3 -1
  219. package/src/node-singletons/url.d.ts.map +1 -1
  220. package/src/node-singletons/url.js +3 -1
  221. package/src/orm/ConnectionManager.d.ts +6 -1
  222. package/src/orm/ConnectionManager.d.ts.map +1 -1
  223. package/src/orm/ConnectionManager.js +14 -0
  224. package/src/orm/DatabaseAdapter.d.ts +6 -0
  225. package/src/orm/DatabaseAdapter.d.ts.map +1 -1
  226. package/src/orm/QueryBuilder.d.ts +8 -1
  227. package/src/orm/QueryBuilder.d.ts.map +1 -1
  228. package/src/orm/QueryBuilder.js +188 -28
  229. package/src/orm/adapters/D1Adapter.d.ts.map +1 -1
  230. package/src/orm/adapters/D1Adapter.js +18 -12
  231. package/src/orm/adapters/MySQLAdapter.d.ts.map +1 -1
  232. package/src/orm/adapters/MySQLAdapter.js +4 -0
  233. package/src/orm/adapters/PostgreSQLAdapter.d.ts.map +1 -1
  234. package/src/orm/adapters/PostgreSQLAdapter.js +4 -0
  235. package/src/orm/adapters/SQLServerAdapter.d.ts.map +1 -1
  236. package/src/orm/adapters/SQLServerAdapter.js +4 -0
  237. package/src/orm/adapters/SQLiteAdapter.d.ts.map +1 -1
  238. package/src/orm/adapters/SQLiteAdapter.js +4 -0
  239. package/src/performance/CodeGenerationBenchmark.js +3 -3
  240. package/src/performance/Optimizer.d.ts +1 -1
  241. package/src/performance/Optimizer.d.ts.map +1 -1
  242. package/src/performance/Optimizer.js +150 -75
  243. package/src/performance/establish-baseline.js +3 -3
  244. package/src/runtime/PluginManager.d.ts +3 -1
  245. package/src/runtime/PluginManager.d.ts.map +1 -1
  246. package/src/runtime/PluginManager.js +124 -28
  247. package/src/runtime/RuntimeDetector.d.ts.map +1 -1
  248. package/src/runtime/RuntimeDetector.js +47 -6
  249. package/src/runtime/adapters/CloudflareAdapter.js +2 -2
  250. package/src/runtime/adapters/FargateAdapter.d.ts.map +1 -1
  251. package/src/runtime/adapters/FargateAdapter.js +2 -1
  252. package/src/runtime/adapters/LambdaAdapter.d.ts.map +1 -1
  253. package/src/runtime/adapters/LambdaAdapter.js +4 -2
  254. package/src/runtime/adapters/NodeServerAdapter.d.ts.map +1 -1
  255. package/src/runtime/adapters/NodeServerAdapter.js +2 -1
  256. package/src/scheduler/ScheduleRunner.d.ts +18 -0
  257. package/src/scheduler/ScheduleRunner.d.ts.map +1 -0
  258. package/src/scheduler/ScheduleRunner.js +155 -0
  259. package/src/scheduler/index.d.ts +3 -0
  260. package/src/scheduler/index.d.ts.map +1 -0
  261. package/src/scheduler/index.js +1 -0
  262. package/src/scheduler/types.d.ts +16 -0
  263. package/src/scheduler/types.d.ts.map +1 -0
  264. package/src/scheduler/types.js +4 -0
  265. package/src/schedules/index.d.ts +2 -0
  266. package/src/schedules/index.d.ts.map +1 -0
  267. package/src/schedules/index.js +1 -0
  268. package/src/schedules/log-cleanup.d.ts +4 -0
  269. package/src/schedules/log-cleanup.d.ts.map +1 -0
  270. package/src/schedules/log-cleanup.js +18 -0
  271. package/src/scripts/GenerateEnvArtifacts.d.ts +13 -0
  272. package/src/scripts/GenerateEnvArtifacts.d.ts.map +1 -0
  273. package/src/scripts/GenerateEnvArtifacts.js +171 -0
  274. package/src/scripts/TemplateSync.js +109 -70
  275. package/src/security/CsrfTokenManager.js +1 -1
  276. package/src/security/Encryptor.js +1 -1
  277. package/src/security/Hash.d.ts +14 -0
  278. package/src/security/Hash.d.ts.map +1 -0
  279. package/src/security/Hash.js +81 -0
  280. package/src/security/StartupSecretValidation.d.ts +20 -0
  281. package/src/security/StartupSecretValidation.d.ts.map +1 -0
  282. package/src/security/StartupSecretValidation.js +61 -0
  283. package/src/security/UrlValidator.d.ts +0 -1
  284. package/src/security/UrlValidator.d.ts.map +1 -1
  285. package/src/security/UrlValidator.js +1 -2
  286. package/src/security/Xss.d.ts +14 -0
  287. package/src/security/Xss.d.ts.map +1 -0
  288. package/src/security/Xss.js +57 -0
  289. package/src/security/XssProtection.d.ts.map +1 -1
  290. package/src/security/XssProtection.js +155 -17
  291. package/src/templates/adapters/MySQLAdapter.ts.tpl +5 -0
  292. package/src/templates/adapters/PostgreSQLAdapter.ts.tpl +5 -0
  293. package/src/templates/adapters/SQLServerAdapter.ts.tpl +5 -0
  294. package/src/templates/adapters/SQLiteAdapter.ts.tpl +5 -0
  295. package/src/templates/features/Queue.ts.tpl +1 -29
  296. package/src/templates/project/basic/.env.example.tpl +48 -0
  297. package/src/templates/project/basic/.env.tpl +89 -94
  298. package/src/templates/project/basic/app/Toolkit/Broadcast/sendBroadcast.ts.tpl +7 -0
  299. package/src/templates/project/basic/app/Toolkit/Mail/sendWelcomeEmail.ts.tpl +30 -0
  300. package/src/templates/project/basic/app/Toolkit/Notification/sendSlackNotification.ts.tpl +10 -0
  301. package/src/templates/project/basic/app/Toolkit/Notification/sendSms.ts.tpl +13 -0
  302. package/src/templates/project/basic/config/FileLogWriter.ts.tpl +240 -0
  303. package/src/templates/project/basic/config/SecretsManager.ts.tpl +44 -21
  304. package/src/templates/project/basic/config/StartupConfigValidator.ts.tpl +151 -0
  305. package/src/templates/project/basic/config/app.ts.tpl +84 -15
  306. package/src/templates/project/basic/config/broadcast.ts.tpl +97 -0
  307. package/src/templates/project/basic/config/cache.ts.tpl +19 -23
  308. package/src/templates/project/basic/config/cloudflare.ts.tpl +57 -0
  309. package/src/templates/project/basic/config/env.ts.tpl +7 -1
  310. package/src/templates/project/basic/config/index.ts.tpl +3 -0
  311. package/src/templates/project/basic/config/logger.ts.tpl +301 -11
  312. package/src/templates/project/basic/config/logging/HttpLogger.ts.tpl +121 -0
  313. package/src/templates/project/basic/config/logging/KvLogger.ts.tpl +181 -0
  314. package/src/templates/project/basic/config/logging/SlackLogger.ts.tpl +156 -0
  315. package/src/templates/project/basic/config/mail.ts.tpl +141 -0
  316. package/src/templates/project/basic/config/middleware.ts.tpl +27 -0
  317. package/src/templates/project/basic/config/notification.ts.tpl +86 -0
  318. package/src/templates/project/basic/config/security.ts.tpl +4 -5
  319. package/src/templates/project/basic/config/startup.ts.tpl +27 -0
  320. package/src/templates/project/basic/config/storage.ts.tpl +77 -42
  321. package/src/templates/project/basic/database/migrations/index.ts.tpl +1 -1
  322. package/src/templates/project/basic/package.json.tpl +1 -1
  323. package/src/templates/project/basic/routes/api.ts.tpl +11 -37
  324. package/src/templates/project/basic/routes/broadcast.ts.tpl +32 -0
  325. package/src/templates/project/basic/routes/health.ts.tpl +134 -0
  326. package/src/templates/project/basic/routes/storage.ts.tpl +42 -0
  327. package/src/templates/project/basic/src/index.ts.tpl +38 -11
  328. package/src/templates/project/basic/template.json +3 -0
  329. package/src/toolkit/Secrets/EnvFile.d.ts +15 -0
  330. package/src/toolkit/Secrets/EnvFile.d.ts.map +1 -0
  331. package/src/toolkit/Secrets/EnvFile.js +63 -0
  332. package/src/toolkit/Secrets/Manifest.d.ts +24 -0
  333. package/src/toolkit/Secrets/Manifest.d.ts.map +1 -0
  334. package/src/toolkit/Secrets/Manifest.js +71 -0
  335. package/src/toolkit/Secrets/index.d.ts +42 -0
  336. package/src/toolkit/Secrets/index.d.ts.map +1 -0
  337. package/src/toolkit/Secrets/index.js +119 -0
  338. package/src/toolkit/Secrets/providers/AwsSecretsManager.d.ts +14 -0
  339. package/src/toolkit/Secrets/providers/AwsSecretsManager.d.ts.map +1 -0
  340. package/src/toolkit/Secrets/providers/AwsSecretsManager.js +131 -0
  341. package/src/toolkit/Secrets/providers/CloudflareKv.d.ts +9 -0
  342. package/src/toolkit/Secrets/providers/CloudflareKv.d.ts.map +1 -0
  343. package/src/toolkit/Secrets/providers/CloudflareKv.js +73 -0
  344. package/src/tools/broadcast/Broadcast.d.ts +7 -0
  345. package/src/tools/broadcast/Broadcast.d.ts.map +1 -0
  346. package/src/tools/broadcast/Broadcast.js +37 -0
  347. package/src/tools/broadcast/drivers/BaseDriver.d.ts +5 -0
  348. package/src/tools/broadcast/drivers/BaseDriver.d.ts.map +1 -0
  349. package/src/tools/broadcast/drivers/BaseDriver.js +8 -0
  350. package/src/tools/broadcast/drivers/InMemory.d.ts +18 -0
  351. package/src/tools/broadcast/drivers/InMemory.d.ts.map +1 -0
  352. package/src/tools/broadcast/drivers/InMemory.js +16 -0
  353. package/src/tools/broadcast/drivers/Pusher.d.ts +8 -0
  354. package/src/tools/broadcast/drivers/Pusher.d.ts.map +1 -0
  355. package/src/tools/broadcast/drivers/Pusher.js +75 -0
  356. package/src/tools/broadcast/drivers/Redis.d.ts +19 -0
  357. package/src/tools/broadcast/drivers/Redis.d.ts.map +1 -0
  358. package/src/tools/broadcast/drivers/Redis.js +73 -0
  359. package/src/tools/broadcast/drivers/RedisHttps.d.ts +14 -0
  360. package/src/tools/broadcast/drivers/RedisHttps.d.ts.map +1 -0
  361. package/src/tools/broadcast/drivers/RedisHttps.js +50 -0
  362. package/src/tools/broadcast/index.d.ts +7 -0
  363. package/src/tools/broadcast/index.d.ts.map +1 -0
  364. package/src/tools/broadcast/index.js +6 -0
  365. package/src/tools/http/Http.d.ts +49 -0
  366. package/src/tools/http/Http.d.ts.map +1 -0
  367. package/src/tools/http/Http.js +169 -0
  368. package/src/tools/http/HttpResponse.d.ts +32 -0
  369. package/src/tools/http/HttpResponse.d.ts.map +1 -0
  370. package/src/tools/http/HttpResponse.js +80 -0
  371. package/src/tools/http/index.d.ts +15 -0
  372. package/src/tools/http/index.d.ts.map +1 -0
  373. package/src/tools/http/index.js +9 -0
  374. package/src/tools/mail/Mail.d.ts +22 -0
  375. package/src/tools/mail/Mail.d.ts.map +1 -0
  376. package/src/tools/mail/Mail.js +105 -0
  377. package/src/tools/mail/attachments.d.ts +23 -0
  378. package/src/tools/mail/attachments.d.ts.map +1 -0
  379. package/src/tools/mail/attachments.js +26 -0
  380. package/src/tools/mail/drivers/BaseDriver.d.ts +5 -0
  381. package/src/tools/mail/drivers/BaseDriver.d.ts.map +1 -0
  382. package/src/tools/mail/drivers/BaseDriver.js +8 -0
  383. package/src/tools/mail/drivers/Mailgun.d.ts +31 -0
  384. package/src/tools/mail/drivers/Mailgun.d.ts.map +1 -0
  385. package/src/tools/mail/drivers/Mailgun.js +81 -0
  386. package/src/tools/mail/drivers/SendGrid.d.ts +29 -0
  387. package/src/tools/mail/drivers/SendGrid.d.ts.map +1 -0
  388. package/src/tools/mail/drivers/SendGrid.js +57 -0
  389. package/src/tools/mail/drivers/Ses.d.ts +24 -0
  390. package/src/tools/mail/drivers/Ses.d.ts.map +1 -0
  391. package/src/tools/mail/drivers/Ses.js +116 -0
  392. package/src/tools/mail/drivers/Smtp.d.ts +38 -0
  393. package/src/tools/mail/drivers/Smtp.d.ts.map +1 -0
  394. package/src/tools/mail/drivers/Smtp.js +327 -0
  395. package/src/tools/mail/templates/index.d.ts +27 -0
  396. package/src/tools/mail/templates/index.d.ts.map +1 -0
  397. package/src/tools/mail/templates/index.js +35 -0
  398. package/src/tools/mail/templates/markdown/index.d.ts +17 -0
  399. package/src/tools/mail/templates/markdown/index.d.ts.map +1 -0
  400. package/src/tools/mail/templates/markdown/index.js +49 -0
  401. package/src/tools/mail/templates/markdown/registry.d.ts +15 -0
  402. package/src/tools/mail/templates/markdown/registry.d.ts.map +1 -0
  403. package/src/tools/mail/templates/markdown/registry.js +34 -0
  404. package/src/tools/mail/templates/markdown/validator.d.ts +16 -0
  405. package/src/tools/mail/templates/markdown/validator.d.ts.map +1 -0
  406. package/src/tools/mail/templates/markdown/validator.js +24 -0
  407. package/src/tools/mail/testing.d.ts +41 -0
  408. package/src/tools/mail/testing.d.ts.map +1 -0
  409. package/src/tools/mail/testing.js +34 -0
  410. package/src/tools/notification/Driver.d.ts +11 -0
  411. package/src/tools/notification/Driver.d.ts.map +1 -0
  412. package/src/tools/notification/Driver.js +1 -0
  413. package/src/tools/notification/Notification.d.ts +11 -0
  414. package/src/tools/notification/Notification.d.ts.map +1 -0
  415. package/src/tools/notification/Notification.js +11 -0
  416. package/src/tools/notification/Registry.d.ts +10 -0
  417. package/src/tools/notification/Registry.d.ts.map +1 -0
  418. package/src/tools/notification/Registry.js +22 -0
  419. package/src/tools/notification/Service.d.ts +6 -0
  420. package/src/tools/notification/Service.d.ts.map +1 -0
  421. package/src/tools/notification/Service.js +18 -0
  422. package/src/tools/notification/config.d.ts +5 -0
  423. package/src/tools/notification/config.d.ts.map +1 -0
  424. package/src/tools/notification/config.js +5 -0
  425. package/src/tools/notification/drivers/BaseDriver.d.ts +5 -0
  426. package/src/tools/notification/drivers/BaseDriver.d.ts.map +1 -0
  427. package/src/tools/notification/drivers/BaseDriver.js +8 -0
  428. package/src/tools/notification/drivers/Console.d.ts +7 -0
  429. package/src/tools/notification/drivers/Console.d.ts.map +1 -0
  430. package/src/tools/notification/drivers/Console.js +13 -0
  431. package/src/tools/notification/drivers/Slack.d.ts +16 -0
  432. package/src/tools/notification/drivers/Slack.d.ts.map +1 -0
  433. package/src/tools/notification/drivers/Slack.js +24 -0
  434. package/src/tools/notification/drivers/Termii.d.ts +10 -0
  435. package/src/tools/notification/drivers/Termii.d.ts.map +1 -0
  436. package/src/tools/notification/drivers/Termii.js +47 -0
  437. package/src/tools/notification/drivers/Twilio.d.ts +21 -0
  438. package/src/tools/notification/drivers/Twilio.d.ts.map +1 -0
  439. package/src/tools/notification/drivers/Twilio.js +48 -0
  440. package/src/tools/notification/templates/markdown/index.d.ts +15 -0
  441. package/src/tools/notification/templates/markdown/index.d.ts.map +1 -0
  442. package/src/tools/notification/templates/markdown/index.js +38 -0
  443. package/src/tools/notification/templates/markdown/registry.d.ts +15 -0
  444. package/src/tools/notification/templates/markdown/registry.d.ts.map +1 -0
  445. package/src/tools/notification/templates/markdown/registry.js +36 -0
  446. package/src/tools/notification/testing.d.ts +19 -0
  447. package/src/tools/notification/testing.d.ts.map +1 -0
  448. package/src/tools/notification/testing.js +35 -0
  449. package/src/tools/notification/testingHelpers.d.ts +12 -0
  450. package/src/tools/notification/testingHelpers.d.ts.map +1 -0
  451. package/src/tools/notification/testingHelpers.js +32 -0
  452. package/src/tools/queue/Queue.d.ts +23 -0
  453. package/src/tools/queue/Queue.d.ts.map +1 -0
  454. package/src/tools/queue/Queue.js +38 -0
  455. package/src/tools/queue/drivers/InMemory.d.ts +10 -0
  456. package/src/tools/queue/drivers/InMemory.d.ts.map +1 -0
  457. package/src/tools/queue/drivers/InMemory.js +55 -0
  458. package/src/tools/queue/drivers/Redis.d.ts +10 -0
  459. package/src/tools/queue/drivers/Redis.d.ts.map +1 -0
  460. package/src/tools/queue/drivers/Redis.js +91 -0
  461. package/src/tools/storage/LocalSignedUrl.d.ts +12 -0
  462. package/src/tools/storage/LocalSignedUrl.d.ts.map +1 -0
  463. package/src/tools/storage/LocalSignedUrl.js +108 -0
  464. package/src/tools/storage/drivers/Gcs.d.ts +20 -0
  465. package/src/tools/storage/drivers/Gcs.d.ts.map +1 -0
  466. package/src/tools/storage/drivers/Gcs.js +152 -0
  467. package/src/tools/storage/drivers/Local.d.ts +18 -0
  468. package/src/tools/storage/drivers/Local.d.ts.map +1 -0
  469. package/src/tools/storage/drivers/Local.js +89 -0
  470. package/src/tools/storage/drivers/R2.d.ts +20 -0
  471. package/src/tools/storage/drivers/R2.d.ts.map +1 -0
  472. package/src/tools/storage/drivers/R2.js +73 -0
  473. package/src/tools/storage/drivers/S3.d.ts +26 -0
  474. package/src/tools/storage/drivers/S3.d.ts.map +1 -0
  475. package/src/tools/storage/drivers/S3.js +258 -0
  476. package/src/tools/storage/index.d.ts +24 -0
  477. package/src/tools/storage/index.d.ts.map +1 -0
  478. package/src/tools/storage/index.js +111 -0
  479. package/src/tools/storage/testing.d.ts +23 -0
  480. package/src/tools/storage/testing.d.ts.map +1 -0
  481. package/src/tools/storage/testing.js +52 -0
  482. package/src/tools/templates/MarkdownRenderer.d.ts +14 -0
  483. package/src/tools/templates/MarkdownRenderer.d.ts.map +1 -0
  484. package/src/tools/templates/MarkdownRenderer.js +300 -0
  485. package/src/tools/templates/index.d.ts +5 -0
  486. package/src/tools/templates/index.d.ts.map +1 -0
  487. package/src/tools/templates/index.js +4 -0
package/README.md CHANGED
@@ -16,7 +16,7 @@ cd my-app
16
16
  npm run dev
17
17
  ```
18
18
 
19
- Your API is now running at `http://localhost:3000`
19
+ Your API is now running at `http://localhost:7777`
20
20
 
21
21
  ## What is Zintrust?
22
22
 
@@ -159,10 +159,10 @@ Test it:
159
159
 
160
160
  ```bash
161
161
  # Get all users
162
- curl http://localhost:3000/api/users
162
+ curl http://localhost:7777/api/users
163
163
 
164
164
  # Create a user
165
- curl -X POST http://localhost:3000/api/users \
165
+ curl -X POST http://localhost:7777/api/users \
166
166
  -H "Content-Type: application/json" \
167
167
  -d '{"name":"John","email":"john@example.com"}'
168
168
  ```
@@ -1 +1 @@
1
- {"version":3,"file":"zintrust.d.ts","sourceRoot":"","sources":["../../bin/zintrust.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AA8CH,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"zintrust.d.ts","sourceRoot":"","sources":["../../bin/zintrust.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAmEH,OAAO,EAAE,CAAC"}
package/bin/zintrust.js CHANGED
@@ -11,7 +11,24 @@ async function main() {
11
11
  EnvFileLoader.ensureLoaded();
12
12
  const { CLI } = await import('../src/cli/CLI');
13
13
  const cli = CLI.create();
14
- await cli.run(process.argv.slice(2));
14
+ // When executing via tsx (e.g. `npx tsx bin/zin.ts ...`), the script path can
15
+ // appear as the first element of `process.argv.slice(2)`. Commander expects
16
+ // args to start at the command name, so we strip a leading script path if present.
17
+ const rawArgs = process.argv.slice(2);
18
+ if (process.env['ZINTRUST_CLI_DEBUG_ARGS'] === '1') {
19
+ try {
20
+ process.stderr.write(`[zintrust-cli] process.argv=${JSON.stringify(process.argv)}\n`);
21
+ process.stderr.write(`[zintrust-cli] rawArgs=${JSON.stringify(rawArgs)}\n`);
22
+ }
23
+ catch {
24
+ // ignore
25
+ }
26
+ }
27
+ const args = rawArgs.length > 0 &&
28
+ (rawArgs[0]?.endsWith('.ts') === true || rawArgs[0]?.endsWith('.js') === true)
29
+ ? rawArgs.slice(1)
30
+ : rawArgs;
31
+ await cli.run(args);
15
32
  }
16
33
  catch (error) {
17
34
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zintrust/core",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Production-grade TypeScript backend framework for JavaScript",
5
5
  "homepage": "https://zintrust.com",
6
6
  "repository": {
@@ -13,6 +13,20 @@
13
13
  "type": "module",
14
14
  "main": "src/index.js",
15
15
  "types": "src/index.d.ts",
16
+ "dependencies": {
17
+ "bcrypt": "^6.0.0",
18
+ "better-sqlite3": "^12.5.0",
19
+ "chalk": "^5.6.2",
20
+ "commander": "^14.0.2",
21
+ "inquirer": "^13.1.0",
22
+ "jsonwebtoken": "^9.0.3",
23
+ "tsx": "^4.21.0"
24
+ },
25
+ "overrides": {
26
+ "node-forge": "1.3.3",
27
+ "cross-spawn": "^7.0.5",
28
+ "glob": "^11.1.0"
29
+ },
16
30
  "bin": {
17
31
  "zintrust": "bin/zintrust.js",
18
32
  "zin": "bin/zin.js",
@@ -1 +1 @@
1
- {"version":3,"file":"Application.d.ts","sourceRoot":"","sources":["../../../src/boot/Application.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAoB,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAmB,MAAM,8BAA8B,CAAC;AACjF,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,kBAAkB,CAAC;AAMxD,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;AAqJD;;GAEG;AACH,eAAO,MAAM,WAAW;IACtB;;OAEG;sBACe,MAAM,GAAG,YAAY;EAwCvC,CAAC;AAEH,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"Application.d.ts","sourceRoot":"","sources":["../../../src/boot/Application.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAoB,MAAM,8BAA8B,CAAC;AAEnF,OAAO,EAAE,gBAAgB,EAAmB,MAAM,8BAA8B,CAAC;AACjF,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,kBAAkB,CAAC;AAOxD,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;AA2LD;;GAEG;AACH,eAAO,MAAM,WAAW;IACtB;;OAEG;sBACe,MAAM,GAAG,YAAY;EAmDvC,CAAC;AAEH,eAAe,WAAW,CAAC"}
@@ -2,11 +2,14 @@
2
2
  * Application - Framework core entry point
3
3
  * Handles application lifecycle, booting, and environment
4
4
  */
5
+ import { appConfig } from '../config';
5
6
  import { ServiceContainer } from '../container/ServiceContainer';
7
+ import { StartupHealthChecks } from '../health/StartupHealthChecks';
6
8
  import { MiddlewareStack } from '../middleware/MiddlewareStack';
7
9
  import { Router } from '../routing/Router';
8
- import { Env } from '../config/env';
10
+ import { FeatureFlags } from '../config/features';
9
11
  import { Logger } from '../config/logger';
12
+ import { StartupConfigValidator } from '../config/StartupConfigValidator';
10
13
  import * as path from '../node-singletons/path';
11
14
  import { pathToFileURL } from '../node-singletons/url';
12
15
  const ShutdownManager = Object.freeze({
@@ -89,11 +92,41 @@ const registerRoutes = async (resolvedBasePath, router) => {
89
92
  Logger.error('Failed to register routes:', error);
90
93
  }
91
94
  };
95
+ const initializeArtifactDirectories = async (resolvedBasePath) => {
96
+ if (resolvedBasePath === '')
97
+ return;
98
+ if (typeof process === 'undefined')
99
+ return;
100
+ let nodeFs;
101
+ try {
102
+ nodeFs = await import('../node-singletons/fs');
103
+ }
104
+ catch {
105
+ return;
106
+ }
107
+ const dirs = ['logs', 'storage', 'tmp'];
108
+ for (const dir of dirs) {
109
+ const fullPath = path.join(resolvedBasePath, dir);
110
+ try {
111
+ if (!nodeFs.existsSync(fullPath)) {
112
+ nodeFs.mkdirSync(fullPath, { recursive: true });
113
+ Logger.info(`✓ Created directory: ${dir}`);
114
+ }
115
+ }
116
+ catch (error) {
117
+ Logger.warn(`Failed to create ${dir} directory`, error);
118
+ }
119
+ }
120
+ };
92
121
  const createLifecycle = (params) => {
93
122
  const boot = async () => {
94
123
  if (params.getBooted())
95
124
  return;
96
125
  Logger.info(`🚀 Booting Zintrust Application in ${params.environment} mode...`);
126
+ StartupConfigValidator.assertValid();
127
+ FeatureFlags.initialize();
128
+ await StartupHealthChecks.assertHealthy();
129
+ await initializeArtifactDirectories(params.resolvedBasePath);
97
130
  await registerRoutes(params.resolvedBasePath, params.router);
98
131
  // Register service providers
99
132
  // Bootstrap services
@@ -123,7 +156,7 @@ export const Application = Object.freeze({
123
156
  create(basePath) {
124
157
  const resolvedBasePath = resolveBasePath(basePath);
125
158
  const joinFromBase = makeJoinFromBase(resolvedBasePath);
126
- const environment = Env.get('NODE_ENV', 'development');
159
+ const environment = appConfig.environment;
127
160
  const container = ServiceContainer.create();
128
161
  const router = Router.createRouter();
129
162
  const middlewareStack = MiddlewareStack.create();
@@ -131,6 +164,16 @@ export const Application = Object.freeze({
131
164
  let booted = false;
132
165
  registerCorePaths(container, resolvedBasePath, joinFromBase);
133
166
  registerCoreInstances({ container, environment, router, middlewareStack, shutdownManager });
167
+ // Register framework-level shutdown hooks for long-lived resources
168
+ // ConnectionManager may not be initialized; shutdownIfInitialized is safe
169
+ // Use dynamic import without top-level await to avoid transforming the module into an async module
170
+ import('../orm/ConnectionManager')
171
+ .then(({ ConnectionManager }) => {
172
+ shutdownManager.add(async () => ConnectionManager.shutdownIfInitialized());
173
+ })
174
+ .catch(() => {
175
+ /* ignore import failures in restrictive runtimes */
176
+ });
134
177
  const { boot, shutdown } = createLifecycle({
135
178
  environment,
136
179
  resolvedBasePath,
@@ -147,7 +190,7 @@ export const Application = Object.freeze({
147
190
  isBooted: () => booted,
148
191
  isDevelopment: () => environment === 'development',
149
192
  isProduction: () => environment === 'production',
150
- isTesting: () => environment === 'testing' || environment === 'test',
193
+ isTesting: () => environment === 'testing',
151
194
  getEnvironment: () => environment,
152
195
  getRouter: () => router,
153
196
  getContainer: () => container,
@@ -1 +1 @@
1
- {"version":3,"file":"Server.d.ts","sourceRoot":"","sources":["../../../src/boot/Server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAQjD,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;AAK9C,MAAM,WAAW,OAAO;IACtB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,aAAa,IAAI,IAAI,CAAC,MAAM,CAAC;CAC9B;AA4ND;;;GAGG;AACH,eAAO,MAAM,MAAM;IACjB;;OAEG;gBACS,YAAY,SAAS,MAAM,SAAS,MAAM,GAAG,OAAO;EA8BhE,CAAC;AAEH,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"Server.d.ts","sourceRoot":"","sources":["../../../src/boot/Server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AASjD,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;AAI9C,MAAM,WAAW,OAAO;IACtB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,aAAa,IAAI,IAAI,CAAC,MAAM,CAAC;CAC9B;AA2ND;;;GAGG;AACH,eAAO,MAAM,MAAM;IACjB;;OAEG;gBACS,YAAY,SAAS,MAAM,SAAS,MAAM,GAAG,OAAO;EA8BhE,CAAC;AAEH,eAAe,MAAM,CAAC"}
@@ -2,6 +2,7 @@
2
2
  * Server - HTTP Server implementation
3
3
  * Uses Node.js built-in HTTP server with no external dependencies
4
4
  */
5
+ import { esmDirname } from '../common/index';
5
6
  import { appConfig } from '../config/app';
6
7
  import { HTTP_HEADERS, MIME_TYPES } from '../config/constants';
7
8
  import { Logger } from '../config/logger';
@@ -11,7 +12,6 @@ import { Response } from '../http/Response';
11
12
  import * as fs from '../node-singletons/fs';
12
13
  import * as http from '../node-singletons/http';
13
14
  import * as path from '../node-singletons/path';
14
- import { fileURLToPath } from '../node-singletons/url';
15
15
  import { Router } from '../routing/Router';
16
16
  const MIME_TYPES_MAP = {
17
17
  '.html': MIME_TYPES.HTML,
@@ -43,8 +43,7 @@ const findPackageRoot = (startDir) => {
43
43
  return startDir;
44
44
  };
45
45
  const getFrameworkPublicRoots = () => {
46
- const thisFile = fileURLToPath(import.meta.url);
47
- const thisDir = path.dirname(thisFile);
46
+ const thisDir = esmDirname(import.meta.url);
48
47
  const packageRoot = findPackageRoot(thisDir);
49
48
  return [
50
49
  path.join(packageRoot, 'dist/public'),
@@ -53,7 +52,7 @@ const getFrameworkPublicRoots = () => {
53
52
  ];
54
53
  };
55
54
  const getDocsPublicRoot = () => {
56
- const isProduction = process.env.NODE_ENV === 'production';
55
+ const isProduction = appConfig.isProduction();
57
56
  // First try app-local roots (developer app override), then fall back to framework-shipped assets.
58
57
  const appRoots = isProduction
59
58
  ? [path.join(process.cwd(), 'public')]
@@ -8,6 +8,48 @@ import { Server } from './Server';
8
8
  import { Env } from '../config/env';
9
9
  import { Logger } from '../config/logger';
10
10
  import { ErrorFactory } from '../exceptions/ZintrustError';
11
+ let appInstance;
12
+ let serverInstance;
13
+ let isShuttingDown = false;
14
+ const withTimeout = async (promise, timeoutMs, label) => {
15
+ if (timeoutMs <= 0)
16
+ return promise;
17
+ let timeoutId;
18
+ try {
19
+ const timeoutPromise = new Promise((_, reject) => {
20
+ timeoutId = globalThis.setTimeout(() => {
21
+ reject(ErrorFactory.createGeneralError(label, { timeoutMs }));
22
+ }, timeoutMs);
23
+ });
24
+ return await Promise.race([promise, timeoutPromise]);
25
+ }
26
+ finally {
27
+ if (timeoutId !== undefined)
28
+ globalThis.clearTimeout(timeoutId);
29
+ }
30
+ };
31
+ const gracefulShutdown = async (signal) => {
32
+ if (isShuttingDown)
33
+ return;
34
+ isShuttingDown = true;
35
+ const timeoutMs = Number(Env.SHUTDOWN_TIMEOUT);
36
+ Logger.info(`${signal} received, shutting down gracefully...`);
37
+ try {
38
+ await withTimeout((async () => {
39
+ if (serverInstance !== undefined) {
40
+ await serverInstance.close();
41
+ }
42
+ if (appInstance !== undefined) {
43
+ await appInstance.shutdown();
44
+ }
45
+ })(), timeoutMs, 'Graceful shutdown timed out');
46
+ process.exit(0);
47
+ }
48
+ catch (error) {
49
+ Logger.error('Graceful shutdown failed:', error);
50
+ process.exit(1);
51
+ }
52
+ };
11
53
  /**
12
54
  * Bootstrap implementation
13
55
  */
@@ -19,6 +61,7 @@ const BootstrapFunctions = Object.freeze({
19
61
  try {
20
62
  // Create application instance
21
63
  const app = Application.create();
64
+ appInstance = app;
22
65
  // Boot application
23
66
  await app.boot();
24
67
  // Get port and host from environment
@@ -26,9 +69,39 @@ const BootstrapFunctions = Object.freeze({
26
69
  const host = Env.get('HOST', 'localhost');
27
70
  // Create and start server
28
71
  const server = Server.create(app, port, host);
72
+ serverInstance = server;
29
73
  // Start listening
30
74
  await server.listen();
31
75
  Logger.info(`Server running at http://${host}:${port}`);
76
+ // Start schedules for long-running runtimes (Node.js / Fargate)
77
+ try {
78
+ const runtime = (await import('../runtime/RuntimeDetector')).RuntimeDetector.detectRuntime();
79
+ if (runtime === 'nodejs' || runtime === 'fargate') {
80
+ const { create: createScheduleRunner } = await import('../scheduler/ScheduleRunner');
81
+ const schedules = await import('../schedules');
82
+ const runner = createScheduleRunner();
83
+ for (const schedule of Object.values(schedules)) {
84
+ // Each schedule is expected to export a default ISchedule
85
+ // @ts-ignore
86
+ runner.register(schedule);
87
+ }
88
+ runner.start();
89
+ // Add shutdown hook to stop schedules gracefully
90
+ const shutdownManager = app.getContainer().get('shutdownManager');
91
+ if ((typeof shutdownManager === 'object' || typeof shutdownManager === 'function') &&
92
+ shutdownManager !== null &&
93
+ 'add' in shutdownManager &&
94
+ typeof shutdownManager.add === 'function') {
95
+ shutdownManager.add(async () => {
96
+ const scheduleTimeoutMs = Env.getInt('SCHEDULE_SHUTDOWN_TIMEOUT_MS', 30000);
97
+ await runner.stop(scheduleTimeoutMs);
98
+ });
99
+ }
100
+ }
101
+ }
102
+ catch (err) {
103
+ Logger.warn('Failed to start schedules:', err);
104
+ }
32
105
  }
33
106
  catch (error) {
34
107
  Logger.error('Failed to bootstrap application:', error);
@@ -40,13 +113,11 @@ const BootstrapFunctions = Object.freeze({
40
113
  * Handle graceful shutdown
41
114
  */
42
115
  setupShutdownHandler() {
43
- process.on('SIGTERM', () => {
44
- Logger.info('SIGTERM received, shutting down gracefully...');
45
- process.exit(0);
116
+ process.on('SIGTERM', async () => {
117
+ await gracefulShutdown('SIGTERM');
46
118
  });
47
- process.on('SIGINT', () => {
48
- Logger.info('SIGINT received, shutting down gracefully...');
49
- process.exit(0);
119
+ process.on('SIGINT', async () => {
120
+ await gracefulShutdown('SIGINT');
50
121
  });
51
122
  },
52
123
  });
@@ -1 +1 @@
1
- {"version":3,"file":"BundleOptimizer.d.ts","sourceRoot":"","sources":["../../../src/builder/BundleOptimizer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,QAAQ,GAAG,YAAY,GAAG,MAAM,GAAG,SAAS,CAAC;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;IACH,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC;CACrC;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe;IAC1B;;OAEG;oBACa,mBAAmB,GAAG,gBAAgB;EA0CtD,CAAC;AAyXH;;GAEG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAclD"}
1
+ {"version":3,"file":"BundleOptimizer.d.ts","sourceRoot":"","sources":["../../../src/builder/BundleOptimizer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,QAAQ,GAAG,YAAY,GAAG,MAAM,GAAG,SAAS,CAAC;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;IACH,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC;CACrC;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe;IAC1B;;OAEG;oBACa,mBAAmB,GAAG,gBAAgB;EA0CtD,CAAC;AA4XH;;GAEG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAclD"}
@@ -8,7 +8,7 @@
8
8
  */
9
9
  import { Logger } from '../config/logger';
10
10
  import fs from '../node-singletons/fs';
11
- import * as path from 'node:path';
11
+ import * as path from '../node-singletons/path';
12
12
  /**
13
13
  * Bundle optimizer - reduces deployed package size
14
14
  * Sealed namespace for immutability
@@ -125,17 +125,19 @@ function printAnalysis(analysis) {
125
125
  */
126
126
  async function analyze(distDir, options) {
127
127
  const files = await getFilesRecursive(distDir);
128
- let totalSize = 0;
128
+ // Collect sizes concurrently but avoid shared mutable state by computing sizes
129
+ // and then reducing the total afterwards to avoid race conditions.
129
130
  const fileAnalysis = await Promise.all(files.map(async (file) => {
130
131
  const stats = await fs.promises.stat(file);
131
132
  const size = stats.size;
132
- totalSize += size;
133
133
  return {
134
134
  path: path.relative(distDir, file),
135
135
  size,
136
136
  percentage: 0,
137
137
  };
138
138
  }));
139
+ // Compute total size in a single pass (no shared mutation)
140
+ const totalSize = fileAnalysis.reduce((acc, f) => acc + f.size, 0);
139
141
  // Calculate percentages
140
142
  fileAnalysis.forEach((f) => {
141
143
  f.percentage = totalSize > 0 ? (f.size / totalSize) * 100 : 0;
@@ -198,12 +200,12 @@ async function removeDevDependencies(distDir, options) {
198
200
  /**
199
201
  * Minify JavaScript files
200
202
  */
203
+ // eslint-disable-next-line @typescript-eslint/require-await
201
204
  async function minifyJavaScript(_aggressive = false) {
202
205
  Logger.info(' → Minifying JavaScript...');
203
206
  // In production, would use esbuild or terser
204
207
  // This is a placeholder showing the pattern
205
208
  Logger.info(' ✓ JavaScript minified');
206
- return Promise.resolve();
207
209
  }
208
210
  /**
209
211
  * Remove a specific module
@@ -1 +1 @@
1
- {"version":3,"file":"KVDriver.d.ts","sourceRoot":"","sources":["../../../../src/cache/drivers/KVDriver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAiEjD;;GAEG;AACH,eAAO,MAAM,QAAQ;kBAjDF,WAAW;EAmD5B,CAAC"}
1
+ {"version":3,"file":"KVDriver.d.ts","sourceRoot":"","sources":["../../../../src/cache/drivers/KVDriver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAoDjD;;GAEG;AACH,eAAO,MAAM,QAAQ;kBAhDF,WAAW;EAkD5B,CAAC"}
@@ -2,23 +2,23 @@
2
2
  * Cloudflare KV Cache Driver
3
3
  * Interfaces with the native KV binding in Cloudflare Workers
4
4
  */
5
+ import { Cloudflare } from '../../config/cloudflare';
5
6
  import { Logger } from '../../config/logger';
6
7
  /**
7
8
  * Create a new KV driver instance
8
9
  */
9
10
  const create = () => {
10
11
  // In Cloudflare Workers, the KV namespace is usually bound to a variable in the environment
11
- const env = globalThis['env'];
12
- const kv = env === undefined ? undefined : env['CACHE'];
12
+ const kv = Cloudflare.getKVBinding('CACHE');
13
13
  return {
14
14
  async get(key) {
15
- if (kv === undefined)
15
+ if (kv === null)
16
16
  return null;
17
17
  const value = await kv.get(key, { type: 'json' });
18
18
  return value ?? null;
19
19
  },
20
20
  async set(key, value, ttl) {
21
- if (kv === undefined) {
21
+ if (kv === null) {
22
22
  Logger.warn('KV binding "CACHE" not found. Cache set ignored.');
23
23
  return;
24
24
  }
@@ -30,7 +30,7 @@ const create = () => {
30
30
  await kv.put(key, JSON.stringify(value), options);
31
31
  },
32
32
  async delete(key) {
33
- if (kv === undefined)
33
+ if (kv === null)
34
34
  return;
35
35
  await kv.delete(key);
36
36
  },
@@ -40,7 +40,7 @@ const create = () => {
40
40
  await Promise.resolve();
41
41
  },
42
42
  async has(key) {
43
- if (kv === undefined)
43
+ if (kv === null)
44
44
  return false;
45
45
  const value = await kv.get(key);
46
46
  return value !== null;
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { Env } from '../../config/env';
6
6
  import { Logger } from '../../config/logger';
7
- import * as net from 'node:net';
7
+ import * as net from '../../node-singletons/net';
8
8
  /**
9
9
  * Create a new Redis driver instance
10
10
  */
@@ -29,11 +29,11 @@ export declare const BaseCommand: Readonly<{
29
29
  /**
30
30
  * Create a command instance with common logic
31
31
  */
32
- create(config: {
32
+ create<T extends IBaseCommand = IBaseCommand>(config: {
33
33
  name: string;
34
34
  description: string;
35
35
  addOptions?: (command: Command) => void;
36
36
  execute: (options: CommandOptions) => void | Promise<void>;
37
- }): IBaseCommand;
37
+ }): T;
38
38
  }>;
39
39
  //# sourceMappingURL=BaseCommand.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseCommand.d.ts","sourceRoot":"","sources":["../../../src/cli/BaseCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,IAAI,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CAC/B;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW;IACtB;;OAEG;mBACY;QACb,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;QACxC,OAAO,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KAC5D,GAAG,YAAY;EA+ChB,CAAC"}
1
+ {"version":3,"file":"BaseCommand.d.ts","sourceRoot":"","sources":["../../../src/cli/BaseCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,IAAI,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CAC/B;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW;IACtB;;OAEG;WACI,CAAC,SAAS,YAAY,yBAAyB;QACpD,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;QACxC,OAAO,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KAC5D,GAAG,CAAC;EAiDL,CAAC"}
@@ -42,7 +42,7 @@ export const BaseCommand = Object.freeze({
42
42
  });
43
43
  return command;
44
44
  };
45
- return {
45
+ const base = {
46
46
  name: config.name,
47
47
  description: config.description,
48
48
  verbose: false,
@@ -54,5 +54,6 @@ export const BaseCommand = Object.freeze({
54
54
  warn: (msg) => ErrorHandler.warn(msg),
55
55
  debug: (msg) => ErrorHandler.debug(msg, true),
56
56
  };
57
+ return base;
57
58
  },
58
59
  });
@@ -1 +1 @@
1
- {"version":3,"file":"CLI.d.ts","sourceRoot":"","sources":["../../../src/cli/CLI.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAqBH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,MAAM,WAAW,IAAI;IACnB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,UAAU,IAAI,OAAO,CAAC;CACvB;AAiLD;;;;;;;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;AAyBH,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;AAqLD;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG;cACJ,IAAI;EAed,CAAC"}
package/src/cli/CLI.js CHANGED
@@ -8,22 +8,25 @@ import { D1MigrateCommand } from './commands/D1MigrateCommand';
8
8
  import { DebugCommand } from './commands/DebugCommand';
9
9
  import { FixCommand } from './commands/FixCommand';
10
10
  import { KeyGenerateCommand } from './commands/KeyGenerateCommand';
11
+ import { MakeMailTemplateCommand } from './commands/MakeMailTemplateCommand';
12
+ import { MakeNotificationTemplateCommand } from './commands/MakeNotificationTemplateCommand';
11
13
  import { MigrateCommand } from './commands/MigrateCommand';
12
14
  import { NewCommand } from './commands/NewCommand';
13
15
  import { PluginCommand } from './commands/PluginCommand';
14
16
  import { PrepareCommand } from './commands/PrepareCommand';
15
17
  import { QACommand } from './commands/QACommand';
18
+ import { SecretsCommand } from './commands/SecretsCommand';
16
19
  import { SimulateCommand } from './commands/SimulateCommand';
17
20
  import { StartCommand } from './commands/StartCommand';
21
+ import { TemplatesCommand } from './commands/TemplatesCommand';
18
22
  import { ErrorHandler } from './ErrorHandler';
23
+ import { esmDirname } from '../common/index';
19
24
  import { Logger } from '../config/logger';
20
25
  import { ErrorFactory } from '../exceptions/ZintrustError';
21
26
  import { readFileSync } from '../node-singletons/fs';
22
- import { dirname, join } from '../node-singletons/path';
23
- import { fileURLToPath } from '../node-singletons/url';
27
+ import { join } from '../node-singletons/path';
24
28
  import { Command } from 'commander';
25
- const __filename = fileURLToPath(import.meta.url);
26
- const __dirname = dirname(__filename);
29
+ const __dirname = esmDirname(import.meta.url);
27
30
  /**
28
31
  * CLI - Main CLI Class
29
32
  * Orchestrates all CLI commands using Commander
@@ -68,12 +71,16 @@ const registerCommands = (program) => {
68
71
  MigrateCommand.create(),
69
72
  D1MigrateCommand.create(),
70
73
  DebugCommand.create(),
74
+ SecretsCommand.create(),
71
75
  ConfigCommand.create(),
72
76
  PluginCommand.create(),
73
77
  QACommand(),
74
78
  FixCommand.create(),
75
79
  KeyGenerateCommand.create(),
76
80
  SimulateCommand,
81
+ TemplatesCommand,
82
+ MakeMailTemplateCommand.create(),
83
+ MakeNotificationTemplateCommand.create(),
77
84
  ];
78
85
  for (const command of commands) {
79
86
  program.addCommand(command.getCommand());
@@ -16,8 +16,8 @@ import { ServiceScaffolder } from '../scaffolding/ServiceScaffolder';
16
16
  import { WorkflowGenerator } from '../scaffolding/WorkflowGenerator';
17
17
  import { ErrorFactory } from '../../exceptions/ZintrustError';
18
18
  import fs from '../../node-singletons/fs';
19
+ import * as path from '../../node-singletons/path';
19
20
  import inquirer from 'inquirer';
20
- import * as path from 'node:path';
21
21
  const addOptions = (command) => {
22
22
  command
23
23
  .argument('<type>', 'What to add: service, feature, migration, model, controller, routes, factory, seeder, requestfactory, responsefactory, or workflow')
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/ConfigCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA+B,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA4T7E;;GAEG;AACH,eAAO,MAAM,aAAa;IACxB;;OAEG;cACO,YAAY;EAsEtB,CAAC"}
1
+ {"version":3,"file":"ConfigCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/ConfigCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA+B,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAiV7E;;GAEG;AACH,eAAO,MAAM,aAAa;IACxB;;OAEG;cACO,YAAY;EAsEtB,CAAC"}
@@ -19,6 +19,26 @@ const addOptions = (command) => {
19
19
  };
20
20
  const getGlobalConfigManager = async () => ConfigManager.getGlobalConfig();
21
21
  const getProjectConfigManager = async () => ConfigManager.getProjectConfig();
22
+ const toDisplayString = (value) => {
23
+ if (value === undefined || value === null)
24
+ return 'null';
25
+ if (typeof value === 'string')
26
+ return value;
27
+ if (typeof value === 'number' || typeof value === 'bigint')
28
+ return value.toString();
29
+ if (typeof value === 'boolean')
30
+ return value ? 'true' : 'false';
31
+ if (typeof value === 'symbol')
32
+ return value.toString();
33
+ if (typeof value === 'function')
34
+ return '[Function]';
35
+ try {
36
+ return JSON.stringify(value, null, 2);
37
+ }
38
+ catch {
39
+ return '[Unserializable]';
40
+ }
41
+ };
22
42
  const formatConfigValue = (value) => {
23
43
  if (value === undefined || value === null)
24
44
  return chalk.gray('null');
@@ -28,7 +48,15 @@ const formatConfigValue = (value) => {
28
48
  return value ? chalk.green('true') : chalk.red('false');
29
49
  if (typeof value === 'number')
30
50
  return chalk.yellow(value.toString());
31
- return String(value);
51
+ if (typeof value === 'string')
52
+ return value;
53
+ if (typeof value === 'bigint')
54
+ return chalk.yellow(value.toString());
55
+ if (typeof value === 'symbol')
56
+ return chalk.gray(value.toString());
57
+ if (typeof value === 'function')
58
+ return chalk.gray('[Function]');
59
+ return chalk.gray(toDisplayString(value));
32
60
  };
33
61
  const parseConfigValue = (value) => {
34
62
  if (value === undefined)
@@ -67,8 +95,8 @@ const displayValidationStatus = (cmd, config) => {
67
95
  cmd.info(chalk.red(` ❌ Configuration has ${errors.length} errors:`));
68
96
  for (const error of errors) {
69
97
  const message = error !== null && typeof error === 'object' && 'message' in error
70
- ? String(error.message)
71
- : String(error);
98
+ ? toDisplayString(error.message)
99
+ : toDisplayString(error);
72
100
  cmd.info(chalk.red(` - ${message}`));
73
101
  }
74
102
  };
@@ -151,7 +179,9 @@ const editSingleConfig = async (cmd, manager, selectedKey) => {
151
179
  let defaultValue = '';
152
180
  if (currentValue !== undefined) {
153
181
  defaultValue =
154
- typeof currentValue === 'object' ? JSON.stringify(currentValue) : String(currentValue);
182
+ typeof currentValue === 'object'
183
+ ? JSON.stringify(currentValue)
184
+ : toDisplayString(currentValue);
155
185
  }
156
186
  const newValue = await PromptHelper.textInput(`Enter new value for "${selectedKey}":`, defaultValue);
157
187
  if (newValue === undefined)
@@ -1,3 +1,7 @@
1
+ /**
2
+ * D1 Migrate Command
3
+ * Run Cloudflare D1 migrations using Wrangler
4
+ */
1
5
  import { IBaseCommand } from '../BaseCommand';
2
6
  /**
3
7
  * D1 Migrate Command
@@ -1 +1 @@
1
- {"version":3,"file":"D1MigrateCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/D1MigrateCommand.ts"],"names":[],"mappings":"AAMA,OAAO,EAA+B,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAmD7E;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,gBAAgB;IAC3B;;OAEG;cACO,YAAY;EAqBtB,CAAC"}
1
+ {"version":3,"file":"D1MigrateCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/D1MigrateCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAA+B,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAsD7E;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,gBAAgB;IAC3B;;OAEG;cACO,YAAY;EAqBtB,CAAC"}