@grouparoo/core
Version:
The Grouparoo Core
39 lines (38 loc) • 1.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExportSend = void 0;
const Destination_1 = require("../../models/Destination");
const Export_1 = require("../../models/Export");
const Option_1 = require("../../models/Option");
const Mapping_1 = require("../../models/Mapping");
const clsTask_1 = require("../../classes/tasks/clsTask");
class ExportSend extends clsTask_1.CLSTask {
constructor() {
super(...arguments);
this.name = "export:send";
this.description = "send the export to the destination";
this.frequency = 0;
this.queue = "exports";
this.inputs = {
destinationId: { required: true },
exportId: { required: true },
};
}
async runWithinTransaction({ destinationId, exportId, }) {
const destination = await Destination_1.Destination.scope(null).findOne({
where: { id: destinationId },
include: [Option_1.Option, Mapping_1.Mapping],
});
if (!destination)
return;
const _export = await Export_1.Export.findOne({
where: { id: exportId },
});
if (!_export)
return;
if (_export.state !== "pending")
return;
await destination.sendExport(_export);
}
}
exports.ExportSend = ExportSend;