oneentry 1.0.175 → 1.0.177
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 +140 -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 +96 -29
- 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 +73 -1
- package/dist/base/asyncModules.js +233 -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 +101 -74
- package/dist/blocks/blocksInterfaces.d.ts +8 -8
- package/dist/discounts/discountsApi.d.ts +9 -7
- package/dist/discounts/discountsApi.js +18 -14
- package/dist/discounts/discountsInterfaces.d.ts +14 -10
- package/dist/events/eventsApi.d.ts +3 -3
- package/dist/events/eventsApi.js +7 -7
- 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 +26 -8
- package/dist/forms-data/formsDataApi.js +45 -14
- package/dist/forms-data/formsDataInterfaces.d.ts +91 -66
- 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 +42 -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 +24 -44
- package/dist/orders/ordersInterfaces.d.ts +21 -14
- package/dist/pages/pagesApi.d.ts +6 -5
- package/dist/pages/pagesApi.js +44 -31
- package/dist/pages/pagesInterfaces.d.ts +18 -15
- 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 +4 -4
- package/dist/product-statuses/productStatusesInterfaces.d.ts +1 -4
- package/dist/products/productsApi.d.ts +38 -58
- package/dist/products/productsApi.js +59 -72
- package/dist/products/productsInterfaces.d.ts +48 -85
- package/dist/search/searchApi.d.ts +1 -1
- package/dist/search/searchApi.js +4 -3
- 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 +96 -29
- 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 +73 -1
- package/esm/base/asyncModules.js +233 -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 +101 -74
- package/esm/blocks/blocksInterfaces.d.ts +8 -8
- package/esm/discounts/discountsApi.d.ts +9 -7
- package/esm/discounts/discountsApi.js +18 -14
- package/esm/discounts/discountsInterfaces.d.ts +14 -10
- package/esm/events/eventsApi.d.ts +3 -3
- package/esm/events/eventsApi.js +7 -7
- 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 +26 -8
- package/esm/forms-data/formsDataApi.js +45 -14
- package/esm/forms-data/formsDataInterfaces.d.ts +91 -66
- 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 +42 -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 +24 -44
- package/esm/orders/ordersInterfaces.d.ts +21 -14
- package/esm/pages/pagesApi.d.ts +6 -5
- package/esm/pages/pagesApi.js +44 -31
- package/esm/pages/pagesInterfaces.d.ts +18 -15
- 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 +4 -4
- package/esm/product-statuses/productStatusesInterfaces.d.ts +1 -4
- package/esm/products/productsApi.d.ts +38 -58
- package/esm/products/productsApi.js +59 -72
- package/esm/products/productsInterfaces.d.ts +48 -85
- package/esm/search/searchApi.d.ts +1 -1
- package/esm/search/searchApi.js +4 -3
- 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
|
@@ -39,7 +39,7 @@ export default class EventsApi extends AsyncModules implements IEvents {
|
|
|
39
39
|
* @handleName subscribeByMarker
|
|
40
40
|
* @param {string} marker - Marker of the event. Example: "product_price_change".
|
|
41
41
|
* @param {number} productId - Product ID. Example: 12345.
|
|
42
|
-
* @param {string} [langCode] - Language code. Default:
|
|
42
|
+
* @param {string} [langCode] - Language code. Default: the client's language.
|
|
43
43
|
* @returns {Promise<boolean | IError>} Returns true if subscription was successful, or an error object if there was an issue.
|
|
44
44
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
45
45
|
* @description This method requires user authorization.
|
|
@@ -52,7 +52,7 @@ export default class EventsApi extends AsyncModules implements IEvents {
|
|
|
52
52
|
* @handleName unsubscribeByMarker
|
|
53
53
|
* @param {string} marker - Marker of the event to unsubscribe from. Example: "product_price_change".
|
|
54
54
|
* @param {number} productId - ID of the product to unsubscribe from. Example: 12345.
|
|
55
|
-
* @param {string} [langCode] - Language code. Default:
|
|
55
|
+
* @param {string} [langCode] - Language code. Default: the client's language.
|
|
56
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.
|
|
@@ -65,7 +65,7 @@ export default class EventsApi extends AsyncModules implements IEvents {
|
|
|
65
65
|
* @handleName getAllEvents
|
|
66
66
|
* @returns {Promise<IContentApiEvent[] | IError>} Returns an array of available events.
|
|
67
67
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
68
|
-
* @description This method returns all available events.
|
|
68
|
+
* @description This method returns all available events. This method requires user authorization — without it the API answers `401 Unauthorized`.
|
|
69
69
|
* @see {@link https://js-sdk.oneentry.cloud/docs/events/getAllEvents getAllEvents} documentation.
|
|
70
70
|
*/
|
|
71
71
|
getAllEvents(): Promise<IContentApiEvent[] | IError>;
|
package/esm/events/eventsApi.js
CHANGED
|
@@ -45,7 +45,7 @@ export default class EventsApi extends AsyncModules {
|
|
|
45
45
|
* @handleName subscribeByMarker
|
|
46
46
|
* @param {string} marker - Marker of the event. Example: "product_price_change".
|
|
47
47
|
* @param {number} productId - Product ID. Example: 12345.
|
|
48
|
-
* @param {string} [langCode] - Language code. Default:
|
|
48
|
+
* @param {string} [langCode] - Language code. Default: the client's language.
|
|
49
49
|
* @returns {Promise<boolean | IError>} Returns true if subscription was successful, or an error object if there was an issue.
|
|
50
50
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
51
51
|
* @description This method requires user authorization.
|
|
@@ -57,14 +57,14 @@ export default class EventsApi extends AsyncModules {
|
|
|
57
57
|
locale: langCode,
|
|
58
58
|
productId,
|
|
59
59
|
};
|
|
60
|
-
return this._fetchBoolean(() => this._fetchPost(`/subscribe/marker/${marker}`, body));
|
|
60
|
+
return this._fetchBoolean(() => this._fetchPost(`/subscribe/marker/${this._pathSegment(marker)}`, body));
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* Unsubscribing to an event on a product.
|
|
64
64
|
* @handleName unsubscribeByMarker
|
|
65
65
|
* @param {string} marker - Marker of the event to unsubscribe from. Example: "product_price_change".
|
|
66
66
|
* @param {number} productId - ID of the product to unsubscribe from. Example: 12345.
|
|
67
|
-
* @param {string} [langCode] - Language code. Default:
|
|
67
|
+
* @param {string} [langCode] - Language code. Default: the client's language.
|
|
68
68
|
* @returns {Promise<boolean | IError>} - Returns true if the unsubscription succeeded, or an error object if there was an issue.
|
|
69
69
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
70
70
|
* @description This method requires user authorization.
|
|
@@ -76,14 +76,14 @@ export default class EventsApi extends AsyncModules {
|
|
|
76
76
|
productId: productId,
|
|
77
77
|
locale: langCode,
|
|
78
78
|
};
|
|
79
|
-
return this._fetchBoolean(() => this._fetchDelete(`/unsubscribe/marker/${marker}`, body));
|
|
79
|
+
return this._fetchBoolean(() => this._fetchDelete(`/unsubscribe/marker/${this._pathSegment(marker)}`, body));
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
82
|
* Returns all available events.
|
|
83
83
|
* @handleName getAllEvents
|
|
84
84
|
* @returns {Promise<IContentApiEvent[] | IError>} Returns an array of available events.
|
|
85
85
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
86
|
-
* @description This method returns all available events.
|
|
86
|
+
* @description This method returns all available events. This method requires user authorization — without it the API answers `401 Unauthorized`.
|
|
87
87
|
* @see {@link https://js-sdk.oneentry.cloud/docs/events/getAllEvents getAllEvents} documentation.
|
|
88
88
|
*/
|
|
89
89
|
async getAllEvents() {
|
|
@@ -102,7 +102,7 @@ export default class EventsApi extends AsyncModules {
|
|
|
102
102
|
* @see {@link https://js-sdk.oneentry.cloud/docs/events/subscribeToForm subscribeToForm} documentation.
|
|
103
103
|
*/
|
|
104
104
|
async subscribeToForm(marker, body) {
|
|
105
|
-
return this._fetchBoolean(() => this._fetchPost(`/forms/subscribe/marker/${marker}`, body));
|
|
105
|
+
return this._fetchBoolean(() => this._fetchPost(`/forms/subscribe/marker/${this._pathSegment(marker)}`, body));
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
108
|
* Returns all form subscriptions.
|
|
@@ -135,6 +135,6 @@ export default class EventsApi extends AsyncModules {
|
|
|
135
135
|
* @see {@link https://js-sdk.oneentry.cloud/docs/events/unsubscribeFromForm unsubscribeFromForm} documentation.
|
|
136
136
|
*/
|
|
137
137
|
async unsubscribeFromForm(marker, body) {
|
|
138
|
-
return this._fetchBoolean(() => this._fetchDelete(`/forms/unsubscribe/marker/${marker}`, body));
|
|
138
|
+
return this._fetchBoolean(() => this._fetchDelete(`/forms/unsubscribe/marker/${this._pathSegment(marker)}`, body));
|
|
139
139
|
}
|
|
140
140
|
}
|
|
@@ -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/${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/${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
|
/**
|
|
@@ -118,17 +118,19 @@ export default class FormsDataApi extends AsyncModules implements IFormsData {
|
|
|
118
118
|
* @param {number} [body.parentId] - Identifier of the parent record, to fetch replies to one submission. Example: 10.
|
|
119
119
|
* @param {string} [body.userIdentifier] - Text identifier of the sender. Example: "admin".
|
|
120
120
|
* @param {FormDataStatus[]} [body.status] - Moderation statuses to keep: "sent", "moderation", "approved", "banned", "deleted". Must be an array; anything outside the set is rejected with `400 each value in status must be a valid enum value`. Example: ["approved"].
|
|
121
|
-
* @param {string} [body.dateFrom] - Lower bound of the submission date, `YYYY-MM-DD`. An empty string means "no bound" — the SDK removes it from the body, because the endpoint answers `400 dateFrom must be a valid date in format "YYYY-MM-DD"` to one. An unparsable non-empty value still fails the request. Example: "2025-01-01".
|
|
122
|
-
* @param {string} [body.dateTo] - Upper bound of the submission date, `YYYY-MM-DD`. An empty string means "no bound", handled like `dateFrom`. Example: "2025-12-31".
|
|
121
|
+
* @param {string} [body.dateFrom] - Lower bound of the submission date, `YYYY-MM-DD` or `YYYY-MM-DD HH:MM:SS`. An empty string means "no bound" — the SDK removes it from the body, because the endpoint answers `400 dateFrom must be a valid date in format "YYYY-MM-DD"` to one. An unparsable non-empty value still fails the request. Example: "2025-01-01".
|
|
122
|
+
* @param {string} [body.dateTo] - Upper bound of the submission date, `YYYY-MM-DD` or `YYYY-MM-DD HH:MM:SS`. An empty string means "no bound", handled like `dateFrom`. Example: "2025-12-31".
|
|
123
123
|
* @param {number} [isExtended] - Pass `1` to return additional fields for each record. Default: `0`. Example: 1.
|
|
124
124
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
125
|
-
* @param {number} [offset] - Number of records to skip. Default: 0.
|
|
126
|
-
* @param {number} [limit] - Maximum number of records to return. Default: 30.
|
|
125
|
+
* @param {number} [offset] - Number of records to skip, `0` or more (a negative one answers `400 offset must not be less than 0`). Default: 0.
|
|
126
|
+
* @param {number} [limit] - Maximum number of records to return, `1` or more (`0` answers `400 limit must not be less than 1`). Default: 30.
|
|
127
127
|
* @returns {Promise<IFormsByMarkerDataEntity | IError>} Returns an object containing the form data or an error object if there was an issue.
|
|
128
128
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
129
129
|
* @description Each record's `formData` comes back **already unwrapped from its locale**. The API sends `formData: { "en_US": [ … ] }`; the SDK normalizes the response and hands over the array for `langCode`, so read `record.formData` — `record.formData[langCode]` is `undefined` and yields an empty list with no error. This holds for both values of `isExtended`.
|
|
130
130
|
*
|
|
131
|
-
* The filter body is typed
|
|
131
|
+
* The filter body is typed because the API refuses a field it does not know: a misspelled `statuses` answers `400 property statuses should not exist`.
|
|
132
|
+
*
|
|
133
|
+
* A marker or `formModuleConfigId` that matches nothing answers `200` with `{ items: [], total: 0 }`, not `404` — an empty list does not prove the form exists.
|
|
132
134
|
*
|
|
133
135
|
* Empty `dateFrom` / `dateTo` are stripped from the body before it is sent: the endpoint validates the pair as dates and rejects an empty string with a `400`, while every other field still treats "" as "no filter".
|
|
134
136
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/getFormsDataByMarker getFormsDataByMarker} documentation.
|
|
@@ -138,6 +140,22 @@ export default class FormsDataApi extends AsyncModules implements IFormsData {
|
|
|
138
140
|
* Update one object of form data by id. Requires user authentication.
|
|
139
141
|
* @handleName updateFormsDataByid
|
|
140
142
|
* @param {number} id - Form data ID. Example: 1.
|
|
143
|
+
* @param {object} [body] - Form data to save: the same fields as in `postFormsData` (`formIdentifier`, `formModuleConfigId`, `moduleEntityIdentifier`, `replayTo`, `status`, `formData`). Default: `{}`.
|
|
144
|
+
* @example
|
|
145
|
+
{
|
|
146
|
+
"formIdentifier": "test-form",
|
|
147
|
+
"formModuleConfigId": 2,
|
|
148
|
+
"moduleEntityIdentifier": "blog",
|
|
149
|
+
"replayTo": null,
|
|
150
|
+
"status": "sent",
|
|
151
|
+
"formData": [
|
|
152
|
+
{
|
|
153
|
+
"marker": "name",
|
|
154
|
+
"type": "string",
|
|
155
|
+
"value": "Test"
|
|
156
|
+
}
|
|
157
|
+
]
|
|
158
|
+
}
|
|
141
159
|
* @returns {Promise<IUpdateFormsData | IError>} Returns an object containing the updated form data or an error object if there was an issue.
|
|
142
160
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/updateFormsDataByid updateFormsDataByid} documentation.
|
|
143
161
|
*/
|
|
@@ -164,11 +182,11 @@ export default class FormsDataApi extends AsyncModules implements IFormsData {
|
|
|
164
182
|
* @handleName getFormsDataByVectorSearch
|
|
165
183
|
* @param {IFormsDataVectorSearch} body - Vector search parameters. Example: `{ queryText: "order confirmation" }`.
|
|
166
184
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
167
|
-
* @param {number} [offset] - Number of records to skip. Default: 0.
|
|
168
|
-
* @param {number} [limit] - Maximum number of records to return. Default: 30.
|
|
185
|
+
* @param {number} [offset] - Number of records to skip, `0` or more. Default: 0.
|
|
186
|
+
* @param {number} [limit] - Maximum number of records to return, `1` or more. Default: 30.
|
|
169
187
|
* @returns {Promise<IVectorSearchResponse<IFormsDataSearchResponse> | IError>} Returns an object with an array of found form data records and total count.
|
|
170
188
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
171
|
-
* @description This method performs a semantic (vector) search for form data.
|
|
189
|
+
* @description This method performs a semantic (vector) search for form data. The body is checked by the API: an empty `queryText` or one longer than 512 characters, a negative `vectorDistanceThreshold` and a `maxHits` below `1` each answer `400`.
|
|
172
190
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/getFormsDataByVectorSearch getFormsDataByVectorSearch} documentation.
|
|
173
191
|
*/
|
|
174
192
|
getFormsDataByVectorSearch(body: IFormsDataVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IVectorSearchResponse<IFormsDataSearchResponse> | IError>;
|
|
@@ -128,12 +128,25 @@ export default class FormsDataApi extends AsyncModules {
|
|
|
128
128
|
return field;
|
|
129
129
|
}));
|
|
130
130
|
}
|
|
131
|
+
// A failed upload used to be sent to the platform as the field's value, and the caller
|
|
132
|
+
// got a success: the form is not sent, the upload's error is the answer
|
|
133
|
+
const uploadError = formData[langCode]
|
|
134
|
+
.flatMap((field) => Array.isArray(field === null || field === void 0 ? void 0 : field.value) ? field.value : [field === null || field === void 0 ? void 0 : field.value])
|
|
135
|
+
.find((value) => this._isErrorResponse(value));
|
|
136
|
+
if (uploadError) {
|
|
137
|
+
if (this.state.isShell) {
|
|
138
|
+
return uploadError;
|
|
139
|
+
}
|
|
140
|
+
throw uploadError;
|
|
141
|
+
}
|
|
131
142
|
// The wrapped formData goes into a new body: written back into the caller's
|
|
132
143
|
// object, a second call with it wrapped the wrapper and answered `400` (CMS-1071)
|
|
133
144
|
const result = await this._fetchPost(``, { ...body, formData });
|
|
134
145
|
// Validate response if validation is enabled
|
|
135
146
|
const validated = await this._validateResponse(result, schema('PostFormResponseSchema'));
|
|
136
|
-
|
|
147
|
+
// The fields went in under `langCode`, so the response is unwrapped from the same
|
|
148
|
+
// locale; without it a call in another language returned `formData` still keyed by it
|
|
149
|
+
return this._normalizeData(validated, langCode);
|
|
137
150
|
}
|
|
138
151
|
/**
|
|
139
152
|
* Tells a file the SDK still has to upload from one already in storage.
|
|
@@ -214,23 +227,25 @@ export default class FormsDataApi extends AsyncModules {
|
|
|
214
227
|
* @param {number} [body.parentId] - Identifier of the parent record, to fetch replies to one submission. Example: 10.
|
|
215
228
|
* @param {string} [body.userIdentifier] - Text identifier of the sender. Example: "admin".
|
|
216
229
|
* @param {FormDataStatus[]} [body.status] - Moderation statuses to keep: "sent", "moderation", "approved", "banned", "deleted". Must be an array; anything outside the set is rejected with `400 each value in status must be a valid enum value`. Example: ["approved"].
|
|
217
|
-
* @param {string} [body.dateFrom] - Lower bound of the submission date, `YYYY-MM-DD`. An empty string means "no bound" — the SDK removes it from the body, because the endpoint answers `400 dateFrom must be a valid date in format "YYYY-MM-DD"` to one. An unparsable non-empty value still fails the request. Example: "2025-01-01".
|
|
218
|
-
* @param {string} [body.dateTo] - Upper bound of the submission date, `YYYY-MM-DD`. An empty string means "no bound", handled like `dateFrom`. Example: "2025-12-31".
|
|
230
|
+
* @param {string} [body.dateFrom] - Lower bound of the submission date, `YYYY-MM-DD` or `YYYY-MM-DD HH:MM:SS`. An empty string means "no bound" — the SDK removes it from the body, because the endpoint answers `400 dateFrom must be a valid date in format "YYYY-MM-DD"` to one. An unparsable non-empty value still fails the request. Example: "2025-01-01".
|
|
231
|
+
* @param {string} [body.dateTo] - Upper bound of the submission date, `YYYY-MM-DD` or `YYYY-MM-DD HH:MM:SS`. An empty string means "no bound", handled like `dateFrom`. Example: "2025-12-31".
|
|
219
232
|
* @param {number} [isExtended] - Pass `1` to return additional fields for each record. Default: `0`. Example: 1.
|
|
220
233
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
221
|
-
* @param {number} [offset] - Number of records to skip. Default: 0.
|
|
222
|
-
* @param {number} [limit] - Maximum number of records to return. Default: 30.
|
|
234
|
+
* @param {number} [offset] - Number of records to skip, `0` or more (a negative one answers `400 offset must not be less than 0`). Default: 0.
|
|
235
|
+
* @param {number} [limit] - Maximum number of records to return, `1` or more (`0` answers `400 limit must not be less than 1`). Default: 30.
|
|
223
236
|
* @returns {Promise<IFormsByMarkerDataEntity | IError>} Returns an object containing the form data or an error object if there was an issue.
|
|
224
237
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
225
238
|
* @description Each record's `formData` comes back **already unwrapped from its locale**. The API sends `formData: { "en_US": [ … ] }`; the SDK normalizes the response and hands over the array for `langCode`, so read `record.formData` — `record.formData[langCode]` is `undefined` and yields an empty list with no error. This holds for both values of `isExtended`.
|
|
226
239
|
*
|
|
227
|
-
* The filter body is typed
|
|
240
|
+
* The filter body is typed because the API refuses a field it does not know: a misspelled `statuses` answers `400 property statuses should not exist`.
|
|
241
|
+
*
|
|
242
|
+
* A marker or `formModuleConfigId` that matches nothing answers `200` with `{ items: [], total: 0 }`, not `404` — an empty list does not prove the form exists.
|
|
228
243
|
*
|
|
229
244
|
* Empty `dateFrom` / `dateTo` are stripped from the body before it is sent: the endpoint validates the pair as dates and rejects an empty string with a `400`, while every other field still treats "" as "no filter".
|
|
230
245
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/getFormsDataByMarker getFormsDataByMarker} documentation.
|
|
231
246
|
*/
|
|
232
247
|
async getFormsDataByMarker(marker, formModuleConfigId, body = {}, isExtended = 0, langCode = this.state.lang, offset = 0, limit = 30) {
|
|
233
|
-
const result = await this._fetchPost(`/marker/${marker}?formModuleConfigId=${formModuleConfigId}&isExtended=${isExtended}&langCode=${langCode}&offset=${offset}&limit=${limit}`, this._stripEmptyDates(body));
|
|
248
|
+
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));
|
|
234
249
|
// Validate response if validation is enabled
|
|
235
250
|
const validated = await this._validateResponse(result, schema('FormsByMarkerDataResponseSchema'));
|
|
236
251
|
return this._normalizeData(validated, langCode);
|
|
@@ -239,11 +254,27 @@ export default class FormsDataApi extends AsyncModules {
|
|
|
239
254
|
* Update one object of form data by id. Requires user authentication.
|
|
240
255
|
* @handleName updateFormsDataByid
|
|
241
256
|
* @param {number} id - Form data ID. Example: 1.
|
|
257
|
+
* @param {object} [body] - Form data to save: the same fields as in `postFormsData` (`formIdentifier`, `formModuleConfigId`, `moduleEntityIdentifier`, `replayTo`, `status`, `formData`). Default: `{}`.
|
|
258
|
+
* @example
|
|
259
|
+
{
|
|
260
|
+
"formIdentifier": "test-form",
|
|
261
|
+
"formModuleConfigId": 2,
|
|
262
|
+
"moduleEntityIdentifier": "blog",
|
|
263
|
+
"replayTo": null,
|
|
264
|
+
"status": "sent",
|
|
265
|
+
"formData": [
|
|
266
|
+
{
|
|
267
|
+
"marker": "name",
|
|
268
|
+
"type": "string",
|
|
269
|
+
"value": "Test"
|
|
270
|
+
}
|
|
271
|
+
]
|
|
272
|
+
}
|
|
242
273
|
* @returns {Promise<IUpdateFormsData | IError>} Returns an object containing the updated form data or an error object if there was an issue.
|
|
243
274
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/updateFormsDataByid updateFormsDataByid} documentation.
|
|
244
275
|
*/
|
|
245
276
|
async updateFormsDataByid(id, body = {}) {
|
|
246
|
-
const result = await this._fetchPut(`/${id}`, body);
|
|
277
|
+
const result = await this._fetchPut(`/${this._pathSegment(String(id))}`, body);
|
|
247
278
|
// Validate response if validation is enabled
|
|
248
279
|
const validated = await this._validateResponse(result, schema('UpdateFormsDataSchema'));
|
|
249
280
|
return validated;
|
|
@@ -257,7 +288,7 @@ export default class FormsDataApi extends AsyncModules {
|
|
|
257
288
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/updateFormsDataStatusByid updateFormsDataStatusByid} documentation.
|
|
258
289
|
*/
|
|
259
290
|
async updateFormsDataStatusByid(id, body = {}) {
|
|
260
|
-
const result = await this._fetchPut(`/${id}/update-status`, body);
|
|
291
|
+
const result = await this._fetchPut(`/${this._pathSegment(String(id))}/update-status`, body);
|
|
261
292
|
return result;
|
|
262
293
|
}
|
|
263
294
|
/**
|
|
@@ -268,19 +299,19 @@ export default class FormsDataApi extends AsyncModules {
|
|
|
268
299
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/deleteFormsDataByid deleteFormsDataByid} documentation.
|
|
269
300
|
*/
|
|
270
301
|
async deleteFormsDataByid(id) {
|
|
271
|
-
const result = await this._fetchDelete(`/${id}`);
|
|
272
|
-
return result;
|
|
302
|
+
const result = await this._fetchDelete(`/${this._pathSegment(String(id))}`);
|
|
303
|
+
return this._asBoolean(result);
|
|
273
304
|
}
|
|
274
305
|
/**
|
|
275
306
|
* Semantic (vector) search for form data.
|
|
276
307
|
* @handleName getFormsDataByVectorSearch
|
|
277
308
|
* @param {IFormsDataVectorSearch} body - Vector search parameters. Example: `{ queryText: "order confirmation" }`.
|
|
278
309
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
279
|
-
* @param {number} [offset] - Number of records to skip. Default: 0.
|
|
280
|
-
* @param {number} [limit] - Maximum number of records to return. Default: 30.
|
|
310
|
+
* @param {number} [offset] - Number of records to skip, `0` or more. Default: 0.
|
|
311
|
+
* @param {number} [limit] - Maximum number of records to return, `1` or more. Default: 30.
|
|
281
312
|
* @returns {Promise<IVectorSearchResponse<IFormsDataSearchResponse> | IError>} Returns an object with an array of found form data records and total count.
|
|
282
313
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
283
|
-
* @description This method performs a semantic (vector) search for form data.
|
|
314
|
+
* @description This method performs a semantic (vector) search for form data. The body is checked by the API: an empty `queryText` or one longer than 512 characters, a negative `vectorDistanceThreshold` and a `maxHits` below `1` each answer `400`.
|
|
284
315
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/getFormsDataByVectorSearch getFormsDataByVectorSearch} documentation.
|
|
285
316
|
*/
|
|
286
317
|
async getFormsDataByVectorSearch(body, langCode = this.state.lang, offset = 0, limit = 30) {
|