@aikirun/types 0.17.0 → 0.19.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/client.d.ts +13 -27
- package/dist/event.d.ts +6 -6
- package/dist/namespace.d.ts +5 -0
- package/dist/namespace.js +0 -0
- package/dist/organization.d.ts +5 -0
- package/dist/organization.js +0 -0
- package/dist/schedule-api.d.ts +12 -11
- package/dist/schedule.d.ts +0 -1
- package/dist/sleep.d.ts +7 -7
- package/dist/state-transition.d.ts +29 -0
- package/dist/state-transition.js +5 -0
- package/dist/task.d.ts +5 -9
- package/dist/task.js +0 -2
- package/dist/workflow-api.d.ts +16 -12
- package/dist/workflow-run-api.d.ts +75 -27
- package/dist/workflow-run.d.ts +37 -26
- package/dist/workflow-run.js +20 -0
- package/dist/workflow.d.ts +3 -1
- package/dist/workflow.js +5 -0
- package/package.json +13 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ScheduleApi } from './schedule-api.js';
|
|
2
2
|
import { WorkflowMeta } from './workflow.js';
|
|
3
|
-
import {
|
|
3
|
+
import { WorkflowRunId, WorkflowRun } from './workflow-run.js';
|
|
4
4
|
import { WorkflowRunApi } from './workflow-run-api.js';
|
|
5
5
|
import { INTERNAL } from './symbols.js';
|
|
6
6
|
import './schedule.js';
|
|
@@ -12,11 +12,12 @@ import './serializable.js';
|
|
|
12
12
|
import './sleep.js';
|
|
13
13
|
import './task.js';
|
|
14
14
|
import './trigger.js';
|
|
15
|
+
import './state-transition.js';
|
|
15
16
|
|
|
16
17
|
interface ClientParams<AppContext = unknown> {
|
|
17
18
|
url: string;
|
|
18
19
|
apiKey?: string;
|
|
19
|
-
redis
|
|
20
|
+
redis?: RedisConfig;
|
|
20
21
|
logger?: Logger;
|
|
21
22
|
createContext?: (run: Readonly<WorkflowRun>) => AppContext | Promise<AppContext>;
|
|
22
23
|
}
|
|
@@ -65,16 +66,10 @@ interface RedisConnection {
|
|
|
65
66
|
getConnection: () => RedisClient;
|
|
66
67
|
closeConnection: () => Promise<void>;
|
|
67
68
|
}
|
|
68
|
-
interface SubscriberMessageMeta {
|
|
69
|
-
stream: string;
|
|
70
|
-
messageId: string;
|
|
71
|
-
consumerGroup: string;
|
|
72
|
-
}
|
|
73
69
|
interface WorkflowRunBatch {
|
|
74
70
|
data: {
|
|
75
71
|
workflowRunId: WorkflowRunId;
|
|
76
72
|
};
|
|
77
|
-
meta?: SubscriberMessageMeta;
|
|
78
73
|
}
|
|
79
74
|
type SubscriberDelayParams = {
|
|
80
75
|
type: "polled";
|
|
@@ -91,34 +86,25 @@ interface ResolvedSubscriberStrategy {
|
|
|
91
86
|
type: string;
|
|
92
87
|
getNextDelay: (context: SubscriberDelayParams) => number;
|
|
93
88
|
getNextBatch: (size: number) => Promise<WorkflowRunBatch[]>;
|
|
94
|
-
heartbeat?: (workflowRunId: WorkflowRunId
|
|
95
|
-
acknowledge?: (
|
|
89
|
+
heartbeat?: (workflowRunId: WorkflowRunId) => Promise<void>;
|
|
90
|
+
acknowledge?: (workflowRunId: WorkflowRunId) => Promise<void>;
|
|
96
91
|
}
|
|
97
|
-
interface
|
|
98
|
-
type: "
|
|
92
|
+
interface RedisStreamsSubscriberStrategy {
|
|
93
|
+
type: "redis";
|
|
99
94
|
intervalMs?: number;
|
|
100
95
|
maxRetryIntervalMs?: number;
|
|
101
96
|
atCapacityIntervalMs?: number;
|
|
97
|
+
blockTimeMs?: number;
|
|
98
|
+
claimMinIdleTimeMs?: number;
|
|
102
99
|
}
|
|
103
|
-
interface
|
|
104
|
-
type: "
|
|
105
|
-
minPollIntervalMs?: number;
|
|
106
|
-
maxPollIntervalMs?: number;
|
|
107
|
-
backoffMultiplier?: number;
|
|
108
|
-
emptyPollThreshold?: number;
|
|
109
|
-
jitterFactor?: number;
|
|
110
|
-
successResetThreshold?: number;
|
|
111
|
-
atCapacityIntervalMs?: number;
|
|
112
|
-
}
|
|
113
|
-
interface RedisStreamsSubscriberStrategy {
|
|
114
|
-
type: "redis";
|
|
100
|
+
interface DbSubscriberStrategy {
|
|
101
|
+
type: "db";
|
|
115
102
|
intervalMs?: number;
|
|
116
103
|
maxRetryIntervalMs?: number;
|
|
117
104
|
atCapacityIntervalMs?: number;
|
|
118
|
-
blockTimeMs?: number;
|
|
119
105
|
claimMinIdleTimeMs?: number;
|
|
120
106
|
}
|
|
121
|
-
type SubscriberStrategy = RedisStreamsSubscriberStrategy;
|
|
107
|
+
type SubscriberStrategy = RedisStreamsSubscriberStrategy | DbSubscriberStrategy;
|
|
122
108
|
interface SubscriberStrategyBuilder {
|
|
123
109
|
init: (workerId: string, callbacks: StrategyCallbacks) => Promise<ResolvedSubscriberStrategy>;
|
|
124
110
|
}
|
|
@@ -127,4 +113,4 @@ interface StrategyCallbacks {
|
|
|
127
113
|
onStop?: () => Promise<void>;
|
|
128
114
|
}
|
|
129
115
|
|
|
130
|
-
export type {
|
|
116
|
+
export type { ApiClient, Client, ClientParams, DbSubscriberStrategy, Logger, RedisClient, RedisConfig, RedisConnection, RedisStreamsSubscriberStrategy, ResolvedSubscriberStrategy, StrategyCallbacks, SubscriberDelayParams, SubscriberStrategy, SubscriberStrategyBuilder, WorkflowRunBatch };
|
package/dist/event.d.ts
CHANGED
|
@@ -6,22 +6,22 @@ type EventName = string & {
|
|
|
6
6
|
};
|
|
7
7
|
declare const EVENT_WAIT_STATUSES: readonly ["received", "timeout"];
|
|
8
8
|
type EventWaitStatus = (typeof EVENT_WAIT_STATUSES)[number];
|
|
9
|
-
interface
|
|
9
|
+
interface EventWaitBase {
|
|
10
10
|
status: EventWaitStatus;
|
|
11
11
|
}
|
|
12
|
-
interface
|
|
12
|
+
interface EventWaitReceived<Data> extends EventWaitBase {
|
|
13
13
|
status: "received";
|
|
14
14
|
data?: Data;
|
|
15
15
|
receivedAt: number;
|
|
16
16
|
reference?: EventReferenceOptions;
|
|
17
17
|
}
|
|
18
|
-
interface
|
|
18
|
+
interface EventWaitTimeout extends EventWaitBase {
|
|
19
19
|
status: "timeout";
|
|
20
20
|
timedOutAt: number;
|
|
21
21
|
}
|
|
22
|
-
type
|
|
22
|
+
type EventWait<Data> = EventWaitReceived<Data> | EventWaitTimeout;
|
|
23
23
|
interface EventWaitQueue<Data> {
|
|
24
|
-
eventWaits:
|
|
24
|
+
eventWaits: EventWait<Data>[];
|
|
25
25
|
}
|
|
26
26
|
interface EventWaitOptions<Timed extends boolean> {
|
|
27
27
|
timeout?: Timed extends true ? DurationObject : never;
|
|
@@ -41,4 +41,4 @@ interface EventReferenceOptions {
|
|
|
41
41
|
id: string;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export { EVENT_WAIT_STATUSES, type EventName, type EventReferenceOptions, type EventSendOptions, type
|
|
44
|
+
export { EVENT_WAIT_STATUSES, type EventName, type EventReferenceOptions, type EventSendOptions, type EventWait, type EventWaitOptions, type EventWaitQueue, type EventWaitReceived, type EventWaitResult, type EventWaitStatus, type EventWaitTimeout };
|
|
File without changes
|
|
File without changes
|
package/dist/schedule-api.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ScheduleSpec, ScheduleActivateOptions, Schedule, ScheduleStatus } from './schedule.js';
|
|
2
|
+
import { WorkflowSource } from './workflow.js';
|
|
2
3
|
|
|
3
4
|
interface ScheduleApi {
|
|
4
5
|
activateV1: (_: ScheduleActivateRequestV1) => Promise<ScheduleActivateResponseV1>;
|
|
5
6
|
getByIdV1: (_: ScheduleGetByIdRequestV1) => Promise<ScheduleGetByIdResponseV1>;
|
|
6
7
|
getByReferenceIdV1: (_: ScheduleGetByReferenceIdRequestV1) => Promise<ScheduleGetByReferenceIdResponseV1>;
|
|
7
8
|
listV1: (_: ScheduleListRequestV1) => Promise<ScheduleListResponseV1>;
|
|
8
|
-
pauseV1: (_: SchedulePauseRequestV1) => Promise<
|
|
9
|
-
resumeV1: (_: ScheduleResumeRequestV1) => Promise<
|
|
9
|
+
pauseV1: (_: SchedulePauseRequestV1) => Promise<void>;
|
|
10
|
+
resumeV1: (_: ScheduleResumeRequestV1) => Promise<void>;
|
|
10
11
|
deleteV1: (_: ScheduleDeleteRequestV1) => Promise<void>;
|
|
11
12
|
}
|
|
12
13
|
interface ScheduleActivateRequestV1 {
|
|
@@ -24,16 +25,19 @@ interface ScheduleGetByIdRequestV1 {
|
|
|
24
25
|
}
|
|
25
26
|
interface ScheduleGetByIdResponseV1 {
|
|
26
27
|
schedule: Schedule;
|
|
28
|
+
runCount: number;
|
|
27
29
|
}
|
|
28
30
|
interface ScheduleGetByReferenceIdRequestV1 {
|
|
29
31
|
referenceId: string;
|
|
30
32
|
}
|
|
31
33
|
interface ScheduleGetByReferenceIdResponseV1 {
|
|
32
34
|
schedule: Schedule;
|
|
35
|
+
runCount: number;
|
|
33
36
|
}
|
|
34
37
|
interface ScheduleWorkflowFilter {
|
|
35
|
-
name
|
|
38
|
+
name: string;
|
|
36
39
|
versionId?: string;
|
|
40
|
+
source: WorkflowSource;
|
|
37
41
|
}
|
|
38
42
|
interface ScheduleListRequestV1 {
|
|
39
43
|
limit?: number;
|
|
@@ -46,23 +50,20 @@ interface ScheduleListRequestV1 {
|
|
|
46
50
|
};
|
|
47
51
|
}
|
|
48
52
|
interface ScheduleListResponseV1 {
|
|
49
|
-
schedules:
|
|
53
|
+
schedules: {
|
|
54
|
+
schedule: Schedule;
|
|
55
|
+
runCount: number;
|
|
56
|
+
}[];
|
|
50
57
|
total: number;
|
|
51
58
|
}
|
|
52
59
|
interface SchedulePauseRequestV1 {
|
|
53
60
|
id: string;
|
|
54
61
|
}
|
|
55
|
-
interface SchedulePauseResponseV1 {
|
|
56
|
-
schedule: Schedule;
|
|
57
|
-
}
|
|
58
62
|
interface ScheduleResumeRequestV1 {
|
|
59
63
|
id: string;
|
|
60
64
|
}
|
|
61
|
-
interface ScheduleResumeResponseV1 {
|
|
62
|
-
schedule: Schedule;
|
|
63
|
-
}
|
|
64
65
|
interface ScheduleDeleteRequestV1 {
|
|
65
66
|
id: string;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
export type { ScheduleActivateRequestV1, ScheduleActivateResponseV1, ScheduleApi, ScheduleDeleteRequestV1, ScheduleGetByIdRequestV1, ScheduleGetByIdResponseV1, ScheduleGetByReferenceIdRequestV1, ScheduleGetByReferenceIdResponseV1, ScheduleListRequestV1, ScheduleListResponseV1, SchedulePauseRequestV1,
|
|
69
|
+
export type { ScheduleActivateRequestV1, ScheduleActivateResponseV1, ScheduleApi, ScheduleDeleteRequestV1, ScheduleGetByIdRequestV1, ScheduleGetByIdResponseV1, ScheduleGetByReferenceIdRequestV1, ScheduleGetByReferenceIdResponseV1, ScheduleListRequestV1, ScheduleListResponseV1, SchedulePauseRequestV1, ScheduleResumeRequestV1, ScheduleWorkflowFilter };
|
package/dist/schedule.d.ts
CHANGED
|
@@ -42,7 +42,6 @@ interface Schedule {
|
|
|
42
42
|
updatedAt: number;
|
|
43
43
|
lastOccurrence?: number;
|
|
44
44
|
nextRunAt: number;
|
|
45
|
-
runCount: number;
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
export { type CronScheduleSpec, type IntervalScheduleSpec, SCHEDULE_CONFLICT_POLICIES, SCHEDULE_OVERLAP_POLICIES, SCHEDULE_STATUSES, SCHEDULE_TYPES, type Schedule, type ScheduleActivateOptions, type ScheduleConflictPolicy, type ScheduleId, type ScheduleOverlapPolicy, type ScheduleReferenceOptions, type ScheduleSpec, type ScheduleStatus, type ScheduleType };
|
package/dist/sleep.d.ts
CHANGED
|
@@ -3,28 +3,28 @@ type SleepName = string & {
|
|
|
3
3
|
};
|
|
4
4
|
declare const SLEEP_STATUSES: readonly ["sleeping", "completed", "cancelled"];
|
|
5
5
|
type SleepStatus = (typeof SLEEP_STATUSES)[number];
|
|
6
|
-
interface
|
|
6
|
+
interface SleepBase {
|
|
7
7
|
status: SleepStatus;
|
|
8
8
|
}
|
|
9
|
-
interface
|
|
9
|
+
interface SleepSleeping extends SleepBase {
|
|
10
10
|
status: "sleeping";
|
|
11
11
|
awakeAt: number;
|
|
12
12
|
}
|
|
13
|
-
interface
|
|
13
|
+
interface SleepCompleted extends SleepBase {
|
|
14
14
|
status: "completed";
|
|
15
15
|
durationMs: number;
|
|
16
16
|
completedAt: number;
|
|
17
17
|
}
|
|
18
|
-
interface
|
|
18
|
+
interface SleepCancelled extends SleepBase {
|
|
19
19
|
status: "cancelled";
|
|
20
20
|
cancelledAt: number;
|
|
21
21
|
}
|
|
22
|
-
type
|
|
22
|
+
type Sleep = SleepSleeping | SleepCompleted | SleepCancelled;
|
|
23
23
|
interface SleepQueue {
|
|
24
|
-
sleeps:
|
|
24
|
+
sleeps: Sleep[];
|
|
25
25
|
}
|
|
26
26
|
interface SleepResult {
|
|
27
27
|
cancelled: boolean;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export { SLEEP_STATUSES, type
|
|
30
|
+
export { SLEEP_STATUSES, type Sleep, type SleepCancelled, type SleepCompleted, type SleepName, type SleepQueue, type SleepResult, type SleepSleeping, type SleepStatus };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { TaskState } from './task.js';
|
|
2
|
+
import { WorkflowRunState } from './workflow-run.js';
|
|
3
|
+
import './retry.js';
|
|
4
|
+
import './serializable.js';
|
|
5
|
+
import './utils.js';
|
|
6
|
+
import './event.js';
|
|
7
|
+
import './duration.js';
|
|
8
|
+
import './sleep.js';
|
|
9
|
+
import './trigger.js';
|
|
10
|
+
|
|
11
|
+
declare const STATE_TRANSITION_TYPES: readonly ["workflow_run", "task"];
|
|
12
|
+
type StateTransitionType = (typeof STATE_TRANSITION_TYPES)[number];
|
|
13
|
+
interface StateTransitionBase {
|
|
14
|
+
id: string;
|
|
15
|
+
createdAt: number;
|
|
16
|
+
type: StateTransitionType;
|
|
17
|
+
}
|
|
18
|
+
interface WorkflowRunStateTransition extends StateTransitionBase {
|
|
19
|
+
type: "workflow_run";
|
|
20
|
+
state: WorkflowRunState;
|
|
21
|
+
}
|
|
22
|
+
interface TaskStateTransition extends StateTransitionBase {
|
|
23
|
+
type: "task";
|
|
24
|
+
taskId: string;
|
|
25
|
+
taskState: TaskState;
|
|
26
|
+
}
|
|
27
|
+
type StateTransition = WorkflowRunStateTransition | TaskStateTransition;
|
|
28
|
+
|
|
29
|
+
export { STATE_TRANSITION_TYPES, type StateTransition, type StateTransitionBase, type StateTransitionType, type TaskStateTransition, type WorkflowRunStateTransition };
|
package/dist/task.d.ts
CHANGED
|
@@ -17,13 +17,6 @@ interface TaskDefinitionOptions {
|
|
|
17
17
|
retry?: RetryStrategy;
|
|
18
18
|
}
|
|
19
19
|
interface TaskStartOptions extends TaskDefinitionOptions {
|
|
20
|
-
reference?: TaskReferenceOptions;
|
|
21
|
-
}
|
|
22
|
-
declare const TASK_CONFLICT_POLICIES: readonly ["error", "return_existing"];
|
|
23
|
-
type TaskConflictPolicy = (typeof TASK_CONFLICT_POLICIES)[number];
|
|
24
|
-
interface TaskReferenceOptions {
|
|
25
|
-
id: string;
|
|
26
|
-
conflictPolicy?: TaskConflictPolicy;
|
|
27
20
|
}
|
|
28
21
|
interface TaskStateBase {
|
|
29
22
|
status: TaskStatus;
|
|
@@ -58,7 +51,7 @@ interface TaskInfo {
|
|
|
58
51
|
}
|
|
59
52
|
interface TransitionTaskStateBase {
|
|
60
53
|
id: string;
|
|
61
|
-
|
|
54
|
+
expectedWorkflowRunRevision: number;
|
|
62
55
|
}
|
|
63
56
|
interface TransitionTaskStateToRunningCreate extends TransitionTaskStateBase {
|
|
64
57
|
type: "create";
|
|
@@ -89,6 +82,9 @@ interface TransitionTaskStateToAwaitingRetry extends TransitionTaskStateBase {
|
|
|
89
82
|
type TaskStateAwaitingRetryRequest = Omit<TaskStateAwaitingRetry, "nextAttemptAt"> & {
|
|
90
83
|
nextAttemptInMs: number;
|
|
91
84
|
};
|
|
85
|
+
interface TaskQueue {
|
|
86
|
+
tasks: TaskInfo[];
|
|
87
|
+
}
|
|
92
88
|
declare class TaskFailedError extends Error {
|
|
93
89
|
readonly taskId: TaskId;
|
|
94
90
|
readonly attempts: number;
|
|
@@ -96,4 +92,4 @@ declare class TaskFailedError extends Error {
|
|
|
96
92
|
constructor(taskId: TaskId, attempts: number, reason: string);
|
|
97
93
|
}
|
|
98
94
|
|
|
99
|
-
export {
|
|
95
|
+
export { TASK_STATUSES, type TaskAddress, type TaskDefinitionOptions, TaskFailedError, type TaskId, type TaskInfo, type TaskName, type TaskQueue, type TaskStartOptions, type TaskState, type TaskStateAwaitingRetry, type TaskStateAwaitingRetryRequest, type TaskStateCompleted, type TaskStateCompletedRequest, type TaskStateFailed, type TaskStateRunning, type TaskStateRunningRequest, type TaskStatus, type TransitionTaskStateBase, type TransitionTaskStateToAwaitingRetry, type TransitionTaskStateToCompleted, type TransitionTaskStateToFailed, type TransitionTaskStateToRunningCreate, type TransitionTaskStateToRunningRetry };
|
package/dist/task.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// task.ts
|
|
2
2
|
var TASK_STATUSES = ["running", "awaiting_retry", "completed", "failed"];
|
|
3
|
-
var TASK_CONFLICT_POLICIES = ["error", "return_existing"];
|
|
4
3
|
var TaskFailedError = class extends Error {
|
|
5
4
|
taskId;
|
|
6
5
|
attempts;
|
|
@@ -14,7 +13,6 @@ var TaskFailedError = class extends Error {
|
|
|
14
13
|
}
|
|
15
14
|
};
|
|
16
15
|
export {
|
|
17
|
-
TASK_CONFLICT_POLICIES,
|
|
18
16
|
TASK_STATUSES,
|
|
19
17
|
TaskFailedError
|
|
20
18
|
};
|
package/dist/workflow-api.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WorkflowSource } from './workflow.js';
|
|
1
2
|
import { WorkflowRunStatus } from './workflow-run.js';
|
|
2
3
|
import './event.js';
|
|
3
4
|
import './duration.js';
|
|
@@ -9,22 +10,12 @@ import './task.js';
|
|
|
9
10
|
import './trigger.js';
|
|
10
11
|
|
|
11
12
|
interface WorkflowApi {
|
|
12
|
-
getStatsV1: (_: WorkflowGetStatsRequestV1) => Promise<WorkflowGetStatsResponseV1>;
|
|
13
13
|
listV1: (_: WorkflowListRequestV1) => Promise<WorkflowListResponseV1>;
|
|
14
14
|
listVersionsV1: (_: WorkflowListVersionsRequestV1) => Promise<WorkflowListVersionsResponseV1>;
|
|
15
|
-
|
|
16
|
-
interface WorkflowGetStatsRequestV1 {
|
|
17
|
-
name?: string;
|
|
18
|
-
versionId?: string;
|
|
19
|
-
}
|
|
20
|
-
interface WorkflowGetStatsResponseV1 {
|
|
21
|
-
stats: WorkflowStats;
|
|
22
|
-
}
|
|
23
|
-
interface WorkflowStats {
|
|
24
|
-
totalRuns: number;
|
|
25
|
-
runsByStatus: Record<WorkflowRunStatus, number>;
|
|
15
|
+
getStatsV1: (_: WorkflowGetStatsRequestV1) => Promise<WorkflowGetStatsResponseV1>;
|
|
26
16
|
}
|
|
27
17
|
interface WorkflowListRequestV1 {
|
|
18
|
+
source: WorkflowSource;
|
|
28
19
|
limit?: number;
|
|
29
20
|
offset?: number;
|
|
30
21
|
sort?: {
|
|
@@ -34,6 +25,7 @@ interface WorkflowListRequestV1 {
|
|
|
34
25
|
}
|
|
35
26
|
interface WorkflowListItem {
|
|
36
27
|
name: string;
|
|
28
|
+
source: WorkflowSource;
|
|
37
29
|
runCount: number;
|
|
38
30
|
lastRunAt: number | null;
|
|
39
31
|
}
|
|
@@ -43,6 +35,7 @@ interface WorkflowListResponseV1 {
|
|
|
43
35
|
}
|
|
44
36
|
interface WorkflowListVersionsRequestV1 {
|
|
45
37
|
name: string;
|
|
38
|
+
source: WorkflowSource;
|
|
46
39
|
limit?: number;
|
|
47
40
|
offset?: number;
|
|
48
41
|
sort?: {
|
|
@@ -60,5 +53,16 @@ interface WorkflowListVersionsResponseV1 {
|
|
|
60
53
|
versions: WorkflowVersionItem[];
|
|
61
54
|
total: number;
|
|
62
55
|
}
|
|
56
|
+
type WorkflowGetStatsRequestV1 = {
|
|
57
|
+
name: string;
|
|
58
|
+
source: WorkflowSource;
|
|
59
|
+
versionId?: string;
|
|
60
|
+
} | undefined;
|
|
61
|
+
interface WorkflowGetStatsResponseV1 {
|
|
62
|
+
stats: WorkflowStats;
|
|
63
|
+
}
|
|
64
|
+
interface WorkflowStats {
|
|
65
|
+
runsByStatus: Record<WorkflowRunStatus, number>;
|
|
66
|
+
}
|
|
63
67
|
|
|
64
68
|
export type { WorkflowApi, WorkflowGetStatsRequestV1, WorkflowGetStatsResponseV1, WorkflowListItem, WorkflowListRequestV1, WorkflowListResponseV1, WorkflowListVersionsRequestV1, WorkflowListVersionsResponseV1, WorkflowStats, WorkflowVersionItem };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { EventSendOptions } from './event.js';
|
|
2
|
-
import {
|
|
2
|
+
import { StateTransition } from './state-transition.js';
|
|
3
|
+
import { TransitionTaskStateToRunningCreate, TransitionTaskStateToRunningRetry, TransitionTaskStateToCompleted, TransitionTaskStateToFailed, TransitionTaskStateToAwaitingRetry, TaskInfo, TaskStateCompleted, TaskStateFailed } from './task.js';
|
|
3
4
|
import { DistributiveOmit, OptionalProp } from './utils.js';
|
|
4
|
-
import {
|
|
5
|
+
import { WorkflowSource } from './workflow.js';
|
|
6
|
+
import { WorkflowRunStatus, WorkflowRun, WorkflowRunState, WorkflowStartOptions, WorkflowRunStateScheduled, WorkflowRunStateSleeping, WorkflowRunStateAwaitingEvent, WorkflowRunStateAwaitingRetry, WorkflowRunStateAwaitingChildWorkflow, WorkflowRunStateCompleted, WorkflowRunStatePaused, WorkflowRunStateCancelled } from './workflow-run.js';
|
|
5
7
|
import './duration.js';
|
|
6
8
|
import './retry.js';
|
|
7
9
|
import './serializable.js';
|
|
@@ -16,10 +18,15 @@ interface WorkflowRunApi {
|
|
|
16
18
|
createV1: (_: WorkflowRunCreateRequestV1) => Promise<WorkflowRunCreateResponseV1>;
|
|
17
19
|
transitionStateV1: (_: WorkflowRunTransitionStateRequestV1) => Promise<WorkflowRunTransitionStateResponseV1>;
|
|
18
20
|
transitionTaskStateV1: (_: WorkflowRunTransitionTaskStateRequestV1) => Promise<WorkflowRunTransitionTaskStateResponseV1>;
|
|
19
|
-
setTaskStateV1: (_: WorkflowRunSetTaskStateRequestV1) => Promise<
|
|
21
|
+
setTaskStateV1: (_: WorkflowRunSetTaskStateRequestV1) => Promise<void>;
|
|
20
22
|
listTransitionsV1: (_: WorkflowRunListTransitionsRequestV1) => Promise<WorkflowRunListTransitionsResponseV1>;
|
|
21
|
-
sendEventV1: (_: WorkflowRunSendEventRequestV1) => Promise<
|
|
23
|
+
sendEventV1: (_: WorkflowRunSendEventRequestV1) => Promise<void>;
|
|
22
24
|
multicastEventV1: (_: WorkflowRunMulticastEventRequestV1) => Promise<void>;
|
|
25
|
+
multicastEventByReferenceV1: (_: WorkflowRunMulticastEventByReferenceRequestV1) => Promise<void>;
|
|
26
|
+
listChildRunsV1: (_: WorkflowRunListChildRunsRequestV1) => Promise<WorkflowRunListChildRunsResponseV1>;
|
|
27
|
+
cancelByIdsV1: (_: WorkflowRunCancelByIdsRequestV1) => Promise<WorkflowRunCancelByIdsResponseV1>;
|
|
28
|
+
claimReadyV1: (_: WorkflowRunClaimReadyRequestV1) => Promise<WorkflowRunClaimReadyResponseV1>;
|
|
29
|
+
heartbeatV1: (_: WorkflowRunHeartbeatRequestV1) => Promise<void>;
|
|
23
30
|
}
|
|
24
31
|
interface WorkflowRunListRequestV1 {
|
|
25
32
|
limit?: number;
|
|
@@ -27,18 +34,25 @@ interface WorkflowRunListRequestV1 {
|
|
|
27
34
|
filters?: {
|
|
28
35
|
id?: string;
|
|
29
36
|
status?: WorkflowRunStatus[];
|
|
30
|
-
|
|
37
|
+
workflow?: WorkflowFilter;
|
|
31
38
|
};
|
|
32
39
|
sort?: {
|
|
33
|
-
field: "createdAt";
|
|
34
40
|
order: "asc" | "desc";
|
|
35
41
|
};
|
|
36
42
|
}
|
|
37
|
-
|
|
43
|
+
type WorkflowFilter = {
|
|
38
44
|
name: string;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
source: WorkflowSource;
|
|
46
|
+
} | {
|
|
47
|
+
name: string;
|
|
48
|
+
source: WorkflowSource;
|
|
49
|
+
versionId: string;
|
|
50
|
+
} | {
|
|
51
|
+
name: string;
|
|
52
|
+
source: WorkflowSource;
|
|
53
|
+
versionId: string;
|
|
54
|
+
referenceId: string;
|
|
55
|
+
};
|
|
42
56
|
interface WorkflowRunListItem {
|
|
43
57
|
id: string;
|
|
44
58
|
name: string;
|
|
@@ -57,11 +71,12 @@ interface WorkflowRunGetByIdRequestV1 {
|
|
|
57
71
|
interface WorkflowRunGetByIdResponseV1 {
|
|
58
72
|
run: WorkflowRun;
|
|
59
73
|
}
|
|
60
|
-
interface
|
|
74
|
+
interface WorkflowRunReference {
|
|
61
75
|
name: string;
|
|
62
76
|
versionId: string;
|
|
63
77
|
referenceId: string;
|
|
64
78
|
}
|
|
79
|
+
type WorkflowRunGetByReferenceIdRequestV1 = WorkflowRunReference;
|
|
65
80
|
interface WorkflowRunGetByReferenceIdResponseV1 {
|
|
66
81
|
run: WorkflowRun;
|
|
67
82
|
}
|
|
@@ -79,7 +94,7 @@ interface WorkflowRunCreateRequestV1 {
|
|
|
79
94
|
options?: WorkflowStartOptions;
|
|
80
95
|
}
|
|
81
96
|
interface WorkflowRunCreateResponseV1 {
|
|
82
|
-
|
|
97
|
+
id: string;
|
|
83
98
|
}
|
|
84
99
|
type WorkflowRunStateScheduledRequest = DistributiveOmit<WorkflowRunStateScheduled, "scheduledAt"> & {
|
|
85
100
|
scheduledInMs: number;
|
|
@@ -124,22 +139,20 @@ interface WorkflowRunTransitionStateRequestPessimistic extends WorkflowRunTransi
|
|
|
124
139
|
}
|
|
125
140
|
type WorkflowRunTransitionStateRequestV1 = WorkflowRunTransitionStateRequestOptimistic | WorkflowRunTransitionStateRequestPessimistic;
|
|
126
141
|
interface WorkflowRunTransitionStateResponseV1 {
|
|
127
|
-
|
|
142
|
+
revision: number;
|
|
143
|
+
state: WorkflowRunState;
|
|
144
|
+
attempts: number;
|
|
128
145
|
}
|
|
129
146
|
type TransitionTaskStateToRunning = TransitionTaskStateToRunningCreate | TransitionTaskStateToRunningRetry;
|
|
130
147
|
type WorkflowRunTransitionTaskStateRequestV1 = TransitionTaskStateToRunning | TransitionTaskStateToCompleted | TransitionTaskStateToFailed | TransitionTaskStateToAwaitingRetry;
|
|
131
148
|
interface WorkflowRunTransitionTaskStateResponseV1 {
|
|
132
|
-
|
|
133
|
-
taskId: string;
|
|
149
|
+
taskInfo: TaskInfo;
|
|
134
150
|
}
|
|
135
151
|
interface WorkflowRunSetTaskStateRequestNew {
|
|
136
152
|
type: "new";
|
|
137
153
|
id: string;
|
|
138
154
|
taskName: string;
|
|
139
155
|
input?: unknown;
|
|
140
|
-
reference?: {
|
|
141
|
-
id: string;
|
|
142
|
-
};
|
|
143
156
|
state: DistributiveOmit<TaskStateCompleted<unknown> | TaskStateFailed, "attempts">;
|
|
144
157
|
}
|
|
145
158
|
interface WorkflowRunSetTaskStateRequestExisting {
|
|
@@ -149,20 +162,16 @@ interface WorkflowRunSetTaskStateRequestExisting {
|
|
|
149
162
|
state: DistributiveOmit<TaskStateCompleted<unknown> | TaskStateFailed, "attempts">;
|
|
150
163
|
}
|
|
151
164
|
type WorkflowRunSetTaskStateRequestV1 = WorkflowRunSetTaskStateRequestNew | WorkflowRunSetTaskStateRequestExisting;
|
|
152
|
-
interface WorkflowRunSetTaskStateResponseV1 {
|
|
153
|
-
run: WorkflowRun;
|
|
154
|
-
}
|
|
155
165
|
interface WorkflowRunListTransitionsRequestV1 {
|
|
156
166
|
id: string;
|
|
157
167
|
limit?: number;
|
|
158
168
|
offset?: number;
|
|
159
169
|
sort?: {
|
|
160
|
-
field: "createdAt";
|
|
161
170
|
order: "asc" | "desc";
|
|
162
171
|
};
|
|
163
172
|
}
|
|
164
173
|
interface WorkflowRunListTransitionsResponseV1 {
|
|
165
|
-
transitions:
|
|
174
|
+
transitions: StateTransition[];
|
|
166
175
|
total: number;
|
|
167
176
|
}
|
|
168
177
|
interface WorkflowRunSendEventRequestV1 {
|
|
@@ -171,14 +180,53 @@ interface WorkflowRunSendEventRequestV1 {
|
|
|
171
180
|
data?: unknown;
|
|
172
181
|
options?: EventSendOptions;
|
|
173
182
|
}
|
|
174
|
-
interface WorkflowRunSendEventResponseV1 {
|
|
175
|
-
run: WorkflowRun;
|
|
176
|
-
}
|
|
177
183
|
interface WorkflowRunMulticastEventRequestV1 {
|
|
178
184
|
ids: string[];
|
|
179
185
|
eventName: string;
|
|
180
186
|
data?: unknown;
|
|
181
187
|
options?: EventSendOptions;
|
|
182
188
|
}
|
|
189
|
+
interface WorkflowRunMulticastEventByReferenceRequestV1 {
|
|
190
|
+
references: WorkflowRunReference[];
|
|
191
|
+
eventName: string;
|
|
192
|
+
data?: unknown;
|
|
193
|
+
options?: EventSendOptions;
|
|
194
|
+
}
|
|
195
|
+
interface WorkflowRunListChildRunsRequestV1 {
|
|
196
|
+
parentRunId: string;
|
|
197
|
+
status?: WorkflowRunStatus[];
|
|
198
|
+
}
|
|
199
|
+
interface WorkflowRunListChildRunsResponseV1 {
|
|
200
|
+
runs: Array<{
|
|
201
|
+
id: string;
|
|
202
|
+
options?: {
|
|
203
|
+
shard?: string;
|
|
204
|
+
};
|
|
205
|
+
}>;
|
|
206
|
+
}
|
|
207
|
+
interface WorkflowRunCancelByIdsRequestV1 {
|
|
208
|
+
ids: string[];
|
|
209
|
+
}
|
|
210
|
+
interface WorkflowRunCancelByIdsResponseV1 {
|
|
211
|
+
cancelledIds: string[];
|
|
212
|
+
}
|
|
213
|
+
interface WorkflowRunClaimReadyRequestV1 {
|
|
214
|
+
workerId: string;
|
|
215
|
+
workflows: Array<{
|
|
216
|
+
name: string;
|
|
217
|
+
versionId: string;
|
|
218
|
+
shard?: string;
|
|
219
|
+
}>;
|
|
220
|
+
limit: number;
|
|
221
|
+
claimMinIdleTimeMs: number;
|
|
222
|
+
}
|
|
223
|
+
interface WorkflowRunClaimReadyResponseV1 {
|
|
224
|
+
runs: Array<{
|
|
225
|
+
id: string;
|
|
226
|
+
}>;
|
|
227
|
+
}
|
|
228
|
+
interface WorkflowRunHeartbeatRequestV1 {
|
|
229
|
+
id: string;
|
|
230
|
+
}
|
|
183
231
|
|
|
184
|
-
export type { TransitionTaskStateToRunning, WorkflowFilter, WorkflowRunApi, WorkflowRunCreateRequestV1, WorkflowRunCreateResponseV1, WorkflowRunGetByIdRequestV1, WorkflowRunGetByIdResponseV1, WorkflowRunGetByReferenceIdRequestV1, WorkflowRunGetByReferenceIdResponseV1, WorkflowRunGetStateRequestV1, WorkflowRunGetStateResponseV1, WorkflowRunListItem, WorkflowRunListRequestV1, WorkflowRunListResponseV1, WorkflowRunListTransitionsRequestV1, WorkflowRunListTransitionsResponseV1, WorkflowRunMulticastEventRequestV1,
|
|
232
|
+
export type { TransitionTaskStateToRunning, WorkflowFilter, WorkflowRunApi, WorkflowRunCancelByIdsRequestV1, WorkflowRunCancelByIdsResponseV1, WorkflowRunClaimReadyRequestV1, WorkflowRunClaimReadyResponseV1, WorkflowRunCreateRequestV1, WorkflowRunCreateResponseV1, WorkflowRunGetByIdRequestV1, WorkflowRunGetByIdResponseV1, WorkflowRunGetByReferenceIdRequestV1, WorkflowRunGetByReferenceIdResponseV1, WorkflowRunGetStateRequestV1, WorkflowRunGetStateResponseV1, WorkflowRunHeartbeatRequestV1, WorkflowRunListChildRunsRequestV1, WorkflowRunListChildRunsResponseV1, WorkflowRunListItem, WorkflowRunListRequestV1, WorkflowRunListResponseV1, WorkflowRunListTransitionsRequestV1, WorkflowRunListTransitionsResponseV1, WorkflowRunMulticastEventByReferenceRequestV1, WorkflowRunMulticastEventRequestV1, WorkflowRunReference, WorkflowRunSendEventRequestV1, WorkflowRunSetTaskStateRequestExisting, WorkflowRunSetTaskStateRequestNew, WorkflowRunSetTaskStateRequestV1, WorkflowRunStateAwaitingChildWorkflowRequest, WorkflowRunStateAwaitingEventRequest, WorkflowRunStateAwaitingRetryRequest, WorkflowRunStateCompletedRequest, WorkflowRunStateRequest, WorkflowRunStateScheduledRequest, WorkflowRunStateScheduledRequestOptimistic, WorkflowRunStateScheduledRequestPessimistic, WorkflowRunStateSleepingRequest, WorkflowRunTransitionStateRequestOptimistic, WorkflowRunTransitionStateRequestPessimistic, WorkflowRunTransitionStateRequestV1, WorkflowRunTransitionStateResponseV1, WorkflowRunTransitionTaskStateRequestV1, WorkflowRunTransitionTaskStateResponseV1 };
|
package/dist/workflow-run.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { EventWaitQueue } from './event.js';
|
|
|
2
2
|
import { RetryStrategy } from './retry.js';
|
|
3
3
|
import { SerializableError } from './serializable.js';
|
|
4
4
|
import { SleepQueue } from './sleep.js';
|
|
5
|
-
import {
|
|
5
|
+
import { TaskQueue } from './task.js';
|
|
6
6
|
import { TriggerStrategy } from './trigger.js';
|
|
7
7
|
import './duration.js';
|
|
8
8
|
import './utils.js';
|
|
@@ -17,6 +17,7 @@ declare const WORKFLOW_RUN_STATUSES: readonly ["scheduled", "queued", "running",
|
|
|
17
17
|
type WorkflowRunStatus = (typeof WORKFLOW_RUN_STATUSES)[number];
|
|
18
18
|
declare const TERMINAL_WORKFLOW_RUN_STATUSES: readonly ["cancelled", "completed", "failed"];
|
|
19
19
|
type TerminalWorkflowRunStatus = (typeof TERMINAL_WORKFLOW_RUN_STATUSES)[number];
|
|
20
|
+
declare const NON_TERMINAL_WORKFLOW_RUN_STATUSES: ("paused" | "sleeping" | "completed" | "cancelled" | "running" | "awaiting_retry" | "failed" | "scheduled" | "queued" | "awaiting_event" | "awaiting_child_workflow")[];
|
|
20
21
|
type NonTerminalWorkflowRunStatus = Exclude<WorkflowRunStatus, TerminalWorkflowRunStatus>;
|
|
21
22
|
declare function isTerminalWorkflowRunStatus(status: WorkflowRunStatus): status is TerminalWorkflowRunStatus;
|
|
22
23
|
declare const WORKFLOW_RUN_CONFLICT_POLICIES: readonly ["error", "return_existing"];
|
|
@@ -141,6 +142,9 @@ interface WorkflowRunStateFailedBySelf extends WorkflowRunStateFailedBase {
|
|
|
141
142
|
type WorkflowRunStateFailed = WorkflowRunStateFailedByTask | WorkflowRunStateFailedByChildWorkflow | WorkflowRunStateFailedBySelf;
|
|
142
143
|
type WorkflowRunStateInComplete = WorkflowRunStateScheduled | WorkflowRunStateQueued | WorkflowRunStateRunning | WorkflowRunStatePaused | WorkflowRunStateSleeping | WorkflowRunStateAwaitingEvent | WorkflowRunStateAwaitingRetry | WorkflowRunStateAwaitingChildWorkflow | WorkflowRunStateCancelled | WorkflowRunStateFailed;
|
|
143
144
|
type WorkflowRunState<Output = unknown> = WorkflowRunStateInComplete | WorkflowRunStateCompleted<Output>;
|
|
145
|
+
type TerminalWorkflowRunState = Extract<WorkflowRunState, {
|
|
146
|
+
status: "cancelled" | "completed" | "failed";
|
|
147
|
+
}>;
|
|
144
148
|
interface WorkflowRun<Input = unknown, Output = unknown> {
|
|
145
149
|
id: string;
|
|
146
150
|
name: string;
|
|
@@ -149,48 +153,43 @@ interface WorkflowRun<Input = unknown, Output = unknown> {
|
|
|
149
153
|
revision: number;
|
|
150
154
|
input?: Input;
|
|
151
155
|
inputHash: string;
|
|
152
|
-
|
|
153
|
-
options: WorkflowStartOptions;
|
|
156
|
+
options?: WorkflowStartOptions;
|
|
154
157
|
attempts: number;
|
|
155
158
|
state: WorkflowRunState<Output>;
|
|
156
|
-
|
|
157
|
-
|
|
159
|
+
taskQueues: Record<string, TaskQueue>;
|
|
160
|
+
sleepQueues: Record<string, SleepQueue>;
|
|
158
161
|
eventWaitQueues: Record<string, EventWaitQueue<unknown>>;
|
|
159
|
-
|
|
162
|
+
childWorkflowRunQueues: Record<string, ChildWorkflowRunQueue>;
|
|
160
163
|
parentWorkflowRunId?: string;
|
|
161
164
|
}
|
|
165
|
+
interface ChildWorkflowRunQueue {
|
|
166
|
+
childWorkflowRuns: ChildWorkflowRunInfo[];
|
|
167
|
+
}
|
|
162
168
|
interface ChildWorkflowRunInfo {
|
|
163
169
|
id: string;
|
|
164
170
|
name: string;
|
|
165
171
|
versionId: string;
|
|
166
172
|
inputHash: string;
|
|
167
|
-
|
|
173
|
+
childWorkflowRunWaitQueues: Record<TerminalWorkflowRunStatus, ChildWorkflowRunWaitQueue>;
|
|
174
|
+
}
|
|
175
|
+
declare const CHILD_WORKFLOW_RUN_WAIT_STATUSES: readonly ["completed", "timeout"];
|
|
176
|
+
type ChildWorkflowRunWaitStatus = (typeof CHILD_WORKFLOW_RUN_WAIT_STATUSES)[number];
|
|
177
|
+
interface ChildWorkflowRunWaitBase {
|
|
178
|
+
status: ChildWorkflowRunWaitStatus;
|
|
168
179
|
}
|
|
169
|
-
|
|
170
|
-
interface ChildWorkflowWaitResultCompleted {
|
|
180
|
+
interface ChildWorkflowRunWaitCompleted extends ChildWorkflowRunWaitBase {
|
|
171
181
|
status: "completed";
|
|
172
182
|
completedAt: number;
|
|
173
|
-
childWorkflowRunState:
|
|
183
|
+
childWorkflowRunState: TerminalWorkflowRunState;
|
|
174
184
|
}
|
|
175
|
-
interface
|
|
185
|
+
interface ChildWorkflowRunWaitTimeout extends ChildWorkflowRunWaitBase {
|
|
176
186
|
status: "timeout";
|
|
177
187
|
timedOutAt: number;
|
|
178
188
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
type: "state" | "task_state";
|
|
183
|
-
}
|
|
184
|
-
interface WorkflowRunStateTransition extends WorkflowRunTransitionBase {
|
|
185
|
-
type: "state";
|
|
186
|
-
state: WorkflowRunState;
|
|
189
|
+
type ChildWorkflowRunWait = ChildWorkflowRunWaitCompleted | ChildWorkflowRunWaitTimeout;
|
|
190
|
+
interface ChildWorkflowRunWaitQueue {
|
|
191
|
+
childWorkflowRunWaits: ChildWorkflowRunWait[];
|
|
187
192
|
}
|
|
188
|
-
interface WorkflowRunTaskStateTransition extends WorkflowRunTransitionBase {
|
|
189
|
-
type: "task_state";
|
|
190
|
-
taskId: string;
|
|
191
|
-
taskState: TaskState;
|
|
192
|
-
}
|
|
193
|
-
type WorkflowRunTransition = WorkflowRunStateTransition | WorkflowRunTaskStateTransition;
|
|
194
193
|
declare class WorkflowRunNotExecutableError extends Error {
|
|
195
194
|
readonly id: WorkflowRunId;
|
|
196
195
|
readonly status: WorkflowRunStatus;
|
|
@@ -210,5 +209,17 @@ declare class WorkflowRunRevisionConflictError extends Error {
|
|
|
210
209
|
readonly id: WorkflowRunId;
|
|
211
210
|
constructor(id: WorkflowRunId);
|
|
212
211
|
}
|
|
212
|
+
declare class NonDeterminismError extends Error {
|
|
213
|
+
readonly id: WorkflowRunId;
|
|
214
|
+
readonly attempts: number;
|
|
215
|
+
readonly unconsumedManifestEntries: {
|
|
216
|
+
taskIds: string[];
|
|
217
|
+
childWorkflowRunIds: string[];
|
|
218
|
+
};
|
|
219
|
+
constructor(id: WorkflowRunId, attempts: number, unconsumedManifestEntries: {
|
|
220
|
+
taskIds: string[];
|
|
221
|
+
childWorkflowRunIds: string[];
|
|
222
|
+
});
|
|
223
|
+
}
|
|
213
224
|
|
|
214
|
-
export { type ChildWorkflowRunInfo, type
|
|
225
|
+
export { CHILD_WORKFLOW_RUN_WAIT_STATUSES, type ChildWorkflowRunInfo, type ChildWorkflowRunQueue, type ChildWorkflowRunWait, type ChildWorkflowRunWaitBase, type ChildWorkflowRunWaitCompleted, type ChildWorkflowRunWaitQueue, type ChildWorkflowRunWaitStatus, type ChildWorkflowRunWaitTimeout, NON_TERMINAL_WORKFLOW_RUN_STATUSES, NonDeterminismError, type NonTerminalWorkflowRunStatus, TERMINAL_WORKFLOW_RUN_STATUSES, type TerminalWorkflowRunState, type TerminalWorkflowRunStatus, WORKFLOW_RUN_CONFLICT_POLICIES, WORKFLOW_RUN_FAILURE_CAUSE, WORKFLOW_RUN_SCHEDULED_REASON, WORKFLOW_RUN_STATUSES, type WorkflowDefinitionOptions, type WorkflowReferenceOptions, type WorkflowRun, type WorkflowRunAddress, type WorkflowRunConflictPolicy, WorkflowRunFailedError, type WorkflowRunFailureCause, type WorkflowRunId, WorkflowRunNotExecutableError, WorkflowRunRevisionConflictError, 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 WorkflowRunStateScheduledBase, type WorkflowRunStateScheduledByAwake, type WorkflowRunStateScheduledByAwakeEarly, type WorkflowRunStateScheduledByChildWorkflow, type WorkflowRunStateScheduledByEvent, type WorkflowRunStateScheduledByNew, type WorkflowRunStateScheduledByResume, type WorkflowRunStateScheduledByRetry, type WorkflowRunStateScheduledByTaskRetry, type WorkflowRunStateSleeping, type WorkflowRunStatus, WorkflowRunSuspendedError, type WorkflowStartOptions, isTerminalWorkflowRunStatus };
|
package/dist/workflow-run.js
CHANGED
|
@@ -13,6 +13,9 @@ var WORKFLOW_RUN_STATUSES = [
|
|
|
13
13
|
"failed"
|
|
14
14
|
];
|
|
15
15
|
var TERMINAL_WORKFLOW_RUN_STATUSES = ["cancelled", "completed", "failed"];
|
|
16
|
+
var NON_TERMINAL_WORKFLOW_RUN_STATUSES = WORKFLOW_RUN_STATUSES.filter(
|
|
17
|
+
(status) => !TERMINAL_WORKFLOW_RUN_STATUSES.includes(status)
|
|
18
|
+
);
|
|
16
19
|
function isTerminalWorkflowRunStatus(status) {
|
|
17
20
|
for (const terminalStatus of TERMINAL_WORKFLOW_RUN_STATUSES) {
|
|
18
21
|
if (status === terminalStatus) {
|
|
@@ -33,6 +36,7 @@ var WORKFLOW_RUN_SCHEDULED_REASON = [
|
|
|
33
36
|
"child_workflow"
|
|
34
37
|
];
|
|
35
38
|
var WORKFLOW_RUN_FAILURE_CAUSE = ["task", "child_workflow", "self"];
|
|
39
|
+
var CHILD_WORKFLOW_RUN_WAIT_STATUSES = ["completed", "timeout"];
|
|
36
40
|
var WorkflowRunNotExecutableError = class extends Error {
|
|
37
41
|
id;
|
|
38
42
|
status;
|
|
@@ -72,7 +76,23 @@ var WorkflowRunRevisionConflictError = class extends Error {
|
|
|
72
76
|
this.id = id;
|
|
73
77
|
}
|
|
74
78
|
};
|
|
79
|
+
var NonDeterminismError = class extends Error {
|
|
80
|
+
id;
|
|
81
|
+
attempts;
|
|
82
|
+
unconsumedManifestEntries;
|
|
83
|
+
constructor(id, attempts, unconsumedManifestEntries) {
|
|
84
|
+
super(`Replay divergence for Workflow run ${id}`);
|
|
85
|
+
this.name = "NonDeterminismError";
|
|
86
|
+
this.id = id;
|
|
87
|
+
this.attempts = attempts;
|
|
88
|
+
this.unconsumedManifestEntries = unconsumedManifestEntries;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
75
91
|
export {
|
|
92
|
+
CHILD_WORKFLOW_RUN_WAIT_STATUSES,
|
|
93
|
+
NON_TERMINAL_WORKFLOW_RUN_STATUSES,
|
|
94
|
+
NonDeterminismError,
|
|
95
|
+
TERMINAL_WORKFLOW_RUN_STATUSES,
|
|
76
96
|
WORKFLOW_RUN_CONFLICT_POLICIES,
|
|
77
97
|
WORKFLOW_RUN_FAILURE_CAUSE,
|
|
78
98
|
WORKFLOW_RUN_SCHEDULED_REASON,
|
package/dist/workflow.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ type WorkflowName = string & {
|
|
|
4
4
|
type WorkflowVersionId = string & {
|
|
5
5
|
_brand: "workflow_version_id";
|
|
6
6
|
};
|
|
7
|
+
declare const WORKFLOW_SOURCES: readonly ["user", "system"];
|
|
8
|
+
type WorkflowSource = (typeof WORKFLOW_SOURCES)[number];
|
|
7
9
|
interface WorkflowMeta {
|
|
8
10
|
name: WorkflowName;
|
|
9
11
|
versionId: WorkflowVersionId;
|
|
@@ -20,4 +22,4 @@ interface Workflow {
|
|
|
20
22
|
lastRunAt: number;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
export type
|
|
25
|
+
export { WORKFLOW_SOURCES, type Workflow, type WorkflowMeta, type WorkflowName, type WorkflowSource, type WorkflowVersionId, type WorkflowVersionStats };
|
package/dist/workflow.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aikirun/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Core type definitions for Aiki - including workflow, task, client, and trigger types",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -20,10 +20,18 @@
|
|
|
20
20
|
"types": "./dist/event.d.ts",
|
|
21
21
|
"import": "./dist/event.js"
|
|
22
22
|
},
|
|
23
|
+
"./namespace": {
|
|
24
|
+
"types": "./dist/namespace.d.ts",
|
|
25
|
+
"import": "./dist/namespace.js"
|
|
26
|
+
},
|
|
23
27
|
"./namespace-api": {
|
|
24
28
|
"types": "./dist/namespace-api.d.ts",
|
|
25
29
|
"import": "./dist/namespace-api.js"
|
|
26
30
|
},
|
|
31
|
+
"./organization": {
|
|
32
|
+
"types": "./dist/organization.d.ts",
|
|
33
|
+
"import": "./dist/organization.js"
|
|
34
|
+
},
|
|
27
35
|
"./retry": {
|
|
28
36
|
"types": "./dist/retry.d.ts",
|
|
29
37
|
"import": "./dist/retry.js"
|
|
@@ -44,6 +52,10 @@
|
|
|
44
52
|
"types": "./dist/sleep.d.ts",
|
|
45
53
|
"import": "./dist/sleep.js"
|
|
46
54
|
},
|
|
55
|
+
"./state-transition": {
|
|
56
|
+
"types": "./dist/state-transition.d.ts",
|
|
57
|
+
"import": "./dist/state-transition.js"
|
|
58
|
+
},
|
|
47
59
|
"./symbols": {
|
|
48
60
|
"types": "./dist/symbols.d.ts",
|
|
49
61
|
"import": "./dist/symbols.js"
|