alepha 0.20.1 → 0.20.2

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 (232) hide show
  1. package/dist/api/files/index.js +2 -1
  2. package/dist/api/files/index.js.map +1 -1
  3. package/dist/api/jobs/index.browser.js +64 -148
  4. package/dist/api/jobs/index.browser.js.map +1 -1
  5. package/dist/api/jobs/index.d.ts +371 -573
  6. package/dist/api/jobs/index.d.ts.map +1 -1
  7. package/dist/api/jobs/index.js +605 -1012
  8. package/dist/api/jobs/index.js.map +1 -1
  9. package/dist/api/notifications/index.d.ts +78 -17
  10. package/dist/api/notifications/index.d.ts.map +1 -1
  11. package/dist/api/notifications/index.js +90 -23
  12. package/dist/api/notifications/index.js.map +1 -1
  13. package/dist/api/payments/index.d.ts +2 -1
  14. package/dist/api/payments/index.d.ts.map +1 -1
  15. package/dist/api/payments/index.js +4 -2
  16. package/dist/api/payments/index.js.map +1 -1
  17. package/dist/api/users/index.d.ts +34 -31
  18. package/dist/api/users/index.d.ts.map +1 -1
  19. package/dist/api/users/index.js +13 -7
  20. package/dist/api/users/index.js.map +1 -1
  21. package/dist/api/verifications/index.js +2 -1
  22. package/dist/api/verifications/index.js.map +1 -1
  23. package/dist/cli/core/index.d.ts +8 -34
  24. package/dist/cli/core/index.d.ts.map +1 -1
  25. package/dist/cli/core/index.js +43 -232
  26. package/dist/cli/core/index.js.map +1 -1
  27. package/dist/cli/platform/index.d.ts +36 -11
  28. package/dist/cli/platform/index.d.ts.map +1 -1
  29. package/dist/cli/platform/index.js +93 -27
  30. package/dist/cli/platform/index.js.map +1 -1
  31. package/dist/command/index.d.ts +1 -1
  32. package/dist/core/index.browser.js +6 -0
  33. package/dist/core/index.browser.js.map +1 -1
  34. package/dist/core/index.d.ts +6 -0
  35. package/dist/core/index.d.ts.map +1 -1
  36. package/dist/core/index.js +6 -0
  37. package/dist/core/index.js.map +1 -1
  38. package/dist/core/index.native.js +6 -0
  39. package/dist/core/index.native.js.map +1 -1
  40. package/dist/core/index.workerd.js +6 -0
  41. package/dist/core/index.workerd.js.map +1 -1
  42. package/dist/react/form/index.d.ts +60 -1
  43. package/dist/react/form/index.d.ts.map +1 -1
  44. package/dist/react/form/index.js +86 -1
  45. package/dist/react/form/index.js.map +1 -1
  46. package/dist/react/head/index.browser.js +16 -1
  47. package/dist/react/head/index.browser.js.map +1 -1
  48. package/dist/react/head/index.d.ts +6 -0
  49. package/dist/react/head/index.d.ts.map +1 -1
  50. package/dist/react/head/index.js +16 -1
  51. package/dist/react/head/index.js.map +1 -1
  52. package/dist/react/router/index.browser.js +0 -10
  53. package/dist/react/router/index.browser.js.map +1 -1
  54. package/dist/react/router/index.d.ts +35 -12
  55. package/dist/react/router/index.d.ts.map +1 -1
  56. package/dist/react/router/index.js +0 -10
  57. package/dist/react/router/index.js.map +1 -1
  58. package/dist/react/ui/index.d.ts +124 -0
  59. package/dist/react/ui/index.d.ts.map +1 -0
  60. package/dist/react/ui/index.js +206 -0
  61. package/dist/react/ui/index.js.map +1 -0
  62. package/dist/router/index.d.ts +13 -13
  63. package/dist/router/index.d.ts.map +1 -1
  64. package/dist/router/index.js +45 -32
  65. package/dist/router/index.js.map +1 -1
  66. package/dist/system/index.d.ts.map +1 -1
  67. package/dist/system/index.js +1 -0
  68. package/dist/system/index.js.map +1 -1
  69. package/dist/topic/core/index.js +1 -1
  70. package/dist/topic/core/index.js.map +1 -1
  71. package/package.json +6 -23
  72. package/src/api/files/jobs/FileJobs.ts +2 -1
  73. package/src/api/jobs/__tests__/$job.spec.ts +316 -2867
  74. package/src/api/jobs/controllers/AdminJobController.ts +29 -138
  75. package/src/api/jobs/entities/jobExecutionEntity.ts +27 -19
  76. package/src/api/jobs/index.browser.ts +5 -7
  77. package/src/api/jobs/index.ts +23 -51
  78. package/src/api/jobs/primitives/$job.ts +66 -58
  79. package/src/api/jobs/providers/JobProvider.ts +561 -566
  80. package/src/api/jobs/providers/JobQueueProvider.ts +18 -19
  81. package/src/api/jobs/schemas/jobConfigAtom.ts +20 -23
  82. package/src/api/jobs/schemas/jobExecutionQuerySchema.ts +3 -27
  83. package/src/api/jobs/schemas/jobExecutionResourceSchema.ts +5 -7
  84. package/src/api/jobs/schemas/jobRegistrationSchema.ts +7 -4
  85. package/src/api/jobs/schemas/triggerJobSchema.ts +0 -1
  86. package/src/api/jobs/services/JobService.ts +90 -483
  87. package/src/api/notifications/controllers/AdminNotificationController.ts +19 -12
  88. package/src/api/notifications/index.ts +7 -4
  89. package/src/api/notifications/jobs/NotificationJobs.ts +83 -12
  90. package/src/api/payments/services/PaymentService.ts +4 -2
  91. package/src/api/users/__tests__/UserJobs.spec.ts +10 -49
  92. package/src/api/users/audits/UserAudits.ts +3 -1
  93. package/src/api/users/buckets/UserBuckets.ts +2 -1
  94. package/src/api/users/index.ts +1 -4
  95. package/src/api/users/jobs/UserJobs.ts +5 -4
  96. package/src/api/verifications/jobs/VerificationJobs.ts +2 -1
  97. package/src/cli/core/__tests__/init.spec.ts +1 -1
  98. package/src/cli/core/commands/init.ts +0 -12
  99. package/src/cli/core/services/PackageManagerUtils.ts +2 -9
  100. package/src/cli/core/services/ProjectScaffolder.ts +17 -65
  101. package/src/cli/core/templates/agentMd.ts +2 -8
  102. package/src/cli/core/templates/apiIndexTs.ts +4 -18
  103. package/src/cli/core/templates/mainCss.ts +1 -36
  104. package/src/cli/core/templates/vitestConfigTs.ts +17 -0
  105. package/src/cli/core/templates/webAppRouterTs.ts +2 -85
  106. package/src/cli/platform/__tests__/CloudflareAdapter.spec.ts +22 -71
  107. package/src/cli/platform/adapters/CloudflareAdapter.ts +12 -11
  108. package/src/cli/platform/atoms/platformOptions.ts +9 -0
  109. package/src/cli/platform/schemas/cloudflare.ts +3 -2
  110. package/src/cli/platform/services/CloudflareApi.ts +164 -25
  111. package/src/cli/platform/services/WranglerApi.ts +0 -17
  112. package/src/core/Alepha.ts +9 -0
  113. package/src/react/form/index.ts +2 -0
  114. package/src/react/form/services/parseField.ts +163 -0
  115. package/src/react/form/services/prettyName.ts +19 -0
  116. package/src/react/head/providers/BrowserHeadProvider.ts +31 -10
  117. package/src/react/router/primitives/$page.ts +35 -12
  118. package/src/react/ui/atoms/uiAtom.ts +28 -0
  119. package/src/react/ui/components/ColorScheme.tsx +36 -0
  120. package/src/react/ui/hooks/useColorMode.ts +49 -0
  121. package/src/react/ui/hooks/useSidebarState.ts +26 -0
  122. package/src/react/ui/hooks/useTheme.ts +22 -0
  123. package/src/react/ui/index.ts +35 -0
  124. package/src/react/ui/services/UiPersistence.ts +41 -0
  125. package/src/router/TemplatedPathParser.ts +50 -51
  126. package/src/router/__tests__/RouterProvider.spec.ts +62 -0
  127. package/src/router/__tests__/TemplatedPathParser.spec.ts +18 -0
  128. package/src/router/providers/RouterProvider.ts +10 -5
  129. package/src/system/providers/NodeShellProvider.ts +1 -0
  130. package/src/topic/core/providers/TopicProvider.ts +1 -1
  131. package/dist/api/invitations/index.d.ts +0 -790
  132. package/dist/api/invitations/index.d.ts.map +0 -1
  133. package/dist/api/invitations/index.js +0 -662
  134. package/dist/api/invitations/index.js.map +0 -1
  135. package/dist/api/issues/index.d.ts +0 -810
  136. package/dist/api/issues/index.d.ts.map +0 -1
  137. package/dist/api/issues/index.js +0 -444
  138. package/dist/api/issues/index.js.map +0 -1
  139. package/dist/api/subscriptions/index.d.ts +0 -1692
  140. package/dist/api/subscriptions/index.d.ts.map +0 -1
  141. package/dist/api/subscriptions/index.js +0 -1867
  142. package/dist/api/subscriptions/index.js.map +0 -1
  143. package/dist/api/workflows/index.browser.js +0 -246
  144. package/dist/api/workflows/index.browser.js.map +0 -1
  145. package/dist/api/workflows/index.d.ts +0 -1618
  146. package/dist/api/workflows/index.d.ts.map +0 -1
  147. package/dist/api/workflows/index.js +0 -1495
  148. package/dist/api/workflows/index.js.map +0 -1
  149. package/src/api/invitations/__tests__/InvitationService.spec.ts +0 -439
  150. package/src/api/invitations/controllers/AdminInvitationController.ts +0 -86
  151. package/src/api/invitations/controllers/InvitationController.ts +0 -84
  152. package/src/api/invitations/entities/invitations.ts +0 -33
  153. package/src/api/invitations/index.ts +0 -58
  154. package/src/api/invitations/jobs/InvitationJobs.ts +0 -37
  155. package/src/api/invitations/providers/InvitationProvider.ts +0 -45
  156. package/src/api/invitations/schemas/createInvitationSchema.ts +0 -12
  157. package/src/api/invitations/schemas/invitationConfigAtom.ts +0 -20
  158. package/src/api/invitations/schemas/invitationQuerySchema.ts +0 -15
  159. package/src/api/invitations/schemas/invitationResourceSchema.ts +0 -6
  160. package/src/api/invitations/schemas/invitationWithResourceInfoSchema.ts +0 -22
  161. package/src/api/invitations/schemas/myInvitationsQuerySchema.ts +0 -10
  162. package/src/api/invitations/services/InvitationService.ts +0 -556
  163. package/src/api/issues/__tests__/IssueService.spec.ts +0 -263
  164. package/src/api/issues/controllers/AdminIssueController.ts +0 -149
  165. package/src/api/issues/controllers/IssueController.ts +0 -44
  166. package/src/api/issues/entities/issues.ts +0 -49
  167. package/src/api/issues/index.ts +0 -50
  168. package/src/api/issues/schemas/createIssueSchema.ts +0 -13
  169. package/src/api/issues/schemas/issueConfigAtom.ts +0 -13
  170. package/src/api/issues/schemas/issueQuerySchema.ts +0 -18
  171. package/src/api/issues/schemas/issueResourceSchema.ts +0 -6
  172. package/src/api/issues/schemas/myIssueQuerySchema.ts +0 -10
  173. package/src/api/issues/schemas/updateIssueSchema.ts +0 -13
  174. package/src/api/issues/services/IssueService.ts +0 -264
  175. package/src/api/jobs/__tests__/$job-middleware.spec.ts +0 -126
  176. package/src/api/jobs/__tests__/JobService.spec.ts +0 -31
  177. package/src/api/jobs/entities/jobExecutionLogEntity.ts +0 -13
  178. package/src/api/jobs/schemas/jobActivitySchema.ts +0 -15
  179. package/src/api/jobs/schemas/jobCronInfoSchema.ts +0 -22
  180. package/src/api/jobs/schemas/jobExecutionDetailResourceSchema.ts +0 -20
  181. package/src/api/jobs/schemas/jobFailureSchema.ts +0 -9
  182. package/src/api/jobs/schemas/jobQueueDepthSchema.ts +0 -14
  183. package/src/api/jobs/schemas/jobStatsSchema.ts +0 -14
  184. package/src/api/jobs/services/JobService-tests.ts +0 -157
  185. package/src/api/subscriptions/__tests__/BillingService.spec.ts +0 -218
  186. package/src/api/subscriptions/__tests__/SubscriptionService.spec.ts +0 -278
  187. package/src/api/subscriptions/controllers/AdminSubscriptionController.ts +0 -212
  188. package/src/api/subscriptions/controllers/SubscriptionController.ts +0 -189
  189. package/src/api/subscriptions/entities/subscriptionEvents.ts +0 -54
  190. package/src/api/subscriptions/entities/subscriptions.ts +0 -68
  191. package/src/api/subscriptions/index.ts +0 -133
  192. package/src/api/subscriptions/jobs/SubscriptionJobs.ts +0 -382
  193. package/src/api/subscriptions/middleware/$requireLimit.ts +0 -50
  194. package/src/api/subscriptions/middleware/$requirePlan.ts +0 -49
  195. package/src/api/subscriptions/notifications/SubscriptionNotifications.ts +0 -110
  196. package/src/api/subscriptions/schemas/cancelSubscriptionSchema.ts +0 -8
  197. package/src/api/subscriptions/schemas/changePlanSchema.ts +0 -9
  198. package/src/api/subscriptions/schemas/createSubscriptionSchema.ts +0 -11
  199. package/src/api/subscriptions/schemas/entitlementsSchema.ts +0 -21
  200. package/src/api/subscriptions/schemas/mrrSchema.ts +0 -13
  201. package/src/api/subscriptions/schemas/planDefinitionSchema.ts +0 -71
  202. package/src/api/subscriptions/schemas/planResourceSchema.ts +0 -25
  203. package/src/api/subscriptions/schemas/subscriptionEventResourceSchema.ts +0 -8
  204. package/src/api/subscriptions/schemas/subscriptionQuerySchema.ts +0 -19
  205. package/src/api/subscriptions/schemas/subscriptionResourceSchema.ts +0 -6
  206. package/src/api/subscriptions/schemas/subscriptionSettingsSchema.ts +0 -32
  207. package/src/api/subscriptions/schemas/subscriptionStatsSchema.ts +0 -23
  208. package/src/api/subscriptions/services/BillingService.ts +0 -437
  209. package/src/api/subscriptions/services/SubscriptionConfig.ts +0 -56
  210. package/src/api/subscriptions/services/SubscriptionService.ts +0 -867
  211. package/src/api/subscriptions/services/UsageService.ts +0 -118
  212. package/src/api/workflows/__tests__/$workflow.spec.ts +0 -616
  213. package/src/api/workflows/controllers/AdminWorkflowController.ts +0 -191
  214. package/src/api/workflows/entities/workflowExecutions.ts +0 -74
  215. package/src/api/workflows/entities/workflowStepExecutions.ts +0 -74
  216. package/src/api/workflows/entities/workflowStepLogs.ts +0 -13
  217. package/src/api/workflows/index.browser.ts +0 -22
  218. package/src/api/workflows/index.ts +0 -115
  219. package/src/api/workflows/jobs/WorkflowJobs.ts +0 -77
  220. package/src/api/workflows/primitives/$workflow.ts +0 -202
  221. package/src/api/workflows/providers/WorkflowProvider.ts +0 -1284
  222. package/src/api/workflows/schemas/workflowActivitySchema.ts +0 -15
  223. package/src/api/workflows/schemas/workflowConfigAtom.ts +0 -51
  224. package/src/api/workflows/schemas/workflowExecutionDetailSchema.ts +0 -18
  225. package/src/api/workflows/schemas/workflowExecutionQuerySchema.ts +0 -26
  226. package/src/api/workflows/schemas/workflowExecutionResourceSchema.ts +0 -30
  227. package/src/api/workflows/schemas/workflowRegistrationSchema.ts +0 -26
  228. package/src/api/workflows/schemas/workflowStatsSchema.ts +0 -16
  229. package/src/api/workflows/schemas/workflowStepExecutionResourceSchema.ts +0 -15
  230. package/src/api/workflows/services/WorkflowService.ts +0 -382
  231. package/src/cli/core/templates/apiAppSecurityTs.ts +0 -43
  232. package/src/cli/core/templates/webAdminDashboardTsx.ts +0 -17
@@ -1,12 +1,11 @@
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";
@@ -317,21 +316,23 @@ declare module "alepha" {
317
316
  //#endregion
318
317
  //#region ../../src/api/jobs/primitives/$job.d.ts
319
318
  /**
320
- * Job primitive for defining scheduled and on-demand tasks with payload validation and retry policies.
319
+ * Job primitive for defining scheduled (cron) or queued (push) tasks.
320
+ *
321
+ * A job must be either **cron-only** (pass `cron`) or **queue-only**
322
+ * (pass `schema`), never both. To run scheduled work that processes
323
+ * payloads, compose two jobs: a cron that pushes payloads, and a
324
+ * queue job that handles them.
321
325
  */
322
326
  declare const $job: {
323
327
  <T extends TSchema = TSchema>(options: JobPrimitiveOptions<T>): JobPrimitive<T>;
324
328
  [KIND]: typeof JobPrimitive;
325
329
  };
326
- interface JobItem<T extends TSchema = TSchema> {
327
- id: string;
330
+ interface JobHandlerArgs<T extends TSchema = TSchema> {
328
331
  payload: Static<T>;
329
332
  attempt: number;
330
- }
331
- interface JobHandlerArgs<T extends TSchema = TSchema> {
332
- items: Array<JobItem<T>>;
333
333
  now: DateTime;
334
334
  signal: AbortSignal;
335
+ executionId: string;
335
336
  }
336
337
  interface JobRetryBackoff {
337
338
  initial: DurationLike;
@@ -347,38 +348,66 @@ interface JobRetryOptions {
347
348
  type JobPriority = "critical" | "high" | "normal" | "low";
348
349
  interface JobPrimitiveOptions<T extends TSchema = TSchema> extends PipelinePrimitiveOptions {
349
350
  /**
350
- * Payload schema (TypeBox). Optional for cron-only jobs.
351
+ * Optional explicit job name. Defaults to `ClassName.propertyKey`.
352
+ * Recommended convention for framework-internal jobs: `api:module:jobName`.
351
353
  */
352
- schema?: T;
354
+ name?: string;
353
355
  /**
354
- * Cron expression for automatic scheduling.
356
+ * Human-readable description (shown in the admin UI).
355
357
  */
356
- cron?: string;
358
+ description?: string;
357
359
  /**
358
- * Whether to use a distributed lock for cron execution.
359
- * @default true
360
+ * Payload schema (TypeBox). When set, the job is queue-mode.
361
+ * Must not be combined with `cron`.
360
362
  */
361
- lock?: boolean;
363
+ schema?: T;
362
364
  /**
363
- * Retry policy for failed executions.
365
+ * Cron expression for recurring execution. When set, the job is cron-mode.
366
+ * Must not be combined with `schema`.
364
367
  */
365
- retry?: JobRetryOptions;
368
+ cron?: string;
366
369
  /**
367
- * Max execution time per attempt.
370
+ * Retry policy for queue-mode jobs.
371
+ * Cron-mode jobs do not retry — the next tick re-runs.
368
372
  */
369
- timeout?: DurationLike;
373
+ retry?: JobRetryOptions;
370
374
  /**
371
- * Max parallel executions.
372
- * @default 1
375
+ * Max execution time per attempt. Handler receives an `AbortSignal`.
373
376
  */
374
- concurrency?: number;
377
+ timeout?: DurationLike;
375
378
  /**
376
- * Default priority for pushed jobs.
379
+ * Default priority for pushed jobs. Used by the sweep to order
380
+ * dispatch when there is a backlog. Real-time queue consumption
381
+ * is FIFO.
377
382
  * @default "normal"
378
383
  */
379
384
  priority?: JobPriority;
380
385
  /**
381
- * Handler function for job execution.
386
+ * Whether to record successful executions.
387
+ *
388
+ * - `"error"` (default for cron, default for queue): only error/cancelled rows kept
389
+ * - `"all"`: keep success rows too (bounded by `keepLastSuccess`)
390
+ * - `"none"`: fire-and-forget, no row even on error
391
+ *
392
+ * Note: queue-mode jobs always write a `pending` row at push time (outbox).
393
+ * This setting controls whether that row is kept on success.
394
+ */
395
+ record?: "error" | "all" | "none";
396
+ /**
397
+ * Override the global ring-buffer trim for this job.
398
+ *
399
+ * - `{ ok: 0, error: 0 }` — **keep forever** (no sweep trim). Useful for
400
+ * audit-heavy jobs where retention is time-based (handled by a separate
401
+ * cron) rather than count-based.
402
+ * - `{ ok: 50 }` — keep last 50 successes; fall back to global default for errors.
403
+ * - omitted — use global `keepLastSuccess` / `keepLastError` from `jobConfig`.
404
+ */
405
+ keep?: {
406
+ ok?: number;
407
+ error?: number;
408
+ };
409
+ /**
410
+ * Handler function. For cron-mode, `payload` is `undefined`.
382
411
  */
383
412
  handler: (args: JobHandlerArgs<T>) => Async<void>;
384
413
  }
@@ -387,41 +416,34 @@ declare class JobPrimitive<T extends TSchema = TSchema> extends PipelinePrimitiv
387
416
  get name(): string;
388
417
  protected onInit(): void;
389
418
  /**
390
- * Push a single payload or an array of payloads.
419
+ * Push a single payload to the queue (queue-mode only).
391
420
  */
392
- push(payload: Static<T> | Array<Static<T>>, options?: PushOptions): Promise<string | string[]>;
421
+ push(payload: Static<T>, options?: PushOptions): Promise<string>;
393
422
  /**
394
- * Push multiple payloads with per-item options.
423
+ * Push multiple payloads at once (queue-mode only).
424
+ * Batched INSERT + batched queue send when supported.
395
425
  */
396
426
  pushMany(items: Array<PushManyItem<T>>): Promise<string[]>;
397
427
  /**
398
- * Cancel a running or pending execution.
428
+ * Cancel a pending or running execution.
399
429
  */
400
430
  cancel(executionId: string): Promise<void>;
401
431
  /**
402
- * Manually trigger the job (admin / CLI).
432
+ * Manually fire a cron-mode job, or trigger a queue-mode job with an explicit payload.
403
433
  */
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;
434
+ trigger(context?: JobTriggerContext<T>): Promise<void>;
417
435
  }
418
436
  //#endregion
419
437
  //#region ../../src/api/jobs/providers/JobProvider.d.ts
438
+ declare const PRIORITY_MAP: Record<JobPriority, number>;
439
+ declare const PRIORITY_REVERSE: Record<number, JobPriority>;
420
440
  interface PushOptions {
421
441
  delay?: DurationLike;
422
442
  key?: string;
423
443
  priority?: JobPriority;
424
444
  scheduledAt?: Date;
445
+ triggeredBy?: string;
446
+ triggeredByName?: string;
425
447
  }
426
448
  interface PushManyItem<T extends TSchema = TSchema> {
427
449
  payload: Static<T>;
@@ -430,8 +452,8 @@ interface PushManyItem<T extends TSchema = TSchema> {
430
452
  priority?: JobPriority;
431
453
  scheduledAt?: Date;
432
454
  }
433
- interface JobTriggerContext {
434
- payload?: Record<string, unknown>;
455
+ interface JobTriggerContext<T extends TSchema = TSchema> {
456
+ payload?: Static<T>;
435
457
  triggeredBy?: string;
436
458
  triggeredByName?: string;
437
459
  }
@@ -439,25 +461,38 @@ interface CancelContext {
439
461
  cancelledBy?: string;
440
462
  cancelledByName?: string;
441
463
  }
442
- interface JobRegistration$1 {
464
+ interface JobRuntimeRegistration {
443
465
  name: string;
444
466
  options: JobPrimitiveOptions;
467
+ type: "cron" | "queue";
445
468
  }
469
+ /**
470
+ * Coordinates cron (scheduler) and queue (push) jobs with a durable outbox
471
+ * table and a single reconciliation sweep.
472
+ *
473
+ * Queue-mode flow:
474
+ * push() → INSERT row (pending) + queue.send({ executionId })
475
+ * worker → SELECT row → UPDATE running → handler → DELETE (ok) / UPDATE (error)
476
+ *
477
+ * Cron-mode flow:
478
+ * scheduler tick → handler runs inline → INSERT row only on error
479
+ *
480
+ * Sweep responsibilities (every `sweepInterval`):
481
+ * - re-enqueue pending rows older than `staleThreshold`
482
+ * - fail running rows older than `max(timeout*2, runTimeout)`
483
+ * - move `scheduled` rows with `scheduledAt <= now` to pending + enqueue
484
+ * - trim per-job history beyond `keepLastSuccess` / `keepLastError`
485
+ */
446
486
  declare class JobProvider {
447
487
  protected readonly alepha: Alepha;
448
488
  protected readonly dt: DateTimeProvider;
449
489
  protected readonly cronProvider: CronProvider;
450
- protected readonly lockProvider: LockProvider;
451
490
  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;
491
+ sweepInterval: number;
492
+ staleThreshold: number;
493
+ runTimeout: number;
494
+ keepLastSuccess: number;
495
+ keepLastError: number;
461
496
  logMaxEntries: number;
462
497
  drainTimeout: number;
463
498
  }>;
@@ -468,26 +503,17 @@ declare class JobProvider {
468
503
  updatedAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_UPDATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
469
504
  jobName: _$alepha.TString;
470
505
  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>;
506
+ status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"pending" | "running" | "scheduled" | "ok" | "error" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
473
507
  priority: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
474
508
  attempt: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
475
509
  maxAttempts: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
510
+ payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
476
511
  scheduledAt: _$alepha.TOptional<_$alepha.TString>;
477
512
  startedAt: _$alepha.TOptional<_$alepha.TString>;
478
513
  completedAt: _$alepha.TOptional<_$alepha.TString>;
479
- result: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
480
514
  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">;
515
+ logs: _$alepha.TOptional<_$alepha.TArray<_$alepha.TObject<{
516
+ level: _$alepha.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
491
517
  message: _$alepha.TString;
492
518
  service: _$alepha.TString;
493
519
  module: _$alepha.TString;
@@ -495,214 +521,143 @@ declare class JobProvider {
495
521
  app: _$alepha.TOptional<_$alepha.TString>;
496
522
  data: _$alepha.TOptional<_$alepha.TAny>;
497
523
  timestamp: _$alepha.TNumber;
498
- }>>;
524
+ }>>>;
525
+ triggeredBy: _$alepha.TOptional<_$alepha.TString>;
526
+ triggeredByName: _$alepha.TOptional<_$alepha.TString>;
527
+ cancelledBy: _$alepha.TOptional<_$alepha.TString>;
528
+ cancelledByName: _$alepha.TOptional<_$alepha.TString>;
499
529
  }>>;
500
- protected readonly jobs: Map<string, JobRegistration$1>;
501
- protected readonly pausedJobs: Set<string>;
530
+ protected readonly jobs: Map<string, JobRuntimeRegistration>;
502
531
  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, {
532
+ protected readonly abortControllers: Map<string, AbortController>;
533
+ protected readonly perExecutionLogs: Map<string, {
509
534
  context?: string | undefined;
510
535
  app?: string | undefined;
511
536
  data?: any;
512
- level: "TRACE" | "SILENT" | "DEBUG" | "INFO" | "WARN" | "ERROR";
537
+ level: "SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR";
513
538
  message: string;
514
539
  service: string;
515
540
  module: string;
516
541
  timestamp: number;
517
542
  }[]>;
518
- protected readonly abortControllers: Map<string, AbortController>;
519
- protected static readonly SWEEP_CRON = "*/5 * * * *";
520
543
  protected stopping: boolean;
521
- protected workerId: string;
544
+ /**
545
+ * Set by `JobQueueProvider` when `AlephaApiJobsQueue` is loaded.
546
+ * When null, queue-mode jobs cannot be pushed.
547
+ */
548
+ queueDispatch: ((jobName: string, executionId: string) => Promise<void>) | null;
522
549
  registerJob(name: string, options: JobPrimitiveOptions): void;
550
+ getRegisteredJobs(): Map<string, JobRuntimeRegistration>;
551
+ protected runCron(name: string): Promise<void>;
523
552
  /**
524
- * Get all registered job definitions.
553
+ * Execute a cron handler inline. Records a row only on error (or always,
554
+ * when `record: 'all'`). No DB writes on the happy path by default.
525
555
  */
526
- getRegisteredJobs(): Map<string, JobRegistration$1>;
556
+ protected executeInline(registration: JobRuntimeRegistration, executionId: string, ctx: {
557
+ payload: unknown;
558
+ attempt: number;
559
+ triggeredBy?: string;
560
+ triggeredByName?: string;
561
+ }): Promise<void>;
562
+ protected writeTerminalRow(executionId: string, jobName: string, status: "ok" | "error", fields: {
563
+ payload: unknown;
564
+ attempt: number;
565
+ startedAt: ReturnType<DateTimeProvider["now"]>;
566
+ error?: Error;
567
+ context: string;
568
+ triggeredBy?: string;
569
+ triggeredByName?: string;
570
+ }): Promise<void>;
527
571
  push(name: string, payload: unknown, options?: PushOptions): Promise<string>;
572
+ /**
573
+ * Fire a local setTimeout so delayed/retrying rows dispatch as close to
574
+ * `scheduledAt` as possible, rather than waiting for the next sweep tick.
575
+ * No-op on stateless runtimes where timers won't survive (the sweep
576
+ * handles those).
577
+ */
578
+ protected scheduleOptimisticDispatch(jobName: string, executionId: string, scheduledAt: string): void;
528
579
  pushMany(name: string, items: Array<PushManyItem>): Promise<string[]>;
580
+ protected dispatchToQueue(jobName: string, executionId: string): Promise<void>;
529
581
  trigger(name: string, context?: JobTriggerContext): Promise<void>;
530
582
  cancel(executionId: string, context?: CancelContext): Promise<void>;
531
- protected scheduleProcessing(jobName: string, executionId: string): Promise<void>;
532
583
  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>;
584
+ protected processQueueExecution(registration: JobRuntimeRegistration, executionId: string): Promise<void>;
539
585
  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>;
586
+ protected handleFailure(executionId: string, registration: JobRuntimeRegistration, currentAttempt: number, error: Error, contextId: string): Promise<void>;
587
+ protected computeBackoff(retry: JobRetryOptions, attempt: number): string;
588
+ protected snapshotLogs(contextId: string): LogEntry[] | undefined;
589
+ protected sweep(): Promise<void>;
590
+ protected dispatchToQueueSafe(jobName: string, executionId: string): Promise<void>;
544
591
  /**
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.
592
+ * Move a row from `scheduled` → `pending` and dispatch it.
593
+ * Used by the optimistic retry/delay timer. If the sweep has already moved
594
+ * the row, or another worker has claimed it, the UPDATE guard fails silently.
558
595
  */
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`.
565
- */
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>;
596
+ protected dispatchScheduled(jobName: string, executionId: string): Promise<void>;
597
+ protected trimRingBuffers(): Promise<void>;
598
+ protected trimByStatus(jobName: string, status: "ok" | "error", keep: number): Promise<void>;
573
599
  protected readonly onStart: _$alepha.HookPrimitive<"start">;
574
600
  protected readonly onStop: _$alepha.HookPrimitive<"stop">;
575
- protected getRegistration(name: string): JobRegistration$1;
601
+ protected getRegistration(name: string): JobRuntimeRegistration;
576
602
  }
577
603
  //#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
604
  //#region ../../src/api/jobs/schemas/jobExecutionQuerySchema.d.ts
610
605
  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>;
606
+ status: _$alepha.TOptional<_$alepha.TUnsafe<"pending" | "running" | "scheduled" | "ok" | "error" | "cancelled">>;
607
+ limit: _$alepha.TOptional<_$alepha.TInteger>;
619
608
  }>;
620
609
  type JobExecutionQuery = Static<typeof jobExecutionQuerySchema>;
621
610
  //#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
611
  //#region ../../src/api/jobs/schemas/jobRegistrationSchema.d.ts
644
612
  declare const jobRegistrationSchema: _$alepha.TObject<{
645
613
  name: _$alepha.TString;
646
- type: _$alepha.TUnsafe<"push" | "cron" | "both">;
614
+ description: _$alepha.TOptional<_$alepha.TString>;
615
+ type: _$alepha.TUnsafe<"cron" | "queue">;
647
616
  priority: _$alepha.TUnsafe<"critical" | "high" | "normal" | "low">;
648
- concurrency: _$alepha.TInteger;
649
- hasSchema: _$alepha.TBoolean;
650
617
  cron: _$alepha.TOptional<_$alepha.TString>;
651
618
  timeout: _$alepha.TOptional<_$alepha.TString>;
652
619
  retry: _$alepha.TOptional<_$alepha.TObject<{
653
620
  retries: _$alepha.TInteger;
654
621
  hasBackoff: _$alepha.TBoolean;
655
622
  }>>;
656
- paused: _$alepha.TBoolean;
623
+ recent: _$alepha.TObject<{
624
+ ok: _$alepha.TInteger;
625
+ error: _$alepha.TInteger;
626
+ lastRun: _$alepha.TOptional<_$alepha.TString>;
627
+ }>;
657
628
  }>;
658
629
  type JobRegistration = Static<typeof jobRegistrationSchema>;
659
630
  //#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
631
  //#region ../../src/api/jobs/services/JobService.d.ts
632
+ /**
633
+ * Admin surface for the job system.
634
+ *
635
+ * Six methods: list jobs, list executions, get execution,
636
+ * trigger, retry, cancel. Everything else lives in events — any
637
+ * analytics/observability is an external concern that subscribes
638
+ * to `job:begin` / `job:success` / `job:error`.
639
+ */
674
640
  declare class JobService {
675
641
  protected readonly alepha: Alepha;
676
- protected readonly dt: DateTimeProvider;
677
642
  protected readonly log: _$alepha_logger0.Logger;
678
643
  protected readonly jobProvider: JobProvider;
679
- protected readonly database: DatabaseProvider;
680
644
  protected readonly executions: _$alepha_orm0.Repository<_$alepha.TObject<{
681
645
  id: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_PRIMARY_KEY>, typeof _$alepha_orm0.PG_DEFAULT>;
682
646
  createdAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_CREATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
683
647
  updatedAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_UPDATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
684
648
  jobName: _$alepha.TString;
685
649
  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>;
650
+ status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"pending" | "running" | "scheduled" | "ok" | "error" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
688
651
  priority: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
689
652
  attempt: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
690
653
  maxAttempts: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
654
+ payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
691
655
  scheduledAt: _$alepha.TOptional<_$alepha.TString>;
692
656
  startedAt: _$alepha.TOptional<_$alepha.TString>;
693
657
  completedAt: _$alepha.TOptional<_$alepha.TString>;
694
- result: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
695
658
  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">;
659
+ logs: _$alepha.TOptional<_$alepha.TArray<_$alepha.TObject<{
660
+ level: _$alepha.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
706
661
  message: _$alepha.TString;
707
662
  service: _$alepha.TString;
708
663
  module: _$alepha.TString;
@@ -710,126 +665,56 @@ declare class JobService {
710
665
  app: _$alepha.TOptional<_$alepha.TString>;
711
666
  data: _$alepha.TOptional<_$alepha.TAny>;
712
667
  timestamp: _$alepha.TNumber;
713
- }>>;
668
+ }>>>;
669
+ triggeredBy: _$alepha.TOptional<_$alepha.TString>;
670
+ triggeredByName: _$alepha.TOptional<_$alepha.TString>;
671
+ cancelledBy: _$alepha.TOptional<_$alepha.TString>;
672
+ cancelledByName: _$alepha.TOptional<_$alepha.TString>;
714
673
  }>>;
715
674
  protected computeCan(status: string): {
716
675
  retry: boolean;
717
676
  cancel: boolean;
718
677
  };
719
678
  /**
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)
679
+ * List every registered job with recent ok/error counts and lastRun.
680
+ * One aggregate query covers all jobs.
725
681
  */
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<{
682
+ listJobs(): Promise<JobRegistration[]>;
683
+ /**
684
+ * Recent executions for a single job, ORDER BY startedAt DESC.
685
+ */
686
+ getExecutions(jobName: string, query?: JobExecutionQuery): Promise<{
801
687
  can: {
802
688
  retry: boolean;
803
689
  cancel: boolean;
804
690
  };
805
- logs: {
806
- context?: string | undefined;
807
- app?: string | undefined;
808
- data?: any;
809
- level: "TRACE" | "SILENT" | "DEBUG" | "INFO" | "WARN" | "ERROR";
810
- message: string;
811
- service: string;
812
- module: string;
813
- timestamp: number;
814
- }[] | undefined;
815
691
  key?: string | null | undefined;
692
+ error?: string | undefined;
816
693
  payload?: _$typebox.StaticRecord<[], "Decode", {}, {
817
694
  id: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_PRIMARY_KEY>, typeof _$alepha_orm0.PG_DEFAULT>;
818
695
  createdAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_CREATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
819
696
  updatedAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_UPDATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
820
697
  jobName: _$alepha.TString;
821
698
  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>;
699
+ status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"pending" | "running" | "scheduled" | "ok" | "error" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
824
700
  priority: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
825
701
  attempt: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
826
702
  maxAttempts: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
703
+ payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
827
704
  scheduledAt: _$alepha.TOptional<_$alepha.TString>;
828
705
  startedAt: _$alepha.TOptional<_$alepha.TString>;
829
706
  completedAt: _$alepha.TOptional<_$alepha.TString>;
830
- result: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
831
707
  error: _$alepha.TOptional<_$alepha.TString>;
832
- workerId: _$alepha.TOptional<_$alepha.TString>;
708
+ logs: _$alepha.TOptional<_$alepha.TArray<_$alepha.TObject<{
709
+ level: _$alepha.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
710
+ message: _$alepha.TString;
711
+ service: _$alepha.TString;
712
+ module: _$alepha.TString;
713
+ context: _$alepha.TOptional<_$alepha.TString>;
714
+ app: _$alepha.TOptional<_$alepha.TString>;
715
+ data: _$alepha.TOptional<_$alepha.TAny>;
716
+ timestamp: _$alepha.TNumber;
717
+ }>>>;
833
718
  triggeredBy: _$alepha.TOptional<_$alepha.TString>;
834
719
  triggeredByName: _$alepha.TOptional<_$alepha.TString>;
835
720
  cancelledBy: _$alepha.TOptional<_$alepha.TString>;
@@ -838,46 +723,104 @@ declare class JobService {
838
723
  scheduledAt?: string | undefined;
839
724
  startedAt?: string | undefined;
840
725
  completedAt?: string | undefined;
841
- result?: _$typebox.StaticRecord<[], "Decode", {}, {
726
+ logs?: {
727
+ context?: string | undefined;
728
+ app?: string | undefined;
729
+ data?: any;
730
+ level: "SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR";
731
+ message: string;
732
+ service: string;
733
+ module: string;
734
+ timestamp: number;
735
+ }[] | undefined;
736
+ triggeredBy?: string | undefined;
737
+ triggeredByName?: string | undefined;
738
+ cancelledBy?: string | undefined;
739
+ cancelledByName?: string | undefined;
740
+ id: string;
741
+ createdAt: string;
742
+ updatedAt: string;
743
+ jobName: string;
744
+ status: "pending" | "running" | "scheduled" | "ok" | "error" | "cancelled";
745
+ priority: number;
746
+ attempt: number;
747
+ maxAttempts: number;
748
+ }[]>;
749
+ /**
750
+ * Full execution detail (includes captured logs).
751
+ */
752
+ getExecution(id: string): Promise<{
753
+ can: {
754
+ retry: boolean;
755
+ cancel: boolean;
756
+ };
757
+ key?: string | null | undefined;
758
+ error?: string | undefined;
759
+ payload?: _$typebox.StaticRecord<[], "Decode", {}, {
842
760
  id: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_PRIMARY_KEY>, typeof _$alepha_orm0.PG_DEFAULT>;
843
761
  createdAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_CREATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
844
762
  updatedAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_UPDATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
845
763
  jobName: _$alepha.TString;
846
764
  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>;
765
+ status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"pending" | "running" | "scheduled" | "ok" | "error" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
849
766
  priority: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
850
767
  attempt: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
851
768
  maxAttempts: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
769
+ payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
852
770
  scheduledAt: _$alepha.TOptional<_$alepha.TString>;
853
771
  startedAt: _$alepha.TOptional<_$alepha.TString>;
854
772
  completedAt: _$alepha.TOptional<_$alepha.TString>;
855
- result: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
856
773
  error: _$alepha.TOptional<_$alepha.TString>;
857
- workerId: _$alepha.TOptional<_$alepha.TString>;
774
+ logs: _$alepha.TOptional<_$alepha.TArray<_$alepha.TObject<{
775
+ level: _$alepha.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
776
+ message: _$alepha.TString;
777
+ service: _$alepha.TString;
778
+ module: _$alepha.TString;
779
+ context: _$alepha.TOptional<_$alepha.TString>;
780
+ app: _$alepha.TOptional<_$alepha.TString>;
781
+ data: _$alepha.TOptional<_$alepha.TAny>;
782
+ timestamp: _$alepha.TNumber;
783
+ }>>>;
858
784
  triggeredBy: _$alepha.TOptional<_$alepha.TString>;
859
785
  triggeredByName: _$alepha.TOptional<_$alepha.TString>;
860
786
  cancelledBy: _$alepha.TOptional<_$alepha.TString>;
861
787
  cancelledByName: _$alepha.TOptional<_$alepha.TString>;
862
788
  }, "^.*$", _$alepha.TAny> | undefined;
863
- error?: string | undefined;
864
- workerId?: string | undefined;
789
+ scheduledAt?: string | undefined;
790
+ startedAt?: string | undefined;
791
+ completedAt?: string | undefined;
792
+ logs?: {
793
+ context?: string | undefined;
794
+ app?: string | undefined;
795
+ data?: any;
796
+ level: "SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR";
797
+ message: string;
798
+ service: string;
799
+ module: string;
800
+ timestamp: number;
801
+ }[] | undefined;
865
802
  triggeredBy?: string | undefined;
866
803
  triggeredByName?: string | undefined;
867
804
  cancelledBy?: string | undefined;
868
805
  cancelledByName?: string | undefined;
869
- priority: number;
870
- status: "running" | "pending" | "scheduled" | "retrying" | "dead" | "completed" | "cancelled";
871
806
  id: string;
872
807
  createdAt: string;
873
808
  updatedAt: string;
874
809
  jobName: string;
810
+ status: "pending" | "running" | "scheduled" | "ok" | "error" | "cancelled";
811
+ priority: number;
875
812
  attempt: number;
876
813
  maxAttempts: number;
877
814
  }>;
815
+ /**
816
+ * Manual trigger (cron jobs) or push-with-payload (queue jobs).
817
+ */
878
818
  triggerJob(name: string, context?: JobTriggerContext): Promise<{
879
819
  ok: boolean;
880
820
  }>;
821
+ /**
822
+ * Retry a dead or cancelled execution by re-pushing with the original payload.
823
+ */
881
824
  retryExecution(id: string, context?: {
882
825
  triggeredBy?: string;
883
826
  triggeredByName?: string;
@@ -890,105 +833,68 @@ declare class JobService {
890
833
  }): Promise<{
891
834
  ok: boolean;
892
835
  }>;
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
836
  }
927
837
  //#endregion
928
838
  //#region ../../src/api/jobs/controllers/AdminJobController.d.ts
839
+ /**
840
+ * Minimal admin surface for the job system. Six endpoints.
841
+ */
929
842
  declare class AdminJobController {
930
843
  protected readonly url: string;
931
844
  protected readonly group: string;
932
845
  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<{
846
+ readonly listJobs: _$alepha_server0.ActionPrimitiveFn<{
949
847
  response: _$alepha.TArray<_$alepha.TObject<{
950
848
  name: _$alepha.TString;
951
- type: _$alepha.TUnsafe<"push" | "cron" | "both">;
849
+ description: _$alepha.TOptional<_$alepha.TString>;
850
+ type: _$alepha.TUnsafe<"cron" | "queue">;
952
851
  priority: _$alepha.TUnsafe<"critical" | "high" | "normal" | "low">;
953
- concurrency: _$alepha.TInteger;
954
- hasSchema: _$alepha.TBoolean;
955
852
  cron: _$alepha.TOptional<_$alepha.TString>;
956
853
  timeout: _$alepha.TOptional<_$alepha.TString>;
957
854
  retry: _$alepha.TOptional<_$alepha.TObject<{
958
855
  retries: _$alepha.TInteger;
959
856
  hasBackoff: _$alepha.TBoolean;
960
857
  }>>;
961
- paused: _$alepha.TBoolean;
858
+ recent: _$alepha.TObject<{
859
+ ok: _$alepha.TInteger;
860
+ error: _$alepha.TInteger;
861
+ lastRun: _$alepha.TOptional<_$alepha.TString>;
862
+ }>;
962
863
  }>>;
963
864
  }>;
964
- readonly findJobExecutions: _$alepha_server0.ActionPrimitiveFn<{
865
+ readonly listExecutions: _$alepha_server0.ActionPrimitiveFn<{
866
+ params: _$alepha.TObject<{
867
+ name: _$alepha.TString;
868
+ }>;
965
869
  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>;
870
+ status: _$alepha.TOptional<_$alepha.TUnsafe<"pending" | "running" | "scheduled" | "ok" | "error" | "cancelled">>;
871
+ limit: _$alepha.TOptional<_$alepha.TInteger>;
974
872
  }>;
975
- response: _$alepha.TPage<_$alepha.TObject<{
873
+ response: _$alepha.TArray<_$alepha.TObject<{
976
874
  id: PgAttr<PgAttr<_$alepha.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
977
875
  createdAt: PgAttr<PgAttr<_$alepha.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
978
876
  updatedAt: PgAttr<PgAttr<_$alepha.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
979
877
  jobName: _$alepha.TString;
980
878
  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>;
879
+ status: PgAttr<_$alepha.TUnsafe<"pending" | "running" | "scheduled" | "ok" | "error" | "cancelled">, typeof PG_DEFAULT>;
983
880
  priority: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
984
881
  attempt: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
985
882
  maxAttempts: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
883
+ payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
986
884
  scheduledAt: _$alepha.TOptional<_$alepha.TString>;
987
885
  startedAt: _$alepha.TOptional<_$alepha.TString>;
988
886
  completedAt: _$alepha.TOptional<_$alepha.TString>;
989
- result: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
990
887
  error: _$alepha.TOptional<_$alepha.TString>;
991
- workerId: _$alepha.TOptional<_$alepha.TString>;
888
+ logs: _$alepha.TOptional<_$alepha.TArray<_$alepha.TObject<{
889
+ level: _$alepha.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
890
+ message: _$alepha.TString;
891
+ service: _$alepha.TString;
892
+ module: _$alepha.TString;
893
+ context: _$alepha.TOptional<_$alepha.TString>;
894
+ app: _$alepha.TOptional<_$alepha.TString>;
895
+ data: _$alepha.TOptional<_$alepha.TAny>;
896
+ timestamp: _$alepha.TNumber;
897
+ }>>>;
992
898
  triggeredBy: _$alepha.TOptional<_$alepha.TString>;
993
899
  triggeredByName: _$alepha.TOptional<_$alepha.TString>;
994
900
  cancelledBy: _$alepha.TOptional<_$alepha.TString>;
@@ -999,7 +905,7 @@ declare class AdminJobController {
999
905
  }>;
1000
906
  }>>;
1001
907
  }>;
1002
- readonly getJobExecution: _$alepha_server0.ActionPrimitiveFn<{
908
+ readonly getExecution: _$alepha_server0.ActionPrimitiveFn<{
1003
909
  params: _$alepha.TObject<{
1004
910
  id: _$alepha.TString;
1005
911
  }>;
@@ -1009,27 +915,17 @@ declare class AdminJobController {
1009
915
  updatedAt: PgAttr<PgAttr<_$alepha.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
1010
916
  jobName: _$alepha.TString;
1011
917
  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>;
918
+ status: PgAttr<_$alepha.TUnsafe<"pending" | "running" | "scheduled" | "ok" | "error" | "cancelled">, typeof PG_DEFAULT>;
1014
919
  priority: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
1015
920
  attempt: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
1016
921
  maxAttempts: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
922
+ payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
1017
923
  scheduledAt: _$alepha.TOptional<_$alepha.TString>;
1018
924
  startedAt: _$alepha.TOptional<_$alepha.TString>;
1019
925
  completedAt: _$alepha.TOptional<_$alepha.TString>;
1020
- result: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
1021
926
  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
927
  logs: _$alepha.TOptional<_$alepha.TArray<_$alepha.TObject<{
1032
- level: _$alepha.TUnsafe<"TRACE" | "SILENT" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
928
+ level: _$alepha.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
1033
929
  message: _$alepha.TString;
1034
930
  service: _$alepha.TString;
1035
931
  module: _$alepha.TString;
@@ -1038,11 +934,21 @@ declare class AdminJobController {
1038
934
  data: _$alepha.TOptional<_$alepha.TAny>;
1039
935
  timestamp: _$alepha.TNumber;
1040
936
  }>>>;
937
+ triggeredBy: _$alepha.TOptional<_$alepha.TString>;
938
+ triggeredByName: _$alepha.TOptional<_$alepha.TString>;
939
+ cancelledBy: _$alepha.TOptional<_$alepha.TString>;
940
+ cancelledByName: _$alepha.TOptional<_$alepha.TString>;
941
+ can: _$alepha.TObject<{
942
+ retry: _$alepha.TBoolean;
943
+ cancel: _$alepha.TBoolean;
944
+ }>;
1041
945
  }>;
1042
946
  }>;
1043
947
  readonly triggerJob: _$alepha_server0.ActionPrimitiveFn<{
1044
- body: _$alepha.TObject<{
948
+ params: _$alepha.TObject<{
1045
949
  name: _$alepha.TString;
950
+ }>;
951
+ body: _$alepha.TObject<{
1046
952
  payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
1047
953
  }>;
1048
954
  response: _$alepha.TObject<{
@@ -1051,7 +957,7 @@ declare class AdminJobController {
1051
957
  count: _$alepha.TOptional<_$alepha.TNumber>;
1052
958
  }>;
1053
959
  }>;
1054
- readonly retryJobExecution: _$alepha_server0.ActionPrimitiveFn<{
960
+ readonly retryExecution: _$alepha_server0.ActionPrimitiveFn<{
1055
961
  params: _$alepha.TObject<{
1056
962
  id: _$alepha.TString;
1057
963
  }>;
@@ -1061,7 +967,7 @@ declare class AdminJobController {
1061
967
  count: _$alepha.TOptional<_$alepha.TNumber>;
1062
968
  }>;
1063
969
  }>;
1064
- readonly cancelJobExecution: _$alepha_server0.ActionPrimitiveFn<{
970
+ readonly cancelExecution: _$alepha_server0.ActionPrimitiveFn<{
1065
971
  params: _$alepha.TObject<{
1066
972
  id: _$alepha.TString;
1067
973
  }>;
@@ -1071,112 +977,43 @@ declare class AdminJobController {
1071
977
  count: _$alepha.TOptional<_$alepha.TNumber>;
1072
978
  }>;
1073
979
  }>;
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
980
  }
1148
981
  //#endregion
1149
982
  //#region ../../src/api/jobs/entities/jobExecutionEntity.d.ts
983
+ /**
984
+ * Job execution record.
985
+ *
986
+ * Stores durable state for queue-mode jobs (outbox pattern) and error records
987
+ * for cron-mode jobs. Successful executions are trimmed by the sweep to keep
988
+ * the last N rows per job (configurable via `jobConfig.keepLastSuccess`).
989
+ *
990
+ * Status transitions:
991
+ * - queue push → pending
992
+ * - worker claim → running
993
+ * - success → ok
994
+ * - terminal failure → error
995
+ * - retry → scheduled (with scheduledAt = now + backoff)
996
+ * - delay → scheduled (with scheduledAt = now + delay)
997
+ * - sweep picks due ones → pending
998
+ * - cancel → cancelled
999
+ */
1150
1000
  declare const jobExecutionEntity: _$alepha_orm0.EntityPrimitive<_$alepha.TObject<{
1151
1001
  id: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_PRIMARY_KEY>, typeof _$alepha_orm0.PG_DEFAULT>;
1152
1002
  createdAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_CREATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
1153
1003
  updatedAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_UPDATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
1154
1004
  jobName: _$alepha.TString;
1155
1005
  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>;
1006
+ status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"pending" | "running" | "scheduled" | "ok" | "error" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
1158
1007
  priority: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
1159
1008
  attempt: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
1160
1009
  maxAttempts: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
1010
+ payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
1161
1011
  scheduledAt: _$alepha.TOptional<_$alepha.TString>;
1162
1012
  startedAt: _$alepha.TOptional<_$alepha.TString>;
1163
1013
  completedAt: _$alepha.TOptional<_$alepha.TString>;
1164
- result: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
1165
1014
  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">;
1015
+ logs: _$alepha.TOptional<_$alepha.TArray<_$alepha.TObject<{
1016
+ level: _$alepha.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
1180
1017
  message: _$alepha.TString;
1181
1018
  service: _$alepha.TString;
1182
1019
  module: _$alepha.TString;
@@ -1184,18 +1021,22 @@ declare const jobExecutionLogEntity: _$alepha_orm0.EntityPrimitive<_$alepha.TObj
1184
1021
  app: _$alepha.TOptional<_$alepha.TString>;
1185
1022
  data: _$alepha.TOptional<_$alepha.TAny>;
1186
1023
  timestamp: _$alepha.TNumber;
1187
- }>>;
1024
+ }>>>;
1025
+ triggeredBy: _$alepha.TOptional<_$alepha.TString>;
1026
+ triggeredByName: _$alepha.TOptional<_$alepha.TString>;
1027
+ cancelledBy: _$alepha.TOptional<_$alepha.TString>;
1028
+ cancelledByName: _$alepha.TOptional<_$alepha.TString>;
1188
1029
  }>>;
1189
- type JobExecutionLogEntity = Static<typeof jobExecutionLogEntity.schema>;
1030
+ type JobExecutionEntity = Static<typeof jobExecutionEntity.schema>;
1031
+ type JobStatus = "pending" | "running" | "scheduled" | "ok" | "error" | "cancelled";
1190
1032
  //#endregion
1191
1033
  //#region ../../src/api/jobs/providers/JobQueueProvider.d.ts
1192
1034
  /**
1193
- * Optional queue-backed dispatch for the job system.
1035
+ * Plumbs outbox-style dispatch through `AlephaQueue`.
1194
1036
  *
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.
1037
+ * Registered only when the app imports `AlephaApiJobsQueue`. Sets
1038
+ * `JobProvider.queueDispatch` eagerly at instantiation so queue-mode jobs
1039
+ * can dispatch regardless of start-hook ordering.
1199
1040
  */
1200
1041
  declare class JobQueueProvider {
1201
1042
  protected readonly jobProvider: JobProvider;
@@ -1203,24 +1044,18 @@ declare class JobQueueProvider {
1203
1044
  jobName: _$alepha.TString;
1204
1045
  executionId: _$alepha.TString;
1205
1046
  }>>;
1206
- protected readonly onStart: _$alepha.HookPrimitive<"start">;
1207
- /**
1208
- * Push a job execution onto the queue for async processing.
1209
- */
1047
+ constructor();
1048
+ protected wireDispatcher(): void;
1210
1049
  push(jobName: string, executionId: string): Promise<void>;
1211
1050
  }
1212
1051
  //#endregion
1213
1052
  //#region ../../src/api/jobs/schemas/jobConfigAtom.d.ts
1214
1053
  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;
1054
+ sweepInterval: _$alepha.TInteger;
1055
+ staleThreshold: _$alepha.TInteger;
1056
+ runTimeout: _$alepha.TInteger;
1057
+ keepLastSuccess: _$alepha.TInteger;
1058
+ keepLastError: _$alepha.TInteger;
1224
1059
  logMaxEntries: _$alepha.TInteger;
1225
1060
  drainTimeout: _$alepha.TInteger;
1226
1061
  }>, "alepha.jobs">;
@@ -1231,34 +1066,24 @@ declare module "alepha" {
1231
1066
  }
1232
1067
  } //# sourceMappingURL=jobConfigAtom.d.ts.map
1233
1068
  //#endregion
1234
- //#region ../../src/api/jobs/schemas/jobExecutionDetailResourceSchema.d.ts
1235
- declare const jobExecutionDetailResourceSchema: _$alepha.TObject<{
1069
+ //#region ../../src/api/jobs/schemas/jobExecutionResourceSchema.d.ts
1070
+ declare const jobExecutionResourceSchema: _$alepha.TObject<{
1236
1071
  id: PgAttr<PgAttr<_$alepha.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
1237
1072
  createdAt: PgAttr<PgAttr<_$alepha.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
1238
1073
  updatedAt: PgAttr<PgAttr<_$alepha.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
1239
1074
  jobName: _$alepha.TString;
1240
1075
  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>;
1076
+ status: PgAttr<_$alepha.TUnsafe<"pending" | "running" | "scheduled" | "ok" | "error" | "cancelled">, typeof PG_DEFAULT>;
1243
1077
  priority: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
1244
1078
  attempt: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
1245
1079
  maxAttempts: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
1080
+ payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
1246
1081
  scheduledAt: _$alepha.TOptional<_$alepha.TString>;
1247
1082
  startedAt: _$alepha.TOptional<_$alepha.TString>;
1248
1083
  completedAt: _$alepha.TOptional<_$alepha.TString>;
1249
- result: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
1250
1084
  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
1085
  logs: _$alepha.TOptional<_$alepha.TArray<_$alepha.TObject<{
1261
- level: _$alepha.TUnsafe<"TRACE" | "SILENT" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
1086
+ level: _$alepha.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
1262
1087
  message: _$alepha.TString;
1263
1088
  service: _$alepha.TString;
1264
1089
  module: _$alepha.TString;
@@ -1267,31 +1092,6 @@ declare const jobExecutionDetailResourceSchema: _$alepha.TObject<{
1267
1092
  data: _$alepha.TOptional<_$alepha.TAny>;
1268
1093
  timestamp: _$alepha.TNumber;
1269
1094
  }>>>;
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
1095
  triggeredBy: _$alepha.TOptional<_$alepha.TString>;
1296
1096
  triggeredByName: _$alepha.TOptional<_$alepha.TString>;
1297
1097
  cancelledBy: _$alepha.TOptional<_$alepha.TString>;
@@ -1305,14 +1105,12 @@ type JobExecutionResource = Static<typeof jobExecutionResourceSchema>;
1305
1105
  //#endregion
1306
1106
  //#region ../../src/api/jobs/schemas/triggerJobSchema.d.ts
1307
1107
  declare const triggerJobSchema: _$alepha.TObject<{
1308
- name: _$alepha.TString;
1309
1108
  payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
1310
1109
  }>;
1311
1110
  type TriggerJob = Static<typeof triggerJobSchema>;
1312
1111
  //#endregion
1313
1112
  //#region ../../src/api/jobs/index.d.ts
1314
1113
  declare module "alepha" {
1315
- interface Env extends Partial<Static<typeof jobEnvSchema>> {}
1316
1114
  interface Hooks {
1317
1115
  "job:begin": {
1318
1116
  name: string;
@@ -1338,30 +1136,30 @@ declare module "alepha" {
1338
1136
  };
1339
1137
  }
1340
1138
  }
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
1139
  /**
1352
- * Job execution framework — unified primitive for deferred, scheduled, and queued work.
1140
+ * Job execution framework — cron and durable queue work with a single primitive.
1353
1141
  *
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
1142
+ * A `$job` is either **cron-only** (declares `cron`) or **queue-only** (declares `schema`).
1143
+ * Cron jobs run inline on their schedule and only record errors by default.
1144
+ * Queue jobs use the outbox pattern: push commits to DB first, then notifies via queue.
1145
+ *
1146
+ * **This module provides cron support only.** To enable queue-mode jobs, also
1147
+ * import {@link AlephaApiJobsQueue} it brings in the queue layer and infrastructure
1148
+ * binding (e.g. Cloudflare Queues). Cron-only deployments (Vercel, CF-without-Queues)
1149
+ * do not need `AlephaApiJobsQueue`.
1361
1150
  *
1362
1151
  * @module alepha.api.jobs
1363
1152
  */
1364
1153
  declare const AlephaApiJobs: _$alepha.Service<_$alepha.Module>;
1154
+ /**
1155
+ * Queue support for `$job`. Import alongside {@link AlephaApiJobs} when your
1156
+ * app declares queue-mode jobs (any `$job` with a `schema`).
1157
+ *
1158
+ * Adds `JobQueueProvider` which plumbs the outbox dispatch through `AlephaQueue`.
1159
+ *
1160
+ * @module alepha.api.jobs.queue
1161
+ */
1162
+ declare const AlephaApiJobsQueue: _$alepha.Service<_$alepha.Module>;
1365
1163
  //#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 };
1164
+ 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
1165
  //# sourceMappingURL=index.d.ts.map