@getstrata/core 2.2.59 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (330) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/core/audit/exportAuditLogs.d.ts +12 -3
  3. package/dist/core/audit/exportStore.d.ts +6 -2
  4. package/dist/core/audit/siemFormatter.d.ts +2 -2
  5. package/dist/core/auth/abilityCatalog.d.ts +1 -9
  6. package/dist/core/auth/authContext.d.ts +2 -0
  7. package/dist/core/auth/authOutcome.d.ts +32 -0
  8. package/dist/core/auth/authReader.d.ts +22 -0
  9. package/dist/core/auth/basicAuthGuard.d.ts +19 -3
  10. package/dist/core/auth/emailVerification.d.ts +1 -1
  11. package/dist/core/auth/guard.d.ts +27 -6
  12. package/dist/core/auth/intendedUrlCookie.d.ts +13 -7
  13. package/dist/core/auth/jwt.d.ts +5 -4
  14. package/dist/core/auth/jwtGuard.d.ts +7 -6
  15. package/dist/core/auth/membershipContext.d.ts +10 -7
  16. package/dist/core/auth/membershipContextMiddleware.d.ts +3 -3
  17. package/dist/core/auth/membershipMiddleware.d.ts +1 -2
  18. package/dist/core/auth/membershipServiceImplementation.d.ts +1 -1
  19. package/dist/core/auth/oauth/oidcIdToken.d.ts +25 -16
  20. package/dist/core/auth/oauth/oidcProvider.d.ts +6 -4
  21. package/dist/core/auth/oauth/providers.d.ts +3 -1
  22. package/dist/core/auth/oneTimeToken.d.ts +2 -3
  23. package/dist/core/auth/passwordConfirmCookie.d.ts +15 -6
  24. package/dist/core/auth/passwordLogin.d.ts +5 -5
  25. package/dist/core/auth/pendingMfaCookie.d.ts +2 -2
  26. package/dist/core/auth/policy.d.ts +23 -10
  27. package/dist/core/auth/requireAuthCapability.d.ts +3 -0
  28. package/dist/core/auth/resolveMembershipService.d.ts +3 -2
  29. package/dist/core/auth/saml/samlAssertionReplay.d.ts +4 -4
  30. package/dist/core/auth/saml/samlServiceProvider.d.ts +11 -7
  31. package/dist/core/auth/scimAuthMiddleware.d.ts +10 -3
  32. package/dist/core/auth/sessionCookie.d.ts +20 -9
  33. package/dist/core/auth/sessionGuard.d.ts +14 -3
  34. package/dist/core/cache/createCacheStore.d.ts +6 -3
  35. package/dist/core/cache/redisCacheStore.d.ts +5 -1
  36. package/dist/core/cache/repository.d.ts +5 -1
  37. package/dist/core/cache/simpleCache.d.ts +2 -1
  38. package/dist/core/cache/tokens.d.ts +8 -0
  39. package/dist/core/config/applicationConfig.d.ts +21 -0
  40. package/dist/core/config/configSnapshot.d.ts +3 -0
  41. package/dist/core/config/envSchema.d.ts +3 -2
  42. package/dist/core/contracts/application.d.ts +153 -0
  43. package/dist/core/contracts/authUserDirectory.d.ts +24 -7
  44. package/dist/core/contracts/container.d.ts +20 -23
  45. package/dist/core/contracts/di.d.ts +4 -2
  46. package/dist/core/contracts/executionContext.d.ts +5 -0
  47. package/dist/core/contracts/executionOperations.d.ts +10 -0
  48. package/dist/core/contracts/executionOwnership.d.ts +38 -0
  49. package/dist/core/contracts/persistence.d.ts +20 -0
  50. package/dist/core/contracts/serviceTokens.d.ts +32 -18
  51. package/dist/core/contracts/services.d.ts +63 -0
  52. package/dist/core/contracts/token.d.ts +19 -0
  53. package/dist/core/crypto/fieldEncryption.d.ts +19 -7
  54. package/dist/core/crypto/fieldEncryptionRotation.d.ts +21 -5
  55. package/dist/core/crypto/mfaSecret.d.ts +10 -3
  56. package/dist/core/database/baseRepository.d.ts +14 -10
  57. package/dist/core/database/bindings.d.ts +6 -0
  58. package/dist/core/database/bunSql.d.ts +3 -12
  59. package/dist/core/database/definitions.d.ts +209 -0
  60. package/dist/core/database/dialect.d.ts +5 -24
  61. package/dist/core/database/driverPorts.d.ts +116 -0
  62. package/dist/core/database/errors.d.ts +47 -7
  63. package/dist/core/database/factory.d.ts +51 -31
  64. package/dist/core/database/index.d.ts +9 -10
  65. package/dist/core/database/keyset.d.ts +2 -1
  66. package/dist/core/database/legacyNativeTransaction.d.ts +5 -0
  67. package/dist/core/database/manager.d.ts +12 -0
  68. package/dist/core/database/model.d.ts +91 -97
  69. package/dist/core/database/modelQuery.d.ts +9 -5
  70. package/dist/core/database/modelRegistry.d.ts +52 -33
  71. package/dist/core/database/mysqlConnection.d.ts +1 -19
  72. package/dist/core/database/mysqlNative.d.ts +38 -0
  73. package/dist/core/database/nativeTransactions.d.ts +16 -0
  74. package/dist/core/database/ormInternal.d.ts +85 -0
  75. package/dist/core/database/ormRuntime.d.ts +4 -0
  76. package/dist/core/database/ownedReadOnlyObservation.d.ts +16 -0
  77. package/dist/core/database/postgresNative.d.ts +11 -0
  78. package/dist/core/database/query.d.ts +24 -23
  79. package/dist/core/database/queryPlanSnapshot.d.ts +7 -0
  80. package/dist/core/database/rawMysql.d.ts +7 -0
  81. package/dist/core/database/rawPostgres.d.ts +23 -0
  82. package/dist/core/database/rawSqlite.d.ts +6 -0
  83. package/dist/core/database/relationQueries.d.ts +3 -2
  84. package/dist/core/database/relationQuery.d.ts +24 -6
  85. package/dist/core/database/repositoryQuery.d.ts +6 -1
  86. package/dist/core/database/schema/driver.d.ts +1 -1
  87. package/dist/core/database/seeders/types.d.ts +1 -1
  88. package/dist/core/database/session.d.ts +13 -0
  89. package/dist/core/database/sessionFactory.d.ts +9 -0
  90. package/dist/core/database/sqlDialects.d.ts +22 -0
  91. package/dist/core/database/tokens.d.ts +7 -0
  92. package/dist/core/database/transactionSession.d.ts +43 -0
  93. package/dist/core/errors/http.d.ts +4 -1
  94. package/dist/core/events/{eventBus.d.ts → eventBusClass.d.ts} +1 -3
  95. package/dist/core/events/index.d.ts +2 -3
  96. package/dist/core/events/outbox/index.d.ts +44 -13
  97. package/dist/core/events/outbox/metrics.d.ts +4 -4
  98. package/dist/core/events/outbox/workerTransport.d.ts +17 -0
  99. package/dist/core/http/authMiddleware.d.ts +2 -2
  100. package/dist/core/http/authorizeMiddleware.d.ts +2 -2
  101. package/dist/core/http/bodySizeLimitMiddleware.d.ts +1 -1
  102. package/dist/core/http/conditionalResponse.d.ts +7 -2
  103. package/dist/core/http/contentSecurityPolicy.d.ts +4 -3
  104. package/dist/core/http/corsMiddleware.d.ts +2 -1
  105. package/dist/core/http/csrfMiddleware.d.ts +6 -1
  106. package/dist/core/http/csrfToken.d.ts +17 -7
  107. package/dist/core/http/databaseError.d.ts +4 -0
  108. package/dist/core/http/etag.d.ts +5 -2
  109. package/dist/core/http/flashMiddleware.d.ts +1 -1
  110. package/dist/core/http/flashSession.d.ts +13 -7
  111. package/dist/core/http/index.d.ts +1 -1
  112. package/dist/core/http/loginThrottleMiddleware.d.ts +3 -3
  113. package/dist/core/http/memoryThrottleMiddleware.d.ts +2 -2
  114. package/dist/core/http/parseMultipartUpload.d.ts +3 -2
  115. package/dist/core/http/requestMetaContext.d.ts +5 -0
  116. package/dist/core/http/requireAbilityMiddleware.d.ts +1 -1
  117. package/dist/core/http/requireAuthMiddleware.d.ts +2 -2
  118. package/dist/core/http/requirePasswordConfirmMiddleware.d.ts +2 -1
  119. package/dist/core/http/requireVerifiedMiddleware.d.ts +2 -2
  120. package/dist/core/http/requireWebAuthMiddleware.d.ts +2 -2
  121. package/dist/core/http/response.d.ts +4 -3
  122. package/dist/core/http/scimThrottleMiddleware.d.ts +4 -3
  123. package/dist/core/http/securedRouteModelBinding.d.ts +10 -3
  124. package/dist/core/http/securityHeadersMiddleware.d.ts +1 -2
  125. package/dist/core/http/signedUrl.d.ts +8 -6
  126. package/dist/core/http/throttleMiddleware.d.ts +9 -5
  127. package/dist/core/http/uploads.d.ts +9 -3
  128. package/dist/core/http/webErrorResponse.d.ts +8 -2
  129. package/dist/core/jobs/exportAuditLogsJob.d.ts +5 -2
  130. package/dist/core/jobs/invalidateCacheTagsJob.d.ts +5 -4
  131. package/dist/core/lifecycle/gracefulShutdown.d.ts +2 -5
  132. package/dist/core/logging/requestLoggingMiddleware.d.ts +1 -1
  133. package/dist/core/mail/mailer.d.ts +7 -5
  134. package/dist/core/openapi/generator.d.ts +12 -4
  135. package/dist/core/openapi/registeredRoute.d.ts +4 -4
  136. package/dist/core/queue/createAppQueue.d.ts +9 -4
  137. package/dist/core/queue/failedJobMetrics.d.ts +11 -2
  138. package/dist/core/queue/failedJobRepository.d.ts +6 -3
  139. package/dist/core/queue/failedJobService.d.ts +1 -0
  140. package/dist/core/queue/index.d.ts +16 -6
  141. package/dist/core/queue/jobRegistry.d.ts +3 -2
  142. package/dist/core/queue/jobRunner.d.ts +10 -4
  143. package/dist/core/queue/publicQueue.d.ts +18 -9
  144. package/dist/core/queue/queueConfig.d.ts +20 -10
  145. package/dist/core/queue/queueHandoff.d.ts +31 -0
  146. package/dist/core/queue/queueMetrics.d.ts +10 -3
  147. package/dist/core/queue/queueServices.d.ts +28 -0
  148. package/dist/core/queue/queueWorkerTransport.d.ts +28 -0
  149. package/dist/core/queue/redisQueue.d.ts +19 -10
  150. package/dist/core/queue/redisQueueKeys.d.ts +5 -5
  151. package/dist/core/queue/redisStreams.d.ts +17 -10
  152. package/dist/core/queue/resilientQueue.d.ts +10 -4
  153. package/dist/core/queue/types.d.ts +1 -0
  154. package/dist/core/runtime/appKeyPrefix.d.ts +5 -5
  155. package/dist/core/runtime/application.d.ts +7 -0
  156. package/dist/core/runtime/executionContext.d.ts +9 -0
  157. package/dist/core/runtime/executionTasks.d.ts +49 -0
  158. package/dist/core/runtime/resourceJournal.d.ts +67 -0
  159. package/dist/core/runtime/serviceGraph.d.ts +14 -0
  160. package/dist/core/security/oauthState.d.ts +13 -9
  161. package/dist/core/security/publicReads.d.ts +2 -2
  162. package/dist/core/security/safeFetch.d.ts +1 -0
  163. package/dist/core/security/safeUrl.d.ts +3 -0
  164. package/dist/core/security/scimTenantTokens.d.ts +1 -1
  165. package/dist/core/security/tokenExpiry.d.ts +1 -1
  166. package/dist/core/security/webhookSignature.d.ts +1 -1
  167. package/dist/core/storage/storage.d.ts +24 -16
  168. package/dist/core/tenant/databaseTenantContext.d.ts +5 -7
  169. package/dist/core/tenant/resolveTenant.d.ts +2 -2
  170. package/dist/core/tenant/scopedDatabasePolicy.d.ts +8 -0
  171. package/dist/core/tenant/tenantDatabaseScope.d.ts +3 -7
  172. package/dist/core/tenant/tenantMiddleware.d.ts +15 -4
  173. package/dist/core/tracing/otel.d.ts +4 -6
  174. package/dist/core/tracing/tracingMiddleware.d.ts +3 -3
  175. package/dist/core/view/etaViewEngine.d.ts +1 -1
  176. package/dist/core/view/index.d.ts +5 -4
  177. package/dist/core/view/tokens.d.ts +8 -0
  178. package/dist/core/view/viewRenderer.d.ts +2 -2
  179. package/dist/core/view/webErrorView.d.ts +8 -7
  180. package/dist/core/view/webLayoutData.d.ts +6 -4
  181. package/dist/entries/audit/exportAuditLogs.js +87 -1024
  182. package/dist/entries/audit/siemFormatter.js +4 -90
  183. package/dist/entries/auth/abilityCatalog.js +28 -0
  184. package/dist/entries/auth/accessControl.js +5 -16
  185. package/dist/entries/auth/accountStateMigration.js +216 -236
  186. package/dist/entries/auth/authOutcome.js +80 -0
  187. package/dist/entries/auth/authReader.js +68 -0
  188. package/dist/entries/auth/basicAuthGuard.js +144 -1249
  189. package/dist/entries/auth/emailVerification.js +2 -2
  190. package/dist/entries/auth/intendedUrlCookie.js +35 -59
  191. package/dist/entries/auth/jwt.js +22 -47
  192. package/dist/entries/auth/jwtGuard.js +99 -231
  193. package/dist/entries/auth/membershipMiddleware.js +71 -10
  194. package/dist/entries/auth/membershipScope.js +16 -22
  195. package/dist/entries/auth/membershipService.js +11 -28
  196. package/dist/entries/auth/oauth/oidcProvider.js +59 -64
  197. package/dist/entries/auth/oauth/providers.js +12 -95
  198. package/dist/entries/auth/oauth/samlProvider.js +53 -1080
  199. package/dist/entries/auth/oneTimeToken.js +27 -289
  200. package/dist/entries/auth/passwordConfirmCookie.js +40 -63
  201. package/dist/entries/auth/passwordLogin.js +94 -399
  202. package/dist/entries/auth/pendingMfaCookie.js +6 -6
  203. package/dist/entries/auth/policy.js +22 -56
  204. package/dist/entries/auth/saml/samlServiceProvider.js +55 -1084
  205. package/dist/entries/auth/scimAuthMiddleware.js +16 -3358
  206. package/dist/entries/auth/sessionCookie.js +58 -73
  207. package/dist/entries/auth/sessionGuard.js +95 -248
  208. package/dist/entries/auth/tokenHash.js +11 -43
  209. package/dist/entries/cache/createCacheStore.js +126 -117
  210. package/dist/entries/cache/repository.js +25 -0
  211. package/dist/entries/cache/simpleCache.js +12 -7
  212. package/dist/entries/cache/tokens.js +9 -0
  213. package/dist/entries/config/applicationConfig.js +163 -0
  214. package/dist/entries/config/envSchema.js +21 -4
  215. package/dist/entries/contracts/application.js +1 -0
  216. package/dist/entries/contracts/authUserDirectory.js +10 -0
  217. package/dist/entries/contracts/container.js +99 -26
  218. package/dist/entries/contracts/di.js +3 -0
  219. package/dist/entries/contracts/executionContext.js +7 -0
  220. package/dist/entries/contracts/executionOperations.js +7 -0
  221. package/dist/entries/contracts/executionOwnership.js +7 -0
  222. package/dist/entries/contracts/membership.js +1 -0
  223. package/dist/entries/contracts/persistence.js +1 -0
  224. package/dist/entries/contracts/serviceTokens.js +26 -116
  225. package/dist/entries/contracts/services.js +98 -0
  226. package/dist/entries/contracts/token.js +41 -0
  227. package/dist/entries/crypto/fieldEncryption.js +49 -50
  228. package/dist/entries/crypto/mfaSecret.js +86 -82
  229. package/dist/entries/database/acquisitionMetrics.js +107 -0
  230. package/dist/entries/database/baseRepository.d.ts +2 -0
  231. package/dist/entries/database/bindings.js +2082 -0
  232. package/dist/entries/database/definitions.js +175 -0
  233. package/dist/entries/database/errors.js +114 -89
  234. package/dist/entries/database/factory.js +67 -28
  235. package/dist/entries/database/migrations.js +172 -224
  236. package/dist/entries/database/model.d.ts +1 -0
  237. package/dist/entries/database/ownedReadOnlyObservation.js +1282 -0
  238. package/dist/entries/database/query.js +159 -161
  239. package/dist/entries/database/repositoryQuery.d.ts +1 -0
  240. package/dist/entries/database/repositoryQuery.js +1 -1373
  241. package/dist/entries/database/schema.js +216 -236
  242. package/dist/entries/database/session.js +1 -0
  243. package/dist/entries/database/sqliteConnection.js +525 -83
  244. package/dist/entries/database/tokens.js +9 -0
  245. package/dist/entries/errors/http.js +118 -1
  246. package/dist/entries/http/authMiddleware.js +8 -5
  247. package/dist/entries/http/authorizeMiddleware.js +1 -1
  248. package/dist/entries/http/bodySizeLimitMiddleware.js +2 -2
  249. package/dist/entries/http/clientIp.js +2 -2
  250. package/dist/entries/http/conditionalResponse.js +19 -7
  251. package/dist/entries/http/corsMiddleware.js +6 -101
  252. package/dist/entries/http/csrfMiddleware.js +92 -106
  253. package/dist/entries/http/csrfToken.js +58 -94
  254. package/dist/entries/http/etag.js +7 -4
  255. package/dist/entries/http/flashMiddleware.js +57 -99
  256. package/dist/entries/http/flashSession.js +41 -68
  257. package/dist/entries/http/memoryThrottleMiddleware.js +43 -186
  258. package/dist/entries/http/metricsMiddleware.js +2 -16
  259. package/dist/entries/http/parseMultipartUpload.js +15 -29
  260. package/dist/entries/http/requireAbilityMiddleware.js +2 -2
  261. package/dist/entries/http/requirePasswordConfirmMiddleware.js +19 -31
  262. package/dist/entries/http/requireVerifiedMiddleware.js +4 -7
  263. package/dist/entries/http/requireWebAuthMiddleware.js +2 -2
  264. package/dist/entries/http/response.js +67 -233
  265. package/dist/entries/http/routeMiddleware.js +0 -14
  266. package/dist/entries/http/scimThrottleMiddleware.js +43 -237
  267. package/dist/entries/http/securedRouteModelBinding.js +37 -25
  268. package/dist/entries/http/securityHeadersMiddleware.js +8 -25
  269. package/dist/entries/http/signedUrl.js +20 -110
  270. package/dist/entries/http/throttleMiddleware.js +41 -185
  271. package/dist/entries/http/uploads.js +9 -24
  272. package/dist/entries/jobs/exportAuditLogsJob.js +17 -1498
  273. package/dist/entries/jobs/invalidateCacheTagsJob.js +12 -47
  274. package/dist/entries/logging/requestLoggingMiddleware.js +4 -4
  275. package/dist/entries/mail/mailer.js +68 -78
  276. package/dist/entries/openapi/generator.js +33 -100
  277. package/dist/entries/queue/createAppQueue.js +416 -254
  278. package/dist/entries/queue/failedJobRepository.js +19 -8
  279. package/dist/entries/queue/failedJobService.js +1 -0
  280. package/dist/entries/queue/jobRunner.js +141 -66
  281. package/dist/entries/queue/publicQueue.js +411 -255
  282. package/dist/entries/queue/queueConfig.js +61 -0
  283. package/dist/entries/queue/queueHandoff.js +318 -0
  284. package/dist/entries/queue/queueMetrics.js +989 -1384
  285. package/dist/entries/queue/queueServices.js +133 -0
  286. package/dist/entries/queue/queueWorkerTransport.js +1703 -0
  287. package/dist/entries/queue/redisQueue.js +282 -180
  288. package/dist/entries/queue.js +6 -45
  289. package/dist/entries/runtime/application.js +1585 -0
  290. package/dist/entries/runtime/asyncContextStore.js +0 -16
  291. package/dist/entries/security/oauthState.js +35 -67
  292. package/dist/entries/security/publicReads.js +4 -4
  293. package/dist/entries/security/safeFetch.js +1 -0
  294. package/dist/entries/security/scimTenantTokens.js +3 -3
  295. package/dist/entries/security/tokenExpiry.js +2 -2
  296. package/dist/entries/security/totp.js +1 -87
  297. package/dist/entries/security/webhookSignature.js +2 -90
  298. package/dist/entries/storage/storage.js +120 -45
  299. package/dist/entries/tenant/databaseTenantContext.js +6 -907
  300. package/dist/entries/tenant/publicTenantHost.js +78 -0
  301. package/dist/entries/tenant/resolveTenant.js +14 -0
  302. package/dist/entries/tenant/scopedDatabasePolicy.js +75 -0
  303. package/dist/entries/tenant/tenancyConfig.js +1 -19
  304. package/dist/entries/tenant/tenantDatabaseScope.js +3 -892
  305. package/dist/entries/tracing/tracingMiddleware.js +104 -173
  306. package/dist/entries/view/tokens.js +11 -0
  307. package/dist/framework/public-api.d.ts +62 -44
  308. package/dist/index.js +10433 -11347
  309. package/dist/internal/ormInternal.js +117 -0
  310. package/dist/internal/ormRuntime.js +5000 -0
  311. package/package.json +158 -46
  312. package/dist/core/database/bindConnection.d.ts +0 -1
  313. package/dist/core/database/boundConnection.d.ts +0 -5
  314. package/dist/core/database/defaultConnection.d.ts +0 -7
  315. package/dist/core/database/namedConnections.d.ts +0 -15
  316. package/dist/core/database/readOnlyCollector.d.ts +0 -7
  317. package/dist/core/database/repositoryConnection.d.ts +0 -4
  318. package/dist/core/database/transaction.d.ts +0 -23
  319. package/dist/core/database/transactionControl.d.ts +0 -6
  320. package/dist/core/events/deferredModelEvents.d.ts +0 -7
  321. package/dist/core/facades/index.d.ts +0 -10
  322. package/dist/core/runtime/applicationRegistry.d.ts +0 -18
  323. package/dist/entries/database/bindConnection.js +0 -1
  324. package/dist/entries/database/boundConnection.js +0 -1
  325. package/dist/entries/database/defaultConnection.js +0 -1
  326. package/dist/entries/database/namedConnections.js +0 -1
  327. package/dist/entries/database/repositoryConnection.js +0 -1
  328. package/dist/entries/database/transaction.js +0 -1
  329. package/dist/entries/facades.js +0 -711
  330. package/dist/entries/runtime/applicationRegistry.js +0 -1
@@ -1,6 +1,11 @@
1
+ import { FAILED_JOB_SERVICE_TOKEN } from "@getstrata/core/contracts/serviceTokens";
1
2
  import type { Queue } from "./index";
2
- import { createFailedJobService, createQueueWorker, createTrackedJob, type FailedJobService } from "./publicQueue";
3
+ import type { JobRegistry } from "./jobRegistry";
4
+ import { createFailedJobService, createQueueServices, createQueueWorker, createSystemQueueServices, createTrackedJob, type QueueServices } from "./publicQueue";
5
+ import type { QueueRetryPolicy, QueueRuntimeConfig } from "./queueConfig";
3
6
  import { resolveQueueConfig } from "./queueConfig";
4
- declare const FAILED_JOB_SERVICE_TOKEN = "core.failedJobs";
5
- declare function createAppQueue(driver: "sync" | "async" | "redis", redisUrl?: string, failedJobs?: FailedJobService, registerJobs?: () => void): Queue;
6
- export { createAppQueue, createFailedJobService, createQueueWorker, createTrackedJob, FAILED_JOB_SERVICE_TOKEN, resolveQueueConfig, };
7
+ declare function createAppQueue(driver: "sync" | "async" | "redis", redisUrl: string | undefined, failedJobs: QueueServices, registry: JobRegistry, retryPolicy?: QueueRetryPolicy, runtime?: QueueRuntimeConfig): Queue;
8
+ export type { QueueHandoff, QueueIdentity } from "@getstrata/core/queue/queueHandoff";
9
+ export { createIdentityQueue, createQueueHandoff } from "@getstrata/core/queue/queueHandoff";
10
+ export type { QueueInvocation, QueueInvocationConfig, QueueServices } from "./queueServices";
11
+ export { createAppQueue, createFailedJobService, createQueueServices, createQueueWorker, createSystemQueueServices, createTrackedJob, FAILED_JOB_SERVICE_TOKEN, resolveQueueConfig, };
@@ -1,9 +1,18 @@
1
+ import type { SqlStatement } from "../database/driverPorts";
2
+ import type { SqlDialect } from "../database/sqlDialects";
3
+ interface ReadOnlyObservationExecutor {
4
+ readonly dialect: SqlDialect;
5
+ execute<Row>(statement: SqlStatement): Promise<readonly Row[]>;
6
+ }
7
+ type FailedJobObservation = <T>(timeoutMs: number, work: (database: ReadOnlyObservationExecutor, remaining: () => number) => Promise<T>) => Promise<T>;
1
8
  interface FailedJobMetricsSnapshot {
2
9
  sampleLimit: number;
3
10
  count: number;
4
11
  capped: boolean;
5
12
  }
6
13
  interface FailedJobMetricsOptions {
14
+ /** Application-owned interruptible read-only observation; no ambient pool fallback. */
15
+ observeReadOnly: FailedJobObservation;
7
16
  timeoutMs?: number;
8
17
  sampleLimit?: number;
9
18
  }
@@ -11,7 +20,7 @@ interface FailedJobMetricsCollector {
11
20
  collect(): Promise<FailedJobMetricsSnapshot>;
12
21
  close(): Promise<void>;
13
22
  }
14
- declare function createFailedJobMetricsCollector(options?: FailedJobMetricsOptions): FailedJobMetricsCollector;
23
+ declare function createFailedJobMetricsCollector(options: FailedJobMetricsOptions): FailedJobMetricsCollector;
15
24
  declare function renderFailedJobMetrics(snapshot: FailedJobMetricsSnapshot): string;
16
- export type { FailedJobMetricsCollector, FailedJobMetricsOptions, FailedJobMetricsSnapshot };
25
+ export type { FailedJobMetricsCollector, FailedJobMetricsOptions, FailedJobMetricsSnapshot, FailedJobObservation, ReadOnlyObservationExecutor, };
17
26
  export { createFailedJobMetricsCollector, renderFailedJobMetrics };
@@ -1,10 +1,13 @@
1
- import { BaseRepository } from "@getstrata/core/database/baseRepository";
1
+ import { type RepositoryBinding } from "@getstrata/core/database/definitions";
2
2
  import type { MutationValues, QueryOptions } from "@getstrata/core/database/types";
3
+ import { BaseRepository } from "#strata-orm-runtime";
3
4
  import type { FailedJobRecord } from "./types";
4
5
  declare class FailedJobRepository extends BaseRepository<FailedJobRecord, "id"> {
5
- constructor();
6
+ private readonly selected;
7
+ constructor(selected: RepositoryBinding<FailedJobRecord, "id">);
6
8
  create(values: MutationValues<FailedJobRecord>): Promise<FailedJobRecord>;
7
9
  findAll(options?: QueryOptions<FailedJobRecord>): Promise<FailedJobRecord[]>;
8
10
  }
9
- export { FailedJobRepository };
11
+ declare const failedJobRepository: import("@getstrata/core/database/definitions").RepositoryDefinition<FailedJobRecord, "id", FailedJobRepository>;
12
+ export { FailedJobRepository, failedJobRepository };
10
13
  export default FailedJobRepository;
@@ -6,6 +6,7 @@ declare class FailedJobService {
6
6
  recordFailure(input: {
7
7
  jobName: string;
8
8
  jobId?: string;
9
+ handoff?: string;
9
10
  payload: Record<string, unknown>;
10
11
  exception: string;
11
12
  }): Promise<FailedJobRecord>;
@@ -1,7 +1,14 @@
1
1
  type QueuePriority = "high" | "default" | "low";
2
2
  /** Logical identity is stable across automatic recovery and supported manual replay. */
3
3
  interface JobContext {
4
+ /** Verified execution identity and owned policy supplied by application queue services. */
5
+ readonly actor?: import("../contracts/application").ExecutionActor;
6
+ readonly tenant?: import("../contracts/application").ApplicationConfig;
7
+ readonly policy?: import("../contracts/persistence").ScopedPolicy;
4
8
  /** One-based execution attempt supplied by the framework retry owner. */
9
+ readonly auditExport?: () => Promise<number>;
10
+ readonly cache?: import("../../types/services").CacheLike;
11
+ readonly database?: import("../database/session").DatabaseSession;
5
12
  readonly attempt?: number;
6
13
  readonly jobId: string;
7
14
  readonly signal: AbortSignal;
@@ -12,17 +19,20 @@ declare abstract class Job<TPayload extends object = object> {
12
19
  readonly maxAttempts?: number;
13
20
  readonly backoffMs?: number;
14
21
  readonly priority?: QueuePriority;
15
- constructor();
16
22
  abstract handle(payload: TPayload, context?: JobContext): Promise<void>;
17
23
  }
24
+ interface QueueDispatchOptions {
25
+ /** Opaque authenticated identity snapshot created by application composition. */
26
+ readonly handoff?: string;
27
+ }
18
28
  interface Queue {
19
29
  close?(): void | Promise<void>;
20
30
  /** Preserve a stored logical identity on deliberate replay; reset execution controls. */
21
- replay?<TPayload extends object>(job: Job<TPayload>, payload: TPayload, jobId: string): Promise<void>;
22
- dispatch<TPayload extends object>(job: Job<TPayload>, payload: TPayload): Promise<void>;
31
+ replay?<TPayload extends object>(job: Job<TPayload>, payload: TPayload, jobId: string, options?: QueueDispatchOptions): Promise<void>;
32
+ dispatch<TPayload extends object>(job: Job<TPayload>, payload: TPayload, options?: QueueDispatchOptions): Promise<void>;
23
33
  }
24
34
  declare class SyncQueue implements Queue {
25
- dispatch<TPayload extends object>(job: Job<TPayload>, payload: TPayload): Promise<void>;
35
+ dispatch<TPayload extends object>(job: Job<TPayload>, payload: TPayload, options?: QueueDispatchOptions): Promise<void>;
26
36
  }
27
37
  declare class AsyncQueue implements Queue {
28
38
  private readonly active;
@@ -30,9 +40,9 @@ declare class AsyncQueue implements Queue {
30
40
  private closed;
31
41
  protected assertOpen(): void;
32
42
  protected enqueue(task: () => Promise<void>, onError: (error: unknown) => void): void;
33
- dispatch<TPayload extends object>(job: Job<TPayload>, payload: TPayload): Promise<void>;
43
+ dispatch<TPayload extends object>(job: Job<TPayload>, payload: TPayload, options?: QueueDispatchOptions): Promise<void>;
34
44
  close(): Promise<void>;
35
45
  }
36
46
  declare function createQueue(driver: "sync" | "async"): Queue;
37
- export type { JobContext, Queue, QueuePriority };
47
+ export type { JobContext, Queue, QueueDispatchOptions, QueuePriority };
38
48
  export { AsyncQueue, createQueue, Job, SyncQueue };
@@ -6,8 +6,9 @@ declare class JobRegistry {
6
6
  register(name: string, factory: JobFactory): void;
7
7
  resolveName(job: Job): string | undefined;
8
8
  track(name: string, job: Job): Job;
9
+ has(name: string): boolean;
9
10
  create(name: string): Job | undefined;
10
11
  names(): string[];
11
12
  }
12
- declare const jobRegistry: JobRegistry;
13
- export { JobRegistry, jobRegistry };
13
+ declare const QUEUE_JOB_REGISTRY_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<JobRegistry>;
14
+ export { JobRegistry, QUEUE_JOB_REGISTRY_TOKEN };
@@ -1,17 +1,23 @@
1
- import type FailedJobService from "./failedJobService";
1
+ import type { JobRegistry } from "./jobRegistry";
2
+ import { type QueueRetryPolicy } from "./queueConfig";
3
+ import type { QueueServices } from "./queueServices";
2
4
  interface QueueJobEnvelope {
3
5
  name: string;
6
+ handoff?: string;
4
7
  payload: Record<string, unknown>;
5
8
  attempts?: number;
6
9
  jobId?: string;
7
10
  deadlineAtMs?: number;
8
11
  cancellable?: boolean;
9
12
  }
10
- declare function parseQueueJobEnvelope(rawPayload: string): QueueJobEnvelope | null;
11
- declare function runQueueJob(envelope: QueueJobEnvelope, failedJobs: Pick<FailedJobService, "recordFailure">, options?: {
13
+ /** Capture the exact data that admission authenticates, before any asynchronous resource acquisition. */
14
+ declare function snapshotQueueJobEnvelope(input: QueueJobEnvelope): QueueJobEnvelope;
15
+ declare function parseQueueJobEnvelope(rawPayload: string, registry: JobRegistry): QueueJobEnvelope | null;
16
+ declare function runQueueJob(envelope: QueueJobEnvelope, failedJobs: Pick<QueueServices, "recordFailure" | "runAttempt">, registry: JobRegistry, options?: {
17
+ retryPolicy?: QueueRetryPolicy;
12
18
  onFailureRecorded?: () => void;
13
19
  context?: import("./index").JobContext;
14
20
  deferRetry?: (envelope: QueueJobEnvelope, delayMs: number) => Promise<void>;
15
21
  }): Promise<void>;
16
22
  export type { QueueJobEnvelope };
17
- export { parseQueueJobEnvelope, runQueueJob };
23
+ export { parseQueueJobEnvelope, runQueueJob, snapshotQueueJobEnvelope };
@@ -1,17 +1,26 @@
1
- import FailedJobRepository from "./failedJobRepository.ts";
1
+ import FailedJobRepository from "@getstrata/core/queue/failedJobRepository";
2
2
  import FailedJobService from "./failedJobService.ts";
3
3
  import type { Job, Queue } from "./index.ts";
4
- import { jobRegistry } from "./jobRegistry.ts";
4
+ import type { JobRegistry } from "./jobRegistry.ts";
5
5
  import { runQueueJob } from "./jobRunner.ts";
6
+ import { type QueueRetryPolicy, type QueueRuntimeConfig } from "./queueConfig";
7
+ import { createFailedJobService, createQueueServices, createSystemQueueServices, type QueueServices } from "./queueServices";
6
8
  import { QueueWorker, RedisQueue } from "./redisQueue.ts";
7
9
  import { RedisStreamsWorker } from "./redisStreams";
8
10
  import { ResilientQueue } from "./resilientQueue.ts";
9
- declare function createFailedJobService(): FailedJobService;
10
- declare function createTrackedJob<TPayload extends object>(name: string, job: Job<TPayload>): Job<TPayload>;
11
- declare function createProductionQueue(driver: "sync" | "async" | "redis", options?: {
11
+ declare function createTrackedJob<TPayload extends object>(registry: JobRegistry, name: string, job: Job<TPayload>): Job<TPayload>;
12
+ declare function createProductionQueue(driver: "sync" | "async" | "redis", options: {
12
13
  redisUrl?: string;
13
- failedJobs?: FailedJobService;
14
- registerJobs?: () => void;
14
+ failedJobs: QueueServices;
15
+ registry: JobRegistry;
16
+ retryPolicy?: QueueRetryPolicy;
17
+ runtime?: QueueRuntimeConfig;
15
18
  }): Queue;
16
- declare function createQueueWorker(redisUrl: string, failedJobs?: FailedJobService): QueueWorker | RedisStreamsWorker;
17
- export { createFailedJobService, createProductionQueue, createQueueWorker, createTrackedJob, FailedJobRepository, FailedJobService, jobRegistry, QueueWorker, RedisQueue, ResilientQueue, runQueueJob, };
19
+ declare function createQueueWorker(redisUrl: string, failedJobs: Pick<QueueServices, "recordFailure" | "runAttempt">, registry: JobRegistry, options?: {
20
+ readonly runtime?: QueueRuntimeConfig;
21
+ readonly retryPolicy?: QueueRetryPolicy;
22
+ }): QueueWorker | RedisStreamsWorker;
23
+ export type { QueueHandoff, QueueIdentity } from "@getstrata/core/queue/queueHandoff";
24
+ export { createIdentityQueue, createQueueHandoff } from "@getstrata/core/queue/queueHandoff";
25
+ export type { QueueInvocation, QueueInvocationConfig, QueueServices } from "./queueServices";
26
+ export { createFailedJobService, createProductionQueue, createQueueServices, createQueueWorker, createSystemQueueServices, createTrackedJob, FailedJobRepository, FailedJobService, QueueWorker, RedisQueue, ResilientQueue, runQueueJob, };
@@ -1,12 +1,22 @@
1
+ declare const DEFAULT_QUEUE_VISIBILITY_MS = 60000;
1
2
  interface QueueConfig {
2
- driver: "sync" | "async" | "redis";
3
- maxAttempts: number;
4
- backoffMs: number;
3
+ readonly driver: "sync" | "async" | "redis";
4
+ readonly maxAttempts: number;
5
+ readonly backoffMs: number;
5
6
  }
6
- declare function resolveQueueConfig(): QueueConfig;
7
- declare const queueConfig: QueueConfig;
8
- export type { QueueConfig };
9
- export { queueConfig, resolveQueueConfig };
10
- declare function resolveRedisQueueTransport(): "lists" | "streams";
11
- declare function readQueueVisibilityMs(): number;
12
- export { readQueueVisibilityMs, resolveRedisQueueTransport };
7
+ interface QueueRuntimeConfig {
8
+ readonly transport: "lists" | "streams";
9
+ readonly visibilityMs: number;
10
+ readonly queueKeys: readonly [string, string, string];
11
+ }
12
+ type QueueRetryPolicy = Readonly<Pick<QueueConfig, "maxAttempts" | "backoffMs">>;
13
+ type QueueEnvironment = Readonly<Record<string, string | undefined>>;
14
+ declare function snapshotQueueRetryPolicy(policy: QueueRetryPolicy): QueueRetryPolicy;
15
+ /** Configuration adapter. Capture the returned immutable policy during application assembly. */
16
+ declare function resolveQueueConfig(env?: QueueEnvironment): Readonly<QueueConfig>;
17
+ declare function resolveRedisQueueTransport(env?: QueueEnvironment): "lists" | "streams";
18
+ declare function readQueueVisibilityMs(env?: QueueEnvironment): number;
19
+ declare function snapshotQueueRuntimeConfig(config: QueueRuntimeConfig): QueueRuntimeConfig;
20
+ declare function resolveQueueRuntimeConfig(env?: QueueEnvironment): QueueRuntimeConfig;
21
+ export type { QueueConfig, QueueRetryPolicy, QueueRuntimeConfig };
22
+ export { DEFAULT_QUEUE_VISIBILITY_MS, readQueueVisibilityMs, resolveQueueConfig, resolveQueueRuntimeConfig, resolveRedisQueueTransport, snapshotQueueRetryPolicy, snapshotQueueRuntimeConfig, };
@@ -0,0 +1,31 @@
1
+ import type { ApplicationConfig, ExecutionActor } from "../contracts/application";
2
+ import type { Queue } from "./index";
3
+ import type { JobRegistry } from "./jobRegistry";
4
+ import type { QueueJobEnvelope } from "./jobRunner";
5
+ interface QueueIdentity {
6
+ readonly actor: ExecutionActor;
7
+ readonly tenant?: ApplicationConfig;
8
+ }
9
+ interface QueueHandoff {
10
+ /** Privileged composition capability: callers must already trust the supplied identity. */
11
+ seal(name: string, payload: object, identity: QueueIdentity): string;
12
+ /** Verify before entering application.invoke or constructing a job. */
13
+ verify(job: QueueJobEnvelope): QueueIdentity;
14
+ }
15
+ declare class QueueHandoffError extends TypeError {
16
+ readonly code = "QUEUE_HANDOFF_INVALID";
17
+ constructor();
18
+ }
19
+ /**
20
+ * Keys and audience are supplied by application assembly, never read from job data or ambient state.
21
+ * A handoff is an authenticated identity snapshot, replayable for at-least-once retry/recovery.
22
+ * It does not provide revocation freshness or a single-delivery guarantee. Rotate keys to invalidate it.
23
+ */
24
+ declare function createQueueHandoff(options: {
25
+ readonly key: Uint8Array;
26
+ readonly audience: string;
27
+ }): QueueHandoff;
28
+ /** Capture identity data only; no request scope, signal, database session or resolver survives dispatch. */
29
+ declare function createIdentityQueue(queue: Queue, registry: JobRegistry, handoff: QueueHandoff, identity: QueueIdentity): Pick<Queue, "dispatch">;
30
+ export type { QueueHandoff, QueueIdentity };
31
+ export { createIdentityQueue, createQueueHandoff, QueueHandoffError };
@@ -1,3 +1,5 @@
1
+ import type { QueueConfig } from "./queueConfig";
2
+ import type { QueueServices } from "./queueServices";
1
3
  interface QueueDepthMetrics {
2
4
  high: number;
3
5
  default: number;
@@ -9,9 +11,14 @@ interface QueueMetricsSnapshot {
9
11
  pending: QueueDepthMetrics;
10
12
  failedCount: number;
11
13
  }
12
- declare function readRedisQueueDepth(redisUrl: string): Promise<QueueDepthMetrics>;
13
- declare function collectQueueMetrics(): Promise<QueueMetricsSnapshot>;
14
- export type { QueueDepthMetrics, QueueMetricsSnapshot };
14
+ declare function readRedisQueueDepth(redisUrl: string, transport?: "lists" | "streams"): Promise<QueueDepthMetrics>;
15
+ interface QueueMetricsOptions {
16
+ readonly driver: QueueConfig["driver"];
17
+ readonly redisUrl?: string;
18
+ readonly transport?: "lists" | "streams";
19
+ }
20
+ declare function collectQueueMetrics(failedJobs: Pick<QueueServices, "listRecent">, options?: QueueMetricsOptions): Promise<QueueMetricsSnapshot>;
21
+ export type { QueueDepthMetrics, QueueMetricsOptions, QueueMetricsSnapshot };
15
22
  export { collectQueueMetrics, readRedisQueueDepth };
16
23
  interface RedisQueueSnapshotOptions {
17
24
  transport?: "lists" | "streams";
@@ -0,0 +1,28 @@
1
+ import { type QueueHandoff } from "@getstrata/core/queue/queueHandoff";
2
+ import type { ExecutionEnvelope } from "../contracts/application";
3
+ import type { DatabaseSession } from "../database/session";
4
+ import type FailedJobService from "./failedJobService";
5
+ import type { JobContext } from "./index";
6
+ import type { QueueJobEnvelope } from "./jobRunner";
7
+ /** Explicit application runner; never retains an execution's database session. */
8
+ type QueueInvocation = <T>(envelope: ExecutionEnvelope, work: (ports: {
9
+ readonly database: DatabaseSession;
10
+ readonly policy?: import("../contracts/persistence").ScopedPolicy;
11
+ }) => T | Promise<T>) => Promise<T>;
12
+ type FailureInput = Parameters<FailedJobService["recordFailure"]>[0];
13
+ interface QueueServices extends Pick<FailedJobService, "recordFailure" | "listRecent" | "retry" | "delete" | "flush"> {
14
+ runAttempt(envelope: QueueJobEnvelope, context: JobContext, work: (context: JobContext) => Promise<void>): Promise<void>;
15
+ }
16
+ interface QueueInvocationConfig {
17
+ readonly jobContext?: Readonly<Pick<JobContext, "cache" | "auditExport">>;
18
+ readonly invoke: QueueInvocation;
19
+ readonly attemptEnvelope: (job: QueueJobEnvelope, context: JobContext) => ExecutionEnvelope;
20
+ readonly recoveryEnvelope: (failure?: FailureInput) => ExecutionEnvelope;
21
+ readonly validateReplay?: (record: import("./types").FailedJobRecord) => void;
22
+ }
23
+ declare function createFailedJobService(database: DatabaseSession): FailedJobService;
24
+ declare function createQueueServices(config: QueueInvocationConfig): QueueServices;
25
+ /** With a verifier, unsigned work is admitted only for the explicit copied system-job allowlist. */
26
+ declare function createSystemQueueServices(invoke: QueueInvocation, jobContext?: Readonly<Pick<JobContext, "cache" | "auditExport">>, handoff?: QueueHandoff, systemJobs?: readonly string[]): QueueServices;
27
+ export type { QueueInvocation, QueueInvocationConfig, QueueServices };
28
+ export { createFailedJobService, createQueueServices, createSystemQueueServices };
@@ -0,0 +1,28 @@
1
+ import type { TransportDefinition } from "../contracts/application";
2
+ import type { JobRegistry } from "./jobRegistry";
3
+ import { type QueueRetryPolicy, type QueueRuntimeConfig } from "./queueConfig";
4
+ import type { QueueServices } from "./queueServices";
5
+ interface QueueWorkerAdapter {
6
+ requestStop(): void;
7
+ run(): Promise<void>;
8
+ processNext?(): Promise<boolean>;
9
+ close(): void | Promise<void>;
10
+ }
11
+ interface QueueWorkerTransport {
12
+ readonly transport: TransportDefinition;
13
+ /** Begin polling after the owning application is ready. Actual settlement is retained for drain. */
14
+ start(): Promise<void>;
15
+ /** Admit one bounded poll with the same transport owner and drain barrier. */
16
+ processNext(): Promise<boolean>;
17
+ }
18
+ declare function createQueueWorkerTransport(options: {
19
+ readonly redisUrl: string;
20
+ readonly registry: JobRegistry | (() => JobRegistry);
21
+ readonly queueServices: Pick<QueueServices, "recordFailure" | "runAttempt">;
22
+ readonly name?: string;
23
+ readonly runtime?: QueueRuntimeConfig;
24
+ readonly retryPolicy?: QueueRetryPolicy;
25
+ readonly createWorker?: (redisUrl: string, services: Pick<QueueServices, "recordFailure" | "runAttempt">, registry: JobRegistry) => QueueWorkerAdapter;
26
+ }): QueueWorkerTransport;
27
+ export type { QueueWorkerAdapter, QueueWorkerTransport };
28
+ export { createQueueWorkerTransport };
@@ -1,7 +1,9 @@
1
1
  import { RedisClient } from "bun";
2
- import type FailedJobService from "./failedJobService";
3
- import type { Job, Queue } from "./index";
2
+ import type { Job, Queue, QueueDispatchOptions } from "./index";
3
+ import type { JobRegistry } from "./jobRegistry";
4
4
  import { parseQueueJobEnvelope, type QueueJobEnvelope } from "./jobRunner";
5
+ import { type QueueRetryPolicy, type QueueRuntimeConfig } from "./queueConfig";
6
+ import type { QueueServices } from "./queueServices";
5
7
  import { QUEUE_HIGH_KEY, QUEUE_LIST_KEY, QUEUE_LOW_KEY, queueKeyForPriority } from "./redisQueueKeys";
6
8
  declare function queueProcessingKey(queueKey: string): string;
7
9
  declare function queueProcessingLeaseKey(queueKey: string): string;
@@ -13,29 +15,36 @@ type QueueReservation = {
13
15
  record: string;
14
16
  };
15
17
  declare function queueInvalidKey(queueKey: string): string;
16
- declare function reserveQueueJob(client: RedisClient, queueKey: string, owner: string): Promise<QueueReservation | null>;
17
- declare function updateQueueReservation(client: RedisClient, queueKey: string, reservation: QueueReservation, action: "renew" | "ack" | "quarantine"): Promise<boolean>;
18
- declare function pollListPriorities(client: RedisClient, queueKeys: readonly string[], owner: string, reservationId: string, reclaim: boolean): Promise<{
18
+ declare function reserveQueueJob(client: RedisClient, queueKey: string, owner: string, visibilityMs?: number): Promise<QueueReservation | null>;
19
+ declare function updateQueueReservation(client: RedisClient, queueKey: string, reservation: QueueReservation, action: "renew" | "ack" | "quarantine", visibilityMs?: number): Promise<boolean>;
20
+ declare function pollListPriorities(client: RedisClient, queueKeys: readonly string[], owner: string, reservationId: string, reclaim: boolean, visibilityMs?: number): Promise<{
19
21
  queueKey: string;
20
22
  reservation: QueueReservation;
21
23
  } | null>;
22
- declare function reclaimExpiredQueueReservations(client: RedisClient, queueKeys?: readonly string[]): Promise<number>;
24
+ declare function reclaimExpiredQueueReservations(client: RedisClient, queueKeys?: readonly string[], visibilityMs?: number): Promise<number>;
23
25
  declare class RedisQueue implements Queue {
26
+ private readonly registry;
27
+ private readonly queueKeys;
24
28
  private readonly client;
25
- constructor(redisUrl: string);
29
+ constructor(redisUrl: string, registry: JobRegistry, queueKeys?: readonly [string, string, string]);
26
30
  close(): void;
27
- dispatch<TPayload extends object>(job: Job<TPayload>, payload: TPayload): Promise<void>;
31
+ dispatch<TPayload extends object>(job: Job<TPayload>, payload: TPayload, options?: QueueDispatchOptions): Promise<void>;
32
+ replay<TPayload extends object>(job: Job<TPayload>, payload: TPayload, jobId: string, options?: QueueDispatchOptions): Promise<void>;
33
+ private admit;
28
34
  }
29
35
  declare class QueueWorker {
30
36
  private readonly redisUrl;
31
37
  private readonly failedJobs;
38
+ private readonly registry;
32
39
  private readonly timeoutSeconds;
33
40
  private readonly queueKeys;
41
+ private readonly visibilityMs;
42
+ private readonly retryPolicy;
34
43
  private readonly owner;
35
44
  private running;
36
45
  private stopping;
37
46
  private client;
38
- constructor(redisUrl: string, failedJobs: FailedJobService, timeoutSeconds?: number, queueKeys?: readonly string[]);
47
+ constructor(redisUrl: string, failedJobs: Pick<QueueServices, "recordFailure" | "runAttempt">, registry: JobRegistry, timeoutSeconds?: number, queueKeys?: readonly string[], retryPolicy?: QueueRetryPolicy, visibilityMs?: number);
39
48
  requestStop(): void;
40
49
  isRunning(): boolean;
41
50
  private reserve;
@@ -43,7 +52,7 @@ declare class QueueWorker {
43
52
  run(): Promise<void>;
44
53
  close(): void;
45
54
  }
46
- declare function countPendingQueueJobs(redisUrl: string): Promise<number>;
55
+ declare function countPendingQueueJobs(redisUrl: string, config?: QueueRuntimeConfig): Promise<number>;
47
56
  export type { StreamReservation, StreamsEnqueueOptions } from "./redisStreams";
48
57
  export { migrateLegacyQueueToStreams, RedisStreamsQueue, RedisStreamsWorker, STREAM_GROUP, streamDeadLetterKey, streamQueueKey, updateStreamReservation, } from "./redisStreams";
49
58
  export type { QueueJobEnvelope, QueueReservation };
@@ -1,8 +1,8 @@
1
1
  import type { QueuePriority } from "./index";
2
- declare const QUEUE_LIST_KEY: string;
3
- declare const QUEUE_HIGH_KEY: string;
4
- declare const QUEUE_LOW_KEY: string;
2
+ declare const QUEUE_LIST_KEY = "strata:queue:default";
3
+ declare const QUEUE_HIGH_KEY = "strata:queue:high";
4
+ declare const QUEUE_LOW_KEY = "strata:queue:low";
5
5
  declare function defaultQueueKeys(): readonly [string, string, string];
6
- declare const QUEUE_KEYS: readonly [string, string, string];
7
- declare function queueKeyForPriority(priority?: QueuePriority): string;
6
+ declare const QUEUE_KEYS: readonly string[];
7
+ declare function queueKeyForPriority(priority?: QueuePriority, keys?: readonly [string, string, string]): string;
8
8
  export { defaultQueueKeys, QUEUE_HIGH_KEY, QUEUE_KEYS, QUEUE_LIST_KEY, QUEUE_LOW_KEY, queueKeyForPriority, };
@@ -1,7 +1,9 @@
1
1
  import { RedisClient } from "bun";
2
- import type FailedJobService from "./failedJobService";
3
- import type { Job, Queue } from "./index";
2
+ import type { Job, Queue, QueueDispatchOptions } from "./index";
3
+ import type { JobRegistry } from "./jobRegistry";
4
4
  import { type QueueJobEnvelope } from "./jobRunner";
5
+ import { type QueueRetryPolicy } from "./queueConfig";
6
+ import type { QueueServices } from "./queueServices";
5
7
  declare const STREAM_GROUP = "strata-workers-v1";
6
8
  declare function streamQueueKey(queueKey: string): string;
7
9
  declare function streamDeadLetterKey(queueKey: string): string;
@@ -16,9 +18,9 @@ declare function cancelStreamJob(client: RedisClient, key: string, jobId: string
16
18
  declare function readStreamCancellation(client: RedisClient, controlKey: string): Promise<boolean>;
17
19
  declare function readStreamTime(client: RedisClient): Promise<number>;
18
20
  declare function watchStreamDeadline(client: RedisClient, deadlineAtMs: number, remainingMs: number, expire: () => void, fail: (error: unknown) => void): () => void;
19
- declare function scheduleStreamRetry(client: RedisClient, key: string, reservation: StreamReservation, envelope: QueueJobEnvelope, delayMs: number): Promise<void>;
21
+ declare function scheduleStreamRetry(client: RedisClient, key: string, reservation: StreamReservation, envelope: QueueJobEnvelope, delayMs: number, visibilityMs?: number): Promise<void>;
20
22
  declare function promoteStreamRetries(client: RedisClient, key: string): Promise<number>;
21
- declare function pollStreamPriorities(client: RedisClient, queueKeys: readonly string[], owner: string, cursors: readonly string[]): Promise<{
23
+ declare function pollStreamPriorities(client: RedisClient, queueKeys: readonly string[], owner: string, cursors: readonly string[], visibilityMs?: number): Promise<{
22
24
  cursors: string[];
23
25
  hit: {
24
26
  index: number;
@@ -33,26 +35,31 @@ type StreamReservation = {
33
35
  };
34
36
  declare function ensureStreamGroup(client: RedisClient, key: string): Promise<void>;
35
37
  declare function readStreamEntry(value: unknown, owner: string): StreamReservation | null;
36
- declare function updateStreamReservation(client: RedisClient, key: string, reservation: StreamReservation, action: "renew" | "ack" | "quarantine", controlKey?: string): Promise<boolean>;
37
- declare function reserveStreamJob(client: RedisClient, key: string, owner: string, cursor?: string): Promise<{
38
+ declare function updateStreamReservation(client: RedisClient, key: string, reservation: StreamReservation, action: "renew" | "ack" | "quarantine", controlKey?: string, visibilityMs?: number): Promise<boolean>;
39
+ declare function reserveStreamJob(client: RedisClient, key: string, owner: string, cursor?: string, visibilityMs?: number): Promise<{
38
40
  reservation: StreamReservation | null;
39
41
  cursor: string;
40
42
  }>;
41
43
  declare class RedisStreamsQueue implements Queue {
44
+ private readonly registry;
45
+ private readonly queueKeys;
42
46
  private readonly client;
43
- constructor(redisUrl: string);
47
+ constructor(redisUrl: string, registry: JobRegistry, queueKeys?: readonly [string, string, string]);
44
48
  close(): void;
45
- dispatch<TPayload extends object>(job: Job<TPayload>, payload: TPayload): Promise<void>;
49
+ dispatch<TPayload extends object>(job: Job<TPayload>, payload: TPayload, options?: QueueDispatchOptions): Promise<void>;
46
50
  enqueue<TPayload extends object>(job: Job<TPayload>, payload: TPayload, options?: StreamsEnqueueOptions): Promise<string>;
47
- replay<TPayload extends object>(job: Job<TPayload>, payload: TPayload, jobId: string): Promise<void>;
51
+ replay<TPayload extends object>(job: Job<TPayload>, payload: TPayload, jobId: string, options?: QueueDispatchOptions): Promise<void>;
48
52
  private admit;
49
53
  cancel(jobId: string): Promise<boolean>;
50
54
  }
51
55
  declare class RedisStreamsWorker {
52
56
  private readonly redisUrl;
53
57
  private readonly failedJobs;
58
+ private readonly registry;
54
59
  private readonly timeoutSeconds;
55
60
  private readonly queueKeys;
61
+ private readonly visibilityMs;
62
+ private readonly retryPolicy;
56
63
  private client;
57
64
  private readonly owner;
58
65
  private readonly cursors;
@@ -61,7 +68,7 @@ declare class RedisStreamsWorker {
61
68
  private running;
62
69
  private stopping;
63
70
  private active?;
64
- constructor(redisUrl: string, failedJobs: FailedJobService, timeoutSeconds?: number, queueKeys?: readonly string[]);
71
+ constructor(redisUrl: string, failedJobs: Pick<QueueServices, "recordFailure" | "runAttempt">, registry: JobRegistry, timeoutSeconds?: number, queueKeys?: readonly string[], retryPolicy?: QueueRetryPolicy, visibilityMs?: number);
65
72
  requestStop(): void;
66
73
  isRunning(): boolean;
67
74
  close(): void;
@@ -1,9 +1,15 @@
1
- import type FailedJobService from "./failedJobService";
2
- import { AsyncQueue, type Job } from "./index";
1
+ import { AsyncQueue, type Job, type QueueDispatchOptions } from "./index";
2
+ import type { JobRegistry } from "./jobRegistry";
3
+ import { type QueueRetryPolicy } from "./queueConfig";
4
+ import type { QueueServices } from "./queueServices";
3
5
  declare class ResilientQueue extends AsyncQueue {
4
6
  private readonly failedJobs;
7
+ private readonly registry;
5
8
  private readonly asyncDispatch;
6
- constructor(failedJobs: FailedJobService, asyncDispatch?: boolean);
7
- dispatch<TPayload extends object>(job: Job<TPayload>, payload: TPayload): Promise<void>;
9
+ private readonly retryPolicy;
10
+ constructor(failedJobs: Pick<QueueServices, "recordFailure" | "runAttempt">, registry: JobRegistry, asyncDispatch?: boolean, retryPolicy?: QueueRetryPolicy);
11
+ dispatch<TPayload extends object>(job: Job<TPayload>, payload: TPayload, options?: QueueDispatchOptions): Promise<void>;
12
+ replay<TPayload extends object>(job: Job<TPayload>, payload: TPayload, jobId: string, options?: QueueDispatchOptions): Promise<void>;
13
+ private admit;
8
14
  }
9
15
  export { ResilientQueue };
@@ -2,6 +2,7 @@ interface FailedJobRecord {
2
2
  id: number;
3
3
  job_name: string;
4
4
  job_id?: string | null;
5
+ handoff?: string | null;
5
6
  payload: Record<string, unknown>;
6
7
  exception: string;
7
8
  failed_at: Date;
@@ -1,7 +1,7 @@
1
1
  import { type EnvRecord } from "./appEnv";
2
- declare function appKeyPrefix(): string;
3
- declare function appCookieName(kind: string): string;
4
- declare function appDevSecret(kind: string): string;
2
+ declare function appKeyPrefix(env?: EnvRecord): string;
3
+ declare function appCookieName(kind: string, env?: EnvRecord): string;
4
+ declare function appDevSecret(kind: string, env?: EnvRecord): string;
5
5
  /**
6
6
  * Use a configured secret, or a predictable local fallback. Production,
7
7
  * staging, and unrecognized APP_ENV values treated as production must set a
@@ -9,10 +9,10 @@ declare function appDevSecret(kind: string): string;
9
9
  */
10
10
  declare function requireConfiguredSecret(names: readonly string[], devKind: string, env?: EnvRecord): string;
11
11
  declare function namespacedRedisKey(kind: string): string;
12
- declare function smtpEhloHost(): string;
12
+ declare function smtpEhloHost(env?: EnvRecord): string;
13
13
  declare function siemEventType(): string;
14
14
  declare function appUserAgent(): string;
15
- declare function otelServiceName(): string;
15
+ declare function otelServiceName(env?: EnvRecord): string;
16
16
  declare function webhookSignatureHeader(): string;
17
17
  declare function appDisplayName(): string;
18
18
  declare function appEnv(): string;
@@ -0,0 +1,7 @@
1
+ import { CORE_EXECUTION_CONTEXT_TOKEN } from "@getstrata/core/contracts/executionContext";
2
+ import type { Application, ApplicationDefinition } from "../contracts/application";
3
+ declare function createApplication(definition: ApplicationDefinition): Application;
4
+ export { aliasService, resourceService, service, valueService, } from "@getstrata/core/contracts/services";
5
+ export type * from "../contracts/application";
6
+ export type * from "../contracts/services";
7
+ export { CORE_EXECUTION_CONTEXT_TOKEN, createApplication };
@@ -0,0 +1,9 @@
1
+ import type { ExecutionContext, ExecutionEnvelope } from "../contracts/application";
2
+ /** Validation and copying perform no timer, listener, container or factory effects. */
3
+ declare function normalizeExecutionEnvelope(input: unknown): ExecutionEnvelope;
4
+ declare function ownExecutionContext(envelope: ExecutionEnvelope, applicationId: string, appSignal: AbortSignal): {
5
+ context: ExecutionContext;
6
+ dispose: () => void;
7
+ check: () => void;
8
+ };
9
+ export { normalizeExecutionEnvelope, ownExecutionContext };