bx-rest 1.5.1 → 1.7.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/CHANGELOG.md +163 -0
- package/README.en.md +206 -3
- package/README.md +207 -3
- package/consts/part-name-methods.d.ts +1 -0
- package/esm2022/consts/part-name-methods.mjs +2 -1
- package/esm2022/functions/errors.mjs +17 -5
- package/esm2022/functions/uniqueElementCode.mjs +24 -0
- package/esm2022/map/pull/application/config.mjs +25 -29
- package/esm2022/map/pull.mjs +8 -13
- package/esm2022/public-api.mjs +3 -2
- package/esm2022/request-navvy/bizproc.mjs +18 -9
- package/esm2022/request-navvy/booking/v1/resource.mjs +2 -2
- package/esm2022/request-navvy/booking/v1/resourcetype.mjs +2 -2
- package/esm2022/request-navvy/calendar/event.mjs +1 -9
- package/esm2022/request-navvy/catalog/catalog.mjs +2 -2
- package/esm2022/request-navvy/catalog/document/element.mjs +2 -2
- package/esm2022/request-navvy/catalog/document.mjs +2 -2
- package/esm2022/request-navvy/catalog/documentcontractor.mjs +2 -2
- package/esm2022/request-navvy/catalog/extra.mjs +2 -2
- package/esm2022/request-navvy/catalog/measure.mjs +2 -2
- package/esm2022/request-navvy/catalog/price.mjs +2 -2
- package/esm2022/request-navvy/catalog/pricetype.mjs +2 -2
- package/esm2022/request-navvy/catalog/pricetypegroup.mjs +2 -2
- package/esm2022/request-navvy/catalog/pricetypelang.mjs +2 -2
- package/esm2022/request-navvy/catalog/product/offer.mjs +2 -2
- package/esm2022/request-navvy/catalog/product/service.mjs +2 -2
- package/esm2022/request-navvy/catalog/product/sku.mjs +2 -2
- package/esm2022/request-navvy/catalog/product.mjs +2 -2
- package/esm2022/request-navvy/catalog/productproperty.mjs +2 -2
- package/esm2022/request-navvy/catalog/productpropertyenum.mjs +2 -2
- package/esm2022/request-navvy/catalog/productpropertyfeature.mjs +2 -2
- package/esm2022/request-navvy/catalog/productpropertysection.mjs +2 -2
- package/esm2022/request-navvy/catalog/ratio.mjs +2 -2
- package/esm2022/request-navvy/catalog/roundingrule.mjs +2 -2
- package/esm2022/request-navvy/catalog/section.mjs +2 -2
- package/esm2022/request-navvy/catalog/store.mjs +2 -2
- package/esm2022/request-navvy/catalog/storeproduct.mjs +2 -2
- package/esm2022/request-navvy/catalog/userfield/document.mjs +2 -2
- package/esm2022/request-navvy/catalog/vat.mjs +2 -2
- package/esm2022/request-navvy/crm/activity.mjs +2 -2
- package/esm2022/request-navvy/crm/deal/recurring.mjs +2 -2
- package/esm2022/request-navvy/crm/item/product/row.mjs +2 -2
- package/esm2022/request-navvy/crm/orderentity.mjs +2 -2
- package/esm2022/request-navvy/crm/requisite/link.mjs +2 -2
- package/esm2022/request-navvy/crm/stagehistory.mjs +2 -2
- package/esm2022/request-navvy/crm/timeline/bindings.mjs +2 -2
- package/esm2022/request-navvy/disk/operation.mjs +3 -10
- package/esm2022/request-navvy/documentgenerator/document.mjs +2 -2
- package/esm2022/request-navvy/documentgenerator/numerator.mjs +2 -2
- package/esm2022/request-navvy/documentgenerator/role.mjs +2 -2
- package/esm2022/request-navvy/documentgenerator/template.mjs +2 -2
- package/esm2022/request-navvy/pull/application/config.mjs +10 -4
- package/esm2022/request-navvy/pull/application/event.mjs +23 -0
- package/esm2022/request-navvy/pull/application/push.mjs +23 -0
- package/esm2022/request-navvy/pull/channel/public.mjs +4 -4
- package/esm2022/request-navvy/pull/config.mjs +8 -4
- package/esm2022/request-navvy/pull.mjs +12 -1
- package/esm2022/request-navvy/sale/basketitem.mjs +2 -2
- package/esm2022/request-navvy/sale/basketproperties.mjs +2 -2
- package/esm2022/request-navvy/sale/businessvaluepersondomain.mjs +2 -2
- package/esm2022/request-navvy/sale/order.mjs +2 -2
- package/esm2022/request-navvy/sale/payment.mjs +2 -2
- package/esm2022/request-navvy/sale/paymentitembasket.mjs +2 -2
- package/esm2022/request-navvy/sale/paymentitemshipment.mjs +2 -2
- package/esm2022/request-navvy/sale/persontype.mjs +2 -2
- package/esm2022/request-navvy/sale/property.mjs +2 -2
- package/esm2022/request-navvy/sale/propertyrelation.mjs +2 -2
- package/esm2022/request-navvy/sale/propertyvalue.mjs +2 -2
- package/esm2022/request-navvy/sale/propertyvariant.mjs +2 -2
- package/esm2022/request-navvy/sale/shipment.mjs +2 -2
- package/esm2022/request-navvy/sale/shipmentitem.mjs +2 -2
- package/esm2022/request-navvy/sale/shipmentproperty.mjs +2 -2
- package/esm2022/request-navvy/sale/shipmentpropertyvalue.mjs +2 -2
- package/esm2022/request-navvy/sale/status.mjs +2 -2
- package/esm2022/request-navvy/sale/statuslang.mjs +2 -2
- package/esm2022/request-navvy/sale/tradebinding.mjs +2 -2
- package/esm2022/request-navvy/sale/tradeplatform.mjs +2 -2
- package/esm2022/request-navvy/socialnetwork/api/livefeed.mjs +1 -5
- package/esm2022/request-navvy/task/operation/elapseditem.mjs +51 -28
- package/esm2022/request-navvy/tasks/task.mjs +1 -119
- package/esm2022/request-navvy/userfieldtype.mjs +2 -2
- package/esm2022/rest/navvy.mjs +66 -64
- package/esm2022/services/base.mjs +1 -4
- package/esm2022/services/context.mjs +59 -0
- package/esm2022/services/http/HttpBX.mjs +52 -19
- package/esm2022/services/http/authRefresh.mjs +25 -23
- package/esm2022/services/http/fetch.mjs +45 -0
- package/esm2022/services/http/http.mjs +25 -71
- package/esm2022/services/http/middleware.mjs +203 -0
- package/esm2022/services/http/sessionKey.mjs +16 -5
- package/esm2022/services/http/transport.mjs +5 -0
- package/esm2022/services/navvy/navvy-pag-nav-keyed.mjs +31 -0
- package/esm2022/services/navvy/navvy-support.mjs +2 -15
- package/esm2022/services/navvy.mjs +32 -31
- package/esm2022/typification/rest/calendar/event/get.mjs +1 -1
- package/esm2022/typification/rest/crm/requisite.mjs +1 -1
- package/esm2022/typification/rest/crm/timeline/bindings.mjs +1 -1
- package/esm2022/typification/rest/pull/application/config/get.mjs +1 -1
- package/esm2022/typification/rest/pull/application/event/add.mjs +2 -0
- package/esm2022/typification/rest/pull/application/push/add.mjs +2 -0
- package/esm2022/typification/rest/pull/config/get.mjs +1 -1
- package/esm2022/typification/rest/pull.mjs +3 -1
- package/esm2022/typification/rest/tasks/task/get.mjs +1 -1
- package/esm2022/typification/settings.mjs +1 -1
- package/fesm2022/bx-rest.mjs +800 -588
- package/fesm2022/bx-rest.mjs.map +1 -1
- package/functions/errors.d.ts +9 -0
- package/functions/uniqueElementCode.d.ts +12 -0
- package/map/pull/application/config.d.ts +3 -0
- package/package.json +1 -1
- package/public-api.d.ts +4 -2
- package/request-navvy/booking/v1/resource.d.ts +1 -1
- package/request-navvy/booking/v1/resourcetype.d.ts +1 -1
- package/request-navvy/catalog/catalog.d.ts +1 -1
- package/request-navvy/catalog/document/element.d.ts +1 -1
- package/request-navvy/catalog/document.d.ts +1 -1
- package/request-navvy/catalog/documentcontractor.d.ts +1 -1
- package/request-navvy/catalog/extra.d.ts +1 -1
- package/request-navvy/catalog/measure.d.ts +1 -1
- package/request-navvy/catalog/price.d.ts +1 -1
- package/request-navvy/catalog/pricetype.d.ts +1 -1
- package/request-navvy/catalog/pricetypegroup.d.ts +1 -1
- package/request-navvy/catalog/pricetypelang.d.ts +1 -1
- package/request-navvy/catalog/product/offer.d.ts +1 -1
- package/request-navvy/catalog/product/service.d.ts +1 -1
- package/request-navvy/catalog/product/sku.d.ts +1 -1
- package/request-navvy/catalog/product.d.ts +1 -1
- package/request-navvy/catalog/productproperty.d.ts +1 -1
- package/request-navvy/catalog/productpropertyenum.d.ts +1 -1
- package/request-navvy/catalog/productpropertyfeature.d.ts +1 -1
- package/request-navvy/catalog/productpropertysection.d.ts +1 -1
- package/request-navvy/catalog/ratio.d.ts +1 -1
- package/request-navvy/catalog/roundingrule.d.ts +1 -1
- package/request-navvy/catalog/section.d.ts +1 -1
- package/request-navvy/catalog/store.d.ts +1 -1
- package/request-navvy/catalog/storeproduct.d.ts +1 -1
- package/request-navvy/catalog/userfield/document.d.ts +1 -1
- package/request-navvy/catalog/vat.d.ts +1 -1
- package/request-navvy/crm/activity.d.ts +1 -1
- package/request-navvy/crm/deal/recurring.d.ts +1 -1
- package/request-navvy/crm/item/product/row.d.ts +5 -1
- package/request-navvy/crm/orderentity.d.ts +5 -1
- package/request-navvy/crm/requisite/link.d.ts +1 -1
- package/request-navvy/crm/stagehistory.d.ts +5 -1
- package/request-navvy/crm/timeline/bindings.d.ts +1 -1
- package/request-navvy/documentgenerator/document.d.ts +1 -1
- package/request-navvy/documentgenerator/numerator.d.ts +1 -1
- package/request-navvy/documentgenerator/role.d.ts +1 -1
- package/request-navvy/documentgenerator/template.d.ts +1 -1
- package/request-navvy/pull/application/config.d.ts +9 -3
- package/request-navvy/pull/application/event.d.ts +17 -0
- package/request-navvy/pull/application/push.d.ts +17 -0
- package/request-navvy/pull/config.d.ts +7 -3
- package/request-navvy/pull.d.ts +11 -0
- package/request-navvy/sale/basketitem.d.ts +1 -1
- package/request-navvy/sale/basketproperties.d.ts +1 -1
- package/request-navvy/sale/businessvaluepersondomain.d.ts +1 -1
- package/request-navvy/sale/order.d.ts +1 -1
- package/request-navvy/sale/payment.d.ts +1 -1
- package/request-navvy/sale/paymentitembasket.d.ts +1 -1
- package/request-navvy/sale/paymentitemshipment.d.ts +1 -1
- package/request-navvy/sale/persontype.d.ts +1 -1
- package/request-navvy/sale/property.d.ts +1 -1
- package/request-navvy/sale/propertyrelation.d.ts +1 -1
- package/request-navvy/sale/propertyvalue.d.ts +1 -1
- package/request-navvy/sale/propertyvariant.d.ts +1 -1
- package/request-navvy/sale/shipment.d.ts +1 -1
- package/request-navvy/sale/shipmentitem.d.ts +1 -1
- package/request-navvy/sale/shipmentproperty.d.ts +1 -1
- package/request-navvy/sale/shipmentpropertyvalue.d.ts +1 -1
- package/request-navvy/sale/status.d.ts +1 -1
- package/request-navvy/sale/statuslang.d.ts +1 -1
- package/request-navvy/sale/tradebinding.d.ts +1 -1
- package/request-navvy/sale/tradeplatform.d.ts +1 -1
- package/request-navvy/task/operation/elapseditem.d.ts +15 -10
- package/request-navvy/userfieldtype.d.ts +1 -1
- package/rest/navvy.d.ts +9 -0
- package/services/context.d.ts +43 -0
- package/services/http/HttpBX.d.ts +11 -0
- package/services/http/authRefresh.d.ts +5 -1
- package/services/http/fetch.d.ts +22 -0
- package/services/http/http.d.ts +20 -9
- package/services/http/middleware.d.ts +32 -0
- package/services/http/sessionKey.d.ts +10 -0
- package/services/http/transport.d.ts +28 -0
- package/services/navvy/navvy-pag-nav-keyed.d.ts +18 -0
- package/services/navvy/navvy-support.d.ts +0 -10
- package/services/navvy.d.ts +17 -0
- package/typification/rest/calendar/event/get.d.ts +1 -1
- package/typification/rest/crm/requisite.d.ts +1 -1
- package/typification/rest/crm/timeline/bindings.d.ts +2 -1
- package/typification/rest/pull/application/config/get.d.ts +1 -1
- package/typification/rest/pull/application/event/add.d.ts +24 -0
- package/typification/rest/pull/application/push/add.d.ts +16 -0
- package/typification/rest/pull/config/get.d.ts +28 -3
- package/typification/rest/pull.d.ts +2 -0
- package/typification/settings.d.ts +68 -0
- package/esm2022/functions/errorHandler.mjs +0 -34
- package/esm2022/request/app.mjs +0 -13
- package/esm2022/request/bizproc/activity.mjs +0 -3
- package/esm2022/request/bizproc/event.mjs +0 -3
- package/esm2022/request/bizproc/robot.mjs +0 -3
- package/esm2022/request/bizproc/task.mjs +0 -3
- package/esm2022/request/bizproc/workflow/instance.mjs +0 -3
- package/esm2022/request/bizproc/workflow/template.mjs +0 -3
- package/esm2022/request/bizproc/workflow.mjs +0 -18
- package/esm2022/request/bizproc.mjs +0 -15
- package/esm2022/request/department.mjs +0 -26
- package/esm2022/request/disk/attachedObject.mjs +0 -14
- package/esm2022/request/disk/file.mjs +0 -18
- package/esm2022/request/disk/folder.mjs +0 -117
- package/esm2022/request/disk.mjs +0 -11
- package/esm2022/request/lists/element.mjs +0 -18
- package/esm2022/request/lists/field.mjs +0 -35
- package/esm2022/request/lists.mjs +0 -86
- package/esm2022/request/log/blogcomment.mjs +0 -3
- package/esm2022/request/log/blogpost.mjs +0 -18
- package/esm2022/request/log.mjs +0 -9
- package/esm2022/request/pull/application/config.mjs +0 -11
- package/esm2022/request/pull/channel/public.mjs +0 -18
- package/esm2022/request/pull/config.mjs +0 -13
- package/esm2022/request/pull.mjs +0 -11
- package/esm2022/request/server.mjs +0 -14
- package/esm2022/request/socialnetwork/api/contentview.mjs +0 -14
- package/esm2022/request/socialnetwork/api/livefeed/blogpost/important.mjs +0 -14
- package/esm2022/request/socialnetwork/api/livefeed/blogpost.mjs +0 -7
- package/esm2022/request/socialnetwork/api/livefeed.mjs +0 -7
- package/esm2022/request/socialnetwork/api.mjs +0 -9
- package/esm2022/request/socialnetwork.mjs +0 -8
- package/esm2022/request/sonet_group.mjs +0 -24
- package/esm2022/request/task/commentitem.mjs +0 -32
- package/esm2022/request/task/elapseditem.mjs +0 -40
- package/esm2022/request/task/item/userfield.mjs +0 -14
- package/esm2022/request/task/item.mjs +0 -7
- package/esm2022/request/task/planner.mjs +0 -11
- package/esm2022/request/task.mjs +0 -13
- package/esm2022/request/tasks/task/result.mjs +0 -22
- package/esm2022/request/tasks/task.mjs +0 -110
- package/esm2022/request/tasks.mjs +0 -7
- package/esm2022/request/user/userfield.mjs +0 -14
- package/esm2022/request/user.mjs +0 -40
- package/esm2022/rest/base.mjs +0 -39
- package/esm2022/services/http/HttpData.mjs +0 -77
- package/esm2022/services/http/base/base.mjs +0 -4
- package/esm2022/services/http/httpNavvy.mjs +0 -14
- package/esm2022/typification/base/answers.mjs +0 -438
- package/esm2022/typification/base/params.mjs +0 -525
- package/esm2022/typification/base/workpiece/methods-list.mjs +0 -2
- package/esm2022/typification/base/workpiece/methods.mjs +0 -2
- package/functions/errorHandler.d.ts +0 -10
- package/request/app.d.ts +0 -8
- package/request/bizproc/activity.d.ts +0 -2
- package/request/bizproc/event.d.ts +0 -2
- package/request/bizproc/robot.d.ts +0 -2
- package/request/bizproc/task.d.ts +0 -2
- package/request/bizproc/workflow/instance.d.ts +0 -2
- package/request/bizproc/workflow/template.d.ts +0 -2
- package/request/bizproc/workflow.d.ts +0 -13
- package/request/bizproc.d.ts +0 -12
- package/request/department.d.ts +0 -18
- package/request/disk/attachedObject.d.ts +0 -8
- package/request/disk/file.d.ts +0 -10
- package/request/disk/folder.d.ts +0 -96
- package/request/disk.d.ts +0 -8
- package/request/lists/element.d.ts +0 -11
- package/request/lists/field.d.ts +0 -11
- package/request/lists.d.ts +0 -31
- package/request/log/blogcomment.d.ts +0 -2
- package/request/log/blogpost.d.ts +0 -11
- package/request/log.d.ts +0 -6
- package/request/pull/application/config.d.ts +0 -5
- package/request/pull/channel/public.d.ts +0 -5
- package/request/pull/config.d.ts +0 -7
- package/request/pull.d.ts +0 -8
- package/request/server.d.ts +0 -7
- package/request/socialnetwork/api/contentview.d.ts +0 -6
- package/request/socialnetwork/api/livefeed/blogpost/important.d.ts +0 -6
- package/request/socialnetwork/api/livefeed/blogpost.d.ts +0 -4
- package/request/socialnetwork/api/livefeed.d.ts +0 -4
- package/request/socialnetwork/api.d.ts +0 -6
- package/request/socialnetwork.d.ts +0 -4
- package/request/sonet_group.d.ts +0 -8
- package/request/task/commentitem.d.ts +0 -23
- package/request/task/elapseditem.d.ts +0 -26
- package/request/task/item/userfield.d.ts +0 -6
- package/request/task/item.d.ts +0 -4
- package/request/task/planner.d.ts +0 -4
- package/request/task.d.ts +0 -10
- package/request/tasks/task/result.d.ts +0 -13
- package/request/tasks/task.d.ts +0 -37
- package/request/tasks.d.ts +0 -4
- package/request/user/userfield.d.ts +0 -8
- package/request/user.d.ts +0 -24
- package/rest/base.d.ts +0 -33
- package/services/http/HttpData.d.ts +0 -7
- package/services/http/base/base.d.ts +0 -7
- package/services/http/httpNavvy.d.ts +0 -10
- package/typification/base/answers.d.ts +0 -12
- package/typification/base/params.d.ts +0 -16
- package/typification/base/workpiece/methods-list.d.ts +0 -247
- package/typification/base/workpiece/methods.d.ts +0 -20
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,169 @@
|
|
|
7
7
|
История до версии 1.0.0 здесь не восстанавливалась — смотрите `git log` для
|
|
8
8
|
более ранних изменений.
|
|
9
9
|
|
|
10
|
+
## [1.7.0] - 2026-11-11
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `.resAll()` у 59 списочных методов, которые листаются через `start`:
|
|
15
|
+
`catalog.*.list` (25 методов), `sale.*.list` (20),
|
|
16
|
+
`documentgenerator.{document,numerator,role,template}.list`,
|
|
17
|
+
`booking.v1.resource.list`, `booking.v1.resourcetype.list`,
|
|
18
|
+
`crm.activity.list`, `crm.item.productrow.list`, `crm.orderentity.list`,
|
|
19
|
+
`crm.stagehistory.list`, `crm.timeline.bindings.list`,
|
|
20
|
+
`crm.requisite.link.list`, `crm.deal.recurring.list` и `userfieldtype.list`.
|
|
21
|
+
Список сверен с документацией Bitrix24. `.res()` у этих методов не
|
|
22
|
+
изменился. Если `result` метода — объект со списком под ключом, как у
|
|
23
|
+
`catalog.product.list` (`{ products: [...] }`), `.resAll()` отдаёт такой же
|
|
24
|
+
объект, где под ключом собраны записи всех страниц. Подробнее — в разделе
|
|
25
|
+
README «Режимы результата».
|
|
26
|
+
- `Navvy.pagNavKeyed()` и класс `NavvyPagNavKeyed` — пагинация для своих
|
|
27
|
+
методов, у которых `result` — объект со списком под ключом.
|
|
28
|
+
- `pull.application.event.add()` — событие в канал приложения, и
|
|
29
|
+
`pull.application.push.add()` — push-уведомление в мобильное приложение.
|
|
30
|
+
Типы параметров: `iBXRestParamPullApplicationEventAdd`,
|
|
31
|
+
`iBXRestParamPullApplicationPushAdd`.
|
|
32
|
+
- `pull.application.config.get()` и `pull.config.get()` принимают
|
|
33
|
+
необязательные параметры `CACHE` и `REOPEN` (тип `iBXRestParamPullConfigGet`).
|
|
34
|
+
В типах ответа появились поля `exp`, `clientId` и `jwt`. Подробнее — в
|
|
35
|
+
разделе README «Push & Pull».
|
|
36
|
+
- Настройка `logRequests` — журнал запросов: функция получает запись о каждом
|
|
37
|
+
HTTP-запросе (метод, адрес, длительность, статус, код ошибки Bitrix). Тип
|
|
38
|
+
записи `BXRestRequestLogEntry`. Адрес в записи не маскируется. Подробнее — в
|
|
39
|
+
разделе README «Журнал запросов».
|
|
40
|
+
- Настройка `transport: 'fetch'` — отправка запросов через глобальный `fetch`
|
|
41
|
+
вместо axios. Ответ не 2xx приходит ошибкой `BXRestHttpError` с полем
|
|
42
|
+
`response: { status, data }`. Подробнее — в разделе README «Транспорт fetch».
|
|
43
|
+
- `new Navvy(settings)` и `new BXRestRequest(settings)` — свои настройки, как у
|
|
44
|
+
`new BXRestNavvy(settings)`. Без аргумента оба работают с глобальными
|
|
45
|
+
`BXRestSettings`, как раньше.
|
|
46
|
+
|
|
47
|
+
### Changed
|
|
48
|
+
|
|
49
|
+
- Тип результата `.res()` у `crm.item.productrow.list`, `crm.orderentity.list`
|
|
50
|
+
и `crm.stagehistory.list` исправлен на объект: `{ productRows }`,
|
|
51
|
+
`{ orderEntity }` и `{ items }`. Раньше тип обещал массив, хотя портал
|
|
52
|
+
отдаёт объект, и само значение не изменилось. Код, который работал с
|
|
53
|
+
результатом как с массивом, перестанет компилироваться: во время выполнения
|
|
54
|
+
он и раньше не работал.
|
|
55
|
+
- Тип результата `userfieldtype.list().res()` исправлен на массив: портал
|
|
56
|
+
отдаёт массив.
|
|
57
|
+
- Типы параметров `crm.timeline.bindings.list` и `crm.requisite.link.list`
|
|
58
|
+
принимают `start`.
|
|
59
|
+
- В сырых типах ответа `iBXRestPullConfigGetHttp` и
|
|
60
|
+
`iBXRestPullApplicationConfigGetHttp` поле `publicChannels` может быть
|
|
61
|
+
`false`: так портал отвечает при версии сервера Push & Pull ниже 4. После
|
|
62
|
+
маппера `.res()` такое значение становится пустым объектом.
|
|
63
|
+
|
|
64
|
+
### Fixed
|
|
65
|
+
|
|
66
|
+
- `task.elapsedItem.operation.getListByIDTask()` загружает все записи каждой
|
|
67
|
+
задачи. Раньше метод запрашивал одну страницу с `nPageSize: 99999`, а по
|
|
68
|
+
документации портал отдаёт не больше 50 записей на страницу, поэтому у
|
|
69
|
+
задачи с большим числом записей часть могла пропасть без ошибки. Теперь
|
|
70
|
+
первые страницы всех задач уходят одним batch, как раньше, а остальные
|
|
71
|
+
страницы догружаются только для задач, где записей больше 50.
|
|
72
|
+
- Публичное поле `pull.channel.public.url.get` указывало на `log.blogpost.add`.
|
|
73
|
+
Теперь там `pull.channel.public.get`, сам запрос и раньше шёл на этот метод.
|
|
74
|
+
- Мапперы `pull.application.config.get()` и `pull.config.get()` больше не
|
|
75
|
+
падают с `TypeError`, если в ответе нет `publicChannels` или одного из
|
|
76
|
+
каналов, и с `Wrong date format`, если в ответе `pull.config.get` нет
|
|
77
|
+
`serverTime`.
|
|
78
|
+
|
|
79
|
+
## [1.6.0] - 2026-11-10
|
|
80
|
+
|
|
81
|
+
### Added
|
|
82
|
+
|
|
83
|
+
- Клиент со своими настройками: `new BXRestNavvy(settings)`. Все запросы
|
|
84
|
+
такого клиента идут на его портал с его токеном, продление авторизации у
|
|
85
|
+
него своё, а `BXRestSettings` на него не влияют. Так в одном процессе можно
|
|
86
|
+
работать с несколькими порталами. `new BXRestNavvy()` без аргумента
|
|
87
|
+
работает с глобальными `BXRestSettings`, как раньше. Подробнее — в разделе
|
|
88
|
+
README «Несколько порталов».
|
|
89
|
+
- Настройки `retryOnQueryLimit`, `timeout` и `throttle` — в `BXRestSettings`
|
|
90
|
+
или у клиента `new BXRestNavvy(settings)`. `retryOnQueryLimit` повторяет
|
|
91
|
+
запрос при `QUERY_LIMIT_EXCEEDED` с растущей паузой, `timeout` отменяет
|
|
92
|
+
запрос, который идёт дольше заданного времени, с ошибкой
|
|
93
|
+
`BXRestTimeoutError`, `throttle` пропускает не больше N запросов в секунду.
|
|
94
|
+
`true` включает значения по умолчанию: 3 попытки с паузой от 1000 мс,
|
|
95
|
+
60 000 мс и 2 запроса в секунду. Пока настройки не заданы, запросы идут как
|
|
96
|
+
раньше. Подробнее — в разделе README «Повтор, таймаут и очередь запросов».
|
|
97
|
+
- Настройка `middleware` — свои функции, через которые проходит каждый
|
|
98
|
+
запрос: логирование, подмена заголовков, свой транспорт вместо axios. Типы
|
|
99
|
+
`BXRestMiddleware`, `BXRestRequestConfig` и `BXRestSend` экспортируются из
|
|
100
|
+
`bx-rest`. Подробнее — в разделе README «Свои middleware».
|
|
101
|
+
|
|
102
|
+
### Changed
|
|
103
|
+
|
|
104
|
+
- Отписка до ответа теперь отменяет HTTP-запрос, как у `HttpClient` в
|
|
105
|
+
Angular. Раньше запрос доходил до конца, а ответ отбрасывался. На
|
|
106
|
+
`firstValueFrom` и обычную подписку это не влияет: они отписываются после
|
|
107
|
+
ответа. Отменяются запросы, которые обрывают `switchMap`, `takeUntil`,
|
|
108
|
+
`timeout` из RxJS или явный `unsubscribe()`. Отмена не откатывает то, что
|
|
109
|
+
портал уже успел сделать.
|
|
110
|
+
- Один экземпляр axios на клиента: он создаётся только при первом запросе.
|
|
111
|
+
Создание объекта запроса стало примерно в 100 раз быстрее (10,7 → 0,15 мкс),
|
|
112
|
+
при `new BXRestNavvy()` — вдвое.
|
|
113
|
+
- Ошибки HTTP библиотека узнаёт по полю `response: { status, data }`, а не
|
|
114
|
+
через `axios.isAxiosError`. Для ошибок axios ничего не меняется, а
|
|
115
|
+
`isBXRestAuthError` и `BXRestApiError` теперь работают и с ошибками своего
|
|
116
|
+
транспорта такой же формы.
|
|
117
|
+
- `bizProc.startProcFormNewsFeed()`: если портал вернул ошибку Bitrix при
|
|
118
|
+
создании элемента списка в ответе 2xx, вызов завершается ошибкой
|
|
119
|
+
`BXRestApiError` с кодом и описанием ошибки. Раньше в этом случае приходила
|
|
120
|
+
общая ошибка `Не удалось запустить бизнес процесс`. Ошибки со статусом не 2xx
|
|
121
|
+
и раньше приходили как `BXRestApiError`.
|
|
122
|
+
- Ошибки, которые библиотека создаёт сама, теперь на английском, как и
|
|
123
|
+
остальные её сообщения (`SessionKeyError`, `BXRestTimeoutError`, ошибки
|
|
124
|
+
разбора значений). Это ошибки `bizProc.startProcFormNewsFeed()`,
|
|
125
|
+
`disk.operation.*` и `task.elapsedItem.operation.*`. Код, который
|
|
126
|
+
сравнивает `err.message` с русским текстом, нужно обновить. Ошибки Bitrix
|
|
127
|
+
(`BXRestApiError`) приходят с текстом портала, как и раньше.
|
|
128
|
+
|
|
129
|
+
### Removed
|
|
130
|
+
|
|
131
|
+
- У `BXRestRequest` удалены публичные члены, которые библиотека не
|
|
132
|
+
использовала: `defSettings`, `getHttpParamsPost()`, `sliceArrayIntoChunks()`
|
|
133
|
+
и `removingMultipleSlashes()`. Они достались от внутреннего базового класса
|
|
134
|
+
и запросы не отправляли. `post()`, `get()`, `httpPost()` и `httpGet()` не
|
|
135
|
+
изменились. Код, который обращался к удалённым членам, перестанет
|
|
136
|
+
компилироваться.
|
|
137
|
+
- Из `bx-rest/services/navvy` удалён абстрактный класс `NavvySupport`:
|
|
138
|
+
библиотека его не использовала. Тип `ReturnTypeNavvy` остался.
|
|
139
|
+
- Из `bx-rest` удалён класс `HttpNavvyServices` вместе с его типами
|
|
140
|
+
`iBXRestParams` и `iBXRestAnswers`. Он отправлял запросы с типами для
|
|
141
|
+
небольшого набора методов, сама библиотека его не использовала, а в README
|
|
142
|
+
он не описан. Вместо него используйте `BXRestNavvy` или
|
|
143
|
+
`BXRestRequest.post()`.
|
|
144
|
+
- Из исходников удалены 63 модуля, недостижимых из точек входа пакета (старый
|
|
145
|
+
слой `request/*`, `rest/base`, `functions/errorHandler`, `isDate`, `isEqual`,
|
|
146
|
+
`isValidDate`, `serializeJavascript`, `services/permission` и другие), и
|
|
147
|
+
закомментированный код. Файлы 52 из них (`.d.ts` и `esm2022/*.mjs`) лежали в
|
|
148
|
+
пакете, но ни основной бандл, ни `exports` их не подключали, поэтому через
|
|
149
|
+
`import` из `bx-rest` и его подпутей они были недоступны. Из пакета удалено
|
|
150
|
+
104 файла. Затронуть это может только код, который импортировал типы по
|
|
151
|
+
внутреннему пути вроде `bx-rest/request/...` при `moduleResolution: "node"`.
|
|
152
|
+
|
|
153
|
+
### Fixed
|
|
154
|
+
|
|
155
|
+
- Проверка типов под `moduleResolution: "nodenext"` или `"node16"` с
|
|
156
|
+
`skipLibCheck: false` больше не падает с ошибкой TS1479 в
|
|
157
|
+
`typification/rest/calendar/event/get.d.ts`. Типы `countries-and-timezones`
|
|
158
|
+
теперь подключаются через `resolution-mode: 'import'`: ветка `require` этого
|
|
159
|
+
пакета указывает на несуществующий файл типов. Сами типы не изменились, код
|
|
160
|
+
пакета тоже. В режиме `bundler` (Angular, Vite, webpack) ошибки не было.
|
|
161
|
+
- `bizProc.startProcFormNewsFeed()` создаёт `ELEMENT_CODE` из префикса
|
|
162
|
+
`bx_rest_` и 128 случайных бит (`crypto.getRandomValues`). Раньше код
|
|
163
|
+
собирался из префикса другого приложения `trace_studio_`, времени и
|
|
164
|
+
`Math.random()`. Если портал отвечает, что такой код уже занят
|
|
165
|
+
(`ERROR_ELEMENT_ALREADY_EXISTS`), вызов создаёт новый код и повторяет
|
|
166
|
+
запрос, всего до трёх попыток.
|
|
167
|
+
- `disk.operation.getOfCreateRootFolderApp()` и
|
|
168
|
+
`getOfCreateRootContentFolderApp()`: если не удалось получить хранилище
|
|
169
|
+
приложения, ошибка теперь так и называется — `Could not get the app
|
|
170
|
+
storage`. Раньше в ней был чужой текст про учёт времени: `Отсутствуют права
|
|
171
|
+
добавление записи затраченного времени`.
|
|
172
|
+
|
|
10
173
|
## [1.5.1] - 2026-11-05
|
|
11
174
|
|
|
12
175
|
### Added
|
package/README.en.md
CHANGED
|
@@ -24,6 +24,11 @@ Also known as: Bitrix24 REST client, BX24 REST SDK, Bitrix24 API client, Bitrix
|
|
|
24
24
|
- [A token from the portal without BX24.js](#a-token-from-the-portal-without-bx24js)
|
|
25
25
|
- [Recipe: straight to the portal](#recipe-straight-to-the-portal)
|
|
26
26
|
- [Recipe: through a backend proxy](#recipe-through-a-backend-proxy)
|
|
27
|
+
- [Several portals](#several-portals)
|
|
28
|
+
- [Retry, timeout and request queue](#retry-timeout-and-request-queue)
|
|
29
|
+
- [Request log](#request-log)
|
|
30
|
+
- [The fetch transport](#the-fetch-transport)
|
|
31
|
+
- [Your own middleware](#your-own-middleware)
|
|
27
32
|
- [Working in an iframe without BX24.js](#working-in-an-iframe-without-bx24js)
|
|
28
33
|
- [Usage in Angular](#usage-in-angular)
|
|
29
34
|
- [SessionKeyServices](#sessionkeyservices)
|
|
@@ -36,6 +41,7 @@ Also known as: Bitrix24 REST client, BX24 REST SDK, Bitrix24 API client, Bitrix
|
|
|
36
41
|
- [A paginated custom method with `pagNav()`](#a-paginated-custom-method-with-pagnav)
|
|
37
42
|
- [Specific methods](#specific-methods)
|
|
38
43
|
- [`tasks.task.list`](#taskstasklist)
|
|
44
|
+
- [Push & Pull](#push--pull)
|
|
39
45
|
- [Date parsing](#date-parsing)
|
|
40
46
|
- [Future features](#future-features)
|
|
41
47
|
- [License](#license)
|
|
@@ -93,12 +99,12 @@ Do not hardcode or commit a production access token. Pass it from your applicati
|
|
|
93
99
|
|
|
94
100
|
### Result modes
|
|
95
101
|
|
|
96
|
-
REST calls are lazy: the request starts when the returned `Observable` is subscribed to or passed to `firstValueFrom`.
|
|
102
|
+
REST calls are lazy: the request starts when the returned `Observable` is subscribed to or passed to `firstValueFrom`. Unsubscribing before the response aborts the HTTP request — this is what `switchMap`, `takeUntil` and the RxJS `timeout` operator rely on. Aborting does not undo what the portal has already done: if `crm.deal.add` reached the server, the deal may be created.
|
|
97
103
|
|
|
98
104
|
| Method | Result |
|
|
99
105
|
| --- | --- |
|
|
100
106
|
| `.res(options?)` | Unwraps the Bitrix response and applies the configured mapper. For paginated methods it returns the current page. |
|
|
101
|
-
| `.resAll()` | Loads and combines every page. Available on
|
|
107
|
+
| `.resAll()` | Loads and combines every page. Available on paged list methods, see below. |
|
|
102
108
|
| `.resVanilla()` | Returns the raw Bitrix response, including fields such as `result`, `total` and `next`. |
|
|
103
109
|
| `.mapForVanilla()` | Keeps the raw response envelope but applies the mapper to its `result`. |
|
|
104
110
|
|
|
@@ -108,6 +114,13 @@ REST calls are lazy: the request starts when the returned `Observable` is subscr
|
|
|
108
114
|
| --- | --- | --- |
|
|
109
115
|
| `throwOnApiError` | `false` | When `true`, a Bitrix-level API error makes the returned `Observable` error out with a `BXRestApiError` instead of resolving with `undefined`. See [Error handling](#error-handling). |
|
|
110
116
|
|
|
117
|
+
`.resAll()` exists on list methods that page through `start`. It requests the first page itself and the rest in packs through `batch`. The result has the same shape as `.res()`:
|
|
118
|
+
|
|
119
|
+
- if the method returns an array (`crm.deal.list`, `crm.activity.list`), `.resAll()` returns an array of all records;
|
|
120
|
+
- if `result` is an object with the list under a key, as with `catalog.product.list` (`{ products: [...] }`) or `sale.order.list` (`{ orders: [...] }`), `.resAll()` returns the same object with the records of all pages under that key.
|
|
121
|
+
|
|
122
|
+
Methods that return the whole list in one response or page in another way (`OFFSET`/`LIMIT`, a page number, the REST v3 `pagination` object) have no `.resAll()`. They are listed with reasons in [list-pagination.spec.ts](https://github.com/Aricatofuka/bx-rest/blob/main/projects/bx-rest/src/rest/list-pagination.spec.ts).
|
|
123
|
+
|
|
111
124
|
## Authentication and OAuth2
|
|
112
125
|
|
|
113
126
|
`auth.source` controls where credentials are read from. `auth.key` controls the request parameter name, except for the special `OAuth2` cookie-credentials mode.
|
|
@@ -196,7 +209,9 @@ For cross-origin requests, the server — the portal or your proxy — must allo
|
|
|
196
209
|
| --- | --- |
|
|
197
210
|
| Bitrix API error with a non-2xx HTTP status — this is how Bitrix sends most errors: `expired_token` (401), `ERROR_METHOD_NOT_FOUND` (404), `QUERY_LIMIT_EXCEEDED` (503), `Not found` from `crm.*.get` (400) | The returned `Observable` errors with a `BXRestApiError`, with or without `throwOnApiError`. |
|
|
198
211
|
| Bitrix API error in the body of a 2xx response | By default, `.res()` resolves normally with `undefined` — **it does not throw**. Pass `{ throwOnApiError: true }` to make it throw a `BXRestApiError` instead. |
|
|
199
|
-
| Transport / configuration errors — network failure, missing auth,
|
|
212
|
+
| Transport / configuration errors — network failure, [`timeout`](#retry-timeout-and-request-queue) exceeded, missing auth, an empty base address (see below), a response that is not from Bitrix (e.g. a proxy's HTML error page) | The returned `Observable` errors with a plain `Error`. The original error is in its `cause`: for a response that is not from Bitrix it is the axios error, with the HTTP status in `cause.response.status`; for `timeout` it is `BXRestTimeoutError`. |
|
|
213
|
+
|
|
214
|
+
**Base address.** The request address is built from two parts: the portal address and `urls.additional_part`. The portal address is `urls.key`, or, with `urls.source: 'localStorage'`, the value stored in `localStorage` under the `urls.key` key. The `Base URL was not resolved` error happens only when both parts are empty. If only the portal address is empty and `additional_part` is `'rest'` (as in the default settings), the request goes to `rest/<method>` relative to the current page. This is meant for pages opened on the portal's own domain. But a request also goes there when nothing was found in `localStorage` under the key, so check the value beforehand.
|
|
200
215
|
|
|
201
216
|
`BXRestApiError` fields:
|
|
202
217
|
|
|
@@ -210,6 +225,8 @@ For cross-origin requests, the server — the portal or your proxy — must allo
|
|
|
210
225
|
|
|
211
226
|
For REST v3 methods, `error` holds the error `code` and `error_description` its `message`.
|
|
212
227
|
|
|
228
|
+
**The token in errors.** An axios error keeps the whole request that was sent: `config.url` holds the address, and with it the webhook secret, and `config.data` holds the body with the token. The library passes this error on as is — in `err.cause` for `.res()` and as the error itself for `.resVanilla()`. So `console.error(err)` or sending the error to an error tracker passes the token along too. If errors go to logs, pick the fields you need, for example `err.status`, `err.error` and `err.cause?.response?.data`.
|
|
229
|
+
|
|
213
230
|
**Recommended — `.res({ throwOnApiError: true })`.** Every Bitrix error then arrives as a `BXRestApiError` whatever the HTTP status, and can be handled alongside transport errors in a single `catchError`/`error` callback:
|
|
214
231
|
|
|
215
232
|
```typescript
|
|
@@ -404,6 +421,140 @@ BXRestSettings.update({
|
|
|
404
421
|
|
|
405
422
|
Errors of the refresh function end up in `authRefreshError` of the original error, and your app may print that error to the console or send it to an error tracker — so keep tokens out of the error messages of the refresh function.
|
|
406
423
|
|
|
424
|
+
## Several portals
|
|
425
|
+
|
|
426
|
+
`BXRestSettings` are shared by the whole app. To work with several portals in one process, for example on a server that serves different customers, pass the settings to the `BXRestNavvy` constructor. Such a client has its own settings: all its requests go to its portal with its token, and `BXRestSettings` do not affect it.
|
|
427
|
+
|
|
428
|
+
```typescript
|
|
429
|
+
import { BXRestNavvy } from 'bx-rest'
|
|
430
|
+
import { firstValueFrom } from 'rxjs'
|
|
431
|
+
|
|
432
|
+
const portalA = new BXRestNavvy({
|
|
433
|
+
auth: { source: () => tokenA, key: 'auth' },
|
|
434
|
+
urls: { source: 'string', key: 'https://a.bitrix24.com', additional_part: 'rest' }
|
|
435
|
+
})
|
|
436
|
+
const portalB = new BXRestNavvy({
|
|
437
|
+
auth: { source: () => tokenB, key: 'auth' },
|
|
438
|
+
urls: { source: 'string', key: 'https://b.bitrix24.com', additional_part: 'rest' }
|
|
439
|
+
})
|
|
440
|
+
|
|
441
|
+
const deals = await firstValueFrom(
|
|
442
|
+
portalA.crm.deal.list({ select: ['ID'], filter: {}, start: 0 }).resAll()
|
|
443
|
+
)
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
- **Without an argument** `new BXRestNavvy()` uses the global `BXRestSettings`, as before.
|
|
447
|
+
- **The format** is the same as for `BXRestSettings.update()`, but the settings are passed in full: `auth` and `urls` are required and are not merged with the global settings.
|
|
448
|
+
- **Changing the token of an existing client.** The library calls `auth.source` before every request, at subscribe time. To change the token, change the value the function returns. Requests created earlier but not started yet get the new token too:
|
|
449
|
+
|
|
450
|
+
```typescript
|
|
451
|
+
let token = await getToken()
|
|
452
|
+
const portal = new BXRestNavvy({
|
|
453
|
+
auth: {
|
|
454
|
+
source: () => token,
|
|
455
|
+
key: 'auth',
|
|
456
|
+
refresh: async () => { token = await getNewToken() } // optional
|
|
457
|
+
},
|
|
458
|
+
urls: { source: 'string', key: 'https://a.bitrix24.com', additional_part: 'rest' }
|
|
459
|
+
})
|
|
460
|
+
|
|
461
|
+
token = newToken // the next request goes out with the new token
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
- **Another portal or other headers** — create a new client, it takes a fraction of a millisecond.
|
|
465
|
+
- **Authorization refresh** is per client: a client's `auth.refresh` is called only for its own requests.
|
|
466
|
+
- **`auth.source: 'cookies'` and `'localStorage'`** read the shared browser storage, so two clients with the same key get the same token. For several portals, set `source` to a function.
|
|
467
|
+
- **Objects created directly** — `new Navvy()` and `new BXRestRequest()` — use the global `BXRestSettings` when called without an argument. They also accept their own settings: `new Navvy(settings)`, `new BXRestRequest(settings)`. Such an object has its own `throttle` queue and authorization refresh, even if a `BXRestNavvy` client has the same settings. `new SessionKeyServices()` always uses the global settings.
|
|
468
|
+
|
|
469
|
+
## Retry, timeout and request queue
|
|
470
|
+
|
|
471
|
+
Three optional settings protect against the Bitrix24 request rate limit and against hanging requests. Set them in `BXRestSettings.update()` for the whole app or in the settings of a `new BXRestNavvy(settings)` client. `true` turns on the defaults, a number or an object sets your own values. While a setting is not set, requests go as before.
|
|
472
|
+
|
|
473
|
+
```typescript
|
|
474
|
+
BXRestSettings.update({
|
|
475
|
+
retryOnQueryLimit: true, // 3 attempts, pause from 1000 ms
|
|
476
|
+
timeout: 30_000, // ms
|
|
477
|
+
throttle: { perSecond: 2 },
|
|
478
|
+
})
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
| Setting | `true` means | What it does |
|
|
482
|
+
| --- | --- | --- |
|
|
483
|
+
| `retryOnQueryLimit` | `{ attempts: 3, delay: 1000 }` | Retries the request when the portal answers `QUERY_LIMIT_EXCEEDED` (HTTP 503, request rate limit exceeded). `attempts` is the total number of attempts including the first one, `delay` is the pause before the second attempt in ms, then it doubles: 1000, 2000, 4000... Other errors are not retried. When the attempts run out, the error of the last one goes out; in `.res()` it is a `BXRestApiError` with `error: 'QUERY_LIMIT_EXCEEDED'`. |
|
|
484
|
+
| `timeout` | `60000` | Time limit for one HTTP request in ms. A request that takes longer is aborted with `BXRestTimeoutError` (its `timeout` field is the limit). In `.res()` it is in `cause`; `.resVanilla()`, `.mapForVanilla()` and `.resAll()` error with it directly. |
|
|
485
|
+
| `throttle` | `{ perSecond: 2 }` | At most `perSecond` requests per second, the rest wait in a queue. 2 requests per second is the Bitrix24 limit on regular plans. |
|
|
486
|
+
|
|
487
|
+
An object may set only some fields: `retryOnQueryLimit: { attempts: 5 }` keeps `delay: 1000`.
|
|
488
|
+
|
|
489
|
+
- **Order:** retry, queue, timeout, [log](#request-log), [your own middleware](#your-own-middleware), [transport](#the-fetch-transport). Every retry attempt queues again and gets its own `timeout`. Waiting in the queue and pauses before a retry do not count towards `timeout`.
|
|
490
|
+
- **The queue** belongs to each `new BXRestNavvy(settings)` client and is shared by everything that uses the global `BXRestSettings`. Every request goes through it, including every batch request of `.resAll()`.
|
|
491
|
+
- **`throttle` is stricter than the portal.** Bitrix24 lets short bursts above the limit through, while `throttle` spreads all requests evenly. If short bursts of requests need to be fast, `retryOnQueryLimit` alone is enough.
|
|
492
|
+
- **Unsubscribing** stops both the wait in the queue and the pause before a retry: such a request is never sent.
|
|
493
|
+
- **Settings are read at subscribe time**, like the rest.
|
|
494
|
+
- **An invalid value** — for example `throttle: { perSecond: 0 }` or a negative `timeout` — fails the request with a `TypeError` that describes it; nothing is sent to the portal.
|
|
495
|
+
|
|
496
|
+
### Request log
|
|
497
|
+
|
|
498
|
+
`logRequests` is a function that receives an entry for every HTTP request once it finishes. It is set the same way, globally or per client:
|
|
499
|
+
|
|
500
|
+
```typescript
|
|
501
|
+
BXRestSettings.update({
|
|
502
|
+
logRequests: entry => console.debug(entry.method, entry.url, `${entry.duration} ms`, entry.failed ? entry.error : 'ok'),
|
|
503
|
+
})
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
| Field | What it holds |
|
|
507
|
+
| --- | --- |
|
|
508
|
+
| `method` | `'GET'` or `'POST'`. |
|
|
509
|
+
| `url` | The full request address. |
|
|
510
|
+
| `duration` | Time from sending to the response or error, ms. |
|
|
511
|
+
| `failed` | `true` if the request failed: a non-2xx response, a network failure, a timeout or a cancel. |
|
|
512
|
+
| `status` | The HTTP status of a failed response. The transport does not report the status of a successful one. |
|
|
513
|
+
| `error` | The Bitrix error code from the response body, such as `QUERY_LIMIT_EXCEEDED`, including one from a 2xx response. If the portal sent no code, the error message. |
|
|
514
|
+
|
|
515
|
+
- **One entry per HTTP request:** every `retryOnQueryLimit` attempt and every batch request of `.resAll()` is its own entry. Waiting in the `throttle` queue does not count towards `duration`.
|
|
516
|
+
- **The address is as is.** The request body is not in the entry, but a webhook keeps its secret in the address, and a GET request keeps the token there. If the log goes to a third-party system, remove them yourself.
|
|
517
|
+
- **An exception from the function** does not affect the request.
|
|
518
|
+
|
|
519
|
+
### The fetch transport
|
|
520
|
+
|
|
521
|
+
By default axios sends the requests. With `transport: 'fetch'` the global `fetch` of the browser or Node 18+ sends them:
|
|
522
|
+
|
|
523
|
+
```typescript
|
|
524
|
+
const portal = new BXRestNavvy({ ...settings, transport: 'fetch' })
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
The result is the same as with axios; only transport errors differ:
|
|
528
|
+
|
|
529
|
+
- on a non-2xx response `.resVanilla()` fails with a `BXRestHttpError` that has `response: { status, data }`, like `AxiosError`; in `.res()` it is in the `cause` of `BXRestApiError`;
|
|
530
|
+
- a network failure comes as the error of `fetch` itself (usually a `TypeError`), without the `request` field axios has.
|
|
531
|
+
|
|
532
|
+
### Your own middleware
|
|
533
|
+
|
|
534
|
+
A middleware is a function every request passes through before it is sent: logging, metrics, changing headers, your own transport instead of axios. Set it in `middleware`, globally or per client in the same way:
|
|
535
|
+
|
|
536
|
+
```typescript
|
|
537
|
+
import { BXRestMiddleware, BXRestSettings } from 'bx-rest'
|
|
538
|
+
|
|
539
|
+
const logDuration: BXRestMiddleware = async (config, next) => {
|
|
540
|
+
const started = Date.now()
|
|
541
|
+
try {
|
|
542
|
+
return await next(config)
|
|
543
|
+
} finally {
|
|
544
|
+
console.debug(config.method, Date.now() - started, 'ms')
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
BXRestSettings.update({ middleware: [logDuration] })
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
- **`config`** is the request: `method` (`'GET'` or `'POST'`), `url` (with the parameters for GET), `data` (the POST body), `headers`, `withCredentials`, `signal`. `next(config)` sends it on and returns the response body.
|
|
552
|
+
- **Order:** the first in the list is the outermost one: it sees the request first and the response last. All your middleware run after `retryOnQueryLimit`, `throttle`, `timeout` and `logRequests`, so they see every retry attempt. The retry after `auth.refresh` wraps all the steps: on an authorization refresh the request passes through them again.
|
|
553
|
+
- **To change the request**, pass a new object on: `next({ ...config, headers: { ...config.headers, 'X-Trace': id } })`.
|
|
554
|
+
- **Your own transport** is a middleware that does not call `next`: it sends the request itself and returns the response body. For a non-2xx response it must reject with an error that has a `response: { status, data }` field, as axios does. The library uses that field to recognize Bitrix errors (`BXRestApiError`) and authorization errors (`auth.refresh`).
|
|
555
|
+
- **Pass `config.signal`** to your transport: it aborts the request on unsubscribe and on `timeout`.
|
|
556
|
+
- **`config.url` and `config.data`** contain the token and the webhook secret — do not log them as they are.
|
|
557
|
+
|
|
407
558
|
## Working in an iframe without BX24.js
|
|
408
559
|
|
|
409
560
|
`BXRestFrame` is the commands an application in an iframe sends to the portal: the frame size, the selection dialogs, sliders, the messenger, placements, options, installation. The same commands and the same names as in BX24.js, but with promises instead of callbacks, and with no need to load BX24.js. bx-rest itself makes the REST requests, and `getAuth()`/`refreshAuth()` give the token for them (see [Authorization refresh](#authorization-refresh)).
|
|
@@ -665,6 +816,12 @@ npm run demo:bootstrap
|
|
|
665
816
|
Then, in any of `projects/demo-angular|demo-vue|demo-react`: `npm run dev`
|
|
666
817
|
(for Angular, `npm start`). See each demo's own README for details.
|
|
667
818
|
|
|
819
|
+
`projects/demo-node` is a Node.js demo without a UI. It shows two portals in
|
|
820
|
+
one process, `retryOnQueryLimit`, `throttle`, `timeout`, your own `middleware`
|
|
821
|
+
for logging and handling `BXRestApiError`. `npm run mock` runs it against a
|
|
822
|
+
built-in mock portal, `npm start` against a real portal using the incoming
|
|
823
|
+
webhook address from `BX_WEBHOOK_A`. On a portal the demo only reads data.
|
|
824
|
+
|
|
668
825
|
## Custom REST methods
|
|
669
826
|
|
|
670
827
|
`Navvy` is exported from `bx-rest`. In Angular, register the `NavvyProvider` shown above and inject `Navvy` into your custom API service. A method URL is represented as an array and is joined with dots before the request is sent.
|
|
@@ -777,6 +934,18 @@ export class BXRestNavvyCustomApiBlogList {
|
|
|
777
934
|
|
|
778
935
|
The returned helper additionally supports `.resAll()` for loading and combining all pages.
|
|
779
936
|
|
|
937
|
+
If the method's `result` is an object with the list under a key, such as `{ items: [...] }`, use `pagNavKeyed()`: its third argument is the list key. `.res()` returns the object as is, `.resAll()` the same object with the records of all pages under the key:
|
|
938
|
+
|
|
939
|
+
```typescript
|
|
940
|
+
type BlogItems = { items?: iBXRestCustomBlogGetHttp[] }
|
|
941
|
+
|
|
942
|
+
this.navvy.pagNavKeyed<BlogItems, BlogItems, iBXRestCustomParamBlogList>(
|
|
943
|
+
['blog', 'item', PNM.$list],
|
|
944
|
+
param,
|
|
945
|
+
'items'
|
|
946
|
+
)
|
|
947
|
+
```
|
|
948
|
+
|
|
780
949
|
## Specific methods
|
|
781
950
|
|
|
782
951
|
### `tasks.task.list`
|
|
@@ -828,6 +997,40 @@ const tasks$ = bxRest.tasks.task.list<
|
|
|
828
997
|
}).res()
|
|
829
998
|
```
|
|
830
999
|
|
|
1000
|
+
### Push & Pull
|
|
1001
|
+
|
|
1002
|
+
The `pull` section returns the settings for connecting to the Push & Pull server and sends application events. The library has no websocket client: connect with your own client following the [protocol description](https://apidocs.bitrix24.com/settings/interactivity/custom-push-and-pull-client.html) or with `PullClient` from [b24jssdk](https://github.com/bitrix24/b24jssdk).
|
|
1003
|
+
|
|
1004
|
+
```typescript
|
|
1005
|
+
import { firstValueFrom } from 'rxjs'
|
|
1006
|
+
import { BXRestNavvy } from 'bx-rest'
|
|
1007
|
+
|
|
1008
|
+
const bxRest = new BXRestNavvy()
|
|
1009
|
+
|
|
1010
|
+
// Server addresses and channels for the client to connect
|
|
1011
|
+
const config = await firstValueFrom(bxRest.pull.application.config.get().res())
|
|
1012
|
+
console.log(config?.server.websocket_secure, config?.channels.private.id, config?.exp)
|
|
1013
|
+
|
|
1014
|
+
// An event in the shared channel of the application: every subscribed client gets it
|
|
1015
|
+
await firstValueFrom(bxRest.pull.application.event.add({
|
|
1016
|
+
COMMAND: 'grid:update',
|
|
1017
|
+
PARAMS: { grid_id: 15 },
|
|
1018
|
+
}).res())
|
|
1019
|
+
```
|
|
1020
|
+
|
|
1021
|
+
| Method | What it does |
|
|
1022
|
+
| --- | --- |
|
|
1023
|
+
| `pull.application.config.get(param?)` | Connection settings for the application: server addresses, the `shared` and `private` channels, public channels, `exp`, and with the right server version `clientId` or `jwt`. Channel dates are `Date`. |
|
|
1024
|
+
| `pull.application.event.add(param)` | An event in the application channel: without `USER_ID` in the shared `shared` channel, with it in the users' personal channels. |
|
|
1025
|
+
| `pull.application.push.add(param)` | A push notification to the Bitrix24 mobile app. For portal administrators only. |
|
|
1026
|
+
| `pull.config.get(param?)` | Connection settings for a user. The method is not in the Bitrix24 documentation, so it is marked `@experimental`. |
|
|
1027
|
+
| `pull.channel.public.get()` | A public Push & Pull channel. |
|
|
1028
|
+
|
|
1029
|
+
- **`pull.application.*` methods** work only in an application context, with its OAuth token. Through a webhook the portal answers `WRONG_AUTH_TYPE`.
|
|
1030
|
+
- **`true` in the response** of `event.add` and `push.add` means "accepted for sending", not "delivered".
|
|
1031
|
+
- **`USER_ID` for a non-administrator.** They can send an event only to themselves, and `USER_ID` must then be a string: `'577'`. The portal rejects a number or an array with `USER_ID_ACCESS_ERROR`.
|
|
1032
|
+
- **The settings are personal:** the `private` channel belongs to the user whose token makes the request. Request them again when `exp` or the channels' `end` expires.
|
|
1033
|
+
|
|
831
1034
|
## Date parsing
|
|
832
1035
|
|
|
833
1036
|
Some Bitrix24 REST fields (notably `calendar.section.get`, `calendar.event.get` and `crm.calllist.*`) return dates as plain strings formatted according to the portal's own date/time settings (Settings → date and time format) — not a fixed ISO format. Because that format is a per-portal setting, `bx-rest` can't know it in advance, so `BXBaseServices.toDate()` (used internally by these mappers) resolves an ambiguous string in three steps, in order:
|