@aikirun/types 0.6.0 → 0.7.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/dist/error.d.ts +4 -4
- package/dist/event.d.ts +5 -5
- package/dist/workflow-run-api.d.ts +18 -6
- package/dist/workflow-run.d.ts +32 -5
- package/dist/workflow-run.js +11 -1
- package/package.json +1 -1
package/dist/error.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
type
|
|
2
|
-
[key: string]:
|
|
3
|
-
} |
|
|
1
|
+
type Serializable = null | string | number | boolean | {
|
|
2
|
+
[key: string]: Serializable;
|
|
3
|
+
} | Serializable[];
|
|
4
4
|
interface SerializableError {
|
|
5
5
|
message: string;
|
|
6
6
|
name: string;
|
|
@@ -8,4 +8,4 @@ interface SerializableError {
|
|
|
8
8
|
cause?: SerializableError;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export type {
|
|
11
|
+
export type { Serializable, SerializableError };
|
package/dist/event.d.ts
CHANGED
|
@@ -14,16 +14,16 @@ interface EventStateReceived<Data> extends EventStateBase {
|
|
|
14
14
|
receivedAt: number;
|
|
15
15
|
idempotencyKey?: string;
|
|
16
16
|
}
|
|
17
|
-
interface
|
|
17
|
+
interface EventStateTimeout extends EventStateBase {
|
|
18
18
|
status: "timeout";
|
|
19
19
|
timedOutAt: number;
|
|
20
20
|
}
|
|
21
|
-
type EventState<Data> = EventStateReceived<Data> |
|
|
21
|
+
type EventState<Data> = EventStateReceived<Data> | EventStateTimeout;
|
|
22
22
|
interface EventQueue<Data> {
|
|
23
23
|
events: EventState<Data>[];
|
|
24
24
|
}
|
|
25
|
-
interface EventWaitOptions<
|
|
26
|
-
timeout?:
|
|
25
|
+
interface EventWaitOptions<Timed extends boolean> {
|
|
26
|
+
timeout?: Timed extends true ? DurationObject : never;
|
|
27
27
|
}
|
|
28
28
|
type EventWaitState<Data, Timed extends boolean> = Timed extends false ? {
|
|
29
29
|
data: Data;
|
|
@@ -37,4 +37,4 @@ interface EventSendOptions {
|
|
|
37
37
|
idempotencyKey?: string;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export type { EventId, EventQueue, EventSendOptions, EventState, EventStateReceived,
|
|
40
|
+
export type { EventId, EventQueue, EventSendOptions, EventState, EventStateReceived, EventStateTimeout, EventStatus, EventWaitOptions, EventWaitState };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EventSendOptions } from './event.js';
|
|
2
2
|
import { TaskState, TaskStateAwaitingRetry } from './task.js';
|
|
3
3
|
import { DistributiveOmit } from './utils.js';
|
|
4
|
-
import { WorkflowRunStatus, WorkflowRun, WorkflowRunState, WorkflowOptions, WorkflowRunStateScheduled, WorkflowRunStateAwaitingEvent, WorkflowRunStateAwaitingRetry, WorkflowRunStatePaused, WorkflowRunStateCancelled, WorkflowRunTransition } from './workflow-run.js';
|
|
4
|
+
import { WorkflowRunStatus, WorkflowRun, WorkflowRunState, WorkflowOptions, WorkflowRunStateScheduled, WorkflowRunStateAwaitingEvent, WorkflowRunStateAwaitingRetry, WorkflowRunStateAwaitingChildWorkflow, WorkflowRunStatePaused, WorkflowRunStateCancelled, WorkflowRunTransition } from './workflow-run.js';
|
|
5
5
|
import './duration.js';
|
|
6
6
|
import './error.js';
|
|
7
7
|
import './retry.js';
|
|
@@ -17,6 +17,7 @@ interface WorkflowRunApi {
|
|
|
17
17
|
transitionTaskStateV1: (input: WorkflowRunTransitionTaskStateRequestV1) => Promise<WorkflowRunTransitionTaskStateResponseV1>;
|
|
18
18
|
listTransitionsV1: (input: WorkflowRunListTransitionsRequestV1) => Promise<WorkflowRunListTransitionsResponseV1>;
|
|
19
19
|
sendEventV1: (input: WorkflowRunSendEventRequestV1) => Promise<WorkflowRunSendEventResponseV1>;
|
|
20
|
+
multicastEventV1: (input: WorkflowRunMulticastEventRequestV1) => Promise<void>;
|
|
20
21
|
}
|
|
21
22
|
interface WorkflowRunListRequestV1 {
|
|
22
23
|
limit?: number;
|
|
@@ -60,6 +61,8 @@ interface WorkflowRunCreateRequestV1 {
|
|
|
60
61
|
workflowId: string;
|
|
61
62
|
workflowVersionId: string;
|
|
62
63
|
input: unknown;
|
|
64
|
+
path?: string;
|
|
65
|
+
parentWorkflowRunId?: string;
|
|
63
66
|
options?: WorkflowOptions;
|
|
64
67
|
}
|
|
65
68
|
interface WorkflowRunCreateResponseV1 {
|
|
@@ -74,16 +77,19 @@ type WorkflowRunStateAwaitingEventRequest = DistributiveOmit<WorkflowRunStateAwa
|
|
|
74
77
|
type WorkflowRunStateAwaitingRetryRequest = DistributiveOmit<WorkflowRunStateAwaitingRetry, "nextAttemptAt"> & {
|
|
75
78
|
nextAttemptInMs: number;
|
|
76
79
|
};
|
|
80
|
+
type WorkflowRunStateAwaitingChildWorkflowRequest = DistributiveOmit<WorkflowRunStateAwaitingChildWorkflow, "timeoutAt"> & {
|
|
81
|
+
timeoutInMs?: number;
|
|
82
|
+
};
|
|
77
83
|
type WorkflowRunStateRequest = Exclude<WorkflowRunState, {
|
|
78
|
-
status: "scheduled" | "awaiting_event" | "awaiting_retry";
|
|
79
|
-
}> | WorkflowRunStateScheduledRequest | WorkflowRunStateAwaitingEventRequest | WorkflowRunStateAwaitingRetryRequest;
|
|
84
|
+
status: "scheduled" | "awaiting_event" | "awaiting_retry" | "awaiting_child_workflow";
|
|
85
|
+
}> | WorkflowRunStateScheduledRequest | WorkflowRunStateAwaitingEventRequest | WorkflowRunStateAwaitingRetryRequest | WorkflowRunStateAwaitingChildWorkflowRequest;
|
|
80
86
|
interface WorkflowRunTransitionStateRequestBase {
|
|
81
87
|
type: "optimistic" | "pessimistic";
|
|
82
88
|
id: string;
|
|
83
89
|
state: WorkflowRunStateRequest;
|
|
84
90
|
}
|
|
85
|
-
type WorkflowRunStateScheduledRequestOptimistic =
|
|
86
|
-
reason: "
|
|
91
|
+
type WorkflowRunStateScheduledRequestOptimistic = Extract<WorkflowRunStateScheduledRequest, {
|
|
92
|
+
reason: "retry" | "task_retry" | "event" | "child_workflow";
|
|
87
93
|
}>;
|
|
88
94
|
type WorkflowRunStateScheduledRequestPessimistic = Exclude<WorkflowRunStateScheduledRequest, WorkflowRunStateScheduledRequestOptimistic>;
|
|
89
95
|
interface WorkflowRunTransitionStateRequestOptimistic extends WorkflowRunTransitionStateRequestBase {
|
|
@@ -138,5 +144,11 @@ interface WorkflowRunSendEventRequestV1 {
|
|
|
138
144
|
interface WorkflowRunSendEventResponseV1 {
|
|
139
145
|
run: WorkflowRun;
|
|
140
146
|
}
|
|
147
|
+
interface WorkflowRunMulticastEventRequestV1 {
|
|
148
|
+
ids: string[];
|
|
149
|
+
eventId: string;
|
|
150
|
+
data: unknown;
|
|
151
|
+
options?: EventSendOptions;
|
|
152
|
+
}
|
|
141
153
|
|
|
142
|
-
export type { TaskStateAwaitingRetryRequest, TaskStateRequest, WorkflowRunApi, WorkflowRunCreateRequestV1, WorkflowRunCreateResponseV1, WorkflowRunGetByIdRequestV1, WorkflowRunGetByIdResponseV1, WorkflowRunGetStateRequestV1, WorkflowRunGetStateResponseV1, WorkflowRunListItem, WorkflowRunListRequestV1, WorkflowRunListResponseV1, WorkflowRunListTransitionsRequestV1, WorkflowRunListTransitionsResponseV1, WorkflowRunSendEventRequestV1, WorkflowRunSendEventResponseV1, WorkflowRunStateAwaitingEventRequest, WorkflowRunStateAwaitingRetryRequest, WorkflowRunStateRequest, WorkflowRunStateScheduledRequest, WorkflowRunStateScheduledRequestOptimistic, WorkflowRunStateScheduledRequestPessimistic, WorkflowRunTransitionStateRequestOptimistic, WorkflowRunTransitionStateRequestPessimistic, WorkflowRunTransitionStateRequestV1, WorkflowRunTransitionStateResponseV1, WorkflowRunTransitionTaskStateRequestV1, WorkflowRunTransitionTaskStateResponseV1 };
|
|
154
|
+
export type { TaskStateAwaitingRetryRequest, TaskStateRequest, WorkflowRunApi, WorkflowRunCreateRequestV1, WorkflowRunCreateResponseV1, WorkflowRunGetByIdRequestV1, WorkflowRunGetByIdResponseV1, WorkflowRunGetStateRequestV1, WorkflowRunGetStateResponseV1, WorkflowRunListItem, WorkflowRunListRequestV1, WorkflowRunListResponseV1, WorkflowRunListTransitionsRequestV1, WorkflowRunListTransitionsResponseV1, WorkflowRunMulticastEventRequestV1, WorkflowRunSendEventRequestV1, WorkflowRunSendEventResponseV1, WorkflowRunStateAwaitingChildWorkflowRequest, WorkflowRunStateAwaitingEventRequest, WorkflowRunStateAwaitingRetryRequest, WorkflowRunStateRequest, WorkflowRunStateScheduledRequest, WorkflowRunStateScheduledRequestOptimistic, WorkflowRunStateScheduledRequestPessimistic, WorkflowRunTransitionStateRequestOptimistic, WorkflowRunTransitionStateRequestPessimistic, WorkflowRunTransitionStateRequestV1, WorkflowRunTransitionStateResponseV1, WorkflowRunTransitionTaskStateRequestV1, WorkflowRunTransitionTaskStateResponseV1 };
|
package/dist/workflow-run.d.ts
CHANGED
|
@@ -10,9 +10,14 @@ import './utils.js';
|
|
|
10
10
|
type WorkflowRunId = string & {
|
|
11
11
|
_brand: "workflow_run_id";
|
|
12
12
|
};
|
|
13
|
+
type WorkflowRunPath = string & {
|
|
14
|
+
_brand: "workflow_run_path";
|
|
15
|
+
};
|
|
13
16
|
type WorkflowRunStatus = "scheduled" | "queued" | "running" | "paused" | "sleeping" | "awaiting_event" | "awaiting_retry" | "awaiting_child_workflow" | "cancelled" | "completed" | "failed";
|
|
14
|
-
|
|
17
|
+
declare const terminalWorkflowRunStatuses: readonly ["cancelled", "completed", "failed"];
|
|
18
|
+
type TerminalWorkflowRunStatus = (typeof terminalWorkflowRunStatuses)[number];
|
|
15
19
|
type NonTerminalWorkflowRunStatus = Exclude<WorkflowRunStatus, TerminalWorkflowRunStatus>;
|
|
20
|
+
declare function isTerminalWorkflowRunStatus(status: WorkflowRunStatus): status is TerminalWorkflowRunStatus;
|
|
16
21
|
interface WorkflowOptions {
|
|
17
22
|
retry?: RetryStrategy;
|
|
18
23
|
idempotencyKey?: string;
|
|
@@ -22,7 +27,7 @@ interface WorkflowOptions {
|
|
|
22
27
|
interface WorkflowRunStateBase {
|
|
23
28
|
status: WorkflowRunStatus;
|
|
24
29
|
}
|
|
25
|
-
type WorkflowRunScheduledReason = "new" | "retry" | "task_retry" | "awake" | "resume" | "event";
|
|
30
|
+
type WorkflowRunScheduledReason = "new" | "retry" | "task_retry" | "awake" | "resume" | "event" | "child_workflow";
|
|
26
31
|
interface WorkflowRunStateScheduledBase extends WorkflowRunStateBase {
|
|
27
32
|
status: "scheduled";
|
|
28
33
|
scheduledAt: number;
|
|
@@ -46,7 +51,10 @@ interface WorkflowRunStateScheduledByResume extends WorkflowRunStateScheduledBas
|
|
|
46
51
|
interface WorkflowRunStateScheduledByEvent extends WorkflowRunStateScheduledBase {
|
|
47
52
|
reason: "event";
|
|
48
53
|
}
|
|
49
|
-
|
|
54
|
+
interface WorkflowRunStateScheduledByChildWorkflow extends WorkflowRunStateScheduledBase {
|
|
55
|
+
reason: "child_workflow";
|
|
56
|
+
}
|
|
57
|
+
type WorkflowRunStateScheduled = WorkflowRunStateScheduledByNew | WorkflowRunStateScheduledByRetry | WorkflowRunStateScheduledByTaskRetry | WorkflowRunStateScheduledByAwake | WorkflowRunStateScheduledByResume | WorkflowRunStateScheduledByEvent | WorkflowRunStateScheduledByChildWorkflow;
|
|
50
58
|
interface WorkflowRunStateQueued extends WorkflowRunStateBase {
|
|
51
59
|
status: "queued";
|
|
52
60
|
reason: WorkflowRunScheduledReason;
|
|
@@ -88,6 +96,9 @@ interface WorkflowRunStateAwaitingRetryCausedBySelf extends WorkflowRunStateAwai
|
|
|
88
96
|
type WorkflowRunStateAwaitingRetry = WorkflowRunStateAwaitingRetryCausedByTask | WorkflowRunStateAwaitingRetryCausedByChildWorkflow | WorkflowRunStateAwaitingRetryCausedBySelf;
|
|
89
97
|
interface WorkflowRunStateAwaitingChildWorkflow extends WorkflowRunStateBase {
|
|
90
98
|
status: "awaiting_child_workflow";
|
|
99
|
+
childWorkflowRunPath: string;
|
|
100
|
+
childWorkflowRunStatus: WorkflowRunStatus;
|
|
101
|
+
timeoutAt?: number;
|
|
91
102
|
}
|
|
92
103
|
interface WorkflowRunStateCancelled extends WorkflowRunStateBase {
|
|
93
104
|
status: "cancelled";
|
|
@@ -123,13 +134,29 @@ interface WorkflowRun<Input = unknown, Output = unknown> {
|
|
|
123
134
|
createdAt: number;
|
|
124
135
|
revision: number;
|
|
125
136
|
input: Input;
|
|
137
|
+
path?: string;
|
|
126
138
|
options: WorkflowOptions;
|
|
127
139
|
attempts: number;
|
|
128
140
|
state: WorkflowRunState<Output>;
|
|
129
141
|
tasksState: Record<string, TaskState>;
|
|
130
142
|
sleepsState: Record<string, SleepState>;
|
|
131
143
|
eventsQueue: Record<string, EventQueue<unknown>>;
|
|
132
|
-
|
|
144
|
+
childWorkflowRuns: Record<string, ChildWorkflowRun>;
|
|
145
|
+
parentWorkflowRunId?: string;
|
|
146
|
+
}
|
|
147
|
+
interface ChildWorkflowRun {
|
|
148
|
+
id: string;
|
|
149
|
+
statusWaitResults: ChildWorkflowWaitResult[];
|
|
150
|
+
}
|
|
151
|
+
type ChildWorkflowWaitResult = ChildWorkflowWaitResultCompleted | ChildWorkflowWaitResultTimeout;
|
|
152
|
+
interface ChildWorkflowWaitResultCompleted {
|
|
153
|
+
status: "completed";
|
|
154
|
+
completedAt: number;
|
|
155
|
+
childWorkflowRunState: WorkflowRunState;
|
|
156
|
+
}
|
|
157
|
+
interface ChildWorkflowWaitResultTimeout {
|
|
158
|
+
status: "timeout";
|
|
159
|
+
timedOutAt: number;
|
|
133
160
|
}
|
|
134
161
|
interface WorkflowRunTransitionBase {
|
|
135
162
|
createdAt: number;
|
|
@@ -160,4 +187,4 @@ declare class WorkflowRunFailedError extends Error {
|
|
|
160
187
|
constructor(id: WorkflowRunId, attempts: number);
|
|
161
188
|
}
|
|
162
189
|
|
|
163
|
-
export { type NonTerminalWorkflowRunStatus, type TerminalWorkflowRunStatus, type WorkflowFailureCause, type WorkflowOptions, type WorkflowRun, WorkflowRunFailedError, type WorkflowRunId, WorkflowRunNotExecutableError, type WorkflowRunScheduledReason, type WorkflowRunState, type WorkflowRunStateAwaitingChildWorkflow, type WorkflowRunStateAwaitingEvent, type WorkflowRunStateAwaitingRetry, type WorkflowRunStateAwaitingRetryBase, type WorkflowRunStateAwaitingRetryCausedByChildWorkflow, type WorkflowRunStateAwaitingRetryCausedBySelf, type WorkflowRunStateAwaitingRetryCausedByTask, type WorkflowRunStateCancelled, type WorkflowRunStateCompleted, type WorkflowRunStateFailed, type WorkflowRunStateFailedByChildWorkflow, type WorkflowRunStateFailedBySelf, type WorkflowRunStateFailedByTask, type WorkflowRunStateInComplete, type WorkflowRunStatePaused, type WorkflowRunStateQueued, type WorkflowRunStateRunning, type WorkflowRunStateScheduled, type WorkflowRunStateScheduledByAwake, type WorkflowRunStateScheduledByEvent, type WorkflowRunStateScheduledByNew, type WorkflowRunStateScheduledByResume, type WorkflowRunStateScheduledByRetry, type WorkflowRunStateScheduledByTaskRetry, type WorkflowRunStateSleeping, type WorkflowRunStateTransition, type WorkflowRunStatus, WorkflowRunSuspendedError, type WorkflowRunTaskStateTransition, type WorkflowRunTransition, type WorkflowRunTransitionBase };
|
|
190
|
+
export { type ChildWorkflowRun, type ChildWorkflowWaitResult, type ChildWorkflowWaitResultCompleted, type ChildWorkflowWaitResultTimeout, type NonTerminalWorkflowRunStatus, type TerminalWorkflowRunStatus, type WorkflowFailureCause, type WorkflowOptions, type WorkflowRun, WorkflowRunFailedError, type WorkflowRunId, WorkflowRunNotExecutableError, type WorkflowRunPath, type WorkflowRunScheduledReason, type WorkflowRunState, type WorkflowRunStateAwaitingChildWorkflow, type WorkflowRunStateAwaitingEvent, type WorkflowRunStateAwaitingRetry, type WorkflowRunStateAwaitingRetryBase, type WorkflowRunStateAwaitingRetryCausedByChildWorkflow, type WorkflowRunStateAwaitingRetryCausedBySelf, type WorkflowRunStateAwaitingRetryCausedByTask, type WorkflowRunStateCancelled, type WorkflowRunStateCompleted, type WorkflowRunStateFailed, type WorkflowRunStateFailedByChildWorkflow, type WorkflowRunStateFailedBySelf, type WorkflowRunStateFailedByTask, type WorkflowRunStateInComplete, type WorkflowRunStatePaused, type WorkflowRunStateQueued, type WorkflowRunStateRunning, type WorkflowRunStateScheduled, type WorkflowRunStateScheduledByAwake, type WorkflowRunStateScheduledByChildWorkflow, type WorkflowRunStateScheduledByEvent, type WorkflowRunStateScheduledByNew, type WorkflowRunStateScheduledByResume, type WorkflowRunStateScheduledByRetry, type WorkflowRunStateScheduledByTaskRetry, type WorkflowRunStateSleeping, type WorkflowRunStateTransition, type WorkflowRunStatus, WorkflowRunSuspendedError, type WorkflowRunTaskStateTransition, type WorkflowRunTransition, type WorkflowRunTransitionBase, isTerminalWorkflowRunStatus };
|
package/dist/workflow-run.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
// workflow-run.ts
|
|
2
|
+
var terminalWorkflowRunStatuses = ["cancelled", "completed", "failed"];
|
|
3
|
+
function isTerminalWorkflowRunStatus(status) {
|
|
4
|
+
for (const terminalStatus of terminalWorkflowRunStatuses) {
|
|
5
|
+
if (status === terminalStatus) {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
2
11
|
var WorkflowRunNotExecutableError = class extends Error {
|
|
3
12
|
constructor(id, status) {
|
|
4
13
|
super(`Workflow ${id} is not executable while ${status}`);
|
|
@@ -25,5 +34,6 @@ var WorkflowRunFailedError = class extends Error {
|
|
|
25
34
|
export {
|
|
26
35
|
WorkflowRunFailedError,
|
|
27
36
|
WorkflowRunNotExecutableError,
|
|
28
|
-
WorkflowRunSuspendedError
|
|
37
|
+
WorkflowRunSuspendedError,
|
|
38
|
+
isTerminalWorkflowRunStatus
|
|
29
39
|
};
|