@zintrust/core 0.1.18 → 0.1.20

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 (558) hide show
  1. package/README.md +16 -10
  2. package/bin/zintrust-main.d.ts.map +1 -1
  3. package/bin/zintrust-main.js +9 -0
  4. package/package.json +11 -2
  5. package/public/error-pages/404.html +145 -0
  6. package/public/error-pages/500.html +266 -0
  7. package/public/error-pages/error.css +628 -0
  8. package/public/error-pages/error.js +428 -0
  9. package/public/index.html +1 -1
  10. package/public/zintrust.svg +30 -0
  11. package/routes/api.d.ts +7 -0
  12. package/routes/api.d.ts.map +1 -0
  13. package/routes/api.js +115 -0
  14. package/routes/broadcast.d.ts +9 -0
  15. package/routes/broadcast.d.ts.map +1 -0
  16. package/routes/broadcast.js +27 -0
  17. package/routes/health.d.ts +7 -0
  18. package/routes/health.d.ts.map +1 -0
  19. package/routes/health.js +127 -0
  20. package/routes/metrics.d.ts +9 -0
  21. package/routes/metrics.d.ts.map +1 -0
  22. package/routes/metrics.js +20 -0
  23. package/routes/openapi.d.ts +9 -0
  24. package/routes/openapi.d.ts.map +1 -0
  25. package/routes/openapi.js +76 -0
  26. package/routes/storage.d.ts +4 -0
  27. package/routes/storage.d.ts.map +1 -0
  28. package/routes/storage.js +35 -0
  29. package/src/boot/Application.d.ts +2 -2
  30. package/src/boot/Application.d.ts.map +1 -1
  31. package/src/boot/Application.js +18 -3
  32. package/src/boot/Server.d.ts +3 -2
  33. package/src/boot/Server.d.ts.map +1 -1
  34. package/src/boot/Server.js +39 -165
  35. package/src/boot/bootstrap.js +1 -1
  36. package/src/cache/Cache.d.ts +1 -1
  37. package/src/cache/Cache.d.ts.map +1 -1
  38. package/src/cache/CacheDriver.d.ts +4 -0
  39. package/src/cache/CacheDriver.d.ts.map +1 -1
  40. package/src/cache/drivers/KVDriver.d.ts +1 -1
  41. package/src/cache/drivers/KVDriver.d.ts.map +1 -1
  42. package/src/cache/drivers/MemoryDriver.d.ts +1 -1
  43. package/src/cache/drivers/MemoryDriver.d.ts.map +1 -1
  44. package/src/cache/drivers/MemoryDriver.js +16 -0
  45. package/src/cache/drivers/MongoDriver.d.ts +1 -1
  46. package/src/cache/drivers/MongoDriver.d.ts.map +1 -1
  47. package/src/cache/drivers/RedisDriver.d.ts +1 -1
  48. package/src/cache/drivers/RedisDriver.d.ts.map +1 -1
  49. package/src/cli/CLI.d.ts.map +1 -1
  50. package/src/cli/CLI.js +12 -4
  51. package/src/cli/PromptHelper.d.ts.map +1 -1
  52. package/src/cli/PromptHelper.js +4 -3
  53. package/src/cli/commands/AddCommand.d.ts +2 -2
  54. package/src/cli/commands/AddCommand.d.ts.map +1 -1
  55. package/src/cli/commands/AddCommand.js +135 -58
  56. package/src/cli/commands/ConfigCommand.d.ts +1 -1
  57. package/src/cli/commands/ConfigCommand.d.ts.map +1 -1
  58. package/src/cli/commands/CreateCommand.d.ts +15 -0
  59. package/src/cli/commands/CreateCommand.d.ts.map +1 -0
  60. package/src/cli/commands/CreateCommand.js +143 -0
  61. package/src/cli/commands/D1MigrateCommand.d.ts +1 -1
  62. package/src/cli/commands/D1MigrateCommand.d.ts.map +1 -1
  63. package/src/cli/commands/D1MigrateCommand.js +16 -20
  64. package/src/cli/commands/DbSeedCommand.d.ts +9 -0
  65. package/src/cli/commands/DbSeedCommand.d.ts.map +1 -0
  66. package/src/cli/commands/DbSeedCommand.js +171 -0
  67. package/src/cli/commands/DebugCommand.d.ts +1 -1
  68. package/src/cli/commands/DebugCommand.d.ts.map +1 -1
  69. package/src/cli/commands/FixCommand.d.ts +1 -1
  70. package/src/cli/commands/FixCommand.d.ts.map +1 -1
  71. package/src/cli/commands/JwtDevCommand.d.ts +8 -0
  72. package/src/cli/commands/JwtDevCommand.d.ts.map +1 -0
  73. package/src/cli/commands/JwtDevCommand.js +114 -0
  74. package/src/cli/commands/KeyGenerateCommand.d.ts +1 -1
  75. package/src/cli/commands/KeyGenerateCommand.d.ts.map +1 -1
  76. package/src/cli/commands/LogsCommand.d.ts +2 -2
  77. package/src/cli/commands/LogsCommand.d.ts.map +1 -1
  78. package/src/cli/commands/LogsCommand.js +36 -2
  79. package/src/cli/commands/MakeMailTemplateCommand.d.ts +1 -1
  80. package/src/cli/commands/MakeMailTemplateCommand.d.ts.map +1 -1
  81. package/src/cli/commands/MakeNotificationTemplateCommand.d.ts +1 -1
  82. package/src/cli/commands/MakeNotificationTemplateCommand.d.ts.map +1 -1
  83. package/src/cli/commands/MigrateCommand.d.ts +1 -1
  84. package/src/cli/commands/MigrateCommand.d.ts.map +1 -1
  85. package/src/cli/commands/MigrateCommand.js +291 -35
  86. package/src/cli/commands/NewCommand.d.ts +2 -2
  87. package/src/cli/commands/NewCommand.d.ts.map +1 -1
  88. package/src/cli/commands/NewCommand.js +38 -13
  89. package/src/cli/commands/PluginCommand.d.ts +1 -1
  90. package/src/cli/commands/PluginCommand.d.ts.map +1 -1
  91. package/src/cli/commands/PrepareCommand.d.ts +1 -1
  92. package/src/cli/commands/PrepareCommand.d.ts.map +1 -1
  93. package/src/cli/commands/QACommand.d.ts +2 -2
  94. package/src/cli/commands/QACommand.d.ts.map +1 -1
  95. package/src/cli/commands/RoutesCommand.d.ts +10 -0
  96. package/src/cli/commands/RoutesCommand.d.ts.map +1 -0
  97. package/src/cli/commands/RoutesCommand.js +242 -0
  98. package/src/cli/commands/SimulateCommand.d.ts +1 -1
  99. package/src/cli/commands/SimulateCommand.d.ts.map +1 -1
  100. package/src/cli/commands/SimulateCommand.js +1 -1
  101. package/src/cli/commands/StartCommand.d.ts.map +1 -1
  102. package/src/cli/commands/StartCommand.js +90 -3
  103. package/src/cli/commands/UpgradeCommand.d.ts +16 -0
  104. package/src/cli/commands/UpgradeCommand.d.ts.map +1 -0
  105. package/src/cli/commands/UpgradeCommand.js +107 -0
  106. package/src/cli/commands/index.d.ts +3 -0
  107. package/src/cli/commands/index.d.ts.map +1 -1
  108. package/src/cli/commands/index.js +3 -0
  109. package/src/cli/commands/runner/index.d.ts +3 -0
  110. package/src/cli/commands/runner/index.d.ts.map +1 -0
  111. package/src/cli/commands/runner/index.js +139 -0
  112. package/src/cli/config/ConfigManager.d.ts +1 -1
  113. package/src/cli/config/ConfigManager.d.ts.map +1 -1
  114. package/src/cli/config/ConfigValidator.d.ts +1 -1
  115. package/src/cli/config/ConfigValidator.d.ts.map +1 -1
  116. package/src/cli/config/ConfigValidator.js +1 -1
  117. package/src/cli/d1/D1SqlMigrations.d.ts +20 -0
  118. package/src/cli/d1/D1SqlMigrations.d.ts.map +1 -0
  119. package/src/cli/d1/D1SqlMigrations.js +224 -0
  120. package/src/cli/d1/WranglerConfig.d.ts +4 -0
  121. package/src/cli/d1/WranglerConfig.d.ts.map +1 -0
  122. package/src/cli/d1/WranglerConfig.js +122 -0
  123. package/src/cli/d1/WranglerD1.d.ts +11 -0
  124. package/src/cli/d1/WranglerD1.d.ts.map +1 -0
  125. package/src/cli/d1/WranglerD1.js +16 -0
  126. package/src/cli/env/EnvFileBackfill.d.ts +10 -0
  127. package/src/cli/env/EnvFileBackfill.d.ts.map +1 -0
  128. package/src/cli/env/EnvFileBackfill.js +64 -0
  129. package/src/cli/scaffolding/ControllerGenerator.d.ts.map +1 -1
  130. package/src/cli/scaffolding/ControllerGenerator.js +72 -22
  131. package/src/cli/scaffolding/FactoryGenerator.d.ts.map +1 -1
  132. package/src/cli/scaffolding/FactoryGenerator.js +3 -1
  133. package/src/cli/scaffolding/GovernanceScaffolder.d.ts +23 -0
  134. package/src/cli/scaffolding/GovernanceScaffolder.d.ts.map +1 -0
  135. package/src/cli/scaffolding/GovernanceScaffolder.js +327 -0
  136. package/src/cli/scaffolding/MigrationGenerator.d.ts +10 -0
  137. package/src/cli/scaffolding/MigrationGenerator.d.ts.map +1 -1
  138. package/src/cli/scaffolding/MigrationGenerator.js +137 -51
  139. package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
  140. package/src/cli/scaffolding/ProjectScaffolder.js +54 -59
  141. package/src/cli/scaffolding/RouteGenerator.d.ts.map +1 -1
  142. package/src/cli/scaffolding/RouteGenerator.js +79 -43
  143. package/src/cli/scaffolding/SeederGenerator.d.ts +5 -0
  144. package/src/cli/scaffolding/SeederGenerator.d.ts.map +1 -1
  145. package/src/cli/scaffolding/SeederGenerator.js +63 -15
  146. package/src/cli/scaffolding/ServiceScaffolder.d.ts.map +1 -1
  147. package/src/cli/scaffolding/ServiceScaffolder.js +24 -3
  148. package/src/cli/scaffolding/index.d.ts +2 -0
  149. package/src/cli/scaffolding/index.d.ts.map +1 -1
  150. package/src/cli/scaffolding/index.js +1 -0
  151. package/src/cli/utils/DistPackager.d.ts.map +1 -1
  152. package/src/cli/utils/DistPackager.js +8 -0
  153. package/src/common/index.d.ts +8 -0
  154. package/src/common/index.d.ts.map +1 -1
  155. package/src/common/index.js +28 -0
  156. package/src/common/utility.d.ts +38 -0
  157. package/src/common/utility.d.ts.map +1 -0
  158. package/src/common/utility.js +101 -0
  159. package/src/config/FileLogWriter.d.ts +2 -1
  160. package/src/config/FileLogWriter.d.ts.map +1 -1
  161. package/src/config/FileLogWriter.js +83 -2
  162. package/src/config/app.d.ts.map +1 -1
  163. package/src/config/app.js +3 -1
  164. package/src/config/broadcast.d.ts +1 -1
  165. package/src/config/broadcast.d.ts.map +1 -1
  166. package/src/config/broadcast.js +1 -1
  167. package/src/config/cache.d.ts +1 -1
  168. package/src/config/cache.d.ts.map +1 -1
  169. package/src/config/cloudflare.d.ts +1 -1
  170. package/src/config/cloudflare.d.ts.map +1 -1
  171. package/src/config/database.d.ts +7 -1
  172. package/src/config/database.d.ts.map +1 -1
  173. package/src/config/database.js +99 -7
  174. package/src/config/env.d.ts +6 -0
  175. package/src/config/env.d.ts.map +1 -1
  176. package/src/config/env.js +7 -0
  177. package/src/config/index.d.ts +8 -2
  178. package/src/config/index.d.ts.map +1 -1
  179. package/src/config/logging/KvLogger.js +1 -1
  180. package/src/config/logging/SlackLogger.js +2 -2
  181. package/src/config/middleware.d.ts +22 -2
  182. package/src/config/middleware.d.ts.map +1 -1
  183. package/src/config/middleware.js +179 -11
  184. package/src/config/notification.js +1 -1
  185. package/src/config/security.d.ts +1 -1
  186. package/src/config/security.js +1 -1
  187. package/src/config/storage.js +1 -1
  188. package/src/config/type.d.ts +8 -2
  189. package/src/config/type.d.ts.map +1 -1
  190. package/src/events/EventDispatcher.d.ts.map +1 -1
  191. package/src/events/EventDispatcher.js +6 -4
  192. package/src/exceptions/ZintrustError.d.ts +7 -0
  193. package/src/exceptions/ZintrustError.d.ts.map +1 -1
  194. package/src/exceptions/ZintrustError.js +56 -0
  195. package/src/features/Auth.d.ts +1 -1
  196. package/src/features/Auth.d.ts.map +1 -1
  197. package/src/features/Auth.js +3 -3
  198. package/src/features/Queue.js +1 -1
  199. package/src/functions/cloudflare.d.ts.map +1 -1
  200. package/src/functions/cloudflare.js +3 -14
  201. package/src/functions/deno.d.ts.map +1 -1
  202. package/src/functions/deno.js +3 -14
  203. package/src/functions/lambda.d.ts.map +1 -1
  204. package/src/functions/lambda.js +3 -14
  205. package/src/health/StartupHealthChecks.js +1 -1
  206. package/src/http/Controller.d.ts +2 -2
  207. package/src/http/Controller.d.ts.map +1 -1
  208. package/src/http/FileUpload.d.ts +68 -0
  209. package/src/http/FileUpload.d.ts.map +1 -0
  210. package/src/http/FileUpload.js +120 -0
  211. package/src/http/Kernel.d.ts +5 -5
  212. package/src/http/Kernel.d.ts.map +1 -1
  213. package/src/http/Kernel.js +139 -23
  214. package/src/http/Request.d.ts +20 -1
  215. package/src/http/Request.d.ts.map +1 -1
  216. package/src/http/Request.js +23 -0
  217. package/src/http/RequestContext.d.ts +6 -0
  218. package/src/http/RequestContext.d.ts.map +1 -1
  219. package/src/http/RequestContext.js +77 -1
  220. package/src/http/Response.d.ts +1 -1
  221. package/src/http/Response.d.ts.map +1 -1
  222. package/src/http/ValidationHelper.d.ts +78 -0
  223. package/src/http/ValidationHelper.d.ts.map +1 -0
  224. package/src/http/ValidationHelper.js +121 -0
  225. package/src/http/error-pages/ErrorPageRenderer.d.ts +17 -0
  226. package/src/http/error-pages/ErrorPageRenderer.d.ts.map +1 -0
  227. package/src/http/error-pages/ErrorPageRenderer.js +88 -0
  228. package/src/http/middleware/BodyParsingMiddleware.d.ts +12 -0
  229. package/src/http/middleware/BodyParsingMiddleware.d.ts.map +1 -0
  230. package/src/http/middleware/BodyParsingMiddleware.js +251 -0
  231. package/src/http/middleware/FileUploadMiddleware.d.ts +12 -0
  232. package/src/http/middleware/FileUploadMiddleware.d.ts.map +1 -0
  233. package/src/http/middleware/FileUploadMiddleware.js +74 -0
  234. package/src/http/parsers/BodyParsers.d.ts +32 -0
  235. package/src/http/parsers/BodyParsers.d.ts.map +1 -0
  236. package/src/http/parsers/BodyParsers.js +159 -0
  237. package/src/http/parsers/MultipartParser.d.ts +33 -0
  238. package/src/http/parsers/MultipartParser.d.ts.map +1 -0
  239. package/src/http/parsers/MultipartParser.js +129 -0
  240. package/src/http/parsers/MultipartParserRegistry.d.ts +34 -0
  241. package/src/http/parsers/MultipartParserRegistry.d.ts.map +1 -0
  242. package/src/http/parsers/MultipartParserRegistry.js +20 -0
  243. package/src/http/validated.d.ts +12 -0
  244. package/src/http/validated.d.ts.map +1 -0
  245. package/src/http/validated.js +41 -0
  246. package/src/index.d.ts +65 -7
  247. package/src/index.d.ts.map +1 -1
  248. package/src/index.js +59 -5
  249. package/src/microservices/RequestTracingMiddleware.d.ts +2 -2
  250. package/src/microservices/RequestTracingMiddleware.d.ts.map +1 -1
  251. package/src/microservices/RequestTracingMiddleware.js +3 -0
  252. package/src/microservices/ServiceAuthMiddleware.d.ts +2 -2
  253. package/src/microservices/ServiceAuthMiddleware.d.ts.map +1 -1
  254. package/src/middleware/AuthMiddleware.d.ts +10 -0
  255. package/src/middleware/AuthMiddleware.d.ts.map +1 -0
  256. package/src/middleware/AuthMiddleware.js +16 -0
  257. package/src/middleware/CsrfMiddleware.d.ts +11 -1
  258. package/src/middleware/CsrfMiddleware.d.ts.map +1 -1
  259. package/src/middleware/CsrfMiddleware.js +33 -0
  260. package/src/middleware/JwtAuthMiddleware.d.ts +11 -0
  261. package/src/middleware/JwtAuthMiddleware.d.ts.map +1 -0
  262. package/src/middleware/JwtAuthMiddleware.js +73 -0
  263. package/src/middleware/LoggingMiddleware.d.ts.map +1 -1
  264. package/src/middleware/LoggingMiddleware.js +8 -3
  265. package/src/middleware/MiddlewareStack.d.ts +2 -2
  266. package/src/middleware/MiddlewareStack.d.ts.map +1 -1
  267. package/src/middleware/RateLimiter.d.ts +2 -2
  268. package/src/middleware/RateLimiter.d.ts.map +1 -1
  269. package/src/middleware/RateLimiter.js +26 -1
  270. package/src/middleware/SanitizeBodyMiddleware.d.ts +12 -0
  271. package/src/middleware/SanitizeBodyMiddleware.d.ts.map +1 -0
  272. package/src/middleware/SanitizeBodyMiddleware.js +31 -0
  273. package/src/middleware/SecurityMiddleware.d.ts +1 -1
  274. package/src/middleware/SecurityMiddleware.d.ts.map +1 -1
  275. package/src/middleware/SessionMiddleware.d.ts +1 -1
  276. package/src/middleware/SessionMiddleware.d.ts.map +1 -1
  277. package/src/middleware/ValidationMiddleware.d.ts +25 -0
  278. package/src/middleware/ValidationMiddleware.d.ts.map +1 -0
  279. package/src/middleware/ValidationMiddleware.js +251 -0
  280. package/src/migrations/MigrationDiscovery.d.ts +5 -0
  281. package/src/migrations/MigrationDiscovery.d.ts.map +1 -0
  282. package/src/migrations/MigrationDiscovery.js +16 -0
  283. package/src/migrations/MigrationLoader.d.ts +5 -0
  284. package/src/migrations/MigrationLoader.d.ts.map +1 -0
  285. package/src/migrations/MigrationLoader.js +43 -0
  286. package/src/migrations/MigrationLock.d.ts +4 -0
  287. package/src/migrations/MigrationLock.d.ts.map +1 -0
  288. package/src/migrations/MigrationLock.js +33 -0
  289. package/src/migrations/Migrator.d.ts +23 -0
  290. package/src/migrations/Migrator.d.ts.map +1 -0
  291. package/src/migrations/Migrator.js +4 -0
  292. package/src/migrations/MigratorFactory.d.ts +25 -0
  293. package/src/migrations/MigratorFactory.d.ts.map +1 -0
  294. package/src/migrations/MigratorFactory.js +323 -0
  295. package/src/migrations/schema/Blueprint.d.ts +5 -0
  296. package/src/migrations/schema/Blueprint.d.ts.map +1 -0
  297. package/src/migrations/schema/Blueprint.js +189 -0
  298. package/src/migrations/schema/Schema.d.ts +8 -0
  299. package/src/migrations/schema/Schema.d.ts.map +1 -0
  300. package/src/migrations/schema/Schema.js +141 -0
  301. package/src/migrations/schema/SchemaCompiler.d.ts +20 -0
  302. package/src/migrations/schema/SchemaCompiler.d.ts.map +1 -0
  303. package/src/migrations/schema/SchemaCompiler.js +262 -0
  304. package/src/migrations/schema/index.d.ts +5 -0
  305. package/src/migrations/schema/index.d.ts.map +1 -0
  306. package/src/migrations/schema/index.js +3 -0
  307. package/src/migrations/schema/types.d.ts +86 -0
  308. package/src/migrations/schema/types.d.ts.map +1 -0
  309. package/src/migrations/schema/types.js +1 -0
  310. package/src/migrations/types.d.ts +45 -0
  311. package/src/migrations/types.d.ts.map +1 -0
  312. package/src/migrations/types.js +1 -0
  313. package/src/node-singletons/crypto.d.ts +1 -1
  314. package/src/node-singletons/crypto.d.ts.map +1 -1
  315. package/src/node-singletons/crypto.js +1 -1
  316. package/src/node-singletons/fs.d.ts +2 -2
  317. package/src/node-singletons/fs.d.ts.map +1 -1
  318. package/src/node-singletons/fs.js +1 -1
  319. package/src/node-singletons/util.d.ts +6 -0
  320. package/src/node-singletons/util.d.ts.map +1 -0
  321. package/src/node-singletons/util.js +5 -0
  322. package/src/node.d.ts +2 -0
  323. package/src/node.d.ts.map +1 -1
  324. package/src/node.js +7 -0
  325. package/src/observability/OpenTelemetry.d.ts +62 -0
  326. package/src/observability/OpenTelemetry.d.ts.map +1 -0
  327. package/src/observability/OpenTelemetry.js +167 -0
  328. package/src/observability/PrometheusMetrics.d.ts +25 -0
  329. package/src/observability/PrometheusMetrics.d.ts.map +1 -0
  330. package/src/observability/PrometheusMetrics.js +114 -0
  331. package/src/openapi/OpenApiGenerator.d.ts +68 -0
  332. package/src/openapi/OpenApiGenerator.d.ts.map +1 -0
  333. package/src/openapi/OpenApiGenerator.js +287 -0
  334. package/src/orm/Database.d.ts +4 -2
  335. package/src/orm/Database.d.ts.map +1 -1
  336. package/src/orm/Database.js +142 -29
  337. package/src/orm/DatabaseAdapter.d.ts +13 -0
  338. package/src/orm/DatabaseAdapter.d.ts.map +1 -1
  339. package/src/orm/DatabaseAdapterRegistry.d.ts.map +1 -1
  340. package/src/orm/DatabaseAdapterRegistry.js +3 -1
  341. package/src/orm/DatabaseRuntimeRegistration.d.ts.map +1 -1
  342. package/src/orm/DatabaseRuntimeRegistration.js +4 -0
  343. package/src/orm/Model.d.ts +30 -2
  344. package/src/orm/Model.d.ts.map +1 -1
  345. package/src/orm/Model.js +255 -62
  346. package/src/orm/QueryBuilder.d.ts +22 -1
  347. package/src/orm/QueryBuilder.d.ts.map +1 -1
  348. package/src/orm/QueryBuilder.js +405 -95
  349. package/src/orm/Relationships.d.ts +7 -1
  350. package/src/orm/Relationships.d.ts.map +1 -1
  351. package/src/orm/Relationships.js +18 -0
  352. package/src/orm/SchemaCompiler.d.ts +9 -0
  353. package/src/orm/SchemaCompiler.d.ts.map +1 -0
  354. package/src/orm/SchemaCompiler.js +145 -0
  355. package/src/orm/adapters/D1Adapter.d.ts +1 -1
  356. package/src/orm/adapters/D1Adapter.d.ts.map +1 -1
  357. package/src/orm/adapters/MySQLAdapter.d.ts +1 -1
  358. package/src/orm/adapters/MySQLAdapter.d.ts.map +1 -1
  359. package/src/orm/adapters/MySQLAdapter.js +88 -69
  360. package/src/orm/adapters/PostgreSQLAdapter.d.ts +1 -1
  361. package/src/orm/adapters/PostgreSQLAdapter.d.ts.map +1 -1
  362. package/src/orm/adapters/PostgreSQLAdapter.js +88 -69
  363. package/src/orm/adapters/SQLServerAdapter.d.ts +1 -1
  364. package/src/orm/adapters/SQLServerAdapter.d.ts.map +1 -1
  365. package/src/orm/adapters/SQLiteAdapter.d.ts +1 -1
  366. package/src/orm/adapters/SQLiteAdapter.d.ts.map +1 -1
  367. package/src/orm/adapters/SQLiteAdapter.js +63 -3
  368. package/src/orm/maintenance/SqliteMaintenance.d.ts +5 -0
  369. package/src/orm/maintenance/SqliteMaintenance.d.ts.map +1 -0
  370. package/src/orm/maintenance/SqliteMaintenance.js +14 -0
  371. package/src/orm/migrations/MigrationStore.d.ts +38 -0
  372. package/src/orm/migrations/MigrationStore.d.ts.map +1 -0
  373. package/src/orm/migrations/MigrationStore.js +157 -0
  374. package/src/performance/CodeGenerationBenchmark.d.ts.map +1 -1
  375. package/src/performance/Optimizer.d.ts +1 -0
  376. package/src/performance/Optimizer.d.ts.map +1 -1
  377. package/src/performance/Optimizer.js +37 -3
  378. package/src/profiling/MemoryProfiler.d.ts +1 -1
  379. package/src/profiling/MemoryProfiler.d.ts.map +1 -1
  380. package/src/profiling/N1Detector.d.ts +1 -1
  381. package/src/profiling/N1Detector.d.ts.map +1 -1
  382. package/src/profiling/QueryLogger.d.ts +1 -1
  383. package/src/profiling/QueryLogger.d.ts.map +1 -1
  384. package/src/profiling/RequestProfiler.d.ts +3 -3
  385. package/src/profiling/RequestProfiler.d.ts.map +1 -1
  386. package/src/routes/api.d.ts +2 -0
  387. package/src/routes/api.d.ts.map +1 -0
  388. package/src/routes/api.js +1 -0
  389. package/src/routes/broadcast.d.ts +2 -0
  390. package/src/routes/broadcast.d.ts.map +1 -0
  391. package/src/routes/broadcast.js +1 -0
  392. package/src/routes/health.d.ts +2 -0
  393. package/src/routes/health.d.ts.map +1 -0
  394. package/src/routes/health.js +1 -0
  395. package/src/routes/metrics.d.ts +2 -0
  396. package/src/routes/metrics.d.ts.map +1 -0
  397. package/src/routes/metrics.js +1 -0
  398. package/src/routes/storage.d.ts +2 -0
  399. package/src/routes/storage.d.ts.map +1 -0
  400. package/src/routes/storage.js +1 -0
  401. package/src/routing/CoreRoutes.d.ts +12 -0
  402. package/src/routing/CoreRoutes.d.ts.map +1 -0
  403. package/src/routing/CoreRoutes.js +151 -0
  404. package/src/routing/RouteRegistry.d.ts +39 -0
  405. package/src/routing/RouteRegistry.d.ts.map +1 -0
  406. package/src/routing/RouteRegistry.js +44 -0
  407. package/src/routing/Router.d.ts +26 -9
  408. package/src/routing/Router.d.ts.map +1 -1
  409. package/src/routing/Router.js +79 -35
  410. package/src/routing/common.d.ts +15 -0
  411. package/src/routing/common.d.ts.map +1 -0
  412. package/src/routing/common.js +47 -0
  413. package/src/routing/doc.d.ts +28 -0
  414. package/src/routing/doc.d.ts.map +1 -0
  415. package/src/routing/doc.js +95 -0
  416. package/src/routing/error.d.ts +21 -0
  417. package/src/routing/error.d.ts.map +1 -0
  418. package/src/routing/error.js +126 -0
  419. package/src/routing/errorPages.d.ts +14 -0
  420. package/src/routing/errorPages.d.ts.map +1 -0
  421. package/src/routing/errorPages.js +103 -0
  422. package/src/routing/publicRoot.d.ts +18 -0
  423. package/src/routing/publicRoot.d.ts.map +1 -0
  424. package/src/routing/publicRoot.js +49 -0
  425. package/src/runtime/PluginAutoImports.d.ts +21 -0
  426. package/src/runtime/PluginAutoImports.d.ts.map +1 -0
  427. package/src/runtime/PluginAutoImports.js +59 -0
  428. package/src/runtime/PluginManager.d.ts +1 -5
  429. package/src/runtime/PluginManager.d.ts.map +1 -1
  430. package/src/runtime/PluginManager.js +25 -18
  431. package/src/runtime/RuntimeAdapter.d.ts.map +1 -1
  432. package/src/runtime/RuntimeAdapter.js +20 -1
  433. package/src/runtime/RuntimeDetector.d.ts +1 -1
  434. package/src/runtime/RuntimeDetector.d.ts.map +1 -1
  435. package/src/runtime/adapters/CloudflareAdapter.d.ts +1 -1
  436. package/src/runtime/adapters/CloudflareAdapter.d.ts.map +1 -1
  437. package/src/runtime/adapters/CloudflareAdapter.js +1 -1
  438. package/src/runtime/adapters/DenoAdapter.d.ts +1 -1
  439. package/src/runtime/adapters/DenoAdapter.d.ts.map +1 -1
  440. package/src/runtime/adapters/DenoAdapter.js +3 -3
  441. package/src/runtime/adapters/LambdaAdapter.d.ts +1 -1
  442. package/src/runtime/adapters/LambdaAdapter.d.ts.map +1 -1
  443. package/src/runtime/adapters/LambdaAdapter.js +1 -1
  444. package/src/runtime/adapters/NodeServerAdapter.d.ts +1 -1
  445. package/src/runtime/adapters/NodeServerAdapter.d.ts.map +1 -1
  446. package/src/runtime/getKernel.d.ts +9 -0
  447. package/src/runtime/getKernel.d.ts.map +1 -0
  448. package/src/runtime/getKernel.js +27 -0
  449. package/src/scripts/TemplateImportsCheck.js +47 -7
  450. package/src/scripts/TemplateSync.js +92 -20
  451. package/src/security/Encryptor.d.ts.map +1 -1
  452. package/src/security/Encryptor.js +64 -7
  453. package/src/security/JwtManager.d.ts +1 -0
  454. package/src/security/JwtManager.d.ts.map +1 -1
  455. package/src/security/JwtManager.js +33 -0
  456. package/src/security/Sanitizer.d.ts +76 -0
  457. package/src/security/Sanitizer.d.ts.map +1 -0
  458. package/src/security/Sanitizer.js +412 -0
  459. package/src/security/TokenRevocation.d.ts +7 -0
  460. package/src/security/TokenRevocation.d.ts.map +1 -0
  461. package/src/security/TokenRevocation.js +57 -0
  462. package/src/seeders/SeederDiscovery.d.ts +5 -0
  463. package/src/seeders/SeederDiscovery.d.ts.map +1 -0
  464. package/src/seeders/SeederDiscovery.js +21 -0
  465. package/src/seeders/SeederLoader.d.ts +5 -0
  466. package/src/seeders/SeederLoader.d.ts.map +1 -0
  467. package/src/seeders/SeederLoader.js +60 -0
  468. package/src/seeders/types.d.ts +18 -0
  469. package/src/seeders/types.d.ts.map +1 -0
  470. package/src/seeders/types.js +1 -0
  471. package/src/session/SessionManager.js +1 -1
  472. package/src/start.d.ts +21 -0
  473. package/src/start.d.ts.map +1 -0
  474. package/src/start.js +60 -0
  475. package/src/templates/adapters/MySQLAdapter.ts.tpl +109 -85
  476. package/src/templates/adapters/PostgreSQLAdapter.ts.tpl +129 -88
  477. package/src/templates/adapters/SQLServerAdapter.ts.tpl +5 -9
  478. package/src/templates/adapters/SQLiteAdapter.ts.tpl +78 -11
  479. package/src/templates/features/Queue.ts.tpl +2 -2
  480. package/src/templates/project/basic/app/Controllers/AuthController.ts.tpl +217 -0
  481. package/src/templates/project/basic/app/Controllers/UserController.ts.tpl +3 -16
  482. package/src/templates/project/basic/app/Middleware/ProfilerMiddleware.ts.tpl +1 -3
  483. package/src/templates/project/basic/app/Middleware/index.ts.tpl +3 -8
  484. package/src/templates/project/basic/app/Models/Post.ts.tpl +2 -3
  485. package/src/templates/project/basic/app/Models/User.ts.tpl +1 -1
  486. package/src/templates/project/basic/app/Types/controller.ts.tpl +46 -0
  487. package/src/templates/project/basic/config/FileLogWriter.ts.tpl +5 -236
  488. package/src/templates/project/basic/config/SecretsManager.ts.tpl +13 -450
  489. package/src/templates/project/basic/config/StartupConfigValidator.ts.tpl +9 -268
  490. package/src/templates/project/basic/config/app.ts.tpl +13 -153
  491. package/src/templates/project/basic/config/broadcast.ts.tpl +15 -129
  492. package/src/templates/project/basic/config/cache.ts.tpl +15 -92
  493. package/src/templates/project/basic/config/cloudflare.ts.tpl +4 -39
  494. package/src/templates/project/basic/config/constants.ts.tpl +9 -65
  495. package/src/templates/project/basic/config/database.ts.tpl +29 -116
  496. package/src/templates/project/basic/config/env.ts.tpl +5 -169
  497. package/src/templates/project/basic/config/features.ts.tpl +6 -54
  498. package/src/templates/project/basic/config/index.ts.tpl +27 -24
  499. package/src/templates/project/basic/config/logger.ts.tpl +5 -381
  500. package/src/templates/project/basic/config/logging/HttpLogger.ts.tpl +1 -1
  501. package/src/templates/project/basic/config/logging/KvLogger.ts.tpl +2 -2
  502. package/src/templates/project/basic/config/logging/SlackLogger.ts.tpl +1 -1
  503. package/src/templates/project/basic/config/mail.ts.tpl +15 -115
  504. package/src/templates/project/basic/config/microservices.ts.tpl +11 -97
  505. package/src/templates/project/basic/config/middleware.ts.tpl +27 -18
  506. package/src/templates/project/basic/config/notification.ts.tpl +14 -127
  507. package/src/templates/project/basic/config/queue.ts.tpl +16 -79
  508. package/src/templates/project/basic/config/security.ts.tpl +11 -163
  509. package/src/templates/project/basic/config/startup.ts.tpl +10 -21
  510. package/src/templates/project/basic/config/storage.ts.tpl +15 -133
  511. package/src/templates/project/basic/config/type.ts.tpl +33 -441
  512. package/src/templates/project/basic/database/factories/UserFactory.ts.tpl +80 -0
  513. package/src/templates/project/basic/database/migrations/create_tasks_table.ts.tpl +28 -0
  514. package/src/templates/project/basic/database/migrations/create_users_table.ts.tpl +29 -0
  515. package/src/templates/project/basic/database/seeders/DatabaseSeeder.ts.tpl +19 -0
  516. package/src/templates/project/basic/database/seeders/UserSeeder.ts.tpl +18 -0
  517. package/src/templates/project/basic/database/seeders/index.ts.tpl +2 -0
  518. package/src/templates/project/basic/package.json.tpl +1 -1
  519. package/src/templates/project/basic/routes/api.ts.tpl +74 -36
  520. package/src/templates/project/basic/routes/health.ts.tpl +1 -6
  521. package/src/templates/project/basic/routes/metrics.ts.tpl +22 -0
  522. package/src/templates/project/basic/src/index.ts.tpl +7 -80
  523. package/src/templates/project/basic/tsconfig.json.tpl +12 -13
  524. package/src/testing/TestEnvironment.d.ts +40 -0
  525. package/src/testing/TestEnvironment.d.ts.map +1 -0
  526. package/src/testing/TestEnvironment.js +141 -0
  527. package/src/testing/TestHttp.d.ts +29 -0
  528. package/src/testing/TestHttp.d.ts.map +1 -0
  529. package/src/testing/TestHttp.js +96 -0
  530. package/src/testing/index.d.ts +5 -0
  531. package/src/testing/index.d.ts.map +1 -0
  532. package/src/testing/index.js +2 -0
  533. package/src/time/DateTime.d.ts +181 -0
  534. package/src/time/DateTime.d.ts.map +1 -0
  535. package/src/time/DateTime.js +300 -0
  536. package/src/time/index.d.ts +7 -0
  537. package/src/time/index.d.ts.map +1 -0
  538. package/src/time/index.js +5 -0
  539. package/src/tools/http/Http.d.ts.map +1 -1
  540. package/src/tools/http/Http.js +4 -0
  541. package/src/tools/mail/drivers/Smtp.js +1 -1
  542. package/src/tools/queue/drivers/InMemory.d.ts +1 -1
  543. package/src/tools/queue/drivers/InMemory.d.ts.map +1 -1
  544. package/src/tools/queue/drivers/InMemory.js +1 -1
  545. package/src/tools/queue/drivers/Redis.d.ts +1 -1
  546. package/src/tools/queue/drivers/Redis.d.ts.map +1 -1
  547. package/src/tools/queue/drivers/Redis.js +1 -1
  548. package/src/validation/ValidationError.d.ts.map +1 -1
  549. package/src/validation/ValidationError.js +4 -2
  550. package/src/validation/Validator.d.ts +49 -16
  551. package/src/validation/Validator.d.ts.map +1 -1
  552. package/src/validation/Validator.js +307 -5
  553. package/src/common/uuid.d.ts +0 -3
  554. package/src/common/uuid.d.ts.map +0 -1
  555. package/src/common/uuid.js +0 -30
  556. package/src/templates/project/basic/.env.example.tpl +0 -74
  557. package/src/templates/project/basic/.env.tpl +0 -166
  558. package/src/templates/project/basic/database/migrations/index.ts.tpl +0 -2
@@ -1,100 +1,23 @@
1
1
  /**
2
- * Cache Configuration
3
- * Caching drivers and settings
4
- * Sealed namespace for immutability
2
+ * Cache Configuration (template)
3
+ *
4
+ * Keep this file declarative:
5
+ * - Core owns env parsing/default logic.
6
+ * - Projects can override values by editing `drivers` and `cacheConfigObj`.
5
7
  */
6
8
 
7
- import { Env } from './env';
8
- import { CacheConfigInput, CacheDriverConfig } from './type';
9
- import { ErrorFactory } from '@zintrust/core';
9
+ import { cacheConfig as coreCacheConfig } from '@zintrust/core';
10
10
 
11
- const getCacheDriver = (config: CacheConfigInput, name?: string): CacheDriverConfig => {
12
- const selected = String(name ?? config.default).trim();
13
- const storeName = selected === 'default' ? String(config.default).trim() : selected;
14
- const isExplicitSelection =
15
- name !== undefined && String(name).trim().length > 0 && String(name).trim() !== 'default';
11
+ type CacheConfigShape = typeof coreCacheConfig;
16
12
 
17
- if (storeName.length > 0 && Object.hasOwn(config.drivers, storeName)) {
18
- const resolved = (config.drivers as Record<string, CacheDriverConfig>)[storeName];
19
- if (resolved !== undefined) return resolved;
20
- }
13
+ export const drivers = {
14
+ ...coreCacheConfig.drivers,
15
+ } satisfies CacheConfigShape['drivers'];
21
16
 
22
- if (isExplicitSelection) {
23
- throw ErrorFactory.createConfigError(`Cache store not configured: ${storeName}`);
24
- }
17
+ export const cacheConfigObj = {
18
+ ...coreCacheConfig,
19
+ drivers,
20
+ } satisfies CacheConfigShape;
25
21
 
26
- if (Object.keys(config.drivers ?? {}).length === 0) {
27
- throw ErrorFactory.createConfigError('No cache stores are configured');
28
- }
29
-
30
- throw ErrorFactory.createConfigError(
31
- `Cache default store not configured: ${storeName || '<empty>'}`
32
- );
33
- };
34
-
35
- const cacheConfigObj = {
36
- /**
37
- * Default cache driver
38
- */
39
- default: (() => {
40
- const envConnection = Env.get('CACHE_CONNECTION', '').trim();
41
-
42
- const envDriver =
43
- typeof (Env as unknown as { CACHE_DRIVER?: unknown }).CACHE_DRIVER === 'string'
44
- ? String((Env as unknown as { CACHE_DRIVER?: unknown }).CACHE_DRIVER)
45
- : Env.get('CACHE_DRIVER', 'memory');
46
-
47
- const selected = envConnection.length > 0 ? envConnection : String(envDriver ?? 'memory');
48
- return selected.trim().toLowerCase();
49
- })(),
50
-
51
- /**
52
- * Cache drivers
53
- */
54
- drivers: {
55
- memory: {
56
- driver: 'memory' as const,
57
- ttl: Env.getInt('CACHE_MEMORY_TTL', 3600),
58
- },
59
- redis: {
60
- driver: 'redis' as const,
61
- host: Env.get('REDIS_HOST', 'localhost'),
62
- port: Env.getInt('REDIS_PORT', 6379),
63
- ttl: Env.getInt('CACHE_REDIS_TTL', 3600),
64
- },
65
- mongodb: {
66
- driver: 'mongodb' as const,
67
- uri: Env.get('MONGO_URI'),
68
- db: Env.get('MONGO_DB', 'zintrust_cache'),
69
- ttl: Env.getInt('CACHE_MONGO_TTL', 3600),
70
- },
71
- kv: {
72
- driver: 'kv' as const,
73
- ttl: Env.getInt('CACHE_KV_TTL', 3600),
74
- },
75
- 'kv-remote': {
76
- driver: 'kv-remote' as const,
77
- ttl: Env.getInt('CACHE_KV_TTL', 3600),
78
- },
79
- },
80
-
81
- /**
82
- * Get cache driver config
83
- */
84
- getDriver(name?: string): CacheDriverConfig {
85
- return getCacheDriver(this, name);
86
- },
87
-
88
- /**
89
- * Key prefix for all cache keys
90
- */
91
- keyPrefix: Env.get('CACHE_KEY_PREFIX', 'zintrust:'),
92
-
93
- /**
94
- * Default cache TTL (seconds)
95
- */
96
- ttl: Env.getInt('CACHE_DEFAULT_TTL', 3600),
97
- };
98
-
99
- export const cacheConfig = Object.freeze(cacheConfigObj);
22
+ export const cacheConfig = cacheConfigObj;
100
23
  export type CacheConfig = typeof cacheConfig;
@@ -1,43 +1,8 @@
1
1
  /**
2
- * Cloudflare Workers Environment Access
2
+ * Cloudflare Workers helpers (template)
3
3
  *
4
- * Centralizes access to Workers bindings via globalThis.env.
5
- * This keeps runtime-specific globals out of adapters/drivers.
4
+ * Keep this file declarative:
5
+ * - Core owns runtime-specific binding logic.
6
6
  */
7
7
 
8
- import { KVNamespace, WorkersEnv } from './type';
9
- import type { DatabaseConfig, ID1Database } from '@zintrust/core';
10
-
11
- const getWorkersEnv = (): WorkersEnv | null => {
12
- const env = (globalThis as unknown as { env?: unknown }).env;
13
- if (env === undefined || env === null) return null;
14
- if (typeof env !== 'object') return null;
15
- return env as WorkersEnv;
16
- };
17
-
18
- const getD1Binding = (config: DatabaseConfig): ID1Database | null => {
19
- if (config.d1 !== undefined && config.d1 !== null) return config.d1;
20
-
21
- const env = getWorkersEnv();
22
- const envDb = env === null ? undefined : (env['DB'] as ID1Database | undefined);
23
- if (envDb !== undefined) return envDb;
24
-
25
- const globalDb = (globalThis as unknown as { DB?: ID1Database }).DB;
26
- if (globalDb !== undefined) return globalDb;
27
-
28
- return null;
29
- };
30
-
31
- const getKVBinding = (bindingName = 'CACHE'): KVNamespace | null => {
32
- const env = getWorkersEnv();
33
- if (env === null) return null;
34
-
35
- const kv = env[bindingName] as KVNamespace | undefined;
36
- return kv ?? null;
37
- };
38
-
39
- export const Cloudflare = Object.freeze({
40
- getWorkersEnv,
41
- getD1Binding,
42
- getKVBinding,
43
- });
8
+ export { Cloudflare } from '@zintrust/core';
@@ -1,70 +1,14 @@
1
1
  /**
2
- * Framework Constants
3
- * Centralized string literals to prevent duplication (SonarQube S1192)
4
- * Sealed namespace for immutability
2
+ * Framework Constants (template)
3
+ *
4
+ * Keep this file declarative:
5
+ * - Core owns canonical constants.
5
6
  */
6
7
 
7
- const HTTP_HEADERS = {
8
- CONTENT_TYPE: 'Content-Type',
9
- ACCEPT: 'Accept',
10
- AUTHORIZATION: 'Authorization',
11
- X_TRACE_ID: 'X-Trace-Id',
12
- X_SERVICE_CALL: 'X-Service-Call',
13
- X_POWERED_BY: 'X-Powered-By',
14
- X_CONTENT_TYPE_OPTIONS: 'X-Content-Type-Options',
15
- X_FRAME_OPTIONS: 'X-Frame-Options',
16
- X_XSS_PROTECTION: 'X-XSS-Protection',
17
- REFERRER_POLICY: 'Referrer-Policy',
18
- CONTENT_SECURITY_POLICY: 'Content-Security-Policy',
19
- } as const;
20
-
21
- const MIME_TYPES = {
22
- JSON: 'application/json',
23
- HTML: 'text/html',
24
- TEXT: 'text/plain',
25
- JS: 'text/javascript',
26
- CSS: 'text/css',
27
- PNG: 'image/png',
28
- JPG: 'image/jpg',
29
- GIF: 'image/gif',
30
- SVG: 'image/svg+xml',
31
- WAV: 'audio/wav',
32
- MP4: 'video/mp4',
33
- WOFF: 'application/font-woff',
34
- TTF: 'application/font-ttf',
35
- EOT: 'application/vnd.ms-fontobject',
36
- OTF: 'application/font-otf',
37
- WASM: 'application/wasm',
38
- } as const;
39
-
40
- const ENV_KEYS = {
41
- NODE_ENV: 'NODE_ENV',
42
- PORT: 'PORT',
43
- HOST: 'HOST',
44
- APP_NAME: 'APP_NAME',
45
- DB_CONNECTION: 'DB_CONNECTION',
46
- DB_HOST: 'DB_HOST',
47
- DB_PORT: 'DB_PORT',
48
- DB_DATABASE: 'DB_DATABASE',
49
- DB_USERNAME: 'DB_USERNAME',
50
- DB_PASSWORD: 'DB_PASSWORD', // NOSONARQUBE
51
- } as const;
52
-
53
- const DEFAULTS = {
54
- CONNECTION: 'default',
55
- DOMAIN: 'default',
56
- NAMESPACE: 'default',
57
- } as const;
58
-
59
- /**
60
- * Constants namespace - sealed for immutability
61
- */
62
- export const Constants = Object.freeze({
8
+ export {
9
+ Constants,
10
+ DEFAULTS,
11
+ ENV_KEYS,
63
12
  HTTP_HEADERS,
64
13
  MIME_TYPES,
65
- ENV_KEYS,
66
- DEFAULTS,
67
- });
68
-
69
- // Re-export for backward compatibility
70
- export { DEFAULTS, ENV_KEYS, HTTP_HEADERS, MIME_TYPES };
14
+ } from '@zintrust/core';
@@ -1,125 +1,38 @@
1
1
  /**
2
- * Database Configuration
3
- * Database connections and pooling settings
4
- * Sealed namespace for immutability
2
+ * Database Configuration (template)
3
+ *
4
+ * This file is intentionally kept simple and editable:
5
+ * - Developers can add/remove connections in `connections`.
6
+ * - Developers can edit `databaseConfigObj` to customize behavior.
7
+ *
8
+ * Core owns the default logic (sqlite path/name resolution, env handling, etc.).
5
9
  */
6
10
 
7
- import { Env } from './env';
8
- import { DatabaseConfigShape, DatabaseConnectionConfig, DatabaseConnections } from './type';
9
- import { ErrorFactory } from '@zintrust/core';
11
+ import { databaseConfig as coreDatabaseConfig } from '@zintrust/core';
12
+ import type { DatabaseConfigShape, DatabaseConnections } from '@zintrust/core';
10
13
 
11
- const hasOwn = (obj: Record<string, unknown>, key: string): boolean => {
12
- return Object.prototype.hasOwnProperty.call(obj, key);
13
- };
14
-
15
- const getDefaultConnection = (connections: DatabaseConnections): string => {
16
- const envSelectedRaw = Env.get('DB_CONNECTION', '');
17
- const value = String(envSelectedRaw ?? '').trim();
18
-
19
- if (value.length > 0 && hasOwn(connections, value)) return value;
20
-
21
- if (envSelectedRaw.trim().length > 0) {
22
- throw ErrorFactory.createConfigError(`Database connection not configured: ${value}`);
23
- }
24
-
25
- return hasOwn(connections, 'sqlite') ? 'sqlite' : (Object.keys(connections)[0] ?? 'sqlite');
26
- };
27
-
28
- const getDatabaseConnection = (config: DatabaseConfigShape): DatabaseConnectionConfig => {
29
- const connName = config.default;
30
- const resolved = config.connections[connName];
31
- if (resolved !== undefined) return resolved;
32
-
33
- // Backwards-compatible fallback.
34
- const sqliteFallback = config.connections['sqlite'];
35
- if (sqliteFallback !== undefined) return sqliteFallback;
36
-
37
- const first = Object.values(config.connections)[0];
38
- if (first !== undefined) return first;
39
-
40
- throw ErrorFactory.createConfigError(
41
- `No database connections are configured (default='${connName}').`
42
- );
43
- };
44
-
45
- const connections = {
46
- sqlite: {
47
- driver: 'sqlite' as const,
48
- database: Env.DB_DATABASE,
49
- migrations: 'database/migrations',
50
- },
51
- postgresql: {
52
- driver: 'postgresql' as const,
53
- host: Env.DB_HOST,
54
- port: Env.DB_PORT,
55
- database: Env.DB_DATABASE,
56
- username: Env.DB_USERNAME,
57
- password: Env.DB_PASSWORD,
58
- ssl: Env.getBool('DB_SSL', false),
59
- pooling: {
60
- enabled: Env.getBool('DB_POOLING', true),
61
- min: Env.getInt('DB_POOL_MIN', 5),
62
- max: Env.getInt('DB_POOL_MAX', 20),
63
- idleTimeout: Env.getInt('DB_IDLE_TIMEOUT', 30000),
64
- connectionTimeout: Env.getInt('DB_CONNECTION_TIMEOUT', 10000),
65
- },
66
- },
67
- mysql: {
68
- driver: 'mysql' as const,
69
- host: Env.DB_HOST,
70
- port: Env.DB_PORT,
71
- database: Env.DB_DATABASE,
72
- username: Env.DB_USERNAME,
73
- password: Env.DB_PASSWORD,
74
- pooling: {
75
- enabled: Env.getBool('DB_POOLING', true),
76
- min: Env.getInt('DB_POOL_MIN', 5),
77
- max: Env.getInt('DB_POOL_MAX', 20),
78
- },
79
- },
14
+ /**
15
+ * Editable connections map.
16
+ *
17
+ * Defaults are sourced from core so you inherit framework-safe behavior.
18
+ */
19
+ export const connections = {
20
+ sqlite: coreDatabaseConfig.connections.sqlite,
21
+ d1: coreDatabaseConfig.connections.d1,
22
+ 'd1-remote': coreDatabaseConfig.connections['d1-remote'],
23
+ postgresql: coreDatabaseConfig.connections.postgresql,
24
+ mysql: coreDatabaseConfig.connections.mysql,
80
25
  } satisfies DatabaseConnections;
81
26
 
82
- const databaseConfigObj = {
83
- /**
84
- * Default database connection
85
- */
86
- default: getDefaultConnection(connections),
87
-
88
- /**
89
- * Database connections
90
- */
27
+ /**
28
+ * Editable database config object.
29
+ *
30
+ * You can override any top-level keys from core, while keeping core defaults.
31
+ */
32
+ export const databaseConfigObj = {
33
+ ...coreDatabaseConfig,
91
34
  connections,
35
+ } satisfies DatabaseConfigShape;
92
36
 
93
- /**
94
- * Get current connection config
95
- */
96
- getConnection(this: DatabaseConfigShape): DatabaseConnectionConfig {
97
- return getDatabaseConnection(this);
98
- },
99
-
100
- /**
101
- * Enable query logging
102
- */
103
- logging: {
104
- enabled: Env.DEBUG,
105
- level: Env.get('DB_LOG_LEVEL', 'debug'),
106
- },
107
-
108
- /**
109
- * Migration settings
110
- */
111
- migrations: {
112
- directory: 'database/migrations',
113
- extension: Env.get('DB_MIGRATION_EXT', '.ts'),
114
- },
115
-
116
- /**
117
- * Seeding settings
118
- */
119
- seeders: {
120
- directory: 'database/seeders',
121
- },
122
- };
123
-
124
- export const databaseConfig = Object.freeze(databaseConfigObj);
37
+ export const databaseConfig = databaseConfigObj;
125
38
  export type DatabaseConfig = typeof databaseConfig;
@@ -1,173 +1,9 @@
1
1
  /**
2
- * Environment Configuration
3
- * Type-safe access to environment variables
2
+ * Environment Configuration (template)
4
3
  *
5
- * Sealed namespace pattern - all exports through Env namespace
6
- * Safe for both Node.js and serverless runtimes (Cloudflare Workers, Deno, Lambda)
4
+ * Keep this file declarative:
5
+ * - Core owns env parsing/default logic.
6
+ * - Projects should import `Env` from here (re-exported from core).
7
7
  */
8
8
 
9
- import { ProcessLike } from './type';
10
-
11
- const getProcessLike = (): ProcessLike | undefined => {
12
- return typeof process === 'undefined' ? undefined : (process as unknown as ProcessLike);
13
- };
14
-
15
- const dirnameFromExecPath = (execPath: string, platform?: string): string => {
16
- const separator = platform === 'win32' ? '\\' : '/';
17
- const lastSep = execPath.lastIndexOf(separator);
18
- if (lastSep <= 0) return '';
19
- return execPath.slice(0, lastSep);
20
- };
21
-
22
- // Private helper functions
23
- const get = (key: string, defaultValue?: string): string => {
24
- const proc = getProcessLike();
25
- const env = proc?.env ?? {};
26
- return env[key] ?? defaultValue ?? '';
27
- };
28
-
29
- const getInt = (key: string, defaultValue?: number): number => {
30
- const proc = getProcessLike();
31
- const env = proc?.env ?? {};
32
- const value = env[key];
33
- if (value === undefined || value === null) return defaultValue ?? 0;
34
- if (typeof value === 'string' && value.trim() === '') return defaultValue ?? 0;
35
- return Number.parseInt(value, 10);
36
- };
37
-
38
- const getBool = (key: string, defaultValue?: boolean): boolean => {
39
- const proc = getProcessLike();
40
- const env = proc?.env ?? {};
41
- const value = env[key];
42
- if (value === undefined || value === null) return defaultValue ?? false;
43
- return value.toLowerCase() === 'true' || value === '1';
44
- };
45
-
46
- const getDefaultLogLevel = (): 'debug' | 'info' | 'warn' | 'error' => {
47
- const NODE_ENV_VALUE = get('NODE_ENV', 'development');
48
- if (NODE_ENV_VALUE === 'production') return 'info';
49
- if (NODE_ENV_VALUE === 'testing') return 'error';
50
- return 'debug';
51
- };
52
-
53
- // Sealed namespace with all environment configuration
54
- export const Env = Object.freeze({
55
- // Helper functions
56
- get,
57
- getInt,
58
- getBool,
59
-
60
- // Core
61
- NODE_ENV: get('NODE_ENV', 'development'),
62
- // Prefer PORT, fallback to APP_PORT for compatibility
63
- PORT: getInt('PORT', getInt('APP_PORT', 3000)),
64
- HOST: get('HOST', 'localhost'),
65
- APP_NAME: get('APP_NAME', 'ZinTrust'),
66
- APP_KEY: get('APP_KEY', ''),
67
- // Optional key rotation support (comma-separated or JSON array of keys)
68
- APP_PREVIOUS_KEYS: get('APP_PREVIOUS_KEYS', ''),
69
-
70
- // Database
71
- DB_CONNECTION: get('DB_CONNECTION', 'sqlite'),
72
- DB_HOST: get('DB_HOST', 'localhost'),
73
- DB_PORT: getInt('DB_PORT', 5432),
74
- // Accept DB_PATH as an alias for sqlite file path (many env templates use it).
75
- DB_DATABASE: get('DB_DATABASE', get('DB_PATH', 'zintrust')),
76
- DB_USERNAME: get('DB_USERNAME', 'postgres'),
77
- DB_PASSWORD: get('DB_PASSWORD', ''),
78
- DB_READ_HOSTS: get('DB_READ_HOSTS', ''),
79
-
80
- // Cloudflare
81
- D1_DATABASE_ID: get('D1_DATABASE_ID'),
82
- KV_NAMESPACE_ID: get('KV_NAMESPACE_ID'),
83
-
84
- // Cloudflare proxy services (D1/KV outside Cloudflare)
85
- D1_REMOTE_URL: get('D1_REMOTE_URL', ''),
86
- D1_REMOTE_KEY_ID: get('D1_REMOTE_KEY_ID', ''),
87
- D1_REMOTE_SECRET: get('D1_REMOTE_SECRET', ''),
88
- D1_REMOTE_MODE: get('D1_REMOTE_MODE', 'registry'),
89
-
90
- KV_REMOTE_URL: get('KV_REMOTE_URL', ''),
91
- KV_REMOTE_KEY_ID: get('KV_REMOTE_KEY_ID', ''),
92
- KV_REMOTE_SECRET: get('KV_REMOTE_SECRET', ''),
93
- KV_REMOTE_NAMESPACE: get('KV_REMOTE_NAMESPACE', ''),
94
-
95
- // Proxy client tuning
96
- ZT_PROXY_SIGNING_WINDOW_MS: getInt('ZT_PROXY_SIGNING_WINDOW_MS', 60000),
97
- ZT_PROXY_TIMEOUT_MS: getInt('ZT_PROXY_TIMEOUT_MS', 30000),
98
-
99
- // Cache
100
- CACHE_DRIVER: get('CACHE_DRIVER', 'memory'),
101
- REDIS_HOST: get('REDIS_HOST', 'localhost'),
102
- REDIS_PORT: getInt('REDIS_PORT', 6379),
103
- REDIS_PASSWORD: get('REDIS_PASSWORD', ''),
104
- MONGO_URI: get('MONGO_URI'),
105
- MONGO_DB: get('MONGO_DB', 'zintrust_cache'),
106
-
107
- // AWS
108
- AWS_REGION: get('AWS_REGION', 'us-east-1'),
109
- AWS_LAMBDA_FUNCTION_NAME: get('AWS_LAMBDA_FUNCTION_NAME'),
110
- AWS_LAMBDA_FUNCTION_VERSION: get('AWS_LAMBDA_FUNCTION_VERSION'),
111
- AWS_EXECUTION_ENV: get('AWS_EXECUTION_ENV'),
112
- LAMBDA_TASK_ROOT: get('LAMBDA_TASK_ROOT'),
113
-
114
- // Microservices
115
- MICROSERVICES: get('MICROSERVICES'),
116
- SERVICES: get('SERVICES'),
117
- MICROSERVICES_TRACING: getBool('MICROSERVICES_TRACING'),
118
- MICROSERVICES_TRACING_RATE: Number.parseFloat(get('MICROSERVICES_TRACING_RATE', '1.0')),
119
- DATABASE_ISOLATION: get('DATABASE_ISOLATION', 'shared'),
120
- SERVICE_API_KEY: get('SERVICE_API_KEY'),
121
- SERVICE_JWT_SECRET: get('SERVICE_JWT_SECRET'),
122
-
123
- // Security
124
- DEBUG: getBool('DEBUG', false),
125
- ENABLE_MICROSERVICES: getBool('ENABLE_MICROSERVICES', false),
126
- TOKEN_TTL: getInt('TOKEN_TTL', 3600000),
127
- TOKEN_LENGTH: getInt('TOKEN_LENGTH', 32),
128
-
129
- // Encryption interop
130
- ENCRYPTION_CIPHER: get('ENCRYPTION_CIPHER', ''),
131
-
132
- // Deployment
133
- ENVIRONMENT: get('ENVIRONMENT', 'development'),
134
- REQUEST_TIMEOUT: getInt('REQUEST_TIMEOUT', 30000),
135
- MAX_BODY_SIZE: getInt('MAX_BODY_SIZE', 10485760),
136
- SHUTDOWN_TIMEOUT: getInt('SHUTDOWN_TIMEOUT', 10000),
137
-
138
- // Logging
139
- LOG_LEVEL: get('LOG_LEVEL', getDefaultLogLevel()) as 'debug' | 'info' | 'warn' | 'error',
140
- LOG_FORMAT: get('LOG_FORMAT', 'text'),
141
- DISABLE_LOGGING: getBool('DISABLE_LOGGING', false),
142
- LOG_HTTP_REQUEST: getBool('LOG_HTTP_REQUEST', false),
143
- LOG_TO_FILE: getBool('LOG_TO_FILE', false),
144
- LOG_ROTATION_SIZE: getInt('LOG_ROTATION_SIZE', 10485760),
145
- LOG_ROTATION_DAYS: getInt('LOG_ROTATION_DAYS', 7),
146
-
147
- // Paths (safely constructed for Node.js environments)
148
- NODE_BIN_DIR: (() => {
149
- try {
150
- const proc = getProcessLike();
151
- if (proc?.execPath === null || proc?.execPath === undefined) return '';
152
- return dirnameFromExecPath(proc.execPath, proc.platform);
153
- } catch {
154
- // Fallback for non-Node environments
155
- return '';
156
- }
157
- })(),
158
- SAFE_PATH: (() => {
159
- try {
160
- const proc = getProcessLike();
161
- if (proc?.execPath === null || proc?.execPath === undefined) return '';
162
-
163
- const binDir = dirnameFromExecPath(proc.execPath, proc.platform);
164
- if (proc.platform === 'win32') {
165
- return [String.raw`C:\Windows\System32`, String.raw`C:\Windows`, binDir].join(';');
166
- }
167
- return ['/usr/bin', '/bin', '/usr/sbin', '/sbin', binDir].join(':');
168
- } catch {
169
- // Fallback for non-Node environments
170
- return '';
171
- }
172
- })(),
173
- });
9
+ export { Env } from '@zintrust/core';
@@ -1,57 +1,9 @@
1
- import { Env } from './env';
2
- import { Logger } from './logger';
3
-
4
- /**
5
- * Feature Flags State
6
- * Internal state managed by the module
7
- */
8
- let _rawQueryEnabled = false;
9
-
10
1
  /**
11
- * Feature Flags - Controls access to advanced/experimental features
12
- * Sealed namespace for immutability
2
+ * Feature Flags (template)
3
+ *
4
+ * Keep this file declarative:
5
+ * - Core owns runtime feature flag behavior.
13
6
  */
14
- export const FeatureFlags = Object.freeze({
15
- /**
16
- * Initialize all feature flags from environment
17
- * Called once during application bootstrap
18
- */
19
- initialize(): void {
20
- _rawQueryEnabled = Env.get('USE_RAW_QRY') === 'true';
21
-
22
- if (_rawQueryEnabled) {
23
- Logger.warn(
24
- '⚠️ FEATURE FLAG ENABLED: Raw SQL Queries are now available via adapter.rawQuery()'
25
- );
26
- Logger.warn('⚠️ This bypasses QueryBuilder safety - use only when necessary');
27
- Logger.warn('⚠️ Ensure parameters are properly bound to prevent SQL injection');
28
- } else {
29
- Logger.info('🔒 Raw SQL Queries are DISABLED (default, recommended for production)');
30
- }
31
- },
32
-
33
- /**
34
- * Check if raw queries are enabled
35
- * Returns cached flag value (no environment lookup)
36
- */
37
- isRawQueryEnabled(): boolean {
38
- return _rawQueryEnabled;
39
- },
40
-
41
- /**
42
- * Reset flags (primarily for testing)
43
- */
44
- reset(): void {
45
- _rawQueryEnabled = false;
46
- },
47
-
48
- /**
49
- * Set raw query enabled state
50
- * Primarily for testing to avoid 'as any' type casting
51
- */
52
- setRawQueryEnabled(enabled: boolean): void {
53
- _rawQueryEnabled = enabled;
54
- },
55
- });
56
7
 
57
- export default FeatureFlags;
8
+ export { FeatureFlags } from '@zintrust/core';
9
+ export { FeatureFlags as default } from '@zintrust/core';