@adonis-agora/durable 0.7.0 → 0.8.1

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 (120) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/README.md +1 -1
  3. package/dist/commands/main.d.ts +3 -2
  4. package/dist/commands/main.d.ts.map +1 -1
  5. package/dist/commands/main.js +3 -2
  6. package/dist/commands/main.js.map +1 -1
  7. package/dist/commands/make_workflow.d.ts +4 -3
  8. package/dist/commands/make_workflow.d.ts.map +1 -1
  9. package/dist/commands/make_workflow.js +4 -3
  10. package/dist/commands/make_workflow.js.map +1 -1
  11. package/dist/configure.d.ts +6 -5
  12. package/dist/configure.d.ts.map +1 -1
  13. package/dist/configure.js +9 -6
  14. package/dist/configure.js.map +1 -1
  15. package/dist/providers/dashboard_provider.d.ts +34 -3
  16. package/dist/providers/dashboard_provider.d.ts.map +1 -1
  17. package/dist/providers/dashboard_provider.js +130 -9
  18. package/dist/providers/dashboard_provider.js.map +1 -1
  19. package/dist/src/base-workflow.d.ts +78 -0
  20. package/dist/src/base-workflow.d.ts.map +1 -0
  21. package/dist/src/base-workflow.js +106 -0
  22. package/dist/src/base-workflow.js.map +1 -0
  23. package/dist/src/codec-state-store.d.ts +13 -0
  24. package/dist/src/codec-state-store.d.ts.map +1 -1
  25. package/dist/src/codec-state-store.js +13 -0
  26. package/dist/src/codec-state-store.js.map +1 -1
  27. package/dist/src/control-flow-signal.d.ts +50 -0
  28. package/dist/src/control-flow-signal.d.ts.map +1 -0
  29. package/dist/src/control-flow-signal.js +54 -0
  30. package/dist/src/control-flow-signal.js.map +1 -0
  31. package/dist/src/control-plane-redis/redis-control-plane.d.ts +57 -5
  32. package/dist/src/control-plane-redis/redis-control-plane.d.ts.map +1 -1
  33. package/dist/src/control-plane-redis/redis-control-plane.js +100 -2
  34. package/dist/src/control-plane-redis/redis-control-plane.js.map +1 -1
  35. package/dist/src/dashboard/auth.d.ts +89 -0
  36. package/dist/src/dashboard/auth.d.ts.map +1 -0
  37. package/dist/src/dashboard/auth.js +113 -0
  38. package/dist/src/dashboard/auth.js.map +1 -0
  39. package/dist/src/dashboard/define_config.d.ts +17 -0
  40. package/dist/src/dashboard/define_config.d.ts.map +1 -1
  41. package/dist/src/dashboard/define_config.js +23 -1
  42. package/dist/src/dashboard/define_config.js.map +1 -1
  43. package/dist/src/dashboard/index.d.ts +5 -0
  44. package/dist/src/dashboard/index.d.ts.map +1 -1
  45. package/dist/src/dashboard/index.js +4 -0
  46. package/dist/src/dashboard/index.js.map +1 -1
  47. package/dist/src/dashboard/login_page.d.ts +23 -0
  48. package/dist/src/dashboard/login_page.d.ts.map +1 -0
  49. package/dist/src/dashboard/login_page.js +170 -0
  50. package/dist/src/dashboard/login_page.js.map +1 -0
  51. package/dist/src/dashboard/session_cookie.d.ts +42 -0
  52. package/dist/src/dashboard/session_cookie.d.ts.map +1 -0
  53. package/dist/src/dashboard/session_cookie.js +97 -0
  54. package/dist/src/dashboard/session_cookie.js.map +1 -0
  55. package/dist/src/define_config.d.ts +3 -2
  56. package/dist/src/define_config.d.ts.map +1 -1
  57. package/dist/src/define_config.js.map +1 -1
  58. package/dist/src/engine.d.ts +51 -1
  59. package/dist/src/engine.d.ts.map +1 -1
  60. package/dist/src/engine.js +213 -27
  61. package/dist/src/engine.js.map +1 -1
  62. package/dist/src/errors.d.ts +6 -1
  63. package/dist/src/errors.d.ts.map +1 -1
  64. package/dist/src/errors.js +7 -2
  65. package/dist/src/errors.js.map +1 -1
  66. package/dist/src/event-accumulators.d.ts +1 -1
  67. package/dist/src/event-accumulators.d.ts.map +1 -1
  68. package/dist/src/events.d.ts +16 -0
  69. package/dist/src/events.d.ts.map +1 -1
  70. package/dist/src/events.js +26 -1
  71. package/dist/src/events.js.map +1 -1
  72. package/dist/src/hooks/workflows.d.ts +3 -2
  73. package/dist/src/hooks/workflows.d.ts.map +1 -1
  74. package/dist/src/hooks/workflows.js +3 -2
  75. package/dist/src/hooks/workflows.js.map +1 -1
  76. package/dist/src/index.d.ts +3 -0
  77. package/dist/src/index.d.ts.map +1 -1
  78. package/dist/src/index.js +3 -0
  79. package/dist/src/index.js.map +1 -1
  80. package/dist/src/interfaces.d.ts +44 -1
  81. package/dist/src/interfaces.d.ts.map +1 -1
  82. package/dist/src/services/main.d.ts +13 -0
  83. package/dist/src/services/main.d.ts.map +1 -0
  84. package/dist/src/services/main.js +17 -0
  85. package/dist/src/services/main.js.map +1 -0
  86. package/dist/src/step-name-symbol.d.ts +2 -2
  87. package/dist/src/step-name-symbol.js +2 -2
  88. package/dist/src/stores/lucid-schema.d.ts +1 -0
  89. package/dist/src/stores/lucid-schema.d.ts.map +1 -1
  90. package/dist/src/stores/lucid-schema.js +15 -0
  91. package/dist/src/stores/lucid-schema.js.map +1 -1
  92. package/dist/src/stores/lucid.d.ts +13 -0
  93. package/dist/src/stores/lucid.d.ts.map +1 -1
  94. package/dist/src/stores/lucid.js +43 -0
  95. package/dist/src/stores/lucid.js.map +1 -1
  96. package/dist/src/testing/in-memory-state-store.d.ts +16 -0
  97. package/dist/src/testing/in-memory-state-store.d.ts.map +1 -1
  98. package/dist/src/testing/in-memory-state-store.js +29 -0
  99. package/dist/src/testing/in-memory-state-store.js.map +1 -1
  100. package/dist/src/testing-kit/state-store-conformance.d.ts.map +1 -1
  101. package/dist/src/testing-kit/state-store-conformance.js +31 -0
  102. package/dist/src/testing-kit/state-store-conformance.js.map +1 -1
  103. package/dist/src/workflow-als.d.ts +21 -0
  104. package/dist/src/workflow-als.d.ts.map +1 -0
  105. package/dist/src/workflow-als.js +22 -0
  106. package/dist/src/workflow-als.js.map +1 -0
  107. package/dist/src/workflow-ctx.d.ts.map +1 -1
  108. package/dist/src/workflow-ctx.js +83 -4
  109. package/dist/src/workflow-ctx.js.map +1 -1
  110. package/dist/src/workflow-discovery.d.ts +21 -15
  111. package/dist/src/workflow-discovery.d.ts.map +1 -1
  112. package/dist/src/workflow-discovery.js +17 -13
  113. package/dist/src/workflow-discovery.js.map +1 -1
  114. package/dist/src/workflow-ref.d.ts +9 -27
  115. package/dist/src/workflow-ref.d.ts.map +1 -1
  116. package/dist/src/workflow-ref.js +12 -34
  117. package/dist/src/workflow-ref.js.map +1 -1
  118. package/dist/stubs/database/migrations/create_durable_tables.stub +13 -1
  119. package/dist/stubs/make/workflow/main.stub +4 -3
  120. package/package.json +6 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,86 @@
1
1
  # @adonis-agora/durable
2
2
 
3
+ ## 0.8.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#8](https://github.com/DavideCarvalho/adonis-durable/pull/8) [`9e3d803`](https://github.com/DavideCarvalho/adonis-durable/commit/9e3d803258986ffe27f9136bce5200f0d6bbdf00) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Fix DashboardProvider crashing every entrypoint on boot
8
+
9
+ `DashboardProvider#boot()` resolved the router while the container was still
10
+ booting, so `router` came back `undefined` and every entrypoint — `node ace`
11
+ included — died before reaching user code. Any app that registered the
12
+ provider could not boot at all.
13
+
14
+ The router is now resolved inside `app.booted()`, once the container can
15
+ actually hand it over.
16
+
17
+ Shipped in [#7](https://github.com/DavideCarvalho/adonis-durable/issues/7) without a changeset, so the fix sat on master unreleased; this
18
+ changeset carries it to npm.
19
+
20
+ ## 0.8.0
21
+
22
+ ### Minor Changes
23
+
24
+ - [`86819e0`](https://github.com/DavideCarvalho/adonis-durable/commit/86819e08666a307046e8845a7d9b9ed3685d7c53) - BaseWorkflow is the sole authoring form; `services/main`; dashboard login; signal/child/subscriber fixes
25
+
26
+ **BREAKING — the `@Workflow` decorator is removed.** Author workflows with a
27
+ `BaseWorkflow` subclass plus `static workflow = { name, version }`:
28
+
29
+ ```ts
30
+ // before
31
+ @Workflow({ name: "charge", version: "1" })
32
+ class ChargeWorkflow {
33
+ async run(ctx: WorkflowCtx, input: Input) {}
34
+ }
35
+
36
+ // after
37
+ export default class ChargeWorkflow extends BaseWorkflow {
38
+ static workflow = { name: "charge", version: "1" };
39
+ async run(ctx: WorkflowCtx, input: Input) {}
40
+ }
41
+ ```
42
+
43
+ `workflowMeta()` now reads only the `static workflow` config; normalization is
44
+ unchanged (version defaults to `'1'`). One authoring form means one thing to
45
+ document, one thing to discover, and no decorator/metadata runtime.
46
+
47
+ **Features**
48
+
49
+ - `BaseWorkflow` with context-aware static `start`/`dispatch`. Call
50
+ `ChargeWorkflow.start(input)` and it does the right thing by context: outside a
51
+ workflow it enqueues on the engine and blocks until the run reaches a terminal
52
+ state; inside one it starts a linked child and suspends the parent. `.dispatch`
53
+ is the fire-and-forget twin, returning `{ runId }` without waiting.
54
+ - `@adonis-agora/durable/services/main` — an idiomatic singleton import, so app
55
+ code reaches the engine the way it reaches any other Adonis service.
56
+ - Control-flow signal marker plus `isWorkflowControlFlowSignal`, so a workflow
57
+ can tell a control-flow signal apart from a domain one.
58
+ - Buffered events are now reliable: an event delivered before its waiter exists is
59
+ no longer lost.
60
+ - Dashboard built-in login screen via `dashboardAuth`.
61
+
62
+ **Fixes**
63
+
64
+ - Closed a lost-wake race in the signal waiter, and added the
65
+ `removeSignalWaiter` SPI so a waiter can be torn down deterministically.
66
+ - A child that fails to _start_ now surfaces the failure to the parent instead of
67
+ stranding it. The parent used to wait forever on a child that never existed:
68
+ the start was fire-and-forget, so nothing ever notified the parent. The child
69
+ start is now deferred and its rejection is reported to the parent as a failed
70
+ child result.
71
+ - The Redis control plane now heals a silently-dead subscriber connection. A
72
+ subscriber whose socket died without an error event stopped delivering messages
73
+ while still looking healthy, and every wake-up routed through it was lost. A
74
+ ping watchdog now detects the dead connection and forces a reconnect.
75
+ - `BaseWorkflow.start` waits for terminal (matching the linked-child path), the
76
+ steps hook is configurable, and the dashboard token comparison is
77
+ constant-time.
78
+
79
+ **eslint-plugin** — `no-nondeterminism` identifies a workflow's `run` body by the
80
+ new authoring form (a `BaseWorkflow` subclass, or any class with a
81
+ `static workflow` config) instead of the removed `@Workflow` decorator. Without
82
+ this the rule would silently stop guarding every workflow in a 0.8 codebase.
83
+
3
84
  ## 0.6.1
4
85
 
5
86
  ### Patch Changes
package/README.md CHANGED
@@ -53,7 +53,7 @@ export default defineConfig({
53
53
  `node ace configure` registers an AdonisJS **Assembler `init` hook** that generates
54
54
  a typed barrel of `app/workflows/` at build/dev time — exactly how core generates
55
55
  the controllers/events/listeners barrels. The provider imports the generated
56
- `.adonisjs/durable/workflows.ts` at boot and registers every `@Workflow` class,
56
+ `.adonisjs/durable/workflows.ts` at boot and registers every `BaseWorkflow` class,
57
57
  instead of scanning the directory with `readdir` at runtime. The file watcher
58
58
  regenerates the barrel whenever a workflow file changes.
59
59
 
@@ -6,8 +6,9 @@ import DurableWork from './work.js';
6
6
  /**
7
7
  * The commands barrel for `@adonis-agora/durable`. Registered in an app's `adonisrc` via
8
8
  * `rcFile.addCommand('@adonis-agora/durable/commands')` (done by this package's `configure`). The ace
9
- * kernel imports this module and treats it as a commands loader: a {@link ListLoader} over the three
10
- * durable commands provides their metadata and constructors.
9
+ * kernel imports this module and treats it as a commands loader: a {@link ListLoader} over the four
10
+ * durable commands (`durable:work`, `durable:runs`, `durable:retry`, `make:workflow`) provides their
11
+ * metadata and constructors.
11
12
  */
12
13
  declare const loader: ListLoader<typeof MakeWorkflow | typeof DurableRetry | typeof DurableRuns | typeof DurableWork>;
13
14
  export declare const getMetaData: () => Promise<import("@adonisjs/core/types/ace").CommandMetaData[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../commands/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,YAAY,MAAM,YAAY,CAAC;AACtC,OAAO,WAAW,MAAM,WAAW,CAAC;AACpC,OAAO,WAAW,MAAM,WAAW,CAAC;AAEpC;;;;;GAKG;AACH,QAAA,MAAM,MAAM,iGAAyE,CAAC;AAEtF,eAAO,MAAM,WAAW,qEAAkC,CAAC;AAC3D,eAAO,MAAM,UAAU,uKAAiC,CAAC;AAEzD,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../commands/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,YAAY,MAAM,YAAY,CAAC;AACtC,OAAO,WAAW,MAAM,WAAW,CAAC;AACpC,OAAO,WAAW,MAAM,WAAW,CAAC;AAEpC;;;;;;GAMG;AACH,QAAA,MAAM,MAAM,iGAAyE,CAAC;AAEtF,eAAO,MAAM,WAAW,qEAAkC,CAAC;AAC3D,eAAO,MAAM,UAAU,uKAAiC,CAAC;AAEzD,eAAe,MAAM,CAAC"}
@@ -6,8 +6,9 @@ import DurableWork from './work.js';
6
6
  /**
7
7
  * The commands barrel for `@adonis-agora/durable`. Registered in an app's `adonisrc` via
8
8
  * `rcFile.addCommand('@adonis-agora/durable/commands')` (done by this package's `configure`). The ace
9
- * kernel imports this module and treats it as a commands loader: a {@link ListLoader} over the three
10
- * durable commands provides their metadata and constructors.
9
+ * kernel imports this module and treats it as a commands loader: a {@link ListLoader} over the four
10
+ * durable commands (`durable:work`, `durable:runs`, `durable:retry`, `make:workflow`) provides their
11
+ * metadata and constructors.
11
12
  */
12
13
  const loader = new ListLoader([DurableWork, DurableRuns, DurableRetry, MakeWorkflow]);
13
14
  export const getMetaData = loader.getMetaData.bind(loader);
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../../commands/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,YAAY,MAAM,YAAY,CAAC;AACtC,OAAO,WAAW,MAAM,WAAW,CAAC;AACpC,OAAO,WAAW,MAAM,WAAW,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC;AAEtF,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAEzD,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../commands/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,YAAY,MAAM,YAAY,CAAC;AACtC,OAAO,WAAW,MAAM,WAAW,CAAC;AACpC,OAAO,WAAW,MAAM,WAAW,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC;AAEtF,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAEzD,eAAe,MAAM,CAAC"}
@@ -2,9 +2,10 @@ import { BaseCommand } from '@adonisjs/core/ace';
2
2
  import type { CommandOptions } from '@adonisjs/core/types/ace';
3
3
  /**
4
4
  * `node ace make:workflow <name>` — scaffold a durable workflow class under `app/workflows/`, the
5
- * parallel to `@adonisjs/queue`'s `make:job` (which scaffolds `app/jobs/`). The generated class is
6
- * `@Workflow`-decorated with a `run(ctx, input)` method and is auto-registered on the engine at boot
7
- * by the durable provider no manual `engine.register(...)`.
5
+ * parallel to `@adonisjs/queue`'s `make:job` (which scaffolds `app/jobs/`). The generated class
6
+ * extends `BaseWorkflow` (the blessed authoring form) with a `static workflow = { name, version }`
7
+ * identity and a `run(ctx, input)` method, and is auto-registered on the engine at boot by the
8
+ * durable provider — no manual `engine.register(...)`.
8
9
  */
9
10
  export default class MakeWorkflow extends BaseCommand {
10
11
  static commandName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"make_workflow.d.ts","sourceRoot":"","sources":["../../commands/make_workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAQ,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG/D;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,WAAW;IACnD,OAAgB,WAAW,SAAmB;IAC9C,OAAgB,WAAW,SAAyC;IACpE,OAAgB,OAAO,EAAE,cAAc,CAA+B;IAG9D,IAAI,EAAE,MAAM,CAAC;IAEN,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAOpC"}
1
+ {"version":3,"file":"make_workflow.d.ts","sourceRoot":"","sources":["../../commands/make_workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAQ,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG/D;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,WAAW;IACnD,OAAgB,WAAW,SAAmB;IAC9C,OAAgB,WAAW,SAAyC;IACpE,OAAgB,OAAO,EAAE,cAAc,CAA+B;IAG9D,IAAI,EAAE,MAAM,CAAC;IAEN,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAOpC"}
@@ -8,9 +8,10 @@ import { BaseCommand, args } from '@adonisjs/core/ace';
8
8
  import { stubsRoot } from '../stubs/main.js';
9
9
  /**
10
10
  * `node ace make:workflow <name>` — scaffold a durable workflow class under `app/workflows/`, the
11
- * parallel to `@adonisjs/queue`'s `make:job` (which scaffolds `app/jobs/`). The generated class is
12
- * `@Workflow`-decorated with a `run(ctx, input)` method and is auto-registered on the engine at boot
13
- * by the durable provider no manual `engine.register(...)`.
11
+ * parallel to `@adonisjs/queue`'s `make:job` (which scaffolds `app/jobs/`). The generated class
12
+ * extends `BaseWorkflow` (the blessed authoring form) with a `static workflow = { name, version }`
13
+ * identity and a `run(ctx, input)` method, and is auto-registered on the engine at boot by the
14
+ * durable provider — no manual `engine.register(...)`.
14
15
  */
15
16
  export default class MakeWorkflow extends BaseCommand {
16
17
  static commandName = 'make:workflow';
@@ -1 +1 @@
1
- {"version":3,"file":"make_workflow.js","sourceRoot":"","sources":["../../commands/make_workflow.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,WAAW;IACnD,MAAM,CAAU,WAAW,GAAG,eAAe,CAAC;IAC9C,MAAM,CAAU,WAAW,GAAG,qCAAqC,CAAC;IACpE,MAAM,CAAU,OAAO,GAAmB,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC;IAK7D,KAAK,CAAC,GAAG;QAChB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC7C,MAAM,QAAQ,CAAC,aAAa,CAAC,SAAS,EAAE,yBAAyB,EAAE;YACjE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;YACxB,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;SACpD,CAAC,CAAC;IACL,CAAC;;AARO;IADP,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;0CAChC"}
1
+ {"version":3,"file":"make_workflow.js","sourceRoot":"","sources":["../../commands/make_workflow.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,WAAW;IACnD,MAAM,CAAU,WAAW,GAAG,eAAe,CAAC;IAC9C,MAAM,CAAU,WAAW,GAAG,qCAAqC,CAAC;IACpE,MAAM,CAAU,OAAO,GAAmB,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC;IAK7D,KAAK,CAAC,GAAG;QAChB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC7C,MAAM,QAAQ,CAAC,aAAa,CAAC,SAAS,EAAE,yBAAyB,EAAE;YACjE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;YACxB,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;SACpD,CAAC,CAAC;IACL,CAAC;;AARO;IADP,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;0CAChC"}
@@ -3,12 +3,13 @@ import type Configure from '@adonisjs/core/commands/configure';
3
3
  * `node ace configure @adonis-agora/durable` — auto-wires the package:
4
4
  *
5
5
  * 1. registers the core service provider in `adonisrc.ts`;
6
- * 2. registers the ace commands barrel (`durable:work`, `durable:runs`,
7
- * `durable:retry`);
6
+ * 2. registers the ace commands barrel (four commands: `durable:work`,
7
+ * `durable:runs`, `durable:retry`, `make:workflow`);
8
8
  * 3. registers the optional dashboard provider;
9
- * 4. registers the Assembler `init` hook that generates the typed `app/workflows`
10
- * barrel at build/dev time (the provider imports it instead of scanning at
11
- * runtime; it falls back to the runtime scan when the barrel is absent);
9
+ * 4. registers the Assembler `init` hooks that generate the typed `app/workflows`
10
+ * and `app/steps` barrels at build/dev time (the provider imports them instead
11
+ * of scanning at runtime; each falls back to the runtime scan when its barrel
12
+ * is absent);
12
13
  * 5. publishes `config/durable.ts` + `config/durable_dashboard.ts`;
13
14
  * 6. publishes the Lucid migrations for the optional `lucid` store and `db`
14
15
  * transport drivers (run `node ace migration:run`, and delete the transport
@@ -1 +1 @@
1
- {"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../configure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,mCAAmC,CAAC;AAG/D;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,SAAS,iBAmBjD"}
1
+ {"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../configure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,mCAAmC,CAAC;AAG/D;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,SAAS,iBAqBjD"}
package/dist/configure.js CHANGED
@@ -3,12 +3,13 @@ import { stubsRoot } from './stubs/main.js';
3
3
  * `node ace configure @adonis-agora/durable` — auto-wires the package:
4
4
  *
5
5
  * 1. registers the core service provider in `adonisrc.ts`;
6
- * 2. registers the ace commands barrel (`durable:work`, `durable:runs`,
7
- * `durable:retry`);
6
+ * 2. registers the ace commands barrel (four commands: `durable:work`,
7
+ * `durable:runs`, `durable:retry`, `make:workflow`);
8
8
  * 3. registers the optional dashboard provider;
9
- * 4. registers the Assembler `init` hook that generates the typed `app/workflows`
10
- * barrel at build/dev time (the provider imports it instead of scanning at
11
- * runtime; it falls back to the runtime scan when the barrel is absent);
9
+ * 4. registers the Assembler `init` hooks that generate the typed `app/workflows`
10
+ * and `app/steps` barrels at build/dev time (the provider imports them instead
11
+ * of scanning at runtime; each falls back to the runtime scan when its barrel
12
+ * is absent);
12
13
  * 5. publishes `config/durable.ts` + `config/durable_dashboard.ts`;
13
14
  * 6. publishes the Lucid migrations for the optional `lucid` store and `db`
14
15
  * transport drivers (run `node ace migration:run`, and delete the transport
@@ -20,8 +21,10 @@ export async function configure(command) {
20
21
  rcFile.addProvider('@adonis-agora/durable/durable_provider');
21
22
  rcFile.addProvider('@adonis-agora/durable/dashboard_provider');
22
23
  rcFile.addCommand('@adonis-agora/durable/commands');
23
- // Generate the typed app/workflows barrel at build/dev time (replaces the runtime readdir scan).
24
+ // Generate the typed app/workflows + app/steps barrels at build/dev time (each replaces its
25
+ // runtime readdir scan; the provider falls back to the scan when a barrel is absent).
24
26
  rcFile.addAssemblerHook('init', '@adonis-agora/durable/hooks/workflows');
27
+ rcFile.addAssemblerHook('init', '@adonis-agora/durable/hooks/steps');
25
28
  });
26
29
  await codemods.makeUsingStub(stubsRoot, 'config/durable.stub', {});
27
30
  await codemods.makeUsingStub(stubsRoot, 'config/durable_dashboard.stub', {});
@@ -1 +1 @@
1
- {"version":3,"file":"configure.js","sourceRoot":"","sources":["../configure.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAkB;IAChD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,cAAc,EAAE,CAAC;IAEhD,MAAM,QAAQ,CAAC,YAAY,CAAC,CAAC,MAAM,EAAE,EAAE;QACrC,MAAM,CAAC,WAAW,CAAC,wCAAwC,CAAC,CAAC;QAC7D,MAAM,CAAC,WAAW,CAAC,0CAA0C,CAAC,CAAC;QAC/D,MAAM,CAAC,UAAU,CAAC,gCAAgC,CAAC,CAAC;QACpD,iGAAiG;QACjG,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,uCAAuC,CAAC,CAAC;IAC3E,CAAC,CAAC,CAAC;IAEH,MAAM,QAAQ,CAAC,aAAa,CAAC,SAAS,EAAE,qBAAqB,EAAE,EAAE,CAAC,CAAC;IACnE,MAAM,QAAQ,CAAC,a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@ -16,12 +16,43 @@ import type { ApplicationService } from '@adonisjs/core/types';
16
16
  export default class DashboardProvider {
17
17
  protected app: ApplicationService;
18
18
  constructor(app: ApplicationService);
19
+ /** Warn once so a throwing `login` hook doesn't spam the logs on every failed attempt. */
20
+ private warnedOnHookThrow;
19
21
  boot(): Promise<void>;
20
22
  private registerRoutes;
21
23
  /**
22
- * Run the configured guard. On denial, replies `403` and returns `false` so
23
- * the route handler short-circuits.
24
+ * Mount the built-in `dashboardAuth` endpoints under `basePath`. All three are public (no guard):
25
+ * they create/destroy the session the {@link enforce} guard checks for.
26
+ *
27
+ * - `GET <base>/login` → the server-rendered login page (never varies per request beyond the
28
+ * developer-controlled `basePath`; `returnTo`/`error` are read client-side from the query).
29
+ * - `POST <base>/login` → verifies credentials via the host `login` hook and mints the cookie.
30
+ * Called by the login page's own `fetch` (JSON body). Uniform `401` on ANY failure — unknown
31
+ * user, wrong password, or a throwing hook — so there is no user-enumeration.
32
+ * - `GET <base>/logout` → clears the cookie and redirects back to the login page. A plain `GET`
33
+ * (idempotent, only ever destroys the caller's own session) so a simple `<a href>` works.
24
34
  */
25
- private guard;
35
+ private registerAuthRoutes;
36
+ /**
37
+ * Run the guards for a dashboard resource. Composes the existing `authorize` hook (bearer
38
+ * token/custom) with the optional `dashboardAuth` session guard — BOTH must pass:
39
+ *
40
+ * 1. `authorize` fails → `403` (unchanged behavior).
41
+ * 2. `dashboardAuth` configured AND no valid session → for a `page` request, redirect `302` to
42
+ * the login page carrying a sanitized `returnTo`; for an `api` request, a plain `401`.
43
+ *
44
+ * When `dashboardAuth` is unconfigured only step 1 runs, so behavior is byte-for-byte unchanged.
45
+ * Returns `false` (and has already written the response) when the request must short-circuit.
46
+ */
47
+ private enforce;
48
+ /** Read the raw (unencoded) session cookie value, or `undefined` when absent. */
49
+ private readSessionCookie;
50
+ /**
51
+ * Write the signed session as an unsigned (`plainCookie`, `encode: false`) cookie — the value
52
+ * carries its own HMAC signature, so AdonisJS's cookie signing would be redundant double-wrapping.
53
+ * `HttpOnly` + `SameSite=Lax` (blocks cross-site POSTs carrying the cookie — CSRF coverage) +
54
+ * `Secure` on https. `Path=/` so it reaches both the UI and API mounts regardless of prefix.
55
+ */
56
+ private writeSessionCookie;
26
57
  }
27
58
  //# sourceMappingURL=dashboard_provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dashboard_provider.d.ts","sourceRoot":"","sources":["../../providers/dashboard_provider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAmB/D;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACxB,SAAS,CAAC,GAAG,EAAE,kBAAkB;gBAAvB,GAAG,EAAE,kBAAkB;IAEvC,IAAI;IASV,OAAO,CAAC,cAAc;IA+CtB;;;OAGG;YACW,KAAK;CAQpB"}
1
+ {"version":3,"file":"dashboard_provider.d.ts","sourceRoot":"","sources":["../../providers/dashboard_provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAqB,MAAM,sBAAsB,CAAC;AA0BlF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACxB,SAAS,CAAC,GAAG,EAAE,kBAAkB;gBAAvB,GAAG,EAAE,kBAAkB;IAE7C,0FAA0F;IAC1F,OAAO,CAAC,iBAAiB,CAAS;IAE5B,IAAI;IA2BV,OAAO,CAAC,cAAc;IAwDtB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,kBAAkB;IAiD1B;;;;;;;;;;OAUG;YACW,OAAO;IA0BrB,iFAAiF;IACjF,OAAO,CAAC,iBAAiB;IAKzB;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;CAU3B"}
@@ -1,7 +1,8 @@
1
- import router from '@adonisjs/core/services/router';
1
+ import { SESSION_COOKIE_NAME, performLogin, readSession, } from '../src/dashboard/auth.js';
2
2
  import { resolveConfig, } from '../src/dashboard/define_config.js';
3
3
  import { cancelRun, getRun, health, listRuns, retryRun, } from '../src/dashboard/handlers.js';
4
4
  import { renderDashboard } from '../src/dashboard/html.js';
5
+ import { renderLoginPage } from '../src/dashboard/login_page.js';
5
6
  import { WorkflowEngine } from '../src/index.js';
6
7
  /**
7
8
  * Mounts the durable dashboard into an AdonisJS app: a JSON API over the
@@ -22,13 +23,33 @@ export default class DashboardProvider {
22
23
  constructor(app) {
23
24
  this.app = app;
24
25
  }
26
+ /** Warn once so a throwing `login` hook doesn't spam the logs on every failed attempt. */
27
+ warnedOnHookThrow = false;
25
28
  async boot() {
26
29
  const config = resolveConfig(this.app.config.get('durable_dashboard', {}));
27
30
  if (!config.enabled)
28
31
  return;
29
- this.registerRoutes(config);
32
+ // Route registration can't happen synchronously in `boot()`: at this point in the AdonisJS
33
+ // lifecycle the HTTP server/router binding may not be resolvable yet (bindings from other
34
+ // providers' `boot()` methods can still be pending), and — critically — the *documented*
35
+ // `@adonisjs/core/services/router` singleton is only assigned once the app's "booted" hooks run
36
+ // (`await app.booted(async () => { router = ... })` inside that service module itself), which
37
+ // fire strictly AFTER every provider's own `boot()`. A provider that imports that singleton and
38
+ // calls `router.get(...)` directly inside `boot()` crashes every entrypoint (serve/ace/tests)
39
+ // that registers it, because `router` is still `undefined` at that point.
40
+ //
41
+ // Deferring to `app.booted(...)` runs our route registration as another "booted" hook — the
42
+ // same mechanism the router service uses to become available in the first place — which is
43
+ // guaranteed to fire BEFORE `app.start()`'s callback boots the HTTP server and commits the
44
+ // router (the last point at which routes can still be added). Resolving `router` fresh from the
45
+ // container here (rather than depending on that service singleton) is also the same pattern
46
+ // `@adonisjs/core`'s own `AppServiceProvider` uses internally.
47
+ await this.app.booted(async () => {
48
+ const router = await this.app.container.make('router');
49
+ this.registerRoutes(router, config);
50
+ });
30
51
  }
31
- registerRoutes(config) {
52
+ registerRoutes(router, config) {
32
53
  const apiBase = `${config.path}/api`;
33
54
  // Resolve the engine lazily per request: the singleton is built by
34
55
  // @adonis-agora/durable's provider, and runs/checkpoints are read through its own
@@ -37,10 +58,18 @@ export default class DashboardProvider {
37
58
  const engine = await this.app.container.make(WorkflowEngine);
38
59
  return { engine };
39
60
  };
61
+ // Built-in `dashboardAuth` login screen (opt-in). Registered ONLY when configured, so omitting
62
+ // `dashboardAuth` leaves route registration byte-for-byte as it was. These endpoints are public
63
+ // (behind NEITHER guard): they MINT the session the guard checks for, and the login page must
64
+ // stay reachable while unauthenticated — including in production, where the default `authorize`
65
+ // hook would otherwise deny it.
66
+ if (config.dashboardAuth) {
67
+ this.registerAuthRoutes(router, config, config.dashboardAuth);
68
+ }
40
69
  // The HTML page.
41
70
  router
42
71
  .get(config.path === '' ? '/' : config.path, async (ctx) => {
43
- if (!(await this.guard(config, ctx)))
72
+ if (!(await this.enforce(config, ctx, 'page')))
44
73
  return;
45
74
  ctx.response.header('content-type', 'text/html; charset=utf-8');
46
75
  return ctx.response.send(renderDashboard(apiBase));
@@ -49,7 +78,7 @@ export default class DashboardProvider {
49
78
  // JSON API.
50
79
  const json = (handler) => {
51
80
  return async (ctx) => {
52
- if (!(await this.guard(config, ctx)))
81
+ if (!(await this.enforce(config, ctx, 'api')))
53
82
  return;
54
83
  try {
55
84
  const result = await handler(await deps(), toApiRequest(ctx));
@@ -71,16 +100,108 @@ export default class DashboardProvider {
71
100
  .as('durable_dashboard.health');
72
101
  }
73
102
  /**
74
- * Run the configured guard. On denial, replies `403` and returns `false` so
75
- * the route handler short-circuits.
103
+ * Mount the built-in `dashboardAuth` endpoints under `basePath`. All three are public (no guard):
104
+ * they create/destroy the session the {@link enforce} guard checks for.
105
+ *
106
+ * - `GET <base>/login` → the server-rendered login page (never varies per request beyond the
107
+ * developer-controlled `basePath`; `returnTo`/`error` are read client-side from the query).
108
+ * - `POST <base>/login` → verifies credentials via the host `login` hook and mints the cookie.
109
+ * Called by the login page's own `fetch` (JSON body). Uniform `401` on ANY failure — unknown
110
+ * user, wrong password, or a throwing hook — so there is no user-enumeration.
111
+ * - `GET <base>/logout` → clears the cookie and redirects back to the login page. A plain `GET`
112
+ * (idempotent, only ever destroys the caller's own session) so a simple `<a href>` works.
113
+ */
114
+ registerAuthRoutes(router, config, auth) {
115
+ const loginPath = `${config.path}/login`;
116
+ const logoutPath = `${config.path}/logout`;
117
+ router
118
+ .get(loginPath, async (ctx) => {
119
+ ctx.response.header('content-type', 'text/html; charset=utf-8');
120
+ ctx.response.header('cache-control', 'no-store, must-revalidate');
121
+ return ctx.response.send(renderLoginPage(config.path));
122
+ })
123
+ .as('durable_dashboard.login.page');
124
+ router
125
+ .post(loginPath, async (ctx) => {
126
+ const outcome = await performLogin(auth, ctx.request.body(), config.path);
127
+ if (outcome.kind === 'bad-request') {
128
+ return ctx.response.status(400).json({ error: outcome.message });
129
+ }
130
+ if (outcome.kind === 'unauthorized') {
131
+ // A throwing hook is a denial (never a 500), warn-logged once so a buggy hook doesn't
132
+ // flood the logs. The client sees the same uniform 401 either way.
133
+ if (outcome.hookError !== undefined && !this.warnedOnHookThrow) {
134
+ this.warnedOnHookThrow = true;
135
+ const message = outcome.hookError instanceof Error
136
+ ? outcome.hookError.message
137
+ : String(outcome.hookError);
138
+ const logger = await this.app.container.make('logger');
139
+ logger.warn(`dashboardAuth login hook threw; treating as denial. ${message}`);
140
+ }
141
+ return ctx.response.status(401).json({ error: outcome.message });
142
+ }
143
+ this.writeSessionCookie(ctx, auth, outcome.cookieValue);
144
+ return ctx.response.status(200).json({ redirectTo: outcome.redirectTo });
145
+ })
146
+ .as('durable_dashboard.login.submit');
147
+ router
148
+ .get(logoutPath, async (ctx) => {
149
+ ctx.response.clearCookie(SESSION_COOKIE_NAME, { path: '/' });
150
+ return ctx.response.redirect().toPath(loginPath);
151
+ })
152
+ .as('durable_dashboard.logout');
153
+ }
154
+ /**
155
+ * Run the guards for a dashboard resource. Composes the existing `authorize` hook (bearer
156
+ * token/custom) with the optional `dashboardAuth` session guard — BOTH must pass:
157
+ *
158
+ * 1. `authorize` fails → `403` (unchanged behavior).
159
+ * 2. `dashboardAuth` configured AND no valid session → for a `page` request, redirect `302` to
160
+ * the login page carrying a sanitized `returnTo`; for an `api` request, a plain `401`.
161
+ *
162
+ * When `dashboardAuth` is unconfigured only step 1 runs, so behavior is byte-for-byte unchanged.
163
+ * Returns `false` (and has already written the response) when the request must short-circuit.
76
164
  */
77
- async guard(config, ctx) {
165
+ async enforce(config, ctx, mode) {
78
166
  const allowed = await config.authorize(ctx);
79
167
  if (!allowed) {
80
168
  ctx.response.status(403).json({ error: 'forbidden' });
81
169
  return false;
82
170
  }
83
- return true;
171
+ const auth = config.dashboardAuth;
172
+ if (!auth)
173
+ return true;
174
+ const session = readSession(auth, this.readSessionCookie(ctx));
175
+ if (session)
176
+ return true;
177
+ if (mode === 'page') {
178
+ const returnTo = ctx.request.url(true);
179
+ ctx.response.redirect().withQs('returnTo', returnTo).toPath(`${config.path}/login`);
180
+ return false;
181
+ }
182
+ ctx.response.status(401).json({ error: 'unauthorized' });
183
+ return false;
184
+ }
185
+ /** Read the raw (unencoded) session cookie value, or `undefined` when absent. */
186
+ readSessionCookie(ctx) {
187
+ const value = ctx.request.plainCookie(SESSION_COOKIE_NAME, undefined, false);
188
+ return typeof value === 'string' && value !== '' ? value : undefined;
189
+ }
190
+ /**
191
+ * Write the signed session as an unsigned (`plainCookie`, `encode: false`) cookie — the value
192
+ * carries its own HMAC signature, so AdonisJS's cookie signing would be redundant double-wrapping.
193
+ * `HttpOnly` + `SameSite=Lax` (blocks cross-site POSTs carrying the cookie — CSRF coverage) +
194
+ * `Secure` on https. `Path=/` so it reaches both the UI and API mounts regardless of prefix.
195
+ */
196
+ writeSessionCookie(ctx, auth, value) {
197
+ ctx.response.plainCookie(SESSION_COOKIE_NAME, value, {
198
+ httpOnly: true,
199
+ sameSite: 'lax',
200
+ secure: ctx.request.secure(),
201
+ path: '/',
202
+ maxAge: Math.floor(auth.ttlMs / 1000),
203
+ encode: false,
204
+ });
84
205
  }
85
206
  }
86
207
  /** Adapt an AdonisJS `HttpContext` to the framework-light {@link ApiRequest}. */
@@ -1 +1 @@
1
- {"version":3,"file":"dashboard_provider.js","sourceRoot":"","sources":["../../providers/dashboard_provider.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,gCAAgC,CAAC;AAEpD,OAAO,EAGL,aAAa,GACd,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAIL,SAAS,EACT,MAAM,EACN,MAAM,EACN,QAAQ,EACR,QAAQ,GACT,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACd;IAAtB,YAAsB,GAAuB;QAAvB,QAAG,GAAH,GAAG,CAAoB;IAAG,CAAC;IAEjD,KAAK,CAAC,IAAI;QACR,MAAM,MAAM,GAAG,aAAa,CAC1B,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAyB,mBAAmB,EAAE,EAAE,CAAC,CACrE,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,OAAO;YAAE,OAAO;QAE5B,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAEO,cAAc,CAAC,MAAsC;QAC3D,MAAM,OAAO,GAAG,GAAG,MAAM,CAAC,IAAI,MAAM,CAAC;QAErC,mEAAmE;QACnE,kFAAkF;QAClF,8EAA8E;QAC9E,MAAM,IAAI,GAAG,KAAK,IAAmB,EAAE;YACrC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAC7D,OAAO,EAAE,MAAM,EAAE,CAAC;QACpB,CAAC,CAAC;QAEF,iBAAiB;QACjB,MAAM;aACH,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,G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AA2B,EAAE,KAAa;QACrF,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,mBAAmB,EAAE,KAAK,EAAE;YACnD,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,KAAK;YACf,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE;YAC5B,IAAI,EAAE,GAAG;YACT,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;YACrC,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;IACL,CAAC;CACF;AAED,iFAAiF;AACjF,SAAS,YAAY,CAAC,GAAgB;IACpC,OAAO;QACL,MAAM,EAAE,GAAG,CAAC,MAA4C;QACxD,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,EAAE,EAAmD;QACxE,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE;KACzB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,78 @@
1
+ import { WorkflowEngine } from './engine.js';
2
+ import type { StartOptions } from './engine.js';
3
+ import type { WorkflowCtx } from './interfaces.js';
4
+ import type { WorkflowClass, WorkflowInputOf, WorkflowOptions, WorkflowOutputOf } from './workflow-ref.js';
5
+ /**
6
+ * Options for `BaseWorkflow`'s static `start`/`dispatch`. A superset of {@link StartOptions} (priority,
7
+ * namespace, tags, searchAttributes) plus an explicit `runId`:
8
+ * - **Outside** a running workflow, `runId` sets the new run's id; omitted → a fresh `randomUUID()`.
9
+ * - **Inside** a running workflow, `runId` is the deterministic child id; omitted → the ctx derives a
10
+ * replay-stable id from the call position (DO NOT pass a random one — it breaks determinism).
11
+ */
12
+ export type WorkflowDispatchOptions = {
13
+ runId?: string | undefined;
14
+ } & StartOptions;
15
+ /**
16
+ * How `BaseWorkflow`'s OUTSIDE static path locates the {@link WorkflowEngine}. Defaults to resolving
17
+ * the engine from the AdonisJS container (a module-singleton locator, exactly how a queue `Job`
18
+ * resolves its manager). Tests (or advanced embeddings) override it with {@link setWorkflowEngineResolver}
19
+ * to inject a specific engine without booting an application.
20
+ */
21
+ export type WorkflowEngineResolver = () => WorkflowEngine | Promise<WorkflowEngine>;
22
+ /**
23
+ * Override how `BaseWorkflow.start`/`dispatch` resolve the engine when called OUTSIDE a running
24
+ * workflow. Pass a resolver returning the engine to use; pass `undefined` to restore the default
25
+ * (container lookup). Primarily a testing seam — inject an in-memory engine, then reset in teardown.
26
+ */
27
+ export declare function setWorkflowEngineResolver(resolver: WorkflowEngineResolver | undefined): void;
28
+ /**
29
+ * Base class for a durable workflow. Declare the workflow's identity as a
30
+ * `static workflow = { name, version }` config and implement `run(ctx, input)`:
31
+ *
32
+ * ```ts
33
+ * export default class CheckoutWorkflow extends BaseWorkflow {
34
+ * static workflow = { name: 'checkout', version: '1' }
35
+ * async run(ctx: WorkflowCtx, order: Order) { … }
36
+ * }
37
+ * ```
38
+ *
39
+ * The static `workflow` config is resolved through `workflowName()` and registered via
40
+ * `app/workflows` auto-discovery.
41
+ *
42
+ * ## Context-aware dispatch
43
+ * The statics behave differently depending on whether they're called inside or outside a running
44
+ * workflow body (detected via the ambient ctx — see {@link getCurrentWorkflowCtx}):
45
+ *
46
+ * | | OUTSIDE (controller/service/script) | INSIDE a running workflow body |
47
+ * |------------|----------------------------------------------------------|---------------------------------------|
48
+ * | `.start` | `engine.start` + `waitForRun` → blocks, returns result | `ctx.child` → linked child, awaits it |
49
+ * | `.dispatch`| `engine.start` → fire-and-forget, returns `{ runId }` | `ctx.startChild` → fire-and-forget |
50
+ *
51
+ * `.start` always means "I want the result"; `.dispatch` always means "fire and forget" — in both
52
+ * contexts. Inside a workflow, routing through `ctx.child`/`ctx.startChild` (never the engine) is what
53
+ * keeps the run deterministic and replay-safe.
54
+ */
55
+ export declare abstract class BaseWorkflow {
56
+ /**
57
+ * The workflow's identity + options. Read by `workflowMeta()`/`workflowName()` and by
58
+ * `app/workflows` auto-discovery. Omit it and the class is not a registrable workflow.
59
+ */
60
+ static workflow?: WorkflowOptions;
61
+ /** The workflow body. `ctx` is the durable context; `input` is the run's typed input. */
62
+ abstract run(ctx: WorkflowCtx, input: unknown): unknown;
63
+ /**
64
+ * Start a run and **wait for its result**. Outside a workflow, enqueues via the engine and blocks
65
+ * until the run settles, returning its output. Inside a running workflow, starts a **linked child**
66
+ * (`ctx.child`) — the parent suspends until the child settles — and returns the child's output.
67
+ */
68
+ static start<C extends WorkflowClass>(this: C, input: WorkflowInputOf<C>, opts?: WorkflowDispatchOptions): Promise<WorkflowOutputOf<C>>;
69
+ /**
70
+ * Start a run **fire-and-forget** and return its `{ runId }` without waiting. Outside a workflow,
71
+ * enqueues via the engine and returns immediately. Inside a running workflow, kicks off a
72
+ * fire-and-forget child (`ctx.startChild`) — the parent keeps running — and returns the child id.
73
+ */
74
+ static dispatch<C extends WorkflowClass>(this: C, input: WorkflowInputOf<C>, opts?: WorkflowDispatchOptions): Promise<{
75
+ runId: string;
76
+ }>;
77
+ }
78
+ //# sourceMappingURL=base-workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-workflow.d.ts","sourceRoot":"","sources":["../../src/base-workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,eAAe,EACf,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAAG,YAAY,CAAC;AAEpF;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAIpF;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EA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