UNPKG

@grouparoo/core

Version:
33 lines (32 loc) 1.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ProcessExports = void 0; const clsTask_1 = require("../../classes/tasks/clsTask"); const ExportProcessor_1 = require("../../models/ExportProcessor"); const Mapping_1 = require("../../models/Mapping"); const Option_1 = require("../../models/Option"); class ProcessExports extends clsTask_1.CLSTask { constructor() { super(...arguments); this.name = "export:process"; this.description = "process exports with an export processor"; this.frequency = 0; this.queue = "exports"; this.inputs = { exportProcessorId: { required: true }, }; } async runWithinTransaction({ exportProcessorId, }) { const exportProcessor = await ExportProcessor_1.ExportProcessor.scope(null).findOne({ where: { id: exportProcessorId, state: "pending" }, }); if (!exportProcessor) return; // may have been processed const destination = await exportProcessor.$get("destination", { include: [Option_1.Option, Mapping_1.Mapping], scope: null, }); await destination.runExportProcessor(exportProcessor); } } exports.ProcessExports = ProcessExports;