@bull-board/api
Version:
A Dashboard server API built on top of bull or bullmq.
47 lines • 1.6 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.jobFlowHandler = void 0;
const job_1 = require("../providers/job");
const queue_1 = require("../providers/queue");
const flow_1 = require("../providers/flow");
const bullMQ_1 = require("../queueAdapters/bullMQ");
const simplifyNode = async (node) => {
if (!node || !node.job.id) {
return null;
}
const children = await Promise.all((node.children || []).map(simplifyNode));
const state = await node.job.getState();
return {
id: node.job.id,
name: node.job.name,
progress: node.job.progress,
state,
queueName: node.job.queueName,
children: children.filter((n) => !!n),
};
};
async function getJobFlow(_req, job, queue, flowTree) {
var _a;
const jobId = job.id;
if (!(queue instanceof bullMQ_1.BullMQAdapter) || !flowTree) {
return {
status: 200,
body: {
nodeId: jobId,
flowRoot: null,
isFlowNode: false,
},
};
}
const rootSimplified = await simplifyNode(flowTree);
return {
status: 200,
body: {
nodeId: jobId,
isFlowNode: ((_a = rootSimplified === null || rootSimplified === void 0 ? void 0 : rootSimplified.children.length) !== null && _a !== void 0 ? _a : 0) > 0,
flowRoot: rootSimplified,
},
};
}
exports.jobFlowHandler = (0, queue_1.queueProvider)((0, job_1.jobProvider)((0, flow_1.flowProvider)(getJobFlow)));
//# sourceMappingURL=jobFlow.js.map