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
@@ -117,9 +117,12 @@ class FormsDataApi extends asyncModules_1.default {
117
117
  // Create an instance of FileUploadingApi with the current state
118
118
  const fileUploader = new fileUploadingApi_1.default(this.state);
119
119
  // Process each element in formData[langCode] asynchronously
120
- formData[langCode] = await Promise.all(formData[langCode].map(async (fd) => {
120
+ formData[langCode] = await Promise.all(formData[langCode].map(async (field) => {
121
121
  // Check if the type is one of the specified types
122
- if (['file', 'image', 'groupOfImages'].includes(fd.type)) {
122
+ if (['file', 'image', 'groupOfImages'].includes(field.type)) {
123
+ // Work on a copy: the caller's field keeps its File and its fileQuery,
124
+ // so a reused body sends the same form again (CMS-1071)
125
+ const fd = { ...field };
123
126
  // If fileQuery does not exist, we create it and assign it to an object with the following properties:
124
127
  if (!fd.fileQuery) {
125
128
  const fileQuery = {
@@ -157,13 +160,15 @@ class FormsDataApi extends asyncModules_1.default {
157
160
  delete fd.fileQuery;
158
161
  // Remove the 'contentType' property from the file object because it is not needed and not valid
159
162
  fd.value = this._stripContentType(fd.value);
163
+ return fd;
160
164
  }
161
- // Return the processed form data element
162
- return fd;
165
+ // Return the form data element untouched
166
+ return field;
163
167
  }));
164
168
  }
165
- body.formData = formData;
166
- const result = await this._fetchPost(``, body);
169
+ // The wrapped formData goes into a new body: written back into the caller's
170
+ // object, a second call with it wrapped the wrapper and answered `400` (CMS-1071)
171
+ const result = await this._fetchPost(``, { ...body, formData });
167
172
  // Validate response if validation is enabled
168
173
  const validated = await this._validateResponse(result, schema('PostFormResponseSchema'));
169
174
  return this._normalizeData(validated);
@@ -183,7 +188,7 @@ class FormsDataApi extends asyncModules_1.default {
183
188
  /**
184
189
  * Removes `contentType` from a file value, which the endpoint does not accept.
185
190
  * @param {T} value - Value of a `file` / `image` / `groupOfImages` field, after the uploads.
186
- * @returns {T} The same value, without `contentType`.
191
+ * @returns {T} The value without `contentType`; entries that carried it are copies, the caller's objects are not modified.
187
192
  * @description `FileUploading.upload` returns `contentType` and form data rejects it,
188
193
  * so it is stripped from an array of values and from a lone value object alike. A value
189
194
  * of any other shape is returned untouched and the endpoint names the field it cannot
@@ -191,18 +196,20 @@ class FormsDataApi extends asyncModules_1.default {
191
196
  * request is made (CMS-990).
192
197
  */
193
198
  _stripContentType(value) {
199
+ // An entry carrying `contentType` is copied without it rather than edited:
200
+ // a descriptor passed through untouched belongs to the caller (CMS-1071)
194
201
  const strip = (item) => {
195
- if (item && typeof item === 'object' && !Array.isArray(item)) {
196
- delete item.contentType;
202
+ if (item &&
203
+ typeof item === 'object' &&
204
+ !Array.isArray(item) &&
205
+ 'contentType' in item) {
206
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
207
+ const { contentType, ...rest } = item;
208
+ return rest;
197
209
  }
210
+ return item;
198
211
  };
199
- if (Array.isArray(value)) {
200
- value.forEach(strip);
201
- }
202
- else {
203
- strip(value);
204
- }
205
- return value;
212
+ return (Array.isArray(value) ? value.map(strip) : strip(value));
206
213
  }
207
214
  /**
208
215
  * Drops the date bounds the endpoint refuses to parse.
@@ -309,7 +316,7 @@ class FormsDataApi extends asyncModules_1.default {
309
316
  * @param {string} [langCode] - Language code. Default: "en_US".
310
317
  * @param {number} [offset] - Parameter for pagination. Default: 0.
311
318
  * @param {number} [limit] - Parameter for pagination. Default: 30.
312
- * @returns {Promise<IFormsDataSearchResponse | IError>} Returns an object with an array of found form data records and total count.
319
+ * @returns {Promise<IVectorSearchResponse<IFormsDataSearchResponse> | IError>} Returns an object with an array of found form data records and total count.
313
320
  * @throws {IError} When isShell=false and an error occurs during the fetch
314
321
  * @description This method performs a semantic (vector) search for form data.
315
322
  * @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/getFormsDataByVectorSearch getFormsDataByVectorSearch} documentation.
@@ -1,4 +1,4 @@
1
- import type { IError } from '../base/utils';
1
+ import type { IError, IVectorSearchResponse } from '../base/utils';
2
2
  import type { IUploadingQuery, IUploadingReturn } from '../file-uploading/fileUploadingInterfaces';
3
3
  /**
4
4
  * Interface for retrieving and posting form data in the system.
@@ -77,10 +77,10 @@ interface IFormsData {
77
77
  * @param {string} [langCode] - Language code. Default: "en_US".
78
78
  * @param {number} [offset] - Parameter for pagination. Default: 0.
79
79
  * @param {number} [limit] - Parameter for pagination. Default: 30.
80
- * @returns {Promise<IFormsDataSearchResponse | IError>} Returns an object with an array of found form data records and total count.
80
+ * @returns {Promise<IVectorSearchResponse<IFormsDataSearchResponse> | IError>} Returns an object with an array of found form data records and total count.
81
81
  * @throws {IError} When isShell=false and an error occurs during the fetch
82
82
  */
83
- getFormsDataByVectorSearch(body: IFormsDataVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IFormsDataSearchResponse | IError>;
83
+ getFormsDataByVectorSearch(body: IFormsDataVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IVectorSearchResponse<IFormsDataSearchResponse> | IError>;
84
84
  }
85
85
  /**
86
86
  * Body for semantic (vector) form data search.
@@ -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
  /**
package/dist/index.d.ts CHANGED
@@ -136,7 +136,7 @@ interface IDefineApi {
136
136
  * @param {string} [config.guestId] - Optional guest identifier sent as the `x-guest-id` header for guest cart/wishlist/activity flows (only while unauthenticated). In the browser, if omitted, a stable per-device id is generated and persisted in localStorage. On the server you MUST pass a per-visitor `guestId` (or call `setGuestId`): the SDK never auto-generates a server id, to avoid sharing one guest across visitors.
137
137
  * @param {string} [config.deviceMetadata] - Optional device-metadata string sent as the `x-device-metadata` header instead of the environment-derived fingerprint. Refresh tokens are bound to this header, so a server issuing tokens for a browser (OAuth code exchange) must pass the browser's string (from `getDeviceMetadata()`), or the token will not be refreshable from that browser.
138
138
  * @param {string} [config.langCode] - Optional langCode parameter
139
- * @param {boolean} [config.traficLimit] - Some methods use multiple queries to make it easier to work with the API. Set this parameter to "false" to save traffic and decide for yourself what data you need.
139
+ * @param {boolean} [config.traficLimit] - Some methods use multiple queries to make it easier to work with the API. Set it to `true` to save traffic and decide for yourself what data you need: the SDK then skips its follow-up requests, and some results change shape (e.g. `searchPage` returns short `{ id, title }` cards). Default: false.
140
140
  * @param {string} [config.auth] - An object with authorization settings.
141
141
  * @param {boolean} [config.auth.customAuth] - Set this flag to true if you want to configure the authorization process yourself. Set the flag to false, or do not pass it at all to have automatic authorization and token renewal.
142
142
  * @param {string} [config.auth.refreshToken] - Transfer the refresh token here, for example from the local storage, to resume the user's session. Otherwise, the user will need to log in every time a new session is created.
package/dist/index.js CHANGED
@@ -59,7 +59,7 @@ Object.defineProperty(exports, "isTimeIntervalAttribute", { enumerable: true, ge
59
59
  * @param {string} [config.guestId] - Optional guest identifier sent as the `x-guest-id` header for guest cart/wishlist/activity flows (only while unauthenticated). In the browser, if omitted, a stable per-device id is generated and persisted in localStorage. On the server you MUST pass a per-visitor `guestId` (or call `setGuestId`): the SDK never auto-generates a server id, to avoid sharing one guest across visitors.
60
60
  * @param {string} [config.deviceMetadata] - Optional device-metadata string sent as the `x-device-metadata` header instead of the environment-derived fingerprint. Refresh tokens are bound to this header, so a server issuing tokens for a browser (OAuth code exchange) must pass the browser's string (from `getDeviceMetadata()`), or the token will not be refreshable from that browser.
61
61
  * @param {string} [config.langCode] - Optional langCode parameter
62
- * @param {boolean} [config.traficLimit] - Some methods use multiple queries to make it easier to work with the API. Set this parameter to "false" to save traffic and decide for yourself what data you need.
62
+ * @param {boolean} [config.traficLimit] - Some methods use multiple queries to make it easier to work with the API. Set it to `true` to save traffic and decide for yourself what data you need: the SDK then skips its follow-up requests, and some results change shape (e.g. `searchPage` returns short `{ id, title }` cards). Default: false.
63
63
  * @param {string} [config.auth] - An object with authorization settings.
64
64
  * @param {boolean} [config.auth.customAuth] - Set this flag to true if you want to configure the authorization process yourself. Set the flag to false, or do not pass it at all to have automatic authorization and token renewal.
65
65
  * @param {string} [config.auth.refreshToken] - Transfer the refresh token here, for example from the local storage, to resume the user's session. Otherwise, the user will need to log in every time a new session is created.
@@ -1,7 +1,7 @@
1
1
  import AsyncModules from '../base/asyncModules';
2
2
  import type StateModule from '../base/stateModule';
3
3
  import type { IError } from '../base/utils';
4
- import type { ICollectionEntity, ICollectionFormObject, ICollectionIsValid, ICollectionQuery, ICollectionRow, ICollectionRowsResponce, ICollectionsApi } from './integrationCollectionsInterfaces';
4
+ import type { ICollectionEntity, ICollectionFormObject, ICollectionIsValid, ICollectionQuery, ICollectionRow, ICollectionRowsResponce, ICollectionsApi, ICollectionsListQuery } from './integrationCollectionsInterfaces';
5
5
  /**
6
6
  * Controllers for working with attributes.
7
7
  * @handle /api/content/integration-collections
@@ -22,22 +22,18 @@ export default class IntegrationCollectionsApi extends AsyncModules implements I
22
22
  * Get all collections.
23
23
  * @handleName getICollections
24
24
  * @param {string} [langCode] - Language code. Default: "en_US".
25
- * @param {object} [userQuery] - Optional set query parameters.
25
+ * @param {ICollectionsListQuery} [userQuery] - Optional set query parameters.
26
26
  * @example
27
27
  {
28
- "limit": 0,
29
- "offset": 30,
30
- "entityType": "orders",
31
- "entityId": 1
28
+ "limit": 30,
29
+ "offset": 0
32
30
  }
33
- * @param {number} [userQuery.limit] - Optional parameter for pagination. Default: 0.
34
- * @param {number} [userQuery.offset] - Optional parameter for pagination. Default: 30.
35
- * @param {string} [userQuery.entityType] - Entity type. Example: "orders".
36
- * @param {number} [userQuery.entityId] - Entity identifier. Example: 1.
31
+ * @param {number} [userQuery.limit] - Optional parameter for pagination. Default: 30.
32
+ * @param {number} [userQuery.offset] - Optional parameter for pagination. Default: 0.
37
33
  * @returns {Promise<ICollectionEntity[] | IError>} Returns an array of ICollection objects or an error object if there was an issue.
38
34
  * @see {@link https://js-sdk.oneentry.cloud/docs/integration-collections/getICollections getICollections} documentation.
39
35
  */
40
- getICollections(langCode?: string, userQuery?: ICollectionQuery): Promise<ICollectionEntity[] | IError>;
36
+ getICollections(langCode?: string, userQuery?: ICollectionsListQuery): Promise<ICollectionEntity[] | IError>;
41
37
  /**
42
38
  * Get a single collection object by id.
43
39
  * @handleName getICollectionById
@@ -53,16 +49,16 @@ export default class IntegrationCollectionsApi extends AsyncModules implements I
53
49
  * @handleName getICollectionRowsById
54
50
  * @param {number} id - Collection id. Example: 1.
55
51
  * @param {string} [langCode] - Language code. Default: "en_US".
56
- * @param {any} [userQuery] - Optional set query parameters.
52
+ * @param {ICollectionQuery} [userQuery] - Optional set query parameters.
57
53
  * @example
58
54
  {
59
- "limit": 0,
60
- "offset": 30,
55
+ "limit": 30,
56
+ "offset": 0,
61
57
  "entityType": "orders",
62
58
  "entityId": 1
63
59
  }
64
- * @param {number} [userQuery.limit] - Optional parameter for pagination. Default: 0.
65
- * @param {number} [userQuery.offset] - Optional parameter for pagination. Default: 30.
60
+ * @param {number} [userQuery.limit] - Optional parameter for pagination. Default: 30.
61
+ * @param {number} [userQuery.offset] - Optional parameter for pagination. Default: 0.
66
62
  * @param {string} [userQuery.entityType] - Entity type. Example: "orders".
67
63
  * @param {number} [userQuery.entityId] - Entity identifier. Example: 1.
68
64
  * @returns {Promise<ICollectionRowsResponce | IError>} Returns object ItemsWithTotal, where items is an array of requested objects.
@@ -65,18 +65,14 @@ class IntegrationCollectionsApi extends asyncModules_1.default {
65
65
  * Get all collections.
66
66
  * @handleName getICollections
67
67
  * @param {string} [langCode] - Language code. Default: "en_US".
68
- * @param {object} [userQuery] - Optional set query parameters.
68
+ * @param {ICollectionsListQuery} [userQuery] - Optional set query parameters.
69
69
  * @example
70
70
  {
71
- "limit": 0,
72
- "offset": 30,
73
- "entityType": "orders",
74
- "entityId": 1
71
+ "limit": 30,
72
+ "offset": 0
75
73
  }
76
- * @param {number} [userQuery.limit] - Optional parameter for pagination. Default: 0.
77
- * @param {number} [userQuery.offset] - Optional parameter for pagination. Default: 30.
78
- * @param {string} [userQuery.entityType] - Entity type. Example: "orders".
79
- * @param {number} [userQuery.entityId] - Entity identifier. Example: 1.
74
+ * @param {number} [userQuery.limit] - Optional parameter for pagination. Default: 30.
75
+ * @param {number} [userQuery.offset] - Optional parameter for pagination. Default: 0.
80
76
  * @returns {Promise<ICollectionEntity[] | IError>} Returns an array of ICollection objects or an error object if there was an issue.
81
77
  * @see {@link https://js-sdk.oneentry.cloud/docs/integration-collections/getICollections getICollections} documentation.
82
78
  */
@@ -108,16 +104,16 @@ class IntegrationCollectionsApi extends asyncModules_1.default {
108
104
  * @handleName getICollectionRowsById
109
105
  * @param {number} id - Collection id. Example: 1.
110
106
  * @param {string} [langCode] - Language code. Default: "en_US".
111
- * @param {any} [userQuery] - Optional set query parameters.
107
+ * @param {ICollectionQuery} [userQuery] - Optional set query parameters.
112
108
  * @example
113
109
  {
114
- "limit": 0,
115
- "offset": 30,
110
+ "limit": 30,
111
+ "offset": 0,
116
112
  "entityType": "orders",
117
113
  "entityId": 1
118
114
  }
119
- * @param {number} [userQuery.limit] - Optional parameter for pagination. Default: 0.
120
- * @param {number} [userQuery.offset] - Optional parameter for pagination. Default: 30.
115
+ * @param {number} [userQuery.limit] - Optional parameter for pagination. Default: 30.
116
+ * @param {number} [userQuery.offset] - Optional parameter for pagination. Default: 0.
121
117
  * @param {string} [userQuery.entityType] - Entity type. Example: "orders".
122
118
  * @param {number} [userQuery.entityId] - Entity identifier. Example: 1.
123
119
  * @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';
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.
@@ -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';
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.
@@ -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.