{"version":3,"file":"call.mjs","sources":["../../../../../src/core/actions/v2/call.ts"],"sourcesContent":["import type { ActionOptions } from '../abstract-action'\nimport type { TypeCallParams } from '../../../types/http'\nimport type { AjaxResult } from '../../http/ajax-result'\nimport { AbstractAction } from '../abstract-action'\nimport { versionManager } from '../../version-manager'\nimport { ApiVersion } from '../../../types/b24'\nimport { LoggerFactory } from '../../../logger'\n\nexport type ActionCallV2 = ActionOptions & {\n  method: string\n  params?: TypeCallParams\n  requestId?: string\n}\n\n/**\n * Calls the Bitrix24 REST API method `restApi:v2`\n *\n * @todo add docs\n */\nexport class CallV2 extends AbstractAction {\n  /**\n   * Calls the Bitrix24 REST API method.\n   *\n   * @template T - The expected data type in the response (default is `unknown`).\n   *\n   * @param {ActionCallV2} options - parameters for executing the request.\n   *     - `method: string` - REST API method name (eg: `crm.item.get`)\n   *     - `params?: TypeCallParams` - Parameters for calling the method.\n   *     - `requestId?: string` - Unique request identifier for tracking. Used for query deduplication and debugging.\n   *\n   * @returns {Promise<AjaxResult<T>>} A promise that resolves to the result of an REST API call.\n   *\n   * @example\n   * import { EnumCrmEntityTypeId } from '@bitrix24/b24jssdk'\n   *\n   * interface CrmItem { id: number, name: string, lastName: string }\n   * const response = await b24.actions.v2.call.make<{ item: CrmItem }>({\n   *   method: 'crm.item.get',\n   *   params: {\n   *     entityTypeId: EnumCrmEntityTypeId.contact,\n   *     id: 123\n   *   },\n   *   requestId: 'item-123'\n   * })\n   * if (!response.isSuccess) {\n   *   throw new Error(`Problem: ${response.getErrorMessages().join('; ')}`)\n   * }\n   * console.log(response.getData().result.item.name)\n   */\n  public override async make<T = unknown>(options: ActionCallV2): Promise<AjaxResult<T>> {\n    if (versionManager.isSupport(ApiVersion.v3, options.method)) {\n      LoggerFactory.forcedLog(\n        this._logger,\n        'warning',\n        `The method ${options.method} is available in restApi:v3. It's worth migrating to the new API.`,\n        {\n          method: options.method,\n          requestId: options.requestId,\n          code: 'JSSDK_CORE_METHOD_AVAILABLE_IN_API_V3'\n        }\n      )\n    }\n\n    const params = options.params || {}\n    return this._b24.getHttpClient(ApiVersion.v2).call<T>(options.method, params, options.requestId)\n  }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAmBO,MAAM,eAAe,cAAA,CAAe;AAAA,EAnB3C;AAmB2C,IAAA,MAAA,CAAA,IAAA,EAAA,QAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA8BzC,MAAsB,KAAkB,OAAA,EAA+C;AACrF,IAAA,IAAI,eAAe,SAAA,CAAU,UAAA,CAAW,EAAA,EAAI,OAAA,CAAQ,MAAM,CAAA,EAAG;AAC3D,MAAA,aAAA,CAAc,SAAA;AAAA,QACZ,IAAA,CAAK,OAAA;AAAA,QACL,SAAA;AAAA,QACA,CAAA,WAAA,EAAc,QAAQ,MAAM,CAAA,iEAAA,CAAA;AAAA,QAC5B;AAAA,UACE,QAAQ,OAAA,CAAQ,MAAA;AAAA,UAChB,WAAW,OAAA,CAAQ,SAAA;AAAA,UACnB,IAAA,EAAM;AAAA;AACR,OACF;AAAA,IACF;AAEA,IAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,MAAA,IAAU,EAAC;AAClC,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,aAAA,CAAc,UAAA,CAAW,EAAE,CAAA,CAAE,IAAA,CAAQ,OAAA,CAAQ,MAAA,EAAQ,MAAA,EAAQ,OAAA,CAAQ,SAAS,CAAA;AAAA,EACjG;AACF;;;;"}