oneentry 1.0.175 → 1.0.177
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 +140 -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 +96 -29
- 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 +73 -1
- package/dist/base/asyncModules.js +233 -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 +101 -74
- package/dist/blocks/blocksInterfaces.d.ts +8 -8
- package/dist/discounts/discountsApi.d.ts +9 -7
- package/dist/discounts/discountsApi.js +18 -14
- package/dist/discounts/discountsInterfaces.d.ts +14 -10
- package/dist/events/eventsApi.d.ts +3 -3
- package/dist/events/eventsApi.js +7 -7
- 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 +26 -8
- package/dist/forms-data/formsDataApi.js +45 -14
- package/dist/forms-data/formsDataInterfaces.d.ts +91 -66
- 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 +42 -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 +24 -44
- package/dist/orders/ordersInterfaces.d.ts +21 -14
- package/dist/pages/pagesApi.d.ts +6 -5
- package/dist/pages/pagesApi.js +44 -31
- package/dist/pages/pagesInterfaces.d.ts +18 -15
- 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 +4 -4
- package/dist/product-statuses/productStatusesInterfaces.d.ts +1 -4
- package/dist/products/productsApi.d.ts +38 -58
- package/dist/products/productsApi.js +59 -72
- package/dist/products/productsInterfaces.d.ts +48 -85
- package/dist/search/searchApi.d.ts +1 -1
- package/dist/search/searchApi.js +4 -3
- 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 +96 -29
- 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 +73 -1
- package/esm/base/asyncModules.js +233 -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 +101 -74
- package/esm/blocks/blocksInterfaces.d.ts +8 -8
- package/esm/discounts/discountsApi.d.ts +9 -7
- package/esm/discounts/discountsApi.js +18 -14
- package/esm/discounts/discountsInterfaces.d.ts +14 -10
- package/esm/events/eventsApi.d.ts +3 -3
- package/esm/events/eventsApi.js +7 -7
- 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 +26 -8
- package/esm/forms-data/formsDataApi.js +45 -14
- package/esm/forms-data/formsDataInterfaces.d.ts +91 -66
- 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 +42 -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 +24 -44
- package/esm/orders/ordersInterfaces.d.ts +21 -14
- package/esm/pages/pagesApi.d.ts +6 -5
- package/esm/pages/pagesApi.js +44 -31
- package/esm/pages/pagesInterfaces.d.ts +18 -15
- 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 +4 -4
- package/esm/product-statuses/productStatusesInterfaces.d.ts +1 -4
- package/esm/products/productsApi.d.ts +38 -58
- package/esm/products/productsApi.js +59 -72
- package/esm/products/productsInterfaces.d.ts +48 -85
- package/esm/search/searchApi.d.ts +1 -1
- package/esm/search/searchApi.js +4 -3
- 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,17 @@ 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.
|
|
338
342
|
* @returns {Promise<IProductsEntity | IError>} ProductEntity object.
|
|
339
343
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
340
|
-
* @description Retrieve one product object.
|
|
344
|
+
* @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
345
|
* @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductById getProductById} documentation.
|
|
342
346
|
*/
|
|
343
347
|
async getProductById(id, langCode = this.state.lang, isNormalized) {
|
|
344
348
|
const query = { langCode };
|
|
345
349
|
if (isNormalized !== undefined)
|
|
346
350
|
query.isNormalized = isNormalized;
|
|
347
|
-
const result = await this._fetchGet(`/${id}?` + this._queryParamsToString(query));
|
|
351
|
+
const result = await this._fetchGet(`/${this._pathSegment(String(id))}?` + this._queryParamsToString(query));
|
|
348
352
|
// Validate response if validation is enabled
|
|
349
353
|
const validated = await this._validateResponse(result, schema('ProductEntitySchema'));
|
|
350
354
|
return this._normalizeData(validated, langCode);
|
|
@@ -353,14 +357,18 @@ class ProductsApi extends asyncModules_1.default {
|
|
|
353
357
|
* Getting a product block object by product id.
|
|
354
358
|
* @handleName getProductBlockById
|
|
355
359
|
* @param {number} id - Product ID. Example: 12345.
|
|
356
|
-
* @
|
|
360
|
+
* @param {string} [langCode] - Language code. Default: the client's language.
|
|
361
|
+
* @returns {Promise<IProductBlock[] | IError>} - Array of the product's block objects.
|
|
357
362
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
358
363
|
* @description Getting a product block object by product id.
|
|
359
364
|
* @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductBlockById getProductBlockById} documentation.
|
|
360
365
|
*/
|
|
361
|
-
async getProductBlockById(id) {
|
|
362
|
-
|
|
363
|
-
|
|
366
|
+
async getProductBlockById(id, langCode = this.state.lang) {
|
|
367
|
+
// Without langCode the API answered in its default language while the SDK
|
|
368
|
+
// unwrapped the client's one, so blocks stayed keyed by locale
|
|
369
|
+
const response = await this._fetchGet(`/${this._pathSegment(String(id))}/blocks?` +
|
|
370
|
+
this._queryParamsToString({ langCode }));
|
|
371
|
+
return this._normalizeData(response, langCode);
|
|
364
372
|
}
|
|
365
373
|
/**
|
|
366
374
|
* Quick search for product page objects with limited output.
|
|
@@ -396,18 +404,13 @@ class ProductsApi extends asyncModules_1.default {
|
|
|
396
404
|
/**
|
|
397
405
|
* Getting the number of products for the entire catalog.
|
|
398
406
|
* @handleName getProductsCount
|
|
399
|
-
* @param {any[]} body - Filter objects with search conditions. Default: `[]`.
|
|
407
|
+
* @param {any[]} [body] - Filter objects with search conditions. Default: `[]`.
|
|
400
408
|
* @example
|
|
401
409
|
[
|
|
402
410
|
{
|
|
403
411
|
"attributeMarker": "price",
|
|
404
|
-
"conditionMarker": "
|
|
405
|
-
"
|
|
406
|
-
"conditionValue": {},
|
|
407
|
-
"pageUrls": [
|
|
408
|
-
"23-laminat-floorwood-maxima"
|
|
409
|
-
],
|
|
410
|
-
"title": "Iphone 17 Pro"
|
|
412
|
+
"conditionMarker": "eq",
|
|
413
|
+
"conditionValue": 51
|
|
411
414
|
}
|
|
412
415
|
]
|
|
413
416
|
* @returns {Promise<IProductsCount | IError>} Object with product items count.
|
|
@@ -430,49 +433,21 @@ class ProductsApi extends asyncModules_1.default {
|
|
|
430
433
|
[
|
|
431
434
|
{
|
|
432
435
|
"attributeMarker": "price",
|
|
433
|
-
"conditionMarker": "
|
|
434
|
-
"
|
|
435
|
-
"conditionValue": {},
|
|
436
|
-
"pageUrls": [
|
|
437
|
-
"23-laminat-floorwood-maxima"
|
|
438
|
-
],
|
|
439
|
-
"title": "Iphone 17 Pro"
|
|
436
|
+
"conditionMarker": "eq",
|
|
437
|
+
"conditionValue": 51
|
|
440
438
|
}
|
|
441
439
|
]
|
|
442
440
|
* @returns {Promise<IProductsCount | IError>} Object with product items count.
|
|
443
441
|
* @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.
|
|
442
|
+
* @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 counts do not depend on the language: on a language where the catalog is empty they still count every product (CMS-1201).
|
|
445
443
|
* @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsCountByPageId getProductsCountByPageId} documentation.
|
|
446
444
|
*/
|
|
447
445
|
async getProductsCountByPageId(id,
|
|
448
446
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
449
447
|
body = []) {
|
|
450
|
-
const result = await this._fetchPost(`/page/${id}/counts`, body);
|
|
448
|
+
const result = await this._fetchPost(`/page/${this._pathSegment(String(id))}/counts`, body);
|
|
451
449
|
return result;
|
|
452
450
|
}
|
|
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
451
|
/**
|
|
477
452
|
* Semantic (vector) search for products.
|
|
478
453
|
* @handleName getProductsByVectorSearch
|
|
@@ -495,15 +470,27 @@ class ProductsApi extends asyncModules_1.default {
|
|
|
495
470
|
return this._normalizeData(result, langCode);
|
|
496
471
|
}
|
|
497
472
|
/**
|
|
498
|
-
*
|
|
499
|
-
* @
|
|
500
|
-
* @param {
|
|
501
|
-
* @
|
|
473
|
+
* Getting the number of products for the catalog page by page url.
|
|
474
|
+
* @handleName getProductsCountByPageUrl
|
|
475
|
+
* @param {string} url - Page URL. Example: "catalog".
|
|
476
|
+
* @param {any[]} [body] - Filter objects with search conditions. Default: `[]`.
|
|
477
|
+
* @example
|
|
478
|
+
[
|
|
479
|
+
{
|
|
480
|
+
"attributeMarker": "price",
|
|
481
|
+
"conditionMarker": "eq",
|
|
482
|
+
"conditionValue": 51
|
|
483
|
+
}
|
|
484
|
+
]
|
|
485
|
+
* @returns {Promise<IProductsCount | IError>} Object with product items count.
|
|
486
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
487
|
+
* @description This method calculates and returns the number of products available on a given catalog page, identified by its URL, with optional filtering. The counts do not depend on the language: on a language where the catalog is empty they still count every product (CMS-1201).
|
|
488
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsCountByPageUrl getProductsCountByPageUrl} documentation.
|
|
502
489
|
*/
|
|
503
490
|
async getProductsCountByPageUrl(url,
|
|
504
491
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
505
492
|
body = []) {
|
|
506
|
-
const result = await this._fetchPost(`/page/url/${url}/counts`, body);
|
|
493
|
+
const result = await this._fetchPost(`/page/url/${this._pathSegments(url)}/counts`, body);
|
|
507
494
|
return result;
|
|
508
495
|
}
|
|
509
496
|
}
|
|
@@ -42,7 +42,7 @@ interface IProductsApi {
|
|
|
42
42
|
"offset": 0,
|
|
43
43
|
"sortOrder": "DESC",
|
|
44
44
|
"sortKey": "id",
|
|
45
|
-
"signPrice": "
|
|
45
|
+
"signPrice": "my_order"
|
|
46
46
|
}
|
|
47
47
|
* @returns {IProductsResponse} Array with ProductEntity objects
|
|
48
48
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
@@ -60,7 +60,7 @@ interface IProductsApi {
|
|
|
60
60
|
"offset": 0,
|
|
61
61
|
"sortOrder": "DESC",
|
|
62
62
|
"sortKey": "id",
|
|
63
|
-
"signPrice": "
|
|
63
|
+
"signPrice": "my_order"
|
|
64
64
|
}
|
|
65
65
|
* @returns {Promise<IProductsResponse | IError>} Products without a category: `{ items, total }`, the same container as getProducts.
|
|
66
66
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
@@ -80,7 +80,7 @@ interface IProductsApi {
|
|
|
80
80
|
"offset": 0,
|
|
81
81
|
"sortOrder": "DESC",
|
|
82
82
|
"sortKey": "id",
|
|
83
|
-
"signPrice": "
|
|
83
|
+
"signPrice": "my_order"
|
|
84
84
|
}
|
|
85
85
|
* @returns {IProductsResponse} Array with ProductEntity objects
|
|
86
86
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
@@ -98,7 +98,7 @@ interface IProductsApi {
|
|
|
98
98
|
"limit": 30,
|
|
99
99
|
"offset": 0,
|
|
100
100
|
"sortOrder": "DESC",
|
|
101
|
-
"signPrice": "
|
|
101
|
+
"signPrice": "my_order",
|
|
102
102
|
"statusMarker": "in_stock"
|
|
103
103
|
}
|
|
104
104
|
* @returns {IProductsInfo} Array with ProductInformation objects.
|
|
@@ -119,7 +119,7 @@ interface IProductsApi {
|
|
|
119
119
|
"offset": 0,
|
|
120
120
|
"sortOrder": "DESC",
|
|
121
121
|
"sortKey": "id",
|
|
122
|
-
"signPrice": "
|
|
122
|
+
"signPrice": "my_order"
|
|
123
123
|
}
|
|
124
124
|
* @returns {IProductsResponse} Array with ProductEntity objects.
|
|
125
125
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
@@ -138,7 +138,7 @@ interface IProductsApi {
|
|
|
138
138
|
"offset": 0,
|
|
139
139
|
"sortOrder": "DESC",
|
|
140
140
|
"sortKey": "id",
|
|
141
|
-
"signPrice": "
|
|
141
|
+
"signPrice": "my_order",
|
|
142
142
|
"statusMarker": "in_stock",
|
|
143
143
|
"templateMarker": "template_12345"
|
|
144
144
|
}
|
|
@@ -150,14 +150,14 @@ interface IProductsApi {
|
|
|
150
150
|
/**
|
|
151
151
|
* Find products by its ids.
|
|
152
152
|
* @handleName getProductsByIds
|
|
153
|
-
* @param {string} ids - Comma-separated IDs
|
|
153
|
+
* @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".
|
|
154
154
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
155
155
|
* @param {IProductsByIdsQuery} [userQuery] - Optional query parameters.
|
|
156
156
|
* @example
|
|
157
157
|
{
|
|
158
158
|
"limit": 30,
|
|
159
159
|
"offset": 0,
|
|
160
|
-
"signPrice": "
|
|
160
|
+
"signPrice": "my_order"
|
|
161
161
|
}
|
|
162
162
|
* @returns {IProductsEntity[]} Array with ProductEntity objects
|
|
163
163
|
* @throws {IError} If there is an error during the fetch operation, it will return an error object.
|
|
@@ -169,7 +169,7 @@ interface IProductsApi {
|
|
|
169
169
|
* @handleName getProductById
|
|
170
170
|
* @param {number} id - Product ID. Example: 12345.
|
|
171
171
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
172
|
-
* @param {boolean} [isNormalized] -
|
|
172
|
+
* @param {boolean} [isNormalized] - Deprecated: the API no longer reads it, the answer is the same with `true`, `false` or without it. Kept for compatibility.
|
|
173
173
|
* @returns {IProductsEntity} ProductEntity object.
|
|
174
174
|
* @throws {IError} If there is an error during the fetch operation, it will return an error object.
|
|
175
175
|
* @description This method retrieves one product object.
|
|
@@ -179,11 +179,12 @@ interface IProductsApi {
|
|
|
179
179
|
* Getting a product block object by product id.
|
|
180
180
|
* @handleName getProductBlockById
|
|
181
181
|
* @param {number} id - Product ID. Example: 12345.
|
|
182
|
-
* @
|
|
182
|
+
* @param {string} [langCode] - Language code. Default: the client's language.
|
|
183
|
+
* @returns {IProductBlock[]} Array of the product's block objects.
|
|
183
184
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
184
185
|
* @description This method gets a product block object by product id.
|
|
185
186
|
*/
|
|
186
|
-
getProductBlockById(id: number): Promise<IProductBlock[] | IError>;
|
|
187
|
+
getProductBlockById(id: number, langCode?: string): Promise<IProductBlock[] | IError>;
|
|
187
188
|
/**
|
|
188
189
|
* Quick search for product page objects with limited output.
|
|
189
190
|
* @handleName searchProduct
|
|
@@ -202,23 +203,8 @@ interface IProductsApi {
|
|
|
202
203
|
[
|
|
203
204
|
{
|
|
204
205
|
"attributeMarker": "price",
|
|
205
|
-
"conditionMarker": "
|
|
206
|
-
"
|
|
207
|
-
"conditionValue": {},
|
|
208
|
-
"pageUrls": [
|
|
209
|
-
"23-laminat-floorwood-maxima"
|
|
210
|
-
],
|
|
211
|
-
"title": "Iphone 17 Pro"
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
"attributeMarker": "price",
|
|
215
|
-
"conditionMarker": "in",
|
|
216
|
-
"statusMarker": "status_1",
|
|
217
|
-
"conditionValue": {},
|
|
218
|
-
"pageUrls": [
|
|
219
|
-
"23-laminat-floorwood-maxima"
|
|
220
|
-
],
|
|
221
|
-
"title": "Iphone 17 Pro"
|
|
206
|
+
"conditionMarker": "eq",
|
|
207
|
+
"conditionValue": 51
|
|
222
208
|
}
|
|
223
209
|
]
|
|
224
210
|
* @returns {IProductsCount} Object with product items count.
|
|
@@ -235,23 +221,8 @@ interface IProductsApi {
|
|
|
235
221
|
[
|
|
236
222
|
{
|
|
237
223
|
"attributeMarker": "price",
|
|
238
|
-
"conditionMarker": "
|
|
239
|
-
"
|
|
240
|
-
"conditionValue": {},
|
|
241
|
-
"pageUrls": [
|
|
242
|
-
"23-laminat-floorwood-maxima"
|
|
243
|
-
],
|
|
244
|
-
"title": "Iphone 17 Pro"
|
|
245
|
-
},
|
|
246
|
-
{
|
|
247
|
-
"attributeMarker": "price",
|
|
248
|
-
"conditionMarker": "in",
|
|
249
|
-
"statusMarker": "status_1",
|
|
250
|
-
"conditionValue": {},
|
|
251
|
-
"pageUrls": [
|
|
252
|
-
"23-laminat-floorwood-maxima"
|
|
253
|
-
],
|
|
254
|
-
"title": "Iphone 17 Pro"
|
|
224
|
+
"conditionMarker": "eq",
|
|
225
|
+
"conditionValue": 51
|
|
255
226
|
}
|
|
256
227
|
]
|
|
257
228
|
* @returns {IProductsCount} Object with product items count.
|
|
@@ -263,28 +234,13 @@ interface IProductsApi {
|
|
|
263
234
|
* Getting the number of products on a catalog page by page URL.
|
|
264
235
|
* @handleName getProductsCountByPageUrl
|
|
265
236
|
* @param {string} url - Page URL. Example: "catalog".
|
|
266
|
-
* @param {
|
|
237
|
+
* @param {object[]} [body] - Filter objects with search conditions. Default: `[]`.
|
|
267
238
|
* @example
|
|
268
239
|
[
|
|
269
240
|
{
|
|
270
241
|
"attributeMarker": "price",
|
|
271
|
-
"conditionMarker": "
|
|
272
|
-
"
|
|
273
|
-
"conditionValue": {},
|
|
274
|
-
"pageUrls": [
|
|
275
|
-
"23-laminat-floorwood-maxima"
|
|
276
|
-
],
|
|
277
|
-
"title": "Iphone 17 Pro"
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
"attributeMarker": "price",
|
|
281
|
-
"conditionMarker": "in",
|
|
282
|
-
"statusMarker": "status_1",
|
|
283
|
-
"conditionValue": {},
|
|
284
|
-
"pageUrls": [
|
|
285
|
-
"23-laminat-floorwood-maxima"
|
|
286
|
-
],
|
|
287
|
-
"title": "Iphone 17 Pro"
|
|
242
|
+
"conditionMarker": "eq",
|
|
243
|
+
"conditionValue": 51
|
|
288
244
|
}
|
|
289
245
|
]
|
|
290
246
|
* @returns {IProductsCount} Object with product items count.
|
|
@@ -311,7 +267,7 @@ interface IProductsApi {
|
|
|
311
267
|
* @property {number} limit - Maximum number of records to return. Default: 30.
|
|
312
268
|
* @property {string} sortOrder - Sort order: "DESC" or "ASC". Default: "DESC".
|
|
313
269
|
* @property {string} sortKey - Field to sort by: "id", "position", "title", "date", "price" or "status". Default: null.
|
|
314
|
-
* @property {string} [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.
|
|
270
|
+
* @property {string} [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`.
|
|
315
271
|
* @see {@link https://js-sdk.oneentry.cloud/docs/products/#Fixing-the-price-signPrice Fixing the price} documentation.
|
|
316
272
|
* @description Base query parameters shared by the product listing endpoints (getProducts, getProductsEmptyPage, getProductsByPageId, getProductsByPageUrl): pagination, sorting and price fixing.
|
|
317
273
|
*/
|
|
@@ -342,7 +298,7 @@ interface IProductsRelatedQuery extends IProductsQueryBase {
|
|
|
342
298
|
* @property {number} [offset] - Number of records to skip. Default: 0.
|
|
343
299
|
* @property {number} [limit] - Maximum number of records to return. Default: 30.
|
|
344
300
|
* @property {string} [sortOrder] - Sort order: "DESC" or "ASC". Default: "DESC".
|
|
345
|
-
* @property {string} [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.
|
|
301
|
+
* @property {string} [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`.
|
|
346
302
|
* @property {string | null} [statusMarker] - Marker of the product status. Default: null. Example: "in_stock".
|
|
347
303
|
*/
|
|
348
304
|
type IProductsPriceQuery = Omit<IProductsQueryBase, 'sortKey'> & {
|
|
@@ -352,7 +308,7 @@ type IProductsPriceQuery = Omit<IProductsQueryBase, 'sortKey'> & {
|
|
|
352
308
|
* Query parameters for getProductsByIds: only price fixing — `ids` is passed
|
|
353
309
|
* as a dedicated method argument.
|
|
354
310
|
* @typedef {object} IProductsByIdsQuery
|
|
355
|
-
* @property {string} [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.
|
|
311
|
+
* @property {string} [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`.
|
|
356
312
|
*/
|
|
357
313
|
type IProductsByIdsQuery = Pick<IProductsQueryBase, 'signPrice'>;
|
|
358
314
|
/**
|
|
@@ -389,7 +345,7 @@ interface IFilterParams {
|
|
|
389
345
|
}
|
|
390
346
|
/**
|
|
391
347
|
* @interface IProductAdditional
|
|
392
|
-
* @property {object} prices -
|
|
348
|
+
* @property {object} prices - Price range of the **whole catalogue**, the same on every product: it depends neither on the product nor on the request filter (two products priced 51 and 150 both carry `{ min: 51, max: 180 }`). Use it for the bounds of a price slider, not for a product's own "from–to" price.
|
|
393
349
|
* @property {number} prices.min - Minimum price value. Example: 5.
|
|
394
350
|
* @property {number} prices.max - Maximum price value. Example: 150.
|
|
395
351
|
* @description Additional indexed values attached to a product entity.
|
|
@@ -399,8 +355,8 @@ interface IProductAdditional {
|
|
|
399
355
|
}
|
|
400
356
|
/**
|
|
401
357
|
* @interface IProductPriceRange
|
|
402
|
-
* @property {number} min -
|
|
403
|
-
* @property {number} max -
|
|
358
|
+
* @property {number} min - Lowest price in the catalogue. Example: 5.
|
|
359
|
+
* @property {number} max - Highest price in the catalogue. Example: 150.
|
|
404
360
|
* @description Aggregated price range for a product, computed from all its variants.
|
|
405
361
|
*/
|
|
406
362
|
interface IProductPriceRange {
|
|
@@ -442,14 +398,20 @@ interface IProductPageRef {
|
|
|
442
398
|
}
|
|
443
399
|
* @property {string | null} sku - Product SKU from the search index, or `null`. Example: "SKU_12345".
|
|
444
400
|
* @property {boolean} isSync - Whether the product is indexed. Example: true.
|
|
445
|
-
* @property {IAttributeValues} attributeValues - Attribute values keyed by attribute marker.
|
|
401
|
+
* @property {IAttributeValues} attributeValues - Attribute values keyed by attribute marker (an object, not an array).
|
|
446
402
|
* @example
|
|
447
|
-
|
|
448
|
-
{
|
|
449
|
-
"
|
|
450
|
-
"value": "
|
|
403
|
+
{
|
|
404
|
+
"product-name": {
|
|
405
|
+
"type": "string",
|
|
406
|
+
"value": "Split",
|
|
407
|
+
"position": 0
|
|
408
|
+
},
|
|
409
|
+
"price": {
|
|
410
|
+
"type": "integer",
|
|
411
|
+
"value": 150,
|
|
412
|
+
"position": 1
|
|
451
413
|
}
|
|
452
|
-
|
|
414
|
+
}
|
|
453
415
|
* @property {string[]} categories - URLs of the catalog pages the product belongs to.
|
|
454
416
|
* @example
|
|
455
417
|
[
|
|
@@ -461,7 +423,7 @@ interface IProductPageRef {
|
|
|
461
423
|
* @property {Array<IFormConfig>} [moduleFormConfigs] - Form configurations of the module.
|
|
462
424
|
* @property {IRating} [rating] - Rating data: average value, likes and dislikes, and the calculation method.
|
|
463
425
|
* @property {boolean} [isPositionLocked] - Whether the sorting position is locked. Example: false.
|
|
464
|
-
* @property {number[]} relatedIds - IDs of related products.
|
|
426
|
+
* @property {number[]} [relatedIds] - IDs of related products.
|
|
465
427
|
* @example
|
|
466
428
|
[
|
|
467
429
|
12345,
|
|
@@ -485,7 +447,7 @@ interface IProductPageRef {
|
|
|
485
447
|
"categoryPath": "products"
|
|
486
448
|
}
|
|
487
449
|
]
|
|
488
|
-
* @property {string[]} [blocks] - Markers of the blocks
|
|
450
|
+
* @property {string[]} [blocks] - Markers of the blocks shown on the product page (not the blocks whose selection includes the product).
|
|
489
451
|
* @example
|
|
490
452
|
[
|
|
491
453
|
"block_12345",
|
|
@@ -613,19 +575,20 @@ interface IProductInfo {
|
|
|
613
575
|
* @property {number} version - Version number of the product block. Example: 1.
|
|
614
576
|
* @property {number} position - Position of the product block in a list or layout. Example: 1.
|
|
615
577
|
* @property {string} identifier - Marker of the product block. Example: "product_block_12345".
|
|
616
|
-
* @property {BlockType} type - Block type. Example: "
|
|
578
|
+
* @property {BlockType} type - Block type. Example: "product_block".
|
|
617
579
|
* @property {object} customSettings - Custom settings of the product block: slider delay, product configuration, similar-product rules and conditions. Example: {}
|
|
618
580
|
* @property {string | null} templateIdentifier - Marker of the template used by the product block, or `null`. Example: "template_12345".
|
|
619
581
|
* @property {boolean} isVisible - Whether the product block is visible. Example: true.
|
|
620
582
|
* @property {boolean} isSync - Whether the product block is synchronized. Example: false.
|
|
621
|
-
* @property {IAttributeValues} attributeValues - Attribute values keyed by attribute marker.
|
|
583
|
+
* @property {IAttributeValues} attributeValues - Attribute values keyed by attribute marker (an object, not an array); `{}` when the block has no attributes.
|
|
622
584
|
* @example
|
|
623
|
-
|
|
624
|
-
{
|
|
625
|
-
"
|
|
626
|
-
"value": "
|
|
585
|
+
{
|
|
586
|
+
"block-text": {
|
|
587
|
+
"type": "string",
|
|
588
|
+
"value": "Similar products",
|
|
589
|
+
"position": 0
|
|
627
590
|
}
|
|
628
|
-
|
|
591
|
+
}
|
|
629
592
|
* @description This interface defines the structure of a product block entity, including its identifiers, attributes, and custom settings.
|
|
630
593
|
*/
|
|
631
594
|
/**
|
|
@@ -725,4 +688,4 @@ interface IVectorSearchProducts {
|
|
|
725
688
|
maxHits?: number;
|
|
726
689
|
debug?: boolean;
|
|
727
690
|
}
|
|
728
|
-
export type { IAggregatedProductGroup, IFilterParams, IProductBlock, IProductInfo, IProductsApi, IProductsByIdsQuery, IProductsCount, IProductSearchResult, IProductsEntity, IProductsInfo, IProductsPriceQuery, IProductsQuery, IProductsQueryBase, IProductsRelatedQuery, IProductsResponse, IVectorSearchProducts, };
|
|
691
|
+
export type { IAggregatedProductGroup, IFilterParams, IProductAdditional, IProductBlock, IProductBlockProductConfig, IProductBlockSettings, IProductBlockSimilarRule, IProductInfo, IProductPageRef, IProductPriceRange, IProductsApi, IProductsByIdsQuery, IProductsCount, IProductSearchResult, IProductsEntity, IProductsInfo, IProductsPriceQuery, IProductsQuery, IProductsQueryBase, IProductsRelatedQuery, IProductsResponse, IVectorSearchProducts, };
|
|
@@ -22,7 +22,7 @@ export default class SearchApi extends AsyncModules implements ISearchApi {
|
|
|
22
22
|
* Public search across titles and attribute values of visible records.
|
|
23
23
|
* @handleName globalSearch
|
|
24
24
|
* @param {string} query - Search query. Example: "winter".
|
|
25
|
-
* @param {TGlobalSearchEntityType[]} [types] - Entity types to search in, sent comma-separated. Searches every type when omitted.
|
|
25
|
+
* @param {TGlobalSearchEntityType[]} [types] - Entity types to search in, sent comma-separated. Searches every type when omitted or empty.
|
|
26
26
|
* @param {'all' | 'visible' | 'hidden'} [visibility] - Visibility filter of the searched records. Default: "all".
|
|
27
27
|
* @param {number} [offset] - Offset for drilldown mode. Pass it only together with exactly one accessible type in `types`.
|
|
28
28
|
* @param {number} [limit] - Page size for drilldown mode. Pass it only together with exactly one accessible type in `types`; otherwise the API responds with `400 Drilldown mode (limit/offset) requires exactly one accessible type in types`. Without it, every group is returned in full.
|
package/dist/search/searchApi.js
CHANGED
|
@@ -60,7 +60,7 @@ class SearchApi extends asyncModules_1.default {
|
|
|
60
60
|
* Public search across titles and attribute values of visible records.
|
|
61
61
|
* @handleName globalSearch
|
|
62
62
|
* @param {string} query - Search query. Example: "winter".
|
|
63
|
-
* @param {TGlobalSearchEntityType[]} [types] - Entity types to search in, sent comma-separated. Searches every type when omitted.
|
|
63
|
+
* @param {TGlobalSearchEntityType[]} [types] - Entity types to search in, sent comma-separated. Searches every type when omitted or empty.
|
|
64
64
|
* @param {'all' | 'visible' | 'hidden'} [visibility] - Visibility filter of the searched records. Default: "all".
|
|
65
65
|
* @param {number} [offset] - Offset for drilldown mode. Pass it only together with exactly one accessible type in `types`.
|
|
66
66
|
* @param {number} [limit] - Page size for drilldown mode. Pass it only together with exactly one accessible type in `types`; otherwise the API responds with `400 Drilldown mode (limit/offset) requires exactly one accessible type in types`. Without it, every group is returned in full.
|
|
@@ -76,7 +76,8 @@ class SearchApi extends asyncModules_1.default {
|
|
|
76
76
|
// without it a word of a second locale answers an empty group (CMS-912).
|
|
77
77
|
const params = {
|
|
78
78
|
q: query,
|
|
79
|
-
types
|
|
79
|
+
// An empty array would go out as `types=` and the API answers no groups
|
|
80
|
+
types: types && types.length > 0 ? types : undefined,
|
|
80
81
|
visibility,
|
|
81
82
|
offset,
|
|
82
83
|
limit,
|
|
@@ -84,7 +85,7 @@ class SearchApi extends asyncModules_1.default {
|
|
|
84
85
|
};
|
|
85
86
|
const data = await this._fetchGet(`?` + this._queryParamsToString(params));
|
|
86
87
|
const validated = await this._validateResponse(data, schema('GlobalSearchResponseSchema'));
|
|
87
|
-
return this._normalizeData(validated);
|
|
88
|
+
return this._normalizeData(validated, langCode);
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
exports.default = SearchApi;
|