oneentry 1.0.176 → 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 +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 +16 -0
- package/dist/forms-data/formsDataApi.js +32 -5
- 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 +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 +3 -3
- 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 +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 +16 -0
- package/esm/forms-data/formsDataApi.js +32 -5
- 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 +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 +3 -3
- 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
|
@@ -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,17 @@ 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.
|
|
300
304
|
* @returns {Promise<IProductsEntity | IError>} ProductEntity object.
|
|
301
305
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
302
|
-
* @description Retrieve one product object.
|
|
306
|
+
* @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
307
|
* @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductById getProductById} documentation.
|
|
304
308
|
*/
|
|
305
309
|
async getProductById(id, langCode = this.state.lang, isNormalized) {
|
|
306
310
|
const query = { langCode };
|
|
307
311
|
if (isNormalized !== undefined)
|
|
308
312
|
query.isNormalized = isNormalized;
|
|
309
|
-
const result = await this._fetchGet(`/${id}?` + this._queryParamsToString(query));
|
|
313
|
+
const result = await this._fetchGet(`/${this._pathSegment(String(id))}?` + this._queryParamsToString(query));
|
|
310
314
|
// Validate response if validation is enabled
|
|
311
315
|
const validated = await this._validateResponse(result, schema('ProductEntitySchema'));
|
|
312
316
|
return this._normalizeData(validated, langCode);
|
|
@@ -315,14 +319,18 @@ export default class ProductsApi extends AsyncModules {
|
|
|
315
319
|
* Getting a product block object by product id.
|
|
316
320
|
* @handleName getProductBlockById
|
|
317
321
|
* @param {number} id - Product ID. Example: 12345.
|
|
318
|
-
* @
|
|
322
|
+
* @param {string} [langCode] - Language code. Default: the client's language.
|
|
323
|
+
* @returns {Promise<IProductBlock[] | IError>} - Array of the product's block objects.
|
|
319
324
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
320
325
|
* @description Getting a product block object by product id.
|
|
321
326
|
* @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductBlockById getProductBlockById} documentation.
|
|
322
327
|
*/
|
|
323
|
-
async getProductBlockById(id) {
|
|
324
|
-
|
|
325
|
-
|
|
328
|
+
async getProductBlockById(id, langCode = this.state.lang) {
|
|
329
|
+
// Without langCode the API answered in its default language while the SDK
|
|
330
|
+
// unwrapped the client's one, so blocks stayed keyed by locale
|
|
331
|
+
const response = await this._fetchGet(`/${this._pathSegment(String(id))}/blocks?` +
|
|
332
|
+
this._queryParamsToString({ langCode }));
|
|
333
|
+
return this._normalizeData(response, langCode);
|
|
326
334
|
}
|
|
327
335
|
/**
|
|
328
336
|
* Quick search for product page objects with limited output.
|
|
@@ -358,18 +366,13 @@ export default class ProductsApi extends AsyncModules {
|
|
|
358
366
|
/**
|
|
359
367
|
* Getting the number of products for the entire catalog.
|
|
360
368
|
* @handleName getProductsCount
|
|
361
|
-
* @param {any[]} body - Filter objects with search conditions. Default: `[]`.
|
|
369
|
+
* @param {any[]} [body] - Filter objects with search conditions. Default: `[]`.
|
|
362
370
|
* @example
|
|
363
371
|
[
|
|
364
372
|
{
|
|
365
373
|
"attributeMarker": "price",
|
|
366
|
-
"conditionMarker": "
|
|
367
|
-
"
|
|
368
|
-
"conditionValue": {},
|
|
369
|
-
"pageUrls": [
|
|
370
|
-
"23-laminat-floorwood-maxima"
|
|
371
|
-
],
|
|
372
|
-
"title": "Iphone 17 Pro"
|
|
374
|
+
"conditionMarker": "eq",
|
|
375
|
+
"conditionValue": 51
|
|
373
376
|
}
|
|
374
377
|
]
|
|
375
378
|
* @returns {Promise<IProductsCount | IError>} Object with product items count.
|
|
@@ -392,49 +395,21 @@ export default class ProductsApi extends AsyncModules {
|
|
|
392
395
|
[
|
|
393
396
|
{
|
|
394
397
|
"attributeMarker": "price",
|
|
395
|
-
"conditionMarker": "
|
|
396
|
-
"
|
|
397
|
-
"conditionValue": {},
|
|
398
|
-
"pageUrls": [
|
|
399
|
-
"23-laminat-floorwood-maxima"
|
|
400
|
-
],
|
|
401
|
-
"title": "Iphone 17 Pro"
|
|
398
|
+
"conditionMarker": "eq",
|
|
399
|
+
"conditionValue": 51
|
|
402
400
|
}
|
|
403
401
|
]
|
|
404
402
|
* @returns {Promise<IProductsCount | IError>} Object with product items count.
|
|
405
403
|
* @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.
|
|
404
|
+
* @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).
|
|
407
405
|
* @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsCountByPageId getProductsCountByPageId} documentation.
|
|
408
406
|
*/
|
|
409
407
|
async getProductsCountByPageId(id,
|
|
410
408
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
411
409
|
body = []) {
|
|
412
|
-
const result = await this._fetchPost(`/page/${id}/counts`, body);
|
|
410
|
+
const result = await this._fetchPost(`/page/${this._pathSegment(String(id))}/counts`, body);
|
|
413
411
|
return result;
|
|
414
412
|
}
|
|
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
413
|
/**
|
|
439
414
|
* Semantic (vector) search for products.
|
|
440
415
|
* @handleName getProductsByVectorSearch
|
|
@@ -457,15 +432,27 @@ export default class ProductsApi extends AsyncModules {
|
|
|
457
432
|
return this._normalizeData(result, langCode);
|
|
458
433
|
}
|
|
459
434
|
/**
|
|
460
|
-
*
|
|
461
|
-
* @
|
|
462
|
-
* @param {
|
|
463
|
-
* @
|
|
435
|
+
* Getting the number of products for the catalog page by page url.
|
|
436
|
+
* @handleName getProductsCountByPageUrl
|
|
437
|
+
* @param {string} url - Page URL. Example: "catalog".
|
|
438
|
+
* @param {any[]} [body] - Filter objects with search conditions. Default: `[]`.
|
|
439
|
+
* @example
|
|
440
|
+
[
|
|
441
|
+
{
|
|
442
|
+
"attributeMarker": "price",
|
|
443
|
+
"conditionMarker": "eq",
|
|
444
|
+
"conditionValue": 51
|
|
445
|
+
}
|
|
446
|
+
]
|
|
447
|
+
* @returns {Promise<IProductsCount | IError>} Object with product items count.
|
|
448
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
449
|
+
* @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).
|
|
450
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsCountByPageUrl getProductsCountByPageUrl} documentation.
|
|
464
451
|
*/
|
|
465
452
|
async getProductsCountByPageUrl(url,
|
|
466
453
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
467
454
|
body = []) {
|
|
468
|
-
const result = await this._fetchPost(`/page/url/${url}/counts`, body);
|
|
455
|
+
const result = await this._fetchPost(`/page/url/${this._pathSegments(url)}/counts`, body);
|
|
469
456
|
return result;
|
|
470
457
|
}
|
|
471
458
|
}
|
|
@@ -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/esm/search/searchApi.js
CHANGED
|
@@ -22,7 +22,7 @@ export default class SearchApi extends AsyncModules {
|
|
|
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.
|
|
@@ -38,7 +38,8 @@ export default class SearchApi extends AsyncModules {
|
|
|
38
38
|
// without it a word of a second locale answers an empty group (CMS-912).
|
|
39
39
|
const params = {
|
|
40
40
|
q: query,
|
|
41
|
-
types
|
|
41
|
+
// An empty array would go out as `types=` and the API answers no groups
|
|
42
|
+
types: types && types.length > 0 ? types : undefined,
|
|
42
43
|
visibility,
|
|
43
44
|
offset,
|
|
44
45
|
limit,
|
|
@@ -46,6 +47,6 @@ export default class SearchApi extends AsyncModules {
|
|
|
46
47
|
};
|
|
47
48
|
const data = await this._fetchGet(`?` + this._queryParamsToString(params));
|
|
48
49
|
const validated = await this._validateResponse(data, schema('GlobalSearchResponseSchema'));
|
|
49
|
-
return this._normalizeData(validated);
|
|
50
|
+
return this._normalizeData(validated, langCode);
|
|
50
51
|
}
|
|
51
52
|
}
|