@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
@@ -0,0 +1,172 @@
1
+ /**
2
+ * Template Generator
3
+ * Scaffolds mail and notification markdown templates into the application source.
4
+ *
5
+ * Notes:
6
+ * - Generates into application folders (default: src/mail/markdown and src/notification/markdown)
7
+ * - Uses FileGenerator for consistent file I/O + logging
8
+ */
9
+ import { FileGenerator } from '../scaffolding/FileGenerator';
10
+ import { Logger } from '../../config/logger';
11
+ import { ErrorFactory } from '../../exceptions/ZintrustError';
12
+ import * as path from '../../node-singletons/path';
13
+ const normalizeList = (items) => {
14
+ const out = [];
15
+ for (const raw of items) {
16
+ const v = raw.trim();
17
+ if (v === '')
18
+ continue;
19
+ if (!out.includes(v))
20
+ out.push(v);
21
+ }
22
+ return out;
23
+ };
24
+ export const TemplateGenerator = Object.freeze({
25
+ validateTemplateName(name) {
26
+ const trimmed = name.trim();
27
+ if (trimmed === '') {
28
+ throw ErrorFactory.createValidationError('Template name cannot be empty');
29
+ }
30
+ // Alphanumeric + hyphens only (case-insensitive)
31
+ const re = /^[a-z0-9-]+$/i;
32
+ if (re.exec(trimmed) === null) {
33
+ throw ErrorFactory.createValidationError('Template name must be alphanumeric and may include hyphens only');
34
+ }
35
+ },
36
+ parseVariablesCsv(csv) {
37
+ if (csv === undefined || csv.trim() === '')
38
+ return [];
39
+ return normalizeList(csv.split(','));
40
+ },
41
+ scaffoldMailMarkdownTemplate(options) {
42
+ this.validateTemplateName(options.name);
43
+ const variables = normalizeList(options.variables);
44
+ const relPath = path.join('src', 'mail', 'markdown', options.category, `${options.name}.md`);
45
+ const filePath = path.join(options.projectRoot, relPath);
46
+ const content = buildMailTemplateContent({
47
+ name: options.name,
48
+ category: options.category,
49
+ variables,
50
+ copyright: options.copyright,
51
+ });
52
+ const wrote = FileGenerator.writeFile(filePath, content, {
53
+ overwrite: options.overwrite === true,
54
+ createDirs: true,
55
+ });
56
+ if (!wrote) {
57
+ return {
58
+ success: false,
59
+ filePath,
60
+ message: `Template already exists (skipped): ${relPath}`,
61
+ };
62
+ }
63
+ return {
64
+ success: true,
65
+ filePath,
66
+ message: `Mail template created: ${relPath}`,
67
+ };
68
+ },
69
+ scaffoldNotificationMarkdownTemplate(options) {
70
+ this.validateTemplateName(options.name);
71
+ const variables = normalizeList(options.variables);
72
+ const channels = normalizeList(options.channels);
73
+ const relPath = path.join('src', 'notification', 'markdown', `${options.name}.md`);
74
+ const filePath = path.join(options.projectRoot, relPath);
75
+ const content = buildNotificationTemplateContent({
76
+ name: options.name,
77
+ channels,
78
+ variables,
79
+ smsVariant: options.smsVariant ?? 'none',
80
+ copyright: options.copyright,
81
+ });
82
+ const wrote = FileGenerator.writeFile(filePath, content, {
83
+ overwrite: options.overwrite === true,
84
+ createDirs: true,
85
+ });
86
+ if (!wrote) {
87
+ return {
88
+ success: false,
89
+ filePath,
90
+ message: `Template already exists (skipped): ${relPath}`,
91
+ };
92
+ }
93
+ return {
94
+ success: true,
95
+ filePath,
96
+ message: `Notification template created: ${relPath}`,
97
+ };
98
+ },
99
+ ensureDirectories(projectRoot) {
100
+ try {
101
+ // These are app-side directories, created on-demand.
102
+ FileGenerator.createDirectories(['src/mail/markdown', 'src/notification/markdown'], projectRoot);
103
+ }
104
+ catch (error) {
105
+ Logger.error('Failed to ensure template directories', error);
106
+ throw ErrorFactory.createTryCatchError('Failed to ensure template directories', error);
107
+ }
108
+ },
109
+ });
110
+ const buildMailTemplateContent = (input) => {
111
+ const variablesLine = input.variables.length > 0 ? input.variables.join(', ') : '';
112
+ const varHint = input.variables.length > 0 ? `<!-- Variables: ${variablesLine} -->\n` : '<!-- Variables: -->\n';
113
+ const normalizedVars = normalizeList(input.variables);
114
+ const hasName = normalizedVars.includes('name');
115
+ const nonNameVars = normalizedVars.filter((v) => v !== 'name');
116
+ const dataRows = normalizedVars.map((v) => `- **${v}:** {{${v}}}`).join('\n');
117
+ const dataSection = normalizedVars.length > 0 ? `## Template Data\n\n${dataRows}\n\n` : '';
118
+ const introLine = hasName ? 'Welcome, {{name}}!' : 'Welcome!';
119
+ const exampleLinkVar = nonNameVars.find((v) => v.toLowerCase().includes('link'));
120
+ const exampleExpiryVar = nonNameVars.find((v) => v.toLowerCase().includes('expiry'));
121
+ const actionLine = exampleLinkVar === undefined
122
+ ? 'Action link: (add your link here)'
123
+ : `Action link: {{${exampleLinkVar}}}`;
124
+ const expiryLine = exampleExpiryVar === undefined ? '' : `_This link expires in {{${exampleExpiryVar}}}._\n\n`;
125
+ // Keep content intentionally minimal and copy-paste ready.
126
+ // Developers can adjust links/layout and remove sections as needed.
127
+ return `<!-- Mail Template: ${input.name} -->
128
+ <!-- Category: ${input.category} -->
129
+ <!-- Copyright: ${input.copyright} -->
130
+ ${varHint}
131
+ # ${introLine}
132
+
133
+ Thanks for reaching out. This is a scaffolded markdown template.
134
+
135
+ ${dataSection}## Next Steps
136
+
137
+ - ${actionLine}
138
+ - Customize the sections for your product
139
+
140
+ ${expiryLine}---
141
+
142
+ Questions? Contact support.
143
+ `;
144
+ };
145
+ const buildNotificationTemplateContent = (input) => {
146
+ const channelsLine = input.channels.length > 0 ? input.channels.join(', ') : '';
147
+ const variablesLine = input.variables.length > 0 ? input.variables.join(', ') : '';
148
+ const smsLine = input.smsVariant === 'short' ? '<!-- SMS Variant: short -->\n' : '';
149
+ const normalizedVars = normalizeList(input.variables);
150
+ const dataRows = normalizedVars.map((v) => `- **${v}:** {{${v}}}`).join('\n');
151
+ const dataSection = normalizedVars.length > 0 ? `## Template Data\n\n${dataRows}\n\n` : '';
152
+ const smsPreviewVars = normalizedVars.slice(0, 2);
153
+ const smsPreview = smsPreviewVars.length > 0
154
+ ? smsPreviewVars.map((v) => `${v}: {{${v}}}`).join(', ')
155
+ : 'add variables as needed';
156
+ const smsVariantBlock = input.smsVariant === 'short'
157
+ ? `\n<!-- SMS Variant Start -->\n\n${input.name}: ${smsPreview}\n\n<!-- SMS Variant End -->\n`
158
+ : '';
159
+ return `<!-- Notification Template: ${input.name} -->
160
+ <!-- Copyright: ${input.copyright} -->
161
+ <!-- Channels: ${channelsLine} -->
162
+ <!-- Variables: ${variablesLine} -->
163
+ ${smsLine}
164
+ # Notification: ${input.name}
165
+
166
+ This is a scaffolded notification template.
167
+
168
+ ${dataSection}---
169
+
170
+ Add your message content here.
171
+ ${smsVariantBlock}`;
172
+ };
@@ -31,4 +31,5 @@ export { ServiceScaffolder } from '../scaffolding/ServiceScaffolder';
31
31
  export type { ServiceOptions, ServiceScaffoldResult } from '../scaffolding/ServiceScaffolder';
32
32
  export { BUILT_IN_TEMPLATES, TemplateEngine } from '../scaffolding/TemplateEngine';
33
33
  export type { Template, TemplateFile, TemplateVariables } from '../scaffolding/TemplateEngine';
34
+ export { TemplateGenerator } from '../scaffolding/TemplateGenerator';
34
35
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cli/scaffolding/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,YAAY,EACV,yBAAyB,EACzB,iBAAiB,EACjB,cAAc,GACf,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,YAAY,EACV,YAAY,EACZ,sBAAsB,EACtB,cAAc,GACf,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,YAAY,EACV,cAAc,EACd,qBAAqB,EACrB,WAAW,GACZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,YAAY,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,YAAY,EACV,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,YAAY,EACV,SAAS,EACT,UAAU,EACV,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,GAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,YAAY,EACV,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACnF,YAAY,EACV,6BAA6B,EAC7B,qBAAqB,EACrB,YAAY,GACb,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AACrF,YAAY,EACV,8BAA8B,EAC9B,sBAAsB,EACtB,aAAa,GACd,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,YAAY,EACV,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,YAAY,GACb,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,YAAY,EACV,WAAW,EACX,qBAAqB,EACrB,aAAa,GACd,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,+BAA+B,EAAE,MAAM,kDAAkD,CAAC;AACnG,YAAY,EACV,eAAe,EACf,6BAA6B,EAC7B,4BAA4B,GAC7B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAE,8BAA8B,EAAE,MAAM,iDAAiD,CAAC;AACjG,YAAY,EACV,2BAA2B,EAC3B,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAChG,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACrF,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cli/scaffolding/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,YAAY,EACV,yBAAyB,EACzB,iBAAiB,EACjB,cAAc,GACf,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,YAAY,EACV,YAAY,EACZ,sBAAsB,EACtB,cAAc,GACf,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,YAAY,EACV,cAAc,EACd,qBAAqB,EACrB,WAAW,GACZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,YAAY,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,YAAY,EACV,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,YAAY,EACV,SAAS,EACT,UAAU,EACV,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,GAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,YAAY,EACV,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACnF,YAAY,EACV,6BAA6B,EAC7B,qBAAqB,EACrB,YAAY,GACb,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AACrF,YAAY,EACV,8BAA8B,EAC9B,sBAAsB,EACtB,aAAa,GACd,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,YAAY,EACV,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,YAAY,GACb,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,YAAY,EACV,WAAW,EACX,qBAAqB,EACrB,aAAa,GACd,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,+BAA+B,EAAE,MAAM,kDAAkD,CAAC;AACnG,YAAY,EACV,eAAe,EACf,6BAA6B,EAC7B,4BAA4B,GAC7B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAE,8BAA8B,EAAE,MAAM,iDAAiD,CAAC;AACjG,YAAY,EACV,2BAA2B,EAC3B,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAChG,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACrF,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACjG,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC"}
@@ -16,3 +16,4 @@ export { ServiceIntegrationTestGenerator } from '../scaffolding/ServiceIntegrati
16
16
  export { ServiceRequestFactoryGenerator } from '../scaffolding/ServiceRequestFactoryGenerator';
17
17
  export { ServiceScaffolder } from '../scaffolding/ServiceScaffolder';
18
18
  export { BUILT_IN_TEMPLATES, TemplateEngine } from '../scaffolding/TemplateEngine';
19
+ export { TemplateGenerator } from '../scaffolding/TemplateGenerator';
@@ -2,7 +2,7 @@ import { appConfig } from '../../config/app';
2
2
  import { ErrorFactory } from '../../exceptions/ZintrustError';
3
3
  import { spawn } from '../../node-singletons/child-process';
4
4
  import { existsSync } from '../../node-singletons/fs';
5
- import * as path from 'node:path';
5
+ import * as path from '../../node-singletons/path';
6
6
  const getExitCode = (exitCode, signal) => {
7
7
  if (typeof exitCode === 'number')
8
8
  return exitCode;
@@ -0,0 +1,41 @@
1
+ export type AwsSigV4Credentials = {
2
+ accessKeyId: string;
3
+ secretAccessKey: string;
4
+ sessionToken?: string;
5
+ };
6
+ type CanonicalizedHeaders = {
7
+ canonicalHeaders: string;
8
+ signedHeaders: string;
9
+ };
10
+ export declare const AwsSigV4: Readonly<{
11
+ sha256Hex(data: string | Uint8Array): string;
12
+ hmacSha256(key: Uint8Array | string, data: string): Uint8Array;
13
+ toAmzDate(date: Date): {
14
+ amzDate: string;
15
+ dateStamp: string;
16
+ };
17
+ deriveSigningKey(params: {
18
+ secretAccessKey: string;
19
+ dateStamp: string;
20
+ region: string;
21
+ service: string;
22
+ }): Uint8Array;
23
+ canonicalizeHeaders(headers: Record<string, string>): CanonicalizedHeaders;
24
+ buildAuthorization(params: {
25
+ method: string;
26
+ canonicalUri: string;
27
+ canonicalQueryString: string;
28
+ headers: Record<string, string>;
29
+ payloadHash: string;
30
+ region: string;
31
+ service: string;
32
+ amzDate: string;
33
+ dateStamp: string;
34
+ credentials: AwsSigV4Credentials;
35
+ }): {
36
+ authorization: string;
37
+ signedHeaders: string;
38
+ };
39
+ }>;
40
+ export {};
41
+ //# sourceMappingURL=AwsSigV4.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AwsSigV4.d.ts","sourceRoot":"","sources":["../../../src/common/AwsSigV4.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,KAAK,oBAAoB,GAAG;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,QAAQ;oBACH,MAAM,GAAG,UAAU,GAAG,MAAM;oBAI5B,UAAU,GAAG,MAAM,QAAQ,MAAM,GAAG,UAAU;oBAI9C,IAAI,GAAG;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE;6BAapC;QACvB,eAAe,EAAE,MAAM,CAAC;QACxB,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;KACjB,GAAG,UAAU;iCAOe,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,oBAAoB;+BAY/C;QACzB,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,EAAE,MAAM,CAAC;QACrB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAChC,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,mBAAmB,CAAC;KAClC,GAAG;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE;EA6CpD,CAAC"}
@@ -0,0 +1,69 @@
1
+ import { createHash, createHmac } from '../node-singletons/crypto';
2
+ export const AwsSigV4 = Object.freeze({
3
+ sha256Hex(data) {
4
+ return createHash('sha256').update(data).digest('hex');
5
+ },
6
+ hmacSha256(key, data) {
7
+ return createHmac('sha256', key).update(data).digest();
8
+ },
9
+ toAmzDate(date) {
10
+ const yyyy = String(date.getUTCFullYear());
11
+ const mm = String(date.getUTCMonth() + 1).padStart(2, '0');
12
+ const dd = String(date.getUTCDate()).padStart(2, '0');
13
+ const hh = String(date.getUTCHours()).padStart(2, '0');
14
+ const mi = String(date.getUTCMinutes()).padStart(2, '0');
15
+ const ss = String(date.getUTCSeconds()).padStart(2, '0');
16
+ const dateStamp = `${yyyy}${mm}${dd}`;
17
+ const amzDate = `${dateStamp}T${hh}${mi}${ss}Z`;
18
+ return { amzDate, dateStamp };
19
+ },
20
+ deriveSigningKey(params) {
21
+ const kDate = this.hmacSha256(`AWS4${params.secretAccessKey}`, params.dateStamp);
22
+ const kRegion = this.hmacSha256(kDate, params.region);
23
+ const kService = this.hmacSha256(kRegion, params.service);
24
+ return this.hmacSha256(kService, 'aws4_request');
25
+ },
26
+ canonicalizeHeaders(headers) {
27
+ const sortedHeaderKeys = Object.keys(headers).sort((a, b) => a.localeCompare(b));
28
+ const canonicalHeaders = sortedHeaderKeys
29
+ .map((k) => `${k}:${String(headers[k]).trim().replaceAll(/\s+/g, ' ')}`)
30
+ .join('\n');
31
+ const signedHeaders = sortedHeaderKeys.join(';');
32
+ return { canonicalHeaders, signedHeaders };
33
+ },
34
+ buildAuthorization(params) {
35
+ const sessionToken = params.credentials.sessionToken;
36
+ if (typeof sessionToken === 'string' &&
37
+ sessionToken.trim() !== '' &&
38
+ params.headers['x-amz-security-token'] === undefined) {
39
+ params.headers['x-amz-security-token'] = sessionToken;
40
+ }
41
+ const { canonicalHeaders, signedHeaders } = this.canonicalizeHeaders(params.headers);
42
+ const canonicalRequest = [
43
+ params.method,
44
+ params.canonicalUri,
45
+ params.canonicalQueryString,
46
+ `${canonicalHeaders}\n`,
47
+ signedHeaders,
48
+ params.payloadHash,
49
+ ].join('\n');
50
+ const algorithm = 'AWS4-HMAC-SHA256';
51
+ const credentialScope = `${params.dateStamp}/${params.region}/${params.service}/aws4_request`;
52
+ const stringToSign = [
53
+ algorithm,
54
+ params.amzDate,
55
+ credentialScope,
56
+ this.sha256Hex(canonicalRequest),
57
+ ].join('\n');
58
+ const signingKey = this.deriveSigningKey({
59
+ secretAccessKey: params.credentials.secretAccessKey,
60
+ dateStamp: params.dateStamp,
61
+ region: params.region,
62
+ service: params.service,
63
+ });
64
+ const signature = createHmac('sha256', signingKey).update(stringToSign).digest('hex');
65
+ const authorization = `${algorithm} Credential=${params.credentials.accessKeyId}/${credentialScope}, ` +
66
+ `SignedHeaders=${signedHeaders}, Signature=${signature}`;
67
+ return { authorization, signedHeaders };
68
+ },
69
+ });
@@ -1,3 +1,7 @@
1
+ export { AwsSigV4 } from './AwsSigV4';
2
+ export declare const FileChecker: {
3
+ exists(filePath: string): boolean;
4
+ };
1
5
  /**
2
6
  * Common utilities - Sealed namespace for immutability
3
7
  */
@@ -6,6 +10,21 @@ export declare const CommonUtils: Readonly<{
6
10
  * Resolve npm executable path from Node.js installation
7
11
  */
8
12
  resolveNpmPath(): string;
13
+ /**
14
+ * RUNTIME UTILITIES
15
+ */
16
+ /**
17
+ * Async delay helper. No-ops when timers are unavailable.
18
+ */
19
+ delay(ms: number): Promise<void>;
20
+ /**
21
+ * Resolve an ESM `import.meta.url` to a filesystem path.
22
+ */
23
+ esmFilePath(metaUrl: string | URL): string;
24
+ /**
25
+ * Resolve an ESM `import.meta.url` to a filesystem directory.
26
+ */
27
+ esmDirname(metaUrl: string | URL): string;
9
28
  /**
10
29
  * STRING UTILITIES
11
30
  */
@@ -32,6 +51,10 @@ export declare const CommonUtils: Readonly<{
32
51
  * Ensure directory exists, create if missing
33
52
  */
34
53
  ensureDir(dirPath: string): void;
54
+ /**
55
+ * Best-effort variant of ensureDir() that never throws.
56
+ */
57
+ ensureDirSafe(dirPath: string): void;
35
58
  /**
36
59
  * Read file contents as string
37
60
  */
@@ -82,6 +105,22 @@ export declare const CommonUtils: Readonly<{
82
105
  * Ensure value is object, throw otherwise
83
106
  */
84
107
  ensureObject(value: unknown, fieldName: string): Record<string, unknown>;
108
+ /**
109
+ * Resolve preferred package manager.
110
+ * If `preferred` is provided, the first value is returned. Otherwise we detect by lock files.
111
+ */
112
+ resolvePackageManager(preferred?: string[]): string;
85
113
  }>;
86
114
  export declare const resolveNpmPath: () => string;
115
+ export declare const delay: (ms: number) => Promise<void>;
116
+ export declare const esmFilePath: (metaUrl: string | URL) => string;
117
+ export declare const esmDirname: (metaUrl: string | URL) => string;
118
+ export declare const resolvePackageManager: (preferred?: string[]) => string;
119
+ export declare const extractErrorMessage: (error: unknown) => string;
120
+ export declare const extractErrorMessageStrict: (error: unknown) => string;
121
+ export declare const fileExists: (filePath: string) => boolean;
122
+ export declare const ensureDir: (dirPath: string) => void;
123
+ export declare const ensureDirSafe: (dirPath: string) => void;
124
+ export declare const readFile: (filePath: string) => string;
125
+ export declare const writeFile: (filePath: string, content: string, createDir?: boolean) => void;
87
126
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,eAAO,MAAM,WAAW;IACtB;;OAEG;sBACe,MAAM;IAgBxB;;OAEG;IAEH;;OAEG;mBACY,MAAM,GAAG,MAAM;IAgB9B;;OAEG;qBACc,MAAM,GAAG,MAAM;IAUhC;;OAEG;sBACe,MAAM,GAAG,MAAM;IAQjC;;OAEG;IAEH;;OAEG;yBACkB,MAAM,GAAG,OAAO;IAQrC;;OAEG;uBACgB,MAAM,GAAG,IAAI;IAMhC;;OAEG;uBACgB,MAAM,GAAG,MAAM;IAUlC;;OAEG;wBACiB,MAAM,WAAW,MAAM,wBAAqB,IAAI;IAcpE;;OAEG;yBACkB,MAAM,GAAG,IAAI;IAYlC;;OAEG;IAEH;;OAEG;2BACoB,MAAM;IAI7B;;OAEG;2BACmB,IAAI,GAAgB,MAAM;IAIhD;;OAEG;8BACuB,MAAM,GAAG,IAAI;IAYvC;;OAEG;IAEH;;OAEG;+BACwB,OAAO,GAAG,MAAM;IAa3C;;OAEG;6BAEQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,kBAChB,MAAM,EAAE,WACf,MAAM,GACd,IAAI;IAWP;;OAEG;mBACY,OAAO,GAAG,OAAO;IAIhC;;OAEG;wBACiB,OAAO,aAAa,MAAM,GAAG,MAAM;IAOvD;;OAEG;wBACiB,OAAO,aAAa,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;EAMxE,CAAC;AAGH,eAAO,MAAM,cAAc,QAAO,MAAsC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,eAAO,MAAM,WAAW;qBACL,MAAM,GAAG,OAAO;CAOlC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW;IACtB;;OAEG;sBACe,MAAM;IAgBxB;;OAEG;IAEH;;OAEG;cACa,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWtC;;OAEG;yBACkB,MAAM,GAAG,GAAG,GAAG,MAAM;IAI1C;;OAEG;wBACiB,MAAM,GAAG,GAAG,GAAG,MAAM;IAIzC;;OAEG;IAEH;;OAEG;mBACY,MAAM,GAAG,MAAM;IAgB9B;;OAEG;qBACc,MAAM,GAAG,MAAM;IAUhC;;OAEG;sBACe,MAAM,GAAG,MAAM;IAQjC;;OAEG;IAEH;;OAEG;yBACkB,MAAM,GAAG,OAAO;IAIrC;;OAEG;uBACgB,MAAM,GAAG,IAAI;IAMhC;;OAEG;2BACoB,MAAM,GAAG,IAAI;IAQpC;;OAEG;uBACgB,MAAM,GAAG,MAAM;IAUlC;;OAEG;wBACiB,MAAM,WAAW,MAAM,wBAAqB,IAAI;IAcpE;;OAEG;yBACkB,MAAM,GAAG,IAAI;IAYlC;;OAEG;IAEH;;OAEG;2BACoB,MAAM;IAI7B;;OAEG;2BACmB,IAAI,GAAgB,MAAM;IAIhD;;OAEG;8BACuB,MAAM,GAAG,IAAI;IAYvC;;OAEG;IAEH;;OAEG;+BACwB,OAAO,GAAG,MAAM;IAa3C;;OAEG;6BAEQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,kBAChB,MAAM,EAAE,WACf,MAAM,GACd,IAAI;IAWP;;OAEG;mBACY,OAAO,GAAG,OAAO;IAIhC;;OAEG;wBACiB,OAAO,aAAa,MAAM,GAAG,MAAM;IAOvD;;OAEG;wBACiB,OAAO,aAAa,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAOxE;;;OAGG;sCAC+B,MAAM,EAAE,GAAG,MAAM;EAgBnD,CAAC;AAGH,eAAO,MAAM,cAAc,QAAO,MAAsC,CAAC;AAEzE,eAAO,MAAM,KAAK,GAAU,IAAI,MAAM,KAAG,OAAO,CAAC,IAAI,CAA0B,CAAC;AAEhF,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,GAAG,GAAG,KAAG,MAA0C,CAAC;AAC/F,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM,GAAG,GAAG,KAAG,MAAyC,CAAC;AAE7F,eAAO,MAAM,qBAAqB,GAAI,YAAY,MAAM,EAAE,KAAG,MAE5D,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,OAAO,OAAO,KAAG,MACb,CAAC;AAIzC,eAAO,MAAM,yBAAyB,GAAI,OAAO,OAAO,KAAG,MAM1D,CAAC;AAGF,eAAO,MAAM,UAAU,GAAI,UAAU,MAAM,KAAG,OAA2C,CAAC;AAC1F,eAAO,MAAM,SAAS,GAAI,SAAS,MAAM,KAAG,IAAsC,CAAC;AACnF,eAAO,MAAM,aAAa,GAAI,SAAS,MAAM,KAAG,IAA0C,CAAC;AAC3F,eAAO,MAAM,QAAQ,GAAI,UAAU,MAAM,KAAG,MAAwC,CAAC;AACrF,eAAO,MAAM,SAAS,GAAI,UAAU,MAAM,EAAE,SAAS,MAAM,EAAE,mBAAgB,KAAG,IAC3B,CAAC"}
@@ -1,6 +1,19 @@
1
1
  import { ErrorFactory } from '../exceptions/ZintrustError';
2
- import fs from '../node-singletons/fs';
3
- import * as path from 'node:path';
2
+ import * as fs from '../node-singletons/fs';
3
+ import * as path from '../node-singletons/path';
4
+ import { fileURLToPath } from '../node-singletons/url';
5
+ export { AwsSigV4 } from './AwsSigV4';
6
+ // Mutable FileChecker used to abstract FS checks for easier testing/mocking
7
+ export const FileChecker = {
8
+ exists(filePath) {
9
+ try {
10
+ return fs.existsSync(filePath);
11
+ }
12
+ catch {
13
+ return false;
14
+ }
15
+ },
16
+ };
4
17
  /**
5
18
  * Common utilities - Sealed namespace for immutability
6
19
  */
@@ -19,6 +32,35 @@ export const CommonUtils = Object.freeze({
19
32
  }
20
33
  throw ErrorFactory.createGeneralError('Unable to locate npm executable. Ensure Node.js (with npm) is installed in the standard location.');
21
34
  },
35
+ /**
36
+ * RUNTIME UTILITIES
37
+ */
38
+ /**
39
+ * Async delay helper. No-ops when timers are unavailable.
40
+ */
41
+ async delay(ms) {
42
+ if (ms <= 0)
43
+ return;
44
+ await new Promise((resolve) => {
45
+ if (typeof globalThis.setTimeout !== 'function') {
46
+ resolve();
47
+ return;
48
+ }
49
+ globalThis.setTimeout(() => resolve(), ms);
50
+ });
51
+ },
52
+ /**
53
+ * Resolve an ESM `import.meta.url` to a filesystem path.
54
+ */
55
+ esmFilePath(metaUrl) {
56
+ return fileURLToPath(metaUrl);
57
+ },
58
+ /**
59
+ * Resolve an ESM `import.meta.url` to a filesystem directory.
60
+ */
61
+ esmDirname(metaUrl) {
62
+ return path.dirname(this.esmFilePath(metaUrl));
63
+ },
22
64
  /**
23
65
  * STRING UTILITIES
24
66
  */
@@ -67,12 +109,7 @@ export const CommonUtils = Object.freeze({
67
109
  * Check if file exists
68
110
  */
69
111
  fileExists(filePath) {
70
- try {
71
- return fs.existsSync(filePath);
72
- }
73
- catch {
74
- return false;
75
- }
112
+ return FileChecker.exists(filePath);
76
113
  },
77
114
  /**
78
115
  * Ensure directory exists, create if missing
@@ -82,6 +119,17 @@ export const CommonUtils = Object.freeze({
82
119
  fs.mkdirSync(dirPath, { recursive: true });
83
120
  }
84
121
  },
122
+ /**
123
+ * Best-effort variant of ensureDir() that never throws.
124
+ */
125
+ ensureDirSafe(dirPath) {
126
+ try {
127
+ this.ensureDir(dirPath);
128
+ }
129
+ catch {
130
+ // best-effort
131
+ }
132
+ },
85
133
  /**
86
134
  * Read file contents as string
87
135
  */
@@ -202,6 +250,51 @@ export const CommonUtils = Object.freeze({
202
250
  }
203
251
  return value;
204
252
  },
253
+ /**
254
+ * Resolve preferred package manager.
255
+ * If `preferred` is provided, the first value is returned. Otherwise we detect by lock files.
256
+ */
257
+ resolvePackageManager(preferred) {
258
+ if (Array.isArray(preferred) && preferred.length > 0) {
259
+ return preferred[0];
260
+ }
261
+ try {
262
+ if (this.fileExists('pnpm-lock.yaml'))
263
+ return 'pnpm';
264
+ if (this.fileExists('yarn.lock'))
265
+ return 'yarn';
266
+ if (this.fileExists('package-lock.json'))
267
+ return 'npm';
268
+ }
269
+ catch {
270
+ // ignore FS errors and fall through to default
271
+ }
272
+ // Default to npm
273
+ return 'npm';
274
+ },
205
275
  });
206
276
  // Re-export for backward compatibility
207
277
  export const resolveNpmPath = () => CommonUtils.resolveNpmPath();
278
+ export const delay = async (ms) => CommonUtils.delay(ms);
279
+ export const esmFilePath = (metaUrl) => CommonUtils.esmFilePath(metaUrl);
280
+ export const esmDirname = (metaUrl) => CommonUtils.esmDirname(metaUrl);
281
+ export const resolvePackageManager = (preferred) => {
282
+ return CommonUtils.resolvePackageManager(preferred);
283
+ };
284
+ export const extractErrorMessage = (error) => CommonUtils.extractErrorMessage(error);
285
+ // Some call sites historically treated non-Error throws (e.g. string) as unknown.
286
+ // Keep that behavior available as a shared helper.
287
+ export const extractErrorMessageStrict = (error) => {
288
+ if (error instanceof Error)
289
+ return error.message;
290
+ if (error !== undefined && error !== null && typeof error === 'object' && 'message' in error) {
291
+ return String(error.message);
292
+ }
293
+ return 'Unknown error';
294
+ };
295
+ // Convenience named exports to make specific helpers testable and import-friendly
296
+ export const fileExists = (filePath) => CommonUtils.fileExists(filePath);
297
+ export const ensureDir = (dirPath) => CommonUtils.ensureDir(dirPath);
298
+ export const ensureDirSafe = (dirPath) => CommonUtils.ensureDirSafe(dirPath);
299
+ export const readFile = (filePath) => CommonUtils.readFile(filePath);
300
+ export const writeFile = (filePath, content, createDir = true) => CommonUtils.writeFile(filePath, content, createDir);
@@ -0,0 +1,3 @@
1
+ export declare const generateUuid: () => string;
2
+ export declare function generateSecureJobId(errMsg?: string): Promise<string>;
3
+ //# sourceMappingURL=uuid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../../src/common/uuid.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,QAAO,MAG/B,CAAC;AAEF,wBAAsB,mBAAmB,CACvC,MAAM,GAAE,MAAgE,GACvE,OAAO,CAAC,MAAM,CAAC,CAqBjB"}
@@ -0,0 +1,30 @@
1
+ import { ErrorFactory } from '../exceptions/ZintrustError';
2
+ export const generateUuid = () => {
3
+ if (typeof globalThis?.crypto?.randomUUID === 'function')
4
+ return globalThis.crypto.randomUUID();
5
+ return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`; // NOSONAR
6
+ };
7
+ export async function generateSecureJobId(errMsg = 'Secure crypto API not available to generate a job id.') {
8
+ if (typeof globalThis.crypto?.randomUUID === 'function') {
9
+ return globalThis.crypto.randomUUID();
10
+ }
11
+ if (typeof globalThis.crypto?.getRandomValues === 'function') {
12
+ const bytes = new Uint8Array(16);
13
+ globalThis.crypto.getRandomValues(bytes);
14
+ return bytesToHex(bytes);
15
+ }
16
+ // Node fallback for environments without Web Crypto
17
+ try {
18
+ const nodeCrypto = await import('../node-singletons/crypto');
19
+ return nodeCrypto.randomBytes(16).toString('hex');
20
+ }
21
+ catch (error) {
22
+ throw ErrorFactory.createTryCatchError(errMsg || 'Secure crypto API not available to generate a job id.', error);
23
+ }
24
+ }
25
+ function bytesToHex(bytes) {
26
+ let out = '';
27
+ for (const b of bytes)
28
+ out += b.toString(16).padStart(2, '0');
29
+ return out;
30
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * FileLogWriter (Node.js only)
3
+ *
4
+ * Provides best-effort file logging with daily + size-based rotation.
5
+ * This module imports Node built-ins and should be loaded only in Node environments.
6
+ */
7
+ type CleanOnceOptions = {
8
+ logsDir?: string;
9
+ keepDays?: number;
10
+ maxTotalSize?: number;
11
+ keepFiles?: number;
12
+ };
13
+ /**
14
+ * Clean log files with additional retention policies.
15
+ * Returns an array of deleted file paths for auditing/tests.
16
+ */
17
+ export declare const cleanOnce: (options?: CleanOnceOptions) => string[];
18
+ export declare const FileLogWriter: Readonly<{
19
+ write(line: string): void;
20
+ }>;
21
+ export default FileLogWriter;
22
+ //# sourceMappingURL=FileLogWriter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileLogWriter.d.ts","sourceRoot":"","sources":["../../../src/config/FileLogWriter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA8EH,KAAK,gBAAgB,GAAG;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAiFF;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,UAAU,gBAAgB,KAAG,MAAM,EAsB5D,CAAC;AAoBF,eAAO,MAAM,aAAa;gBACZ,MAAM,GAAG,IAAI;EAqBzB,CAAC;AAEH,eAAe,aAAa,CAAC"}