@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
@@ -1,20 +1,23 @@
1
1
  import type { WorkflowEngine } from './engine.js';
2
2
  import { type WorkflowClass, type WorkflowMeta } from './workflow-ref.js';
3
- /** A discovered, decorated workflow class plus the metadata its `@Workflow` decorator stamped. */
3
+ /** A discovered workflow class plus its resolved {@link WorkflowMeta} from a `BaseWorkflow`
4
+ * subclass's `static workflow` config. */
4
5
  export interface DiscoveredWorkflow {
5
6
  meta: WorkflowMeta;
6
7
  cls: WorkflowClass;
7
8
  }
8
9
  /**
9
- * Register a single `@Workflow`-decorated class on the engine: instantiate it once and bind its
10
- * `run(ctx, input)` as the workflow body via `engine.register`. The low-level
11
- * `engine.register(name, version, fn)` stays the escape hatch — this is the convenience the
12
- * `app/workflows` convention builds on. No-op (returns `false`) for an undecorated class.
10
+ * Register a single workflow class on the engine a `BaseWorkflow` subclass (its `static workflow`
11
+ * config), resolved via {@link workflowMeta}. Instantiates it once and binds its `run(ctx, input)`
12
+ * as the workflow body via `engine.register`. The low-level `engine.register(name, version, fn)`
13
+ * stays the escape hatch — this is the convenience the `app/workflows` convention builds on. No-op
14
+ * (returns `false`) for a non-workflow class (no `static workflow` config).
13
15
  */
14
16
  export declare function registerWorkflowClass(engine: WorkflowEngine, cls: unknown): boolean;
15
17
  /**
16
- * Scan a directory RECURSIVELY for modules and collect every exported `@Workflow`-decorated class
17
- * (the default export and any named export are considered) — so nested conventions like
18
+ * Scan a directory RECURSIVELY for modules and collect every exported workflow class — a
19
+ * `BaseWorkflow` subclass (the default export and any named export are considered) — so nested
20
+ * conventions like
18
21
  * `app/workflows/billing/charge_workflow.ts` are found, matching `make:workflow`'s nested-path
19
22
  * scaffolding. Only the environment-appropriate extension is imported (see {@link MODULE_EXT}), and
20
23
  * each module path is visited once, so a built `.js` and a dev `.ts` of the same module never both
@@ -23,23 +26,26 @@ export declare function registerWorkflowClass(engine: WorkflowEngine, cls: unkno
23
26
  */
24
27
  export declare function discoverWorkflows(dir: string): Promise<DiscoveredWorkflow[]>;
25
28
  /**
26
- * Discover every `@Workflow` class under `dir` and register each on the engine. Returns the
27
- * registered metadata so the caller can log what was wired. Best-effort over a missing directory.
29
+ * Discover every workflow class (`BaseWorkflow` subclass) under `dir` and register each on the
30
+ * engine. Returns the registered metadata so the caller can log what was wired.
31
+ * Best-effort over a missing directory.
28
32
  */
29
33
  export declare function registerWorkflowsFromDir(engine: WorkflowEngine, dir: string): Promise<WorkflowMeta[]>;
30
34
  /**
31
35
  * The shape of the build-time barrel generated by the Assembler `init` hook
32
36
  * (`@adonis-agora/durable/hooks/workflows`): a map of stable key → lazy module import, e.g.
33
37
  * `{ Charge: () => import('#workflows/charge_workflow') }`. The exact key is irrelevant here — we
34
- * register every `@Workflow`-decorated export of every module, identical to the runtime scan.
38
+ * register every workflow export of every module (`BaseWorkflow` subclass), identical to the runtime
39
+ * scan.
35
40
  */
36
41
  export type WorkflowsBarrel = Record<string, () => Promise<Record<string, unknown>>>;
37
42
  /**
38
- * Register every `@Workflow` class reachable from a generated {@link WorkflowsBarrel}, by awaiting
39
- * each lazy module import and registering each decorated export — the build-time equivalent of
40
- * {@link registerWorkflowsFromDir}, with no runtime `readdir`. Each module is imported once and each
41
- * decorated class registered once (deduped), so a class re-exported from several modules is safe.
42
- * Returns the registered metadata so the caller can log what was wired.
43
+ * Register every workflow class reachable from a generated {@link WorkflowsBarrel} (`BaseWorkflow`
44
+ * subclass), by awaiting each lazy module import and registering each
45
+ * workflow export — the build-time equivalent of {@link registerWorkflowsFromDir}, with no runtime
46
+ * `readdir`. Each module is imported once and each class registered once (deduped), so a class
47
+ * re-exported from several modules is safe. Returns the registered metadata so the caller can log
48
+ * what was wired.
43
49
  */
44
50
  export declare function registerWorkflowsFromBarrel(engine: WorkflowEngine, barrel: WorkflowsBarrel): Promise<WorkflowMeta[]>;
45
51
  //# sourceMappingURL=workflow-discovery.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-discovery.d.ts","sourceRoot":"","sources":["../../src/workflow-discovery.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAgB,MAAM,mBAAmB,CAAC;AAExF,kGAAkG;AAClG,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,YAAY,CAAC;IACnB,GAAG,EAAE,aAAa,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAgBnF;AAUD;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAuBlF;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,cAAc,EACtB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,YAAY,EAAE,CAAC,CAIzB;AAED;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;AAErF;;;;;;GAMG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,YAAY,EAAE,CAAC,CAezB"}
1
+ {"version":3,"file":"workflow-discovery.d.ts","sourceRoot":"","sources":["../../src/workflow-discovery.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAgB,MAAM,mBAAmB,CAAC;AAExF;2CAC2C;AAC3C,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,YAAY,CAAC;IACnB,GAAG,EAAE,aAAa,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAgBnF;AAUD;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAuBlF;AAED;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,cAAc,EACtB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,YAAY,EAAE,CAAC,CAIzB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;AAErF;;;;;;;GAOG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,YAAY,EAAE,CAAC,CAezB"}
@@ -3,10 +3,11 @@ import { extname, join } from 'node:path';
3
3
  import { pathToFileURL } from 'node:url';
4
4
  import { workflowMeta } from './workflow-ref.js';
5
5
  /**
6
- * Register a single `@Workflow`-decorated class on the engine: instantiate it once and bind its
7
- * `run(ctx, input)` as the workflow body via `engine.register`. The low-level
8
- * `engine.register(name, version, fn)` stays the escape hatch — this is the convenience the
9
- * `app/workflows` convention builds on. No-op (returns `false`) for an undecorated class.
6
+ * Register a single workflow class on the engine a `BaseWorkflow` subclass (its `static workflow`
7
+ * config), resolved via {@link workflowMeta}. Instantiates it once and binds its `run(ctx, input)`
8
+ * as the workflow body via `engine.register`. The low-level `engine.register(name, version, fn)`
9
+ * stays the escape hatch — this is the convenience the `app/workflows` convention builds on. No-op
10
+ * (returns `false`) for a non-workflow class (no `static workflow` config).
10
11
  */
11
12
  export function registerWorkflowClass(engine, cls) {
12
13
  const meta = workflowMeta(cls);
@@ -29,8 +30,9 @@ export function registerWorkflowClass(engine, cls) {
29
30
  */
30
31
  const MODULE_EXT = extname(import.meta.url || '') === '.ts' ? '.ts' : '.js';
31
32
  /**
32
- * Scan a directory RECURSIVELY for modules and collect every exported `@Workflow`-decorated class
33
- * (the default export and any named export are considered) — so nested conventions like
33
+ * Scan a directory RECURSIVELY for modules and collect every exported workflow class — a
34
+ * `BaseWorkflow` subclass (the default export and any named export are considered) — so nested
35
+ * conventions like
34
36
  * `app/workflows/billing/charge_workflow.ts` are found, matching `make:workflow`'s nested-path
35
37
  * scaffolding. Only the environment-appropriate extension is imported (see {@link MODULE_EXT}), and
36
38
  * each module path is visited once, so a built `.js` and a dev `.ts` of the same module never both
@@ -66,8 +68,9 @@ export async function discoverWorkflows(dir) {
66
68
  return found;
67
69
  }
68
70
  /**
69
- * Discover every `@Workflow` class under `dir` and register each on the engine. Returns the
70
- * registered metadata so the caller can log what was wired. Best-effort over a missing directory.
71
+ * Discover every workflow class (`BaseWorkflow` subclass) under `dir` and register each on the
72
+ * engine. Returns the registered metadata so the caller can log what was wired.
73
+ * Best-effort over a missing directory.
71
74
  */
72
75
  export async function registerWorkflowsFromDir(engine, dir) {
73
76
  const discovered = await discoverWorkflows(dir);
@@ -76,11 +79,12 @@ export async function registerWorkflowsFromDir(engine, dir) {
76
79
  return discovered.map((d) => d.meta);
77
80
  }
78
81
  /**
79
- * Register every `@Workflow` class reachable from a generated {@link WorkflowsBarrel}, by awaiting
80
- * each lazy module import and registering each decorated export — the build-time equivalent of
81
- * {@link registerWorkflowsFromDir}, with no runtime `readdir`. Each module is imported once and each
82
- * decorated class registered once (deduped), so a class re-exported from several modules is safe.
83
- * Returns the registered metadata so the caller can log what was wired.
82
+ * Register every workflow class reachable from a generated {@link WorkflowsBarrel} (`BaseWorkflow`
83
+ * subclass), by awaiting each lazy module import and registering each
84
+ * workflow export — the build-time equivalent of {@link registerWorkflowsFromDir}, with no runtime
85
+ * `readdir`. Each module is imported once and each class registered once (deduped), so a class
86
+ * re-exported from several modules is safe. Returns the registered metadata so the caller can log
87
+ * what was wired.
84
88
  */
85
89
  export async function registerWorkflowsFromBarrel(engine, barrel) {
86
90
  const registered = [];
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-discovery.js","sourceRoot":"","sources":["../../src/workflow-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAyC,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAQxF;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAsB,EAAE,GAAY;IACxE,MAAM,IAAI,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IACxB,MAAM,IAAI,GAAG,GAAkF,CAAC;IAChG,MAAM,QAAQ,GAAG,IAAI,IAAI,EAAE,CAAC;IAC5B,MAAM,CAAC,QAAQ,CACb,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,OAAO,EACZ,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EACzD;QACE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,GAAG,CAAC,IAAI,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,EAA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B,qBAAqB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACxC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -5,14 +5,7 @@
5
5
  * `ctx.child(ShippingWorkflow, input)` type-checks the input and returns a typed result — while a
6
6
  * string stays available for the cross-runtime case.
7
7
  */
8
- /**
9
- * The symbol the `@Workflow` decorator stamps the full options onto (name + version + tags …), so
10
- * auto-discovery can register the class against the engine and a class ref can be resolved back to
11
- * its name via {@link workflowName}. A global-registry symbol (`Symbol.for`) so it survives duplicate
12
- * copies of this package in a dependency tree.
13
- */
14
- export declare const WORKFLOW_META_KEY: unique symbol;
15
- /** Options passed to `@Workflow({ name, version, … })`. */
8
+ /** Options for a workflow's `static workflow = { name, version, … }` config (see {@link BaseWorkflow}). */
16
9
  export interface WorkflowOptions {
17
10
  /** The registered workflow name (the cross-runtime identity, e.g. `order`). */
18
11
  name: string;
@@ -25,29 +18,18 @@ export interface WorkflowOptions {
25
18
  /** Event names that start a run of this workflow when published (see `onEvent`). */
26
19
  onEvent?: string[];
27
20
  }
28
- /** The metadata the `@Workflow` decorator stamps onto a class for discovery + registration. */
21
+ /** The metadata read off a workflow class's `static workflow` config for discovery + registration. */
29
22
  export interface WorkflowMeta extends WorkflowOptions {
30
23
  version: string;
31
24
  }
32
25
  /**
33
- * Class decorator marking a class as a durable workflow. Stamps the full options (name + version +
34
- * tags …) so a class ref resolves via {@link workflowName} and the provider's `app/workflows`
35
- * auto-discovery can register it on the engine no manual `engine.register(...)`. The class must
36
- * expose `run(ctx, input)`; that method becomes the workflow body.
37
- *
38
- * ```ts
39
- * @Workflow({ name: 'order', version: '1' })
40
- * export default class OrderWorkflow {
41
- * async run(ctx: WorkflowCtx, input: { id: string }) { ... }
42
- * }
43
- * ```
26
+ * Read a class's {@link WorkflowMeta} its name/version/tags/… from its `static workflow =
27
+ * { name, version, }` config (the {@link BaseWorkflow} authoring form). Any absent `version` is
28
+ * normalized to `'1'`. Returns `undefined` for a class carrying no valid config (a class with no
29
+ * `static workflow`, or one whose `name` is not a string, is not a registrable workflow).
44
30
  */
45
- export declare function Workflow(options: WorkflowOptions): <T extends abstract new (...args: never[]) => {
46
- run(ctx: never, input: never): unknown;
47
- }>(target: T) => T;
48
- /** Read the {@link WorkflowMeta} a `@Workflow` decorator stamped on a class, or `undefined`. */
49
31
  export declare function workflowMeta(target: unknown): WorkflowMeta | undefined;
50
- /** Structural shape of a `@Workflow` class — its `run(ctx, input)` carries the input/output types. */
32
+ /** Structural shape of a workflow class — its `run(ctx, input)` carries the input/output types. */
51
33
  export type WorkflowClass<TInput = unknown, TOutput = unknown> = abstract new (...args: never[]) => {
52
34
  run(ctx: never, input: TInput): Promise<TOutput> | TOutput;
53
35
  };
@@ -63,8 +45,8 @@ export type WorkflowOutputOf<C> = C extends abstract new (...args: never[]) => {
63
45
  } ? Awaited<R> : unknown;
64
46
  /**
65
47
  * Resolve a {@link WorkflowRef} to its registered workflow name: a string is returned as-is; a
66
- * `@Workflow` class is resolved via the name the decorator stamped in its metadata. Throws if a
67
- * class was never decorated (so it carries no registered name).
48
+ * workflow class is resolved via the name on its `static workflow` config. Throws if a class carries
49
+ * no `static workflow` config (so it has no registered name).
68
50
  */
69
51
  export declare function workflowName(ref: WorkflowRef): string;
70
52
  //# sourceMappingURL=workflow-ref.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-ref.d.ts","sourceRoot":"","sources":["../../src/workflow-ref.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,OAAO,MAAmD,CAAC;AAE3F,2DAA2D;AAC3D,MAAM,WAAW,eAAe;IAC9B,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAC;IACb,yFAAyF;IACzF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,IAAI,CAA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AM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,IACvD,MAAM,GACN,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEnC,uDAAuD;AACvD,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,CAAC,SAAS,QAAQ,MACjD,GAAG,IAAI,EAAE,KAAK,EAAE,KACb;IACH,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC;CAC1C,GACG,CAAC,GACD,OAAO,CAAC;AAEZ,gFAAgF;AAChF,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAAC,SAAS,QAAQ,MAClD,GAAG,IAAI,EAAE,KAAK,EAAE,KACb;IACH,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC,CAAC;CACxC,GACG,OAAO,CAAC,CAAC,CAAC,GACV,OAAO,CAAC;AAEZ;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,CASrD"}
@@ -6,53 +6,31 @@
6
6
  * string stays available for the cross-runtime case.
7
7
  */
8
8
  /**
9
- * The symbol the `@Workflow` decorator stamps the full options onto (name + version + tags …), so
10
- * auto-discovery can register the class against the engine and a class ref can be resolved back to
11
- * its name via {@link workflowName}. A global-registry symbol (`Symbol.for`) so it survives duplicate
12
- * copies of this package in a dependency tree.
9
+ * Read a class's {@link WorkflowMeta} its name/version/tags/… from its `static workflow =
10
+ * { name, version, }` config (the {@link BaseWorkflow} authoring form). Any absent `version` is
11
+ * normalized to `'1'`. Returns `undefined` for a class carrying no valid config (a class with no
12
+ * `static workflow`, or one whose `name` is not a string, is not a registrable workflow).
13
13
  */
14
- export const WORKFLOW_META_KEY = Symbol.for('@agora/durable:workflow-meta');
15
- /**
16
- * Class decorator marking a class as a durable workflow. Stamps the full options (name + version +
17
- * tags …) so a class ref resolves via {@link workflowName} and the provider's `app/workflows`
18
- * auto-discovery can register it on the engine — no manual `engine.register(...)`. The class must
19
- * expose `run(ctx, input)`; that method becomes the workflow body.
20
- *
21
- * ```ts
22
- * @Workflow({ name: 'order', version: '1' })
23
- * export default class OrderWorkflow {
24
- * async run(ctx: WorkflowCtx, input: { id: string }) { ... }
25
- * }
26
- * ```
27
- */
28
- export function Workflow(options) {
29
- return (target) => {
30
- const meta = { ...options, version: options.version ?? '1' };
31
- Object.defineProperty(target, WORKFLOW_META_KEY, {
32
- value: meta,
33
- enumerable: false,
34
- configurable: true,
35
- });
36
- return target;
37
- };
38
- }
39
- /** Read the {@link WorkflowMeta} a `@Workflow` decorator stamped on a class, or `undefined`. */
40
14
  export function workflowMeta(target) {
41
15
  if (typeof target !== 'function')
42
16
  return undefined;
43
- return target[WORKFLOW_META_KEY];
17
+ const config = target.workflow;
18
+ if (config && typeof config === 'object' && typeof config.name === 'string') {
19
+ return { ...config, version: config.version ?? '1' };
20
+ }
21
+ return undefined;
44
22
  }
45
23
  /**
46
24
  * Resolve a {@link WorkflowRef} to its registered workflow name: a string is returned as-is; a
47
- * `@Workflow` class is resolved via the name the decorator stamped in its metadata. Throws if a
48
- * class was never decorated (so it carries no registered name).
25
+ * workflow class is resolved via the name on its `static workflow` config. Throws if a class carries
26
+ * no `static workflow` config (so it has no registered name).
49
27
  */
50
28
  export function workflowName(ref) {
51
29
  if (typeof ref === 'string')
52
30
  return ref;
53
31
  const name = workflowMeta(ref)?.name;
54
32
  if (!name) {
55
- throw new Error(`workflow class ${ref.name} has no registered name — is it decorated with @Workflow({ name })?`);
33
+ throw new Error(`workflow class ${ref.name} has no registered name — does it declare \`static workflow = { name }\`?`);
56
34
  }
57
35
  return name;
58
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-ref.js","sourceRoot":"","sources":["../../src/workflow-ref.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAkB,MAAM,CAAC,GAAG,C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,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC5E,OAAO,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,GAAG,EAAE,CAAC;IACvD,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAgCD;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,GAAgB;IAC3C,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC;IACxC,MAAM,IAAI,GAAG,YAAY,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;IACrC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CACb,kBAAkB,GAAG,CAAC,IAAI,2EAA2E,CACtG,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -5,7 +5,7 @@ import { BaseSchema } from '@adonisjs/lucid/schema'
5
5
 
6
6
  /**
7
7
  * Durable workflow tables for the @adonis-agora/durable `lucid` state store: runs, step checkpoints, the
8
- * search-attribute side-table, signal waiters and buffered signals. JSON payloads are stored as TEXT (the store
8
+ * search-attribute side-table, signal waiters, buffered signals and buffered events. JSON payloads are stored as TEXT (the store
9
9
  * (de)serializes them) and timestamps as epoch-ms integers, so the schema is portable across
10
10
  * SQLite / Postgres / MySQL.
11
11
  */
@@ -79,9 +79,21 @@ export default class extends BaseSchema {
79
79
  table.text('payload')
80
80
  table.index(['token'], 'durable_buffered_signals_token_idx')
81
81
  })
82
+
83
+ // Reliable (buffered) events: a publish matching no live waiter keeps ONE copy here, consumed by
84
+ // the first future matching `waitForEvent`. Keyed by `name` (many waiters share a name with
85
+ // different `match`); `id` is the caller-minted PK; `published_at` is epoch-ms.
86
+ this.schema.createTable('durable_buffered_events', (table) => {
87
+ table.string('id').primary()
88
+ table.string('name').notNullable()
89
+ table.text('payload')
90
+ table.bigInteger('published_at').notNullable()
91
+ table.index(['name', 'published_at'], 'durable_buffered_events_name_idx')
92
+ })
82
93
  }
83
94
 
84
95
  async down() {
96
+ this.schema.dropTableIfExists('durable_buffered_events')
85
97
  this.schema.dropTableIfExists('durable_buffered_signals')
86
98
  this.schema.dropTableIfExists('durable_signal_waiters')
87
99
  this.schema.dropTableIfExists('durable_run_attributes')
@@ -6,15 +6,16 @@
6
6
  to: app.makePath('app/workflows', entity.path, workflowFileName + '.ts')
7
7
  })
8
8
  }}}
9
- import { Workflow } from '@adonis-agora/durable'
9
+ import { BaseWorkflow } from '@adonis-agora/durable'
10
10
  import type { WorkflowCtx } from '@adonis-agora/durable'
11
11
 
12
12
  interface {{ workflowName }}Input {
13
13
  // Define your workflow input here
14
14
  }
15
15
 
16
- @Workflow({ name: '{{ registeredName }}', version: '1' })
17
- export default class {{ workflowName }}Workflow {
16
+ export default class {{ workflowName }}Workflow extends BaseWorkflow {
17
+ static workflow = { name: '{{ registeredName }}', version: '1' }
18
+
18
19
  async run(ctx: WorkflowCtx, input: {{ workflowName }}Input) {
19
20
  // Your workflow logic here — compose ctx.step / ctx.localStep / ctx.child / ctx.sleep …
20
21
  return input
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adonis-agora/durable",
3
- "version": "0.7.0",
3
+ "version": "0.8.1",
4
4
  "description": "Durable cross-app workflows for AdonisJS — deterministic replay engine, AdonisJS binding, ace commands, dashboard, OpenTelemetry, Telescope, testing harness and Redis admission, all in one package. Part of the Agora ecosystem.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -18,6 +18,11 @@
18
18
  "import": "./dist/src/index.js",
19
19
  "default": "./dist/src/index.js"
20
20
  },
21
+ "./services/main": {
22
+ "types": "./dist/src/services/main.d.ts",
23
+ "import": "./dist/src/services/main.js",
24
+ "default": "./dist/src/services/main.js"
25
+ },
21
26
  "./durable_provider": {
22
27
  "types": "./dist/providers/durable_provider.d.ts",
23
28
  "import": "./dist/providers/durable_provider.js",