@adonis-agora/durable 0.3.0 → 0.5.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 (51) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +47 -0
  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 +2 -1
  6. package/dist/commands/main.js.map +1 -1
  7. package/dist/commands/make_workflow.d.ts +16 -0
  8. package/dist/commands/make_workflow.d.ts.map +1 -0
  9. package/dist/commands/make_workflow.js +30 -0
  10. package/dist/commands/make_workflow.js.map +1 -0
  11. package/dist/configure.d.ts +5 -2
  12. package/dist/configure.d.ts.map +1 -1
  13. package/dist/configure.js +7 -2
  14. package/dist/configure.js.map +1 -1
  15. package/dist/providers/durable_provider.d.ts +12 -0
  16. package/dist/providers/durable_provider.d.ts.map +1 -1
  17. package/dist/providers/durable_provider.js +50 -2
  18. package/dist/providers/durable_provider.js.map +1 -1
  19. package/dist/src/define_config.d.ts +11 -3
  20. package/dist/src/define_config.d.ts.map +1 -1
  21. package/dist/src/define_config.js.map +1 -1
  22. package/dist/src/hooks/workflows.d.ts +53 -0
  23. package/dist/src/hooks/workflows.d.ts.map +1 -0
  24. package/dist/src/hooks/workflows.js +55 -0
  25. package/dist/src/hooks/workflows.js.map +1 -0
  26. package/dist/src/index.d.ts +3 -1
  27. package/dist/src/index.d.ts.map +1 -1
  28. package/dist/src/index.js +2 -0
  29. package/dist/src/index.js.map +1 -1
  30. package/dist/src/protocol.d.ts.map +1 -1
  31. package/dist/src/protocol.js +50 -18
  32. package/dist/src/protocol.js.map +1 -1
  33. package/dist/src/transports/event-emitter.d.ts +60 -0
  34. package/dist/src/transports/event-emitter.d.ts.map +1 -0
  35. package/dist/src/transports/event-emitter.js +103 -0
  36. package/dist/src/transports/event-emitter.js.map +1 -0
  37. package/dist/src/transports/factory.d.ts +23 -2
  38. package/dist/src/transports/factory.d.ts.map +1 -1
  39. package/dist/src/transports/factory.js +20 -1
  40. package/dist/src/transports/factory.js.map +1 -1
  41. package/dist/src/workflow-discovery.d.ts +45 -0
  42. package/dist/src/workflow-discovery.d.ts.map +1 -0
  43. package/dist/src/workflow-discovery.js +103 -0
  44. package/dist/src/workflow-discovery.js.map +1 -0
  45. package/dist/src/workflow-ref.d.ts +41 -5
  46. package/dist/src/workflow-ref.d.ts.map +1 -1
  47. package/dist/src/workflow-ref.js +37 -6
  48. package/dist/src/workflow-ref.js.map +1 -1
  49. package/dist/stubs/config/durable.stub +6 -1
  50. package/dist/stubs/make/workflow/main.stub +22 -0
  51. package/package.json +11 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @adonis-agora/durable
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`9ae80aa`](https://github.com/DavideCarvalho/adonis-durable/commit/9ae80aa167fc27157b8e7c605bdb2805e6730dea) - feat: in-process EventEmitter transport; workflows codegen via Adonis assembler hook
8
+
9
+ - New production **in-process** transport `transports.eventEmitter()` backed by a single Node `EventEmitter`: a single-process app runs real durable workflows with NO external infrastructure (no DB, no Redis, no broker). It decouples dispatch → worker → result over the event loop (mirroring a real broker), and funnels every step through `runStepHandler`, so the scoped context restore works identically. Distinct from the test-only `transports.memory()`. Selectable via `transport: 'event-emitter'` in `config/durable.ts`; the default is unchanged.
10
+ - Workflows discovery now prefers a **build-time barrel** generated by an AdonisJS Assembler `init` hook (`@adonis-agora/durable/hooks/workflows`), exactly how core generates the controllers/events/listeners barrels via `IndexGenerator`. The dev server / test runner / bundler generates `.adonisjs/durable/workflows.ts` and the file watcher regenerates it on change; the provider imports it at boot instead of scanning `app/workflows` with `readdir`. Register it in `adonisrc.ts` under `hooks.init` (the `configure` command wires it for you). The runtime `readdir` scan is kept as a **fallback** so apps that don't register the hook keep working unchanged.
11
+
12
+ ## 0.4.0
13
+
14
+ ### Minor Changes
15
+
16
+ - [`d2591d0`](https://github.com/DavideCarvalho/adonis-durable/commit/d2591d0040bafb2301b41250e91a5d2961d9ad13) - Automatic cross-process context propagation + `app/workflows` auto-discovery and `make:workflow`.
17
+
18
+ - The full Agora request context (userRef / tenant / traceId) now rides each remote task automatically and is restored on the worker before the step handler runs — `ctx.call(remoteStep, input)` sees the originating request's context with zero manual serialize/deserialize. Best-effort, no-op when `@adonis-agora/context` is not installed.
19
+ - New class-based authoring convention mirroring `@adonisjs/queue`'s `app/jobs`: a `@Workflow` class per file under `app/workflows/` is auto-registered on the engine at boot (configurable via `workflowsPath`, opt-out with `false`), plus a `node ace make:workflow <name>` scaffold. `engine.register(name, version, fn)` remains the low-level escape hatch.
20
+
21
+ - [`6c31452`](https://github.com/DavideCarvalho/adonis-durable/commit/6c31452f14789fa98f20ea5f6164f421d76fc2df) - Scoped automatic cross-process context restore (was a no-op on db/queue workers); recursive workflow discovery; single-extension import.
22
+
23
+ - Workers now restore the originating request's context by running each step handler INSIDE an active context store seeded from the task snapshot, via the new `Symbol.for('@agora/context:scope')` slot. The previous `@agora/context:set` path only populated an already-active store, so restore was inert on the db/queue workers (no active scope) — automatic propagation now actually works, and each task runs in its own scope (no cross-task bleed on a long-lived worker). Clean no-op when `@adonis-agora/context` is not installed.
24
+ - The dispatch carrier is passed through opaquely (`context: () => accessor.get()`) instead of merging structured `userRef`/`tenantId`/`traceId` into it — the scope slot round-trips the whole snapshot, so the producer-owned carrier stays shape-opaque.
25
+ - `app/workflows` discovery is now recursive, so nested `app/workflows/billing/charge_workflow.ts` is found (matching `make:workflow`'s nested-path scaffolding). Only the environment-appropriate module extension is imported, so a built app (`.js`) and a dev app (`.ts`) never double-register the same workflow.
26
+
3
27
  ## 0.3.0
4
28
 
5
29
  ### Minor Changes
package/README.md CHANGED
@@ -24,6 +24,53 @@ persistent store and a broker-backed transport in `config/durable.ts` for
24
24
  production. When `@adonis-agora/context` is installed, the originating tenant/user/
25
25
  correlation carrier rides each dispatched task (best-effort, no hard dependency).
26
26
 
27
+ ## Transports
28
+
29
+ Select a transport by name in `config/durable.ts`:
30
+
31
+ - `transports.eventEmitter()` — **production in-process** transport over a Node
32
+ `EventEmitter`. Zero external infrastructure (no DB, no Redis, no broker): step
33
+ handlers run in this same process, decoupled from the dispatching workflow over
34
+ the event loop. Use it for a single-process production app.
35
+ - `transports.queue({ connection })` — cross-process over `@adonisjs/queue`.
36
+ - `transports.db({ connection })` — cross-process over the app database
37
+ (`@adonisjs/lucid`), no broker.
38
+ - `transports.memory()` — test-only (drives `dispatch` straight into the handler).
39
+
40
+ ```ts
41
+ import { defineConfig, transports } from '@adonis-agora/durable'
42
+
43
+ export default defineConfig({
44
+ transport: 'event-emitter',
45
+ transports: {
46
+ 'event-emitter': transports.eventEmitter(),
47
+ },
48
+ })
49
+ ```
50
+
51
+ ## Workflows codegen (Assembler hook)
52
+
53
+ `node ace configure` registers an AdonisJS **Assembler `init` hook** that generates
54
+ a typed barrel of `app/workflows/` at build/dev time — exactly how core generates
55
+ the controllers/events/listeners barrels. The provider imports the generated
56
+ `.adonisjs/durable/workflows.ts` at boot and registers every `@Workflow` class,
57
+ instead of scanning the directory with `readdir` at runtime. The file watcher
58
+ regenerates the barrel whenever a workflow file changes.
59
+
60
+ Register it in `adonisrc.ts` (the `configure` command does this for you):
61
+
62
+ ```ts
63
+ export default defineConfig({
64
+ hooks: {
65
+ init: [() => import('@adonis-agora/durable/hooks/workflows')],
66
+ },
67
+ })
68
+ ```
69
+
70
+ If the hook is not registered (or the barrel hasn't been generated yet) the
71
+ provider **falls back** to the runtime directory scan, so apps that don't opt in
72
+ keep working unchanged. Opt out of discovery entirely with `workflowsPath: false`.
73
+
27
74
  ## License
28
75
 
29
76
  MIT © Davi Carvalho
@@ -1,4 +1,5 @@
1
1
  import { ListLoader } from '@adonisjs/core/ace';
2
+ import MakeWorkflow from './make_workflow.js';
2
3
  import DurableRetry from './retry.js';
3
4
  import DurableRuns from './runs.js';
4
5
  import DurableWork from './work.js';
@@ -8,8 +9,8 @@ import DurableWork from './work.js';
8
9
  * kernel imports this module and treats it as a commands loader: a {@link ListLoader} over the three
9
10
  * durable commands provides their metadata and constructors.
10
11
  */
11
- declare const loader: ListLoader<typeof DurableRetry | typeof DurableRuns | typeof DurableWork>;
12
+ declare const loader: ListLoader<typeof MakeWorkflow | typeof DurableRetry | typeof DurableRuns | typeof DurableWork>;
12
13
  export declare const getMetaData: () => Promise<import("@adonisjs/core/types/ace").CommandMetaData[]>;
13
- export declare const getCommand: (metaData: import("@adonisjs/core/types/ace").CommandMetaData) => Promise<typeof DurableRetry | typeof DurableRuns | typeof DurableWork | null>;
14
+ export declare const getCommand: (metaData: import("@adonisjs/core/types/ace").CommandMetaData) => Promise<typeof MakeWorkflow | typeof DurableRetry | typeof DurableRuns | typeof DurableWork | null>;
14
15
  export default loader;
15
16
  //# sourceMappingURL=main.d.ts.map
@@ -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,YAAY,CAAC;AACtC,OAAO,WAAW,MAAM,WAAW,CAAC;AACpC,OAAO,WAAW,MAAM,WAAW,CAAC;AAEpC;;;;;GAKG;AACH,QAAA,MAAM,MAAM,2EAA2D,CAAC;AAExE,eAAO,MAAM,WAAW,qEAAkC,CAAC;AAC3D,eAAO,MAAM,UAAU,iJAAiC,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;;;;;GAKG;AACH,QAAA,MAAM,MAAM,iGAAyE,CAAC;AAEtF,eAAO,MAAM,WAAW,qEAAkC,CAAC;AAC3D,eAAO,MAAM,UAAU,uKAAiC,CAAC;AAEzD,eAAe,MAAM,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { ListLoader } from '@adonisjs/core/ace';
2
+ import MakeWorkflow from './make_workflow.js';
2
3
  import DurableRetry from './retry.js';
3
4
  import DurableRuns from './runs.js';
4
5
  import DurableWork from './work.js';
@@ -8,7 +9,7 @@ import DurableWork from './work.js';
8
9
  * kernel imports this module and treats it as a commands loader: a {@link ListLoader} over the three
9
10
  * durable commands provides their metadata and constructors.
10
11
  */
11
- const loader = new ListLoader([DurableWork, DurableRuns, DurableRetry]);
12
+ const loader = new ListLoader([DurableWork, DurableRuns, DurableRetry, MakeWorkflow]);
12
13
  export const getMetaData = loader.getMetaData.bind(loader);
13
14
  export const getCommand = loader.getCommand.bind(loader);
14
15
  export default 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,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,CAAC,CAAC,CAAC;AAExE,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;;;;;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"}
@@ -0,0 +1,16 @@
1
+ import { BaseCommand } from '@adonisjs/core/ace';
2
+ import type { CommandOptions } from '@adonisjs/core/types/ace';
3
+ /**
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(...)`.
8
+ */
9
+ export default class MakeWorkflow extends BaseCommand {
10
+ static commandName: string;
11
+ static description: string;
12
+ static options: CommandOptions;
13
+ name: string;
14
+ run(): Promise<void>;
15
+ }
16
+ //# sourceMappingURL=make_workflow.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,30 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { BaseCommand, args } from '@adonisjs/core/ace';
8
+ import { stubsRoot } from '../stubs/main.js';
9
+ /**
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(...)`.
14
+ */
15
+ export default class MakeWorkflow extends BaseCommand {
16
+ static commandName = 'make:workflow';
17
+ static description = 'Create a new durable workflow class';
18
+ static options = { allowUnknownFlags: true };
19
+ async run() {
20
+ const codemods = await this.createCodemods();
21
+ await codemods.makeUsingStub(stubsRoot, 'make/workflow/main.stub', {
22
+ flags: this.parsed.flags,
23
+ entity: this.app.generators.createEntity(this.name),
24
+ });
25
+ }
26
+ }
27
+ __decorate([
28
+ args.string({ description: 'Name of the workflow' })
29
+ ], MakeWorkflow.prototype, "name", void 0);
30
+ //# sourceMappingURL=make_workflow.js.map
@@ -0,0 +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"}
@@ -6,8 +6,11 @@ import type Configure from '@adonisjs/core/commands/configure';
6
6
  * 2. registers the ace commands barrel (`durable:work`, `durable:runs`,
7
7
  * `durable:retry`);
8
8
  * 3. registers the optional dashboard provider;
9
- * 4. publishes `config/durable.ts` + `config/durable_dashboard.ts`;
10
- * 5. publishes the Lucid migrations for the optional `lucid` store and `db`
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);
12
+ * 5. publishes `config/durable.ts` + `config/durable_dashboard.ts`;
13
+ * 6. publishes the Lucid migrations for the optional `lucid` store and `db`
11
14
  * transport drivers (run `node ace migration:run`, and delete the transport
12
15
  * migration if you don't use the `db` transport).
13
16
  */
@@ -1 +1 @@
1
- {"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../configure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,mCAAmC,CAAC;AAG/D;;;;;;;;;;;GAWG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,SAAS,iBAiBjD"}
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"}
package/dist/configure.js CHANGED
@@ -6,8 +6,11 @@ import { stubsRoot } from './stubs/main.js';
6
6
  * 2. registers the ace commands barrel (`durable:work`, `durable:runs`,
7
7
  * `durable:retry`);
8
8
  * 3. registers the optional dashboard provider;
9
- * 4. publishes `config/durable.ts` + `config/durable_dashboard.ts`;
10
- * 5. publishes the Lucid migrations for the optional `lucid` store and `db`
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);
12
+ * 5. publishes `config/durable.ts` + `config/durable_dashboard.ts`;
13
+ * 6. publishes the Lucid migrations for the optional `lucid` store and `db`
11
14
  * transport drivers (run `node ace migration:run`, and delete the transport
12
15
  * migration if you don't use the `db` transport).
13
16
  */
@@ -17,6 +20,8 @@ export async function configure(command) {
17
20
  rcFile.addProvider('@adonis-agora/durable/durable_provider');
18
21
  rcFile.addProvider('@adonis-agora/durable/dashboard_provider');
19
22
  rcFile.addCommand('@adonis-agora/durable/commands');
23
+ // Generate the typed app/workflows barrel at build/dev time (replaces the runtime readdir scan).
24
+ rcFile.addAssemblerHook('init', '@adonis-agora/durable/hooks/workflows');
20
25
  });
21
26
  await codemods.makeUsingStub(stubsRoot, 'config/durable.stub', {});
22
27
  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;;;;;;;;;;;GAWG;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;IACtD,CAAC,CAAC,CAAC;IAEH,MAAM,QAAQ,CAAC,aAAa,CAAC,SAAS,EAAE,qBAAqB,EAAE,EAAE,CAAC,CAAC;IACnE,MAAM,QAAQ,CAAC,aAAa,CAAC,SAAS,EAAE,+BAA+B,EAAE,EAAE,CAAC,CAAC;IAC7E,MAAM,QAAQ,CAAC,aAAa,CAAC,SAAS,EAAE,gDAAgD,EAAE,EAAE,CAAC,CAAC;IAC9F,MAAM,QAAQ,CAAC,aAAa,CAC1B,SAAS,EACT,0DAA0D,EAC1D,EAAE,CACH,CAAC;AACJ,CAAC"}
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,aAAa,CAAC,SAAS,EAAE,+BAA+B,EAAE,EAAE,CAAC,CAAC;IAC7E,MAAM,QAAQ,CAAC,aAAa,CAAC,SAAS,EAAE,gDAAgD,EAAE,EAAE,CAAC,CAAC;IAC9F,MAAM,QAAQ,CAAC,aAAa,CAC1B,SAAS,EACT,0DAA0D,EAC1D,EAAE,CACH,CAAC;AACJ,CAAC"}
@@ -23,6 +23,18 @@ export default class DurableProvider {
23
23
  protected app: ApplicationService;
24
24
  constructor(app: ApplicationService);
25
25
  register(): void;
26
+ /**
27
+ * Auto-register the `app/workflows` convention so users never call `engine.register(...)` by hand
28
+ * (mirrors `@adonisjs/queue`'s `app/jobs`). Opt-out with `config.workflowsPath = false`.
29
+ *
30
+ * Prefers the **build-time barrel** generated by the Assembler `init` hook
31
+ * (`@adonis-agora/durable/hooks/workflows` → `.adonisjs/durable/workflows.js`): registering from it
32
+ * avoids any runtime `readdir`. When that barrel is absent (the hook isn't registered in
33
+ * `adonisrc.ts`, or it hasn't been generated yet) it FALLS BACK to the runtime directory scan, so
34
+ * apps that don't opt into the hook keep working unchanged. The low-level
35
+ * `engine.register(name, version, fn)` remains the escape hatch.
36
+ */
37
+ boot(): Promise<void>;
26
38
  /**
27
39
  * Once everything is booted, bridge engine lifecycle events onto the `@adonis-agora/diagnostics` bus —
28
40
  * but only when diagnostics is actually installed (its emit slot is populated at module load).
@@ -1 +1 @@
1
- {"version":3,"file":"durable_provider.d.ts","sourceRoot":"","sources":["../../providers/durable_provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAkC/D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;;IAKtB,SAAS,CAAC,GAAG,EAAE,kBAAkB;gBAAvB,GAAG,EAAE,kBAAkB;IAE7C,QAAQ;IAkFR;;;;;;OAMG;IACG,KAAK;IAOL,QAAQ;CAUf"}
1
+ {"version":3,"file":"durable_provider.d.ts","sourceRoot":"","sources":["../../providers/durable_provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAoC/D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;;IAKtB,SAAS,CAAC,GAAG,EAAE,kBAAkB;gBAAvB,GAAG,EAAE,kBAAkB;IAE7C,QAAQ;IA4CR;;;;;;;;;;OAUG;IACG,IAAI;IA2EV;;;;;;OAMG;IACG,KAAK;IAOL,QAAQ;CAUf"}
@@ -1,4 +1,5 @@
1
- import { InMemoryStateStore, InMemoryTransport, WorkflowEngine, attachDurableDiagnostics, } from '../src/index.js';
1
+ import { pathToFileURL } from 'node:url';
2
+ import { InMemoryStateStore, InMemoryTransport, WorkflowEngine, attachDurableDiagnostics, registerWorkflowsFromBarrel, registerWorkflowsFromDir, } from '../src/index.js';
2
3
  const CONTEXT_ACCESSOR = Symbol.for('@agora/context:accessor');
3
4
  /**
4
5
  * Global slot `@adonis-agora/diagnostics-otel` publishes its `otelTraceparent` under: a
@@ -62,7 +63,9 @@ export default class DurableProvider {
62
63
  ? { compensationRetries: config.compensationRetries }
63
64
  : {}),
64
65
  ...(config.runDispatcher ? { runDispatcher: config.runDispatcher } : {}),
65
- // Best-effort context propagation from @adonis-agora/context (no hard dep).
66
+ // Best-effort context propagation from @adonis-agora/context (no hard dep): pass the opaque
67
+ // carrier through verbatim. The carrier is producer-owned and shape-opaque; the worker's
68
+ // scope slot round-trips the whole snapshot via Context.run, so no field-picking is needed.
66
69
  ...(accessor ? { context: () => accessor.get() } : {}),
67
70
  // Best-effort OTel trace continuation from @adonis-agora/diagnostics-otel (no hard dep).
68
71
  ...(otelTraceparent ? { traceparent: otelTraceparent } : {}),
@@ -70,6 +73,51 @@ export default class DurableProvider {
70
73
  return new WorkflowEngine(deps);
71
74
  });
72
75
  }
76
+ /**
77
+ * Auto-register the `app/workflows` convention so users never call `engine.register(...)` by hand
78
+ * (mirrors `@adonisjs/queue`'s `app/jobs`). Opt-out with `config.workflowsPath = false`.
79
+ *
80
+ * Prefers the **build-time barrel** generated by the Assembler `init` hook
81
+ * (`@adonis-agora/durable/hooks/workflows` → `.adonisjs/durable/workflows.js`): registering from it
82
+ * avoids any runtime `readdir`. When that barrel is absent (the hook isn't registered in
83
+ * `adonisrc.ts`, or it hasn't been generated yet) it FALLS BACK to the runtime directory scan, so
84
+ * apps that don't opt into the hook keep working unchanged. The low-level
85
+ * `engine.register(name, version, fn)` remains the escape hatch.
86
+ */
87
+ async boot() {
88
+ const config = this.app.config.get('durable', {});
89
+ if (config.workflowsPath === false)
90
+ return;
91
+ const engine = await this.app.container.make(WorkflowEngine);
92
+ const barrel = await this.#loadGeneratedWorkflowsBarrel();
93
+ if (barrel) {
94
+ await registerWorkflowsFromBarrel(engine, barrel);
95
+ return;
96
+ }
97
+ // Fallback: no generated barrel — scan the configured directory at runtime.
98
+ const dir = this.app.makePath(config.workflowsPath ?? 'app/workflows');
99
+ await registerWorkflowsFromDir(engine, dir);
100
+ }
101
+ /**
102
+ * Best-effort import of the build-time workflows barrel the Assembler `init` hook generates. Returns
103
+ * the barrel's `workflows` export when present, or `null` when the file doesn't exist (the hook
104
+ * isn't registered) — the signal for `boot()` to fall back to the runtime scan. Only a genuine
105
+ * "module not found" is swallowed; any other import error propagates (a broken generated barrel
106
+ * should surface, not silently degrade).
107
+ */
108
+ async #loadGeneratedWorkflowsBarrel() {
109
+ const path = this.app.makePath('.adonisjs/durable/workflows.js');
110
+ try {
111
+ const mod = (await import(pathToFileURL(path).href));
112
+ return mod.workflows ?? null;
113
+ }
114
+ catch (err) {
115
+ const code = err.code;
116
+ if (code === 'ERR_MODULE_NOT_FOUND' || code === 'ENOENT')
117
+ return null;
118
+ throw err;
119
+ }
120
+ }
73
121
  /** Resolve the configured state store (a key of `config.stores`), or the in-memory default. */
74
122
  async #resolveStore(config, ctx) {
75
123
  const name = config.store;
@@ -1 +1 @@
1
- {"version":3,"file":"durable_provider.js","sourceRoot":"","sources":["../../providers/durable_provider.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,kBAAkB,EAClB,iBAAiB,EAKjB,cAAc,EAEd,wBAAwB,GACzB,MAAM,iBAAiB,CAAC;AAOzB,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;AAE/D;;;;;GAKG;AACH,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;AAE/D,6GAA6G;AAC7G,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;AAE/D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;IAKZ;IAJtB,kBAAkB,GAAwB,IAAI,CAAC;IAC/C,UAAU,GAAyD,IAAI,CAAC;IACxE,aAAa,GAA4D,IAAI,CAAC;IAE9E,YAAsB,GAAuB;QAAvB,QAAG,GAAH,GAAG,CAAoB;IAAG,CAAC;IAEjD,QAAQ;QACN,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,cAAc,EAAE,KAAK,IAAI,EAAE;YACtD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAgB,SAAS,EAAE,EAAE,CAAC,CAAC;YACjE,MAAM,QAAQ,GAAI,UAAsC,CAAC,gBAAgB,CAE5D,CAAC;YACd,MAAM,eAAe,GAAI,UAAs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AAK;QACT,MAAM,IAAI,GAAI,UAAsC,CAAC,gBAAgB,CAAC,CAAC;QACvE,IAAI,OAAO,IAAI,KAAK,UAAU;YAAE,OAAO;QACvC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC7D,IAAI,CAAC,kBAAkB,GAAG,wBAAwB,CAAC,MAAM,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,IAAI,CAAC,kBAAkB,EAAE,EAAE,CAAC;QAC5B,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;QAC/B,+FAA+F;QAC/F,MAAM,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,sFAAsF;QACtF,MAAM,IAAI,CAAC,aAAa,EAAE,KAAK,EAAE,EAAE,CAAC;QACpC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC5B,CAAC;CACF"}
@@ -5,7 +5,7 @@ import type { ScheduledWorkflow } from './scheduler.js';
5
5
  import { stores } from './stores/factory.js';
6
6
  import type { LucidStoreConfig, StoreContext, StoreFactory } from './stores/factory.js';
7
7
  import { transports } from './transports/factory.js';
8
- import type { DbTransportConfig, MemoryTransportConfig, QueueTransportConfig, TransportContext, TransportFactory } from './transports/factory.js';
8
+ import type { DbTransportConfig, EventEmitterTransportConfig, MemoryTransportConfig, QueueTransportConfig, TransportContext, TransportFactory } from './transports/factory.js';
9
9
  /**
10
10
  * Shape of `config/durable.ts`. Everything is optional — by default the engine uses an in-process
11
11
  * state store + transport (single-process, no extra infra). Pick a `transport`/`store` by name from
@@ -20,7 +20,8 @@ import type { DbTransportConfig, MemoryTransportConfig, QueueTransportConfig, Tr
20
20
  * export default defineConfig({
21
21
  * transport: 'queue',
22
22
  * transports: {
23
- * memory: transports.memory(),
23
+ * // production single-process, no external infra:
24
+ * 'event-emitter': transports.eventEmitter(),
24
25
  * queue: transports.queue({ adapter: redis({ host: '127.0.0.1' }), group: 'durable' }),
25
26
  * db: transports.db({ connection: 'pg' }),
26
27
  * },
@@ -71,9 +72,16 @@ export interface DurableConfig {
71
72
  * `cron-parser` peer dependency. Omit (or leave empty) to register no schedules.
72
73
  */
73
74
  schedules?: ScheduledWorkflow[];
75
+ /**
76
+ * Directory (relative to the app root) the provider scans at boot for `@Workflow`-decorated classes
77
+ * to auto-register on the engine — the `app/workflows` convention, mirroring `@adonisjs/queue`'s
78
+ * `app/jobs`. Default `'app/workflows'`. Set `false` to disable discovery entirely (register by
79
+ * hand with `engine.register(...)`). A missing directory is fine — nothing to register.
80
+ */
81
+ workflowsPath?: string | false;
74
82
  }
75
83
  /** Identity helper giving `config/durable.ts` full type-checking. */
76
84
  export declare function defineConfig(config?: DurableConfig): DurableConfig;
77
85
  export { transports, stores, controlPlanes };
78
- export type { TransportContext, TransportFactory, MemoryTransportConfig, QueueTransportConfig, DbTransportConfig, StoreContext, StoreFactory, LucidStoreConfig, ControlPlaneContext, ControlPlaneFactory, RedisControlPlaneConfig, };
86
+ export type { TransportContext, TransportFactory, MemoryTransportConfig, EventEmitterTransportConfig, QueueTransportConfig, DbTransportConfig, StoreContext, StoreFactory, LucidStoreConfig, ControlPlaneContext, ControlPlaneFactory, RedisControlPlaneConfig, };
79
87
  //# sourceMappingURL=define_config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"define_config.d.ts","sourceRoot":"","sources":["../../src/define_config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,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AC,EAAE,MAAM,CAAC;IACpB,yFAAyF;IACzF,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gEAAgE;IAChE,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gFAAgF;IAChF,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAChC;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;CAChC;AAED,qEAAqE;AACrE,wBAAgB,YAAY,CAAC,MAAM,GAAE,aAAkB,GAAG,aAAa,CAEtE;AAED,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;AAC7C,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,2BAA2B,EAC3B,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,GACxB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"define_config.js","sourceRoot":"","sources":["../../src/define_config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAQ5D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AA4ErD,qEAAqE;AACrE,MAAM,UAAU,YAAY,CAAC,SAAwB,EAAE;IACrD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"define_config.js","sourceRoot":"","sources":["../../src/define_config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAQ5D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAqFrD,qEAAqE;AACrE,MAAM,UAAU,YAAY,CAAC,SAAwB,EAAE;IACrD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,53 @@
1
+ import type { IndexGenerator } from '@adonisjs/assembler/index_generator';
2
+ /**
3
+ * Where the generated workflows barrel is written, relative to the app root. The durable provider
4
+ * imports THIS path at boot (build-time codegen) instead of scanning `app/workflows` with `readdir`
5
+ * at runtime. Kept in sync with {@link GENERATED_WORKFLOWS_MODULE} the provider imports.
6
+ */
7
+ export declare const GENERATED_WORKFLOWS_OUTPUT = ".adonisjs/durable/workflows.ts";
8
+ /**
9
+ * Options for {@link workflowsHook} — mirror the relevant `IndexGenerator.add` knobs so an app can
10
+ * point the generator at a non-default workflows directory or import alias.
11
+ */
12
+ export interface WorkflowsHookOptions {
13
+ /** Directory the generator scans for workflow modules, relative to the app root. Default `app/workflows`. */
14
+ source?: string;
15
+ /** Import alias the generated barrel uses for each workflow module. Default `#workflows`. */
16
+ importAlias?: string;
17
+ /** Output path for the generated barrel, relative to the app root. Default `.adonisjs/durable/workflows.ts`. */
18
+ output?: string;
19
+ }
20
+ /**
21
+ * An AdonisJS **Assembler `init` hook** that generates a typed barrel of the app's `app/workflows/`
22
+ * directory at build/dev time — exactly how `@adonisjs/core` generates the controllers/events/listeners
23
+ * barrels (`indexEntities`). The build-time barrel replaces the provider's runtime `readdir` scan: the
24
+ * dev server / test runner / bundler runs this `init` hook once, and the file watcher re-runs the
25
+ * `IndexGenerator` (via its tracked `addFile`/`removeFile`) whenever a workflow file changes, so the
26
+ * generated `.adonisjs/durable/workflows.ts` always reflects `app/workflows`.
27
+ *
28
+ * The generated file is a lazy barrel — `export const workflows = { Name: () => import('#workflows/…') }`
29
+ * — which the durable provider imports at boot, awaiting each thunk and registering every
30
+ * `@Workflow`-decorated export it finds (falling back to the runtime scan when the barrel is absent).
31
+ *
32
+ * Register it in `adonisrc.ts`:
33
+ *
34
+ * ```ts
35
+ * export default defineConfig({
36
+ * hooks: {
37
+ * init: [() => import('@adonis-agora/durable/hooks/workflows')],
38
+ * },
39
+ * })
40
+ * ```
41
+ *
42
+ * The default export is the hook object the assembler expects (`{ run(parent, hooks, indexGenerator) }`).
43
+ */
44
+ export declare function workflowsHook(options?: WorkflowsHookOptions): {
45
+ run(_parent: unknown, _hooks: unknown, indexGenerator: IndexGenerator): void;
46
+ };
47
+ /** The default export is the hook object itself, so `() => import('@adonis-agora/durable/hooks/workflows')`
48
+ * in `adonisrc.ts` resolves to a ready hook (the assembler calls its `run`). */
49
+ declare const _default: {
50
+ run(_parent: unknown, _hooks: unknown, indexGenerator: IndexGenerator): void;
51
+ };
52
+ export default _default;
53
+ //# sourceMappingURL=workflows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../../src/hooks/workflows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAE1E;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,mCAAmC,CAAC;AAE3E;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,6GAA6G;IAC7G,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6FAA6F;IAC7F,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gHAAgH;IAChH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,aAAa,CAAC,OAAO,GAAE,oBAAyB;iBAM/C,OAAO,UAAU,OAAO,kBAAkB,cAAc,GAAG,IAAI;EAe/E;AAED;iFACiF;;iBAlBhE,OAAO,UAAU,OAAO,kBAAkB,cAAc,GAAG,IAAI;;AAmBhF,wBAA+B"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Where the generated workflows barrel is written, relative to the app root. The durable provider
3
+ * imports THIS path at boot (build-time codegen) instead of scanning `app/workflows` with `readdir`
4
+ * at runtime. Kept in sync with {@link GENERATED_WORKFLOWS_MODULE} the provider imports.
5
+ */
6
+ export const GENERATED_WORKFLOWS_OUTPUT = '.adonisjs/durable/workflows.ts';
7
+ /**
8
+ * An AdonisJS **Assembler `init` hook** that generates a typed barrel of the app's `app/workflows/`
9
+ * directory at build/dev time — exactly how `@adonisjs/core` generates the controllers/events/listeners
10
+ * barrels (`indexEntities`). The build-time barrel replaces the provider's runtime `readdir` scan: the
11
+ * dev server / test runner / bundler runs this `init` hook once, and the file watcher re-runs the
12
+ * `IndexGenerator` (via its tracked `addFile`/`removeFile`) whenever a workflow file changes, so the
13
+ * generated `.adonisjs/durable/workflows.ts` always reflects `app/workflows`.
14
+ *
15
+ * The generated file is a lazy barrel — `export const workflows = { Name: () => import('#workflows/…') }`
16
+ * — which the durable provider imports at boot, awaiting each thunk and registering every
17
+ * `@Workflow`-decorated export it finds (falling back to the runtime scan when the barrel is absent).
18
+ *
19
+ * Register it in `adonisrc.ts`:
20
+ *
21
+ * ```ts
22
+ * export default defineConfig({
23
+ * hooks: {
24
+ * init: [() => import('@adonis-agora/durable/hooks/workflows')],
25
+ * },
26
+ * })
27
+ * ```
28
+ *
29
+ * The default export is the hook object the assembler expects (`{ run(parent, hooks, indexGenerator) }`).
30
+ */
31
+ export function workflowsHook(options = {}) {
32
+ const source = options.source ?? 'app/workflows';
33
+ const importAlias = options.importAlias ?? '#workflows';
34
+ const output = options.output ?? GENERATED_WORKFLOWS_OUTPUT;
35
+ return {
36
+ run(_parent, _hooks, indexGenerator) {
37
+ indexGenerator.add('workflows', {
38
+ source,
39
+ as: 'barrelFile',
40
+ exportName: 'workflows',
41
+ importAlias,
42
+ // `app/workflows/billing/charge_workflow.ts` → key `Billing/Charge`; the `Workflow` suffix is
43
+ // dropped so a barrel key reads as the class, mirroring controllers' `removeSuffix: 'controller'`.
44
+ removeSuffix: 'workflow',
45
+ skipSegments: ['workflows'],
46
+ output,
47
+ comment: true,
48
+ });
49
+ },
50
+ };
51
+ }
52
+ /** The default export is the hook object itself, so `() => import('@adonis-agora/durable/hooks/workflows')`
53
+ * in `adonisrc.ts` resolves to a ready hook (the assembler calls its `run`). */
54
+ export default workflowsHook();
55
+ //# sourceMappingURL=workflows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflows.js","sourceRoot":"","sources":["../../../src/hooks/workflows.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,gCAAgC,CAAC;AAe3E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,aAAa,CAAC,UAAgC,EAAE;IAC9D,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,eAAe,CAAC;IACjD,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,YAAY,CAAC;IACxD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,0BAA0B,CAAC;IAE5D,OAAO;QACL,GAAG,CAAC,OAAgB,EAAE,MAAe,EAAE,cAA8B;YACnE,cAAc,CAAC,GAAG,CAAC,WAAW,EAAE;gBAC9B,MAAM;gBACN,EAAE,EAAE,YAAY;gBAChB,UAAU,EAAE,WAAW;gBACvB,WAAW;gBACX,8FAA8F;gBAC9F,mGAAmG;gBACnG,YAAY,EAAE,UAAU;gBACxB,YAAY,EAAE,CAAC,WAAW,CAAC;gBAC3B,MAAM;gBACN,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC;AAED;iFACiF;AACjF,eAAe,aAAa,EAAE,CAAC"}
@@ -20,10 +20,12 @@ export * from './scheduler.js';
20
20
  export * from './search-attributes.js';
21
21
  export * from './tokens.js';
22
22
  export * from './workflow-ref.js';
23
+ export * from './workflow-discovery.js';
23
24
  export { InMemoryStateStore } from './testing/in-memory-state-store.js';
24
25
  export { InMemoryTransport } from './testing/in-memory-transport.js';
25
26
  export { transports } from './transports/factory.js';
26
- export type { TransportContext, TransportFactory, MemoryTransportConfig, QueueTransportConfig, DbTransportConfig, } from './transports/factory.js';
27
+ export type { TransportContext, TransportFactory, MemoryTransportConfig, EventEmitterTransportConfig, QueueTransportConfig, DbTransportConfig, } from './transports/factory.js';
28
+ export { EventEmitterTransport, type EventEmitterTransportOptions, } from './transports/event-emitter.js';
27
29
  export { QueueTransport, type QueueTransportOptions } from './transports/queue.js';
28
30
  export { DbTransport, type DbTransportOptions } from './transports/db.js';
29
31
  export { TRANSPORT_TABLES, createDurableTransportTables, dropDurableTransportTables, } from './transports/db-schema.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,eAAO,MAAM,OAAO,UAAU,CAAC;AAG/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAGrE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,YAAY,EACV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OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,KAAK,WAAW,GACjB,MAAM,8CAA8C,CAAC;AAGtD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/src/index.js CHANGED
@@ -21,10 +21,12 @@ export * from './scheduler.js';
21
21
  export * from './search-attributes.js';
22
22
  export * from './tokens.js';
23
23
  export * from './workflow-ref.js';
24
+ export * from './workflow-discovery.js';
24
25
  export { InMemoryStateStore } from './testing/in-memory-state-store.js';
25
26
  export { InMemoryTransport } from './testing/in-memory-transport.js';
26
27
  // --- config-driven transport drivers ----------------------------------------
27
28
  export { transports } from './transports/factory.js';
29
+ export { EventEmitterTransport, } from './transports/event-emitter.js';
28
30
  export { QueueTransport } from './transports/queue.js';
29
31
  export { DbTransport } from './transports/db.js';
30
32
  export { TRANSPORT_TABLES, createDurableTransportTables, dropDurableTransportTables, } from './transports/db-schema.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,+EAA+E;AAC/E,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC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{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAa,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGrF;oGACoG;AACpG,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;6FAC6F;AAC7F,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,EAAE,KAAK,MAAM,KAAG,MAA8B,CAAC;AAE5F;kGACkG;AAClG,MAAM,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AAE1F;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,WAAW,GAAG,SAAS,GAC/B,OAAO,CAAC,UAAU,CAAC,CA+BrB"}
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAa,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAgCrF;oGACoG;AACpG,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;6FAC6F;AAC7F,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,EAAE,KAAK,MAAM,KAAG,MAA8B,CAAC;AAE5F;kGACkG;AAClG,MAAM,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AAE1F;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,WAAW,GAAG,SAAS,GAC/B,OAAO,CAAC,UAAU,CAAC,CAqCrB"}