@aikirun/types 0.13.0 → 0.15.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 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,63 @@
1
+ import { ScheduleSpec, Schedule, ScheduleStatus } from './schedule.js';
2
+
3
+ interface ScheduleApi {
4
+ activateV1: (_: ScheduleActivateRequestV1) => Promise<ScheduleActivateResponseV1>;
5
+ getByIdV1: (_: ScheduleGetByIdRequestV1) => Promise<ScheduleGetByIdResponseV1>;
6
+ getByNameV1: (_: ScheduleGetByNameRequestV1) => Promise<ScheduleGetByNameResponseV1>;
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
+ name: string;
14
+ workflowName: string;
15
+ workflowVersionId: string;
16
+ input?: unknown;
17
+ spec: ScheduleSpec;
18
+ }
19
+ interface ScheduleActivateResponseV1 {
20
+ schedule: Schedule;
21
+ }
22
+ interface ScheduleGetByIdRequestV1 {
23
+ id: string;
24
+ }
25
+ interface ScheduleGetByIdResponseV1 {
26
+ schedule: Schedule;
27
+ }
28
+ interface ScheduleGetByNameRequestV1 {
29
+ name: string;
30
+ workflowName: string;
31
+ workflowVersionId: string;
32
+ }
33
+ interface ScheduleGetByNameResponseV1 {
34
+ schedule: Schedule;
35
+ }
36
+ interface ScheduleListRequestV1 {
37
+ limit?: number;
38
+ offset?: number;
39
+ filters?: {
40
+ status?: ScheduleStatus[];
41
+ };
42
+ }
43
+ interface ScheduleListResponseV1 {
44
+ schedules: Schedule[];
45
+ total: number;
46
+ }
47
+ interface SchedulePauseRequestV1 {
48
+ id: string;
49
+ }
50
+ interface SchedulePauseResponseV1 {
51
+ schedule: Schedule;
52
+ }
53
+ interface ScheduleResumeRequestV1 {
54
+ id: string;
55
+ }
56
+ interface ScheduleResumeResponseV1 {
57
+ schedule: Schedule;
58
+ }
59
+ interface ScheduleDeleteRequestV1 {
60
+ id: string;
61
+ }
62
+
63
+ export type { ScheduleActivateRequestV1, ScheduleActivateResponseV1, ScheduleApi, ScheduleDeleteRequestV1, ScheduleGetByIdRequestV1, ScheduleGetByIdResponseV1, ScheduleGetByNameRequestV1, ScheduleGetByNameResponseV1, ScheduleListRequestV1, ScheduleListResponseV1, SchedulePauseRequestV1, SchedulePauseResponseV1, ScheduleResumeRequestV1, ScheduleResumeResponseV1 };
File without changes
@@ -0,0 +1,36 @@
1
+ type ScheduleId = string & {
2
+ _brand: "schedule_id";
3
+ };
4
+ type ScheduleName = string & {
5
+ _brand: "schedule_name";
6
+ };
7
+ type OverlapPolicy = "allow" | "skip" | "cancel_previous";
8
+ interface CronScheduleSpec {
9
+ type: "cron";
10
+ expression: string;
11
+ timezone?: string;
12
+ overlapPolicy?: OverlapPolicy;
13
+ }
14
+ interface IntervalScheduleSpec {
15
+ type: "interval";
16
+ everyMs: number;
17
+ overlapPolicy?: OverlapPolicy;
18
+ }
19
+ type ScheduleSpec = CronScheduleSpec | IntervalScheduleSpec;
20
+ type ScheduleStatus = "active" | "paused" | "deleted";
21
+ interface Schedule {
22
+ id: string;
23
+ name: string;
24
+ workflowName: string;
25
+ workflowVersionId: string;
26
+ input?: unknown;
27
+ spec: ScheduleSpec;
28
+ status: ScheduleStatus;
29
+ createdAt: number;
30
+ updatedAt: number;
31
+ lastOccurrence?: number;
32
+ nextRunAt: number;
33
+ runCount: number;
34
+ }
35
+
36
+ export type { CronScheduleSpec, IntervalScheduleSpec, OverlapPolicy, Schedule, ScheduleId, ScheduleName, ScheduleSpec, ScheduleStatus };
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 TaskPath = string & {
12
- _brand: "task_path";
11
+ type TaskAddress = string & {
12
+ _brand: "task_address";
13
13
  };
14
14
  type TaskStatus = "running" | "awaiting_retry" | "completed" | "failed";
15
- interface TaskOptions {
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
- onConflict?: "error" | "return_existing";
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?: TaskOptions;
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?: TaskOptions;
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 TaskOptions, type TaskPath, type TaskReferenceOptions, 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 };
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, WorkflowOptions, WorkflowRunStateScheduled, WorkflowRunStateAwaitingEvent, WorkflowRunStateAwaitingRetry, WorkflowRunStateAwaitingChildWorkflow, WorkflowRunStateCompleted, WorkflowRunStatePaused, WorkflowRunStateCancelled, WorkflowRunTransition } from './workflow-run.js';
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';
@@ -25,23 +25,27 @@ interface WorkflowRunListRequestV1 {
25
25
  limit?: number;
26
26
  offset?: number;
27
27
  filters?: {
28
- workflows?: {
29
- id?: string;
30
- versionId?: string;
31
- }[];
28
+ runId?: string;
32
29
  status?: WorkflowRunStatus[];
30
+ workflows?: WorkflowFilter[];
33
31
  };
34
32
  sort?: {
35
33
  field: "createdAt";
36
34
  order: "asc" | "desc";
37
35
  };
38
36
  }
37
+ interface WorkflowFilter {
38
+ name: string;
39
+ versionId?: string;
40
+ referenceId?: string;
41
+ }
39
42
  interface WorkflowRunListItem {
40
43
  id: string;
41
44
  name: string;
42
45
  versionId: string;
43
46
  createdAt: number;
44
47
  status: WorkflowRunStatus;
48
+ referenceId?: string;
45
49
  }
46
50
  interface WorkflowRunListResponseV1 {
47
51
  runs: WorkflowRunListItem[];
@@ -72,7 +76,7 @@ interface WorkflowRunCreateRequestV1 {
72
76
  versionId: string;
73
77
  input?: unknown;
74
78
  parentWorkflowRunId?: string;
75
- options?: WorkflowOptions;
79
+ options?: WorkflowStartOptions;
76
80
  }
77
81
  interface WorkflowRunCreateResponseV1 {
78
82
  run: WorkflowRun;
@@ -174,4 +178,4 @@ interface WorkflowRunMulticastEventRequestV1 {
174
178
  options?: EventSendOptions;
175
179
  }
176
180
 
177
- export type { TransitionTaskStateToRunning, 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 };
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 };
@@ -10,8 +10,8 @@ import './utils.js';
10
10
  type WorkflowRunId = string & {
11
11
  _brand: "workflow_run_id";
12
12
  };
13
- type WorkflowRunPath = string & {
14
- _brand: "workflow_run_path";
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
- onConflict?: "error" | "return_existing";
23
+ conflictPolicy?: "error" | "return_existing";
24
24
  }
25
- interface WorkflowOptions {
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,8 @@ interface WorkflowRun<Input = unknown, Output = unknown> {
141
143
  createdAt: number;
142
144
  revision: number;
143
145
  input?: Input;
144
- path: string;
145
- options: WorkflowOptions;
146
+ address: string;
147
+ options: WorkflowStartOptions;
146
148
  attempts: number;
147
149
  state: WorkflowRunState<Output>;
148
150
  tasks: Record<string, TaskInfo>;
@@ -203,4 +205,4 @@ declare class WorkflowRunConflictError extends Error {
203
205
  constructor(id: WorkflowRunId);
204
206
  }
205
207
 
206
- export { type ChildWorkflowRunInfo, type ChildWorkflowWaitResult, type ChildWorkflowWaitResultCompleted, type ChildWorkflowWaitResultTimeout, type NonTerminalWorkflowRunStatus, type TerminalWorkflowRunStatus, type WorkflowFailureCause, type WorkflowOptions, type WorkflowReferenceOptions, type WorkflowRun, WorkflowRunConflictError, WorkflowRunFailedError, type WorkflowRunId, WorkflowRunNotExecutableError, type WorkflowRunPath, type WorkflowRunScheduledReason, type WorkflowRunState, type WorkflowRunStateAwaitingChildWorkflow, type WorkflowRunStateAwaitingEvent, type WorkflowRunStateAwaitingRetry, type WorkflowRunStateAwaitingRetryBase, type WorkflowRunStateAwaitingRetryCausedByChildWorkflow, type WorkflowRunStateAwaitingRetryCausedBySelf, type WorkflowRunStateAwaitingRetryCausedByTask, type WorkflowRunStateCancelled, type WorkflowRunStateCompleted, type WorkflowRunStateFailed, type WorkflowRunStateFailedByChildWorkflow, type WorkflowRunStateFailedBySelf, type WorkflowRunStateFailedByTask, type WorkflowRunStateInComplete, type WorkflowRunStatePaused, type WorkflowRunStateQueued, type WorkflowRunStateRunning, type WorkflowRunStateScheduled, type 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, isTerminalWorkflowRunStatus };
208
+ export { type ChildWorkflowRunInfo, type ChildWorkflowWaitResult, type ChildWorkflowWaitResultCompleted, type ChildWorkflowWaitResultTimeout, type NonTerminalWorkflowRunStatus, type TerminalWorkflowRunStatus, type WorkflowDefinitionOptions, type WorkflowFailureCause, type WorkflowReferenceOptions, type WorkflowRun, type WorkflowRunAddress, WorkflowRunConflictError, WorkflowRunFailedError, type WorkflowRunId, WorkflowRunNotExecutableError, type WorkflowRunScheduledReason, type WorkflowRunState, type WorkflowRunStateAwaitingChildWorkflow, type WorkflowRunStateAwaitingEvent, type WorkflowRunStateAwaitingRetry, type WorkflowRunStateAwaitingRetryBase, type WorkflowRunStateAwaitingRetryCausedByChildWorkflow, type WorkflowRunStateAwaitingRetryCausedBySelf, type WorkflowRunStateAwaitingRetryCausedByTask, type WorkflowRunStateCancelled, type WorkflowRunStateCompleted, type WorkflowRunStateFailed, type WorkflowRunStateFailedByChildWorkflow, type WorkflowRunStateFailedBySelf, type WorkflowRunStateFailedByTask, type WorkflowRunStateInComplete, type WorkflowRunStatePaused, type WorkflowRunStateQueued, type WorkflowRunStateRunning, type WorkflowRunStateScheduled, type 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aikirun/types",
3
- "version": "0.13.0",
3
+ "version": "0.15.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"