@aikirun/types 0.14.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +3 -0
- package/dist/schedule-api.d.ts +68 -0
- package/dist/schedule-api.js +0 -0
- package/dist/schedule.d.ts +40 -0
- package/dist/schedule.js +0 -0
- package/dist/task.d.ts +9 -7
- package/dist/workflow-run-api.d.ts +2 -2
- package/dist/workflow-run.d.ts +12 -9
- package/dist/workflow-run.js +3 -3
- package/package.json +9 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { ScheduleApi } from './schedule-api.js';
|
|
1
2
|
import { WorkflowMeta } from './workflow.js';
|
|
2
3
|
import { WorkflowRun, WorkflowRunId } from './workflow-run.js';
|
|
3
4
|
import { WorkflowRunApi } from './workflow-run-api.js';
|
|
4
5
|
import { INTERNAL } from './symbols.js';
|
|
6
|
+
import './schedule.js';
|
|
5
7
|
import './event.js';
|
|
6
8
|
import './duration.js';
|
|
7
9
|
import './utils.js';
|
|
@@ -39,6 +41,7 @@ interface Logger {
|
|
|
39
41
|
}
|
|
40
42
|
interface ApiClient {
|
|
41
43
|
workflowRun: WorkflowRunApi;
|
|
44
|
+
schedule: ScheduleApi;
|
|
42
45
|
}
|
|
43
46
|
interface RedisClient {
|
|
44
47
|
xclaim(...args: unknown[]): Promise<unknown>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ScheduleSpec, ScheduleActivateOptions, Schedule, ScheduleStatus } from './schedule.js';
|
|
2
|
+
|
|
3
|
+
interface ScheduleApi {
|
|
4
|
+
activateV1: (_: ScheduleActivateRequestV1) => Promise<ScheduleActivateResponseV1>;
|
|
5
|
+
getByIdV1: (_: ScheduleGetByIdRequestV1) => Promise<ScheduleGetByIdResponseV1>;
|
|
6
|
+
getByReferenceIdV1: (_: ScheduleGetByReferenceIdRequestV1) => Promise<ScheduleGetByReferenceIdResponseV1>;
|
|
7
|
+
listV1: (_: ScheduleListRequestV1) => Promise<ScheduleListResponseV1>;
|
|
8
|
+
pauseV1: (_: SchedulePauseRequestV1) => Promise<SchedulePauseResponseV1>;
|
|
9
|
+
resumeV1: (_: ScheduleResumeRequestV1) => Promise<ScheduleResumeResponseV1>;
|
|
10
|
+
deleteV1: (_: ScheduleDeleteRequestV1) => Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
interface ScheduleActivateRequestV1 {
|
|
13
|
+
workflowName: string;
|
|
14
|
+
workflowVersionId: string;
|
|
15
|
+
input?: unknown;
|
|
16
|
+
spec: ScheduleSpec;
|
|
17
|
+
options?: ScheduleActivateOptions;
|
|
18
|
+
}
|
|
19
|
+
interface ScheduleActivateResponseV1 {
|
|
20
|
+
schedule: Schedule;
|
|
21
|
+
}
|
|
22
|
+
interface ScheduleGetByIdRequestV1 {
|
|
23
|
+
id: string;
|
|
24
|
+
}
|
|
25
|
+
interface ScheduleGetByIdResponseV1 {
|
|
26
|
+
schedule: Schedule;
|
|
27
|
+
}
|
|
28
|
+
interface ScheduleGetByReferenceIdRequestV1 {
|
|
29
|
+
referenceId: string;
|
|
30
|
+
}
|
|
31
|
+
interface ScheduleGetByReferenceIdResponseV1 {
|
|
32
|
+
schedule: Schedule;
|
|
33
|
+
}
|
|
34
|
+
interface ScheduleWorkflowFilter {
|
|
35
|
+
name?: string;
|
|
36
|
+
versionId?: string;
|
|
37
|
+
}
|
|
38
|
+
interface ScheduleListRequestV1 {
|
|
39
|
+
limit?: number;
|
|
40
|
+
offset?: number;
|
|
41
|
+
filters?: {
|
|
42
|
+
status?: ScheduleStatus[];
|
|
43
|
+
id?: string;
|
|
44
|
+
referenceId?: string;
|
|
45
|
+
workflows?: ScheduleWorkflowFilter[];
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
interface ScheduleListResponseV1 {
|
|
49
|
+
schedules: Schedule[];
|
|
50
|
+
total: number;
|
|
51
|
+
}
|
|
52
|
+
interface SchedulePauseRequestV1 {
|
|
53
|
+
id: string;
|
|
54
|
+
}
|
|
55
|
+
interface SchedulePauseResponseV1 {
|
|
56
|
+
schedule: Schedule;
|
|
57
|
+
}
|
|
58
|
+
interface ScheduleResumeRequestV1 {
|
|
59
|
+
id: string;
|
|
60
|
+
}
|
|
61
|
+
interface ScheduleResumeResponseV1 {
|
|
62
|
+
schedule: Schedule;
|
|
63
|
+
}
|
|
64
|
+
interface ScheduleDeleteRequestV1 {
|
|
65
|
+
id: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type { ScheduleActivateRequestV1, ScheduleActivateResponseV1, ScheduleApi, ScheduleDeleteRequestV1, ScheduleGetByIdRequestV1, ScheduleGetByIdResponseV1, ScheduleGetByReferenceIdRequestV1, ScheduleGetByReferenceIdResponseV1, ScheduleListRequestV1, ScheduleListResponseV1, SchedulePauseRequestV1, SchedulePauseResponseV1, ScheduleResumeRequestV1, ScheduleResumeResponseV1, ScheduleWorkflowFilter };
|
|
File without changes
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
type ScheduleId = string & {
|
|
2
|
+
_brand: "schedule_id";
|
|
3
|
+
};
|
|
4
|
+
type OverlapPolicy = "allow" | "skip" | "cancel_previous";
|
|
5
|
+
interface ScheduleReferenceOptions {
|
|
6
|
+
id: string;
|
|
7
|
+
conflictPolicy?: "upsert" | "error";
|
|
8
|
+
}
|
|
9
|
+
interface ScheduleActivateOptions {
|
|
10
|
+
reference?: ScheduleReferenceOptions;
|
|
11
|
+
}
|
|
12
|
+
interface CronScheduleSpec {
|
|
13
|
+
type: "cron";
|
|
14
|
+
expression: string;
|
|
15
|
+
timezone?: string;
|
|
16
|
+
overlapPolicy?: OverlapPolicy;
|
|
17
|
+
}
|
|
18
|
+
interface IntervalScheduleSpec {
|
|
19
|
+
type: "interval";
|
|
20
|
+
everyMs: number;
|
|
21
|
+
overlapPolicy?: OverlapPolicy;
|
|
22
|
+
}
|
|
23
|
+
type ScheduleSpec = CronScheduleSpec | IntervalScheduleSpec;
|
|
24
|
+
type ScheduleStatus = "active" | "paused" | "deleted";
|
|
25
|
+
interface Schedule {
|
|
26
|
+
id: string;
|
|
27
|
+
workflowName: string;
|
|
28
|
+
workflowVersionId: string;
|
|
29
|
+
input?: unknown;
|
|
30
|
+
spec: ScheduleSpec;
|
|
31
|
+
status: ScheduleStatus;
|
|
32
|
+
options?: ScheduleActivateOptions;
|
|
33
|
+
createdAt: number;
|
|
34
|
+
updatedAt: number;
|
|
35
|
+
lastOccurrence?: number;
|
|
36
|
+
nextRunAt: number;
|
|
37
|
+
runCount: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type { CronScheduleSpec, IntervalScheduleSpec, OverlapPolicy, Schedule, ScheduleActivateOptions, ScheduleId, ScheduleReferenceOptions, ScheduleSpec, ScheduleStatus };
|
package/dist/schedule.js
ADDED
|
File without changes
|
package/dist/task.d.ts
CHANGED
|
@@ -8,17 +8,19 @@ type TaskId = string & {
|
|
|
8
8
|
type TaskName = string & {
|
|
9
9
|
_brand: "task_name";
|
|
10
10
|
};
|
|
11
|
-
type
|
|
12
|
-
_brand: "
|
|
11
|
+
type TaskAddress = string & {
|
|
12
|
+
_brand: "task_address";
|
|
13
13
|
};
|
|
14
14
|
type TaskStatus = "running" | "awaiting_retry" | "completed" | "failed";
|
|
15
|
-
interface
|
|
15
|
+
interface TaskDefinitionOptions {
|
|
16
16
|
retry?: RetryStrategy;
|
|
17
|
+
}
|
|
18
|
+
interface TaskStartOptions extends TaskDefinitionOptions {
|
|
17
19
|
reference?: TaskReferenceOptions;
|
|
18
20
|
}
|
|
19
21
|
interface TaskReferenceOptions {
|
|
20
22
|
id: string;
|
|
21
|
-
|
|
23
|
+
conflictPolicy?: "error" | "return_existing";
|
|
22
24
|
}
|
|
23
25
|
interface TaskStateBase {
|
|
24
26
|
status: TaskStatus;
|
|
@@ -58,13 +60,13 @@ interface TransitionTaskStateBase {
|
|
|
58
60
|
interface TransitionTaskStateToRunningCreate extends TransitionTaskStateBase {
|
|
59
61
|
type: "create";
|
|
60
62
|
taskName: string;
|
|
61
|
-
options?:
|
|
63
|
+
options?: TaskStartOptions;
|
|
62
64
|
taskState: TaskStateRunningRequest;
|
|
63
65
|
}
|
|
64
66
|
interface TransitionTaskStateToRunningRetry extends TransitionTaskStateBase {
|
|
65
67
|
type: "retry";
|
|
66
68
|
taskId: string;
|
|
67
|
-
options?:
|
|
69
|
+
options?: TaskStartOptions;
|
|
68
70
|
taskState: TaskStateRunningRequest;
|
|
69
71
|
}
|
|
70
72
|
type TaskStateRunningRequest = OptionalProp<TaskStateRunning<unknown>, "input">;
|
|
@@ -91,4 +93,4 @@ declare class TaskFailedError extends Error {
|
|
|
91
93
|
constructor(taskId: TaskId, attempts: number, reason: string);
|
|
92
94
|
}
|
|
93
95
|
|
|
94
|
-
export { TaskFailedError, type TaskId, type TaskInfo, type TaskName, type
|
|
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 };
|
|
@@ -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,
|
|
4
|
+
import { WorkflowRunStatus, WorkflowRun, WorkflowRunState, WorkflowStartOptions, WorkflowRunStateScheduled, 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';
|
|
@@ -76,7 +76,7 @@ interface WorkflowRunCreateRequestV1 {
|
|
|
76
76
|
versionId: string;
|
|
77
77
|
input?: unknown;
|
|
78
78
|
parentWorkflowRunId?: string;
|
|
79
|
-
options?:
|
|
79
|
+
options?: WorkflowStartOptions;
|
|
80
80
|
}
|
|
81
81
|
interface WorkflowRunCreateResponseV1 {
|
|
82
82
|
run: WorkflowRun;
|
package/dist/workflow-run.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ import './utils.js';
|
|
|
10
10
|
type WorkflowRunId = string & {
|
|
11
11
|
_brand: "workflow_run_id";
|
|
12
12
|
};
|
|
13
|
-
type
|
|
14
|
-
_brand: "
|
|
13
|
+
type WorkflowRunAddress = string & {
|
|
14
|
+
_brand: "workflow_run_address";
|
|
15
15
|
};
|
|
16
16
|
type WorkflowRunStatus = "scheduled" | "queued" | "running" | "paused" | "sleeping" | "awaiting_event" | "awaiting_retry" | "awaiting_child_workflow" | "cancelled" | "completed" | "failed";
|
|
17
17
|
declare const terminalWorkflowRunStatuses: readonly ["cancelled", "completed", "failed"];
|
|
@@ -20,12 +20,14 @@ type NonTerminalWorkflowRunStatus = Exclude<WorkflowRunStatus, TerminalWorkflowR
|
|
|
20
20
|
declare function isTerminalWorkflowRunStatus(status: WorkflowRunStatus): status is TerminalWorkflowRunStatus;
|
|
21
21
|
interface WorkflowReferenceOptions {
|
|
22
22
|
id: string;
|
|
23
|
-
|
|
23
|
+
conflictPolicy?: "error" | "return_existing";
|
|
24
24
|
}
|
|
25
|
-
interface
|
|
25
|
+
interface WorkflowDefinitionOptions {
|
|
26
26
|
retry?: RetryStrategy;
|
|
27
|
-
reference?: WorkflowReferenceOptions;
|
|
28
27
|
trigger?: TriggerStrategy;
|
|
28
|
+
}
|
|
29
|
+
interface WorkflowStartOptions extends WorkflowDefinitionOptions {
|
|
30
|
+
reference?: WorkflowReferenceOptions;
|
|
29
31
|
shard?: string;
|
|
30
32
|
}
|
|
31
33
|
interface WorkflowRunStateBase {
|
|
@@ -141,8 +143,9 @@ interface WorkflowRun<Input = unknown, Output = unknown> {
|
|
|
141
143
|
createdAt: number;
|
|
142
144
|
revision: number;
|
|
143
145
|
input?: Input;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
+
inputHash: string;
|
|
147
|
+
address: string;
|
|
148
|
+
options: WorkflowStartOptions;
|
|
146
149
|
attempts: number;
|
|
147
150
|
state: WorkflowRunState<Output>;
|
|
148
151
|
tasks: Record<string, TaskInfo>;
|
|
@@ -198,9 +201,9 @@ declare class WorkflowRunFailedError extends Error {
|
|
|
198
201
|
readonly reason?: string;
|
|
199
202
|
constructor(id: WorkflowRunId, attempts: number, reason?: string);
|
|
200
203
|
}
|
|
201
|
-
declare class
|
|
204
|
+
declare class WorkflowRunRevisionConflictError extends Error {
|
|
202
205
|
readonly id: WorkflowRunId;
|
|
203
206
|
constructor(id: WorkflowRunId);
|
|
204
207
|
}
|
|
205
208
|
|
|
206
|
-
export { type ChildWorkflowRunInfo, type ChildWorkflowWaitResult, type ChildWorkflowWaitResultCompleted, type ChildWorkflowWaitResultTimeout, type NonTerminalWorkflowRunStatus, type TerminalWorkflowRunStatus, type
|
|
209
|
+
export { type ChildWorkflowRunInfo, type ChildWorkflowWaitResult, type ChildWorkflowWaitResultCompleted, type ChildWorkflowWaitResultTimeout, type NonTerminalWorkflowRunStatus, type TerminalWorkflowRunStatus, type WorkflowDefinitionOptions, type WorkflowFailureCause, type WorkflowReferenceOptions, type WorkflowRun, type WorkflowRunAddress, WorkflowRunFailedError, 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
|
@@ -39,18 +39,18 @@ var WorkflowRunFailedError = class extends Error {
|
|
|
39
39
|
this.reason = reason;
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
-
var
|
|
42
|
+
var WorkflowRunRevisionConflictError = class extends Error {
|
|
43
43
|
id;
|
|
44
44
|
constructor(id) {
|
|
45
45
|
super(`Conflict while trying to update Workflow run ${id}`);
|
|
46
|
-
this.name = "
|
|
46
|
+
this.name = "WorkflowRunRevisionConflictError";
|
|
47
47
|
this.id = id;
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
export {
|
|
51
|
-
WorkflowRunConflictError,
|
|
52
51
|
WorkflowRunFailedError,
|
|
53
52
|
WorkflowRunNotExecutableError,
|
|
53
|
+
WorkflowRunRevisionConflictError,
|
|
54
54
|
WorkflowRunSuspendedError,
|
|
55
55
|
isTerminalWorkflowRunStatus
|
|
56
56
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aikirun/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Core type definitions for Aiki - including workflow, task, client, and trigger types",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -20,6 +20,14 @@
|
|
|
20
20
|
"types": "./dist/retry.d.ts",
|
|
21
21
|
"import": "./dist/retry.js"
|
|
22
22
|
},
|
|
23
|
+
"./schedule": {
|
|
24
|
+
"types": "./dist/schedule.d.ts",
|
|
25
|
+
"import": "./dist/schedule.js"
|
|
26
|
+
},
|
|
27
|
+
"./schedule-api": {
|
|
28
|
+
"types": "./dist/schedule-api.d.ts",
|
|
29
|
+
"import": "./dist/schedule-api.js"
|
|
30
|
+
},
|
|
23
31
|
"./serializable": {
|
|
24
32
|
"types": "./dist/serializable.d.ts",
|
|
25
33
|
"import": "./dist/serializable.js"
|