@bitrix24/b24jssdk
Version:
Bitrix24 REST API JavaScript SDK
68 lines (65 loc) • 1.89 kB
JavaScript
/**
* @package @bitrix24/b24jssdk
* @version 1.0.5
* @copyright (c) 2026 Bitrix24
* @license MIT
* @see https://github.com/bitrix24/b24jssdk
* @see https://bitrix24.github.io/b24jssdk/
*/
import { SdkError } from '../../sdk-error.mjs';
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
class ParseRow {
static {
__name(this, "ParseRow");
}
static getBatchCommand(row, options) {
if (row) {
if (typeof row === "object" && "method" in row && typeof row.method === "string") {
return {
method: row.method,
query: row.params,
as: row.as ?? options.asDefaultValue,
parallel: row.parallel ?? options.parallelDefaultValue
};
}
if (Array.isArray(row) && row.length > 0 && typeof row[0] === "string") {
return {
method: row[0],
query: row[1],
as: options.asDefaultValue,
parallel: options.parallelDefaultValue
};
}
}
throw new SdkError({
code: "JSSDK_INTERACTION_BATCH_ROW_FAIL",
description: `There were difficulties parsing the command for batch.
${JSON.stringify({
row,
options
})}`,
status: 500
});
}
static getMethodsFromCommands(calls) {
const result = [];
const optsFake = {
parallelDefaultValue: false
};
if (Array.isArray(calls)) {
calls.forEach((row) => {
const command = ParseRow.getBatchCommand(row, optsFake);
result.push(command.method);
});
} else {
Object.entries(calls).forEach(([index, row]) => {
const command = ParseRow.getBatchCommand(row, { ...optsFake, asDefaultValue: index });
result.push(command.method);
});
}
return result;
}
}
export { ParseRow };
//# sourceMappingURL=parse-row.mjs.map