oneentry 1.0.176 → 1.0.178
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.
- package/README.md +12 -5
- package/changelog.md +116 -0
- package/dist/admins/adminsApi.js +2 -9
- package/dist/admins/adminsInterfaces.d.ts +5 -5
- package/dist/admins/adminsSchemas.d.ts +4 -4
- package/dist/admins/adminsSchemas.js +2 -2
- package/dist/attribute-sets/attributeSetsApi.d.ts +1 -1
- package/dist/attribute-sets/attributeSetsApi.js +4 -4
- package/dist/attribute-sets/attributeSetsInterfaces.d.ts +65 -14
- package/dist/attribute-sets/attributeSetsSchemas.d.ts +8 -6
- package/dist/attribute-sets/attributeSetsSchemas.js +6 -9
- package/dist/auth-provider/authProviderApi.d.ts +4 -4
- package/dist/auth-provider/authProviderApi.js +90 -23
- package/dist/auth-provider/authProviderSchemas.d.ts +1 -0
- package/dist/auth-provider/authProviderSchemas.js +1 -0
- package/dist/auth-provider/authProvidersInterfaces.d.ts +8 -6
- package/dist/base/asyncModules.d.ts +62 -1
- package/dist/base/asyncModules.js +219 -37
- package/dist/base/stateModule.d.ts +2 -0
- package/dist/base/stateModule.js +22 -12
- package/dist/base/syncModules.d.ts +18 -10
- package/dist/base/syncModules.js +100 -29
- package/dist/base/utils.d.ts +26 -21
- package/dist/base/validation.d.ts +3 -3
- package/dist/base/validation.js +6 -7
- package/dist/blocks/blocksApi.d.ts +20 -17
- package/dist/blocks/blocksApi.js +82 -64
- package/dist/blocks/blocksInterfaces.d.ts +8 -8
- package/dist/discounts/discountsApi.d.ts +9 -7
- package/dist/discounts/discountsApi.js +16 -13
- package/dist/discounts/discountsInterfaces.d.ts +14 -10
- package/dist/events/eventsApi.d.ts +3 -3
- package/dist/events/eventsApi.js +3 -3
- package/dist/events/eventsInterfaces.d.ts +10 -14
- package/dist/file-uploading/fileUploadingApi.d.ts +4 -4
- package/dist/file-uploading/fileUploadingApi.js +13 -5
- package/dist/file-uploading/fileUploadingInterfaces.d.ts +5 -6
- package/dist/filters/filtersApi.js +2 -2
- package/dist/forms/formsApi.js +2 -2
- package/dist/forms/formsInterfaces.d.ts +1 -3
- package/dist/forms/formsSchemas.d.ts +3 -6
- package/dist/forms/formsSchemas.js +2 -4
- package/dist/forms-data/formsDataApi.d.ts +27 -1
- package/dist/forms-data/formsDataApi.js +119 -68
- package/dist/forms-data/formsDataInterfaces.d.ts +17 -13
- package/dist/general-types/generalTypesInterfaces.d.ts +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.js +50 -7
- package/dist/integration-collections/integrationCollectionsApi.d.ts +15 -4
- package/dist/integration-collections/integrationCollectionsApi.js +41 -14
- package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +8 -9
- package/dist/integration-collections/integrationCollectionsSchemas.d.ts +0 -2
- package/dist/integration-collections/integrationCollectionsSchemas.js +0 -1
- package/dist/menus/menusApi.js +1 -1
- package/dist/orders/ordersApi.d.ts +1 -13
- package/dist/orders/ordersApi.js +21 -42
- package/dist/orders/ordersInterfaces.d.ts +21 -14
- package/dist/pages/pagesApi.d.ts +8 -6
- package/dist/pages/pagesApi.js +48 -33
- package/dist/pages/pagesInterfaces.d.ts +20 -16
- package/dist/pages/pagesSchemas.d.ts +0 -3
- package/dist/pages/pagesSchemas.js +0 -1
- package/dist/payments/paymentsApi.d.ts +10 -11
- package/dist/payments/paymentsApi.js +22 -18
- package/dist/payments/paymentsInterfaces.d.ts +12 -14
- package/dist/payments/paymentsSchemas.d.ts +21 -20
- package/dist/payments/paymentsSchemas.js +5 -8
- package/dist/product-statuses/productStatusesApi.d.ts +1 -1
- package/dist/product-statuses/productStatusesApi.js +3 -3
- package/dist/product-statuses/productStatusesInterfaces.d.ts +1 -4
- package/dist/products/productsApi.d.ts +50 -64
- package/dist/products/productsApi.js +79 -80
- package/dist/products/productsInterfaces.d.ts +59 -90
- package/dist/search/searchApi.d.ts +3 -2
- package/dist/search/searchApi.js +7 -4
- package/dist/search/searchInterfaces.d.ts +2 -1
- package/dist/sitemap/sitemapInterfaces.d.ts +10 -6
- package/dist/subscriptions/subscriptionsApi.d.ts +1 -1
- package/dist/subscriptions/subscriptionsApi.js +1 -1
- package/dist/subscriptions/subscriptionsInterfaces.d.ts +1 -1
- package/dist/system/systemApi.d.ts +2 -0
- package/dist/system/systemApi.js +2 -0
- package/dist/system/systemInterfaces.d.ts +2 -0
- package/dist/templates/templatesApi.d.ts +2 -2
- package/dist/templates/templatesApi.js +12 -11
- package/dist/templates/templatesInterfaces.d.ts +2 -2
- package/dist/templates-preview/templatesPreviewApi.js +2 -2
- package/dist/templates-preview/templatesPreviewInterfaces.d.ts +23 -13
- package/dist/templates-preview/templatesPreviewSchemas.d.ts +7 -0
- package/dist/templates-preview/templatesPreviewSchemas.js +2 -0
- package/dist/user-groups/userGroupsApi.js +5 -5
- package/dist/user-groups/userGroupsSchemas.d.ts +4 -4
- package/dist/users/usersApi.d.ts +1 -1
- package/dist/users/usersApi.js +28 -15
- package/dist/users/usersInterfaces.d.ts +2 -9
- package/dist/web-socket/lazySocket.d.ts +6 -5
- package/dist/web-socket/lazySocket.js +212 -15
- package/dist/web-socket/wsApi.d.ts +7 -4
- package/dist/web-socket/wsApi.js +49 -12
- package/dist/web-socket/wsInterfaces.d.ts +41 -4
- package/esm/admins/adminsApi.js +2 -9
- package/esm/admins/adminsInterfaces.d.ts +5 -5
- package/esm/admins/adminsSchemas.d.ts +4 -4
- package/esm/admins/adminsSchemas.js +2 -2
- package/esm/attribute-sets/attributeSetsApi.d.ts +1 -1
- package/esm/attribute-sets/attributeSetsApi.js +4 -4
- package/esm/attribute-sets/attributeSetsInterfaces.d.ts +65 -14
- package/esm/attribute-sets/attributeSetsSchemas.d.ts +8 -6
- package/esm/attribute-sets/attributeSetsSchemas.js +6 -9
- package/esm/auth-provider/authProviderApi.d.ts +4 -4
- package/esm/auth-provider/authProviderApi.js +90 -23
- package/esm/auth-provider/authProviderSchemas.d.ts +1 -0
- package/esm/auth-provider/authProviderSchemas.js +1 -0
- package/esm/auth-provider/authProvidersInterfaces.d.ts +8 -6
- package/esm/base/asyncModules.d.ts +62 -1
- package/esm/base/asyncModules.js +219 -37
- package/esm/base/stateModule.d.ts +2 -0
- package/esm/base/stateModule.js +22 -12
- package/esm/base/syncModules.d.ts +18 -10
- package/esm/base/syncModules.js +99 -29
- package/esm/base/utils.d.ts +26 -21
- package/esm/base/validation.d.ts +3 -3
- package/esm/base/validation.js +6 -7
- package/esm/blocks/blocksApi.d.ts +20 -17
- package/esm/blocks/blocksApi.js +82 -64
- package/esm/blocks/blocksInterfaces.d.ts +8 -8
- package/esm/discounts/discountsApi.d.ts +9 -7
- package/esm/discounts/discountsApi.js +16 -13
- package/esm/discounts/discountsInterfaces.d.ts +14 -10
- package/esm/events/eventsApi.d.ts +3 -3
- package/esm/events/eventsApi.js +3 -3
- package/esm/events/eventsInterfaces.d.ts +10 -14
- package/esm/file-uploading/fileUploadingApi.d.ts +4 -4
- package/esm/file-uploading/fileUploadingApi.js +13 -5
- package/esm/file-uploading/fileUploadingInterfaces.d.ts +5 -6
- package/esm/filters/filtersApi.js +2 -2
- package/esm/forms/formsApi.js +2 -2
- package/esm/forms/formsInterfaces.d.ts +1 -3
- package/esm/forms/formsSchemas.d.ts +3 -6
- package/esm/forms/formsSchemas.js +2 -4
- package/esm/forms-data/formsDataApi.d.ts +27 -1
- package/esm/forms-data/formsDataApi.js +119 -68
- package/esm/forms-data/formsDataInterfaces.d.ts +17 -13
- package/esm/general-types/generalTypesInterfaces.d.ts +1 -1
- package/esm/index.d.ts +7 -6
- package/esm/index.js +50 -7
- package/esm/integration-collections/integrationCollectionsApi.d.ts +15 -4
- package/esm/integration-collections/integrationCollectionsApi.js +41 -14
- package/esm/integration-collections/integrationCollectionsInterfaces.d.ts +8 -9
- package/esm/integration-collections/integrationCollectionsSchemas.d.ts +0 -2
- package/esm/integration-collections/integrationCollectionsSchemas.js +0 -1
- package/esm/menus/menusApi.js +1 -1
- package/esm/orders/ordersApi.d.ts +1 -13
- package/esm/orders/ordersApi.js +21 -42
- package/esm/orders/ordersInterfaces.d.ts +21 -14
- package/esm/pages/pagesApi.d.ts +8 -6
- package/esm/pages/pagesApi.js +48 -33
- package/esm/pages/pagesInterfaces.d.ts +20 -16
- package/esm/pages/pagesSchemas.d.ts +0 -3
- package/esm/pages/pagesSchemas.js +0 -1
- package/esm/payments/paymentsApi.d.ts +10 -11
- package/esm/payments/paymentsApi.js +22 -18
- package/esm/payments/paymentsInterfaces.d.ts +12 -14
- package/esm/payments/paymentsSchemas.d.ts +21 -20
- package/esm/payments/paymentsSchemas.js +5 -8
- package/esm/product-statuses/productStatusesApi.d.ts +1 -1
- package/esm/product-statuses/productStatusesApi.js +3 -3
- package/esm/product-statuses/productStatusesInterfaces.d.ts +1 -4
- package/esm/products/productsApi.d.ts +50 -64
- package/esm/products/productsApi.js +79 -80
- package/esm/products/productsInterfaces.d.ts +59 -90
- package/esm/search/searchApi.d.ts +3 -2
- package/esm/search/searchApi.js +7 -4
- package/esm/search/searchInterfaces.d.ts +2 -1
- package/esm/sitemap/sitemapInterfaces.d.ts +10 -6
- package/esm/subscriptions/subscriptionsApi.d.ts +1 -1
- package/esm/subscriptions/subscriptionsApi.js +1 -1
- package/esm/subscriptions/subscriptionsInterfaces.d.ts +1 -1
- package/esm/system/systemApi.d.ts +2 -0
- package/esm/system/systemApi.js +2 -0
- package/esm/system/systemInterfaces.d.ts +2 -0
- package/esm/templates/templatesApi.d.ts +2 -2
- package/esm/templates/templatesApi.js +11 -10
- package/esm/templates/templatesInterfaces.d.ts +2 -2
- package/esm/templates-preview/templatesPreviewApi.js +2 -2
- package/esm/templates-preview/templatesPreviewInterfaces.d.ts +23 -13
- package/esm/templates-preview/templatesPreviewSchemas.d.ts +7 -0
- package/esm/templates-preview/templatesPreviewSchemas.js +2 -0
- package/esm/user-groups/userGroupsApi.js +5 -5
- package/esm/user-groups/userGroupsSchemas.d.ts +4 -4
- package/esm/users/usersApi.d.ts +1 -1
- package/esm/users/usersApi.js +28 -15
- package/esm/users/usersInterfaces.d.ts +2 -9
- package/esm/web-socket/lazySocket.d.ts +6 -5
- package/esm/web-socket/lazySocket.js +212 -15
- package/esm/web-socket/wsApi.d.ts +7 -4
- package/esm/web-socket/wsApi.js +49 -12
- package/esm/web-socket/wsInterfaces.d.ts +41 -4
- package/package.json +2 -2
|
@@ -20,7 +20,7 @@ interface IEvents {
|
|
|
20
20
|
* @handleName subscribeByMarker
|
|
21
21
|
* @param {string} marker - The marker identifying the event. Example: "product_price_change".
|
|
22
22
|
* @param {number} productId - The ID of the product to subscribe to. Example: 12345.
|
|
23
|
-
* @param {string} [langCode] - Optional language code for localization. Default:
|
|
23
|
+
* @param {string} [langCode] - Optional language code for localization. Default: the client's language.
|
|
24
24
|
* @returns {Promise<boolean | IError>} A promise that resolves to any type or an error.
|
|
25
25
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
26
26
|
* @description This method subscribes to an event on a product by its marker.
|
|
@@ -31,7 +31,7 @@ interface IEvents {
|
|
|
31
31
|
* @handleName unsubscribeByMarker
|
|
32
32
|
* @param {string} marker - The marker identifying the event. Example: "product_price_change".
|
|
33
33
|
* @param {number} productId - ID of the product to unsubscribe from. Example: 12345.
|
|
34
|
-
* @param {string} [langCode] - Optional language code for localization. Default:
|
|
34
|
+
* @param {string} [langCode] - Optional language code for localization. Default: the client's language.
|
|
35
35
|
* @returns {Promise<boolean | IError>} A promise that resolves to any type or an error.
|
|
36
36
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
37
37
|
* @description This method unsubscribes from an event on a product by its marker.
|
|
@@ -42,7 +42,7 @@ interface IEvents {
|
|
|
42
42
|
* @handleName getAllEvents
|
|
43
43
|
* @returns {Promise<IContentApiEvent[] | IError>} A promise that resolves to an array of events or an error.
|
|
44
44
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
45
|
-
* @description This method returns all available events.
|
|
45
|
+
* @description This method returns all available events. This method requires user authorization — without it the API answers `401 Unauthorized`.
|
|
46
46
|
*/
|
|
47
47
|
getAllEvents(): Promise<IContentApiEvent[] | IError>;
|
|
48
48
|
/**
|
|
@@ -85,16 +85,12 @@ interface IEvents {
|
|
|
85
85
|
* @property {number} total - Total number of found records. Example: 100.
|
|
86
86
|
* @property {ISubscriptionItem[]} items - Subscriptions, each with an event marker and a product ID.
|
|
87
87
|
* @example
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
productId:
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
eventMarker: 'product_stock_update',
|
|
95
|
-
productId: 67890
|
|
96
|
-
}
|
|
97
|
-
]
|
|
88
|
+
{
|
|
89
|
+
"total": 1,
|
|
90
|
+
"items": [
|
|
91
|
+
{ "eventMarker": "lessPrice", "productId": 2954 }
|
|
92
|
+
]
|
|
93
|
+
}
|
|
98
94
|
* @property { string } items.eventMarker - Event marker.
|
|
99
95
|
* @property { number } items.productId - Product ID.
|
|
100
96
|
* @description Represents a response from the events API containing a total count and an array of subscription items.
|
|
@@ -173,4 +169,4 @@ interface ISubscribeFormEvent {
|
|
|
173
169
|
formDataId: number;
|
|
174
170
|
status?: string;
|
|
175
171
|
}
|
|
176
|
-
export type { IContentApiEvent, IEvents, IFormSubscriptionsResponse, IListFormSubscription, ISubscribeBody, ISubscribeFormEvent, ISubscriptions, };
|
|
172
|
+
export type { IContentApiEvent, IEvents, IFormSubscriptionsResponse, IListFormSubscription, ISubscribeBody, ISubscribeFormEvent, ISubscriptionItem, ISubscriptions, };
|
|
@@ -99,6 +99,7 @@ export default class FileUploadingApi extends AsyncModules implements IFileUploa
|
|
|
99
99
|
* @param {string} filename - The name to give the created file.
|
|
100
100
|
* @param {string} [mimeType] - Optional MIME type for the file.
|
|
101
101
|
* @returns {Promise<File>} A promise that resolves to a File object.
|
|
102
|
+
* @throws {Error} When the URL answers with an error status — the body of the error page is not turned into a file.
|
|
102
103
|
*/
|
|
103
104
|
createFileFromUrl(url: string, filename: string, mimeType?: string): Promise<File>;
|
|
104
105
|
/**
|
|
@@ -108,10 +109,9 @@ export default class FileUploadingApi extends AsyncModules implements IFileUploa
|
|
|
108
109
|
* @param {string} type - Storage type; determines the folder the file is stored in, for example `"page"`. Example: "page".
|
|
109
110
|
* @param {string} entity - Name of the entity the file belongs to; sets the folder name in the storage. Example: "editor".
|
|
110
111
|
* @param {string} filename - File name. Example: "file.png".
|
|
111
|
-
* @param {string} [template] -
|
|
112
|
-
* @returns {Promise<Response
|
|
113
|
-
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
112
|
+
* @param {string} [template] - Kept for compatibility: `GET /files` ignores it — the answer is the original file with any value, an unknown template included (CMS-1101, CMS-1128). Previews are made on `upload`.
|
|
113
|
+
* @returns {Promise<Response>} Resolves to the raw `Response` of the request — also on an error: check `response.ok`. A missing file answers `404` with a JSON body but a `content-type` taken from the requested file name (`image/png` …).
|
|
114
114
|
* @see {@link https://js-sdk.oneentry.cloud/docs/file-uploading/getFile getFile} documentation.
|
|
115
115
|
*/
|
|
116
|
-
getFile(id: number, type: string, entity: string, filename: string, template?: string): Promise<Response
|
|
116
|
+
getFile(id: number, type: string, entity: string, filename: string, template?: string): Promise<Response>;
|
|
117
117
|
}
|
|
@@ -83,7 +83,10 @@ export default class FileUploadingApi extends AsyncModules {
|
|
|
83
83
|
const query = { ...this._defaultQuery, ...fileQuery };
|
|
84
84
|
// The endpoint answers 200 with an empty body, which _parseJson reads as `{}`;
|
|
85
85
|
// _fetchBoolean turns that into the declared `true` (CMS-1072)
|
|
86
|
-
return this._fetchBoolean(() => this._fetchDelete(
|
|
86
|
+
return this._fetchBoolean(() => this._fetchDelete(
|
|
87
|
+
// The name is encoded like the other parameters: `#` cut the query and dropped
|
|
88
|
+
// type/entity/id, `&id=` added parameters of its own
|
|
89
|
+
`?` + this._queryParamsToString({ filename, ...query })));
|
|
87
90
|
}
|
|
88
91
|
/**
|
|
89
92
|
* Public search across the content of files attached to records.
|
|
@@ -133,10 +136,15 @@ export default class FileUploadingApi extends AsyncModules {
|
|
|
133
136
|
* @param {string} filename - The name to give the created file.
|
|
134
137
|
* @param {string} [mimeType] - Optional MIME type for the file.
|
|
135
138
|
* @returns {Promise<File>} A promise that resolves to a File object.
|
|
139
|
+
* @throws {Error} When the URL answers with an error status — the body of the error page is not turned into a file.
|
|
136
140
|
*/
|
|
137
141
|
async createFileFromUrl(url, filename, mimeType) {
|
|
138
142
|
// eslint-disable-next-line no-undef
|
|
139
143
|
const response = await fetch(url);
|
|
144
|
+
// A 404 page of the storage used to become the "file" and was then uploaded as is
|
|
145
|
+
if (!response.ok) {
|
|
146
|
+
throw new Error(`OneEntry SDK: createFileFromUrl got ${response.status} from ${url}`);
|
|
147
|
+
}
|
|
140
148
|
const blob = await response.blob();
|
|
141
149
|
const file = new File([blob], filename, { type: mimeType || blob.type });
|
|
142
150
|
return file;
|
|
@@ -148,14 +156,14 @@ export default class FileUploadingApi extends AsyncModules {
|
|
|
148
156
|
* @param {string} type - Storage type; determines the folder the file is stored in, for example `"page"`. Example: "page".
|
|
149
157
|
* @param {string} entity - Name of the entity the file belongs to; sets the folder name in the storage. Example: "editor".
|
|
150
158
|
* @param {string} filename - File name. Example: "file.png".
|
|
151
|
-
* @param {string} [template] -
|
|
152
|
-
* @returns {Promise<Response
|
|
153
|
-
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
159
|
+
* @param {string} [template] - Kept for compatibility: `GET /files` ignores it — the answer is the original file with any value, an unknown template included (CMS-1101, CMS-1128). Previews are made on `upload`.
|
|
160
|
+
* @returns {Promise<Response>} Resolves to the raw `Response` of the request — also on an error: check `response.ok`. A missing file answers `404` with a JSON body but a `content-type` taken from the requested file name (`image/png` …).
|
|
154
161
|
* @see {@link https://js-sdk.oneentry.cloud/docs/file-uploading/getFile getFile} documentation.
|
|
155
162
|
*/
|
|
156
163
|
async getFile(id, type, entity, filename, template) {
|
|
157
164
|
// eslint-disable-next-line no-undef
|
|
158
|
-
const response = await fetch(this._getFullPath(
|
|
165
|
+
const response = await fetch(this._getFullPath('?' +
|
|
166
|
+
this._queryParamsToString({ id, type, entity, filename, template })), {
|
|
159
167
|
method: 'GET',
|
|
160
168
|
headers: {
|
|
161
169
|
'Content-Type': 'application/json',
|
|
@@ -66,11 +66,10 @@ interface IFileUploading {
|
|
|
66
66
|
* @param {string} type - Storage type; determines the folder the file is stored in, for example `"page"`. Example: "page".
|
|
67
67
|
* @param {string} entity - Name of the entity the file belongs to; sets the folder name in the storage. Example: "editor".
|
|
68
68
|
* @param {string} filename - File name. Example: "file.png".
|
|
69
|
-
* @param {string} [template] -
|
|
70
|
-
* @returns {Response
|
|
71
|
-
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
69
|
+
* @param {string} [template] - Kept for compatibility: `GET /files` ignores it — the answer is the original file with any value, an unknown template included (CMS-1101, CMS-1128). Previews are made on `upload`.
|
|
70
|
+
* @returns {Response} The raw `Response` of the request — also on an error: check `response.ok`. A missing file answers `404` with a JSON body but a `content-type` taken from the file name. No IError is returned and nothing is thrown on an HTTP error.
|
|
72
71
|
*/
|
|
73
|
-
getFile(id: number, type: string, entity: string, filename: string, template?: string): Promise<Response
|
|
72
|
+
getFile(id: number, type: string, entity: string, filename: string, template?: string): Promise<Response>;
|
|
74
73
|
/**
|
|
75
74
|
* Public search across the content of files attached to records.
|
|
76
75
|
* @handleName searchFileContent
|
|
@@ -186,7 +185,7 @@ interface IFileSearchItem {
|
|
|
186
185
|
* The `IFileSearchQueryLanguage` interface describes how the query language was resolved.
|
|
187
186
|
* @interface IFileSearchQueryLanguage
|
|
188
187
|
* @property {string[]} resolved - Languages the query was actually run in. Example: ["english"].
|
|
189
|
-
* @property {string} source - How they were chosen: "explicit" when taken from `langCode
|
|
188
|
+
* @property {string} source - How they were chosen: `"explicit"` when taken from `langCode`; detected otherwise (seen: `"script"`). Detection runs only with `langCode: ""` — by default the client's language is sent. Example: "explicit".
|
|
190
189
|
* @property {string[]} candidates - Languages that were considered. Example: ["english"].
|
|
191
190
|
* @description How the query language was resolved for the search.
|
|
192
191
|
*/
|
|
@@ -202,7 +201,7 @@ interface IFileSearchQueryLanguage {
|
|
|
202
201
|
* @property {number} offset - Number of records to skip. Example: 0.
|
|
203
202
|
* @property {number} limit - Maximum number of records to return. Example: 10.
|
|
204
203
|
* @property {IFileSearchQueryLanguage} queryLanguage - How the query language was resolved.
|
|
205
|
-
* @property {string[]} warnings -
|
|
204
|
+
* @property {string[]} warnings - Warning codes, empty when there are none. Seen: `processing_disabled` (content indexing is off — `items` is always empty), `query_language_capped`, `query_too_common`.
|
|
206
205
|
* @property {IFileSearchItem[]} items - Files that match the query.
|
|
207
206
|
* @description The result of a file content search.
|
|
208
207
|
*/
|
|
@@ -29,8 +29,8 @@ export default class FiltersApi extends AsyncModules {
|
|
|
29
29
|
* @see {@link https://js-sdk.oneentry.cloud/docs/filters/getFilterByMarker getFilterByMarker} documentation.
|
|
30
30
|
*/
|
|
31
31
|
async getFilterByMarker(marker, langCode = this.state.lang) {
|
|
32
|
-
const data = await this._fetchGet(`/marker/${this._pathSegment(marker)}?langCode=${langCode}`);
|
|
32
|
+
const data = await this._fetchGet(`/marker/${this._pathSegment(marker)}?langCode=${encodeURIComponent(langCode)}`);
|
|
33
33
|
const validated = await this._validateResponse(data, schema('ContentFilterSchema'));
|
|
34
|
-
return this._normalizeData(validated);
|
|
34
|
+
return this._normalizeData(validated, langCode);
|
|
35
35
|
}
|
|
36
36
|
}
|
package/esm/forms/formsApi.js
CHANGED
|
@@ -31,7 +31,7 @@ export default class FormsApi extends AsyncModules {
|
|
|
31
31
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms/getAllForms getAllForms} documentation.
|
|
32
32
|
*/
|
|
33
33
|
async getAllForms(langCode = this.state.lang, offset = 0, limit = 30) {
|
|
34
|
-
const result = await this._fetchGet(`?langCode=${langCode}&offset=${offset}&limit=${limit}`);
|
|
34
|
+
const result = await this._fetchGet(`?langCode=${encodeURIComponent(langCode)}&offset=${encodeURIComponent(String(offset))}&limit=${encodeURIComponent(String(limit))}`);
|
|
35
35
|
// Validate response if validation is enabled
|
|
36
36
|
const validated = await this._validateResponse(result, schema('FormsResponseSchema'));
|
|
37
37
|
return this._normalizeData(validated, langCode);
|
|
@@ -46,7 +46,7 @@ export default class FormsApi extends AsyncModules {
|
|
|
46
46
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms/getFormByMarker getFormByMarker} documentation.
|
|
47
47
|
*/
|
|
48
48
|
async getFormByMarker(marker, langCode = this.state.lang) {
|
|
49
|
-
const result = await this._fetchGet(`/marker/${this._pathSegment(marker)}?langCode=${langCode}`);
|
|
49
|
+
const result = await this._fetchGet(`/marker/${this._pathSegment(marker)}?langCode=${encodeURIComponent(langCode)}`);
|
|
50
50
|
// Validate response if validation is enabled
|
|
51
51
|
const validated = await this._validateResponse(result, schema('FormEntitySchema'));
|
|
52
52
|
return this._normalizeData(validated, langCode);
|
|
@@ -69,10 +69,9 @@ interface IFromPages {
|
|
|
69
69
|
* @property {number} version - Version number of the object; changes with each update. Example: 1.
|
|
70
70
|
* @property {number} position - Position of the object, used for sorting. Example: 1.
|
|
71
71
|
* @property {string} identifier - Text identifier (marker) of the object. Example: "form_contact_us".
|
|
72
|
-
* @property {string} processingType - How form submissions are processed
|
|
72
|
+
* @property {string} processingType - How form submissions are processed: the processing type chosen in the form settings. Example: "script".
|
|
73
73
|
* @property {number | null} templateId - ID of the template used by the form, or `null` when the form has no template. Example: 6789.
|
|
74
74
|
* @property {IFormAttribute[]} attributes - Form fields with their localization, validators and form-specific flags, sorted by `position`. The API returns an empty object for forms with no attributes — the SDK normalizes it to an empty array.
|
|
75
|
-
* @property {number | string} [total] - Total count of related entries. Example: "1".
|
|
76
75
|
* @property {IFormConfig[]} [moduleFormConfigs] - Form configurations of the module associated with the form.
|
|
77
76
|
* @description This interface defines the structure of a form entity, including its identifiers, attributes, and processing data.
|
|
78
77
|
*/
|
|
@@ -87,7 +86,6 @@ interface IFormsEntity {
|
|
|
87
86
|
processingType: string;
|
|
88
87
|
templateId: number | null;
|
|
89
88
|
attributes: IFormAttribute[];
|
|
90
|
-
total?: number | string;
|
|
91
89
|
moduleFormConfigs?: IFormConfig[];
|
|
92
90
|
}
|
|
93
91
|
/**
|
|
@@ -13,8 +13,7 @@ export declare const FormEntitySchema: z.ZodObject<{
|
|
|
13
13
|
type: z.ZodNullable<z.ZodString>;
|
|
14
14
|
attributeSetId: z.ZodNullable<z.ZodNumber>;
|
|
15
15
|
templateId: z.ZodNullable<z.ZodNumber>;
|
|
16
|
-
|
|
17
|
-
attributes: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
|
|
16
|
+
attributes: z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>;
|
|
18
17
|
moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
19
18
|
}, z.core.$strip>;
|
|
20
19
|
/**
|
|
@@ -32,8 +31,7 @@ export declare const FormsResponseSchema: z.ZodObject<{
|
|
|
32
31
|
type: z.ZodNullable<z.ZodString>;
|
|
33
32
|
attributeSetId: z.ZodNullable<z.ZodNumber>;
|
|
34
33
|
templateId: z.ZodNullable<z.ZodNumber>;
|
|
35
|
-
|
|
36
|
-
attributes: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
|
|
34
|
+
attributes: z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>;
|
|
37
35
|
moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
38
36
|
}, z.core.$strip>>;
|
|
39
37
|
}, z.core.$strip>;
|
|
@@ -50,7 +48,6 @@ export declare const SingleFormSchema: z.ZodObject<{
|
|
|
50
48
|
type: z.ZodNullable<z.ZodString>;
|
|
51
49
|
attributeSetId: z.ZodNullable<z.ZodNumber>;
|
|
52
50
|
templateId: z.ZodNullable<z.ZodNumber>;
|
|
53
|
-
|
|
54
|
-
attributes: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
|
|
51
|
+
attributes: z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>;
|
|
55
52
|
moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
56
53
|
}, z.core.$strip>;
|
|
@@ -13,10 +13,8 @@ export const FormEntitySchema = z.object({
|
|
|
13
13
|
type: z.string().nullable(),
|
|
14
14
|
attributeSetId: z.number().nullable(),
|
|
15
15
|
templateId: z.number().nullable(),
|
|
16
|
-
|
|
17
|
-
attributes: z
|
|
18
|
-
.union([z.array(z.any()), z.record(z.string(), z.any())])
|
|
19
|
-
.optional(),
|
|
16
|
+
// Required as in IFormsEntity: a form without fields comes as `{}`
|
|
17
|
+
attributes: z.union([z.array(z.any()), z.record(z.string(), z.any())]),
|
|
20
18
|
moduleFormConfigs: z.array(z.any()).optional(),
|
|
21
19
|
});
|
|
22
20
|
/**
|
|
@@ -136,14 +136,40 @@ export default class FormsDataApi extends AsyncModules implements IFormsData {
|
|
|
136
136
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/getFormsDataByMarker getFormsDataByMarker} documentation.
|
|
137
137
|
*/
|
|
138
138
|
getFormsDataByMarker(marker: string, formModuleConfigId: number, body?: IFormsDataFilter, isExtended?: number, langCode?: string, offset?: number, limit?: number): Promise<IFormsByMarkerDataEntity | IError>;
|
|
139
|
+
/**
|
|
140
|
+
* Wrap the caller's flat `formData` array under its language code and upload any
|
|
141
|
+
* file fields, so the submit endpoints receive `{ [langCode]: [...] }`. Shared by
|
|
142
|
+
* postFormsData and updateFormsDataByid so the two never diverge.
|
|
143
|
+
* @param {FormDataType[]} rawFormData - Flat array of form fields.
|
|
144
|
+
* @param {string} langCode - Language code the fields are wrapped under.
|
|
145
|
+
* @returns {Promise<object>} The locale-keyed formData and the first upload error, if any.
|
|
146
|
+
*/
|
|
147
|
+
private _buildLocalizedFormData;
|
|
139
148
|
/**
|
|
140
149
|
* Update one object of form data by id. Requires user authentication.
|
|
141
150
|
* @handleName updateFormsDataByid
|
|
142
151
|
* @param {number} id - Form data ID. Example: 1.
|
|
152
|
+
* @param {IBodyPostFormData} body - Form data to save: the same fields as in `postFormsData` (`formIdentifier`, `formModuleConfigId`, `moduleEntityIdentifier`, `replayTo`, `status`, `formData`). The flat `formData` array is wrapped under `langCode` before sending, exactly like `postFormsData`.
|
|
153
|
+
* @param {string} [langCode] - Language code the form fields are saved under. Default: "en_US".
|
|
154
|
+
* @example
|
|
155
|
+
{
|
|
156
|
+
"formIdentifier": "test-form",
|
|
157
|
+
"formModuleConfigId": 2,
|
|
158
|
+
"moduleEntityIdentifier": "blog",
|
|
159
|
+
"replayTo": null,
|
|
160
|
+
"status": "sent",
|
|
161
|
+
"formData": [
|
|
162
|
+
{
|
|
163
|
+
"marker": "name",
|
|
164
|
+
"type": "string",
|
|
165
|
+
"value": "Test"
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
}
|
|
143
169
|
* @returns {Promise<IUpdateFormsData | IError>} Returns an object containing the updated form data or an error object if there was an issue.
|
|
144
170
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/updateFormsDataByid updateFormsDataByid} documentation.
|
|
145
171
|
*/
|
|
146
|
-
updateFormsDataByid(id: number, body?:
|
|
172
|
+
updateFormsDataByid(id: number, body: IBodyPostFormData, langCode?: string): Promise<IUpdateFormsData | IError>;
|
|
147
173
|
/**
|
|
148
174
|
* Update form data status by id. Requires user authentication.
|
|
149
175
|
* @handleName updateFormsDataStatusByid
|
|
@@ -66,67 +66,13 @@ export default class FormsDataApi extends AsyncModules {
|
|
|
66
66
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/postFormsData postFormsData} documentation.
|
|
67
67
|
*/
|
|
68
68
|
async postFormsData(body, langCode = this.state.lang) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
* Check if there is any element in formData[langCode] that contains one of the specified types
|
|
77
|
-
*/
|
|
78
|
-
if (formData[langCode].find((fd) => ['file', 'image', 'groupOfImages'].includes(fd.type))) {
|
|
79
|
-
// Create an instance of FileUploadingApi with the current state
|
|
80
|
-
const fileUploader = new FileUploadingApi(this.state);
|
|
81
|
-
// Process each element in formData[langCode] asynchronously
|
|
82
|
-
formData[langCode] = await Promise.all(formData[langCode].map(async (field) => {
|
|
83
|
-
// Check if the type is one of the specified types
|
|
84
|
-
if (['file', 'image', 'groupOfImages'].includes(field.type)) {
|
|
85
|
-
// Work on a copy: the caller's field keeps its File and its fileQuery,
|
|
86
|
-
// so a reused body sends the same form again (CMS-1071)
|
|
87
|
-
const fd = { ...field };
|
|
88
|
-
// If fileQuery does not exist, we create it and assign it to an object with the following properties:
|
|
89
|
-
if (!fd.fileQuery) {
|
|
90
|
-
const fileQuery = {
|
|
91
|
-
type: 'page',
|
|
92
|
-
entity: 'editor',
|
|
93
|
-
// Generate a random 4-digit ID
|
|
94
|
-
id: Number(Math.floor(Math.random() * 10000)
|
|
95
|
-
.toString()
|
|
96
|
-
.padStart(4, '0')),
|
|
97
|
-
};
|
|
98
|
-
fd.fileQuery = fileQuery;
|
|
99
|
-
}
|
|
100
|
-
// Convert fd.value to an array if it is a FileList, otherwise use it directly
|
|
101
|
-
const filesArray = typeof FileList !== 'undefined' && fd.value instanceof FileList
|
|
102
|
-
? Array.from(fd.value)
|
|
103
|
-
: fd.value;
|
|
104
|
-
// If filesArray is an array, upload the files it holds asynchronously
|
|
105
|
-
if (Array.isArray(filesArray)) {
|
|
106
|
-
const uploadPromises = filesArray.map((file) =>
|
|
107
|
-
// An entry that is already in storage is passed through: a
|
|
108
|
-
// second upload would send the descriptor itself as the file
|
|
109
|
-
// and the endpoint answers `value[0].filename is required`.
|
|
110
|
-
this._isUploadable(file)
|
|
111
|
-
? fileUploader.upload(file, fd.fileQuery).catch((e) => e)
|
|
112
|
-
: file);
|
|
113
|
-
fd.value = (await Promise.all(uploadPromises)).flat();
|
|
114
|
-
}
|
|
115
|
-
// If fd.value is a single File or Blob, upload it
|
|
116
|
-
else if (this._isUploadable(fd.value)) {
|
|
117
|
-
fd.value = await fileUploader
|
|
118
|
-
.upload(fd.value, fd.fileQuery)
|
|
119
|
-
.catch((e) => e); // Catch any errors during upload
|
|
120
|
-
}
|
|
121
|
-
// Remove the 'fileQuery' property from the object after processing
|
|
122
|
-
delete fd.fileQuery;
|
|
123
|
-
// Remove the 'contentType' property from the file object because it is not needed and not valid
|
|
124
|
-
fd.value = this._stripContentType(fd.value);
|
|
125
|
-
return fd;
|
|
126
|
-
}
|
|
127
|
-
// Return the form data element untouched
|
|
128
|
-
return field;
|
|
129
|
-
}));
|
|
69
|
+
// Wrap the flat formData under langCode (and upload any files) before sending
|
|
70
|
+
const { formData, uploadError } = await this._buildLocalizedFormData(body.formData, langCode);
|
|
71
|
+
if (uploadError) {
|
|
72
|
+
if (this.state.isShell) {
|
|
73
|
+
return uploadError;
|
|
74
|
+
}
|
|
75
|
+
throw uploadError;
|
|
130
76
|
}
|
|
131
77
|
// The wrapped formData goes into a new body: written back into the caller's
|
|
132
78
|
// object, a second call with it wrapped the wrapper and answered `400` (CMS-1071)
|
|
@@ -234,23 +180,128 @@ export default class FormsDataApi extends AsyncModules {
|
|
|
234
180
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/getFormsDataByMarker getFormsDataByMarker} documentation.
|
|
235
181
|
*/
|
|
236
182
|
async getFormsDataByMarker(marker, formModuleConfigId, body = {}, isExtended = 0, langCode = this.state.lang, offset = 0, limit = 30) {
|
|
237
|
-
const result = await this._fetchPost(`/marker/${this._pathSegment(marker)}?formModuleConfigId=${formModuleConfigId}&isExtended=${isExtended}&langCode=${langCode}&offset=${offset}&limit=${limit}`, this._stripEmptyDates(body));
|
|
183
|
+
const result = await this._fetchPost(`/marker/${this._pathSegment(marker)}?formModuleConfigId=${encodeURIComponent(String(formModuleConfigId))}&isExtended=${encodeURIComponent(String(isExtended))}&langCode=${encodeURIComponent(langCode)}&offset=${encodeURIComponent(String(offset))}&limit=${encodeURIComponent(String(limit))}`, this._stripEmptyDates(body));
|
|
238
184
|
// Validate response if validation is enabled
|
|
239
185
|
const validated = await this._validateResponse(result, schema('FormsByMarkerDataResponseSchema'));
|
|
240
186
|
return this._normalizeData(validated, langCode);
|
|
241
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* Wrap the caller's flat `formData` array under its language code and upload any
|
|
190
|
+
* file fields, so the submit endpoints receive `{ [langCode]: [...] }`. Shared by
|
|
191
|
+
* postFormsData and updateFormsDataByid so the two never diverge.
|
|
192
|
+
* @param {FormDataType[]} rawFormData - Flat array of form fields.
|
|
193
|
+
* @param {string} langCode - Language code the fields are wrapped under.
|
|
194
|
+
* @returns {Promise<object>} The locale-keyed formData and the first upload error, if any.
|
|
195
|
+
*/
|
|
196
|
+
async _buildLocalizedFormData(rawFormData, langCode) {
|
|
197
|
+
const formData = {};
|
|
198
|
+
// filter button fields; keep spam fields so the captcha token in their `value` reaches the server
|
|
199
|
+
formData[langCode] = Array.isArray(rawFormData)
|
|
200
|
+
? rawFormData.filter((fd) => fd.type !== 'button')
|
|
201
|
+
: [rawFormData].filter((fd) => fd.type !== 'button');
|
|
202
|
+
/**
|
|
203
|
+
* Handle file uploads if fileQuery is present
|
|
204
|
+
* Check if there is any element in formData[langCode] that contains one of the specified types
|
|
205
|
+
*/
|
|
206
|
+
if (formData[langCode].find((fd) => ['file', 'image', 'groupOfImages'].includes(fd.type))) {
|
|
207
|
+
// Create an instance of FileUploadingApi with the current state
|
|
208
|
+
const fileUploader = new FileUploadingApi(this.state);
|
|
209
|
+
// Process each element in formData[langCode] asynchronously
|
|
210
|
+
formData[langCode] = await Promise.all(formData[langCode].map(async (field) => {
|
|
211
|
+
// Check if the type is one of the specified types
|
|
212
|
+
if (['file', 'image', 'groupOfImages'].includes(field.type)) {
|
|
213
|
+
// Work on a copy: the caller's field keeps its File and its fileQuery,
|
|
214
|
+
// so a reused body sends the same form again (CMS-1071)
|
|
215
|
+
const fd = { ...field };
|
|
216
|
+
// If fileQuery does not exist, we create it and assign it to an object with the following properties:
|
|
217
|
+
if (!fd.fileQuery) {
|
|
218
|
+
const fileQuery = {
|
|
219
|
+
type: 'page',
|
|
220
|
+
entity: 'editor',
|
|
221
|
+
// Generate a random 4-digit ID
|
|
222
|
+
id: Number(Math.floor(Math.random() * 10000)
|
|
223
|
+
.toString()
|
|
224
|
+
.padStart(4, '0')),
|
|
225
|
+
};
|
|
226
|
+
fd.fileQuery = fileQuery;
|
|
227
|
+
}
|
|
228
|
+
// Convert fd.value to an array if it is a FileList, otherwise use it directly
|
|
229
|
+
const filesArray = typeof FileList !== 'undefined' && fd.value instanceof FileList
|
|
230
|
+
? Array.from(fd.value)
|
|
231
|
+
: fd.value;
|
|
232
|
+
// If filesArray is an array, upload the files it holds asynchronously
|
|
233
|
+
if (Array.isArray(filesArray)) {
|
|
234
|
+
const uploadPromises = filesArray.map((file) =>
|
|
235
|
+
// An entry that is already in storage is passed through: a
|
|
236
|
+
// second upload would send the descriptor itself as the file
|
|
237
|
+
// and the endpoint answers `value[0].filename is required`.
|
|
238
|
+
this._isUploadable(file)
|
|
239
|
+
? fileUploader.upload(file, fd.fileQuery).catch((e) => e)
|
|
240
|
+
: file);
|
|
241
|
+
fd.value = (await Promise.all(uploadPromises)).flat();
|
|
242
|
+
}
|
|
243
|
+
// If fd.value is a single File or Blob, upload it
|
|
244
|
+
else if (this._isUploadable(fd.value)) {
|
|
245
|
+
fd.value = await fileUploader
|
|
246
|
+
.upload(fd.value, fd.fileQuery)
|
|
247
|
+
.catch((e) => e); // Catch any errors during upload
|
|
248
|
+
}
|
|
249
|
+
// Remove the 'fileQuery' property from the object after processing
|
|
250
|
+
delete fd.fileQuery;
|
|
251
|
+
// Remove the 'contentType' property from the file object because it is not needed and not valid
|
|
252
|
+
fd.value = this._stripContentType(fd.value);
|
|
253
|
+
return fd;
|
|
254
|
+
}
|
|
255
|
+
// Return the form data element untouched
|
|
256
|
+
return field;
|
|
257
|
+
}));
|
|
258
|
+
}
|
|
259
|
+
// A failed upload used to be sent to the platform as the field's value, and the caller
|
|
260
|
+
// got a success: the form is not sent, the upload's error is the answer
|
|
261
|
+
const uploadError = formData[langCode]
|
|
262
|
+
.flatMap((field) => Array.isArray(field === null || field === void 0 ? void 0 : field.value) ? field.value : [field === null || field === void 0 ? void 0 : field.value])
|
|
263
|
+
.find((value) => this._isErrorResponse(value));
|
|
264
|
+
return { formData, uploadError };
|
|
265
|
+
}
|
|
242
266
|
/**
|
|
243
267
|
* Update one object of form data by id. Requires user authentication.
|
|
244
268
|
* @handleName updateFormsDataByid
|
|
245
269
|
* @param {number} id - Form data ID. Example: 1.
|
|
270
|
+
* @param {IBodyPostFormData} body - Form data to save: the same fields as in `postFormsData` (`formIdentifier`, `formModuleConfigId`, `moduleEntityIdentifier`, `replayTo`, `status`, `formData`). The flat `formData` array is wrapped under `langCode` before sending, exactly like `postFormsData`.
|
|
271
|
+
* @param {string} [langCode] - Language code the form fields are saved under. Default: "en_US".
|
|
272
|
+
* @example
|
|
273
|
+
{
|
|
274
|
+
"formIdentifier": "test-form",
|
|
275
|
+
"formModuleConfigId": 2,
|
|
276
|
+
"moduleEntityIdentifier": "blog",
|
|
277
|
+
"replayTo": null,
|
|
278
|
+
"status": "sent",
|
|
279
|
+
"formData": [
|
|
280
|
+
{
|
|
281
|
+
"marker": "name",
|
|
282
|
+
"type": "string",
|
|
283
|
+
"value": "Test"
|
|
284
|
+
}
|
|
285
|
+
]
|
|
286
|
+
}
|
|
246
287
|
* @returns {Promise<IUpdateFormsData | IError>} Returns an object containing the updated form data or an error object if there was an issue.
|
|
247
288
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/updateFormsDataByid updateFormsDataByid} documentation.
|
|
248
289
|
*/
|
|
249
|
-
async updateFormsDataByid(id, body =
|
|
250
|
-
|
|
290
|
+
async updateFormsDataByid(id, body, langCode = this.state.lang) {
|
|
291
|
+
// Wrap the flat formData under langCode (and upload any files) — the endpoint
|
|
292
|
+
// rejects a flat array with `400 formData must be ... keyed by lang code`
|
|
293
|
+
const { formData, uploadError } = await this._buildLocalizedFormData(body.formData, langCode);
|
|
294
|
+
if (uploadError) {
|
|
295
|
+
if (this.state.isShell) {
|
|
296
|
+
return uploadError;
|
|
297
|
+
}
|
|
298
|
+
throw uploadError;
|
|
299
|
+
}
|
|
300
|
+
const result = await this._fetchPut(`/${this._pathSegment(String(id))}`, { ...body, formData });
|
|
251
301
|
// Validate response if validation is enabled
|
|
252
302
|
const validated = await this._validateResponse(result, schema('UpdateFormsDataSchema'));
|
|
253
|
-
|
|
303
|
+
// The fields went in under `langCode`, so unwrap the response from the same locale
|
|
304
|
+
return this._normalizeData(validated, langCode);
|
|
254
305
|
}
|
|
255
306
|
/**
|
|
256
307
|
* Update form data status by id. Requires user authentication.
|
|
@@ -261,7 +312,7 @@ export default class FormsDataApi extends AsyncModules {
|
|
|
261
312
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/updateFormsDataStatusByid updateFormsDataStatusByid} documentation.
|
|
262
313
|
*/
|
|
263
314
|
async updateFormsDataStatusByid(id, body = {}) {
|
|
264
|
-
const result = await this._fetchPut(`/${id}/update-status`, body);
|
|
315
|
+
const result = await this._fetchPut(`/${this._pathSegment(String(id))}/update-status`, body);
|
|
265
316
|
return result;
|
|
266
317
|
}
|
|
267
318
|
/**
|
|
@@ -272,8 +323,8 @@ export default class FormsDataApi extends AsyncModules {
|
|
|
272
323
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/deleteFormsDataByid deleteFormsDataByid} documentation.
|
|
273
324
|
*/
|
|
274
325
|
async deleteFormsDataByid(id) {
|
|
275
|
-
const result = await this._fetchDelete(`/${id}`);
|
|
276
|
-
return result;
|
|
326
|
+
const result = await this._fetchDelete(`/${this._pathSegment(String(id))}`);
|
|
327
|
+
return this._asBoolean(result);
|
|
277
328
|
}
|
|
278
329
|
/**
|
|
279
330
|
* Semantic (vector) search for form data.
|
|
@@ -225,9 +225,14 @@ interface IFormDataEntity {
|
|
|
225
225
|
"id": 1,
|
|
226
226
|
"formIdentifier": "form",
|
|
227
227
|
"time": "2025-06-06T19:07:45.993Z",
|
|
228
|
-
"formData":
|
|
229
|
-
|
|
230
|
-
|
|
228
|
+
"formData": [
|
|
229
|
+
{
|
|
230
|
+
"marker": "name",
|
|
231
|
+
"type": "string",
|
|
232
|
+
"value": "Test"
|
|
233
|
+
}
|
|
234
|
+
],
|
|
235
|
+
"attributeSetIdentifier": "form"
|
|
231
236
|
}
|
|
232
237
|
]
|
|
233
238
|
* @property {number} total - Total number of found records. Example: 100.
|
|
@@ -241,13 +246,13 @@ interface IFormsDataEntity {
|
|
|
241
246
|
* Represents the structure of a form data entity.
|
|
242
247
|
* @interface IFormByMarkerDataEntity
|
|
243
248
|
* @property {number} id - ID of the form data record. Example: 12345.
|
|
244
|
-
* @property {null | number} parentId - ID of the parent form data record; `null` for a top-level record. Example: 123.
|
|
249
|
+
* @property {null | number} [parentId] - ID of the parent form data record; `null` for a top-level record. Returned only with `isExtended` = 1. Example: 123.
|
|
245
250
|
* @property {string} formIdentifier - Marker of the form. Example: "contact_form".
|
|
246
|
-
* @property {number} depth - Example: 1.
|
|
247
|
-
* @property {string | null} ip - IP address the form was submitted from. Example: '127.0.0.1'.
|
|
248
|
-
* @property {string | null} fingerprint - Device fingerprint of the sender. Example: 'fingerprint'.
|
|
249
|
-
* @property {string | null} status - Moderation status of the record: "sent", "moderation", "approved", "banned" or "deleted"; `null` when the form does not moderate. Example: 'approved'.
|
|
250
|
-
* @property {string | null} userIdentifier - Text identifier (marker) of the user. Example: "admin".
|
|
251
|
+
* @property {number} [depth] - Nesting depth of the record. Returned only with `isExtended` = 1. Example: 1.
|
|
252
|
+
* @property {string | null} [ip] - IP address the form was submitted from. Not returned by the by-marker list. Example: '127.0.0.1'.
|
|
253
|
+
* @property {string | null} [fingerprint] - Device fingerprint of the sender. Not returned by the by-marker list. Example: 'fingerprint'.
|
|
254
|
+
* @property {string | null} [status] - Moderation status of the record: "sent", "moderation", "approved", "banned" or "deleted"; `null` when the form does not moderate. Returned only with `isExtended` = 1. Example: 'approved'.
|
|
255
|
+
* @property {string | null} [userIdentifier] - Text identifier (marker) of the user. Returned only with `isExtended` = 1. Example: "admin".
|
|
251
256
|
* @property {FormDataType[]} formData - Submitted fields, **already unwrapped from the locale**: the API returns `{ "en_US": [ … ] }` and the SDK hands over the array for the requested `langCode`. Read `formData` directly — `formData[langCode]` is `undefined`.
|
|
252
257
|
* @example
|
|
253
258
|
[
|
|
@@ -260,7 +265,7 @@ interface IFormsDataEntity {
|
|
|
260
265
|
* @property {string | null} attributeSetIdentifier - Marker of the attribute set used by the form. Example: "product_attributes".
|
|
261
266
|
* @property {Date | string} time - Date and time the form data was last changed. Example: "2023-10-01T12:00:00Z".
|
|
262
267
|
* @property {string} entityIdentifier - Marker of the entity the record belongs to. Example: "test".
|
|
263
|
-
* @property {boolean} isUserAdmin - Whether the record was submitted by an admin. Example: true.
|
|
268
|
+
* @property {boolean} [isUserAdmin] - Whether the record was submitted by an admin. Returned only with `isExtended` = 1. Example: true.
|
|
264
269
|
* @property {number} formModuleConfigId - ID of the form module configuration. Example: 2.
|
|
265
270
|
* @property {string} [moduleIdentifier] - Marker of the module. Example: "blog".
|
|
266
271
|
* @property {number} entityId - ID of the entity the record belongs to. Example: 2.
|
|
@@ -287,7 +292,7 @@ interface IFormByMarkerDataEntity {
|
|
|
287
292
|
/**
|
|
288
293
|
* Represents a collection of form data entities.
|
|
289
294
|
* @interface IFormsByMarkerDataEntity
|
|
290
|
-
* @property {IFormByMarkerDataEntity[]} items - Form data records.
|
|
295
|
+
* @property {IFormByMarkerDataEntity[]} items - Form data records. The example shows a record with `isExtended` = 1; without it `parentId`, `depth`, `status`, `userIdentifier` and `isUserAdmin` are not returned.
|
|
291
296
|
* @example
|
|
292
297
|
[
|
|
293
298
|
{
|
|
@@ -295,7 +300,6 @@ interface IFormByMarkerDataEntity {
|
|
|
295
300
|
"parentId": null,
|
|
296
301
|
"formIdentifier": "test-form",
|
|
297
302
|
"depth": 0,
|
|
298
|
-
"ip": null,
|
|
299
303
|
"status": null,
|
|
300
304
|
"userIdentifier": null,
|
|
301
305
|
"formData": [
|
|
@@ -862,4 +866,4 @@ interface IListOptionValue {
|
|
|
862
866
|
value: string;
|
|
863
867
|
extended: IListOptionExtended;
|
|
864
868
|
}
|
|
865
|
-
export type { FormDataPostType, FormDataStatus, FormDataType, IBodyPostFormData, IBodyPostTypeList, IBodyPostTypeSpam, IBodyPostTypeText, IBodyTypeEntity, IBodyTypeFile, IBodyTypeImageGroupOfImages, IBodyTypeRadioButtonList, IBodyTypeStringNumberFloat, IBodyTypeText, IBodyTypeTextWithHeader, IBodyTypeTimeDate, IBodyTypeTimeInterval, ICaptchaEvent, ICaptchaValue, IFileValue, IFormByMarkerDataEntity, IFormDataEntity, IFormDataSearchEntity, IFormsByMarkerDataEntity, IFormsData, IFormsDataEntity, IFormsDataFilter, IFormsDataSearchResponse, IFormsDataVectorSearch, IImageValue, IImageValueParams, IListOptionExtended, IListOptionValue, IPostFormResponse, IPostFormResponseData, ITextEditorParams, ITextSubmissionValue, ITextValue, ITextWithHeaderValue, ITimeDateValue, IUpdateFormsData, };
|
|
869
|
+
export type { FormDataPostType, FormDataStatus, FormDataType, IBodyPostFormData, IBodyPostTypeList, IBodyPostTypeSpam, IBodyPostTypeText, IBodyTypeEntity, IBodyTypeFile, IBodyTypeImageGroupOfImages, IBodyTypeRadioButtonList, IBodyTypeStringNumberFloat, IBodyTypeText, IBodyTypeTextWithHeader, IBodyTypeTimeDate, IBodyTypeTimeInterval, ICaptchaEvent, ICaptchaValue, IFileValue, IFormByMarkerDataEntity, IFormDataEntity, IFormDataSearchEntity, IFormsByMarkerDataEntity, IFormsData, IFormsDataEntity, IFormsDataFilter, IFormsDataSearchResponse, IFormsDataVectorSearch, IImageValue, IImageValueParams, IListOptionExtended, IListOptionValue, IPostFormResponse, IPostFormResponseData, ITextEditorParams, ITextSubmissionValue, ITextSubmissionValueHtml, ITextSubmissionValueMd, ITextSubmissionValuePlain, ITextValue, ITextWithHeaderValue, ITimeDateValue, IUpdateFormsData, };
|
|
@@ -19,7 +19,7 @@ interface IGeneralTypes {
|
|
|
19
19
|
* Represents a general type entity.
|
|
20
20
|
* @interface IGeneralTypesEntity
|
|
21
21
|
* @property {number} id - ID of the type. Example: 1.
|
|
22
|
-
* @property {BlockType} type - Type name: a `BlockType` value such as `"product"` or `"service"`. Example: "product"
|
|
22
|
+
* @property {BlockType} type - Type name: a `BlockType` value such as `"product"`, `"catalog_page"`, `"product_block"` or `"service"`. Example: "product".
|
|
23
23
|
* @description Represents a general type entity with an identifier and a type.
|
|
24
24
|
*/
|
|
25
25
|
interface IGeneralTypesEntity {
|