Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | 1x 1x 1x 6x 6x 6x 6x 6x 6x 6x 3x 3x 3x 1x 2x 1x 3x 1x | const { getActiveFlowId } = require('../shared/activeFlow')
const { requirePermission } = require('../utils/requirePermission')
const { getJob } = require('../utils/jobsTable')
function jsonResponse(statusCode, body) {
return {
statusCode,
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
},
body: JSON.stringify(body)
}
}
async function getForkJobHandler(event) {
try {
const flowId = await getActiveFlowId(event)
Iif (!flowId) {
return jsonResponse(401, { error: 'Missing flow context' })
}
const jobId = event.pathParameters?.jobId
const job = await getJob(jobId)
if (!job || job.type !== 'fork' || job.flowId !== flowId) {
return jsonResponse(404, { error: 'Fork job not found' })
}
const response = { status: job.status, ...(job.progress && { progress: job.progress }) }
if (job.status === 'completed') {
response.result = job.result
} else if (job.status === 'failed') {
response.error = job.error
}
return jsonResponse(200, response)
} catch (error) {
console.error('[get-fork-job] Exception:', error.message, error.stack)
return jsonResponse(500, { error: 'Failed to get fork job' })
}
}
exports.handler = requirePermission(getForkJobHandler, { permission: 'entities:create' })
|