@cognigy/rest-api-client
Version:
Cognigy REST-Client
16 lines • 901 B
JavaScript
/* Custom Modules */
import { BadRequestError } from "../../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);
}
export const validateBatchOperations = (operations, loggerStack, maxAmountOfOperationsPerBatchCall) => {
maxAmountOfOperationsPerBatchCall = maxAmountOfOperationsPerBatchCall || defaultMaxAmountOfOperationsPerBatchCall;
if (Array.isArray(operations) &&
operations.length > maxAmountOfOperationsPerBatchCall) {
throw new BadRequestError(`Only ${maxAmountOfOperationsPerBatchCall} operations per batch call allowed`, loggerStack);
}
};
//# sourceMappingURL=operations.js.map