@kubun/plugin-workflow-api 0.15.0 → 0.16.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/lib/index.d.ts +11 -0
- package/lib/index.js +31 -1
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -38,6 +38,10 @@ export type WorkflowDefinition<State extends Record<string, unknown> = Record<st
|
|
|
38
38
|
retry?: RetryPolicy;
|
|
39
39
|
onTerminal?: (info: TerminalInfo) => void;
|
|
40
40
|
managed?: boolean;
|
|
41
|
+
remote?: {
|
|
42
|
+
observe?: boolean;
|
|
43
|
+
command?: boolean;
|
|
44
|
+
};
|
|
41
45
|
};
|
|
42
46
|
export type WorkflowEvents = {
|
|
43
47
|
started: {
|
|
@@ -85,6 +89,10 @@ export type ListFilter = {
|
|
|
85
89
|
queue?: string;
|
|
86
90
|
status?: WorkflowStatus;
|
|
87
91
|
};
|
|
92
|
+
export declare const RETRY_REFUSAL_REASONS: readonly ["not_found", "not_failed", "no_next_action", "singleton"];
|
|
93
|
+
export type RetryRefusalReason = (typeof RETRY_REFUSAL_REASONS)[number];
|
|
94
|
+
export declare const COMMAND_REFUSAL_REASONS: readonly ["not_commandable", "not_found", "not_failed", "no_next_action", "singleton"];
|
|
95
|
+
export type CommandRefusalReason = (typeof COMMAND_REFUSAL_REASONS)[number];
|
|
88
96
|
export type QueueOptions = {
|
|
89
97
|
concurrency: number;
|
|
90
98
|
ratePerMinute?: number;
|
|
@@ -112,6 +120,8 @@ export type PeriodicSync = {
|
|
|
112
120
|
export type WorkflowAPI = {
|
|
113
121
|
register<State extends Record<string, unknown>, Handlers extends HandlersRecord<State> = HandlersRecord<State>>(def: WorkflowDefinition<State, Handlers>): void;
|
|
114
122
|
isManagedWorkflow(name: string): boolean;
|
|
123
|
+
isRemotelyObservable(name: string): boolean;
|
|
124
|
+
isRemotelyCommandable(name: string): boolean;
|
|
115
125
|
defineQueue(name: string, opts: QueueOptions): void;
|
|
116
126
|
enqueue(name: string, params?: unknown, opts?: EnqueueOptions): Promise<InstanceHandle>;
|
|
117
127
|
schedule(name: string, params: unknown, when: ScheduleSpec): Promise<ScheduleHandle>;
|
|
@@ -121,6 +131,7 @@ export type WorkflowAPI = {
|
|
|
121
131
|
reactivate?: boolean;
|
|
122
132
|
}): Promise<ScheduleHandle>;
|
|
123
133
|
cancel(instanceID: string): Promise<void>;
|
|
134
|
+
retry(instanceID: string): Promise<InstanceStatus>;
|
|
124
135
|
get(instanceID: string): Promise<InstanceStatus | null>;
|
|
125
136
|
list(filter?: ListFilter): Promise<Array<InstanceStatus>>;
|
|
126
137
|
getCurrentInstance(name: string, singletonKey: string): Promise<InstanceStatus | null>;
|
package/lib/index.js
CHANGED
|
@@ -4,4 +4,34 @@
|
|
|
4
4
|
// runtime edge on the workflow plugin, so a consumer stays independently
|
|
5
5
|
// loadable. The plugin implements these; the pure policy math and `defineWorkflow`
|
|
6
6
|
// stay in @kubun/plugin-workflow.
|
|
7
|
-
|
|
7
|
+
// Why an operator retry refused, when it did not re-arm. Never a silent false
|
|
8
|
+
// success: `retry` throws a typed error carrying one of these.
|
|
9
|
+
// - `not_found`: no instance with that id.
|
|
10
|
+
// - `not_failed`: the instance is not in `failed` (already re-armed, running,
|
|
11
|
+
// or terminal-completed/cancelled) — includes losing the race to a concurrent
|
|
12
|
+
// retry that flipped it out of `failed` first.
|
|
13
|
+
// - `no_next_action`: a failed row with no resumable action; re-arming it would
|
|
14
|
+
// fabricate an entry point, so it is refused rather than restarted.
|
|
15
|
+
// - `singleton`: a live (pending/running) instance already holds the same
|
|
16
|
+
// (name, singletonKey); re-arming would create a second live singleton.
|
|
17
|
+
//
|
|
18
|
+
// Runtime const, not just a type: consumers that cannot value-import the engine
|
|
19
|
+
// (e.g. plugin-p2p's type-only boundary) still need the exact reason set at
|
|
20
|
+
// runtime to recover a structurally-caught refusal, so this is the one place
|
|
21
|
+
// that set is spelled out.
|
|
22
|
+
export const RETRY_REFUSAL_REASONS = [
|
|
23
|
+
'not_found',
|
|
24
|
+
'not_failed',
|
|
25
|
+
'no_next_action',
|
|
26
|
+
'singleton'
|
|
27
|
+
];
|
|
28
|
+
// The full reason set a DIRECTED group command can refuse with: the engine's own
|
|
29
|
+
// retry refusals plus `not_commandable`, which only the p2p command boundary
|
|
30
|
+
// raises (a workflow that did not opt into remote command). Single-sourced here so
|
|
31
|
+
// the p2p wire schema and the caller-facing contract type both derive from ONE
|
|
32
|
+
// list and cannot drift — the wire enum spreads this, the contract's reason type
|
|
33
|
+
// aliases CommandRefusalReason.
|
|
34
|
+
export const COMMAND_REFUSAL_REASONS = [
|
|
35
|
+
'not_commandable',
|
|
36
|
+
...RETRY_REFUSAL_REASONS
|
|
37
|
+
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubun/plugin-workflow-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"license": "see LICENSE.md",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"LICENSE.md"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@kubun/store-workflow": "^0.
|
|
18
|
+
"@kubun/store-workflow": "^0.16.0",
|
|
19
19
|
"@sozai/event": "^0.1.3",
|
|
20
20
|
"@sozai/flow": "^0.3.1",
|
|
21
21
|
"@sozai/schema": "^0.1.2"
|