@bitrix24/b24jssdk 1.3.0 → 2.0.0
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 +3 -2
- package/README.md +2 -0
- package/dist/cjs/_virtual/_commonjsHelpers.cjs +19 -0
- package/dist/cjs/_virtual/_commonjsHelpers.cjs.map +1 -0
- package/dist/cjs/_virtual/protobuf.cjs +20 -0
- package/dist/cjs/_virtual/protobuf.cjs.map +1 -0
- package/dist/cjs/_virtual/protobuf2.cjs +14 -0
- package/dist/cjs/_virtual/protobuf2.cjs.map +1 -0
- package/dist/cjs/core/abstract-b24.cjs +357 -0
- package/dist/cjs/core/abstract-b24.cjs.map +1 -0
- package/dist/cjs/core/actions/abstract-action.cjs +26 -0
- package/dist/cjs/core/actions/abstract-action.cjs.map +1 -0
- package/dist/cjs/core/actions/abstract-batch.cjs +97 -0
- package/dist/cjs/core/actions/abstract-batch.cjs.map +1 -0
- package/dist/cjs/core/actions/manager.cjs +55 -0
- package/dist/cjs/core/actions/manager.cjs.map +1 -0
- package/dist/cjs/core/actions/v2/batch-by-chunk.cjs +95 -0
- package/dist/cjs/core/actions/v2/batch-by-chunk.cjs.map +1 -0
- package/dist/cjs/core/actions/v2/batch.cjs +128 -0
- package/dist/cjs/core/actions/v2/batch.cjs.map +1 -0
- package/dist/cjs/core/actions/v2/call-list.cjs +144 -0
- package/dist/cjs/core/actions/v2/call-list.cjs.map +1 -0
- package/dist/cjs/core/actions/v2/call.cjs +56 -0
- package/dist/cjs/core/actions/v2/call.cjs.map +1 -0
- package/dist/cjs/core/actions/v2/fetch-list.cjs +145 -0
- package/dist/cjs/core/actions/v2/fetch-list.cjs.map +1 -0
- package/dist/cjs/core/actions/v2/manager-v2.cjs +76 -0
- package/dist/cjs/core/actions/v2/manager-v2.cjs.map +1 -0
- package/dist/cjs/core/actions/v3/_keyset-paginate.cjs +69 -0
- package/dist/cjs/core/actions/v3/_keyset-paginate.cjs.map +1 -0
- package/dist/cjs/core/actions/v3/aggregate.cjs +96 -0
- package/dist/cjs/core/actions/v3/aggregate.cjs.map +1 -0
- package/dist/cjs/core/actions/v3/batch-by-chunk.cjs +93 -0
- package/dist/cjs/core/actions/v3/batch-by-chunk.cjs.map +1 -0
- package/dist/cjs/core/actions/v3/batch.cjs +122 -0
- package/dist/cjs/core/actions/v3/batch.cjs.map +1 -0
- package/dist/cjs/core/actions/v3/call-list.cjs +126 -0
- package/dist/cjs/core/actions/v3/call-list.cjs.map +1 -0
- package/dist/cjs/core/actions/v3/call-tail.cjs +118 -0
- package/dist/cjs/core/actions/v3/call-tail.cjs.map +1 -0
- package/dist/cjs/core/actions/v3/call.cjs +51 -0
- package/dist/cjs/core/actions/v3/call.cjs.map +1 -0
- package/dist/cjs/core/actions/v3/fetch-list.cjs +122 -0
- package/dist/cjs/core/actions/v3/fetch-list.cjs.map +1 -0
- package/dist/cjs/core/actions/v3/fetch-tail.cjs +112 -0
- package/dist/cjs/core/actions/v3/fetch-tail.cjs.map +1 -0
- package/dist/cjs/core/actions/v3/manager-v3.cjs +100 -0
- package/dist/cjs/core/actions/v3/manager-v3.cjs.map +1 -0
- package/dist/cjs/core/http/abstract-http.cjs +641 -0
- package/dist/cjs/core/http/abstract-http.cjs.map +1 -0
- package/dist/cjs/core/http/ajax-error.cjs +113 -0
- package/dist/cjs/core/http/ajax-error.cjs.map +1 -0
- package/dist/cjs/core/http/ajax-result.cjs +219 -0
- package/dist/cjs/core/http/ajax-result.cjs.map +1 -0
- package/dist/cjs/core/http/limiters/adaptive-delayer.cjs +137 -0
- package/dist/cjs/core/http/limiters/adaptive-delayer.cjs.map +1 -0
- package/dist/cjs/core/http/limiters/manager.cjs +373 -0
- package/dist/cjs/core/http/limiters/manager.cjs.map +1 -0
- package/dist/cjs/core/http/limiters/operating-limiter.cjs +173 -0
- package/dist/cjs/core/http/limiters/operating-limiter.cjs.map +1 -0
- package/dist/cjs/core/http/limiters/params-factory.cjs +124 -0
- package/dist/cjs/core/http/limiters/params-factory.cjs.map +1 -0
- package/dist/cjs/core/http/limiters/rate-limiter.cjs +404 -0
- package/dist/cjs/core/http/limiters/rate-limiter.cjs.map +1 -0
- package/dist/cjs/core/http/redact.cjs +85 -0
- package/dist/cjs/core/http/redact.cjs.map +1 -0
- package/dist/cjs/core/http/v2.cjs +85 -0
- package/dist/cjs/core/http/v2.cjs.map +1 -0
- package/dist/cjs/core/http/v3.cjs +82 -0
- package/dist/cjs/core/http/v3.cjs.map +1 -0
- package/dist/cjs/core/interaction/batch/abstract-interaction-batch.cjs +71 -0
- package/dist/cjs/core/interaction/batch/abstract-interaction-batch.cjs.map +1 -0
- package/dist/cjs/core/interaction/batch/parse-row.cjs +69 -0
- package/dist/cjs/core/interaction/batch/parse-row.cjs.map +1 -0
- package/dist/cjs/core/interaction/batch/processing/interface-strategy.cjs +87 -0
- package/dist/cjs/core/interaction/batch/processing/interface-strategy.cjs.map +1 -0
- package/dist/cjs/core/interaction/batch/processing/v2/abstract-processing.cjs +138 -0
- package/dist/cjs/core/interaction/batch/processing/v2/abstract-processing.cjs.map +1 -0
- package/dist/cjs/core/interaction/batch/processing/v2/as-array.cjs +34 -0
- package/dist/cjs/core/interaction/batch/processing/v2/as-array.cjs.map +1 -0
- package/dist/cjs/core/interaction/batch/processing/v2/as-object.cjs +34 -0
- package/dist/cjs/core/interaction/batch/processing/v2/as-object.cjs.map +1 -0
- package/dist/cjs/core/interaction/batch/processing/v3/abstract-processing.cjs +115 -0
- package/dist/cjs/core/interaction/batch/processing/v3/abstract-processing.cjs.map +1 -0
- package/dist/cjs/core/interaction/batch/processing/v3/as-array.cjs +34 -0
- package/dist/cjs/core/interaction/batch/processing/v3/as-array.cjs.map +1 -0
- package/dist/cjs/core/interaction/batch/processing/v3/as-object.cjs +34 -0
- package/dist/cjs/core/interaction/batch/processing/v3/as-object.cjs.map +1 -0
- package/dist/cjs/core/interaction/batch/v2.cjs +47 -0
- package/dist/cjs/core/interaction/batch/v2.cjs.map +1 -0
- package/dist/cjs/core/interaction/batch/v3.cjs +45 -0
- package/dist/cjs/core/interaction/batch/v3.cjs.map +1 -0
- package/dist/cjs/core/language/list.cjs +59 -0
- package/dist/cjs/core/language/list.cjs.map +1 -0
- package/dist/cjs/core/request-id-generator.cjs +44 -0
- package/dist/cjs/core/request-id-generator.cjs.map +1 -0
- package/dist/cjs/core/result.cjs +137 -0
- package/dist/cjs/core/result.cjs.map +1 -0
- package/dist/cjs/core/sdk-error.cjs +85 -0
- package/dist/cjs/core/sdk-error.cjs.map +1 -0
- package/dist/cjs/core/tools/abstract-tool.cjs +26 -0
- package/dist/cjs/core/tools/abstract-tool.cjs.map +1 -0
- package/dist/cjs/core/tools/healthcheck.cjs +50 -0
- package/dist/cjs/core/tools/healthcheck.cjs.map +1 -0
- package/dist/cjs/core/tools/manager.cjs +52 -0
- package/dist/cjs/core/tools/manager.cjs.map +1 -0
- package/dist/cjs/core/tools/ping.cjs +58 -0
- package/dist/cjs/core/tools/ping.cjs.map +1 -0
- package/dist/cjs/core/version-manager.cjs +57 -0
- package/dist/cjs/core/version-manager.cjs.map +1 -0
- package/dist/cjs/frame/auth.cjs +100 -0
- package/dist/cjs/frame/auth.cjs.map +1 -0
- package/dist/cjs/frame/b24.cjs +178 -0
- package/dist/cjs/frame/b24.cjs.map +1 -0
- package/dist/cjs/frame/dialog.cjs +120 -0
- package/dist/cjs/frame/dialog.cjs.map +1 -0
- package/dist/cjs/frame/frame.cjs +103 -0
- package/dist/cjs/frame/frame.cjs.map +1 -0
- package/dist/cjs/frame/message/commands.cjs +39 -0
- package/dist/cjs/frame/message/commands.cjs.map +1 -0
- package/dist/cjs/frame/message/controller.cjs +191 -0
- package/dist/cjs/frame/message/controller.cjs.map +1 -0
- package/dist/cjs/frame/options.cjs +108 -0
- package/dist/cjs/frame/options.cjs.map +1 -0
- package/dist/cjs/frame/parent.cjs +259 -0
- package/dist/cjs/frame/parent.cjs.map +1 -0
- package/dist/cjs/frame/placement.cjs +156 -0
- package/dist/cjs/frame/placement.cjs.map +1 -0
- package/dist/cjs/frame/slider.cjs +162 -0
- package/dist/cjs/frame/slider.cjs.map +1 -0
- package/dist/cjs/helper/abstract-helper.cjs +55 -0
- package/dist/cjs/helper/abstract-helper.cjs.map +1 -0
- package/dist/cjs/helper/app-manager.cjs +39 -0
- package/dist/cjs/helper/app-manager.cjs.map +1 -0
- package/dist/cjs/helper/currency-manager.cjs +215 -0
- package/dist/cjs/helper/currency-manager.cjs.map +1 -0
- package/dist/cjs/helper/helper-manager.cjs +397 -0
- package/dist/cjs/helper/helper-manager.cjs.map +1 -0
- package/dist/cjs/helper/license-manager.cjs +52 -0
- package/dist/cjs/helper/license-manager.cjs.map +1 -0
- package/dist/cjs/helper/options-manager.cjs +205 -0
- package/dist/cjs/helper/options-manager.cjs.map +1 -0
- package/dist/cjs/helper/payment-manager.cjs +35 -0
- package/dist/cjs/helper/payment-manager.cjs.map +1 -0
- package/dist/cjs/helper/profile-manager.cjs +35 -0
- package/dist/cjs/helper/profile-manager.cjs.map +1 -0
- package/dist/cjs/helper/use-b24-helper.cjs +85 -0
- package/dist/cjs/helper/use-b24-helper.cjs.map +1 -0
- package/dist/cjs/hook/auth.cjs +79 -0
- package/dist/cjs/hook/auth.cjs.map +1 -0
- package/dist/cjs/hook/b24.cjs +117 -0
- package/dist/cjs/hook/b24.cjs.map +1 -0
- package/dist/cjs/index.cjs +176 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +6415 -0
- package/dist/cjs/index.d.mts +6415 -0
- package/dist/cjs/index.d.ts +6415 -0
- package/dist/cjs/loader-b24frame.cjs +103 -0
- package/dist/cjs/loader-b24frame.cjs.map +1 -0
- package/dist/cjs/logger/abstract-logger.cjs +71 -0
- package/dist/cjs/logger/abstract-logger.cjs.map +1 -0
- package/dist/cjs/logger/browser.cjs +165 -0
- package/dist/cjs/logger/browser.cjs.map +1 -0
- package/dist/cjs/logger/formatter/abstract-formatter.cjs +36 -0
- package/dist/cjs/logger/formatter/abstract-formatter.cjs.map +1 -0
- package/dist/cjs/logger/formatter/json-formatter.cjs +36 -0
- package/dist/cjs/logger/formatter/json-formatter.cjs.map +1 -0
- package/dist/cjs/logger/formatter/line-formatter.cjs +43 -0
- package/dist/cjs/logger/formatter/line-formatter.cjs.map +1 -0
- package/dist/cjs/logger/formatter/telegram-formatter.cjs +105 -0
- package/dist/cjs/logger/formatter/telegram-formatter.cjs.map +1 -0
- package/dist/cjs/logger/handler/abstract-handler.cjs +41 -0
- package/dist/cjs/logger/handler/abstract-handler.cjs.map +1 -0
- package/dist/cjs/logger/handler/consola-adapter.cjs +64 -0
- package/dist/cjs/logger/handler/consola-adapter.cjs.map +1 -0
- package/dist/cjs/logger/handler/console-handler.cjs +100 -0
- package/dist/cjs/logger/handler/console-handler.cjs.map +1 -0
- package/dist/cjs/logger/handler/console-v2-handler.cjs +53 -0
- package/dist/cjs/logger/handler/console-v2-handler.cjs.map +1 -0
- package/dist/cjs/logger/handler/memory-handler.cjs +50 -0
- package/dist/cjs/logger/handler/memory-handler.cjs.map +1 -0
- package/dist/cjs/logger/handler/stream-handler.cjs +75 -0
- package/dist/cjs/logger/handler/stream-handler.cjs.map +1 -0
- package/dist/cjs/logger/handler/telegram-handler.cjs +159 -0
- package/dist/cjs/logger/handler/telegram-handler.cjs.map +1 -0
- package/dist/cjs/logger/handler/winston-adapter.cjs +59 -0
- package/dist/cjs/logger/handler/winston-adapter.cjs.map +1 -0
- package/dist/cjs/logger/logger-factory.cjs +69 -0
- package/dist/cjs/logger/logger-factory.cjs.map +1 -0
- package/dist/cjs/logger/logger.cjs +78 -0
- package/dist/cjs/logger/logger.cjs.map +1 -0
- package/dist/cjs/logger/null-logger.cjs +34 -0
- package/dist/cjs/logger/null-logger.cjs.map +1 -0
- package/dist/cjs/logger/processor/memory-usage-processor.cjs +22 -0
- package/dist/cjs/logger/processor/memory-usage-processor.cjs.map +1 -0
- package/dist/cjs/logger/processor/pid-processor.cjs +22 -0
- package/dist/cjs/logger/processor/pid-processor.cjs.map +1 -0
- package/dist/cjs/oauth/auth.cjs +214 -0
- package/dist/cjs/oauth/auth.cjs.map +1 -0
- package/dist/cjs/oauth/b24.cjs +119 -0
- package/dist/cjs/oauth/b24.cjs.map +1 -0
- package/dist/cjs/oauth/refresh-token-error.cjs +22 -0
- package/dist/cjs/oauth/refresh-token-error.cjs.map +1 -0
- package/dist/cjs/pullClient/abstract-connector.cjs +80 -0
- package/dist/cjs/pullClient/abstract-connector.cjs.map +1 -0
- package/dist/cjs/pullClient/channel-manager.cjs +91 -0
- package/dist/cjs/pullClient/channel-manager.cjs.map +1 -0
- package/dist/cjs/pullClient/client.cjs +2177 -0
- package/dist/cjs/pullClient/client.cjs.map +1 -0
- package/dist/cjs/pullClient/errors.cjs +34 -0
- package/dist/cjs/pullClient/errors.cjs.map +1 -0
- package/dist/cjs/pullClient/json-rpc.cjs +213 -0
- package/dist/cjs/pullClient/json-rpc.cjs.map +1 -0
- package/dist/cjs/pullClient/long-polling-connector.cjs +159 -0
- package/dist/cjs/pullClient/long-polling-connector.cjs.map +1 -0
- package/dist/cjs/pullClient/protobuf/index.cjs +22 -0
- package/dist/cjs/pullClient/protobuf/index.cjs.map +1 -0
- package/dist/cjs/pullClient/protobuf/model.cjs +1060 -0
- package/dist/cjs/pullClient/protobuf/model.cjs.map +1 -0
- package/dist/cjs/pullClient/protobuf/protobuf.cjs +4655 -0
- package/dist/cjs/pullClient/protobuf/protobuf.cjs.map +1 -0
- package/dist/cjs/pullClient/shared-config.cjs +135 -0
- package/dist/cjs/pullClient/shared-config.cjs.map +1 -0
- package/dist/cjs/pullClient/storage-manager.cjs +74 -0
- package/dist/cjs/pullClient/storage-manager.cjs.map +1 -0
- package/dist/cjs/pullClient/web-socket-connector.cjs +131 -0
- package/dist/cjs/pullClient/web-socket-connector.cjs.map +1 -0
- package/dist/cjs/tools/batch-ref-v3.cjs +54 -0
- package/dist/cjs/tools/batch-ref-v3.cjs.map +1 -0
- package/dist/cjs/tools/browser.cjs +156 -0
- package/dist/cjs/tools/browser.cjs.map +1 -0
- package/dist/cjs/tools/environment.cjs +32 -0
- package/dist/cjs/tools/environment.cjs.map +1 -0
- package/dist/cjs/tools/filter-v3.cjs +139 -0
- package/dist/cjs/tools/filter-v3.cjs.map +1 -0
- package/dist/cjs/tools/formatters/iban.cjs +307 -0
- package/dist/cjs/tools/formatters/iban.cjs.map +1 -0
- package/dist/cjs/tools/formatters/numbers.cjs +68 -0
- package/dist/cjs/tools/formatters/numbers.cjs.map +1 -0
- package/dist/cjs/tools/index.cjs +42 -0
- package/dist/cjs/tools/index.cjs.map +1 -0
- package/dist/cjs/tools/scroll-size.cjs +29 -0
- package/dist/cjs/tools/scroll-size.cjs.map +1 -0
- package/dist/cjs/tools/text.cjs +210 -0
- package/dist/cjs/tools/text.cjs.map +1 -0
- package/dist/cjs/tools/type.cjs +339 -0
- package/dist/cjs/tools/type.cjs.map +1 -0
- package/dist/cjs/tools/use-formatters.cjs +462 -0
- package/dist/cjs/tools/use-formatters.cjs.map +1 -0
- package/dist/cjs/tools/uuidv7.cjs +58 -0
- package/dist/cjs/tools/uuidv7.cjs.map +1 -0
- package/dist/cjs/types/b24-helper.cjs +62 -0
- package/dist/cjs/types/b24-helper.cjs.map +1 -0
- package/dist/cjs/types/b24.cjs +18 -0
- package/dist/cjs/types/b24.cjs.map +1 -0
- package/dist/cjs/types/bizproc/index.cjs +195 -0
- package/dist/cjs/types/bizproc/index.cjs.map +1 -0
- package/dist/cjs/types/catalog/index.cjs +39 -0
- package/dist/cjs/types/catalog/index.cjs.map +1 -0
- package/dist/cjs/types/common.cjs +33 -0
- package/dist/cjs/types/common.cjs.map +1 -0
- package/dist/cjs/types/crm/entity-type.cjs +62 -0
- package/dist/cjs/types/crm/entity-type.cjs.map +1 -0
- package/dist/cjs/types/crm/productrow.cjs +19 -0
- package/dist/cjs/types/crm/productrow.cjs.map +1 -0
- package/dist/cjs/types/logger.cjs +24 -0
- package/dist/cjs/types/logger.cjs.map +1 -0
- package/dist/cjs/types/pull.cjs +94 -0
- package/dist/cjs/types/pull.cjs.map +1 -0
- 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 -15
- package/dist/esm/core/actions/v2/call.mjs.map +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/_keyset-paginate.mjs +66 -0
- package/dist/esm/core/actions/v3/_keyset-paginate.mjs.map +1 -0
- package/dist/esm/core/actions/v3/aggregate.mjs +94 -0
- package/dist/esm/core/actions/v3/aggregate.mjs.map +1 -0
- package/dist/esm/core/actions/v3/batch-by-chunk.mjs +1 -1
- package/dist/esm/core/actions/v3/batch.mjs +1 -10
- package/dist/esm/core/actions/v3/batch.mjs.map +1 -1
- package/dist/esm/core/actions/v3/call-list.mjs +30 -44
- package/dist/esm/core/actions/v3/call-list.mjs.map +1 -1
- package/dist/esm/core/actions/v3/call-tail.mjs +116 -0
- package/dist/esm/core/actions/v3/call-tail.mjs.map +1 -0
- package/dist/esm/core/actions/v3/call.mjs +1 -10
- package/dist/esm/core/actions/v3/call.mjs.map +1 -1
- package/dist/esm/core/actions/v3/fetch-list.mjs +24 -41
- package/dist/esm/core/actions/v3/fetch-list.mjs.map +1 -1
- package/dist/esm/core/actions/v3/fetch-tail.mjs +110 -0
- package/dist/esm/core/actions/v3/fetch-tail.mjs.map +1 -0
- package/dist/esm/core/actions/v3/manager-v3.mjs +25 -1
- package/dist/esm/core/actions/v3/manager-v3.mjs.map +1 -1
- package/dist/esm/core/http/abstract-http.mjs +68 -17
- package/dist/esm/core/http/abstract-http.mjs.map +1 -1
- package/dist/esm/core/http/ajax-error.mjs +1 -1
- package/dist/esm/core/http/ajax-result.mjs +9 -8
- 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 +1 -1
- package/dist/esm/core/http/limiters/operating-limiter.mjs +1 -1
- package/dist/esm/core/http/limiters/params-factory.mjs +1 -1
- package/dist/esm/core/http/limiters/rate-limiter.mjs +1 -1
- package/dist/esm/core/http/redact.mjs +41 -13
- package/dist/esm/core/http/redact.mjs.map +1 -1
- package/dist/esm/core/http/v2.mjs +1 -18
- package/dist/esm/core/http/v2.mjs.map +1 -1
- package/dist/esm/core/http/v3.mjs +1 -15
- package/dist/esm/core/http/v3.mjs.map +1 -1
- 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 +44 -1
- package/dist/esm/core/interaction/batch/processing/interface-strategy.mjs.map +1 -1
- package/dist/esm/core/interaction/batch/processing/v2/abstract-processing.mjs +7 -6
- 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 +3 -3
- package/dist/esm/core/interaction/batch/processing/v2/as-array.mjs.map +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 +7 -19
- 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 +3 -3
- package/dist/esm/core/interaction/batch/processing/v3/as-array.mjs.map +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 +11 -4
- package/dist/esm/core/result.mjs.map +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 +19 -157
- package/dist/esm/core/version-manager.mjs.map +1 -1
- package/dist/esm/frame/auth.mjs +1 -1
- package/dist/esm/frame/b24.mjs +8 -2
- package/dist/esm/frame/b24.mjs.map +1 -1
- package/dist/esm/frame/dialog.mjs +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 +17 -6
- package/dist/esm/frame/message/controller.mjs.map +1 -1
- package/dist/esm/frame/options.mjs +1 -1
- package/dist/esm/frame/parent.mjs +1 -1
- package/dist/esm/frame/placement.mjs +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 +3 -3
- package/dist/esm/hook/b24.mjs.map +1 -1
- package/dist/esm/index.d.mts +412 -39
- package/dist/esm/index.d.ts +412 -39
- package/dist/esm/index.mjs +3 -1
- package/dist/esm/index.mjs.map +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 +13 -16
- package/dist/esm/oauth/auth.mjs.map +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/client.mjs +141 -30
- package/dist/esm/pullClient/client.mjs.map +1 -1
- package/dist/esm/pullClient/errors.mjs +1 -1
- package/dist/esm/pullClient/json-rpc.mjs +5 -4
- package/dist/esm/pullClient/json-rpc.mjs.map +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/batch-ref-v3.mjs +52 -0
- package/dist/esm/tools/batch-ref-v3.mjs.map +1 -0
- package/dist/esm/tools/browser.mjs +1 -1
- package/dist/esm/tools/environment.mjs +1 -1
- package/dist/esm/tools/filter-v3.mjs +137 -0
- package/dist/esm/tools/filter-v3.mjs.map +1 -0
- 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 +1258 -719
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/index.min.js +26 -26
- package/dist/umd/index.min.js.map +1 -1
- package/dist/umd/package.json +3 -0
- package/package.json +12 -4
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @package @bitrix24/b24jssdk
|
|
3
|
+
* @version 2.0.0
|
|
4
|
+
* @copyright (c) 2026 Bitrix24
|
|
5
|
+
* @license MIT
|
|
6
|
+
* @see https://github.com/bitrix24/b24jssdk
|
|
7
|
+
* @see https://bitrix24.github.io/b24jssdk/
|
|
8
|
+
*/
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
const abstractBatch = require('../abstract-batch.cjs');
|
|
12
|
+
const b24 = require('../../../types/b24.cjs');
|
|
13
|
+
|
|
14
|
+
var __defProp = Object.defineProperty;
|
|
15
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
16
|
+
class BatchV3 extends abstractBatch.AbstractBatch {
|
|
17
|
+
static {
|
|
18
|
+
__name(this, "BatchV3");
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Executes a batch request to the Bitrix24 REST API with a maximum number of commands of no more than 50.
|
|
22
|
+
* Allows you to execute multiple requests in a single API call, significantly improving performance.
|
|
23
|
+
*
|
|
24
|
+
* @template T - The data type returned by batch query commands (default is `unknown`)
|
|
25
|
+
*
|
|
26
|
+
* @param {ActionBatchV3} options - parameters for executing the request.
|
|
27
|
+
* - `calls: BatchCommandsArrayUniversal | BatchCommandsObjectUniversal | BatchNamedCommandsUniversal` - Commands to execute in a batch.
|
|
28
|
+
* Supports several formats:
|
|
29
|
+
* 1. Array of tuples: `[['method1', params1], ['method2', params2], ...]`
|
|
30
|
+
* 2. Array of objects: `[{ method: 'method1', params: params1 }, { method: 'method2', params: params2 }, ...]`
|
|
31
|
+
* 3. An object with named commands: `{ cmd1: { method: 'method1', params: params1 }, cmd2: ['method2', params2], ...}`
|
|
32
|
+
* - `options?: IB24BatchOptions` - Additional options for executing a batch request.
|
|
33
|
+
* - `isHaltOnError?: boolean` - Whether to stop execution on the first error (default: true)
|
|
34
|
+
* - `requestId?: string` - Unique request identifier for tracking. Used for query deduplication and debugging (default: undefined)
|
|
35
|
+
* - `returnAjaxResult?: boolean` - Whether to return an AjaxResult object instead of data (default: false)
|
|
36
|
+
*
|
|
37
|
+
* @returns {Promise<CallBatchResult<T>>} A promise that is resolved by the result of executing a batch request:
|
|
38
|
+
* - On success: a `Result` object with the command execution results
|
|
39
|
+
* - The structure of the results depends on the format of the `calls` input data:
|
|
40
|
+
* - For an array of commands, an array of results in the same order
|
|
41
|
+
* - For named commands, an object with keys corresponding to the command names
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* interface TaskItem { id: number, title: string }
|
|
45
|
+
* const response = await b24.actions.v3.batch.make<{ item: TaskItem }>({
|
|
46
|
+
* calls: [
|
|
47
|
+
* ['tasks.task.get', { id: 1, select: ['id', 'title'] }],
|
|
48
|
+
* ['tasks.task.get', { id: 2, select: ['id', 'title'] }],
|
|
49
|
+
* ['tasks.task.get', { id: 3, select: ['id', 'title'] }]
|
|
50
|
+
* ],
|
|
51
|
+
* options: {
|
|
52
|
+
* isHaltOnError: true,
|
|
53
|
+
* returnAjaxResult: true,
|
|
54
|
+
* requestId: 'batch-123'
|
|
55
|
+
* }
|
|
56
|
+
* })
|
|
57
|
+
* if (!response.isSuccess) {
|
|
58
|
+
* throw new Error(`Problem: ${response.getErrorMessages().join('; ')}`)
|
|
59
|
+
* }
|
|
60
|
+
*
|
|
61
|
+
* const resultData = (response as Result<AjaxResult<{ item: TaskItem }>[]>).getData()
|
|
62
|
+
* resultData.forEach((resultRow, index) => {
|
|
63
|
+
* if (resultRow.isSuccess) {
|
|
64
|
+
* console.log(`Item ${index + 1}:`, resultRow.getData()!.result.item)
|
|
65
|
+
* }
|
|
66
|
+
* })
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* const response = await b24.actions.v3.batch.make({
|
|
70
|
+
* calls: [
|
|
71
|
+
* { method: 'tasks.task.get', params: { id: 1, select: ['id', 'title'] } },
|
|
72
|
+
* { method: 'tasks.task.get', params: { id: 2, select: ['id', 'title'] } }
|
|
73
|
+
* ],
|
|
74
|
+
* options: {
|
|
75
|
+
* isHaltOnError: true,
|
|
76
|
+
* returnAjaxResult: true,
|
|
77
|
+
* requestId: 'batch-123'
|
|
78
|
+
* }
|
|
79
|
+
* })
|
|
80
|
+
* if (!response.isSuccess) {
|
|
81
|
+
* throw new Error(`Problem: ${response.getErrorMessages().join('; ')}`)
|
|
82
|
+
* }
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* interface TaskItem { id: number, title: string }
|
|
86
|
+
* interface MainEventLogItem { id: number, userId: number }
|
|
87
|
+
* const response = await b24.actions.v3.batch.make<{ item: TaskItem } | { items: MainEventLogItem[] }>({
|
|
88
|
+
* calls: {
|
|
89
|
+
* Task: { method: 'tasks.task.get', params: { id: 1, select: ['id', 'title'] } },
|
|
90
|
+
* MainEventLog: ['main.eventlog.list', { select: ['id', 'userId'], pagination: { limit: 5 } }]
|
|
91
|
+
* },
|
|
92
|
+
* options: {
|
|
93
|
+
* isHaltOnError: true,
|
|
94
|
+
* returnAjaxResult: true,
|
|
95
|
+
* requestId: 'batch-123'
|
|
96
|
+
* }
|
|
97
|
+
* })
|
|
98
|
+
* if (!response.isSuccess) {
|
|
99
|
+
* throw new Error(`Problem: ${response.getErrorMessages().join('; ')}`)
|
|
100
|
+
* }
|
|
101
|
+
*
|
|
102
|
+
* const results = response.getData() as Record<string, AjaxResult<{ item: TaskItem } | { items: MainEventLogItem[] }>>
|
|
103
|
+
* console.log('Task:', results.Task.getData()?.result.item as TaskItem)
|
|
104
|
+
* console.log('MainEventLog:', results.MainEventLog.getData()?.result.items as MainEventLogItem[])
|
|
105
|
+
*
|
|
106
|
+
* @warning The maximum number of commands in one batch request is 50.
|
|
107
|
+
* @note A batch request executes faster than sequential single calls,
|
|
108
|
+
* but if one command fails, the entire batch may fail
|
|
109
|
+
* (depending on API settings and options).
|
|
110
|
+
*/
|
|
111
|
+
async make(options) {
|
|
112
|
+
const opts = {
|
|
113
|
+
...options.options,
|
|
114
|
+
apiVersion: b24.ApiVersion.v3
|
|
115
|
+
};
|
|
116
|
+
const response = await this._b24.getHttpClient(b24.ApiVersion.v3).batch(options.calls, opts);
|
|
117
|
+
return this._processBatchResponse(response, options.calls, opts);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
exports.BatchV3 = BatchV3;
|
|
122
|
+
//# sourceMappingURL=batch.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.cjs","sources":["../../../../../src/core/actions/v3/batch.ts"],"sourcesContent":["import type { ActionOptions } from '../abstract-action'\nimport type { CallBatchResult, IB24BatchOptions } from '../../../types/b24'\nimport type {\n BatchCommandsArrayUniversal,\n BatchCommandsObjectUniversal,\n BatchNamedCommandsUniversal\n} from '../../../types/http'\nimport { AbstractBatch } from '../abstract-batch'\nimport { ApiVersion } from '../../../types/b24'\n\nexport type ActionBatchV3 = ActionOptions & {\n calls: BatchCommandsArrayUniversal | BatchCommandsObjectUniversal | BatchNamedCommandsUniversal\n options?: IB24BatchOptions\n}\n\n/**\n * Executes a batch request to the Bitrix24 REST API with a maximum number of commands of no more than 50. `restApi:v3`\n * Allows you to execute multiple requests in a single API call, significantly improving performance.\n *\n * @todo add docs\n */\nexport class BatchV3 extends AbstractBatch {\n /**\n * Executes a batch request to the Bitrix24 REST API with a maximum number of commands of no more than 50.\n * Allows you to execute multiple requests in a single API call, significantly improving performance.\n *\n * @template T - The data type returned by batch query commands (default is `unknown`)\n *\n * @param {ActionBatchV3} options - parameters for executing the request.\n * - `calls: BatchCommandsArrayUniversal | BatchCommandsObjectUniversal | BatchNamedCommandsUniversal` - Commands to execute in a batch.\n * Supports several formats:\n * 1. Array of tuples: `[['method1', params1], ['method2', params2], ...]`\n * 2. Array of objects: `[{ method: 'method1', params: params1 }, { method: 'method2', params: params2 }, ...]`\n * 3. An object with named commands: `{ cmd1: { method: 'method1', params: params1 }, cmd2: ['method2', params2], ...}`\n * - `options?: IB24BatchOptions` - Additional options for executing a batch request.\n * - `isHaltOnError?: boolean` - Whether to stop execution on the first error (default: true)\n * - `requestId?: string` - Unique request identifier for tracking. Used for query deduplication and debugging (default: undefined)\n * - `returnAjaxResult?: boolean` - Whether to return an AjaxResult object instead of data (default: false)\n *\n * @returns {Promise<CallBatchResult<T>>} A promise that is resolved by the result of executing a batch request:\n * - On success: a `Result` object with the command execution results\n * - The structure of the results depends on the format of the `calls` input data:\n * - For an array of commands, an array of results in the same order\n * - For named commands, an object with keys corresponding to the command names\n *\n * @example\n * interface TaskItem { id: number, title: string }\n * const response = await b24.actions.v3.batch.make<{ item: TaskItem }>({\n * calls: [\n * ['tasks.task.get', { id: 1, select: ['id', 'title'] }],\n * ['tasks.task.get', { id: 2, select: ['id', 'title'] }],\n * ['tasks.task.get', { id: 3, select: ['id', 'title'] }]\n * ],\n * options: {\n * isHaltOnError: true,\n * returnAjaxResult: true,\n * requestId: 'batch-123'\n * }\n * })\n * if (!response.isSuccess) {\n * throw new Error(`Problem: ${response.getErrorMessages().join('; ')}`)\n * }\n *\n * const resultData = (response as Result<AjaxResult<{ item: TaskItem }>[]>).getData()\n * resultData.forEach((resultRow, index) => {\n * if (resultRow.isSuccess) {\n * console.log(`Item ${index + 1}:`, resultRow.getData()!.result.item)\n * }\n * })\n *\n * @example\n * const response = await b24.actions.v3.batch.make({\n * calls: [\n * { method: 'tasks.task.get', params: { id: 1, select: ['id', 'title'] } },\n * { method: 'tasks.task.get', params: { id: 2, select: ['id', 'title'] } }\n * ],\n * options: {\n * isHaltOnError: true,\n * returnAjaxResult: true,\n * requestId: 'batch-123'\n * }\n * })\n * if (!response.isSuccess) {\n * throw new Error(`Problem: ${response.getErrorMessages().join('; ')}`)\n * }\n *\n * @example\n * interface TaskItem { id: number, title: string }\n * interface MainEventLogItem { id: number, userId: number }\n * const response = await b24.actions.v3.batch.make<{ item: TaskItem } | { items: MainEventLogItem[] }>({\n * calls: {\n * Task: { method: 'tasks.task.get', params: { id: 1, select: ['id', 'title'] } },\n * MainEventLog: ['main.eventlog.list', { select: ['id', 'userId'], pagination: { limit: 5 } }]\n * },\n * options: {\n * isHaltOnError: true,\n * returnAjaxResult: true,\n * requestId: 'batch-123'\n * }\n * })\n * if (!response.isSuccess) {\n * throw new Error(`Problem: ${response.getErrorMessages().join('; ')}`)\n * }\n *\n * const results = response.getData() as Record<string, AjaxResult<{ item: TaskItem } | { items: MainEventLogItem[] }>>\n * console.log('Task:', results.Task.getData()?.result.item as TaskItem)\n * console.log('MainEventLog:', results.MainEventLog.getData()?.result.items as MainEventLogItem[])\n *\n * @warning The maximum number of commands in one batch request is 50.\n * @note A batch request executes faster than sequential single calls,\n * but if one command fails, the entire batch may fail\n * (depending on API settings and options).\n */\n public override async make<T = unknown>(options: ActionBatchV3): Promise<CallBatchResult<T>> {\n const opts = {\n ...options.options,\n apiVersion: ApiVersion.v3\n }\n\n // No client-side allowlist: every command is sent to the v3 batch endpoint\n // and the server validates each method (unknown ones come back as errors).\n const response = await this._b24.getHttpClient(ApiVersion.v3).batch<T>(options.calls, opts)\n\n return this._processBatchResponse<T>(response, options.calls, opts)\n }\n}\n"],"names":["AbstractBatch","ApiVersion"],"mappings":";;;;;;;;;;;;;;;AAqBO,MAAM,gBAAgBA,2BAAA,CAAc;AAAA,EArB3C;AAqB2C,IAAA,MAAA,CAAA,IAAA,EAAA,SAAA,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;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;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,EA4FzC,MAAsB,KAAkB,OAAA,EAAqD;AAC3F,IAAA,MAAM,IAAA,GAAO;AAAA,MACX,GAAG,OAAA,CAAQ,OAAA;AAAA,MACX,YAAYC,cAAA,CAAW;AAAA,KACzB;AAIA,IAAA,MAAM,QAAA,GAAW,MAAM,IAAA,CAAK,IAAA,CAAK,aAAA,CAAcA,cAAA,CAAW,EAAE,CAAA,CAAE,KAAA,CAAS,OAAA,CAAQ,KAAA,EAAO,IAAI,CAAA;AAE1F,IAAA,OAAO,IAAA,CAAK,qBAAA,CAAyB,QAAA,EAAU,OAAA,CAAQ,OAAO,IAAI,CAAA;AAAA,EACpE;AACF;;;;"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @package @bitrix24/b24jssdk
|
|
3
|
+
* @version 2.0.0
|
|
4
|
+
* @copyright (c) 2026 Bitrix24
|
|
5
|
+
* @license MIT
|
|
6
|
+
* @see https://github.com/bitrix24/b24jssdk
|
|
7
|
+
* @see https://bitrix24.github.io/b24jssdk/
|
|
8
|
+
*/
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
const abstractAction = require('../abstract-action.cjs');
|
|
12
|
+
const result = require('../../result.cjs');
|
|
13
|
+
const _keysetPaginate = require('./_keyset-paginate.cjs');
|
|
14
|
+
|
|
15
|
+
var __defProp = Object.defineProperty;
|
|
16
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
17
|
+
class CallListV3 extends abstractAction.AbstractAction {
|
|
18
|
+
static {
|
|
19
|
+
__name(this, "CallListV3");
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Fast data retrieval without counting the total number of records.
|
|
23
|
+
*
|
|
24
|
+
* @template T - The type of the elements of the returned array (default is `unknown`).
|
|
25
|
+
*
|
|
26
|
+
* @param {ActionCallListV3} options - parameters for executing the request.
|
|
27
|
+
* - `method: string` - The name of the REST API method that returns a list of data (for example: `crm.item.list`, `tasks.task.list`)
|
|
28
|
+
* - `params?: Omit<TypeCallParams, 'pagination' | 'order'>` - Request parameters, excluding the `pagination` and `order` parameters,
|
|
29
|
+
* since the method is designed to obtain all data in one call.
|
|
30
|
+
* Note: Use `filter`, `order`, and `select` to control the selection.
|
|
31
|
+
* - `idKey?: string` - The name of the id field as it appears in each RESPONSE item; its value
|
|
32
|
+
* drives the cursor. Default is 'id'. Set it to match the id field the method returns.
|
|
33
|
+
* - `cursorIdKey?: string` - The field name used in the REQUEST for `order` and the
|
|
34
|
+
* `[field, '>', n]` page filter. Defaults to `idKey`. Set it only when the sortable /
|
|
35
|
+
* filterable field name differs from the response field name (e.g. an uppercase request
|
|
36
|
+
* field but a lowercase response id): pass `idKey: 'id', cursorIdKey: 'ID'`.
|
|
37
|
+
* - `customKeyForResult: string` - A custom key indicating that the response REST API will be
|
|
38
|
+
* grouped by this field.
|
|
39
|
+
* Example: `items` to group a list of CRM items.
|
|
40
|
+
* - `requestId?: string` - Unique request identifier for tracking. Used for query deduplication and debugging.
|
|
41
|
+
* - `limit?: number` - How many records to retrieve at a time. Default is `50`. Maximum is `1000`.
|
|
42
|
+
*
|
|
43
|
+
* @returns {Promise<Result<T[]>>} A promise that resolves to the result of an REST API call.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* import { Text } from '@bitrix24/b24jssdk'
|
|
47
|
+
*
|
|
48
|
+
* interface MainEventLogItem { id: number, userId: number }
|
|
49
|
+
* const sixMonthAgo = new Date()
|
|
50
|
+
* sixMonthAgo.setMonth((new Date()).getMonth() - 6)
|
|
51
|
+
* sixMonthAgo.setHours(0, 0, 0)
|
|
52
|
+
* const response = await b24.actions.v3.callList.make<MainEventLogItem>({
|
|
53
|
+
* method: 'main.eventlog.list',
|
|
54
|
+
* params: {
|
|
55
|
+
* filter: [
|
|
56
|
+
* ['timestampX', '>=', Text.toB24Format(sixMonthAgo)] // created at least 6 months ago
|
|
57
|
+
* ],
|
|
58
|
+
* select: ['id', 'userId']
|
|
59
|
+
* },
|
|
60
|
+
* idKey: 'id',
|
|
61
|
+
* customKeyForResult: 'items',
|
|
62
|
+
* requestId: 'eventlog-123',
|
|
63
|
+
* limit: 60
|
|
64
|
+
* })
|
|
65
|
+
* if (!response.isSuccess) {
|
|
66
|
+
* throw new Error(`Problem: ${response.getErrorMessages().join('; ')}`)
|
|
67
|
+
* }
|
|
68
|
+
* const list = response.getData()
|
|
69
|
+
* console.log(`Result: ${list?.length}`) // Number of items received
|
|
70
|
+
*/
|
|
71
|
+
async make(options) {
|
|
72
|
+
const batchSize = options?.limit ?? 50;
|
|
73
|
+
const result$1 = new result.Result();
|
|
74
|
+
const idKey = options?.idKey ?? "id";
|
|
75
|
+
const cursorIdKey = options?.cursorIdKey ?? idKey;
|
|
76
|
+
const customKeyForResult = options?.customKeyForResult ?? null;
|
|
77
|
+
const params = options?.params ?? {};
|
|
78
|
+
if ("order" in params && params["order"]) {
|
|
79
|
+
this._logger.warning("callList.make: user-provided `order` parameter is ignored because cursor-based pagination requires ordering by cursorIdKey. Use `filter` to narrow results instead.");
|
|
80
|
+
}
|
|
81
|
+
const { order: _ignoredOrder, ...restParams } = params;
|
|
82
|
+
const requestParams = {
|
|
83
|
+
...restParams,
|
|
84
|
+
order: { [cursorIdKey]: "ASC" },
|
|
85
|
+
filter: [...params["filter"] || []],
|
|
86
|
+
pagination: { page: 0, limit: batchSize }
|
|
87
|
+
};
|
|
88
|
+
const allItems = [];
|
|
89
|
+
try {
|
|
90
|
+
for await (const page of _keysetPaginate.keysetPaginate(this._b24, this._logger, {
|
|
91
|
+
method: options.method,
|
|
92
|
+
requestId: options.requestId,
|
|
93
|
+
customKeyForResult,
|
|
94
|
+
initialCursor: 0,
|
|
95
|
+
// Emulated keyset: append the `[cursorIdKey, '>', cursor]` page filter.
|
|
96
|
+
buildParams: /* @__PURE__ */ __name((cursor) => ({ ...requestParams, filter: [...requestParams.filter, [cursorIdKey, ">", cursor]] }), "buildParams"),
|
|
97
|
+
// Advance by the numeric id read from the last item via `idKey`. A
|
|
98
|
+
// non-numeric value (almost always an `idKey` that doesn't match the
|
|
99
|
+
// response field — e.g. sorting by `ID` while the response carries a
|
|
100
|
+
// lowercase `id`) stops the walk instead of silently truncating.
|
|
101
|
+
readNextCursor: /* @__PURE__ */ __name((lastItem) => {
|
|
102
|
+
const value = Number.parseInt(lastItem[idKey], 10);
|
|
103
|
+
return Number.isFinite(value) ? value : null;
|
|
104
|
+
}, "readNextCursor"),
|
|
105
|
+
noCursorWarning: `callList.make: pagination stops here \u2014 no numeric id could be read from the returned items via idKey "${idKey}". Make sure idKey matches the id field in the response; if the sortable field name differs from it, also set cursorIdKey (e.g. idKey: 'id', cursorIdKey: 'ID').`,
|
|
106
|
+
errorLabel: "callFastListMethod"
|
|
107
|
+
})) {
|
|
108
|
+
for (const item of page) {
|
|
109
|
+
allItems.push(item);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
} catch (error) {
|
|
113
|
+
if (error instanceof _keysetPaginate.KeysetPaginationError) {
|
|
114
|
+
for (const [index, err] of error.errors) {
|
|
115
|
+
result$1.addError(err, index);
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
throw error;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return result$1.setData(allItems);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
exports.CallListV3 = CallListV3;
|
|
126
|
+
//# sourceMappingURL=call-list.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-list.cjs","sources":["../../../../../src/core/actions/v3/call-list.ts"],"sourcesContent":["import type { ActionOptions } from '../abstract-action'\nimport type { TypeCallParams } from '../../../types/http'\nimport { AbstractAction } from '../abstract-action'\nimport { Result } from '../../result'\nimport { keysetPaginate, KeysetPaginationError } from './_keyset-paginate'\n\nexport type ActionCallListV3 = ActionOptions & {\n method: string\n params?: Omit<TypeCallParams, 'pagination' | 'order'>\n idKey?: string\n cursorIdKey?: string\n customKeyForResult: string\n requestId?: string\n limit?: number\n}\n\n/**\n * Fast data retrieval without counting the total number of records. `restApi:v3`\n *\n * @todo add docs\n */\nexport class CallListV3 extends AbstractAction {\n /**\n * Fast data retrieval without counting the total number of records.\n *\n * @template T - The type of the elements of the returned array (default is `unknown`).\n *\n * @param {ActionCallListV3} options - parameters for executing the request.\n * - `method: string` - The name of the REST API method that returns a list of data (for example: `crm.item.list`, `tasks.task.list`)\n * - `params?: Omit<TypeCallParams, 'pagination' | 'order'>` - Request parameters, excluding the `pagination` and `order` parameters,\n * since the method is designed to obtain all data in one call.\n * Note: Use `filter`, `order`, and `select` to control the selection.\n * - `idKey?: string` - The name of the id field as it appears in each RESPONSE item; its value\n * drives the cursor. Default is 'id'. Set it to match the id field the method returns.\n * - `cursorIdKey?: string` - The field name used in the REQUEST for `order` and the\n * `[field, '>', n]` page filter. Defaults to `idKey`. Set it only when the sortable /\n * filterable field name differs from the response field name (e.g. an uppercase request\n * field but a lowercase response id): pass `idKey: 'id', cursorIdKey: 'ID'`.\n * - `customKeyForResult: string` - A custom key indicating that the response REST API will be\n * grouped by this field.\n * Example: `items` to group a list of CRM items.\n * - `requestId?: string` - Unique request identifier for tracking. Used for query deduplication and debugging.\n * - `limit?: number` - How many records to retrieve at a time. Default is `50`. Maximum is `1000`.\n *\n * @returns {Promise<Result<T[]>>} A promise that resolves to the result of an REST API call.\n *\n * @example\n * import { Text } from '@bitrix24/b24jssdk'\n *\n * interface MainEventLogItem { id: number, userId: number }\n * const sixMonthAgo = new Date()\n * sixMonthAgo.setMonth((new Date()).getMonth() - 6)\n * sixMonthAgo.setHours(0, 0, 0)\n * const response = await b24.actions.v3.callList.make<MainEventLogItem>({\n * method: 'main.eventlog.list',\n * params: {\n * filter: [\n * ['timestampX', '>=', Text.toB24Format(sixMonthAgo)] // created at least 6 months ago\n * ],\n * select: ['id', 'userId']\n * },\n * idKey: 'id',\n * customKeyForResult: 'items',\n * requestId: 'eventlog-123',\n * limit: 60\n * })\n * if (!response.isSuccess) {\n * throw new Error(`Problem: ${response.getErrorMessages().join('; ')}`)\n * }\n * const list = response.getData()\n * console.log(`Result: ${list?.length}`) // Number of items received\n */\n public override async make<T = unknown>(options: ActionCallListV3): Promise<Result<T[]>> {\n const batchSize = options?.limit ?? 50\n const result: Result<T[]> = new Result()\n\n const idKey = options?.idKey ?? 'id'\n const cursorIdKey = options?.cursorIdKey ?? idKey\n const customKeyForResult = options?.customKeyForResult ?? null\n const params = options?.params ?? {}\n\n // Warn and strip user-provided `order` — cursor pagination requires ordering by cursorIdKey only\n if ('order' in params && params['order']) {\n this._logger.warning('callList.make: user-provided `order` parameter is ignored because cursor-based pagination requires ordering by cursorIdKey. Use `filter` to narrow results instead.')\n }\n\n const { order: _ignoredOrder, ...restParams } = params as TypeCallParams\n const requestParams: TypeCallParams = {\n ...restParams,\n order: { [cursorIdKey]: 'ASC' },\n filter: [...(params['filter'] || [])],\n pagination: { page: 0, limit: batchSize }\n }\n\n const allItems: T[] = []\n try {\n for await (const page of keysetPaginate<T>(this._b24, this._logger, {\n method: options.method,\n requestId: options.requestId,\n customKeyForResult,\n initialCursor: 0,\n // Emulated keyset: append the `[cursorIdKey, '>', cursor]` page filter.\n buildParams: cursor => ({ ...requestParams, filter: [...requestParams.filter, [cursorIdKey, '>', cursor]] }),\n // Advance by the numeric id read from the last item via `idKey`. A\n // non-numeric value (almost always an `idKey` that doesn't match the\n // response field — e.g. sorting by `ID` while the response carries a\n // lowercase `id`) stops the walk instead of silently truncating.\n readNextCursor: (lastItem) => {\n const value = Number.parseInt(lastItem[idKey], 10)\n return Number.isFinite(value) ? value : null\n },\n noCursorWarning: `callList.make: pagination stops here — no numeric id could be read from the returned items via idKey \"${idKey}\". Make sure idKey matches the id field in the response; if the sortable field name differs from it, also set cursorIdKey (e.g. idKey: 'id', cursorIdKey: 'ID').`,\n errorLabel: 'callFastListMethod'\n })) {\n for (const item of page) {\n allItems.push(item)\n }\n }\n } catch (error) {\n if (error instanceof KeysetPaginationError) {\n for (const [index, err] of error.errors) {\n result.addError(err, index)\n }\n } else {\n throw error\n }\n }\n\n return result.setData(allItems)\n }\n}\n"],"names":["AbstractAction","result","Result","keysetPaginate","KeysetPaginationError"],"mappings":"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"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @package @bitrix24/b24jssdk
|
|
3
|
+
* @version 2.0.0
|
|
4
|
+
* @copyright (c) 2026 Bitrix24
|
|
5
|
+
* @license MIT
|
|
6
|
+
* @see https://github.com/bitrix24/b24jssdk
|
|
7
|
+
* @see https://bitrix24.github.io/b24jssdk/
|
|
8
|
+
*/
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
const abstractAction = require('../abstract-action.cjs');
|
|
12
|
+
const result = require('../../result.cjs');
|
|
13
|
+
const sdkError = require('../../sdk-error.cjs');
|
|
14
|
+
const _keysetPaginate = require('./_keyset-paginate.cjs');
|
|
15
|
+
|
|
16
|
+
var __defProp = Object.defineProperty;
|
|
17
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
18
|
+
class CallTailV3 extends abstractAction.AbstractAction {
|
|
19
|
+
static {
|
|
20
|
+
__name(this, "CallTailV3");
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns every record of a `tail` method as one array.
|
|
24
|
+
*
|
|
25
|
+
* @template T - The type of the elements of the returned array (default is `unknown`).
|
|
26
|
+
*
|
|
27
|
+
* @param {ActionCallTailV3} options - parameters for executing the request.
|
|
28
|
+
* - `method: string` - A REST API `tail` method name (for example: `main.eventlog.tail`).
|
|
29
|
+
* - `params?: Omit<TypeCallParams, 'pagination' | 'order' | 'cursor'>` - Request parameters
|
|
30
|
+
* (`filter`, `select`). `pagination`, `order` and `cursor` are managed by this helper.
|
|
31
|
+
* The cursor field must NOT be used in `filter`.
|
|
32
|
+
* - `cursorField?: string` - The DTO field that drives the cursor. Default is `id`.
|
|
33
|
+
* - `order?: 'ASC' | 'DESC'` - Cursor direction. Default is `ASC`. For `DESC` you MUST pass
|
|
34
|
+
* `initialValue` (the server pages by `field < value`, so the default `0` returns nothing).
|
|
35
|
+
* - `customKeyForResult?: string` - The key the response groups rows under. Default is `items`.
|
|
36
|
+
* - `requestId?: string` - Unique request identifier for tracking.
|
|
37
|
+
* - `limit?: number` - How many records to retrieve at a time. Default is `50`. Maximum is `1000`.
|
|
38
|
+
* - `initialValue?: number | string` - Cursor start value for the first page. Default is `0`
|
|
39
|
+
* (valid for ascending numeric fields); required for `DESC` and for non-numeric fields.
|
|
40
|
+
*
|
|
41
|
+
* @returns {Promise<Result<T[]>>} A promise that resolves to the result of an REST API call.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* const response = await b24.actions.v3.callTail.make<{ id: string }>({
|
|
45
|
+
* method: 'main.eventlog.tail',
|
|
46
|
+
* params: { select: ['id', 'auditType'] },
|
|
47
|
+
* cursorField: 'id',
|
|
48
|
+
* customKeyForResult: 'items'
|
|
49
|
+
* })
|
|
50
|
+
* if (!response.isSuccess) {
|
|
51
|
+
* throw new Error(`Problem: ${response.getErrorMessages().join('; ')}`)
|
|
52
|
+
* }
|
|
53
|
+
* console.log(`Result: ${response.getData()?.length}`)
|
|
54
|
+
*/
|
|
55
|
+
async make(options) {
|
|
56
|
+
const batchSize = options?.limit ?? 50;
|
|
57
|
+
const result$1 = new result.Result();
|
|
58
|
+
const cursorField = options?.cursorField ?? "id";
|
|
59
|
+
const order = options?.order ?? "ASC";
|
|
60
|
+
const customKeyForResult = options?.customKeyForResult ?? "items";
|
|
61
|
+
const params = options?.params ?? {};
|
|
62
|
+
if (/desc/i.test(order) && options?.initialValue === void 0) {
|
|
63
|
+
throw new sdkError.SdkError({
|
|
64
|
+
code: "JSSDK_CORE_B24_CALL_TAIL_DESC_REQUIRES_INITIAL_VALUE",
|
|
65
|
+
description: 'callTail.make: order "DESC" requires an explicit `initialValue` (the server pages by `field < value`, so the default 0 returns nothing). Pass `initialValue` set to the type maximum / newest value.',
|
|
66
|
+
status: 500
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
if (Array.isArray(params["filter"]) && params["filter"].some((c) => Array.isArray(c) && c[0] === cursorField)) {
|
|
70
|
+
this._logger.warning(`callTail.make: the cursor field "${cursorField}" must not appear in \`filter\` \u2014 the server orders and pages by it and will reject a filter on the same field (INVALIDFILTEREXCEPTION). Remove it from \`filter\`.`);
|
|
71
|
+
}
|
|
72
|
+
let select = params["select"];
|
|
73
|
+
if (Array.isArray(select)) {
|
|
74
|
+
if (!select.includes(cursorField)) {
|
|
75
|
+
select = [...select, cursorField];
|
|
76
|
+
}
|
|
77
|
+
} else if (cursorField !== "id") {
|
|
78
|
+
this._logger.warning(`callTail.make: no \`select\` provided with a non-default cursorField "${cursorField}" \u2014 make sure it is in the server's default field set, otherwise pass \`select\` including "${cursorField}" so the cursor can advance.`);
|
|
79
|
+
}
|
|
80
|
+
const { select: _ignoredSelect, ...restParams } = params;
|
|
81
|
+
const allItems = [];
|
|
82
|
+
try {
|
|
83
|
+
for await (const page of _keysetPaginate.keysetPaginate(this._b24, this._logger, {
|
|
84
|
+
method: options.method,
|
|
85
|
+
requestId: options.requestId,
|
|
86
|
+
customKeyForResult,
|
|
87
|
+
initialCursor: options?.initialValue ?? 0,
|
|
88
|
+
// Native keyset: drive the server's `cursor: { field, value, order, limit }`.
|
|
89
|
+
buildParams: /* @__PURE__ */ __name((cursor) => ({
|
|
90
|
+
...restParams,
|
|
91
|
+
...select ? { select } : {},
|
|
92
|
+
cursor: { field: cursorField, value: cursor, order, limit: batchSize }
|
|
93
|
+
}), "buildParams"),
|
|
94
|
+
// Advance by the raw cursor-field value from the last item; a missing
|
|
95
|
+
// value (cursorField not selected / wrong name) stops the walk.
|
|
96
|
+
readNextCursor: /* @__PURE__ */ __name((lastItem) => lastItem[cursorField] ?? null, "readNextCursor"),
|
|
97
|
+
noCursorWarning: `callTail.make: pagination stops here \u2014 no value could be read from the returned items via cursorField "${cursorField}". Make sure cursorField matches a field present in the response (and in \`select\`).`,
|
|
98
|
+
errorLabel: "callTailMethod"
|
|
99
|
+
})) {
|
|
100
|
+
for (const item of page) {
|
|
101
|
+
allItems.push(item);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
} catch (error) {
|
|
105
|
+
if (error instanceof _keysetPaginate.KeysetPaginationError) {
|
|
106
|
+
for (const [index, err] of error.errors) {
|
|
107
|
+
result$1.addError(err, index);
|
|
108
|
+
}
|
|
109
|
+
} else {
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return result$1.setData(allItems);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
exports.CallTailV3 = CallTailV3;
|
|
118
|
+
//# sourceMappingURL=call-tail.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-tail.cjs","sources":["../../../../../src/core/actions/v3/call-tail.ts"],"sourcesContent":["import type { ActionOptions } from '../abstract-action'\nimport type { TypeCallParams } from '../../../types/http'\nimport { AbstractAction } from '../abstract-action'\nimport { Result } from '../../result'\nimport { SdkError } from '../../sdk-error'\nimport { keysetPaginate, KeysetPaginationError } from './_keyset-paginate'\n\nexport type ActionCallTailV3 = ActionOptions & {\n method: string\n params?: Omit<TypeCallParams, 'pagination' | 'order' | 'cursor'>\n cursorField?: string\n order?: 'ASC' | 'DESC' | 'asc' | 'desc' | string\n customKeyForResult?: string\n requestId?: string\n limit?: number\n initialValue?: number | string\n}\n\n/**\n * Fast data retrieval via the native `tail` (keyset cursor) action, without\n * counting the total number of records. `restApi:v3`\n *\n * The eager counterpart of `fetchTail`: it walks the same native\n * `cursor: { field, value, order, limit }` pagination and returns every record\n * as a single array. See the v3 reference §6.2. The cursor field MUST NOT appear\n * in `filter`.\n */\nexport class CallTailV3 extends AbstractAction {\n /**\n * Returns every record of a `tail` method as one array.\n *\n * @template T - The type of the elements of the returned array (default is `unknown`).\n *\n * @param {ActionCallTailV3} options - parameters for executing the request.\n * - `method: string` - A REST API `tail` method name (for example: `main.eventlog.tail`).\n * - `params?: Omit<TypeCallParams, 'pagination' | 'order' | 'cursor'>` - Request parameters\n * (`filter`, `select`). `pagination`, `order` and `cursor` are managed by this helper.\n * The cursor field must NOT be used in `filter`.\n * - `cursorField?: string` - The DTO field that drives the cursor. Default is `id`.\n * - `order?: 'ASC' | 'DESC'` - Cursor direction. Default is `ASC`. For `DESC` you MUST pass\n * `initialValue` (the server pages by `field < value`, so the default `0` returns nothing).\n * - `customKeyForResult?: string` - The key the response groups rows under. Default is `items`.\n * - `requestId?: string` - Unique request identifier for tracking.\n * - `limit?: number` - How many records to retrieve at a time. Default is `50`. Maximum is `1000`.\n * - `initialValue?: number | string` - Cursor start value for the first page. Default is `0`\n * (valid for ascending numeric fields); required for `DESC` and for non-numeric fields.\n *\n * @returns {Promise<Result<T[]>>} A promise that resolves to the result of an REST API call.\n *\n * @example\n * const response = await b24.actions.v3.callTail.make<{ id: string }>({\n * method: 'main.eventlog.tail',\n * params: { select: ['id', 'auditType'] },\n * cursorField: 'id',\n * customKeyForResult: 'items'\n * })\n * if (!response.isSuccess) {\n * throw new Error(`Problem: ${response.getErrorMessages().join('; ')}`)\n * }\n * console.log(`Result: ${response.getData()?.length}`)\n */\n public override async make<T = unknown>(options: ActionCallTailV3): Promise<Result<T[]>> {\n const batchSize = options?.limit ?? 50\n const result: Result<T[]> = new Result()\n\n const cursorField = options?.cursorField ?? 'id'\n const order = options?.order ?? 'ASC'\n const customKeyForResult = options?.customKeyForResult ?? 'items'\n const params = options?.params ?? {}\n\n // DESC keyset needs an explicit start: the server pages by `field < value`,\n // so the default first-page value 0 would match nothing for a non-negative\n // field. Require `initialValue` (the type maximum / newest value) for DESC.\n if (/desc/i.test(order) && options?.initialValue === undefined) {\n throw new SdkError({\n code: 'JSSDK_CORE_B24_CALL_TAIL_DESC_REQUIRES_INITIAL_VALUE',\n description: 'callTail.make: order \"DESC\" requires an explicit `initialValue` (the server pages by `field < value`, so the default 0 returns nothing). Pass `initialValue` set to the type maximum / newest value.',\n status: 500\n })\n }\n\n // Cursor field must not also live in `filter` (server rejects with\n // INVALIDFILTEREXCEPTION). Detection covers only the short-form triples.\n if (Array.isArray(params['filter']) && params['filter'].some((c: any) => Array.isArray(c) && c[0] === cursorField)) {\n this._logger.warning(`callTail.make: the cursor field \"${cursorField}\" must not appear in \\`filter\\` — the server orders and pages by it and will reject a filter on the same field (INVALIDFILTEREXCEPTION). Remove it from \\`filter\\`.`)\n }\n\n // Cursor field must be readable to advance. Append it to an explicit\n // `select`; warn for a non-default cursorField when `select` is omitted.\n let select = params['select'] as string[] | undefined\n if (Array.isArray(select)) {\n if (!select.includes(cursorField)) {\n select = [...select, cursorField]\n }\n } else if (cursorField !== 'id') {\n this._logger.warning(`callTail.make: no \\`select\\` provided with a non-default cursorField \"${cursorField}\" — make sure it is in the server's default field set, otherwise pass \\`select\\` including \"${cursorField}\" so the cursor can advance.`)\n }\n\n const { select: _ignoredSelect, ...restParams } = params as TypeCallParams\n\n const allItems: T[] = []\n try {\n for await (const page of keysetPaginate<T>(this._b24, this._logger, {\n method: options.method,\n requestId: options.requestId,\n customKeyForResult,\n initialCursor: options?.initialValue ?? 0,\n // Native keyset: drive the server's `cursor: { field, value, order, limit }`.\n buildParams: cursor => ({\n ...restParams,\n ...(select ? { select } : {}),\n cursor: { field: cursorField, value: cursor, order, limit: batchSize }\n }),\n // Advance by the raw cursor-field value from the last item; a missing\n // value (cursorField not selected / wrong name) stops the walk.\n readNextCursor: lastItem => lastItem[cursorField] ?? null,\n noCursorWarning: `callTail.make: pagination stops here — no value could be read from the returned items via cursorField \"${cursorField}\". Make sure cursorField matches a field present in the response (and in \\`select\\`).`,\n errorLabel: 'callTailMethod'\n })) {\n for (const item of page) {\n allItems.push(item)\n }\n }\n } catch (error) {\n if (error instanceof KeysetPaginationError) {\n for (const [index, err] of error.errors) {\n result.addError(err, index)\n }\n } else {\n throw error\n }\n }\n\n return result.setData(allItems)\n }\n}\n"],"names":["AbstractAction","result","Result","SdkError","keysetPaginate","KeysetPaginationError"],"mappings":"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"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @package @bitrix24/b24jssdk
|
|
3
|
+
* @version 2.0.0
|
|
4
|
+
* @copyright (c) 2026 Bitrix24
|
|
5
|
+
* @license MIT
|
|
6
|
+
* @see https://github.com/bitrix24/b24jssdk
|
|
7
|
+
* @see https://bitrix24.github.io/b24jssdk/
|
|
8
|
+
*/
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
const abstractAction = require('../abstract-action.cjs');
|
|
12
|
+
const b24 = require('../../../types/b24.cjs');
|
|
13
|
+
|
|
14
|
+
var __defProp = Object.defineProperty;
|
|
15
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
16
|
+
class CallV3 extends abstractAction.AbstractAction {
|
|
17
|
+
static {
|
|
18
|
+
__name(this, "CallV3");
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Calls the Bitrix24 REST API method.
|
|
22
|
+
*
|
|
23
|
+
* @template T - The expected data type in the response (default is `unknown`).
|
|
24
|
+
*
|
|
25
|
+
* @param {ActionCallV3} options - parameters for executing the request.
|
|
26
|
+
* - `method: string` - REST API method name (eg: `crm.item.get`)
|
|
27
|
+
* - `params?: TypeCallParams` - Parameters for calling the method.
|
|
28
|
+
* - `requestId?: string` - Unique request identifier for tracking. Used for query deduplication and debugging.
|
|
29
|
+
*
|
|
30
|
+
* @returns {Promise<AjaxResult<T>>} A promise that resolves to the result of an REST API call.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* interface TaskItem { id: number, title: string }
|
|
34
|
+
* const response = await b24.actions.v3.call.make<{ item: TaskItem }>({
|
|
35
|
+
* method: 'tasks.task.get',
|
|
36
|
+
* params: { id: 123, select: ['id', 'title'] },
|
|
37
|
+
* requestId: 'task-123'
|
|
38
|
+
* })
|
|
39
|
+
* if (!response.isSuccess) {
|
|
40
|
+
* throw new Error(`Problem: ${response.getErrorMessages().join('; ')}`)
|
|
41
|
+
* }
|
|
42
|
+
* console.log(response.getData().result.item.title)
|
|
43
|
+
*/
|
|
44
|
+
async make(options) {
|
|
45
|
+
const params = options.params || {};
|
|
46
|
+
return this._b24.getHttpClient(b24.ApiVersion.v3).call(options.method, params, options.requestId);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
exports.CallV3 = CallV3;
|
|
51
|
+
//# sourceMappingURL=call.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call.cjs","sources":["../../../../../src/core/actions/v3/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 { ApiVersion } from '../../../types/b24'\n\nexport type ActionCallV3 = ActionOptions & {\n method: string\n params?: TypeCallParams\n requestId?: string\n}\n\n/**\n * Calls the Bitrix24 REST API method `restApi:v3`\n *\n * @todo add docs\n */\nexport class CallV3 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 {ActionCallV3} 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 * interface TaskItem { id: number, title: string }\n * const response = await b24.actions.v3.call.make<{ item: TaskItem }>({\n * method: 'tasks.task.get',\n * params: { id: 123, select: ['id', 'title'] },\n * requestId: 'task-123'\n * })\n * if (!response.isSuccess) {\n * throw new Error(`Problem: ${response.getErrorMessages().join('; ')}`)\n * }\n * console.log(response.getData().result.item.title)\n */\n public override async make<T = unknown>(options: ActionCallV3): Promise<AjaxResult<T>> {\n // No client-side allowlist: the method is sent straight to the v3 endpoint\n // and the server decides (an unknown method returns METHODNOTFOUNDEXCEPTION).\n const params = options.params || {}\n return this._b24.getHttpClient(ApiVersion.v3).call<T>(options.method, params, options.requestId)\n }\n}\n"],"names":["AbstractAction","ApiVersion"],"mappings":";;;;;;;;;;;;;;;AAiBO,MAAM,eAAeA,6BAAA,CAAe;AAAA,EAjB3C;AAiB2C,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,EAyBzC,MAAsB,KAAkB,OAAA,EAA+C;AAGrF,IAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,MAAA,IAAU,EAAC;AAClC,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,aAAA,CAAcC,cAAA,CAAW,EAAE,CAAA,CAAE,IAAA,CAAQ,OAAA,CAAQ,MAAA,EAAQ,MAAA,EAAQ,OAAA,CAAQ,SAAS,CAAA;AAAA,EACjG;AACF;;;;"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @package @bitrix24/b24jssdk
|
|
3
|
+
* @version 2.0.0
|
|
4
|
+
* @copyright (c) 2026 Bitrix24
|
|
5
|
+
* @license MIT
|
|
6
|
+
* @see https://github.com/bitrix24/b24jssdk
|
|
7
|
+
* @see https://bitrix24.github.io/b24jssdk/
|
|
8
|
+
*/
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
const abstractAction = require('../abstract-action.cjs');
|
|
12
|
+
const sdkError = require('../../sdk-error.cjs');
|
|
13
|
+
const _keysetPaginate = require('./_keyset-paginate.cjs');
|
|
14
|
+
|
|
15
|
+
var __defProp = Object.defineProperty;
|
|
16
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
17
|
+
class FetchListV3 extends abstractAction.AbstractAction {
|
|
18
|
+
static {
|
|
19
|
+
__name(this, "FetchListV3");
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Calls a REST API list method and returns an async generator for efficient large data retrieval.
|
|
23
|
+
* Implements the fast algorithm for iterating over large datasets without loading all data into memory at once.
|
|
24
|
+
*
|
|
25
|
+
* @template T - The type of items in the returned arrays (default is `unknown`).
|
|
26
|
+
*
|
|
27
|
+
* @param {ActionFetchListV3} options - parameters for executing the request.
|
|
28
|
+
* - `method: string` - The name of the REST API method that returns a list of data (for example: `crm.item.list`, `tasks.task.list`)
|
|
29
|
+
* - `params?: Omit<TypeCallParams, 'pagination' | 'order'>` - Request parameters, excluding the `pagination` and `order` parameters,
|
|
30
|
+
* since the method is designed to obtain all data in one call.
|
|
31
|
+
* Note: Use `filter`, `order`, and `select` to control the selection.
|
|
32
|
+
* - `idKey?: string` - The name of the id field as it appears in each RESPONSE item; its value
|
|
33
|
+
* drives the cursor. Default is 'id'. Set it to match the id field the method returns.
|
|
34
|
+
* - `cursorIdKey?: string` - The field name used in the REQUEST for `order` and the
|
|
35
|
+
* `[field, '>', n]` page filter. Defaults to `idKey`. Set it only when the sortable /
|
|
36
|
+
* filterable field name differs from the response field name (e.g. an uppercase request
|
|
37
|
+
* field but a lowercase response id): pass `idKey: 'id', cursorIdKey: 'ID'`.
|
|
38
|
+
* - `customKeyForResult: string` - A custom key indicating that the response REST API will be
|
|
39
|
+
* grouped by this field.
|
|
40
|
+
* Example: `items` to group a list of CRM items.
|
|
41
|
+
* - `requestId?: string` - Unique request identifier for tracking. Used for query deduplication and debugging.
|
|
42
|
+
* - `limit?: number` - How many records to retrieve at a time. Default is `50`. Maximum is `1000`.
|
|
43
|
+
*
|
|
44
|
+
* @returns {AsyncGenerator<T[]>} An async generator that yields chunks of data as arrays of type `T`.
|
|
45
|
+
* Each iteration returns the next page/batch of results until all data is fetched.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* import { Text } from '@bitrix24/b24jssdk'
|
|
49
|
+
*
|
|
50
|
+
* interface MainEventLogItem { id: number, userId: number }
|
|
51
|
+
* const sixMonthAgo = new Date()
|
|
52
|
+
* sixMonthAgo.setMonth((new Date()).getMonth() - 6)
|
|
53
|
+
* sixMonthAgo.setHours(0, 0, 0)
|
|
54
|
+
* const generator = b24.actions.v3.fetchList.make<MainEventLogItem>({
|
|
55
|
+
* method: 'main.eventlog.list',
|
|
56
|
+
* params: {
|
|
57
|
+
* filter: [
|
|
58
|
+
* ['timestampX', '>=', Text.toB24Format(sixMonthAgo)] // created at least 6 months ago
|
|
59
|
+
* ],
|
|
60
|
+
* select: ['id', 'userId']
|
|
61
|
+
* },
|
|
62
|
+
* idKey: 'id',
|
|
63
|
+
* customKeyForResult: 'items',
|
|
64
|
+
* requestId: 'eventlog-123',
|
|
65
|
+
* limit: 60
|
|
66
|
+
* })
|
|
67
|
+
*
|
|
68
|
+
* for await (const chunk of generator) {
|
|
69
|
+
* // Process chunk (e.g., save to database, analyze, etc.)
|
|
70
|
+
* console.log(`Processing ${chunk.length} items`)
|
|
71
|
+
* }
|
|
72
|
+
*/
|
|
73
|
+
async *make(options) {
|
|
74
|
+
const batchSize = options?.limit ?? 50;
|
|
75
|
+
const idKey = options?.idKey ?? "id";
|
|
76
|
+
const cursorIdKey = options?.cursorIdKey ?? idKey;
|
|
77
|
+
const customKeyForResult = options?.customKeyForResult ?? null;
|
|
78
|
+
const params = options?.params ?? {};
|
|
79
|
+
if ("order" in params && params["order"]) {
|
|
80
|
+
this._logger.warning("fetchList.make: user-provided `order` parameter is ignored because cursor-based pagination requires ordering by cursorIdKey. Use `filter` to narrow results instead.");
|
|
81
|
+
}
|
|
82
|
+
const { order: _ignoredOrder, ...restParams } = params;
|
|
83
|
+
const requestParams = {
|
|
84
|
+
...restParams,
|
|
85
|
+
order: { [cursorIdKey]: "ASC" },
|
|
86
|
+
filter: [...params["filter"] || []],
|
|
87
|
+
pagination: { page: 0, limit: batchSize }
|
|
88
|
+
};
|
|
89
|
+
try {
|
|
90
|
+
yield* _keysetPaginate.keysetPaginate(this._b24, this._logger, {
|
|
91
|
+
method: options.method,
|
|
92
|
+
requestId: options.requestId,
|
|
93
|
+
customKeyForResult,
|
|
94
|
+
initialCursor: 0,
|
|
95
|
+
// Emulated keyset: append the `[cursorIdKey, '>', cursor]` page filter.
|
|
96
|
+
buildParams: /* @__PURE__ */ __name((cursor) => ({ ...requestParams, filter: [...requestParams.filter, [cursorIdKey, ">", cursor]] }), "buildParams"),
|
|
97
|
+
// Advance by the numeric id read from the last item via `idKey`. A
|
|
98
|
+
// non-numeric value (almost always an `idKey` that doesn't match the
|
|
99
|
+
// response field — e.g. sorting by `ID` while the response carries a
|
|
100
|
+
// lowercase `id`) stops the walk instead of silently truncating.
|
|
101
|
+
readNextCursor: /* @__PURE__ */ __name((lastItem) => {
|
|
102
|
+
const value = Number.parseInt(lastItem[idKey], 10);
|
|
103
|
+
return Number.isFinite(value) ? value : null;
|
|
104
|
+
}, "readNextCursor"),
|
|
105
|
+
noCursorWarning: `fetchList.make: pagination stops here \u2014 no numeric id could be read from the returned items via idKey "${idKey}". Make sure idKey matches the id field in the response; if the sortable field name differs from it, also set cursorIdKey (e.g. idKey: 'id', cursorIdKey: 'ID').`,
|
|
106
|
+
errorLabel: "fetchListMethod"
|
|
107
|
+
});
|
|
108
|
+
} catch (error) {
|
|
109
|
+
if (error instanceof _keysetPaginate.KeysetPaginationError) {
|
|
110
|
+
throw new sdkError.SdkError({
|
|
111
|
+
code: "JSSDK_CORE_B24_FETCH_LIST_METHOD_API_V3",
|
|
112
|
+
description: `API Error: ${error.messages.join("; ")}`,
|
|
113
|
+
status: 500
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
exports.FetchListV3 = FetchListV3;
|
|
122
|
+
//# sourceMappingURL=fetch-list.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-list.cjs","sources":["../../../../../src/core/actions/v3/fetch-list.ts"],"sourcesContent":["import type { ActionOptions } from '../abstract-action'\nimport type { TypeCallParams } from '../../../types/http'\nimport { AbstractAction } from '../abstract-action'\nimport { SdkError } from '../../sdk-error'\nimport { keysetPaginate, KeysetPaginationError } from './_keyset-paginate'\n\nexport type ActionFetchListV3 = ActionOptions & {\n method: string\n params?: Omit<TypeCallParams, 'pagination' | 'order'>\n idKey?: string\n cursorIdKey?: string\n customKeyForResult: string\n requestId?: string\n limit?: number\n}\n\n/**\n * Calls a REST API list method and returns an async generator for efficient large data retrieval. `restApi:v3`\n *\n * @todo add docs\n */\nexport class FetchListV3 extends AbstractAction {\n /**\n * Calls a REST API list method and returns an async generator for efficient large data retrieval.\n * Implements the fast algorithm for iterating over large datasets without loading all data into memory at once.\n *\n * @template T - The type of items in the returned arrays (default is `unknown`).\n *\n * @param {ActionFetchListV3} options - parameters for executing the request.\n * - `method: string` - The name of the REST API method that returns a list of data (for example: `crm.item.list`, `tasks.task.list`)\n * - `params?: Omit<TypeCallParams, 'pagination' | 'order'>` - Request parameters, excluding the `pagination` and `order` parameters,\n * since the method is designed to obtain all data in one call.\n * Note: Use `filter`, `order`, and `select` to control the selection.\n * - `idKey?: string` - The name of the id field as it appears in each RESPONSE item; its value\n * drives the cursor. Default is 'id'. Set it to match the id field the method returns.\n * - `cursorIdKey?: string` - The field name used in the REQUEST for `order` and the\n * `[field, '>', n]` page filter. Defaults to `idKey`. Set it only when the sortable /\n * filterable field name differs from the response field name (e.g. an uppercase request\n * field but a lowercase response id): pass `idKey: 'id', cursorIdKey: 'ID'`.\n * - `customKeyForResult: string` - A custom key indicating that the response REST API will be\n * grouped by this field.\n * Example: `items` to group a list of CRM items.\n * - `requestId?: string` - Unique request identifier for tracking. Used for query deduplication and debugging.\n * - `limit?: number` - How many records to retrieve at a time. Default is `50`. Maximum is `1000`.\n *\n * @returns {AsyncGenerator<T[]>} An async generator that yields chunks of data as arrays of type `T`.\n * Each iteration returns the next page/batch of results until all data is fetched.\n *\n * @example\n * import { Text } from '@bitrix24/b24jssdk'\n *\n * interface MainEventLogItem { id: number, userId: number }\n * const sixMonthAgo = new Date()\n * sixMonthAgo.setMonth((new Date()).getMonth() - 6)\n * sixMonthAgo.setHours(0, 0, 0)\n * const generator = b24.actions.v3.fetchList.make<MainEventLogItem>({\n * method: 'main.eventlog.list',\n * params: {\n * filter: [\n * ['timestampX', '>=', Text.toB24Format(sixMonthAgo)] // created at least 6 months ago\n * ],\n * select: ['id', 'userId']\n * },\n * idKey: 'id',\n * customKeyForResult: 'items',\n * requestId: 'eventlog-123',\n * limit: 60\n * })\n *\n * for await (const chunk of generator) {\n * // Process chunk (e.g., save to database, analyze, etc.)\n * console.log(`Processing ${chunk.length} items`)\n * }\n */\n public override async* make<T = unknown>(options: ActionFetchListV3): AsyncGenerator<T[]> {\n const batchSize = options?.limit ?? 50\n\n const idKey = options?.idKey ?? 'id'\n const cursorIdKey = options?.cursorIdKey ?? idKey\n const customKeyForResult = options?.customKeyForResult ?? null\n const params = options?.params ?? {}\n\n // Warn and strip user-provided `order` — cursor pagination requires ordering by cursorIdKey only\n if ('order' in params && params['order']) {\n this._logger.warning('fetchList.make: user-provided `order` parameter is ignored because cursor-based pagination requires ordering by cursorIdKey. Use `filter` to narrow results instead.')\n }\n\n const { order: _ignoredOrder, ...restParams } = params as TypeCallParams\n const requestParams: TypeCallParams = {\n ...restParams,\n order: { [cursorIdKey]: 'ASC' },\n filter: [...(params['filter'] || [])],\n pagination: { page: 0, limit: batchSize }\n }\n\n try {\n yield* keysetPaginate<T>(this._b24, this._logger, {\n method: options.method,\n requestId: options.requestId,\n customKeyForResult,\n initialCursor: 0,\n // Emulated keyset: append the `[cursorIdKey, '>', cursor]` page filter.\n buildParams: cursor => ({ ...requestParams, filter: [...requestParams.filter, [cursorIdKey, '>', cursor]] }),\n // Advance by the numeric id read from the last item via `idKey`. A\n // non-numeric value (almost always an `idKey` that doesn't match the\n // response field — e.g. sorting by `ID` while the response carries a\n // lowercase `id`) stops the walk instead of silently truncating.\n readNextCursor: (lastItem) => {\n const value = Number.parseInt(lastItem[idKey], 10)\n return Number.isFinite(value) ? value : null\n },\n noCursorWarning: `fetchList.make: pagination stops here — no numeric id could be read from the returned items via idKey \"${idKey}\". Make sure idKey matches the id field in the response; if the sortable field name differs from it, also set cursorIdKey (e.g. idKey: 'id', cursorIdKey: 'ID').`,\n errorLabel: 'fetchListMethod'\n })\n } catch (error) {\n if (error instanceof KeysetPaginationError) {\n throw new SdkError({\n code: 'JSSDK_CORE_B24_FETCH_LIST_METHOD_API_V3',\n description: `API Error: ${error.messages.join('; ')}`,\n status: 500\n })\n }\n throw error\n }\n }\n}\n"],"names":["AbstractAction","keysetPaginate","KeysetPaginationError","SdkError"],"mappings":";;;;;;;;;;;;;;;;AAqBO,MAAM,oBAAoBA,6BAAA,CAAe;AAAA,EArBhD;AAqBgD,IAAA,MAAA,CAAA,IAAA,EAAA,aAAA,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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqD9C,OAAuB,KAAkB,OAAA,EAAiD;AACxF,IAAA,MAAM,SAAA,GAAY,SAAS,KAAA,IAAS,EAAA;AAEpC,IAAA,MAAM,KAAA,GAAQ,SAAS,KAAA,IAAS,IAAA;AAChC,IAAA,MAAM,WAAA,GAAc,SAAS,WAAA,IAAe,KAAA;AAC5C,IAAA,MAAM,kBAAA,GAAqB,SAAS,kBAAA,IAAsB,IAAA;AAC1D,IAAA,MAAM,MAAA,GAAS,OAAA,EAAS,MAAA,IAAU,EAAC;AAGnC,IAAA,IAAI,OAAA,IAAW,MAAA,IAAU,MAAA,CAAO,OAAO,CAAA,EAAG;AACxC,MAAA,IAAA,CAAK,OAAA,CAAQ,QAAQ,sKAAsK,CAAA;AAAA,IAC7L;AAEA,IAAA,MAAM,EAAE,KAAA,EAAO,aAAA,EAAe,GAAG,YAAW,GAAI,MAAA;AAChD,IAAA,MAAM,aAAA,GAAgC;AAAA,MACpC,GAAG,UAAA;AAAA,MACH,KAAA,EAAO,EAAE,CAAC,WAAW,GAAG,KAAA,EAAM;AAAA,MAC9B,QAAQ,CAAC,GAAI,OAAO,QAAQ,CAAA,IAAK,EAAG,CAAA;AAAA,MACpC,UAAA,EAAY,EAAE,IAAA,EAAM,CAAA,EAAG,OAAO,SAAA;AAAU,KAC1C;AAEA,IAAA,IAAI;AACF,MAAA,OAAOC,8BAAA,CAAkB,IAAA,CAAK,IAAA,EAAM,IAAA,CAAK,OAAA,EAAS;AAAA,QAChD,QAAQ,OAAA,CAAQ,MAAA;AAAA,QAChB,WAAW,OAAA,CAAQ,SAAA;AAAA,QACnB,kBAAA;AAAA,QACA,aAAA,EAAe,CAAA;AAAA;AAAA,QAEf,6BAAa,MAAA,CAAA,CAAA,MAAA,MAAW,EAAE,GAAG,aAAA,EAAe,QAAQ,CAAC,GAAG,aAAA,CAAc,MAAA,EAAQ,CAAC,WAAA,EAAa,GAAA,EAAK,MAAM,CAAC,GAAE,CAAA,EAA7F,aAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAKb,cAAA,0BAAiB,QAAA,KAAa;AAC5B,UAAA,MAAM,QAAQ,MAAA,CAAO,QAAA,CAAS,QAAA,CAAS,KAAK,GAAG,EAAE,CAAA;AACjD,UAAA,OAAO,MAAA,CAAO,QAAA,CAAS,KAAK,CAAA,GAAI,KAAA,GAAQ,IAAA;AAAA,QAC1C,CAAA,EAHgB,gBAAA,CAAA;AAAA,QAIhB,eAAA,EAAiB,+GAA0G,KAAK,CAAA,gKAAA,CAAA;AAAA,QAChI,UAAA,EAAY;AAAA,OACb,CAAA;AAAA,IACH,SAAS,KAAA,EAAO;AACd,MAAA,IAAI,iBAAiBC,qCAAA,EAAuB;AAC1C,QAAA,MAAM,IAAIC,iBAAA,CAAS;AAAA,UACjB,IAAA,EAAM,yCAAA;AAAA,UACN,aAAa,CAAA,WAAA,EAAc,KAAA,CAAM,QAAA,CAAS,IAAA,CAAK,IAAI,CAAC,CAAA,CAAA;AAAA,UACpD,MAAA,EAAQ;AAAA,SACT,CAAA;AAAA,MACH;AACA,MAAA,MAAM,KAAA;AAAA,IACR;AAAA,EACF;AACF;;;;"}
|