@aikirun/types 0.16.0 → 0.17.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 +1 -0
- 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/schedule.d.ts +23 -15
- package/dist/schedule.js +11 -0
- package/dist/sleep.d.ts +3 -2
- package/dist/sleep.js +5 -0
- package/dist/task.d.ts +6 -3
- package/dist/task.js +4 -0
- package/dist/workflow-run-api.d.ts +8 -5
- package/dist/workflow-run.d.ts +18 -13
- package/dist/workflow-run.js +31 -2
- package/package.json +9 -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
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 EventWaitStateBase {
|
|
10
|
+
status: EventWaitStatus;
|
|
10
11
|
}
|
|
11
|
-
interface
|
|
12
|
+
interface EventWaitStateReceived<Data> extends EventWaitStateBase {
|
|
12
13
|
status: "received";
|
|
13
14
|
data?: Data;
|
|
14
15
|
receivedAt: number;
|
|
15
16
|
reference?: EventReferenceOptions;
|
|
16
17
|
}
|
|
17
|
-
interface
|
|
18
|
+
interface EventWaitStateTimeout extends EventWaitStateBase {
|
|
18
19
|
status: "timeout";
|
|
19
20
|
timedOutAt: number;
|
|
20
21
|
}
|
|
21
|
-
type
|
|
22
|
-
interface
|
|
23
|
-
|
|
22
|
+
type EventWaitState<Data> = EventWaitStateReceived<Data> | EventWaitStateTimeout;
|
|
23
|
+
interface EventWaitQueue<Data> {
|
|
24
|
+
eventWaits: EventWaitState<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 EventWaitOptions, type EventWaitQueue, type EventWaitResult, type EventWaitState, type EventWaitStateReceived, type EventWaitStateTimeout, type EventWaitStatus };
|
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
|
package/dist/schedule.d.ts
CHANGED
|
@@ -1,34 +1,42 @@
|
|
|
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;
|
|
@@ -37,4 +45,4 @@ interface Schedule {
|
|
|
37
45
|
runCount: number;
|
|
38
46
|
}
|
|
39
47
|
|
|
40
|
-
export type
|
|
48
|
+
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,7 +1,8 @@
|
|
|
1
1
|
type SleepName = string & {
|
|
2
2
|
_brand: "sleep_name";
|
|
3
3
|
};
|
|
4
|
-
|
|
4
|
+
declare const SLEEP_STATUSES: readonly ["sleeping", "completed", "cancelled"];
|
|
5
|
+
type SleepStatus = (typeof SLEEP_STATUSES)[number];
|
|
5
6
|
interface SleepStateBase {
|
|
6
7
|
status: SleepStatus;
|
|
7
8
|
}
|
|
@@ -26,4 +27,4 @@ interface SleepResult {
|
|
|
26
27
|
cancelled: boolean;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
export type
|
|
30
|
+
export { SLEEP_STATUSES, type SleepName, type SleepQueue, type SleepResult, type SleepState, type SleepStateCancelled, type SleepStateCompleted, type SleepStateSleeping, type SleepStatus };
|
package/dist/sleep.js
CHANGED
package/dist/task.d.ts
CHANGED
|
@@ -11,16 +11,19 @@ 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
20
|
reference?: TaskReferenceOptions;
|
|
20
21
|
}
|
|
22
|
+
declare const TASK_CONFLICT_POLICIES: readonly ["error", "return_existing"];
|
|
23
|
+
type TaskConflictPolicy = (typeof TASK_CONFLICT_POLICIES)[number];
|
|
21
24
|
interface TaskReferenceOptions {
|
|
22
25
|
id: string;
|
|
23
|
-
conflictPolicy?:
|
|
26
|
+
conflictPolicy?: TaskConflictPolicy;
|
|
24
27
|
}
|
|
25
28
|
interface TaskStateBase {
|
|
26
29
|
status: TaskStatus;
|
|
@@ -93,4 +96,4 @@ declare class TaskFailedError extends Error {
|
|
|
93
96
|
constructor(taskId: TaskId, attempts: number, reason: string);
|
|
94
97
|
}
|
|
95
98
|
|
|
96
|
-
export { type TaskAddress, type TaskDefinitionOptions, TaskFailedError, type TaskId, type TaskInfo, type TaskName, type TaskReferenceOptions, 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 };
|
|
99
|
+
export { TASK_CONFLICT_POLICIES, TASK_STATUSES, type TaskAddress, type TaskConflictPolicy, type TaskDefinitionOptions, TaskFailedError, type TaskId, type TaskInfo, type TaskName, type TaskReferenceOptions, 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,6 @@
|
|
|
1
1
|
// task.ts
|
|
2
|
+
var TASK_STATUSES = ["running", "awaiting_retry", "completed", "failed"];
|
|
3
|
+
var TASK_CONFLICT_POLICIES = ["error", "return_existing"];
|
|
2
4
|
var TaskFailedError = class extends Error {
|
|
3
5
|
taskId;
|
|
4
6
|
attempts;
|
|
@@ -12,5 +14,7 @@ var TaskFailedError = class extends Error {
|
|
|
12
14
|
}
|
|
13
15
|
};
|
|
14
16
|
export {
|
|
17
|
+
TASK_CONFLICT_POLICIES,
|
|
18
|
+
TASK_STATUSES,
|
|
15
19
|
TaskFailedError
|
|
16
20
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EventSendOptions } from './event.js';
|
|
2
2
|
import { TransitionTaskStateToRunningCreate, TransitionTaskStateToRunningRetry, TransitionTaskStateToCompleted, TransitionTaskStateToFailed, TransitionTaskStateToAwaitingRetry, TaskStateCompleted, TaskStateFailed } from './task.js';
|
|
3
3
|
import { DistributiveOmit, OptionalProp } from './utils.js';
|
|
4
|
-
import { WorkflowRunStatus, WorkflowRun, WorkflowRunState, WorkflowStartOptions, WorkflowRunStateScheduled, WorkflowRunStateAwaitingEvent, WorkflowRunStateAwaitingRetry, WorkflowRunStateAwaitingChildWorkflow, WorkflowRunStateCompleted, WorkflowRunStatePaused, WorkflowRunStateCancelled, WorkflowRunTransition } from './workflow-run.js';
|
|
4
|
+
import { WorkflowRunStatus, WorkflowRun, WorkflowRunState, WorkflowStartOptions, WorkflowRunStateScheduled, WorkflowRunStateSleeping, WorkflowRunStateAwaitingEvent, WorkflowRunStateAwaitingRetry, WorkflowRunStateAwaitingChildWorkflow, WorkflowRunStateCompleted, WorkflowRunStatePaused, WorkflowRunStateCancelled, WorkflowRunTransition } from './workflow-run.js';
|
|
5
5
|
import './duration.js';
|
|
6
6
|
import './retry.js';
|
|
7
7
|
import './serializable.js';
|
|
@@ -25,7 +25,7 @@ interface WorkflowRunListRequestV1 {
|
|
|
25
25
|
limit?: number;
|
|
26
26
|
offset?: number;
|
|
27
27
|
filters?: {
|
|
28
|
-
|
|
28
|
+
id?: string;
|
|
29
29
|
status?: WorkflowRunStatus[];
|
|
30
30
|
workflows?: WorkflowFilter[];
|
|
31
31
|
};
|
|
@@ -84,6 +84,9 @@ interface WorkflowRunCreateResponseV1 {
|
|
|
84
84
|
type WorkflowRunStateScheduledRequest = DistributiveOmit<WorkflowRunStateScheduled, "scheduledAt"> & {
|
|
85
85
|
scheduledInMs: number;
|
|
86
86
|
};
|
|
87
|
+
type WorkflowRunStateSleepingRequest = DistributiveOmit<WorkflowRunStateSleeping, "awakeAt"> & {
|
|
88
|
+
durationMs: number;
|
|
89
|
+
};
|
|
87
90
|
type WorkflowRunStateAwaitingEventRequest = DistributiveOmit<WorkflowRunStateAwaitingEvent, "timeoutAt"> & {
|
|
88
91
|
timeoutInMs?: number;
|
|
89
92
|
};
|
|
@@ -95,8 +98,8 @@ type WorkflowRunStateAwaitingChildWorkflowRequest = DistributiveOmit<WorkflowRun
|
|
|
95
98
|
};
|
|
96
99
|
type WorkflowRunStateCompletedRequest = OptionalProp<WorkflowRunStateCompleted<unknown>, "output">;
|
|
97
100
|
type WorkflowRunStateRequest = Exclude<WorkflowRunState, {
|
|
98
|
-
status: "scheduled" | "awaiting_event" | "awaiting_retry" | "awaiting_child_workflow" | "completed";
|
|
99
|
-
}> | WorkflowRunStateScheduledRequest | WorkflowRunStateAwaitingEventRequest | WorkflowRunStateAwaitingRetryRequest | WorkflowRunStateAwaitingChildWorkflowRequest | WorkflowRunStateCompletedRequest;
|
|
101
|
+
status: "scheduled" | "sleeping" | "awaiting_event" | "awaiting_retry" | "awaiting_child_workflow" | "completed";
|
|
102
|
+
}> | WorkflowRunStateScheduledRequest | WorkflowRunStateSleepingRequest | WorkflowRunStateAwaitingEventRequest | WorkflowRunStateAwaitingRetryRequest | WorkflowRunStateAwaitingChildWorkflowRequest | WorkflowRunStateCompletedRequest;
|
|
100
103
|
interface WorkflowRunTransitionStateRequestBase {
|
|
101
104
|
type: "optimistic" | "pessimistic";
|
|
102
105
|
id: string;
|
|
@@ -178,4 +181,4 @@ interface WorkflowRunMulticastEventRequestV1 {
|
|
|
178
181
|
options?: EventSendOptions;
|
|
179
182
|
}
|
|
180
183
|
|
|
181
|
-
export type { TransitionTaskStateToRunning, WorkflowFilter, WorkflowRunApi, WorkflowRunCreateRequestV1, WorkflowRunCreateResponseV1, WorkflowRunGetByIdRequestV1, WorkflowRunGetByIdResponseV1, WorkflowRunGetByReferenceIdRequestV1, WorkflowRunGetByReferenceIdResponseV1, WorkflowRunGetStateRequestV1, WorkflowRunGetStateResponseV1, WorkflowRunListItem, WorkflowRunListRequestV1, WorkflowRunListResponseV1, WorkflowRunListTransitionsRequestV1, WorkflowRunListTransitionsResponseV1, WorkflowRunMulticastEventRequestV1, WorkflowRunSendEventRequestV1, WorkflowRunSendEventResponseV1, WorkflowRunSetTaskStateRequestExisting, WorkflowRunSetTaskStateRequestNew, WorkflowRunSetTaskStateRequestV1, WorkflowRunSetTaskStateResponseV1, WorkflowRunStateAwaitingChildWorkflowRequest, WorkflowRunStateAwaitingEventRequest, WorkflowRunStateAwaitingRetryRequest, WorkflowRunStateCompletedRequest, WorkflowRunStateRequest, WorkflowRunStateScheduledRequest, WorkflowRunStateScheduledRequestOptimistic, WorkflowRunStateScheduledRequestPessimistic, WorkflowRunTransitionStateRequestOptimistic, WorkflowRunTransitionStateRequestPessimistic, WorkflowRunTransitionStateRequestV1, WorkflowRunTransitionStateResponseV1, WorkflowRunTransitionTaskStateRequestV1, WorkflowRunTransitionTaskStateResponseV1 };
|
|
184
|
+
export type { TransitionTaskStateToRunning, WorkflowFilter, WorkflowRunApi, WorkflowRunCreateRequestV1, WorkflowRunCreateResponseV1, WorkflowRunGetByIdRequestV1, WorkflowRunGetByIdResponseV1, WorkflowRunGetByReferenceIdRequestV1, WorkflowRunGetByReferenceIdResponseV1, WorkflowRunGetStateRequestV1, WorkflowRunGetStateResponseV1, WorkflowRunListItem, WorkflowRunListRequestV1, WorkflowRunListResponseV1, WorkflowRunListTransitionsRequestV1, WorkflowRunListTransitionsResponseV1, WorkflowRunMulticastEventRequestV1, WorkflowRunSendEventRequestV1, WorkflowRunSendEventResponseV1, WorkflowRunSetTaskStateRequestExisting, WorkflowRunSetTaskStateRequestNew, WorkflowRunSetTaskStateRequestV1, WorkflowRunSetTaskStateResponseV1, WorkflowRunStateAwaitingChildWorkflowRequest, WorkflowRunStateAwaitingEventRequest, WorkflowRunStateAwaitingRetryRequest, WorkflowRunStateCompletedRequest, WorkflowRunStateRequest, WorkflowRunStateScheduledRequest, WorkflowRunStateScheduledRequestOptimistic, WorkflowRunStateScheduledRequestPessimistic, WorkflowRunStateSleepingRequest, WorkflowRunTransitionStateRequestOptimistic, WorkflowRunTransitionStateRequestPessimistic, WorkflowRunTransitionStateRequestV1, WorkflowRunTransitionStateResponseV1, WorkflowRunTransitionTaskStateRequestV1, WorkflowRunTransitionTaskStateResponseV1 };
|
package/dist/workflow-run.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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';
|
|
@@ -13,14 +13,17 @@ 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];
|
|
19
20
|
type NonTerminalWorkflowRunStatus = Exclude<WorkflowRunStatus, TerminalWorkflowRunStatus>;
|
|
20
21
|
declare function isTerminalWorkflowRunStatus(status: WorkflowRunStatus): status is TerminalWorkflowRunStatus;
|
|
22
|
+
declare const WORKFLOW_RUN_CONFLICT_POLICIES: readonly ["error", "return_existing"];
|
|
23
|
+
type WorkflowRunConflictPolicy = (typeof WORKFLOW_RUN_CONFLICT_POLICIES)[number];
|
|
21
24
|
interface WorkflowReferenceOptions {
|
|
22
25
|
id: string;
|
|
23
|
-
conflictPolicy?:
|
|
26
|
+
conflictPolicy?: WorkflowRunConflictPolicy;
|
|
24
27
|
}
|
|
25
28
|
interface WorkflowDefinitionOptions {
|
|
26
29
|
retry?: RetryStrategy;
|
|
@@ -33,7 +36,8 @@ interface WorkflowStartOptions extends WorkflowDefinitionOptions {
|
|
|
33
36
|
interface WorkflowRunStateBase {
|
|
34
37
|
status: WorkflowRunStatus;
|
|
35
38
|
}
|
|
36
|
-
|
|
39
|
+
declare const WORKFLOW_RUN_SCHEDULED_REASON: readonly ["new", "retry", "task_retry", "awake", "awake_early", "resume", "event", "child_workflow"];
|
|
40
|
+
type WorkflowRunScheduledReason = (typeof WORKFLOW_RUN_SCHEDULED_REASON)[number];
|
|
37
41
|
interface WorkflowRunStateScheduledBase extends WorkflowRunStateBase {
|
|
38
42
|
status: "scheduled";
|
|
39
43
|
scheduledAt: number;
|
|
@@ -77,17 +81,18 @@ interface WorkflowRunStatePaused extends WorkflowRunStateBase {
|
|
|
77
81
|
interface WorkflowRunStateSleeping extends WorkflowRunStateBase {
|
|
78
82
|
status: "sleeping";
|
|
79
83
|
sleepName: string;
|
|
80
|
-
|
|
84
|
+
awakeAt: number;
|
|
81
85
|
}
|
|
82
86
|
interface WorkflowRunStateAwaitingEvent extends WorkflowRunStateBase {
|
|
83
87
|
status: "awaiting_event";
|
|
84
88
|
eventName: string;
|
|
85
89
|
timeoutAt?: number;
|
|
86
90
|
}
|
|
87
|
-
|
|
91
|
+
declare const WORKFLOW_RUN_FAILURE_CAUSE: readonly ["task", "child_workflow", "self"];
|
|
92
|
+
type WorkflowRunFailureCause = (typeof WORKFLOW_RUN_FAILURE_CAUSE)[number];
|
|
88
93
|
interface WorkflowRunStateAwaitingRetryBase extends WorkflowRunStateBase {
|
|
89
94
|
status: "awaiting_retry";
|
|
90
|
-
cause:
|
|
95
|
+
cause: WorkflowRunFailureCause;
|
|
91
96
|
nextAttemptAt: number;
|
|
92
97
|
}
|
|
93
98
|
interface WorkflowRunStateAwaitingRetryCausedByTask extends WorkflowRunStateAwaitingRetryBase {
|
|
@@ -106,7 +111,7 @@ type WorkflowRunStateAwaitingRetry = WorkflowRunStateAwaitingRetryCausedByTask |
|
|
|
106
111
|
interface WorkflowRunStateAwaitingChildWorkflow extends WorkflowRunStateBase {
|
|
107
112
|
status: "awaiting_child_workflow";
|
|
108
113
|
childWorkflowRunId: string;
|
|
109
|
-
childWorkflowRunStatus:
|
|
114
|
+
childWorkflowRunStatus: TerminalWorkflowRunStatus;
|
|
110
115
|
timeoutAt?: number;
|
|
111
116
|
}
|
|
112
117
|
interface WorkflowRunStateCancelled extends WorkflowRunStateBase {
|
|
@@ -119,7 +124,7 @@ interface WorkflowRunStateCompleted<Output> extends WorkflowRunStateBase {
|
|
|
119
124
|
}
|
|
120
125
|
interface WorkflowRunStateFailedBase extends WorkflowRunStateBase {
|
|
121
126
|
status: "failed";
|
|
122
|
-
cause:
|
|
127
|
+
cause: WorkflowRunFailureCause;
|
|
123
128
|
}
|
|
124
129
|
interface WorkflowRunStateFailedByTask extends WorkflowRunStateFailedBase {
|
|
125
130
|
cause: "task";
|
|
@@ -150,7 +155,7 @@ interface WorkflowRun<Input = unknown, Output = unknown> {
|
|
|
150
155
|
state: WorkflowRunState<Output>;
|
|
151
156
|
tasks: Record<string, TaskInfo>;
|
|
152
157
|
sleepsQueue: Record<string, SleepQueue>;
|
|
153
|
-
|
|
158
|
+
eventWaitQueues: Record<string, EventWaitQueue<unknown>>;
|
|
154
159
|
childWorkflowRuns: Record<string, ChildWorkflowRunInfo>;
|
|
155
160
|
parentWorkflowRunId?: string;
|
|
156
161
|
}
|
|
@@ -206,4 +211,4 @@ declare class WorkflowRunRevisionConflictError extends Error {
|
|
|
206
211
|
constructor(id: WorkflowRunId);
|
|
207
212
|
}
|
|
208
213
|
|
|
209
|
-
export { type ChildWorkflowRunInfo, type ChildWorkflowWaitResult, type ChildWorkflowWaitResultCompleted, type ChildWorkflowWaitResultTimeout, type NonTerminalWorkflowRunStatus, type TerminalWorkflowRunStatus,
|
|
214
|
+
export { type ChildWorkflowRunInfo, type ChildWorkflowWaitResult, type ChildWorkflowWaitResultCompleted, type ChildWorkflowWaitResultTimeout, type NonTerminalWorkflowRunStatus, 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 WorkflowRunStateTransition, type WorkflowRunStatus, WorkflowRunSuspendedError, type WorkflowRunTaskStateTransition, type WorkflowRunTransition, type WorkflowRunTransitionBase, type WorkflowStartOptions, isTerminalWorkflowRunStatus };
|
package/dist/workflow-run.js
CHANGED
|
@@ -1,13 +1,38 @@
|
|
|
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"];
|
|
3
16
|
function isTerminalWorkflowRunStatus(status) {
|
|
4
|
-
for (const terminalStatus of
|
|
17
|
+
for (const terminalStatus of TERMINAL_WORKFLOW_RUN_STATUSES) {
|
|
5
18
|
if (status === terminalStatus) {
|
|
6
19
|
return true;
|
|
7
20
|
}
|
|
8
21
|
}
|
|
9
22
|
return false;
|
|
10
23
|
}
|
|
24
|
+
var WORKFLOW_RUN_CONFLICT_POLICIES = ["error", "return_existing"];
|
|
25
|
+
var WORKFLOW_RUN_SCHEDULED_REASON = [
|
|
26
|
+
"new",
|
|
27
|
+
"retry",
|
|
28
|
+
"task_retry",
|
|
29
|
+
"awake",
|
|
30
|
+
"awake_early",
|
|
31
|
+
"resume",
|
|
32
|
+
"event",
|
|
33
|
+
"child_workflow"
|
|
34
|
+
];
|
|
35
|
+
var WORKFLOW_RUN_FAILURE_CAUSE = ["task", "child_workflow", "self"];
|
|
11
36
|
var WorkflowRunNotExecutableError = class extends Error {
|
|
12
37
|
id;
|
|
13
38
|
status;
|
|
@@ -48,6 +73,10 @@ var WorkflowRunRevisionConflictError = class extends Error {
|
|
|
48
73
|
}
|
|
49
74
|
};
|
|
50
75
|
export {
|
|
76
|
+
WORKFLOW_RUN_CONFLICT_POLICIES,
|
|
77
|
+
WORKFLOW_RUN_FAILURE_CAUSE,
|
|
78
|
+
WORKFLOW_RUN_SCHEDULED_REASON,
|
|
79
|
+
WORKFLOW_RUN_STATUSES,
|
|
51
80
|
WorkflowRunFailedError,
|
|
52
81
|
WorkflowRunNotExecutableError,
|
|
53
82
|
WorkflowRunRevisionConflictError,
|
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aikirun/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.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,10 @@
|
|
|
16
20
|
"types": "./dist/event.d.ts",
|
|
17
21
|
"import": "./dist/event.js"
|
|
18
22
|
},
|
|
23
|
+
"./namespace-api": {
|
|
24
|
+
"types": "./dist/namespace-api.d.ts",
|
|
25
|
+
"import": "./dist/namespace-api.js"
|
|
26
|
+
},
|
|
19
27
|
"./retry": {
|
|
20
28
|
"types": "./dist/retry.d.ts",
|
|
21
29
|
"import": "./dist/retry.js"
|