@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.
- package/CHANGELOG.md +81 -0
- package/README.md +1 -1
- package/dist/commands/main.d.ts +3 -2
- package/dist/commands/main.d.ts.map +1 -1
- package/dist/commands/main.js +3 -2
- package/dist/commands/main.js.map +1 -1
- package/dist/commands/make_workflow.d.ts +4 -3
- package/dist/commands/make_workflow.d.ts.map +1 -1
- package/dist/commands/make_workflow.js +4 -3
- package/dist/commands/make_workflow.js.map +1 -1
- package/dist/configure.d.ts +6 -5
- package/dist/configure.d.ts.map +1 -1
- package/dist/configure.js +9 -6
- package/dist/configure.js.map +1 -1
- package/dist/providers/dashboard_provider.d.ts +34 -3
- package/dist/providers/dashboard_provider.d.ts.map +1 -1
- package/dist/providers/dashboard_provider.js +130 -9
- package/dist/providers/dashboard_provider.js.map +1 -1
- package/dist/src/base-workflow.d.ts +78 -0
- package/dist/src/base-workflow.d.ts.map +1 -0
- package/dist/src/base-workflow.js +106 -0
- package/dist/src/base-workflow.js.map +1 -0
- package/dist/src/codec-state-store.d.ts +13 -0
- package/dist/src/codec-state-store.d.ts.map +1 -1
- package/dist/src/codec-state-store.js +13 -0
- package/dist/src/codec-state-store.js.map +1 -1
- package/dist/src/control-flow-signal.d.ts +50 -0
- package/dist/src/control-flow-signal.d.ts.map +1 -0
- package/dist/src/control-flow-signal.js +54 -0
- package/dist/src/control-flow-signal.js.map +1 -0
- package/dist/src/control-plane-redis/redis-control-plane.d.ts +57 -5
- package/dist/src/control-plane-redis/redis-control-plane.d.ts.map +1 -1
- package/dist/src/control-plane-redis/redis-control-plane.js +100 -2
- package/dist/src/control-plane-redis/redis-control-plane.js.map +1 -1
- package/dist/src/dashboard/auth.d.ts +89 -0
- package/dist/src/dashboard/auth.d.ts.map +1 -0
- package/dist/src/dashboard/auth.js +113 -0
- package/dist/src/dashboard/auth.js.map +1 -0
- package/dist/src/dashboard/define_config.d.ts +17 -0
- package/dist/src/dashboard/define_config.d.ts.map +1 -1
- package/dist/src/dashboard/define_config.js +23 -1
- package/dist/src/dashboard/define_config.js.map +1 -1
- package/dist/src/dashboard/index.d.ts +5 -0
- package/dist/src/dashboard/index.d.ts.map +1 -1
- package/dist/src/dashboard/index.js +4 -0
- package/dist/src/dashboard/index.js.map +1 -1
- package/dist/src/dashboard/login_page.d.ts +23 -0
- package/dist/src/dashboard/login_page.d.ts.map +1 -0
- package/dist/src/dashboard/login_page.js +170 -0
- package/dist/src/dashboard/login_page.js.map +1 -0
- package/dist/src/dashboard/session_cookie.d.ts +42 -0
- package/dist/src/dashboard/session_cookie.d.ts.map +1 -0
- package/dist/src/dashboard/session_cookie.js +97 -0
- package/dist/src/dashboard/session_cookie.js.map +1 -0
- package/dist/src/define_config.d.ts +3 -2
- package/dist/src/define_config.d.ts.map +1 -1
- package/dist/src/define_config.js.map +1 -1
- package/dist/src/engine.d.ts +51 -1
- package/dist/src/engine.d.ts.map +1 -1
- package/dist/src/engine.js +213 -27
- package/dist/src/engine.js.map +1 -1
- package/dist/src/errors.d.ts +6 -1
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +7 -2
- package/dist/src/errors.js.map +1 -1
- package/dist/src/event-accumulators.d.ts +1 -1
- package/dist/src/event-accumulators.d.ts.map +1 -1
- package/dist/src/events.d.ts +16 -0
- package/dist/src/events.d.ts.map +1 -1
- package/dist/src/events.js +26 -1
- package/dist/src/events.js.map +1 -1
- package/dist/src/hooks/workflows.d.ts +3 -2
- package/dist/src/hooks/workflows.d.ts.map +1 -1
- package/dist/src/hooks/workflows.js +3 -2
- package/dist/src/hooks/workflows.js.map +1 -1
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/interfaces.d.ts +44 -1
- package/dist/src/interfaces.d.ts.map +1 -1
- package/dist/src/services/main.d.ts +13 -0
- package/dist/src/services/main.d.ts.map +1 -0
- package/dist/src/services/main.js +17 -0
- package/dist/src/services/main.js.map +1 -0
- package/dist/src/step-name-symbol.d.ts +2 -2
- package/dist/src/step-name-symbol.js +2 -2
- package/dist/src/stores/lucid-schema.d.ts +1 -0
- package/dist/src/stores/lucid-schema.d.ts.map +1 -1
- package/dist/src/stores/lucid-schema.js +15 -0
- package/dist/src/stores/lucid-schema.js.map +1 -1
- package/dist/src/stores/lucid.d.ts +13 -0
- package/dist/src/stores/lucid.d.ts.map +1 -1
- package/dist/src/stores/lucid.js +43 -0
- package/dist/src/stores/lucid.js.map +1 -1
- package/dist/src/testing/in-memory-state-store.d.ts +16 -0
- package/dist/src/testing/in-memory-state-store.d.ts.map +1 -1
- package/dist/src/testing/in-memory-state-store.js +29 -0
- package/dist/src/testing/in-memory-state-store.js.map +1 -1
- package/dist/src/testing-kit/state-store-conformance.d.ts.map +1 -1
- package/dist/src/testing-kit/state-store-conformance.js +31 -0
- package/dist/src/testing-kit/state-store-conformance.js.map +1 -1
- package/dist/src/workflow-als.d.ts +21 -0
- package/dist/src/workflow-als.d.ts.map +1 -0
- package/dist/src/workflow-als.js +22 -0
- package/dist/src/workflow-als.js.map +1 -0
- package/dist/src/workflow-ctx.d.ts.map +1 -1
- package/dist/src/workflow-ctx.js +83 -4
- package/dist/src/workflow-ctx.js.map +1 -1
- package/dist/src/workflow-discovery.d.ts +21 -15
- package/dist/src/workflow-discovery.d.ts.map +1 -1
- package/dist/src/workflow-discovery.js +17 -13
- package/dist/src/workflow-discovery.js.map +1 -1
- package/dist/src/workflow-ref.d.ts +9 -27
- package/dist/src/workflow-ref.d.ts.map +1 -1
- package/dist/src/workflow-ref.js +12 -34
- package/dist/src/workflow-ref.js.map +1 -1
- package/dist/stubs/database/migrations/create_durable_tables.stub +13 -1
- package/dist/stubs/make/workflow/main.stub +4 -3
- 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
|
|
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
|
|
10
|
-
*
|
|
11
|
-
* `engine.register(name, version, fn)`
|
|
12
|
-
* `app/workflows` convention builds on. No-op
|
|
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
|
|
17
|
-
* (the default export and any named export are considered) — so nested
|
|
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
|
|
27
|
-
* registered metadata so the caller can log what was wired.
|
|
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
|
|
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
|
|
39
|
-
* each lazy module import and registering each
|
|
40
|
-
* {@link registerWorkflowsFromDir}, with no runtime
|
|
41
|
-
*
|
|
42
|
-
* Returns the registered metadata so the caller can log
|
|
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
|
|
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
|
|
7
|
-
*
|
|
8
|
-
* `engine.register(name, version, fn)`
|
|
9
|
-
* `app/workflows` convention builds on. No-op
|
|
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
|
|
33
|
-
* (the default export and any named export are considered) — so nested
|
|
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
|
|
70
|
-
* registered metadata so the caller can log what was wired.
|
|
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
|
|
80
|
-
* each lazy module import and registering each
|
|
81
|
-
* {@link registerWorkflowsFromDir}, with no runtime
|
|
82
|
-
*
|
|
83
|
-
* Returns the registered metadata so the caller can log
|
|
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;
|
|
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,I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IAEX,MAAM,UAAU,GAAG,MAAM,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAChD,KAAK,MAAM,EAAE,GAAG,EAAE,IAAI,UAAU;QAAE,qBAAqB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACrE,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACvC,CAAC;AAWD;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,MAAsB,EACtB,MAAuB;IAEvB,MAAM,UAAU,GAAmB,EAAE,CAAC;IACtC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAW,CAAC;IAChC,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QACzC,MAAM,GAAG,GAAG,MAAM,IAAI,EAAE,CAAC;QACzB,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1C,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC;gBAAE,SAAS;YACjC,MAAM,IAAI,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;YACpC,IAAI,CAAC,IAAI;gBAAE,SAAS;YACpB,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACnB,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
|
|
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
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
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
|
|
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
|
-
*
|
|
67
|
-
*
|
|
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
|
|
1
|
+
{"version":3,"file":"workflow-ref.d.ts","sourceRoot":"","sources":["../../src/workflow-ref.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,2GAA2G;AAC3G,MAAM,WAAW,eAAe;IAC9B,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAC;IACb,yFAAyF;IACzF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,kFAAkF;IAClF,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACnC,oFAAoF;IACpF,OAAO,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6,31 @@
|
|
|
6
6
|
* string stays available for the cross-runtime case.
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
48
|
-
*
|
|
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 —
|
|
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;
|
|
1
|
+
{"version":3,"file":"workflow-ref.js","sourceRoot":"","sources":["../../src/workflow-ref.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAqBH;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,MAAe;IAC1C,IAAI,OAAO,MAAM,KAAK,UAAU;QAAE,OAAO,SAAS,CAAC;IACnD,MAAM,MAAM,GAAI,MAAyC,CAAC,QAAQ,CAAC;IACnE,IAAI,MAAM,IAAI,OAAO,MAAM,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
|
|
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 {
|
|
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
|
-
|
|
17
|
-
|
|
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.
|
|
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",
|