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
package/changelog.md CHANGED
@@ -1,5 +1,58 @@
1
1
  # SDK Change Log
2
2
 
3
+ ## v.1.0.173
4
+
5
+ ### What's Changed
6
+
7
+ - **⚠️ Breaking (types): `FileUploading.upload` and `FileUploading.delete` require `fileQuery`, and `IUploadingQuery` requires `type`, `entity` and `id`.** The signature and the JSDoc declared all of them optional, and the SDK filled the gaps with `null` — which the endpoint refuses: without any of the three both methods answer `400 type should not be empty; entity should not be empty; id should not be empty`, and a `delete` without `type` leaves the file in place. A call that compiled could never succeed. It is now a compile error instead of a `400` at run time; code that already passed a full `fileQuery` is unaffected. `width`, `height`, `compress` and `template` stay optional. The per-field `fileQuery` of `postFormsData` is unchanged — there the SDK still picks a folder when none is given (CMS-1085).
8
+
9
+ - **`IntegrationCollections` types accept the calls the API accepts.** `ICollectionFormObject.formData` was declared as a map keyed by language only, so the flat array `[{ marker, type, value }]` shown in the JSDoc example of `createICollectionRow` — and stored by the platform — did not compile; it is now `ICollectionFormData[] | Record<string, ICollectionFormData[]>`. All four fields of `ICollectionQuery` were required, so `{ limit, offset }` did not compile either; they are optional now. `getICollections` takes the new `ICollectionsListQuery` (`limit`, `offset`): the collection list has no entity filter. The JSDoc of both list methods gave the pagination defaults swapped (`limit` 0, `offset` 30); the code has always used `limit` 30, `offset` 0, and so does the JSDoc now (CMS-1078, CMS-1086).
10
+
11
+ - **`IFilterParams.attributeMarker` and `conditionValue` are optional.** A filter entry may select by `statusMarker` (or `pageUrls`, `title`) alone — `getProducts([{ statusMarker: 'sale' }])` is answered and filtered by the endpoint (an unknown status gives `total: 0`), but the type refused it without a cast (CMS-1086).
12
+
13
+ - **`System.getApiStat` is typed.** It returned `Promise<unknown>` and its JSDoc promised "object with date and count"; the endpoint answers an array of one-key day objects, `[{ "2026-10-25": 17280 }, { "2026-10-26": 13671 }]`. The return type is now `IApiStatEntry[] | IError`, with `IApiStatEntry = Record<string, number>` exported (CMS-1077).
14
+
15
+ ### What's Fixed
16
+
17
+ - **JSDoc that the documentation site is generated from.**
18
+ - `IConfig.traficLimit` and the `config.traficLimit` parameter of `defineOneEntry` said "set it to `false` to save traffic" — the opposite of the code: `true` makes the SDK skip its follow-up requests (one request instead of six for a quick page search) and shortens some results to `{ id, title }` cards (CMS-1084).
19
+ - `Templates.getAllTemplates`, `getTemplateByType` and `getTemplateByMarker` named `GroupedTemplatesObject` and `TemplateEntity`, which do not exist; they name `BlockType` and `ITemplateEntity` now, and `getTemplateByType` is described as the array it returns (CMS-1077).
20
+ - `AuthProvider.getActiveSessionsByMarker` carried the description of `getAuthProviderByMarker`; it describes the user's active sessions now (CMS-1086).
21
+ - `ProductStatuses.getProductsByStatusMarker` and `validateMarker` called their argument a product marker; it is a product status marker (CMS-1086).
22
+ - Examples carried Russian data into English documentation: `"Ivan"` in the order examples and `"ru-RU"` in `IActiveSession` are `"John"` and `"en-US"` (CMS-1086).
23
+
24
+ ### Tests
25
+
26
+ - **`callercontracts.spec.ts` checks the types against the API.** ts-jest type-checks the file, so a type that drifts back fails the run: a flat collection `formData`, `{ limit, offset }` as a collection query, a status-only product filter and the `getApiStat` array must compile, and `upload` / `delete` without `fileQuery` must not (`@ts-expect-error`). The test client is typed now — it was `any`, which would have let such checks pass silently. Against 1.0.172 the file does not compile, with six errors naming exactly these types.
27
+
28
+ ## v.1.0.172
29
+
30
+ ### What's Fixed
31
+
32
+ - **`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).
33
+
34
+ - **`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).
35
+
36
+ - **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).
37
+
38
+ - **`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).
39
+
40
+ - **`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).
41
+
42
+ ### What's Changed
43
+
44
+ - **`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).
45
+
46
+ - **`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).
47
+
48
+ - **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).
49
+
50
+ - **`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).
51
+
52
+ ### Tests
53
+
54
+ - **`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.
55
+
3
56
  ## v.1.0.171
4
57
 
5
58
  ### 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.
@@ -233,9 +233,9 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
233
233
  * Getting active user sessions data.
234
234
  * @handleName getActiveSessionsByMarker
235
235
  * @param {string} marker - The text identifier of the authorization provider. Example: "email".
236
- * @returns {Promise<IActiveSession[] | IError>} Returns an auth provider object.
236
+ * @returns {Promise<IActiveSession[] | IError>} Array of the authenticated user's active sessions for this provider, one per device (`deviceInfo`).
237
237
  * @throws {IError} When isShell=false and an error occurs during the fetch
238
- * @description Getting a single authorization provider object by marker.
238
+ * @description Getting the authenticated user's active sessions for the authorization provider. This method requires user authorization.
239
239
  * @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/getActiveSessionsByMarker getActiveSessionsByMarker} documentation.
240
240
  */
241
241
  getActiveSessionsByMarker(marker: string): Promise<IActiveSession[] | IError>;
@@ -366,9 +366,9 @@ class AuthProviderApi extends asyncModules_1.default {
366
366
  * Getting active user sessions data.
367
367
  * @handleName getActiveSessionsByMarker
368
368
  * @param {string} marker - The text identifier of the authorization provider. Example: "email".
369
- * @returns {Promise<IActiveSession[] | IError>} Returns an auth provider object.
369
+ * @returns {Promise<IActiveSession[] | IError>} Array of the authenticated user's active sessions for this provider, one per device (`deviceInfo`).
370
370
  * @throws {IError} When isShell=false and an error occurs during the fetch
371
- * @description Getting a single authorization provider object by marker.
371
+ * @description Getting the authenticated user's active sessions for the authorization provider. This method requires user authorization.
372
372
  * @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/getActiveSessionsByMarker getActiveSessionsByMarker} documentation.
373
373
  */
374
374
  async getActiveSessionsByMarker(marker) {
@@ -405,11 +405,11 @@ interface IAuthPostBody {
405
405
  {
406
406
  "os": "Win32",
407
407
  "browser": "Node.js/22",
408
- "location": "ru-RU"
408
+ "location": "en-US"
409
409
  }
410
410
  * @property {string} deviceInfo.os - The operating system of the active session. Example: "Win32".
411
411
  * @property {string} deviceInfo.browser - The browser used in the active session. Example: "Node.js/22".
412
- * @property {string} deviceInfo.location - The location of the active session. Example: "ru-RU".
412
+ * @property {string} deviceInfo.location - The location of the active session. Example: "en-US".
413
413
  * @description This interface defines the structure of the body used in authentication requests, containing an array of authentication data.
414
414
  */
415
415
  interface IActiveSession {
@@ -419,7 +419,7 @@ interface IActiveSession {
419
419
  * @interface IDeviceInfo
420
420
  * @property {string} os - The operating system of the active session. Example: "Win32".
421
421
  * @property {string} browser - The browser used in the active session. Example: "Node.js/22".
422
- * @property {string} location - The locale of the active session. Example: "ru-RU".
422
+ * @property {string} location - The locale of the active session. Example: "en-US".
423
423
  * @description Information about the device tied to an active authentication session.
424
424
  */
425
425
  interface IDeviceInfo {
@@ -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
  }
@@ -4,7 +4,7 @@
4
4
  * @property {string} [guestId] - Guest identifier sent as the `x-guest-id` header on unauthenticated requests. Lets cart/wishlist/activity endpoints work for a guest. In the browser a stable id is auto-generated (localStorage) when omitted; on the server pass a per-visitor id. Can also be set later via `setGuestId`.
5
5
  * @property {string} [deviceMetadata] - Device-metadata string sent as the `x-device-metadata` header on POST requests and token refresh, overriding the environment-derived fingerprint. The API binds refresh tokens to this header, so server-side flows that issue tokens on behalf of a browser (e.g. an OAuth code exchange) must pass the browser's string here — otherwise the token is bound to the server's fingerprint and cannot be refreshed from the browser. Obtain the string in the browser via `getDeviceMetadata()`. Can also be set later via `setDeviceMetadata`.
6
6
  * @property {string} [langCode] - specify the default language to avoid specifying it in every request.
7
- * @property {boolean} [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.
7
+ * @property {boolean} [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 (full pages behind quick search results, products of page blocks), and some results change shape — e.g. `searchPage` returns short `{ id, title }` cards. Default: false.
8
8
  * @property {boolean} [rawData] - Set to true to keep an attribute's nested `additionalFields` as the
9
9
  * array the API sends, instead of the marker-keyed map the SDK builds by default. It turns off only that
10
10
  * transformation — locale unwrapping, sorting by `position`, single-file unwrapping and number casting
@@ -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}.
@@ -23,7 +23,7 @@ export default class FileUploadingApi extends AsyncModules implements IFileUploa
23
23
  * Upload file function.
24
24
  * @handleName upload
25
25
  * @param {File | Blob} file - File to upload. Example: `new File(["content"], "file.png", {"type": "image/png"})`
26
- * @param {IUploadingQuery} [fileQuery] - Optional set query parameters.
26
+ * @param {IUploadingQuery} fileQuery - Where the file lives in the storage. Required: without `type`, `entity` and `id` the endpoint answers `400 … should not be empty`.
27
27
  * @example
28
28
  {
29
29
  "type": "page",
@@ -34,9 +34,9 @@ export default class FileUploadingApi extends AsyncModules implements IFileUploa
34
34
  "compress": true,
35
35
  "template": 1
36
36
  }
37
- * @param {string} [fileQuery.type] - Type, determines the folder name in the storage. Example: "page".
38
- * @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
39
- * @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787.
37
+ * @param {string} fileQuery.type - Type, determines the folder name in the storage. Example: "page".
38
+ * @param {string} fileQuery.entity - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
39
+ * @param {number} fileQuery.id - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787.
40
40
  * @param {number} [fileQuery.width] - Optional width parameter. Example: 0.
41
41
  * @param {number} [fileQuery.height] - Optional height parameter. Example: 0.
42
42
  * @param {boolean} [fileQuery.compress] - Optional flag of optimization (compression) for images. Example: true.
@@ -45,12 +45,12 @@ export default class FileUploadingApi extends AsyncModules implements IFileUploa
45
45
  * @throws {IError} When isShell=false and an error occurs during the fetch
46
46
  * @see {@link https://js-sdk.oneentry.cloud/docs/file-uploading/upload upload} documentation.
47
47
  */
48
- upload(file: File | Blob, fileQuery?: IUploadingQuery): Promise<IUploadingReturn[] | IError>;
48
+ upload(file: File | Blob, fileQuery: IUploadingQuery): Promise<IUploadingReturn[] | IError>;
49
49
  /**
50
50
  * Deletes a file from the cloud file storage.
51
51
  * @handleName delete
52
52
  * @param {string} filename - File name. Example: "file.png".
53
- * @param {IUploadingQuery} [fileQuery] - Optional set query parameters.
53
+ * @param {IUploadingQuery} fileQuery - Where the file lives in the storage. Required: without `type`, `entity` and `id` the endpoint answers `400 … should not be empty`.
54
54
  * @example
55
55
  {
56
56
  "type": "page",
@@ -58,15 +58,15 @@ export default class FileUploadingApi extends AsyncModules implements IFileUploa
58
58
  "id": 3787,
59
59
  "template": 1
60
60
  }
61
- * @param {string} [fileQuery.type] - Type, determines the folder name in the storage. Example: "page".
62
- * @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
63
- * @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787.
61
+ * @param {string} fileQuery.type - Type, determines the folder name in the storage. Example: "page".
62
+ * @param {string} fileQuery.entity - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
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
  */
69
- delete(filename: string, fileQuery?: IUploadingQuery): Promise<boolean | IError>;
69
+ delete(filename: string, fileQuery: IUploadingQuery): Promise<boolean | IError>;
70
70
  /**
71
71
  * Public search across the content of files attached to records.
72
72
  * @handleName searchFileContent
@@ -56,9 +56,6 @@ class FileUploadingApi extends asyncModules_1.default {
56
56
  super(state);
57
57
  /** FileUploadingApi class */
58
58
  this._defaultQuery = {
59
- type: null,
60
- entity: null,
61
- id: null,
62
59
  width: null,
63
60
  height: null,
64
61
  compress: null,
@@ -69,7 +66,7 @@ class FileUploadingApi extends asyncModules_1.default {
69
66
  * Upload file function.
70
67
  * @handleName upload
71
68
  * @param {File | Blob} file - File to upload. Example: `new File(["content"], "file.png", {"type": "image/png"})`
72
- * @param {IUploadingQuery} [fileQuery] - Optional set query parameters.
69
+ * @param {IUploadingQuery} fileQuery - Where the file lives in the storage. Required: without `type`, `entity` and `id` the endpoint answers `400 … should not be empty`.
73
70
  * @example
74
71
  {
75
72
  "type": "page",
@@ -80,9 +77,9 @@ class FileUploadingApi extends asyncModules_1.default {
80
77
  "compress": true,
81
78
  "template": 1
82
79
  }
83
- * @param {string} [fileQuery.type] - Type, determines the folder name in the storage. Example: "page".
84
- * @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
85
- * @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787.
80
+ * @param {string} fileQuery.type - Type, determines the folder name in the storage. Example: "page".
81
+ * @param {string} fileQuery.entity - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
82
+ * @param {number} fileQuery.id - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787.
86
83
  * @param {number} [fileQuery.width] - Optional width parameter. Example: 0.
87
84
  * @param {number} [fileQuery.height] - Optional height parameter. Example: 0.
88
85
  * @param {boolean} [fileQuery.compress] - Optional flag of optimization (compression) for images. Example: true.
@@ -104,7 +101,7 @@ class FileUploadingApi extends asyncModules_1.default {
104
101
  * Deletes a file from the cloud file storage.
105
102
  * @handleName delete
106
103
  * @param {string} filename - File name. Example: "file.png".
107
- * @param {IUploadingQuery} [fileQuery] - Optional set query parameters.
104
+ * @param {IUploadingQuery} fileQuery - Where the file lives in the storage. Required: without `type`, `entity` and `id` the endpoint answers `400 … should not be empty`.
108
105
  * @example
109
106
  {
110
107
  "type": "page",
@@ -112,18 +109,19 @@ class FileUploadingApi extends asyncModules_1.default {
112
109
  "id": 3787,
113
110
  "template": 1
114
111
  }
115
- * @param {string} [fileQuery.type] - Type, determines the folder name in the storage. Example: "page".
116
- * @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
117
- * @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787.
112
+ * @param {string} fileQuery.type - Type, determines the folder name in the storage. Example: "page".
113
+ * @param {string} fileQuery.entity - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
114
+ * @param {number} fileQuery.id - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787.
118
115
  * @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.
116
+ * @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
117
  * @throws {IError} When isShell=false and an error occurs during the fetch
121
118
  * @see {@link https://js-sdk.oneentry.cloud/docs/file-uploading/delete delete} documentation.
122
119
  */
123
120
  async delete(filename, fileQuery) {
124
121
  const query = { ...this._defaultQuery, ...fileQuery };
125
- const result = await this._fetchDelete(`?filename=${filename}&` + this._queryParamsToString(query));
126
- return result;
122
+ // The endpoint answers 200 with an empty body, which _parseJson reads as `{}`;
123
+ // _fetchBoolean turns that into the declared `true` (CMS-1072)
124
+ return this._fetchBoolean(() => this._fetchDelete(`?filename=${filename}&` + this._queryParamsToString(query)));
127
125
  }
128
126
  /**
129
127
  * Public search across the content of files attached to records.
@@ -17,7 +17,7 @@ interface IFileUploading {
17
17
  * Upload file function.
18
18
  * @handleName upload
19
19
  * @param {File | Blob} file - File to upload. Example: `new File(["content"], "file.png", {"type": "image/png"})`
20
- * @param {IUploadingQuery} [fileQuery] - Optional set query parameters.
20
+ * @param {IUploadingQuery} fileQuery - Where the file lives in the storage. Required: without `type`, `entity` and `id` the endpoint answers `400 … should not be empty`.
21
21
  * @example
22
22
  {
23
23
  "type": "page",
@@ -28,9 +28,9 @@ interface IFileUploading {
28
28
  "compress": true,
29
29
  "template": 1
30
30
  }
31
- * @param {string} [fileQuery.type] - Type, determines the folder name in the storage. Example: "page".
32
- * @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
33
- * @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787.
31
+ * @param {string} fileQuery.type - Type, determines the folder name in the storage. Example: "page".
32
+ * @param {string} fileQuery.entity - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
33
+ * @param {number} fileQuery.id - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787.
34
34
  * @param {number} [fileQuery.width] - Optional width parameter. Example: 0.
35
35
  * @param {number} [fileQuery.height] - Optional height parameter. Example: 0.
36
36
  * @param {boolean} [fileQuery.compress] - Optional flag of optimization (compression) for images. Example: true.
@@ -38,12 +38,12 @@ interface IFileUploading {
38
38
  * @returns {IUploadingReturn[]} Uploads a file to an Amazon S3-compatible cloud file storage.
39
39
  * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
40
40
  */
41
- upload(file: File | Blob, fileQuery?: IUploadingQuery): Promise<IUploadingReturn[] | IError>;
41
+ upload(file: File | Blob, fileQuery: IUploadingQuery): Promise<IUploadingReturn[] | IError>;
42
42
  /**
43
43
  * Deletes a file from the cloud file storage.
44
44
  * @handleName delete
45
45
  * @param {string} [filename] - File name. Example: "file.png".
46
- * @param {IUploadingQuery} [fileQuery] - Optional set query parameters.
46
+ * @param {IUploadingQuery} fileQuery - Where the file lives in the storage. Required: without `type`, `entity` and `id` the endpoint answers `400 … should not be empty`.
47
47
  * @example
48
48
  {
49
49
  "type": "page",
@@ -51,14 +51,14 @@ interface IFileUploading {
51
51
  "id": 3787,
52
52
  "template": 1
53
53
  }
54
- * @param {string} [fileQuery.type] - Type, determines the folder name in the storage. Example: "page".
55
- * @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
56
- * @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787.
54
+ * @param {string} fileQuery.type - Type, determines the folder name in the storage. Example: "page".
55
+ * @param {string} fileQuery.entity - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
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
- delete(filename: string, fileQuery?: IUploadingQuery): Promise<boolean | IError>;
61
+ delete(filename: string, fileQuery: IUploadingQuery): Promise<boolean | IError>;
62
62
  /**
63
63
  * Get file by parameters.
64
64
  * @handleName getFile
@@ -106,12 +106,12 @@ interface IFileEntity {
106
106
  * @property {number} [width] - Width parameter. Example: 0.
107
107
  * @property {number} [height] - Height parameter. Example: 0.
108
108
  * @property {boolean} [compress] - Flag of optimization (compression) for images. Example: true.
109
- * @description Represents a query for uploading files, including type, entity, and optional parameters like width, height, and compression.
109
+ * @description Represents a query for uploading files, including type, entity, and optional parameters like width, height, and compression. `type`, `entity` and `id` are required by the endpoint: it answers `400 … should not be empty` without any of them (CMS-1085).
110
110
  */
111
111
  interface IUploadingQuery {
112
- type: string | null;
113
- entity: string | null;
114
- id: number | null;
112
+ type: string;
113
+ entity: string;
114
+ id: number;
115
115
  [key: string]: string | number | boolean | null;
116
116
  }
117
117
  /**
@@ -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
  }