@shipfox/api-workflows 16.0.0 → 16.1.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 +4 -4
- package/.turbo/turbo-type.log +1 -0
- package/CHANGELOG.md +20 -0
- package/dist/core/agent-tools.js +8 -3
- package/dist/core/agent-tools.js.map +1 -1
- package/dist/core/entities/step.d.ts +1 -1
- package/dist/core/entities/step.d.ts.map +1 -1
- package/dist/core/entities/step.js +2 -1
- package/dist/core/entities/step.js.map +1 -1
- package/dist/core/errors.d.ts +1 -1
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js.map +1 -1
- package/dist/core/step-config/materialize-job-execution-steps.js +2 -0
- package/dist/core/step-config/materialize-job-execution-steps.js.map +1 -1
- package/dist/core/step-config/resolve-step-config.js +3 -1
- package/dist/core/step-config/resolve-step-config.js.map +1 -1
- package/dist/db/db.d.ts +8 -8
- package/dist/db/index.d.ts +1 -1
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +1 -1
- package/dist/db/index.js.map +1 -1
- package/dist/db/schema/steps.d.ts +2 -2
- package/dist/db/schema/workflow-run-attempts.d.ts +2 -2
- package/dist/db/workflow-runs/outbox.d.ts +1 -0
- package/dist/db/workflow-runs/outbox.d.ts.map +1 -1
- package/dist/db/workflow-runs/outbox.js +2 -1
- package/dist/db/workflow-runs/outbox.js.map +1 -1
- package/dist/db/workflow-runs/run-create.d.ts.map +1 -1
- package/dist/db/workflow-runs/run-create.js +49 -1
- package/dist/db/workflow-runs/run-create.js.map +1 -1
- package/dist/db/workflow-runs/steps.d.ts +6 -0
- package/dist/db/workflow-runs/steps.d.ts.map +1 -1
- package/dist/db/workflow-runs/steps.js +14 -0
- package/dist/db/workflow-runs/steps.js.map +1 -1
- package/dist/db/workflow-runs.d.ts +1 -1
- package/dist/db/workflow-runs.d.ts.map +1 -1
- package/dist/db/workflow-runs.js +1 -1
- package/dist/db/workflow-runs.js.map +1 -1
- package/dist/presentation/inter-module.d.ts.map +1 -1
- package/dist/presentation/inter-module.js +6 -1
- package/dist/presentation/inter-module.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/core/agent-tools.test.ts +85 -0
- package/src/core/agent-tools.ts +11 -3
- package/src/core/entities/step.ts +1 -1
- package/src/core/errors.ts +2 -0
- package/src/core/job-execution.test.ts +1 -0
- package/src/core/run-workflow.test.ts +4 -0
- package/src/core/step-config/materialize-job-execution-steps.ts +2 -0
- package/src/core/step-config/resolve-step-config.ts +4 -1
- package/src/db/index.ts +1 -0
- package/src/db/workflow-runs/outbox.ts +2 -0
- package/src/db/workflow-runs/run-create.test.ts +41 -0
- package/src/db/workflow-runs/run-create.ts +81 -3
- package/src/db/workflow-runs/steps.ts +19 -0
- package/src/db/workflow-runs.ts +1 -0
- package/src/presentation/inter-module.test.ts +26 -0
- package/src/presentation/inter-module.ts +9 -1
- package/src/presentation/routes/agent-runtime-config.test.ts +2 -0
- package/test/factories/workflow-model.ts +74 -2
- package/test/fixtures/agent-inter-module.ts +2 -0
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -91,6 +91,7 @@ export async function bulkUpdateStepStatuses(params, tx) {
|
|
|
91
91
|
logOutcome: 'abandoned',
|
|
92
92
|
finishedAt: new Date()
|
|
93
93
|
}).from(steps).where(and(eq(stepAttempts.stepId, steps.id), eq(steps.jobExecutionId, params.jobExecutionId), eq(stepAttempts.status, 'running'))).returning({
|
|
94
|
+
id: stepAttempts.id,
|
|
94
95
|
stepId: stepAttempts.stepId,
|
|
95
96
|
attempt: stepAttempts.attempt,
|
|
96
97
|
logOutcome: stepAttempts.logOutcome
|
|
@@ -98,6 +99,7 @@ export async function bulkUpdateStepStatuses(params, tx) {
|
|
|
98
99
|
if (finalizedAttempts.length > 0) {
|
|
99
100
|
for (const attempt of finalizedAttempts){
|
|
100
101
|
await writeStepAttemptTerminatedOutbox(tx, {
|
|
102
|
+
stepAttemptId: attempt.id,
|
|
101
103
|
stepId: attempt.stepId,
|
|
102
104
|
attempt: attempt.attempt,
|
|
103
105
|
status: params.status,
|
|
@@ -223,6 +225,7 @@ export async function finishStepAttempt(params, tx) {
|
|
|
223
225
|
restartFeedback: params.restartFeedback ?? null,
|
|
224
226
|
finishedAt: new Date()
|
|
225
227
|
}).where(and(eq(stepAttempts.stepId, params.stepId), eq(stepAttempts.attempt, params.attempt), eq(stepAttempts.status, 'running'))).returning({
|
|
228
|
+
id: stepAttempts.id,
|
|
226
229
|
stepId: stepAttempts.stepId,
|
|
227
230
|
attempt: stepAttempts.attempt,
|
|
228
231
|
logOutcome: stepAttempts.logOutcome
|
|
@@ -230,6 +233,7 @@ export async function finishStepAttempt(params, tx) {
|
|
|
230
233
|
const row = rows[0];
|
|
231
234
|
if (!row) return;
|
|
232
235
|
await writeStepAttemptTerminatedOutbox(tx, {
|
|
236
|
+
stepAttemptId: row.id,
|
|
233
237
|
stepId: row.stepId,
|
|
234
238
|
attempt: row.attempt,
|
|
235
239
|
status: params.status,
|
|
@@ -268,6 +272,16 @@ export async function getStepAttempts(jobId) {
|
|
|
268
272
|
}).from(stepAttempts).innerJoin(steps, eq(stepAttempts.stepId, steps.id)).innerJoin(jobExecutions, eq(steps.jobExecutionId, jobExecutions.id)).where(eq(jobExecutions.jobId, jobId)).orderBy(asc(stepAttempts.executionOrder));
|
|
269
273
|
return rows.map((row)=>toStepAttempt(row.stepAttempt));
|
|
270
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* Lists only the step attempt ids of a job, without materializing the full
|
|
277
|
+
* attempt entities. The session release sweep only needs the ids to release
|
|
278
|
+
* claims, so this keeps the per-job-terminated query off a full-row projection.
|
|
279
|
+
*/ export async function listStepAttemptIdsByJobId(jobId) {
|
|
280
|
+
const rows = await db().select({
|
|
281
|
+
id: stepAttempts.id
|
|
282
|
+
}).from(stepAttempts).innerJoin(steps, eq(stepAttempts.stepId, steps.id)).innerJoin(jobExecutions, eq(steps.jobExecutionId, jobExecutions.id)).where(eq(jobExecutions.jobId, jobId));
|
|
283
|
+
return rows.map((row)=>row.id);
|
|
284
|
+
}
|
|
271
285
|
export async function getStepAttemptsByJobIds(jobIds) {
|
|
272
286
|
if (jobIds.length === 0) return [];
|
|
273
287
|
const rows = await db().select({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/db/workflow-runs/steps.ts"],"sourcesContent":["import type {LogOutcomeDto} from '@shipfox/api-workflows-dto';\nimport {and, asc, count, desc, eq, gte, inArray, sql} from 'drizzle-orm';\nimport type {\n PersistedEvaluationTraceEntry,\n Step,\n StepAttempt,\n StepAttemptStatus,\n StepStatus,\n StepStatusReason,\n} from '#core/entities/step.js';\nimport {deriveCompletion, isTerminal} from '#core/step-transition/decide-step-transition.js';\nimport {db, type Tx} from '../db.js';\nimport {jobExecutions} from '../schema/job-executions.js';\nimport {jobs} from '../schema/jobs.js';\nimport {stepAttempts, toStepAttempt} from '../schema/step-attempts.js';\nimport {steps, toStep} from '../schema/steps.js';\nimport {workflowRunAttempts} from '../schema/workflow-run-attempts.js';\nimport {workflowRuns} from '../schema/workflow-runs.js';\nimport {writeJobStepsSettledOutbox, writeStepAttemptTerminatedOutbox} from './outbox.js';\nimport {NON_TERMINAL_STEP_STATUS_FILTER} from './shared.js';\n\nexport async function getStepByIdForJobExecution(params: {\n stepId: string;\n jobExecutionId: string;\n}): Promise<Step | undefined> {\n const rows = await db()\n .select()\n .from(steps)\n .where(and(eq(steps.id, params.stepId), eq(steps.jobExecutionId, params.jobExecutionId)))\n .limit(1);\n\n const row = rows[0];\n if (!row) return undefined;\n return toStep(row);\n}\n\nexport async function getStepById(stepId: string): Promise<Step | undefined> {\n const rows = await db().select().from(steps).where(eq(steps.id, stepId)).limit(1);\n\n const row = rows[0];\n if (!row) return undefined;\n return toStep(row);\n}\n\nexport interface StepAttemptDetail {\n workflowRunId: string;\n workflowRunAttemptId: string;\n step: Step;\n attempt: StepAttempt;\n}\n\nexport interface JobExecutionFailureOrigin {\n jobExecutionId: string;\n stepId: string;\n stepName: string;\n stepStatus: StepStatus;\n stepAttempt: number;\n stepError: Record<string, unknown> | null;\n attemptStatus: StepAttemptStatus | null;\n attemptError: Record<string, unknown> | null;\n attemptExitCode: number | null;\n}\n\n/**\n * Read only the current attempt for the most relevant step. The terminal job event identifies\n * the execution, so this intentionally avoids hydrating the execution's complete attempt\n * history. If no attempt was dispatched, the first step still gives the projection a stable\n * troubleshooting origin for failures that happened before step work started.\n */\nexport async function getJobExecutionFailureOrigin(\n jobExecutionId: string,\n): Promise<JobExecutionFailureOrigin | undefined> {\n const rows = await db()\n .select({\n jobExecutionId: jobExecutions.id,\n stepId: steps.id,\n stepName: steps.name,\n stepStatus: steps.status,\n stepAttempt: steps.currentAttempt,\n stepError: steps.error,\n attemptStatus: stepAttempts.status,\n attemptError: stepAttempts.error,\n attemptExitCode: stepAttempts.exitCode,\n })\n .from(jobExecutions)\n .innerJoin(steps, eq(steps.jobExecutionId, jobExecutions.id))\n .leftJoin(\n stepAttempts,\n and(eq(stepAttempts.stepId, steps.id), eq(stepAttempts.attempt, steps.currentAttempt)),\n )\n .where(eq(jobExecutions.id, jobExecutionId))\n .orderBy(\n desc(\n sql<number>`case when ${steps.status} = 'failed' or ${stepAttempts.status} = 'failed' or ${steps.statusReason} = 'condition_errored' then 1 else 0 end`,\n ),\n asc(steps.position),\n asc(steps.id),\n )\n .limit(1);\n\n const row = rows[0];\n if (!row) return undefined;\n\n return {\n ...row,\n stepError: (row.stepError as Record<string, unknown> | null) ?? null,\n attemptError: (row.attemptError as Record<string, unknown> | null) ?? null,\n attemptStatus: row.attemptStatus === null ? null : (row.attemptStatus as StepAttemptStatus),\n attemptExitCode: row.attemptExitCode ?? null,\n };\n}\n\nexport async function getStepAttemptDetail(params: {\n stepId: string;\n attempt: number;\n}): Promise<StepAttemptDetail | undefined> {\n const rows = await db()\n .select({\n workflowRunId: workflowRuns.id,\n workflowRunAttemptId: workflowRunAttempts.id,\n step: steps,\n stepAttempt: stepAttempts,\n })\n .from(stepAttempts)\n .innerJoin(steps, eq(stepAttempts.stepId, steps.id))\n .innerJoin(jobExecutions, eq(steps.jobExecutionId, jobExecutions.id))\n .innerJoin(jobs, eq(jobExecutions.jobId, jobs.id))\n .innerJoin(workflowRunAttempts, eq(jobs.workflowRunAttemptId, workflowRunAttempts.id))\n .innerJoin(workflowRuns, eq(workflowRunAttempts.workflowRunId, workflowRuns.id))\n .where(and(eq(stepAttempts.stepId, params.stepId), eq(stepAttempts.attempt, params.attempt)))\n .limit(1);\n\n const row = rows[0];\n if (!row) return undefined;\n\n return {\n workflowRunId: row.workflowRunId,\n workflowRunAttemptId: row.workflowRunAttemptId,\n step: toStep(row.step),\n attempt: toStepAttempt(row.stepAttempt),\n };\n}\n\nexport async function getStepsByJobId(jobId: string): Promise<Step[]> {\n const rows = await db()\n .select({step: steps})\n .from(steps)\n .innerJoin(jobExecutions, eq(steps.jobExecutionId, jobExecutions.id))\n .where(eq(jobExecutions.jobId, jobId))\n .orderBy(asc(steps.position));\n return rows.map((row) => toStep(row.step));\n}\n\nexport async function getStepsByJobExecutionId(jobExecutionId: string): Promise<Step[]> {\n const rows = await db()\n .select()\n .from(steps)\n .where(eq(steps.jobExecutionId, jobExecutionId))\n .orderBy(asc(steps.position));\n return rows.map(toStep);\n}\n\nexport interface BulkUpdateStepStatusesParams {\n jobExecutionId: string;\n status: Extract<StepStatus, 'failed' | 'cancelled'>;\n}\n\nexport async function bulkUpdateStepStatuses(\n params: BulkUpdateStepStatusesParams,\n tx?: Tx,\n): Promise<void> {\n if (!tx) {\n await db().transaction((transaction) => bulkUpdateStepStatuses(params, transaction));\n return;\n }\n\n await tx\n .update(steps)\n .set({\n status: params.status,\n statusReason: null,\n updatedAt: new Date(),\n })\n .where(and(eq(steps.jobExecutionId, params.jobExecutionId), NON_TERMINAL_STEP_STATUS_FILTER));\n\n // Finalize open attempt rows so a timed-out/cancelled sweep does not leave\n // phantom in-flight work for gate and restart logic.\n const finalizedAttempts = await tx\n .update(stepAttempts)\n .set({status: params.status, logOutcome: 'abandoned', finishedAt: new Date()})\n .from(steps)\n .where(\n and(\n eq(stepAttempts.stepId, steps.id),\n eq(steps.jobExecutionId, params.jobExecutionId),\n eq(stepAttempts.status, 'running'),\n ),\n )\n .returning({\n stepId: stepAttempts.stepId,\n attempt: stepAttempts.attempt,\n logOutcome: stepAttempts.logOutcome,\n });\n\n if (finalizedAttempts.length > 0) {\n for (const attempt of finalizedAttempts) {\n await writeStepAttemptTerminatedOutbox(tx, {\n stepId: attempt.stepId,\n attempt: attempt.attempt,\n status: params.status,\n logOutcome: attempt.logOutcome ?? 'abandoned',\n });\n }\n }\n}\n\n// Per-step progression primitives. They take a mandatory `tx` because they only\n// run inside the job-execution service's transaction, and every write guards on\n// the never-downgrade predicate so a late or duplicate write cannot overwrite an\n// already-terminal row.\n\nexport async function getStepsByJobExecutionIdForUpdate(\n jobExecutionId: string,\n tx: Tx,\n): Promise<Step[]> {\n const rows = await tx\n .select()\n .from(steps)\n .where(eq(steps.jobExecutionId, jobExecutionId))\n .orderBy(asc(steps.position))\n .for('update');\n return rows.map(toStep);\n}\n\nexport async function getStepAttemptsByJobExecutionId(\n jobExecutionId: string,\n tx: Tx,\n): Promise<StepAttempt[]> {\n const rows = await tx\n .select()\n .from(stepAttempts)\n .where(eq(stepAttempts.jobExecutionId, jobExecutionId))\n .orderBy(asc(stepAttempts.executionOrder), asc(stepAttempts.id));\n return rows.map(toStepAttempt);\n}\n\nexport interface MarkStepRunningParams {\n jobExecutionId: string;\n stepId: string;\n}\n\nexport async function markStepRunning(params: MarkStepRunningParams, tx: Tx): Promise<Step | null> {\n const rows = await tx\n .update(steps)\n .set({\n status: 'running',\n statusReason: null,\n evaluationTrace: null,\n updatedAt: new Date(),\n })\n .where(\n and(\n eq(steps.id, params.stepId),\n eq(steps.jobExecutionId, params.jobExecutionId),\n NON_TERMINAL_STEP_STATUS_FILTER,\n ),\n )\n .returning();\n const row = rows[0];\n if (!row) return null;\n const step = toStep(row);\n // Open the attempt this dispatch runs. onConflictDoNothing makes a racing\n // re-dispatch a no-op against the unique (step_id, attempt) anchor; normal\n // re-delivery returns the already-running step without calling this.\n await insertRunningStepAttempt(\n {\n jobExecutionId: step.jobExecutionId,\n stepId: step.id,\n attempt: step.currentAttempt,\n config: step.config,\n },\n tx,\n );\n return step;\n}\n\nexport interface DispatchStepWithCompletedConfigParams {\n jobExecutionId: string;\n stepId: string;\n config: Record<string, unknown>;\n evaluationTrace: readonly PersistedEvaluationTraceEntry[] | null;\n}\n\nexport async function dispatchStepWithCompletedConfig(\n params: DispatchStepWithCompletedConfigParams,\n tx: Tx,\n): Promise<Step | null> {\n const rows = await tx\n .update(steps)\n .set({\n status: 'running',\n statusReason: null,\n evaluationTrace: null,\n config: params.config,\n updatedAt: new Date(),\n })\n .where(\n and(\n eq(steps.id, params.stepId),\n eq(steps.jobExecutionId, params.jobExecutionId),\n NON_TERMINAL_STEP_STATUS_FILTER,\n ),\n )\n .returning();\n const row = rows[0];\n if (!row) return null;\n const step = toStep(row);\n await insertRunningStepAttempt(\n {\n jobExecutionId: step.jobExecutionId,\n stepId: step.id,\n attempt: step.currentAttempt,\n config: params.config,\n evaluationTrace: params.evaluationTrace,\n },\n tx,\n );\n return step;\n}\n\nexport interface MarkStepSkippedParams {\n jobExecutionId: string;\n stepId: string;\n statusReason: StepStatusReason;\n evaluationTrace: readonly PersistedEvaluationTraceEntry[];\n}\n\nexport async function markStepSkipped(params: MarkStepSkippedParams, tx: Tx): Promise<Step | null> {\n const rows = await tx\n .update(steps)\n .set({\n status: 'skipped',\n statusReason: params.statusReason,\n evaluationTrace: params.evaluationTrace,\n error: null,\n updatedAt: new Date(),\n })\n .where(\n and(\n eq(steps.id, params.stepId),\n eq(steps.jobExecutionId, params.jobExecutionId),\n eq(steps.status, 'pending'),\n ),\n )\n .returning();\n const row = rows[0];\n return row ? toStep(row) : null;\n}\n\nexport async function settleJobFailed(\n tx: Tx,\n params: {\n jobId: string;\n jobExecutionId: string;\n failedStepId: string;\n error: Record<string, unknown>;\n },\n): Promise<'succeeded' | 'failed' | null> {\n await applyStepResult(\n {\n jobExecutionId: params.jobExecutionId,\n stepId: params.failedStepId,\n status: 'failed',\n error: params.error,\n },\n tx,\n );\n\n const after = await getStepsByJobExecutionIdForUpdate(params.jobExecutionId, tx);\n if (!after.every((step) => isTerminal(step.status))) return null;\n\n const status = deriveCompletion(after);\n await writeJobStepsSettledOutbox(tx, {\n jobId: params.jobId,\n jobExecutionId: params.jobExecutionId,\n status,\n });\n return status;\n}\n\nexport interface InsertRunningStepAttemptParams {\n jobExecutionId: string;\n stepId: string;\n attempt: number;\n config?: Record<string, unknown> | null;\n evaluationTrace?: readonly PersistedEvaluationTraceEntry[] | null;\n}\n\nexport async function insertRunningStepAttempt(\n params: InsertRunningStepAttemptParams,\n tx: Tx,\n): Promise<void> {\n const [{nextExecutionOrder} = {nextExecutionOrder: 1}] = await tx\n .select({\n nextExecutionOrder: sql<number>`coalesce(max(${stepAttempts.executionOrder}), 0) + 1`,\n })\n .from(stepAttempts)\n .where(eq(stepAttempts.jobExecutionId, params.jobExecutionId));\n\n await tx\n .insert(stepAttempts)\n .values({\n jobExecutionId: params.jobExecutionId,\n stepId: params.stepId,\n attempt: params.attempt,\n executionOrder: nextExecutionOrder,\n status: 'running',\n config: params.config ?? null,\n evaluationTrace: params.evaluationTrace ?? null,\n })\n .onConflictDoNothing({target: [stepAttempts.stepId, stepAttempts.attempt]});\n}\n\nexport interface FinishStepAttemptParams {\n stepId: string;\n attempt: number;\n status: Exclude<StepAttemptStatus, 'running'>;\n error?: Record<string, unknown> | null;\n output?: Record<string, unknown> | null;\n response?: string | null;\n exitCode?: number | null;\n logOutcome: LogOutcomeDto;\n gateResult?: Record<string, unknown> | null;\n restartFeedback?: string | null;\n}\n\n// Finalize the running attempt to a terminal state. The `status='running'` guard\n// makes this idempotent: a duplicate report finds the attempt already terminal\n// and updates nothing (never-downgrade for the audit row).\nexport async function finishStepAttempt(params: FinishStepAttemptParams, tx: Tx): Promise<void> {\n const rows = await tx\n .update(stepAttempts)\n .set({\n status: params.status,\n output: params.output ?? null,\n response: params.response ?? null,\n error: params.error ?? null,\n exitCode: params.exitCode ?? null,\n logOutcome: params.logOutcome,\n gateResult: params.gateResult ?? null,\n restartFeedback: params.restartFeedback ?? null,\n finishedAt: new Date(),\n })\n .where(\n and(\n eq(stepAttempts.stepId, params.stepId),\n eq(stepAttempts.attempt, params.attempt),\n eq(stepAttempts.status, 'running'),\n ),\n )\n .returning({\n stepId: stepAttempts.stepId,\n attempt: stepAttempts.attempt,\n logOutcome: stepAttempts.logOutcome,\n });\n\n const row = rows[0];\n if (!row) return;\n\n await writeStepAttemptTerminatedOutbox(tx, {\n stepId: row.stepId,\n attempt: row.attempt,\n status: params.status,\n logOutcome: row.logOutcome ?? params.logOutcome,\n });\n}\n\nexport interface RewindStepsToPendingParams {\n jobExecutionId: string;\n fromPosition: number;\n}\n\n// Restart-only: rewind every step at or after `fromPosition` back to pending,\n// clearing its result and bumping both `version` and `current_attempt` so the next\n// dispatch opens a fresh attempt. This DELIBERATELY bypasses the never-downgrade\n// guard used everywhere else. It is the one place that resurrects terminal steps,\n// so it must only be called from the durable-restart path, never the ordinary\n// report path. It must run in the same transaction as the failed-attempt write.\nexport async function rewindStepsToPending(\n params: RewindStepsToPendingParams,\n tx: Tx,\n): Promise<void> {\n await tx\n .update(steps)\n .set({\n status: 'pending',\n statusReason: null,\n error: null,\n version: sql`${steps.version} + 1`,\n currentAttempt: sql`${steps.currentAttempt} + 1`,\n updatedAt: new Date(),\n })\n .where(\n and(\n eq(steps.jobExecutionId, params.jobExecutionId),\n gte(steps.position, params.fromPosition),\n ),\n );\n}\n\n// Count a single step's own attempts. Used to bound the restart cap on the\n// gating step's actual executions: `steps.current_attempt` can't be used for\n// the cap because a rewind also bumps it for downstream steps swept into the\n// rewind range (which would inflate a later gate's cap in a multi-gate job).\nexport async function countStepAttempts(stepId: string, tx: Tx): Promise<number> {\n const rows = await tx\n .select({total: count()})\n .from(stepAttempts)\n .where(eq(stepAttempts.stepId, stepId));\n return Number(rows[0]?.total ?? 0);\n}\n\nexport async function getStepAttempts(jobId: string): Promise<StepAttempt[]> {\n const rows = await db()\n .select({stepAttempt: stepAttempts})\n .from(stepAttempts)\n .innerJoin(steps, eq(stepAttempts.stepId, steps.id))\n .innerJoin(jobExecutions, eq(steps.jobExecutionId, jobExecutions.id))\n .where(eq(jobExecutions.jobId, jobId))\n .orderBy(asc(stepAttempts.executionOrder));\n return rows.map((row) => toStepAttempt(row.stepAttempt));\n}\n\nexport async function getStepAttemptsByJobIds(jobIds: string[]): Promise<StepAttempt[]> {\n if (jobIds.length === 0) return [];\n const rows = await db()\n .select({stepAttempt: stepAttempts, jobId: jobExecutions.jobId})\n .from(stepAttempts)\n .innerJoin(steps, eq(stepAttempts.stepId, steps.id))\n .innerJoin(jobExecutions, eq(steps.jobExecutionId, jobExecutions.id))\n .where(inArray(jobExecutions.jobId, jobIds))\n .orderBy(asc(jobExecutions.jobId), asc(stepAttempts.executionOrder));\n return rows.map((row) => toStepAttempt(row.stepAttempt));\n}\n\nexport interface ApplyStepResultParams {\n jobExecutionId: string;\n stepId: string;\n status: 'succeeded' | 'failed';\n error: Record<string, unknown> | null;\n}\n\nexport async function applyStepResult(params: ApplyStepResultParams, tx: Tx): Promise<void> {\n await tx\n .update(steps)\n .set({\n status: params.status,\n statusReason: null,\n error: params.error ?? null,\n updatedAt: new Date(),\n })\n .where(\n and(\n eq(steps.id, params.stepId),\n eq(steps.jobExecutionId, params.jobExecutionId),\n NON_TERMINAL_STEP_STATUS_FILTER,\n ),\n );\n}\n\nexport interface CancelRemainingStepsParams {\n jobExecutionId: string;\n}\n\nexport async function cancelRemainingSteps(\n params: CancelRemainingStepsParams,\n tx: Tx,\n): Promise<void> {\n await bulkUpdateStepStatuses({jobExecutionId: params.jobExecutionId, status: 'cancelled'}, tx);\n}\n"],"names":["and","asc","count","desc","eq","gte","inArray","sql","deriveCompletion","isTerminal","db","jobExecutions","jobs","stepAttempts","toStepAttempt","steps","toStep","workflowRunAttempts","workflowRuns","writeJobStepsSettledOutbox","writeStepAttemptTerminatedOutbox","NON_TERMINAL_STEP_STATUS_FILTER","getStepByIdForJobExecution","params","rows","select","from","where","id","stepId","jobExecutionId","limit","row","undefined","getStepById","getJobExecutionFailureOrigin","stepName","name","stepStatus","status","stepAttempt","currentAttempt","stepError","error","attemptStatus","attemptError","attemptExitCode","exitCode","innerJoin","leftJoin","attempt","orderBy","statusReason","position","getStepAttemptDetail","workflowRunId","workflowRunAttemptId","step","jobId","getStepsByJobId","map","getStepsByJobExecutionId","bulkUpdateStepStatuses","tx","transaction","update","set","updatedAt","Date","finalizedAttempts","logOutcome","finishedAt","returning","length","getStepsByJobExecutionIdForUpdate","for","getStepAttemptsByJobExecutionId","executionOrder","markStepRunning","evaluationTrace","insertRunningStepAttempt","config","dispatchStepWithCompletedConfig","markStepSkipped","settleJobFailed","applyStepResult","failedStepId","after","every","nextExecutionOrder","insert","values","onConflictDoNothing","target","finishStepAttempt","output","response","gateResult","restartFeedback","rewindStepsToPending","version","fromPosition","countStepAttempts","total","Number","getStepAttempts","getStepAttemptsByJobIds","jobIds","cancelRemainingSteps"],"mappings":"AACA,SAAQA,GAAG,EAAEC,GAAG,EAAEC,KAAK,EAAEC,IAAI,EAAEC,EAAE,EAAEC,GAAG,EAAEC,OAAO,EAAEC,GAAG,QAAO,cAAc;AASzE,SAAQC,gBAAgB,EAAEC,UAAU,QAAO,kDAAkD;AAC7F,SAAQC,EAAE,QAAgB,WAAW;AACrC,SAAQC,aAAa,QAAO,8BAA8B;AAC1D,SAAQC,IAAI,QAAO,oBAAoB;AACvC,SAAQC,YAAY,EAAEC,aAAa,QAAO,6BAA6B;AACvE,SAAQC,KAAK,EAAEC,MAAM,QAAO,qBAAqB;AACjD,SAAQC,mBAAmB,QAAO,qCAAqC;AACvE,SAAQC,YAAY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OAAOpB,OAAOoB,KAAK,IAAI;QACvBwB,WAAW,IAAIC;IACjB,GACCzC,KAAK,CACJ3B,IACEI,GAAGW,MAAMa,EAAE,EAAEL,OAAOM,MAAM,GAC1BzB,GAAGW,MAAMe,cAAc,EAAEP,OAAOO,cAAc,GAC9CT;AAGR;AAMA,OAAO,eAAeuF,qBACpBrF,MAAkC,EAClCwC,EAAM;IAEN,MAAMD,uBAAuB;QAAChC,gBAAgBP,OAAOO,cAAc;QAAES,QAAQ;IAAW,GAAGwB;AAC7F"}
|
|
1
|
+
{"version":3,"sources":["../../../src/db/workflow-runs/steps.ts"],"sourcesContent":["import type {LogOutcomeDto} from '@shipfox/api-workflows-dto';\nimport {and, asc, count, desc, eq, gte, inArray, sql} from 'drizzle-orm';\nimport type {\n PersistedEvaluationTraceEntry,\n Step,\n StepAttempt,\n StepAttemptStatus,\n StepStatus,\n StepStatusReason,\n} from '#core/entities/step.js';\nimport {deriveCompletion, isTerminal} from '#core/step-transition/decide-step-transition.js';\nimport {db, type Tx} from '../db.js';\nimport {jobExecutions} from '../schema/job-executions.js';\nimport {jobs} from '../schema/jobs.js';\nimport {stepAttempts, toStepAttempt} from '../schema/step-attempts.js';\nimport {steps, toStep} from '../schema/steps.js';\nimport {workflowRunAttempts} from '../schema/workflow-run-attempts.js';\nimport {workflowRuns} from '../schema/workflow-runs.js';\nimport {writeJobStepsSettledOutbox, writeStepAttemptTerminatedOutbox} from './outbox.js';\nimport {NON_TERMINAL_STEP_STATUS_FILTER} from './shared.js';\n\nexport async function getStepByIdForJobExecution(params: {\n stepId: string;\n jobExecutionId: string;\n}): Promise<Step | undefined> {\n const rows = await db()\n .select()\n .from(steps)\n .where(and(eq(steps.id, params.stepId), eq(steps.jobExecutionId, params.jobExecutionId)))\n .limit(1);\n\n const row = rows[0];\n if (!row) return undefined;\n return toStep(row);\n}\n\nexport async function getStepById(stepId: string): Promise<Step | undefined> {\n const rows = await db().select().from(steps).where(eq(steps.id, stepId)).limit(1);\n\n const row = rows[0];\n if (!row) return undefined;\n return toStep(row);\n}\n\nexport interface StepAttemptDetail {\n workflowRunId: string;\n workflowRunAttemptId: string;\n step: Step;\n attempt: StepAttempt;\n}\n\nexport interface JobExecutionFailureOrigin {\n jobExecutionId: string;\n stepId: string;\n stepName: string;\n stepStatus: StepStatus;\n stepAttempt: number;\n stepError: Record<string, unknown> | null;\n attemptStatus: StepAttemptStatus | null;\n attemptError: Record<string, unknown> | null;\n attemptExitCode: number | null;\n}\n\n/**\n * Read only the current attempt for the most relevant step. The terminal job event identifies\n * the execution, so this intentionally avoids hydrating the execution's complete attempt\n * history. If no attempt was dispatched, the first step still gives the projection a stable\n * troubleshooting origin for failures that happened before step work started.\n */\nexport async function getJobExecutionFailureOrigin(\n jobExecutionId: string,\n): Promise<JobExecutionFailureOrigin | undefined> {\n const rows = await db()\n .select({\n jobExecutionId: jobExecutions.id,\n stepId: steps.id,\n stepName: steps.name,\n stepStatus: steps.status,\n stepAttempt: steps.currentAttempt,\n stepError: steps.error,\n attemptStatus: stepAttempts.status,\n attemptError: stepAttempts.error,\n attemptExitCode: stepAttempts.exitCode,\n })\n .from(jobExecutions)\n .innerJoin(steps, eq(steps.jobExecutionId, jobExecutions.id))\n .leftJoin(\n stepAttempts,\n and(eq(stepAttempts.stepId, steps.id), eq(stepAttempts.attempt, steps.currentAttempt)),\n )\n .where(eq(jobExecutions.id, jobExecutionId))\n .orderBy(\n desc(\n sql<number>`case when ${steps.status} = 'failed' or ${stepAttempts.status} = 'failed' or ${steps.statusReason} = 'condition_errored' then 1 else 0 end`,\n ),\n asc(steps.position),\n asc(steps.id),\n )\n .limit(1);\n\n const row = rows[0];\n if (!row) return undefined;\n\n return {\n ...row,\n stepError: (row.stepError as Record<string, unknown> | null) ?? null,\n attemptError: (row.attemptError as Record<string, unknown> | null) ?? null,\n attemptStatus: row.attemptStatus === null ? null : (row.attemptStatus as StepAttemptStatus),\n attemptExitCode: row.attemptExitCode ?? null,\n };\n}\n\nexport async function getStepAttemptDetail(params: {\n stepId: string;\n attempt: number;\n}): Promise<StepAttemptDetail | undefined> {\n const rows = await db()\n .select({\n workflowRunId: workflowRuns.id,\n workflowRunAttemptId: workflowRunAttempts.id,\n step: steps,\n stepAttempt: stepAttempts,\n })\n .from(stepAttempts)\n .innerJoin(steps, eq(stepAttempts.stepId, steps.id))\n .innerJoin(jobExecutions, eq(steps.jobExecutionId, jobExecutions.id))\n .innerJoin(jobs, eq(jobExecutions.jobId, jobs.id))\n .innerJoin(workflowRunAttempts, eq(jobs.workflowRunAttemptId, workflowRunAttempts.id))\n .innerJoin(workflowRuns, eq(workflowRunAttempts.workflowRunId, workflowRuns.id))\n .where(and(eq(stepAttempts.stepId, params.stepId), eq(stepAttempts.attempt, params.attempt)))\n .limit(1);\n\n const row = rows[0];\n if (!row) return undefined;\n\n return {\n workflowRunId: row.workflowRunId,\n workflowRunAttemptId: row.workflowRunAttemptId,\n step: toStep(row.step),\n attempt: toStepAttempt(row.stepAttempt),\n };\n}\n\nexport async function getStepsByJobId(jobId: string): Promise<Step[]> {\n const rows = await db()\n .select({step: steps})\n .from(steps)\n .innerJoin(jobExecutions, eq(steps.jobExecutionId, jobExecutions.id))\n .where(eq(jobExecutions.jobId, jobId))\n .orderBy(asc(steps.position));\n return rows.map((row) => toStep(row.step));\n}\n\nexport async function getStepsByJobExecutionId(jobExecutionId: string): Promise<Step[]> {\n const rows = await db()\n .select()\n .from(steps)\n .where(eq(steps.jobExecutionId, jobExecutionId))\n .orderBy(asc(steps.position));\n return rows.map(toStep);\n}\n\nexport interface BulkUpdateStepStatusesParams {\n jobExecutionId: string;\n status: Extract<StepStatus, 'failed' | 'cancelled'>;\n}\n\nexport async function bulkUpdateStepStatuses(\n params: BulkUpdateStepStatusesParams,\n tx?: Tx,\n): Promise<void> {\n if (!tx) {\n await db().transaction((transaction) => bulkUpdateStepStatuses(params, transaction));\n return;\n }\n\n await tx\n .update(steps)\n .set({\n status: params.status,\n statusReason: null,\n updatedAt: new Date(),\n })\n .where(and(eq(steps.jobExecutionId, params.jobExecutionId), NON_TERMINAL_STEP_STATUS_FILTER));\n\n // Finalize open attempt rows so a timed-out/cancelled sweep does not leave\n // phantom in-flight work for gate and restart logic.\n const finalizedAttempts = await tx\n .update(stepAttempts)\n .set({status: params.status, logOutcome: 'abandoned', finishedAt: new Date()})\n .from(steps)\n .where(\n and(\n eq(stepAttempts.stepId, steps.id),\n eq(steps.jobExecutionId, params.jobExecutionId),\n eq(stepAttempts.status, 'running'),\n ),\n )\n .returning({\n id: stepAttempts.id,\n stepId: stepAttempts.stepId,\n attempt: stepAttempts.attempt,\n logOutcome: stepAttempts.logOutcome,\n });\n\n if (finalizedAttempts.length > 0) {\n for (const attempt of finalizedAttempts) {\n await writeStepAttemptTerminatedOutbox(tx, {\n stepAttemptId: attempt.id,\n stepId: attempt.stepId,\n attempt: attempt.attempt,\n status: params.status,\n logOutcome: attempt.logOutcome ?? 'abandoned',\n });\n }\n }\n}\n\n// Per-step progression primitives. They take a mandatory `tx` because they only\n// run inside the job-execution service's transaction, and every write guards on\n// the never-downgrade predicate so a late or duplicate write cannot overwrite an\n// already-terminal row.\n\nexport async function getStepsByJobExecutionIdForUpdate(\n jobExecutionId: string,\n tx: Tx,\n): Promise<Step[]> {\n const rows = await tx\n .select()\n .from(steps)\n .where(eq(steps.jobExecutionId, jobExecutionId))\n .orderBy(asc(steps.position))\n .for('update');\n return rows.map(toStep);\n}\n\nexport async function getStepAttemptsByJobExecutionId(\n jobExecutionId: string,\n tx: Tx,\n): Promise<StepAttempt[]> {\n const rows = await tx\n .select()\n .from(stepAttempts)\n .where(eq(stepAttempts.jobExecutionId, jobExecutionId))\n .orderBy(asc(stepAttempts.executionOrder), asc(stepAttempts.id));\n return rows.map(toStepAttempt);\n}\n\nexport interface MarkStepRunningParams {\n jobExecutionId: string;\n stepId: string;\n}\n\nexport async function markStepRunning(params: MarkStepRunningParams, tx: Tx): Promise<Step | null> {\n const rows = await tx\n .update(steps)\n .set({\n status: 'running',\n statusReason: null,\n evaluationTrace: null,\n updatedAt: new Date(),\n })\n .where(\n and(\n eq(steps.id, params.stepId),\n eq(steps.jobExecutionId, params.jobExecutionId),\n NON_TERMINAL_STEP_STATUS_FILTER,\n ),\n )\n .returning();\n const row = rows[0];\n if (!row) return null;\n const step = toStep(row);\n // Open the attempt this dispatch runs. onConflictDoNothing makes a racing\n // re-dispatch a no-op against the unique (step_id, attempt) anchor; normal\n // re-delivery returns the already-running step without calling this.\n await insertRunningStepAttempt(\n {\n jobExecutionId: step.jobExecutionId,\n stepId: step.id,\n attempt: step.currentAttempt,\n config: step.config,\n },\n tx,\n );\n return step;\n}\n\nexport interface DispatchStepWithCompletedConfigParams {\n jobExecutionId: string;\n stepId: string;\n config: Record<string, unknown>;\n evaluationTrace: readonly PersistedEvaluationTraceEntry[] | null;\n}\n\nexport async function dispatchStepWithCompletedConfig(\n params: DispatchStepWithCompletedConfigParams,\n tx: Tx,\n): Promise<Step | null> {\n const rows = await tx\n .update(steps)\n .set({\n status: 'running',\n statusReason: null,\n evaluationTrace: null,\n config: params.config,\n updatedAt: new Date(),\n })\n .where(\n and(\n eq(steps.id, params.stepId),\n eq(steps.jobExecutionId, params.jobExecutionId),\n NON_TERMINAL_STEP_STATUS_FILTER,\n ),\n )\n .returning();\n const row = rows[0];\n if (!row) return null;\n const step = toStep(row);\n await insertRunningStepAttempt(\n {\n jobExecutionId: step.jobExecutionId,\n stepId: step.id,\n attempt: step.currentAttempt,\n config: params.config,\n evaluationTrace: params.evaluationTrace,\n },\n tx,\n );\n return step;\n}\n\nexport interface MarkStepSkippedParams {\n jobExecutionId: string;\n stepId: string;\n statusReason: StepStatusReason;\n evaluationTrace: readonly PersistedEvaluationTraceEntry[];\n}\n\nexport async function markStepSkipped(params: MarkStepSkippedParams, tx: Tx): Promise<Step | null> {\n const rows = await tx\n .update(steps)\n .set({\n status: 'skipped',\n statusReason: params.statusReason,\n evaluationTrace: params.evaluationTrace,\n error: null,\n updatedAt: new Date(),\n })\n .where(\n and(\n eq(steps.id, params.stepId),\n eq(steps.jobExecutionId, params.jobExecutionId),\n eq(steps.status, 'pending'),\n ),\n )\n .returning();\n const row = rows[0];\n return row ? toStep(row) : null;\n}\n\nexport async function settleJobFailed(\n tx: Tx,\n params: {\n jobId: string;\n jobExecutionId: string;\n failedStepId: string;\n error: Record<string, unknown>;\n },\n): Promise<'succeeded' | 'failed' | null> {\n await applyStepResult(\n {\n jobExecutionId: params.jobExecutionId,\n stepId: params.failedStepId,\n status: 'failed',\n error: params.error,\n },\n tx,\n );\n\n const after = await getStepsByJobExecutionIdForUpdate(params.jobExecutionId, tx);\n if (!after.every((step) => isTerminal(step.status))) return null;\n\n const status = deriveCompletion(after);\n await writeJobStepsSettledOutbox(tx, {\n jobId: params.jobId,\n jobExecutionId: params.jobExecutionId,\n status,\n });\n return status;\n}\n\nexport interface InsertRunningStepAttemptParams {\n jobExecutionId: string;\n stepId: string;\n attempt: number;\n config?: Record<string, unknown> | null;\n evaluationTrace?: readonly PersistedEvaluationTraceEntry[] | null;\n}\n\nexport async function insertRunningStepAttempt(\n params: InsertRunningStepAttemptParams,\n tx: Tx,\n): Promise<void> {\n const [{nextExecutionOrder} = {nextExecutionOrder: 1}] = await tx\n .select({\n nextExecutionOrder: sql<number>`coalesce(max(${stepAttempts.executionOrder}), 0) + 1`,\n })\n .from(stepAttempts)\n .where(eq(stepAttempts.jobExecutionId, params.jobExecutionId));\n\n await tx\n .insert(stepAttempts)\n .values({\n jobExecutionId: params.jobExecutionId,\n stepId: params.stepId,\n attempt: params.attempt,\n executionOrder: nextExecutionOrder,\n status: 'running',\n config: params.config ?? null,\n evaluationTrace: params.evaluationTrace ?? null,\n })\n .onConflictDoNothing({target: [stepAttempts.stepId, stepAttempts.attempt]});\n}\n\nexport interface FinishStepAttemptParams {\n stepId: string;\n attempt: number;\n status: Exclude<StepAttemptStatus, 'running'>;\n error?: Record<string, unknown> | null;\n output?: Record<string, unknown> | null;\n response?: string | null;\n exitCode?: number | null;\n logOutcome: LogOutcomeDto;\n gateResult?: Record<string, unknown> | null;\n restartFeedback?: string | null;\n}\n\n// Finalize the running attempt to a terminal state. The `status='running'` guard\n// makes this idempotent: a duplicate report finds the attempt already terminal\n// and updates nothing (never-downgrade for the audit row).\nexport async function finishStepAttempt(params: FinishStepAttemptParams, tx: Tx): Promise<void> {\n const rows = await tx\n .update(stepAttempts)\n .set({\n status: params.status,\n output: params.output ?? null,\n response: params.response ?? null,\n error: params.error ?? null,\n exitCode: params.exitCode ?? null,\n logOutcome: params.logOutcome,\n gateResult: params.gateResult ?? null,\n restartFeedback: params.restartFeedback ?? null,\n finishedAt: new Date(),\n })\n .where(\n and(\n eq(stepAttempts.stepId, params.stepId),\n eq(stepAttempts.attempt, params.attempt),\n eq(stepAttempts.status, 'running'),\n ),\n )\n .returning({\n id: stepAttempts.id,\n stepId: stepAttempts.stepId,\n attempt: stepAttempts.attempt,\n logOutcome: stepAttempts.logOutcome,\n });\n\n const row = rows[0];\n if (!row) return;\n\n await writeStepAttemptTerminatedOutbox(tx, {\n stepAttemptId: row.id,\n stepId: row.stepId,\n attempt: row.attempt,\n status: params.status,\n logOutcome: row.logOutcome ?? params.logOutcome,\n });\n}\n\nexport interface RewindStepsToPendingParams {\n jobExecutionId: string;\n fromPosition: number;\n}\n\n// Restart-only: rewind every step at or after `fromPosition` back to pending,\n// clearing its result and bumping both `version` and `current_attempt` so the next\n// dispatch opens a fresh attempt. This DELIBERATELY bypasses the never-downgrade\n// guard used everywhere else. It is the one place that resurrects terminal steps,\n// so it must only be called from the durable-restart path, never the ordinary\n// report path. It must run in the same transaction as the failed-attempt write.\nexport async function rewindStepsToPending(\n params: RewindStepsToPendingParams,\n tx: Tx,\n): Promise<void> {\n await tx\n .update(steps)\n .set({\n status: 'pending',\n statusReason: null,\n error: null,\n version: sql`${steps.version} + 1`,\n currentAttempt: sql`${steps.currentAttempt} + 1`,\n updatedAt: new Date(),\n })\n .where(\n and(\n eq(steps.jobExecutionId, params.jobExecutionId),\n gte(steps.position, params.fromPosition),\n ),\n );\n}\n\n// Count a single step's own attempts. Used to bound the restart cap on the\n// gating step's actual executions: `steps.current_attempt` can't be used for\n// the cap because a rewind also bumps it for downstream steps swept into the\n// rewind range (which would inflate a later gate's cap in a multi-gate job).\nexport async function countStepAttempts(stepId: string, tx: Tx): Promise<number> {\n const rows = await tx\n .select({total: count()})\n .from(stepAttempts)\n .where(eq(stepAttempts.stepId, stepId));\n return Number(rows[0]?.total ?? 0);\n}\n\nexport async function getStepAttempts(jobId: string): Promise<StepAttempt[]> {\n const rows = await db()\n .select({stepAttempt: stepAttempts})\n .from(stepAttempts)\n .innerJoin(steps, eq(stepAttempts.stepId, steps.id))\n .innerJoin(jobExecutions, eq(steps.jobExecutionId, jobExecutions.id))\n .where(eq(jobExecutions.jobId, jobId))\n .orderBy(asc(stepAttempts.executionOrder));\n return rows.map((row) => toStepAttempt(row.stepAttempt));\n}\n\n/**\n * Lists only the step attempt ids of a job, without materializing the full\n * attempt entities. The session release sweep only needs the ids to release\n * claims, so this keeps the per-job-terminated query off a full-row projection.\n */\nexport async function listStepAttemptIdsByJobId(jobId: string): Promise<string[]> {\n const rows = await db()\n .select({id: stepAttempts.id})\n .from(stepAttempts)\n .innerJoin(steps, eq(stepAttempts.stepId, steps.id))\n .innerJoin(jobExecutions, eq(steps.jobExecutionId, jobExecutions.id))\n .where(eq(jobExecutions.jobId, jobId));\n return rows.map((row) => row.id);\n}\n\nexport async function getStepAttemptsByJobIds(jobIds: string[]): Promise<StepAttempt[]> {\n if (jobIds.length === 0) return [];\n const rows = await db()\n .select({stepAttempt: stepAttempts, jobId: jobExecutions.jobId})\n .from(stepAttempts)\n .innerJoin(steps, eq(stepAttempts.stepId, steps.id))\n .innerJoin(jobExecutions, eq(steps.jobExecutionId, jobExecutions.id))\n .where(inArray(jobExecutions.jobId, jobIds))\n .orderBy(asc(jobExecutions.jobId), asc(stepAttempts.executionOrder));\n return rows.map((row) => toStepAttempt(row.stepAttempt));\n}\n\nexport interface ApplyStepResultParams {\n jobExecutionId: string;\n stepId: string;\n status: 'succeeded' | 'failed';\n error: Record<string, unknown> | null;\n}\n\nexport async function applyStepResult(params: ApplyStepResultParams, tx: Tx): Promise<void> {\n await tx\n .update(steps)\n .set({\n status: params.status,\n statusReason: null,\n error: params.error ?? null,\n updatedAt: new Date(),\n })\n .where(\n and(\n eq(steps.id, params.stepId),\n eq(steps.jobExecutionId, params.jobExecutionId),\n NON_TERMINAL_STEP_STATUS_FILTER,\n ),\n );\n}\n\nexport interface CancelRemainingStepsParams {\n jobExecutionId: string;\n}\n\nexport async function cancelRemainingSteps(\n params: CancelRemainingStepsParams,\n tx: Tx,\n): Promise<void> {\n await bulkUpdateStepStatuses({jobExecutionId: params.jobExecutionId, status: 'cancelled'}, tx);\n}\n"],"names":["and","asc","count","desc","eq","gte","inArray","sql","deriveCompletion","isTerminal","db","jobExecutions","jobs","stepAttempts","toStepAttempt","steps","toStep","workflowRunAttempts","workflowRuns","writeJobStepsSettledOutbox","writeStepAttemptTerminatedOutbox","NON_TERMINAL_STEP_STATUS_FILTER","getStepByIdForJobExecution","params","rows","select","from","where","id","stepId","jobExecutionId","limit","row","undefined","getStepById","getJobExecutionFailureOrigin","stepName","name","stepStatus","status","stepAttempt","currentAttempt","stepError","error","attemptStatus","attemptError","attemptExitCode","exitCode","innerJoin","leftJoin","attempt","orderBy","statusReason","position","getStepAttemptDetail","workflowRunId","workflowRunAttemptId","step","jobId","getStepsByJobId","map","getStepsByJobExecutionId","bulkUpdateStepStatuses","tx","transaction","update","set","updatedAt","Date","finalizedAttempts","logOutcome","finishedAt","returning","length","stepAttemptId","getStepsByJobExecutionIdForUpdate","for","getStepAttemptsByJobExecutionId","executionOrder","markStepRunning","evaluationTrace","insertRunningStepAttempt","config","dispatchStepWithCompletedConfig","markStepSkipped","settleJobFailed","applyStepResult","failedStepId","after","every","nextExecutionOrder","insert","values","onConflictDoNothing","target","finishStepAttempt","output","response","gateResult","restartFeedback","rewindStepsToPending","version","fromPosition","countStepAttempts","total","Number","getStepAttempts","listStepAttemptIdsByJobId","getStepAttemptsByJobIds","jobIds","cancelRemainingSteps"],"mappings":"AACA,SAAQA,GAAG,EAAEC,GAAG,EAAEC,KAAK,EAAEC,IAAI,EAAEC,EAAE,EAAEC,GAAG,EAAEC,OAAO,EAAEC,GAAG,QAAO,cAAc;AASzE,SAAQC,gBAAgB,EAAEC,UAAU,QAAO,kDAAkD;AAC7F,SAAQC,EAAE,QAAgB,WAAW;AACrC,SAAQC,aAAa,QAAO,8BAA8B;AAC1D,SAAQC,IAAI,QAAO,oBAAoB;AACvC,SAAQC,YAAY,EAAEC,aAAa,QAAO,6BAA6B;AACvE,SAAQC,KAAK,EAAEC,MAAM,QAAO,qBAAqB;AACjD,SAAQC,mBAAmB,QAAO,qCAAqC;AACvE,SAAQC,YAAY,QAAO,6BAA6B;AACxD,SAAQC,0BAA0B,EAAEC,gCAAgC,QAAO,cAAc;AACzF,SAAQC,+BAA+B,QAAO,cAAc;AAE5D,OAAO,eAAeC,2BAA2BC,MAGhD;IACC,MAAMC,OAAO,MAAMd,KAChBe,MAAM,GACNC,IAAI,CAACX,OACLY,KAAK,CAAC3B,IAAII,GAAGW,MAAMa,EAAE,EAAEL,OAAOM,MAAM,GAAGzB,GAAGW,MAAMe,cAAc,EAAEP,OAAOO,cAAc,IACrFC,KAAK,CAAC;IAET,MAAMC,MAAMR,IAAI,CAAC,EAAE;IACnB,IAAI,CAACQ,KAAK,OAAOC;IACjB,OAAOjB,OAAOgB;AAChB;AAEA,OAAO,eAAeE,YAAYL,MAAc;IAC9C,MAAML,OAAO,MAAMd,KAAKe,MAAM,GAAGC,IAAI,CAACX,OAAOY,KAAK,CAACvB,GAAGW,MAAMa,EAAE,EAAEC,SAASE,KAAK,CAAC;IAE/E,MAAMC,MAAMR,IAAI,CAAC,EAAE;IACnB,IAAI,CAACQ,KAAK,OAAOC;IACjB,OAAOjB,OAAOgB;AAChB;AAqBA;;;;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AAc,GAC9CT;AAGR;AAMA,OAAO,eAAeyF,qBACpBvF,MAAkC,EAClCwC,EAAM;IAEN,MAAMD,uBAAuB;QAAChC,gBAAgBP,OAAOO,cAAc;QAAES,QAAQ;IAAW,GAAGwB;AAC7F"}
|
|
@@ -9,5 +9,5 @@ export type { CancelWorkflowRunParams, CreateRerunWorkflowRunParams, CreateWorkf
|
|
|
9
9
|
export { cancelWorkflowRun, createRerunWorkflowRun, createWorkflowRun, failWorkflowRunAsTimedOut, loadReferencedVariables, updateWorkflowRunStatus, } from './workflow-runs/runs.js';
|
|
10
10
|
export { getWorkflowContextForJob } from './workflow-runs/shared.js';
|
|
11
11
|
export type { ApplyStepResultParams, BulkUpdateStepStatusesParams, CancelRemainingStepsParams, DispatchStepWithCompletedConfigParams, FinishStepAttemptParams, InsertRunningStepAttemptParams, JobExecutionFailureOrigin, MarkStepRunningParams, MarkStepSkippedParams, RewindStepsToPendingParams, StepAttemptDetail, } from './workflow-runs/steps.js';
|
|
12
|
-
export { applyStepResult, bulkUpdateStepStatuses, cancelRemainingSteps, countStepAttempts, dispatchStepWithCompletedConfig, finishStepAttempt, getJobExecutionFailureOrigin, getStepAttemptDetail, getStepAttempts, getStepAttemptsByJobExecutionId, getStepAttemptsByJobIds, getStepById, getStepByIdForJobExecution, getStepsByJobExecutionId, getStepsByJobExecutionIdForUpdate, getStepsByJobId, insertRunningStepAttempt, markStepRunning, markStepSkipped, rewindStepsToPending, settleJobFailed, } from './workflow-runs/steps.js';
|
|
12
|
+
export { applyStepResult, bulkUpdateStepStatuses, cancelRemainingSteps, countStepAttempts, dispatchStepWithCompletedConfig, finishStepAttempt, getJobExecutionFailureOrigin, getStepAttemptDetail, getStepAttempts, getStepAttemptsByJobExecutionId, getStepAttemptsByJobIds, getStepById, getStepByIdForJobExecution, getStepsByJobExecutionId, getStepsByJobExecutionIdForUpdate, getStepsByJobId, insertRunningStepAttempt, listStepAttemptIdsByJobId, markStepRunning, markStepSkipped, rewindStepsToPending, settleJobFailed, } from './workflow-runs/steps.js';
|
|
13
13
|
//# sourceMappingURL=workflow-runs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-runs.d.ts","sourceRoot":"","sources":["../../src/db/workflow-runs.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,uCAAuC,EACvC,8BAA8B,GAC/B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,mBAAmB,EACnB,uBAAuB,EACvB,sCAAsC,EACtC,4BAA4B,EAC5B,iBAAiB,EACjB,2BAA2B,EAC3B,mCAAmC,EACnC,wBAAwB,GACzB,MAAM,mCAAmC,CAAC;AAC3C,YAAY,EACV,4BAA4B,EAC5B,wBAAwB,EACxB,qBAAqB,EACrB,QAAQ,EACR,8BAA8B,EAC9B,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,8BAA8B,EAC9B,UAAU,EACV,WAAW,EACX,6BAA6B,EAC7B,sBAAsB,EACtB,iCAAiC,EACjC,eAAe,EACf,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,6BAA6B,EAC7B,iCAAiC,EACjC,0BAA0B,EAC1B,gCAAgC,EAChC,8BAA8B,GAC/B,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,EACzB,+BAA+B,EAC/B,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,4BAA4B,EAC5B,yBAAyB,EACzB,qBAAqB,EACrB,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,8BAA8B,EAC9B,qBAAqB,EACrB,gBAAgB,EAChB,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,2BAA2B,EAC3B,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,uBAAuB,EACvB,4BAA4B,EAC5B,uBAAuB,EACvB,+BAA+B,EAC/B,6BAA6B,GAC9B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,iBAAiB,EACjB,yBAAyB,EACzB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAC,wBAAwB,EAAC,MAAM,2BAA2B,CAAC;AACnE,YAAY,EACV,qBAAqB,EACrB,4BAA4B,EAC5B,0BAA0B,EAC1B,qCAAqC,EACrC,uBAAuB,EACvB,8BAA8B,EAC9B,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACpB,iBAAiB,EACjB,+BAA+B,EAC/B,iBAAiB,EACjB,4BAA4B,EAC5B,oBAAoB,EACpB,eAAe,EACf,+BAA+B,EAC/B,uBAAuB,EACvB,WAAW,EACX,0BAA0B,EAC1B,wBAAwB,EACxB,iCAAiC,EACjC,eAAe,EACf,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,eAAe,GAChB,MAAM,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"workflow-runs.d.ts","sourceRoot":"","sources":["../../src/db/workflow-runs.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,uCAAuC,EACvC,8BAA8B,GAC/B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,mBAAmB,EACnB,uBAAuB,EACvB,sCAAsC,EACtC,4BAA4B,EAC5B,iBAAiB,EACjB,2BAA2B,EAC3B,mCAAmC,EACnC,wBAAwB,GACzB,MAAM,mCAAmC,CAAC;AAC3C,YAAY,EACV,4BA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yB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACpB,iBAAiB,EACjB,+BAA+B,EAC/B,iBAAiB,EACjB,4BAA4B,EAC5B,oBAAoB,EACpB,eAAe,EACf,+BAA+B,EAC/B,uBAAuB,EACvB,WAAW,EACX,0BAA0B,EAC1B,wBAAwB,EACxB,iCAAiC,EACjC,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,eAAe,GAChB,MAAM,0BAA0B,CAAC"}
|
package/dist/db/workflow-runs.js
CHANGED
|
@@ -4,6 +4,6 @@ export { writeJobExecutionQueuedOutbox, writeJobExecutionTerminatedOutbox, write
|
|
|
4
4
|
export { buildWorkflowRunListConditions, getJobExecutionDetail, getLatestAttempt, getWorkflowJobExecutionDepth, getWorkflowRunAggregates, getWorkflowRunAttemptById, getWorkflowRunByAttemptId, getWorkflowRunById, getWorkflowRunDetail, listRunAttempts, listWorkflowRunJobSummaries, listWorkflowRuns, listWorkflowRunsByProject } from './workflow-runs/queries.js';
|
|
5
5
|
export { cancelWorkflowRun, createRerunWorkflowRun, createWorkflowRun, failWorkflowRunAsTimedOut, loadReferencedVariables, updateWorkflowRunStatus } from './workflow-runs/runs.js';
|
|
6
6
|
export { getWorkflowContextForJob } from './workflow-runs/shared.js';
|
|
7
|
-
export { applyStepResult, bulkUpdateStepStatuses, cancelRemainingSteps, countStepAttempts, dispatchStepWithCompletedConfig, finishStepAttempt, getJobExecutionFailureOrigin, getStepAttemptDetail, getStepAttempts, getStepAttemptsByJobExecutionId, getStepAttemptsByJobIds, getStepById, getStepByIdForJobExecution, getStepsByJobExecutionId, getStepsByJobExecutionIdForUpdate, getStepsByJobId, insertRunningStepAttempt, markStepRunning, markStepSkipped, rewindStepsToPending, settleJobFailed } from './workflow-runs/steps.js';
|
|
7
|
+
export { applyStepResult, bulkUpdateStepStatuses, cancelRemainingSteps, countStepAttempts, dispatchStepWithCompletedConfig, finishStepAttempt, getJobExecutionFailureOrigin, getStepAttemptDetail, getStepAttempts, getStepAttemptsByJobExecutionId, getStepAttemptsByJobIds, getStepById, getStepByIdForJobExecution, getStepsByJobExecutionId, getStepsByJobExecutionIdForUpdate, getStepsByJobId, insertRunningStepAttempt, listStepAttemptIdsByJobId, markStepRunning, markStepSkipped, rewindStepsToPending, settleJobFailed } from './workflow-runs/steps.js';
|
|
8
8
|
|
|
9
9
|
//# sourceMappingURL=workflow-runs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/db/workflow-runs.ts"],"sourcesContent":["export type {\n UpdateJobExecutionStatusAtVersionParams,\n UpdateJobExecutionStatusParams,\n} from './workflow-runs/job-executions.js';\nexport {\n failJobExecutionAsTimedOut,\n getFirstJobExecutionByJobId,\n getJobExecutionById,\n getJobExecutionsByJobId,\n getJobExecutionsByWorkflowRunAttemptId,\n getLatestJobExecutionByJobId,\n queueJobExecution,\n recordJobExecutionStartedAt,\n resolveJobExecutionAfterLeaseExpiry,\n updateJobExecutionStatus,\n} from './workflow-runs/job-executions.js';\nexport type {\n EvaluateJobActivationsParams,\n EvaluateJobSuccessResult,\n JobActivationDecision,\n JobScope,\n UpdateJobStatusAtVersionParams,\n UpdateJobStatusParams,\n} from './workflow-runs/jobs.js';\nexport {\n evaluateJobActivations,\n evaluateJobSuccess,\n getDirectDependencyJobContexts,\n getJobById,\n getJobScope,\n getJobsByWorkflowRunAttemptId,\n getJobsByWorkflowRunId,\n resolveJobStatusFromJobExecutions,\n updateJobStatus,\n updateJobStatusAtVersion,\n} from './workflow-runs/jobs.js';\nexport {\n writeJobExecutionQueuedOutbox,\n writeJobExecutionTerminatedOutbox,\n writeJobStepsSettledOutbox,\n writeStepAttemptTerminatedOutbox,\n writeStepRestartEnqueuedOutbox,\n} from './workflow-runs/outbox.js';\nexport type {\n ListWorkflowRunsParams,\n ListWorkflowRunsResult,\n WorkflowJobExecutionDepth,\n WorkflowJobExecutionDepthParams,\n WorkflowRunAggregates,\n WorkflowRunCursor,\n WorkflowRunFilters,\n WorkflowRunJobRawStatusCount,\n WorkflowRunJobStatusCount,\n WorkflowRunJobSummary,\n WorkflowRunJobSummaryTarget,\n WorkflowRunJobsSummary,\n} from './workflow-runs/queries.js';\nexport {\n buildWorkflowRunListConditions,\n getJobExecutionDetail,\n getLatestAttempt,\n getWorkflowJobExecutionDepth,\n getWorkflowRunAggregates,\n getWorkflowRunAttemptById,\n getWorkflowRunByAttemptId,\n getWorkflowRunById,\n getWorkflowRunDetail,\n listRunAttempts,\n listWorkflowRunJobSummaries,\n listWorkflowRuns,\n listWorkflowRunsByProject,\n} from './workflow-runs/queries.js';\nexport type {\n CancelWorkflowRunParams,\n CreateRerunWorkflowRunParams,\n CreateWorkflowRunParams,\n FailWorkflowRunAsTimedOutParams,\n UpdateWorkflowRunStatusParams,\n} from './workflow-runs/runs.js';\nexport {\n cancelWorkflowRun,\n createRerunWorkflowRun,\n createWorkflowRun,\n failWorkflowRunAsTimedOut,\n loadReferencedVariables,\n updateWorkflowRunStatus,\n} from './workflow-runs/runs.js';\nexport {getWorkflowContextForJob} from './workflow-runs/shared.js';\nexport type {\n ApplyStepResultParams,\n BulkUpdateStepStatusesParams,\n CancelRemainingStepsParams,\n DispatchStepWithCompletedConfigParams,\n FinishStepAttemptParams,\n InsertRunningStepAttemptParams,\n JobExecutionFailureOrigin,\n MarkStepRunningParams,\n MarkStepSkippedParams,\n RewindStepsToPendingParams,\n StepAttemptDetail,\n} from './workflow-runs/steps.js';\nexport {\n applyStepResult,\n bulkUpdateStepStatuses,\n cancelRemainingSteps,\n countStepAttempts,\n dispatchStepWithCompletedConfig,\n finishStepAttempt,\n getJobExecutionFailureOrigin,\n getStepAttemptDetail,\n getStepAttempts,\n getStepAttemptsByJobExecutionId,\n getStepAttemptsByJobIds,\n getStepById,\n getStepByIdForJobExecution,\n getStepsByJobExecutionId,\n getStepsByJobExecutionIdForUpdate,\n getStepsByJobId,\n insertRunningStepAttempt,\n markStepRunning,\n markStepSkipped,\n rewindStepsToPending,\n settleJobFailed,\n} from './workflow-runs/steps.js';\n"],"names":["failJobExecutionAsTimedOut","getFirstJobExecutionByJobId","getJobExecutionById","getJobExecutionsByJobId","getJobExecutionsByWorkflowRunAttemptId","getLatestJobExecutionByJobId","queueJobExecution","recordJobExecutionStartedAt","resolveJobExecutionAfterLeaseExpiry","updateJobExecutionStatus","evaluateJobActivations","evaluateJobSuccess","getDirectDependencyJobContexts","getJobById","getJobScope","getJobsByWorkflowRunAttemptId","getJobsByWorkflowRunId","resolveJobStatusFromJobExecutions","updateJobStatus","updateJobStatusAtVersion","writeJobExecutionQueuedOutbox","writeJobExecutionTerminatedOutbox","writeJobStepsSettledOutbox","writeStepAttemptTerminatedOutbox","writeStepRestartEnqueuedOutbox","buildWorkflowRunListConditions","getJobExecutionDetail","getLatestAttempt","getWorkflowJobExecutionDepth","getWorkflowRunAggregates","getWorkflowRunAttemptById","getWorkflowRunByAttemptId","getWorkflowRunById","getWorkflowRunDetail","listRunAttempts","listWorkflowRunJobSummaries","listWorkflowRuns","listWorkflowRunsByProject","cancelWorkflowRun","createRerunWorkflowRun","createWorkflowRun","failWorkflowRunAsTimedOut","loadReferencedVariables","updateWorkflowRunStatus","getWorkflowContextForJob","applyStepResult","bulkUpdateStepStatuses","cancelRemainingSteps","countStepAttempts","dispatchStepWithCompletedConfig","finishStepAttempt","getJobExecutionFailureOrigin","getStepAttemptDetail","getStepAttempts","getStepAttemptsByJobExecutionId","getStepAttemptsByJobIds","getStepById","getStepByIdForJobExecution","getStepsByJobExecutionId","getStepsByJobExecutionIdForUpdate","getStepsByJobId","insertRunningStepAttempt","markStepRunning","markStepSkipped","rewindStepsToPending","settleJobFailed"],"mappings":"AAIA,SACEA,0BAA0B,EAC1BC,2BAA2B,EAC3BC,mBAAmB,EACnBC,uBAAuB,EACvBC,sCAAsC,EACtCC,4BAA4B,EAC5BC,iBAAiB,EACjBC,2BAA2B,EAC3BC,mCAAmC,EACnCC,wBAAwB,QACnB,oCAAoC;AAS3C,SACEC,sBAAsB,EACtBC,kBAAkB,EAClBC,8BAA8B,EAC9BC,UAAU,EACVC,WAAW,EACXC,6BAA6B,EAC7BC,sBAAsB,EACtBC,iCAAiC,EACjCC,eAAe,EACfC,wBAAwB,QACnB,0BAA0B;AACjC,SACEC,6BAA6B,EAC7BC,iCAAiC,EACjCC,0BAA0B,EAC1BC,gCAAgC,EAChCC,8BAA8B,QACzB,4BAA4B;AAenC,SACEC,8BAA8B,EAC9BC,qBAAqB,EACrBC,gBAAgB,EAChBC,4BAA4B,EAC5BC,wBAAwB,EACxBC,yBAAyB,EACzBC,yBAAyB,EACzBC,kBAAkB,EAClBC,oBAAoB,EACpBC,eAAe,EACfC,2BAA2B,EAC3BC,gBAAgB,EAChBC,yBAAyB,QACpB,6BAA6B;AAQpC,SACEC,iBAAiB,EACjBC,sBAAsB,EACtBC,iBAAiB,EACjBC,yBAAyB,EACzBC,uBAAuB,EACvBC,uBAAuB,QAClB,0BAA0B;AACjC,SAAQC,wBAAwB,QAAO,4BAA4B;AAcnE,SACEC,eAAe,EACfC,sBAAsB,EACtBC,oBAAoB,EACpBC,iBAAiB,EACjBC,+BAA+B,EAC/BC,iBAAiB,EACjBC,4BAA4B,EAC5BC,oBAAoB,EACpBC,eAAe,EACfC,+BAA+B,EAC/BC,uBAAuB,EACvBC,WAAW,EACXC,0BAA0B,EAC1BC,wBAAwB,EACxBC,iCAAiC,EACjCC,eAAe,EACfC,wBAAwB,EACxBC,eAAe,EACfC,eAAe,EACfC,oBAAoB,EACpBC,eAAe,QACV,2BAA2B"}
|
|
1
|
+
{"version":3,"sources":["../../src/db/workflow-runs.ts"],"sourcesContent":["export type {\n UpdateJobExecutionStatusAtVersionParams,\n UpdateJobExecutionStatusParams,\n} from './workflow-runs/job-executions.js';\nexport {\n failJobExecutionAsTimedOut,\n getFirstJobExecutionByJobId,\n getJobExecutionById,\n getJobExecutionsByJobId,\n getJobExecutionsByWorkflowRunAttemptId,\n getLatestJobExecutionByJobId,\n queueJobExecution,\n recordJobExecutionStartedAt,\n resolveJobExecutionAfterLeaseExpiry,\n updateJobExecutionStatus,\n} from './workflow-runs/job-executions.js';\nexport type {\n EvaluateJobActivationsParams,\n EvaluateJobSuccessResult,\n JobActivationDecision,\n JobScope,\n UpdateJobStatusAtVersionParams,\n UpdateJobStatusParams,\n} from './workflow-runs/jobs.js';\nexport {\n evaluateJobActivations,\n evaluateJobSuccess,\n getDirectDependencyJobContexts,\n getJobById,\n getJobScope,\n getJobsByWorkflowRunAttemptId,\n getJobsByWorkflowRunId,\n resolveJobStatusFromJobExecutions,\n updateJobStatus,\n updateJobStatusAtVersion,\n} from './workflow-runs/jobs.js';\nexport {\n writeJobExecutionQueuedOutbox,\n writeJobExecutionTerminatedOutbox,\n writeJobStepsSettledOutbox,\n writeStepAttemptTerminatedOutbox,\n writeStepRestartEnqueuedOutbox,\n} from './workflow-runs/outbox.js';\nexport type {\n ListWorkflowRunsParams,\n ListWorkflowRunsResult,\n WorkflowJobExecutionDepth,\n WorkflowJobExecutionDepthParams,\n WorkflowRunAggregates,\n WorkflowRunCursor,\n WorkflowRunFilters,\n WorkflowRunJobRawStatusCount,\n WorkflowRunJobStatusCount,\n WorkflowRunJobSummary,\n WorkflowRunJobSummaryTarget,\n WorkflowRunJobsSummary,\n} from './workflow-runs/queries.js';\nexport {\n buildWorkflowRunListConditions,\n getJobExecutionDetail,\n getLatestAttempt,\n getWorkflowJobExecutionDepth,\n getWorkflowRunAggregates,\n getWorkflowRunAttemptById,\n getWorkflowRunByAttemptId,\n getWorkflowRunById,\n getWorkflowRunDetail,\n listRunAttempts,\n listWorkflowRunJobSummaries,\n listWorkflowRuns,\n listWorkflowRunsByProject,\n} from './workflow-runs/queries.js';\nexport type {\n CancelWorkflowRunParams,\n CreateRerunWorkflowRunParams,\n CreateWorkflowRunParams,\n FailWorkflowRunAsTimedOutParams,\n UpdateWorkflowRunStatusParams,\n} from './workflow-runs/runs.js';\nexport {\n cancelWorkflowRun,\n createRerunWorkflowRun,\n createWorkflowRun,\n failWorkflowRunAsTimedOut,\n loadReferencedVariables,\n updateWorkflowRunStatus,\n} from './workflow-runs/runs.js';\nexport {getWorkflowContextForJob} from './workflow-runs/shared.js';\nexport type {\n ApplyStepResultParams,\n BulkUpdateStepStatusesParams,\n CancelRemainingStepsParams,\n DispatchStepWithCompletedConfigParams,\n FinishStepAttemptParams,\n InsertRunningStepAttemptParams,\n JobExecutionFailureOrigin,\n MarkStepRunningParams,\n MarkStepSkippedParams,\n RewindStepsToPendingParams,\n StepAttemptDetail,\n} from './workflow-runs/steps.js';\nexport {\n applyStepResult,\n bulkUpdateStepStatuses,\n cancelRemainingSteps,\n countStepAttempts,\n dispatchStepWithCompletedConfig,\n finishStepAttempt,\n getJobExecutionFailureOrigin,\n getStepAttemptDetail,\n getStepAttempts,\n getStepAttemptsByJobExecutionId,\n getStepAttemptsByJobIds,\n getStepById,\n getStepByIdForJobExecution,\n getStepsByJobExecutionId,\n getStepsByJobExecutionIdForUpdate,\n getStepsByJobId,\n insertRunningStepAttempt,\n listStepAttemptIdsByJobId,\n markStepRunning,\n markStepSkipped,\n rewindStepsToPending,\n settleJobFailed,\n} from './workflow-runs/steps.js';\n"],"names":["failJobExecutionAsTimedOut","getFirstJobExecutionByJobId","getJobExecutionById","getJobExecutionsByJobId","getJobExecutionsByWorkflowRunAttemptId","getLatestJobExecutionByJobId","queueJobExecution","recordJobExecutionStartedAt","resolveJobExecutionAfterLeaseExpiry","updateJobExecutionStatus","evaluateJobActivations","evaluateJobSuccess","getDirectDependencyJobContexts","getJobById","getJobScope","getJobsByWorkflowRunAttemptId","getJobsByWorkflowRunId","resolveJobStatusFromJobExecutions","updateJobStatus","updateJobStatusAtVersion","writeJobExecutionQueuedOutbox","writeJobExecutionTerminatedOutbox","writeJobStepsSettledOutbox","writeStepAttemptTerminatedOutbox","writeStepRestartEnqueuedOutbox","buildWorkflowRunListConditions","getJobExecutionDetail","getLatestAttempt","getWorkflowJobExecutionDepth","getWorkflowRunAggregates","getWorkflowRunAttemptById","getWorkflowRunByAttemptId","getWorkflowRunById","getWorkflowRunDetail","listRunAttempts","listWorkflowRunJobSummaries","listWorkflowRuns","listWorkflowRunsByProject","cancelWorkflowRun","createRerunWorkflowRun","createWorkflowRun","failWorkflowRunAsTimedOut","loadReferencedVariables","updateWorkflowRunStatus","getWorkflowContextForJob","applyStepResult","bulkUpdateStepStatuses","cancelRemainingSteps","countStepAttempts","dispatchStepWithCompletedConfig","finishStepAttempt","getJobExecutionFailureOrigin","getStepAttemptDetail","getStepAttempts","getStepAttemptsByJobExecutionId","getStepAttemptsByJobIds","getStepById","getStepByIdForJobExecution","getStepsByJobExecutionId","getStepsByJobExecutionIdForUpdate","getStepsByJobId","insertRunningStepAttempt","listStepAttemptIdsByJobId","markStepRunning","markStepSkipped","rewindStepsToPending","settleJobFailed"],"mappings":"AAIA,SACEA,0BAA0B,EAC1BC,2BAA2B,EAC3BC,mBAAmB,EACnBC,uBAAuB,EACvBC,sCAAsC,EACtCC,4BAA4B,EAC5BC,iBAAiB,EACjBC,2BAA2B,EAC3BC,mCAAmC,EACnCC,wBAAwB,QACnB,oCAAoC;AAS3C,SACEC,sBAAsB,EACtBC,kBAAkB,EAClBC,8BAA8B,EAC9BC,UAAU,EACVC,WAAW,EACXC,6BAA6B,EAC7BC,sBAAsB,EACtBC,iCAAiC,EACjCC,eAAe,EACfC,wBAAwB,QACnB,0BAA0B;AACjC,SACEC,6BAA6B,EAC7BC,iCAAiC,EACjCC,0BAA0B,EAC1BC,gCAAgC,EAChCC,8BAA8B,QACzB,4BAA4B;AAenC,SACEC,8BAA8B,EAC9BC,qBAAqB,EACrBC,gBAAgB,EAChBC,4BAA4B,EAC5BC,wBAAwB,EACxBC,yBAAyB,EACzBC,yBAAyB,EACzBC,kBAAkB,EAClBC,oBAAoB,EACpBC,eAAe,EACfC,2BAA2B,EAC3BC,gBAAgB,EAChBC,yBAAyB,QACpB,6BAA6B;AAQpC,SACEC,iBAAiB,EACjBC,sBAAsB,EACtBC,iBAAiB,EACjBC,yBAAyB,EACzBC,uBAAuB,EACvBC,uBAAuB,QAClB,0BAA0B;AACjC,SAAQC,wBAAwB,QAAO,4BAA4B;AAcnE,SACEC,eAAe,EACfC,sBAAsB,EACtBC,oBAAoB,EACpBC,iBAAiB,EACjBC,+BAA+B,EAC/BC,iBAAiB,EACjBC,4BAA4B,EAC5BC,oBAAoB,EACpBC,eAAe,EACfC,+BAA+B,EAC/BC,uBAAuB,EACvBC,WAAW,EACXC,0BAA0B,EAC1BC,wBAAwB,EACxBC,iCAAiC,EACjCC,eAAe,EACfC,wBAAwB,EACxBC,yBAAyB,EACzBC,eAAe,EACfC,eAAe,EACfC,oBAAoB,EACpBC,eAAe,QACV,2BAA2B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inter-module.d.ts","sourceRoot":"","sources":["../../src/presentation/inter-module.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,2CAA2C,CAAC;AAC5F,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,gDAAgD,CAAC;AAC7F,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AACjF,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,uCAAuC,CAAC;AACpF,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,uCAAuC,CAAC;AACpF,OAAO,EAAC,4BAA4B,EAAC,MAAM,yCAAyC,CAAC;AACrF,OAAO,KAAK,EAAC,2BAA2B,EAAC,MAAM,0CAA0C,CAAC;AAC1F,OAAO,EAIL,KAAK,uBAAuB,EAC7B,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"inter-module.d.ts","sourceRoot":"","sources":["../../src/presentation/inter-module.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,2CAA2C,CAAC;AAC5F,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,gDAAgD,CAAC;AAC7F,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AACjF,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,uCAAuC,CAAC;AACpF,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,uCAAuC,CAAC;AACpF,OAAO,EAAC,4BAA4B,EAAC,MAAM,yCAAyC,CAAC;AACrF,OAAO,KAAK,EAAC,2BAA2B,EAAC,MAAM,0CAA0C,CAAC;AAC1F,OAAO,EAIL,KAAK,uBAAuB,EAC7B,MAAM,uBAAuB,CAAC;AAgC/B,wBAAgB,sCAAsC,CAAC,MAAM,EAAE;IAC7D,KAAK,EAAE,sBAAsB,CAAC;IAC9B,WAAW,EAAE,4BAA4B,CAAC;IAC1C,UAAU,EAAE,2BAA2B,CAAC;IACxC,OAAO,EAAE,IAAI,CAAC,wBAAwB,EAAE,yBAAyB,CAAC,CAAC;IACnE,OAAO,EAAE,wBAAwB,CAAC;IAClC,YAAY,EAAE,wBAAwB,CAAC;IACvC,QAAQ,EAAE,oBAAoB,CAAC;CAChC,GAAG,uBAAuB,CAAC,OAAO,4BAA4B,CAAC,CA2I/D;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAWlF;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE/D"}
|
|
@@ -6,7 +6,7 @@ import { InvalidJobRunnerLabelsError, WorkspaceDeletedError, WorkspaceNotFoundEr
|
|
|
6
6
|
import { AgentConfigUnresolvableError, AgentIntegrationMaterializationError, DefinitionNotFoundError, InterpolationUnresolvableError, ProjectMismatchError, runDevWorkflow, runWorkflow } from '#core/index.js';
|
|
7
7
|
import { resolveWorkflowRunTriggerReference } from '#core/resolve-trigger-reference.js';
|
|
8
8
|
import { assertWorkspaceAdmitsNewJobs } from '#core/workspace-admission.js';
|
|
9
|
-
import { getJobScope, getStepById, getStepByIdForJobExecution } from '#db/index.js';
|
|
9
|
+
import { getJobScope, getStepById, getStepByIdForJobExecution, listStepAttemptIdsByJobId } from '#db/index.js';
|
|
10
10
|
import { deliverEventToListener } from '#db/job-listener-events.js';
|
|
11
11
|
export function createWorkflowsInterModulePresentation(params) {
|
|
12
12
|
return defineInterModulePresentation(workflowsInterModuleContract, {
|
|
@@ -114,6 +114,11 @@ export function createWorkflowsInterModulePresentation(params) {
|
|
|
114
114
|
harness: parsed.success ? parsed.data : DEFAULT_HARNESS
|
|
115
115
|
};
|
|
116
116
|
},
|
|
117
|
+
listJobStepAttempts: async ({ jobId })=>{
|
|
118
|
+
return {
|
|
119
|
+
stepAttemptIds: await listStepAttemptIdsByJobId(jobId)
|
|
120
|
+
};
|
|
121
|
+
},
|
|
117
122
|
getLeasedAgentToolContext: async (input)=>{
|
|
118
123
|
const method = workflowsInterModuleContract.methods.getLeasedAgentToolContext;
|
|
119
124
|
const { active: leaseIsActive } = await params.runners.getLeaseState({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/presentation/inter-module.ts"],"sourcesContent":["import {materializedAgentStepConfigSchema} from '@shipfox/api-agent-dto';\nimport type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport type {DefinitionsInterModuleClient} from '@shipfox/api-definitions-dto/inter-module';\nimport type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto/inter-module';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';\nimport type {RunnersInterModuleClient} from '@shipfox/api-runners-dto/inter-module';\nimport type {SecretsInterModuleClient} from '@shipfox/api-secrets-dto/inter-module';\nimport {workflowsInterModuleContract} from '@shipfox/api-workflows-dto/inter-module';\nimport type {WorkspacesInterModuleClient} from '@shipfox/api-workspaces-dto/inter-module';\nimport {\n createInterModuleKnownError,\n defineInterModulePresentation,\n type InterModuleKnownErrorFor,\n type InterModulePresentation,\n} from '@shipfox/inter-module';\nimport {DEFAULT_HARNESS, harnessSchema} from '@shipfox/workflow-document';\nimport type {WorkflowRunTriggerReference} from '#core/entities/workflow-run.js';\nimport {\n InvalidJobRunnerLabelsError,\n WorkspaceDeletedError,\n WorkspaceNotFoundError,\n WorkspaceSuspendedError,\n} from '#core/errors.js';\nimport {\n AgentConfigUnresolvableError,\n AgentIntegrationMaterializationError,\n DefinitionNotFoundError,\n InterpolationUnresolvableError,\n ProjectMismatchError,\n runDevWorkflow,\n runWorkflow,\n} from '#core/index.js';\nimport {resolveWorkflowRunTriggerReference} from '#core/resolve-trigger-reference.js';\nimport {assertWorkspaceAdmitsNewJobs} from '#core/workspace-admission.js';\nimport {getJobScope, getStepById, getStepByIdForJobExecution} from '#db/index.js';\nimport {deliverEventToListener} from '#db/job-listener-events.js';\n\ntype WorkspaceAdmissionKnownError = InterModuleKnownErrorFor<\n typeof workflowsInterModuleContract.methods.deliverEventToJobListener\n>;\n\nexport function createWorkflowsInterModulePresentation(params: {\n agent: AgentInterModuleClient;\n definitions: DefinitionsInterModuleClient;\n workspaces: WorkspacesInterModuleClient;\n secrets: Pick<SecretsInterModuleClient, 'getVariablesByNamespace'>;\n runners: RunnersInterModuleClient;\n integrations: IntegrationsModuleClient;\n projects: ProjectsModuleClient;\n}): InterModulePresentation<typeof workflowsInterModuleContract> {\n return defineInterModulePresentation(workflowsInterModuleContract, {\n startRunFromTrigger: async (input) => {\n try {\n await assertWorkspaceAdmitsNewJobs(params.workspaces, input.workspaceId);\n const run = await runWorkflow(\n params.definitions,\n {\n agent: params.agent,\n workspaceId: input.workspaceId,\n projectId: input.projectId,\n definitionId: input.definitionId,\n triggerPayload: input.triggerPayload,\n triggerConnectionId: input.triggerConnectionId,\n inputs: input.inputs,\n triggerIdempotencyKey: input.idempotencyKey,\n integrations: params.integrations,\n projects: params.projects,\n },\n {secrets: params.secrets},\n );\n return {id: run.id, name: run.name};\n } catch (error) {\n throw toStartRunKnownError(error, input.definitionId);\n }\n },\n startDevRun: async (input) => {\n try {\n await assertWorkspaceAdmitsNewJobs(params.workspaces, input.workspaceId);\n const run = await runDevWorkflow(\n params.agent,\n {\n workspaceId: input.workspaceId,\n projectId: input.projectId,\n workflowId: input.workflowId,\n model: input.model,\n sourceSnapshot: input.sourceSnapshot,\n devSource: {\n ...input.devSource,\n replayOfEventId: input.devSource.replayOfEventId ?? null,\n },\n triggerPayload: input.triggerPayload,\n triggerConnectionId: input.triggerConnectionId,\n inputs: input.inputs,\n integrations: params.integrations,\n projects: params.projects,\n },\n {secrets: params.secrets},\n );\n return {id: run.id, name: run.name};\n } catch (error) {\n throw toStartDevRunKnownError(error);\n }\n },\n resolveWorkflowRunTriggerReference: async (input) =>\n await resolveWorkflowRunTriggerReference({\n workspaceId: input.workspaceId,\n triggerConnectionId: input.triggerConnectionId,\n triggerPayload: input.triggerPayload,\n integrations: params.integrations,\n projects: params.projects,\n }),\n deliverEventToJobListener: async (input) => {\n const method = workflowsInterModuleContract.methods.deliverEventToJobListener;\n try {\n const scope = input.disposition === 'fire' ? await getJobScope(input.jobId) : undefined;\n if (scope) {\n await assertWorkspaceAdmitsNewJobs(params.workspaces, scope.workspaceId);\n }\n\n let triggerReference: WorkflowRunTriggerReference | null = null;\n if (input.triggerReference !== undefined) {\n triggerReference = input.triggerReference;\n } else if (scope) {\n triggerReference = await resolveWorkflowRunTriggerReference({\n workspaceId: scope.workspaceId,\n triggerConnectionId: input.triggerConnectionId,\n triggerPayload: {\n provider: input.provider,\n source: input.source,\n event: input.event,\n deliveryId: input.deliveryId,\n data: input.payload,\n },\n integrations: params.integrations,\n projects: params.projects,\n });\n }\n return await deliverEventToListener({\n ...input,\n triggerReference,\n receivedAt: new Date(input.receivedAt),\n });\n } catch (error) {\n const workspaceError = toWorkspaceAdmissionKnownError(method, error);\n if (workspaceError !== undefined) throw workspaceError;\n throw error;\n }\n },\n getStepLogContext: async ({stepId}) => {\n const step = await getStepById(stepId);\n const parsed = harnessSchema.safeParse(step?.config.harness);\n return {harness: parsed.success ? parsed.data : DEFAULT_HARNESS};\n },\n getLeasedAgentToolContext: async (input) => {\n const method = workflowsInterModuleContract.methods.getLeasedAgentToolContext;\n const {active: leaseIsActive} = await params.runners.getLeaseState({\n jobId: input.jobId,\n jobExecutionId: input.jobExecutionId,\n runnerSessionId: input.runnerSessionId,\n });\n if (!leaseIsActive) throw createInterModuleKnownError(method, 'lease-not-active', {});\n\n const step = await getStepByIdForJobExecution({\n stepId: input.stepId,\n jobExecutionId: input.jobExecutionId,\n });\n if (!step) throw createInterModuleKnownError(method, 'step-not-found', {});\n\n const scope = await getJobScope(input.jobId);\n if (!scope) throw createInterModuleKnownError(method, 'job-not-found', {});\n if (step.currentAttempt !== input.attempt) {\n throw createInterModuleKnownError(method, 'step-attempt-mismatch', {});\n }\n if (step.status !== 'running')\n throw createInterModuleKnownError(method, 'step-not-running', {});\n if (step.type !== 'agent')\n throw createInterModuleKnownError(method, 'leased-step-not-agent', {});\n\n const config = materializedAgentStepConfigSchema.safeParse(step.config);\n if (!config.success) {\n throw createInterModuleKnownError(method, 'agent-step-config-invalid', {});\n }\n return {workspaceId: scope.workspaceId, integrations: config.data.integrations ?? []};\n },\n });\n}\n\nexport function toStartRunKnownError(error: unknown, definitionId: string): unknown {\n const method = workflowsInterModuleContract.methods.startRunFromTrigger;\n const mapped = toRunCreationKnownError(method, error);\n if (mapped !== undefined) return mapped;\n if (error instanceof DefinitionNotFoundError) {\n return createInterModuleKnownError(method, 'definition-not-found', {definitionId});\n }\n if (error instanceof ProjectMismatchError) {\n return createInterModuleKnownError(method, 'project-mismatch', {});\n }\n return error;\n}\n\nexport function toStartDevRunKnownError(error: unknown): unknown {\n return toRunCreationKnownError(workflowsInterModuleContract.methods.startDevRun, error) ?? error;\n}\n\nfunction toRunCreationKnownError(\n method:\n | typeof workflowsInterModuleContract.methods.startRunFromTrigger\n | typeof workflowsInterModuleContract.methods.startDevRun,\n error: unknown,\n): unknown {\n const workspaceError = toWorkspaceAdmissionKnownError(method, error);\n if (workspaceError !== undefined) return workspaceError;\n if (error instanceof AgentConfigUnresolvableError) {\n return createInterModuleKnownError(method, 'agent-config-unresolvable', {\n definitionId: error.definitionId,\n });\n }\n if (error instanceof AgentIntegrationMaterializationError) {\n return createInterModuleKnownError(method, 'agent-integration-materialization-failed', {});\n }\n if (error instanceof InterpolationUnresolvableError) {\n return createInterModuleKnownError(method, 'interpolation-unresolvable', {\n definitionId: error.definitionId,\n field: error.field,\n source: error.source,\n ...(error.envKey === undefined ? {} : {envKey: error.envKey}),\n });\n }\n if (error instanceof InvalidJobRunnerLabelsError) {\n return createInterModuleKnownError(method, 'invalid-job-runner-labels', {\n labels: [...error.labels],\n });\n }\n return undefined;\n}\n\nfunction toWorkspaceAdmissionKnownError(\n method:\n | typeof workflowsInterModuleContract.methods.startRunFromTrigger\n | typeof workflowsInterModuleContract.methods.startDevRun\n | typeof workflowsInterModuleContract.methods.deliverEventToJobListener,\n error: unknown,\n): WorkspaceAdmissionKnownError | undefined {\n if (error instanceof WorkspaceSuspendedError) {\n return createInterModuleKnownError(method, 'workspace-suspended', {\n workspaceId: error.workspaceId,\n });\n }\n if (error instanceof WorkspaceDeletedError) {\n return createInterModuleKnownError(method, 'workspace-deleted', {\n workspaceId: error.workspaceId,\n });\n }\n if (error instanceof WorkspaceNotFoundError) {\n return createInterModuleKnownError(method, 'workspace-not-found', {\n workspaceId: error.workspaceId,\n });\n }\n return undefined;\n}\n"],"names":["materializedAgentStepConfigSchema","workflowsInterModuleContract","createInterModuleKnownError","defineInterModulePresentation","DEFAULT_HARNESS","harnessSchema","InvalidJobRunnerLabelsError","WorkspaceDeletedError","WorkspaceNotFoundError","WorkspaceSuspendedError","AgentConfigUnresolvableError","AgentIntegrationMaterializationError","DefinitionNotFoundError","InterpolationUnresolvableError","ProjectMismatchError","runDevWorkflow","runWorkflow","resolveWorkflowRunTriggerReference","assertWorkspaceAdmitsNewJobs","getJobScope","getStepById","getStepByIdForJobExecution","deliverEventToListener","createWorkflowsInterModulePresentation","params","startRunFromTrigger","input","workspaces","workspaceId","run","definitions","agent","projectId","definitionId","triggerPayload","triggerConnectionId","inputs","triggerIdempotencyKey","idempotencyKey","integrations","projects","secrets","id","name","error","toStartRunKnownError","startDevRun","workflowId","model","sourceSnapshot","devSource","replayOfEventId","toStartDevRunKnownError","deliverEventToJobListener","method","methods","scope","disposition","jobId","undefined","triggerReference","provider","source","event","deliveryId","data","payload","receivedAt","Date","workspaceError","toWorkspaceAdmissionKnownError","getStepLogContext","stepId","step","parsed","safeParse","config","harness","success","getLeasedAgentToolContext","active","leaseIsActive","runners","getLeaseState","jobExecutionId","runnerSessionId","currentAttempt","attempt","status","type","mapped","toRunCreationKnownError","field","envKey","labels"],"mappings":"AAAA,SAAQA,iCAAiC,QAAO,yBAAyB;AAOzE,SAAQC,4BAA4B,QAAO,0CAA0C;AAErF,SACEC,2BAA2B,EAC3BC,6BAA6B,QAGxB,wBAAwB;AAC/B,SAAQC,eAAe,EAAEC,aAAa,QAAO,6BAA6B;AAE1E,SACEC,2BAA2B,EAC3BC,qBAAqB,EACrBC,sBAAsB,EACtBC,uBAAuB,QAClB,kBAAkB;AACzB,SACEC,4BAA4B,EAC5BC,oCAAoC,EACpCC,uBAAuB,EACvBC,8BAA8B,EAC9BC,oBAAoB,EACpBC,cAAc,EACdC,WAAW,QACN,iBAAiB;AACxB,SAAQC,kCAAkC,QAAO,qCAAqC;AACtF,SAAQC,4BAA4B,QAAO,+BAA+B;AAC1E,SAAQC,WAAW,EAAEC,WAAW,EAAEC,0BAA0B,QAAO,eAAe;AAClF,SAAQC,sBAAsB,QAAO,6BAA6B;AAMlE,OAAO,SAASC,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ErB,cAAcW,MAAMX,YAAY;YAChC2D,OAAOhD,MAAMgD,KAAK;YAClB9B,QAAQlB,MAAMkB,MAAM;YACpB,GAAIlB,MAAMiD,MAAM,KAAKlC,YAAY,CAAC,IAAI;gBAACkC,QAAQjD,MAAMiD,MAAM;YAAA,CAAC;QAC9D;IACF;IACA,IAAIjD,iBAAiBtC,6BAA6B;QAChD,OAAOJ,4BAA4BoD,QAAQ,6BAA6B;YACtEwC,QAAQ;mBAAIlD,MAAMkD,MAAM;aAAC;QAC3B;IACF;IACA,OAAOnC;AACT;AAEA,SAASW,+BACPhB,MAGyE,EACzEV,KAAc;IAEd,IAAIA,iBAAiBnC,yBAAyB;QAC5C,OAAOP,4BAA4BoD,QAAQ,uBAAuB;YAChE1B,aAAagB,MAAMhB,WAAW;QAChC;IACF;IACA,IAAIgB,iBAAiBrC,uBAAuB;QAC1C,OAAOL,4BAA4BoD,QAAQ,qBAAqB;YAC9D1B,aAAagB,MAAMhB,WAAW;QAChC;IACF;IACA,IAAIgB,iBAAiBpC,wBAAwB;QAC3C,OAAON,4BAA4BoD,QAAQ,uBAAuB;YAChE1B,aAAagB,MAAMhB,WAAW;QAChC;IACF;IACA,OAAO+B;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../src/presentation/inter-module.ts"],"sourcesContent":["import {materializedAgentStepConfigSchema} from '@shipfox/api-agent-dto';\nimport type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport type {DefinitionsInterModuleClient} from '@shipfox/api-definitions-dto/inter-module';\nimport type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto/inter-module';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';\nimport type {RunnersInterModuleClient} from '@shipfox/api-runners-dto/inter-module';\nimport type {SecretsInterModuleClient} from '@shipfox/api-secrets-dto/inter-module';\nimport {workflowsInterModuleContract} from '@shipfox/api-workflows-dto/inter-module';\nimport type {WorkspacesInterModuleClient} from '@shipfox/api-workspaces-dto/inter-module';\nimport {\n createInterModuleKnownError,\n defineInterModulePresentation,\n type InterModuleKnownErrorFor,\n type InterModulePresentation,\n} from '@shipfox/inter-module';\nimport {DEFAULT_HARNESS, harnessSchema} from '@shipfox/workflow-document';\nimport type {WorkflowRunTriggerReference} from '#core/entities/workflow-run.js';\nimport {\n InvalidJobRunnerLabelsError,\n WorkspaceDeletedError,\n WorkspaceNotFoundError,\n WorkspaceSuspendedError,\n} from '#core/errors.js';\nimport {\n AgentConfigUnresolvableError,\n AgentIntegrationMaterializationError,\n DefinitionNotFoundError,\n InterpolationUnresolvableError,\n ProjectMismatchError,\n runDevWorkflow,\n runWorkflow,\n} from '#core/index.js';\nimport {resolveWorkflowRunTriggerReference} from '#core/resolve-trigger-reference.js';\nimport {assertWorkspaceAdmitsNewJobs} from '#core/workspace-admission.js';\nimport {\n getJobScope,\n getStepById,\n getStepByIdForJobExecution,\n listStepAttemptIdsByJobId,\n} from '#db/index.js';\nimport {deliverEventToListener} from '#db/job-listener-events.js';\n\ntype WorkspaceAdmissionKnownError = InterModuleKnownErrorFor<\n typeof workflowsInterModuleContract.methods.deliverEventToJobListener\n>;\n\nexport function createWorkflowsInterModulePresentation(params: {\n agent: AgentInterModuleClient;\n definitions: DefinitionsInterModuleClient;\n workspaces: WorkspacesInterModuleClient;\n secrets: Pick<SecretsInterModuleClient, 'getVariablesByNamespace'>;\n runners: RunnersInterModuleClient;\n integrations: IntegrationsModuleClient;\n projects: ProjectsModuleClient;\n}): InterModulePresentation<typeof workflowsInterModuleContract> {\n return defineInterModulePresentation(workflowsInterModuleContract, {\n startRunFromTrigger: async (input) => {\n try {\n await assertWorkspaceAdmitsNewJobs(params.workspaces, input.workspaceId);\n const run = await runWorkflow(\n params.definitions,\n {\n agent: params.agent,\n workspaceId: input.workspaceId,\n projectId: input.projectId,\n definitionId: input.definitionId,\n triggerPayload: input.triggerPayload,\n triggerConnectionId: input.triggerConnectionId,\n inputs: input.inputs,\n triggerIdempotencyKey: input.idempotencyKey,\n integrations: params.integrations,\n projects: params.projects,\n },\n {secrets: params.secrets},\n );\n return {id: run.id, name: run.name};\n } catch (error) {\n throw toStartRunKnownError(error, input.definitionId);\n }\n },\n startDevRun: async (input) => {\n try {\n await assertWorkspaceAdmitsNewJobs(params.workspaces, input.workspaceId);\n const run = await runDevWorkflow(\n params.agent,\n {\n workspaceId: input.workspaceId,\n projectId: input.projectId,\n workflowId: input.workflowId,\n model: input.model,\n sourceSnapshot: input.sourceSnapshot,\n devSource: {\n ...input.devSource,\n replayOfEventId: input.devSource.replayOfEventId ?? null,\n },\n triggerPayload: input.triggerPayload,\n triggerConnectionId: input.triggerConnectionId,\n inputs: input.inputs,\n integrations: params.integrations,\n projects: params.projects,\n },\n {secrets: params.secrets},\n );\n return {id: run.id, name: run.name};\n } catch (error) {\n throw toStartDevRunKnownError(error);\n }\n },\n resolveWorkflowRunTriggerReference: async (input) =>\n await resolveWorkflowRunTriggerReference({\n workspaceId: input.workspaceId,\n triggerConnectionId: input.triggerConnectionId,\n triggerPayload: input.triggerPayload,\n integrations: params.integrations,\n projects: params.projects,\n }),\n deliverEventToJobListener: async (input) => {\n const method = workflowsInterModuleContract.methods.deliverEventToJobListener;\n try {\n const scope = input.disposition === 'fire' ? await getJobScope(input.jobId) : undefined;\n if (scope) {\n await assertWorkspaceAdmitsNewJobs(params.workspaces, scope.workspaceId);\n }\n\n let triggerReference: WorkflowRunTriggerReference | null = null;\n if (input.triggerReference !== undefined) {\n triggerReference = input.triggerReference;\n } else if (scope) {\n triggerReference = await resolveWorkflowRunTriggerReference({\n workspaceId: scope.workspaceId,\n triggerConnectionId: input.triggerConnectionId,\n triggerPayload: {\n provider: input.provider,\n source: input.source,\n event: input.event,\n deliveryId: input.deliveryId,\n data: input.payload,\n },\n integrations: params.integrations,\n projects: params.projects,\n });\n }\n return await deliverEventToListener({\n ...input,\n triggerReference,\n receivedAt: new Date(input.receivedAt),\n });\n } catch (error) {\n const workspaceError = toWorkspaceAdmissionKnownError(method, error);\n if (workspaceError !== undefined) throw workspaceError;\n throw error;\n }\n },\n getStepLogContext: async ({stepId}) => {\n const step = await getStepById(stepId);\n const parsed = harnessSchema.safeParse(step?.config.harness);\n return {harness: parsed.success ? parsed.data : DEFAULT_HARNESS};\n },\n listJobStepAttempts: async ({jobId}) => {\n return {stepAttemptIds: await listStepAttemptIdsByJobId(jobId)};\n },\n getLeasedAgentToolContext: async (input) => {\n const method = workflowsInterModuleContract.methods.getLeasedAgentToolContext;\n const {active: leaseIsActive} = await params.runners.getLeaseState({\n jobId: input.jobId,\n jobExecutionId: input.jobExecutionId,\n runnerSessionId: input.runnerSessionId,\n });\n if (!leaseIsActive) throw createInterModuleKnownError(method, 'lease-not-active', {});\n\n const step = await getStepByIdForJobExecution({\n stepId: input.stepId,\n jobExecutionId: input.jobExecutionId,\n });\n if (!step) throw createInterModuleKnownError(method, 'step-not-found', {});\n\n const scope = await getJobScope(input.jobId);\n if (!scope) throw createInterModuleKnownError(method, 'job-not-found', {});\n if (step.currentAttempt !== input.attempt) {\n throw createInterModuleKnownError(method, 'step-attempt-mismatch', {});\n }\n if (step.status !== 'running')\n throw createInterModuleKnownError(method, 'step-not-running', {});\n if (step.type !== 'agent')\n throw createInterModuleKnownError(method, 'leased-step-not-agent', {});\n\n const config = materializedAgentStepConfigSchema.safeParse(step.config);\n if (!config.success) {\n throw createInterModuleKnownError(method, 'agent-step-config-invalid', {});\n }\n return {workspaceId: scope.workspaceId, integrations: config.data.integrations ?? []};\n },\n });\n}\n\nexport function toStartRunKnownError(error: unknown, definitionId: string): unknown {\n const method = workflowsInterModuleContract.methods.startRunFromTrigger;\n const mapped = toRunCreationKnownError(method, error);\n if (mapped !== undefined) return mapped;\n if (error instanceof DefinitionNotFoundError) {\n return createInterModuleKnownError(method, 'definition-not-found', {definitionId});\n }\n if (error instanceof ProjectMismatchError) {\n return createInterModuleKnownError(method, 'project-mismatch', {});\n }\n return error;\n}\n\nexport function toStartDevRunKnownError(error: unknown): unknown {\n return toRunCreationKnownError(workflowsInterModuleContract.methods.startDevRun, error) ?? error;\n}\n\nfunction toRunCreationKnownError(\n method:\n | typeof workflowsInterModuleContract.methods.startRunFromTrigger\n | typeof workflowsInterModuleContract.methods.startDevRun,\n error: unknown,\n): unknown {\n const workspaceError = toWorkspaceAdmissionKnownError(method, error);\n if (workspaceError !== undefined) return workspaceError;\n if (error instanceof AgentConfigUnresolvableError) {\n return createInterModuleKnownError(method, 'agent-config-unresolvable', {\n definitionId: error.definitionId,\n });\n }\n if (error instanceof AgentIntegrationMaterializationError) {\n return createInterModuleKnownError(method, 'agent-integration-materialization-failed', {});\n }\n if (error instanceof InterpolationUnresolvableError) {\n return createInterModuleKnownError(method, 'interpolation-unresolvable', {\n definitionId: error.definitionId,\n field: error.field,\n source: error.source,\n ...(error.envKey === undefined ? {} : {envKey: error.envKey}),\n });\n }\n if (error instanceof InvalidJobRunnerLabelsError) {\n return createInterModuleKnownError(method, 'invalid-job-runner-labels', {\n labels: [...error.labels],\n });\n }\n return undefined;\n}\n\nfunction toWorkspaceAdmissionKnownError(\n method:\n | typeof workflowsInterModuleContract.methods.startRunFromTrigger\n | typeof workflowsInterModuleContract.methods.startDevRun\n | typeof workflowsInterModuleContract.methods.deliverEventToJobListener,\n error: unknown,\n): WorkspaceAdmissionKnownError | undefined {\n if (error instanceof WorkspaceSuspendedError) {\n return createInterModuleKnownError(method, 'workspace-suspended', {\n workspaceId: error.workspaceId,\n });\n }\n if (error instanceof WorkspaceDeletedError) {\n return createInterModuleKnownError(method, 'workspace-deleted', {\n workspaceId: error.workspaceId,\n });\n }\n if (error instanceof WorkspaceNotFoundError) {\n return createInterModuleKnownError(method, 'workspace-not-found', {\n workspaceId: error.workspaceId,\n });\n }\n return undefined;\n}\n"],"names":["materializedAgentStepConfigSchema","workflowsInterModuleContract","createInterModuleKnownError","defineInterModulePresentation","DEFAULT_HARNESS","harnessSchema","InvalidJobRunnerLabelsError","WorkspaceDeletedError","WorkspaceNotFoundError","WorkspaceSuspendedError","AgentConfigUnresolvableError","AgentIntegrationMaterializationError","DefinitionNotFoundError","InterpolationUnresolvableError","ProjectMismatchError","runDevWorkflow","runWorkflow","resolveWorkflowRunTriggerReference","assertWorkspaceAdmitsNewJobs","getJobScope","getStepById","getStepByIdForJobExecution","listStepAttemptIdsByJobId","deliverEventToListener","createWorkflowsInterModulePresentation","params","startRunFromTrigger","input","workspaces","workspaceId","run","definitions","agent","projectId","definitionId","triggerPayload","triggerConnectionId","inputs","triggerIdempotencyKey","idempotencyKey","integrations","projects","secrets","id","name","error","toStartRunKnownError","startDevRun","workflowId","model","sourceSnapshot","devSource","replayOfEventId","toStartDevRunKnownError","deliverEventToJobListener","method","methods","scope","disposition","jobId","undefined","triggerReference","provider","source","event","deliveryId","data","payload","receivedAt","Date","workspaceError","toWorkspaceAdmissionKnownError","getStepLogContext","stepId","step","parsed","safeParse","config","harness","success","listJobStepAttempts","stepAttemptIds","getLeasedAgentToolContext","active","leaseIsActive","runners","getLeaseState","jobExecutionId","runnerSessionId","currentAttempt","attempt","status","type","mapped","toRunCreationKnownError","field","envKey","labels"],"mappings":"AAAA,SAAQA,iCAAiC,QAAO,yBAAyB;AAOzE,SAAQC,4BAA4B,QAAO,0CAA0C;AAErF,SACEC,2BAA2B,EAC3BC,6BAA6B,QAGxB,wBAAwB;AAC/B,SAAQC,eAAe,EAAEC,aAAa,QAAO,6BAA6B;AAE1E,SACEC,2BAA2B,EAC3BC,qBAAqB,EACrBC,sBAAsB,EACtBC,uBAAuB,QAClB,kBAAkB;AACzB,SACEC,4BAA4B,EAC5BC,oCAAoC,EACpCC,uBAAuB,EACvBC,8BAA8B,EAC9BC,oBAAoB,EACpBC,cAAc,EACdC,WAAW,QACN,iBAAiB;AACxB,SAAQC,kCAAkC,QAAO,qCAAqC;AACtF,SAAQC,4BAA4B,QAAO,+BAA+B;AAC1E,SACEC,WAAW,EACXC,WAAW,EACXC,0BAA0B,EAC1BC,yBAAyB,QACpB,eAAe;AACtB,SAAQC,sBAAsB,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