@bitrix24/b24jssdk 1.0.6 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README-AI.md +28 -3
- package/dist/esm/_virtual/_commonjsHelpers.mjs +1 -1
- package/dist/esm/_virtual/protobuf.mjs +1 -1
- package/dist/esm/_virtual/protobuf2.mjs +1 -1
- package/dist/esm/core/abstract-b24.mjs +1 -1
- package/dist/esm/core/actions/abstract-action.mjs +1 -1
- package/dist/esm/core/actions/abstract-batch.mjs +1 -1
- package/dist/esm/core/actions/manager.mjs +1 -1
- package/dist/esm/core/actions/v2/batch-by-chunk.mjs +1 -1
- package/dist/esm/core/actions/v2/batch.mjs +1 -1
- package/dist/esm/core/actions/v2/call-list.mjs +1 -1
- package/dist/esm/core/actions/v2/call.mjs +1 -1
- package/dist/esm/core/actions/v2/fetch-list.mjs +1 -1
- package/dist/esm/core/actions/v2/manager-v2.mjs +1 -1
- package/dist/esm/core/actions/v3/batch-by-chunk.mjs +1 -1
- package/dist/esm/core/actions/v3/batch.mjs +1 -1
- package/dist/esm/core/actions/v3/call-list.mjs +1 -1
- package/dist/esm/core/actions/v3/call.mjs +1 -1
- package/dist/esm/core/actions/v3/fetch-list.mjs +1 -1
- package/dist/esm/core/actions/v3/manager-v3.mjs +1 -1
- package/dist/esm/core/http/abstract-http.mjs +2 -2
- package/dist/esm/core/http/ajax-error.mjs +1 -1
- package/dist/esm/core/http/ajax-result.mjs +44 -4
- package/dist/esm/core/http/ajax-result.mjs.map +1 -1
- package/dist/esm/core/http/limiters/adaptive-delayer.mjs +1 -1
- package/dist/esm/core/http/limiters/manager.mjs +70 -38
- package/dist/esm/core/http/limiters/manager.mjs.map +1 -1
- package/dist/esm/core/http/limiters/operating-limiter.mjs +1 -1
- package/dist/esm/core/http/limiters/params-factory.mjs +3 -2
- package/dist/esm/core/http/limiters/params-factory.mjs.map +1 -1
- package/dist/esm/core/http/limiters/rate-limiter.mjs +1 -1
- package/dist/esm/core/http/v2.mjs +2 -2
- package/dist/esm/core/http/v3.mjs +2 -2
- package/dist/esm/core/interaction/batch/abstract-interaction-batch.mjs +1 -1
- package/dist/esm/core/interaction/batch/parse-row.mjs +1 -1
- package/dist/esm/core/interaction/batch/processing/interface-strategy.mjs +1 -1
- package/dist/esm/core/interaction/batch/processing/v2/abstract-processing.mjs +2 -2
- package/dist/esm/core/interaction/batch/processing/v2/abstract-processing.mjs.map +1 -1
- package/dist/esm/core/interaction/batch/processing/v2/as-array.mjs +1 -1
- package/dist/esm/core/interaction/batch/processing/v2/as-object.mjs +1 -1
- package/dist/esm/core/interaction/batch/processing/v3/abstract-processing.mjs +16 -9
- package/dist/esm/core/interaction/batch/processing/v3/abstract-processing.mjs.map +1 -1
- package/dist/esm/core/interaction/batch/processing/v3/as-array.mjs +1 -1
- package/dist/esm/core/interaction/batch/processing/v3/as-object.mjs +1 -1
- package/dist/esm/core/interaction/batch/v2.mjs +1 -1
- package/dist/esm/core/interaction/batch/v3.mjs +1 -1
- package/dist/esm/core/language/list.mjs +1 -1
- package/dist/esm/core/request-id-generator.mjs +1 -1
- package/dist/esm/core/result.mjs +1 -1
- package/dist/esm/core/sdk-error.mjs +1 -1
- package/dist/esm/core/tools/abstract-tool.mjs +1 -1
- package/dist/esm/core/tools/healthcheck.mjs +1 -1
- package/dist/esm/core/tools/manager.mjs +1 -1
- package/dist/esm/core/tools/ping.mjs +1 -1
- package/dist/esm/core/version-manager.mjs +1 -1
- package/dist/esm/frame/auth.mjs +1 -1
- package/dist/esm/frame/b24.mjs +1 -1
- package/dist/esm/frame/dialog.mjs +45 -5
- package/dist/esm/frame/dialog.mjs.map +1 -1
- package/dist/esm/frame/frame.mjs +1 -1
- package/dist/esm/frame/message/commands.mjs +1 -1
- package/dist/esm/frame/message/controller.mjs +1 -1
- package/dist/esm/frame/options.mjs +1 -1
- package/dist/esm/frame/parent.mjs +1 -1
- package/dist/esm/frame/placement.mjs +32 -9
- package/dist/esm/frame/placement.mjs.map +1 -1
- package/dist/esm/frame/slider.mjs +1 -1
- package/dist/esm/helper/abstract-helper.mjs +1 -1
- package/dist/esm/helper/app-manager.mjs +1 -1
- package/dist/esm/helper/currency-manager.mjs +1 -1
- package/dist/esm/helper/helper-manager.mjs +1 -1
- package/dist/esm/helper/license-manager.mjs +1 -1
- package/dist/esm/helper/options-manager.mjs +1 -1
- package/dist/esm/helper/payment-manager.mjs +1 -1
- package/dist/esm/helper/profile-manager.mjs +1 -1
- package/dist/esm/helper/use-b24-helper.mjs +1 -1
- package/dist/esm/hook/auth.mjs +1 -1
- package/dist/esm/hook/b24.mjs +1 -1
- package/dist/esm/index.d.mts +174 -11
- package/dist/esm/index.d.ts +174 -11
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/loader-b24frame.mjs +1 -1
- package/dist/esm/logger/abstract-logger.mjs +1 -1
- package/dist/esm/logger/browser.mjs +1 -1
- package/dist/esm/logger/formatter/abstract-formatter.mjs +1 -1
- package/dist/esm/logger/formatter/json-formatter.mjs +1 -1
- package/dist/esm/logger/formatter/line-formatter.mjs +1 -1
- package/dist/esm/logger/formatter/telegram-formatter.mjs +1 -1
- package/dist/esm/logger/handler/abstract-handler.mjs +1 -1
- package/dist/esm/logger/handler/consola-adapter.mjs +1 -1
- package/dist/esm/logger/handler/console-handler.mjs +1 -1
- package/dist/esm/logger/handler/console-v2-handler.mjs +1 -1
- package/dist/esm/logger/handler/memory-handler.mjs +1 -1
- package/dist/esm/logger/handler/stream-handler.mjs +1 -1
- package/dist/esm/logger/handler/telegram-handler.mjs +1 -1
- package/dist/esm/logger/handler/winston-adapter.mjs +1 -1
- package/dist/esm/logger/logger-factory.mjs +1 -1
- package/dist/esm/logger/logger.mjs +1 -1
- package/dist/esm/logger/null-logger.mjs +1 -1
- package/dist/esm/logger/processor/memory-usage-processor.mjs +1 -1
- package/dist/esm/logger/processor/pid-processor.mjs +1 -1
- package/dist/esm/oauth/auth.mjs +1 -1
- package/dist/esm/oauth/b24.mjs +1 -1
- package/dist/esm/oauth/refresh-token-error.mjs +1 -1
- package/dist/esm/pullClient/abstract-connector.mjs +1 -1
- package/dist/esm/pullClient/channel-manager.mjs +1 -1
- package/dist/esm/pullClient/channel-manager.mjs.map +1 -1
- package/dist/esm/pullClient/client.mjs +1 -1
- package/dist/esm/pullClient/errors.mjs +1 -1
- package/dist/esm/pullClient/json-rpc.mjs +1 -1
- package/dist/esm/pullClient/long-polling-connector.mjs +1 -1
- package/dist/esm/pullClient/protobuf/index.mjs +1 -1
- package/dist/esm/pullClient/protobuf/model.mjs +1 -1
- package/dist/esm/pullClient/protobuf/protobuf.mjs +1 -1
- package/dist/esm/pullClient/shared-config.mjs +1 -1
- package/dist/esm/pullClient/storage-manager.mjs +1 -1
- package/dist/esm/pullClient/web-socket-connector.mjs +1 -1
- package/dist/esm/tools/browser.mjs +1 -1
- package/dist/esm/tools/environment.mjs +1 -1
- package/dist/esm/tools/formatters/iban.mjs +1 -1
- package/dist/esm/tools/formatters/numbers.mjs +1 -1
- package/dist/esm/tools/index.mjs +1 -1
- package/dist/esm/tools/scroll-size.mjs +1 -1
- package/dist/esm/tools/text.mjs +1 -1
- package/dist/esm/tools/type.mjs +1 -1
- package/dist/esm/tools/use-formatters.mjs +1 -1
- package/dist/esm/tools/uuidv7.mjs +1 -1
- package/dist/esm/types/b24-helper.mjs +1 -1
- package/dist/esm/types/b24.mjs +1 -1
- package/dist/esm/types/bizproc/index.mjs +1 -1
- package/dist/esm/types/catalog/index.mjs +1 -1
- package/dist/esm/types/common.mjs +1 -1
- package/dist/esm/types/crm/entity-type.mjs +1 -1
- package/dist/esm/types/crm/productrow.mjs +1 -1
- package/dist/esm/types/logger.mjs +1 -1
- package/dist/esm/types/pull.mjs +1 -1
- package/dist/umd/index.js +209 -66
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/index.min.js +19 -19
- package/dist/umd/index.min.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.d.ts
CHANGED
|
@@ -1324,6 +1324,51 @@ interface RestrictionParams {
|
|
|
1324
1324
|
* Default: 1_000
|
|
1325
1325
|
*/
|
|
1326
1326
|
retryDelay?: number;
|
|
1327
|
+
/**
|
|
1328
|
+
* Whether to retry on transport-level errors (`NETWORK_ERROR`, `REQUEST_TIMEOUT`).
|
|
1329
|
+
*
|
|
1330
|
+
* Default: `true` — preserves the historical retry behaviour.
|
|
1331
|
+
*
|
|
1332
|
+
* Set to `false` for **non-idempotent** calls (e.g. `crm.documentgenerator.document.add`,
|
|
1333
|
+
* any `*.add` that creates an entity, file uploads). When the request times out
|
|
1334
|
+
* client-side, the server may still have processed it successfully — retrying then
|
|
1335
|
+
* creates duplicates. With `retryOnNetworkError: false` the SDK immediately throws
|
|
1336
|
+
* `NETWORK_ERROR` / `REQUEST_TIMEOUT` instead of retrying.
|
|
1337
|
+
*
|
|
1338
|
+
* For long-running heavy operations also raise the axios timeout:
|
|
1339
|
+
* ```ts
|
|
1340
|
+
* const clientAxios = $b24.getHttpClient(ApiVersion.v2).ajaxClient
|
|
1341
|
+
* clientAxios.defaults.timeout = 120_000
|
|
1342
|
+
* ```
|
|
1343
|
+
*/
|
|
1344
|
+
retryOnNetworkError?: boolean;
|
|
1345
|
+
/**
|
|
1346
|
+
* Additional error codes that must be thrown as exceptions immediately,
|
|
1347
|
+
* without any retry. Merged with the SDK's built-in hard list — you can
|
|
1348
|
+
* only **add** codes, not remove built-ins (auth / fatal codes are always hard).
|
|
1349
|
+
*
|
|
1350
|
+
* Use this for business-specific or custom REST methods whose error codes
|
|
1351
|
+
* the SDK doesn't know about (otherwise the SDK treats unknown codes as
|
|
1352
|
+
* transient and retries them with backoff).
|
|
1353
|
+
*
|
|
1354
|
+
* @example
|
|
1355
|
+
* ```ts
|
|
1356
|
+
* await $b24.setRestrictionManagerParams({
|
|
1357
|
+
* ...ParamsFactory.getDefault(),
|
|
1358
|
+
* hardErrorCodes: ['DOCUMENT_GENERATOR_ALREADY_IN_QUEUE', 'MY_APP_BAD_PAYLOAD']
|
|
1359
|
+
* })
|
|
1360
|
+
* ```
|
|
1361
|
+
*/
|
|
1362
|
+
hardErrorCodes?: string[];
|
|
1363
|
+
/**
|
|
1364
|
+
* Additional error codes that should be returned inside `AjaxResult` as a
|
|
1365
|
+
* soft error instead of thrown. Merged with the SDK's built-in soft list.
|
|
1366
|
+
*
|
|
1367
|
+
* Use this when your application expects to inspect a specific REST error
|
|
1368
|
+
* code as part of normal control flow (e.g. validation errors from a
|
|
1369
|
+
* custom v3 endpoint).
|
|
1370
|
+
*/
|
|
1371
|
+
softErrorCodes?: string[];
|
|
1327
1372
|
}
|
|
1328
1373
|
/**
|
|
1329
1374
|
* Limiter operation statistics
|
|
@@ -2534,7 +2579,21 @@ type BatchPayload<C> = {
|
|
|
2534
2579
|
readonly time: PayloadTime;
|
|
2535
2580
|
};
|
|
2536
2581
|
type Payload<P> = TypeDescriptionErrorV3 | TypeDescriptionError | GetPayload<P> | ListPayload<P> | BatchPayload<P>;
|
|
2537
|
-
|
|
2582
|
+
/**
|
|
2583
|
+
* Public shape of a successful REST response, as exposed by `AjaxResult.getData()`.
|
|
2584
|
+
*
|
|
2585
|
+
* The Bitrix24 REST API always wraps a success response in `{ result, time }` —
|
|
2586
|
+
* this is true for both `restApi:v2` and `restApi:v3`. Any v2-only envelope
|
|
2587
|
+
* fields (`next`, `total`) are intentionally NOT part of this type: they have
|
|
2588
|
+
* no `restApi:v3` counterpart, and the SDK's `actions.v{2,3}.{callList,fetchList}`
|
|
2589
|
+
* helpers handle pagination internally so consumers never need to read them.
|
|
2590
|
+
*
|
|
2591
|
+
* @see GetPayload
|
|
2592
|
+
*/
|
|
2593
|
+
type SuccessPayload<P> = {
|
|
2594
|
+
readonly result: P;
|
|
2595
|
+
readonly time: PayloadTime;
|
|
2596
|
+
};
|
|
2538
2597
|
|
|
2539
2598
|
type AjaxQuery = Readonly<{
|
|
2540
2599
|
method: string;
|
|
@@ -2561,9 +2620,35 @@ declare class AjaxResult<T = unknown> extends Result<Payload<T>> implements IRes
|
|
|
2561
2620
|
getData(): undefined | SuccessPayload<T>;
|
|
2562
2621
|
/**
|
|
2563
2622
|
* Alias for isMore
|
|
2623
|
+
*
|
|
2624
|
+
* @deprecated Will be removed in `2.0.0`. Tied to the `restApi:v2` envelope
|
|
2625
|
+
* field `next`, which `restApi:v3` does not return. Use the SDK's list
|
|
2626
|
+
* helpers — they hide pagination entirely:
|
|
2627
|
+
* - `restApi:v2`: {@link CallListV2.make `b24.actions.v2.callList.make`} or {@link FetchListV2.make `b24.actions.v2.fetchList.make`}
|
|
2628
|
+
* - `restApi:v3`: {@link CallListV3.make `b24.actions.v3.callList.make`} or {@link FetchListV3.make `b24.actions.v3.fetchList.make`}
|
|
2629
|
+
*
|
|
2630
|
+
* @removed 2.0.0
|
|
2564
2631
|
*/
|
|
2565
2632
|
hasMore(): boolean;
|
|
2633
|
+
/**
|
|
2634
|
+
* @deprecated Will be removed in `2.0.0`. Tied to the `restApi:v2` envelope
|
|
2635
|
+
* field `next`, which `restApi:v3` does not return. Use the SDK's list
|
|
2636
|
+
* helpers — they hide pagination entirely:
|
|
2637
|
+
* - `restApi:v2`: {@link CallListV2.make `b24.actions.v2.callList.make`} or {@link FetchListV2.make `b24.actions.v2.fetchList.make`}
|
|
2638
|
+
* - `restApi:v3`: {@link CallListV3.make `b24.actions.v3.callList.make`} or {@link FetchListV3.make `b24.actions.v3.fetchList.make`}
|
|
2639
|
+
*
|
|
2640
|
+
* @removed 2.0.0
|
|
2641
|
+
*/
|
|
2566
2642
|
isMore(): boolean;
|
|
2643
|
+
/**
|
|
2644
|
+
* @deprecated Will be removed in `2.0.0`. Tied to the `restApi:v2` envelope
|
|
2645
|
+
* field `total`, which `restApi:v3` does not return. For `restApi:v3` the
|
|
2646
|
+
* SDK exposes element counts via the `aggregate` action (`count` /
|
|
2647
|
+
* `countDistinct`); for `restApi:v2` use the list helpers, which iterate
|
|
2648
|
+
* without exposing `total`.
|
|
2649
|
+
*
|
|
2650
|
+
* @removed 2.0.0
|
|
2651
|
+
*/
|
|
2567
2652
|
getTotal(): number;
|
|
2568
2653
|
getStatus(): number;
|
|
2569
2654
|
getQuery(): Readonly<AjaxQuery>;
|
|
@@ -2571,9 +2656,25 @@ declare class AjaxResult<T = unknown> extends Result<Payload<T>> implements IRes
|
|
|
2571
2656
|
* Alias for getNext
|
|
2572
2657
|
* @param http
|
|
2573
2658
|
*
|
|
2574
|
-
* @
|
|
2659
|
+
* @deprecated Will be removed in `2.0.0`. `restApi:v3` does not support
|
|
2660
|
+
* `getNext()` (the v2 envelope field `next` does not exist). Use the SDK's
|
|
2661
|
+
* list helpers instead — they hide pagination entirely:
|
|
2662
|
+
* - `restApi:v2`: {@link CallListV2.make `b24.actions.v2.callList.make`} or {@link FetchListV2.make `b24.actions.v2.fetchList.make`}
|
|
2663
|
+
* - `restApi:v3`: {@link CallListV3.make `b24.actions.v3.callList.make`} or {@link FetchListV3.make `b24.actions.v3.fetchList.make`}
|
|
2664
|
+
*
|
|
2665
|
+
* @removed 2.0.0
|
|
2575
2666
|
*/
|
|
2576
2667
|
fetchNext(http: TypeHttp): Promise<AjaxResult<T> | null>;
|
|
2668
|
+
/**
|
|
2669
|
+
* @deprecated Will be removed in `2.0.0`. Throws on `restApi:v3` because the
|
|
2670
|
+
* v2 envelope field `next` is not part of the v3 protocol. Use the SDK's
|
|
2671
|
+
* list helpers instead — they hide pagination entirely:
|
|
2672
|
+
* - `restApi:v2`: {@link CallListV2.make `b24.actions.v2.callList.make`} or {@link FetchListV2.make `b24.actions.v2.fetchList.make`}
|
|
2673
|
+
* - `restApi:v3`: {@link CallListV3.make `b24.actions.v3.callList.make`} or {@link FetchListV3.make `b24.actions.v3.fetchList.make`}
|
|
2674
|
+
*
|
|
2675
|
+
* @throws {SdkError} `JSSDK_CORE_METHOD_NOT_SUPPORT_IN_API_V3` when called against a `restApi:v3` HTTP client. This throw is preserved until `2.0.0`.
|
|
2676
|
+
* @removed 2.0.0
|
|
2677
|
+
*/
|
|
2577
2678
|
getNext(http: TypeHttp): Promise<AjaxResult<T> | false>;
|
|
2578
2679
|
setData(): never;
|
|
2579
2680
|
}
|
|
@@ -3904,11 +4005,33 @@ declare class RestrictionManager {
|
|
|
3904
4005
|
updateStats(requestId: string, method: string, timeData: any): Promise<void>;
|
|
3905
4006
|
handleError(requestId: string, method: string, params: any, error: any, attempt: number): Promise<number>;
|
|
3906
4007
|
/**
|
|
3907
|
-
*
|
|
4008
|
+
* Built-in hard error codes (always throw, never retry).
|
|
4009
|
+
*
|
|
4010
|
+
* Includes authorization and fatal codes that must never be silently retried.
|
|
4011
|
+
* Use `RestrictionParams.hardErrorCodes` to extend this list with custom codes.
|
|
4012
|
+
*/
|
|
4013
|
+
static readonly BUILT_IN_HARD_ERROR_CODES: readonly string[];
|
|
4014
|
+
/**
|
|
4015
|
+
* Built-in soft error codes (returned as `AjaxResult` with error, never thrown).
|
|
4016
|
+
*
|
|
4017
|
+
* Use `RestrictionParams.softErrorCodes` to extend this list with custom codes.
|
|
4018
|
+
*/
|
|
4019
|
+
static readonly BUILT_IN_SOFT_ERROR_CODES: readonly string[];
|
|
4020
|
+
/**
|
|
4021
|
+
* Codes that cause the SDK to throw immediately.
|
|
4022
|
+
*
|
|
4023
|
+
* Composed of:
|
|
4024
|
+
* - `BUILT_IN_HARD_ERROR_CODES` (always included)
|
|
4025
|
+
* - `NETWORK_ERROR` and `REQUEST_TIMEOUT` when `retryOnNetworkError === false`
|
|
4026
|
+
* - `RestrictionParams.hardErrorCodes` (user-provided extensions)
|
|
3908
4027
|
*/
|
|
3909
4028
|
get exceptionCodeForHard(): string[];
|
|
3910
4029
|
/**
|
|
3911
|
-
*
|
|
4030
|
+
* Codes returned as `AjaxResult` with an `AjaxError` payload instead of thrown.
|
|
4031
|
+
*
|
|
4032
|
+
* Composed of:
|
|
4033
|
+
* - `BUILT_IN_SOFT_ERROR_CODES` (always included)
|
|
4034
|
+
* - `RestrictionParams.softErrorCodes` (user-provided extensions)
|
|
3912
4035
|
*/
|
|
3913
4036
|
get exceptionCodeForSoft(): string[];
|
|
3914
4037
|
incrementError(method: string): void;
|
|
@@ -4898,10 +5021,26 @@ declare class DialogManager {
|
|
|
4898
5021
|
*/
|
|
4899
5022
|
selectAccess(blockedAccessPermissions?: string[]): Promise<SelectedAccess[]>;
|
|
4900
5023
|
/**
|
|
4901
|
-
*
|
|
5024
|
+
* Invokes the system dialog for selecting CRM entities
|
|
5025
|
+
* (leads, contacts, companies, deals, quotes).
|
|
5026
|
+
*
|
|
5027
|
+
* The resolved `SelectedCRM` object contains a separate bucket per
|
|
5028
|
+
* entity type. Each present bucket is a real `Array`, so consumers can
|
|
5029
|
+
* use `.length`, `.map()`, `for..of`, etc. directly. Buckets for entity
|
|
5030
|
+
* types that were not selected (or not requested via `entityType`) are
|
|
5031
|
+
* left `undefined` rather than being set to an empty array.
|
|
4902
5032
|
*
|
|
4903
|
-
*
|
|
4904
|
-
*
|
|
5033
|
+
* Note: the parent window historically returned each bucket as a
|
|
5034
|
+
* `Record<string, SelectedCRMEntity>` (e.g. `{ 0: {...}, 1: {...} }`).
|
|
5035
|
+
* The SDK normalizes that response to a real array before returning it.
|
|
5036
|
+
*
|
|
5037
|
+
* @param {SelectCRMParams} [params] - Filter and behavior options.
|
|
5038
|
+
* - `entityType`: which entity types are shown in the dialog.
|
|
5039
|
+
* - `multiple`: allow multiple selection (default `false`).
|
|
5040
|
+
* - `value`: pre-selected entities (only applied when `multiple` is `true`).
|
|
5041
|
+
* @return {Promise<SelectedCRM>} Resolves to an object whose properties
|
|
5042
|
+
* (`lead`, `contact`, `company`, `deal`, `quote`) are arrays of
|
|
5043
|
+
* {@link SelectedCRMEntity} objects.
|
|
4905
5044
|
*
|
|
4906
5045
|
* @link https://apidocs.bitrix24.com/sdk/bx24-js-sdk/system-dialogues/bx24-select-crm.html
|
|
4907
5046
|
*/
|
|
@@ -4989,14 +5128,38 @@ declare class PlacementManager {
|
|
|
4989
5128
|
bindEvent(eventName: string, callBack: (...args: any[]) => void): Promise<any>;
|
|
4990
5129
|
/**
|
|
4991
5130
|
* Call the Registered Interface Command
|
|
4992
|
-
* @param { string } command
|
|
4993
|
-
* @param { Record<string, any> } parameters
|
|
4994
|
-
* @return { Promise<any> }
|
|
4995
5131
|
*
|
|
4996
5132
|
* @link https://apidocs.bitrix24.com/api-reference/widgets/ui-interaction/bx24-placement-call.html
|
|
4997
|
-
*
|
|
5133
|
+
*
|
|
5134
|
+
* @memo The `setValue` command is special: the parent window calls `JSON.parse(value)`
|
|
5135
|
+
* on the received payload, so `value` MUST be a JSON-serialized string
|
|
5136
|
+
* (e.g. `JSON.stringify('test')` or `JSON.stringify({ a: 1 })`).
|
|
5137
|
+
* Prefer {@link PlacementManager.setValue} which serializes for you.
|
|
5138
|
+
*
|
|
5139
|
+
* @throws {TypeError} when `command === 'setValue'` and `parameters.value` is not a string.
|
|
4998
5140
|
*/
|
|
5141
|
+
call(command: 'setValue', parameters: {
|
|
5142
|
+
value: string;
|
|
5143
|
+
}): Promise<any>;
|
|
4999
5144
|
call(command: string, parameters?: Record<string, any>): Promise<any>;
|
|
5145
|
+
/**
|
|
5146
|
+
* Set Value for the Current Embedding Location
|
|
5147
|
+
*
|
|
5148
|
+
* Convenience wrapper around `placement.call('setValue', ...)` that handles
|
|
5149
|
+
* JSON serialization. Pass any value (string, number, boolean, object, array)
|
|
5150
|
+
* — it will be serialized via `JSON.stringify` before being sent to the
|
|
5151
|
+
* parent window, which performs `JSON.parse` on receipt.
|
|
5152
|
+
*
|
|
5153
|
+
* @param { unknown } value Any JSON-serializable value
|
|
5154
|
+
* @return { Promise<any> }
|
|
5155
|
+
*
|
|
5156
|
+
* @link https://apidocs.bitrix24.com/api-reference/widgets/ui-interaction/bx24-placement-call.html
|
|
5157
|
+
*
|
|
5158
|
+
* @example
|
|
5159
|
+
* await b24.placement.setValue('test')
|
|
5160
|
+
* await b24.placement.setValue({ id: 1, title: 'demo' })
|
|
5161
|
+
*/
|
|
5162
|
+
setValue(value: unknown): Promise<any>;
|
|
5000
5163
|
/**
|
|
5001
5164
|
* Set Up the Interface Event Handler
|
|
5002
5165
|
* @param {string} command
|
package/dist/esm/index.mjs
CHANGED
package/dist/esm/oauth/auth.mjs
CHANGED
package/dist/esm/oauth/b24.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel-manager.mjs","sources":["../../../src/pullClient/channel-manager.ts"],"sourcesContent":["import type { AjaxResult } from '../core/http/ajax-result'\nimport type { TypeChanel, TypeChannelManagerParams, TypePublicIdDescriptor } from '../types/pull'\nimport type { TypeB24 } from '../types/b24'\nimport type { SuccessPayload } from '../types/payloads'\nimport type { LoggerInterface } from '../logger'\nimport { LoggerFactory } from '../logger'\n\nexport class ChannelManager {\n private _logger: LoggerInterface\n private _publicIds: Map<number, TypeChanel>\n private _restClient: TypeB24\n private _getPublicListMethod: string\n\n constructor(params: TypeChannelManagerParams) {\n this._logger = LoggerFactory.createNullLogger()\n this._publicIds = new Map()\n\n this._restClient = params.b24\n this._getPublicListMethod = params.getPublicListMethod\n }\n\n setLogger(logger: LoggerInterface): void {\n this._logger = logger\n }\n\n getLogger(): LoggerInterface {\n return this._logger\n }\n\n /**\n * @param {Array} users Array of user ids.\n * @return {Promise}\n */\n async getPublicIds(users: number[]): Promise<Record<number, TypeChanel>> {\n const now = new Date()\n\n const result: Record<number, TypeChanel> = {}\n const unknownUsers: number[] = []\n\n for (const userId of users) {\n const chanel = this._publicIds.get(userId)\n\n if (chanel && chanel.end > now) {\n result[chanel.userId] = chanel\n } else {\n unknownUsers.push(userId)\n }\n }\n\n if (unknownUsers.length === 0) {\n return Promise.resolve(result)\n }\n\n /**\n * @memo we not use Promise.reject()\n */\n return new Promise((resolve) => {\n this._restClient\n .callMethod(this._getPublicListMethod, {\n users: unknownUsers\n })\n .then((response: AjaxResult) => {\n const data = (response.getData() as SuccessPayload<TypePublicIdDescriptor
|
|
1
|
+
{"version":3,"file":"channel-manager.mjs","sources":["../../../src/pullClient/channel-manager.ts"],"sourcesContent":["import type { AjaxResult } from '../core/http/ajax-result'\nimport type { TypeChanel, TypeChannelManagerParams, TypePublicIdDescriptor } from '../types/pull'\nimport type { TypeB24 } from '../types/b24'\nimport type { SuccessPayload } from '../types/payloads'\nimport type { LoggerInterface } from '../logger'\nimport { LoggerFactory } from '../logger'\n\nexport class ChannelManager {\n private _logger: LoggerInterface\n private _publicIds: Map<number, TypeChanel>\n private _restClient: TypeB24\n private _getPublicListMethod: string\n\n constructor(params: TypeChannelManagerParams) {\n this._logger = LoggerFactory.createNullLogger()\n this._publicIds = new Map()\n\n this._restClient = params.b24\n this._getPublicListMethod = params.getPublicListMethod\n }\n\n setLogger(logger: LoggerInterface): void {\n this._logger = logger\n }\n\n getLogger(): LoggerInterface {\n return this._logger\n }\n\n /**\n * @param {Array} users Array of user ids.\n * @return {Promise}\n */\n async getPublicIds(users: number[]): Promise<Record<number, TypeChanel>> {\n const now = new Date()\n\n const result: Record<number, TypeChanel> = {}\n const unknownUsers: number[] = []\n\n for (const userId of users) {\n const chanel = this._publicIds.get(userId)\n\n if (chanel && chanel.end > now) {\n result[chanel.userId] = chanel\n } else {\n unknownUsers.push(userId)\n }\n }\n\n if (unknownUsers.length === 0) {\n return Promise.resolve(result)\n }\n\n /**\n * @memo we not use Promise.reject()\n */\n return new Promise((resolve) => {\n this._restClient\n .callMethod(this._getPublicListMethod, {\n users: unknownUsers\n })\n .then((response: AjaxResult) => {\n const data = (response.getData() as SuccessPayload<Record<string, TypePublicIdDescriptor>>).result\n\n /**\n * @memo test this\n */\n this.setPublicIds(Object.values(data))\n\n for (const userId of unknownUsers) {\n const chanel = this._publicIds.get(userId)\n if (chanel) {\n result[chanel.userId] = chanel\n }\n }\n\n resolve(result)\n })\n .catch((error: Error | string) => {\n this.getLogger().error('some error in getPublicIds', { error })\n return resolve({})\n })\n })\n }\n\n /**\n * @param {TypePublicIdDescriptor[]} publicIds\n */\n public setPublicIds(publicIds: TypePublicIdDescriptor[]): void {\n publicIds.forEach((publicIdDescriptor: TypePublicIdDescriptor) => {\n const userId = Number(publicIdDescriptor.user_id)\n this._publicIds.set(userId, {\n userId: userId,\n publicId: publicIdDescriptor.public_id,\n signature: publicIdDescriptor.signature,\n start: new Date(publicIdDescriptor.start),\n end: new Date(publicIdDescriptor.end)\n } as TypeChanel)\n })\n }\n}\n"],"names":[],"mappings":"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"}
|