UNPKG

@bitrix24/b24jssdk

Version:

Bitrix24 REST API JavaScript SDK

1 lines • 3.3 kB
{"version":3,"file":"v3.mjs","sources":["../../../../../src/core/interaction/batch/v3.ts"],"sourcesContent":["import { AbstractInteractionBatch } from './abstract-interaction-batch'\nimport type { BatchResponsePayload } from './abstract-interaction-batch'\nimport type { AjaxResult } from '../../http/ajax-result'\nimport type { Result } from '../../result'\nimport type { ICallBatchResult } from '../../../types/http'\nimport { SdkError } from '../../sdk-error'\n\n/**\n * Working with batch requests in `restApi:v3`\n */\n\n/**\n * The **SDK's own** ceiling on commands in one `restApi:v3` batch.\n *\n * Not the portal's. 51 commands posted straight at the v3 batch endpoint came\n * back HTTP 200 with 51 results — measured on an on-premise build\n * (`SM_VERSION 26.700.0`). So the real v3 boundary, wherever it is, is above 51\n * and is not published anywhere we can read.\n *\n * 50 is chosen to match `restApi:v2`, where the server does enforce one:\n * `CRestUtil::BATCH_MAX_LENGTH = 50`, checked per command, over-length answered\n * with `ERROR_BATCH_LENGTH_EXCEEDED` — read in the portal's PHP sources rather\n * than measured. Holding both versions to one number keeps `batchByChunk`'s\n * chunking identical across them and keeps the failure client-side, where it is\n * a named error rather than whatever the server would do past its own limit.\n *\n * Raising it is a runtime change, not a documentation one: 51 is a lower bound,\n * not a boundary, and `batchByChunk` already covers callers who have more.\n */\nexport const MAX_BATCH_COMMANDS_V3 = 50\n\nexport class InteractionBatchV3 extends AbstractInteractionBatch {\n override get maxSize(): number {\n return MAX_BATCH_COMMANDS_V3\n }\n\n public override async prepareResponse<T>(response: AjaxResult<BatchResponsePayload<T>>): Promise<Result<ICallBatchResult<T>>> {\n if (!this.processingStrategy) {\n throw new SdkError({\n code: 'JSSDK_INTERACTION_BATCH_EMPTY_PROCESSING_STRATEGY',\n description: 'ProcessingStrategy not set',\n status: 500\n })\n }\n\n // const responseData = response.getData()\n const responseHelper = {\n requestId: response.getQuery().requestId,\n parallelDefaultValue: this.parallelDefaultValue,\n restrictionManager: this.restrictionManager,\n response\n }\n\n const results = await this.processingStrategy.prepareItems<T>(this._commands, responseHelper)\n\n return this.processingStrategy.handleResults<T>(this._commands, results, responseHelper)\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AA6BO,MAAM,qBAAA,GAAwB;AAE9B,MAAM,2BAA2B,wBAAA,CAAyB;AAAA,EA/BjE;AA+BiE,IAAA,MAAA,CAAA,IAAA,EAAA,oBAAA,CAAA;AAAA;AAAA,EAC/D,IAAa,OAAA,GAAkB;AAC7B,IAAA,OAAO,qBAAA;AAAA,EACT;AAAA,EAEA,MAAsB,gBAAmB,QAAA,EAAqF;AAC5H,IAAA,IAAI,CAAC,KAAK,kBAAA,EAAoB;AAC5B,MAAA,MAAM,IAAI,QAAA,CAAS;AAAA,QACjB,IAAA,EAAM,mDAAA;AAAA,QACN,WAAA,EAAa,4BAAA;AAAA,QACb,MAAA,EAAQ;AAAA,OACT,CAAA;AAAA,IACH;AAGA,IAAA,MAAM,cAAA,GAAiB;AAAA,MACrB,SAAA,EAAW,QAAA,CAAS,QAAA,EAAS,CAAE,SAAA;AAAA,MAC/B,sBAAsB,IAAA,CAAK,oBAAA;AAAA,MAC3B,oBAAoB,IAAA,CAAK,kBAAA;AAAA,MACzB;AAAA,KACF;AAEA,IAAA,MAAM,UAAU,MAAM,IAAA,CAAK,mBAAmB,YAAA,CAAgB,IAAA,CAAK,WAAW,cAAc,CAAA;AAE5F,IAAA,OAAO,KAAK,kBAAA,CAAmB,aAAA,CAAiB,IAAA,CAAK,SAAA,EAAW,SAAS,cAAc,CAAA;AAAA,EACzF;AACF;;;;"}