oneentry 1.0.159 → 1.0.161

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/README.md +2 -0
  2. package/changelog.md +56 -1
  3. package/dist/admins/adminsApi.d.ts +15 -1
  4. package/dist/admins/adminsApi.js +29 -0
  5. package/dist/admins/adminsInterfaces.d.ts +37 -1
  6. package/dist/base/lazySchema.d.ts +15 -0
  7. package/dist/base/lazySchema.js +20 -0
  8. package/dist/discounts/discountsApi.d.ts +14 -1
  9. package/dist/discounts/discountsApi.js +21 -0
  10. package/dist/discounts/discountsInterfaces.d.ts +27 -1
  11. package/dist/filters/filtersInterfaces.d.ts +2 -2
  12. package/dist/filters/filtersSchemas.d.ts +1 -1
  13. package/dist/filters/filtersSchemas.js +4 -1
  14. package/dist/forms-data/formsDataApi.d.ts +14 -1
  15. package/dist/forms-data/formsDataApi.js +21 -0
  16. package/dist/forms-data/formsDataInterfaces.d.ts +74 -1
  17. package/dist/index.d.ts +4 -0
  18. package/dist/index.js +3 -0
  19. package/dist/orders/ordersApi.d.ts +15 -1
  20. package/dist/orders/ordersApi.js +22 -0
  21. package/dist/orders/ordersInterfaces.d.ts +27 -1
  22. package/dist/pages/pagesApi.d.ts +14 -1
  23. package/dist/pages/pagesApi.js +21 -0
  24. package/dist/pages/pagesInterfaces.d.ts +38 -1
  25. package/dist/payments/paymentsInterfaces.d.ts +2 -2
  26. package/dist/products/productsInterfaces.d.ts +1 -1
  27. package/dist/search/searchApi.d.ts +35 -0
  28. package/dist/search/searchApi.js +86 -0
  29. package/dist/search/searchInterfaces.d.ts +94 -0
  30. package/dist/search/searchInterfaces.js +2 -0
  31. package/dist/search/searchSchemas.d.ts +73 -0
  32. package/dist/search/searchSchemas.js +44 -0
  33. package/dist/templates-preview/templatesPreviewInterfaces.d.ts +0 -2
  34. package/dist/templates-preview/templatesPreviewSchemas.d.ts +0 -2
  35. package/dist/templates-preview/templatesPreviewSchemas.js +0 -1
  36. package/dist/types.d.ts +35 -0
  37. package/dist/types.js +2 -0
  38. package/dist/users/usersApi.d.ts +15 -1
  39. package/dist/users/usersApi.js +22 -0
  40. package/dist/users/usersInterfaces.d.ts +39 -1
  41. package/dist/web-socket/lazySocket.d.ts +18 -0
  42. package/dist/web-socket/lazySocket.js +70 -0
  43. package/esm/admins/adminsApi.d.ts +66 -0
  44. package/esm/admins/adminsApi.js +90 -0
  45. package/esm/admins/adminsInterfaces.d.ts +137 -0
  46. package/esm/admins/adminsInterfaces.js +1 -0
  47. package/esm/admins/adminsSchemas.d.ts +48 -0
  48. package/esm/admins/adminsSchemas.js +31 -0
  49. package/esm/attribute-sets/attributeSetsApi.d.ts +67 -0
  50. package/esm/attribute-sets/attributeSetsApi.js +97 -0
  51. package/esm/attribute-sets/attributeSetsInterfaces.d.ts +285 -0
  52. package/esm/attribute-sets/attributeSetsInterfaces.js +1 -0
  53. package/esm/attribute-sets/attributeSetsSchemas.d.ts +84 -0
  54. package/esm/attribute-sets/attributeSetsSchemas.js +66 -0
  55. package/esm/auth-provider/authProviderApi.d.ts +262 -0
  56. package/esm/auth-provider/authProviderApi.js +362 -0
  57. package/esm/auth-provider/authProviderSchemas.d.ts +124 -0
  58. package/esm/auth-provider/authProviderSchemas.js +92 -0
  59. package/esm/auth-provider/authProvidersInterfaces.d.ts +430 -0
  60. package/esm/auth-provider/authProvidersInterfaces.js +1 -0
  61. package/esm/base/asyncModules.d.ts +123 -0
  62. package/esm/base/asyncModules.js +382 -0
  63. package/esm/base/lazySchema.d.ts +15 -0
  64. package/esm/base/lazySchema.js +17 -0
  65. package/esm/base/stateModule.d.ts +35 -0
  66. package/esm/base/stateModule.js +51 -0
  67. package/esm/base/syncModules.d.ts +245 -0
  68. package/esm/base/syncModules.js +555 -0
  69. package/esm/base/timeIntervals.d.ts +95 -0
  70. package/esm/base/timeIntervals.js +317 -0
  71. package/esm/base/utils.d.ts +354 -0
  72. package/esm/base/utils.js +1 -0
  73. package/esm/base/validation.d.ts +98 -0
  74. package/esm/base/validation.js +118 -0
  75. package/esm/blocks/blocksApi.d.ts +252 -0
  76. package/esm/blocks/blocksApi.js +394 -0
  77. package/esm/blocks/blocksInterfaces.d.ts +361 -0
  78. package/esm/blocks/blocksInterfaces.js +1 -0
  79. package/esm/blocks/blocksSchemas.d.ts +213 -0
  80. package/esm/blocks/blocksSchemas.js +40 -0
  81. package/esm/discounts/discountsApi.d.ts +94 -0
  82. package/esm/discounts/discountsApi.js +136 -0
  83. package/esm/discounts/discountsInterfaces.d.ts +293 -0
  84. package/esm/discounts/discountsInterfaces.js +1 -0
  85. package/esm/events/eventsApi.d.ts +108 -0
  86. package/esm/events/eventsApi.js +141 -0
  87. package/esm/events/eventsInterfaces.d.ts +176 -0
  88. package/esm/events/eventsInterfaces.js +1 -0
  89. package/esm/file-uploading/fileUploadingApi.d.ts +91 -0
  90. package/esm/file-uploading/fileUploadingApi.js +127 -0
  91. package/esm/file-uploading/fileUploadingInterfaces.d.ts +116 -0
  92. package/esm/file-uploading/fileUploadingInterfaces.js +1 -0
  93. package/esm/file-uploading/fileUploadingSchemas.d.ts +24 -0
  94. package/esm/file-uploading/fileUploadingSchemas.js +19 -0
  95. package/esm/filters/filtersApi.d.ts +32 -0
  96. package/esm/filters/filtersApi.js +36 -0
  97. package/esm/filters/filtersInterfaces.d.ts +56 -0
  98. package/esm/filters/filtersInterfaces.js +1 -0
  99. package/esm/filters/filtersSchemas.d.ts +32 -0
  100. package/esm/filters/filtersSchemas.js +29 -0
  101. package/esm/forms/formsApi.d.ts +44 -0
  102. package/esm/forms/formsApi.js +54 -0
  103. package/esm/forms/formsInterfaces.d.ts +237 -0
  104. package/esm/forms/formsInterfaces.js +1 -0
  105. package/esm/forms/formsSchemas.d.ts +56 -0
  106. package/esm/forms/formsSchemas.js +32 -0
  107. package/esm/forms-data/formsDataApi.d.ts +124 -0
  108. package/esm/forms-data/formsDataApi.js +210 -0
  109. package/esm/forms-data/formsDataInterfaces.d.ts +670 -0
  110. package/esm/forms-data/formsDataInterfaces.js +1 -0
  111. package/esm/forms-data/formsDataSchemas.d.ts +107 -0
  112. package/esm/forms-data/formsDataSchemas.js +83 -0
  113. package/esm/general-types/generalTypesApi.d.ts +29 -0
  114. package/esm/general-types/generalTypesApi.js +34 -0
  115. package/esm/general-types/generalTypesInterfaces.d.ts +29 -0
  116. package/esm/general-types/generalTypesInterfaces.js +1 -0
  117. package/esm/general-types/generalTypesSchemas.d.ts +68 -0
  118. package/esm/general-types/generalTypesSchemas.js +42 -0
  119. package/esm/index.d.ts +143 -0
  120. package/esm/index.js +124 -0
  121. package/esm/integration-collections/integrationCollectionsApi.d.ts +172 -0
  122. package/esm/integration-collections/integrationCollectionsApi.js +224 -0
  123. package/esm/integration-collections/integrationCollectionsInterfaces.d.ts +317 -0
  124. package/esm/integration-collections/integrationCollectionsInterfaces.js +1 -0
  125. package/esm/integration-collections/integrationCollectionsSchemas.d.ts +84 -0
  126. package/esm/integration-collections/integrationCollectionsSchemas.js +60 -0
  127. package/esm/locales/localesApi.d.ts +28 -0
  128. package/esm/locales/localesApi.js +33 -0
  129. package/esm/locales/localesInterfaces.d.ts +40 -0
  130. package/esm/locales/localesInterfaces.js +1 -0
  131. package/esm/locales/localesSchemas.d.ts +32 -0
  132. package/esm/locales/localesSchemas.js +23 -0
  133. package/esm/menus/menusApi.d.ts +30 -0
  134. package/esm/menus/menusApi.js +35 -0
  135. package/esm/menus/menusInterfaces.d.ts +87 -0
  136. package/esm/menus/menusInterfaces.js +2 -0
  137. package/esm/menus/menusSchemas.d.ts +16 -0
  138. package/esm/menus/menusSchemas.js +25 -0
  139. package/esm/orders/ordersApi.d.ts +213 -0
  140. package/esm/orders/ordersApi.js +288 -0
  141. package/esm/orders/ordersInterfaces.d.ts +763 -0
  142. package/esm/orders/ordersInterfaces.js +1 -0
  143. package/esm/orders/ordersSchemas.d.ts +312 -0
  144. package/esm/orders/ordersSchemas.js +171 -0
  145. package/esm/package.json +4 -0
  146. package/esm/pages/pagesApi.d.ts +173 -0
  147. package/esm/pages/pagesApi.js +414 -0
  148. package/esm/pages/pagesInterfaces.d.ts +344 -0
  149. package/esm/pages/pagesInterfaces.js +1 -0
  150. package/esm/pages/pagesSchemas.d.ts +121 -0
  151. package/esm/pages/pagesSchemas.js +60 -0
  152. package/esm/payments/paymentsApi.d.ts +88 -0
  153. package/esm/payments/paymentsApi.js +122 -0
  154. package/esm/payments/paymentsInterfaces.d.ts +189 -0
  155. package/esm/payments/paymentsInterfaces.js +1 -0
  156. package/esm/payments/paymentsSchemas.d.ts +94 -0
  157. package/esm/payments/paymentsSchemas.js +53 -0
  158. package/esm/product-statuses/productStatusesApi.d.ts +50 -0
  159. package/esm/product-statuses/productStatusesApi.js +68 -0
  160. package/esm/product-statuses/productStatusesInterfaces.d.ts +62 -0
  161. package/esm/product-statuses/productStatusesInterfaces.js +1 -0
  162. package/esm/product-statuses/productStatusesSchemas.d.ts +34 -0
  163. package/esm/product-statuses/productStatusesSchemas.js +27 -0
  164. package/esm/products/productsApi.d.ts +366 -0
  165. package/esm/products/productsApi.js +468 -0
  166. package/esm/products/productsInterfaces.d.ts +723 -0
  167. package/esm/products/productsInterfaces.js +1 -0
  168. package/esm/products/productsSchemas.d.ts +234 -0
  169. package/esm/products/productsSchemas.js +121 -0
  170. package/esm/search/searchApi.d.ts +35 -0
  171. package/esm/search/searchApi.js +47 -0
  172. package/esm/search/searchInterfaces.d.ts +94 -0
  173. package/esm/search/searchInterfaces.js +1 -0
  174. package/esm/search/searchSchemas.d.ts +73 -0
  175. package/esm/search/searchSchemas.js +41 -0
  176. package/esm/sitemap/sitemapApi.d.ts +37 -0
  177. package/esm/sitemap/sitemapApi.js +41 -0
  178. package/esm/sitemap/sitemapInterfaces.d.ts +51 -0
  179. package/esm/sitemap/sitemapInterfaces.js +1 -0
  180. package/esm/subscriptions/subscriptionsApi.d.ts +74 -0
  181. package/esm/subscriptions/subscriptionsApi.js +90 -0
  182. package/esm/subscriptions/subscriptionsInterfaces.d.ts +111 -0
  183. package/esm/subscriptions/subscriptionsInterfaces.js +1 -0
  184. package/esm/subscriptions/subscriptionsSchemas.d.ts +46 -0
  185. package/esm/subscriptions/subscriptionsSchemas.js +38 -0
  186. package/esm/system/systemApi.d.ts +46 -0
  187. package/esm/system/systemApi.js +53 -0
  188. package/esm/system/systemInterfaces.d.ts +29 -0
  189. package/esm/system/systemInterfaces.js +1 -0
  190. package/esm/templates/templatesApi.d.ts +53 -0
  191. package/esm/templates/templatesApi.js +78 -0
  192. package/esm/templates/templatesInterfaces.d.ts +68 -0
  193. package/esm/templates/templatesInterfaces.js +1 -0
  194. package/esm/templates/templatesSchemas.d.ts +48 -0
  195. package/esm/templates/templatesSchemas.js +28 -0
  196. package/esm/templates-preview/templatesPreviewApi.d.ts +40 -0
  197. package/esm/templates-preview/templatesPreviewApi.js +50 -0
  198. package/esm/templates-preview/templatesPreviewInterfaces.d.ts +129 -0
  199. package/esm/templates-preview/templatesPreviewInterfaces.js +1 -0
  200. package/esm/templates-preview/templatesPreviewSchemas.d.ts +79 -0
  201. package/esm/templates-preview/templatesPreviewSchemas.js +43 -0
  202. package/esm/types.d.ts +35 -0
  203. package/esm/types.js +1 -0
  204. package/esm/user-activity/userActivityApi.d.ts +31 -0
  205. package/esm/user-activity/userActivityApi.js +37 -0
  206. package/esm/user-activity/userActivityInterfaces.d.ts +42 -0
  207. package/esm/user-activity/userActivityInterfaces.js +1 -0
  208. package/esm/users/usersApi.d.ts +249 -0
  209. package/esm/users/usersApi.js +312 -0
  210. package/esm/users/usersInterfaces.d.ts +419 -0
  211. package/esm/users/usersInterfaces.js +1 -0
  212. package/esm/users/usersSchemas.d.ts +72 -0
  213. package/esm/users/usersSchemas.js +55 -0
  214. package/esm/web-socket/lazySocket.d.ts +18 -0
  215. package/esm/web-socket/lazySocket.js +67 -0
  216. package/esm/web-socket/wsApi.d.ts +27 -0
  217. package/esm/web-socket/wsApi.js +43 -0
  218. package/esm/web-socket/wsInterfaces.d.ts +16 -0
  219. package/esm/web-socket/wsInterfaces.js +1 -0
  220. package/package.json +47 -2
  221. package/types.d.ts +1 -0
  222. package/types.js +1 -0
@@ -0,0 +1,32 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Form entity schema
4
+ * Includes all fields returned by the API
5
+ */
6
+ export const FormEntitySchema = z.object({
7
+ id: z.number(),
8
+ identifier: z.string(),
9
+ localizeInfos: z.union([z.record(z.string(), z.any()), z.array(z.any())]),
10
+ version: z.number(),
11
+ position: z.number(),
12
+ processingType: z.string(),
13
+ type: z.string().nullable(),
14
+ attributeSetId: z.number().nullable(),
15
+ templateId: z.number().nullable(),
16
+ total: z.union([z.number(), z.string()]).optional(),
17
+ attributes: z
18
+ .union([z.array(z.any()), z.record(z.string(), z.any())])
19
+ .optional(),
20
+ moduleFormConfigs: z.array(z.any()).optional(),
21
+ });
22
+ /**
23
+ * Forms response schema (paginated)
24
+ */
25
+ export const FormsResponseSchema = z.object({
26
+ total: z.number(),
27
+ items: z.array(FormEntitySchema),
28
+ });
29
+ /**
30
+ * Single form response schema
31
+ */
32
+ export const SingleFormSchema = FormEntitySchema;
@@ -0,0 +1,124 @@
1
+ import AsyncModules from '../base/asyncModules.js';
2
+ import type StateModule from '../base/stateModule.js';
3
+ import type { IError } from '../base/utils.js';
4
+ import type { IBodyPostFormData, IFormsByMarkerDataEntity, IFormsData, IFormsDataSearchResponse, IFormsDataVectorSearch, IPostFormResponse, IUpdateFormsData } from './formsDataInterfaces.js';
5
+ /**
6
+ * Controllers for working with form data
7
+ * @handle /api/content/form-data
8
+ * @class FormsDataApi
9
+ * @augments AsyncModules
10
+ * @implements {IFormsData}
11
+ * @description This class provides methods to interact with form data, including retrieving all forms data, creating new form data entries, and fetching form data by marker.
12
+ */
13
+ export default class FormsDataApi extends AsyncModules implements IFormsData {
14
+ protected state: StateModule;
15
+ protected _url: string;
16
+ /**
17
+ * Constructor for FormsDataApi class.
18
+ */
19
+ constructor(state: StateModule);
20
+ /**
21
+ * Creating an object of data save information by form
22
+ * @handleName postFormsData
23
+ * @param {IBodyPostFormData} body - Request body.
24
+ * @example
25
+ {
26
+ "formIdentifier": "test-form",
27
+ "formModuleConfigId": 2,
28
+ "moduleEntityIdentifier": "blog",
29
+ "replayTo": null,
30
+ "status": "sent",
31
+ "formData": [
32
+ {
33
+ "marker": "name",
34
+ "type": "string",
35
+ "value": "Test"
36
+ }
37
+ ]
38
+ }
39
+ * @param {string} body.formIdentifier - The identifier for the form. Example: "form".
40
+ * @param {number} body.formModuleConfigId - The ID of the form module configuration. Example: 2.
41
+ * @param {string} body.moduleEntityIdentifier - The identifier of the module entity. Example: "form".
42
+ * @param {string | null} [body.replayTo] - The email address to which the reply should be sent.
43
+ * @param {string | null} [body.status] - The status of the form submission.
44
+ * @param {FormDataType[]} body.formData - Form data.
45
+ * @example
46
+ [
47
+ {
48
+ "marker": "name",
49
+ "type": "string",
50
+ "value": "Jack"
51
+ }
52
+ ]
53
+ * @param {string} body.formData[].marker - The marker identifying the form field. Example: "name".
54
+ * @param {string} body.formData[].type - The type of the form field. Example: "string".
55
+ * @param {string} body.formData[].value - The value of the form field. Example: "Jack".
56
+ * @param {string} [langCode] - Language code. Default: "en_US".
57
+ * @returns {Promise<IPostFormResponse | IError>} Returns an object containing the created form data entry and message.
58
+ * @throws {IError} When isShell=false and an error occurs during the fetch
59
+ * @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/postFormsData postFormsData} documentation.
60
+ */
61
+ postFormsData(body: IBodyPostFormData, langCode?: string): Promise<IPostFormResponse | IError>;
62
+ /**
63
+ * Get one object of form data by marker.
64
+ * @handleName getFormsDataByMarker
65
+ * @param {string} marker - Marker of the form. Example: "contact_form".
66
+ * @param {number} formModuleConfigId - Form module configuration ID. Example: 4.
67
+ * @param {object} [body] - Request body.
68
+ * @example
69
+ {
70
+ "entityIdentifier": 14,
71
+ "entityparentIdentifier": 167,
72
+ "userIdentifier": "",
73
+ "status": ["new", "approved"],
74
+ "dateFrom": "2025-01-01",
75
+ "dateTo": ""
76
+ }
77
+ * @param {number} [isExtended] - Flag for getting additional fields. Example: 1.
78
+ * @param {string} [langCode] - Language code. Default: "en_US".
79
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
80
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
81
+ * @returns {Promise<IFormsByMarkerDataEntity | IError>} Returns an object containing the form data or an error object if there was an issue.
82
+ * @throws {IError} When isShell=false and an error occurs during the fetch
83
+ * @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/getFormsDataByMarker getFormsDataByMarker} documentation.
84
+ */
85
+ getFormsDataByMarker(marker: string, formModuleConfigId: number, body?: object, isExtended?: number, langCode?: string, offset?: number, limit?: number): Promise<IFormsByMarkerDataEntity | IError>;
86
+ /**
87
+ * Update one object of form data by id. Requires user authentication.
88
+ * @handleName updateFormsDataByid
89
+ * @param {number} id - ID of the form data. Example: 1.
90
+ * @returns {Promise<IUpdateFormsData | IError>} Returns an object containing the updated form data or an error object if there was an issue.
91
+ * @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/updateFormsDataByid updateFormsDataByid} documentation.
92
+ */
93
+ updateFormsDataByid(id: number, body?: object): Promise<IUpdateFormsData | IError>;
94
+ /**
95
+ * Update form data status by id. Requires user authentication.
96
+ * @handleName updateFormsDataStatusByid
97
+ * @param {number} id - ID of the form data. Example: 1.
98
+ * @param {object} body - Request body.
99
+ * @returns {Promise<boolean | IError>} Returns an object containing the updated form data or an error object if there was an issue.
100
+ * @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/updateFormsDataStatusByid updateFormsDataStatusByid} documentation.
101
+ */
102
+ updateFormsDataStatusByid(id: number, body?: object): Promise<boolean | IError>;
103
+ /**
104
+ * Delete one object of form data by id. Requires user authentication.
105
+ * @handleName deleteFormsDataByid
106
+ * @param {number} id - ID of the form data. Example: 1.
107
+ * @returns {Promise<boolean | IError>} Returns an object containing the deleted form data or an error object if there was an issue.
108
+ * @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/deleteFormsDataByid deleteFormsDataByid} documentation.
109
+ */
110
+ deleteFormsDataByid(id: number): Promise<boolean | IError>;
111
+ /**
112
+ * Semantic (vector) search for form data.
113
+ * @handleName getFormsDataByVectorSearch
114
+ * @param {IFormsDataVectorSearch} body - Vector search body. Example: `{ queryText: "order confirmation" }`.
115
+ * @param {string} [langCode] - Language code. Default: "en_US".
116
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
117
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
118
+ * @returns {Promise<IFormsDataSearchResponse | IError>} Returns an object with an array of found form data records and total count.
119
+ * @throws {IError} When isShell=false and an error occurs during the fetch
120
+ * @description This method performs a semantic (vector) search for form data.
121
+ * @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/getFormsDataByVectorSearch getFormsDataByVectorSearch} documentation.
122
+ */
123
+ getFormsDataByVectorSearch(body: IFormsDataVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IFormsDataSearchResponse | IError>;
124
+ }
@@ -0,0 +1,210 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import AsyncModules from '../base/asyncModules.js';
3
+ import createSchemaLoader from '../base/lazySchema.js';
4
+ import FileUploadingApi from '../file-uploading/fileUploadingApi.js';
5
+ const schema = createSchemaLoader(() => import('./formsDataSchemas.js'));
6
+ /**
7
+ * Controllers for working with form data
8
+ * @handle /api/content/form-data
9
+ * @class FormsDataApi
10
+ * @augments AsyncModules
11
+ * @implements {IFormsData}
12
+ * @description This class provides methods to interact with form data, including retrieving all forms data, creating new form data entries, and fetching form data by marker.
13
+ */
14
+ export default class FormsDataApi extends AsyncModules {
15
+ /**
16
+ * Constructor for FormsDataApi class.
17
+ */
18
+ constructor(state) {
19
+ super(state);
20
+ this._url = state.url + '/api/content/form-data';
21
+ }
22
+ /**
23
+ * Creating an object of data save information by form
24
+ * @handleName postFormsData
25
+ * @param {IBodyPostFormData} body - Request body.
26
+ * @example
27
+ {
28
+ "formIdentifier": "test-form",
29
+ "formModuleConfigId": 2,
30
+ "moduleEntityIdentifier": "blog",
31
+ "replayTo": null,
32
+ "status": "sent",
33
+ "formData": [
34
+ {
35
+ "marker": "name",
36
+ "type": "string",
37
+ "value": "Test"
38
+ }
39
+ ]
40
+ }
41
+ * @param {string} body.formIdentifier - The identifier for the form. Example: "form".
42
+ * @param {number} body.formModuleConfigId - The ID of the form module configuration. Example: 2.
43
+ * @param {string} body.moduleEntityIdentifier - The identifier of the module entity. Example: "form".
44
+ * @param {string | null} [body.replayTo] - The email address to which the reply should be sent.
45
+ * @param {string | null} [body.status] - The status of the form submission.
46
+ * @param {FormDataType[]} body.formData - Form data.
47
+ * @example
48
+ [
49
+ {
50
+ "marker": "name",
51
+ "type": "string",
52
+ "value": "Jack"
53
+ }
54
+ ]
55
+ * @param {string} body.formData[].marker - The marker identifying the form field. Example: "name".
56
+ * @param {string} body.formData[].type - The type of the form field. Example: "string".
57
+ * @param {string} body.formData[].value - The value of the form field. Example: "Jack".
58
+ * @param {string} [langCode] - Language code. Default: "en_US".
59
+ * @returns {Promise<IPostFormResponse | IError>} Returns an object containing the created form data entry and message.
60
+ * @throws {IError} When isShell=false and an error occurs during the fetch
61
+ * @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/postFormsData postFormsData} documentation.
62
+ */
63
+ async postFormsData(body, langCode = this.state.lang) {
64
+ const formData = {};
65
+ // filter button fields; keep spam fields so the captcha token in their `value` reaches the server
66
+ formData[langCode] = Array.isArray(body.formData)
67
+ ? body.formData.filter((fd) => fd.type !== 'button')
68
+ : [body.formData].filter((fd) => fd.type !== 'button');
69
+ /**
70
+ * Handle file uploads if fileQuery is present
71
+ * Check if there is any element in formData[langCode] that contains one of the specified types
72
+ */
73
+ if (formData[langCode].find((fd) => ['file', 'image', 'groupOfImages'].includes(fd.type))) {
74
+ // Create an instance of FileUploadingApi with the current state
75
+ const fileUploader = new FileUploadingApi(this.state);
76
+ // Process each element in formData[langCode] asynchronously
77
+ formData[langCode] = await Promise.all(formData[langCode].map(async (fd) => {
78
+ // Check if the type is one of the specified types
79
+ if (['file', 'image', 'groupOfImages'].includes(fd.type)) {
80
+ // If fileQuery does not exist, we create it and assign it to an object with the following properties:
81
+ if (!fd.fileQuery) {
82
+ const fileQuery = {
83
+ type: 'page',
84
+ entity: 'editor',
85
+ // Generate a random 4-digit ID
86
+ id: Number(Math.floor(Math.random() * 10000)
87
+ .toString()
88
+ .padStart(4, '0')),
89
+ };
90
+ fd.fileQuery = fileQuery;
91
+ }
92
+ // Convert fd.value to an array if it is a FileList, otherwise use it directly
93
+ const filesArray = typeof FileList !== 'undefined' && fd.value instanceof FileList
94
+ ? Array.from(fd.value)
95
+ : fd.value;
96
+ // If filesArray is an array, upload each file asynchronously
97
+ if (Array.isArray(filesArray)) {
98
+ const uploadPromises = filesArray.map((file) => fileUploader.upload(file, fd.fileQuery).catch((e) => e));
99
+ fd.value = (await Promise.all(uploadPromises)).flat();
100
+ }
101
+ // If fd.value is a single File or Blob, upload it
102
+ else if (fd.value instanceof File || fd.value instanceof Blob) {
103
+ fd.value = await fileUploader
104
+ .upload(fd.value, fd.fileQuery)
105
+ .catch((e) => e); // Catch any errors during upload
106
+ }
107
+ // Remove the 'fileQuery' property from the object after processing
108
+ delete fd.fileQuery;
109
+ // Remove the 'contentType' property from the file object because it is not needed and not valid
110
+ fd.value.map((file) => {
111
+ delete file.contentType;
112
+ });
113
+ }
114
+ // Return the processed form data element
115
+ return fd;
116
+ }));
117
+ }
118
+ body.formData = formData;
119
+ const result = await this._fetchPost(``, body);
120
+ // Validate response if validation is enabled
121
+ const validated = await this._validateResponse(result, schema('PostFormResponseSchema'));
122
+ return this._normalizeData(validated);
123
+ }
124
+ /**
125
+ * Get one object of form data by marker.
126
+ * @handleName getFormsDataByMarker
127
+ * @param {string} marker - Marker of the form. Example: "contact_form".
128
+ * @param {number} formModuleConfigId - Form module configuration ID. Example: 4.
129
+ * @param {object} [body] - Request body.
130
+ * @example
131
+ {
132
+ "entityIdentifier": 14,
133
+ "entityparentIdentifier": 167,
134
+ "userIdentifier": "",
135
+ "status": ["new", "approved"],
136
+ "dateFrom": "2025-01-01",
137
+ "dateTo": ""
138
+ }
139
+ * @param {number} [isExtended] - Flag for getting additional fields. Example: 1.
140
+ * @param {string} [langCode] - Language code. Default: "en_US".
141
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
142
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
143
+ * @returns {Promise<IFormsByMarkerDataEntity | IError>} Returns an object containing the form data or an error object if there was an issue.
144
+ * @throws {IError} When isShell=false and an error occurs during the fetch
145
+ * @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/getFormsDataByMarker getFormsDataByMarker} documentation.
146
+ */
147
+ async getFormsDataByMarker(marker, formModuleConfigId, body = {}, isExtended = 0, langCode = this.state.lang, offset = 0, limit = 30) {
148
+ const result = await this._fetchPost(`/marker/${marker}?formModuleConfigId=${formModuleConfigId}&isExtended=${isExtended}&langCode=${langCode}&offset=${offset}&limit=${limit}`, body);
149
+ // Validate response if validation is enabled
150
+ const validated = await this._validateResponse(result, schema('FormsByMarkerDataResponseSchema'));
151
+ return this._normalizeData(validated, langCode);
152
+ }
153
+ /**
154
+ * Update one object of form data by id. Requires user authentication.
155
+ * @handleName updateFormsDataByid
156
+ * @param {number} id - ID of the form data. Example: 1.
157
+ * @returns {Promise<IUpdateFormsData | IError>} Returns an object containing the updated form data or an error object if there was an issue.
158
+ * @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/updateFormsDataByid updateFormsDataByid} documentation.
159
+ */
160
+ async updateFormsDataByid(id, body = {}) {
161
+ const result = await this._fetchPut(`/${id}`, body);
162
+ // Validate response if validation is enabled
163
+ const validated = await this._validateResponse(result, schema('UpdateFormsDataSchema'));
164
+ return validated;
165
+ }
166
+ /**
167
+ * Update form data status by id. Requires user authentication.
168
+ * @handleName updateFormsDataStatusByid
169
+ * @param {number} id - ID of the form data. Example: 1.
170
+ * @param {object} body - Request body.
171
+ * @returns {Promise<boolean | IError>} Returns an object containing the updated form data or an error object if there was an issue.
172
+ * @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/updateFormsDataStatusByid updateFormsDataStatusByid} documentation.
173
+ */
174
+ async updateFormsDataStatusByid(id, body = {}) {
175
+ const result = await this._fetchPut(`/${id}/update-status`, body);
176
+ return result;
177
+ }
178
+ /**
179
+ * Delete one object of form data by id. Requires user authentication.
180
+ * @handleName deleteFormsDataByid
181
+ * @param {number} id - ID of the form data. Example: 1.
182
+ * @returns {Promise<boolean | IError>} Returns an object containing the deleted form data or an error object if there was an issue.
183
+ * @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/deleteFormsDataByid deleteFormsDataByid} documentation.
184
+ */
185
+ async deleteFormsDataByid(id) {
186
+ const result = await this._fetchDelete(`/${id}`);
187
+ return result;
188
+ }
189
+ /**
190
+ * Semantic (vector) search for form data.
191
+ * @handleName getFormsDataByVectorSearch
192
+ * @param {IFormsDataVectorSearch} body - Vector search body. Example: `{ queryText: "order confirmation" }`.
193
+ * @param {string} [langCode] - Language code. Default: "en_US".
194
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
195
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
196
+ * @returns {Promise<IFormsDataSearchResponse | IError>} Returns an object with an array of found form data records and total count.
197
+ * @throws {IError} When isShell=false and an error occurs during the fetch
198
+ * @description This method performs a semantic (vector) search for form data.
199
+ * @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/getFormsDataByVectorSearch getFormsDataByVectorSearch} documentation.
200
+ */
201
+ async getFormsDataByVectorSearch(body, langCode = this.state.lang, offset = 0, limit = 30) {
202
+ const query = {
203
+ langCode,
204
+ offset,
205
+ limit,
206
+ };
207
+ const result = await this._fetchPost(`/vector/search?` + this._queryParamsToString(query), body);
208
+ return this._normalizeData(result, langCode);
209
+ }
210
+ }