oneentry 1.0.171 → 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 +28 -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 +4 -4
  20. package/dist/forms-data/formsDataApi.js +24 -17
  21. package/dist/forms-data/formsDataInterfaces.d.ts +3 -3
  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 +4 -4
  55. package/esm/forms-data/formsDataApi.js +24 -17
  56. package/esm/forms-data/formsDataInterfaces.d.ts +3 -3
  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
package/changelog.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # SDK Change Log
2
2
 
3
+ ## v.1.0.172
4
+
5
+ ### What's Fixed
6
+
7
+ - **`Orders.createOrder`, `Orders.updateOrderByMarkerAndId` and `FormData.postFormsData` no longer modify the body they are given.** All three wrapped `formData` into `{ [langCode]: [...] }` and wrote the result back into the caller's object (`body.formData = formData`) — the same class of defect 1.0.168 fixed in `_normalizePostBody`, in three methods that wrap on their own. A reused body (a retry, a shared template, form state passed by reference) was wrapped a second time: `createOrder` and `postFormsData` answered `400 formData's marker '#0' marker is required`, and `updateOrderByMarkerAndId` answered **`200` and stored the broken `formData` in the order**. The wrapped value now goes into a new body. `postFormsData` also processed file fields in place — it replaced the caller's `File` with the upload result, deleted `fileQuery` and stripped `contentType` from a descriptor passed through — and now works on copies of those fields too (CMS-1063, CMS-1071).
8
+
9
+ - **`UserActivity.trackUserActivity` returned `true` for a refused event.** With `isShell` on — the default — the API error came back as a value nobody inspected, so a `400 type must be a valid enum value` read as "recorded"; with `isShell` off the thrown error was caught and returned, while the JSDoc promises a throw. The method now goes through `_fetchBoolean`: `true` on the `204`, the `IError` otherwise, thrown when `isShell` is off (CMS-1064).
10
+
11
+ - **Methods built on `_fetchBoolean` threw nothing when `isShell` was off.** `Events.subscribeByMarker`, `unsubscribeByMarker`, `subscribeToForm`, `unsubscribeFromForm`, `Subscriptions.cancelSubscription` and `recoverSubscriptions` caught the error `browserResponse` throws in that mode and returned it, so a `try/catch` around them never fired and `if (result)` took the error object for success. The helper now rethrows when `isShell` is off, as every other method does. The JSDoc of `unsubscribeByMarker` said `Promise<any | IError>` and now matches the signature (CMS-1067).
12
+
13
+ - **`Pages.searchPage` searched only the default language.** The method sent `lang=` where the endpoint reads `langCode`, and the endpoint treats an unknown parameter as no language at all. On a bilingual stand `searchPage('Блог', undefined, 'ru_RU')` came back empty, while `searchPage('Blog', undefined, 'ru_RU')` found the English titles and then loaded them in `ru_RU`: the pages missing in that locale answered `404`, and those errors were returned as elements of the `IPagesEntity[]` array. The parameter is `langCode` now, a found page that cannot be loaded is left out of the result, and the result keeps the order of the search instead of the order the requests finished in (CMS-1068).
14
+
15
+ - **`FileUploading.delete` resolved to `{}` on success, not to the declared `boolean`.** The endpoint answers `200` with an empty body, which the parser reads as `{}`. The method now returns `true`, so `=== true` and `typeof result === 'boolean'` work as the type says (CMS-1072).
16
+
17
+ ### What's Changed
18
+
19
+ - **`Products.getProductsEmptyPage` returns `IProductsResponse`.** It was declared as `IAggregatedProductGroup[]`, but the endpoint answers `{ items, total }` — the same container as `getProducts` — and the SDK never converted it, so `result.map(...)` compiled and failed at run time. The response is now validated with the same schema as `getProducts` when validation is on. `IAggregatedProductGroup` is kept for existing imports and marked deprecated: no method returns it (CMS-1065).
20
+
21
+ - **`indexReady` is declared on all seven vector search responses.** The platform answers every `…/vector/search` with `indexReady`: `false` means the index for that entity and language is not built yet and empty `items` do not mean "nothing matched". The SDK passed the field through but no type declared it. The new `IVectorSearchResponse<T>` adds it to the module's own container, and `getUsersByVectorSearch`, `getProductsByVectorSearch`, `getPagesByVectorSearch`, `getOrdersByVectorSearch`, `getDiscountsByVectorSearch`, `getAdminsByVectorSearch` and `getFormsDataByVectorSearch` return it. It is assignable to the container they declared before, so existing code compiles unchanged (CMS-1074).
22
+
23
+ - **Products query types follow what the endpoint accepts.** `IProductsQueryBase.sortKey` takes `'status'`, which the endpoint sorts by and the type refused; `IProductsRelatedQuery` declares `relationMode: 'global' | 'local'` of `GET /products/{id}/related`; the JSDoc example of `IFilterParams.conditionMarker` was `"equals"`, which answers `400 filter.0.conditionMarker must be a valid enum value`, and is `"eq"` now (CMS-1066).
24
+
25
+ - **`BlockType` no longer includes `'none'`.** The platform has no such type — `GET /general-types` does not return it — and a filter by it answers `400 type must be a valid enum value`. The `general-types` response schema drops it as well. The JSDoc of `getBlocks` listed 12 of the types and lists all 22 now. `'service'` stays: it is the platform's own name for the type, and the `400` the `type` filter of `getBlocks` and `getTemplateByType` currently gives it is a platform defect, reported as CMS-1073 (CMS-1062).
26
+
27
+ ### Tests
28
+
29
+ - **`src/base/tests/callercontracts.spec.ts` pins these contracts** with a stubbed `fetch`, no stand required: a reused order and form body sent identically twice and left untouched, a file descriptor passed through without losing `contentType` on the caller's side, `trackUserActivity` on `204` / `400` with `isShell` on and off, `subscribeByMarker` throwing when `isShell` is off, `searchPage` sending `langCode` and dropping a page it could not load, and `FileUploading.delete` returning `true`. Against 1.0.171 ten of its thirteen cases fail.
30
+
3
31
  ## v.1.0.171
4
32
 
5
33
  ### What's Fixed
@@ -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 { IFilterParams } from '../products/productsInterfaces';
5
5
  import type { IAdminEntity, IAdmins, IAdminsResponse, IAdminsVectorSearch } from './adminsInterfaces';
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
  }
@@ -104,7 +104,7 @@ class AdminsApi extends asyncModules_1.default {
104
104
  * @param {string} [langCode] - Language code. Default: "en_US".
105
105
  * @param {number} [offset] - Parameter for pagination. Default: 0.
106
106
  * @param {number} [limit] - Parameter for pagination. Default: 30.
107
- * @returns {Promise<IAdminsResponse | IError>} Returns an object with an array of found admins and total count.
107
+ * @returns {Promise<IVectorSearchResponse<IAdminsResponse> | IError>} Returns an object with an array of found admins and total count.
108
108
  * @throws {IError} When isShell=false and an error occurs during the fetch
109
109
  * @description This method performs a semantic (vector) search for admins.
110
110
  * @see {@link https://js-sdk.oneentry.cloud/docs/admins/getAdminsByVectorSearch getAdminsByVectorSearch} documentation.
@@ -1,4 +1,4 @@
1
- import type { IAttributeValues, IError } from '../base/utils';
1
+ import type { IAttributeValues, IError, IVectorSearchResponse } from '../base/utils';
2
2
  import type { IFormConfig } from '../forms/formsInterfaces';
3
3
  import type { IFilterParams } from '../products/productsInterfaces';
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
  /**
@@ -168,8 +168,13 @@ class AsyncModules extends syncModules_1.default {
168
168
  * (the default) browserResponse returns the API error instead of throwing
169
169
  * it, so relying on the catch alone would report every failed call — a 404
170
170
  * from cancelSubscription, a 403 from recoverSubscriptions — as a success.
171
+ *
172
+ * With `isShell` disabled browserResponse throws, and the error is thrown on
173
+ * from here too: returning it would break the `@throws` contract every caller
174
+ * documents, and a `try/catch` around the call would never fire (CMS-1067).
171
175
  * @param {() => Promise<unknown>} request - Thunk performing the fetch call.
172
- * @returns {Promise<boolean | IError>} `true` on success, IError on failure.
176
+ * @returns {Promise<boolean | IError>} `true` on success, IError on failure when isShell=true.
177
+ * @throws {IError} When isShell=false and the request fails.
173
178
  */
174
179
  async _fetchBoolean(request) {
175
180
  try {
@@ -180,6 +185,9 @@ class AsyncModules extends syncModules_1.default {
180
185
  return true;
181
186
  }
182
187
  catch (e) {
188
+ if (!this.state.isShell) {
189
+ throw e;
190
+ }
183
191
  return e;
184
192
  }
185
193
  }
@@ -439,6 +439,16 @@ interface IHttpOptions {
439
439
  headers: IHttpHeaders;
440
440
  body?: string | FormData | Blob;
441
441
  }
442
+ /**
443
+ * Response of a semantic (vector) search: the module's own list container plus `indexReady`.
444
+ * @typedef {object} IVectorSearchResponse
445
+ * @template T
446
+ * @property {boolean} indexReady - `false` when no vectors are built yet for this entity and language: the query was not embedded, and empty `items` do not mean "nothing matched". `true` — an honest search result.
447
+ * @description Every `…/vector/search` endpoint answers with `indexReady` next to its list (CMS-1074).
448
+ */
449
+ type IVectorSearchResponse<T> = T & {
450
+ indexReady: boolean;
451
+ };
442
452
  /**
443
453
  * LangType
444
454
  */
@@ -447,4 +457,4 @@ type LangType = string | Array<string>;
447
457
  * LocalizeType
448
458
  */
449
459
  type LocalizeType = ILocalizeInfo;
450
- export type { IAttributeFile, IAttributeLocalizeInfo, IAttributes, IAttributeValue, IAttributeValues, IConfig, IError, IFileAttributeValue, IHttpHeaders, IHttpOptions, IListAttributeValue, ILocalizeInfo, INumberAttributeValue, IRating, IStringAttributeValue, ITimeIntervalAttributeValue, ITimeIntervalEntitySchedule, ITimeIntervalGroup, ITimeIntervalPoint, ITimeIntervalRange, ITimeIntervalSchedule, ITimeIntervalWindow, ITypedAttributeValue, LangType, LocalizeType, TimeIntervalPair, };
460
+ export type { IAttributeFile, IAttributeLocalizeInfo, IAttributes, IAttributeValue, IAttributeValues, IConfig, IError, IFileAttributeValue, IHttpHeaders, IHttpOptions, IListAttributeValue, ILocalizeInfo, INumberAttributeValue, IRating, IStringAttributeValue, ITimeIntervalAttributeValue, ITimeIntervalEntitySchedule, ITimeIntervalGroup, ITimeIntervalPoint, ITimeIntervalRange, ITimeIntervalSchedule, ITimeIntervalWindow, ITypedAttributeValue, IVectorSearchResponse, LangType, LocalizeType, TimeIntervalPair, };
@@ -21,7 +21,7 @@ export default class BlocksApi extends AsyncModules implements IBlocks {
21
21
  /**
22
22
  * Get blocks by parameters.
23
23
  * @handleName getBlocks
24
- * @param {BlockType} [type] - Optional block type to filter by. Available values: "product" | "error_page" | "catalog_page" | "product_preview" | "similar_products_block" | "product_block" | "form" | "common_page" | "common_block" | "order" | "service" | "none". When omitted, blocks of all types are returned. Example: 'product'.
24
+ * @param {BlockType} [type] - Optional block type to filter by. Available values: "product" | "error_page" | "catalog_page" | "product_preview" | "similar_products_block" | "product_block" | "frequently_ordered_block" | "trending_block" | "recently_viewed_block" | "repeat_purchase_block" | "slider_block" | "personal_recommendations_block" | "cart_complement_block" | "cart_similar_block" | "wishlist_similar_block" | "form" | "common_page" | "common_block" | "order" | "service" | "external_page" | "discount" (see BlockType). When omitted, blocks of all types are returned. Example: 'product'.
25
25
  * @param {string} [langCode] - Language code. Default: "en_US".
26
26
  * @param {number} [offset] - Parameter for pagination. Default: 0.
27
27
  * @param {number} [limit] - Parameter for pagination. Default: 30.
@@ -60,7 +60,7 @@ class BlocksApi extends asyncModules_1.default {
60
60
  /**
61
61
  * Get blocks by parameters.
62
62
  * @handleName getBlocks
63
- * @param {BlockType} [type] - Optional block type to filter by. Available values: "product" | "error_page" | "catalog_page" | "product_preview" | "similar_products_block" | "product_block" | "form" | "common_page" | "common_block" | "order" | "service" | "none". When omitted, blocks of all types are returned. Example: 'product'.
63
+ * @param {BlockType} [type] - Optional block type to filter by. Available values: "product" | "error_page" | "catalog_page" | "product_preview" | "similar_products_block" | "product_block" | "frequently_ordered_block" | "trending_block" | "recently_viewed_block" | "repeat_purchase_block" | "slider_block" | "personal_recommendations_block" | "cart_complement_block" | "cart_similar_block" | "wishlist_similar_block" | "form" | "common_page" | "common_block" | "order" | "service" | "external_page" | "discount" (see BlockType). When omitted, blocks of all types are returned. Example: 'product'.
64
64
  * @param {string} [langCode] - Language code. Default: "en_US".
65
65
  * @param {number} [offset] - Parameter for pagination. Default: 0.
66
66
  * @param {number} [limit] - Parameter for pagination. Default: 30.
@@ -309,9 +309,11 @@ interface ISearchBlock {
309
309
  /**
310
310
  * BlockType
311
311
  * @type {BlockType}
312
- * @description This type defines the possible values for block types used in the system.
312
+ * @description This type defines the possible values for block types used in the system: the types `GET /api/content/general-types` returns.
313
+ * `'none'` was dropped — the platform has no such type and a filter by it answers `400 type must be a valid enum value` (CMS-1062).
314
+ * `'service'` is the platform's own name for the type, but the `type` filter of getBlocks and getTemplateByType currently refuses it with the same `400`; that is a platform defect (CMS-1073).
313
315
  */
314
- type BlockType = 'product' | 'error_page' | 'catalog_page' | 'product_preview' | 'similar_products_block' | 'product_block' | 'frequently_ordered_block' | 'trending_block' | 'recently_viewed_block' | 'repeat_purchase_block' | 'slider_block' | 'personal_recommendations_block' | 'cart_complement_block' | 'cart_similar_block' | 'wishlist_similar_block' | 'form' | 'common_page' | 'common_block' | 'order' | 'service' | 'external_page' | 'discount' | 'none';
316
+ type BlockType = 'product' | 'error_page' | 'catalog_page' | 'product_preview' | 'similar_products_block' | 'product_block' | 'frequently_ordered_block' | 'trending_block' | 'recently_viewed_block' | 'repeat_purchase_block' | 'slider_block' | 'personal_recommendations_block' | 'cart_complement_block' | 'cart_similar_block' | 'wishlist_similar_block' | 'form' | 'common_page' | 'common_block' | 'order' | 'service' | 'external_page' | 'discount';
315
317
  /**
316
318
  * Lookup body for block product endpoints by explicit productIds.
317
319
  * @interface IBlockProductsLookup
@@ -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 { IBonusBalanceEntity, IBonusHistoryResponse, IBonusTransactionType, ICouponValidationResult, IDiscountsApi, IDiscountsEntity, IDiscountsResponse, IDiscountsVectorSearch, IDiscountType } from './discountsInterfaces';
5
5
  /**
6
6
  * Controllers for working with events
@@ -85,10 +85,10 @@ export default class DiscountsApi extends AsyncModules implements IDiscountsApi
85
85
  * @param {string} [langCode] - Language code. Default: "en_US".
86
86
  * @param {number} [offset] - Parameter for pagination. Default: 0.
87
87
  * @param {number} [limit] - Parameter for pagination. Default: 30.
88
- * @returns {Promise<IDiscountsResponse | IError>} Returns an object with an array of found discounts and total count.
88
+ * @returns {Promise<IVectorSearchResponse<IDiscountsResponse> | IError>} Returns an object with an array of found discounts and total count.
89
89
  * @throws {IError} When isShell=false and an error occurs during the fetch
90
90
  * @description This method performs a semantic (vector) search for discounts.
91
91
  * @see {@link https://js-sdk.oneentry.cloud/docs/discounts/getDiscountsByVectorSearch getDiscountsByVectorSearch} documentation.
92
92
  */
93
- getDiscountsByVectorSearch(body: IDiscountsVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IDiscountsResponse | IError>;
93
+ getDiscountsByVectorSearch(body: IDiscountsVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IVectorSearchResponse<IDiscountsResponse> | IError>;
94
94
  }
@@ -124,7 +124,7 @@ class DiscountsApi extends asyncModules_1.default {
124
124
  * @param {string} [langCode] - Language code. Default: "en_US".
125
125
  * @param {number} [offset] - Parameter for pagination. Default: 0.
126
126
  * @param {number} [limit] - Parameter for pagination. Default: 30.
127
- * @returns {Promise<IDiscountsResponse | IError>} Returns an object with an array of found discounts and total count.
127
+ * @returns {Promise<IVectorSearchResponse<IDiscountsResponse> | IError>} Returns an object with an array of found discounts and total count.
128
128
  * @throws {IError} When isShell=false and an error occurs during the fetch
129
129
  * @description This method performs a semantic (vector) search for discounts.
130
130
  * @see {@link https://js-sdk.oneentry.cloud/docs/discounts/getDiscountsByVectorSearch getDiscountsByVectorSearch} documentation.
@@ -1,4 +1,4 @@
1
- import type { IAttributeValues, IError, ILocalizeInfo } from '../base/utils';
1
+ import type { IAttributeValues, IError, ILocalizeInfo, IVectorSearchResponse } from '../base/utils';
2
2
  /**
3
3
  * Discount type.
4
4
  */
@@ -66,10 +66,10 @@ interface IDiscountsApi {
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<IDiscountsResponse | IError>} Returns an object with an array of found discounts and total count.
69
+ * @returns {Promise<IVectorSearchResponse<IDiscountsResponse> | IError>} Returns an object with an array of found discounts and total count.
70
70
  * @throws {IError} When isShell=false and an error occurs during the fetch
71
71
  */
72
- getDiscountsByVectorSearch(body: IDiscountsVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IDiscountsResponse | IError>;
72
+ getDiscountsByVectorSearch(body: IDiscountsVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IVectorSearchResponse<IDiscountsResponse> | IError>;
73
73
  }
74
74
  /**
75
75
  * Body for semantic (vector) discount search.
@@ -53,7 +53,7 @@ export default class EventsApi extends AsyncModules implements IEvents {
53
53
  * @param {string} marker - The marker of the event to unsubscribe from. Example: "product_price_change".
54
54
  * @param {number} productId - The ID of the product to unsubscribe from. Example: 12345.
55
55
  * @param {string} [langCode] - Language code. Default: "en_US".
56
- * @returns {Promise<any | IError>} - Returns a promise that resolves to the result of the unsubscription operation or an error object if there was an issue.
56
+ * @returns {Promise<boolean | IError>} - Returns true if the unsubscription succeeded, or an error object if there was an issue.
57
57
  * @throws {IError} When isShell=false and an error occurs during the fetch
58
58
  * @description This method requires user authorization.
59
59
  * @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}.
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- /* eslint-disable jsdoc/reject-any-type */
7
6
  /* eslint-disable @typescript-eslint/no-explicit-any */
8
7
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
9
8
  /**
@@ -71,7 +70,7 @@ class EventsApi extends asyncModules_1.default {
71
70
  * @param {string} marker - The marker of the event to unsubscribe from. Example: "product_price_change".
72
71
  * @param {number} productId - The ID of the product to unsubscribe from. Example: 12345.
73
72
  * @param {string} [langCode] - Language code. Default: "en_US".
74
- * @returns {Promise<any | IError>} - Returns a promise that resolves to the result of the unsubscription operation or an error object if there was an issue.
73
+ * @returns {Promise<boolean | IError>} - Returns true if the unsubscription succeeded, or an error object if there was an issue.
75
74
  * @throws {IError} When isShell=false and an error occurs during the fetch
76
75
  * @description This method requires user authorization.
77
76
  * @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}.
@@ -62,7 +62,7 @@ export default class FileUploadingApi extends AsyncModules implements IFileUploa
62
62
  * @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
63
63
  * @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787.
64
64
  * @param {number} [fileQuery.template] - preview template identifier. Example: 1.
65
- * @returns {Promise<boolean | IError>} Returns a promise that resolves to the result of the deletion operation or an error object if there was an issue.
65
+ * @returns {Promise<boolean | IError>} Returns a promise that resolves to true when the file was deleted or an error object if there was an issue.
66
66
  * @throws {IError} When isShell=false and an error occurs during the fetch
67
67
  * @see {@link https://js-sdk.oneentry.cloud/docs/file-uploading/delete delete} documentation.
68
68
  */
@@ -116,14 +116,15 @@ class FileUploadingApi extends asyncModules_1.default {
116
116
  * @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
117
117
  * @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787.
118
118
  * @param {number} [fileQuery.template] - preview template identifier. Example: 1.
119
- * @returns {Promise<boolean | IError>} Returns a promise that resolves to the result of the deletion operation or an error object if there was an issue.
119
+ * @returns {Promise<boolean | IError>} Returns a promise that resolves to true when the file was deleted or an error object if there was an issue.
120
120
  * @throws {IError} When isShell=false and an error occurs during the fetch
121
121
  * @see {@link https://js-sdk.oneentry.cloud/docs/file-uploading/delete delete} documentation.
122
122
  */
123
123
  async delete(filename, fileQuery) {
124
124
  const query = { ...this._defaultQuery, ...fileQuery };
125
- const result = await this._fetchDelete(`?filename=${filename}&` + this._queryParamsToString(query));
126
- return result;
125
+ // The endpoint answers 200 with an empty body, which _parseJson reads as `{}`;
126
+ // _fetchBoolean turns that into the declared `true` (CMS-1072)
127
+ return this._fetchBoolean(() => this._fetchDelete(`?filename=${filename}&` + this._queryParamsToString(query)));
127
128
  }
128
129
  /**
129
130
  * Public search across the content of files attached to records.
@@ -55,7 +55,7 @@ interface IFileUploading {
55
55
  * @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
56
56
  * @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787.
57
57
  * @param {number} [fileQuery.template] - preview template identifier. Example: 1.
58
- * @returns {boolean | IError} Returns a promise that resolves to the result of the deletion operation or an error object if there was an issue.
58
+ * @returns {boolean | IError} Returns a promise that resolves to true when the file was deleted or an error object if there was an issue.
59
59
  * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
60
60
  */
61
61
  delete(filename: string, fileQuery?: IUploadingQuery): Promise<boolean | IError>;
@@ -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 { IBodyPostFormData, IFormsByMarkerDataEntity, IFormsData, IFormsDataFilter, IFormsDataSearchResponse, IFormsDataVectorSearch, IPostFormResponse, IUpdateFormsData } from './formsDataInterfaces';
5
5
  /**
6
6
  * Controllers for working with form data
@@ -76,7 +76,7 @@ export default class FormsDataApi extends AsyncModules implements IFormsData {
76
76
  /**
77
77
  * Removes `contentType` from a file value, which the endpoint does not accept.
78
78
  * @param {T} value - Value of a `file` / `image` / `groupOfImages` field, after the uploads.
79
- * @returns {T} The same value, without `contentType`.
79
+ * @returns {T} The value without `contentType`; entries that carried it are copies, the caller's objects are not modified.
80
80
  * @description `FileUploading.upload` returns `contentType` and form data rejects it,
81
81
  * so it is stripped from an array of values and from a lone value object alike. A value
82
82
  * of any other shape is returned untouched and the endpoint names the field it cannot
@@ -166,10 +166,10 @@ export default class FormsDataApi extends AsyncModules implements IFormsData {
166
166
  * @param {string} [langCode] - Language code. Default: "en_US".
167
167
  * @param {number} [offset] - Parameter for pagination. Default: 0.
168
168
  * @param {number} [limit] - Parameter for pagination. Default: 30.
169
- * @returns {Promise<IFormsDataSearchResponse | IError>} Returns an object with an array of found form data records and total count.
169
+ * @returns {Promise<IVectorSearchResponse<IFormsDataSearchResponse> | IError>} Returns an object with an array of found form data records and total count.
170
170
  * @throws {IError} When isShell=false and an error occurs during the fetch
171
171
  * @description This method performs a semantic (vector) search for form data.
172
172
  * @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/getFormsDataByVectorSearch getFormsDataByVectorSearch} documentation.
173
173
  */
174
- getFormsDataByVectorSearch(body: IFormsDataVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IFormsDataSearchResponse | IError>;
174
+ getFormsDataByVectorSearch(body: IFormsDataVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IVectorSearchResponse<IFormsDataSearchResponse> | IError>;
175
175
  }
@@ -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
  /**
@@ -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.