@shipfox/api-workflows 12.6.0 → 13.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +23 -0
- package/dist/core/entities/workflow-run.d.ts +3 -0
- package/dist/core/entities/workflow-run.d.ts.map +1 -1
- package/dist/core/entities/workflow-run.js.map +1 -1
- 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/job-listeners.d.ts.map +1 -1
- package/dist/db/job-listeners.js +17 -1
- package/dist/db/job-listeners.js.map +1 -1
- package/dist/db/workflow-runs/job-executions.d.ts +2 -3
- package/dist/db/workflow-runs/job-executions.d.ts.map +1 -1
- package/dist/db/workflow-runs/job-executions.js +48 -20
- package/dist/db/workflow-runs/job-executions.js.map +1 -1
- package/dist/db/workflow-runs/outbox.d.ts +15 -0
- package/dist/db/workflow-runs/outbox.d.ts.map +1 -1
- package/dist/db/workflow-runs/outbox.js +35 -1
- package/dist/db/workflow-runs/outbox.js.map +1 -1
- package/dist/db/workflow-runs/queries.d.ts +5 -3
- package/dist/db/workflow-runs/queries.d.ts.map +1 -1
- package/dist/db/workflow-runs/queries.js +20 -6
- package/dist/db/workflow-runs/queries.js.map +1 -1
- package/dist/db/workflow-runs/run-graph.d.ts.map +1 -1
- package/dist/db/workflow-runs/run-graph.js +12 -0
- package/dist/db/workflow-runs/run-graph.js.map +1 -1
- package/dist/db/workflow-runs/run-status.d.ts.map +1 -1
- package/dist/db/workflow-runs/run-status.js +13 -1
- package/dist/db/workflow-runs/run-status.js.map +1 -1
- package/dist/db/workflow-runs.d.ts +2 -2
- package/dist/db/workflow-runs.d.ts.map +1 -1
- package/dist/db/workflow-runs.js +2 -2
- package/dist/db/workflow-runs.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- package/dist/presentation/dto/workflow-run.d.ts.map +1 -1
- package/dist/presentation/dto/workflow-run.js +4 -2
- package/dist/presentation/dto/workflow-run.js.map +1 -1
- package/dist/presentation/index.d.ts +1 -1
- package/dist/presentation/index.d.ts.map +1 -1
- package/dist/presentation/index.js +1 -1
- package/dist/presentation/index.js.map +1 -1
- package/dist/presentation/routes/get-run.d.ts.map +1 -1
- package/dist/presentation/routes/get-run.js +2 -1
- package/dist/presentation/routes/get-run.js.map +1 -1
- package/dist/presentation/subscribers/index.d.ts +0 -1
- package/dist/presentation/subscribers/index.d.ts.map +1 -1
- package/dist/presentation/subscribers/index.js +0 -1
- package/dist/presentation/subscribers/index.js.map +1 -1
- package/dist/temporal/activities/index.d.ts +2 -18
- package/dist/temporal/activities/index.d.ts.map +1 -1
- package/dist/temporal/activities/index.js +3 -5
- package/dist/temporal/activities/index.js.map +1 -1
- package/dist/temporal/activities/orchestration-activities.d.ts +5 -14
- package/dist/temporal/activities/orchestration-activities.d.ts.map +1 -1
- package/dist/temporal/activities/orchestration-activities.js +13 -34
- package/dist/temporal/activities/orchestration-activities.js.map +1 -1
- package/dist/temporal/workflows/index.bundle.js +20 -68
- package/dist/temporal/workflows/job-execution-orchestration.d.ts +0 -3
- package/dist/temporal/workflows/job-execution-orchestration.d.ts.map +1 -1
- package/dist/temporal/workflows/job-execution-orchestration.js +17 -41
- package/dist/temporal/workflows/job-execution-orchestration.js.map +1 -1
- package/dist/temporal/workflows/job-listener-orchestration.d.ts +0 -3
- package/dist/temporal/workflows/job-listener-orchestration.d.ts.map +1 -1
- package/dist/temporal/workflows/job-listener-orchestration.js +1 -9
- package/dist/temporal/workflows/job-listener-orchestration.js.map +1 -1
- package/dist/temporal/workflows/run-orchestration.d.ts.map +1 -1
- package/dist/temporal/workflows/run-orchestration.js +2 -18
- package/dist/temporal/workflows/run-orchestration.js.map +1 -1
- package/dist/temporal/workflows/test-env.d.ts +4 -6
- package/dist/temporal/workflows/test-env.d.ts.map +1 -1
- package/dist/temporal/workflows/test-env.js +13 -24
- package/dist/temporal/workflows/test-env.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/core/entities/workflow-run.ts +3 -0
- package/src/db/index.ts +1 -1
- package/src/db/job-listeners.test.ts +21 -0
- package/src/db/job-listeners.ts +18 -0
- package/src/db/workflow-runs/job-executions.test.ts +110 -12
- package/src/db/workflow-runs/job-executions.ts +54 -29
- package/src/db/workflow-runs/outbox.ts +63 -0
- package/src/db/workflow-runs/queries.test.ts +27 -0
- package/src/db/workflow-runs/queries.ts +31 -5
- package/src/db/workflow-runs/run-graph.ts +17 -0
- package/src/db/workflow-runs/run-status.test.ts +13 -0
- package/src/db/workflow-runs/run-status.ts +15 -1
- package/src/db/workflow-runs.ts +3 -1
- package/src/index.ts +1 -5
- package/src/presentation/dto/workflow-run.ts +7 -1
- package/src/presentation/index.ts +0 -1
- package/src/presentation/routes/get-run.test.ts +31 -0
- package/src/presentation/routes/get-run.ts +1 -0
- package/src/presentation/routes/list-runs.test.ts +5 -1
- package/src/presentation/subscribers/index.ts +0 -1
- package/src/temporal/activities/index.ts +2 -8
- package/src/temporal/activities/orchestration-activities.test.ts +17 -1
- package/src/temporal/activities/orchestration-activities.ts +13 -46
- package/src/temporal/workflows/job-execution-orchestration.test.ts +6 -25
- package/src/temporal/workflows/job-execution-orchestration.ts +17 -43
- package/src/temporal/workflows/job-listener-orchestration-continuation.test.ts +0 -3
- package/src/temporal/workflows/job-listener-orchestration.test.ts +9 -12
- package/src/temporal/workflows/job-listener-orchestration.ts +0 -8
- package/src/temporal/workflows/run-orchestration.test.ts +22 -33
- package/src/temporal/workflows/run-orchestration.ts +4 -28
- package/src/temporal/workflows/test-env.ts +14 -34
- package/test/fixtures/runners-inter-module.ts +0 -3
- package/test/helpers/workflow-runs.ts +25 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/dist/presentation/subscribers/on-runner-job-queued.d.ts +0 -3
- package/dist/presentation/subscribers/on-runner-job-queued.d.ts.map +0 -1
- package/dist/presentation/subscribers/on-runner-job-queued.js +0 -20
- package/dist/presentation/subscribers/on-runner-job-queued.js.map +0 -1
- package/src/presentation/subscribers/on-runner-job-queued.test.ts +0 -57
- package/src/presentation/subscribers/on-runner-job-queued.ts +0 -23
|
@@ -10,11 +10,11 @@ export interface TestConfig {
|
|
|
10
10
|
dag: RunDag;
|
|
11
11
|
/** Map of jobId → status the mock runner should signal back */
|
|
12
12
|
jobResults: Map<string, RuntimeCompletionStatus>;
|
|
13
|
-
/** If set,
|
|
14
|
-
|
|
15
|
-
/** If true,
|
|
13
|
+
/** If set, queueJobExecutionActivity will throw with this message instead of signaling */
|
|
14
|
+
queueError?: string;
|
|
15
|
+
/** If true, queueJobExecutionActivity sends two job-finished signals (for dedup testing) */
|
|
16
16
|
duplicateSignal?: boolean;
|
|
17
|
-
/** If true,
|
|
17
|
+
/** If true, queueJobExecutionActivity does nothing without a signal for timeout testing */
|
|
18
18
|
skipSignal?: boolean;
|
|
19
19
|
/** If true, emit the claim but hold back the terminal outcome (for deadline testing) */
|
|
20
20
|
skipOutcomeSignal?: boolean;
|
|
@@ -28,8 +28,6 @@ export interface TestConfig {
|
|
|
28
28
|
leaseExpiredStatus?: RuntimeCompletionStatus;
|
|
29
29
|
/** If set, resolveJobStatusFromJobExecutionsActivity throws with this message */
|
|
30
30
|
resolveJobStatusError?: string;
|
|
31
|
-
/** If set, releaseLeaseActivity throws (non-retryable) to prove the workflow still returns */
|
|
32
|
-
releaseLeaseError?: string;
|
|
33
31
|
/** Scripted job activation decisions keyed by job id; defaults to start */
|
|
34
32
|
activationDecisions?: Map<string, JobActivationDecision>;
|
|
35
33
|
/** If set, failJobExecutionAsTimedOutActivity throws (for timeout error-path testing) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-env.d.ts","sourceRoot":"","sources":["../../../src/temporal/workflows/test-env.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,uBAAuB,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K,CAAC;IAC/D,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE;QAAC,cAAc,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,QAAQ,GAAG,WAAW,CAAA;KAAC,CAAC;CAClE,CAAC,CACH;AAMD,wBAAgB,MAAM,CACpB,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,MAAM,EAAO,EACnB,OAAO,GAAE;IACP,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC;IACtD,sBAAsB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACzC,GACL,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAiBxB;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,aAAa,SAAU,GAAG,MAAM,CAU7E;AAMD,eAAO,IAAI,OAAO,EAAE,uBAAuB,CAAC;AAC5C,eAAO,IAAI,MAAM,EAAE,MAAM,CAAC;AAI1B,wBAAsB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAe9C;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAIjD"}
|
|
@@ -180,37 +180,35 @@ function createMockActivities() {
|
|
|
180
180
|
params
|
|
181
181
|
});
|
|
182
182
|
},
|
|
183
|
-
cancelRunnerJobsActivity: (params)=>{
|
|
184
|
-
calls.push({
|
|
185
|
-
name: 'cancelRunnerJobsActivity',
|
|
186
|
-
params
|
|
187
|
-
});
|
|
188
|
-
},
|
|
189
183
|
// Scheduling is step-less. The mock runner reports the job outcome by signalling
|
|
190
184
|
// the per-step terminal-completion signal (job-finished) and/or the lease-expiry
|
|
191
185
|
// signal, reproducing the outbox → subscriber → signal rail.
|
|
192
|
-
|
|
186
|
+
queueJobExecutionActivity: async (params)=>{
|
|
193
187
|
calls.push({
|
|
194
|
-
name: '
|
|
188
|
+
name: 'queueJobExecutionActivity',
|
|
195
189
|
params
|
|
196
190
|
});
|
|
197
|
-
if (cfg.
|
|
191
|
+
if (cfg.queueError) {
|
|
198
192
|
const { ApplicationFailure } = await import('@temporalio/common');
|
|
199
|
-
throw ApplicationFailure.nonRetryable(cfg.
|
|
193
|
+
throw ApplicationFailure.nonRetryable(cfg.queueError);
|
|
200
194
|
}
|
|
201
|
-
|
|
195
|
+
const queued = {
|
|
196
|
+
newVersion: nextVersion(),
|
|
197
|
+
status: 'pending'
|
|
198
|
+
};
|
|
199
|
+
if (cfg.skipSignal) return queued;
|
|
202
200
|
const status = cfg.jobResults.get(params.jobId) ?? 'succeeded';
|
|
203
201
|
const handle = testEnv.client.workflow.getHandle(`job:${params.jobId}`);
|
|
204
202
|
await handle.signal(JOB_CLAIMED_SIGNAL, {
|
|
205
203
|
jobExecutionId: params.jobExecutionId,
|
|
206
204
|
claimedAt: cfg.claimedAt ?? '2026-06-22T10:05:00.000Z'
|
|
207
205
|
});
|
|
208
|
-
if (cfg.skipOutcomeSignal) return;
|
|
206
|
+
if (cfg.skipOutcomeSignal) return queued;
|
|
209
207
|
if (cfg.signalLeaseExpired) {
|
|
210
208
|
await handle.signal(JOB_LEASE_EXPIRED_SIGNAL, {
|
|
211
209
|
jobExecutionId: params.jobExecutionId
|
|
212
210
|
});
|
|
213
|
-
return;
|
|
211
|
+
return queued;
|
|
214
212
|
}
|
|
215
213
|
if (cfg.signalBoth) {
|
|
216
214
|
await handle.signal(JOB_FINISHED_SIGNAL, {
|
|
@@ -220,7 +218,7 @@ function createMockActivities() {
|
|
|
220
218
|
await handle.signal(JOB_LEASE_EXPIRED_SIGNAL, {
|
|
221
219
|
jobExecutionId: params.jobExecutionId
|
|
222
220
|
});
|
|
223
|
-
return;
|
|
221
|
+
return queued;
|
|
224
222
|
}
|
|
225
223
|
// The terminal outbox is independent from the claim, but the mock delivers it from the
|
|
226
224
|
// pending → running activity. This gives the workflow a deterministic ordering boundary
|
|
@@ -230,6 +228,7 @@ function createMockActivities() {
|
|
|
230
228
|
status,
|
|
231
229
|
duplicateSignal: cfg.duplicateSignal ?? false
|
|
232
230
|
});
|
|
231
|
+
return queued;
|
|
233
232
|
},
|
|
234
233
|
resolveLeaseExpiredJobExecutionActivity: (params)=>{
|
|
235
234
|
calls.push({
|
|
@@ -258,16 +257,6 @@ function createMockActivities() {
|
|
|
258
257
|
jobVersion: nextVersion()
|
|
259
258
|
};
|
|
260
259
|
},
|
|
261
|
-
releaseLeaseActivity: async (params)=>{
|
|
262
|
-
calls.push({
|
|
263
|
-
name: 'releaseLeaseActivity',
|
|
264
|
-
params
|
|
265
|
-
});
|
|
266
|
-
if (cfg.releaseLeaseError) {
|
|
267
|
-
const { ApplicationFailure } = await import('@temporalio/common');
|
|
268
|
-
throw ApplicationFailure.nonRetryable(cfg.releaseLeaseError);
|
|
269
|
-
}
|
|
270
|
-
},
|
|
271
260
|
failJobExecutionAsTimedOutActivity: async (params)=>{
|
|
272
261
|
calls.push({
|
|
273
262
|
name: 'failJobExecutionAsTimedOutActivity',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/temporal/workflows/test-env.ts"],"sourcesContent":["import {resolve} from 'node:path';\nimport {TestWorkflowEnvironment} from '@temporalio/testing';\nimport {Worker} from '@temporalio/worker';\nimport type {RuntimeCompletionStatus} from '#core/workflow-scheduling/runtime-dag.js';\nimport type {JobActivationDecision} from '#db/index.js';\nimport type {\n ActivateJobListenerResult,\n DrainListenerEventsResult,\n ListenerBufferPeek,\n} from '#db/job-listeners.js';\nimport type {RunDag} from '../activities/orchestration-activities.js';\nimport {JOB_CLAIMED_SIGNAL, JOB_FINISHED_SIGNAL, JOB_LEASE_EXPIRED_SIGNAL} from '../constants.js';\n\nconst TASK_QUEUE = 'test-orchestration';\nconst WORKFLOWS_PATH = resolve(import.meta.dirname, '../../../dist/temporal/workflows/index.js');\n\nexport {TASK_QUEUE};\n\n// ---------------------------------------------------------------------------\n// Shared mutable test config: each test sets this before starting a workflow.\n// Activities read from it via closure. Tests run serially within a describe.\n// ---------------------------------------------------------------------------\n\nexport interface TestConfig {\n dag: RunDag;\n /** Map of jobId → status the mock runner should signal back */\n jobResults: Map<string, RuntimeCompletionStatus>;\n /** If set, enqueueJobExecutionForRunner will throw with this message instead of signaling */\n enqueueError?: string;\n /** If true, enqueueJobExecutionForRunner sends two job-finished signals (for dedup testing) */\n duplicateSignal?: boolean;\n /** If true, enqueueJobExecutionForRunner does nothing without a signal for timeout testing */\n skipSignal?: boolean;\n /** If true, emit the claim but hold back the terminal outcome (for deadline testing) */\n skipOutcomeSignal?: boolean;\n /** Runner-owned claim timestamp used by the mock claim event */\n claimedAt?: string;\n /** If true, signal job-lease-expired instead of job-finished */\n signalLeaseExpired?: boolean;\n /** If true, signal BOTH job-finished and job-lease-expired (precedence testing) */\n signalBoth?: boolean;\n /** Status resolveLeaseExpiredJobExecutionActivity returns (defaults to 'failed') */\n leaseExpiredStatus?: RuntimeCompletionStatus;\n /** If set, resolveJobStatusFromJobExecutionsActivity throws with this message */\n resolveJobStatusError?: string;\n /** If set, releaseLeaseActivity throws (non-retryable) to prove the workflow still returns */\n releaseLeaseError?: string;\n /** Scripted job activation decisions keyed by job id; defaults to start */\n activationDecisions?: Map<string, JobActivationDecision>;\n /** If set, failJobExecutionAsTimedOutActivity throws (for timeout error-path testing) */\n failJobExecutionAsTimedOutError?: string;\n /** Effective status returned by the initial running setRunAttemptStatus call */\n initialRunStatus?: string;\n /** Effective status returned by a running setJobStatus call */\n runningJobStatus?: string;\n /** Result returned by activateJobListenerActivity (defaults to a running listener) */\n listenerActivated?: ActivateJobListenerResult;\n /** Scripted drain results consumed in order; once exhausted, drain returns {kind: 'empty'} */\n drainResults?: DrainListenerEventsResult[];\n /** Scripted listener buffer peeks consumed in order; once exhausted, returns an empty buffer */\n peekResults?: ListenerBufferPeek[];\n /** Result returned by resolveJobListenerActivity (defaults to succeeded) */\n listenerResolved?: {status: 'succeeded' | 'failed'; jobVersion: number};\n}\n\nexport let cfg: TestConfig;\n\nexport function setCfg(value: TestConfig): void {\n cfg = value;\n}\n\n// Track every activity call for assertions\nexport interface ActivityCall {\n name: string;\n params: unknown;\n}\n\nexport let calls: ActivityCall[];\nlet versionSeq: number;\nconst pendingJobOutcomes = new Map<\n string,\n {\n handle: ReturnType<typeof testEnv.client.workflow.getHandle>;\n status: RuntimeCompletionStatus;\n duplicateSignal: boolean;\n }\n>();\n\nfunction nextVersion(): number {\n return ++versionSeq;\n}\n\nexport function resetCalls(): void {\n calls = [];\n versionSeq = 0;\n pendingJobOutcomes.clear();\n}\n\nexport function callsNamed(name: string): ActivityCall[] {\n return calls.filter((c) => c.name === name);\n}\n\nexport function setRunAttemptStatusCalls() {\n return callsNamed('setRunAttemptStatus') as Array<{\n name: string;\n params: {runAttemptId: string; status: string; version: number};\n }>;\n}\n\nexport function setJobStatusCalls() {\n return callsNamed('setJobStatus') as Array<{\n name: string;\n params: {jobId: string; status: string; version: number; statusReason?: string | null};\n }>;\n}\n\nexport function setExecutionStatusCalls() {\n return callsNamed('setJobExecutionStatus') as Array<{\n name: string;\n params: {jobExecutionId: string; status: string; version: number; statusReason?: string | null};\n }>;\n}\n\nexport function listenerFiringOutcomeCalls() {\n return callsNamed('recordListenerFiringOutcomeActivity') as Array<{\n name: string;\n params: {outcome: 'succeeded' | 'failed' | 'cancelled'};\n }>;\n}\n\nexport function resolveJobListenerCalls() {\n return callsNamed('resolveJobListenerActivity') as Array<{\n name: string;\n params: {jobId: string; reason: string};\n }>;\n}\n\nexport function settleListenerCalls() {\n return callsNamed('settleListenerJobExecutionActivity') as Array<{\n name: string;\n params: {jobExecutionId: string; status: 'failed' | 'cancelled'};\n }>;\n}\n\n// ---------------------------------------------------------------------------\n// DAG helpers\n// ---------------------------------------------------------------------------\n\nexport function dagJob(\n id: string,\n key: string,\n deps: string[] = [],\n options: {\n mode?: RunDag['jobs'][number]['mode'] | undefined;\n status?: RunDag['jobs'][number]['status'] | undefined;\n hasActivationCondition?: boolean | undefined;\n } = {},\n): RunDag['jobs'][number] {\n const mode = options.mode ?? 'one_shot';\n return {\n id,\n key,\n mode,\n status: options.status ?? 'pending',\n ...(mode === 'listening' ? {} : {jobExecutionId: id, executionVersion: 1}),\n executionTimeoutMs: null,\n listeningTimeoutMs: null,\n maxExecutions: null,\n onResolve: null,\n hasActivationCondition: options.hasActivationCondition ?? false,\n dependencies: deps,\n runner: ['ubuntu22'],\n version: 1,\n };\n}\n\nexport function makeDag(jobs: RunDag['jobs'], workflowRunId = 'run-1'): RunDag {\n return {\n workflowRunId,\n runAttemptId: `${workflowRunId}-attempt-1`,\n workspaceId: 'workspace-1',\n projectId: 'project-1',\n runVersion: 1,\n runTimeoutMs: 30 * 24 * 60 * 60 * 1000,\n jobs,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Environment lifecycle\n// ---------------------------------------------------------------------------\n\nexport let testEnv: TestWorkflowEnvironment;\nexport let worker: Worker;\n\nlet workerRunPromise: Promise<void> | undefined;\n\nexport async function setupEnv(): Promise<void> {\n testEnv = await TestWorkflowEnvironment.createLocal();\n\n worker = await Worker.create({\n connection: testEnv.nativeConnection,\n taskQueue: TASK_QUEUE,\n workflowsPath: WORKFLOWS_PATH,\n activities: createMockActivities(),\n });\n\n // Run worker in background: it processes tasks until shutdown is called\n workerRunPromise = worker.run();\n workerRunPromise.catch(() => {\n // Suppress unhandled rejection on shutdown\n });\n}\n\nexport async function teardownEnv(): Promise<void> {\n worker?.shutdown();\n await workerRunPromise;\n await testEnv?.teardown();\n}\n\nfunction createMockActivities() {\n return {\n loadRunAttemptDag: (runAttemptId: string): RunDag => {\n calls.push({name: 'loadRunAttemptDag', params: runAttemptId});\n return cfg.dag;\n },\n\n setRunAttemptStatus: (params: {runAttemptId: string; status: string; version: number}) => {\n calls.push({name: 'setRunAttemptStatus', params});\n const status =\n params.status === 'running' && cfg.initialRunStatus ? cfg.initialRunStatus : params.status;\n return {newVersion: nextVersion(), status};\n },\n\n setJobStatus: (params: {\n jobId: string;\n status: string;\n version: number;\n statusReason?: string | null;\n }) => {\n calls.push({name: 'setJobStatus', params});\n const status =\n params.status === 'running' && cfg.runningJobStatus ? cfg.runningJobStatus : params.status;\n return {newVersion: nextVersion(), status};\n },\n\n evaluateJobActivationsActivity: (params: {\n runAttemptId: string;\n jobs: readonly {jobId: string; expectedVersion: number}[];\n }): JobActivationDecision[] => {\n calls.push({name: 'evaluateJobActivationsActivity', params});\n return params.jobs.map((job) => {\n const decision = cfg.activationDecisions?.get(job.jobId);\n return decision ?? {kind: 'start-job', jobId: job.jobId};\n });\n },\n\n setJobExecutionStatus: async (params: {\n jobExecutionId: string;\n status: string;\n version: number;\n statusReason?: string | null;\n }) => {\n calls.push({name: 'setJobExecutionStatus', params});\n const status =\n params.status === 'running' && cfg.runningJobStatus ? cfg.runningJobStatus : params.status;\n\n if (params.status === 'running') {\n const outcome = pendingJobOutcomes.get(params.jobExecutionId);\n pendingJobOutcomes.delete(params.jobExecutionId);\n if (outcome && status === 'running') {\n await outcome.handle.signal(JOB_FINISHED_SIGNAL, {\n status: outcome.status,\n jobExecutionId: params.jobExecutionId,\n });\n if (outcome.duplicateSignal) {\n await outcome.handle.signal(JOB_FINISHED_SIGNAL, {\n status: 'failed',\n jobExecutionId: params.jobExecutionId,\n });\n }\n }\n }\n\n return {newVersion: nextVersion(), status};\n },\n\n bulkSetStepStatuses: (params: {jobExecutionId: string; status: string}) => {\n calls.push({name: 'bulkSetStepStatuses', params});\n },\n\n cancelRunnerJobsActivity: (params: {jobIds: string[]}) => {\n calls.push({name: 'cancelRunnerJobsActivity', params});\n },\n\n // Scheduling is step-less. The mock runner reports the job outcome by signalling\n // the per-step terminal-completion signal (job-finished) and/or the lease-expiry\n // signal, reproducing the outbox → subscriber → signal rail.\n enqueueJobExecutionForRunner: async (params: {\n workspaceId: string;\n workflowRunId: string;\n runAttemptId: string;\n jobId: string;\n jobExecutionId: string;\n projectId: string;\n requiredLabels: string[];\n }) => {\n calls.push({name: 'enqueueJobExecutionForRunner', params});\n\n if (cfg.enqueueError) {\n const {ApplicationFailure} = await import('@temporalio/common');\n throw ApplicationFailure.nonRetryable(cfg.enqueueError);\n }\n\n if (cfg.skipSignal) return;\n\n const status = cfg.jobResults.get(params.jobId) ?? 'succeeded';\n const handle = testEnv.client.workflow.getHandle(`job:${params.jobId}`);\n await handle.signal(JOB_CLAIMED_SIGNAL, {\n jobExecutionId: params.jobExecutionId,\n claimedAt: cfg.claimedAt ?? '2026-06-22T10:05:00.000Z',\n });\n\n if (cfg.skipOutcomeSignal) return;\n\n if (cfg.signalLeaseExpired) {\n await handle.signal(JOB_LEASE_EXPIRED_SIGNAL, {jobExecutionId: params.jobExecutionId});\n return;\n }\n\n if (cfg.signalBoth) {\n await handle.signal(JOB_FINISHED_SIGNAL, {status, jobExecutionId: params.jobExecutionId});\n await handle.signal(JOB_LEASE_EXPIRED_SIGNAL, {jobExecutionId: params.jobExecutionId});\n return;\n }\n\n // The terminal outbox is independent from the claim, but the mock delivers it from the\n // pending → running activity. This gives the workflow a deterministic ordering boundary\n // without leaving a polling promise alive after the test finishes.\n pendingJobOutcomes.set(params.jobExecutionId, {\n handle,\n status,\n duplicateSignal: cfg.duplicateSignal ?? false,\n });\n },\n\n resolveLeaseExpiredJobExecutionActivity: (params: {\n jobExecutionId: string;\n expectedVersion: number;\n }) => {\n calls.push({name: 'resolveLeaseExpiredJobExecutionActivity', params});\n return {status: cfg.leaseExpiredStatus ?? 'failed', executionVersion: nextVersion()};\n },\n\n resolveJobStatusFromJobExecutionsActivity: async (params: {jobId: string}) => {\n calls.push({name: 'resolveJobStatusFromJobExecutionsActivity', params});\n if (cfg.resolveJobStatusError) {\n const {ApplicationFailure} = await import('@temporalio/common');\n throw ApplicationFailure.nonRetryable(cfg.resolveJobStatusError);\n }\n const terminalExecutionStatus = [...setExecutionStatusCalls()]\n .reverse()\n .find(\n (call) => call.params.jobExecutionId === params.jobId && call.params.status !== 'running',\n )?.params.status as RuntimeCompletionStatus | undefined;\n return {\n status: cfg.leaseExpiredStatus ?? terminalExecutionStatus ?? 'succeeded',\n jobVersion: nextVersion(),\n };\n },\n\n releaseLeaseActivity: async (params: {jobExecutionId: string}) => {\n calls.push({name: 'releaseLeaseActivity', params});\n if (cfg.releaseLeaseError) {\n const {ApplicationFailure} = await import('@temporalio/common');\n throw ApplicationFailure.nonRetryable(cfg.releaseLeaseError);\n }\n },\n\n failJobExecutionAsTimedOutActivity: async (params: {\n jobExecutionId: string;\n runAttemptId: string;\n expectedVersion: number;\n }) => {\n calls.push({name: 'failJobExecutionAsTimedOutActivity', params});\n if (cfg.failJobExecutionAsTimedOutError) {\n const {ApplicationFailure} = await import('@temporalio/common');\n throw ApplicationFailure.nonRetryable(cfg.failJobExecutionAsTimedOutError);\n }\n return {newVersion: nextVersion()};\n },\n\n activateJobListenerActivity: (params: {jobId: string; expectedVersion: number}) => {\n calls.push({name: 'activateJobListenerActivity', params});\n return (\n cfg.listenerActivated ?? {\n status: 'running',\n jobStatus: 'running',\n jobVersion: nextVersion(),\n executionCount: 0,\n }\n );\n },\n\n // Each call consumes the next scripted drain result. An exhausted script means\n // \"no events buffered\", which parks the listener until a signal or its deadline.\n drainListenerEventsActivity: (params: {\n jobId: string;\n expectedSequence: number;\n maxSize?: number;\n }) => {\n calls.push({name: 'drainListenerEventsActivity', params});\n return cfg.drainResults?.shift() ?? {kind: 'empty'};\n },\n\n peekListenerBufferActivity: (params: {jobId: string}) => {\n calls.push({name: 'peekListenerBufferActivity', params});\n return (\n cfg.peekResults?.shift() ?? {\n fireCount: 0,\n resolvePending: false,\n oldestAgeMs: 0,\n newestAgeMs: 0,\n }\n );\n },\n\n resolveJobListenerActivity: (params: {jobId: string; reason: string}) => {\n calls.push({name: 'resolveJobListenerActivity', params});\n return cfg.listenerResolved ?? {status: 'succeeded', jobVersion: nextVersion()};\n },\n\n settleListenerJobExecutionActivity: (params: {\n jobExecutionId: string;\n status: 'failed' | 'cancelled';\n }) => {\n calls.push({name: 'settleListenerJobExecutionActivity', params});\n },\n\n recordListenerFiringOutcomeActivity: (params: {\n outcome: 'succeeded' | 'failed' | 'cancelled';\n }) => {\n calls.push({name: 'recordListenerFiringOutcomeActivity', params});\n },\n };\n}\n"],"names":["resolve","TestWorkflowEnvironment","Worker","JOB_CLAIMED_SIGNAL","JOB_FINISHED_SIGNAL","JOB_LEASE_EXPIRED_SIGNAL","TASK_QUEUE","WORKFLOWS_PATH","dirname","cfg","setCfg","value","calls","versionSeq","pendingJobOutcomes","Map","nextVersion","resetCalls","clear","callsNamed","name","filter","c","setRunAttemptStatusCalls","setJobStatusCalls","setExecutionStatusCalls","listenerFiringOutcomeCalls","resolveJobListenerCalls","settleListenerCalls","dagJob","id","key","deps","options","mode","status","jobExecutionId","executionVersion","executionTimeoutMs","listeningTimeoutMs","maxExecutions","onResolve","hasActivationCondition","dependencies","runner","version","makeDag","jobs","workflowRunId","runAttemptId","workspaceId","projectId","runVersion","runTimeoutMs","testEnv","worker","workerRunPromise","setupEnv","createLocal","create","connection","nativeConnection","taskQueue","workflowsPath","activities","createMockActivities","run","catch","teardownEnv","shutdown","teardown","loadRunAttemptDag","push","params","dag","setRunAttemptStatus","initialRunStatus","newVersion","setJobStatus","runningJobStatus","evaluateJobActivationsActivity","map","job","decision","activationDecisions","get","jobId","kind","setJobExecutionStatus","outcome","delete","handle","signal","duplicateSignal","bulkSetStepStatuses","cancelRunnerJobsActivity","enqueueJobExecutionForRunner","enqueueError","ApplicationFailure","nonRetryable","skipSignal","jobResults","client","workflow","getHandle","claimedAt","skipOutcomeSignal","signalLeaseExpired","signalBoth","set","resolveLeaseExpiredJobExecutionActivity","leaseExpiredStatus","resolveJobStatusFromJobExecutionsActivity","resolveJobStatusError","terminalExecutionStatus","reverse","find","call","jobVersion","releaseLeaseActivity","releaseLeaseError","failJobExecutionAsTimedOutActivity","failJobExecutionAsTimedOutError","activateJobListenerActivity","listenerActivated","jobStatus","executionCount","drainListenerEventsActivity","drainResults","shift","peekListenerBufferActivity","peekResults","fireCount","resolvePending","oldestAgeMs","newestAgeMs","resolveJobListenerActivity","listenerResolved","settleListenerJobExecutionActivity","recordListenerFiringOutcomeActivity"],"mappings":"AAAA,SAAQA,OAAO,QAAO,YAAY;AAClC,SAAQC,uBAAuB,QAAO,sBAAsB;AAC5D,SAAQC,MAAM,QAAO,qBAAqB;AAS1C,SAAQC,kBAAkB,EAAEC,mBAAmB,EAAEC,wBAAwB,QAAO,kBAAkB;AAElG,MAAMC,aAAa;AACnB,MAAMC,iBAAiBP,QAAQ,YAAYQ,OAAO,EAAE;AAEpD,SAAQF,UAAU,GAAE;AAiDpB,OAAO,IAAIG,IAAgB;AAE3B,OAAO,SAASC,OAAOC,KAAiB;IACtCF,MAAME;AACR;AAQA,OAAO,IAAIC,MAAsB;AACjC,IAAIC;AACJ,MAAMC,qBAAqB,IAAIC;AAS/B,SAASC;IACP,OAAO,EAAEH;AACX;AAEA,OAAO,SAASI;IACdL,QAAQ,EAAE;IACVC,aAAa;IACbC,mBAAmBI,KAAK;AAC1B;AAEA,OAAO,SAASC,WAAWC,IAAY;IACrC,OAAOR,MAAMS,MAAM,CAAC,CAACC,IAAMA,EAAEF,IAAI,KAAKA;AACxC;AAEA,OAAO,SAASG;IACd,OAAOJ,WAAW;AAIpB;AAEA,OAAO,SAASK;IACd,OAAOL,WAAW;AAIpB;AAEA,OAAO,SAASM;IACd,OAAON,WAAW;AAIpB;AAEA,OAAO,SAASO;IACd,OAAOP,WAAW;AAIpB;AAEA,OAAO,SAASQ;IACd,OAAOR,WAAW;AAIpB;AAEA,OAAO,SAASS;IACd,OAAOT,WAAW;AAIpB;AAEA,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAE9E,OAAO,SAASU,OACdC,EAAU,EACVC,GAAW,EACXC,OAAiB,EAAE,E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AqC,CAAClE;YAGpC7D,MAAM4D,IAAI,CAAC;gBAACpD,MAAM;gBAAuCqD;YAAM;QACjE;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/temporal/workflows/test-env.ts"],"sourcesContent":["import {resolve} from 'node:path';\nimport {TestWorkflowEnvironment} from '@temporalio/testing';\nimport {Worker} from '@temporalio/worker';\nimport type {RuntimeCompletionStatus} from '#core/workflow-scheduling/runtime-dag.js';\nimport type {JobActivationDecision} from '#db/index.js';\nimport type {\n ActivateJobListenerResult,\n DrainListenerEventsResult,\n ListenerBufferPeek,\n} from '#db/job-listeners.js';\nimport type {RunDag} from '../activities/orchestration-activities.js';\nimport {JOB_CLAIMED_SIGNAL, JOB_FINISHED_SIGNAL, JOB_LEASE_EXPIRED_SIGNAL} from '../constants.js';\n\nconst TASK_QUEUE = 'test-orchestration';\nconst WORKFLOWS_PATH = resolve(import.meta.dirname, '../../../dist/temporal/workflows/index.js');\n\nexport {TASK_QUEUE};\n\n// ---------------------------------------------------------------------------\n// Shared mutable test config: each test sets this before starting a workflow.\n// Activities read from it via closure. Tests run serially within a describe.\n// ---------------------------------------------------------------------------\n\nexport interface TestConfig {\n dag: RunDag;\n /** Map of jobId → status the mock runner should signal back */\n jobResults: Map<string, RuntimeCompletionStatus>;\n /** If set, queueJobExecutionActivity will throw with this message instead of signaling */\n queueError?: string;\n /** If true, queueJobExecutionActivity sends two job-finished signals (for dedup testing) */\n duplicateSignal?: boolean;\n /** If true, queueJobExecutionActivity does nothing without a signal for timeout testing */\n skipSignal?: boolean;\n /** If true, emit the claim but hold back the terminal outcome (for deadline testing) */\n skipOutcomeSignal?: boolean;\n /** Runner-owned claim timestamp used by the mock claim event */\n claimedAt?: string;\n /** If true, signal job-lease-expired instead of job-finished */\n signalLeaseExpired?: boolean;\n /** If true, signal BOTH job-finished and job-lease-expired (precedence testing) */\n signalBoth?: boolean;\n /** Status resolveLeaseExpiredJobExecutionActivity returns (defaults to 'failed') */\n leaseExpiredStatus?: RuntimeCompletionStatus;\n /** If set, resolveJobStatusFromJobExecutionsActivity throws with this message */\n resolveJobStatusError?: string;\n /** Scripted job activation decisions keyed by job id; defaults to start */\n activationDecisions?: Map<string, JobActivationDecision>;\n /** If set, failJobExecutionAsTimedOutActivity throws (for timeout error-path testing) */\n failJobExecutionAsTimedOutError?: string;\n /** Effective status returned by the initial running setRunAttemptStatus call */\n initialRunStatus?: string;\n /** Effective status returned by a running setJobStatus call */\n runningJobStatus?: string;\n /** Result returned by activateJobListenerActivity (defaults to a running listener) */\n listenerActivated?: ActivateJobListenerResult;\n /** Scripted drain results consumed in order; once exhausted, drain returns {kind: 'empty'} */\n drainResults?: DrainListenerEventsResult[];\n /** Scripted listener buffer peeks consumed in order; once exhausted, returns an empty buffer */\n peekResults?: ListenerBufferPeek[];\n /** Result returned by resolveJobListenerActivity (defaults to succeeded) */\n listenerResolved?: {status: 'succeeded' | 'failed'; jobVersion: number};\n}\n\nexport let cfg: TestConfig;\n\nexport function setCfg(value: TestConfig): void {\n cfg = value;\n}\n\n// Track every activity call for assertions\nexport interface ActivityCall {\n name: string;\n params: unknown;\n}\n\nexport let calls: ActivityCall[];\nlet versionSeq: number;\nconst pendingJobOutcomes = new Map<\n string,\n {\n handle: ReturnType<typeof testEnv.client.workflow.getHandle>;\n status: RuntimeCompletionStatus;\n duplicateSignal: boolean;\n }\n>();\n\nfunction nextVersion(): number {\n return ++versionSeq;\n}\n\nexport function resetCalls(): void {\n calls = [];\n versionSeq = 0;\n pendingJobOutcomes.clear();\n}\n\nexport function callsNamed(name: string): ActivityCall[] {\n return calls.filter((c) => c.name === name);\n}\n\nexport function setRunAttemptStatusCalls() {\n return callsNamed('setRunAttemptStatus') as Array<{\n name: string;\n params: {runAttemptId: string; status: string; version: number};\n }>;\n}\n\nexport function setJobStatusCalls() {\n return callsNamed('setJobStatus') as Array<{\n name: string;\n params: {jobId: string; status: string; version: number; statusReason?: string | null};\n }>;\n}\n\nexport function setExecutionStatusCalls() {\n return callsNamed('setJobExecutionStatus') as Array<{\n name: string;\n params: {jobExecutionId: string; status: string; version: number; statusReason?: string | null};\n }>;\n}\n\nexport function listenerFiringOutcomeCalls() {\n return callsNamed('recordListenerFiringOutcomeActivity') as Array<{\n name: string;\n params: {outcome: 'succeeded' | 'failed' | 'cancelled'};\n }>;\n}\n\nexport function resolveJobListenerCalls() {\n return callsNamed('resolveJobListenerActivity') as Array<{\n name: string;\n params: {jobId: string; reason: string};\n }>;\n}\n\nexport function settleListenerCalls() {\n return callsNamed('settleListenerJobExecutionActivity') as Array<{\n name: string;\n params: {jobExecutionId: string; status: 'failed' | 'cancelled'};\n }>;\n}\n\n// ---------------------------------------------------------------------------\n// DAG helpers\n// ---------------------------------------------------------------------------\n\nexport function dagJob(\n id: string,\n key: string,\n deps: string[] = [],\n options: {\n mode?: RunDag['jobs'][number]['mode'] | undefined;\n status?: RunDag['jobs'][number]['status'] | undefined;\n hasActivationCondition?: boolean | undefined;\n } = {},\n): RunDag['jobs'][number] {\n const mode = options.mode ?? 'one_shot';\n return {\n id,\n key,\n mode,\n status: options.status ?? 'pending',\n ...(mode === 'listening' ? {} : {jobExecutionId: id, executionVersion: 1}),\n executionTimeoutMs: null,\n listeningTimeoutMs: null,\n maxExecutions: null,\n onResolve: null,\n hasActivationCondition: options.hasActivationCondition ?? false,\n dependencies: deps,\n runner: ['ubuntu22'],\n version: 1,\n };\n}\n\nexport function makeDag(jobs: RunDag['jobs'], workflowRunId = 'run-1'): RunDag {\n return {\n workflowRunId,\n runAttemptId: `${workflowRunId}-attempt-1`,\n workspaceId: 'workspace-1',\n projectId: 'project-1',\n runVersion: 1,\n runTimeoutMs: 30 * 24 * 60 * 60 * 1000,\n jobs,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Environment lifecycle\n// ---------------------------------------------------------------------------\n\nexport let testEnv: TestWorkflowEnvironment;\nexport let worker: Worker;\n\nlet workerRunPromise: Promise<void> | undefined;\n\nexport async function setupEnv(): Promise<void> {\n testEnv = await TestWorkflowEnvironment.createLocal();\n\n worker = await Worker.create({\n connection: testEnv.nativeConnection,\n taskQueue: TASK_QUEUE,\n workflowsPath: WORKFLOWS_PATH,\n activities: createMockActivities(),\n });\n\n // Run worker in background: it processes tasks until shutdown is called\n workerRunPromise = worker.run();\n workerRunPromise.catch(() => {\n // Suppress unhandled rejection on shutdown\n });\n}\n\nexport async function teardownEnv(): Promise<void> {\n worker?.shutdown();\n await workerRunPromise;\n await testEnv?.teardown();\n}\n\nfunction createMockActivities() {\n return {\n loadRunAttemptDag: (runAttemptId: string): RunDag => {\n calls.push({name: 'loadRunAttemptDag', params: runAttemptId});\n return cfg.dag;\n },\n\n setRunAttemptStatus: (params: {runAttemptId: string; status: string; version: number}) => {\n calls.push({name: 'setRunAttemptStatus', params});\n const status =\n params.status === 'running' && cfg.initialRunStatus ? cfg.initialRunStatus : params.status;\n return {newVersion: nextVersion(), status};\n },\n\n setJobStatus: (params: {\n jobId: string;\n status: string;\n version: number;\n statusReason?: string | null;\n }) => {\n calls.push({name: 'setJobStatus', params});\n const status =\n params.status === 'running' && cfg.runningJobStatus ? cfg.runningJobStatus : params.status;\n return {newVersion: nextVersion(), status};\n },\n\n evaluateJobActivationsActivity: (params: {\n runAttemptId: string;\n jobs: readonly {jobId: string; expectedVersion: number}[];\n }): JobActivationDecision[] => {\n calls.push({name: 'evaluateJobActivationsActivity', params});\n return params.jobs.map((job) => {\n const decision = cfg.activationDecisions?.get(job.jobId);\n return decision ?? {kind: 'start-job', jobId: job.jobId};\n });\n },\n\n setJobExecutionStatus: async (params: {\n jobExecutionId: string;\n status: string;\n version: number;\n statusReason?: string | null;\n }) => {\n calls.push({name: 'setJobExecutionStatus', params});\n const status =\n params.status === 'running' && cfg.runningJobStatus ? cfg.runningJobStatus : params.status;\n\n if (params.status === 'running') {\n const outcome = pendingJobOutcomes.get(params.jobExecutionId);\n pendingJobOutcomes.delete(params.jobExecutionId);\n if (outcome && status === 'running') {\n await outcome.handle.signal(JOB_FINISHED_SIGNAL, {\n status: outcome.status,\n jobExecutionId: params.jobExecutionId,\n });\n if (outcome.duplicateSignal) {\n await outcome.handle.signal(JOB_FINISHED_SIGNAL, {\n status: 'failed',\n jobExecutionId: params.jobExecutionId,\n });\n }\n }\n }\n\n return {newVersion: nextVersion(), status};\n },\n\n bulkSetStepStatuses: (params: {jobExecutionId: string; status: string}) => {\n calls.push({name: 'bulkSetStepStatuses', params});\n },\n\n // Scheduling is step-less. The mock runner reports the job outcome by signalling\n // the per-step terminal-completion signal (job-finished) and/or the lease-expiry\n // signal, reproducing the outbox → subscriber → signal rail.\n queueJobExecutionActivity: async (params: {jobId: string; jobExecutionId: string}) => {\n calls.push({name: 'queueJobExecutionActivity', params});\n\n if (cfg.queueError) {\n const {ApplicationFailure} = await import('@temporalio/common');\n throw ApplicationFailure.nonRetryable(cfg.queueError);\n }\n\n const queued = {newVersion: nextVersion(), status: 'pending' as const};\n if (cfg.skipSignal) return queued;\n\n const status = cfg.jobResults.get(params.jobId) ?? 'succeeded';\n const handle = testEnv.client.workflow.getHandle(`job:${params.jobId}`);\n await handle.signal(JOB_CLAIMED_SIGNAL, {\n jobExecutionId: params.jobExecutionId,\n claimedAt: cfg.claimedAt ?? '2026-06-22T10:05:00.000Z',\n });\n\n if (cfg.skipOutcomeSignal) return queued;\n\n if (cfg.signalLeaseExpired) {\n await handle.signal(JOB_LEASE_EXPIRED_SIGNAL, {jobExecutionId: params.jobExecutionId});\n return queued;\n }\n\n if (cfg.signalBoth) {\n await handle.signal(JOB_FINISHED_SIGNAL, {status, jobExecutionId: params.jobExecutionId});\n await handle.signal(JOB_LEASE_EXPIRED_SIGNAL, {jobExecutionId: params.jobExecutionId});\n return queued;\n }\n\n // The terminal outbox is independent from the claim, but the mock delivers it from the\n // pending → running activity. This gives the workflow a deterministic ordering boundary\n // without leaving a polling promise alive after the test finishes.\n pendingJobOutcomes.set(params.jobExecutionId, {\n handle,\n status,\n duplicateSignal: cfg.duplicateSignal ?? false,\n });\n return queued;\n },\n\n resolveLeaseExpiredJobExecutionActivity: (params: {\n jobExecutionId: string;\n expectedVersion: number;\n }) => {\n calls.push({name: 'resolveLeaseExpiredJobExecutionActivity', params});\n return {status: cfg.leaseExpiredStatus ?? 'failed', executionVersion: nextVersion()};\n },\n\n resolveJobStatusFromJobExecutionsActivity: async (params: {jobId: string}) => {\n calls.push({name: 'resolveJobStatusFromJobExecutionsActivity', params});\n if (cfg.resolveJobStatusError) {\n const {ApplicationFailure} = await import('@temporalio/common');\n throw ApplicationFailure.nonRetryable(cfg.resolveJobStatusError);\n }\n const terminalExecutionStatus = [...setExecutionStatusCalls()]\n .reverse()\n .find(\n (call) => call.params.jobExecutionId === params.jobId && call.params.status !== 'running',\n )?.params.status as RuntimeCompletionStatus | undefined;\n return {\n status: cfg.leaseExpiredStatus ?? terminalExecutionStatus ?? 'succeeded',\n jobVersion: nextVersion(),\n };\n },\n\n failJobExecutionAsTimedOutActivity: async (params: {\n jobExecutionId: string;\n runAttemptId: string;\n expectedVersion: number;\n }) => {\n calls.push({name: 'failJobExecutionAsTimedOutActivity', params});\n if (cfg.failJobExecutionAsTimedOutError) {\n const {ApplicationFailure} = await import('@temporalio/common');\n throw ApplicationFailure.nonRetryable(cfg.failJobExecutionAsTimedOutError);\n }\n return {newVersion: nextVersion()};\n },\n\n activateJobListenerActivity: (params: {jobId: string; expectedVersion: number}) => {\n calls.push({name: 'activateJobListenerActivity', params});\n return (\n cfg.listenerActivated ?? {\n status: 'running',\n jobStatus: 'running',\n jobVersion: nextVersion(),\n executionCount: 0,\n }\n );\n },\n\n // Each call consumes the next scripted drain result. An exhausted script means\n // \"no events buffered\", which parks the listener until a signal or its deadline.\n drainListenerEventsActivity: (params: {\n jobId: string;\n expectedSequence: number;\n maxSize?: number;\n }) => {\n calls.push({name: 'drainListenerEventsActivity', params});\n return cfg.drainResults?.shift() ?? {kind: 'empty'};\n },\n\n peekListenerBufferActivity: (params: {jobId: string}) => {\n calls.push({name: 'peekListenerBufferActivity', params});\n return (\n cfg.peekResults?.shift() ?? {\n fireCount: 0,\n resolvePending: false,\n oldestAgeMs: 0,\n newestAgeMs: 0,\n }\n );\n },\n\n resolveJobListenerActivity: (params: {jobId: string; reason: string}) => {\n calls.push({name: 'resolveJobListenerActivity', params});\n return cfg.listenerResolved ?? {status: 'succeeded', jobVersion: nextVersion()};\n },\n\n settleListenerJobExecutionActivity: (params: {\n jobExecutionId: string;\n status: 'failed' | 'cancelled';\n }) => {\n calls.push({name: 'settleListenerJobExecutionActivity', params});\n },\n\n recordListenerFiringOutcomeActivity: (params: {\n outcome: 'succeeded' | 'failed' | 'cancelled';\n }) => {\n calls.push({name: 'recordListenerFiringOutcomeActivity', params});\n },\n };\n}\n"],"names":["resolve","TestWorkflowEnvironment","Worker","JOB_CLAIMED_SIGNAL","JOB_FINISHED_SIGNAL","JOB_LEASE_EXPIRED_SIGNAL","TASK_QUEUE","WORKFLOWS_PATH","dirname","cfg","setCfg","value","calls","versionSeq","pendingJobOutcomes","Map","nextVersion","resetCalls","clear","callsNamed","name","filter","c","setRunAttemptStatusCalls","setJobStatusCalls","setExecutionStatusCalls","listenerFiringOutcomeCalls","resolveJobListenerCalls","settleListenerCalls","dagJob","id","key","deps","options","mode","status","jobExecutionId","executionVersion","executionTimeoutMs","listeningTimeoutMs","maxExecutions","onResolve","hasActivationCondition","dependencies","runner","version","makeDag","jobs","workflowRunId","runAttemptId","workspaceId","projectId","runVersion","runTimeoutMs","testEnv","worker","workerRunPromise","setupEnv","createLocal","create","connection","nativeConnection","taskQueue","workflowsPath","activities","createMockActivities","run","catch","teardownEnv","shutdown","teardown","loadRunAttemptDag","push","params","dag","setRunAttemptStatus","initialRunStatus","newVersion","setJobStatus","runningJobStatus","evaluateJobActivationsActivity","map","job","decision","activationDecisions","get","jobId","kind","setJobExecutionStatus","outcome","delete","handle","signal","duplicateSignal","bulkSetStepStatuses","queueJobExecutionActivity","queueError","ApplicationFailure","nonRetryable","queued","skipSignal","jobResults","client","workflow","getHandle","claimedAt","skipOutcomeSignal","signalLeaseExpired","signalBoth","set","resolveLeaseExpiredJobExecutionActivity","leaseExpiredStatus","resolveJobStatusFromJobExecutionsActivity","resolveJobStatusError","terminalExecutionStatus","reverse","find","call","jobVersion","failJobExecutionAsTimedOutActivity","failJobExecutionAsTimedOutError","activateJobListenerActivity","listenerActivated","jobStatus","executionCount","drainListenerEventsActivity","drainResults","shift","peekListenerBufferActivity","peekResults","fireCount","resolvePending","oldestAgeMs","newestAgeMs","resolveJobListenerActivity","listenerResolved","settleListenerJobExecutionActivity","recordListenerFiringOutcomeActivity"],"mappings":"AAAA,SAAQA,OAAO,QAAO,YAAY;AAClC,SAAQC,uBAAuB,QAAO,sBAAsB;AAC5D,SAAQC,MAAM,QAAO,qBAAqB;AAS1C,SAAQC,kBAAkB,EAAEC,mBAAmB,EAAEC,wBAAwB,QAAO,kBAAkB;AAElG,MAAMC,aAAa;AACnB,MAAMC,iBAAiBP,QAAQ,YAAYQ,OAAO,EAAE;AAEpD,SAAQF,UAAU,GAAE;AA+CpB,OAAO,IAAIG,IAAgB;AAE3B,OAAO,SAASC,OAAOC,KAAiB;IACtCF,MAAME;AACR;AAQA,OAAO,IAAIC,MAAsB;AACjC,IAAIC;AACJ,MAAMC,qBAAqB,IAAIC;AAS/B,SAASC;IACP,OAAO,EAAEH;AACX;AAEA,OAAO,SAASI;IACdL,QAAQ,EAAE;IACVC,aAAa;IACbC,mBAAmBI,KAAK;AAC1B;AAEA,OAAO,SAASC,WAAWC,IAAY;IACrC,OAAOR,MAAMS,MAAM,CAAC,CAACC,IAAMA,EAAEF,IAAI,KAAKA;AACxC;AAEA,OAAO,SAASG;IACd,OAAOJ,WAAW;AAIpB;AAEA,OAAO,SAASK;IACd,OAAOL,WAAW;AAIpB;AAEA,OAAO,SAASM;IACd,OAAON,WAAW;AAIpB;AAEA,OAAO,SAASO;IACd,OAAOP,WAAW;AAIpB;AAEA,OAAO,SAASQ;IACd,OAAOR,WAAW;AAIpB;AAEA,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