@nestbox-ai/cli
Version:
The cli tools that helps developers to build agents
78 lines • 4.37 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.registerDocProcJobCommands = registerDocProcJobCommands;
const chalk_1 = __importDefault(require("chalk"));
const apiUtils_1 = require("./apiUtils");
const helpers_1 = require("./helpers");
function registerDocProcJobCommands(docProcCommand) {
const jobCommand = docProcCommand.command('job').description('Monitor document-processing jobs');
jobCommand
.command('list')
.description('List document-processing jobs')
.option('--state <state>', 'Filter state')
.option('--page <page>', 'Page number', '1')
.option('--limit <limit>', 'Page size', '20')
.option('--project <projectId>', 'Project ID or name (defaults to current project)')
.option('--instance <instanceId>', 'Document processing instance ID')
.option('--json', 'Output JSON')
.action((options) => {
(0, helpers_1.withDocProcErrorHandling)(() => __awaiter(this, void 0, void 0, function* () {
const apis = (0, apiUtils_1.createDocProcApis)();
if (!apis)
return;
const context = yield (0, helpers_1.resolveDocProcContext)(apis, options);
const response = yield apis.documentProcessingApi.documentProcessingControllerListJobs(context.projectId, context.instanceId, {
params: {
page: Number(options.page),
limit: Number(options.limit),
state: options.state,
},
});
const data = (0, helpers_1.getResponseData)(response);
if ((0, helpers_1.maybePrintJson)(data, options.json))
return;
const jobs = (data === null || data === void 0 ? void 0 : data.data) || data || [];
if (!jobs.length) {
console.log(chalk_1.default.yellow('No jobs found.'));
return;
}
(0, helpers_1.printSimpleTable)(['Job ID', 'State', 'Document ID', 'Created At'], jobs.map((job) => [job.id || 'N/A', job.state || job.status || 'N/A', job.documentId || 'N/A', job.createdAt || 'N/A']));
}));
});
jobCommand
.command('status')
.description('Get job status by ID')
.requiredOption('--job <jobId>', 'Job ID')
.option('--full', 'Use full job endpoint instead of lightweight status')
.option('--project <projectId>', 'Project ID or name (defaults to current project)')
.option('--instance <instanceId>', 'Document processing instance ID')
.option('--json', 'Output JSON')
.action((options) => {
(0, helpers_1.withDocProcErrorHandling)(() => __awaiter(this, void 0, void 0, function* () {
const apis = (0, apiUtils_1.createDocProcApis)();
if (!apis)
return;
const context = yield (0, helpers_1.resolveDocProcContext)(apis, options);
const response = options.full
? yield apis.documentProcessingApi.documentProcessingControllerGetJob(context.projectId, context.instanceId, options.job)
: yield apis.documentProcessingApi.documentProcessingControllerGetJobStatus(context.projectId, context.instanceId, options.job);
const data = (0, helpers_1.getResponseData)(response);
if ((0, helpers_1.maybePrintJson)(data, options.json))
return;
console.log(JSON.stringify(data, null, 2));
}));
});
}
//# sourceMappingURL=job.js.map