@zintrust/core 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (518) hide show
  1. package/README.md +214 -0
  2. package/bin/zintrust.d.ts.map +1 -1
  3. package/bin/zintrust.js +18 -1
  4. package/package.json +4 -34
  5. package/public/index.html +535 -0
  6. package/src/boot/Application.d.ts.map +1 -1
  7. package/src/boot/Application.js +46 -3
  8. package/src/boot/Server.d.ts.map +1 -1
  9. package/src/boot/Server.js +3 -4
  10. package/src/boot/bootstrap.js +77 -6
  11. package/src/builder/BundleOptimizer.d.ts.map +1 -1
  12. package/src/builder/BundleOptimizer.js +25 -29
  13. package/src/cache/Cache.d.ts.map +1 -1
  14. package/src/cache/Cache.js +4 -2
  15. package/src/cache/drivers/KVDriver.d.ts.map +1 -1
  16. package/src/cache/drivers/KVDriver.js +8 -7
  17. package/src/cache/drivers/MemoryDriver.d.ts.map +1 -1
  18. package/src/cache/drivers/MemoryDriver.js +5 -0
  19. package/src/cache/drivers/RedisDriver.js +1 -1
  20. package/src/cli/BaseCommand.d.ts +2 -2
  21. package/src/cli/BaseCommand.d.ts.map +1 -1
  22. package/src/cli/BaseCommand.js +2 -1
  23. package/src/cli/CLI.d.ts.map +1 -1
  24. package/src/cli/CLI.js +22 -18
  25. package/src/cli/ErrorHandler.d.ts.map +1 -1
  26. package/src/cli/ErrorHandler.js +2 -4
  27. package/src/cli/commands/AddCommand.d.ts +81 -0
  28. package/src/cli/commands/AddCommand.d.ts.map +1 -1
  29. package/src/cli/commands/AddCommand.js +24 -5
  30. package/src/cli/commands/ConfigCommand.d.ts.map +1 -1
  31. package/src/cli/commands/ConfigCommand.js +59 -25
  32. package/src/cli/commands/D1MigrateCommand.d.ts +4 -0
  33. package/src/cli/commands/D1MigrateCommand.d.ts.map +1 -1
  34. package/src/cli/commands/D1MigrateCommand.js +6 -4
  35. package/src/cli/commands/FixCommand.d.ts.map +1 -1
  36. package/src/cli/commands/FixCommand.js +3 -15
  37. package/src/cli/commands/LogsCleanupCommand.d.ts +6 -0
  38. package/src/cli/commands/LogsCleanupCommand.d.ts.map +1 -0
  39. package/src/cli/commands/LogsCleanupCommand.js +20 -0
  40. package/src/cli/commands/LogsCommand.d.ts.map +1 -1
  41. package/src/cli/commands/LogsCommand.js +4 -6
  42. package/src/cli/commands/MakeMailTemplateCommand.d.ts +10 -0
  43. package/src/cli/commands/MakeMailTemplateCommand.d.ts.map +1 -0
  44. package/src/cli/commands/MakeMailTemplateCommand.js +74 -0
  45. package/src/cli/commands/MakeNotificationTemplateCommand.d.ts +10 -0
  46. package/src/cli/commands/MakeNotificationTemplateCommand.d.ts.map +1 -0
  47. package/src/cli/commands/MakeNotificationTemplateCommand.js +113 -0
  48. package/src/cli/commands/MigrateCommand.d.ts.map +1 -1
  49. package/src/cli/commands/MigrateCommand.js +3 -3
  50. package/src/cli/commands/NewCommand.d.ts +4 -0
  51. package/src/cli/commands/NewCommand.d.ts.map +1 -1
  52. package/src/cli/commands/NewCommand.js +34 -19
  53. package/src/cli/commands/PluginCommand.d.ts.map +1 -1
  54. package/src/cli/commands/PluginCommand.js +8 -4
  55. package/src/cli/commands/PrepareCommand.d.ts.map +1 -1
  56. package/src/cli/commands/PrepareCommand.js +1 -1
  57. package/src/cli/commands/QACommand.d.ts.map +1 -1
  58. package/src/cli/commands/QACommand.js +16 -26
  59. package/src/cli/commands/SecretsCommand.d.ts +16 -0
  60. package/src/cli/commands/SecretsCommand.d.ts.map +1 -0
  61. package/src/cli/commands/SecretsCommand.js +91 -0
  62. package/src/cli/commands/StartCommand.d.ts.map +1 -1
  63. package/src/cli/commands/StartCommand.js +2 -2
  64. package/src/cli/commands/TemplatesCommand.d.ts +3 -0
  65. package/src/cli/commands/TemplatesCommand.d.ts.map +1 -0
  66. package/src/cli/commands/TemplatesCommand.js +65 -0
  67. package/src/cli/commands/index.d.ts +5 -0
  68. package/src/cli/commands/index.d.ts.map +1 -1
  69. package/src/cli/commands/index.js +5 -0
  70. package/src/cli/config/ConfigManager.js +1 -1
  71. package/src/cli/index.d.ts +2 -1
  72. package/src/cli/index.d.ts.map +1 -1
  73. package/src/cli/index.js +2 -1
  74. package/src/cli/scaffolding/ControllerGenerator.d.ts.map +1 -1
  75. package/src/cli/scaffolding/ControllerGenerator.js +11 -10
  76. package/src/cli/scaffolding/FeatureScaffolder.js +4 -4
  77. package/src/cli/scaffolding/FileGenerator.js +1 -1
  78. package/src/cli/scaffolding/MigrationGenerator.d.ts.map +1 -1
  79. package/src/cli/scaffolding/MigrationGenerator.js +10 -9
  80. package/src/cli/scaffolding/ModelGenerator.d.ts.map +1 -1
  81. package/src/cli/scaffolding/ModelGenerator.js +11 -10
  82. package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
  83. package/src/cli/scaffolding/ProjectScaffolder.js +61 -11
  84. package/src/cli/scaffolding/ResponseFactoryGenerator.d.ts.map +1 -1
  85. package/src/cli/scaffolding/ResponseFactoryGenerator.js +2 -1
  86. package/src/cli/scaffolding/RouteGenerator.d.ts.map +1 -1
  87. package/src/cli/scaffolding/RouteGenerator.js +15 -14
  88. package/src/cli/scaffolding/SeederGenerator.js +1 -1
  89. package/src/cli/scaffolding/ServiceIntegrationTestGenerator.d.ts.map +1 -1
  90. package/src/cli/scaffolding/ServiceIntegrationTestGenerator.js +7 -6
  91. package/src/cli/scaffolding/ServiceRequestFactoryGenerator.d.ts +1 -1
  92. package/src/cli/scaffolding/ServiceRequestFactoryGenerator.d.ts.map +1 -1
  93. package/src/cli/scaffolding/ServiceRequestFactoryGenerator.js +2 -2
  94. package/src/cli/scaffolding/ServiceScaffolder.d.ts.map +1 -1
  95. package/src/cli/scaffolding/ServiceScaffolder.js +13 -12
  96. package/src/cli/scaffolding/TemplateEngine.d.ts +10 -3
  97. package/src/cli/scaffolding/TemplateEngine.d.ts.map +1 -1
  98. package/src/cli/scaffolding/TemplateEngine.js +15 -285
  99. package/src/cli/scaffolding/TemplateGenerator.d.ts +40 -0
  100. package/src/cli/scaffolding/TemplateGenerator.d.ts.map +1 -0
  101. package/src/cli/scaffolding/TemplateGenerator.js +172 -0
  102. package/src/cli/scaffolding/index.d.ts +1 -0
  103. package/src/cli/scaffolding/index.d.ts.map +1 -1
  104. package/src/cli/scaffolding/index.js +1 -0
  105. package/src/cli/utils/spawn.js +1 -1
  106. package/src/common/AwsSigV4.d.ts +41 -0
  107. package/src/common/AwsSigV4.d.ts.map +1 -0
  108. package/src/common/AwsSigV4.js +69 -0
  109. package/src/common/index.d.ts +39 -0
  110. package/src/common/index.d.ts.map +1 -1
  111. package/src/common/index.js +101 -8
  112. package/src/common/uuid.d.ts +3 -0
  113. package/src/common/uuid.d.ts.map +1 -0
  114. package/src/common/uuid.js +30 -0
  115. package/src/config/FileLogWriter.d.ts +22 -0
  116. package/src/config/FileLogWriter.d.ts.map +1 -0
  117. package/src/config/FileLogWriter.js +192 -0
  118. package/src/config/SecretsManager.d.ts.map +1 -1
  119. package/src/config/SecretsManager.js +26 -0
  120. package/src/config/StartupConfigValidator.d.ts +15 -0
  121. package/src/config/StartupConfigValidator.d.ts.map +1 -0
  122. package/src/config/StartupConfigValidator.js +86 -0
  123. package/src/config/app.d.ts +2 -1
  124. package/src/config/app.d.ts.map +1 -1
  125. package/src/config/app.js +65 -15
  126. package/src/config/broadcast.d.ts +47 -0
  127. package/src/config/broadcast.d.ts.map +1 -0
  128. package/src/config/broadcast.js +54 -0
  129. package/src/config/cache.d.ts +13 -17
  130. package/src/config/cache.d.ts.map +1 -1
  131. package/src/config/cache.js +9 -11
  132. package/src/config/cloudflare.d.ts +26 -0
  133. package/src/config/cloudflare.d.ts.map +1 -0
  134. package/src/config/cloudflare.js +38 -0
  135. package/src/config/env.d.ts +6 -0
  136. package/src/config/env.d.ts.map +1 -1
  137. package/src/config/env.js +6 -0
  138. package/src/config/index.d.ts +52 -28
  139. package/src/config/index.d.ts.map +1 -1
  140. package/src/config/index.js +3 -0
  141. package/src/config/logger.d.ts +2 -0
  142. package/src/config/logger.d.ts.map +1 -1
  143. package/src/config/logger.js +270 -11
  144. package/src/config/logging/HttpLogger.d.ts +23 -0
  145. package/src/config/logging/HttpLogger.d.ts.map +1 -0
  146. package/src/config/logging/HttpLogger.js +93 -0
  147. package/src/config/logging/KvLogger.d.ts +22 -0
  148. package/src/config/logging/KvLogger.d.ts.map +1 -0
  149. package/src/config/logging/KvLogger.js +143 -0
  150. package/src/config/logging/SlackLogger.d.ts +23 -0
  151. package/src/config/logging/SlackLogger.d.ts.map +1 -0
  152. package/src/config/logging/SlackLogger.js +119 -0
  153. package/src/config/mail.d.ts +81 -0
  154. package/src/config/mail.d.ts.map +1 -0
  155. package/src/config/mail.js +73 -0
  156. package/src/config/middleware.d.ts +8 -0
  157. package/src/config/middleware.d.ts.map +1 -0
  158. package/src/config/middleware.js +18 -0
  159. package/src/config/notification.d.ts +62 -0
  160. package/src/config/notification.d.ts.map +1 -0
  161. package/src/config/notification.js +43 -0
  162. package/src/config/security.d.ts.map +1 -1
  163. package/src/config/security.js +2 -2
  164. package/src/config/startup.d.ts +23 -0
  165. package/src/config/startup.d.ts.map +1 -0
  166. package/src/config/startup.js +15 -0
  167. package/src/config/storage.d.ts +21 -35
  168. package/src/config/storage.d.ts.map +1 -1
  169. package/src/config/storage.js +57 -37
  170. package/src/database/migrations/index.d.ts +1 -1
  171. package/src/database/migrations/index.d.ts.map +1 -1
  172. package/src/database/migrations/index.js +2 -1
  173. package/src/features/Queue.js +1 -25
  174. package/src/functions/lambda.d.ts.map +1 -1
  175. package/src/functions/lambda.js +6 -1
  176. package/src/health/RuntimeHealthProbes.d.ts +13 -0
  177. package/src/health/RuntimeHealthProbes.d.ts.map +1 -0
  178. package/src/health/RuntimeHealthProbes.js +62 -0
  179. package/src/health/StartupHealthChecks.d.ts +26 -0
  180. package/src/health/StartupHealthChecks.d.ts.map +1 -0
  181. package/src/health/StartupHealthChecks.js +124 -0
  182. package/src/http/ErrorResponse.d.ts +28 -0
  183. package/src/http/ErrorResponse.d.ts.map +1 -0
  184. package/src/http/ErrorResponse.js +42 -0
  185. package/src/http/Kernel.d.ts +5 -0
  186. package/src/http/Kernel.d.ts.map +1 -1
  187. package/src/http/Kernel.js +96 -30
  188. package/src/http/Request.d.ts +1 -1
  189. package/src/http/Request.d.ts.map +1 -1
  190. package/src/http/RequestContext.d.ts +20 -0
  191. package/src/http/RequestContext.d.ts.map +1 -0
  192. package/src/http/RequestContext.js +77 -0
  193. package/src/index.d.ts +9 -1
  194. package/src/index.d.ts.map +1 -1
  195. package/src/index.js +8 -2
  196. package/src/microservices/MicroserviceBootstrap.d.ts.map +1 -1
  197. package/src/microservices/MicroserviceBootstrap.js +6 -5
  198. package/src/microservices/MicroserviceManager.d.ts.map +1 -1
  199. package/src/microservices/MicroserviceManager.js +7 -5
  200. package/src/microservices/PostgresAdapter.d.ts.map +1 -1
  201. package/src/microservices/PostgresAdapter.js +7 -4
  202. package/src/microservices/ServiceBundler.d.ts.map +1 -1
  203. package/src/microservices/ServiceBundler.js +3 -1
  204. package/src/microservices/ServiceHealthMonitor.d.ts.map +1 -1
  205. package/src/microservices/ServiceHealthMonitor.js +7 -3
  206. package/src/middleware/CsrfMiddleware.d.ts.map +1 -1
  207. package/src/middleware/CsrfMiddleware.js +2 -19
  208. package/src/middleware/ErrorHandlerMiddleware.d.ts +6 -0
  209. package/src/middleware/ErrorHandlerMiddleware.d.ts.map +1 -0
  210. package/src/middleware/ErrorHandlerMiddleware.js +33 -0
  211. package/src/middleware/LoggingMiddleware.d.ts +9 -0
  212. package/src/middleware/LoggingMiddleware.d.ts.map +1 -0
  213. package/src/middleware/LoggingMiddleware.js +36 -0
  214. package/src/middleware/index.d.ts +2 -0
  215. package/src/middleware/index.d.ts.map +1 -1
  216. package/src/middleware/index.js +2 -0
  217. package/src/node-singletons/async_hooks.d.ts +9 -0
  218. package/src/node-singletons/async_hooks.d.ts.map +1 -0
  219. package/src/node-singletons/async_hooks.js +8 -0
  220. package/src/node-singletons/fs.d.ts +2 -2
  221. package/src/node-singletons/fs.d.ts.map +1 -1
  222. package/src/node-singletons/fs.js +2 -2
  223. package/src/node-singletons/http.d.ts +1 -1
  224. package/src/node-singletons/http.d.ts.map +1 -1
  225. package/src/node-singletons/http.js +1 -1
  226. package/src/node-singletons/index.d.ts +4 -0
  227. package/src/node-singletons/index.d.ts.map +1 -1
  228. package/src/node-singletons/index.js +4 -0
  229. package/src/node-singletons/net.d.ts +9 -0
  230. package/src/node-singletons/net.d.ts.map +1 -0
  231. package/src/node-singletons/net.js +8 -0
  232. package/src/node-singletons/os.d.ts +3 -3
  233. package/src/node-singletons/os.d.ts.map +1 -1
  234. package/src/node-singletons/os.js +3 -4
  235. package/src/node-singletons/path.d.ts +3 -1
  236. package/src/node-singletons/path.d.ts.map +1 -1
  237. package/src/node-singletons/path.js +3 -1
  238. package/src/node-singletons/perf-hooks.d.ts +3 -1
  239. package/src/node-singletons/perf-hooks.d.ts.map +1 -1
  240. package/src/node-singletons/perf-hooks.js +3 -1
  241. package/src/node-singletons/process.d.ts +23 -0
  242. package/src/node-singletons/process.d.ts.map +1 -0
  243. package/src/node-singletons/process.js +8 -0
  244. package/src/node-singletons/readline.d.ts +3 -3
  245. package/src/node-singletons/readline.d.ts.map +1 -1
  246. package/src/node-singletons/readline.js +3 -4
  247. package/src/node-singletons/tls.d.ts +9 -0
  248. package/src/node-singletons/tls.d.ts.map +1 -0
  249. package/src/node-singletons/tls.js +8 -0
  250. package/src/node-singletons/url.d.ts +3 -1
  251. package/src/node-singletons/url.d.ts.map +1 -1
  252. package/src/node-singletons/url.js +3 -1
  253. package/src/orm/ConnectionManager.d.ts +6 -1
  254. package/src/orm/ConnectionManager.d.ts.map +1 -1
  255. package/src/orm/ConnectionManager.js +14 -0
  256. package/src/orm/DatabaseAdapter.d.ts +6 -0
  257. package/src/orm/DatabaseAdapter.d.ts.map +1 -1
  258. package/src/orm/QueryBuilder.d.ts +8 -1
  259. package/src/orm/QueryBuilder.d.ts.map +1 -1
  260. package/src/orm/QueryBuilder.js +188 -28
  261. package/src/orm/adapters/D1Adapter.d.ts.map +1 -1
  262. package/src/orm/adapters/D1Adapter.js +18 -12
  263. package/src/orm/adapters/MySQLAdapter.d.ts.map +1 -1
  264. package/src/orm/adapters/MySQLAdapter.js +4 -0
  265. package/src/orm/adapters/PostgreSQLAdapter.d.ts.map +1 -1
  266. package/src/orm/adapters/PostgreSQLAdapter.js +4 -0
  267. package/src/orm/adapters/SQLServerAdapter.d.ts.map +1 -1
  268. package/src/orm/adapters/SQLServerAdapter.js +4 -0
  269. package/src/orm/adapters/SQLiteAdapter.d.ts.map +1 -1
  270. package/src/orm/adapters/SQLiteAdapter.js +4 -0
  271. package/src/performance/Benchmark.d.ts.map +1 -1
  272. package/src/performance/Benchmark.js +3 -0
  273. package/src/performance/CodeGenerationBenchmark.js +3 -3
  274. package/src/performance/Optimizer.d.ts +1 -1
  275. package/src/performance/Optimizer.d.ts.map +1 -1
  276. package/src/performance/Optimizer.js +157 -80
  277. package/src/performance/establish-baseline.js +3 -3
  278. package/src/runtime/PluginManager.d.ts +3 -1
  279. package/src/runtime/PluginManager.d.ts.map +1 -1
  280. package/src/runtime/PluginManager.js +124 -28
  281. package/src/runtime/RuntimeDetector.d.ts.map +1 -1
  282. package/src/runtime/RuntimeDetector.js +47 -5
  283. package/src/runtime/adapters/CloudflareAdapter.js +2 -2
  284. package/src/runtime/adapters/DenoAdapter.js +9 -7
  285. package/src/runtime/adapters/FargateAdapter.d.ts.map +1 -1
  286. package/src/runtime/adapters/FargateAdapter.js +4 -3
  287. package/src/runtime/adapters/LambdaAdapter.d.ts.map +1 -1
  288. package/src/runtime/adapters/LambdaAdapter.js +4 -2
  289. package/src/runtime/adapters/NodeServerAdapter.d.ts.map +1 -1
  290. package/src/runtime/adapters/NodeServerAdapter.js +7 -6
  291. package/src/scheduler/ScheduleRunner.d.ts +18 -0
  292. package/src/scheduler/ScheduleRunner.d.ts.map +1 -0
  293. package/src/scheduler/ScheduleRunner.js +155 -0
  294. package/src/scheduler/index.d.ts +3 -0
  295. package/src/scheduler/index.d.ts.map +1 -0
  296. package/src/scheduler/index.js +1 -0
  297. package/src/scheduler/types.d.ts +16 -0
  298. package/src/scheduler/types.d.ts.map +1 -0
  299. package/src/scheduler/types.js +4 -0
  300. package/src/schedules/index.d.ts +2 -0
  301. package/src/schedules/index.d.ts.map +1 -0
  302. package/src/schedules/index.js +1 -0
  303. package/src/schedules/log-cleanup.d.ts +4 -0
  304. package/src/schedules/log-cleanup.d.ts.map +1 -0
  305. package/src/schedules/log-cleanup.js +18 -0
  306. package/src/scripts/GenerateEnvArtifacts.d.ts +13 -0
  307. package/src/scripts/GenerateEnvArtifacts.d.ts.map +1 -0
  308. package/src/scripts/GenerateEnvArtifacts.js +171 -0
  309. package/src/scripts/TemplateSync.js +109 -70
  310. package/src/security/CsrfTokenManager.js +1 -1
  311. package/src/security/Encryptor.js +1 -1
  312. package/src/security/Hash.d.ts +14 -0
  313. package/src/security/Hash.d.ts.map +1 -0
  314. package/src/security/Hash.js +81 -0
  315. package/src/security/StartupSecretValidation.d.ts +20 -0
  316. package/src/security/StartupSecretValidation.d.ts.map +1 -0
  317. package/src/security/StartupSecretValidation.js +61 -0
  318. package/src/security/UrlValidator.d.ts +0 -1
  319. package/src/security/UrlValidator.d.ts.map +1 -1
  320. package/src/security/UrlValidator.js +1 -2
  321. package/src/security/Xss.d.ts +14 -0
  322. package/src/security/Xss.d.ts.map +1 -0
  323. package/src/security/Xss.js +57 -0
  324. package/src/security/XssProtection.d.ts.map +1 -1
  325. package/src/security/XssProtection.js +150 -16
  326. package/src/templates/adapters/MySQLAdapter.ts.tpl +5 -0
  327. package/src/templates/adapters/PostgreSQLAdapter.ts.tpl +5 -0
  328. package/src/templates/adapters/SQLServerAdapter.ts.tpl +5 -0
  329. package/src/templates/adapters/SQLiteAdapter.ts.tpl +5 -0
  330. package/src/templates/features/Queue.ts.tpl +1 -29
  331. package/src/templates/project/basic/.env.example.tpl +48 -0
  332. package/src/templates/project/basic/.env.tpl +89 -94
  333. package/src/templates/project/basic/app/Toolkit/Broadcast/sendBroadcast.ts.tpl +7 -0
  334. package/src/templates/project/basic/app/Toolkit/Mail/sendWelcomeEmail.ts.tpl +30 -0
  335. package/src/templates/project/basic/app/Toolkit/Notification/sendSlackNotification.ts.tpl +10 -0
  336. package/src/templates/project/basic/app/Toolkit/Notification/sendSms.ts.tpl +13 -0
  337. package/src/templates/project/basic/config/FileLogWriter.ts.tpl +240 -0
  338. package/src/templates/project/basic/config/SecretsManager.ts.tpl +32 -1
  339. package/src/templates/project/basic/config/StartupConfigValidator.ts.tpl +151 -0
  340. package/src/templates/project/basic/config/app.ts.tpl +84 -15
  341. package/src/templates/project/basic/config/broadcast.ts.tpl +97 -0
  342. package/src/templates/project/basic/config/cache.ts.tpl +19 -23
  343. package/src/templates/project/basic/config/cloudflare.ts.tpl +57 -0
  344. package/src/templates/project/basic/config/env.ts.tpl +7 -1
  345. package/src/templates/project/basic/config/index.ts.tpl +3 -0
  346. package/src/templates/project/basic/config/logger.ts.tpl +301 -11
  347. package/src/templates/project/basic/config/logging/HttpLogger.ts.tpl +121 -0
  348. package/src/templates/project/basic/config/logging/KvLogger.ts.tpl +181 -0
  349. package/src/templates/project/basic/config/logging/SlackLogger.ts.tpl +156 -0
  350. package/src/templates/project/basic/config/mail.ts.tpl +141 -0
  351. package/src/templates/project/basic/config/middleware.ts.tpl +27 -0
  352. package/src/templates/project/basic/config/notification.ts.tpl +86 -0
  353. package/src/templates/project/basic/config/security.ts.tpl +4 -5
  354. package/src/templates/project/basic/config/startup.ts.tpl +27 -0
  355. package/src/templates/project/basic/config/storage.ts.tpl +77 -42
  356. package/src/templates/project/basic/database/migrations/index.ts.tpl +1 -1
  357. package/src/templates/project/basic/package.json.tpl +1 -1
  358. package/src/templates/project/basic/routes/api.ts.tpl +9 -37
  359. package/src/templates/project/basic/routes/broadcast.ts.tpl +32 -0
  360. package/src/templates/project/basic/routes/health.ts.tpl +134 -0
  361. package/src/templates/project/basic/src/index.ts.tpl +38 -11
  362. package/src/templates/project/basic/template.json +3 -0
  363. package/src/toolkit/Secrets/EnvFile.d.ts +15 -0
  364. package/src/toolkit/Secrets/EnvFile.d.ts.map +1 -0
  365. package/src/toolkit/Secrets/EnvFile.js +63 -0
  366. package/src/toolkit/Secrets/Manifest.d.ts +24 -0
  367. package/src/toolkit/Secrets/Manifest.d.ts.map +1 -0
  368. package/src/toolkit/Secrets/Manifest.js +71 -0
  369. package/src/toolkit/Secrets/index.d.ts +42 -0
  370. package/src/toolkit/Secrets/index.d.ts.map +1 -0
  371. package/src/toolkit/Secrets/index.js +119 -0
  372. package/src/toolkit/Secrets/providers/AwsSecretsManager.d.ts +14 -0
  373. package/src/toolkit/Secrets/providers/AwsSecretsManager.d.ts.map +1 -0
  374. package/src/toolkit/Secrets/providers/AwsSecretsManager.js +131 -0
  375. package/src/toolkit/Secrets/providers/CloudflareKv.d.ts +9 -0
  376. package/src/toolkit/Secrets/providers/CloudflareKv.d.ts.map +1 -0
  377. package/src/toolkit/Secrets/providers/CloudflareKv.js +73 -0
  378. package/src/tools/broadcast/Broadcast.d.ts +7 -0
  379. package/src/tools/broadcast/Broadcast.d.ts.map +1 -0
  380. package/src/tools/broadcast/Broadcast.js +37 -0
  381. package/src/tools/broadcast/drivers/BaseDriver.d.ts +5 -0
  382. package/src/tools/broadcast/drivers/BaseDriver.d.ts.map +1 -0
  383. package/src/tools/broadcast/drivers/BaseDriver.js +8 -0
  384. package/src/tools/broadcast/drivers/InMemory.d.ts +18 -0
  385. package/src/tools/broadcast/drivers/InMemory.d.ts.map +1 -0
  386. package/src/tools/broadcast/drivers/InMemory.js +16 -0
  387. package/src/tools/broadcast/drivers/Pusher.d.ts +8 -0
  388. package/src/tools/broadcast/drivers/Pusher.d.ts.map +1 -0
  389. package/src/tools/broadcast/drivers/Pusher.js +75 -0
  390. package/src/tools/broadcast/drivers/Redis.d.ts +19 -0
  391. package/src/tools/broadcast/drivers/Redis.d.ts.map +1 -0
  392. package/src/tools/broadcast/drivers/Redis.js +73 -0
  393. package/src/tools/broadcast/drivers/RedisHttps.d.ts +14 -0
  394. package/src/tools/broadcast/drivers/RedisHttps.d.ts.map +1 -0
  395. package/src/tools/broadcast/drivers/RedisHttps.js +50 -0
  396. package/src/tools/broadcast/index.d.ts +7 -0
  397. package/src/tools/broadcast/index.d.ts.map +1 -0
  398. package/src/tools/broadcast/index.js +6 -0
  399. package/src/tools/http/Http.d.ts +51 -0
  400. package/src/tools/http/Http.d.ts.map +1 -0
  401. package/src/tools/http/Http.js +171 -0
  402. package/src/tools/http/HttpResponse.d.ts +32 -0
  403. package/src/tools/http/HttpResponse.d.ts.map +1 -0
  404. package/src/tools/http/HttpResponse.js +80 -0
  405. package/src/tools/http/index.d.ts +15 -0
  406. package/src/tools/http/index.d.ts.map +1 -0
  407. package/src/tools/http/index.js +9 -0
  408. package/src/tools/mail/Mail.d.ts +22 -0
  409. package/src/tools/mail/Mail.d.ts.map +1 -0
  410. package/src/tools/mail/Mail.js +105 -0
  411. package/src/tools/mail/attachments.d.ts +23 -0
  412. package/src/tools/mail/attachments.d.ts.map +1 -0
  413. package/src/tools/mail/attachments.js +26 -0
  414. package/src/tools/mail/drivers/BaseDriver.d.ts +5 -0
  415. package/src/tools/mail/drivers/BaseDriver.d.ts.map +1 -0
  416. package/src/tools/mail/drivers/BaseDriver.js +8 -0
  417. package/src/tools/mail/drivers/Mailgun.d.ts +31 -0
  418. package/src/tools/mail/drivers/Mailgun.d.ts.map +1 -0
  419. package/src/tools/mail/drivers/Mailgun.js +81 -0
  420. package/src/tools/mail/drivers/SendGrid.d.ts +29 -0
  421. package/src/tools/mail/drivers/SendGrid.d.ts.map +1 -0
  422. package/src/tools/mail/drivers/SendGrid.js +57 -0
  423. package/src/tools/mail/drivers/Ses.d.ts +24 -0
  424. package/src/tools/mail/drivers/Ses.d.ts.map +1 -0
  425. package/src/tools/mail/drivers/Ses.js +116 -0
  426. package/src/tools/mail/drivers/Smtp.d.ts +38 -0
  427. package/src/tools/mail/drivers/Smtp.d.ts.map +1 -0
  428. package/src/tools/mail/drivers/Smtp.js +327 -0
  429. package/src/tools/mail/templates/index.d.ts +27 -0
  430. package/src/tools/mail/templates/index.d.ts.map +1 -0
  431. package/src/tools/mail/templates/index.js +35 -0
  432. package/src/tools/mail/templates/markdown/index.d.ts +17 -0
  433. package/src/tools/mail/templates/markdown/index.d.ts.map +1 -0
  434. package/src/tools/mail/templates/markdown/index.js +49 -0
  435. package/src/tools/mail/templates/markdown/registry.d.ts +15 -0
  436. package/src/tools/mail/templates/markdown/registry.d.ts.map +1 -0
  437. package/src/tools/mail/templates/markdown/registry.js +34 -0
  438. package/src/tools/mail/templates/markdown/validator.d.ts +16 -0
  439. package/src/tools/mail/templates/markdown/validator.d.ts.map +1 -0
  440. package/src/tools/mail/templates/markdown/validator.js +24 -0
  441. package/src/tools/mail/testing.d.ts +41 -0
  442. package/src/tools/mail/testing.d.ts.map +1 -0
  443. package/src/tools/mail/testing.js +34 -0
  444. package/src/tools/notification/Driver.d.ts +11 -0
  445. package/src/tools/notification/Driver.d.ts.map +1 -0
  446. package/src/tools/notification/Driver.js +1 -0
  447. package/src/tools/notification/Notification.d.ts +11 -0
  448. package/src/tools/notification/Notification.d.ts.map +1 -0
  449. package/src/tools/notification/Notification.js +11 -0
  450. package/src/tools/notification/Registry.d.ts +10 -0
  451. package/src/tools/notification/Registry.d.ts.map +1 -0
  452. package/src/tools/notification/Registry.js +22 -0
  453. package/src/tools/notification/Service.d.ts +6 -0
  454. package/src/tools/notification/Service.d.ts.map +1 -0
  455. package/src/tools/notification/Service.js +18 -0
  456. package/src/tools/notification/config.d.ts +5 -0
  457. package/src/tools/notification/config.d.ts.map +1 -0
  458. package/src/tools/notification/config.js +5 -0
  459. package/src/tools/notification/drivers/BaseDriver.d.ts +5 -0
  460. package/src/tools/notification/drivers/BaseDriver.d.ts.map +1 -0
  461. package/src/tools/notification/drivers/BaseDriver.js +8 -0
  462. package/src/tools/notification/drivers/Console.d.ts +7 -0
  463. package/src/tools/notification/drivers/Console.d.ts.map +1 -0
  464. package/src/tools/notification/drivers/Console.js +13 -0
  465. package/src/tools/notification/drivers/Slack.d.ts +16 -0
  466. package/src/tools/notification/drivers/Slack.d.ts.map +1 -0
  467. package/src/tools/notification/drivers/Slack.js +24 -0
  468. package/src/tools/notification/drivers/Termii.d.ts +10 -0
  469. package/src/tools/notification/drivers/Termii.d.ts.map +1 -0
  470. package/src/tools/notification/drivers/Termii.js +47 -0
  471. package/src/tools/notification/drivers/Twilio.d.ts +21 -0
  472. package/src/tools/notification/drivers/Twilio.d.ts.map +1 -0
  473. package/src/tools/notification/drivers/Twilio.js +48 -0
  474. package/src/tools/notification/templates/markdown/index.d.ts +15 -0
  475. package/src/tools/notification/templates/markdown/index.d.ts.map +1 -0
  476. package/src/tools/notification/templates/markdown/index.js +38 -0
  477. package/src/tools/notification/templates/markdown/registry.d.ts +15 -0
  478. package/src/tools/notification/templates/markdown/registry.d.ts.map +1 -0
  479. package/src/tools/notification/templates/markdown/registry.js +36 -0
  480. package/src/tools/notification/testing.d.ts +19 -0
  481. package/src/tools/notification/testing.d.ts.map +1 -0
  482. package/src/tools/notification/testing.js +35 -0
  483. package/src/tools/notification/testingHelpers.d.ts +12 -0
  484. package/src/tools/notification/testingHelpers.d.ts.map +1 -0
  485. package/src/tools/notification/testingHelpers.js +32 -0
  486. package/src/tools/queue/Queue.d.ts +23 -0
  487. package/src/tools/queue/Queue.d.ts.map +1 -0
  488. package/src/tools/queue/Queue.js +38 -0
  489. package/src/tools/queue/drivers/InMemory.d.ts +10 -0
  490. package/src/tools/queue/drivers/InMemory.d.ts.map +1 -0
  491. package/src/tools/queue/drivers/InMemory.js +55 -0
  492. package/src/tools/queue/drivers/Redis.d.ts +10 -0
  493. package/src/tools/queue/drivers/Redis.d.ts.map +1 -0
  494. package/src/tools/queue/drivers/Redis.js +91 -0
  495. package/src/tools/storage/drivers/Gcs.d.ts +20 -0
  496. package/src/tools/storage/drivers/Gcs.d.ts.map +1 -0
  497. package/src/tools/storage/drivers/Gcs.js +152 -0
  498. package/src/tools/storage/drivers/Local.d.ts +17 -0
  499. package/src/tools/storage/drivers/Local.d.ts.map +1 -0
  500. package/src/tools/storage/drivers/Local.js +63 -0
  501. package/src/tools/storage/drivers/R2.d.ts +20 -0
  502. package/src/tools/storage/drivers/R2.d.ts.map +1 -0
  503. package/src/tools/storage/drivers/R2.js +73 -0
  504. package/src/tools/storage/drivers/S3.d.ts +26 -0
  505. package/src/tools/storage/drivers/S3.d.ts.map +1 -0
  506. package/src/tools/storage/drivers/S3.js +258 -0
  507. package/src/tools/storage/index.d.ts +24 -0
  508. package/src/tools/storage/index.d.ts.map +1 -0
  509. package/src/tools/storage/index.js +112 -0
  510. package/src/tools/storage/testing.d.ts +23 -0
  511. package/src/tools/storage/testing.d.ts.map +1 -0
  512. package/src/tools/storage/testing.js +52 -0
  513. package/src/tools/templates/MarkdownRenderer.d.ts +14 -0
  514. package/src/tools/templates/MarkdownRenderer.d.ts.map +1 -0
  515. package/src/tools/templates/MarkdownRenderer.js +300 -0
  516. package/src/tools/templates/index.d.ts +5 -0
  517. package/src/tools/templates/index.d.ts.map +1 -0
  518. package/src/tools/templates/index.js +4 -0
@@ -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')
@@ -143,7 +143,7 @@ const addFeature = async (cmd, featureName, opts) => {
143
143
  throw ErrorFactory.createValidationError('Service path is required');
144
144
  const fullServicePath = path.join(projectRoot, servicePath);
145
145
  cmd.info(`Adding feature: ${name}...`);
146
- const result = await FeatureScaffolder.addFeature({
146
+ const result = FeatureScaffolder.addFeature({
147
147
  name: name,
148
148
  servicePath: fullServicePath,
149
149
  withTest: opts.withTest,
@@ -151,7 +151,7 @@ const addFeature = async (cmd, featureName, opts) => {
151
151
  if (result.success === false)
152
152
  throw ErrorFactory.createCliError(result.message);
153
153
  cmd.success(`Feature '${name}' added successfully!`);
154
- cmd.info(`Files created: ${result.filesCreated.length}`);
154
+ cmd.info(`Files created: ${result.filesCreated?.length || 0}`);
155
155
  cmd.info(`\nNext steps:\n • Integrate feature in service\n • Update routes if needed\n • Add to configuration`);
156
156
  };
157
157
  const promptMigrationConfig = async () => {
@@ -380,7 +380,7 @@ const addFactory = async (cmd, factoryName, opts) => {
380
380
  else if (config.name === '') {
381
381
  throw ErrorFactory.createValidationError('Factory name is required');
382
382
  }
383
- if (config.modelName === '' && opts.noInteractive !== true) {
383
+ if (config.modelName === '') {
384
384
  throw ErrorFactory.createValidationError('Model name is required for factory generation');
385
385
  }
386
386
  const factoriesPath = path.join(projectRoot, 'database', 'factories');
@@ -485,7 +485,7 @@ const addSeeder = async (cmd, seederName, opts) => {
485
485
  else if (config.name === '') {
486
486
  throw ErrorFactory.createValidationError('Seeder name is required');
487
487
  }
488
- if (config.modelName === '' && opts.noInteractive !== true) {
488
+ if (config.modelName === '') {
489
489
  throw ErrorFactory.createValidationError('Model name is required for seeder generation');
490
490
  }
491
491
  const seedersPath = path.join(projectRoot, 'database', 'seeders');
@@ -814,4 +814,23 @@ export const AddCommand = Object.freeze({
814
814
  });
815
815
  return cmd;
816
816
  },
817
+ /**
818
+ * Internal helpers for testing
819
+ * @internal
820
+ */
821
+ _helpers: {
822
+ promptServiceConfig,
823
+ promptFeatureConfig,
824
+ promptMigrationConfig,
825
+ promptModelConfig,
826
+ promptControllerConfig,
827
+ promptRoutesConfig,
828
+ promptFactoryConfig,
829
+ promptSeederConfig,
830
+ promptRequestFactoryConfig,
831
+ promptResponseFactoryName,
832
+ promptResponseFactoryConfig,
833
+ promptWorkflowConfig,
834
+ getDefaultResponseFields,
835
+ },
817
836
  });
@@ -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;AA2T7E;;GAEG;AACH,eAAO,MAAM,aAAa;IACxB;;OAEG;cACO,YAAY;EA4EtB,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)
@@ -66,7 +94,10 @@ const displayValidationStatus = (cmd, config) => {
66
94
  const errors = validation?.errors ?? [];
67
95
  cmd.info(chalk.red(` ❌ Configuration has ${errors.length} errors:`));
68
96
  for (const error of errors) {
69
- cmd.info(chalk.red(` - ${error}`));
97
+ const message = error !== null && typeof error === 'object' && 'message' in error
98
+ ? toDisplayString(error.message)
99
+ : toDisplayString(error);
100
+ cmd.info(chalk.red(` - ${message}`));
70
101
  }
71
102
  };
72
103
  const displayConfigurationKeys = (cmd, keys) => {
@@ -83,23 +114,22 @@ const displayConfigurationValues = (cmd, config) => {
83
114
  cmd.info(`${chalk.cyan(key)}: ${formatConfigValue(value)}`);
84
115
  }
85
116
  };
86
- const handleGet = async (cmd, manager, key) => {
117
+ const handleGet = (cmd, manager, key) => {
87
118
  if (key === undefined) {
88
119
  ErrorHandler.usageError('Configuration key is required for "get"');
89
- return;
90
120
  }
91
121
  if (typeof manager.get !== 'function') {
92
122
  cmd.warn('Configuration manager does not support "get"');
93
- return;
94
123
  }
95
- const value = manager.get(key);
96
- if (value === undefined) {
97
- cmd.warn(`Configuration key "${key}" not found`);
98
- return;
124
+ if (typeof manager.get === 'function' && key !== undefined) {
125
+ const value = manager.get(key);
126
+ if (value === undefined) {
127
+ cmd.warn(`Configuration key "${key}" not found`);
128
+ }
129
+ cmd.info(formatConfigValue(value));
99
130
  }
100
- cmd.info(formatConfigValue(value));
101
131
  };
102
- const handleSet = async (cmd, manager, key, value) => {
132
+ const handleSet = (cmd, manager, key, value) => {
103
133
  if (key === undefined || value === undefined) {
104
134
  ErrorHandler.usageError('Both key and value are required for "set"');
105
135
  return;
@@ -111,19 +141,18 @@ const handleSet = async (cmd, manager, key, value) => {
111
141
  const parsedValue = parseConfigValue(value);
112
142
  const validationError = ConfigValidator.validateValue(key, parsedValue);
113
143
  if (validationError) {
114
- cmd.warn(`Validation error for "${key}": ${validationError}`);
144
+ cmd.warn(`Validation error for "${key}": ${validationError.message}`);
115
145
  return;
116
146
  }
117
147
  manager.set(key, parsedValue);
118
148
  if (typeof manager.save === 'function') {
119
- await manager.save();
149
+ manager.save();
120
150
  }
121
151
  cmd.success(`Configuration updated: ${key} = ${value}`);
122
152
  };
123
- const handleList = async (cmd, manager, options) => {
153
+ const handleList = (cmd, manager, options) => {
124
154
  if (options['json'] === true && typeof manager.export === 'function') {
125
155
  cmd.info(manager.export());
126
- return;
127
156
  }
128
157
  const config = typeof manager.getConfig === 'function' ? manager.getConfig() : {};
129
158
  cmd.info(chalk.bold('\n🛠️ Current Configuration:\n'));
@@ -141,7 +170,7 @@ const handleReset = async (cmd, manager) => {
141
170
  return;
142
171
  }
143
172
  if (typeof manager.reset === 'function') {
144
- await manager.reset();
173
+ manager.reset();
145
174
  }
146
175
  cmd.success('Configuration reset to defaults');
147
176
  };
@@ -150,7 +179,9 @@ const editSingleConfig = async (cmd, manager, selectedKey) => {
150
179
  let defaultValue = '';
151
180
  if (currentValue !== undefined) {
152
181
  defaultValue =
153
- typeof currentValue === 'object' ? JSON.stringify(currentValue) : String(currentValue);
182
+ typeof currentValue === 'object'
183
+ ? JSON.stringify(currentValue)
184
+ : toDisplayString(currentValue);
154
185
  }
155
186
  const newValue = await PromptHelper.textInput(`Enter new value for "${selectedKey}":`, defaultValue);
156
187
  if (newValue === undefined)
@@ -158,14 +189,14 @@ const editSingleConfig = async (cmd, manager, selectedKey) => {
158
189
  const parsedValue = parseConfigValue(newValue);
159
190
  const validationError = ConfigValidator.validateValue(selectedKey, parsedValue);
160
191
  if (validationError) {
161
- cmd.warn(`Validation error: ${validationError}`);
192
+ cmd.warn(`Validation error: ${validationError.message}`);
162
193
  return;
163
194
  }
164
195
  if (typeof manager.set === 'function') {
165
196
  manager.set(selectedKey, parsedValue);
166
197
  }
167
198
  if (typeof manager.save === 'function') {
168
- await manager.save();
199
+ manager.save();
169
200
  }
170
201
  cmd.success(`Updated ${selectedKey}`);
171
202
  };
@@ -180,12 +211,15 @@ const handleEdit = async (cmd, manager) => {
180
211
  return;
181
212
  }
182
213
  const menuKeys = [...availableKeys].sort((a, b) => a.localeCompare(b)).concat(['(Done)']);
214
+ // Interactive prompt loop must be sequential.
215
+ /* eslint-disable no-await-in-loop */
183
216
  while (true) {
184
217
  const selectedKey = await PromptHelper.chooseFrom('Select configuration key to edit:', menuKeys);
185
218
  if (selectedKey === '' || selectedKey === '(Done)')
186
219
  break;
187
220
  await editSingleConfig(cmd, manager, selectedKey);
188
221
  }
222
+ /* eslint-enable no-await-in-loop */
189
223
  cmd.success('Configuration editing complete');
190
224
  };
191
225
  const handleExport = (cmd, manager) => {
@@ -232,22 +266,22 @@ export const ConfigCommand = Object.freeze({
232
266
  execute: async (options) => executeConfig(cmd, options),
233
267
  });
234
268
  cmd.getConfigManager = async (isGlobal) => isGlobal ? getGlobalConfigManager() : getProjectConfigManager();
235
- cmd.handleGet = async (manager, key, value) => handleGet(cmd, manager, key ?? value);
236
- cmd.handleSet = async (manager, key, value) => handleSet(cmd, manager, key, value);
237
- cmd.handleList = async (manager, options) => handleList(cmd, manager, options);
269
+ cmd.handleGet = (manager, key, value) => handleGet(cmd, manager, key ?? value);
270
+ cmd.handleSet = (manager, key, value) => handleSet(cmd, manager, key, value);
271
+ cmd.handleList = (manager, options) => handleList(cmd, manager, options);
238
272
  cmd.handleReset = async (manager) => handleReset(cmd, manager);
239
273
  cmd.handleEdit = async (manager) => handleEdit(cmd, manager);
240
274
  cmd.handleExport = (manager) => handleExport(cmd, manager);
241
275
  cmd.handleAction = async (action, manager, key, value, options) => {
242
276
  switch (action.toLowerCase()) {
243
277
  case 'get':
244
- await cmd.handleGet(manager, key, value);
278
+ cmd.handleGet(manager, key, value);
245
279
  return;
246
280
  case 'set':
247
- await cmd.handleSet(manager, key, value, options);
281
+ cmd.handleSet(manager, key, value, options);
248
282
  return;
249
283
  case 'list':
250
- await cmd.handleList(manager, options ?? {});
284
+ cmd.handleList(manager, options ?? {});
251
285
  return;
252
286
  case 'reset':
253
287
  await cmd.handleReset(manager);
@@ -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":"AAQA,OAAO,EAA+B,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAiD7E;;;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"}
@@ -1,21 +1,23 @@
1
- import { appConfig } from '../../config/app';
2
1
  /**
3
2
  * D1 Migrate Command
4
3
  * Run Cloudflare D1 migrations using Wrangler
5
4
  */
6
- import { resolveNpmPath } from '../../common';
7
- import { ErrorFactory } from '../../exceptions/ZintrustError';
8
5
  import { BaseCommand } from '../BaseCommand';
6
+ import { resolveNpmPath } from '../../common/index';
7
+ import { appConfig } from '../../config/app';
9
8
  import { Logger } from '../../config/logger';
9
+ import { ErrorFactory } from '../../exceptions/ZintrustError';
10
10
  import { execFileSync } from '../../node-singletons/child-process';
11
+ // eslint-disable-next-line @typescript-eslint/require-await
11
12
  const runWrangler = async (cmd, args) => {
12
13
  const npmPath = resolveNpmPath();
13
14
  cmd.debug(`Executing: npm exec --yes -- wrangler ${args.join(' ')}`);
14
- return execFileSync(npmPath, ['exec', '--yes', '--', 'wrangler', ...args], {
15
+ const result = execFileSync(npmPath, ['exec', '--yes', '--', 'wrangler', ...args], {
15
16
  stdio: 'pipe',
16
17
  encoding: 'utf8',
17
18
  env: appConfig.getSafeEnv(),
18
19
  });
20
+ return result;
19
21
  };
20
22
  const executeD1Migrate = async (cmd, options) => {
21
23
  const isLocal = options['local'] === true || options['remote'] !== true;
@@ -1 +1 @@
1
- {"version":3,"file":"FixCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/FixCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAA+B,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAqE7E;;GAEG;AACH,eAAO,MAAM,UAAU;IACrB;;OAEG;cACO,YAAY;EAkBtB,CAAC"}
1
+ {"version":3,"file":"FixCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/FixCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAA+B,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAmD7E;;GAEG;AACH,eAAO,MAAM,UAAU;IACrB;;OAEG;cACO,YAAY;EAkBtB,CAAC"}
@@ -4,21 +4,9 @@
4
4
  */
5
5
  import { appConfig } from '../../config';
6
6
  import { BaseCommand } from '../BaseCommand';
7
+ import { resolveNpmPath } from '../../common/index';
7
8
  import { ErrorFactory } from '../../exceptions/ZintrustError';
8
9
  import { execFileSync } from '../../node-singletons/child-process';
9
- import fs from '../../node-singletons/fs';
10
- import * as path from '../../node-singletons/path';
11
- const resolveNpmPath = () => {
12
- const nodeBinDir = path.dirname(process.execPath);
13
- const candidates = process.platform === 'win32'
14
- ? [path.join(nodeBinDir, 'npm.cmd'), path.join(nodeBinDir, 'npm.exe')]
15
- : [path.join(nodeBinDir, 'npm')];
16
- for (const candidate of candidates) {
17
- if (fs.existsSync(candidate))
18
- return candidate;
19
- }
20
- throw ErrorFactory.createCliError('Unable to locate npm executable. Ensure Node.js (with npm) is installed in the standard location.');
21
- };
22
10
  const runNpmScript = (cmd, args) => {
23
11
  const npmPath = resolveNpmPath();
24
12
  cmd.debug(`Executing: npm run ${args.join(' ')}`);
@@ -28,7 +16,7 @@ const runNpmScript = (cmd, args) => {
28
16
  env: appConfig.getSafeEnv(),
29
17
  });
30
18
  };
31
- const executeFix = async (cmd, options) => {
19
+ const executeFix = (cmd, options) => {
32
20
  cmd.info('Starting automated code fixes...');
33
21
  try {
34
22
  const isDryRun = options['dryRun'] === true;
@@ -70,7 +58,7 @@ export const FixCommand = Object.freeze({
70
58
  name: 'fix',
71
59
  description: 'Run automated code fixes',
72
60
  addOptions,
73
- execute: async (options) => executeFix(cmd, options),
61
+ execute: (options) => executeFix(cmd, options),
74
62
  });
75
63
  cmd.resolveNpmPath = () => resolveNpmPath();
76
64
  cmd.getSafeEnv = () => appConfig.getSafeEnv();
@@ -0,0 +1,6 @@
1
+ import { type IBaseCommand } from '../BaseCommand';
2
+ export declare const LogsCleanupCommand: Readonly<{
3
+ create(): IBaseCommand;
4
+ }>;
5
+ export default LogsCleanupCommand;
6
+ //# sourceMappingURL=LogsCleanupCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LogsCleanupCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/LogsCleanupCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGlE,eAAO,MAAM,kBAAkB;cACnB,YAAY;EAiBtB,CAAC;AAEH,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { BaseCommand } from '../BaseCommand';
2
+ import { cleanLogsOnce } from '../../config/logger';
3
+ export const LogsCleanupCommand = Object.freeze({
4
+ create() {
5
+ // Create the command first, then assign the execute implementation so we can
6
+ // safely reference the instance (`cmd`) from inside the handler.
7
+ const cmd = BaseCommand.create({
8
+ name: 'logs:cleanup',
9
+ description: 'Run a one-off log cleanup based on configured retention',
10
+ execute: async () => { },
11
+ });
12
+ cmd.execute = async (_options) => {
13
+ cmd.info('Running log cleanup...');
14
+ const deleted = await cleanLogsOnce();
15
+ cmd.info(`Deleted ${deleted.length} log files`);
16
+ };
17
+ return cmd;
18
+ },
19
+ });
20
+ export default LogsCleanupCommand;
@@ -1 +1 @@
1
- {"version":3,"file":"LogsCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/LogsCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA+B,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAM7E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA8KpC,eAAO,MAAM,WAAW;IACtB;;OAEG;cACO,YAAY;IAwBtB;;;OAGG;sBACe,OAAO,GAAG,IAAI;EAchC,CAAC;AAEH,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"LogsCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/LogsCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA+B,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAO7E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA2KpC,eAAO,MAAM,WAAW;IACtB;;OAEG;cACO,YAAY;IAwBtB;;;OAGG;sBACe,OAAO,GAAG,IAAI;EAchC,CAAC;AAEH,eAAe,WAAW,CAAC"}
@@ -7,8 +7,8 @@ import { Logger as FileLogger } from '../logger/Logger';
7
7
  import { Logger } from '../../config/logger';
8
8
  import { ErrorFactory } from '../../exceptions/ZintrustError';
9
9
  import fs from '../../node-singletons/fs';
10
+ import * as path from '../../node-singletons/path';
10
11
  import chalk from 'chalk';
11
- import * as path from 'node:path';
12
12
  const normalizeLogsOptions = (options) => {
13
13
  const level = typeof options['level'] === 'string' ? options['level'] : 'info';
14
14
  const clear = options['clear'] === true;
@@ -117,11 +117,6 @@ const followLogs = (category) => {
117
117
  });
118
118
  };
119
119
  const clearLogs = (loggerInstance, category) => {
120
- const confirmed = true;
121
- if (!confirmed) {
122
- Logger.info(chalk.yellow('Clearing logs cancelled'));
123
- return;
124
- }
125
120
  const success = loggerInstance.clearLogs(category);
126
121
  if (success === true) {
127
122
  Logger.info(chalk.green(`✓ Cleared logs for category: ${category}`));
@@ -133,6 +128,9 @@ const clearLogs = (loggerInstance, category) => {
133
128
  const executeLogs = (options) => {
134
129
  const normalized = normalizeLogsOptions(options);
135
130
  const loggerInstance = FileLogger.getInstance();
131
+ if (options['lines'] !== undefined && Number.isNaN(Number(options['lines']))) {
132
+ throw ErrorFactory.createGeneralError('Lines must be a number');
133
+ }
136
134
  if (normalized.clear) {
137
135
  clearLogs(loggerInstance, normalized.category);
138
136
  return;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * make:mail-template
3
+ * Scaffolds a mail markdown template into the project.
4
+ */
5
+ import { IBaseCommand } from '../BaseCommand';
6
+ export declare const MakeMailTemplateCommand: Readonly<{
7
+ create(): IBaseCommand;
8
+ }>;
9
+ export default MakeMailTemplateCommand;
10
+ //# sourceMappingURL=MakeMailTemplateCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MakeMailTemplateCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/MakeMailTemplateCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA+B,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAgC7E,eAAO,MAAM,uBAAuB;cACxB,YAAY;EA4EtB,CAAC;AAEH,eAAe,uBAAuB,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * make:mail-template
3
+ * Scaffolds a mail markdown template into the project.
4
+ */
5
+ import { BaseCommand } from '../BaseCommand';
6
+ import { ErrorHandler } from '../ErrorHandler';
7
+ import { PromptHelper } from '../PromptHelper';
8
+ import { FileGenerator } from '../scaffolding/FileGenerator';
9
+ import { TemplateGenerator } from '../scaffolding/TemplateGenerator';
10
+ import { ErrorFactory } from '../../exceptions/ZintrustError';
11
+ import * as path from '../../node-singletons/path';
12
+ const addOptions = (command) => {
13
+ command.argument('[name]', 'Template name (alphanumeric + hyphens only)');
14
+ command.option('--category <category>', 'auth|transactional|notifications');
15
+ command.option('--vars <csv>', 'Comma-separated variables (e.g., name,confirmLink,expiryMinutes)');
16
+ command.option('--overwrite', 'Overwrite existing file');
17
+ command.option('--no-interactive', 'Disable prompts (requires args/options)');
18
+ };
19
+ const defaultCopyright = () => process.env['TEMPLATE_COPYRIGHT'] ?? '© 2025 Zintrust Framework. All rights reserved.';
20
+ export const MakeMailTemplateCommand = Object.freeze({
21
+ create() {
22
+ return BaseCommand.create({
23
+ name: 'make:mail-template',
24
+ description: 'Scaffold a mail markdown template into src/mail/markdown',
25
+ addOptions,
26
+ execute: async (options) => {
27
+ const interactive = options.noInteractive !== true;
28
+ const argName = options.args?.[0];
29
+ const name = argName ??
30
+ (interactive ? await PromptHelper.textInput('Template name:', 'welcome', true) : '');
31
+ if (name.trim() === '') {
32
+ throw ErrorFactory.createValidationError('Template name required');
33
+ }
34
+ const categoryInput = options.category ??
35
+ (interactive
36
+ ? await PromptHelper.chooseFrom('Category:', ['auth', 'transactional', 'notifications'], 'auth', true)
37
+ : 'auth');
38
+ const category = categoryInput;
39
+ const varsCsv = options.vars ??
40
+ (interactive
41
+ ? await PromptHelper.textInput('Variables (comma-separated):', 'name,confirmLink,expiryMinutes', true)
42
+ : '');
43
+ const variables = TemplateGenerator.parseVariablesCsv(varsCsv);
44
+ TemplateGenerator.ensureDirectories(process.cwd());
45
+ // If file exists and overwrite not specified, ask.
46
+ const desired = {
47
+ name,
48
+ category,
49
+ variables,
50
+ copyright: defaultCopyright(),
51
+ projectRoot: process.cwd(),
52
+ overwrite: options.overwrite === true,
53
+ };
54
+ if (options.overwrite !== true && interactive) {
55
+ const relPath = path.join('src', 'mail', 'markdown', category, `${name}.md`);
56
+ const fullPath = path.join(process.cwd(), relPath);
57
+ if (FileGenerator.fileExists(fullPath)) {
58
+ const confirm = await PromptHelper.confirm('File exists. Overwrite?', false, true);
59
+ if (confirm) {
60
+ desired.overwrite = true;
61
+ }
62
+ }
63
+ }
64
+ const result = TemplateGenerator.scaffoldMailMarkdownTemplate(desired);
65
+ if (result.success) {
66
+ ErrorHandler.success(result.message);
67
+ return;
68
+ }
69
+ ErrorHandler.warn(result.message);
70
+ },
71
+ });
72
+ },
73
+ });
74
+ export default MakeMailTemplateCommand;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * make:notification-template
3
+ * Scaffolds a notification markdown template into the project.
4
+ */
5
+ import { IBaseCommand } from '../BaseCommand';
6
+ export declare const MakeNotificationTemplateCommand: Readonly<{
7
+ create(): IBaseCommand;
8
+ }>;
9
+ export default MakeNotificationTemplateCommand;
10
+ //# sourceMappingURL=MakeNotificationTemplateCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MakeNotificationTemplateCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/MakeNotificationTemplateCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA+B,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAoH7E,eAAO,MAAM,+BAA+B;cAChC,YAAY;EAqCtB,CAAC;AAEH,eAAe,+BAA+B,CAAC"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * make:notification-template
3
+ * Scaffolds a notification markdown template into the project.
4
+ */
5
+ import { BaseCommand } from '../BaseCommand';
6
+ import { ErrorHandler } from '../ErrorHandler';
7
+ import { PromptHelper } from '../PromptHelper';
8
+ import { FileGenerator } from '../scaffolding/FileGenerator';
9
+ import { TemplateGenerator } from '../scaffolding/TemplateGenerator';
10
+ import { ErrorFactory } from '../../exceptions/ZintrustError';
11
+ import * as path from '../../node-singletons/path';
12
+ import inquirer from 'inquirer';
13
+ const addOptions = (command) => {
14
+ command.argument('[name]', 'Template name (alphanumeric + hyphens only)');
15
+ command.option('--channels <csv>', 'Comma-separated channels: mail,sms,slack,discord');
16
+ command.option('--vars <csv>', 'Comma-separated variables');
17
+ command.option('--sms-variant <mode>', 'short|none', 'none');
18
+ command.option('--overwrite', 'Overwrite existing file');
19
+ command.option('--no-interactive', 'Disable prompts (requires args/options)');
20
+ };
21
+ const defaultCopyright = () => process.env['TEMPLATE_COPYRIGHT'] ?? '© 2025 Zintrust Framework. All rights reserved.';
22
+ const parseChannelsCsv = (csv) => {
23
+ if (csv === undefined || csv.trim() === '')
24
+ return [];
25
+ const parts = csv
26
+ .split(',')
27
+ .map((p) => p.trim())
28
+ .filter((p) => p !== '');
29
+ const out = [];
30
+ for (const p of parts) {
31
+ const lower = p.toLowerCase();
32
+ if (lower === 'mail' || lower === 'sms' || lower === 'slack' || lower === 'discord') {
33
+ if (!out.includes(lower))
34
+ out.push(lower);
35
+ }
36
+ }
37
+ return out;
38
+ };
39
+ const resolveName = async (options, interactive) => {
40
+ const argName = options.args?.[0];
41
+ const name = argName ??
42
+ (interactive ? await PromptHelper.textInput('Template name:', 'security-alert', true) : '');
43
+ if (name.trim() === '') {
44
+ throw ErrorFactory.createValidationError('Template name required');
45
+ }
46
+ return name;
47
+ };
48
+ const resolveChannels = async (options, interactive) => {
49
+ let channels = parseChannelsCsv(options.channels);
50
+ if (channels.length > 0)
51
+ return channels;
52
+ if (!interactive)
53
+ return [];
54
+ const answer = await inquirer.prompt([
55
+ {
56
+ type: 'checkbox',
57
+ name: 'channels',
58
+ message: 'Channels:',
59
+ choices: ['mail', 'sms', 'slack', 'discord'],
60
+ default: ['mail'],
61
+ },
62
+ ]);
63
+ channels = answer.channels ?? ['mail'];
64
+ return channels;
65
+ };
66
+ const resolveVariables = async (options, interactive) => {
67
+ const varsCsv = options.vars ??
68
+ (interactive
69
+ ? await PromptHelper.textInput('Variables (comma-separated):', 'ipAddress,location,deviceName,reviewLink', true)
70
+ : '');
71
+ return TemplateGenerator.parseVariablesCsv(varsCsv);
72
+ };
73
+ const maybeEnableOverwrite = async (interactive, overwriteFlag, relPath) => {
74
+ if (!interactive || overwriteFlag)
75
+ return overwriteFlag;
76
+ const fullPath = path.join(process.cwd(), relPath);
77
+ if (!FileGenerator.fileExists(fullPath))
78
+ return false;
79
+ return PromptHelper.confirm('File exists. Overwrite?', false, true);
80
+ };
81
+ export const MakeNotificationTemplateCommand = Object.freeze({
82
+ create() {
83
+ return BaseCommand.create({
84
+ name: 'make:notification-template',
85
+ description: 'Scaffold a notification markdown template into src/notification/markdown',
86
+ addOptions,
87
+ execute: async (options) => {
88
+ const interactive = options.noInteractive !== true;
89
+ const name = await resolveName(options, interactive);
90
+ const channels = await resolveChannels(options, interactive);
91
+ const variables = await resolveVariables(options, interactive);
92
+ const smsVariant = (options.smsVariant ?? 'none');
93
+ TemplateGenerator.ensureDirectories(process.cwd());
94
+ const relPath = path.join('src', 'notification', 'markdown', `${name}.md`);
95
+ const overwrite = await maybeEnableOverwrite(interactive, options.overwrite === true, relPath);
96
+ const result = TemplateGenerator.scaffoldNotificationMarkdownTemplate({
97
+ name,
98
+ channels,
99
+ variables,
100
+ smsVariant,
101
+ copyright: defaultCopyright(),
102
+ projectRoot: process.cwd(),
103
+ overwrite,
104
+ });
105
+ if (result.success)
106
+ ErrorHandler.success(result.message);
107
+ else
108
+ ErrorHandler.warn(result.message);
109
+ },
110
+ });
111
+ },
112
+ });
113
+ export default MakeNotificationTemplateCommand;
@@ -1 +1 @@
1
- {"version":3,"file":"MigrateCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/MigrateCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA+B,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAI7E;;GAEG;AACH,eAAO,MAAM,cAAc;IACzB;;OAEG;cACO,YAAY;EA8CtB,CAAC"}
1
+ {"version":3,"file":"MigrateCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/MigrateCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA+B,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAI7E;;GAEG;AACH,eAAO,MAAM,cAAc;IACzB;;OAEG;cACO,YAAY;EA2CtB,CAAC"}