alepha 0.20.1 → 0.20.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 (393) hide show
  1. package/README.md +0 -1
  2. package/assets/swagger-ui/swagger-ui-bundle.js +1 -1
  3. package/assets/swagger-ui/swagger-ui.css +1 -1
  4. package/dist/api/audits/index.browser.js +49 -0
  5. package/dist/api/audits/index.browser.js.map +1 -1
  6. package/dist/api/audits/index.d.ts.map +1 -1
  7. package/dist/api/audits/index.js +49 -0
  8. package/dist/api/audits/index.js.map +1 -1
  9. package/dist/api/files/index.d.ts.map +1 -1
  10. package/dist/api/files/index.js +2 -1
  11. package/dist/api/files/index.js.map +1 -1
  12. package/dist/api/jobs/index.browser.js +64 -148
  13. package/dist/api/jobs/index.browser.js.map +1 -1
  14. package/dist/api/jobs/index.d.ts +339 -600
  15. package/dist/api/jobs/index.d.ts.map +1 -1
  16. package/dist/api/jobs/index.js +605 -1012
  17. package/dist/api/jobs/index.js.map +1 -1
  18. package/dist/api/keys/index.js.map +1 -1
  19. package/dist/api/notifications/index.d.ts +79 -27
  20. package/dist/api/notifications/index.d.ts.map +1 -1
  21. package/dist/api/notifications/index.js +90 -23
  22. package/dist/api/notifications/index.js.map +1 -1
  23. package/dist/api/organizations/index.d.ts.map +1 -1
  24. package/dist/api/parameters/index.browser.js +37 -0
  25. package/dist/api/parameters/index.browser.js.map +1 -1
  26. package/dist/api/parameters/index.d.ts +4 -65
  27. package/dist/api/parameters/index.d.ts.map +1 -1
  28. package/dist/api/parameters/index.js +37 -0
  29. package/dist/api/parameters/index.js.map +1 -1
  30. package/dist/api/payments/index.d.ts +2 -1
  31. package/dist/api/payments/index.d.ts.map +1 -1
  32. package/dist/api/payments/index.js +4 -2
  33. package/dist/api/payments/index.js.map +1 -1
  34. package/dist/api/users/index.d.ts +225 -5199
  35. package/dist/api/users/index.d.ts.map +1 -1
  36. package/dist/api/users/index.js +15 -11
  37. package/dist/api/users/index.js.map +1 -1
  38. package/dist/api/verifications/index.d.ts.map +1 -1
  39. package/dist/api/verifications/index.js +4 -2
  40. package/dist/api/verifications/index.js.map +1 -1
  41. package/dist/bucket/index.js +5 -1
  42. package/dist/bucket/index.js.map +1 -1
  43. package/dist/bucket/index.workerd.js +5 -1
  44. package/dist/bucket/index.workerd.js.map +1 -1
  45. package/dist/cache/core/index.js.map +1 -1
  46. package/dist/cache/core/index.workerd.js.map +1 -1
  47. package/dist/captcha/index.js.map +1 -1
  48. package/dist/cli/core/index.d.ts +225 -11681
  49. package/dist/cli/core/index.d.ts.map +1 -1
  50. package/dist/cli/core/index.js +732 -257
  51. package/dist/cli/core/index.js.map +1 -1
  52. package/dist/cli/devtools/index.js +7 -1
  53. package/dist/cli/devtools/index.js.map +1 -1
  54. package/dist/cli/platform/index.d.ts +65 -63
  55. package/dist/cli/platform/index.d.ts.map +1 -1
  56. package/dist/cli/platform/index.js +140 -27
  57. package/dist/cli/platform/index.js.map +1 -1
  58. package/dist/cli/vendor/index.js +15 -0
  59. package/dist/cli/vendor/index.js.map +1 -1
  60. package/dist/command/index.d.ts +1 -1
  61. package/dist/command/index.js +1 -1
  62. package/dist/command/index.js.map +1 -1
  63. package/dist/core/index.browser.js +6 -0
  64. package/dist/core/index.browser.js.map +1 -1
  65. package/dist/core/index.d.ts +8 -8
  66. package/dist/core/index.d.ts.map +1 -1
  67. package/dist/core/index.js +6 -0
  68. package/dist/core/index.js.map +1 -1
  69. package/dist/core/index.native.js +6 -0
  70. package/dist/core/index.native.js.map +1 -1
  71. package/dist/core/index.workerd.js +6 -0
  72. package/dist/core/index.workerd.js.map +1 -1
  73. package/dist/crypto/index.js.map +1 -1
  74. package/dist/datetime/index.js.map +1 -1
  75. package/dist/email/core/index.js.map +1 -1
  76. package/dist/email/smtp/index.js +2 -10522
  77. package/dist/email/smtp/index.js.map +1 -1
  78. package/dist/fake/index.d.ts +4 -8085
  79. package/dist/fake/index.d.ts.map +1 -1
  80. package/dist/fake/index.js +3 -33554
  81. package/dist/fake/index.js.map +1 -1
  82. package/dist/lock/core/index.js.map +1 -1
  83. package/dist/lock/redis/index.js.map +1 -1
  84. package/dist/logger/index.js +32 -1
  85. package/dist/logger/index.js.map +1 -1
  86. package/dist/mcp/index.js +5 -1
  87. package/dist/mcp/index.js.map +1 -1
  88. package/dist/orm/core/index.browser.js +1 -361
  89. package/dist/orm/core/index.browser.js.map +1 -1
  90. package/dist/orm/core/index.bun.js +14 -406
  91. package/dist/orm/core/index.bun.js.map +1 -1
  92. package/dist/orm/core/index.d.ts +96 -5117
  93. package/dist/orm/core/index.d.ts.map +1 -1
  94. package/dist/orm/core/index.js +23 -419
  95. package/dist/orm/core/index.js.map +1 -1
  96. package/dist/orm/postgres/index.bun.js +17 -20
  97. package/dist/orm/postgres/index.bun.js.map +1 -1
  98. package/dist/orm/postgres/index.d.ts +2 -613
  99. package/dist/orm/postgres/index.d.ts.map +1 -1
  100. package/dist/orm/postgres/index.js +17 -20
  101. package/dist/orm/postgres/index.js.map +1 -1
  102. package/dist/react/core/index.js.map +1 -1
  103. package/dist/react/form/index.d.ts +60 -1
  104. package/dist/react/form/index.d.ts.map +1 -1
  105. package/dist/react/form/index.js +86 -1
  106. package/dist/react/form/index.js.map +1 -1
  107. package/dist/react/head/index.browser.js +16 -1
  108. package/dist/react/head/index.browser.js.map +1 -1
  109. package/dist/react/head/index.d.ts +6 -0
  110. package/dist/react/head/index.d.ts.map +1 -1
  111. package/dist/react/head/index.js +16 -1
  112. package/dist/react/head/index.js.map +1 -1
  113. package/dist/react/i18n/index.js.map +1 -1
  114. package/dist/react/intro/index.js +22 -17
  115. package/dist/react/intro/index.js.map +1 -1
  116. package/dist/react/router/index.browser.js +78 -12
  117. package/dist/react/router/index.browser.js.map +1 -1
  118. package/dist/react/router/index.d.ts +57 -13
  119. package/dist/react/router/index.d.ts.map +1 -1
  120. package/dist/react/router/index.js +102 -14
  121. package/dist/react/router/index.js.map +1 -1
  122. package/dist/react/testing/index.d.ts +1 -411
  123. package/dist/react/testing/index.d.ts.map +1 -1
  124. package/dist/react/testing/index.js +13 -12293
  125. package/dist/react/testing/index.js.map +1 -1
  126. package/dist/react/ui/index.d.ts +124 -0
  127. package/dist/react/ui/index.d.ts.map +1 -0
  128. package/dist/react/ui/index.js +209 -0
  129. package/dist/react/ui/index.js.map +1 -0
  130. package/dist/react/websocket/index.js.map +1 -1
  131. package/dist/redis/index.js.map +1 -1
  132. package/dist/router/index.d.ts +13 -13
  133. package/dist/router/index.d.ts.map +1 -1
  134. package/dist/router/index.js +45 -32
  135. package/dist/router/index.js.map +1 -1
  136. package/dist/scheduler/index.d.ts +1 -83
  137. package/dist/scheduler/index.d.ts.map +1 -1
  138. package/dist/scheduler/index.js +2 -391
  139. package/dist/scheduler/index.js.map +1 -1
  140. package/dist/scheduler/index.workerd.js +2 -391
  141. package/dist/scheduler/index.workerd.js.map +1 -1
  142. package/dist/security/index.browser.js.map +1 -1
  143. package/dist/security/index.d.ts +2 -325
  144. package/dist/security/index.d.ts.map +1 -1
  145. package/dist/security/index.js +3 -1362
  146. package/dist/security/index.js.map +1 -1
  147. package/dist/server/auth/index.d.ts +1 -1054
  148. package/dist/server/auth/index.d.ts.map +1 -1
  149. package/dist/server/auth/index.js +16 -1224
  150. package/dist/server/auth/index.js.map +1 -1
  151. package/dist/server/cookies/index.js.map +1 -1
  152. package/dist/server/core/index.browser.js.map +1 -1
  153. package/dist/server/core/index.d.ts +1 -4
  154. package/dist/server/core/index.d.ts.map +1 -1
  155. package/dist/server/core/index.js +19 -4
  156. package/dist/server/core/index.js.map +1 -1
  157. package/dist/server/links/index.browser.js.map +1 -1
  158. package/dist/server/links/index.js.map +1 -1
  159. package/dist/server/metrics/index.d.ts +1 -514
  160. package/dist/server/metrics/index.d.ts.map +1 -1
  161. package/dist/server/metrics/index.js +4 -4356
  162. package/dist/server/metrics/index.js.map +1 -1
  163. package/dist/server/rate-limit/index.js.map +1 -1
  164. package/dist/server/static/index.js.map +1 -1
  165. package/dist/server/swagger/index.js +1 -1
  166. package/dist/server/swagger/index.js.map +1 -1
  167. package/dist/sms/index.js.map +1 -1
  168. package/dist/system/index.browser.js.map +1 -1
  169. package/dist/system/index.d.ts.map +1 -1
  170. package/dist/system/index.js +1 -0
  171. package/dist/system/index.js.map +1 -1
  172. package/dist/system/index.workerd.js.map +1 -1
  173. package/dist/topic/core/index.js +1 -1
  174. package/dist/topic/core/index.js.map +1 -1
  175. package/dist/websocket/index.browser.js +21 -0
  176. package/dist/websocket/index.browser.js.map +1 -1
  177. package/dist/websocket/index.js +21 -0
  178. package/dist/websocket/index.js.map +1 -1
  179. package/package.json +23 -37
  180. package/src/api/files/__tests__/FileController.spec.ts +1 -1
  181. package/src/api/files/jobs/FileJobs.ts +2 -1
  182. package/src/api/jobs/__tests__/$job.spec.ts +320 -2867
  183. package/src/api/jobs/controllers/AdminJobController.ts +29 -138
  184. package/src/api/jobs/entities/jobExecutionEntity.ts +27 -19
  185. package/src/api/jobs/index.browser.ts +5 -7
  186. package/src/api/jobs/index.ts +23 -51
  187. package/src/api/jobs/primitives/$job.ts +66 -58
  188. package/src/api/jobs/providers/JobProvider.ts +561 -566
  189. package/src/api/jobs/providers/JobQueueProvider.ts +18 -19
  190. package/src/api/jobs/schemas/jobConfigAtom.ts +20 -23
  191. package/src/api/jobs/schemas/jobExecutionQuerySchema.ts +3 -27
  192. package/src/api/jobs/schemas/jobExecutionResourceSchema.ts +5 -7
  193. package/src/api/jobs/schemas/jobRegistrationSchema.ts +7 -4
  194. package/src/api/jobs/schemas/triggerJobSchema.ts +0 -1
  195. package/src/api/jobs/services/JobService.ts +90 -483
  196. package/src/api/notifications/controllers/AdminNotificationController.ts +19 -12
  197. package/src/api/notifications/index.ts +7 -4
  198. package/src/api/notifications/jobs/NotificationJobs.ts +83 -12
  199. package/src/api/payments/services/PaymentService.ts +4 -2
  200. package/src/api/users/__tests__/UserJobs.spec.ts +10 -49
  201. package/src/api/users/audits/UserAudits.ts +3 -1
  202. package/src/api/users/buckets/UserBuckets.ts +2 -1
  203. package/src/api/users/index.ts +1 -4
  204. package/src/api/users/jobs/UserJobs.ts +5 -4
  205. package/src/api/users/schemas/userQuerySchema.ts +0 -1
  206. package/src/api/users/services/UserService.ts +1 -5
  207. package/src/api/verifications/__tests__/CodeVerification.spec.ts +14 -0
  208. package/src/api/verifications/__tests__/LinkVerification.spec.ts +14 -0
  209. package/src/api/verifications/jobs/VerificationJobs.ts +2 -1
  210. package/src/api/verifications/services/VerificationService.ts +1 -0
  211. package/src/cli/core/__tests__/init.spec.ts +209 -1
  212. package/src/cli/core/commands/init.ts +9 -9
  213. package/src/cli/core/services/PackageManagerUtils.ts +22 -12
  214. package/src/cli/core/services/ProjectScaffolder.ts +300 -70
  215. package/src/cli/core/tasks/BuildDockerTask.ts +9 -10
  216. package/src/cli/core/tasks/BuildServerTask.ts +8 -0
  217. package/src/cli/core/templates/agentMd.ts +2 -8
  218. package/src/cli/core/templates/apiIndexTs.ts +22 -14
  219. package/src/cli/core/templates/componentsJsonTs.ts +39 -0
  220. package/src/cli/core/templates/mainCss.ts +2 -36
  221. package/src/cli/core/templates/saasAdminLayoutTsx.ts +77 -0
  222. package/src/cli/core/templates/saasAdminPagesTsx.ts +26 -0
  223. package/src/cli/core/templates/saasAuthLayoutTsx.ts +20 -0
  224. package/src/cli/core/templates/saasAuthPagesTsx.ts +62 -0
  225. package/src/cli/core/templates/saasRealmProviderTs.ts +46 -0
  226. package/src/cli/core/templates/vitestConfigTs.ts +17 -0
  227. package/src/cli/core/templates/webAppRouterTs.ts +102 -82
  228. package/src/cli/core/templates/webIndexTs.ts +23 -1
  229. package/src/cli/platform/__tests__/CloudflareAdapter.spec.ts +22 -71
  230. package/src/cli/platform/__tests__/SecretsCommand.spec.ts +2 -0
  231. package/src/cli/platform/adapters/CloudflareAdapter.ts +12 -11
  232. package/src/cli/platform/atoms/platformOptions.ts +9 -0
  233. package/src/cli/platform/schemas/cloudflare.ts +3 -2
  234. package/src/cli/platform/services/CloudflareApi.ts +164 -25
  235. package/src/cli/platform/services/WranglerApi.ts +0 -17
  236. package/src/command/providers/CliProvider.ts +1 -1
  237. package/src/core/Alepha.ts +9 -0
  238. package/src/core/interfaces/Service.ts +3 -1
  239. package/src/core/providers/TypeProvider.ts +1 -1
  240. package/src/logger/services/Logger.ts +1 -1
  241. package/src/mcp/__tests__/$resource.spec.ts +1 -1
  242. package/src/mcp/__tests__/$tool.spec.ts +1 -1
  243. package/src/mcp/__tests__/McpServerProvider.spec.ts +1 -1
  244. package/src/orm/__tests__/$repository-tests.ts +1 -0
  245. package/src/orm/__tests__/orm-next-tests.ts +2 -67
  246. package/src/orm/__tests__/orm-next.spec.ts +0 -21
  247. package/src/orm/core/index.shared.ts +0 -2
  248. package/src/orm/core/index.ts +1 -2
  249. package/src/orm/core/primitives/$repository.ts +3 -6
  250. package/src/orm/core/providers/drivers/DatabaseProvider.ts +0 -5
  251. package/src/orm/core/providers/drivers/NodeSqliteProvider.ts +11 -13
  252. package/src/orm/core/services/ModelBuilder.ts +1 -13
  253. package/src/orm/core/services/Repository.ts +1 -42
  254. package/src/orm/core/services/SqliteModelBuilder.ts +2 -33
  255. package/src/orm/postgres/services/PostgresModelBuilder.ts +10 -45
  256. package/src/react/form/index.ts +2 -0
  257. package/src/react/form/services/parseField.ts +163 -0
  258. package/src/react/form/services/prettyName.ts +19 -0
  259. package/src/react/head/providers/BrowserHeadProvider.ts +31 -10
  260. package/src/react/intro/components/GettingStartedAuthSlide.tsx +11 -4
  261. package/src/react/router/__tests__/ReactBrowserProvider.browser.spec.ts +213 -2
  262. package/src/react/router/primitives/$page.ts +35 -12
  263. package/src/react/router/providers/ReactBrowserProvider.ts +73 -0
  264. package/src/react/router/providers/ReactBrowserRouterProvider.ts +1 -1
  265. package/src/react/router/providers/ReactPreloadProvider.ts +1 -1
  266. package/src/react/router/providers/ReactServerProvider.ts +1 -0
  267. package/src/react/ui/atoms/uiAtom.ts +28 -0
  268. package/src/react/ui/components/ColorScheme.tsx +36 -0
  269. package/src/react/ui/hooks/useColorMode.ts +49 -0
  270. package/src/react/ui/hooks/useSidebarState.ts +26 -0
  271. package/src/react/ui/hooks/useTheme.ts +22 -0
  272. package/src/react/ui/index.ts +35 -0
  273. package/src/react/ui/services/UiPersistence.ts +41 -0
  274. package/src/router/TemplatedPathParser.ts +50 -51
  275. package/src/router/__tests__/RouterProvider.spec.ts +62 -0
  276. package/src/router/__tests__/TemplatedPathParser.spec.ts +18 -0
  277. package/src/router/providers/RouterProvider.ts +10 -5
  278. package/src/scheduler/providers/CronProvider.ts +1 -1
  279. package/src/security/primitives/$basicAuth.ts +1 -1
  280. package/src/server/auth/providers/ServerAuthProvider.ts +5 -1
  281. package/src/server/core/interfaces/ServerRequest.ts +1 -0
  282. package/src/server/core/providers/ServerProvider.ts +1 -1
  283. package/src/server/core/providers/ServerRouterProvider.ts +2 -2
  284. package/src/server/core/services/HttpClient.ts +1 -1
  285. package/src/server/swagger/providers/ServerSwaggerProvider.ts +1 -1
  286. package/src/system/providers/NodeShellProvider.ts +1 -0
  287. package/src/topic/core/providers/TopicProvider.ts +1 -1
  288. package/dist/api/invitations/index.d.ts +0 -790
  289. package/dist/api/invitations/index.d.ts.map +0 -1
  290. package/dist/api/invitations/index.js +0 -662
  291. package/dist/api/invitations/index.js.map +0 -1
  292. package/dist/api/issues/index.d.ts +0 -810
  293. package/dist/api/issues/index.d.ts.map +0 -1
  294. package/dist/api/issues/index.js +0 -444
  295. package/dist/api/issues/index.js.map +0 -1
  296. package/dist/api/subscriptions/index.d.ts +0 -1692
  297. package/dist/api/subscriptions/index.d.ts.map +0 -1
  298. package/dist/api/subscriptions/index.js +0 -1867
  299. package/dist/api/subscriptions/index.js.map +0 -1
  300. package/dist/api/workflows/index.browser.js +0 -246
  301. package/dist/api/workflows/index.browser.js.map +0 -1
  302. package/dist/api/workflows/index.d.ts +0 -1618
  303. package/dist/api/workflows/index.d.ts.map +0 -1
  304. package/dist/api/workflows/index.js +0 -1495
  305. package/dist/api/workflows/index.js.map +0 -1
  306. package/dist/react/testing/chunk-DBEY4PJZ.js +0 -16
  307. package/src/api/invitations/__tests__/InvitationService.spec.ts +0 -439
  308. package/src/api/invitations/controllers/AdminInvitationController.ts +0 -86
  309. package/src/api/invitations/controllers/InvitationController.ts +0 -84
  310. package/src/api/invitations/entities/invitations.ts +0 -33
  311. package/src/api/invitations/index.ts +0 -58
  312. package/src/api/invitations/jobs/InvitationJobs.ts +0 -37
  313. package/src/api/invitations/providers/InvitationProvider.ts +0 -45
  314. package/src/api/invitations/schemas/createInvitationSchema.ts +0 -12
  315. package/src/api/invitations/schemas/invitationConfigAtom.ts +0 -20
  316. package/src/api/invitations/schemas/invitationQuerySchema.ts +0 -15
  317. package/src/api/invitations/schemas/invitationResourceSchema.ts +0 -6
  318. package/src/api/invitations/schemas/invitationWithResourceInfoSchema.ts +0 -22
  319. package/src/api/invitations/schemas/myInvitationsQuerySchema.ts +0 -10
  320. package/src/api/invitations/services/InvitationService.ts +0 -556
  321. package/src/api/issues/__tests__/IssueService.spec.ts +0 -263
  322. package/src/api/issues/controllers/AdminIssueController.ts +0 -149
  323. package/src/api/issues/controllers/IssueController.ts +0 -44
  324. package/src/api/issues/entities/issues.ts +0 -49
  325. package/src/api/issues/index.ts +0 -50
  326. package/src/api/issues/schemas/createIssueSchema.ts +0 -13
  327. package/src/api/issues/schemas/issueConfigAtom.ts +0 -13
  328. package/src/api/issues/schemas/issueQuerySchema.ts +0 -18
  329. package/src/api/issues/schemas/issueResourceSchema.ts +0 -6
  330. package/src/api/issues/schemas/myIssueQuerySchema.ts +0 -10
  331. package/src/api/issues/schemas/updateIssueSchema.ts +0 -13
  332. package/src/api/issues/services/IssueService.ts +0 -264
  333. package/src/api/jobs/__tests__/$job-middleware.spec.ts +0 -126
  334. package/src/api/jobs/__tests__/JobService.spec.ts +0 -31
  335. package/src/api/jobs/entities/jobExecutionLogEntity.ts +0 -13
  336. package/src/api/jobs/schemas/jobActivitySchema.ts +0 -15
  337. package/src/api/jobs/schemas/jobCronInfoSchema.ts +0 -22
  338. package/src/api/jobs/schemas/jobExecutionDetailResourceSchema.ts +0 -20
  339. package/src/api/jobs/schemas/jobFailureSchema.ts +0 -9
  340. package/src/api/jobs/schemas/jobQueueDepthSchema.ts +0 -14
  341. package/src/api/jobs/schemas/jobStatsSchema.ts +0 -14
  342. package/src/api/jobs/services/JobService-tests.ts +0 -157
  343. package/src/api/subscriptions/__tests__/BillingService.spec.ts +0 -218
  344. package/src/api/subscriptions/__tests__/SubscriptionService.spec.ts +0 -278
  345. package/src/api/subscriptions/controllers/AdminSubscriptionController.ts +0 -212
  346. package/src/api/subscriptions/controllers/SubscriptionController.ts +0 -189
  347. package/src/api/subscriptions/entities/subscriptionEvents.ts +0 -54
  348. package/src/api/subscriptions/entities/subscriptions.ts +0 -68
  349. package/src/api/subscriptions/index.ts +0 -133
  350. package/src/api/subscriptions/jobs/SubscriptionJobs.ts +0 -382
  351. package/src/api/subscriptions/middleware/$requireLimit.ts +0 -50
  352. package/src/api/subscriptions/middleware/$requirePlan.ts +0 -49
  353. package/src/api/subscriptions/notifications/SubscriptionNotifications.ts +0 -110
  354. package/src/api/subscriptions/schemas/cancelSubscriptionSchema.ts +0 -8
  355. package/src/api/subscriptions/schemas/changePlanSchema.ts +0 -9
  356. package/src/api/subscriptions/schemas/createSubscriptionSchema.ts +0 -11
  357. package/src/api/subscriptions/schemas/entitlementsSchema.ts +0 -21
  358. package/src/api/subscriptions/schemas/mrrSchema.ts +0 -13
  359. package/src/api/subscriptions/schemas/planDefinitionSchema.ts +0 -71
  360. package/src/api/subscriptions/schemas/planResourceSchema.ts +0 -25
  361. package/src/api/subscriptions/schemas/subscriptionEventResourceSchema.ts +0 -8
  362. package/src/api/subscriptions/schemas/subscriptionQuerySchema.ts +0 -19
  363. package/src/api/subscriptions/schemas/subscriptionResourceSchema.ts +0 -6
  364. package/src/api/subscriptions/schemas/subscriptionSettingsSchema.ts +0 -32
  365. package/src/api/subscriptions/schemas/subscriptionStatsSchema.ts +0 -23
  366. package/src/api/subscriptions/services/BillingService.ts +0 -437
  367. package/src/api/subscriptions/services/SubscriptionConfig.ts +0 -56
  368. package/src/api/subscriptions/services/SubscriptionService.ts +0 -867
  369. package/src/api/subscriptions/services/UsageService.ts +0 -118
  370. package/src/api/workflows/__tests__/$workflow.spec.ts +0 -616
  371. package/src/api/workflows/controllers/AdminWorkflowController.ts +0 -191
  372. package/src/api/workflows/entities/workflowExecutions.ts +0 -74
  373. package/src/api/workflows/entities/workflowStepExecutions.ts +0 -74
  374. package/src/api/workflows/entities/workflowStepLogs.ts +0 -13
  375. package/src/api/workflows/index.browser.ts +0 -22
  376. package/src/api/workflows/index.ts +0 -115
  377. package/src/api/workflows/jobs/WorkflowJobs.ts +0 -77
  378. package/src/api/workflows/primitives/$workflow.ts +0 -202
  379. package/src/api/workflows/providers/WorkflowProvider.ts +0 -1284
  380. package/src/api/workflows/schemas/workflowActivitySchema.ts +0 -15
  381. package/src/api/workflows/schemas/workflowConfigAtom.ts +0 -51
  382. package/src/api/workflows/schemas/workflowExecutionDetailSchema.ts +0 -18
  383. package/src/api/workflows/schemas/workflowExecutionQuerySchema.ts +0 -26
  384. package/src/api/workflows/schemas/workflowExecutionResourceSchema.ts +0 -30
  385. package/src/api/workflows/schemas/workflowRegistrationSchema.ts +0 -26
  386. package/src/api/workflows/schemas/workflowStatsSchema.ts +0 -16
  387. package/src/api/workflows/schemas/workflowStepExecutionResourceSchema.ts +0 -15
  388. package/src/api/workflows/services/WorkflowService.ts +0 -382
  389. package/src/cli/core/templates/apiAppSecurityTs.ts +0 -43
  390. package/src/cli/core/templates/webAdminDashboardTsx.ts +0 -17
  391. package/src/orm/core/__tests__/parseQueryString.spec.ts +0 -196
  392. package/src/orm/core/helpers/parseQueryString.ts +0 -502
  393. package/src/orm/core/primitives/$view.ts +0 -88
@@ -1,16 +1,14 @@
1
1
  import * as _$alepha from "alepha";
2
2
  import { Alepha, AlephaError, Async, KIND, PipelinePrimitive, PipelinePrimitiveOptions, Static, TNull, TObject, TOptional, TSchema, TUnion } from "alepha";
3
- import { LockProvider } from "alepha/lock";
4
3
  import * as _$alepha_queue0 from "alepha/queue";
5
4
  import { CronProvider } from "alepha/scheduler";
6
5
  import * as _$alepha_server0 from "alepha/server";
7
6
  import * as _$alepha_logger0 from "alepha/logger";
7
+ import { LogEntry } from "alepha/logger";
8
8
  import * as _$alepha_orm0 from "alepha/orm";
9
- import { DatabaseProvider } from "alepha/orm";
10
9
  import { DateTime, DateTimeProvider, DurationLike } from "alepha/datetime";
11
10
  import { BuildExtraConfigColumns, SQL } from "drizzle-orm";
12
11
  import { PgColumnBuilderBase, PgSequenceOptions, PgTableExtraConfigValue, UpdateDeleteAction } from "drizzle-orm/pg-core";
13
- import * as _$typebox from "typebox";
14
12
  //#region ../../src/orm/core/schemas/insertSchema.d.ts
15
13
  /**
16
14
  * Transforms a TObject schema for insert operations.
@@ -317,21 +315,23 @@ declare module "alepha" {
317
315
  //#endregion
318
316
  //#region ../../src/api/jobs/primitives/$job.d.ts
319
317
  /**
320
- * Job primitive for defining scheduled and on-demand tasks with payload validation and retry policies.
318
+ * Job primitive for defining scheduled (cron) or queued (push) tasks.
319
+ *
320
+ * A job must be either **cron-only** (pass `cron`) or **queue-only**
321
+ * (pass `schema`), never both. To run scheduled work that processes
322
+ * payloads, compose two jobs: a cron that pushes payloads, and a
323
+ * queue job that handles them.
321
324
  */
322
325
  declare const $job: {
323
326
  <T extends TSchema = TSchema>(options: JobPrimitiveOptions<T>): JobPrimitive<T>;
324
327
  [KIND]: typeof JobPrimitive;
325
328
  };
326
- interface JobItem<T extends TSchema = TSchema> {
327
- id: string;
329
+ interface JobHandlerArgs<T extends TSchema = TSchema> {
328
330
  payload: Static<T>;
329
331
  attempt: number;
330
- }
331
- interface JobHandlerArgs<T extends TSchema = TSchema> {
332
- items: Array<JobItem<T>>;
333
332
  now: DateTime;
334
333
  signal: AbortSignal;
334
+ executionId: string;
335
335
  }
336
336
  interface JobRetryBackoff {
337
337
  initial: DurationLike;
@@ -347,38 +347,66 @@ interface JobRetryOptions {
347
347
  type JobPriority = "critical" | "high" | "normal" | "low";
348
348
  interface JobPrimitiveOptions<T extends TSchema = TSchema> extends PipelinePrimitiveOptions {
349
349
  /**
350
- * Payload schema (TypeBox). Optional for cron-only jobs.
350
+ * Optional explicit job name. Defaults to `ClassName.propertyKey`.
351
+ * Recommended convention for framework-internal jobs: `api:module:jobName`.
351
352
  */
352
- schema?: T;
353
+ name?: string;
353
354
  /**
354
- * Cron expression for automatic scheduling.
355
+ * Human-readable description (shown in the admin UI).
355
356
  */
356
- cron?: string;
357
+ description?: string;
357
358
  /**
358
- * Whether to use a distributed lock for cron execution.
359
- * @default true
359
+ * Payload schema (TypeBox). When set, the job is queue-mode.
360
+ * Must not be combined with `cron`.
360
361
  */
361
- lock?: boolean;
362
+ schema?: T;
362
363
  /**
363
- * Retry policy for failed executions.
364
+ * Cron expression for recurring execution. When set, the job is cron-mode.
365
+ * Must not be combined with `schema`.
364
366
  */
365
- retry?: JobRetryOptions;
367
+ cron?: string;
366
368
  /**
367
- * Max execution time per attempt.
369
+ * Retry policy for queue-mode jobs.
370
+ * Cron-mode jobs do not retry — the next tick re-runs.
368
371
  */
369
- timeout?: DurationLike;
372
+ retry?: JobRetryOptions;
370
373
  /**
371
- * Max parallel executions.
372
- * @default 1
374
+ * Max execution time per attempt. Handler receives an `AbortSignal`.
373
375
  */
374
- concurrency?: number;
376
+ timeout?: DurationLike;
375
377
  /**
376
- * Default priority for pushed jobs.
378
+ * Default priority for pushed jobs. Used by the sweep to order
379
+ * dispatch when there is a backlog. Real-time queue consumption
380
+ * is FIFO.
377
381
  * @default "normal"
378
382
  */
379
383
  priority?: JobPriority;
380
384
  /**
381
- * Handler function for job execution.
385
+ * Whether to record successful executions.
386
+ *
387
+ * - `"error"` (default for cron, default for queue): only error/cancelled rows kept
388
+ * - `"all"`: keep success rows too (bounded by `keepLastSuccess`)
389
+ * - `"none"`: fire-and-forget, no row even on error
390
+ *
391
+ * Note: queue-mode jobs always write a `pending` row at push time (outbox).
392
+ * This setting controls whether that row is kept on success.
393
+ */
394
+ record?: "error" | "all" | "none";
395
+ /**
396
+ * Override the global ring-buffer trim for this job.
397
+ *
398
+ * - `{ ok: 0, error: 0 }` — **keep forever** (no sweep trim). Useful for
399
+ * audit-heavy jobs where retention is time-based (handled by a separate
400
+ * cron) rather than count-based.
401
+ * - `{ ok: 50 }` — keep last 50 successes; fall back to global default for errors.
402
+ * - omitted — use global `keepLastSuccess` / `keepLastError` from `jobConfig`.
403
+ */
404
+ keep?: {
405
+ ok?: number;
406
+ error?: number;
407
+ };
408
+ /**
409
+ * Handler function. For cron-mode, `payload` is `undefined`.
382
410
  */
383
411
  handler: (args: JobHandlerArgs<T>) => Async<void>;
384
412
  }
@@ -387,41 +415,34 @@ declare class JobPrimitive<T extends TSchema = TSchema> extends PipelinePrimitiv
387
415
  get name(): string;
388
416
  protected onInit(): void;
389
417
  /**
390
- * Push a single payload or an array of payloads.
418
+ * Push a single payload to the queue (queue-mode only).
391
419
  */
392
- push(payload: Static<T> | Array<Static<T>>, options?: PushOptions): Promise<string | string[]>;
420
+ push(payload: Static<T>, options?: PushOptions): Promise<string>;
393
421
  /**
394
- * Push multiple payloads with per-item options.
422
+ * Push multiple payloads at once (queue-mode only).
423
+ * Batched INSERT + batched queue send when supported.
395
424
  */
396
425
  pushMany(items: Array<PushManyItem<T>>): Promise<string[]>;
397
426
  /**
398
- * Cancel a running or pending execution.
427
+ * Cancel a pending or running execution.
399
428
  */
400
429
  cancel(executionId: string): Promise<void>;
401
430
  /**
402
- * Manually trigger the job (admin / CLI).
431
+ * Manually fire a cron-mode job, or trigger a queue-mode job with an explicit payload.
403
432
  */
404
- trigger(context?: JobTriggerContext): Promise<void>;
405
- /**
406
- * Pause this job. Pushed items are still accepted but processing is held.
407
- */
408
- pause(): void;
409
- /**
410
- * Resume a paused job and dispatch any pending items.
411
- */
412
- resume(): Promise<void>;
413
- /**
414
- * Whether this job is currently paused.
415
- */
416
- get paused(): boolean;
433
+ trigger(context?: JobTriggerContext<T>): Promise<void>;
417
434
  }
418
435
  //#endregion
419
436
  //#region ../../src/api/jobs/providers/JobProvider.d.ts
437
+ declare const PRIORITY_MAP: Record<JobPriority, number>;
438
+ declare const PRIORITY_REVERSE: Record<number, JobPriority>;
420
439
  interface PushOptions {
421
440
  delay?: DurationLike;
422
441
  key?: string;
423
442
  priority?: JobPriority;
424
443
  scheduledAt?: Date;
444
+ triggeredBy?: string;
445
+ triggeredByName?: string;
425
446
  }
426
447
  interface PushManyItem<T extends TSchema = TSchema> {
427
448
  payload: Static<T>;
@@ -430,8 +451,8 @@ interface PushManyItem<T extends TSchema = TSchema> {
430
451
  priority?: JobPriority;
431
452
  scheduledAt?: Date;
432
453
  }
433
- interface JobTriggerContext {
434
- payload?: Record<string, unknown>;
454
+ interface JobTriggerContext<T extends TSchema = TSchema> {
455
+ payload?: Static<T>;
435
456
  triggeredBy?: string;
436
457
  triggeredByName?: string;
437
458
  }
@@ -439,25 +460,38 @@ interface CancelContext {
439
460
  cancelledBy?: string;
440
461
  cancelledByName?: string;
441
462
  }
442
- interface JobRegistration$1 {
463
+ interface JobRuntimeRegistration {
443
464
  name: string;
444
465
  options: JobPrimitiveOptions;
466
+ type: "cron" | "queue";
445
467
  }
468
+ /**
469
+ * Coordinates cron (scheduler) and queue (push) jobs with a durable outbox
470
+ * table and a single reconciliation sweep.
471
+ *
472
+ * Queue-mode flow:
473
+ * push() → INSERT row (pending) + queue.send({ executionId })
474
+ * worker → SELECT row → UPDATE running → handler → DELETE (ok) / UPDATE (error)
475
+ *
476
+ * Cron-mode flow:
477
+ * scheduler tick → handler runs inline → INSERT row only on error
478
+ *
479
+ * Sweep responsibilities (every `sweepInterval`):
480
+ * - re-enqueue pending rows older than `staleThreshold`
481
+ * - fail running rows older than `max(timeout*2, runTimeout)`
482
+ * - move `scheduled` rows with `scheduledAt <= now` to pending + enqueue
483
+ * - trim per-job history beyond `keepLastSuccess` / `keepLastError`
484
+ */
446
485
  declare class JobProvider {
447
486
  protected readonly alepha: Alepha;
448
487
  protected readonly dt: DateTimeProvider;
449
488
  protected readonly cronProvider: CronProvider;
450
- protected readonly lockProvider: LockProvider;
451
489
  protected readonly config: Readonly<{
452
- recovery: {
453
- interval: number;
454
- staleThreshold: number;
455
- runTimeout: number;
456
- };
457
- delayed: {
458
- interval: number;
459
- };
460
- logRetentionDays: number;
490
+ sweepInterval: number;
491
+ staleThreshold: number;
492
+ runTimeout: number;
493
+ keepLastSuccess: number;
494
+ keepLastError: number;
461
495
  logMaxEntries: number;
462
496
  drainTimeout: number;
463
497
  }>;
@@ -468,26 +502,17 @@ declare class JobProvider {
468
502
  updatedAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_UPDATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
469
503
  jobName: _$alepha.TString;
470
504
  key: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TNull, _$alepha.TString]>>;
471
- payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
472
- status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"running" | "pending" | "scheduled" | "retrying" | "dead" | "completed" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
505
+ status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"ok" | "error" | "pending" | "running" | "scheduled" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
473
506
  priority: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
474
507
  attempt: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
475
508
  maxAttempts: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
509
+ payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
476
510
  scheduledAt: _$alepha.TOptional<_$alepha.TString>;
477
511
  startedAt: _$alepha.TOptional<_$alepha.TString>;
478
512
  completedAt: _$alepha.TOptional<_$alepha.TString>;
479
- result: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
480
513
  error: _$alepha.TOptional<_$alepha.TString>;
481
- workerId: _$alepha.TOptional<_$alepha.TString>;
482
- triggeredBy: _$alepha.TOptional<_$alepha.TString>;
483
- triggeredByName: _$alepha.TOptional<_$alepha.TString>;
484
- cancelledBy: _$alepha.TOptional<_$alepha.TString>;
485
- cancelledByName: _$alepha.TOptional<_$alepha.TString>;
486
- }>>;
487
- protected readonly executionLogs: _$alepha_orm0.Repository<_$alepha.TObject<{
488
- id: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_PRIMARY_KEY>, typeof _$alepha_orm0.PG_DEFAULT>;
489
- logs: _$alepha.TArray<_$alepha.TObject<{
490
- level: _$alepha.TUnsafe<"TRACE" | "SILENT" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
514
+ logs: _$alepha.TOptional<_$alepha.TArray<_$alepha.TObject<{
515
+ level: _$alepha.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
491
516
  message: _$alepha.TString;
492
517
  service: _$alepha.TString;
493
518
  module: _$alepha.TString;
@@ -495,214 +520,143 @@ declare class JobProvider {
495
520
  app: _$alepha.TOptional<_$alepha.TString>;
496
521
  data: _$alepha.TOptional<_$alepha.TAny>;
497
522
  timestamp: _$alepha.TNumber;
498
- }>>;
523
+ }>>>;
524
+ triggeredBy: _$alepha.TOptional<_$alepha.TString>;
525
+ triggeredByName: _$alepha.TOptional<_$alepha.TString>;
526
+ cancelledBy: _$alepha.TOptional<_$alepha.TString>;
527
+ cancelledByName: _$alepha.TOptional<_$alepha.TString>;
499
528
  }>>;
500
- protected readonly jobs: Map<string, JobRegistration$1>;
501
- protected readonly pausedJobs: Set<string>;
529
+ protected readonly jobs: Map<string, JobRuntimeRegistration>;
502
530
  protected readonly inFlight: Set<Promise<void>>;
503
- /**
504
- * When set, job executions are dispatched through a queue (e.g. `JobQueueProvider`).
505
- * When null, jobs execute inline (fire-and-forget). Useful for serverless environments.
506
- */
507
- queueDispatch: ((jobName: string, executionId: string) => Promise<void>) | null;
508
- protected readonly logs: Map<string, {
531
+ protected readonly abortControllers: Map<string, AbortController>;
532
+ protected readonly perExecutionLogs: Map<string, {
509
533
  context?: string | undefined;
510
534
  app?: string | undefined;
511
535
  data?: any;
512
- level: "TRACE" | "SILENT" | "DEBUG" | "INFO" | "WARN" | "ERROR";
536
+ level: "SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR";
513
537
  message: string;
514
538
  service: string;
515
539
  module: string;
516
540
  timestamp: number;
517
541
  }[]>;
518
- protected readonly abortControllers: Map<string, AbortController>;
519
- protected static readonly SWEEP_CRON = "*/5 * * * *";
520
542
  protected stopping: boolean;
521
- protected workerId: string;
543
+ /**
544
+ * Set by `JobQueueProvider` when `AlephaApiJobsQueue` is loaded.
545
+ * When null, queue-mode jobs cannot be pushed.
546
+ */
547
+ queueDispatch: ((jobName: string, executionId: string) => Promise<void>) | null;
522
548
  registerJob(name: string, options: JobPrimitiveOptions): void;
549
+ getRegisteredJobs(): Map<string, JobRuntimeRegistration>;
550
+ protected runCron(name: string): Promise<void>;
523
551
  /**
524
- * Get all registered job definitions.
552
+ * Execute a cron handler inline. Records a row only on error (or always,
553
+ * when `record: 'all'`). No DB writes on the happy path by default.
525
554
  */
526
- getRegisteredJobs(): Map<string, JobRegistration$1>;
555
+ protected executeInline(registration: JobRuntimeRegistration, executionId: string, ctx: {
556
+ payload: unknown;
557
+ attempt: number;
558
+ triggeredBy?: string;
559
+ triggeredByName?: string;
560
+ }): Promise<void>;
561
+ protected writeTerminalRow(executionId: string, jobName: string, status: "ok" | "error", fields: {
562
+ payload: unknown;
563
+ attempt: number;
564
+ startedAt: ReturnType<DateTimeProvider["now"]>;
565
+ error?: Error;
566
+ context: string;
567
+ triggeredBy?: string;
568
+ triggeredByName?: string;
569
+ }): Promise<void>;
527
570
  push(name: string, payload: unknown, options?: PushOptions): Promise<string>;
571
+ /**
572
+ * Fire a local setTimeout so delayed/retrying rows dispatch as close to
573
+ * `scheduledAt` as possible, rather than waiting for the next sweep tick.
574
+ * No-op on stateless runtimes where timers won't survive (the sweep
575
+ * handles those).
576
+ */
577
+ protected scheduleOptimisticDispatch(jobName: string, executionId: string, scheduledAt: string): void;
528
578
  pushMany(name: string, items: Array<PushManyItem>): Promise<string[]>;
579
+ protected dispatchToQueue(jobName: string, executionId: string): Promise<void>;
529
580
  trigger(name: string, context?: JobTriggerContext): Promise<void>;
530
581
  cancel(executionId: string, context?: CancelContext): Promise<void>;
531
- protected scheduleProcessing(jobName: string, executionId: string): Promise<void>;
532
582
  processExecution(jobName: string, executionId: string): Promise<void>;
533
- protected processExecutionInner(jobName: string, executionId: string): Promise<void>;
534
- /**
535
- * After a job finishes (success, failure, or cancel), dispatch any pending
536
- * jobs that were deferred due to the concurrency limit.
537
- */
538
- protected dispatchNextPending(jobName: string): Promise<void>;
583
+ protected processQueueExecution(registration: JobRuntimeRegistration, executionId: string): Promise<void>;
539
584
  protected claim(executionId: string): Promise<boolean>;
540
- protected handleFailure(executionId: string, jobName: string, error: Error, context: string): Promise<void>;
541
- protected computeBackoff(retryOpts: JobRetryOptions, attempt: number): string;
542
- protected writeLogs(executionId: string, context: string): Promise<void>;
543
- protected dispatchRetrying(jobName: string, executionId: string): Promise<void>;
585
+ protected handleFailure(executionId: string, registration: JobRuntimeRegistration, currentAttempt: number, error: Error, contextId: string): Promise<void>;
586
+ protected computeBackoff(retry: JobRetryOptions, attempt: number): string;
587
+ protected snapshotLogs(contextId: string): LogEntry[] | undefined;
588
+ protected sweep(): Promise<void>;
589
+ protected dispatchToQueueSafe(jobName: string, executionId: string): Promise<void>;
544
590
  /**
545
- * Recovery Sweep (Section 5.1)
546
- *
547
- * Runs every `recovery.interval` (default: 1 minute).
548
- * - Stale `pending` jobs older than `staleThreshold` → re-dispatch.
549
- * - Crashed `running` jobs older than `max(job.timeout * 2, recovery.runTimeout)` → mark failed, apply retry policy.
550
- */
551
- protected recoverySweep(): Promise<void>;
552
- /**
553
- * Delayed Dispatch Sweep (Section 5.2)
554
- *
555
- * Runs every `delayed.interval` (default: 30 seconds).
556
- * Scans for `scheduled` and `retrying` jobs where `scheduledAt <= now`,
557
- * moves them to `pending`, and dispatches to the queue layer.
558
- */
559
- protected delayedDispatchSweep(): Promise<void>;
560
- /**
561
- * Log Purge (Section 5.3)
562
- *
563
- * Runs daily at 03:00 via cron.
564
- * Deletes completed/dead/cancelled execution records older than `logRetentionDays`.
591
+ * Move a row from `scheduled` → `pending` and dispatch it.
592
+ * Used by the optimistic retry/delay timer. If the sweep has already moved
593
+ * the row, or another worker has claimed it, the UPDATE guard fails silently.
565
594
  */
566
- protected logPurge(): Promise<void>;
567
- pauseJob(name: string): void;
568
- resumeJob(name: string): Promise<void>;
569
- isJobPaused(name: string): boolean;
570
- getPausedJobs(): string[];
571
- protected tryLock(key: string, ttlMs: number): Promise<boolean>;
572
- protected releaseLock(key: string): Promise<void>;
595
+ protected dispatchScheduled(jobName: string, executionId: string): Promise<void>;
596
+ protected trimRingBuffers(): Promise<void>;
597
+ protected trimByStatus(jobName: string, status: "ok" | "error", keep: number): Promise<void>;
573
598
  protected readonly onStart: _$alepha.HookPrimitive<"start">;
574
599
  protected readonly onStop: _$alepha.HookPrimitive<"stop">;
575
- protected getRegistration(name: string): JobRegistration$1;
600
+ protected getRegistration(name: string): JobRuntimeRegistration;
576
601
  }
577
602
  //#endregion
578
- //#region ../../src/api/jobs/schemas/jobActivitySchema.d.ts
579
- declare const jobActivityPointSchema: _$alepha.TObject<{
580
- date: _$alepha.TString;
581
- completed: _$alepha.TInteger;
582
- failed: _$alepha.TInteger;
583
- }>;
584
- type JobActivityPoint = Static<typeof jobActivityPointSchema>;
585
- declare const jobActivityQuerySchema: _$alepha.TObject<{
586
- days: _$alepha.TOptional<_$alepha.TInteger>;
587
- }>;
588
- type JobActivityQuery = Static<typeof jobActivityQuerySchema>;
589
- //#endregion
590
- //#region ../../src/api/jobs/schemas/jobCronInfoSchema.d.ts
591
- declare const jobCronInfoSchema: _$alepha.TObject<{
592
- name: _$alepha.TString;
593
- cron: _$alepha.TString;
594
- lock: _$alepha.TBoolean;
595
- priority: _$alepha.TUnsafe<"critical" | "high" | "normal" | "low">;
596
- concurrency: _$alepha.TInteger;
597
- hasSchema: _$alepha.TBoolean;
598
- paused: _$alepha.TBoolean;
599
- lastExecution: _$alepha.TOptional<_$alepha.TObject<{
600
- id: _$alepha.TString;
601
- status: _$alepha.TString;
602
- startedAt: _$alepha.TOptional<_$alepha.TString>;
603
- completedAt: _$alepha.TOptional<_$alepha.TString>;
604
- error: _$alepha.TOptional<_$alepha.TString>;
605
- }>>;
606
- }>;
607
- type JobCronInfo = Static<typeof jobCronInfoSchema>;
608
- //#endregion
609
603
  //#region ../../src/api/jobs/schemas/jobExecutionQuerySchema.d.ts
610
604
  declare const jobExecutionQuerySchema: _$alepha.TObject<{
611
- page: _$alepha.TOptional<_$alepha.TInteger>;
612
- size: _$alepha.TOptional<_$alepha.TInteger>;
613
- sort: _$alepha.TOptional<_$alepha.TString>;
614
- job: _$alepha.TOptional<_$alepha.TString>;
615
- status: _$alepha.TOptional<_$alepha.TUnsafe<"running" | "pending" | "scheduled" | "retrying" | "dead" | "completed" | "cancelled">>;
616
- priority: _$alepha.TOptional<_$alepha.TUnsafe<"critical" | "high" | "normal" | "low">>;
617
- from: _$alepha.TOptional<_$alepha.TString>;
618
- to: _$alepha.TOptional<_$alepha.TString>;
605
+ status: _$alepha.TOptional<_$alepha.TUnsafe<"ok" | "error" | "pending" | "running" | "scheduled" | "cancelled">>;
606
+ limit: _$alepha.TOptional<_$alepha.TInteger>;
619
607
  }>;
620
608
  type JobExecutionQuery = Static<typeof jobExecutionQuerySchema>;
621
609
  //#endregion
622
- //#region ../../src/api/jobs/schemas/jobFailureSchema.d.ts
623
- declare const jobFailureSchema: _$alepha.TObject<{
624
- jobName: _$alepha.TString;
625
- failures: _$alepha.TInteger;
626
- lastError: _$alepha.TOptional<_$alepha.TString>;
627
- }>;
628
- type JobFailure = Static<typeof jobFailureSchema>;
629
- //#endregion
630
- //#region ../../src/api/jobs/schemas/jobQueueDepthSchema.d.ts
631
- declare const jobQueueDepthSchema: _$alepha.TObject<{
632
- jobName: _$alepha.TString;
633
- pending: _$alepha.TInteger;
634
- running: _$alepha.TInteger;
635
- scheduled: _$alepha.TInteger;
636
- retrying: _$alepha.TInteger;
637
- dead: _$alepha.TInteger;
638
- concurrency: _$alepha.TInteger;
639
- paused: _$alepha.TBoolean;
640
- }>;
641
- type JobQueueDepth = Static<typeof jobQueueDepthSchema>;
642
- //#endregion
643
610
  //#region ../../src/api/jobs/schemas/jobRegistrationSchema.d.ts
644
611
  declare const jobRegistrationSchema: _$alepha.TObject<{
645
612
  name: _$alepha.TString;
646
- type: _$alepha.TUnsafe<"push" | "cron" | "both">;
613
+ description: _$alepha.TOptional<_$alepha.TString>;
614
+ type: _$alepha.TUnsafe<"cron" | "queue">;
647
615
  priority: _$alepha.TUnsafe<"critical" | "high" | "normal" | "low">;
648
- concurrency: _$alepha.TInteger;
649
- hasSchema: _$alepha.TBoolean;
650
616
  cron: _$alepha.TOptional<_$alepha.TString>;
651
617
  timeout: _$alepha.TOptional<_$alepha.TString>;
652
618
  retry: _$alepha.TOptional<_$alepha.TObject<{
653
619
  retries: _$alepha.TInteger;
654
620
  hasBackoff: _$alepha.TBoolean;
655
621
  }>>;
656
- paused: _$alepha.TBoolean;
622
+ recent: _$alepha.TObject<{
623
+ ok: _$alepha.TInteger;
624
+ error: _$alepha.TInteger;
625
+ lastRun: _$alepha.TOptional<_$alepha.TString>;
626
+ }>;
657
627
  }>;
658
628
  type JobRegistration = Static<typeof jobRegistrationSchema>;
659
629
  //#endregion
660
- //#region ../../src/api/jobs/schemas/jobStatsSchema.d.ts
661
- declare const jobStatsSchema: _$alepha.TObject<{
662
- registered: _$alepha.TInteger;
663
- running: _$alepha.TInteger;
664
- pending: _$alepha.TInteger;
665
- scheduled: _$alepha.TInteger;
666
- retrying: _$alepha.TInteger;
667
- dead: _$alepha.TInteger;
668
- completed: _$alepha.TInteger;
669
- failed: _$alepha.TInteger;
670
- }>;
671
- type JobStats = Static<typeof jobStatsSchema>;
672
- //#endregion
673
630
  //#region ../../src/api/jobs/services/JobService.d.ts
631
+ /**
632
+ * Admin surface for the job system.
633
+ *
634
+ * Six methods: list jobs, list executions, get execution,
635
+ * trigger, retry, cancel. Everything else lives in events — any
636
+ * analytics/observability is an external concern that subscribes
637
+ * to `job:begin` / `job:success` / `job:error`.
638
+ */
674
639
  declare class JobService {
675
640
  protected readonly alepha: Alepha;
676
- protected readonly dt: DateTimeProvider;
677
641
  protected readonly log: _$alepha_logger0.Logger;
678
642
  protected readonly jobProvider: JobProvider;
679
- protected readonly database: DatabaseProvider;
680
643
  protected readonly executions: _$alepha_orm0.Repository<_$alepha.TObject<{
681
644
  id: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_PRIMARY_KEY>, typeof _$alepha_orm0.PG_DEFAULT>;
682
645
  createdAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_CREATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
683
646
  updatedAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_UPDATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
684
647
  jobName: _$alepha.TString;
685
648
  key: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TNull, _$alepha.TString]>>;
686
- payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
687
- status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"running" | "pending" | "scheduled" | "retrying" | "dead" | "completed" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
649
+ status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"ok" | "error" | "pending" | "running" | "scheduled" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
688
650
  priority: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
689
651
  attempt: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
690
652
  maxAttempts: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
653
+ payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
691
654
  scheduledAt: _$alepha.TOptional<_$alepha.TString>;
692
655
  startedAt: _$alepha.TOptional<_$alepha.TString>;
693
656
  completedAt: _$alepha.TOptional<_$alepha.TString>;
694
- result: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
695
657
  error: _$alepha.TOptional<_$alepha.TString>;
696
- workerId: _$alepha.TOptional<_$alepha.TString>;
697
- triggeredBy: _$alepha.TOptional<_$alepha.TString>;
698
- triggeredByName: _$alepha.TOptional<_$alepha.TString>;
699
- cancelledBy: _$alepha.TOptional<_$alepha.TString>;
700
- cancelledByName: _$alepha.TOptional<_$alepha.TString>;
701
- }>>;
702
- protected readonly executionLogs: _$alepha_orm0.Repository<_$alepha.TObject<{
703
- id: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_PRIMARY_KEY>, typeof _$alepha_orm0.PG_DEFAULT>;
704
- logs: _$alepha.TArray<_$alepha.TObject<{
705
- level: _$alepha.TUnsafe<"TRACE" | "SILENT" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
658
+ logs: _$alepha.TOptional<_$alepha.TArray<_$alepha.TObject<{
659
+ level: _$alepha.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
706
660
  message: _$alepha.TString;
707
661
  service: _$alepha.TString;
708
662
  module: _$alepha.TString;
@@ -710,164 +664,88 @@ declare class JobService {
710
664
  app: _$alepha.TOptional<_$alepha.TString>;
711
665
  data: _$alepha.TOptional<_$alepha.TAny>;
712
666
  timestamp: _$alepha.TNumber;
713
- }>>;
667
+ }>>>;
668
+ triggeredBy: _$alepha.TOptional<_$alepha.TString>;
669
+ triggeredByName: _$alepha.TOptional<_$alepha.TString>;
670
+ cancelledBy: _$alepha.TOptional<_$alepha.TString>;
671
+ cancelledByName: _$alepha.TOptional<_$alepha.TString>;
714
672
  }>>;
715
673
  protected computeCan(status: string): {
716
674
  retry: boolean;
717
675
  cancel: boolean;
718
676
  };
719
677
  /**
720
- * Convert an ISO date string to the raw SQL parameter format
721
- * expected by the current database dialect.
722
- *
723
- * - PostgreSQL: ISO string (timestamp comparison)
724
- * - SQLite: epoch milliseconds (integer comparison)
678
+ * List every registered job with recent ok/error counts and lastRun.
679
+ * One aggregate query covers all jobs.
725
680
  */
726
- protected toRawDate(iso: string): string | number;
727
- getStats(days?: number): Promise<JobStats>;
728
- getRegistry(): JobRegistration[];
729
- findExecutions(query?: JobExecutionQuery): Promise<{
730
- content: {
731
- can: {
732
- retry: boolean;
733
- cancel: boolean;
734
- };
735
- key?: string | null | undefined;
736
- payload?: _$typebox.StaticRecord<[], "Decode", {}, {
737
- id: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_PRIMARY_KEY>, typeof _$alepha_orm0.PG_DEFAULT>;
738
- createdAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_CREATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
739
- updatedAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_UPDATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
740
- jobName: _$alepha.TString;
741
- key: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TNull, _$alepha.TString]>>;
742
- payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
743
- status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"running" | "pending" | "scheduled" | "retrying" | "dead" | "completed" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
744
- priority: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
745
- attempt: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
746
- maxAttempts: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
747
- scheduledAt: _$alepha.TOptional<_$alepha.TString>;
748
- startedAt: _$alepha.TOptional<_$alepha.TString>;
749
- completedAt: _$alepha.TOptional<_$alepha.TString>;
750
- result: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
751
- error: _$alepha.TOptional<_$alepha.TString>;
752
- workerId: _$alepha.TOptional<_$alepha.TString>;
753
- triggeredBy: _$alepha.TOptional<_$alepha.TString>;
754
- triggeredByName: _$alepha.TOptional<_$alepha.TString>;
755
- cancelledBy: _$alepha.TOptional<_$alepha.TString>;
756
- cancelledByName: _$alepha.TOptional<_$alepha.TString>;
757
- }, "^.*$", _$alepha.TAny> | undefined;
758
- scheduledAt?: string | undefined;
759
- startedAt?: string | undefined;
760
- completedAt?: string | undefined;
761
- result?: _$typebox.StaticRecord<[], "Decode", {}, {
762
- id: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_PRIMARY_KEY>, typeof _$alepha_orm0.PG_DEFAULT>;
763
- createdAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_CREATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
764
- updatedAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_UPDATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
765
- jobName: _$alepha.TString;
766
- key: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TNull, _$alepha.TString]>>;
767
- payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
768
- status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"running" | "pending" | "scheduled" | "retrying" | "dead" | "completed" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
769
- priority: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
770
- attempt: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
771
- maxAttempts: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
772
- scheduledAt: _$alepha.TOptional<_$alepha.TString>;
773
- startedAt: _$alepha.TOptional<_$alepha.TString>;
774
- completedAt: _$alepha.TOptional<_$alepha.TString>;
775
- result: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
776
- error: _$alepha.TOptional<_$alepha.TString>;
777
- workerId: _$alepha.TOptional<_$alepha.TString>;
778
- triggeredBy: _$alepha.TOptional<_$alepha.TString>;
779
- triggeredByName: _$alepha.TOptional<_$alepha.TString>;
780
- cancelledBy: _$alepha.TOptional<_$alepha.TString>;
781
- cancelledByName: _$alepha.TOptional<_$alepha.TString>;
782
- }, "^.*$", _$alepha.TAny> | undefined;
783
- error?: string | undefined;
784
- workerId?: string | undefined;
785
- triggeredBy?: string | undefined;
786
- triggeredByName?: string | undefined;
787
- cancelledBy?: string | undefined;
788
- cancelledByName?: string | undefined;
789
- priority: number;
790
- status: "running" | "pending" | "scheduled" | "retrying" | "dead" | "completed" | "cancelled";
791
- id: string;
792
- createdAt: string;
793
- updatedAt: string;
794
- jobName: string;
795
- attempt: number;
796
- maxAttempts: number;
797
- }[];
798
- page: _$alepha.StaticDecode<typeof _$alepha.pageMetadataSchema>;
799
- }>;
800
- getExecution(id: string): Promise<{
681
+ listJobs(): Promise<JobRegistration[]>;
682
+ /**
683
+ * Recent executions for a single job, ORDER BY startedAt DESC.
684
+ */
685
+ getExecutions(jobName: string, query?: JobExecutionQuery): Promise<{
801
686
  can: {
802
687
  retry: boolean;
803
688
  cancel: boolean;
804
689
  };
805
- logs: {
690
+ error?: string | undefined;
691
+ key?: string | null | undefined;
692
+ payload?: Record<string, any> | undefined;
693
+ scheduledAt?: string | undefined;
694
+ startedAt?: string | undefined;
695
+ completedAt?: string | undefined;
696
+ logs?: {
806
697
  context?: string | undefined;
807
698
  app?: string | undefined;
808
699
  data?: any;
809
- level: "TRACE" | "SILENT" | "DEBUG" | "INFO" | "WARN" | "ERROR";
700
+ level: "SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR";
810
701
  message: string;
811
702
  service: string;
812
703
  module: string;
813
704
  timestamp: number;
814
705
  }[] | undefined;
706
+ triggeredBy?: string | undefined;
707
+ triggeredByName?: string | undefined;
708
+ cancelledBy?: string | undefined;
709
+ cancelledByName?: string | undefined;
710
+ priority: number;
711
+ status: "ok" | "error" | "pending" | "running" | "scheduled" | "cancelled";
712
+ id: string;
713
+ createdAt: string;
714
+ updatedAt: string;
715
+ jobName: string;
716
+ attempt: number;
717
+ maxAttempts: number;
718
+ }[]>;
719
+ /**
720
+ * Full execution detail (includes captured logs).
721
+ */
722
+ getExecution(id: string): Promise<{
723
+ can: {
724
+ retry: boolean;
725
+ cancel: boolean;
726
+ };
727
+ error?: string | undefined;
815
728
  key?: string | null | undefined;
816
- payload?: _$typebox.StaticRecord<[], "Decode", {}, {
817
- id: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_PRIMARY_KEY>, typeof _$alepha_orm0.PG_DEFAULT>;
818
- createdAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_CREATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
819
- updatedAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_UPDATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
820
- jobName: _$alepha.TString;
821
- key: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TNull, _$alepha.TString]>>;
822
- payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
823
- status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"running" | "pending" | "scheduled" | "retrying" | "dead" | "completed" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
824
- priority: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
825
- attempt: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
826
- maxAttempts: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
827
- scheduledAt: _$alepha.TOptional<_$alepha.TString>;
828
- startedAt: _$alepha.TOptional<_$alepha.TString>;
829
- completedAt: _$alepha.TOptional<_$alepha.TString>;
830
- result: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
831
- error: _$alepha.TOptional<_$alepha.TString>;
832
- workerId: _$alepha.TOptional<_$alepha.TString>;
833
- triggeredBy: _$alepha.TOptional<_$alepha.TString>;
834
- triggeredByName: _$alepha.TOptional<_$alepha.TString>;
835
- cancelledBy: _$alepha.TOptional<_$alepha.TString>;
836
- cancelledByName: _$alepha.TOptional<_$alepha.TString>;
837
- }, "^.*$", _$alepha.TAny> | undefined;
729
+ payload?: Record<string, any> | undefined;
838
730
  scheduledAt?: string | undefined;
839
731
  startedAt?: string | undefined;
840
732
  completedAt?: string | undefined;
841
- result?: _$typebox.StaticRecord<[], "Decode", {}, {
842
- id: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_PRIMARY_KEY>, typeof _$alepha_orm0.PG_DEFAULT>;
843
- createdAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_CREATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
844
- updatedAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_UPDATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
845
- jobName: _$alepha.TString;
846
- key: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TNull, _$alepha.TString]>>;
847
- payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
848
- status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"running" | "pending" | "scheduled" | "retrying" | "dead" | "completed" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
849
- priority: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
850
- attempt: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
851
- maxAttempts: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
852
- scheduledAt: _$alepha.TOptional<_$alepha.TString>;
853
- startedAt: _$alepha.TOptional<_$alepha.TString>;
854
- completedAt: _$alepha.TOptional<_$alepha.TString>;
855
- result: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
856
- error: _$alepha.TOptional<_$alepha.TString>;
857
- workerId: _$alepha.TOptional<_$alepha.TString>;
858
- triggeredBy: _$alepha.TOptional<_$alepha.TString>;
859
- triggeredByName: _$alepha.TOptional<_$alepha.TString>;
860
- cancelledBy: _$alepha.TOptional<_$alepha.TString>;
861
- cancelledByName: _$alepha.TOptional<_$alepha.TString>;
862
- }, "^.*$", _$alepha.TAny> | undefined;
863
- error?: string | undefined;
864
- workerId?: string | undefined;
733
+ logs?: {
734
+ context?: string | undefined;
735
+ app?: string | undefined;
736
+ data?: any;
737
+ level: "SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR";
738
+ message: string;
739
+ service: string;
740
+ module: string;
741
+ timestamp: number;
742
+ }[] | undefined;
865
743
  triggeredBy?: string | undefined;
866
744
  triggeredByName?: string | undefined;
867
745
  cancelledBy?: string | undefined;
868
746
  cancelledByName?: string | undefined;
869
747
  priority: number;
870
- status: "running" | "pending" | "scheduled" | "retrying" | "dead" | "completed" | "cancelled";
748
+ status: "ok" | "error" | "pending" | "running" | "scheduled" | "cancelled";
871
749
  id: string;
872
750
  createdAt: string;
873
751
  updatedAt: string;
@@ -875,9 +753,15 @@ declare class JobService {
875
753
  attempt: number;
876
754
  maxAttempts: number;
877
755
  }>;
756
+ /**
757
+ * Manual trigger (cron jobs) or push-with-payload (queue jobs).
758
+ */
878
759
  triggerJob(name: string, context?: JobTriggerContext): Promise<{
879
760
  ok: boolean;
880
761
  }>;
762
+ /**
763
+ * Retry a dead or cancelled execution by re-pushing with the original payload.
764
+ */
881
765
  retryExecution(id: string, context?: {
882
766
  triggeredBy?: string;
883
767
  triggeredByName?: string;
@@ -890,105 +774,68 @@ declare class JobService {
890
774
  }): Promise<{
891
775
  ok: boolean;
892
776
  }>;
893
- pauseJob(name: string, context?: {
894
- pausedBy?: string;
895
- pausedByName?: string;
896
- }): {
897
- ok: boolean;
898
- };
899
- resumeJob(name: string, context?: {
900
- resumedBy?: string;
901
- resumedByName?: string;
902
- }): Promise<{
903
- ok: boolean;
904
- }>;
905
- getPausedJobs(): string[];
906
- getCronJobs(): Promise<JobCronInfo[]>;
907
- getQueueDepth(): Promise<JobQueueDepth[]>;
908
- getActivity(days?: number): Promise<JobActivityPoint[]>;
909
- protected getActivitySqlite(days?: number): Promise<JobActivityPoint[]>;
910
- getTopFailures(days?: number): Promise<JobFailure[]>;
911
- protected getTopFailuresSqlite(periodAgoIso: string): Promise<JobFailure[]>;
912
- /**
913
- * Fetch the most recent execution per job name.
914
- *
915
- * - PostgreSQL: uses `DISTINCT ON` for a single-pass query
916
- * - SQLite: uses ORM queries (one per job name) since `DISTINCT ON` is not supported
917
- */
918
- protected getLastExecutionPerJob(jobNames: string[]): Promise<Map<string, {
919
- id: string;
920
- job_name: string;
921
- status: string;
922
- started_at?: string | null;
923
- completed_at?: string | null;
924
- error?: string | null;
925
- }>>;
926
777
  }
927
778
  //#endregion
928
779
  //#region ../../src/api/jobs/controllers/AdminJobController.d.ts
780
+ /**
781
+ * Minimal admin surface for the job system. Six endpoints.
782
+ */
929
783
  declare class AdminJobController {
930
784
  protected readonly url: string;
931
785
  protected readonly group: string;
932
786
  protected readonly jobService: JobService;
933
- readonly getJobStats: _$alepha_server0.ActionPrimitiveFn<{
934
- query: _$alepha.TObject<{
935
- days: _$alepha.TOptional<_$alepha.TInteger>;
936
- }>;
937
- response: _$alepha.TObject<{
938
- registered: _$alepha.TInteger;
939
- running: _$alepha.TInteger;
940
- pending: _$alepha.TInteger;
941
- scheduled: _$alepha.TInteger;
942
- retrying: _$alepha.TInteger;
943
- dead: _$alepha.TInteger;
944
- completed: _$alepha.TInteger;
945
- failed: _$alepha.TInteger;
946
- }>;
947
- }>;
948
- readonly getJobRegistry: _$alepha_server0.ActionPrimitiveFn<{
787
+ readonly listJobs: _$alepha_server0.ActionPrimitiveFn<{
949
788
  response: _$alepha.TArray<_$alepha.TObject<{
950
789
  name: _$alepha.TString;
951
- type: _$alepha.TUnsafe<"push" | "cron" | "both">;
790
+ description: _$alepha.TOptional<_$alepha.TString>;
791
+ type: _$alepha.TUnsafe<"cron" | "queue">;
952
792
  priority: _$alepha.TUnsafe<"critical" | "high" | "normal" | "low">;
953
- concurrency: _$alepha.TInteger;
954
- hasSchema: _$alepha.TBoolean;
955
793
  cron: _$alepha.TOptional<_$alepha.TString>;
956
794
  timeout: _$alepha.TOptional<_$alepha.TString>;
957
795
  retry: _$alepha.TOptional<_$alepha.TObject<{
958
796
  retries: _$alepha.TInteger;
959
797
  hasBackoff: _$alepha.TBoolean;
960
798
  }>>;
961
- paused: _$alepha.TBoolean;
799
+ recent: _$alepha.TObject<{
800
+ ok: _$alepha.TInteger;
801
+ error: _$alepha.TInteger;
802
+ lastRun: _$alepha.TOptional<_$alepha.TString>;
803
+ }>;
962
804
  }>>;
963
805
  }>;
964
- readonly findJobExecutions: _$alepha_server0.ActionPrimitiveFn<{
806
+ readonly listExecutions: _$alepha_server0.ActionPrimitiveFn<{
807
+ params: _$alepha.TObject<{
808
+ name: _$alepha.TString;
809
+ }>;
965
810
  query: _$alepha.TObject<{
966
- page: _$alepha.TOptional<_$alepha.TInteger>;
967
- size: _$alepha.TOptional<_$alepha.TInteger>;
968
- sort: _$alepha.TOptional<_$alepha.TString>;
969
- job: _$alepha.TOptional<_$alepha.TString>;
970
- status: _$alepha.TOptional<_$alepha.TUnsafe<"running" | "pending" | "scheduled" | "retrying" | "dead" | "completed" | "cancelled">>;
971
- priority: _$alepha.TOptional<_$alepha.TUnsafe<"critical" | "high" | "normal" | "low">>;
972
- from: _$alepha.TOptional<_$alepha.TString>;
973
- to: _$alepha.TOptional<_$alepha.TString>;
811
+ status: _$alepha.TOptional<_$alepha.TUnsafe<"ok" | "error" | "pending" | "running" | "scheduled" | "cancelled">>;
812
+ limit: _$alepha.TOptional<_$alepha.TInteger>;
974
813
  }>;
975
- response: _$alepha.TPage<_$alepha.TObject<{
814
+ response: _$alepha.TArray<_$alepha.TObject<{
976
815
  id: PgAttr<PgAttr<_$alepha.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
977
816
  createdAt: PgAttr<PgAttr<_$alepha.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
978
817
  updatedAt: PgAttr<PgAttr<_$alepha.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
979
818
  jobName: _$alepha.TString;
980
819
  key: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TNull, _$alepha.TString]>>;
981
- payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
982
- status: PgAttr<_$alepha.TUnsafe<"running" | "pending" | "scheduled" | "retrying" | "dead" | "completed" | "cancelled">, typeof PG_DEFAULT>;
820
+ status: PgAttr<_$alepha.TUnsafe<"ok" | "error" | "pending" | "running" | "scheduled" | "cancelled">, typeof PG_DEFAULT>;
983
821
  priority: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
984
822
  attempt: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
985
823
  maxAttempts: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
824
+ payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
986
825
  scheduledAt: _$alepha.TOptional<_$alepha.TString>;
987
826
  startedAt: _$alepha.TOptional<_$alepha.TString>;
988
827
  completedAt: _$alepha.TOptional<_$alepha.TString>;
989
- result: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
990
828
  error: _$alepha.TOptional<_$alepha.TString>;
991
- workerId: _$alepha.TOptional<_$alepha.TString>;
829
+ logs: _$alepha.TOptional<_$alepha.TArray<_$alepha.TObject<{
830
+ level: _$alepha.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
831
+ message: _$alepha.TString;
832
+ service: _$alepha.TString;
833
+ module: _$alepha.TString;
834
+ context: _$alepha.TOptional<_$alepha.TString>;
835
+ app: _$alepha.TOptional<_$alepha.TString>;
836
+ data: _$alepha.TOptional<_$alepha.TAny>;
837
+ timestamp: _$alepha.TNumber;
838
+ }>>>;
992
839
  triggeredBy: _$alepha.TOptional<_$alepha.TString>;
993
840
  triggeredByName: _$alepha.TOptional<_$alepha.TString>;
994
841
  cancelledBy: _$alepha.TOptional<_$alepha.TString>;
@@ -999,7 +846,7 @@ declare class AdminJobController {
999
846
  }>;
1000
847
  }>>;
1001
848
  }>;
1002
- readonly getJobExecution: _$alepha_server0.ActionPrimitiveFn<{
849
+ readonly getExecution: _$alepha_server0.ActionPrimitiveFn<{
1003
850
  params: _$alepha.TObject<{
1004
851
  id: _$alepha.TString;
1005
852
  }>;
@@ -1009,27 +856,17 @@ declare class AdminJobController {
1009
856
  updatedAt: PgAttr<PgAttr<_$alepha.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
1010
857
  jobName: _$alepha.TString;
1011
858
  key: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TNull, _$alepha.TString]>>;
1012
- payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
1013
- status: PgAttr<_$alepha.TUnsafe<"running" | "pending" | "scheduled" | "retrying" | "dead" | "completed" | "cancelled">, typeof PG_DEFAULT>;
859
+ status: PgAttr<_$alepha.TUnsafe<"ok" | "error" | "pending" | "running" | "scheduled" | "cancelled">, typeof PG_DEFAULT>;
1014
860
  priority: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
1015
861
  attempt: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
1016
862
  maxAttempts: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
863
+ payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
1017
864
  scheduledAt: _$alepha.TOptional<_$alepha.TString>;
1018
865
  startedAt: _$alepha.TOptional<_$alepha.TString>;
1019
866
  completedAt: _$alepha.TOptional<_$alepha.TString>;
1020
- result: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
1021
867
  error: _$alepha.TOptional<_$alepha.TString>;
1022
- workerId: _$alepha.TOptional<_$alepha.TString>;
1023
- triggeredBy: _$alepha.TOptional<_$alepha.TString>;
1024
- triggeredByName: _$alepha.TOptional<_$alepha.TString>;
1025
- cancelledBy: _$alepha.TOptional<_$alepha.TString>;
1026
- cancelledByName: _$alepha.TOptional<_$alepha.TString>;
1027
- can: _$alepha.TObject<{
1028
- retry: _$alepha.TBoolean;
1029
- cancel: _$alepha.TBoolean;
1030
- }>;
1031
868
  logs: _$alepha.TOptional<_$alepha.TArray<_$alepha.TObject<{
1032
- level: _$alepha.TUnsafe<"TRACE" | "SILENT" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
869
+ level: _$alepha.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
1033
870
  message: _$alepha.TString;
1034
871
  service: _$alepha.TString;
1035
872
  module: _$alepha.TString;
@@ -1038,11 +875,21 @@ declare class AdminJobController {
1038
875
  data: _$alepha.TOptional<_$alepha.TAny>;
1039
876
  timestamp: _$alepha.TNumber;
1040
877
  }>>>;
878
+ triggeredBy: _$alepha.TOptional<_$alepha.TString>;
879
+ triggeredByName: _$alepha.TOptional<_$alepha.TString>;
880
+ cancelledBy: _$alepha.TOptional<_$alepha.TString>;
881
+ cancelledByName: _$alepha.TOptional<_$alepha.TString>;
882
+ can: _$alepha.TObject<{
883
+ retry: _$alepha.TBoolean;
884
+ cancel: _$alepha.TBoolean;
885
+ }>;
1041
886
  }>;
1042
887
  }>;
1043
888
  readonly triggerJob: _$alepha_server0.ActionPrimitiveFn<{
1044
- body: _$alepha.TObject<{
889
+ params: _$alepha.TObject<{
1045
890
  name: _$alepha.TString;
891
+ }>;
892
+ body: _$alepha.TObject<{
1046
893
  payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
1047
894
  }>;
1048
895
  response: _$alepha.TObject<{
@@ -1051,7 +898,7 @@ declare class AdminJobController {
1051
898
  count: _$alepha.TOptional<_$alepha.TNumber>;
1052
899
  }>;
1053
900
  }>;
1054
- readonly retryJobExecution: _$alepha_server0.ActionPrimitiveFn<{
901
+ readonly retryExecution: _$alepha_server0.ActionPrimitiveFn<{
1055
902
  params: _$alepha.TObject<{
1056
903
  id: _$alepha.TString;
1057
904
  }>;
@@ -1061,7 +908,7 @@ declare class AdminJobController {
1061
908
  count: _$alepha.TOptional<_$alepha.TNumber>;
1062
909
  }>;
1063
910
  }>;
1064
- readonly cancelJobExecution: _$alepha_server0.ActionPrimitiveFn<{
911
+ readonly cancelExecution: _$alepha_server0.ActionPrimitiveFn<{
1065
912
  params: _$alepha.TObject<{
1066
913
  id: _$alepha.TString;
1067
914
  }>;
@@ -1071,112 +918,43 @@ declare class AdminJobController {
1071
918
  count: _$alepha.TOptional<_$alepha.TNumber>;
1072
919
  }>;
1073
920
  }>;
1074
- readonly getJobActivity: _$alepha_server0.ActionPrimitiveFn<{
1075
- query: _$alepha.TObject<{
1076
- days: _$alepha.TOptional<_$alepha.TInteger>;
1077
- }>;
1078
- response: _$alepha.TArray<_$alepha.TObject<{
1079
- date: _$alepha.TString;
1080
- completed: _$alepha.TInteger;
1081
- failed: _$alepha.TInteger;
1082
- }>>;
1083
- }>;
1084
- readonly getCronJobs: _$alepha_server0.ActionPrimitiveFn<{
1085
- response: _$alepha.TArray<_$alepha.TObject<{
1086
- name: _$alepha.TString;
1087
- cron: _$alepha.TString;
1088
- lock: _$alepha.TBoolean;
1089
- priority: _$alepha.TUnsafe<"critical" | "high" | "normal" | "low">;
1090
- concurrency: _$alepha.TInteger;
1091
- hasSchema: _$alepha.TBoolean;
1092
- paused: _$alepha.TBoolean;
1093
- lastExecution: _$alepha.TOptional<_$alepha.TObject<{
1094
- id: _$alepha.TString;
1095
- status: _$alepha.TString;
1096
- startedAt: _$alepha.TOptional<_$alepha.TString>;
1097
- completedAt: _$alepha.TOptional<_$alepha.TString>;
1098
- error: _$alepha.TOptional<_$alepha.TString>;
1099
- }>>;
1100
- }>>;
1101
- }>;
1102
- readonly getJobQueueDepth: _$alepha_server0.ActionPrimitiveFn<{
1103
- response: _$alepha.TArray<_$alepha.TObject<{
1104
- jobName: _$alepha.TString;
1105
- pending: _$alepha.TInteger;
1106
- running: _$alepha.TInteger;
1107
- scheduled: _$alepha.TInteger;
1108
- retrying: _$alepha.TInteger;
1109
- dead: _$alepha.TInteger;
1110
- concurrency: _$alepha.TInteger;
1111
- paused: _$alepha.TBoolean;
1112
- }>>;
1113
- }>;
1114
- readonly getJobTopFailures: _$alepha_server0.ActionPrimitiveFn<{
1115
- query: _$alepha.TObject<{
1116
- days: _$alepha.TOptional<_$alepha.TInteger>;
1117
- }>;
1118
- response: _$alepha.TArray<_$alepha.TObject<{
1119
- jobName: _$alepha.TString;
1120
- failures: _$alepha.TInteger;
1121
- lastError: _$alepha.TOptional<_$alepha.TString>;
1122
- }>>;
1123
- }>;
1124
- readonly pauseJob: _$alepha_server0.ActionPrimitiveFn<{
1125
- body: _$alepha.TObject<{
1126
- name: _$alepha.TString;
1127
- }>;
1128
- response: _$alepha.TObject<{
1129
- ok: _$alepha.TBoolean;
1130
- id: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TString, _$alepha.TInteger]>>;
1131
- count: _$alepha.TOptional<_$alepha.TNumber>;
1132
- }>;
1133
- }>;
1134
- readonly resumeJob: _$alepha_server0.ActionPrimitiveFn<{
1135
- body: _$alepha.TObject<{
1136
- name: _$alepha.TString;
1137
- }>;
1138
- response: _$alepha.TObject<{
1139
- ok: _$alepha.TBoolean;
1140
- id: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TString, _$alepha.TInteger]>>;
1141
- count: _$alepha.TOptional<_$alepha.TNumber>;
1142
- }>;
1143
- }>;
1144
- readonly getPausedJobs: _$alepha_server0.ActionPrimitiveFn<{
1145
- response: _$alepha.TArray<_$alepha.TString>;
1146
- }>;
1147
921
  }
1148
922
  //#endregion
1149
923
  //#region ../../src/api/jobs/entities/jobExecutionEntity.d.ts
924
+ /**
925
+ * Job execution record.
926
+ *
927
+ * Stores durable state for queue-mode jobs (outbox pattern) and error records
928
+ * for cron-mode jobs. Successful executions are trimmed by the sweep to keep
929
+ * the last N rows per job (configurable via `jobConfig.keepLastSuccess`).
930
+ *
931
+ * Status transitions:
932
+ * - queue push → pending
933
+ * - worker claim → running
934
+ * - success → ok
935
+ * - terminal failure → error
936
+ * - retry → scheduled (with scheduledAt = now + backoff)
937
+ * - delay → scheduled (with scheduledAt = now + delay)
938
+ * - sweep picks due ones → pending
939
+ * - cancel → cancelled
940
+ */
1150
941
  declare const jobExecutionEntity: _$alepha_orm0.EntityPrimitive<_$alepha.TObject<{
1151
942
  id: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_PRIMARY_KEY>, typeof _$alepha_orm0.PG_DEFAULT>;
1152
943
  createdAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_CREATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
1153
944
  updatedAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_UPDATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
1154
945
  jobName: _$alepha.TString;
1155
946
  key: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TNull, _$alepha.TString]>>;
1156
- payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
1157
- status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"running" | "pending" | "scheduled" | "retrying" | "dead" | "completed" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
947
+ status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"ok" | "error" | "pending" | "running" | "scheduled" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
1158
948
  priority: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
1159
949
  attempt: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
1160
950
  maxAttempts: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
951
+ payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
1161
952
  scheduledAt: _$alepha.TOptional<_$alepha.TString>;
1162
953
  startedAt: _$alepha.TOptional<_$alepha.TString>;
1163
954
  completedAt: _$alepha.TOptional<_$alepha.TString>;
1164
- result: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
1165
955
  error: _$alepha.TOptional<_$alepha.TString>;
1166
- workerId: _$alepha.TOptional<_$alepha.TString>;
1167
- triggeredBy: _$alepha.TOptional<_$alepha.TString>;
1168
- triggeredByName: _$alepha.TOptional<_$alepha.TString>;
1169
- cancelledBy: _$alepha.TOptional<_$alepha.TString>;
1170
- cancelledByName: _$alepha.TOptional<_$alepha.TString>;
1171
- }>>;
1172
- type JobExecutionEntity = Static<typeof jobExecutionEntity.schema>;
1173
- type JobStatus = "pending" | "scheduled" | "retrying" | "running" | "completed" | "dead" | "cancelled";
1174
- //#endregion
1175
- //#region ../../src/api/jobs/entities/jobExecutionLogEntity.d.ts
1176
- declare const jobExecutionLogEntity: _$alepha_orm0.EntityPrimitive<_$alepha.TObject<{
1177
- id: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_PRIMARY_KEY>, typeof _$alepha_orm0.PG_DEFAULT>;
1178
- logs: _$alepha.TArray<_$alepha.TObject<{
1179
- level: _$alepha.TUnsafe<"TRACE" | "SILENT" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
956
+ logs: _$alepha.TOptional<_$alepha.TArray<_$alepha.TObject<{
957
+ level: _$alepha.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
1180
958
  message: _$alepha.TString;
1181
959
  service: _$alepha.TString;
1182
960
  module: _$alepha.TString;
@@ -1184,18 +962,22 @@ declare const jobExecutionLogEntity: _$alepha_orm0.EntityPrimitive<_$alepha.TObj
1184
962
  app: _$alepha.TOptional<_$alepha.TString>;
1185
963
  data: _$alepha.TOptional<_$alepha.TAny>;
1186
964
  timestamp: _$alepha.TNumber;
1187
- }>>;
965
+ }>>>;
966
+ triggeredBy: _$alepha.TOptional<_$alepha.TString>;
967
+ triggeredByName: _$alepha.TOptional<_$alepha.TString>;
968
+ cancelledBy: _$alepha.TOptional<_$alepha.TString>;
969
+ cancelledByName: _$alepha.TOptional<_$alepha.TString>;
1188
970
  }>>;
1189
- type JobExecutionLogEntity = Static<typeof jobExecutionLogEntity.schema>;
971
+ type JobExecutionEntity = Static<typeof jobExecutionEntity.schema>;
972
+ type JobStatus = "pending" | "running" | "scheduled" | "ok" | "error" | "cancelled";
1190
973
  //#endregion
1191
974
  //#region ../../src/api/jobs/providers/JobQueueProvider.d.ts
1192
975
  /**
1193
- * Optional queue-backed dispatch for the job system.
976
+ * Plumbs outbox-style dispatch through `AlephaQueue`.
1194
977
  *
1195
- * When registered, `JobProvider` will push work through this queue instead of
1196
- * executing inline. This is the default for long-running (non-serverless) environments.
1197
- * In serverless environments (Cloudflare Workers, Vercel), this provider is typically
1198
- * omitted so jobs execute inline without requiring an external queue resource.
978
+ * Registered only when the app imports `AlephaApiJobsQueue`. Sets
979
+ * `JobProvider.queueDispatch` eagerly at instantiation so queue-mode jobs
980
+ * can dispatch regardless of start-hook ordering.
1199
981
  */
1200
982
  declare class JobQueueProvider {
1201
983
  protected readonly jobProvider: JobProvider;
@@ -1203,24 +985,18 @@ declare class JobQueueProvider {
1203
985
  jobName: _$alepha.TString;
1204
986
  executionId: _$alepha.TString;
1205
987
  }>>;
1206
- protected readonly onStart: _$alepha.HookPrimitive<"start">;
1207
- /**
1208
- * Push a job execution onto the queue for async processing.
1209
- */
988
+ constructor();
989
+ protected wireDispatcher(): void;
1210
990
  push(jobName: string, executionId: string): Promise<void>;
1211
991
  }
1212
992
  //#endregion
1213
993
  //#region ../../src/api/jobs/schemas/jobConfigAtom.d.ts
1214
994
  declare const jobConfig: _$alepha.Atom<_$alepha.TObject<{
1215
- recovery: _$alepha.TObject<{
1216
- interval: _$alepha.TInteger;
1217
- staleThreshold: _$alepha.TInteger;
1218
- runTimeout: _$alepha.TInteger;
1219
- }>;
1220
- delayed: _$alepha.TObject<{
1221
- interval: _$alepha.TInteger;
1222
- }>;
1223
- logRetentionDays: _$alepha.TInteger;
995
+ sweepInterval: _$alepha.TInteger;
996
+ staleThreshold: _$alepha.TInteger;
997
+ runTimeout: _$alepha.TInteger;
998
+ keepLastSuccess: _$alepha.TInteger;
999
+ keepLastError: _$alepha.TInteger;
1224
1000
  logMaxEntries: _$alepha.TInteger;
1225
1001
  drainTimeout: _$alepha.TInteger;
1226
1002
  }>, "alepha.jobs">;
@@ -1231,34 +1007,24 @@ declare module "alepha" {
1231
1007
  }
1232
1008
  } //# sourceMappingURL=jobConfigAtom.d.ts.map
1233
1009
  //#endregion
1234
- //#region ../../src/api/jobs/schemas/jobExecutionDetailResourceSchema.d.ts
1235
- declare const jobExecutionDetailResourceSchema: _$alepha.TObject<{
1010
+ //#region ../../src/api/jobs/schemas/jobExecutionResourceSchema.d.ts
1011
+ declare const jobExecutionResourceSchema: _$alepha.TObject<{
1236
1012
  id: PgAttr<PgAttr<_$alepha.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
1237
1013
  createdAt: PgAttr<PgAttr<_$alepha.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
1238
1014
  updatedAt: PgAttr<PgAttr<_$alepha.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
1239
1015
  jobName: _$alepha.TString;
1240
1016
  key: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TNull, _$alepha.TString]>>;
1241
- payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
1242
- status: PgAttr<_$alepha.TUnsafe<"running" | "pending" | "scheduled" | "retrying" | "dead" | "completed" | "cancelled">, typeof PG_DEFAULT>;
1017
+ status: PgAttr<_$alepha.TUnsafe<"ok" | "error" | "pending" | "running" | "scheduled" | "cancelled">, typeof PG_DEFAULT>;
1243
1018
  priority: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
1244
1019
  attempt: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
1245
1020
  maxAttempts: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
1021
+ payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
1246
1022
  scheduledAt: _$alepha.TOptional<_$alepha.TString>;
1247
1023
  startedAt: _$alepha.TOptional<_$alepha.TString>;
1248
1024
  completedAt: _$alepha.TOptional<_$alepha.TString>;
1249
- result: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
1250
1025
  error: _$alepha.TOptional<_$alepha.TString>;
1251
- workerId: _$alepha.TOptional<_$alepha.TString>;
1252
- triggeredBy: _$alepha.TOptional<_$alepha.TString>;
1253
- triggeredByName: _$alepha.TOptional<_$alepha.TString>;
1254
- cancelledBy: _$alepha.TOptional<_$alepha.TString>;
1255
- cancelledByName: _$alepha.TOptional<_$alepha.TString>;
1256
- can: _$alepha.TObject<{
1257
- retry: _$alepha.TBoolean;
1258
- cancel: _$alepha.TBoolean;
1259
- }>;
1260
1026
  logs: _$alepha.TOptional<_$alepha.TArray<_$alepha.TObject<{
1261
- level: _$alepha.TUnsafe<"TRACE" | "SILENT" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
1027
+ level: _$alepha.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
1262
1028
  message: _$alepha.TString;
1263
1029
  service: _$alepha.TString;
1264
1030
  module: _$alepha.TString;
@@ -1267,31 +1033,6 @@ declare const jobExecutionDetailResourceSchema: _$alepha.TObject<{
1267
1033
  data: _$alepha.TOptional<_$alepha.TAny>;
1268
1034
  timestamp: _$alepha.TNumber;
1269
1035
  }>>>;
1270
- }>;
1271
- type JobExecutionDetailResource = Static<typeof jobExecutionDetailResourceSchema>;
1272
- //#endregion
1273
- //#region ../../src/api/jobs/schemas/jobExecutionResourceSchema.d.ts
1274
- declare const jobExecutionCanSchema: _$alepha.TObject<{
1275
- retry: _$alepha.TBoolean;
1276
- cancel: _$alepha.TBoolean;
1277
- }>;
1278
- declare const jobExecutionResourceSchema: _$alepha.TObject<{
1279
- id: PgAttr<PgAttr<_$alepha.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
1280
- createdAt: PgAttr<PgAttr<_$alepha.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
1281
- updatedAt: PgAttr<PgAttr<_$alepha.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
1282
- jobName: _$alepha.TString;
1283
- key: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TNull, _$alepha.TString]>>;
1284
- payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
1285
- status: PgAttr<_$alepha.TUnsafe<"running" | "pending" | "scheduled" | "retrying" | "dead" | "completed" | "cancelled">, typeof PG_DEFAULT>;
1286
- priority: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
1287
- attempt: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
1288
- maxAttempts: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
1289
- scheduledAt: _$alepha.TOptional<_$alepha.TString>;
1290
- startedAt: _$alepha.TOptional<_$alepha.TString>;
1291
- completedAt: _$alepha.TOptional<_$alepha.TString>;
1292
- result: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
1293
- error: _$alepha.TOptional<_$alepha.TString>;
1294
- workerId: _$alepha.TOptional<_$alepha.TString>;
1295
1036
  triggeredBy: _$alepha.TOptional<_$alepha.TString>;
1296
1037
  triggeredByName: _$alepha.TOptional<_$alepha.TString>;
1297
1038
  cancelledBy: _$alepha.TOptional<_$alepha.TString>;
@@ -1305,14 +1046,12 @@ type JobExecutionResource = Static<typeof jobExecutionResourceSchema>;
1305
1046
  //#endregion
1306
1047
  //#region ../../src/api/jobs/schemas/triggerJobSchema.d.ts
1307
1048
  declare const triggerJobSchema: _$alepha.TObject<{
1308
- name: _$alepha.TString;
1309
1049
  payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
1310
1050
  }>;
1311
1051
  type TriggerJob = Static<typeof triggerJobSchema>;
1312
1052
  //#endregion
1313
1053
  //#region ../../src/api/jobs/index.d.ts
1314
1054
  declare module "alepha" {
1315
- interface Env extends Partial<Static<typeof jobEnvSchema>> {}
1316
1055
  interface Hooks {
1317
1056
  "job:begin": {
1318
1057
  name: string;
@@ -1338,30 +1077,30 @@ declare module "alepha" {
1338
1077
  };
1339
1078
  }
1340
1079
  }
1341
- declare const jobEnvSchema: _$alepha.TObject<{
1342
- /**
1343
- * Controls whether the job system dispatches work through a queue or executes inline.
1344
- *
1345
- * - `1` — always use queue (force queue even in serverless)
1346
- * - `0` — never use queue (force inline, useful for testing)
1347
- * - not set — auto: use queue when NOT serverless (default)
1348
- */
1349
- ALEPHA_JOBS_QUEUE: _$alepha.TOptional<_$alepha.TInteger>;
1350
- }>;
1351
1080
  /**
1352
- * Job execution framework — unified primitive for deferred, scheduled, and queued work.
1081
+ * Job execution framework — cron and durable queue work with a single primitive.
1353
1082
  *
1354
- * **Features:**
1355
- * - Push-based jobs with typed payloads
1356
- * - Cron scheduling with execution tracking
1357
- * - Retry with exponential backoff
1358
- * - Priority, delay, cancellation
1359
- * - Deduplication via unique keys
1360
- * - Per-execution log capture
1083
+ * A `$job` is either **cron-only** (declares `cron`) or **queue-only** (declares `schema`).
1084
+ * Cron jobs run inline on their schedule and only record errors by default.
1085
+ * Queue jobs use the outbox pattern: push commits to DB first, then notifies via queue.
1086
+ *
1087
+ * **This module provides cron support only.** To enable queue-mode jobs, also
1088
+ * import {@link AlephaApiJobsQueue} it brings in the queue layer and infrastructure
1089
+ * binding (e.g. Cloudflare Queues). Cron-only deployments (Vercel, CF-without-Queues)
1090
+ * do not need `AlephaApiJobsQueue`.
1361
1091
  *
1362
1092
  * @module alepha.api.jobs
1363
1093
  */
1364
1094
  declare const AlephaApiJobs: _$alepha.Service<_$alepha.Module>;
1095
+ /**
1096
+ * Queue support for `$job`. Import alongside {@link AlephaApiJobs} when your
1097
+ * app declares queue-mode jobs (any `$job` with a `schema`).
1098
+ *
1099
+ * Adds `JobQueueProvider` which plumbs the outbox dispatch through `AlephaQueue`.
1100
+ *
1101
+ * @module alepha.api.jobs.queue
1102
+ */
1103
+ declare const AlephaApiJobsQueue: _$alepha.Service<_$alepha.Module>;
1365
1104
  //#endregion
1366
- export { $job, AdminJobController, AlephaApiJobs, CancelContext, JobActivityPoint, JobActivityQuery, JobConfig, JobCronInfo, JobExecutionDetailResource, JobExecutionEntity, JobExecutionLogEntity, JobExecutionQuery, JobExecutionResource, JobFailure, JobHandlerArgs, JobItem, JobPrimitive, JobPrimitiveOptions, JobPriority, JobProvider, JobQueueDepth, JobQueueProvider, JobRegistration, JobRetryBackoff, JobRetryOptions, JobService, JobStats, JobStatus, JobTriggerContext, PushManyItem, PushOptions, TriggerJob, jobActivityPointSchema, jobActivityQuerySchema, jobConfig, jobCronInfoSchema, jobExecutionCanSchema, jobExecutionDetailResourceSchema, jobExecutionEntity, jobExecutionLogEntity, jobExecutionQuerySchema, jobExecutionResourceSchema, jobFailureSchema, jobQueueDepthSchema, jobRegistrationSchema, jobStatsSchema, triggerJobSchema };
1105
+ export { $job, AdminJobController, AlephaApiJobs, AlephaApiJobsQueue, CancelContext, JobConfig, JobExecutionEntity, JobExecutionQuery, JobExecutionResource, JobHandlerArgs, JobPrimitive, JobPrimitiveOptions, JobPriority, JobProvider, JobQueueProvider, JobRegistration, JobRetryBackoff, JobRetryOptions, JobService, JobStatus, JobTriggerContext, PRIORITY_MAP, PRIORITY_REVERSE, PushManyItem, PushOptions, TriggerJob, jobConfig, jobExecutionEntity, jobExecutionQuerySchema, jobExecutionResourceSchema, jobRegistrationSchema, triggerJobSchema };
1367
1106
  //# sourceMappingURL=index.d.ts.map