@adonis-agora/durable 0.19.2 → 0.20.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.
- package/CHANGELOG.md +16 -0
- package/dist/src/dashboard/index.d.ts +1 -1
- package/dist/src/dashboard/index.js +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/workflow-ref.d.ts +25 -1
- package/dist/src/workflow-ref.d.ts.map +1 -1
- package/dist/src/workflow-ref.js +31 -0
- package/dist/src/workflow-ref.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @adonis-agora/durable
|
|
2
2
|
|
|
3
|
+
## 0.20.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#43](https://github.com/DavideCarvalho/adonis-durable/pull/43) [`b4ba291`](https://github.com/DavideCarvalho/adonis-durable/commit/b4ba2916c3e8cdb198e86c60b7aac403df4df3d2) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - New `@Scheduled(...)` class decorator — the decorator form of the colocated `static schedule`. It only stamps `static schedule` on the class; normalization (key defaults, `workflow` fill-in, the `static workflow` requirement) stays in `workflowSchedules`, so both authoring forms behave identically:
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
@Scheduled({ cron: '0 4 * * *', timezone: 'America/Sao_Paulo' })
|
|
11
|
+
export default class CrawlWorkflow extends BaseWorkflow {
|
|
12
|
+
static workflow = { name: 'crawl' }
|
|
13
|
+
async run(ctx: WorkflowCtx) { … }
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Repeated applications and an existing `static schedule` literal compose, accumulating in source order (top decorator first, then the literal). With several schedules on one class, prefer explicit `key`s over the positional `${name}:${i}` defaults — the key is part of the deterministic run id, and reordering declarations would silently re-key them.
|
|
18
|
+
|
|
3
19
|
## 0.19.2
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Keep in sync with this package's `version` in package.json. */
|
|
2
|
-
export declare const VERSION = "0.
|
|
2
|
+
export declare const VERSION = "0.20.0";
|
|
3
3
|
export { defineConfig, defaultAuthorize, resolveConfig } from './define_config.js';
|
|
4
4
|
export type { AuthorizeHook, DurableDashboardConfig, ResolvedDurableDashboardConfig, } from './define_config.js';
|
|
5
5
|
export { listRuns, getRun, retryRun, redispatchPendingRun, cancelRun, health, ok, } from './handlers.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Keep in sync with this package's `version` in package.json. */
|
|
2
|
-
export const VERSION = '0.
|
|
2
|
+
export const VERSION = '0.20.0';
|
|
3
3
|
export { defineConfig, defaultAuthorize, resolveConfig } from './define_config.js';
|
|
4
4
|
export { listRuns, getRun, retryRun, redispatchPendingRun, cancelRun, health, ok, } from './handlers.js';
|
|
5
5
|
export { renderDashboard } from './html.js';
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Keep in sync with this package's `version` in package.json. */
|
|
2
|
-
export const VERSION = '0.
|
|
2
|
+
export const VERSION = '0.20.0';
|
|
3
3
|
// --- engine + core primitives -----------------------------------------------
|
|
4
4
|
export * from './admission.js';
|
|
5
5
|
export * from './control-flow-signal.js';
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* string stays available for the cross-runtime case.
|
|
7
7
|
*/
|
|
8
8
|
import type { SingletonConfig } from './engine.js';
|
|
9
|
-
import type { ScheduledWorkflow } from './scheduler.js';
|
|
9
|
+
import type { ScheduledWorkflow, WorkflowScheduleConfig } from './scheduler.js';
|
|
10
10
|
/** Options for a workflow's `static workflow = { name, version, … }` config (see {@link BaseWorkflow}). */
|
|
11
11
|
export interface WorkflowOptions {
|
|
12
12
|
/** The registered workflow name (the cross-runtime identity, e.g. `order`). */
|
|
@@ -54,6 +54,30 @@ export declare function workflowMeta(target: unknown): WorkflowMeta | undefined;
|
|
|
54
54
|
* (not a registrable workflow) or no `static schedule`.
|
|
55
55
|
*/
|
|
56
56
|
export declare function workflowSchedules(target: unknown): ScheduledWorkflow[];
|
|
57
|
+
/**
|
|
58
|
+
* Class-decorator form of the colocated schedule — the same declaration `static schedule = {...}`
|
|
59
|
+
* makes, for codebases that prefer decorators:
|
|
60
|
+
*
|
|
61
|
+
* ```ts
|
|
62
|
+
* @Scheduled({ cron: '0 4 * * *', timezone: 'America/Sao_Paulo' })
|
|
63
|
+
* export default class CrawlWorkflow extends BaseWorkflow {
|
|
64
|
+
* static workflow = { name: 'crawl' }
|
|
65
|
+
* async run(ctx: WorkflowCtx) { … }
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* It only stamps `static schedule` on the class — normalization (key defaults, `workflow` fill-in)
|
|
70
|
+
* stays in {@link workflowSchedules}, so both authoring forms behave identically, including the
|
|
71
|
+
* requirement of a `static workflow` config (a decorated class without one is not registrable and
|
|
72
|
+
* its schedules are ignored, same as a bare `static schedule`).
|
|
73
|
+
*
|
|
74
|
+
* Composes: repeated `@Scheduled(...)` applications and an existing `static schedule` accumulate.
|
|
75
|
+
* Decorators apply bottom-up, so each application PREPENDS — the final array reads in **source
|
|
76
|
+
* order** (top decorator first, then lower ones, then the `static schedule` literal). With several
|
|
77
|
+
* schedules on one class, prefer explicit `key`s over the positional `${name}:${i}` defaults: the
|
|
78
|
+
* key is part of the deterministic run id, and reordering declarations would silently re-key them.
|
|
79
|
+
*/
|
|
80
|
+
export declare function Scheduled(config: WorkflowScheduleConfig | WorkflowScheduleConfig[]): ClassDecorator;
|
|
57
81
|
/** Structural shape of a workflow class — its `run(ctx, input)` carries the input/output types. */
|
|
58
82
|
export type WorkflowClass<TInput = unknown, TOutput = unknown> = abstract new (...args: never[]) => {
|
|
59
83
|
run(ctx: never, input: TInput): Promise<TOutput> | TOutput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-ref.d.ts","sourceRoot":"","sources":["../../src/workflow-ref.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"workflow-ref.d.ts","sourceRoot":"","sources":["../../src/workflow-ref.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAEhF,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,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B;AAED,sGAAsG;AACtG,MAAM,WAAW,YAAa,SAAQ,eAAe;IACnD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,YAAY,GAAG,SAAS,CAOtE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,iBAAiB,EAAE,CAWtE;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,sBAAsB,GAAG,sBAAsB,EAAE,GACxD,cAAc,CAUhB;AAED,mGAAmG;AACnG,MAAM,MAAM,aAAa,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,QAAQ,MACvE,GAAG,IAAI,EAAE,KAAK,EAAE,KACb;IACH,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;CAC5D,CAAC;AAEF,yGAAyG;AACzG,MAAM,MAAM,WAAW,CAAC,MAAM,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"}
|
package/dist/src/workflow-ref.js
CHANGED
|
@@ -46,6 +46,37 @@ export function workflowSchedules(target) {
|
|
|
46
46
|
key: s.key ?? (arr.length > 1 ? `${meta.name}:${i}` : meta.name),
|
|
47
47
|
}));
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Class-decorator form of the colocated schedule — the same declaration `static schedule = {...}`
|
|
51
|
+
* makes, for codebases that prefer decorators:
|
|
52
|
+
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* @Scheduled({ cron: '0 4 * * *', timezone: 'America/Sao_Paulo' })
|
|
55
|
+
* export default class CrawlWorkflow extends BaseWorkflow {
|
|
56
|
+
* static workflow = { name: 'crawl' }
|
|
57
|
+
* async run(ctx: WorkflowCtx) { … }
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* It only stamps `static schedule` on the class — normalization (key defaults, `workflow` fill-in)
|
|
62
|
+
* stays in {@link workflowSchedules}, so both authoring forms behave identically, including the
|
|
63
|
+
* requirement of a `static workflow` config (a decorated class without one is not registrable and
|
|
64
|
+
* its schedules are ignored, same as a bare `static schedule`).
|
|
65
|
+
*
|
|
66
|
+
* Composes: repeated `@Scheduled(...)` applications and an existing `static schedule` accumulate.
|
|
67
|
+
* Decorators apply bottom-up, so each application PREPENDS — the final array reads in **source
|
|
68
|
+
* order** (top decorator first, then lower ones, then the `static schedule` literal). With several
|
|
69
|
+
* schedules on one class, prefer explicit `key`s over the positional `${name}:${i}` defaults: the
|
|
70
|
+
* key is part of the deterministic run id, and reordering declarations would silently re-key them.
|
|
71
|
+
*/
|
|
72
|
+
export function Scheduled(config) {
|
|
73
|
+
return (target) => {
|
|
74
|
+
const cls = target;
|
|
75
|
+
const existing = cls.schedule === undefined ? [] : Array.isArray(cls.schedule) ? cls.schedule : [cls.schedule];
|
|
76
|
+
const added = Array.isArray(config) ? config : [config];
|
|
77
|
+
cls.schedule = [...added, ...existing];
|
|
78
|
+
};
|
|
79
|
+
}
|
|
49
80
|
/**
|
|
50
81
|
* Resolve a {@link WorkflowRef} to its registered workflow name: a string is returned as-is; a
|
|
51
82
|
* workflow class is resolved via the name on its `static workflow` config. Throws if a class carries
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-ref.js","sourceRoot":"","sources":["../../src/workflow-ref.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAkCH;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,MAA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
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonis-agora/durable",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
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": {
|