@shipfox/api-workflows-dto 12.7.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shipfox/api-workflows-dto",
3
3
  "license": "MIT",
4
- "version": "12.7.0",
4
+ "version": "13.0.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/ShipfoxHQ/shipfox.git",
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  WORKFLOWS_JOB_ACTIVATED,
3
3
  WORKFLOWS_JOB_EVENT_DELIVERED,
4
- WORKFLOWS_JOB_EXECUTION_TIMED_OUT,
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
- workflowsJobExecutionTimedOutSchema,
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 validJobExecutionTimedOut = {
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
- 'workflowsJobExecutionTimedOutSchema',
326
- workflowsJobExecutionTimedOutSchema,
327
- validJobExecutionTimedOut,
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
- WORKFLOWS_JOB_EXECUTION_TIMED_OUT,
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
- export const WORKFLOWS_JOB_EXECUTION_TIMED_OUT = 'workflows.job_execution.timed_out' as const;
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 workflowsJobExecutionTimedOutSchema = z.object({
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 WorkflowsJobExecutionTimedOutEventDto = z.infer<
74
- typeof workflowsJobExecutionTimedOutSchema
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
- [WORKFLOWS_JOB_EXECUTION_TIMED_OUT]: WorkflowsJobExecutionTimedOutEventDto;
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
- [WORKFLOWS_JOB_EXECUTION_TIMED_OUT]: workflowsJobExecutionTimedOutSchema,
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
- WORKFLOWS_JOB_EXECUTION_TIMED_OUT,
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 WorkflowsJobExecutionTimedOutEventDto,
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
- workflowsJobExecutionTimedOutSchema,
156
+ workflowsJobExecutionQueuedSchema,
157
+ workflowsJobExecutionTerminatedSchema,
155
158
  workflowsJobStepsSettledSchema,
156
159
  workflowsJobTerminatedSchema,
157
160
  workflowsStepAttemptTerminatedSchema,