oneentry 1.0.171 → 1.0.173

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 (106) hide show
  1. package/changelog.md +53 -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/auth-provider/authProviderApi.d.ts +2 -2
  6. package/dist/auth-provider/authProviderApi.js +2 -2
  7. package/dist/auth-provider/authProvidersInterfaces.d.ts +3 -3
  8. package/dist/base/asyncModules.d.ts +6 -1
  9. package/dist/base/asyncModules.js +9 -1
  10. package/dist/base/utils.d.ts +12 -2
  11. package/dist/blocks/blocksApi.d.ts +1 -1
  12. package/dist/blocks/blocksApi.js +1 -1
  13. package/dist/blocks/blocksInterfaces.d.ts +4 -2
  14. package/dist/discounts/discountsApi.d.ts +3 -3
  15. package/dist/discounts/discountsApi.js +1 -1
  16. package/dist/discounts/discountsInterfaces.d.ts +3 -3
  17. package/dist/events/eventsApi.d.ts +1 -1
  18. package/dist/events/eventsApi.js +1 -2
  19. package/dist/file-uploading/fileUploadingApi.d.ts +11 -11
  20. package/dist/file-uploading/fileUploadingApi.js +12 -14
  21. package/dist/file-uploading/fileUploadingInterfaces.d.ts +15 -15
  22. package/dist/forms-data/formsDataApi.d.ts +4 -4
  23. package/dist/forms-data/formsDataApi.js +24 -17
  24. package/dist/forms-data/formsDataInterfaces.d.ts +3 -3
  25. package/dist/general-types/generalTypesSchemas.d.ts +0 -2
  26. package/dist/general-types/generalTypesSchemas.js +0 -1
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.js +1 -1
  29. package/dist/integration-collections/integrationCollectionsApi.d.ts +12 -16
  30. package/dist/integration-collections/integrationCollectionsApi.js +10 -14
  31. package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +24 -23
  32. package/dist/orders/ordersApi.d.ts +16 -3
  33. package/dist/orders/ordersApi.js +25 -15
  34. package/dist/orders/ordersInterfaces.d.ts +5 -5
  35. package/dist/pages/pagesApi.d.ts +4 -4
  36. package/dist/pages/pagesApi.js +9 -13
  37. package/dist/pages/pagesInterfaces.d.ts +3 -3
  38. package/dist/product-statuses/productStatusesApi.d.ts +2 -2
  39. package/dist/product-statuses/productStatusesApi.js +2 -2
  40. package/dist/product-statuses/productStatusesInterfaces.d.ts +2 -2
  41. package/dist/products/productsApi.d.ts +7 -6
  42. package/dist/products/productsApi.js +6 -3
  43. package/dist/products/productsInterfaces.d.ts +18 -13
  44. package/dist/system/systemApi.d.ts +4 -4
  45. package/dist/system/systemApi.js +2 -2
  46. package/dist/system/systemInterfaces.d.ts +11 -5
  47. package/dist/templates/templatesApi.d.ts +3 -3
  48. package/dist/templates/templatesApi.js +3 -3
  49. package/dist/templates/templatesInterfaces.d.ts +3 -3
  50. package/dist/user-activity/userActivityApi.js +4 -7
  51. package/dist/users/usersApi.d.ts +3 -3
  52. package/dist/users/usersApi.js +1 -1
  53. package/dist/users/usersInterfaces.d.ts +3 -3
  54. package/esm/admins/adminsApi.d.ts +3 -3
  55. package/esm/admins/adminsApi.js +1 -1
  56. package/esm/admins/adminsInterfaces.d.ts +3 -3
  57. package/esm/auth-provider/authProviderApi.d.ts +2 -2
  58. package/esm/auth-provider/authProviderApi.js +2 -2
  59. package/esm/auth-provider/authProvidersInterfaces.d.ts +3 -3
  60. package/esm/base/asyncModules.d.ts +6 -1
  61. package/esm/base/asyncModules.js +9 -1
  62. package/esm/base/utils.d.ts +12 -2
  63. package/esm/blocks/blocksApi.d.ts +1 -1
  64. package/esm/blocks/blocksApi.js +1 -1
  65. package/esm/blocks/blocksInterfaces.d.ts +4 -2
  66. package/esm/discounts/discountsApi.d.ts +3 -3
  67. package/esm/discounts/discountsApi.js +1 -1
  68. package/esm/discounts/discountsInterfaces.d.ts +3 -3
  69. package/esm/events/eventsApi.d.ts +1 -1
  70. package/esm/events/eventsApi.js +1 -2
  71. package/esm/file-uploading/fileUploadingApi.d.ts +11 -11
  72. package/esm/file-uploading/fileUploadingApi.js +12 -14
  73. package/esm/file-uploading/fileUploadingInterfaces.d.ts +15 -15
  74. package/esm/forms-data/formsDataApi.d.ts +4 -4
  75. package/esm/forms-data/formsDataApi.js +24 -17
  76. package/esm/forms-data/formsDataInterfaces.d.ts +3 -3
  77. package/esm/general-types/generalTypesSchemas.d.ts +0 -2
  78. package/esm/general-types/generalTypesSchemas.js +0 -1
  79. package/esm/index.d.ts +1 -1
  80. package/esm/index.js +1 -1
  81. package/esm/integration-collections/integrationCollectionsApi.d.ts +12 -16
  82. package/esm/integration-collections/integrationCollectionsApi.js +10 -14
  83. package/esm/integration-collections/integrationCollectionsInterfaces.d.ts +24 -23
  84. package/esm/orders/ordersApi.d.ts +16 -3
  85. package/esm/orders/ordersApi.js +25 -15
  86. package/esm/orders/ordersInterfaces.d.ts +5 -5
  87. package/esm/pages/pagesApi.d.ts +4 -4
  88. package/esm/pages/pagesApi.js +9 -13
  89. package/esm/pages/pagesInterfaces.d.ts +3 -3
  90. package/esm/product-statuses/productStatusesApi.d.ts +2 -2
  91. package/esm/product-statuses/productStatusesApi.js +2 -2
  92. package/esm/product-statuses/productStatusesInterfaces.d.ts +2 -2
  93. package/esm/products/productsApi.d.ts +7 -6
  94. package/esm/products/productsApi.js +6 -3
  95. package/esm/products/productsInterfaces.d.ts +18 -13
  96. package/esm/system/systemApi.d.ts +4 -4
  97. package/esm/system/systemApi.js +2 -2
  98. package/esm/system/systemInterfaces.d.ts +11 -5
  99. package/esm/templates/templatesApi.d.ts +3 -3
  100. package/esm/templates/templatesApi.js +3 -3
  101. package/esm/templates/templatesInterfaces.d.ts +3 -3
  102. package/esm/user-activity/userActivityApi.js +4 -7
  103. package/esm/users/usersApi.d.ts +3 -3
  104. package/esm/users/usersApi.js +1 -1
  105. package/esm/users/usersInterfaces.d.ts +3 -3
  106. package/package.json +2 -2
@@ -27,18 +27,14 @@ export default class IntegrationCollectionsApi extends AsyncModules {
27
27
  * Get all collections.
28
28
  * @handleName getICollections
29
29
  * @param {string} [langCode] - Language code. Default: "en_US".
30
- * @param {object} [userQuery] - Optional set query parameters.
30
+ * @param {ICollectionsListQuery} [userQuery] - Optional set query parameters.
31
31
  * @example
32
32
  {
33
- "limit": 0,
34
- "offset": 30,
35
- "entityType": "orders",
36
- "entityId": 1
33
+ "limit": 30,
34
+ "offset": 0
37
35
  }
38
- * @param {number} [userQuery.limit] - Optional parameter for pagination. Default: 0.
39
- * @param {number} [userQuery.offset] - Optional parameter for pagination. Default: 30.
40
- * @param {string} [userQuery.entityType] - Entity type. Example: "orders".
41
- * @param {number} [userQuery.entityId] - Entity identifier. Example: 1.
36
+ * @param {number} [userQuery.limit] - Optional parameter for pagination. Default: 30.
37
+ * @param {number} [userQuery.offset] - Optional parameter for pagination. Default: 0.
42
38
  * @returns {Promise<ICollectionEntity[] | IError>} Returns an array of ICollection objects or an error object if there was an issue.
43
39
  * @see {@link https://js-sdk.oneentry.cloud/docs/integration-collections/getICollections getICollections} documentation.
44
40
  */
@@ -70,16 +66,16 @@ export default class IntegrationCollectionsApi extends AsyncModules {
70
66
  * @handleName getICollectionRowsById
71
67
  * @param {number} id - Collection id. Example: 1.
72
68
  * @param {string} [langCode] - Language code. Default: "en_US".
73
- * @param {any} [userQuery] - Optional set query parameters.
69
+ * @param {ICollectionQuery} [userQuery] - Optional set query parameters.
74
70
  * @example
75
71
  {
76
- "limit": 0,
77
- "offset": 30,
72
+ "limit": 30,
73
+ "offset": 0,
78
74
  "entityType": "orders",
79
75
  "entityId": 1
80
76
  }
81
- * @param {number} [userQuery.limit] - Optional parameter for pagination. Default: 0.
82
- * @param {number} [userQuery.offset] - Optional parameter for pagination. Default: 30.
77
+ * @param {number} [userQuery.limit] - Optional parameter for pagination. Default: 30.
78
+ * @param {number} [userQuery.offset] - Optional parameter for pagination. Default: 0.
83
79
  * @param {string} [userQuery.entityType] - Entity type. Example: "orders".
84
80
  * @param {number} [userQuery.entityId] - Entity identifier. Example: 1.
85
81
  * @returns {Promise<ICollectionRowsResponce | IError>} Returns object ItemsWithTotal, where items is an array of requested objects.
@@ -8,23 +8,19 @@ interface ICollectionsApi {
8
8
  * Get all collections.
9
9
  * @handleName getICollections
10
10
  * @param {string} [langCode] - Language code. Default: "en_US".
11
- * @param {ICollectionQuery} [userQuery] - Query parameters.
11
+ * @param {ICollectionsListQuery} [userQuery] - Query parameters.
12
12
  * @example
13
13
  {
14
14
  "limit": 30,
15
- "offset": 0,
16
- "entityType": "orders",
17
- "entityId": 1
15
+ "offset": 0
18
16
  }
19
- * @param {number} [userQuery.limit] - Parameter for pagination. Default: 0.
20
- * @param {number} [userQuery.offset] - Parameter for pagination. Default: 30.
21
- * @param {string} [userQuery.entityType] - Entity type. Example: "orders".
22
- * @param {number} [userQuery.entityId] - Entity identifier. Example: 1.
17
+ * @param {number} [userQuery.limit] - Parameter for pagination. Default: 30.
18
+ * @param {number} [userQuery.offset] - Parameter for pagination. Default: 0.
23
19
  * @returns {ICollectionEntity[]} Returns an array of ICollection objects or an error object if there was an issue.
24
20
  * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
25
21
  * @description This method gets all collections.
26
22
  */
27
- getICollections(langCode?: string, userQuery?: ICollectionQuery): Promise<ICollectionEntity[] | IError>;
23
+ getICollections(langCode?: string, userQuery?: ICollectionsListQuery): Promise<ICollectionEntity[] | IError>;
28
24
  /**
29
25
  * Get a single collection object by id.
30
26
  * @handleName getICollectionById
@@ -205,7 +201,7 @@ interface ICollectionFormData {
205
201
  * Collection form object
206
202
  * @interface ICollectionFormObject
207
203
  * @property {string} formIdentifier - Text identifier (marker) of the form. Example: "collection-form".
208
- * @property {Record<string, ICollectionFormData>} formData - An object where keys are form field markers and values are arrays of ICollectionFormData objects.
204
+ * @property {ICollectionFormData[] | Record<string, ICollectionFormData[]>} formData - Field values: a flat array `[{ marker, type, value }]` (as in the example), or the same array wrapped in a language code — `{ "en_US": [...] }`. The platform stores both; the SDK sends the value as is.
209
205
  * @example
210
206
  [
211
207
  {
@@ -221,9 +217,7 @@ interface ICollectionFormData {
221
217
  */
222
218
  interface ICollectionFormObject {
223
219
  formIdentifier: string;
224
- formData: {
225
- [key: string]: ICollectionFormData[];
226
- };
220
+ formData: ICollectionFormData[] | Record<string, ICollectionFormData[]>;
227
221
  }
228
222
  /**
229
223
  * Collection row object
@@ -301,17 +295,24 @@ interface ICollectionIsValid {
301
295
  valid: boolean;
302
296
  }
303
297
  /**
304
- * Query parameters for collection requests.
298
+ * Query parameters for collection row requests. All of them are optional.
305
299
  * @interface ICollectionQuery
306
- * @property {number} limit - Parameter for pagination. Default: 30.
307
- * @property {number} offset - Parameter for pagination. Default: 0.
308
- * @property {string} entityType - Entity type. Example: "orders".
309
- * @property {number} entityId - Entity identifier. Example: 1.
300
+ * @property {number} [limit] - Parameter for pagination. Default: 30.
301
+ * @property {number} [offset] - Parameter for pagination. Default: 0.
302
+ * @property {string} [entityType] - Entity type. Example: "orders".
303
+ * @property {number} [entityId] - Entity identifier. Example: 1.
310
304
  */
311
305
  interface ICollectionQuery {
312
- limit: number;
313
- offset: number;
314
- entityType: string;
315
- entityId: number;
306
+ limit?: number;
307
+ offset?: number;
308
+ entityType?: string;
309
+ entityId?: number;
316
310
  }
317
- export type { ICollectionEntity, ICollectionFormObject, ICollectionIsValid, ICollectionQuery, ICollectionResponce, ICollectionRow, ICollectionRowsResponce, ICollectionsApi, };
311
+ /**
312
+ * Query parameters for getICollections: pagination only — the collection list takes no entity filter.
313
+ * @typedef {object} ICollectionsListQuery
314
+ * @property {number} [limit] - Parameter for pagination. Default: 30.
315
+ * @property {number} [offset] - Parameter for pagination. Default: 0.
316
+ */
317
+ type ICollectionsListQuery = Pick<ICollectionQuery, 'limit' | 'offset'>;
318
+ export type { ICollectionEntity, ICollectionFormObject, ICollectionIsValid, ICollectionQuery, ICollectionResponce, ICollectionRow, ICollectionRowsResponce, ICollectionsApi, ICollectionsListQuery, };
@@ -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 { IBaseOrdersEntity, ICreateOrderPreview, ICreateRefundRequest, IOrderByMarkerEntity, IOrderData, IOrderPreviewResponse, IOrdersApi, IOrdersByMarkerEntity, IOrdersEntity, IOrderStatus, IOrdersVectorSearch, IRefundRequest } from './ordersInterfaces.js';
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
  }
@@ -149,13 +149,7 @@ export default class OrdersApi extends AsyncModules {
149
149
  * @see {@link https://js-sdk.oneentry.cloud/docs/orders/createOrder createOrder} documentation.
150
150
  */
151
151
  async createOrder(marker, body, langCode = this.state.lang) {
152
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
153
- const formData = {};
154
- formData[langCode] = Array.isArray(body.formData)
155
- ? body.formData
156
- : [body.formData];
157
- body.formData = formData;
158
- const result = await this._fetchPost(`/marker/${marker}/orders`, body);
152
+ const result = await this._fetchPost(`/marker/${marker}/orders`, this._wrapOrderFormData(body, langCode));
159
153
  // Validate response if validation is enabled
160
154
  const validated = await this._validateResponse(result, schema('CreateOrderResponseSchema'));
161
155
  return this._normalizeData(validated);
@@ -191,13 +185,7 @@ export default class OrdersApi extends AsyncModules {
191
185
  * @see {@link https://js-sdk.oneentry.cloud/docs/orders/updateOrderByMarkerAndId updateOrderByMarkerAndId} documentation.
192
186
  */
193
187
  async updateOrderByMarkerAndId(marker, id, body, langCode = this.state.lang) {
194
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
195
- const formData = {};
196
- formData[langCode] = Array.isArray(body.formData)
197
- ? body.formData
198
- : [body.formData];
199
- body.formData = formData;
200
- const result = await this._fetchPut(`/marker/${marker}/orders/${id}?langCode=${langCode}`, body);
188
+ const result = await this._fetchPut(`/marker/${marker}/orders/${id}?langCode=${langCode}`, this._wrapOrderFormData(body, langCode));
201
189
  // Validate response if validation is enabled
202
190
  const validated = await this._validateResponse(result, schema('UpdateOrderResponseSchema'));
203
191
  return this._normalizeData(validated);
@@ -267,7 +255,7 @@ export default class OrdersApi extends AsyncModules {
267
255
  * @param {string} [langCode] - Language code. Default: "en_US".
268
256
  * @param {number} [offset] - Parameter for pagination. Default: 0.
269
257
  * @param {number} [limit] - Parameter for pagination. Default: 30.
270
- * @returns {Promise<IOrdersByMarkerEntity | IError>} Returns an object with an array of found orders and total count.
258
+ * @returns {Promise<IVectorSearchResponse<IOrdersByMarkerEntity> | IError>} Returns an object with an array of found orders and total count.
271
259
  * @throws {IError} When isShell=false and an error occurs during the fetch
272
260
  * @description This method performs a semantic (vector) search over the orders of the authorized user. It requires user authorization.
273
261
  * @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}.
@@ -304,4 +292,26 @@ export default class OrdersApi extends AsyncModules {
304
292
  this._url = savedUrl;
305
293
  }
306
294
  }
295
+ /**
296
+ * Builds the order body the API expects: `formData` wrapped in a map keyed by locale.
297
+ *
298
+ * The wrapping is done on a copy. Writing it back into the caller's object made
299
+ * a reused body — a retry, a shared template — arrive wrapped twice: `createOrder`
300
+ * answered `400 formData's marker '#0' marker is required`, and
301
+ * `updateOrderByMarkerAndId` answered `200` and stored the broken `formData` in
302
+ * the order (CMS-1063).
303
+ * @param {IOrderData} body - Order body as the caller passed it. Left unchanged.
304
+ * @param {string} langCode - Locale key to wrap `formData` into.
305
+ * @returns {object} A new body with `formData` as `{ [langCode]: [...] }`.
306
+ */
307
+ _wrapOrderFormData(body, langCode) {
308
+ return {
309
+ ...body,
310
+ formData: {
311
+ [langCode]: Array.isArray(body.formData)
312
+ ? body.formData
313
+ : [body.formData],
314
+ },
315
+ };
316
+ }
307
317
  }
@@ -1,4 +1,4 @@
1
- import type { IError, ILocalizeInfo } from '../base/utils.js';
1
+ import type { IError, ILocalizeInfo, IVectorSearchResponse } from '../base/utils.js';
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.
@@ -211,7 +211,7 @@ interface IOrdersVectorSearch {
211
211
  "formData": [
212
212
  {
213
213
  "marker": "order_name",
214
- "value": "Ivan",
214
+ "value": "John",
215
215
  "type": "string"
216
216
  }
217
217
  ],
@@ -578,7 +578,7 @@ interface IOrderSplit {
578
578
  [
579
579
  {
580
580
  "marker": "order_name",
581
- "value": "Ivan",
581
+ "value": "John",
582
582
  "type": "string"
583
583
  }
584
584
  ]
@@ -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 { IPagesApi, IPageSearchResult, IPagesEntity, IPagesResponse, IPagesVectorSearch, IPositionBlock } from './pagesInterfaces.js';
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
@@ -182,27 +182,23 @@ export default class PagesApi extends AsyncModules {
182
182
  * @param {string} [langCode] - Language code. Default: "en_US".
183
183
  * @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)
184
184
  * @throws {IError} When isShell=false and an error occurs during the fetch
185
- * @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.
185
+ * @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.
186
186
  * @see {@link https://js-sdk.oneentry.cloud/docs/pages/searchPage searchPage} documentation.
187
187
  */
188
188
  async searchPage(name, url, langCode = this.state.lang) {
189
189
  // Fetch data from the server using a GET request to perform a quick search by page name and language code
190
190
  const urlPart = url ? `url=${encodeURIComponent(url)}&` : '';
191
- const searchPages = await this._fetchGet(`/quick/search?${urlPart}lang=${encodeURIComponent(langCode)}&name=${encodeURIComponent(name)}`);
192
- // /quick/search?url=catalog&langCode=en_US&name=cat
191
+ const searchPages = await this._fetchGet(`/quick/search?${urlPart}langCode=${encodeURIComponent(langCode)}&name=${encodeURIComponent(name)}`);
193
192
  // Validate response if validation is enabled
194
193
  const data = (await this._validateResponse(searchPages, schema('PageSearchResponseSchema')));
195
194
  // Check if there is no traffic limit set in the state
196
195
  if (!this.state.traficLimit && Array.isArray(data)) {
197
- // Initialize an empty array to store detailed page information
198
- const pageList = [];
199
- // Use Promise.all to fetch detailed information for each page concurrently
200
- await Promise.all(data.map(async (page) => {
201
- // Fetch detailed page information by page ID and push it to pageList
202
- await this.getPageById(page.id, langCode).then((result) => {
203
- pageList.push(result);
204
- });
205
- }));
196
+ // Fetch detailed information for each page concurrently, keeping the search order
197
+ const fetched = await Promise.all(data.map((page) => this.getPageById(page.id, langCode)));
198
+ // A page the quick search found but getPageById could not load (404 in this
199
+ // language, closed route) is left out: an IError has no place in IPagesEntity[]
200
+ // and broke `page.localizeInfos.title` on the caller's side (CMS-1068)
201
+ const pageList = fetched.filter((page) => !this._isErrorResponse(page));
206
202
  // Add templates to the fetched pages
207
203
  const withTemplate = await this.addTemplateToPages(pageList);
208
204
  // Normalize the data and return it; ensures consistent structure or handles errors
@@ -219,7 +215,7 @@ export default class PagesApi extends AsyncModules {
219
215
  * @param {string} [langCode] - Language code. Default: "en_US".
220
216
  * @param {number} [offset] - Parameter for pagination. Default: 0.
221
217
  * @param {number} [limit] - Parameter for pagination. Default: 30.
222
- * @returns {Promise<IPagesResponse | IError>} Returns an object with an array of found pages and total count.
218
+ * @returns {Promise<IVectorSearchResponse<IPagesResponse> | IError>} Returns an object with an array of found pages and total count.
223
219
  * @throws {IError} When isShell=false and an error occurs during the fetch
224
220
  * @description This method performs a semantic (vector) search for pages.
225
221
  * @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.js';
1
+ import type { IAttributes, IAttributeValues, IError, ILocalizeInfo, IRating, IVectorSearchResponse, LangType } from '../base/utils.js';
2
2
  import type { BlockType, IBlockEntity } from '../blocks/blocksInterfaces.js';
3
3
  import type { IFormConfig } from '../forms/formsInterfaces.js';
4
4
  import type { IProductsEntity, IProductsResponse } from '../products/productsInterfaces.js';
@@ -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.
@@ -29,7 +29,7 @@ export default class ProductStatusesApi extends AsyncModules implements IProduct
29
29
  /**
30
30
  * Search for a product status object by its textual identifier (marker).
31
31
  * @handleName getProductsByStatusMarker
32
- * @param {string} marker - Product marker. Example: "in_stock".
32
+ * @param {string} marker - Product status marker. Example: "in_stock".
33
33
  * @param {string} [langCode] - Language code. Default: "en_US".
34
34
  * @returns {Promise<IProductStatusEntity | IError>} Returns a product status object.
35
35
  * @throws {IError} When isShell=false and an error occurs during the fetch
@@ -40,7 +40,7 @@ export default class ProductStatusesApi extends AsyncModules implements IProduct
40
40
  /**
41
41
  * Check the existence of a textual identifier.
42
42
  * @handleName validateMarker
43
- * @param {string} marker - Product marker. Example: "in_stock".
43
+ * @param {string} marker - Product status marker. Example: "in_stock".
44
44
  * @returns {Promise<boolean | IError>} Returns true if the textual identifier (marker) exists or false if it doesn't.
45
45
  * @throws {IError} When isShell=false and an error occurs during the fetch
46
46
  * @description Check the existence of a textual identifier.
@@ -34,7 +34,7 @@ export default class ProductStatusesApi extends AsyncModules {
34
34
  /**
35
35
  * Search for a product status object by its textual identifier (marker).
36
36
  * @handleName getProductsByStatusMarker
37
- * @param {string} marker - Product marker. Example: "in_stock".
37
+ * @param {string} marker - Product status marker. Example: "in_stock".
38
38
  * @param {string} [langCode] - Language code. Default: "en_US".
39
39
  * @returns {Promise<IProductStatusEntity | IError>} Returns a product status object.
40
40
  * @throws {IError} When isShell=false and an error occurs during the fetch
@@ -50,7 +50,7 @@ export default class ProductStatusesApi extends AsyncModules {
50
50
  /**
51
51
  * Check the existence of a textual identifier.
52
52
  * @handleName validateMarker
53
- * @param {string} marker - Product marker. Example: "in_stock".
53
+ * @param {string} marker - Product status marker. Example: "in_stock".
54
54
  * @returns {Promise<boolean | IError>} Returns true if the textual identifier (marker) exists or false if it doesn't.
55
55
  * @throws {IError} When isShell=false and an error occurs during the fetch
56
56
  * @description Check the existence of a textual identifier.
@@ -16,7 +16,7 @@ interface IProductStatusesApi {
16
16
  /**
17
17
  * Search for a product status object by its textual identifier (marker).
18
18
  * @handleName getProductsByStatusMarker
19
- * @param {string} marker - Product marker. Example: "in_stock".
19
+ * @param {string} marker - Product status marker. Example: "in_stock".
20
20
  * @param {string} [langCode] - Language code. Default: "en_US".
21
21
  * @returns {IProductStatusEntity} Returns a product status object.
22
22
  * @throws {IError} If there is an error during the fetch operation, it will return an error object.
@@ -26,7 +26,7 @@ interface IProductStatusesApi {
26
26
  /**
27
27
  * Check the existence of a textual identifier.
28
28
  * @handleName validateMarker
29
- * @param {string} marker - Product marker. Example: "in_stock".
29
+ * @param {string} marker - Product status marker. Example: "in_stock".
30
30
  * @returns {boolean} Returns true if the textual identifier (marker) exists or false if it doesn't.
31
31
  * @throws {IError} If there is an error during the fetch operation, it will return an error object.
32
32
  * @description This method checks the existence of a textual identifier.
@@ -1,7 +1,7 @@
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';
4
- import type { IAggregatedProductGroup, IFilterParams, IProductBlock, IProductsApi, IProductsByIdsQuery, IProductsCount, IProductSearchResult, IProductsEntity, IProductsInfo, IProductsPriceQuery, IProductsQueryBase, IProductsRelatedQuery, IProductsResponse, IVectorSearchProducts } from './productsInterfaces.js';
3
+ import type { IError, IVectorSearchResponse } from '../base/utils.js';
4
+ import type { IFilterParams, IProductBlock, IProductsApi, IProductsByIdsQuery, IProductsCount, IProductSearchResult, IProductsEntity, IProductsInfo, IProductsPriceQuery, IProductsQueryBase, IProductsRelatedQuery, IProductsResponse, IVectorSearchProducts } from './productsInterfaces.js';
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.
@@ -87,7 +87,7 @@ export default class ProductsApi extends AsyncModules {
87
87
  "sortKey": "id",
88
88
  "signPrice": "orders"
89
89
  }
90
- * @returns {Promise<IAggregatedProductGroup[] | IError>} Array with AggregatedProductGroup objects.
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
92
92
  * @description Search for all product page objects with pagination (and aggregation) that do not have a category.
93
93
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsEmptyPage getProductsEmptyPage} documentation.
@@ -95,7 +95,9 @@ export default class ProductsApi extends AsyncModules {
95
95
  async getProductsEmptyPage(body = {}, langCode = this.state.lang, userQuery) {
96
96
  const query = { ...userQuery, langCode };
97
97
  const result = await this._fetchPost(`/empty-page?` + this._queryParamsToString(query), body);
98
- return this._normalizeData(result);
98
+ // Validate response if validation is enabled
99
+ const validated = await this._validateResponse(result, schema('ProductsResponseSchema'));
100
+ return this._normalizeData(validated, langCode);
99
101
  }
100
102
  /**
101
103
  * Search for all products with pagination for the selected category.
@@ -247,6 +249,7 @@ export default class ProductsApi extends AsyncModules {
247
249
  * @param {number} [userQuery.offset] - Optional parameter for pagination. Default: 0.
248
250
  * @param {string} [userQuery.sortOrder] - Optional sorting order "DESC" | "ASC". Example: "DESC".
249
251
  * @param {string} [userQuery.sortKey] - Optional field to sort by ("id", "title", "date", "price", "position", "status"). Example: "id".
252
+ * @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".
250
253
  * @returns {Promise<IProductsResponse | IError>} Array with ProductEntity objects
251
254
  * @throws {IError} When isShell=false and an error occurs during the fetch
252
255
  * @description Find all related product page objects.
@@ -439,7 +442,7 @@ export default class ProductsApi extends AsyncModules {
439
442
  * @param {string} [langCode] - Language code. Default: "en_US".
440
443
  * @param {number} [offset] - Parameter for pagination. Default: 0.
441
444
  * @param {number} [limit] - Parameter for pagination. Default: 30.
442
- * @returns {Promise<IProductsResponse | IError>} Returns an object with an array of found products and total count.
445
+ * @returns {Promise<IVectorSearchResponse<IProductsResponse> | IError>} Returns an object with an array of found products and total count.
443
446
  * @throws {IError} When isShell=false and an error occurs during the fetch
444
447
  * @description This method performs a semantic (vector) search for products.
445
448
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsByVectorSearch getProductsByVectorSearch} documentation.