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/dist/events/eventsApi.js
CHANGED
|
@@ -50,7 +50,7 @@ class EventsApi extends asyncModules_1.default {
|
|
|
50
50
|
* @handleName subscribeByMarker
|
|
51
51
|
* @param {string} marker - Marker of the event. Example: "product_price_change".
|
|
52
52
|
* @param {number} productId - Product ID. Example: 12345.
|
|
53
|
-
* @param {string} [langCode] - Language code. Default:
|
|
53
|
+
* @param {string} [langCode] - Language code. Default: the client's language.
|
|
54
54
|
* @returns {Promise<boolean | IError>} Returns true if subscription was successful, or an error object if there was an issue.
|
|
55
55
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
56
56
|
* @description This method requires user authorization.
|
|
@@ -62,14 +62,14 @@ class EventsApi extends asyncModules_1.default {
|
|
|
62
62
|
locale: langCode,
|
|
63
63
|
productId,
|
|
64
64
|
};
|
|
65
|
-
return this._fetchBoolean(() => this._fetchPost(`/subscribe/marker/${marker}`, body));
|
|
65
|
+
return this._fetchBoolean(() => this._fetchPost(`/subscribe/marker/${this._pathSegment(marker)}`, body));
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
68
|
* Unsubscribing to an event on a product.
|
|
69
69
|
* @handleName unsubscribeByMarker
|
|
70
70
|
* @param {string} marker - Marker of the event to unsubscribe from. Example: "product_price_change".
|
|
71
71
|
* @param {number} productId - ID of the product to unsubscribe from. Example: 12345.
|
|
72
|
-
* @param {string} [langCode] - Language code. Default:
|
|
72
|
+
* @param {string} [langCode] - Language code. Default: the client's language.
|
|
73
73
|
* @returns {Promise<boolean | IError>} - Returns true if the unsubscription succeeded, or an error object if there was an issue.
|
|
74
74
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
75
75
|
* @description This method requires user authorization.
|
|
@@ -81,14 +81,14 @@ class EventsApi extends asyncModules_1.default {
|
|
|
81
81
|
productId: productId,
|
|
82
82
|
locale: langCode,
|
|
83
83
|
};
|
|
84
|
-
return this._fetchBoolean(() => this._fetchDelete(`/unsubscribe/marker/${marker}`, body));
|
|
84
|
+
return this._fetchBoolean(() => this._fetchDelete(`/unsubscribe/marker/${this._pathSegment(marker)}`, body));
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
87
|
* Returns all available events.
|
|
88
88
|
* @handleName getAllEvents
|
|
89
89
|
* @returns {Promise<IContentApiEvent[] | IError>} Returns an array of available events.
|
|
90
90
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
91
|
-
* @description This method returns all available events.
|
|
91
|
+
* @description This method returns all available events. This method requires user authorization — without it the API answers `401 Unauthorized`.
|
|
92
92
|
* @see {@link https://js-sdk.oneentry.cloud/docs/events/getAllEvents getAllEvents} documentation.
|
|
93
93
|
*/
|
|
94
94
|
async getAllEvents() {
|
|
@@ -107,7 +107,7 @@ class EventsApi extends asyncModules_1.default {
|
|
|
107
107
|
* @see {@link https://js-sdk.oneentry.cloud/docs/events/subscribeToForm subscribeToForm} documentation.
|
|
108
108
|
*/
|
|
109
109
|
async subscribeToForm(marker, body) {
|
|
110
|
-
return this._fetchBoolean(() => this._fetchPost(`/forms/subscribe/marker/${marker}`, body));
|
|
110
|
+
return this._fetchBoolean(() => this._fetchPost(`/forms/subscribe/marker/${this._pathSegment(marker)}`, body));
|
|
111
111
|
}
|
|
112
112
|
/**
|
|
113
113
|
* Returns all form subscriptions.
|
|
@@ -140,7 +140,7 @@ class EventsApi extends asyncModules_1.default {
|
|
|
140
140
|
* @see {@link https://js-sdk.oneentry.cloud/docs/events/unsubscribeFromForm unsubscribeFromForm} documentation.
|
|
141
141
|
*/
|
|
142
142
|
async unsubscribeFromForm(marker, body) {
|
|
143
|
-
return this._fetchBoolean(() => this._fetchDelete(`/forms/unsubscribe/marker/${marker}`, body));
|
|
143
|
+
return this._fetchBoolean(() => this._fetchDelete(`/forms/unsubscribe/marker/${this._pathSegment(marker)}`, body));
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
exports.default = EventsApi;
|
|
@@ -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
|
}
|
|
@@ -121,7 +121,10 @@ class FileUploadingApi extends asyncModules_1.default {
|
|
|
121
121
|
const query = { ...this._defaultQuery, ...fileQuery };
|
|
122
122
|
// The endpoint answers 200 with an empty body, which _parseJson reads as `{}`;
|
|
123
123
|
// _fetchBoolean turns that into the declared `true` (CMS-1072)
|
|
124
|
-
return this._fetchBoolean(() => this._fetchDelete(
|
|
124
|
+
return this._fetchBoolean(() => this._fetchDelete(
|
|
125
|
+
// The name is encoded like the other parameters: `#` cut the query and dropped
|
|
126
|
+
// type/entity/id, `&id=` added parameters of its own
|
|
127
|
+
`?` + this._queryParamsToString({ filename, ...query })));
|
|
125
128
|
}
|
|
126
129
|
/**
|
|
127
130
|
* Public search across the content of files attached to records.
|
|
@@ -171,10 +174,15 @@ class FileUploadingApi extends asyncModules_1.default {
|
|
|
171
174
|
* @param {string} filename - The name to give the created file.
|
|
172
175
|
* @param {string} [mimeType] - Optional MIME type for the file.
|
|
173
176
|
* @returns {Promise<File>} A promise that resolves to a File object.
|
|
177
|
+
* @throws {Error} When the URL answers with an error status — the body of the error page is not turned into a file.
|
|
174
178
|
*/
|
|
175
179
|
async createFileFromUrl(url, filename, mimeType) {
|
|
176
180
|
// eslint-disable-next-line no-undef
|
|
177
181
|
const response = await fetch(url);
|
|
182
|
+
// A 404 page of the storage used to become the "file" and was then uploaded as is
|
|
183
|
+
if (!response.ok) {
|
|
184
|
+
throw new Error(`OneEntry SDK: createFileFromUrl got ${response.status} from ${url}`);
|
|
185
|
+
}
|
|
178
186
|
const blob = await response.blob();
|
|
179
187
|
const file = new File([blob], filename, { type: mimeType || blob.type });
|
|
180
188
|
return file;
|
|
@@ -186,14 +194,14 @@ class FileUploadingApi extends asyncModules_1.default {
|
|
|
186
194
|
* @param {string} type - Storage type; determines the folder the file is stored in, for example `"page"`. Example: "page".
|
|
187
195
|
* @param {string} entity - Name of the entity the file belongs to; sets the folder name in the storage. Example: "editor".
|
|
188
196
|
* @param {string} filename - File name. Example: "file.png".
|
|
189
|
-
* @param {string} [template] -
|
|
190
|
-
* @returns {Promise<Response
|
|
191
|
-
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
197
|
+
* @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`.
|
|
198
|
+
* @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` …).
|
|
192
199
|
* @see {@link https://js-sdk.oneentry.cloud/docs/file-uploading/getFile getFile} documentation.
|
|
193
200
|
*/
|
|
194
201
|
async getFile(id, type, entity, filename, template) {
|
|
195
202
|
// eslint-disable-next-line no-undef
|
|
196
|
-
const response = await fetch(this._getFullPath(
|
|
203
|
+
const response = await fetch(this._getFullPath('?' +
|
|
204
|
+
this._queryParamsToString({ id, type, entity, filename, template })), {
|
|
197
205
|
method: 'GET',
|
|
198
206
|
headers: {
|
|
199
207
|
'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
|
*/
|
|
@@ -67,9 +67,9 @@ class FiltersApi extends asyncModules_1.default {
|
|
|
67
67
|
* @see {@link https://js-sdk.oneentry.cloud/docs/filters/getFilterByMarker getFilterByMarker} documentation.
|
|
68
68
|
*/
|
|
69
69
|
async getFilterByMarker(marker, langCode = this.state.lang) {
|
|
70
|
-
const data = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
70
|
+
const data = await this._fetchGet(`/marker/${this._pathSegment(marker)}?langCode=${encodeURIComponent(langCode)}`);
|
|
71
71
|
const validated = await this._validateResponse(data, schema('ContentFilterSchema'));
|
|
72
|
-
return this._normalizeData(validated);
|
|
72
|
+
return this._normalizeData(validated, langCode);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
exports.default = FiltersApi;
|
package/dist/forms/formsApi.js
CHANGED
|
@@ -69,7 +69,7 @@ class FormsApi extends asyncModules_1.default {
|
|
|
69
69
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms/getAllForms getAllForms} documentation.
|
|
70
70
|
*/
|
|
71
71
|
async getAllForms(langCode = this.state.lang, offset = 0, limit = 30) {
|
|
72
|
-
const result = await this._fetchGet(`?langCode=${langCode}&offset=${offset}&limit=${limit}`);
|
|
72
|
+
const result = await this._fetchGet(`?langCode=${encodeURIComponent(langCode)}&offset=${encodeURIComponent(String(offset))}&limit=${encodeURIComponent(String(limit))}`);
|
|
73
73
|
// Validate response if validation is enabled
|
|
74
74
|
const validated = await this._validateResponse(result, schema('FormsResponseSchema'));
|
|
75
75
|
return this._normalizeData(validated, langCode);
|
|
@@ -84,7 +84,7 @@ class FormsApi extends asyncModules_1.default {
|
|
|
84
84
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms/getFormByMarker getFormByMarker} documentation.
|
|
85
85
|
*/
|
|
86
86
|
async getFormByMarker(marker, langCode = this.state.lang) {
|
|
87
|
-
const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
87
|
+
const result = await this._fetchGet(`/marker/${this._pathSegment(marker)}?langCode=${encodeURIComponent(langCode)}`);
|
|
88
88
|
// Validate response if validation is enabled
|
|
89
89
|
const validated = await this._validateResponse(result, schema('FormEntitySchema'));
|
|
90
90
|
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>;
|
|
@@ -16,10 +16,8 @@ exports.FormEntitySchema = zod_1.z.object({
|
|
|
16
16
|
type: zod_1.z.string().nullable(),
|
|
17
17
|
attributeSetId: zod_1.z.number().nullable(),
|
|
18
18
|
templateId: zod_1.z.number().nullable(),
|
|
19
|
-
|
|
20
|
-
attributes: zod_1.z
|
|
21
|
-
.union([zod_1.z.array(zod_1.z.any()), zod_1.z.record(zod_1.z.string(), zod_1.z.any())])
|
|
22
|
-
.optional(),
|
|
19
|
+
// Required as in IFormsEntity: a form without fields comes as `{}`
|
|
20
|
+
attributes: zod_1.z.union([zod_1.z.array(zod_1.z.any()), zod_1.z.record(zod_1.z.string(), zod_1.z.any())]),
|
|
23
21
|
moduleFormConfigs: zod_1.z.array(zod_1.z.any()).optional(),
|
|
24
22
|
});
|
|
25
23
|
/**
|
|
@@ -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>;
|
|
@@ -166,12 +166,25 @@ class FormsDataApi extends asyncModules_1.default {
|
|
|
166
166
|
return field;
|
|
167
167
|
}));
|
|
168
168
|
}
|
|
169
|
+
// A failed upload used to be sent to the platform as the field's value, and the caller
|
|
170
|
+
// got a success: the form is not sent, the upload's error is the answer
|
|
171
|
+
const uploadError = formData[langCode]
|
|
172
|
+
.flatMap((field) => Array.isArray(field === null || field === void 0 ? void 0 : field.value) ? field.value : [field === null || field === void 0 ? void 0 : field.value])
|
|
173
|
+
.find((value) => this._isErrorResponse(value));
|
|
174
|
+
if (uploadError) {
|
|
175
|
+
if (this.state.isShell) {
|
|
176
|
+
return uploadError;
|
|
177
|
+
}
|
|
178
|
+
throw uploadError;
|
|
179
|
+
}
|
|
169
180
|
// The wrapped formData goes into a new body: written back into the caller's
|
|
170
181
|
// object, a second call with it wrapped the wrapper and answered `400` (CMS-1071)
|
|
171
182
|
const result = await this._fetchPost(``, { ...body, formData });
|
|
172
183
|
// Validate response if validation is enabled
|
|
173
184
|
const validated = await this._validateResponse(result, schema('PostFormResponseSchema'));
|
|
174
|
-
|
|
185
|
+
// The fields went in under `langCode`, so the response is unwrapped from the same
|
|
186
|
+
// locale; without it a call in another language returned `formData` still keyed by it
|
|
187
|
+
return this._normalizeData(validated, langCode);
|
|
175
188
|
}
|
|
176
189
|
/**
|
|
177
190
|
* Tells a file the SDK still has to upload from one already in storage.
|
|
@@ -252,23 +265,25 @@ class FormsDataApi extends asyncModules_1.default {
|
|
|
252
265
|
* @param {number} [body.parentId] - Identifier of the parent record, to fetch replies to one submission. Example: 10.
|
|
253
266
|
* @param {string} [body.userIdentifier] - Text identifier of the sender. Example: "admin".
|
|
254
267
|
* @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"].
|
|
255
|
-
* @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".
|
|
256
|
-
* @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".
|
|
268
|
+
* @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".
|
|
269
|
+
* @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".
|
|
257
270
|
* @param {number} [isExtended] - Pass `1` to return additional fields for each record. Default: `0`. Example: 1.
|
|
258
271
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
259
|
-
* @param {number} [offset] - Number of records to skip. Default: 0.
|
|
260
|
-
* @param {number} [limit] - Maximum number of records to return. Default: 30.
|
|
272
|
+
* @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.
|
|
273
|
+
* @param {number} [limit] - Maximum number of records to return, `1` or more (`0` answers `400 limit must not be less than 1`). Default: 30.
|
|
261
274
|
* @returns {Promise<IFormsByMarkerDataEntity | IError>} Returns an object containing the form data or an error object if there was an issue.
|
|
262
275
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
263
276
|
* @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`.
|
|
264
277
|
*
|
|
265
|
-
* The filter body is typed
|
|
278
|
+
* 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`.
|
|
279
|
+
*
|
|
280
|
+
* A marker or `formModuleConfigId` that matches nothing answers `200` with `{ items: [], total: 0 }`, not `404` — an empty list does not prove the form exists.
|
|
266
281
|
*
|
|
267
282
|
* 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".
|
|
268
283
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/getFormsDataByMarker getFormsDataByMarker} documentation.
|
|
269
284
|
*/
|
|
270
285
|
async getFormsDataByMarker(marker, formModuleConfigId, body = {}, isExtended = 0, langCode = this.state.lang, offset = 0, limit = 30) {
|
|
271
|
-
const result = await this._fetchPost(`/marker/${marker}?formModuleConfigId=${formModuleConfigId}&isExtended=${isExtended}&langCode=${langCode}&offset=${offset}&limit=${limit}`, this._stripEmptyDates(body));
|
|
286
|
+
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));
|
|
272
287
|
// Validate response if validation is enabled
|
|
273
288
|
const validated = await this._validateResponse(result, schema('FormsByMarkerDataResponseSchema'));
|
|
274
289
|
return this._normalizeData(validated, langCode);
|
|
@@ -277,11 +292,27 @@ class FormsDataApi extends asyncModules_1.default {
|
|
|
277
292
|
* Update one object of form data by id. Requires user authentication.
|
|
278
293
|
* @handleName updateFormsDataByid
|
|
279
294
|
* @param {number} id - Form data ID. Example: 1.
|
|
295
|
+
* @param {object} [body] - Form data to save: the same fields as in `postFormsData` (`formIdentifier`, `formModuleConfigId`, `moduleEntityIdentifier`, `replayTo`, `status`, `formData`). Default: `{}`.
|
|
296
|
+
* @example
|
|
297
|
+
{
|
|
298
|
+
"formIdentifier": "test-form",
|
|
299
|
+
"formModuleConfigId": 2,
|
|
300
|
+
"moduleEntityIdentifier": "blog",
|
|
301
|
+
"replayTo": null,
|
|
302
|
+
"status": "sent",
|
|
303
|
+
"formData": [
|
|
304
|
+
{
|
|
305
|
+
"marker": "name",
|
|
306
|
+
"type": "string",
|
|
307
|
+
"value": "Test"
|
|
308
|
+
}
|
|
309
|
+
]
|
|
310
|
+
}
|
|
280
311
|
* @returns {Promise<IUpdateFormsData | IError>} Returns an object containing the updated form data or an error object if there was an issue.
|
|
281
312
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/updateFormsDataByid updateFormsDataByid} documentation.
|
|
282
313
|
*/
|
|
283
314
|
async updateFormsDataByid(id, body = {}) {
|
|
284
|
-
const result = await this._fetchPut(`/${id}`, body);
|
|
315
|
+
const result = await this._fetchPut(`/${this._pathSegment(String(id))}`, body);
|
|
285
316
|
// Validate response if validation is enabled
|
|
286
317
|
const validated = await this._validateResponse(result, schema('UpdateFormsDataSchema'));
|
|
287
318
|
return validated;
|
|
@@ -295,7 +326,7 @@ class FormsDataApi extends asyncModules_1.default {
|
|
|
295
326
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/updateFormsDataStatusByid updateFormsDataStatusByid} documentation.
|
|
296
327
|
*/
|
|
297
328
|
async updateFormsDataStatusByid(id, body = {}) {
|
|
298
|
-
const result = await this._fetchPut(`/${id}/update-status`, body);
|
|
329
|
+
const result = await this._fetchPut(`/${this._pathSegment(String(id))}/update-status`, body);
|
|
299
330
|
return result;
|
|
300
331
|
}
|
|
301
332
|
/**
|
|
@@ -306,19 +337,19 @@ class FormsDataApi extends asyncModules_1.default {
|
|
|
306
337
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/deleteFormsDataByid deleteFormsDataByid} documentation.
|
|
307
338
|
*/
|
|
308
339
|
async deleteFormsDataByid(id) {
|
|
309
|
-
const result = await this._fetchDelete(`/${id}`);
|
|
310
|
-
return result;
|
|
340
|
+
const result = await this._fetchDelete(`/${this._pathSegment(String(id))}`);
|
|
341
|
+
return this._asBoolean(result);
|
|
311
342
|
}
|
|
312
343
|
/**
|
|
313
344
|
* Semantic (vector) search for form data.
|
|
314
345
|
* @handleName getFormsDataByVectorSearch
|
|
315
346
|
* @param {IFormsDataVectorSearch} body - Vector search parameters. Example: `{ queryText: "order confirmation" }`.
|
|
316
347
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
317
|
-
* @param {number} [offset] - Number of records to skip. Default: 0.
|
|
318
|
-
* @param {number} [limit] - Maximum number of records to return. Default: 30.
|
|
348
|
+
* @param {number} [offset] - Number of records to skip, `0` or more. Default: 0.
|
|
349
|
+
* @param {number} [limit] - Maximum number of records to return, `1` or more. Default: 30.
|
|
319
350
|
* @returns {Promise<IVectorSearchResponse<IFormsDataSearchResponse> | IError>} Returns an object with an array of found form data records and total count.
|
|
320
351
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
321
|
-
* @description This method performs a semantic (vector) search for form data.
|
|
352
|
+
* @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`.
|
|
322
353
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/getFormsDataByVectorSearch getFormsDataByVectorSearch} documentation.
|
|
323
354
|
*/
|
|
324
355
|
async getFormsDataByVectorSearch(body, langCode = this.state.lang, offset = 0, limit = 30) {
|