@bitrix24/b24jssdk
Version:
Bitrix24 REST API JavaScript SDK
61 lines (58 loc) • 2.99 kB
JavaScript
/**
* @package @bitrix24/b24jssdk
* @version 3.0.0
* @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 });
const DEFAULT_MAX_PAGES = 1e4;
function resolveMaxPages(action, maxPages) {
if (void 0 === maxPages) {
return DEFAULT_MAX_PAGES;
}
if (!Number.isInteger(maxPages) || maxPages < 1) {
throw new SdkError({
code: "JSSDK_ACTION_INVALID_MAX_PAGES",
description: `${action}: \`maxPages\` must be a positive integer \u2014 it is the number of pages the walk may read before it gives up. Omit it to use the default of ${DEFAULT_MAX_PAGES}.`,
status: 400
});
}
return maxPages;
}
__name(resolveMaxPages, "resolveMaxPages");
function maxPagesExceededError(action, method, maxPages) {
return new SdkError({
code: "JSSDK_ACTION_MAX_PAGES_EXCEEDED",
description: `${action}: stopped after ${maxPages} pages of \`${method}\` without reaching the end of the data. Either the read is genuinely larger than the ceiling \u2014 raise \`maxPages\` \u2014 or the walk is not making progress, which happens when the page condition is not applied and the cursor repeats values whose order the SDK cannot judge (a cursor that demonstrably moves backwards is reported earlier, as JSSDK_ACTION_CURSOR_WENT_BACKWARDS). The eager helpers (callList / callTail) return the pages they did read, with this error attached \u2014 so check \`isSuccess\` rather than assuming a returned list is whole. A streaming helper (fetchList / fetchTail) has already yielded every page it read, and throws this instead.`,
status: 500
});
}
__name(maxPagesExceededError, "maxPagesExceededError");
function walkAbortedError(action, method) {
return new SdkError({
code: "JSSDK_ACTION_ABORTED",
description: `${action}: the walk over \`${method}\` was aborted through its \`signal\`. The eager helpers (callList / callTail) return the pages they did read, with this error attached; a streaming helper (fetchList / fetchTail) has already yielded every page it read, and throws this instead.`,
status: 400
});
}
__name(walkAbortedError, "walkAbortedError");
function assertNotAborted(signal, action, method) {
if (true === signal?.aborted) {
throw walkAbortedError(action, method);
}
}
__name(assertNotAborted, "assertNotAborted");
const WALK_BOUNDS_ERROR_CODES = /* @__PURE__ */ new Set([
"JSSDK_ACTION_MAX_PAGES_EXCEEDED",
"JSSDK_ACTION_ABORTED"
]);
function isWalkBoundsError(error) {
return error instanceof SdkError && WALK_BOUNDS_ERROR_CODES.has(error.code);
}
__name(isWalkBoundsError, "isWalkBoundsError");
export { DEFAULT_MAX_PAGES, assertNotAborted, isWalkBoundsError, maxPagesExceededError, resolveMaxPages, walkAbortedError };
//# sourceMappingURL=_walk-bounds.mjs.map