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 46 47 48 49 50 51 52 | 1x 1x 1x 1x 1x 1x 5x 5x 5x 1x 5x 5x 5x 5x 5x 5x 5x 1x | const { getActiveFlowId } = require('../shared/activeFlow')
const { requirePermission } = require('../utils/requirePermission')
const { queryJobsByFlow } = require('../utils/jobsTable')
const { buildExportJobView } = require('../utils/exportJobView')
const DEFAULT_LIMIT = 20
const MAX_LIMIT = 100
function jsonResponse(statusCode, body) {
return {
statusCode,
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
},
body: JSON.stringify(body)
}
}
function parseLimit(rawLimit) {
const parsed = parseInt(rawLimit, 10)
if (!Number.isFinite(parsed)) return DEFAULT_LIMIT
return Math.min(Math.max(parsed, 1), MAX_LIMIT)
}
async function listExportJobsHandler(event) {
try {
const flowId = await getActiveFlowId(event)
const userId = event.requestContext?.authorizer?.claims?.sub
Iif (!flowId) {
return jsonResponse(401, { error: 'Missing flow context' })
}
const { items, nextToken } = await queryJobsByFlow({
flowId,
userId,
type: 'export',
limit: parseLimit(event.queryStringParameters?.limit),
nextToken: event.queryStringParameters?.nextToken
})
const views = await Promise.all(items.map(buildExportJobView))
return jsonResponse(200, { items: views, nextToken, hasMore: !!nextToken })
} catch (error) {
console.error('[list-export-jobs] Exception:', error.message, error.stack)
return jsonResponse(500, { error: 'Failed to list export jobs' })
}
}
exports.handler = requirePermission(listExportJobsHandler, { permission: 'entities:list' })
|