@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 CHANGED
@@ -24,6 +24,8 @@ npm install @aikirun/types
24
24
  - `/error` - Serializable error types
25
25
  - `/sleep` - Sleep definition types
26
26
  - `/event` - Event definition types
27
+ - `/schedule` - Schedule definition types
28
+ - `/schedule-api` - API contract types
27
29
 
28
30
  ## Usage
29
31
 
@@ -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 };
@@ -0,0 +1,5 @@
1
+ // api-key-api.ts
2
+ var API_KEY_STATUSES = ["active", "revoked", "expired"];
3
+ export {
4
+ API_KEY_STATUSES
5
+ };
package/dist/client.d.ts CHANGED
@@ -15,6 +15,7 @@ import './trigger.js';
15
15
 
16
16
  interface ClientParams<AppContext = unknown> {
17
17
  url: string;
18
+ apiKey?: string;
18
19
  redis: RedisConfig;
19
20
  logger?: Logger;
20
21
  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
- type EventStatus = "received" | "timeout";
8
- interface EventStateBase {
9
- status: EventStatus;
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 EventStateReceived<Data> extends EventStateBase {
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 EventStateTimeout extends EventStateBase {
18
+ interface EventWaitStateTimeout extends EventWaitStateBase {
18
19
  status: "timeout";
19
20
  timedOutAt: number;
20
21
  }
21
- type EventState<Data> = EventStateReceived<Data> | EventStateTimeout;
22
- interface EventQueue<Data> {
23
- events: EventState<Data>[];
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 EventWaitState<Data, Timed extends boolean> = Timed extends false ? {
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 type { EventName, EventQueue, EventReferenceOptions, EventSendOptions, EventState, EventStateReceived, EventStateTimeout, EventStatus, EventWaitOptions, EventWaitState };
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,5 @@
1
+ // event.ts
2
+ var EVENT_WAIT_STATUSES = ["received", "timeout"];
3
+ export {
4
+ EVENT_WAIT_STATUSES
5
+ };
@@ -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
@@ -1,34 +1,42 @@
1
1
  type ScheduleId = string & {
2
2
  _brand: "schedule_id";
3
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;
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
- type ScheduleStatus = "active" | "paused" | "deleted";
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 { CronScheduleSpec, IntervalScheduleSpec, OverlapPolicy, Schedule, ScheduleActivateOptions, ScheduleId, ScheduleReferenceOptions, ScheduleSpec, ScheduleStatus };
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
- type SleepStatus = "sleeping" | "completed" | "cancelled";
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 { SleepName, SleepQueue, SleepResult, SleepState, SleepStateCancelled, SleepStateCompleted, SleepStateSleeping, SleepStatus };
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
@@ -0,0 +1,5 @@
1
+ // sleep.ts
2
+ var SLEEP_STATUSES = ["sleeping", "completed", "cancelled"];
3
+ export {
4
+ SLEEP_STATUSES
5
+ };
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
- type TaskStatus = "running" | "awaiting_retry" | "completed" | "failed";
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?: "error" | "return_existing";
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
- runId?: string;
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 };
@@ -1,4 +1,4 @@
1
- import { EventQueue } from './event.js';
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
- type WorkflowRunStatus = "scheduled" | "queued" | "running" | "paused" | "sleeping" | "awaiting_event" | "awaiting_retry" | "awaiting_child_workflow" | "cancelled" | "completed" | "failed";
17
- declare const terminalWorkflowRunStatuses: readonly ["cancelled", "completed", "failed"];
18
- type TerminalWorkflowRunStatus = (typeof terminalWorkflowRunStatuses)[number];
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?: "error" | "return_existing";
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
- type WorkflowRunScheduledReason = "new" | "retry" | "task_retry" | "awake" | "awake_early" | "resume" | "event" | "child_workflow";
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
- durationMs: number;
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
- type WorkflowFailureCause = "task" | "child_workflow" | "self";
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: WorkflowFailureCause;
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: WorkflowRunStatus;
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: WorkflowFailureCause;
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
- eventsQueue: Record<string, EventQueue<unknown>>;
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, 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 };
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 };
@@ -1,13 +1,38 @@
1
1
  // workflow-run.ts
2
- var terminalWorkflowRunStatuses = ["cancelled", "completed", "failed"];
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 terminalWorkflowRunStatuses) {
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.16.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"