@aikirun/types 0.16.0 → 0.18.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/README.md +2 -0
- package/dist/api-key-api.d.ts +31 -0
- package/dist/api-key-api.js +5 -0
- package/dist/client.d.ts +3 -1
- package/dist/event.d.ts +11 -10
- package/dist/event.js +5 -0
- package/dist/namespace-api.d.ts +17 -0
- package/dist/namespace-api.js +0 -0
- 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 +23 -16
- package/dist/schedule.js +11 -0
- package/dist/sleep.d.ts +9 -8
- package/dist/sleep.js +5 -0
- package/dist/state-transition.d.ts +29 -0
- package/dist/state-transition.js +5 -0
- package/dist/task.d.ts +7 -8
- package/dist/task.js +2 -0
- package/dist/workflow-api.d.ts +16 -12
- package/dist/workflow-run-api.d.ts +61 -30
- package/dist/workflow-run.d.ts +54 -38
- package/dist/workflow-run.js +51 -2
- package/dist/workflow.d.ts +3 -1
- package/dist/workflow.js +5 -0
- package/package.json +21 -1
package/README.md
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
declare const API_KEY_STATUSES: readonly ["active", "revoked", "expired"];
|
|
2
|
+
type ApiKeyStatus = (typeof API_KEY_STATUSES)[number];
|
|
3
|
+
interface ApiKeyInfo {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
keyPrefix: string;
|
|
7
|
+
status: ApiKeyStatus;
|
|
8
|
+
createdAt: number;
|
|
9
|
+
expiresAt: number | null;
|
|
10
|
+
}
|
|
11
|
+
interface ApiKeyCreateRequestV1 {
|
|
12
|
+
name: string;
|
|
13
|
+
expiresAt?: number;
|
|
14
|
+
}
|
|
15
|
+
interface ApiKeyCreateResponseV1 {
|
|
16
|
+
key: string;
|
|
17
|
+
info: ApiKeyInfo;
|
|
18
|
+
}
|
|
19
|
+
interface ApiKeyListResponseV1 {
|
|
20
|
+
keyInfos: ApiKeyInfo[];
|
|
21
|
+
}
|
|
22
|
+
interface ApiKeyRevokeRequestV1 {
|
|
23
|
+
id: string;
|
|
24
|
+
}
|
|
25
|
+
interface ApiKeyApi {
|
|
26
|
+
createV1: (_: ApiKeyCreateRequestV1) => Promise<ApiKeyCreateResponseV1>;
|
|
27
|
+
listV1: () => Promise<ApiKeyListResponseV1>;
|
|
28
|
+
revokeV1: (_: ApiKeyRevokeRequestV1) => Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { API_KEY_STATUSES, type ApiKeyApi, type ApiKeyCreateRequestV1, type ApiKeyCreateResponseV1, type ApiKeyInfo, type ApiKeyListResponseV1, type ApiKeyRevokeRequestV1, type ApiKeyStatus };
|
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,9 +12,11 @@ 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;
|
|
19
|
+
apiKey?: string;
|
|
18
20
|
redis: RedisConfig;
|
|
19
21
|
logger?: Logger;
|
|
20
22
|
createContext?: (run: Readonly<WorkflowRun>) => AppContext | Promise<AppContext>;
|
package/dist/event.d.ts
CHANGED
|
@@ -4,28 +4,29 @@ import './utils.js';
|
|
|
4
4
|
type EventName = string & {
|
|
5
5
|
_brand: "event_name";
|
|
6
6
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
declare const EVENT_WAIT_STATUSES: readonly ["received", "timeout"];
|
|
8
|
+
type EventWaitStatus = (typeof EVENT_WAIT_STATUSES)[number];
|
|
9
|
+
interface EventWaitBase {
|
|
10
|
+
status: EventWaitStatus;
|
|
10
11
|
}
|
|
11
|
-
interface
|
|
12
|
+
interface EventWaitReceived<Data> extends EventWaitBase {
|
|
12
13
|
status: "received";
|
|
13
14
|
data?: Data;
|
|
14
15
|
receivedAt: number;
|
|
15
16
|
reference?: EventReferenceOptions;
|
|
16
17
|
}
|
|
17
|
-
interface
|
|
18
|
+
interface EventWaitTimeout extends EventWaitBase {
|
|
18
19
|
status: "timeout";
|
|
19
20
|
timedOutAt: number;
|
|
20
21
|
}
|
|
21
|
-
type
|
|
22
|
-
interface
|
|
23
|
-
|
|
22
|
+
type EventWait<Data> = EventWaitReceived<Data> | EventWaitTimeout;
|
|
23
|
+
interface EventWaitQueue<Data> {
|
|
24
|
+
eventWaits: EventWait<Data>[];
|
|
24
25
|
}
|
|
25
26
|
interface EventWaitOptions<Timed extends boolean> {
|
|
26
27
|
timeout?: Timed extends true ? DurationObject : never;
|
|
27
28
|
}
|
|
28
|
-
type
|
|
29
|
+
type EventWaitResult<Data, Timed extends boolean> = Timed extends false ? {
|
|
29
30
|
data: Data;
|
|
30
31
|
} : {
|
|
31
32
|
timeout: false;
|
|
@@ -40,4 +41,4 @@ interface EventReferenceOptions {
|
|
|
40
41
|
id: string;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
export
|
|
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 };
|
package/dist/event.js
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface NamespaceInfo {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
organizationId: string;
|
|
5
|
+
createdAt: number;
|
|
6
|
+
}
|
|
7
|
+
interface NamespaceCreateRequestV1 {
|
|
8
|
+
name: string;
|
|
9
|
+
}
|
|
10
|
+
interface NamespaceCreateResponseV1 {
|
|
11
|
+
namespace: NamespaceInfo;
|
|
12
|
+
}
|
|
13
|
+
interface NamespaceApi {
|
|
14
|
+
createV1: (_: NamespaceCreateRequestV1) => Promise<NamespaceCreateResponseV1>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type { NamespaceApi, NamespaceCreateRequestV1, NamespaceCreateResponseV1, NamespaceInfo };
|
|
File without changes
|
|
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
|
@@ -1,40 +1,47 @@
|
|
|
1
1
|
type ScheduleId = string & {
|
|
2
2
|
_brand: "schedule_id";
|
|
3
3
|
};
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
declare const SCHEDULE_STATUSES: readonly ["active", "paused", "deleted"];
|
|
5
|
+
type ScheduleStatus = (typeof SCHEDULE_STATUSES)[number];
|
|
6
|
+
declare const SCHEDULE_TYPES: readonly ["cron", "interval"];
|
|
7
|
+
type ScheduleType = (typeof SCHEDULE_TYPES)[number];
|
|
8
|
+
declare const SCHEDULE_OVERLAP_POLICIES: readonly ["allow", "skip", "cancel_previous"];
|
|
9
|
+
type ScheduleOverlapPolicy = (typeof SCHEDULE_OVERLAP_POLICIES)[number];
|
|
10
|
+
interface ScheduleSpecBase {
|
|
11
|
+
type: ScheduleType;
|
|
12
|
+
overlapPolicy?: ScheduleOverlapPolicy;
|
|
11
13
|
}
|
|
12
|
-
interface CronScheduleSpec {
|
|
14
|
+
interface CronScheduleSpec extends ScheduleSpecBase {
|
|
13
15
|
type: "cron";
|
|
14
16
|
expression: string;
|
|
15
17
|
timezone?: string;
|
|
16
|
-
overlapPolicy?: OverlapPolicy;
|
|
17
18
|
}
|
|
18
|
-
interface IntervalScheduleSpec {
|
|
19
|
+
interface IntervalScheduleSpec extends ScheduleSpecBase {
|
|
19
20
|
type: "interval";
|
|
20
21
|
everyMs: number;
|
|
21
|
-
overlapPolicy?: OverlapPolicy;
|
|
22
22
|
}
|
|
23
23
|
type ScheduleSpec = CronScheduleSpec | IntervalScheduleSpec;
|
|
24
|
-
|
|
24
|
+
declare const SCHEDULE_CONFLICT_POLICIES: readonly ["upsert", "error"];
|
|
25
|
+
type ScheduleConflictPolicy = (typeof SCHEDULE_CONFLICT_POLICIES)[number];
|
|
26
|
+
interface ScheduleReferenceOptions {
|
|
27
|
+
id: string;
|
|
28
|
+
conflictPolicy?: ScheduleConflictPolicy;
|
|
29
|
+
}
|
|
30
|
+
interface ScheduleActivateOptions {
|
|
31
|
+
reference?: ScheduleReferenceOptions;
|
|
32
|
+
}
|
|
25
33
|
interface Schedule {
|
|
26
34
|
id: string;
|
|
27
35
|
workflowName: string;
|
|
28
36
|
workflowVersionId: string;
|
|
29
|
-
input?: unknown;
|
|
30
|
-
spec: ScheduleSpec;
|
|
31
37
|
status: ScheduleStatus;
|
|
38
|
+
spec: ScheduleSpec;
|
|
39
|
+
input?: unknown;
|
|
32
40
|
options?: ScheduleActivateOptions;
|
|
33
41
|
createdAt: number;
|
|
34
42
|
updatedAt: number;
|
|
35
43
|
lastOccurrence?: number;
|
|
36
44
|
nextRunAt: number;
|
|
37
|
-
runCount: number;
|
|
38
45
|
}
|
|
39
46
|
|
|
40
|
-
export type
|
|
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/schedule.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// schedule.ts
|
|
2
|
+
var SCHEDULE_STATUSES = ["active", "paused", "deleted"];
|
|
3
|
+
var SCHEDULE_TYPES = ["cron", "interval"];
|
|
4
|
+
var SCHEDULE_OVERLAP_POLICIES = ["allow", "skip", "cancel_previous"];
|
|
5
|
+
var SCHEDULE_CONFLICT_POLICIES = ["upsert", "error"];
|
|
6
|
+
export {
|
|
7
|
+
SCHEDULE_CONFLICT_POLICIES,
|
|
8
|
+
SCHEDULE_OVERLAP_POLICIES,
|
|
9
|
+
SCHEDULE_STATUSES,
|
|
10
|
+
SCHEDULE_TYPES
|
|
11
|
+
};
|
package/dist/sleep.d.ts
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
type SleepName = string & {
|
|
2
2
|
_brand: "sleep_name";
|
|
3
3
|
};
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
declare const SLEEP_STATUSES: readonly ["sleeping", "completed", "cancelled"];
|
|
5
|
+
type SleepStatus = (typeof SLEEP_STATUSES)[number];
|
|
6
|
+
interface SleepBase {
|
|
6
7
|
status: SleepStatus;
|
|
7
8
|
}
|
|
8
|
-
interface
|
|
9
|
+
interface SleepSleeping extends SleepBase {
|
|
9
10
|
status: "sleeping";
|
|
10
11
|
awakeAt: number;
|
|
11
12
|
}
|
|
12
|
-
interface
|
|
13
|
+
interface SleepCompleted extends SleepBase {
|
|
13
14
|
status: "completed";
|
|
14
15
|
durationMs: number;
|
|
15
16
|
completedAt: number;
|
|
16
17
|
}
|
|
17
|
-
interface
|
|
18
|
+
interface SleepCancelled extends SleepBase {
|
|
18
19
|
status: "cancelled";
|
|
19
20
|
cancelledAt: number;
|
|
20
21
|
}
|
|
21
|
-
type
|
|
22
|
+
type Sleep = SleepSleeping | SleepCompleted | SleepCancelled;
|
|
22
23
|
interface SleepQueue {
|
|
23
|
-
sleeps:
|
|
24
|
+
sleeps: Sleep[];
|
|
24
25
|
}
|
|
25
26
|
interface SleepResult {
|
|
26
27
|
cancelled: boolean;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
export type
|
|
30
|
+
export { SLEEP_STATUSES, type Sleep, type SleepCancelled, type SleepCompleted, type SleepName, type SleepQueue, type SleepResult, type SleepSleeping, type SleepStatus };
|
package/dist/sleep.js
CHANGED
|
@@ -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
|
@@ -11,16 +11,12 @@ type TaskName = string & {
|
|
|
11
11
|
type TaskAddress = string & {
|
|
12
12
|
_brand: "task_address";
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
declare const TASK_STATUSES: readonly ["running", "awaiting_retry", "completed", "failed"];
|
|
15
|
+
type TaskStatus = (typeof TASK_STATUSES)[number];
|
|
15
16
|
interface TaskDefinitionOptions {
|
|
16
17
|
retry?: RetryStrategy;
|
|
17
18
|
}
|
|
18
19
|
interface TaskStartOptions extends TaskDefinitionOptions {
|
|
19
|
-
reference?: TaskReferenceOptions;
|
|
20
|
-
}
|
|
21
|
-
interface TaskReferenceOptions {
|
|
22
|
-
id: string;
|
|
23
|
-
conflictPolicy?: "error" | "return_existing";
|
|
24
20
|
}
|
|
25
21
|
interface TaskStateBase {
|
|
26
22
|
status: TaskStatus;
|
|
@@ -55,7 +51,7 @@ interface TaskInfo {
|
|
|
55
51
|
}
|
|
56
52
|
interface TransitionTaskStateBase {
|
|
57
53
|
id: string;
|
|
58
|
-
|
|
54
|
+
expectedWorkflowRunRevision: number;
|
|
59
55
|
}
|
|
60
56
|
interface TransitionTaskStateToRunningCreate extends TransitionTaskStateBase {
|
|
61
57
|
type: "create";
|
|
@@ -86,6 +82,9 @@ interface TransitionTaskStateToAwaitingRetry extends TransitionTaskStateBase {
|
|
|
86
82
|
type TaskStateAwaitingRetryRequest = Omit<TaskStateAwaitingRetry, "nextAttemptAt"> & {
|
|
87
83
|
nextAttemptInMs: number;
|
|
88
84
|
};
|
|
85
|
+
interface TaskQueue {
|
|
86
|
+
tasks: TaskInfo[];
|
|
87
|
+
}
|
|
89
88
|
declare class TaskFailedError extends Error {
|
|
90
89
|
readonly taskId: TaskId;
|
|
91
90
|
readonly attempts: number;
|
|
@@ -93,4 +92,4 @@ declare class TaskFailedError extends Error {
|
|
|
93
92
|
constructor(taskId: TaskId, attempts: number, reason: string);
|
|
94
93
|
}
|
|
95
94
|
|
|
96
|
-
export { type TaskAddress, type TaskDefinitionOptions, TaskFailedError, type TaskId, type TaskInfo, type TaskName, type
|
|
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,4 +1,5 @@
|
|
|
1
1
|
// task.ts
|
|
2
|
+
var TASK_STATUSES = ["running", "awaiting_retry", "completed", "failed"];
|
|
2
3
|
var TaskFailedError = class extends Error {
|
|
3
4
|
taskId;
|
|
4
5
|
attempts;
|
|
@@ -12,5 +13,6 @@ var TaskFailedError = class extends Error {
|
|
|
12
13
|
}
|
|
13
14
|
};
|
|
14
15
|
export {
|
|
16
|
+
TASK_STATUSES,
|
|
15
17
|
TaskFailedError
|
|
16
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,29 +18,39 @@ 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>;
|
|
23
28
|
}
|
|
24
29
|
interface WorkflowRunListRequestV1 {
|
|
25
30
|
limit?: number;
|
|
26
31
|
offset?: number;
|
|
27
32
|
filters?: {
|
|
28
|
-
|
|
33
|
+
id?: string;
|
|
29
34
|
status?: WorkflowRunStatus[];
|
|
30
|
-
|
|
35
|
+
workflow?: WorkflowFilter;
|
|
31
36
|
};
|
|
32
37
|
sort?: {
|
|
33
|
-
field: "createdAt";
|
|
34
38
|
order: "asc" | "desc";
|
|
35
39
|
};
|
|
36
40
|
}
|
|
37
|
-
|
|
41
|
+
type WorkflowFilter = {
|
|
38
42
|
name: string;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
source: WorkflowSource;
|
|
44
|
+
} | {
|
|
45
|
+
name: string;
|
|
46
|
+
source: WorkflowSource;
|
|
47
|
+
versionId: string;
|
|
48
|
+
} | {
|
|
49
|
+
name: string;
|
|
50
|
+
source: WorkflowSource;
|
|
51
|
+
versionId: string;
|
|
52
|
+
referenceId: string;
|
|
53
|
+
};
|
|
42
54
|
interface WorkflowRunListItem {
|
|
43
55
|
id: string;
|
|
44
56
|
name: string;
|
|
@@ -57,11 +69,12 @@ interface WorkflowRunGetByIdRequestV1 {
|
|
|
57
69
|
interface WorkflowRunGetByIdResponseV1 {
|
|
58
70
|
run: WorkflowRun;
|
|
59
71
|
}
|
|
60
|
-
interface
|
|
72
|
+
interface WorkflowRunReference {
|
|
61
73
|
name: string;
|
|
62
74
|
versionId: string;
|
|
63
75
|
referenceId: string;
|
|
64
76
|
}
|
|
77
|
+
type WorkflowRunGetByReferenceIdRequestV1 = WorkflowRunReference;
|
|
65
78
|
interface WorkflowRunGetByReferenceIdResponseV1 {
|
|
66
79
|
run: WorkflowRun;
|
|
67
80
|
}
|
|
@@ -79,11 +92,14 @@ interface WorkflowRunCreateRequestV1 {
|
|
|
79
92
|
options?: WorkflowStartOptions;
|
|
80
93
|
}
|
|
81
94
|
interface WorkflowRunCreateResponseV1 {
|
|
82
|
-
|
|
95
|
+
id: string;
|
|
83
96
|
}
|
|
84
97
|
type WorkflowRunStateScheduledRequest = DistributiveOmit<WorkflowRunStateScheduled, "scheduledAt"> & {
|
|
85
98
|
scheduledInMs: number;
|
|
86
99
|
};
|
|
100
|
+
type WorkflowRunStateSleepingRequest = DistributiveOmit<WorkflowRunStateSleeping, "awakeAt"> & {
|
|
101
|
+
durationMs: number;
|
|
102
|
+
};
|
|
87
103
|
type WorkflowRunStateAwaitingEventRequest = DistributiveOmit<WorkflowRunStateAwaitingEvent, "timeoutAt"> & {
|
|
88
104
|
timeoutInMs?: number;
|
|
89
105
|
};
|
|
@@ -95,8 +111,8 @@ type WorkflowRunStateAwaitingChildWorkflowRequest = DistributiveOmit<WorkflowRun
|
|
|
95
111
|
};
|
|
96
112
|
type WorkflowRunStateCompletedRequest = OptionalProp<WorkflowRunStateCompleted<unknown>, "output">;
|
|
97
113
|
type WorkflowRunStateRequest = Exclude<WorkflowRunState, {
|
|
98
|
-
status: "scheduled" | "awaiting_event" | "awaiting_retry" | "awaiting_child_workflow" | "completed";
|
|
99
|
-
}> | WorkflowRunStateScheduledRequest | WorkflowRunStateAwaitingEventRequest | WorkflowRunStateAwaitingRetryRequest | WorkflowRunStateAwaitingChildWorkflowRequest | WorkflowRunStateCompletedRequest;
|
|
114
|
+
status: "scheduled" | "sleeping" | "awaiting_event" | "awaiting_retry" | "awaiting_child_workflow" | "completed";
|
|
115
|
+
}> | WorkflowRunStateScheduledRequest | WorkflowRunStateSleepingRequest | WorkflowRunStateAwaitingEventRequest | WorkflowRunStateAwaitingRetryRequest | WorkflowRunStateAwaitingChildWorkflowRequest | WorkflowRunStateCompletedRequest;
|
|
100
116
|
interface WorkflowRunTransitionStateRequestBase {
|
|
101
117
|
type: "optimistic" | "pessimistic";
|
|
102
118
|
id: string;
|
|
@@ -121,22 +137,20 @@ interface WorkflowRunTransitionStateRequestPessimistic extends WorkflowRunTransi
|
|
|
121
137
|
}
|
|
122
138
|
type WorkflowRunTransitionStateRequestV1 = WorkflowRunTransitionStateRequestOptimistic | WorkflowRunTransitionStateRequestPessimistic;
|
|
123
139
|
interface WorkflowRunTransitionStateResponseV1 {
|
|
124
|
-
|
|
140
|
+
revision: number;
|
|
141
|
+
state: WorkflowRunState;
|
|
142
|
+
attempts: number;
|
|
125
143
|
}
|
|
126
144
|
type TransitionTaskStateToRunning = TransitionTaskStateToRunningCreate | TransitionTaskStateToRunningRetry;
|
|
127
145
|
type WorkflowRunTransitionTaskStateRequestV1 = TransitionTaskStateToRunning | TransitionTaskStateToCompleted | TransitionTaskStateToFailed | TransitionTaskStateToAwaitingRetry;
|
|
128
146
|
interface WorkflowRunTransitionTaskStateResponseV1 {
|
|
129
|
-
|
|
130
|
-
taskId: string;
|
|
147
|
+
taskInfo: TaskInfo;
|
|
131
148
|
}
|
|
132
149
|
interface WorkflowRunSetTaskStateRequestNew {
|
|
133
150
|
type: "new";
|
|
134
151
|
id: string;
|
|
135
152
|
taskName: string;
|
|
136
153
|
input?: unknown;
|
|
137
|
-
reference?: {
|
|
138
|
-
id: string;
|
|
139
|
-
};
|
|
140
154
|
state: DistributiveOmit<TaskStateCompleted<unknown> | TaskStateFailed, "attempts">;
|
|
141
155
|
}
|
|
142
156
|
interface WorkflowRunSetTaskStateRequestExisting {
|
|
@@ -146,20 +160,16 @@ interface WorkflowRunSetTaskStateRequestExisting {
|
|
|
146
160
|
state: DistributiveOmit<TaskStateCompleted<unknown> | TaskStateFailed, "attempts">;
|
|
147
161
|
}
|
|
148
162
|
type WorkflowRunSetTaskStateRequestV1 = WorkflowRunSetTaskStateRequestNew | WorkflowRunSetTaskStateRequestExisting;
|
|
149
|
-
interface WorkflowRunSetTaskStateResponseV1 {
|
|
150
|
-
run: WorkflowRun;
|
|
151
|
-
}
|
|
152
163
|
interface WorkflowRunListTransitionsRequestV1 {
|
|
153
164
|
id: string;
|
|
154
165
|
limit?: number;
|
|
155
166
|
offset?: number;
|
|
156
167
|
sort?: {
|
|
157
|
-
field: "createdAt";
|
|
158
168
|
order: "asc" | "desc";
|
|
159
169
|
};
|
|
160
170
|
}
|
|
161
171
|
interface WorkflowRunListTransitionsResponseV1 {
|
|
162
|
-
transitions:
|
|
172
|
+
transitions: StateTransition[];
|
|
163
173
|
total: number;
|
|
164
174
|
}
|
|
165
175
|
interface WorkflowRunSendEventRequestV1 {
|
|
@@ -168,14 +178,35 @@ interface WorkflowRunSendEventRequestV1 {
|
|
|
168
178
|
data?: unknown;
|
|
169
179
|
options?: EventSendOptions;
|
|
170
180
|
}
|
|
171
|
-
interface WorkflowRunSendEventResponseV1 {
|
|
172
|
-
run: WorkflowRun;
|
|
173
|
-
}
|
|
174
181
|
interface WorkflowRunMulticastEventRequestV1 {
|
|
175
182
|
ids: string[];
|
|
176
183
|
eventName: string;
|
|
177
184
|
data?: unknown;
|
|
178
185
|
options?: EventSendOptions;
|
|
179
186
|
}
|
|
187
|
+
interface WorkflowRunMulticastEventByReferenceRequestV1 {
|
|
188
|
+
references: WorkflowRunReference[];
|
|
189
|
+
eventName: string;
|
|
190
|
+
data?: unknown;
|
|
191
|
+
options?: EventSendOptions;
|
|
192
|
+
}
|
|
193
|
+
interface WorkflowRunListChildRunsRequestV1 {
|
|
194
|
+
parentRunId: string;
|
|
195
|
+
status?: WorkflowRunStatus[];
|
|
196
|
+
}
|
|
197
|
+
interface WorkflowRunListChildRunsResponseV1 {
|
|
198
|
+
runs: Array<{
|
|
199
|
+
id: string;
|
|
200
|
+
options?: {
|
|
201
|
+
shard?: string;
|
|
202
|
+
};
|
|
203
|
+
}>;
|
|
204
|
+
}
|
|
205
|
+
interface WorkflowRunCancelByIdsRequestV1 {
|
|
206
|
+
ids: string[];
|
|
207
|
+
}
|
|
208
|
+
interface WorkflowRunCancelByIdsResponseV1 {
|
|
209
|
+
cancelledIds: string[];
|
|
210
|
+
}
|
|
180
211
|
|
|
181
|
-
export type { TransitionTaskStateToRunning, WorkflowFilter, WorkflowRunApi, WorkflowRunCreateRequestV1, WorkflowRunCreateResponseV1, WorkflowRunGetByIdRequestV1, WorkflowRunGetByIdResponseV1, WorkflowRunGetByReferenceIdRequestV1, WorkflowRunGetByReferenceIdResponseV1, WorkflowRunGetStateRequestV1, WorkflowRunGetStateResponseV1, WorkflowRunListItem, WorkflowRunListRequestV1, WorkflowRunListResponseV1, WorkflowRunListTransitionsRequestV1, WorkflowRunListTransitionsResponseV1, WorkflowRunMulticastEventRequestV1,
|
|
212
|
+
export type { TransitionTaskStateToRunning, WorkflowFilter, WorkflowRunApi, WorkflowRunCancelByIdsRequestV1, WorkflowRunCancelByIdsResponseV1, WorkflowRunCreateRequestV1, WorkflowRunCreateResponseV1, WorkflowRunGetByIdRequestV1, WorkflowRunGetByIdResponseV1, WorkflowRunGetByReferenceIdRequestV1, WorkflowRunGetByReferenceIdResponseV1, WorkflowRunGetStateRequestV1, WorkflowRunGetStateResponseV1, 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
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
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';
|
|
@@ -13,14 +13,18 @@ type WorkflowRunId = string & {
|
|
|
13
13
|
type WorkflowRunAddress = string & {
|
|
14
14
|
_brand: "workflow_run_address";
|
|
15
15
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
declare const WORKFLOW_RUN_STATUSES: readonly ["scheduled", "queued", "running", "paused", "sleeping", "awaiting_event", "awaiting_retry", "awaiting_child_workflow", "cancelled", "completed", "failed"];
|
|
17
|
+
type WorkflowRunStatus = (typeof WORKFLOW_RUN_STATUSES)[number];
|
|
18
|
+
declare const TERMINAL_WORKFLOW_RUN_STATUSES: readonly ["cancelled", "completed", "failed"];
|
|
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")[];
|
|
19
21
|
type NonTerminalWorkflowRunStatus = Exclude<WorkflowRunStatus, TerminalWorkflowRunStatus>;
|
|
20
22
|
declare function isTerminalWorkflowRunStatus(status: WorkflowRunStatus): status is TerminalWorkflowRunStatus;
|
|
23
|
+
declare const WORKFLOW_RUN_CONFLICT_POLICIES: readonly ["error", "return_existing"];
|
|
24
|
+
type WorkflowRunConflictPolicy = (typeof WORKFLOW_RUN_CONFLICT_POLICIES)[number];
|
|
21
25
|
interface WorkflowReferenceOptions {
|
|
22
26
|
id: string;
|
|
23
|
-
conflictPolicy?:
|
|
27
|
+
conflictPolicy?: WorkflowRunConflictPolicy;
|
|
24
28
|
}
|
|
25
29
|
interface WorkflowDefinitionOptions {
|
|
26
30
|
retry?: RetryStrategy;
|
|
@@ -33,7 +37,8 @@ interface WorkflowStartOptions extends WorkflowDefinitionOptions {
|
|
|
33
37
|
interface WorkflowRunStateBase {
|
|
34
38
|
status: WorkflowRunStatus;
|
|
35
39
|
}
|
|
36
|
-
|
|
40
|
+
declare const WORKFLOW_RUN_SCHEDULED_REASON: readonly ["new", "retry", "task_retry", "awake", "awake_early", "resume", "event", "child_workflow"];
|
|
41
|
+
type WorkflowRunScheduledReason = (typeof WORKFLOW_RUN_SCHEDULED_REASON)[number];
|
|
37
42
|
interface WorkflowRunStateScheduledBase extends WorkflowRunStateBase {
|
|
38
43
|
status: "scheduled";
|
|
39
44
|
scheduledAt: number;
|
|
@@ -77,17 +82,18 @@ interface WorkflowRunStatePaused extends WorkflowRunStateBase {
|
|
|
77
82
|
interface WorkflowRunStateSleeping extends WorkflowRunStateBase {
|
|
78
83
|
status: "sleeping";
|
|
79
84
|
sleepName: string;
|
|
80
|
-
|
|
85
|
+
awakeAt: number;
|
|
81
86
|
}
|
|
82
87
|
interface WorkflowRunStateAwaitingEvent extends WorkflowRunStateBase {
|
|
83
88
|
status: "awaiting_event";
|
|
84
89
|
eventName: string;
|
|
85
90
|
timeoutAt?: number;
|
|
86
91
|
}
|
|
87
|
-
|
|
92
|
+
declare const WORKFLOW_RUN_FAILURE_CAUSE: readonly ["task", "child_workflow", "self"];
|
|
93
|
+
type WorkflowRunFailureCause = (typeof WORKFLOW_RUN_FAILURE_CAUSE)[number];
|
|
88
94
|
interface WorkflowRunStateAwaitingRetryBase extends WorkflowRunStateBase {
|
|
89
95
|
status: "awaiting_retry";
|
|
90
|
-
cause:
|
|
96
|
+
cause: WorkflowRunFailureCause;
|
|
91
97
|
nextAttemptAt: number;
|
|
92
98
|
}
|
|
93
99
|
interface WorkflowRunStateAwaitingRetryCausedByTask extends WorkflowRunStateAwaitingRetryBase {
|
|
@@ -106,7 +112,7 @@ type WorkflowRunStateAwaitingRetry = WorkflowRunStateAwaitingRetryCausedByTask |
|
|
|
106
112
|
interface WorkflowRunStateAwaitingChildWorkflow extends WorkflowRunStateBase {
|
|
107
113
|
status: "awaiting_child_workflow";
|
|
108
114
|
childWorkflowRunId: string;
|
|
109
|
-
childWorkflowRunStatus:
|
|
115
|
+
childWorkflowRunStatus: TerminalWorkflowRunStatus;
|
|
110
116
|
timeoutAt?: number;
|
|
111
117
|
}
|
|
112
118
|
interface WorkflowRunStateCancelled extends WorkflowRunStateBase {
|
|
@@ -119,7 +125,7 @@ interface WorkflowRunStateCompleted<Output> extends WorkflowRunStateBase {
|
|
|
119
125
|
}
|
|
120
126
|
interface WorkflowRunStateFailedBase extends WorkflowRunStateBase {
|
|
121
127
|
status: "failed";
|
|
122
|
-
cause:
|
|
128
|
+
cause: WorkflowRunFailureCause;
|
|
123
129
|
}
|
|
124
130
|
interface WorkflowRunStateFailedByTask extends WorkflowRunStateFailedBase {
|
|
125
131
|
cause: "task";
|
|
@@ -136,6 +142,9 @@ interface WorkflowRunStateFailedBySelf extends WorkflowRunStateFailedBase {
|
|
|
136
142
|
type WorkflowRunStateFailed = WorkflowRunStateFailedByTask | WorkflowRunStateFailedByChildWorkflow | WorkflowRunStateFailedBySelf;
|
|
137
143
|
type WorkflowRunStateInComplete = WorkflowRunStateScheduled | WorkflowRunStateQueued | WorkflowRunStateRunning | WorkflowRunStatePaused | WorkflowRunStateSleeping | WorkflowRunStateAwaitingEvent | WorkflowRunStateAwaitingRetry | WorkflowRunStateAwaitingChildWorkflow | WorkflowRunStateCancelled | WorkflowRunStateFailed;
|
|
138
144
|
type WorkflowRunState<Output = unknown> = WorkflowRunStateInComplete | WorkflowRunStateCompleted<Output>;
|
|
145
|
+
type TerminalWorkflowRunState = Extract<WorkflowRunState, {
|
|
146
|
+
status: "cancelled" | "completed" | "failed";
|
|
147
|
+
}>;
|
|
139
148
|
interface WorkflowRun<Input = unknown, Output = unknown> {
|
|
140
149
|
id: string;
|
|
141
150
|
name: string;
|
|
@@ -144,48 +153,43 @@ interface WorkflowRun<Input = unknown, Output = unknown> {
|
|
|
144
153
|
revision: number;
|
|
145
154
|
input?: Input;
|
|
146
155
|
inputHash: string;
|
|
147
|
-
|
|
148
|
-
options: WorkflowStartOptions;
|
|
156
|
+
options?: WorkflowStartOptions;
|
|
149
157
|
attempts: number;
|
|
150
158
|
state: WorkflowRunState<Output>;
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
159
|
+
taskQueues: Record<string, TaskQueue>;
|
|
160
|
+
sleepQueues: Record<string, SleepQueue>;
|
|
161
|
+
eventWaitQueues: Record<string, EventWaitQueue<unknown>>;
|
|
162
|
+
childWorkflowRunQueues: Record<string, ChildWorkflowRunQueue>;
|
|
155
163
|
parentWorkflowRunId?: string;
|
|
156
164
|
}
|
|
165
|
+
interface ChildWorkflowRunQueue {
|
|
166
|
+
childWorkflowRuns: ChildWorkflowRunInfo[];
|
|
167
|
+
}
|
|
157
168
|
interface ChildWorkflowRunInfo {
|
|
158
169
|
id: string;
|
|
159
170
|
name: string;
|
|
160
171
|
versionId: string;
|
|
161
172
|
inputHash: string;
|
|
162
|
-
|
|
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;
|
|
163
179
|
}
|
|
164
|
-
|
|
165
|
-
interface ChildWorkflowWaitResultCompleted {
|
|
180
|
+
interface ChildWorkflowRunWaitCompleted extends ChildWorkflowRunWaitBase {
|
|
166
181
|
status: "completed";
|
|
167
182
|
completedAt: number;
|
|
168
|
-
childWorkflowRunState:
|
|
183
|
+
childWorkflowRunState: TerminalWorkflowRunState;
|
|
169
184
|
}
|
|
170
|
-
interface
|
|
185
|
+
interface ChildWorkflowRunWaitTimeout extends ChildWorkflowRunWaitBase {
|
|
171
186
|
status: "timeout";
|
|
172
187
|
timedOutAt: number;
|
|
173
188
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
type: "state" | "task_state";
|
|
178
|
-
}
|
|
179
|
-
interface WorkflowRunStateTransition extends WorkflowRunTransitionBase {
|
|
180
|
-
type: "state";
|
|
181
|
-
state: WorkflowRunState;
|
|
189
|
+
type ChildWorkflowRunWait = ChildWorkflowRunWaitCompleted | ChildWorkflowRunWaitTimeout;
|
|
190
|
+
interface ChildWorkflowRunWaitQueue {
|
|
191
|
+
childWorkflowRunWaits: ChildWorkflowRunWait[];
|
|
182
192
|
}
|
|
183
|
-
interface WorkflowRunTaskStateTransition extends WorkflowRunTransitionBase {
|
|
184
|
-
type: "task_state";
|
|
185
|
-
taskId: string;
|
|
186
|
-
taskState: TaskState;
|
|
187
|
-
}
|
|
188
|
-
type WorkflowRunTransition = WorkflowRunStateTransition | WorkflowRunTaskStateTransition;
|
|
189
193
|
declare class WorkflowRunNotExecutableError extends Error {
|
|
190
194
|
readonly id: WorkflowRunId;
|
|
191
195
|
readonly status: WorkflowRunStatus;
|
|
@@ -205,5 +209,17 @@ declare class WorkflowRunRevisionConflictError extends Error {
|
|
|
205
209
|
readonly id: WorkflowRunId;
|
|
206
210
|
constructor(id: WorkflowRunId);
|
|
207
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
|
+
}
|
|
208
224
|
|
|
209
|
-
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
|
@@ -1,13 +1,42 @@
|
|
|
1
1
|
// workflow-run.ts
|
|
2
|
-
var
|
|
2
|
+
var WORKFLOW_RUN_STATUSES = [
|
|
3
|
+
"scheduled",
|
|
4
|
+
"queued",
|
|
5
|
+
"running",
|
|
6
|
+
"paused",
|
|
7
|
+
"sleeping",
|
|
8
|
+
"awaiting_event",
|
|
9
|
+
"awaiting_retry",
|
|
10
|
+
"awaiting_child_workflow",
|
|
11
|
+
"cancelled",
|
|
12
|
+
"completed",
|
|
13
|
+
"failed"
|
|
14
|
+
];
|
|
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
|
+
);
|
|
3
19
|
function isTerminalWorkflowRunStatus(status) {
|
|
4
|
-
for (const terminalStatus of
|
|
20
|
+
for (const terminalStatus of TERMINAL_WORKFLOW_RUN_STATUSES) {
|
|
5
21
|
if (status === terminalStatus) {
|
|
6
22
|
return true;
|
|
7
23
|
}
|
|
8
24
|
}
|
|
9
25
|
return false;
|
|
10
26
|
}
|
|
27
|
+
var WORKFLOW_RUN_CONFLICT_POLICIES = ["error", "return_existing"];
|
|
28
|
+
var WORKFLOW_RUN_SCHEDULED_REASON = [
|
|
29
|
+
"new",
|
|
30
|
+
"retry",
|
|
31
|
+
"task_retry",
|
|
32
|
+
"awake",
|
|
33
|
+
"awake_early",
|
|
34
|
+
"resume",
|
|
35
|
+
"event",
|
|
36
|
+
"child_workflow"
|
|
37
|
+
];
|
|
38
|
+
var WORKFLOW_RUN_FAILURE_CAUSE = ["task", "child_workflow", "self"];
|
|
39
|
+
var CHILD_WORKFLOW_RUN_WAIT_STATUSES = ["completed", "timeout"];
|
|
11
40
|
var WorkflowRunNotExecutableError = class extends Error {
|
|
12
41
|
id;
|
|
13
42
|
status;
|
|
@@ -47,7 +76,27 @@ var WorkflowRunRevisionConflictError = class extends Error {
|
|
|
47
76
|
this.id = id;
|
|
48
77
|
}
|
|
49
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
|
+
};
|
|
50
91
|
export {
|
|
92
|
+
CHILD_WORKFLOW_RUN_WAIT_STATUSES,
|
|
93
|
+
NON_TERMINAL_WORKFLOW_RUN_STATUSES,
|
|
94
|
+
NonDeterminismError,
|
|
95
|
+
TERMINAL_WORKFLOW_RUN_STATUSES,
|
|
96
|
+
WORKFLOW_RUN_CONFLICT_POLICIES,
|
|
97
|
+
WORKFLOW_RUN_FAILURE_CAUSE,
|
|
98
|
+
WORKFLOW_RUN_SCHEDULED_REASON,
|
|
99
|
+
WORKFLOW_RUN_STATUSES,
|
|
51
100
|
WorkflowRunFailedError,
|
|
52
101
|
WorkflowRunNotExecutableError,
|
|
53
102
|
WorkflowRunRevisionConflictError,
|
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,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aikirun/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Core type definitions for Aiki - including workflow, task, client, and trigger types",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
|
+
"./api-key-api": {
|
|
8
|
+
"types": "./dist/api-key-api.d.ts",
|
|
9
|
+
"import": "./dist/api-key-api.js"
|
|
10
|
+
},
|
|
7
11
|
"./client": {
|
|
8
12
|
"types": "./dist/client.d.ts",
|
|
9
13
|
"import": "./dist/client.js"
|
|
@@ -16,6 +20,18 @@
|
|
|
16
20
|
"types": "./dist/event.d.ts",
|
|
17
21
|
"import": "./dist/event.js"
|
|
18
22
|
},
|
|
23
|
+
"./namespace": {
|
|
24
|
+
"types": "./dist/namespace.d.ts",
|
|
25
|
+
"import": "./dist/namespace.js"
|
|
26
|
+
},
|
|
27
|
+
"./namespace-api": {
|
|
28
|
+
"types": "./dist/namespace-api.d.ts",
|
|
29
|
+
"import": "./dist/namespace-api.js"
|
|
30
|
+
},
|
|
31
|
+
"./organization": {
|
|
32
|
+
"types": "./dist/organization.d.ts",
|
|
33
|
+
"import": "./dist/organization.js"
|
|
34
|
+
},
|
|
19
35
|
"./retry": {
|
|
20
36
|
"types": "./dist/retry.d.ts",
|
|
21
37
|
"import": "./dist/retry.js"
|
|
@@ -36,6 +52,10 @@
|
|
|
36
52
|
"types": "./dist/sleep.d.ts",
|
|
37
53
|
"import": "./dist/sleep.js"
|
|
38
54
|
},
|
|
55
|
+
"./state-transition": {
|
|
56
|
+
"types": "./dist/state-transition.d.ts",
|
|
57
|
+
"import": "./dist/state-transition.js"
|
|
58
|
+
},
|
|
39
59
|
"./symbols": {
|
|
40
60
|
"types": "./dist/symbols.d.ts",
|
|
41
61
|
"import": "./dist/symbols.js"
|