@zintrust/core 0.1.39 → 0.1.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (475) hide show
  1. package/bin/zintrust-main.d.ts.map +1 -1
  2. package/bin/zintrust-main.js +22 -1
  3. package/package.json +8 -4
  4. package/public/error-pages/404.html +2 -2
  5. package/src/auth/Auth.js +1 -1
  6. package/src/boot/Application.d.ts +1 -16
  7. package/src/boot/Application.d.ts.map +1 -1
  8. package/src/boot/Application.js +2 -262
  9. package/src/boot/Server.d.ts +1 -1
  10. package/src/boot/Server.d.ts.map +1 -1
  11. package/src/boot/bootstrap.js +23 -9
  12. package/src/boot/registry/registerRoute.d.ts +6 -0
  13. package/src/boot/registry/registerRoute.d.ts.map +1 -0
  14. package/src/boot/registry/registerRoute.js +96 -0
  15. package/src/boot/registry/runtime.d.ts +15 -0
  16. package/src/boot/registry/runtime.d.ts.map +1 -0
  17. package/src/boot/registry/runtime.js +353 -0
  18. package/src/boot/registry/type.d.ts +25 -0
  19. package/src/boot/registry/type.d.ts.map +1 -0
  20. package/src/boot/registry/type.js +1 -0
  21. package/src/boot/registry/worker.d.ts +6 -0
  22. package/src/boot/registry/worker.d.ts.map +1 -0
  23. package/src/boot/registry/worker.js +35 -0
  24. package/src/cache/drivers/KVRemoteDriver.d.ts.map +1 -1
  25. package/src/cache/drivers/KVRemoteDriver.js +14 -1
  26. package/src/cli/CLI.d.ts.map +1 -1
  27. package/src/cli/CLI.js +82 -34
  28. package/src/cli/ErrorHandler.js +1 -1
  29. package/src/cli/commands/ContainerProxiesCommand.d.ts +5 -0
  30. package/src/cli/commands/ContainerProxiesCommand.d.ts.map +1 -0
  31. package/src/cli/commands/ContainerProxiesCommand.js +77 -0
  32. package/src/cli/commands/ContainerWorkersCommand.d.ts +5 -0
  33. package/src/cli/commands/ContainerWorkersCommand.d.ts.map +1 -0
  34. package/src/cli/commands/ContainerWorkersCommand.js +57 -0
  35. package/src/cli/commands/DeployCommand.d.ts +16 -0
  36. package/src/cli/commands/DeployCommand.d.ts.map +1 -0
  37. package/src/cli/commands/DeployCommand.js +110 -0
  38. package/src/cli/commands/DeployContainerProxiesCommand.d.ts +5 -0
  39. package/src/cli/commands/DeployContainerProxiesCommand.d.ts.map +1 -0
  40. package/src/cli/commands/DeployContainerProxiesCommand.js +27 -0
  41. package/src/cli/commands/DeployContainerWorkersCommand.d.ts +5 -0
  42. package/src/cli/commands/DeployContainerWorkersCommand.d.ts.map +1 -0
  43. package/src/cli/commands/DeployContainerWorkersCommand.js +27 -0
  44. package/src/cli/commands/DockerComposeCommandUtils.d.ts +3 -0
  45. package/src/cli/commands/DockerComposeCommandUtils.d.ts.map +1 -0
  46. package/src/cli/commands/DockerComposeCommandUtils.js +34 -0
  47. package/src/cli/commands/DoctorArchitectureCommand.d.ts +5 -0
  48. package/src/cli/commands/DoctorArchitectureCommand.d.ts.map +1 -0
  49. package/src/cli/commands/DoctorArchitectureCommand.js +54 -0
  50. package/src/cli/commands/InitContainerCommand.d.ts +5 -0
  51. package/src/cli/commands/InitContainerCommand.d.ts.map +1 -0
  52. package/src/cli/commands/InitContainerCommand.js +216 -0
  53. package/src/cli/commands/InitProducerCommand.d.ts +5 -0
  54. package/src/cli/commands/InitProducerCommand.d.ts.map +1 -0
  55. package/src/cli/commands/InitProducerCommand.js +47 -0
  56. package/src/cli/commands/InitProxyCommand.d.ts +5 -0
  57. package/src/cli/commands/InitProxyCommand.d.ts.map +1 -0
  58. package/src/cli/commands/InitProxyCommand.js +442 -0
  59. package/src/cli/commands/MongoDBProxyCommand.d.ts +5 -0
  60. package/src/cli/commands/MongoDBProxyCommand.d.ts.map +1 -0
  61. package/src/cli/commands/MongoDBProxyCommand.js +98 -0
  62. package/src/cli/commands/MySqlProxyCommand.d.ts +6 -0
  63. package/src/cli/commands/MySqlProxyCommand.d.ts.map +1 -0
  64. package/src/cli/commands/MySqlProxyCommand.js +32 -0
  65. package/src/cli/commands/PostgresProxyCommand.d.ts +6 -0
  66. package/src/cli/commands/PostgresProxyCommand.d.ts.map +1 -0
  67. package/src/cli/commands/PostgresProxyCommand.js +32 -0
  68. package/src/cli/commands/ProxyCommand.d.ts +12 -0
  69. package/src/cli/commands/ProxyCommand.d.ts.map +1 -0
  70. package/src/cli/commands/ProxyCommand.js +80 -0
  71. package/src/cli/commands/ProxyCommandUtils.d.ts +6 -0
  72. package/src/cli/commands/ProxyCommandUtils.d.ts.map +1 -0
  73. package/src/cli/commands/ProxyCommandUtils.js +38 -0
  74. package/src/cli/commands/QueueRecoveryCommand.d.ts +6 -0
  75. package/src/cli/commands/QueueRecoveryCommand.d.ts.map +1 -0
  76. package/src/cli/commands/QueueRecoveryCommand.js +513 -0
  77. package/src/cli/commands/RedisProxyCommand.d.ts +6 -0
  78. package/src/cli/commands/RedisProxyCommand.d.ts.map +1 -0
  79. package/src/cli/commands/RedisProxyCommand.js +53 -0
  80. package/src/cli/commands/SmtpProxyCommand.d.ts +6 -0
  81. package/src/cli/commands/SmtpProxyCommand.d.ts.map +1 -0
  82. package/src/cli/commands/SmtpProxyCommand.js +56 -0
  83. package/src/cli/commands/SqlProxyCommandUtils.d.ts +46 -0
  84. package/src/cli/commands/SqlProxyCommandUtils.d.ts.map +1 -0
  85. package/src/cli/commands/SqlProxyCommandUtils.js +48 -0
  86. package/src/cli/commands/SqlServerProxyCommand.d.ts +5 -0
  87. package/src/cli/commands/SqlServerProxyCommand.d.ts.map +1 -0
  88. package/src/cli/commands/SqlServerProxyCommand.js +85 -0
  89. package/src/cli/commands/StartCommand.d.ts.map +1 -1
  90. package/src/cli/commands/StartCommand.js +145 -18
  91. package/src/cli/commands/WorkerCommands.d.ts +1 -0
  92. package/src/cli/commands/WorkerCommands.d.ts.map +1 -1
  93. package/src/cli/commands/WorkerCommands.js +140 -6
  94. package/src/cli/commands/index.d.ts +2 -0
  95. package/src/cli/commands/index.d.ts.map +1 -1
  96. package/src/cli/commands/index.js +2 -0
  97. package/src/cli/commands/runner/index.d.ts +2 -2
  98. package/src/cli/commands/runner/index.d.ts.map +1 -1
  99. package/src/cli/commands/runner/index.js +15 -4
  100. package/src/cli/d1/D1SqlMigrations.d.ts.map +1 -1
  101. package/src/cli/d1/D1SqlMigrations.js +3 -0
  102. package/src/cli/index.d.ts +4 -0
  103. package/src/cli/index.d.ts.map +1 -1
  104. package/src/cli/index.js +4 -0
  105. package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
  106. package/src/cli/scaffolding/ProjectScaffolder.js +2 -0
  107. package/src/cli/scaffolding/ServiceScaffolder.d.ts.map +1 -1
  108. package/src/cli/scaffolding/ServiceScaffolder.js +1 -0
  109. package/src/cli/utils/EnvFileLoader.d.ts +2 -1
  110. package/src/cli/utils/EnvFileLoader.d.ts.map +1 -1
  111. package/src/cli/utils/EnvFileLoader.js +22 -21
  112. package/src/cli/utils/spawn.d.ts.map +1 -1
  113. package/src/cli/utils/spawn.js +17 -10
  114. package/src/cli/workers/QueueWorkRunner.js +1 -1
  115. package/src/common/ExternalServiceUtils.d.ts.map +1 -1
  116. package/src/common/ExternalServiceUtils.js +7 -2
  117. package/src/common/HealthRoutes.d.ts.map +1 -1
  118. package/src/common/HealthRoutes.js +50 -2
  119. package/src/common/RemoteSignedJson.d.ts +1 -0
  120. package/src/common/RemoteSignedJson.d.ts.map +1 -1
  121. package/src/common/RemoteSignedJson.js +39 -13
  122. package/src/common/index.d.ts +1 -0
  123. package/src/common/index.d.ts.map +1 -1
  124. package/src/common/index.js +12 -1
  125. package/src/config/FileLogWriter.d.ts.map +1 -1
  126. package/src/config/FileLogWriter.js +21 -6
  127. package/src/config/app.d.ts +4 -0
  128. package/src/config/app.d.ts.map +1 -1
  129. package/src/config/app.js +4 -0
  130. package/src/config/cache.d.ts.map +1 -1
  131. package/src/config/cache.js +22 -2
  132. package/src/config/cloudflare.d.ts +5 -1
  133. package/src/config/cloudflare.d.ts.map +1 -1
  134. package/src/config/cloudflare.js +48 -0
  135. package/src/config/database.d.ts.map +1 -1
  136. package/src/config/database.js +48 -13
  137. package/src/config/env.d.ts +90 -2
  138. package/src/config/env.d.ts.map +1 -1
  139. package/src/config/env.js +160 -18
  140. package/src/config/index.d.ts +1 -0
  141. package/src/config/index.d.ts.map +1 -1
  142. package/src/config/logger.d.ts.map +1 -1
  143. package/src/config/logger.js +60 -16
  144. package/src/config/mail.d.ts.map +1 -1
  145. package/src/config/mail.js +16 -10
  146. package/src/config/middleware.d.ts +5 -0
  147. package/src/config/middleware.d.ts.map +1 -1
  148. package/src/config/middleware.js +19 -1
  149. package/src/config/queue.d.ts.map +1 -1
  150. package/src/config/queue.js +70 -9
  151. package/src/config/redis.d.ts.map +1 -1
  152. package/src/config/redis.js +48 -13
  153. package/src/config/storage.d.ts.map +1 -1
  154. package/src/config/storage.js +1 -0
  155. package/src/config/type.d.ts +19 -0
  156. package/src/config/type.d.ts.map +1 -1
  157. package/src/config/workers.d.ts.map +1 -1
  158. package/src/config/workers.js +122 -16
  159. package/src/functions/cloudflare.d.ts.map +1 -1
  160. package/src/functions/cloudflare.js +55 -1
  161. package/src/health/StartupHealthChecks.js +1 -1
  162. package/src/http/FileUpload.d.ts +3 -2
  163. package/src/http/FileUpload.d.ts.map +1 -1
  164. package/src/http/Kernel.d.ts.map +1 -1
  165. package/src/http/Kernel.js +2 -1
  166. package/src/http/error-pages/ErrorPageRenderer.d.ts +4 -0
  167. package/src/http/error-pages/ErrorPageRenderer.d.ts.map +1 -1
  168. package/src/http/error-pages/ErrorPageRenderer.js +141 -1
  169. package/src/http/middleware/BodyParsingMiddleware.d.ts.map +1 -1
  170. package/src/http/middleware/BodyParsingMiddleware.js +33 -6
  171. package/src/index.d.ts +25 -53
  172. package/src/index.d.ts.map +1 -1
  173. package/src/index.js +30 -14
  174. package/src/microservices/ServiceAuthMiddleware.d.ts.map +1 -1
  175. package/src/microservices/ServiceAuthMiddleware.js +12 -4
  176. package/src/middleware/CsrfMiddleware.d.ts.map +1 -1
  177. package/src/middleware/CsrfMiddleware.js +39 -10
  178. package/src/middleware/ErrorHandlerMiddleware.d.ts.map +1 -1
  179. package/src/middleware/ErrorHandlerMiddleware.js +2 -1
  180. package/src/migrations/MigrationLoader.js +1 -1
  181. package/src/migrations/schema/SchemaCompiler.d.ts.map +1 -1
  182. package/src/migrations/schema/SchemaCompiler.js +6 -3
  183. package/src/node-singletons/crypto.d.ts +1 -1
  184. package/src/node-singletons/crypto.d.ts.map +1 -1
  185. package/src/node-singletons/crypto.js +1 -1
  186. package/src/node-singletons/fs.d.ts +1 -1
  187. package/src/node-singletons/fs.d.ts.map +1 -1
  188. package/src/node-singletons/path.d.ts +1 -1
  189. package/src/node-singletons/path.d.ts.map +1 -1
  190. package/src/node-singletons/path.js +1 -1
  191. package/src/node-singletons/stream.d.ts +11 -0
  192. package/src/node-singletons/stream.d.ts.map +1 -0
  193. package/src/node-singletons/stream.js +8 -0
  194. package/src/observability/OpenTelemetry.d.ts +7 -0
  195. package/src/observability/OpenTelemetry.d.ts.map +1 -1
  196. package/src/observability/OpenTelemetry.js +49 -2
  197. package/src/orm/Database.d.ts +4 -0
  198. package/src/orm/Database.d.ts.map +1 -1
  199. package/src/orm/Database.js +80 -9
  200. package/src/orm/DatabaseRuntimeRegistration.d.ts.map +1 -1
  201. package/src/orm/DatabaseRuntimeRegistration.js +2 -0
  202. package/src/orm/QueryBuilder.d.ts +1 -0
  203. package/src/orm/QueryBuilder.d.ts.map +1 -1
  204. package/src/orm/QueryBuilder.js +33 -3
  205. package/src/orm/SchemaCompiler.d.ts.map +1 -1
  206. package/src/orm/SchemaCompiler.js +6 -3
  207. package/src/orm/adapters/D1RemoteAdapter.d.ts.map +1 -1
  208. package/src/orm/adapters/D1RemoteAdapter.js +14 -1
  209. package/src/orm/adapters/MongoDBProxyAdapter.d.ts +3 -0
  210. package/src/orm/adapters/MongoDBProxyAdapter.d.ts.map +1 -0
  211. package/src/orm/adapters/MongoDBProxyAdapter.js +128 -0
  212. package/src/orm/adapters/MySQLProxyAdapter.d.ts +11 -0
  213. package/src/orm/adapters/MySQLProxyAdapter.d.ts.map +1 -0
  214. package/src/orm/adapters/MySQLProxyAdapter.js +143 -0
  215. package/src/orm/adapters/PostgreSQLProxyAdapter.d.ts +11 -0
  216. package/src/orm/adapters/PostgreSQLProxyAdapter.d.ts.map +1 -0
  217. package/src/orm/adapters/PostgreSQLProxyAdapter.js +147 -0
  218. package/src/orm/adapters/ProxyCache.d.ts +9 -0
  219. package/src/orm/adapters/ProxyCache.d.ts.map +1 -0
  220. package/src/orm/adapters/ProxyCache.js +24 -0
  221. package/src/orm/adapters/ProxySignedRequest.d.ts +11 -0
  222. package/src/orm/adapters/ProxySignedRequest.d.ts.map +1 -0
  223. package/src/orm/adapters/ProxySignedRequest.js +30 -0
  224. package/src/orm/adapters/ProxySigningPath.d.ts +3 -0
  225. package/src/orm/adapters/ProxySigningPath.d.ts.map +1 -0
  226. package/src/orm/adapters/ProxySigningPath.js +25 -0
  227. package/src/orm/adapters/SqlProxyAdapterUtils.d.ts +19 -0
  228. package/src/orm/adapters/SqlProxyAdapterUtils.d.ts.map +1 -0
  229. package/src/orm/adapters/SqlProxyAdapterUtils.js +35 -0
  230. package/src/orm/adapters/SqlServerProxyAdapter.d.ts +3 -0
  231. package/src/orm/adapters/SqlServerProxyAdapter.d.ts.map +1 -0
  232. package/src/orm/adapters/SqlServerProxyAdapter.js +146 -0
  233. package/src/performance/Optimizer.d.ts +1 -0
  234. package/src/performance/Optimizer.d.ts.map +1 -1
  235. package/src/performance/Optimizer.js +21 -8
  236. package/src/proxy/ErrorHandler.d.ts +11 -0
  237. package/src/proxy/ErrorHandler.d.ts.map +1 -0
  238. package/src/proxy/ErrorHandler.js +7 -0
  239. package/src/proxy/PoolManager.d.ts +8 -0
  240. package/src/proxy/PoolManager.d.ts.map +1 -0
  241. package/src/proxy/PoolManager.js +18 -0
  242. package/src/proxy/ProxyBackend.d.ts +18 -0
  243. package/src/proxy/ProxyBackend.d.ts.map +1 -0
  244. package/src/proxy/ProxyBackend.js +1 -0
  245. package/src/proxy/ProxyConfig.d.ts +12 -0
  246. package/src/proxy/ProxyConfig.d.ts.map +1 -0
  247. package/src/proxy/ProxyConfig.js +1 -0
  248. package/src/proxy/ProxyRegistry.d.ts +10 -0
  249. package/src/proxy/ProxyRegistry.d.ts.map +1 -0
  250. package/src/proxy/ProxyRegistry.js +11 -0
  251. package/src/proxy/ProxyServer.d.ts +21 -0
  252. package/src/proxy/ProxyServer.d.ts.map +1 -0
  253. package/src/proxy/ProxyServer.js +84 -0
  254. package/src/proxy/ProxyServerUtils.d.ts +37 -0
  255. package/src/proxy/ProxyServerUtils.d.ts.map +1 -0
  256. package/src/proxy/ProxyServerUtils.js +42 -0
  257. package/src/proxy/ProxySigningConfigResolver.d.ts +22 -0
  258. package/src/proxy/ProxySigningConfigResolver.d.ts.map +1 -0
  259. package/src/proxy/ProxySigningConfigResolver.js +24 -0
  260. package/src/proxy/ProxySigningRequest.d.ts +12 -0
  261. package/src/proxy/ProxySigningRequest.d.ts.map +1 -0
  262. package/src/proxy/ProxySigningRequest.js +31 -0
  263. package/src/proxy/RequestValidator.d.ts +15 -0
  264. package/src/proxy/RequestValidator.d.ts.map +1 -0
  265. package/src/proxy/RequestValidator.js +25 -0
  266. package/src/proxy/SigningService.d.ts +39 -0
  267. package/src/proxy/SigningService.d.ts.map +1 -0
  268. package/src/proxy/SigningService.js +107 -0
  269. package/src/proxy/SqlPayloadValidator.d.ts +13 -0
  270. package/src/proxy/SqlPayloadValidator.d.ts.map +1 -0
  271. package/src/proxy/SqlPayloadValidator.js +14 -0
  272. package/src/proxy/d1/ZintrustD1Proxy.d.ts +2 -0
  273. package/src/proxy/d1/ZintrustD1Proxy.d.ts.map +1 -0
  274. package/src/proxy/d1/ZintrustD1Proxy.js +1 -0
  275. package/src/proxy/d1/register.d.ts +2 -0
  276. package/src/proxy/d1/register.d.ts.map +1 -0
  277. package/src/proxy/d1/register.js +5 -0
  278. package/src/proxy/kv/ZintrustKvProxy.d.ts +2 -0
  279. package/src/proxy/kv/ZintrustKvProxy.d.ts.map +1 -0
  280. package/src/proxy/kv/ZintrustKvProxy.js +1 -0
  281. package/src/proxy/kv/register.d.ts +2 -0
  282. package/src/proxy/kv/register.d.ts.map +1 -0
  283. package/src/proxy/kv/register.js +5 -0
  284. package/src/proxy/mongodb/MongoDBProxyServer.d.ts +33 -0
  285. package/src/proxy/mongodb/MongoDBProxyServer.d.ts.map +1 -0
  286. package/src/proxy/mongodb/MongoDBProxyServer.js +202 -0
  287. package/src/proxy/mongodb/register.d.ts +2 -0
  288. package/src/proxy/mongodb/register.d.ts.map +1 -0
  289. package/src/proxy/mongodb/register.js +5 -0
  290. package/src/proxy/mysql/MySqlProxyServer.d.ts +14 -0
  291. package/src/proxy/mysql/MySqlProxyServer.d.ts.map +1 -0
  292. package/src/proxy/mysql/MySqlProxyServer.js +169 -0
  293. package/src/proxy/mysql/register.d.ts +2 -0
  294. package/src/proxy/mysql/register.d.ts.map +1 -0
  295. package/src/proxy/mysql/register.js +5 -0
  296. package/src/proxy/postgres/PostgresProxyServer.d.ts +14 -0
  297. package/src/proxy/postgres/PostgresProxyServer.d.ts.map +1 -0
  298. package/src/proxy/postgres/PostgresProxyServer.js +140 -0
  299. package/src/proxy/postgres/register.d.ts +2 -0
  300. package/src/proxy/postgres/register.d.ts.map +1 -0
  301. package/src/proxy/postgres/register.js +5 -0
  302. package/src/proxy/redis/RedisProxyServer.d.ts +12 -0
  303. package/src/proxy/redis/RedisProxyServer.d.ts.map +1 -0
  304. package/src/proxy/redis/RedisProxyServer.js +192 -0
  305. package/src/proxy/redis/register.d.ts +2 -0
  306. package/src/proxy/redis/register.d.ts.map +1 -0
  307. package/src/proxy/redis/register.js +5 -0
  308. package/src/proxy/smtp/SmtpProxyServer.d.ts +19 -0
  309. package/src/proxy/smtp/SmtpProxyServer.d.ts.map +1 -0
  310. package/src/proxy/smtp/SmtpProxyServer.js +289 -0
  311. package/src/proxy/smtp/register.d.ts +2 -0
  312. package/src/proxy/smtp/register.d.ts.map +1 -0
  313. package/src/proxy/smtp/register.js +5 -0
  314. package/src/proxy/sqlserver/SqlServerProxyServer.d.ts +14 -0
  315. package/src/proxy/sqlserver/SqlServerProxyServer.d.ts.map +1 -0
  316. package/src/proxy/sqlserver/SqlServerProxyServer.js +168 -0
  317. package/src/proxy/sqlserver/register.d.ts +2 -0
  318. package/src/proxy/sqlserver/register.d.ts.map +1 -0
  319. package/src/proxy/sqlserver/register.js +5 -0
  320. package/src/routes/doc.d.ts.map +1 -1
  321. package/src/routes/doc.js +16 -2
  322. package/src/routes/error.d.ts +5 -4
  323. package/src/routes/error.d.ts.map +1 -1
  324. package/src/routes/error.js +15 -13
  325. package/src/routes/errorPages.d.ts +2 -0
  326. package/src/routes/errorPages.d.ts.map +1 -1
  327. package/src/routes/errorPages.js +144 -4
  328. package/src/runtime/PluginAutoImports.d.ts +1 -0
  329. package/src/runtime/PluginAutoImports.d.ts.map +1 -1
  330. package/src/runtime/PluginAutoImports.js +94 -9
  331. package/src/runtime/RuntimeAdapter.d.ts +8 -9
  332. package/src/runtime/RuntimeAdapter.d.ts.map +1 -1
  333. package/src/runtime/RuntimeAdapter.js +120 -34
  334. package/src/runtime/RuntimeServices.d.ts +47 -0
  335. package/src/runtime/RuntimeServices.d.ts.map +1 -0
  336. package/src/runtime/RuntimeServices.js +164 -0
  337. package/src/runtime/StartupConfigFileRegistry.d.ts +4 -4
  338. package/src/runtime/StartupConfigFileRegistry.d.ts.map +1 -1
  339. package/src/runtime/StartupConfigFileRegistry.js +12 -0
  340. package/src/runtime/WorkerAdapterImports.d.ts +5 -0
  341. package/src/runtime/WorkerAdapterImports.d.ts.map +1 -0
  342. package/src/runtime/WorkerAdapterImports.js +17 -0
  343. package/src/runtime/WorkersModule.d.ts +6 -0
  344. package/src/runtime/WorkersModule.d.ts.map +1 -0
  345. package/src/runtime/WorkersModule.js +278 -0
  346. package/src/runtime/adapters/CloudflareAdapter.d.ts.map +1 -1
  347. package/src/runtime/adapters/CloudflareAdapter.js +19 -2
  348. package/src/runtime/adapters/DenoAdapter.js +1 -0
  349. package/src/runtime/adapters/FargateAdapter.js +1 -1
  350. package/src/runtime/adapters/LambdaAdapter.js +1 -1
  351. package/src/runtime/adapters/NodeServerAdapter.js +1 -1
  352. package/src/runtime/detectRuntime.d.ts +10 -0
  353. package/src/runtime/detectRuntime.d.ts.map +1 -0
  354. package/src/runtime/detectRuntime.js +57 -0
  355. package/src/runtime/useFileLoader.d.ts.map +1 -1
  356. package/src/runtime/useFileLoader.js +16 -0
  357. package/src/scripts/TemplateImportsCheck.js +2 -2
  358. package/src/scripts/TemplateSync.js +3 -4
  359. package/src/security/CsrfTokenManager.d.ts +18 -9
  360. package/src/security/CsrfTokenManager.d.ts.map +1 -1
  361. package/src/security/CsrfTokenManager.js +204 -11
  362. package/src/security/Hash.d.ts +1 -1
  363. package/src/security/Hash.d.ts.map +1 -1
  364. package/src/security/Hash.js +31 -36
  365. package/src/seeders/SeederLoader.js +1 -1
  366. package/src/session/SessionManager.d.ts +3 -0
  367. package/src/session/SessionManager.d.ts.map +1 -1
  368. package/src/session/SessionManager.js +49 -10
  369. package/src/sockets/CloudflareSocket.d.ts +24 -0
  370. package/src/sockets/CloudflareSocket.d.ts.map +1 -0
  371. package/src/sockets/CloudflareSocket.js +259 -0
  372. package/src/start.d.ts.map +1 -1
  373. package/src/start.js +1 -8
  374. package/src/templates/project/basic/app/Middleware/index.ts.tpl +1 -1
  375. package/src/templates/project/basic/src/zintrust.plugins.wg.ts.tpl +8 -0
  376. package/src/toolkit/Secrets/providers/AwsSecretsManager.d.ts.map +1 -1
  377. package/src/toolkit/Secrets/providers/AwsSecretsManager.js +4 -2
  378. package/src/tools/mail/drivers/Smtp.d.ts.map +1 -1
  379. package/src/tools/mail/drivers/Smtp.js +223 -18
  380. package/src/tools/mail/index.d.ts.map +1 -1
  381. package/src/tools/mail/index.js +5 -4
  382. package/src/tools/mail/template-loader.d.ts.map +1 -1
  383. package/src/tools/mail/template-loader.js +197 -29
  384. package/src/tools/mail/templates/auth-password-reset.d.ts +3 -0
  385. package/src/tools/mail/templates/auth-password-reset.d.ts.map +1 -0
  386. package/src/tools/mail/templates/auth-password-reset.js +231 -0
  387. package/src/tools/mail/templates/auth-welcome.d.ts +3 -0
  388. package/src/tools/mail/templates/auth-welcome.d.ts.map +1 -0
  389. package/src/tools/mail/templates/auth-welcome.js +236 -0
  390. package/src/tools/mail/templates/general.d.ts +3 -0
  391. package/src/tools/mail/templates/general.d.ts.map +1 -0
  392. package/src/tools/mail/templates/general.js +109 -0
  393. package/src/tools/mail/templates/index.js +2 -2
  394. package/src/tools/mail/templates/job-completed.d.ts +3 -0
  395. package/src/tools/mail/templates/job-completed.d.ts.map +1 -0
  396. package/src/tools/mail/templates/job-completed.js +188 -0
  397. package/src/tools/mail/templates/notifications-new-comment.d.ts +3 -0
  398. package/src/tools/mail/templates/notifications-new-comment.d.ts.map +1 -0
  399. package/src/tools/mail/templates/notifications-new-comment.js +228 -0
  400. package/src/tools/mail/templates/password-reset.d.ts +3 -0
  401. package/src/tools/mail/templates/password-reset.d.ts.map +1 -0
  402. package/src/tools/mail/templates/password-reset.js +221 -0
  403. package/src/tools/mail/templates/performance-report.d.ts +3 -0
  404. package/src/tools/mail/templates/performance-report.d.ts.map +1 -0
  405. package/src/tools/mail/templates/performance-report.js +258 -0
  406. package/src/tools/mail/templates/welcome.d.ts +3 -0
  407. package/src/tools/mail/templates/welcome.d.ts.map +1 -0
  408. package/src/tools/mail/templates/welcome.js +187 -0
  409. package/src/tools/mail/templates/worker-alert.d.ts +3 -0
  410. package/src/tools/mail/templates/worker-alert.d.ts.map +1 -0
  411. package/src/tools/mail/templates/worker-alert.js +229 -0
  412. package/src/tools/notification/Notification.js +1 -1
  413. package/src/tools/notification/testingHelpers.js +6 -5
  414. package/src/tools/queue/AdvancedQueue.js +2 -6
  415. package/src/tools/queue/IdempotencyManager.d.ts +6 -0
  416. package/src/tools/queue/IdempotencyManager.d.ts.map +1 -0
  417. package/src/tools/queue/IdempotencyManager.js +36 -0
  418. package/src/tools/queue/JobHeartbeatStore.d.ts +16 -0
  419. package/src/tools/queue/JobHeartbeatStore.d.ts.map +1 -0
  420. package/src/tools/queue/JobHeartbeatStore.js +67 -0
  421. package/src/tools/queue/JobReconciliationRunner.d.ts +16 -0
  422. package/src/tools/queue/JobReconciliationRunner.d.ts.map +1 -0
  423. package/src/tools/queue/JobReconciliationRunner.js +88 -0
  424. package/src/tools/queue/JobRecoveryDaemon.d.ts +27 -0
  425. package/src/tools/queue/JobRecoveryDaemon.d.ts.map +1 -0
  426. package/src/tools/queue/JobRecoveryDaemon.js +205 -0
  427. package/src/tools/queue/JobStateTracker.d.ts +131 -0
  428. package/src/tools/queue/JobStateTracker.d.ts.map +1 -0
  429. package/src/tools/queue/JobStateTracker.js +387 -0
  430. package/src/tools/queue/JobStateTrackerDbPersistence.d.ts +12 -0
  431. package/src/tools/queue/JobStateTrackerDbPersistence.d.ts.map +1 -0
  432. package/src/tools/queue/JobStateTrackerDbPersistence.js +148 -0
  433. package/src/tools/queue/Queue.d.ts.map +1 -1
  434. package/src/tools/queue/Queue.js +160 -16
  435. package/src/tools/queue/QueueDataRedactor.d.ts +6 -0
  436. package/src/tools/queue/QueueDataRedactor.d.ts.map +1 -0
  437. package/src/tools/queue/QueueDataRedactor.js +45 -0
  438. package/src/tools/queue/QueueExtensions.d.ts.map +1 -1
  439. package/src/tools/queue/QueueExtensions.js +2 -1
  440. package/src/tools/queue/QueueReliabilityMetrics.d.ts +38 -0
  441. package/src/tools/queue/QueueReliabilityMetrics.d.ts.map +1 -0
  442. package/src/tools/queue/QueueReliabilityMetrics.js +131 -0
  443. package/src/tools/queue/QueueReliabilityOrchestrator.d.ts +7 -0
  444. package/src/tools/queue/QueueReliabilityOrchestrator.d.ts.map +1 -0
  445. package/src/tools/queue/QueueReliabilityOrchestrator.js +59 -0
  446. package/src/tools/queue/QueueRuntimeRegistration.d.ts +1 -9
  447. package/src/tools/queue/QueueRuntimeRegistration.d.ts.map +1 -1
  448. package/src/tools/queue/QueueRuntimeRegistration.js +75 -4
  449. package/src/tools/queue/QueueTracing.d.ts +32 -0
  450. package/src/tools/queue/QueueTracing.d.ts.map +1 -0
  451. package/src/tools/queue/QueueTracing.js +151 -0
  452. package/src/tools/queue/StalledJobMonitor.d.ts +5 -0
  453. package/src/tools/queue/StalledJobMonitor.d.ts.map +1 -0
  454. package/src/tools/queue/StalledJobMonitor.js +21 -0
  455. package/src/tools/queue/TimeoutManager.d.ts +14 -0
  456. package/src/tools/queue/TimeoutManager.d.ts.map +1 -0
  457. package/src/tools/queue/TimeoutManager.js +77 -0
  458. package/src/tools/queue/drivers/Redis.d.ts +1 -0
  459. package/src/tools/queue/drivers/Redis.d.ts.map +1 -1
  460. package/src/tools/queue/drivers/Redis.js +1 -0
  461. package/src/tools/queue/index.d.ts +10 -0
  462. package/src/tools/queue/index.d.ts.map +1 -1
  463. package/src/tools/queue/index.js +10 -0
  464. package/src/tools/redis/RedisKeyManager.d.ts +3 -0
  465. package/src/tools/redis/RedisKeyManager.d.ts.map +1 -1
  466. package/src/tools/redis/RedisKeyManager.js +15 -0
  467. package/src/tools/storage/drivers/R2.d.ts +13 -0
  468. package/src/tools/storage/drivers/R2.d.ts.map +1 -1
  469. package/src/tools/storage/drivers/R2.js +29 -0
  470. package/src/zintrust.plugins.d.ts +9 -0
  471. package/src/zintrust.plugins.d.ts.map +1 -0
  472. package/src/zintrust.plugins.js +7 -0
  473. package/src/zintrust.plugins.wg.d.ts +9 -0
  474. package/src/zintrust.plugins.wg.d.ts.map +1 -0
  475. package/src/zintrust.plugins.wg.js +7 -0
package/src/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @zintrust/core v0.1.39
2
+ * @zintrust/core v0.1.41
3
3
  *
4
4
  * ZinTrust Framework - Production-Grade TypeScript Backend
5
5
  * Built for performance, type safety, and exceptional developer experience
6
6
  *
7
7
  * Build Information:
8
- * Built: 2026-01-31T09:27:42.547Z
8
+ * Built: 2026-02-15T07:16:08.895Z
9
9
  * Node: >=20.0.0
10
10
  * License: MIT
11
11
  *
@@ -20,14 +20,11 @@
20
20
  * Framework version and build metadata
21
21
  * Available at runtime for debugging and health checks
22
22
  */
23
- export const ZINTRUST_VERSION = '0.1.23';
24
- export const ZINTRUST_BUILD_DATE = '2026-01-31T09:27:42.518Z'; // Replaced during build
25
- import { Application } from './boot/Application.js';
26
- import { AwsSigV4 } from './common/index.js';
27
- import { SignedRequest } from './security/SignedRequest.js';
28
- const ZintrustApplication = Application;
29
- const ZintrustAwsSigV4 = AwsSigV4;
30
- const ZintrustSignedRequest = SignedRequest;
23
+ export const ZINTRUST_VERSION = '0.1.41';
24
+ export const ZINTRUST_BUILD_DATE = '2026-02-15T07:16:08.864Z'; // Replaced during build
25
+ export { Application } from './boot/Application.js';
26
+ export { AwsSigV4 } from './common/index.js';
27
+ export { SignedRequest } from './security/SignedRequest.js';
31
28
  export { Server } from './boot/Server.js';
32
29
  export { ServiceContainer } from './container/ServiceContainer.js';
33
30
  export { createPaginator, getNextPageUrl, getPrevPageUrl, Paginator } from './database/Paginator.js';
@@ -58,7 +55,6 @@ export { SQLServerAdapter } from './orm/adapters/SQLServerAdapter.js';
58
55
  export { Database, resetDatabase, useDatabase, useEnsureDbConnected } from './orm/Database.js';
59
56
  export { Model } from './orm/Model.js';
60
57
  export { QueryBuilder } from './orm/QueryBuilder.js';
61
- export { ZintrustApplication as Application };
62
58
  // Time Utilities
63
59
  export { DateTime } from './time/DateTime.js';
64
60
  // Migrations
@@ -73,7 +69,6 @@ export { DatabaseAdapterRegistry } from './orm/DatabaseAdapterRegistry.js';
73
69
  // Common
74
70
  export { generateSecureJobId, generateUuid, getString, Utilities, } from './common/utility.js';
75
71
  export { delay, ensureDirSafe } from './common/index.js';
76
- export { ZintrustAwsSigV4 as AwsSigV4 };
77
72
  // Collections
78
73
  export { collect, Collection } from './collections/index.js';
79
74
  // HTTP Client
@@ -92,6 +87,8 @@ export { PrometheusMetrics } from './observability/PrometheusMetrics.js';
92
87
  export { ValidationError } from './validation/ValidationError.js';
93
88
  export { Schema, Validator } from './validation/Validator.js';
94
89
  // Security
90
+ export { _ZINTRUST_CLOUDFLARE_D1_PROXY_BUILD_DATE, _ZINTRUST_CLOUDFLARE_D1_PROXY_VERSION, ZintrustD1Proxy, } from './proxy/d1/ZintrustD1Proxy.js';
91
+ export { _ZINTRUST_CLOUDFLARE_KV_PROXY_BUILD_DATE, _ZINTRUST_CLOUDFLARE_KV_PROXY_VERSION, ZintrustKvProxy, } from './proxy/kv/ZintrustKvProxy.js';
95
92
  export { CsrfTokenManager } from './security/CsrfTokenManager.js';
96
93
  export { EncryptedEnvelope } from './security/EncryptedEnvelope.js';
97
94
  export { Encryptor } from './security/Encryptor.js';
@@ -102,9 +99,10 @@ export { createSanitizer, Sanitizer } from './security/Sanitizer.js';
102
99
  export { TokenRevocation } from './security/TokenRevocation.js';
103
100
  export { Xss } from './security/Xss.js';
104
101
  export { XssProtection } from './security/XssProtection.js';
105
- export { ZintrustSignedRequest as SignedRequest };
106
102
  // Exceptions
107
103
  export { ErrorFactory } from './exceptions/ZintrustError.js';
104
+ // Runtime services
105
+ export { detectCloudflareWorkers, detectRuntimePlatform, RUNTIME_PLATFORM, RuntimeServices, } from './runtime/RuntimeServices.js';
108
106
  // Events
109
107
  export { EventDispatcher } from './events/EventDispatcher.js';
110
108
  // Sessions
@@ -128,7 +126,7 @@ export { MicroserviceManager } from './microservices/MicroserviceManager.js';
128
126
  export { RequestTracingMiddleware } from './microservices/RequestTracingMiddleware.js';
129
127
  export { ServiceAuthMiddleware } from './microservices/ServiceAuthMiddleware.js';
130
128
  export { HealthCheckHandler, ServiceHealthMonitor } from './microservices/ServiceHealthMonitor.js';
131
- export { middlewareConfig, MiddlewareKeys } from './config/middleware.js';
129
+ export { clearMiddlewareConfigCache, middlewareConfig, MiddlewareKeys } from './config/middleware.js';
132
130
  export { createBaseDrivers, queueConfig } from './config/queue.js';
133
131
  export { default as broadcastConfig } from './config/broadcast.js';
134
132
  export { default as notificationConfig } from './config/notification.js';
@@ -177,8 +175,20 @@ export { R2Driver } from './tools/storage/drivers/R2.js';
177
175
  export { GcsDriver } from './tools/storage/drivers/Gcs.js';
178
176
  // Queue drivers (for external registration packages)
179
177
  export { RedisQueue } from './tools/queue/drivers/Redis.js';
178
+ export { IdempotencyManager } from './tools/queue/IdempotencyManager.js';
179
+ export { JobHeartbeatStore } from './tools/queue/JobHeartbeatStore.js';
180
+ export { JobReconciliationRunner } from './tools/queue/JobReconciliationRunner.js';
181
+ export { JobRecoveryDaemon } from './tools/queue/JobRecoveryDaemon.js';
182
+ export { JobStateTracker } from './tools/queue/JobStateTracker.js';
183
+ export { autoRegisterJobStateTrackerPersistenceFromEnv, createJobStateTrackerDbPersistence, } from './tools/queue/JobStateTrackerDbPersistence.js';
180
184
  export { createLockProvider, getLockProvider, registerLockProvider } from './tools/queue/LockProvider.js';
181
185
  export { Queue, resolveLockPrefix } from './tools/queue/Queue.js';
186
+ export { QueueDataRedactor } from './tools/queue/QueueDataRedactor.js';
187
+ export { QueueReliabilityMetrics } from './tools/queue/QueueReliabilityMetrics.js';
188
+ export { QueueReliabilityOrchestrator } from './tools/queue/QueueReliabilityOrchestrator.js';
189
+ export { QueueTracing } from './tools/queue/QueueTracing.js';
190
+ export { StalledJobMonitor } from './tools/queue/StalledJobMonitor.js';
191
+ export { TimeoutManager } from './tools/queue/TimeoutManager.js';
182
192
  // Seeders (for database seeding)
183
193
  export { SeederLoader } from './seeders/SeederLoader.js';
184
194
  // Schedules
@@ -193,6 +203,10 @@ export { MicroserviceGenerator } from './microservices/MicroserviceGenerator.js'
193
203
  export { BaseCommand } from './cli/BaseCommand.js';
194
204
  export { CLI } from './cli/CLI.js';
195
205
  export { ErrorHandler, EXIT_CODES } from './cli/ErrorHandler.js';
206
+ // Proxy utilities (shared across proxy servers)
207
+ export { ErrorHandler as ProxyErrorHandler } from './proxy/ErrorHandler.js';
208
+ export { RequestValidator } from './proxy/RequestValidator.js';
209
+ export { SigningService } from './proxy/SigningService.js';
196
210
  // Runtime detection and kernel
197
211
  export { getKernel } from './runtime/getKernel.js';
198
212
  export { useFileLoader } from './runtime/useFileLoader.js';
@@ -208,5 +222,7 @@ export { ZintrustLang } from './lang/lang.js';
208
222
  export { createRedisConnection, workersConfig } from './config/workers.js';
209
223
  // Redis config key - Singleton exports
210
224
  export { createRedisKey, extractOriginalKey, getBullMQSafeQueueName, getPrefix, isAppKey, RedisKeys, } from './tools/redis/RedisKeyManager.js';
225
+ export { CloudflareSocket } from './sockets/CloudflareSocket.js';
226
+ export { detectRuntime } from './runtime/detectRuntime.js';
211
227
  // NOTE: Node-only exports (like FileLogWriter, process) are intentionally not
212
228
  // exported from this root entrypoint. Use the '@zintrust/core/node' subpath.
@@ -1 +1 @@
1
- {"version":3,"file":"ServiceAuthMiddleware.d.ts","sourceRoot":"","sources":["../../../src/microservices/ServiceAuthMiddleware.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAIhD,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnE;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEjE,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,YAAY,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IAC/B,QAAQ,IAAI,MAAM,CAAC;CACpB;AAED;;GAEG;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,SAAS,EAAE,IAAI,EAAE,YAAY,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChF;AAkND,eAAO,MAAM,qBAAqB,kCAA+C,CAAC;AAElF,eAAe,qBAAqB,CAAC"}
@@ -200,9 +200,17 @@ const verifyStrategy = (strategy, auth, context, deps) => {
200
200
  }
201
201
  };
202
202
  const createServiceAuthMiddleware = () => {
203
- const defaultApiKeyAuth = ApiKeyAuth.create();
204
- const defaultJwtAuth = JwtAuth.create();
203
+ let defaultApiKeyAuth = null;
204
+ let defaultJwtAuth = null;
205
205
  let customValidator = null;
206
+ const getApiKeyAuth = () => {
207
+ defaultApiKeyAuth ??= ApiKeyAuth.create();
208
+ return defaultApiKeyAuth;
209
+ };
210
+ const getJwtAuth = () => {
211
+ defaultJwtAuth ??= JwtAuth.create();
212
+ return defaultJwtAuth;
213
+ };
206
214
  return {
207
215
  /**
208
216
  * Register custom auth validator
@@ -224,8 +232,8 @@ const createServiceAuthMiddleware = () => {
224
232
  return res.setStatus(401).json({ error: 'Missing or invalid authorization header' });
225
233
  }
226
234
  const result = verifyStrategy(strategy, auth, context, {
227
- apiKeyAuth: defaultApiKeyAuth,
228
- jwtAuth: defaultJwtAuth,
235
+ apiKeyAuth: getApiKeyAuth(),
236
+ jwtAuth: getJwtAuth(),
229
237
  customValidator,
230
238
  });
231
239
  if (!result.authenticated) {
@@ -1 +1 @@
1
- {"version":3,"file":"CsrfMiddleware.d.ts","sourceRoot":"","sources":["../../../src/middleware/CsrfMiddleware.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAI9D,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AASD,eAAO,MAAM,cAAc;IACzB;;OAEG;qBACa,WAAW,GAAQ,UAAU;EAiE7C,CAAC"}
1
+ {"version":3,"file":"CsrfMiddleware.d.ts","sourceRoot":"","sources":["../../../src/middleware/CsrfMiddleware.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAK9D,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AA0CD,eAAO,MAAM,cAAc;IACzB;;OAEG;qBACa,WAAW,GAAQ,UAAU;EA6D7C,CAAC"}
@@ -12,6 +12,39 @@ const DEFAULT_OPTIONS = {
12
12
  bodyKey: '_csrf',
13
13
  ignoreMethods: ['GET', 'HEAD', 'OPTIONS'],
14
14
  };
15
+ // Global cleanup registry to avoid leaking intervals per middleware instance
16
+ // We use WeakRef so the manager (and middleware) can be garbage collected
17
+ // when no longer in use, even if this interval keeps running.
18
+ const canUseWeakRef = typeof WeakRef === 'function';
19
+ const managerRegistry = new Set();
20
+ let globalCleanupTimer = null;
21
+ const ensureCleanupTimer = () => {
22
+ if (globalCleanupTimer !== null)
23
+ return;
24
+ if (typeof setInterval !== 'function')
25
+ return;
26
+ if (globalThis.CF !== undefined)
27
+ return;
28
+ if (!canUseWeakRef)
29
+ return;
30
+ globalCleanupTimer = setInterval(() => {
31
+ if (managerRegistry.size === 0)
32
+ return;
33
+ for (const ref of managerRegistry) {
34
+ const mgr = ref.deref();
35
+ if (mgr) {
36
+ void mgr.cleanup().catch(() => undefined);
37
+ }
38
+ else {
39
+ managerRegistry.delete(ref);
40
+ }
41
+ }
42
+ }, 3600000);
43
+ // Use helper to handle runtime differences (Node vs others)
44
+ if (globalCleanupTimer !== null && isUnrefableTimer(globalCleanupTimer)) {
45
+ globalCleanupTimer.unref();
46
+ }
47
+ };
15
48
  export const CsrfMiddleware = Object.freeze({
16
49
  /**
17
50
  * Create CSRF protection middleware
@@ -20,14 +53,10 @@ export const CsrfMiddleware = Object.freeze({
20
53
  const config = { ...DEFAULT_OPTIONS, ...options };
21
54
  const manager = CsrfTokenManager.create();
22
55
  const sessions = SessionManager.create();
23
- // Periodic cleanup to prevent memory leaks
24
- // Run every hour (matching default token TTL)
25
- const cleanupTimer = setInterval(() => {
26
- manager.cleanup();
27
- }, 3600000);
28
- // Node: allow process to exit; other runtimes may not support unref()
29
- if (isUnrefableTimer(cleanupTimer)) {
30
- cleanupTimer.unref();
56
+ ensureCleanupTimer();
57
+ // Register for global cleanup instead of creating a local timer
58
+ if (canUseWeakRef) {
59
+ managerRegistry.add(new WeakRef(manager));
31
60
  }
32
61
  return async (req, res, next) => {
33
62
  if (shouldSkipCsrfForRequest(req, config)) {
@@ -42,7 +71,7 @@ export const CsrfMiddleware = Object.freeze({
42
71
  const method = req.getMethod();
43
72
  // 1. Token Generation (for safe methods)
44
73
  if (config.ignoreMethods?.includes(method) ?? false) {
45
- const token = manager.generateToken(sessionId);
74
+ const token = await manager.generateToken(sessionId);
46
75
  // Set cookie for Double Submit Cookie pattern (readable by frontend)
47
76
  appendSetCookie(res, `${config.cookieName}=${token}; Path=/; SameSite=Strict`);
48
77
  // Also expose in locals for server-side rendering
@@ -55,7 +84,7 @@ export const CsrfMiddleware = Object.freeze({
55
84
  const tokenFromBody = req.getBody()?.[config.bodyKey ?? '_csrf'];
56
85
  const tokenFromCookie = cookies[config.cookieName ?? 'XSRF-TOKEN'];
57
86
  const token = tokenFromHeader || tokenFromBody || tokenFromCookie;
58
- if (!token || !manager.validateToken(sessionId, token)) {
87
+ if (!token || !(await manager.validateToken(sessionId, token))) {
59
88
  Logger.warn(`CSRF validation failed for session ${sessionId}`);
60
89
  res.setStatus(403);
61
90
  res.json({
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorHandlerMiddleware.d.ts","sourceRoot":"","sources":["../../../src/middleware/ErrorHandlerMiddleware.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAU9D,eAAO,MAAM,sBAAsB;cACvB,UAAU;EA+BpB,CAAC;AAEH,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"ErrorHandlerMiddleware.d.ts","sourceRoot":"","sources":["../../../src/middleware/ErrorHandlerMiddleware.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAU9D,eAAO,MAAM,sBAAsB;cACvB,UAAU;EAsCpB,CAAC;AAEH,eAAe,sBAAsB,CAAC"}
@@ -28,7 +28,8 @@ export const ErrorHandlerMiddleware = Object.freeze({
28
28
  res.setStatus(500);
29
29
  if (errorMode === 'html') {
30
30
  // Use HTML error page instead of JSON
31
- ErrorRouting.handleInternalServerErrorWithWrappers(req, res, error, requestId);
31
+ const handleInternalServerErrorWithWrappers = ErrorRouting.handleInternalServerErrorWithWrappers;
32
+ await handleInternalServerErrorWithWrappers(req, res, error, requestId);
32
33
  }
33
34
  else {
34
35
  res.json(ErrorResponse.internalServerError('Internal server error', requestId, includeStack ? error?.stack : undefined));
@@ -1,6 +1,6 @@
1
1
  import { ErrorFactory } from '../exceptions/ZintrustError.js';
2
2
  import * as path from '../node-singletons/path.js';
3
- import { pathToFileURL } from 'node:url';
3
+ import { pathToFileURL } from '../node-singletons/url.js';
4
4
  function isFunction(value) {
5
5
  return typeof value === 'function';
6
6
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaCompiler.d.ts","sourceRoot":"","sources":["../../../../src/migrations/schema/SchemaCompiler.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,gBAAgB,EAEh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AAA;KAAE,GAAG,MAAM;8BAK5D,MAAM,SAAS,MAAM,QAAQ,cAAc,GAAG,MAAM,EAAE;EAIhF,CAAC"}
@@ -90,7 +90,7 @@ function getAutoIncrementColumnSql(driver, colName, type) {
90
90
  }
91
91
  throw ErrorFactory.createValidationError(`Auto-increment not supported for driver: ${driver}`);
92
92
  }
93
- function formatDefaultValueSql(table, def) {
93
+ function formatDefaultValueSql(driver, table, def) {
94
94
  if (def.defaultValue === undefined)
95
95
  return null;
96
96
  const dv = def.defaultValue;
@@ -98,8 +98,11 @@ function formatDefaultValueSql(table, def) {
98
98
  return ColumnType.DEFAULT_NULL;
99
99
  if (typeof dv === 'number' && Number.isFinite(dv))
100
100
  return `DEFAULT ${dv}`;
101
- if (typeof dv === 'boolean')
101
+ if (typeof dv === 'boolean') {
102
+ if (driver === AdaptersEnum.postgresql)
103
+ return `DEFAULT ${dv ? 'true' : 'false'}`;
102
104
  return `DEFAULT ${dv ? 1 : 0}`;
105
+ }
103
106
  if (typeof dv === 'string') {
104
107
  if (dv === ColumnType.CURRENT_TIMESTAMP)
105
108
  return `DEFAULT ${ColumnType.CURRENT_TIMESTAMP}`;
@@ -132,7 +135,7 @@ function buildColumnSql(driver, table, def) {
132
135
  parts.push(ColumnType.UNIQUE);
133
136
  if (def.primary === true)
134
137
  parts.push(ColumnType.PRIMARY_KEY);
135
- const defaultSql = formatDefaultValueSql(table, def);
138
+ const defaultSql = formatDefaultValueSql(driver, table, def);
136
139
  if (defaultSql !== null)
137
140
  parts.push(defaultSql);
138
141
  return parts.join(' ');
@@ -3,5 +3,5 @@
3
3
  * Safe to import in both API and CLI code
4
4
  * Exported from node:crypto built-in
5
5
  */
6
- export { createCipheriv, createDecipheriv, createHash, createHmac, createSign, createVerify, generateKeyPairSync, pbkdf2, pbkdf2Sync, randomBytes, randomInt, scryptSync, timingSafeEqual, } from 'node:crypto';
6
+ export { createCipheriv, createDecipheriv, createHash, createHmac, createSign, createVerify, generateKeyPairSync, pbkdf2, pbkdf2Sync, randomBytes, randomInt, randomUUID, scryptSync, timingSafeEqual, } from 'node:crypto';
7
7
  //# sourceMappingURL=crypto.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../../src/node-singletons/crypto.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,MAAM,EACN,UAAU,EACV,WAAW,EACX,SAAS,EACT,UAAU,EACV,eAAe,GAChB,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../../src/node-singletons/crypto.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,MAAM,EACN,UAAU,EACV,WAAW,EACX,SAAS,EACT,UAAU,EACV,UAAU,EACV,eAAe,GAChB,MAAM,aAAa,CAAC"}
@@ -3,4 +3,4 @@
3
3
  * Safe to import in both API and CLI code
4
4
  * Exported from node:crypto built-in
5
5
  */
6
- export { createCipheriv, createDecipheriv, createHash, createHmac, createSign, createVerify, generateKeyPairSync, pbkdf2, pbkdf2Sync, randomBytes, randomInt, scryptSync, timingSafeEqual, } from 'node:crypto';
6
+ export { createCipheriv, createDecipheriv, createHash, createHmac, createSign, createVerify, generateKeyPairSync, pbkdf2, pbkdf2Sync, randomBytes, randomInt, randomUUID, scryptSync, timingSafeEqual, } from 'node:crypto';
@@ -6,7 +6,7 @@
6
6
  import * as fs from 'node:fs';
7
7
  export * as fsPromises from 'node:fs/promises';
8
8
  export { appendFileSync, copyFileSync, createReadStream, createWriteStream, existsSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, renameSync, rmSync, statSync, unlinkSync, utimesSync, writeFileSync, } from 'node:fs';
9
- export type { ReadStream, Stats, WriteStream } from 'node:fs';
9
+ export type { PathLike, ReadStream, Stats, WriteStream, WriteStreamOptions } from 'node:fs';
10
10
  export { mkdir, mkdtemp, readFile, realpath, rm, stat, writeFile } from 'node:fs/promises';
11
11
  export default fs;
12
12
  //# sourceMappingURL=fs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../src/node-singletons/fs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAK9B,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EACL,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,EACZ,UAAU,EACV,MAAM,EACN,QAAQ,EACR,UAAU,EACV,UAAU,EACV,aAAa,GACd,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE9D,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG3F,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../src/node-singletons/fs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAK9B,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EACL,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,EACZ,UAAU,EACV,MAAM,EACN,QAAQ,EACR,UAAU,EACV,UAAU,EACV,aAAa,GACd,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE5F,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG3F,eAAe,EAAE,CAAC"}
@@ -4,6 +4,6 @@
4
4
  * Exported from node:path built-in
5
5
  */
6
6
  import * as path from 'node:path';
7
- export declare const basename: typeof path.basename, delimiter: ";" | ":", dirname: typeof path.dirname, extname: typeof path.extname, join: typeof path.join, relative: typeof path.relative, resolve: typeof path.resolve, sep: "/" | "\\";
7
+ export declare const basename: typeof path.basename, delimiter: ";" | ":", dirname: typeof path.dirname, extname: typeof path.extname, join: typeof path.join, relative: typeof path.relative, resolve: typeof path.resolve, sep: "/" | "\\", posix: typeof path, win32: typeof path;
8
8
  export default path;
9
9
  //# sourceMappingURL=path.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/node-singletons/path.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,eAAO,MAAQ,QAAQ,wBAAE,SAAS,aAAE,OAAO,uBAAE,OAAO,uBAAE,IAAI,oBAAE,QAAQ,wBAAE,OAAO,uBAAE,GAAG,YAAS,CAAC;AAE5F,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/node-singletons/path.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,eAAO,MAAQ,QAAQ,wBAAE,SAAS,aAAE,OAAO,uBAAE,OAAO,uBAAE,IAAI,oBAAE,QAAQ,wBAAE,OAAO,uBAAE,GAAG,cAAE,KAAK,eAAE,KAAK,aAC1F,CAAC;AAEP,eAAe,IAAI,CAAC"}
@@ -4,5 +4,5 @@
4
4
  * Exported from node:path built-in
5
5
  */
6
6
  import * as path from 'node:path';
7
- export const { basename, delimiter, dirname, extname, join, relative, resolve, sep } = path;
7
+ export const { basename, delimiter, dirname, extname, join, relative, resolve, sep, posix, win32 } = path;
8
8
  export default path;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Node.js Stream Module Singleton
3
+ * CLI-only: Should not be imported in API/serverless code
4
+ * Exported from node:stream built-in
5
+ */
6
+ import * as stream from 'node:stream';
7
+ export declare const Readable: typeof stream.Readable, Writable: typeof stream.Writable, Duplex: typeof stream.Duplex, Transform: typeof stream.Transform, PassThrough: typeof stream.PassThrough, pipeline: typeof stream.pipeline, finished: typeof stream.finished;
8
+ export type { DuplexOptions, ReadableOptions, TransformOptions, WritableOptions, } from 'node:stream';
9
+ export type { ReadableStream, WritableStream } from 'node:stream/web';
10
+ export default stream;
11
+ //# sourceMappingURL=stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../src/node-singletons/stream.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,eAAO,MAAQ,QAAQ,0BAAE,QAAQ,0BAAE,MAAM,wBAAE,SAAS,2BAAE,WAAW,6BAAE,QAAQ,0BAAE,QAAQ,wBAAW,CAAC;AAEjG,YAAY,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtE,eAAe,MAAM,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Node.js Stream Module Singleton
3
+ * CLI-only: Should not be imported in API/serverless code
4
+ * Exported from node:stream built-in
5
+ */
6
+ import * as stream from 'node:stream';
7
+ export const { Readable, Writable, Duplex, Transform, PassThrough, pipeline, finished } = stream;
8
+ export default stream;
@@ -46,6 +46,12 @@ export interface RecordDbQuerySpanInput {
46
46
  driver: string;
47
47
  durationMs: number;
48
48
  }
49
+ export interface RecordQueueOperationSpanInput {
50
+ queueName: string;
51
+ operation: 'enqueue' | 'dequeue' | 'ack' | 'length' | 'drain';
52
+ durationMs: number;
53
+ status: 'ok' | 'error';
54
+ }
49
55
  type HeaderGetter = {
50
56
  getHeader(name: string): unknown;
51
57
  };
@@ -57,6 +63,7 @@ export declare const OpenTelemetry: Readonly<{
57
63
  endHttpServerSpan: (span: Span, input: EndHttpServerSpanInput) => void;
58
64
  injectTraceHeaders: (headers: Record<string, string>) => Record<string, string>;
59
65
  recordDbQuerySpan: (input: RecordDbQuerySpanInput) => void;
66
+ recordQueueOperationSpan: (input: RecordQueueOperationSpanInput) => void;
60
67
  }>;
61
68
  export default OpenTelemetry;
62
69
  //# sourceMappingURL=OpenTelemetry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"OpenTelemetry.d.ts","sourceRoot":"","sources":["../../../src/observability/OpenTelemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAsExD,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,IAAI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EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,6BAA6B;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,SAAS,GAAG,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC9D,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,IAAI,GAAG,OAAO,CAAC;CACxB;AAED,KAAK,YAAY,GAAG;IAClB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAClC,CAAC;AAwMF,eAAO,MAAM,aAAa;qBAtMJ,OAAO;+BAyBK,YAAY,SAAS,wBAAwB,KAAG,WAAW;qBAyB/D,CAAC,OAAO,OAAO,MAAM,MAAM,OAAO,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,CAAC,CAAC;yBAKpD,IAAI,UAAU,MAAM,SAAS,MAAM,KAAG,IAAI;8BASrC,IAAI,SAAS,sBAAsB,KAAG,IAAI;kCA+BtC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;+BA2BlD,sBAAsB,KAAG,IAAI;sCAkCtB,6BAA6B,KAAG,IAAI;EAmD3E,CAAC;AAEH,eAAe,aAAa,CAAC"}
@@ -62,9 +62,9 @@ const fallbackPropagation = {
62
62
  };
63
63
  const fallbackTrace = {
64
64
  getTracer: () => ({
65
- startSpan: () => noopSpan,
65
+ startSpan: (_name, _options, _context) => noopSpan,
66
66
  }),
67
- getSpan: () => undefined,
67
+ getSpan: (_ctx) => undefined,
68
68
  setSpan: (ctx) => ctx,
69
69
  };
70
70
  const fallbackSpanKind = {
@@ -75,6 +75,17 @@ const fallbackSpanStatusCode = {
75
75
  OK: 1,
76
76
  ERROR: 2,
77
77
  };
78
+ const resolveSpanStatusCode = () => {
79
+ return otel()?.SpanStatusCode ?? fallbackSpanStatusCode;
80
+ };
81
+ const resolveTracingContext = () => {
82
+ const api = otel();
83
+ return {
84
+ traceApi: api?.trace ?? fallbackTrace,
85
+ activeContext: api?.context?.active() ?? fallbackContext.active(),
86
+ spanKind: api?.SpanKind ?? fallbackSpanKind,
87
+ };
88
+ };
78
89
  const otel = () => resolveOpenTelemetryApi();
79
90
  const isEnabled = () => {
80
91
  return Env.getBool('OTEL_ENABLED', false);
@@ -210,6 +221,41 @@ const recordDbQuerySpan = (input) => {
210
221
  // best-effort
211
222
  }
212
223
  };
224
+ const recordQueueOperationSpan = (input) => {
225
+ if (isEnabled() === false)
226
+ return;
227
+ try {
228
+ const tracing = resolveTracingContext();
229
+ const parentSpan = tracing.traceApi.getSpan(tracing.activeContext);
230
+ if (!parentSpan)
231
+ return;
232
+ const tracer = tracing.traceApi.getTracer('zintrust');
233
+ const now = Date.now();
234
+ const durationMs = Number.isFinite(input.durationMs) ? Math.max(0, input.durationMs) : 0;
235
+ const startTime = now - durationMs;
236
+ const span = tracer.startSpan(`queue.${input.operation}`, {
237
+ kind: tracing.spanKind.CLIENT,
238
+ startTime,
239
+ attributes: {
240
+ 'messaging.system': 'zintrust-queue',
241
+ 'messaging.operation': input.operation,
242
+ 'messaging.destination': input.queueName,
243
+ 'zintrust.queue.status': input.status,
244
+ },
245
+ }, tracing.activeContext);
246
+ const statusCode = resolveSpanStatusCode();
247
+ if (input.status === 'error') {
248
+ span.setStatus({ code: statusCode.ERROR });
249
+ }
250
+ else {
251
+ span.setStatus({ code: statusCode.OK });
252
+ }
253
+ span.end(now);
254
+ }
255
+ catch {
256
+ // best-effort
257
+ }
258
+ };
213
259
  export const OpenTelemetry = Object.freeze({
214
260
  isEnabled,
215
261
  startHttpServerSpan,
@@ -218,5 +264,6 @@ export const OpenTelemetry = Object.freeze({
218
264
  endHttpServerSpan,
219
265
  injectTraceHeaders,
220
266
  recordDbQuerySpan,
267
+ recordQueueOperationSpan,
221
268
  });
222
269
  export default OpenTelemetry;
@@ -5,6 +5,9 @@
5
5
  import type { SupportedDriver } from '../migrations/enum';
6
6
  import type { DatabaseConfig, IDatabaseAdapter, QueryResult } from './DatabaseAdapter';
7
7
  import type { IQueryBuilder } from './QueryBuilder';
8
+ export type RawValue = {
9
+ __raw: string;
10
+ };
8
11
  export interface IDatabase {
9
12
  connect(): Promise<void>;
10
13
  disconnect(): Promise<void>;
@@ -12,6 +15,7 @@ export interface IDatabase {
12
15
  query(sql: string, parameters?: unknown[], isRead?: boolean): Promise<unknown[]>;
13
16
  queryOne(sql: string, parameters?: unknown[], isRead?: boolean): Promise<unknown>;
14
17
  execute(sql: string, parameters?: unknown[], isRead?: boolean): Promise<QueryResult>;
18
+ raw(value: string): RawValue;
15
19
  transaction<T>(callback: (db: IDatabase) => Promise<T>): Promise<T>;
16
20
  table(name: string): IQueryBuilder;
17
21
  onBeforeQuery(handler: (query: string, params: unknown[]) => void): void;
@@ -1 +1 @@
1
- {"version":3,"file":"Database.d.ts","sourceRoot":"","sources":["../../../src/orm/Database.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAQxD,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE1F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,MAAM,WAAW,SAAS;IACxB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,WAAW,IAAI,OAAO,CAAC;IACvB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,OAAO,EAAE,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,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