@adonis-agora/durable 0.54.2 → 0.55.0

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 (43) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/commands/durable_worker.d.ts.map +1 -1
  3. package/dist/commands/durable_worker.js +3 -1
  4. package/dist/commands/durable_worker.js.map +1 -1
  5. package/dist/providers/durable_provider.d.ts.map +1 -1
  6. package/dist/providers/durable_provider.js +5 -2
  7. package/dist/providers/durable_provider.js.map +1 -1
  8. package/dist/src/codec-state-store.d.ts +2 -0
  9. package/dist/src/codec-state-store.d.ts.map +1 -1
  10. package/dist/src/codec-state-store.js +6 -0
  11. package/dist/src/codec-state-store.js.map +1 -1
  12. package/dist/src/dashboard/index.d.ts +1 -1
  13. package/dist/src/dashboard/index.js +1 -1
  14. package/dist/src/engine.d.ts +2 -2
  15. package/dist/src/engine.d.ts.map +1 -1
  16. package/dist/src/engine.js +11 -8
  17. package/dist/src/engine.js.map +1 -1
  18. package/dist/src/index.d.ts +1 -1
  19. package/dist/src/index.js +1 -1
  20. package/dist/src/interfaces.d.ts +13 -2
  21. package/dist/src/interfaces.d.ts.map +1 -1
  22. package/dist/src/interfaces.js.map +1 -1
  23. package/dist/src/step-discovery.d.ts +25 -4
  24. package/dist/src/step-discovery.d.ts.map +1 -1
  25. package/dist/src/step-discovery.js +103 -36
  26. package/dist/src/step-discovery.js.map +1 -1
  27. package/dist/src/stores/lucid.d.ts +2 -0
  28. package/dist/src/stores/lucid.d.ts.map +1 -1
  29. package/dist/src/stores/lucid.js +15 -0
  30. package/dist/src/stores/lucid.js.map +1 -1
  31. package/dist/src/testing/in-memory-state-store.d.ts +1 -0
  32. package/dist/src/testing/in-memory-state-store.d.ts.map +1 -1
  33. package/dist/src/testing/in-memory-state-store.js +10 -0
  34. package/dist/src/testing/in-memory-state-store.js.map +1 -1
  35. package/dist/src/testing-kit/state-store-conformance.d.ts.map +1 -1
  36. package/dist/src/testing-kit/state-store-conformance.js +31 -0
  37. package/dist/src/testing-kit/state-store-conformance.js.map +1 -1
  38. package/dist/src/worker-runtime/index.d.ts +1 -1
  39. package/dist/src/worker-runtime/index.d.ts.map +1 -1
  40. package/dist/src/worker-runtime/index.js.map +1 -1
  41. package/package.json +2 -2
  42. package/skills/durable-transports-stores/SKILL.md +7 -5
  43. package/skills/durable-workflows/SKILL.md +11 -6
@@ -296,15 +296,17 @@ export default defineConfig({
296
296
  })
297
297
  ```
298
298
 
299
- A custom store should implement `countCheckpoints(runId, fromSeq, toSeq,
300
- statuses)` as a `COUNT` (the step-fan join barrier asks it once per fan per
301
- batch, skipped while more of the same fan's results are queued behind the batch;
302
- without it the engine loads the run's checkpoints to count), implement
299
+ A custom store should implement `hasCheckpoints(runId, fromSeq, toSeq,
300
+ statuses)` as one `SELECT seq ... ORDER BY seq DESC LIMIT 1` (the step-fan join
301
+ barrier asks it once per fan per batch, skipped while more of the same fan's
302
+ results are queued behind the batch; without it the engine asks
303
+ `countCheckpoints`), `countCheckpoints` as a `COUNT` (without either the engine
304
+ loads the run's checkpoints), implement
303
305
  `saveCheckpointIfPending` as one conditional `UPDATE ... WHERE status = 'pending'`
304
306
  (without it a blind save can put a settled step back to `pending`), and return
305
307
  `listDueTimers` most overdue first, with or without a `limit`. Run
306
308
  `runStateStoreContract` from `@adonis-agora/durable/testing/conformance`, which
307
- covers all three and fails a store missing either method. The contract also
309
+ covers each of them and fails a store missing one of these methods. The contract also
308
310
  requires `saveCheckpointsIfPending` (batched result settling), `deleteRuns`
309
311
  (batched retention/purge deletes), `runFacets`, `pruneBufferedEvents`
310
312
  (`eventBufferTtl`) and the `checkpointStats` + `queryCheckpoints` pair (the run
@@ -41,9 +41,11 @@ A modular app (one folder per bounded context) lists several directories:
41
41
  `workflowsPath` and `stepsPath` in `config/durable.ts` take an array, and so
42
42
  does the `source` option of the `workflowsHook` / `stepsHook` codegen hooks.
43
43
  Names must be unique across those directories. To register one more directory
44
- from a preload, call `registerWorkflowsFromDir(engine, dir)` and
45
- `registerStepsFromDir(engine, dir)`. The engine serves steps through its
46
- transport (`engine.handle`).
44
+ from a preload, call `registerWorkflowsFromDir(engine, dir, factory?)` and
45
+ `registerStepsFromDir(engine, dir, factory?)`. The engine serves steps through its
46
+ transport (`engine.handle`). Pass `(Ctor) => app.container.make(Ctor)` as the
47
+ factory for constructor DI (for steps it runs on every execution); without it
48
+ classes are built once with `new Ctor()`.
47
49
 
48
50
  ## Setup
49
51
 
@@ -78,8 +80,11 @@ fire-and-forget child instead of a top-level run.
78
80
 
79
81
  ### Pattern 1 — typed steps with `@Step`, `defineStep`, and DI
80
82
 
81
- Steps are discovered from `app/steps` and served by name automatically. A
82
- `@Step` method ref passed to `ctx.step` gives full input/output typing:
83
+ Steps are discovered from `app/steps` and served by name automatically. Each
84
+ `@Step` class is resolved through the container on every execution (like an
85
+ `@adonisjs/queue` job), so it can take `@inject()` constructor dependencies and
86
+ a `container.swap(...)` after boot reaches the next execution. A `@Step` method ref passed to `ctx.step`
87
+ gives full input/output typing:
83
88
 
84
89
  ```ts title="app/steps/payment_steps.ts"
85
90
  import { Step } from '@adonis-agora/durable'
@@ -123,7 +128,7 @@ export default class OrderWorkflow extends BaseWorkflow {
123
128
  }
124
129
  ```
125
130
 
126
- The instance is built once at registration and reused for every run — treat the
131
+ The workflow instance is built once at registration and reused for every run — treat the
127
132
  constructor as wiring; keep per-run state in input and step outputs, never on
128
133
  `this`. Injected services are for **composing**, not doing work: reach them
129
134
  through step refs so the work is checkpointed.