@cognigy/rest-api-client
Version:
Cognigy REST-Client
20 lines • 1.07 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateBatchOperations = void 0;
/* Custom Modules */
const errors_1 = require("../../errors");
let defaultMaxAmountOfOperationsPerBatchCall = 100;
// @ts-ignore
const { MAX_AMOUNT_OF_OPERATIONS_PER_BATCH_CALL } = process === null || process === void 0 ? void 0 : process.env;
if (MAX_AMOUNT_OF_OPERATIONS_PER_BATCH_CALL) {
defaultMaxAmountOfOperationsPerBatchCall = parseInt(MAX_AMOUNT_OF_OPERATIONS_PER_BATCH_CALL, 10);
}
const validateBatchOperations = (operations, loggerStack, maxAmountOfOperationsPerBatchCall) => {
maxAmountOfOperationsPerBatchCall = maxAmountOfOperationsPerBatchCall || defaultMaxAmountOfOperationsPerBatchCall;
if (Array.isArray(operations) &&
operations.length > maxAmountOfOperationsPerBatchCall) {
throw new errors_1.BadRequestError(`Only ${maxAmountOfOperationsPerBatchCall} operations per batch call allowed`, loggerStack);
}
};
exports.validateBatchOperations = validateBatchOperations;
//# sourceMappingURL=operations.js.map