@bitrix24/b24jssdk
Version:
Bitrix24 REST API JavaScript SDK
1 lines • 3.21 kB
Source Map (JSON)
{"version":3,"file":"version-manager.cjs","sources":["../../../src/core/version-manager.ts"],"sourcesContent":["import { ApiVersion } from '../types/b24'\nimport type {\n BatchCommandsArrayUniversal,\n BatchCommandsObjectUniversal,\n BatchNamedCommandsUniversal\n} from '../types/http'\n\n/**\n * Decides which REST API version a method is routed through.\n *\n * The SDK no longer maintains a hardcoded v3 method allowlist. A portal's set of\n * v3 methods is large and version/edition-dependent (the authoritative list is\n * the portal's own OpenAPI document, `rest.documentation.openapi`), so gating on\n * a static list both lagged behind the server and blocked valid methods. The\n * server is now the single source of truth: an unknown v3 method simply comes\n * back as `METHODNOTFOUNDEXCEPTION`.\n *\n * Consequences:\n * - `actions.v3.*` no longer pre-flight-rejects a method — it is sent to the v3\n * endpoint and the server validates it.\n * - v3 is opt-in only via the explicit `actions.v3.*` surface; version\n * auto-detection therefore defaults to v2 (the universal endpoint).\n */\nclass VersionManager {\n static create(): VersionManager {\n return new VersionManager()\n }\n\n /**\n * List of supported API versions.\n * The highest version must be first.\n */\n public getAllApiVersions(): ApiVersion[] {\n return [ApiVersion.v3, ApiVersion.v2]\n }\n\n /**\n * Retained for backward compatibility. The SDK no longer keeps a v3 method\n * allowlist, so support is not decided client-side any more — always returns\n * `true`. Method existence is validated by the server.\n */\n public isSupport(_version: ApiVersion, _method: string): boolean {\n return true\n }\n\n /**\n * Returns the API version to use when the caller did not specify one. With the\n * allowlist removed there is no client-side signal that a method is a v3\n * method, so this defaults to v2 (the universal endpoint). Use the explicit\n * `actions.v3.*` surface to call a method on v3.\n */\n public automaticallyObtainApiVersion(_method: string): ApiVersion {\n return ApiVersion.v2\n }\n\n /**\n * Batch counterpart of {@link automaticallyObtainApiVersion}. Defaults to v2;\n * call `actions.v3.batch.make` explicitly to run a batch on v3.\n */\n public automaticallyObtainApiVersionForBatch(\n _calls: BatchCommandsArrayUniversal | BatchCommandsObjectUniversal | BatchNamedCommandsUniversal\n ): ApiVersion {\n return ApiVersion.v2\n }\n}\n\nexport const versionManager = VersionManager.create()\n"],"names":["ApiVersion"],"mappings":";;;;;;;;;;;;;;AAuBA,MAAM,cAAA,CAAe;AAAA,EAvBrB;AAuBqB,IAAA,MAAA,CAAA,IAAA,EAAA,gBAAA,CAAA;AAAA;AAAA,EACnB,OAAO,MAAA,GAAyB;AAC9B,IAAA,OAAO,IAAI,cAAA,EAAe;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,iBAAA,GAAkC;AACvC,IAAA,OAAO,CAACA,cAAA,CAAW,EAAA,EAAIA,cAAA,CAAW,EAAE,CAAA;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,SAAA,CAAU,UAAsB,OAAA,EAA0B;AAC/D,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQO,8BAA8B,OAAA,EAA6B;AAChE,IAAA,OAAOA,cAAA,CAAW,EAAA;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,sCACL,MAAA,EACY;AACZ,IAAA,OAAOA,cAAA,CAAW,EAAA;AAAA,EACpB;AACF;AAEO,MAAM,cAAA,GAAiB,eAAe,MAAA;;;;"}