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.
- package/README.md +12 -5
- package/changelog.md +116 -0
- package/dist/admins/adminsApi.js +2 -9
- package/dist/admins/adminsInterfaces.d.ts +5 -5
- package/dist/admins/adminsSchemas.d.ts +4 -4
- package/dist/admins/adminsSchemas.js +2 -2
- package/dist/attribute-sets/attributeSetsApi.d.ts +1 -1
- package/dist/attribute-sets/attributeSetsApi.js +4 -4
- package/dist/attribute-sets/attributeSetsInterfaces.d.ts +65 -14
- package/dist/attribute-sets/attributeSetsSchemas.d.ts +8 -6
- package/dist/attribute-sets/attributeSetsSchemas.js +6 -9
- package/dist/auth-provider/authProviderApi.d.ts +4 -4
- package/dist/auth-provider/authProviderApi.js +90 -23
- package/dist/auth-provider/authProviderSchemas.d.ts +1 -0
- package/dist/auth-provider/authProviderSchemas.js +1 -0
- package/dist/auth-provider/authProvidersInterfaces.d.ts +8 -6
- package/dist/base/asyncModules.d.ts +62 -1
- package/dist/base/asyncModules.js +219 -37
- package/dist/base/stateModule.d.ts +2 -0
- package/dist/base/stateModule.js +22 -12
- package/dist/base/syncModules.d.ts +18 -10
- package/dist/base/syncModules.js +100 -29
- package/dist/base/utils.d.ts +26 -21
- package/dist/base/validation.d.ts +3 -3
- package/dist/base/validation.js +6 -7
- package/dist/blocks/blocksApi.d.ts +20 -17
- package/dist/blocks/blocksApi.js +82 -64
- package/dist/blocks/blocksInterfaces.d.ts +8 -8
- package/dist/discounts/discountsApi.d.ts +9 -7
- package/dist/discounts/discountsApi.js +16 -13
- package/dist/discounts/discountsInterfaces.d.ts +14 -10
- package/dist/events/eventsApi.d.ts +3 -3
- package/dist/events/eventsApi.js +3 -3
- package/dist/events/eventsInterfaces.d.ts +10 -14
- package/dist/file-uploading/fileUploadingApi.d.ts +4 -4
- package/dist/file-uploading/fileUploadingApi.js +13 -5
- package/dist/file-uploading/fileUploadingInterfaces.d.ts +5 -6
- package/dist/filters/filtersApi.js +2 -2
- package/dist/forms/formsApi.js +2 -2
- package/dist/forms/formsInterfaces.d.ts +1 -3
- package/dist/forms/formsSchemas.d.ts +3 -6
- package/dist/forms/formsSchemas.js +2 -4
- package/dist/forms-data/formsDataApi.d.ts +27 -1
- package/dist/forms-data/formsDataApi.js +119 -68
- package/dist/forms-data/formsDataInterfaces.d.ts +17 -13
- package/dist/general-types/generalTypesInterfaces.d.ts +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.js +50 -7
- package/dist/integration-collections/integrationCollectionsApi.d.ts +15 -4
- package/dist/integration-collections/integrationCollectionsApi.js +41 -14
- package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +8 -9
- package/dist/integration-collections/integrationCollectionsSchemas.d.ts +0 -2
- package/dist/integration-collections/integrationCollectionsSchemas.js +0 -1
- package/dist/menus/menusApi.js +1 -1
- package/dist/orders/ordersApi.d.ts +1 -13
- package/dist/orders/ordersApi.js +21 -42
- package/dist/orders/ordersInterfaces.d.ts +21 -14
- package/dist/pages/pagesApi.d.ts +8 -6
- package/dist/pages/pagesApi.js +48 -33
- package/dist/pages/pagesInterfaces.d.ts +20 -16
- package/dist/pages/pagesSchemas.d.ts +0 -3
- package/dist/pages/pagesSchemas.js +0 -1
- package/dist/payments/paymentsApi.d.ts +10 -11
- package/dist/payments/paymentsApi.js +22 -18
- package/dist/payments/paymentsInterfaces.d.ts +12 -14
- package/dist/payments/paymentsSchemas.d.ts +21 -20
- package/dist/payments/paymentsSchemas.js +5 -8
- package/dist/product-statuses/productStatusesApi.d.ts +1 -1
- package/dist/product-statuses/productStatusesApi.js +3 -3
- package/dist/product-statuses/productStatusesInterfaces.d.ts +1 -4
- package/dist/products/productsApi.d.ts +50 -64
- package/dist/products/productsApi.js +79 -80
- package/dist/products/productsInterfaces.d.ts +59 -90
- package/dist/search/searchApi.d.ts +3 -2
- package/dist/search/searchApi.js +7 -4
- package/dist/search/searchInterfaces.d.ts +2 -1
- package/dist/sitemap/sitemapInterfaces.d.ts +10 -6
- package/dist/subscriptions/subscriptionsApi.d.ts +1 -1
- package/dist/subscriptions/subscriptionsApi.js +1 -1
- package/dist/subscriptions/subscriptionsInterfaces.d.ts +1 -1
- package/dist/system/systemApi.d.ts +2 -0
- package/dist/system/systemApi.js +2 -0
- package/dist/system/systemInterfaces.d.ts +2 -0
- package/dist/templates/templatesApi.d.ts +2 -2
- package/dist/templates/templatesApi.js +12 -11
- package/dist/templates/templatesInterfaces.d.ts +2 -2
- package/dist/templates-preview/templatesPreviewApi.js +2 -2
- package/dist/templates-preview/templatesPreviewInterfaces.d.ts +23 -13
- package/dist/templates-preview/templatesPreviewSchemas.d.ts +7 -0
- package/dist/templates-preview/templatesPreviewSchemas.js +2 -0
- package/dist/user-groups/userGroupsApi.js +5 -5
- package/dist/user-groups/userGroupsSchemas.d.ts +4 -4
- package/dist/users/usersApi.d.ts +1 -1
- package/dist/users/usersApi.js +28 -15
- package/dist/users/usersInterfaces.d.ts +2 -9
- package/dist/web-socket/lazySocket.d.ts +6 -5
- package/dist/web-socket/lazySocket.js +212 -15
- package/dist/web-socket/wsApi.d.ts +7 -4
- package/dist/web-socket/wsApi.js +49 -12
- package/dist/web-socket/wsInterfaces.d.ts +41 -4
- package/esm/admins/adminsApi.js +2 -9
- package/esm/admins/adminsInterfaces.d.ts +5 -5
- package/esm/admins/adminsSchemas.d.ts +4 -4
- package/esm/admins/adminsSchemas.js +2 -2
- package/esm/attribute-sets/attributeSetsApi.d.ts +1 -1
- package/esm/attribute-sets/attributeSetsApi.js +4 -4
- package/esm/attribute-sets/attributeSetsInterfaces.d.ts +65 -14
- package/esm/attribute-sets/attributeSetsSchemas.d.ts +8 -6
- package/esm/attribute-sets/attributeSetsSchemas.js +6 -9
- package/esm/auth-provider/authProviderApi.d.ts +4 -4
- package/esm/auth-provider/authProviderApi.js +90 -23
- package/esm/auth-provider/authProviderSchemas.d.ts +1 -0
- package/esm/auth-provider/authProviderSchemas.js +1 -0
- package/esm/auth-provider/authProvidersInterfaces.d.ts +8 -6
- package/esm/base/asyncModules.d.ts +62 -1
- package/esm/base/asyncModules.js +219 -37
- package/esm/base/stateModule.d.ts +2 -0
- package/esm/base/stateModule.js +22 -12
- package/esm/base/syncModules.d.ts +18 -10
- package/esm/base/syncModules.js +99 -29
- package/esm/base/utils.d.ts +26 -21
- package/esm/base/validation.d.ts +3 -3
- package/esm/base/validation.js +6 -7
- package/esm/blocks/blocksApi.d.ts +20 -17
- package/esm/blocks/blocksApi.js +82 -64
- package/esm/blocks/blocksInterfaces.d.ts +8 -8
- package/esm/discounts/discountsApi.d.ts +9 -7
- package/esm/discounts/discountsApi.js +16 -13
- package/esm/discounts/discountsInterfaces.d.ts +14 -10
- package/esm/events/eventsApi.d.ts +3 -3
- package/esm/events/eventsApi.js +3 -3
- package/esm/events/eventsInterfaces.d.ts +10 -14
- package/esm/file-uploading/fileUploadingApi.d.ts +4 -4
- package/esm/file-uploading/fileUploadingApi.js +13 -5
- package/esm/file-uploading/fileUploadingInterfaces.d.ts +5 -6
- package/esm/filters/filtersApi.js +2 -2
- package/esm/forms/formsApi.js +2 -2
- package/esm/forms/formsInterfaces.d.ts +1 -3
- package/esm/forms/formsSchemas.d.ts +3 -6
- package/esm/forms/formsSchemas.js +2 -4
- package/esm/forms-data/formsDataApi.d.ts +27 -1
- package/esm/forms-data/formsDataApi.js +119 -68
- package/esm/forms-data/formsDataInterfaces.d.ts +17 -13
- package/esm/general-types/generalTypesInterfaces.d.ts +1 -1
- package/esm/index.d.ts +7 -6
- package/esm/index.js +50 -7
- package/esm/integration-collections/integrationCollectionsApi.d.ts +15 -4
- package/esm/integration-collections/integrationCollectionsApi.js +41 -14
- package/esm/integration-collections/integrationCollectionsInterfaces.d.ts +8 -9
- package/esm/integration-collections/integrationCollectionsSchemas.d.ts +0 -2
- package/esm/integration-collections/integrationCollectionsSchemas.js +0 -1
- package/esm/menus/menusApi.js +1 -1
- package/esm/orders/ordersApi.d.ts +1 -13
- package/esm/orders/ordersApi.js +21 -42
- package/esm/orders/ordersInterfaces.d.ts +21 -14
- package/esm/pages/pagesApi.d.ts +8 -6
- package/esm/pages/pagesApi.js +48 -33
- package/esm/pages/pagesInterfaces.d.ts +20 -16
- package/esm/pages/pagesSchemas.d.ts +0 -3
- package/esm/pages/pagesSchemas.js +0 -1
- package/esm/payments/paymentsApi.d.ts +10 -11
- package/esm/payments/paymentsApi.js +22 -18
- package/esm/payments/paymentsInterfaces.d.ts +12 -14
- package/esm/payments/paymentsSchemas.d.ts +21 -20
- package/esm/payments/paymentsSchemas.js +5 -8
- package/esm/product-statuses/productStatusesApi.d.ts +1 -1
- package/esm/product-statuses/productStatusesApi.js +3 -3
- package/esm/product-statuses/productStatusesInterfaces.d.ts +1 -4
- package/esm/products/productsApi.d.ts +50 -64
- package/esm/products/productsApi.js +79 -80
- package/esm/products/productsInterfaces.d.ts +59 -90
- package/esm/search/searchApi.d.ts +3 -2
- package/esm/search/searchApi.js +7 -4
- package/esm/search/searchInterfaces.d.ts +2 -1
- package/esm/sitemap/sitemapInterfaces.d.ts +10 -6
- package/esm/subscriptions/subscriptionsApi.d.ts +1 -1
- package/esm/subscriptions/subscriptionsApi.js +1 -1
- package/esm/subscriptions/subscriptionsInterfaces.d.ts +1 -1
- package/esm/system/systemApi.d.ts +2 -0
- package/esm/system/systemApi.js +2 -0
- package/esm/system/systemInterfaces.d.ts +2 -0
- package/esm/templates/templatesApi.d.ts +2 -2
- package/esm/templates/templatesApi.js +11 -10
- package/esm/templates/templatesInterfaces.d.ts +2 -2
- package/esm/templates-preview/templatesPreviewApi.js +2 -2
- package/esm/templates-preview/templatesPreviewInterfaces.d.ts +23 -13
- package/esm/templates-preview/templatesPreviewSchemas.d.ts +7 -0
- package/esm/templates-preview/templatesPreviewSchemas.js +2 -0
- package/esm/user-groups/userGroupsApi.js +5 -5
- package/esm/user-groups/userGroupsSchemas.d.ts +4 -4
- package/esm/users/usersApi.d.ts +1 -1
- package/esm/users/usersApi.js +28 -15
- package/esm/users/usersInterfaces.d.ts +2 -9
- package/esm/web-socket/lazySocket.d.ts +6 -5
- package/esm/web-socket/lazySocket.js +212 -15
- package/esm/web-socket/wsApi.d.ts +7 -4
- package/esm/web-socket/wsApi.js +49 -12
- package/esm/web-socket/wsInterfaces.d.ts +41 -4
- 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": "
|
|
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.
|
|
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": "
|
|
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": "
|
|
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
|
-
|
|
186
|
-
|
|
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": "
|
|
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?` +
|
|
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": "
|
|
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}
|
|
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": "
|
|
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
|
|
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
|
|
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": "
|
|
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] -
|
|
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
|
-
|
|
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
|
-
* @
|
|
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
|
-
|
|
363
|
-
|
|
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
|
|
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": "
|
|
405
|
-
"
|
|
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
|
|
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": "
|
|
434
|
-
"
|
|
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
|
|
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
|
-
*
|
|
499
|
-
* @
|
|
500
|
-
* @param {
|
|
501
|
-
* @
|
|
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
|
|
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
|
}
|