n8n-nodes-everest-tms
Version:
Everest TMS n8n integration
34 lines • 1.7 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.executeExportOperations = executeExportOperations;
const GenericFunctions_1 = require("../GenericFunctions");
async function executeExportOperations(itemIndex) {
const operation = this.getNodeParameter('operation', itemIndex);
if (operation === 'create') {
const type = this.getNodeParameter('type', itemIndex);
const format = this.getNodeParameter('format', itemIndex);
const fields = this.getNodeParameter('fields', itemIndex, []);
const filters = this.getNodeParameter('filters', itemIndex, {});
(0, GenericFunctions_1.validateRequiredFields)({ type, format }, ['type', 'format']);
const body = {
type,
format,
};
// Add fields if specified
if (fields && fields.length > 0) {
body.fields = fields;
}
// Process filters - now as a simple object instead of array
if (filters && Object.keys(filters).length > 0) {
let cleanedFilters = (0, GenericFunctions_1.cleanObject)(filters);
// Handle date conversion for Europe/Paris timezone
cleanedFilters = (0, GenericFunctions_1.convertDateFieldsToParisTimezone)(cleanedFilters, ['date_between_start', 'date_between_end']);
// Add the filters object directly to the body
body.filters = cleanedFilters;
}
const response = await GenericFunctions_1.everestApiRequest.call(this, 'POST', '/exports/create', body);
return response;
}
throw new Error(`The operation "${operation}" is not known!`);
}
//# sourceMappingURL=ExportOperations.js.map