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
|
@@ -53,14 +53,14 @@ export default class ProductsApi extends AsyncModules {
|
|
|
53
53
|
"offset": 0,
|
|
54
54
|
"sortOrder": "DESC",
|
|
55
55
|
"sortKey": "id",
|
|
56
|
-
"signPrice": "
|
|
56
|
+
"signPrice": "my_order"
|
|
57
57
|
}
|
|
58
|
-
* @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.
|
|
58
|
+
* @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`.
|
|
59
59
|
* @see {@link https://js-sdk.oneentry.cloud/docs/products/#Fixing-the-price-signPrice Fixing the price} documentation.
|
|
60
60
|
* @param {string} [userQuery.sortOrder] - Sorting order parameter.
|
|
61
61
|
* @returns {Promise<IProductsResponse | IError>} Products response, or IError when isShell=true
|
|
62
62
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
63
|
-
* @description Fetch products with optional filters and pagination.
|
|
63
|
+
* @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.
|
|
64
64
|
* @see {@link https://js-sdk.oneentry.cloud/docs/products/getProducts getProducts} documentation.
|
|
65
65
|
*/
|
|
66
66
|
async getProducts(body = [], langCode = this.state.lang, userQuery) {
|
|
@@ -85,7 +85,7 @@ export default class ProductsApi extends AsyncModules {
|
|
|
85
85
|
"offset": 0,
|
|
86
86
|
"sortOrder": "DESC",
|
|
87
87
|
"sortKey": "id",
|
|
88
|
-
"signPrice": "
|
|
88
|
+
"signPrice": "my_order"
|
|
89
89
|
}
|
|
90
90
|
* @returns {Promise<IProductsResponse | IError>} Products without a category: `{ items, total }`, the same container as getProducts.
|
|
91
91
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
@@ -136,7 +136,7 @@ export default class ProductsApi extends AsyncModules {
|
|
|
136
136
|
"offset": 0,
|
|
137
137
|
"sortOrder": "DESC",
|
|
138
138
|
"sortKey": "id",
|
|
139
|
-
"signPrice": "
|
|
139
|
+
"signPrice": "my_order"
|
|
140
140
|
}
|
|
141
141
|
* @returns {Promise<IProductsResponse | IError>} Array with ProductEntity objects
|
|
142
142
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
@@ -144,8 +144,11 @@ export default class ProductsApi extends AsyncModules {
|
|
|
144
144
|
* @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsByPageId getProductsByPageId} documentation.
|
|
145
145
|
*/
|
|
146
146
|
async getProductsByPageId(id, body = [], langCode = this.state.lang, userQuery) {
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
// Positional arguments win over the same keys in userQuery; one serializer
|
|
148
|
+
// builds the query, so langCode is encoded and sent once
|
|
149
|
+
const query = { ...userQuery, langCode };
|
|
150
|
+
const result = await this._fetchPost(`/page/${this._pathSegment(String(id))}?` +
|
|
151
|
+
this._queryParamsToString(query), { filter: body });
|
|
149
152
|
// Validate response if validation is enabled
|
|
150
153
|
const validated = await this._validateResponse(result, schema('ProductsResponseSchema'));
|
|
151
154
|
return this._normalizeData(validated, langCode);
|
|
@@ -161,7 +164,7 @@ export default class ProductsApi extends AsyncModules {
|
|
|
161
164
|
"limit": 30,
|
|
162
165
|
"offset": 0,
|
|
163
166
|
"sortOrder": "DESC",
|
|
164
|
-
"signPrice": "
|
|
167
|
+
"signPrice": "my_order",
|
|
165
168
|
"statusMarker": "in_stock"
|
|
166
169
|
}
|
|
167
170
|
* @returns {Promise<IProductsInfo | IError>} Array with ProductInformation objects.
|
|
@@ -174,7 +177,8 @@ export default class ProductsApi extends AsyncModules {
|
|
|
174
177
|
...userQuery,
|
|
175
178
|
langCode,
|
|
176
179
|
};
|
|
177
|
-
const result = await this._fetchGet(`/page/${url}/prices?` +
|
|
180
|
+
const result = await this._fetchGet(`/page/${this._pathSegments(url)}/prices?` +
|
|
181
|
+
this._queryParamsToString(query));
|
|
178
182
|
return result;
|
|
179
183
|
}
|
|
180
184
|
/**
|
|
@@ -214,7 +218,7 @@ export default class ProductsApi extends AsyncModules {
|
|
|
214
218
|
"offset": 0,
|
|
215
219
|
"sortOrder": "DESC",
|
|
216
220
|
"sortKey": "id",
|
|
217
|
-
"signPrice": "
|
|
221
|
+
"signPrice": "my_order"
|
|
218
222
|
}
|
|
219
223
|
* @returns {Promise<IProductsResponse | IError>} Array with ProductEntity objects.
|
|
220
224
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
@@ -222,8 +226,8 @@ export default class ProductsApi extends AsyncModules {
|
|
|
222
226
|
* @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsByPageUrl getProductsByPageUrl} documentation.
|
|
223
227
|
*/
|
|
224
228
|
async getProductsByPageUrl(url, body = [], langCode = this.state.lang, userQuery) {
|
|
225
|
-
const query = { ...userQuery };
|
|
226
|
-
const result = await this._fetchPost(`/page/url/${url}
|
|
229
|
+
const query = { ...userQuery, langCode };
|
|
230
|
+
const result = await this._fetchPost(`/page/url/${this._pathSegments(url)}?` +
|
|
227
231
|
this._queryParamsToString(query), { filter: body });
|
|
228
232
|
// Validate response if validation is enabled
|
|
229
233
|
const validated = await this._validateResponse(result, schema('ProductsResponseSchema'));
|
|
@@ -241,7 +245,7 @@ export default class ProductsApi extends AsyncModules {
|
|
|
241
245
|
"offset": 0,
|
|
242
246
|
"sortOrder": "DESC",
|
|
243
247
|
"sortKey": "id",
|
|
244
|
-
"signPrice": "
|
|
248
|
+
"signPrice": "my_order",
|
|
245
249
|
"statusMarker": "in_stock",
|
|
246
250
|
"templateMarker": "template_12345"
|
|
247
251
|
}
|
|
@@ -256,8 +260,9 @@ export default class ProductsApi extends AsyncModules {
|
|
|
256
260
|
* @see {@link https://js-sdk.oneentry.cloud/docs/products/getRelatedProductsById getRelatedProductsById} documentation.
|
|
257
261
|
*/
|
|
258
262
|
async getRelatedProductsById(id, langCode = this.state.lang, userQuery) {
|
|
259
|
-
const query = { ...userQuery };
|
|
260
|
-
const result = await this._fetchGet(`/${id}/related
|
|
263
|
+
const query = { ...userQuery, langCode };
|
|
264
|
+
const result = await this._fetchGet(`/${this._pathSegment(String(id))}/related?` +
|
|
265
|
+
this._queryParamsToString(query));
|
|
261
266
|
// Validate response if validation is enabled
|
|
262
267
|
const validated = await this._validateResponse(result, schema('ProductsResponseSchema'));
|
|
263
268
|
return this._normalizeData(validated, langCode);
|
|
@@ -265,18 +270,18 @@ export default class ProductsApi extends AsyncModules {
|
|
|
265
270
|
/**
|
|
266
271
|
* Find products by its ids.
|
|
267
272
|
* @handleName getProductsByIds
|
|
268
|
-
* @param {string} ids - Comma-separated IDs
|
|
273
|
+
* @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".
|
|
269
274
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
270
275
|
* @param {IProductsByIdsQuery} [userQuery] - Optional query parameters.
|
|
271
276
|
* @example
|
|
272
277
|
{
|
|
273
278
|
"limit": 30,
|
|
274
279
|
"offset": 0,
|
|
275
|
-
"signPrice": "
|
|
280
|
+
"signPrice": "my_order"
|
|
276
281
|
}
|
|
277
282
|
* @param {number} [userQuery.limit] - Maximum number of records to return. Default: 30.
|
|
278
283
|
* @param {number} [userQuery.offset] - Number of records to skip. Default: 0.
|
|
279
|
-
* @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.
|
|
284
|
+
* @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`.
|
|
280
285
|
* @returns {Promise<IProductsEntity[] | IError>} Array with ProductEntity objects
|
|
281
286
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
282
287
|
* @description Find products by its ids.
|
|
@@ -286,9 +291,8 @@ export default class ProductsApi extends AsyncModules {
|
|
|
286
291
|
const query = {
|
|
287
292
|
ids,
|
|
288
293
|
langCode,
|
|
289
|
-
...userQuery,
|
|
290
294
|
};
|
|
291
|
-
const result = await this._fetchGet(`/ids?` + this._queryParamsToString(query));
|
|
295
|
+
const result = await this._fetchGet(`/ids?` + this._queryParamsToString({ ...userQuery, ...query }));
|
|
292
296
|
return this._normalizeData(result, langCode);
|
|
293
297
|
}
|
|
294
298
|
/**
|
|
@@ -296,17 +300,20 @@ export default class ProductsApi extends AsyncModules {
|
|
|
296
300
|
* @handleName getProductById
|
|
297
301
|
* @param {number} id - Product ID. Example: 12345.
|
|
298
302
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
299
|
-
* @param {boolean} [isNormalized] -
|
|
303
|
+
* @param {boolean} [isNormalized] - Deprecated: the API no longer reads it, the answer is the same with `true`, `false` or without it. Kept for compatibility.
|
|
304
|
+
* @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`.
|
|
300
305
|
* @returns {Promise<IProductsEntity | IError>} ProductEntity object.
|
|
301
306
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
302
|
-
* @description Retrieve one product object.
|
|
307
|
+
* @description Retrieve one product object. A product with no translation in `langCode` answers `404 Product not found` — there is no fallback to another language.
|
|
303
308
|
* @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductById getProductById} documentation.
|
|
304
309
|
*/
|
|
305
|
-
async getProductById(id, langCode = this.state.lang, isNormalized) {
|
|
310
|
+
async getProductById(id, langCode = this.state.lang, isNormalized, signPrice) {
|
|
306
311
|
const query = { langCode };
|
|
307
312
|
if (isNormalized !== undefined)
|
|
308
313
|
query.isNormalized = isNormalized;
|
|
309
|
-
|
|
314
|
+
if (signPrice !== undefined)
|
|
315
|
+
query.signPrice = signPrice;
|
|
316
|
+
const result = await this._fetchGet(`/${this._pathSegment(String(id))}?` + this._queryParamsToString(query));
|
|
310
317
|
// Validate response if validation is enabled
|
|
311
318
|
const validated = await this._validateResponse(result, schema('ProductEntitySchema'));
|
|
312
319
|
return this._normalizeData(validated, langCode);
|
|
@@ -315,27 +322,35 @@ export default class ProductsApi extends AsyncModules {
|
|
|
315
322
|
* Getting a product block object by product id.
|
|
316
323
|
* @handleName getProductBlockById
|
|
317
324
|
* @param {number} id - Product ID. Example: 12345.
|
|
318
|
-
* @
|
|
325
|
+
* @param {string} [langCode] - Language code. Default: the client's language.
|
|
326
|
+
* @returns {Promise<IProductBlock[] | IError>} - Array of the product's block objects.
|
|
319
327
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
320
328
|
* @description Getting a product block object by product id.
|
|
321
329
|
* @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductBlockById getProductBlockById} documentation.
|
|
322
330
|
*/
|
|
323
|
-
async getProductBlockById(id) {
|
|
324
|
-
|
|
325
|
-
|
|
331
|
+
async getProductBlockById(id, langCode = this.state.lang) {
|
|
332
|
+
// Without langCode the API answered in its default language while the SDK
|
|
333
|
+
// unwrapped the client's one, so blocks stayed keyed by locale
|
|
334
|
+
const response = await this._fetchGet(`/${this._pathSegment(String(id))}/blocks?` +
|
|
335
|
+
this._queryParamsToString({ langCode }));
|
|
336
|
+
return this._normalizeData(response, langCode);
|
|
326
337
|
}
|
|
327
338
|
/**
|
|
328
339
|
* Quick search for product page objects with limited output.
|
|
329
340
|
* @handleName searchProduct
|
|
330
341
|
* @param {string} name - Text to search for in product titles (`localizeInfos.title`) in the requested language. Example: "laminat".
|
|
331
342
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
343
|
+
* @param {string} [url] - URL of a catalog page to search within that category. Default: the whole catalog.
|
|
344
|
+
* @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.
|
|
332
345
|
* @returns {Promise<IProductsEntity[] | IProductSearchResult[] | IError>} Array with ProductEntity objects, or an array with short ProductSearchResult cards when the traficLimit config option is enabled
|
|
333
346
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
334
347
|
* @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.
|
|
335
348
|
* @see {@link https://js-sdk.oneentry.cloud/docs/products/searchProduct searchProduct} documentation.
|
|
336
349
|
*/
|
|
337
|
-
async searchProduct(name, langCode = this.state.lang) {
|
|
338
|
-
const
|
|
350
|
+
async searchProduct(name, langCode = this.state.lang, url, correct) {
|
|
351
|
+
const extra = (url ? `&url=${encodeURIComponent(url)}` : '') +
|
|
352
|
+
(correct !== undefined ? `&correct=${correct}` : '');
|
|
353
|
+
const result = await this._fetchGet(`/quick/search?langCode=${encodeURIComponent(langCode)}&name=${encodeURIComponent(name)}${extra}`);
|
|
339
354
|
// Validate response if validation is enabled
|
|
340
355
|
const searchProducts = (await this._validateResponse(result, schema('ProductSearchResponseSchema')));
|
|
341
356
|
if (!this.state.traficLimit && Array.isArray(searchProducts)) {
|
|
@@ -358,29 +373,25 @@ export default class ProductsApi extends AsyncModules {
|
|
|
358
373
|
/**
|
|
359
374
|
* Getting the number of products for the entire catalog.
|
|
360
375
|
* @handleName getProductsCount
|
|
361
|
-
* @param {any[]} body - Filter objects with search conditions. Default: `[]`.
|
|
376
|
+
* @param {any[]} [body] - Filter objects with search conditions. Default: `[]`.
|
|
377
|
+
* @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.
|
|
362
378
|
* @example
|
|
363
379
|
[
|
|
364
380
|
{
|
|
365
381
|
"attributeMarker": "price",
|
|
366
|
-
"conditionMarker": "
|
|
367
|
-
"
|
|
368
|
-
"conditionValue": {},
|
|
369
|
-
"pageUrls": [
|
|
370
|
-
"23-laminat-floorwood-maxima"
|
|
371
|
-
],
|
|
372
|
-
"title": "Iphone 17 Pro"
|
|
382
|
+
"conditionMarker": "eq",
|
|
383
|
+
"conditionValue": 51
|
|
373
384
|
}
|
|
374
385
|
]
|
|
375
386
|
* @returns {Promise<IProductsCount | IError>} Object with product items count.
|
|
376
387
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
377
|
-
* @description This method calculates and returns the total number of products present across the entire catalog, optionally applying specified filters.
|
|
388
|
+
* @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`.
|
|
378
389
|
* @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsCount getProductsCount} documentation.
|
|
379
390
|
*/
|
|
380
391
|
async getProductsCount(
|
|
381
392
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
382
|
-
body = []) {
|
|
383
|
-
const result = await this._fetchPost(`/all/counts
|
|
393
|
+
body = [], langCode = this.state.lang) {
|
|
394
|
+
const result = await this._fetchPost(`/all/counts?` + this._queryParamsToString({ langCode }), body);
|
|
384
395
|
return result;
|
|
385
396
|
}
|
|
386
397
|
/**
|
|
@@ -388,53 +399,27 @@ export default class ProductsApi extends AsyncModules {
|
|
|
388
399
|
* @handleName getProductsCountByPageId
|
|
389
400
|
* @param {number | string} id - Page ID. Example: 12345.
|
|
390
401
|
* @param {any[]} [body] - Filter objects with search conditions. Default: `[]`.
|
|
402
|
+
* @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.
|
|
391
403
|
* @example
|
|
392
404
|
[
|
|
393
405
|
{
|
|
394
406
|
"attributeMarker": "price",
|
|
395
|
-
"conditionMarker": "
|
|
396
|
-
"
|
|
397
|
-
"conditionValue": {},
|
|
398
|
-
"pageUrls": [
|
|
399
|
-
"23-laminat-floorwood-maxima"
|
|
400
|
-
],
|
|
401
|
-
"title": "Iphone 17 Pro"
|
|
407
|
+
"conditionMarker": "eq",
|
|
408
|
+
"conditionValue": 51
|
|
402
409
|
}
|
|
403
410
|
]
|
|
404
411
|
* @returns {Promise<IProductsCount | IError>} Object with product items count.
|
|
405
412
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
406
|
-
* @description This method calculates and returns the number of products available on a given catalog page, identified by its page ID, with optional filtering.
|
|
413
|
+
* @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.
|
|
407
414
|
* @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsCountByPageId getProductsCountByPageId} documentation.
|
|
408
415
|
*/
|
|
409
416
|
async getProductsCountByPageId(id,
|
|
410
417
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
411
|
-
body = []) {
|
|
412
|
-
const result = await this._fetchPost(`/page/${id}/counts
|
|
418
|
+
body = [], langCode = this.state.lang) {
|
|
419
|
+
const result = await this._fetchPost(`/page/${this._pathSegment(String(id))}/counts?` +
|
|
420
|
+
this._queryParamsToString({ langCode }), body);
|
|
413
421
|
return result;
|
|
414
422
|
}
|
|
415
|
-
/**
|
|
416
|
-
* Getting the number of products for the catalog page by page url.
|
|
417
|
-
* @handleName getProductsCountByPageUrl
|
|
418
|
-
* @param {string} url - Page URL.
|
|
419
|
-
* @param {any[]} body - Filter objects with search conditions. Default: `[]`.
|
|
420
|
-
* @example
|
|
421
|
-
[
|
|
422
|
-
{
|
|
423
|
-
"attributeMarker": "price",
|
|
424
|
-
"conditionMarker": "in",
|
|
425
|
-
"statusMarker": "status_1",
|
|
426
|
-
"conditionValue": {},
|
|
427
|
-
"pageUrls": [
|
|
428
|
-
"23-laminat-floorwood-maxima"
|
|
429
|
-
],
|
|
430
|
-
"title": "Iphone 17 Pro"
|
|
431
|
-
}
|
|
432
|
-
]
|
|
433
|
-
* @returns {Promise<IProductsCount | IError>} Object with product items count.
|
|
434
|
-
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
435
|
-
* @description This method calculates and returns the number of products available on a given catalog page, identified by its URL, with optional filtering.
|
|
436
|
-
* @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsCountByPageUrl getProductsCountByPageUrl} documentation.
|
|
437
|
-
*/
|
|
438
423
|
/**
|
|
439
424
|
* Semantic (vector) search for products.
|
|
440
425
|
* @handleName getProductsByVectorSearch
|
|
@@ -457,15 +442,29 @@ export default class ProductsApi extends AsyncModules {
|
|
|
457
442
|
return this._normalizeData(result, langCode);
|
|
458
443
|
}
|
|
459
444
|
/**
|
|
460
|
-
*
|
|
461
|
-
* @
|
|
462
|
-
* @param {
|
|
463
|
-
* @
|
|
445
|
+
* Getting the number of products for the catalog page by page url.
|
|
446
|
+
* @handleName getProductsCountByPageUrl
|
|
447
|
+
* @param {string} url - Page URL. Example: "catalog".
|
|
448
|
+
* @param {any[]} [body] - Filter objects with search conditions. Default: `[]`.
|
|
449
|
+
* @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.
|
|
450
|
+
* @example
|
|
451
|
+
[
|
|
452
|
+
{
|
|
453
|
+
"attributeMarker": "price",
|
|
454
|
+
"conditionMarker": "eq",
|
|
455
|
+
"conditionValue": 51
|
|
456
|
+
}
|
|
457
|
+
]
|
|
458
|
+
* @returns {Promise<IProductsCount | IError>} Object with product items count.
|
|
459
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
460
|
+
* @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.
|
|
461
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsCountByPageUrl getProductsCountByPageUrl} documentation.
|
|
464
462
|
*/
|
|
465
463
|
async getProductsCountByPageUrl(url,
|
|
466
464
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
467
|
-
body = []) {
|
|
468
|
-
const result = await this._fetchPost(`/page/url/${url}/counts
|
|
465
|
+
body = [], langCode = this.state.lang) {
|
|
466
|
+
const result = await this._fetchPost(`/page/url/${this._pathSegments(url)}/counts?` +
|
|
467
|
+
this._queryParamsToString({ langCode }), body);
|
|
469
468
|
return result;
|
|
470
469
|
}
|
|
471
470
|
}
|