oneentry 1.0.176 → 1.0.178

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 (199) hide show
  1. package/README.md +12 -5
  2. package/changelog.md +116 -0
  3. package/dist/admins/adminsApi.js +2 -9
  4. package/dist/admins/adminsInterfaces.d.ts +5 -5
  5. package/dist/admins/adminsSchemas.d.ts +4 -4
  6. package/dist/admins/adminsSchemas.js +2 -2
  7. package/dist/attribute-sets/attributeSetsApi.d.ts +1 -1
  8. package/dist/attribute-sets/attributeSetsApi.js +4 -4
  9. package/dist/attribute-sets/attributeSetsInterfaces.d.ts +65 -14
  10. package/dist/attribute-sets/attributeSetsSchemas.d.ts +8 -6
  11. package/dist/attribute-sets/attributeSetsSchemas.js +6 -9
  12. package/dist/auth-provider/authProviderApi.d.ts +4 -4
  13. package/dist/auth-provider/authProviderApi.js +90 -23
  14. package/dist/auth-provider/authProviderSchemas.d.ts +1 -0
  15. package/dist/auth-provider/authProviderSchemas.js +1 -0
  16. package/dist/auth-provider/authProvidersInterfaces.d.ts +8 -6
  17. package/dist/base/asyncModules.d.ts +62 -1
  18. package/dist/base/asyncModules.js +219 -37
  19. package/dist/base/stateModule.d.ts +2 -0
  20. package/dist/base/stateModule.js +22 -12
  21. package/dist/base/syncModules.d.ts +18 -10
  22. package/dist/base/syncModules.js +100 -29
  23. package/dist/base/utils.d.ts +26 -21
  24. package/dist/base/validation.d.ts +3 -3
  25. package/dist/base/validation.js +6 -7
  26. package/dist/blocks/blocksApi.d.ts +20 -17
  27. package/dist/blocks/blocksApi.js +82 -64
  28. package/dist/blocks/blocksInterfaces.d.ts +8 -8
  29. package/dist/discounts/discountsApi.d.ts +9 -7
  30. package/dist/discounts/discountsApi.js +16 -13
  31. package/dist/discounts/discountsInterfaces.d.ts +14 -10
  32. package/dist/events/eventsApi.d.ts +3 -3
  33. package/dist/events/eventsApi.js +3 -3
  34. package/dist/events/eventsInterfaces.d.ts +10 -14
  35. package/dist/file-uploading/fileUploadingApi.d.ts +4 -4
  36. package/dist/file-uploading/fileUploadingApi.js +13 -5
  37. package/dist/file-uploading/fileUploadingInterfaces.d.ts +5 -6
  38. package/dist/filters/filtersApi.js +2 -2
  39. package/dist/forms/formsApi.js +2 -2
  40. package/dist/forms/formsInterfaces.d.ts +1 -3
  41. package/dist/forms/formsSchemas.d.ts +3 -6
  42. package/dist/forms/formsSchemas.js +2 -4
  43. package/dist/forms-data/formsDataApi.d.ts +27 -1
  44. package/dist/forms-data/formsDataApi.js +119 -68
  45. package/dist/forms-data/formsDataInterfaces.d.ts +17 -13
  46. package/dist/general-types/generalTypesInterfaces.d.ts +1 -1
  47. package/dist/index.d.ts +7 -6
  48. package/dist/index.js +50 -7
  49. package/dist/integration-collections/integrationCollectionsApi.d.ts +15 -4
  50. package/dist/integration-collections/integrationCollectionsApi.js +41 -14
  51. package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +8 -9
  52. package/dist/integration-collections/integrationCollectionsSchemas.d.ts +0 -2
  53. package/dist/integration-collections/integrationCollectionsSchemas.js +0 -1
  54. package/dist/menus/menusApi.js +1 -1
  55. package/dist/orders/ordersApi.d.ts +1 -13
  56. package/dist/orders/ordersApi.js +21 -42
  57. package/dist/orders/ordersInterfaces.d.ts +21 -14
  58. package/dist/pages/pagesApi.d.ts +8 -6
  59. package/dist/pages/pagesApi.js +48 -33
  60. package/dist/pages/pagesInterfaces.d.ts +20 -16
  61. package/dist/pages/pagesSchemas.d.ts +0 -3
  62. package/dist/pages/pagesSchemas.js +0 -1
  63. package/dist/payments/paymentsApi.d.ts +10 -11
  64. package/dist/payments/paymentsApi.js +22 -18
  65. package/dist/payments/paymentsInterfaces.d.ts +12 -14
  66. package/dist/payments/paymentsSchemas.d.ts +21 -20
  67. package/dist/payments/paymentsSchemas.js +5 -8
  68. package/dist/product-statuses/productStatusesApi.d.ts +1 -1
  69. package/dist/product-statuses/productStatusesApi.js +3 -3
  70. package/dist/product-statuses/productStatusesInterfaces.d.ts +1 -4
  71. package/dist/products/productsApi.d.ts +50 -64
  72. package/dist/products/productsApi.js +79 -80
  73. package/dist/products/productsInterfaces.d.ts +59 -90
  74. package/dist/search/searchApi.d.ts +3 -2
  75. package/dist/search/searchApi.js +7 -4
  76. package/dist/search/searchInterfaces.d.ts +2 -1
  77. package/dist/sitemap/sitemapInterfaces.d.ts +10 -6
  78. package/dist/subscriptions/subscriptionsApi.d.ts +1 -1
  79. package/dist/subscriptions/subscriptionsApi.js +1 -1
  80. package/dist/subscriptions/subscriptionsInterfaces.d.ts +1 -1
  81. package/dist/system/systemApi.d.ts +2 -0
  82. package/dist/system/systemApi.js +2 -0
  83. package/dist/system/systemInterfaces.d.ts +2 -0
  84. package/dist/templates/templatesApi.d.ts +2 -2
  85. package/dist/templates/templatesApi.js +12 -11
  86. package/dist/templates/templatesInterfaces.d.ts +2 -2
  87. package/dist/templates-preview/templatesPreviewApi.js +2 -2
  88. package/dist/templates-preview/templatesPreviewInterfaces.d.ts +23 -13
  89. package/dist/templates-preview/templatesPreviewSchemas.d.ts +7 -0
  90. package/dist/templates-preview/templatesPreviewSchemas.js +2 -0
  91. package/dist/user-groups/userGroupsApi.js +5 -5
  92. package/dist/user-groups/userGroupsSchemas.d.ts +4 -4
  93. package/dist/users/usersApi.d.ts +1 -1
  94. package/dist/users/usersApi.js +28 -15
  95. package/dist/users/usersInterfaces.d.ts +2 -9
  96. package/dist/web-socket/lazySocket.d.ts +6 -5
  97. package/dist/web-socket/lazySocket.js +212 -15
  98. package/dist/web-socket/wsApi.d.ts +7 -4
  99. package/dist/web-socket/wsApi.js +49 -12
  100. package/dist/web-socket/wsInterfaces.d.ts +41 -4
  101. package/esm/admins/adminsApi.js +2 -9
  102. package/esm/admins/adminsInterfaces.d.ts +5 -5
  103. package/esm/admins/adminsSchemas.d.ts +4 -4
  104. package/esm/admins/adminsSchemas.js +2 -2
  105. package/esm/attribute-sets/attributeSetsApi.d.ts +1 -1
  106. package/esm/attribute-sets/attributeSetsApi.js +4 -4
  107. package/esm/attribute-sets/attributeSetsInterfaces.d.ts +65 -14
  108. package/esm/attribute-sets/attributeSetsSchemas.d.ts +8 -6
  109. package/esm/attribute-sets/attributeSetsSchemas.js +6 -9
  110. package/esm/auth-provider/authProviderApi.d.ts +4 -4
  111. package/esm/auth-provider/authProviderApi.js +90 -23
  112. package/esm/auth-provider/authProviderSchemas.d.ts +1 -0
  113. package/esm/auth-provider/authProviderSchemas.js +1 -0
  114. package/esm/auth-provider/authProvidersInterfaces.d.ts +8 -6
  115. package/esm/base/asyncModules.d.ts +62 -1
  116. package/esm/base/asyncModules.js +219 -37
  117. package/esm/base/stateModule.d.ts +2 -0
  118. package/esm/base/stateModule.js +22 -12
  119. package/esm/base/syncModules.d.ts +18 -10
  120. package/esm/base/syncModules.js +99 -29
  121. package/esm/base/utils.d.ts +26 -21
  122. package/esm/base/validation.d.ts +3 -3
  123. package/esm/base/validation.js +6 -7
  124. package/esm/blocks/blocksApi.d.ts +20 -17
  125. package/esm/blocks/blocksApi.js +82 -64
  126. package/esm/blocks/blocksInterfaces.d.ts +8 -8
  127. package/esm/discounts/discountsApi.d.ts +9 -7
  128. package/esm/discounts/discountsApi.js +16 -13
  129. package/esm/discounts/discountsInterfaces.d.ts +14 -10
  130. package/esm/events/eventsApi.d.ts +3 -3
  131. package/esm/events/eventsApi.js +3 -3
  132. package/esm/events/eventsInterfaces.d.ts +10 -14
  133. package/esm/file-uploading/fileUploadingApi.d.ts +4 -4
  134. package/esm/file-uploading/fileUploadingApi.js +13 -5
  135. package/esm/file-uploading/fileUploadingInterfaces.d.ts +5 -6
  136. package/esm/filters/filtersApi.js +2 -2
  137. package/esm/forms/formsApi.js +2 -2
  138. package/esm/forms/formsInterfaces.d.ts +1 -3
  139. package/esm/forms/formsSchemas.d.ts +3 -6
  140. package/esm/forms/formsSchemas.js +2 -4
  141. package/esm/forms-data/formsDataApi.d.ts +27 -1
  142. package/esm/forms-data/formsDataApi.js +119 -68
  143. package/esm/forms-data/formsDataInterfaces.d.ts +17 -13
  144. package/esm/general-types/generalTypesInterfaces.d.ts +1 -1
  145. package/esm/index.d.ts +7 -6
  146. package/esm/index.js +50 -7
  147. package/esm/integration-collections/integrationCollectionsApi.d.ts +15 -4
  148. package/esm/integration-collections/integrationCollectionsApi.js +41 -14
  149. package/esm/integration-collections/integrationCollectionsInterfaces.d.ts +8 -9
  150. package/esm/integration-collections/integrationCollectionsSchemas.d.ts +0 -2
  151. package/esm/integration-collections/integrationCollectionsSchemas.js +0 -1
  152. package/esm/menus/menusApi.js +1 -1
  153. package/esm/orders/ordersApi.d.ts +1 -13
  154. package/esm/orders/ordersApi.js +21 -42
  155. package/esm/orders/ordersInterfaces.d.ts +21 -14
  156. package/esm/pages/pagesApi.d.ts +8 -6
  157. package/esm/pages/pagesApi.js +48 -33
  158. package/esm/pages/pagesInterfaces.d.ts +20 -16
  159. package/esm/pages/pagesSchemas.d.ts +0 -3
  160. package/esm/pages/pagesSchemas.js +0 -1
  161. package/esm/payments/paymentsApi.d.ts +10 -11
  162. package/esm/payments/paymentsApi.js +22 -18
  163. package/esm/payments/paymentsInterfaces.d.ts +12 -14
  164. package/esm/payments/paymentsSchemas.d.ts +21 -20
  165. package/esm/payments/paymentsSchemas.js +5 -8
  166. package/esm/product-statuses/productStatusesApi.d.ts +1 -1
  167. package/esm/product-statuses/productStatusesApi.js +3 -3
  168. package/esm/product-statuses/productStatusesInterfaces.d.ts +1 -4
  169. package/esm/products/productsApi.d.ts +50 -64
  170. package/esm/products/productsApi.js +79 -80
  171. package/esm/products/productsInterfaces.d.ts +59 -90
  172. package/esm/search/searchApi.d.ts +3 -2
  173. package/esm/search/searchApi.js +7 -4
  174. package/esm/search/searchInterfaces.d.ts +2 -1
  175. package/esm/sitemap/sitemapInterfaces.d.ts +10 -6
  176. package/esm/subscriptions/subscriptionsApi.d.ts +1 -1
  177. package/esm/subscriptions/subscriptionsApi.js +1 -1
  178. package/esm/subscriptions/subscriptionsInterfaces.d.ts +1 -1
  179. package/esm/system/systemApi.d.ts +2 -0
  180. package/esm/system/systemApi.js +2 -0
  181. package/esm/system/systemInterfaces.d.ts +2 -0
  182. package/esm/templates/templatesApi.d.ts +2 -2
  183. package/esm/templates/templatesApi.js +11 -10
  184. package/esm/templates/templatesInterfaces.d.ts +2 -2
  185. package/esm/templates-preview/templatesPreviewApi.js +2 -2
  186. package/esm/templates-preview/templatesPreviewInterfaces.d.ts +23 -13
  187. package/esm/templates-preview/templatesPreviewSchemas.d.ts +7 -0
  188. package/esm/templates-preview/templatesPreviewSchemas.js +2 -0
  189. package/esm/user-groups/userGroupsApi.js +5 -5
  190. package/esm/user-groups/userGroupsSchemas.d.ts +4 -4
  191. package/esm/users/usersApi.d.ts +1 -1
  192. package/esm/users/usersApi.js +28 -15
  193. package/esm/users/usersInterfaces.d.ts +2 -9
  194. package/esm/web-socket/lazySocket.d.ts +6 -5
  195. package/esm/web-socket/lazySocket.js +212 -15
  196. package/esm/web-socket/wsApi.d.ts +7 -4
  197. package/esm/web-socket/wsApi.js +49 -12
  198. package/esm/web-socket/wsInterfaces.d.ts +41 -4
  199. package/package.json +2 -2
@@ -91,14 +91,14 @@ class ProductsApi extends asyncModules_1.default {
91
91
  "offset": 0,
92
92
  "sortOrder": "DESC",
93
93
  "sortKey": "id",
94
- "signPrice": "orders"
94
+ "signPrice": "my_order"
95
95
  }
96
- * @param {string} [userQuery.signPrice] - Marker of the order storage to fix prices for. When set, each product comes with a `signedPrice` that holds the price for a limited time. Example: "orders_storage".
96
+ * @param {string} [userQuery.signPrice] - Marker of the order storage to fix prices for. When set, each product comes with a `signedPrice` that holds the price for a limited time. Must be an existing orders storage marker of the project, e.g. "my_order"; a marker with no such storage fails the whole request with `404 Specified orders storage for price signature not found`.
97
97
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/#Fixing-the-price-signPrice Fixing the price} documentation.
98
98
  * @param {string} [userQuery.sortOrder] - Sorting order parameter.
99
99
  * @returns {Promise<IProductsResponse | IError>} Products response, or IError when isShell=true
100
100
  * @throws {IError} When isShell=false and an error occurs during the fetch
101
- * @description Fetch products with optional filters and pagination.
101
+ * @description Fetch products with optional filters and pagination. `limit` is an integer from `1` (`0` or `1.5` answer `400`). A `signPrice` naming no orders storage fails the whole request with `404 Specified orders storage for price signature not found`. Products without a translation in `langCode` are left out.
102
102
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/getProducts getProducts} documentation.
103
103
  */
104
104
  async getProducts(body = [], langCode = this.state.lang, userQuery) {
@@ -123,7 +123,7 @@ class ProductsApi extends asyncModules_1.default {
123
123
  "offset": 0,
124
124
  "sortOrder": "DESC",
125
125
  "sortKey": "id",
126
- "signPrice": "orders"
126
+ "signPrice": "my_order"
127
127
  }
128
128
  * @returns {Promise<IProductsResponse | IError>} Products without a category: `{ items, total }`, the same container as getProducts.
129
129
  * @throws {IError} When isShell=false and an error occurs during the fetch
@@ -174,7 +174,7 @@ class ProductsApi extends asyncModules_1.default {
174
174
  "offset": 0,
175
175
  "sortOrder": "DESC",
176
176
  "sortKey": "id",
177
- "signPrice": "orders"
177
+ "signPrice": "my_order"
178
178
  }
179
179
  * @returns {Promise<IProductsResponse | IError>} Array with ProductEntity objects
180
180
  * @throws {IError} When isShell=false and an error occurs during the fetch
@@ -182,8 +182,11 @@ class ProductsApi extends asyncModules_1.default {
182
182
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsByPageId getProductsByPageId} documentation.
183
183
  */
184
184
  async getProductsByPageId(id, body = [], langCode = this.state.lang, userQuery) {
185
- const query = { ...userQuery };
186
- const result = await this._fetchPost(`/page/${id}?langCode=${langCode}&` + this._queryParamsToString(query), { filter: body });
185
+ // Positional arguments win over the same keys in userQuery; one serializer
186
+ // builds the query, so langCode is encoded and sent once
187
+ const query = { ...userQuery, langCode };
188
+ const result = await this._fetchPost(`/page/${this._pathSegment(String(id))}?` +
189
+ this._queryParamsToString(query), { filter: body });
187
190
  // Validate response if validation is enabled
188
191
  const validated = await this._validateResponse(result, schema('ProductsResponseSchema'));
189
192
  return this._normalizeData(validated, langCode);
@@ -199,7 +202,7 @@ class ProductsApi extends asyncModules_1.default {
199
202
  "limit": 30,
200
203
  "offset": 0,
201
204
  "sortOrder": "DESC",
202
- "signPrice": "orders",
205
+ "signPrice": "my_order",
203
206
  "statusMarker": "in_stock"
204
207
  }
205
208
  * @returns {Promise<IProductsInfo | IError>} Array with ProductInformation objects.
@@ -212,7 +215,8 @@ class ProductsApi extends asyncModules_1.default {
212
215
  ...userQuery,
213
216
  langCode,
214
217
  };
215
- const result = await this._fetchGet(`/page/${url}/prices?` + this._queryParamsToString(query));
218
+ const result = await this._fetchGet(`/page/${this._pathSegments(url)}/prices?` +
219
+ this._queryParamsToString(query));
216
220
  return result;
217
221
  }
218
222
  /**
@@ -252,7 +256,7 @@ class ProductsApi extends asyncModules_1.default {
252
256
  "offset": 0,
253
257
  "sortOrder": "DESC",
254
258
  "sortKey": "id",
255
- "signPrice": "orders"
259
+ "signPrice": "my_order"
256
260
  }
257
261
  * @returns {Promise<IProductsResponse | IError>} Array with ProductEntity objects.
258
262
  * @throws {IError} When isShell=false and an error occurs during the fetch
@@ -260,8 +264,8 @@ class ProductsApi extends asyncModules_1.default {
260
264
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsByPageUrl getProductsByPageUrl} documentation.
261
265
  */
262
266
  async getProductsByPageUrl(url, body = [], langCode = this.state.lang, userQuery) {
263
- const query = { ...userQuery };
264
- const result = await this._fetchPost(`/page/url/${url}?langCode=${langCode}&` +
267
+ const query = { ...userQuery, langCode };
268
+ const result = await this._fetchPost(`/page/url/${this._pathSegments(url)}?` +
265
269
  this._queryParamsToString(query), { filter: body });
266
270
  // Validate response if validation is enabled
267
271
  const validated = await this._validateResponse(result, schema('ProductsResponseSchema'));
@@ -279,7 +283,7 @@ class ProductsApi extends asyncModules_1.default {
279
283
  "offset": 0,
280
284
  "sortOrder": "DESC",
281
285
  "sortKey": "id",
282
- "signPrice": "orders",
286
+ "signPrice": "my_order",
283
287
  "statusMarker": "in_stock",
284
288
  "templateMarker": "template_12345"
285
289
  }
@@ -294,8 +298,9 @@ class ProductsApi extends asyncModules_1.default {
294
298
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/getRelatedProductsById getRelatedProductsById} documentation.
295
299
  */
296
300
  async getRelatedProductsById(id, langCode = this.state.lang, userQuery) {
297
- const query = { ...userQuery };
298
- const result = await this._fetchGet(`/${id}/related?langCode=${langCode}&` + this._queryParamsToString(query));
301
+ const query = { ...userQuery, langCode };
302
+ const result = await this._fetchGet(`/${this._pathSegment(String(id))}/related?` +
303
+ this._queryParamsToString(query));
299
304
  // Validate response if validation is enabled
300
305
  const validated = await this._validateResponse(result, schema('ProductsResponseSchema'));
301
306
  return this._normalizeData(validated, langCode);
@@ -303,18 +308,18 @@ class ProductsApi extends asyncModules_1.default {
303
308
  /**
304
309
  * Find products by its ids.
305
310
  * @handleName getProductsByIds
306
- * @param {string} ids - Comma-separated IDs of the product pages to fetch. Example: "12345,67890".
311
+ * @param {string} ids - Comma-separated product IDs. Unknown ids are dropped and repeated ones collapsed; a non-numeric one answers `400 Incorrect request`. Example: "12345,67890".
307
312
  * @param {string} [langCode] - Language code. Default: "en_US".
308
313
  * @param {IProductsByIdsQuery} [userQuery] - Optional query parameters.
309
314
  * @example
310
315
  {
311
316
  "limit": 30,
312
317
  "offset": 0,
313
- "signPrice": "orders"
318
+ "signPrice": "my_order"
314
319
  }
315
320
  * @param {number} [userQuery.limit] - Maximum number of records to return. Default: 30.
316
321
  * @param {number} [userQuery.offset] - Number of records to skip. Default: 0.
317
- * @param {string} [userQuery.signPrice] - Marker of the order storage to fix prices for. When set, each product comes with a `signedPrice` that holds the price for a limited time.
322
+ * @param {string} [userQuery.signPrice] - Marker of the order storage to fix prices for. When set, each product comes with a `signedPrice` that holds the price for a limited time. Must be an existing orders storage marker of the project, e.g. "my_order"; a marker with no such storage fails the whole request with `404 Specified orders storage for price signature not found`.
318
323
  * @returns {Promise<IProductsEntity[] | IError>} Array with ProductEntity objects
319
324
  * @throws {IError} When isShell=false and an error occurs during the fetch
320
325
  * @description Find products by its ids.
@@ -324,9 +329,8 @@ class ProductsApi extends asyncModules_1.default {
324
329
  const query = {
325
330
  ids,
326
331
  langCode,
327
- ...userQuery,
328
332
  };
329
- const result = await this._fetchGet(`/ids?` + this._queryParamsToString(query));
333
+ const result = await this._fetchGet(`/ids?` + this._queryParamsToString({ ...userQuery, ...query }));
330
334
  return this._normalizeData(result, langCode);
331
335
  }
332
336
  /**
@@ -334,17 +338,20 @@ class ProductsApi extends asyncModules_1.default {
334
338
  * @handleName getProductById
335
339
  * @param {number} id - Product ID. Example: 12345.
336
340
  * @param {string} [langCode] - Language code. Default: "en_US".
337
- * @param {boolean} [isNormalized] - When `true`, the product is returned in normalized form.
341
+ * @param {boolean} [isNormalized] - Deprecated: the API no longer reads it, the answer is the same with `true`, `false` or without it. Kept for compatibility.
342
+ * @param {string} [signPrice] - Marker of an orders storage to fix the price for. When set, the product comes with a `signedPrice` holding the price for a limited time; an unknown marker fails the request with `404 Specified orders storage for price signature not found`.
338
343
  * @returns {Promise<IProductsEntity | IError>} ProductEntity object.
339
344
  * @throws {IError} When isShell=false and an error occurs during the fetch
340
- * @description Retrieve one product object.
345
+ * @description Retrieve one product object. A product with no translation in `langCode` answers `404 Product not found` — there is no fallback to another language.
341
346
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductById getProductById} documentation.
342
347
  */
343
- async getProductById(id, langCode = this.state.lang, isNormalized) {
348
+ async getProductById(id, langCode = this.state.lang, isNormalized, signPrice) {
344
349
  const query = { langCode };
345
350
  if (isNormalized !== undefined)
346
351
  query.isNormalized = isNormalized;
347
- const result = await this._fetchGet(`/${id}?` + this._queryParamsToString(query));
352
+ if (signPrice !== undefined)
353
+ query.signPrice = signPrice;
354
+ const result = await this._fetchGet(`/${this._pathSegment(String(id))}?` + this._queryParamsToString(query));
348
355
  // Validate response if validation is enabled
349
356
  const validated = await this._validateResponse(result, schema('ProductEntitySchema'));
350
357
  return this._normalizeData(validated, langCode);
@@ -353,27 +360,35 @@ class ProductsApi extends asyncModules_1.default {
353
360
  * Getting a product block object by product id.
354
361
  * @handleName getProductBlockById
355
362
  * @param {number} id - Product ID. Example: 12345.
356
- * @returns {Promise<IProductBlock | IError>} - Product block object.
363
+ * @param {string} [langCode] - Language code. Default: the client's language.
364
+ * @returns {Promise<IProductBlock[] | IError>} - Array of the product's block objects.
357
365
  * @throws {IError} When isShell=false and an error occurs during the fetch
358
366
  * @description Getting a product block object by product id.
359
367
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductBlockById getProductBlockById} documentation.
360
368
  */
361
- async getProductBlockById(id) {
362
- const response = await this._fetchGet(`/${id}/blocks`);
363
- return this._normalizeData(response);
369
+ async getProductBlockById(id, langCode = this.state.lang) {
370
+ // Without langCode the API answered in its default language while the SDK
371
+ // unwrapped the client's one, so blocks stayed keyed by locale
372
+ const response = await this._fetchGet(`/${this._pathSegment(String(id))}/blocks?` +
373
+ this._queryParamsToString({ langCode }));
374
+ return this._normalizeData(response, langCode);
364
375
  }
365
376
  /**
366
377
  * Quick search for product page objects with limited output.
367
378
  * @handleName searchProduct
368
379
  * @param {string} name - Text to search for in product titles (`localizeInfos.title`) in the requested language. Example: "laminat".
369
380
  * @param {string} [langCode] - Language code. Default: "en_US".
381
+ * @param {string} [url] - URL of a catalog page to search within that category. Default: the whole catalog.
382
+ * @param {boolean} [correct] - Correct typos by the project's search dictionary first. The API defaults to `true`; pass `false` to search the query as is.
370
383
  * @returns {Promise<IProductsEntity[] | IProductSearchResult[] | IError>} Array with ProductEntity objects, or an array with short ProductSearchResult cards when the traficLimit config option is enabled
371
384
  * @throws {IError} When isShell=false and an error occurs during the fetch
372
385
  * @description Quick search for product page objects with limited output. The quick search endpoint returns short cards ({ id, title, pageId }); with traficLimit enabled they are returned as is, otherwise full product entities are fetched for the found ids.
373
386
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/searchProduct searchProduct} documentation.
374
387
  */
375
- async searchProduct(name, langCode = this.state.lang) {
376
- const result = await this._fetchGet(`/quick/search?langCode=${encodeURIComponent(langCode)}&name=${encodeURIComponent(name)}`);
388
+ async searchProduct(name, langCode = this.state.lang, url, correct) {
389
+ const extra = (url ? `&url=${encodeURIComponent(url)}` : '') +
390
+ (correct !== undefined ? `&correct=${correct}` : '');
391
+ const result = await this._fetchGet(`/quick/search?langCode=${encodeURIComponent(langCode)}&name=${encodeURIComponent(name)}${extra}`);
377
392
  // Validate response if validation is enabled
378
393
  const searchProducts = (await this._validateResponse(result, schema('ProductSearchResponseSchema')));
379
394
  if (!this.state.traficLimit && Array.isArray(searchProducts)) {
@@ -396,29 +411,25 @@ class ProductsApi extends asyncModules_1.default {
396
411
  /**
397
412
  * Getting the number of products for the entire catalog.
398
413
  * @handleName getProductsCount
399
- * @param {any[]} body - Filter objects with search conditions. Default: `[]`.
414
+ * @param {any[]} [body] - Filter objects with search conditions. Default: `[]`.
415
+ * @param {string} [langCode] - Language code. Default: "en_US". Must be one of the project's active languages — an inactive one answers `400 langCode must be one of the active languages`. The count reflects the products visible in that language.
400
416
  * @example
401
417
  [
402
418
  {
403
419
  "attributeMarker": "price",
404
- "conditionMarker": "in",
405
- "statusMarker": "status_1",
406
- "conditionValue": {},
407
- "pageUrls": [
408
- "23-laminat-floorwood-maxima"
409
- ],
410
- "title": "Iphone 17 Pro"
420
+ "conditionMarker": "eq",
421
+ "conditionValue": 51
411
422
  }
412
423
  ]
413
424
  * @returns {Promise<IProductsCount | IError>} Object with product items count.
414
425
  * @throws {IError} When isShell=false and an error occurs during the fetch
415
- * @description This method calculates and returns the total number of products present across the entire catalog, optionally applying specified filters.
426
+ * @description This method calculates and returns the total number of products present across the entire catalog, optionally applying specified filters. The request carries `langCode`; it must be an active language of the project, otherwise the API answers `400`.
416
427
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsCount getProductsCount} documentation.
417
428
  */
418
429
  async getProductsCount(
419
430
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
420
- body = []) {
421
- const result = await this._fetchPost(`/all/counts`, body);
431
+ body = [], langCode = this.state.lang) {
432
+ const result = await this._fetchPost(`/all/counts?` + this._queryParamsToString({ langCode }), body);
422
433
  return result;
423
434
  }
424
435
  /**
@@ -426,53 +437,27 @@ class ProductsApi extends asyncModules_1.default {
426
437
  * @handleName getProductsCountByPageId
427
438
  * @param {number | string} id - Page ID. Example: 12345.
428
439
  * @param {any[]} [body] - Filter objects with search conditions. Default: `[]`.
440
+ * @param {string} [langCode] - Language code. Default: "en_US". Must be one of the project's active languages — an inactive one answers `400 langCode must be one of the active languages`. The count reflects the products visible in that language.
429
441
  * @example
430
442
  [
431
443
  {
432
444
  "attributeMarker": "price",
433
- "conditionMarker": "in",
434
- "statusMarker": "status_1",
435
- "conditionValue": {},
436
- "pageUrls": [
437
- "23-laminat-floorwood-maxima"
438
- ],
439
- "title": "Iphone 17 Pro"
445
+ "conditionMarker": "eq",
446
+ "conditionValue": 51
440
447
  }
441
448
  ]
442
449
  * @returns {Promise<IProductsCount | IError>} Object with product items count.
443
450
  * @throws {IError} When isShell=false and an error occurs during the fetch
444
- * @description This method calculates and returns the number of products available on a given catalog page, identified by its page ID, with optional filtering.
451
+ * @description This method calculates and returns the number of products available on a given catalog page, identified by its page ID, with optional filtering. The request carries `langCode`; it must be an active language of the project (an inactive one answers `400`), and the count reflects the products visible in that language.
445
452
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsCountByPageId getProductsCountByPageId} documentation.
446
453
  */
447
454
  async getProductsCountByPageId(id,
448
455
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
449
- body = []) {
450
- const result = await this._fetchPost(`/page/${id}/counts`, body);
456
+ body = [], langCode = this.state.lang) {
457
+ const result = await this._fetchPost(`/page/${this._pathSegment(String(id))}/counts?` +
458
+ this._queryParamsToString({ langCode }), body);
451
459
  return result;
452
460
  }
453
- /**
454
- * Getting the number of products for the catalog page by page url.
455
- * @handleName getProductsCountByPageUrl
456
- * @param {string} url - Page URL.
457
- * @param {any[]} body - Filter objects with search conditions. Default: `[]`.
458
- * @example
459
- [
460
- {
461
- "attributeMarker": "price",
462
- "conditionMarker": "in",
463
- "statusMarker": "status_1",
464
- "conditionValue": {},
465
- "pageUrls": [
466
- "23-laminat-floorwood-maxima"
467
- ],
468
- "title": "Iphone 17 Pro"
469
- }
470
- ]
471
- * @returns {Promise<IProductsCount | IError>} Object with product items count.
472
- * @throws {IError} When isShell=false and an error occurs during the fetch
473
- * @description This method calculates and returns the number of products available on a given catalog page, identified by its URL, with optional filtering.
474
- * @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsCountByPageUrl getProductsCountByPageUrl} documentation.
475
- */
476
461
  /**
477
462
  * Semantic (vector) search for products.
478
463
  * @handleName getProductsByVectorSearch
@@ -495,15 +480,29 @@ class ProductsApi extends asyncModules_1.default {
495
480
  return this._normalizeData(result, langCode);
496
481
  }
497
482
  /**
498
- * Get products by page url.
499
- * @param {string} url - Page URL.
500
- * @param {any[]} body - Request body.
501
- * @returns {IProductsEntity[] | IError} Returns an array of products or an error object.
483
+ * Getting the number of products for the catalog page by page url.
484
+ * @handleName getProductsCountByPageUrl
485
+ * @param {string} url - Page URL. Example: "catalog".
486
+ * @param {any[]} [body] - Filter objects with search conditions. Default: `[]`.
487
+ * @param {string} [langCode] - Language code. Default: "en_US". Must be one of the project's active languages — an inactive one answers `400 langCode must be one of the active languages`. The count reflects the products visible in that language.
488
+ * @example
489
+ [
490
+ {
491
+ "attributeMarker": "price",
492
+ "conditionMarker": "eq",
493
+ "conditionValue": 51
494
+ }
495
+ ]
496
+ * @returns {Promise<IProductsCount | IError>} Object with product items count.
497
+ * @throws {IError} When isShell=false and an error occurs during the fetch
498
+ * @description This method calculates and returns the number of products available on a given catalog page, identified by its URL, with optional filtering. The request carries `langCode`; it must be an active language of the project (an inactive one answers `400`), and the count reflects the products visible in that language.
499
+ * @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsCountByPageUrl getProductsCountByPageUrl} documentation.
502
500
  */
503
501
  async getProductsCountByPageUrl(url,
504
502
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
505
- body = []) {
506
- const result = await this._fetchPost(`/page/url/${url}/counts`, body);
503
+ body = [], langCode = this.state.lang) {
504
+ const result = await this._fetchPost(`/page/url/${this._pathSegments(url)}/counts?` +
505
+ this._queryParamsToString({ langCode }), body);
507
506
  return result;
508
507
  }
509
508
  }