oneentry 1.0.160 → 1.0.162

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.
Files changed (238) hide show
  1. package/README.md +2 -0
  2. package/changelog.md +61 -0
  3. package/dist/admins/adminsApi.d.ts +15 -1
  4. package/dist/admins/adminsApi.js +29 -0
  5. package/dist/admins/adminsInterfaces.d.ts +39 -1
  6. package/dist/admins/adminsSchemas.d.ts +2 -0
  7. package/dist/admins/adminsSchemas.js +1 -0
  8. package/dist/attribute-sets/attributeSetsInterfaces.d.ts +2 -0
  9. package/dist/auth-provider/authProviderSchemas.d.ts +1 -0
  10. package/dist/base/lazySchema.d.ts +15 -0
  11. package/dist/base/lazySchema.js +20 -0
  12. package/dist/base/validation.d.ts +1 -0
  13. package/dist/base/validation.js +1 -0
  14. package/dist/blocks/blocksApi.d.ts +16 -8
  15. package/dist/blocks/blocksApi.js +24 -15
  16. package/dist/blocks/blocksInterfaces.d.ts +16 -8
  17. package/dist/discounts/discountsApi.d.ts +14 -1
  18. package/dist/discounts/discountsApi.js +21 -0
  19. package/dist/discounts/discountsInterfaces.d.ts +29 -1
  20. package/dist/filters/filtersInterfaces.d.ts +2 -2
  21. package/dist/filters/filtersSchemas.d.ts +1 -1
  22. package/dist/filters/filtersSchemas.js +4 -1
  23. package/dist/forms-data/formsDataApi.d.ts +14 -1
  24. package/dist/forms-data/formsDataApi.js +21 -0
  25. package/dist/forms-data/formsDataInterfaces.d.ts +78 -1
  26. package/dist/index.d.ts +4 -0
  27. package/dist/index.js +3 -0
  28. package/dist/menus/menusInterfaces.d.ts +4 -0
  29. package/dist/menus/menusSchemas.js +2 -0
  30. package/dist/orders/ordersApi.d.ts +15 -1
  31. package/dist/orders/ordersApi.js +22 -0
  32. package/dist/orders/ordersInterfaces.d.ts +29 -1
  33. package/dist/orders/ordersSchemas.d.ts +2 -0
  34. package/dist/orders/ordersSchemas.js +1 -0
  35. package/dist/pages/pagesApi.d.ts +14 -11
  36. package/dist/pages/pagesApi.js +21 -17
  37. package/dist/pages/pagesInterfaces.d.ts +37 -17
  38. package/dist/pages/pagesSchemas.d.ts +3 -7
  39. package/dist/pages/pagesSchemas.js +2 -8
  40. package/dist/payments/paymentsInterfaces.d.ts +2 -2
  41. package/dist/products/productsInterfaces.d.ts +1 -1
  42. package/dist/search/searchApi.d.ts +35 -0
  43. package/dist/search/searchApi.js +86 -0
  44. package/dist/search/searchInterfaces.d.ts +94 -0
  45. package/dist/search/searchInterfaces.js +2 -0
  46. package/dist/search/searchSchemas.d.ts +73 -0
  47. package/dist/search/searchSchemas.js +44 -0
  48. package/dist/templates-preview/templatesPreviewInterfaces.d.ts +0 -2
  49. package/dist/templates-preview/templatesPreviewSchemas.d.ts +0 -2
  50. package/dist/templates-preview/templatesPreviewSchemas.js +0 -1
  51. package/dist/types.d.ts +35 -0
  52. package/dist/types.js +2 -0
  53. package/dist/users/usersApi.d.ts +15 -1
  54. package/dist/users/usersApi.js +22 -0
  55. package/dist/users/usersInterfaces.d.ts +41 -1
  56. package/dist/users/usersSchemas.d.ts +1 -0
  57. package/dist/web-socket/lazySocket.d.ts +18 -0
  58. package/dist/web-socket/lazySocket.js +70 -0
  59. package/esm/admins/adminsApi.d.ts +66 -0
  60. package/esm/admins/adminsApi.js +90 -0
  61. package/esm/admins/adminsInterfaces.d.ts +139 -0
  62. package/esm/admins/adminsInterfaces.js +1 -0
  63. package/esm/admins/adminsSchemas.d.ts +50 -0
  64. package/esm/admins/adminsSchemas.js +32 -0
  65. package/esm/attribute-sets/attributeSetsApi.d.ts +67 -0
  66. package/esm/attribute-sets/attributeSetsApi.js +97 -0
  67. package/esm/attribute-sets/attributeSetsInterfaces.d.ts +287 -0
  68. package/esm/attribute-sets/attributeSetsInterfaces.js +1 -0
  69. package/esm/attribute-sets/attributeSetsSchemas.d.ts +84 -0
  70. package/esm/attribute-sets/attributeSetsSchemas.js +66 -0
  71. package/esm/auth-provider/authProviderApi.d.ts +262 -0
  72. package/esm/auth-provider/authProviderApi.js +362 -0
  73. package/esm/auth-provider/authProviderSchemas.d.ts +125 -0
  74. package/esm/auth-provider/authProviderSchemas.js +92 -0
  75. package/esm/auth-provider/authProvidersInterfaces.d.ts +430 -0
  76. package/esm/auth-provider/authProvidersInterfaces.js +1 -0
  77. package/esm/base/asyncModules.d.ts +123 -0
  78. package/esm/base/asyncModules.js +382 -0
  79. package/esm/base/lazySchema.d.ts +15 -0
  80. package/esm/base/lazySchema.js +17 -0
  81. package/esm/base/stateModule.d.ts +35 -0
  82. package/esm/base/stateModule.js +51 -0
  83. package/esm/base/syncModules.d.ts +245 -0
  84. package/esm/base/syncModules.js +555 -0
  85. package/esm/base/timeIntervals.d.ts +95 -0
  86. package/esm/base/timeIntervals.js +317 -0
  87. package/esm/base/utils.d.ts +354 -0
  88. package/esm/base/utils.js +1 -0
  89. package/esm/base/validation.d.ts +99 -0
  90. package/esm/base/validation.js +119 -0
  91. package/esm/blocks/blocksApi.d.ts +260 -0
  92. package/esm/blocks/blocksApi.js +403 -0
  93. package/esm/blocks/blocksInterfaces.d.ts +369 -0
  94. package/esm/blocks/blocksInterfaces.js +1 -0
  95. package/esm/blocks/blocksSchemas.d.ts +213 -0
  96. package/esm/blocks/blocksSchemas.js +40 -0
  97. package/esm/discounts/discountsApi.d.ts +94 -0
  98. package/esm/discounts/discountsApi.js +136 -0
  99. package/esm/discounts/discountsInterfaces.d.ts +295 -0
  100. package/esm/discounts/discountsInterfaces.js +1 -0
  101. package/esm/events/eventsApi.d.ts +108 -0
  102. package/esm/events/eventsApi.js +141 -0
  103. package/esm/events/eventsInterfaces.d.ts +176 -0
  104. package/esm/events/eventsInterfaces.js +1 -0
  105. package/esm/file-uploading/fileUploadingApi.d.ts +91 -0
  106. package/esm/file-uploading/fileUploadingApi.js +127 -0
  107. package/esm/file-uploading/fileUploadingInterfaces.d.ts +116 -0
  108. package/esm/file-uploading/fileUploadingInterfaces.js +1 -0
  109. package/esm/file-uploading/fileUploadingSchemas.d.ts +24 -0
  110. package/esm/file-uploading/fileUploadingSchemas.js +19 -0
  111. package/esm/filters/filtersApi.d.ts +32 -0
  112. package/esm/filters/filtersApi.js +36 -0
  113. package/esm/filters/filtersInterfaces.d.ts +56 -0
  114. package/esm/filters/filtersInterfaces.js +1 -0
  115. package/esm/filters/filtersSchemas.d.ts +32 -0
  116. package/esm/filters/filtersSchemas.js +29 -0
  117. package/esm/forms/formsApi.d.ts +44 -0
  118. package/esm/forms/formsApi.js +54 -0
  119. package/esm/forms/formsInterfaces.d.ts +237 -0
  120. package/esm/forms/formsInterfaces.js +1 -0
  121. package/esm/forms/formsSchemas.d.ts +56 -0
  122. package/esm/forms/formsSchemas.js +32 -0
  123. package/esm/forms-data/formsDataApi.d.ts +124 -0
  124. package/esm/forms-data/formsDataApi.js +210 -0
  125. package/esm/forms-data/formsDataInterfaces.d.ts +674 -0
  126. package/esm/forms-data/formsDataInterfaces.js +1 -0
  127. package/esm/forms-data/formsDataSchemas.d.ts +107 -0
  128. package/esm/forms-data/formsDataSchemas.js +83 -0
  129. package/esm/general-types/generalTypesApi.d.ts +29 -0
  130. package/esm/general-types/generalTypesApi.js +34 -0
  131. package/esm/general-types/generalTypesInterfaces.d.ts +29 -0
  132. package/esm/general-types/generalTypesInterfaces.js +1 -0
  133. package/esm/general-types/generalTypesSchemas.d.ts +68 -0
  134. package/esm/general-types/generalTypesSchemas.js +42 -0
  135. package/esm/index.d.ts +143 -0
  136. package/esm/index.js +124 -0
  137. package/esm/integration-collections/integrationCollectionsApi.d.ts +172 -0
  138. package/esm/integration-collections/integrationCollectionsApi.js +224 -0
  139. package/esm/integration-collections/integrationCollectionsInterfaces.d.ts +317 -0
  140. package/esm/integration-collections/integrationCollectionsInterfaces.js +1 -0
  141. package/esm/integration-collections/integrationCollectionsSchemas.d.ts +84 -0
  142. package/esm/integration-collections/integrationCollectionsSchemas.js +60 -0
  143. package/esm/locales/localesApi.d.ts +28 -0
  144. package/esm/locales/localesApi.js +33 -0
  145. package/esm/locales/localesInterfaces.d.ts +40 -0
  146. package/esm/locales/localesInterfaces.js +1 -0
  147. package/esm/locales/localesSchemas.d.ts +32 -0
  148. package/esm/locales/localesSchemas.js +23 -0
  149. package/esm/menus/menusApi.d.ts +30 -0
  150. package/esm/menus/menusApi.js +35 -0
  151. package/esm/menus/menusInterfaces.d.ts +91 -0
  152. package/esm/menus/menusInterfaces.js +2 -0
  153. package/esm/menus/menusSchemas.d.ts +16 -0
  154. package/esm/menus/menusSchemas.js +27 -0
  155. package/esm/orders/ordersApi.d.ts +213 -0
  156. package/esm/orders/ordersApi.js +288 -0
  157. package/esm/orders/ordersInterfaces.d.ts +765 -0
  158. package/esm/orders/ordersInterfaces.js +1 -0
  159. package/esm/orders/ordersSchemas.d.ts +314 -0
  160. package/esm/orders/ordersSchemas.js +172 -0
  161. package/esm/package.json +4 -0
  162. package/esm/pages/pagesApi.d.ts +163 -0
  163. package/esm/pages/pagesApi.js +397 -0
  164. package/esm/pages/pagesInterfaces.d.ts +327 -0
  165. package/esm/pages/pagesInterfaces.js +1 -0
  166. package/esm/pages/pagesSchemas.d.ts +117 -0
  167. package/esm/pages/pagesSchemas.js +54 -0
  168. package/esm/payments/paymentsApi.d.ts +88 -0
  169. package/esm/payments/paymentsApi.js +122 -0
  170. package/esm/payments/paymentsInterfaces.d.ts +189 -0
  171. package/esm/payments/paymentsInterfaces.js +1 -0
  172. package/esm/payments/paymentsSchemas.d.ts +94 -0
  173. package/esm/payments/paymentsSchemas.js +53 -0
  174. package/esm/product-statuses/productStatusesApi.d.ts +50 -0
  175. package/esm/product-statuses/productStatusesApi.js +68 -0
  176. package/esm/product-statuses/productStatusesInterfaces.d.ts +62 -0
  177. package/esm/product-statuses/productStatusesInterfaces.js +1 -0
  178. package/esm/product-statuses/productStatusesSchemas.d.ts +34 -0
  179. package/esm/product-statuses/productStatusesSchemas.js +27 -0
  180. package/esm/products/productsApi.d.ts +366 -0
  181. package/esm/products/productsApi.js +468 -0
  182. package/esm/products/productsInterfaces.d.ts +723 -0
  183. package/esm/products/productsInterfaces.js +1 -0
  184. package/esm/products/productsSchemas.d.ts +234 -0
  185. package/esm/products/productsSchemas.js +121 -0
  186. package/esm/search/searchApi.d.ts +35 -0
  187. package/esm/search/searchApi.js +47 -0
  188. package/esm/search/searchInterfaces.d.ts +94 -0
  189. package/esm/search/searchInterfaces.js +1 -0
  190. package/esm/search/searchSchemas.d.ts +73 -0
  191. package/esm/search/searchSchemas.js +41 -0
  192. package/esm/sitemap/sitemapApi.d.ts +37 -0
  193. package/esm/sitemap/sitemapApi.js +41 -0
  194. package/esm/sitemap/sitemapInterfaces.d.ts +51 -0
  195. package/esm/sitemap/sitemapInterfaces.js +1 -0
  196. package/esm/subscriptions/subscriptionsApi.d.ts +74 -0
  197. package/esm/subscriptions/subscriptionsApi.js +90 -0
  198. package/esm/subscriptions/subscriptionsInterfaces.d.ts +111 -0
  199. package/esm/subscriptions/subscriptionsInterfaces.js +1 -0
  200. package/esm/subscriptions/subscriptionsSchemas.d.ts +46 -0
  201. package/esm/subscriptions/subscriptionsSchemas.js +38 -0
  202. package/esm/system/systemApi.d.ts +46 -0
  203. package/esm/system/systemApi.js +53 -0
  204. package/esm/system/systemInterfaces.d.ts +29 -0
  205. package/esm/system/systemInterfaces.js +1 -0
  206. package/esm/templates/templatesApi.d.ts +53 -0
  207. package/esm/templates/templatesApi.js +78 -0
  208. package/esm/templates/templatesInterfaces.d.ts +68 -0
  209. package/esm/templates/templatesInterfaces.js +1 -0
  210. package/esm/templates/templatesSchemas.d.ts +48 -0
  211. package/esm/templates/templatesSchemas.js +28 -0
  212. package/esm/templates-preview/templatesPreviewApi.d.ts +40 -0
  213. package/esm/templates-preview/templatesPreviewApi.js +50 -0
  214. package/esm/templates-preview/templatesPreviewInterfaces.d.ts +129 -0
  215. package/esm/templates-preview/templatesPreviewInterfaces.js +1 -0
  216. package/esm/templates-preview/templatesPreviewSchemas.d.ts +79 -0
  217. package/esm/templates-preview/templatesPreviewSchemas.js +43 -0
  218. package/esm/types.d.ts +35 -0
  219. package/esm/types.js +1 -0
  220. package/esm/user-activity/userActivityApi.d.ts +31 -0
  221. package/esm/user-activity/userActivityApi.js +37 -0
  222. package/esm/user-activity/userActivityInterfaces.d.ts +42 -0
  223. package/esm/user-activity/userActivityInterfaces.js +1 -0
  224. package/esm/users/usersApi.d.ts +249 -0
  225. package/esm/users/usersApi.js +312 -0
  226. package/esm/users/usersInterfaces.d.ts +421 -0
  227. package/esm/users/usersInterfaces.js +1 -0
  228. package/esm/users/usersSchemas.d.ts +73 -0
  229. package/esm/users/usersSchemas.js +55 -0
  230. package/esm/web-socket/lazySocket.d.ts +18 -0
  231. package/esm/web-socket/lazySocket.js +67 -0
  232. package/esm/web-socket/wsApi.d.ts +27 -0
  233. package/esm/web-socket/wsApi.js +43 -0
  234. package/esm/web-socket/wsInterfaces.d.ts +16 -0
  235. package/esm/web-socket/wsInterfaces.js +1 -0
  236. package/package.json +5 -1
  237. package/types.d.ts +1 -0
  238. package/types.js +1 -0
@@ -0,0 +1,403 @@
1
+ /* eslint-disable jsdoc/reject-any-type */
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ import AsyncModules from '../base/asyncModules.js';
4
+ import createSchemaLoader from '../base/lazySchema.js';
5
+ const schema = createSchemaLoader(() => import('./blocksSchemas.js'));
6
+ /**
7
+ * Controllers for working with blocks.
8
+ * @handle /api/content/blocks
9
+ * @class BlocksApi
10
+ * @augments AsyncModules
11
+ * @implements {IBlocks}
12
+ * @description This class provides methods to interact with blocks.
13
+ */
14
+ export default class BlocksApi extends AsyncModules {
15
+ /**
16
+ * Constructor for BlocksApi class.
17
+ */
18
+ constructor(state) {
19
+ super(state);
20
+ this._url = state.url + '/api/content/blocks';
21
+ }
22
+ /**
23
+ * Get blocks by parameters.
24
+ * @handleName getBlocks
25
+ * @param {BlockType} [type] - Optional block type to filter by. Available values: "product" | "error_page" | "catalog_page" | "product_preview" | "similar_products_block" | "product_block" | "form" | "common_page" | "common_block" | "order" | "service" | "none". When omitted, blocks of all types are returned. Example: 'product'.
26
+ * @param {string} [langCode] - Language code. Default: "en_US".
27
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
28
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
29
+ * @returns {Promise<IBlocksResponse | IError>} Returns BlocksEntity object.
30
+ * @throws {IError} When isShell=false and an error occurs during the fetch
31
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getBlocks getBlocks} documentation.
32
+ */
33
+ async getBlocks(type, langCode = this.state.lang, offset = 0, limit = 30) {
34
+ // type is omitted from the query when not provided — the API rejects an
35
+ // empty type value, so it must not be sent at all.
36
+ const query = this._queryParamsToString({ langCode, type, offset, limit });
37
+ const response = await this._fetchPost(`?${query}`);
38
+ // Validate response if validation is enabled
39
+ const validated = await this._validateResponse(response, schema('BlocksResponseSchema'));
40
+ if (!this.state.traficLimit) {
41
+ const normalizeResponse = this._normalizeData(validated);
42
+ // On API error responses (e.g. 403 without list permission, 422) the
43
+ // normalized value is an IError without `items` — skip enrichment and
44
+ // return it as-is
45
+ if (Array.isArray(normalizeResponse.items)) {
46
+ await Promise.all(normalizeResponse.items.map((block) => this._enrichBlock(block, langCode, offset, limit, true)));
47
+ }
48
+ return normalizeResponse;
49
+ }
50
+ return this._normalizeData(validated);
51
+ }
52
+ /**
53
+ * Get block by marker.
54
+ * @handleName getBlockByMarker
55
+ * @param {string} marker - Marker of Block. Example: "product_block".
56
+ * @param {string} [langCode] - Language code. Default: "en_US".
57
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
58
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
59
+ * @returns {Promise<IBlockEntity | IError>} - Returns a BlockEntity object.
60
+ * @throws {IError} When isShell=false and an error occurs during the fetch
61
+ * @description This method retrieves a block by its marker and includes additional information such as similar products or products associated with the block.
62
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getBlockByMarker getBlockByMarker} documentation.
63
+ */
64
+ async getBlockByMarker(marker, langCode = this.state.lang, offset = 0, limit = 30) {
65
+ const response = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
66
+ // Validate response if validation is enabled
67
+ const validated = await this._validateResponse(response, schema('BlockEntitySchema'));
68
+ const normalizeResponse = this._normalizeData(validated);
69
+ await this._enrichBlock(normalizeResponse, langCode, offset, limit, !this.state.traficLimit);
70
+ return normalizeResponse;
71
+ }
72
+ /**
73
+ * Enrich a single block in place.
74
+ *
75
+ * Lifts product display settings from `customSettings.productConfig` to
76
+ * numeric top-level fields, strips internal-only fields, and — when
77
+ * `loadProducts` is true — fetches the related products for
78
+ * `similar_products_block` / `product_block` blocks. Shared by `getBlocks`
79
+ * (array) and `getBlockByMarker` (single block). Mutates `block` in place.
80
+ * @param {any} block - Normalized block to enrich (mutated in place).
81
+ * @param {string} langCode - Language code passed to product sub-requests.
82
+ * @param {number} offset - Pagination offset for product sub-requests.
83
+ * @param {number} limit - Pagination limit for product sub-requests.
84
+ * @param {boolean} loadProducts - Whether to fetch related products.
85
+ * @returns {Promise<void>} Resolves when enrichment (incl. sub-requests) is done.
86
+ */
87
+ async _enrichBlock(block, langCode, offset, limit, loadProducts) {
88
+ const customSettings = block.customSettings;
89
+ // Если у блока есть настройки отображения товаров (productConfig) —
90
+ // переносим их на верхний уровень блока в числовом формате (в API значения
91
+ // хранятся строками, поэтому приводим через «+»).
92
+ if (customSettings &&
93
+ Object.prototype.hasOwnProperty.call(customSettings, 'productConfig')) {
94
+ if (customSettings.productConfig.countElementsPerRow)
95
+ block.countElementsPerRow =
96
+ +customSettings.productConfig.countElementsPerRow;
97
+ if (customSettings.productConfig.quantity)
98
+ block.quantity = +customSettings.productConfig.quantity;
99
+ }
100
+ // Убираем служебные/внутренние поля из итогового объекта блока.
101
+ delete block.customSettings;
102
+ delete block.attributesSetIdentifier;
103
+ delete block.productPageUrls;
104
+ // В режиме экономии трафика товары не подгружаем.
105
+ if (!loadProducts)
106
+ return;
107
+ // Подгружаем связанные товары по идентификатору блока. При ошибке запроса
108
+ // подставляем пустой массив, чтобы один упавший подзапрос не ронял весь
109
+ // ответ (в getBlocks — не ломал обработку остальных блоков).
110
+ if (block.type === 'similar_products_block') {
111
+ try {
112
+ block.similarProducts = await this.getSimilarProducts(block.identifier, langCode, offset, limit);
113
+ }
114
+ catch {
115
+ block.similarProducts = [];
116
+ }
117
+ }
118
+ else if (block.type === 'product_block') {
119
+ try {
120
+ block.products = await this.getProductsByBlockMarker(block.identifier, langCode, offset, limit);
121
+ }
122
+ catch {
123
+ block.products = [];
124
+ }
125
+ }
126
+ }
127
+ /**
128
+ * Get similar products by block marker.
129
+ * @handleName getSimilarProducts
130
+ * @param {string} marker - Block identifier. Example: "similar_products_block".
131
+ * @param {string} [langCode] - Language code. Default: "en_US".
132
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
133
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
134
+ * @param {string} [signPrice] - Order storage marker for price fixing. If the parameter is set, the price is fixed for a certain time.
135
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/#Fixing-the-price-signPrice Fixing the price} documentation.
136
+ * @param {number} [productId] - Optional product id to find similar products for.
137
+ * @returns {Promise<IProductsResponse | IError>} Returns the total count and an array of product items in object by specified block marker.
138
+ * @throws {IError} When isShell=false and an error occurs during the fetch
139
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getSimilarProducts getSimilarProducts} documentation.
140
+ */
141
+ async getSimilarProducts(marker, langCode = this.state.lang, offset = 0, limit = 30, signPrice, productId) {
142
+ const query = {
143
+ langCode,
144
+ offset,
145
+ limit,
146
+ signPrice,
147
+ productId,
148
+ };
149
+ const result = await this._fetchGet(`/${marker}/similar-products?` + this._queryParamsToString(query));
150
+ return this._normalizeData(result);
151
+ }
152
+ /**
153
+ * Get products by block marker.
154
+ * @handleName getProductsByBlockMarker
155
+ * @param {string} marker - Block identifier. Example: "product_block".
156
+ * @param {string} [langCode] - Language code. Default: "en_US".
157
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
158
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
159
+ * @param {string} [signPrice] - Order storage marker for price fixing. If the parameter is set, the price is fixed for a certain time.
160
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/#Fixing-the-price-signPrice Fixing the price} documentation.
161
+ * @returns {Promise<IProductsEntity[] | IError>} Return array of BlocksEntity object.
162
+ * @throws {IError} When isShell=false and an error occurs during the fetch
163
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getProductsByBlockMarker getProductsByBlockMarker} documentation.
164
+ */
165
+ async getProductsByBlockMarker(marker, langCode = this.state.lang, offset = 0, limit = 30, signPrice) {
166
+ const query = {
167
+ langCode,
168
+ offset,
169
+ limit,
170
+ signPrice,
171
+ };
172
+ const result = await this._fetchGet(`/${marker}/products?` + this._queryParamsToString(query));
173
+ // On API error responses there is no `items` array — return the (normalized)
174
+ // error as-is instead of producing `undefined` from `result.items`.
175
+ if (!Array.isArray(result === null || result === void 0 ? void 0 : result.items)) {
176
+ return this._normalizeData(result);
177
+ }
178
+ return this._normalizeData(result.items);
179
+ }
180
+ /**
181
+ * Get frequently ordered products by block marker and product id.
182
+ * @handleName getFrequentlyOrderedProducts
183
+ * @param {number} productId - Product id. Example: 1.
184
+ * @param {string} marker - Block marker. Example: "frequently_ordered_block".
185
+ * @param {string} [langCode] - Language code. Default: "en_US".
186
+ * @param {string} [signPrice] - Order storage marker for price fixing. If the parameter is set, the price is fixed for a certain time.
187
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/#Fixing-the-price-signPrice Fixing the price} documentation.
188
+ * @param {number} [limit] - Maximum number of products to return. When omitted, the block's own quantity setting applies. Example: 10.
189
+ * @returns {Promise<IProductsResponse | IError>} Returns a products response with items and total.
190
+ * @throws {IError} When isShell=false and an error occurs during the fetch
191
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getFrequentlyOrderedProducts getFrequentlyOrderedProducts} documentation.
192
+ */
193
+ async getFrequentlyOrderedProducts(productId, marker, langCode = this.state.lang, signPrice, limit) {
194
+ const query = {
195
+ langCode,
196
+ signPrice,
197
+ limit,
198
+ };
199
+ const data = await this._fetchGet(`/${marker}/products/${productId}/frequently-ordered?` +
200
+ this._queryParamsToString(query));
201
+ return this._normalizeData(data);
202
+ }
203
+ /**
204
+ * Quick search for block objects with limited output.
205
+ * @handleName searchBlock
206
+ * @param {string} name - Search string. Example: "product_block".
207
+ * @param {string} [langCode] - Language code. Default: "en_US".
208
+ * @returns {Promise<ISearchBlock[] | IError>} Returns an array of ISearchBlock objects.
209
+ * @throws {IError} When isShell=false and an error occurs during the fetch
210
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/searchBlock searchBlock} documentation.
211
+ */
212
+ async searchBlock(name, langCode = this.state.lang) {
213
+ const result = await this._fetchGet(`/quick/search?langCode=${encodeURIComponent(langCode)}&name=${encodeURIComponent(name)}`);
214
+ // Validate response if validation is enabled
215
+ const validated = await this._validateResponse(result, schema('SearchBlocksResponseSchema'));
216
+ return validated;
217
+ }
218
+ /**
219
+ * Get "complete your cart" products by the cart from context (auth user or guest).
220
+ * @handleName getCartComplement
221
+ * @param {string} marker - Block marker. Example: "cart_complement_block".
222
+ * @param {string} [langCode] - Language code. Default: "en_US".
223
+ * @param {string} [signPrice] - Order storage marker for price fixing. If the parameter is set, the price is fixed for a certain time.
224
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/#Fixing-the-price-signPrice Fixing the price} documentation.
225
+ * @param {number} [limit] - Maximum number of products to return. When omitted, the block's own quantity setting applies. Example: 10.
226
+ * @returns {Promise<IProductsResponse | IError>} Returns an object with an array of products, total count and totalFound.
227
+ * @throws {IError} When isShell=false and an error occurs during the fetch
228
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getCartComplement getCartComplement} documentation.
229
+ */
230
+ async getCartComplement(marker, langCode = this.state.lang, signPrice, limit) {
231
+ const query = { langCode, signPrice, limit };
232
+ const data = await this._fetchGet(`/${marker}/cart-complement?` + this._queryParamsToString(query));
233
+ return this._normalizeData(data);
234
+ }
235
+ /**
236
+ * Get "complete your cart" products by an explicit list of productIds (POST body).
237
+ * @handleName getCartComplementByProductIds
238
+ * @param {string} marker - Block marker. Example: "cart_complement_block".
239
+ * @param {IBlockProductsLookup} body - Lookup body.
240
+ * @example
241
+ {
242
+ "productIds": [1, 2],
243
+ "langCode": "en_US"
244
+ }
245
+ * @returns {Promise<IProductsResponse | IError>} Returns an object with an array of products, total count and totalFound.
246
+ * @throws {IError} When isShell=false and an error occurs during the fetch
247
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getCartComplementByProductIds getCartComplementByProductIds} documentation.
248
+ */
249
+ async getCartComplementByProductIds(marker, body) {
250
+ const data = await this._fetchPost(`/${marker}/cart-complement`, { langCode: this.state.lang, ...body });
251
+ return this._normalizeData(data);
252
+ }
253
+ /**
254
+ * Get "similar to cart" products by the cart from context (auth user or guest).
255
+ * @handleName getCartSimilar
256
+ * @param {string} marker - Block marker. Example: "cart_similar_block".
257
+ * @param {string} [langCode] - Language code. Default: "en_US".
258
+ * @param {string} [signPrice] - Order storage marker for price fixing. If the parameter is set, the price is fixed for a certain time.
259
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/#Fixing-the-price-signPrice Fixing the price} documentation.
260
+ * @param {number} [limit] - Maximum number of products to return. When omitted, the block's own quantity setting applies. Example: 10.
261
+ * @returns {Promise<IProductsResponse | IError>} Returns an object with an array of products, total count and totalFound.
262
+ * @throws {IError} When isShell=false and an error occurs during the fetch
263
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getCartSimilar getCartSimilar} documentation.
264
+ */
265
+ async getCartSimilar(marker, langCode = this.state.lang, signPrice, limit) {
266
+ const query = { langCode, signPrice, limit };
267
+ const data = await this._fetchGet(`/${marker}/cart-similar?` + this._queryParamsToString(query));
268
+ return this._normalizeData(data);
269
+ }
270
+ /**
271
+ * Get "similar to cart" products by an explicit list of productIds (POST body).
272
+ * @handleName getCartSimilarByProductIds
273
+ * @param {string} marker - Block marker. Example: "cart_similar_block".
274
+ * @param {IBlockProductsLookup} body - Lookup body.
275
+ * @example
276
+ {
277
+ "productIds": [1, 2],
278
+ "langCode": "en_US"
279
+ }
280
+ * @returns {Promise<IProductsResponse | IError>} Returns an object with an array of products, total count and totalFound.
281
+ * @throws {IError} When isShell=false and an error occurs during the fetch
282
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getCartSimilarByProductIds getCartSimilarByProductIds} documentation.
283
+ */
284
+ async getCartSimilarByProductIds(marker, body) {
285
+ const data = await this._fetchPost(`/${marker}/cart-similar`, { langCode: this.state.lang, ...body });
286
+ return this._normalizeData(data);
287
+ }
288
+ /**
289
+ * Get personal recommendations for the user.
290
+ * @handleName getPersonalRecommendations
291
+ * @param {string} marker - Block marker. Example: "personal_recommendations_block".
292
+ * @param {string} [langCode] - Language code. Default: "en_US".
293
+ * @param {string} [signPrice] - Order storage marker for price fixing. If the parameter is set, the price is fixed for a certain time.
294
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/#Fixing-the-price-signPrice Fixing the price} documentation.
295
+ * @param {number} [limit] - Maximum number of products to return. When omitted, the block's own quantity setting applies. Example: 10.
296
+ * @returns {Promise<IProductsResponse | IError>} Returns an object with an array of products, total count and totalFound.
297
+ * @throws {IError} When isShell=false and an error occurs during the fetch
298
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getPersonalRecommendations getPersonalRecommendations} documentation.
299
+ */
300
+ async getPersonalRecommendations(marker, langCode = this.state.lang, signPrice, limit) {
301
+ const query = { langCode, signPrice, limit };
302
+ const data = await this._fetchGet(`/${marker}/personal-recommendations?` + this._queryParamsToString(query));
303
+ return this._normalizeData(data);
304
+ }
305
+ /**
306
+ * Get recently viewed products.
307
+ * @handleName getRecentlyViewed
308
+ * @param {string} marker - Block marker. Example: "recently_viewed_block".
309
+ * @param {string} [langCode] - Language code. Default: "en_US".
310
+ * @param {string} [signPrice] - Order storage marker for price fixing. If the parameter is set, the price is fixed for a certain time.
311
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/#Fixing-the-price-signPrice Fixing the price} documentation.
312
+ * @param {number} [limit] - Maximum number of products to return. When omitted, the block's own quantity setting applies. Example: 10.
313
+ * @returns {Promise<IProductsResponse | IError>} Returns an object with an array of products, total count and totalFound.
314
+ * @throws {IError} When isShell=false and an error occurs during the fetch
315
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getRecentlyViewed getRecentlyViewed} documentation.
316
+ */
317
+ async getRecentlyViewed(marker, langCode = this.state.lang, signPrice, limit) {
318
+ const query = { langCode, signPrice, limit };
319
+ const data = await this._fetchGet(`/${marker}/recently-viewed?` + this._queryParamsToString(query));
320
+ return this._normalizeData(data);
321
+ }
322
+ /**
323
+ * Get products for repeat purchase.
324
+ * @handleName getRepeatPurchase
325
+ * @param {string} marker - Block marker. Example: "repeat_purchase_block".
326
+ * @param {string} [langCode] - Language code. Default: "en_US".
327
+ * @param {string} [signPrice] - Order storage marker for price fixing. If the parameter is set, the price is fixed for a certain time.
328
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/#Fixing-the-price-signPrice Fixing the price} documentation.
329
+ * @param {number} [limit] - Maximum number of products to return. When omitted, the block's own quantity setting applies. Example: 10.
330
+ * @returns {Promise<IProductsResponse | IError>} Returns an object with an array of products, total count and totalFound.
331
+ * @throws {IError} When isShell=false and an error occurs during the fetch
332
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getRepeatPurchase getRepeatPurchase} documentation.
333
+ */
334
+ async getRepeatPurchase(marker, langCode = this.state.lang, signPrice, limit) {
335
+ const query = { langCode, signPrice, limit };
336
+ const data = await this._fetchGet(`/${marker}/repeat-purchase?` + this._queryParamsToString(query));
337
+ return this._normalizeData(data);
338
+ }
339
+ /**
340
+ * Get the block's slides tree as a flat pre-order array (slider_block only).
341
+ * @handleName getSlides
342
+ * @param {string} marker - Block marker. Example: "slider_block".
343
+ * @returns {Promise<IBlockSlidesResponse | IError>} Returns the slides response.
344
+ * @throws {IError} When isShell=false and an error occurs during the fetch
345
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getSlides getSlides} documentation.
346
+ */
347
+ async getSlides(marker) {
348
+ const data = await this._fetchGet(`/${marker}/slides`);
349
+ return this._normalizeData(data);
350
+ }
351
+ /**
352
+ * Get trending products of the block.
353
+ * @handleName getTrending
354
+ * @param {string} marker - Block marker. Example: "trending_block".
355
+ * @param {string} [langCode] - Language code. Default: "en_US".
356
+ * @param {string} [signPrice] - Order storage marker for price fixing. If the parameter is set, the price is fixed for a certain time.
357
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/#Fixing-the-price-signPrice Fixing the price} documentation.
358
+ * @param {number} [limit] - Maximum number of products to return. When omitted, the block's own quantity setting applies. Example: 10.
359
+ * @returns {Promise<IProductsResponse | IError>} Returns an object with an array of products, total count and totalFound.
360
+ * @throws {IError} When isShell=false and an error occurs during the fetch
361
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getTrending getTrending} documentation.
362
+ */
363
+ async getTrending(marker, langCode = this.state.lang, signPrice, limit) {
364
+ const query = { langCode, signPrice, limit };
365
+ const data = await this._fetchGet(`/${marker}/trending?` + this._queryParamsToString(query));
366
+ return this._normalizeData(data);
367
+ }
368
+ /**
369
+ * Get "similar to wishlist" products by the wishlist from context (auth user or guest).
370
+ * @handleName getWishlistSimilar
371
+ * @param {string} marker - Block marker. Example: "wishlist_similar_block".
372
+ * @param {string} [langCode] - Language code. Default: "en_US".
373
+ * @param {string} [signPrice] - Order storage marker for price fixing. If the parameter is set, the price is fixed for a certain time.
374
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/#Fixing-the-price-signPrice Fixing the price} documentation.
375
+ * @param {number} [limit] - Maximum number of products to return. When omitted, the block's own quantity setting applies. Example: 10.
376
+ * @returns {Promise<IProductsResponse | IError>} Returns an object with an array of products, total count and totalFound.
377
+ * @throws {IError} When isShell=false and an error occurs during the fetch
378
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getWishlistSimilar getWishlistSimilar} documentation.
379
+ */
380
+ async getWishlistSimilar(marker, langCode = this.state.lang, signPrice, limit) {
381
+ const query = { langCode, signPrice, limit };
382
+ const data = await this._fetchGet(`/${marker}/wishlist-similar?` + this._queryParamsToString(query));
383
+ return this._normalizeData(data);
384
+ }
385
+ /**
386
+ * Get "similar to wishlist" products by an explicit list of productIds (POST body).
387
+ * @handleName getWishlistSimilarByProductIds
388
+ * @param {string} marker - Block marker. Example: "wishlist_similar_block".
389
+ * @param {IBlockProductsLookup} body - Lookup body.
390
+ * @example
391
+ {
392
+ "productIds": [1, 2],
393
+ "langCode": "en_US"
394
+ }
395
+ * @returns {Promise<IProductsResponse | IError>} Returns an object with an array of products, total count and totalFound.
396
+ * @throws {IError} When isShell=false and an error occurs during the fetch
397
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getWishlistSimilarByProductIds getWishlistSimilarByProductIds} documentation.
398
+ */
399
+ async getWishlistSimilarByProductIds(marker, body) {
400
+ const data = await this._fetchPost(`/${marker}/wishlist-similar`, { langCode: this.state.lang, ...body });
401
+ return this._normalizeData(data);
402
+ }
403
+ }