@shipfox/api-workflows-dto 12.6.0 → 13.0.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +15 -0
- package/dist/events.d.ts +72 -5
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +23 -4
- package/dist/events.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/schemas/workflow-run-detail.d.ts +1 -0
- package/dist/schemas/workflow-run-detail.d.ts.map +1 -1
- package/dist/schemas/workflow-run-detail.js +8 -1
- package/dist/schemas/workflow-run-detail.js.map +1 -1
- package/dist/schemas/workflow-run.d.ts +2 -0
- package/dist/schemas/workflow-run.d.ts.map +1 -1
- package/dist/schemas/workflow-run.js +8 -1
- package/dist/schemas/workflow-run.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/events.test.ts +43 -7
- package/src/events.ts +28 -6
- package/src/index.ts +6 -3
- package/src/schemas/workflow-run-detail.ts +8 -0
- package/src/schemas/workflow-run.test.ts +3 -0
- package/src/schemas/workflow-run.ts +8 -0
- package/tsconfig.build.tsbuildinfo +1 -1
package/package.json
CHANGED
package/src/events.test.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WORKFLOWS_JOB_ACTIVATED,
|
|
3
3
|
WORKFLOWS_JOB_EVENT_DELIVERED,
|
|
4
|
-
|
|
4
|
+
WORKFLOWS_JOB_EXECUTION_QUEUED,
|
|
5
|
+
WORKFLOWS_JOB_EXECUTION_TERMINATED,
|
|
5
6
|
WORKFLOWS_JOB_STEPS_SETTLED,
|
|
6
7
|
WORKFLOWS_JOB_TERMINATED,
|
|
7
8
|
WORKFLOWS_STEP_ATTEMPT_TERMINATED,
|
|
@@ -12,7 +13,8 @@ import {
|
|
|
12
13
|
workflowsEventSchemas,
|
|
13
14
|
workflowsJobActivatedSchema,
|
|
14
15
|
workflowsJobEventDeliveredSchema,
|
|
15
|
-
|
|
16
|
+
workflowsJobExecutionQueuedSchema,
|
|
17
|
+
workflowsJobExecutionTerminatedSchema,
|
|
16
18
|
workflowsJobStepsSettledSchema,
|
|
17
19
|
workflowsJobTerminatedSchema,
|
|
18
20
|
workflowsStepAttemptTerminatedSchema,
|
|
@@ -52,10 +54,25 @@ const validRunCancelled = {
|
|
|
52
54
|
projectId: 'proj-1',
|
|
53
55
|
};
|
|
54
56
|
|
|
55
|
-
const
|
|
57
|
+
const validJobExecutionQueued = {
|
|
56
58
|
jobId: 'job-1',
|
|
57
59
|
jobExecutionId: 'execution-1',
|
|
60
|
+
workflowRunId: 'run-1',
|
|
61
|
+
workflowRunAttemptId: 'attempt-1',
|
|
62
|
+
workspaceId: 'ws-1',
|
|
63
|
+
projectId: 'project-1',
|
|
64
|
+
requiredLabels: ['linux'],
|
|
65
|
+
queuedAt: '2026-08-11T08:00:00.000Z',
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const validJobExecutionTerminated = {
|
|
69
|
+
jobId: 'job-1',
|
|
70
|
+
jobExecutionId: 'execution-1',
|
|
71
|
+
workflowRunId: 'run-1',
|
|
58
72
|
workflowRunAttemptId: 'attempt-1',
|
|
73
|
+
status: 'cancelled',
|
|
74
|
+
statusReason: 'run_cancelled',
|
|
75
|
+
statusReasonMessage: null,
|
|
59
76
|
};
|
|
60
77
|
|
|
61
78
|
const validJobActivated = {
|
|
@@ -187,6 +204,24 @@ describe('workflowsJobTerminatedSchema', () => {
|
|
|
187
204
|
});
|
|
188
205
|
});
|
|
189
206
|
|
|
207
|
+
describe('workflowsJobExecutionTerminatedSchema', () => {
|
|
208
|
+
it('parses a terminal job-execution fact', () => {
|
|
209
|
+
const result = workflowsJobExecutionTerminatedSchema.parse(validJobExecutionTerminated);
|
|
210
|
+
|
|
211
|
+
expect(result).toEqual(validJobExecutionTerminated);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it('rejects a non-terminal status', () => {
|
|
215
|
+
const parse = () =>
|
|
216
|
+
workflowsJobExecutionTerminatedSchema.parse({
|
|
217
|
+
...validJobExecutionTerminated,
|
|
218
|
+
status: 'running',
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
expect(parse).toThrow();
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
|
|
190
225
|
describe('workflowsWorkflowRunTerminatedSchema', () => {
|
|
191
226
|
it('parses a valid run-terminated payload unchanged', () => {
|
|
192
227
|
const result = workflowsWorkflowRunTerminatedSchema.parse(validRunTerminated);
|
|
@@ -322,9 +357,9 @@ describe.each([
|
|
|
322
357
|
'projectId',
|
|
323
358
|
],
|
|
324
359
|
[
|
|
325
|
-
'
|
|
326
|
-
|
|
327
|
-
|
|
360
|
+
'workflowsJobExecutionQueuedSchema',
|
|
361
|
+
workflowsJobExecutionQueuedSchema,
|
|
362
|
+
validJobExecutionQueued,
|
|
328
363
|
'jobId',
|
|
329
364
|
],
|
|
330
365
|
['workflowsJobActivatedSchema', workflowsJobActivatedSchema, validJobActivated, 'mode'],
|
|
@@ -379,7 +414,8 @@ describe('workflowsEventSchemas', () => {
|
|
|
379
414
|
WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED,
|
|
380
415
|
WORKFLOWS_WORKFLOW_RUN_TERMINATED,
|
|
381
416
|
WORKFLOWS_WORKFLOW_RUN_CANCELLED,
|
|
382
|
-
|
|
417
|
+
WORKFLOWS_JOB_EXECUTION_QUEUED,
|
|
418
|
+
WORKFLOWS_JOB_EXECUTION_TERMINATED,
|
|
383
419
|
WORKFLOWS_JOB_ACTIVATED,
|
|
384
420
|
WORKFLOWS_JOB_EVENT_DELIVERED,
|
|
385
421
|
WORKFLOWS_JOB_TERMINATED,
|
package/src/events.ts
CHANGED
|
@@ -11,7 +11,11 @@ export const WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED =
|
|
|
11
11
|
export const WORKFLOWS_WORKFLOW_RUN_TERMINATED = 'workflows.workflow_run.terminated' as const;
|
|
12
12
|
// Intent fact for cooperative run cancellation. Consumers use this to stop orchestration.
|
|
13
13
|
export const WORKFLOWS_WORKFLOW_RUN_CANCELLED = 'workflows.workflow_run.cancelled' as const;
|
|
14
|
-
|
|
14
|
+
// Terminal fact for a job execution, written in the same transaction as every
|
|
15
|
+
// transition to succeeded, failed, or cancelled.
|
|
16
|
+
export const WORKFLOWS_JOB_EXECUTION_TERMINATED = 'workflows.job_execution.terminated' as const;
|
|
17
|
+
// Scheduling fact for a job execution, written when workflows first records it as queued.
|
|
18
|
+
export const WORKFLOWS_JOB_EXECUTION_QUEUED = 'workflows.job_execution.queued' as const;
|
|
15
19
|
export const WORKFLOWS_JOB_ACTIVATED = 'workflows.job.activated' as const;
|
|
16
20
|
export const WORKFLOWS_JOB_EVENT_DELIVERED = 'workflows.job_event.delivered' as const;
|
|
17
21
|
// Terminal fact for a job: the single reliable "this job is over" signal, written in
|
|
@@ -65,13 +69,29 @@ export type WorkflowsWorkflowRunCancelledEventDto = z.infer<
|
|
|
65
69
|
typeof workflowsWorkflowRunCancelledSchema
|
|
66
70
|
>;
|
|
67
71
|
|
|
68
|
-
export const
|
|
72
|
+
export const workflowsJobExecutionQueuedSchema = z.object({
|
|
69
73
|
jobId: nonEmptyStringSchema,
|
|
70
74
|
jobExecutionId: nonEmptyStringSchema,
|
|
75
|
+
workflowRunId: nonEmptyStringSchema,
|
|
76
|
+
workflowRunAttemptId: nonEmptyStringSchema,
|
|
77
|
+
workspaceId: nonEmptyStringSchema,
|
|
78
|
+
projectId: nonEmptyStringSchema,
|
|
79
|
+
requiredLabels: z.array(nonEmptyStringSchema).min(1),
|
|
80
|
+
queuedAt: z.string().datetime(),
|
|
81
|
+
});
|
|
82
|
+
export type WorkflowsJobExecutionQueuedEventDto = z.infer<typeof workflowsJobExecutionQueuedSchema>;
|
|
83
|
+
|
|
84
|
+
export const workflowsJobExecutionTerminatedSchema = z.object({
|
|
85
|
+
jobId: nonEmptyStringSchema,
|
|
86
|
+
jobExecutionId: nonEmptyStringSchema,
|
|
87
|
+
workflowRunId: nonEmptyStringSchema,
|
|
71
88
|
workflowRunAttemptId: nonEmptyStringSchema,
|
|
89
|
+
status: workflowRunTerminalStatusSchema,
|
|
90
|
+
statusReason: jobStatusReasonSchema.nullable(),
|
|
91
|
+
statusReasonMessage: z.string().nullable().optional(),
|
|
72
92
|
});
|
|
73
|
-
export type
|
|
74
|
-
typeof
|
|
93
|
+
export type WorkflowsJobExecutionTerminatedEventDto = z.infer<
|
|
94
|
+
typeof workflowsJobExecutionTerminatedSchema
|
|
75
95
|
>;
|
|
76
96
|
|
|
77
97
|
const workflowsJobActivatedBaseSchema = z.object({
|
|
@@ -196,7 +216,8 @@ export interface WorkflowsEventMapDto {
|
|
|
196
216
|
[WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED]: WorkflowsWorkflowRunAttemptCreatedEventDto;
|
|
197
217
|
[WORKFLOWS_WORKFLOW_RUN_TERMINATED]: WorkflowsWorkflowRunTerminatedEventDto;
|
|
198
218
|
[WORKFLOWS_WORKFLOW_RUN_CANCELLED]: WorkflowsWorkflowRunCancelledEventDto;
|
|
199
|
-
[
|
|
219
|
+
[WORKFLOWS_JOB_EXECUTION_QUEUED]: WorkflowsJobExecutionQueuedEventDto;
|
|
220
|
+
[WORKFLOWS_JOB_EXECUTION_TERMINATED]: WorkflowsJobExecutionTerminatedEventDto;
|
|
200
221
|
[WORKFLOWS_JOB_ACTIVATED]: WorkflowsJobActivatedEventDto;
|
|
201
222
|
[WORKFLOWS_JOB_EVENT_DELIVERED]: WorkflowsJobEventDeliveredEventDto;
|
|
202
223
|
[WORKFLOWS_JOB_TERMINATED]: WorkflowsJobTerminatedEventDto;
|
|
@@ -209,7 +230,8 @@ export const workflowsEventSchemas = {
|
|
|
209
230
|
[WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED]: workflowsWorkflowRunAttemptCreatedSchema,
|
|
210
231
|
[WORKFLOWS_WORKFLOW_RUN_TERMINATED]: workflowsWorkflowRunTerminatedSchema,
|
|
211
232
|
[WORKFLOWS_WORKFLOW_RUN_CANCELLED]: workflowsWorkflowRunCancelledSchema,
|
|
212
|
-
[
|
|
233
|
+
[WORKFLOWS_JOB_EXECUTION_QUEUED]: workflowsJobExecutionQueuedSchema,
|
|
234
|
+
[WORKFLOWS_JOB_EXECUTION_TERMINATED]: workflowsJobExecutionTerminatedSchema,
|
|
213
235
|
[WORKFLOWS_JOB_ACTIVATED]: workflowsJobActivatedSchema,
|
|
214
236
|
[WORKFLOWS_JOB_EVENT_DELIVERED]: workflowsJobEventDeliveredSchema,
|
|
215
237
|
[WORKFLOWS_JOB_TERMINATED]: workflowsJobTerminatedSchema,
|
package/src/index.ts
CHANGED
|
@@ -128,7 +128,8 @@ export {
|
|
|
128
128
|
terminalStatusSchema,
|
|
129
129
|
WORKFLOWS_JOB_ACTIVATED,
|
|
130
130
|
WORKFLOWS_JOB_EVENT_DELIVERED,
|
|
131
|
-
|
|
131
|
+
WORKFLOWS_JOB_EXECUTION_QUEUED,
|
|
132
|
+
WORKFLOWS_JOB_EXECUTION_TERMINATED,
|
|
132
133
|
WORKFLOWS_JOB_STEPS_SETTLED,
|
|
133
134
|
WORKFLOWS_JOB_TERMINATED,
|
|
134
135
|
WORKFLOWS_STEP_ATTEMPT_TERMINATED,
|
|
@@ -139,7 +140,8 @@ export {
|
|
|
139
140
|
type WorkflowsEventMapDto,
|
|
140
141
|
type WorkflowsJobActivatedEventDto,
|
|
141
142
|
type WorkflowsJobEventDeliveredEventDto,
|
|
142
|
-
type
|
|
143
|
+
type WorkflowsJobExecutionQueuedEventDto,
|
|
144
|
+
type WorkflowsJobExecutionTerminatedEventDto,
|
|
143
145
|
type WorkflowsJobStepsSettledEventDto,
|
|
144
146
|
type WorkflowsJobTerminatedEventDto,
|
|
145
147
|
type WorkflowsStepAttemptTerminatedEventDto,
|
|
@@ -151,7 +153,8 @@ export {
|
|
|
151
153
|
workflowsEventSchemas,
|
|
152
154
|
workflowsJobActivatedSchema,
|
|
153
155
|
workflowsJobEventDeliveredSchema,
|
|
154
|
-
|
|
156
|
+
workflowsJobExecutionQueuedSchema,
|
|
157
|
+
workflowsJobExecutionTerminatedSchema,
|
|
155
158
|
workflowsJobStepsSettledSchema,
|
|
156
159
|
workflowsJobTerminatedSchema,
|
|
157
160
|
workflowsStepAttemptTerminatedSchema,
|
|
@@ -72,6 +72,14 @@ export type WorkflowRunJobDetailDto = z.infer<typeof workflowRunJobDetailDtoSche
|
|
|
72
72
|
export const workflowRunDetailResponseSchema = workflowRunResponseSchema.extend({
|
|
73
73
|
run_attempt: workflowRunAttemptDtoSchema,
|
|
74
74
|
jobs: z.array(workflowRunJobDetailDtoSchema),
|
|
75
|
+
/**
|
|
76
|
+
* Whether any job execution of this attempt reached its runner. Redundant with the executions
|
|
77
|
+
* below, and deliberately so: the server decides it once for both this response and the run
|
|
78
|
+
* list, which is what keeps the two surfaces from reaching different answers.
|
|
79
|
+
*
|
|
80
|
+
* Defaults to started for the same rollout reason as the list item's copy.
|
|
81
|
+
*/
|
|
82
|
+
has_started_job_execution: z.boolean().optional().default(true),
|
|
75
83
|
});
|
|
76
84
|
|
|
77
85
|
export type WorkflowRunDetailResponseDto = z.infer<typeof workflowRunDetailResponseSchema>;
|
|
@@ -120,6 +120,7 @@ describe('workflow run list item schema', () => {
|
|
|
120
120
|
source_snapshot: null,
|
|
121
121
|
jobs: [jobDto(0)],
|
|
122
122
|
job_status_counts: [{status: 'succeeded', count: 1}],
|
|
123
|
+
has_started_job_execution: true,
|
|
123
124
|
});
|
|
124
125
|
|
|
125
126
|
expect(result.jobs).toHaveLength(1);
|
|
@@ -185,6 +186,7 @@ describe('workflow run list item schema', () => {
|
|
|
185
186
|
{status: 'succeeded', count: 40},
|
|
186
187
|
{status: 'failed', count: 2},
|
|
187
188
|
],
|
|
189
|
+
has_started_job_execution: true,
|
|
188
190
|
});
|
|
189
191
|
|
|
190
192
|
expect(result.job_status_counts).toHaveLength(2);
|
|
@@ -196,6 +198,7 @@ describe('workflow run list item schema', () => {
|
|
|
196
198
|
source_snapshot: null,
|
|
197
199
|
jobs: Array.from({length: WORKFLOW_RUN_JOB_PREVIEW_LIMIT + 1}, (_, index) => jobDto(index)),
|
|
198
200
|
job_status_counts: [],
|
|
201
|
+
has_started_job_execution: false,
|
|
199
202
|
});
|
|
200
203
|
|
|
201
204
|
expect(result.success).toBe(false);
|
|
@@ -201,6 +201,14 @@ export const workflowRunListItemSchema = workflowRunResponseSchema.extend({
|
|
|
201
201
|
* Optional so a new web client can consume an older API response during rollout.
|
|
202
202
|
*/
|
|
203
203
|
job_display_status_counts: z.array(workflowRunJobDisplayStatusCountDtoSchema).optional(),
|
|
204
|
+
/**
|
|
205
|
+
* Whether any job execution in the attempt reached its runner. A `cancelled` job does not say
|
|
206
|
+
* this on its own, so the counts above cannot answer it.
|
|
207
|
+
*
|
|
208
|
+
* Defaults to started, so an older API response during a rollout keeps the reading a run had
|
|
209
|
+
* before this field existed rather than claiming work that ran never began.
|
|
210
|
+
*/
|
|
211
|
+
has_started_job_execution: z.boolean().optional().default(true),
|
|
204
212
|
});
|
|
205
213
|
|
|
206
214
|
export type WorkflowRunListItemDto = z.input<typeof workflowRunListItemSchema>;
|