oneentry 1.0.170 → 1.0.172

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/changelog.md +40 -0
  2. package/dist/admins/adminsApi.d.ts +3 -3
  3. package/dist/admins/adminsApi.js +1 -1
  4. package/dist/admins/adminsInterfaces.d.ts +3 -3
  5. package/dist/base/asyncModules.d.ts +6 -1
  6. package/dist/base/asyncModules.js +9 -1
  7. package/dist/base/utils.d.ts +11 -1
  8. package/dist/blocks/blocksApi.d.ts +1 -1
  9. package/dist/blocks/blocksApi.js +1 -1
  10. package/dist/blocks/blocksInterfaces.d.ts +4 -2
  11. package/dist/discounts/discountsApi.d.ts +3 -3
  12. package/dist/discounts/discountsApi.js +1 -1
  13. package/dist/discounts/discountsInterfaces.d.ts +3 -3
  14. package/dist/events/eventsApi.d.ts +1 -1
  15. package/dist/events/eventsApi.js +1 -2
  16. package/dist/file-uploading/fileUploadingApi.d.ts +1 -1
  17. package/dist/file-uploading/fileUploadingApi.js +4 -3
  18. package/dist/file-uploading/fileUploadingInterfaces.d.ts +1 -1
  19. package/dist/forms-data/formsDataApi.d.ts +28 -4
  20. package/dist/forms-data/formsDataApi.js +66 -15
  21. package/dist/forms-data/formsDataInterfaces.d.ts +13 -9
  22. package/dist/general-types/generalTypesSchemas.d.ts +0 -2
  23. package/dist/general-types/generalTypesSchemas.js +0 -1
  24. package/dist/orders/ordersApi.d.ts +16 -3
  25. package/dist/orders/ordersApi.js +25 -15
  26. package/dist/orders/ordersInterfaces.d.ts +3 -3
  27. package/dist/pages/pagesApi.d.ts +4 -4
  28. package/dist/pages/pagesApi.js +9 -13
  29. package/dist/pages/pagesInterfaces.d.ts +3 -3
  30. package/dist/products/productsApi.d.ts +7 -6
  31. package/dist/products/productsApi.js +6 -3
  32. package/dist/products/productsInterfaces.d.ts +14 -9
  33. package/dist/user-activity/userActivityApi.js +4 -7
  34. package/dist/users/usersApi.d.ts +3 -3
  35. package/dist/users/usersApi.js +1 -1
  36. package/dist/users/usersInterfaces.d.ts +3 -3
  37. package/esm/admins/adminsApi.d.ts +3 -3
  38. package/esm/admins/adminsApi.js +1 -1
  39. package/esm/admins/adminsInterfaces.d.ts +3 -3
  40. package/esm/base/asyncModules.d.ts +6 -1
  41. package/esm/base/asyncModules.js +9 -1
  42. package/esm/base/utils.d.ts +11 -1
  43. package/esm/blocks/blocksApi.d.ts +1 -1
  44. package/esm/blocks/blocksApi.js +1 -1
  45. package/esm/blocks/blocksInterfaces.d.ts +4 -2
  46. package/esm/discounts/discountsApi.d.ts +3 -3
  47. package/esm/discounts/discountsApi.js +1 -1
  48. package/esm/discounts/discountsInterfaces.d.ts +3 -3
  49. package/esm/events/eventsApi.d.ts +1 -1
  50. package/esm/events/eventsApi.js +1 -2
  51. package/esm/file-uploading/fileUploadingApi.d.ts +1 -1
  52. package/esm/file-uploading/fileUploadingApi.js +4 -3
  53. package/esm/file-uploading/fileUploadingInterfaces.d.ts +1 -1
  54. package/esm/forms-data/formsDataApi.d.ts +28 -4
  55. package/esm/forms-data/formsDataApi.js +66 -15
  56. package/esm/forms-data/formsDataInterfaces.d.ts +13 -9
  57. package/esm/general-types/generalTypesSchemas.d.ts +0 -2
  58. package/esm/general-types/generalTypesSchemas.js +0 -1
  59. package/esm/orders/ordersApi.d.ts +16 -3
  60. package/esm/orders/ordersApi.js +25 -15
  61. package/esm/orders/ordersInterfaces.d.ts +3 -3
  62. package/esm/pages/pagesApi.d.ts +4 -4
  63. package/esm/pages/pagesApi.js +9 -13
  64. package/esm/pages/pagesInterfaces.d.ts +3 -3
  65. package/esm/products/productsApi.d.ts +7 -6
  66. package/esm/products/productsApi.js +6 -3
  67. package/esm/products/productsInterfaces.d.ts +14 -9
  68. package/esm/user-activity/userActivityApi.js +4 -7
  69. package/esm/users/usersApi.d.ts +3 -3
  70. package/esm/users/usersApi.js +1 -1
  71. package/esm/users/usersInterfaces.d.ts +3 -3
  72. package/package.json +2 -2
@@ -10,7 +10,6 @@ import { z } from 'zod';
10
10
  export declare const GeneralTypeEntitySchema: z.ZodObject<{
11
11
  id: z.ZodNumber;
12
12
  type: z.ZodEnum<{
13
- none: "none";
14
13
  product: "product";
15
14
  order: "order";
16
15
  form: "form";
@@ -41,7 +40,6 @@ export declare const GeneralTypeEntitySchema: z.ZodObject<{
41
40
  export declare const GeneralTypesResponseSchema: z.ZodArray<z.ZodObject<{
42
41
  id: z.ZodNumber;
43
42
  type: z.ZodEnum<{
44
- none: "none";
45
43
  product: "product";
46
44
  order: "order";
47
45
  form: "form";
@@ -36,7 +36,6 @@ exports.GeneralTypeEntitySchema = zod_1.z.object({
36
36
  'service',
37
37
  'external_page',
38
38
  'discount',
39
- 'none',
40
39
  ]),
41
40
  });
42
41
  /**
@@ -1,6 +1,6 @@
1
1
  import AsyncModules from '../base/asyncModules';
2
2
  import type StateModule from '../base/stateModule';
3
- import type { IError } from '../base/utils';
3
+ import type { IError, IVectorSearchResponse } from '../base/utils';
4
4
  import type { IBaseOrdersEntity, ICreateOrderPreview, ICreateRefundRequest, IOrderByMarkerEntity, IOrderData, IOrderPreviewResponse, IOrdersApi, IOrdersByMarkerEntity, IOrdersEntity, IOrderStatus, IOrdersVectorSearch, IRefundRequest } from './ordersInterfaces';
5
5
  /**
6
6
  * Controllers for working with orders.
@@ -204,13 +204,13 @@ export default class OrdersApi extends AsyncModules implements IOrdersApi {
204
204
  * @param {string} [langCode] - Language code. Default: "en_US".
205
205
  * @param {number} [offset] - Parameter for pagination. Default: 0.
206
206
  * @param {number} [limit] - Parameter for pagination. Default: 30.
207
- * @returns {Promise<IOrdersByMarkerEntity | IError>} Returns an object with an array of found orders and total count.
207
+ * @returns {Promise<IVectorSearchResponse<IOrdersByMarkerEntity> | IError>} Returns an object with an array of found orders and total count.
208
208
  * @throws {IError} When isShell=false and an error occurs during the fetch
209
209
  * @description This method performs a semantic (vector) search over the orders of the authorized user. It requires user authorization.
210
210
  * @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
211
211
  * @see {@link https://js-sdk.oneentry.cloud/docs/orders/getOrdersByVectorSearch getOrdersByVectorSearch} documentation.
212
212
  */
213
- getOrdersByVectorSearch(body: IOrdersVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IOrdersByMarkerEntity | IError>;
213
+ getOrdersByVectorSearch(body: IOrdersVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IVectorSearchResponse<IOrdersByMarkerEntity> | IError>;
214
214
  /**
215
215
  * Runs a fetch against the `/orders` base URL instead of the default
216
216
  * `/orders-storage`, then restores the original URL.
@@ -224,4 +224,17 @@ export default class OrdersApi extends AsyncModules implements IOrdersApi {
224
224
  * @template T
225
225
  */
226
226
  private _withOrdersUrl;
227
+ /**
228
+ * Builds the order body the API expects: `formData` wrapped in a map keyed by locale.
229
+ *
230
+ * The wrapping is done on a copy. Writing it back into the caller's object made
231
+ * a reused body — a retry, a shared template — arrive wrapped twice: `createOrder`
232
+ * answered `400 formData's marker '#0' marker is required`, and
233
+ * `updateOrderByMarkerAndId` answered `200` and stored the broken `formData` in
234
+ * the order (CMS-1063).
235
+ * @param {IOrderData} body - Order body as the caller passed it. Left unchanged.
236
+ * @param {string} langCode - Locale key to wrap `formData` into.
237
+ * @returns {object} A new body with `formData` as `{ [langCode]: [...] }`.
238
+ */
239
+ private _wrapOrderFormData;
227
240
  }
@@ -187,13 +187,7 @@ class OrdersApi extends asyncModules_1.default {
187
187
  * @see {@link https://js-sdk.oneentry.cloud/docs/orders/createOrder createOrder} documentation.
188
188
  */
189
189
  async createOrder(marker, body, langCode = this.state.lang) {
190
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
191
- const formData = {};
192
- formData[langCode] = Array.isArray(body.formData)
193
- ? body.formData
194
- : [body.formData];
195
- body.formData = formData;
196
- const result = await this._fetchPost(`/marker/${marker}/orders`, body);
190
+ const result = await this._fetchPost(`/marker/${marker}/orders`, this._wrapOrderFormData(body, langCode));
197
191
  // Validate response if validation is enabled
198
192
  const validated = await this._validateResponse(result, schema('CreateOrderResponseSchema'));
199
193
  return this._normalizeData(validated);
@@ -229,13 +223,7 @@ class OrdersApi extends asyncModules_1.default {
229
223
  * @see {@link https://js-sdk.oneentry.cloud/docs/orders/updateOrderByMarkerAndId updateOrderByMarkerAndId} documentation.
230
224
  */
231
225
  async updateOrderByMarkerAndId(marker, id, body, langCode = this.state.lang) {
232
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
233
- const formData = {};
234
- formData[langCode] = Array.isArray(body.formData)
235
- ? body.formData
236
- : [body.formData];
237
- body.formData = formData;
238
- const result = await this._fetchPut(`/marker/${marker}/orders/${id}?langCode=${langCode}`, body);
226
+ const result = await this._fetchPut(`/marker/${marker}/orders/${id}?langCode=${langCode}`, this._wrapOrderFormData(body, langCode));
239
227
  // Validate response if validation is enabled
240
228
  const validated = await this._validateResponse(result, schema('UpdateOrderResponseSchema'));
241
229
  return this._normalizeData(validated);
@@ -305,7 +293,7 @@ class OrdersApi extends asyncModules_1.default {
305
293
  * @param {string} [langCode] - Language code. Default: "en_US".
306
294
  * @param {number} [offset] - Parameter for pagination. Default: 0.
307
295
  * @param {number} [limit] - Parameter for pagination. Default: 30.
308
- * @returns {Promise<IOrdersByMarkerEntity | IError>} Returns an object with an array of found orders and total count.
296
+ * @returns {Promise<IVectorSearchResponse<IOrdersByMarkerEntity> | IError>} Returns an object with an array of found orders and total count.
309
297
  * @throws {IError} When isShell=false and an error occurs during the fetch
310
298
  * @description This method performs a semantic (vector) search over the orders of the authorized user. It requires user authorization.
311
299
  * @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
@@ -342,5 +330,27 @@ class OrdersApi extends asyncModules_1.default {
342
330
  this._url = savedUrl;
343
331
  }
344
332
  }
333
+ /**
334
+ * Builds the order body the API expects: `formData` wrapped in a map keyed by locale.
335
+ *
336
+ * The wrapping is done on a copy. Writing it back into the caller's object made
337
+ * a reused body — a retry, a shared template — arrive wrapped twice: `createOrder`
338
+ * answered `400 formData's marker '#0' marker is required`, and
339
+ * `updateOrderByMarkerAndId` answered `200` and stored the broken `formData` in
340
+ * the order (CMS-1063).
341
+ * @param {IOrderData} body - Order body as the caller passed it. Left unchanged.
342
+ * @param {string} langCode - Locale key to wrap `formData` into.
343
+ * @returns {object} A new body with `formData` as `{ [langCode]: [...] }`.
344
+ */
345
+ _wrapOrderFormData(body, langCode) {
346
+ return {
347
+ ...body,
348
+ formData: {
349
+ [langCode]: Array.isArray(body.formData)
350
+ ? body.formData
351
+ : [body.formData],
352
+ },
353
+ };
354
+ }
345
355
  }
346
356
  exports.default = OrdersApi;
@@ -1,4 +1,4 @@
1
- import type { IError, ILocalizeInfo } from '../base/utils';
1
+ import type { IError, ILocalizeInfo, IVectorSearchResponse } from '../base/utils';
2
2
  /**
3
3
  * @interface IOrdersApi
4
4
  * @description Represents the API for managing orders in the order storage.
@@ -176,10 +176,10 @@ interface IOrdersApi {
176
176
  * @param {string} [langCode] - Language code. Default: "en_US".
177
177
  * @param {number} [offset] - Parameter for pagination. Default: 0.
178
178
  * @param {number} [limit] - Parameter for pagination. Default: 30.
179
- * @returns {Promise<IOrdersByMarkerEntity | IError>} Returns an object with an array of found orders and total count.
179
+ * @returns {Promise<IVectorSearchResponse<IOrdersByMarkerEntity> | IError>} Returns an object with an array of found orders and total count.
180
180
  * @throws {IError} When isShell=false and an error occurs during the fetch
181
181
  */
182
- getOrdersByVectorSearch(body: IOrdersVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IOrdersByMarkerEntity | IError>;
182
+ getOrdersByVectorSearch(body: IOrdersVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IVectorSearchResponse<IOrdersByMarkerEntity> | IError>;
183
183
  }
184
184
  /**
185
185
  * Body for semantic (vector) order search.
@@ -1,6 +1,6 @@
1
1
  import AsyncModules from '../base/asyncModules';
2
2
  import type StateModule from '../base/stateModule';
3
- import type { IError } from '../base/utils';
3
+ import type { IError, IVectorSearchResponse } from '../base/utils';
4
4
  import type { IPagesApi, IPageSearchResult, IPagesEntity, IPagesResponse, IPagesVectorSearch, IPositionBlock } from './pagesInterfaces';
5
5
  /**
6
6
  * Controllers for working with page objects, including catalog pages
@@ -88,7 +88,7 @@ export default class PagesApi extends AsyncModules implements IPagesApi {
88
88
  * @param {string} [langCode] - Language code. Default: "en_US".
89
89
  * @returns {Promise<IPagesEntity[] | IPageSearchResult[] | IError>} Returns found pages as an array of PageEntity objects, an array of short PageSearchResult cards when the traficLimit config option is enabled, or an empty array [] (if there is no data)
90
90
  * @throws {IError} When isShell=false and an error occurs during the fetch
91
- * @description Quick search for page objects with limited output. The quick search endpoint returns short cards ({ id, title }); with traficLimit enabled they are returned as is, otherwise full page entities are fetched for the found ids.
91
+ * @description Quick search for page objects with limited output. The quick search endpoint returns short cards ({ id, title }); with traficLimit enabled they are returned as is, otherwise full page entities are fetched for the found ids. The search runs in `langCode`, and a found page that cannot be loaded in that language is left out of the result.
92
92
  * @see {@link https://js-sdk.oneentry.cloud/docs/pages/searchPage searchPage} documentation.
93
93
  */
94
94
  searchPage(name: string, url?: string, langCode?: string): Promise<IPagesEntity[] | IPageSearchResult[] | IError>;
@@ -99,12 +99,12 @@ export default class PagesApi extends AsyncModules implements IPagesApi {
99
99
  * @param {string} [langCode] - Language code. Default: "en_US".
100
100
  * @param {number} [offset] - Parameter for pagination. Default: 0.
101
101
  * @param {number} [limit] - Parameter for pagination. Default: 30.
102
- * @returns {Promise<IPagesResponse | IError>} Returns an object with an array of found pages and total count.
102
+ * @returns {Promise<IVectorSearchResponse<IPagesResponse> | IError>} Returns an object with an array of found pages and total count.
103
103
  * @throws {IError} When isShell=false and an error occurs during the fetch
104
104
  * @description This method performs a semantic (vector) search for pages.
105
105
  * @see {@link https://js-sdk.oneentry.cloud/docs/pages/getPagesByVectorSearch getPagesByVectorSearch} documentation.
106
106
  */
107
- getPagesByVectorSearch(body: IPagesVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IPagesResponse | IError>;
107
+ getPagesByVectorSearch(body: IPagesVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IVectorSearchResponse<IPagesResponse> | IError>;
108
108
  /**
109
109
  * Add template data to pages
110
110
  * @handleName addTemplateToPages
@@ -220,27 +220,23 @@ class PagesApi extends asyncModules_1.default {
220
220
  * @param {string} [langCode] - Language code. Default: "en_US".
221
221
  * @returns {Promise<IPagesEntity[] | IPageSearchResult[] | IError>} Returns found pages as an array of PageEntity objects, an array of short PageSearchResult cards when the traficLimit config option is enabled, or an empty array [] (if there is no data)
222
222
  * @throws {IError} When isShell=false and an error occurs during the fetch
223
- * @description Quick search for page objects with limited output. The quick search endpoint returns short cards ({ id, title }); with traficLimit enabled they are returned as is, otherwise full page entities are fetched for the found ids.
223
+ * @description Quick search for page objects with limited output. The quick search endpoint returns short cards ({ id, title }); with traficLimit enabled they are returned as is, otherwise full page entities are fetched for the found ids. The search runs in `langCode`, and a found page that cannot be loaded in that language is left out of the result.
224
224
  * @see {@link https://js-sdk.oneentry.cloud/docs/pages/searchPage searchPage} documentation.
225
225
  */
226
226
  async searchPage(name, url, langCode = this.state.lang) {
227
227
  // Fetch data from the server using a GET request to perform a quick search by page name and language code
228
228
  const urlPart = url ? `url=${encodeURIComponent(url)}&` : '';
229
- const searchPages = await this._fetchGet(`/quick/search?${urlPart}lang=${encodeURIComponent(langCode)}&name=${encodeURIComponent(name)}`);
230
- // /quick/search?url=catalog&langCode=en_US&name=cat
229
+ const searchPages = await this._fetchGet(`/quick/search?${urlPart}langCode=${encodeURIComponent(langCode)}&name=${encodeURIComponent(name)}`);
231
230
  // Validate response if validation is enabled
232
231
  const data = (await this._validateResponse(searchPages, schema('PageSearchResponseSchema')));
233
232
  // Check if there is no traffic limit set in the state
234
233
  if (!this.state.traficLimit && Array.isArray(data)) {
235
- // Initialize an empty array to store detailed page information
236
- const pageList = [];
237
- // Use Promise.all to fetch detailed information for each page concurrently
238
- await Promise.all(data.map(async (page) => {
239
- // Fetch detailed page information by page ID and push it to pageList
240
- await this.getPageById(page.id, langCode).then((result) => {
241
- pageList.push(result);
242
- });
243
- }));
234
+ // Fetch detailed information for each page concurrently, keeping the search order
235
+ const fetched = await Promise.all(data.map((page) => this.getPageById(page.id, langCode)));
236
+ // A page the quick search found but getPageById could not load (404 in this
237
+ // language, closed route) is left out: an IError has no place in IPagesEntity[]
238
+ // and broke `page.localizeInfos.title` on the caller's side (CMS-1068)
239
+ const pageList = fetched.filter((page) => !this._isErrorResponse(page));
244
240
  // Add templates to the fetched pages
245
241
  const withTemplate = await this.addTemplateToPages(pageList);
246
242
  // Normalize the data and return it; ensures consistent structure or handles errors
@@ -257,7 +253,7 @@ class PagesApi extends asyncModules_1.default {
257
253
  * @param {string} [langCode] - Language code. Default: "en_US".
258
254
  * @param {number} [offset] - Parameter for pagination. Default: 0.
259
255
  * @param {number} [limit] - Parameter for pagination. Default: 30.
260
- * @returns {Promise<IPagesResponse | IError>} Returns an object with an array of found pages and total count.
256
+ * @returns {Promise<IVectorSearchResponse<IPagesResponse> | IError>} Returns an object with an array of found pages and total count.
261
257
  * @throws {IError} When isShell=false and an error occurs during the fetch
262
258
  * @description This method performs a semantic (vector) search for pages.
263
259
  * @see {@link https://js-sdk.oneentry.cloud/docs/pages/getPagesByVectorSearch getPagesByVectorSearch} documentation.
@@ -1,4 +1,4 @@
1
- import type { IAttributes, IAttributeValues, IError, ILocalizeInfo, IRating, LangType } from '../base/utils';
1
+ import type { IAttributes, IAttributeValues, IError, ILocalizeInfo, IRating, IVectorSearchResponse, LangType } from '../base/utils';
2
2
  import type { BlockType, IBlockEntity } from '../blocks/blocksInterfaces';
3
3
  import type { IFormConfig } from '../forms/formsInterfaces';
4
4
  import type { IProductsEntity, IProductsResponse } from '../products/productsInterfaces';
@@ -84,11 +84,11 @@ interface IPagesApi {
84
84
  * @param {string} [langCode] - Language code. Default: "en_US".
85
85
  * @param {number} [offset] - Parameter for pagination. Default: 0.
86
86
  * @param {number} [limit] - Parameter for pagination. Default: 30.
87
- * @returns {IPagesResponse} A promise that resolves to a pages response (items + total) or an error.
87
+ * @returns {IVectorSearchResponse<IPagesResponse>} A promise that resolves to a pages response (items + total + indexReady) or an error.
88
88
  * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
89
89
  * @description This method performs a semantic (vector) search for pages.
90
90
  */
91
- getPagesByVectorSearch(body: IPagesVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IPagesResponse | IError>;
91
+ getPagesByVectorSearch(body: IPagesVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IVectorSearchResponse<IPagesResponse> | IError>;
92
92
  }
93
93
  /**
94
94
  * Body for semantic (vector) page search.
@@ -1,7 +1,7 @@
1
1
  import AsyncModules from '../base/asyncModules';
2
2
  import type StateModule from '../base/stateModule';
3
- import type { IError } from '../base/utils';
4
- import type { IAggregatedProductGroup, IFilterParams, IProductBlock, IProductsApi, IProductsByIdsQuery, IProductsCount, IProductSearchResult, IProductsEntity, IProductsInfo, IProductsPriceQuery, IProductsQueryBase, IProductsRelatedQuery, IProductsResponse, IVectorSearchProducts } from './productsInterfaces';
3
+ import type { IError, IVectorSearchResponse } from '../base/utils';
4
+ import type { IFilterParams, IProductBlock, IProductsApi, IProductsByIdsQuery, IProductsCount, IProductSearchResult, IProductsEntity, IProductsInfo, IProductsPriceQuery, IProductsQueryBase, IProductsRelatedQuery, IProductsResponse, IVectorSearchProducts } from './productsInterfaces';
5
5
  /**
6
6
  * Controllers for working with product pages
7
7
  * @handle /api/content/products
@@ -77,12 +77,12 @@ export default class ProductsApi extends AsyncModules implements IProductsApi {
77
77
  "sortKey": "id",
78
78
  "signPrice": "orders"
79
79
  }
80
- * @returns {Promise<IAggregatedProductGroup[] | IError>} Array with AggregatedProductGroup objects.
80
+ * @returns {Promise<IProductsResponse | IError>} Products without a category: `{ items, total }`, the same container as getProducts.
81
81
  * @throws {IError} When isShell=false and an error occurs during the fetch
82
82
  * @description Search for all product page objects with pagination (and aggregation) that do not have a category.
83
83
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsEmptyPage getProductsEmptyPage} documentation.
84
84
  */
85
- getProductsEmptyPage(body?: object, langCode?: string, userQuery?: IProductsQueryBase): Promise<IAggregatedProductGroup[] | IError>;
85
+ getProductsEmptyPage(body?: object, langCode?: string, userQuery?: IProductsQueryBase): Promise<IProductsResponse | IError>;
86
86
  /**
87
87
  * Search for all products with pagination for the selected category.
88
88
  * @handleName getProductsByPageId
@@ -213,6 +213,7 @@ export default class ProductsApi extends AsyncModules implements IProductsApi {
213
213
  * @param {number} [userQuery.offset] - Optional parameter for pagination. Default: 0.
214
214
  * @param {string} [userQuery.sortOrder] - Optional sorting order "DESC" | "ASC". Example: "DESC".
215
215
  * @param {string} [userQuery.sortKey] - Optional field to sort by ("id", "title", "date", "price", "position", "status"). Example: "id".
216
+ * @param {string} [userQuery.relationMode] - How relations are computed: "global" (default) or "local", which also requires the product `id` itself to satisfy the template condition. Example: "local".
216
217
  * @returns {Promise<IProductsResponse | IError>} Array with ProductEntity objects
217
218
  * @throws {IError} When isShell=false and an error occurs during the fetch
218
219
  * @description Find all related product page objects.
@@ -350,12 +351,12 @@ export default class ProductsApi extends AsyncModules implements IProductsApi {
350
351
  * @param {string} [langCode] - Language code. Default: "en_US".
351
352
  * @param {number} [offset] - Parameter for pagination. Default: 0.
352
353
  * @param {number} [limit] - Parameter for pagination. Default: 30.
353
- * @returns {Promise<IProductsResponse | IError>} Returns an object with an array of found products and total count.
354
+ * @returns {Promise<IVectorSearchResponse<IProductsResponse> | IError>} Returns an object with an array of found products and total count.
354
355
  * @throws {IError} When isShell=false and an error occurs during the fetch
355
356
  * @description This method performs a semantic (vector) search for products.
356
357
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsByVectorSearch getProductsByVectorSearch} documentation.
357
358
  */
358
- getProductsByVectorSearch(body: IVectorSearchProducts, langCode?: string, offset?: number, limit?: number): Promise<IProductsResponse | IError>;
359
+ getProductsByVectorSearch(body: IVectorSearchProducts, langCode?: string, offset?: number, limit?: number): Promise<IVectorSearchResponse<IProductsResponse> | IError>;
359
360
  /**
360
361
  * Get products by page url.
361
362
  * @param {string} url - Page url.
@@ -125,7 +125,7 @@ class ProductsApi extends asyncModules_1.default {
125
125
  "sortKey": "id",
126
126
  "signPrice": "orders"
127
127
  }
128
- * @returns {Promise<IAggregatedProductGroup[] | IError>} Array with AggregatedProductGroup objects.
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
130
130
  * @description Search for all product page objects with pagination (and aggregation) that do not have a category.
131
131
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsEmptyPage getProductsEmptyPage} documentation.
@@ -133,7 +133,9 @@ class ProductsApi extends asyncModules_1.default {
133
133
  async getProductsEmptyPage(body = {}, langCode = this.state.lang, userQuery) {
134
134
  const query = { ...userQuery, langCode };
135
135
  const result = await this._fetchPost(`/empty-page?` + this._queryParamsToString(query), body);
136
- return this._normalizeData(result);
136
+ // Validate response if validation is enabled
137
+ const validated = await this._validateResponse(result, schema('ProductsResponseSchema'));
138
+ return this._normalizeData(validated, langCode);
137
139
  }
138
140
  /**
139
141
  * Search for all products with pagination for the selected category.
@@ -285,6 +287,7 @@ class ProductsApi extends asyncModules_1.default {
285
287
  * @param {number} [userQuery.offset] - Optional parameter for pagination. Default: 0.
286
288
  * @param {string} [userQuery.sortOrder] - Optional sorting order "DESC" | "ASC". Example: "DESC".
287
289
  * @param {string} [userQuery.sortKey] - Optional field to sort by ("id", "title", "date", "price", "position", "status"). Example: "id".
290
+ * @param {string} [userQuery.relationMode] - How relations are computed: "global" (default) or "local", which also requires the product `id` itself to satisfy the template condition. Example: "local".
288
291
  * @returns {Promise<IProductsResponse | IError>} Array with ProductEntity objects
289
292
  * @throws {IError} When isShell=false and an error occurs during the fetch
290
293
  * @description Find all related product page objects.
@@ -477,7 +480,7 @@ class ProductsApi extends asyncModules_1.default {
477
480
  * @param {string} [langCode] - Language code. Default: "en_US".
478
481
  * @param {number} [offset] - Parameter for pagination. Default: 0.
479
482
  * @param {number} [limit] - Parameter for pagination. Default: 30.
480
- * @returns {Promise<IProductsResponse | IError>} Returns an object with an array of found products and total count.
483
+ * @returns {Promise<IVectorSearchResponse<IProductsResponse> | IError>} Returns an object with an array of found products and total count.
481
484
  * @throws {IError} When isShell=false and an error occurs during the fetch
482
485
  * @description This method performs a semantic (vector) search for products.
483
486
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsByVectorSearch getProductsByVectorSearch} documentation.
@@ -1,4 +1,4 @@
1
- import type { IAttributeValues, IError, ILocalizeInfo, IRating } from '../base/utils';
1
+ import type { IAttributeValues, IError, ILocalizeInfo, IRating, IVectorSearchResponse } from '../base/utils';
2
2
  import type { BlockType } from '../blocks/blocksInterfaces';
3
3
  import type { IFormConfig } from '../forms/formsInterfaces';
4
4
  /**
@@ -62,11 +62,11 @@ interface IProductsApi {
62
62
  "sortKey": "id",
63
63
  "signPrice": "orders"
64
64
  }
65
- * @returns {IProductsResponse} Array with ProductEntity objects.
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.
67
67
  * @description This method searches for all product page objects with pagination that do not have a category.
68
68
  */
69
- getProductsEmptyPage(body?: object, langCode?: string, userQuery?: IProductsQueryBase): Promise<IAggregatedProductGroup[] | IError>;
69
+ getProductsEmptyPage(body?: object, langCode?: string, userQuery?: IProductsQueryBase): Promise<IProductsResponse | IError>;
70
70
  /**
71
71
  * Search for all products with pagination for the selected category.
72
72
  * @handleName getProductsByPageId
@@ -299,18 +299,18 @@ interface IProductsApi {
299
299
  * @param {string} [langCode] - Language code. Default: "en_US".
300
300
  * @param {number} [offset] - Parameter for pagination. Default: 0.
301
301
  * @param {number} [limit] - Parameter for pagination. Default: 30.
302
- * @returns {IProductsResponse} A promise that resolves to a products response (items + total) or an error.
302
+ * @returns {IVectorSearchResponse<IProductsResponse>} A promise that resolves to a products response (items + total + indexReady) or an error.
303
303
  * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
304
304
  * @description This method performs a semantic (vector) search for products.
305
305
  */
306
- getProductsByVectorSearch(body: IVectorSearchProducts, langCode?: string, offset?: number, limit?: number): Promise<IProductsResponse | IError>;
306
+ getProductsByVectorSearch(body: IVectorSearchProducts, langCode?: string, offset?: number, limit?: number): Promise<IVectorSearchResponse<IProductsResponse> | IError>;
307
307
  }
308
308
  /**
309
309
  * @interface IProductsQueryBase
310
310
  * @property {number} offset - Parameter for pagination. Default: 0.
311
311
  * @property {number} limit - Parameter for pagination. Default: 30.
312
312
  * @property {string} sortOrder - Sort order "DESC" | "ASC". Default: "DESC".
313
- * @property {string} sortKey - Field for sorting (default - null). Possible values: "id", "position", "title", "date", "price". Default: null.
313
+ * @property {string} sortKey - Field for sorting (default - null). Possible values: "id", "position", "title", "date", "price", "status". Default: null.
314
314
  * @property {string} [signPrice] - Order storage marker for price fixing. If the parameter is set, the price is fixed for a certain time.
315
315
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/#Fixing-the-price-signPrice Fixing the price} documentation.
316
316
  * @description Base query parameters shared by the product listing endpoints (getProducts, getProductsEmptyPage, getProductsByPageId, getProductsByPageUrl): pagination, sorting and price fixing.
@@ -319,7 +319,7 @@ interface IProductsQueryBase {
319
319
  offset?: number;
320
320
  limit?: number;
321
321
  sortOrder?: 'DESC' | 'ASC' | null;
322
- sortKey?: 'id' | 'position' | 'title' | 'date' | 'price' | null;
322
+ sortKey?: 'id' | 'position' | 'title' | 'date' | 'price' | 'status' | null;
323
323
  signPrice?: string;
324
324
  }
325
325
  /**
@@ -327,11 +327,13 @@ interface IProductsQueryBase {
327
327
  * @augments IProductsQueryBase
328
328
  * @property {string | null} [statusMarker] - Product page status marker, default null. Example: "in_stock".
329
329
  * @property {string | null} [templateMarker] - Product page template marker, default null. Example: "template_12345".
330
- * @description Query parameters for getRelatedProductsById: the base query plus product page status and template markers.
330
+ * @property {string} [relationMode] - How relations are computed: "global" (the default) runs the template's chain of conditions as is; "local" additionally requires the attribute value of the product `id` to satisfy the template condition (same operator, same stored operand) before the products of that step are kept. Example: "local".
331
+ * @description Query parameters for getRelatedProductsById: the base query plus product page status and template markers and the relation mode.
331
332
  */
332
333
  interface IProductsRelatedQuery extends IProductsQueryBase {
333
334
  statusMarker?: string | null;
334
335
  templateMarker?: string | null;
336
+ relationMode?: 'global' | 'local';
335
337
  }
336
338
  /**
337
339
  * Query parameters for getProductsPriceByPageUrl: the base query without
@@ -366,7 +368,7 @@ type IProductsQuery = IProductsQueryBase;
366
368
  /**
367
369
  * @interface IFilterParams
368
370
  * @property {string | null} attributeMarker - The text identifier of the indexed attribute by which values are filtered. Default: null. Example: "color".
369
- * @property {string | null} [conditionMarker] - Id of the filter condition by which the values are filtered. Default: null. Example: "equals".
371
+ * @property {string | null} [conditionMarker] - Id of the filter condition by which the values are filtered. Default: null. Example: "eq".
370
372
  * @property {number | string | null} conditionValue - The value that is being searched for, default null. Example: "new".
371
373
  * @property {string | null} [pageUrl] - Url of the category page object. Example: ["23-laminat-floorwood-maxima"].
372
374
  * @property {string[] | null} [pageUrls] - Url of the category page object. Example: ["23-laminat-floorwood-maxima"].
@@ -694,6 +696,9 @@ interface IProductBlock {
694
696
  }
695
697
  /**
696
698
  * @interface IAggregatedProductGroup
699
+ * @deprecated No method returns this shape: getProductsEmptyPage was declared with it,
700
+ * but the endpoint answers `{ items, total }` — see IProductsResponse (CMS-1065).
701
+ * Kept so that existing imports still compile.
697
702
  * @property {string} attrValue - Attribute value.
698
703
  * @property {IProductsEntity[]} items - Array of product entities.
699
704
  * @property {string[]} productIds - Array of product ids.
@@ -31,13 +31,10 @@ class UserActivityApi extends asyncModules_1.default {
31
31
  * @see {@link https://js-sdk.oneentry.cloud/docs/user-activity/trackUserActivity trackUserActivity} documentation.
32
32
  */
33
33
  async trackUserActivity(body) {
34
- try {
35
- await this._fetchPost(`/track`, body);
36
- return true;
37
- }
38
- catch (e) {
39
- return e;
40
- }
34
+ // The endpoint answers 204: success is the absence of an error. Through
35
+ // _fetchBoolean a 400 comes back as IError instead of `true`, and with
36
+ // isShell=false it is thrown as documented (CMS-1064)
37
+ return this._fetchBoolean(() => this._fetchPost(`/track`, body));
41
38
  }
42
39
  }
43
40
  exports.default = UserActivityApi;
@@ -1,6 +1,6 @@
1
1
  import AsyncModules from '../base/asyncModules';
2
2
  import type StateModule from '../base/stateModule';
3
- import type { IError } from '../base/utils';
3
+ import type { IError, IVectorSearchResponse } from '../base/utils';
4
4
  import type { ICartAddItem, ICartResponse, ICartSet, IUserBody, IUserEntity, IUsersApi, IUsersResponse, IUsersVectorSearch, IWishlistAddItem, IWishlistResponse, IWishlistSet } from './usersInterfaces';
5
5
  /**
6
6
  * Controllers for working with users
@@ -239,11 +239,11 @@ export default class UsersApi extends AsyncModules implements IUsersApi {
239
239
  * @param {string} [langCode] - Language code. Default: "en_US".
240
240
  * @param {number} [offset] - Parameter for pagination. Default: 0.
241
241
  * @param {number} [limit] - Parameter for pagination. Default: 30.
242
- * @returns {Promise<IUsersResponse | IError>} Returns an object with an array of found users and total count.
242
+ * @returns {Promise<IVectorSearchResponse<IUsersResponse> | IError>} Returns an object with an array of found users and total count.
243
243
  * @throws {IError} When isShell=false and an error occurs during the fetch
244
244
  * @description This method performs a semantic (vector) search for users. It requires user authorization.
245
245
  * @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
246
246
  * @see {@link https://js-sdk.oneentry.cloud/docs/users/getUsersByVectorSearch getUsersByVectorSearch} documentation.
247
247
  */
248
- getUsersByVectorSearch(body: IUsersVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IUsersResponse | IError>;
248
+ getUsersByVectorSearch(body: IUsersVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IVectorSearchResponse<IUsersResponse> | IError>;
249
249
  }
@@ -332,7 +332,7 @@ class UsersApi extends asyncModules_1.default {
332
332
  * @param {string} [langCode] - Language code. Default: "en_US".
333
333
  * @param {number} [offset] - Parameter for pagination. Default: 0.
334
334
  * @param {number} [limit] - Parameter for pagination. Default: 30.
335
- * @returns {Promise<IUsersResponse | IError>} Returns an object with an array of found users and total count.
335
+ * @returns {Promise<IVectorSearchResponse<IUsersResponse> | IError>} Returns an object with an array of found users and total count.
336
336
  * @throws {IError} When isShell=false and an error occurs during the fetch
337
337
  * @description This method performs a semantic (vector) search for users. It requires user authorization.
338
338
  * @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
@@ -1,5 +1,5 @@
1
1
  import type { IAuthData, IAuthFormData, INotificationData } from '../auth-provider/authProvidersInterfaces';
2
- import type { IError, IRating } from '../base/utils';
2
+ import type { IError, IRating, IVectorSearchResponse } from '../base/utils';
3
3
  import type { IFormConfig } from '../forms/formsInterfaces';
4
4
  import type { FormDataType } from '../forms-data/formsDataInterfaces';
5
5
  /**
@@ -217,12 +217,12 @@ interface IUsersApi {
217
217
  * @param {string} [langCode] - Language code. Default: "en_US".
218
218
  * @param {number} [offset] - Parameter for pagination. Default: 0.
219
219
  * @param {number} [limit] - Parameter for pagination. Default: 30.
220
- * @returns {Promise<IUsersResponse | IError>} A promise resolving to a users response (items + total), or an error.
220
+ * @returns {Promise<IVectorSearchResponse<IUsersResponse> | IError>} A promise resolving to a users response (items + total), or an error.
221
221
  * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
222
222
  * @description This method performs a semantic (vector) search for users. It requires user authorization.
223
223
  * @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
224
224
  */
225
- getUsersByVectorSearch(body: IUsersVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IUsersResponse | IError>;
225
+ getUsersByVectorSearch(body: IUsersVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IVectorSearchResponse<IUsersResponse> | IError>;
226
226
  }
227
227
  /**
228
228
  * Body for semantic (vector) user search.
@@ -1,6 +1,6 @@
1
1
  import AsyncModules from '../base/asyncModules.js';
2
2
  import type StateModule from '../base/stateModule.js';
3
- import type { IError } from '../base/utils.js';
3
+ import type { IError, IVectorSearchResponse } from '../base/utils.js';
4
4
  import type { IFilterParams } from '../products/productsInterfaces.js';
5
5
  import type { IAdminEntity, IAdmins, IAdminsResponse, IAdminsVectorSearch } from './adminsInterfaces.js';
6
6
  /**
@@ -57,10 +57,10 @@ export default class AdminsApi extends AsyncModules implements IAdmins {
57
57
  * @param {string} [langCode] - Language code. Default: "en_US".
58
58
  * @param {number} [offset] - Parameter for pagination. Default: 0.
59
59
  * @param {number} [limit] - Parameter for pagination. Default: 30.
60
- * @returns {Promise<IAdminsResponse | IError>} Returns an object with an array of found admins and total count.
60
+ * @returns {Promise<IVectorSearchResponse<IAdminsResponse> | IError>} Returns an object with an array of found admins and total count.
61
61
  * @throws {IError} When isShell=false and an error occurs during the fetch
62
62
  * @description This method performs a semantic (vector) search for admins.
63
63
  * @see {@link https://js-sdk.oneentry.cloud/docs/admins/getAdminsByVectorSearch getAdminsByVectorSearch} documentation.
64
64
  */
65
- getAdminsByVectorSearch(body: IAdminsVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IAdminsResponse | IError>;
65
+ getAdminsByVectorSearch(body: IAdminsVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IVectorSearchResponse<IAdminsResponse> | IError>;
66
66
  }
@@ -66,7 +66,7 @@ export default class AdminsApi extends AsyncModules {
66
66
  * @param {string} [langCode] - Language code. Default: "en_US".
67
67
  * @param {number} [offset] - Parameter for pagination. Default: 0.
68
68
  * @param {number} [limit] - Parameter for pagination. Default: 30.
69
- * @returns {Promise<IAdminsResponse | IError>} Returns an object with an array of found admins and total count.
69
+ * @returns {Promise<IVectorSearchResponse<IAdminsResponse> | IError>} Returns an object with an array of found admins and total count.
70
70
  * @throws {IError} When isShell=false and an error occurs during the fetch
71
71
  * @description This method performs a semantic (vector) search for admins.
72
72
  * @see {@link https://js-sdk.oneentry.cloud/docs/admins/getAdminsByVectorSearch getAdminsByVectorSearch} documentation.
@@ -1,4 +1,4 @@
1
- import type { IAttributeValues, IError } from '../base/utils.js';
1
+ import type { IAttributeValues, IError, IVectorSearchResponse } from '../base/utils.js';
2
2
  import type { IFormConfig } from '../forms/formsInterfaces.js';
3
3
  import type { IFilterParams } from '../products/productsInterfaces.js';
4
4
  /**
@@ -40,10 +40,10 @@ interface IAdmins {
40
40
  * @param {string} [langCode] - Language code. Default: "en_US".
41
41
  * @param {number} [offset] - Parameter for pagination. Default: 0.
42
42
  * @param {number} [limit] - Parameter for pagination. Default: 30.
43
- * @returns {IAdminsResponse} Returns an object with an array of found admins and total count.
43
+ * @returns {IVectorSearchResponse<IAdminsResponse>} Returns an object with an array of found admins, total count and indexReady.
44
44
  * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
45
45
  */
46
- getAdminsByVectorSearch(body: IAdminsVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IAdminsResponse | IError>;
46
+ getAdminsByVectorSearch(body: IAdminsVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IVectorSearchResponse<IAdminsResponse> | IError>;
47
47
  }
48
48
  /**
49
49
  * Body for semantic (vector) admin search.
@@ -79,8 +79,13 @@ export default abstract class AsyncModules extends SyncModules {
79
79
  * (the default) browserResponse returns the API error instead of throwing
80
80
  * it, so relying on the catch alone would report every failed call — a 404
81
81
  * from cancelSubscription, a 403 from recoverSubscriptions — as a success.
82
+ *
83
+ * With `isShell` disabled browserResponse throws, and the error is thrown on
84
+ * from here too: returning it would break the `@throws` contract every caller
85
+ * documents, and a `try/catch` around the call would never fire (CMS-1067).
82
86
  * @param {() => Promise<unknown>} request - Thunk performing the fetch call.
83
- * @returns {Promise<boolean | IError>} `true` on success, IError on failure.
87
+ * @returns {Promise<boolean | IError>} `true` on success, IError on failure when isShell=true.
88
+ * @throws {IError} When isShell=false and the request fails.
84
89
  */
85
90
  protected _fetchBoolean(request: () => Promise<unknown>): Promise<boolean | IError>;
86
91
  /**
@@ -130,8 +130,13 @@ export default class AsyncModules extends SyncModules {
130
130
  * (the default) browserResponse returns the API error instead of throwing
131
131
  * it, so relying on the catch alone would report every failed call — a 404
132
132
  * from cancelSubscription, a 403 from recoverSubscriptions — as a success.
133
+ *
134
+ * With `isShell` disabled browserResponse throws, and the error is thrown on
135
+ * from here too: returning it would break the `@throws` contract every caller
136
+ * documents, and a `try/catch` around the call would never fire (CMS-1067).
133
137
  * @param {() => Promise<unknown>} request - Thunk performing the fetch call.
134
- * @returns {Promise<boolean | IError>} `true` on success, IError on failure.
138
+ * @returns {Promise<boolean | IError>} `true` on success, IError on failure when isShell=true.
139
+ * @throws {IError} When isShell=false and the request fails.
135
140
  */
136
141
  async _fetchBoolean(request) {
137
142
  try {
@@ -142,6 +147,9 @@ export default class AsyncModules extends SyncModules {
142
147
  return true;
143
148
  }
144
149
  catch (e) {
150
+ if (!this.state.isShell) {
151
+ throw e;
152
+ }
145
153
  return e;
146
154
  }
147
155
  }