@integry/sdk 4.7.39 → 4.7.41

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 (267) hide show
  1. package/dist/esm/index.csm.js +1 -1
  2. package/dist/umd/index.umd.js +1 -1
  3. package/package.json +6 -1
  4. package/.eslintignore +0 -1
  5. package/.vscode/launch.json +0 -17
  6. package/CHANGELOG_INTERNAL.md +0 -134
  7. package/README_INTERNAL.md +0 -176
  8. package/THIRD_PARTY_LICENSES +0 -525
  9. package/generateTests.js +0 -80
  10. package/jest.config.cjs +0 -10
  11. package/src/components/AddTagButton/index.ts +0 -23
  12. package/src/components/BasicSelect/index.ts +0 -123
  13. package/src/components/BasicSelect/styles.module.scss +0 -44
  14. package/src/components/Button/index.ts +0 -97
  15. package/src/components/Button/styles.module.scss +0 -152
  16. package/src/components/CheckboxGroup/Checkbox.ts +0 -104
  17. package/src/components/CheckboxGroup/index.ts +0 -190
  18. package/src/components/CheckboxGroup/styles.module.scss +0 -63
  19. package/src/components/CollapsedMenu/index.ts +0 -104
  20. package/src/components/CollapsedMenu/styles.module.scss +0 -46
  21. package/src/components/ConfigureFieldWrapper/index.ts +0 -85
  22. package/src/components/ConfigureFieldWrapper/styles.module.scss +0 -57
  23. package/src/components/EditableText/index.ts +0 -121
  24. package/src/components/EditableText/styles.module.scss +0 -38
  25. package/src/components/EditableTextArea/index.ts +0 -143
  26. package/src/components/EditableTextArea/styles.module.scss +0 -91
  27. package/src/components/ErrorMessage/index.ts +0 -16
  28. package/src/components/ErrorMessage/styles.module.scss +0 -19
  29. package/src/components/ErrorPage/index.ts +0 -42
  30. package/src/components/ErrorPage/styles.module.scss +0 -26
  31. package/src/components/Footer/index.ts +0 -41
  32. package/src/components/Footer/styles.module.scss +0 -40
  33. package/src/components/HTMLContent/index.tsx +0 -205
  34. package/src/components/HTMLContent/styles.module.scss +0 -3
  35. package/src/components/InfoBox/index.ts +0 -48
  36. package/src/components/InfoBox/styles.module.scss +0 -21
  37. package/src/components/Input/BaseInput/index.ts +0 -170
  38. package/src/components/Input/BaseInput/styles.module.scss +0 -95
  39. package/src/components/Input/DateInput/index.ts +0 -103
  40. package/src/components/Input/DateInput/styles.module.scss +0 -50
  41. package/src/components/Input/Input/index.ts +0 -225
  42. package/src/components/Input/Input/styles.module.scss +0 -16
  43. package/src/components/Input/PasswordInput/index.ts +0 -164
  44. package/src/components/Input/PasswordInput/styles.module.scss +0 -37
  45. package/src/components/Input/index.ts +0 -7
  46. package/src/components/Label/index.ts +0 -61
  47. package/src/components/Label/styles.module.scss +0 -41
  48. package/src/components/LargeLoader/index.ts +0 -25
  49. package/src/components/LargeLoader/styles.module.scss +0 -16
  50. package/src/components/Listbox/ListBoxItem.ts +0 -57
  51. package/src/components/Listbox/index.ts +0 -488
  52. package/src/components/Listbox/styles.module.scss +0 -197
  53. package/src/components/Loader/index.ts +0 -25
  54. package/src/components/Loader/styles.module.scss +0 -16
  55. package/src/components/MediaGallery/MediaGalleryModal.ts +0 -82
  56. package/src/components/MediaGallery/MediaSlider.ts +0 -76
  57. package/src/components/MediaGallery/index.ts +0 -92
  58. package/src/components/MediaGallery/styles.module.scss +0 -156
  59. package/src/components/MediaUpload/index.ts +0 -233
  60. package/src/components/MediaUpload/styles.module.scss +0 -118
  61. package/src/components/Modal/index.ts +0 -87
  62. package/src/components/Modal/styles.module.scss +0 -441
  63. package/src/components/MultipurposeField/Dropdown/ListBoxItem.tsx +0 -59
  64. package/src/components/MultipurposeField/Dropdown/index.tsx +0 -1202
  65. package/src/components/MultipurposeField/Dropdown/styles.module.scss +0 -215
  66. package/src/components/MultipurposeField/TagMenu/index.ts +0 -536
  67. package/src/components/MultipurposeField/TagMenu/styles.module.scss +0 -175
  68. package/src/components/MultipurposeField/TagOptions/index.tsx +0 -83
  69. package/src/components/MultipurposeField/TagOptions/styles.module.scss +0 -95
  70. package/src/components/MultipurposeField/index.tsx +0 -944
  71. package/src/components/MultipurposeField/styles.module.scss +0 -77
  72. package/src/components/NewModal/index.ts +0 -69
  73. package/src/components/NewModal/styles.module.scss +0 -70
  74. package/src/components/OverflowTooltip/index.tsx +0 -59
  75. package/src/components/PopUp/ConfirmationPopUp/index.ts +0 -58
  76. package/src/components/PopUp/ConfirmationPopUp/styles.module.scss +0 -49
  77. package/src/components/PopUp/SuccessPopUp/index.ts +0 -62
  78. package/src/components/PopUp/SuccessPopUp/styles.module.scss +0 -38
  79. package/src/components/RadioGroup/Radio.ts +0 -128
  80. package/src/components/RadioGroup/index.ts +0 -169
  81. package/src/components/RadioGroup/styles.module.scss +0 -81
  82. package/src/components/Search/index.ts +0 -69
  83. package/src/components/Search/styles.module.scss +0 -149
  84. package/src/components/TabBar/Tab.ts +0 -33
  85. package/src/components/TabBar/index.ts +0 -64
  86. package/src/components/TabBar/styles.module.scss +0 -43
  87. package/src/components/Tag/index.ts +0 -29
  88. package/src/components/Tag/styles.module.scss +0 -57
  89. package/src/components/TagsMenu/index.ts +0 -1697
  90. package/src/components/TagsMenu/styles.module.scss +0 -350
  91. package/src/components/TestComponent/index.ts +0 -71
  92. package/src/components/TestComponent/styles.module.scss +0 -152
  93. package/src/components/TextArea/index.ts +0 -172
  94. package/src/components/TextArea/styles.module.scss +0 -72
  95. package/src/components/TextContent/index.tsx +0 -128
  96. package/src/components/TextContent/styles.module.scss +0 -6
  97. package/src/components/ThreeDotLoader/index.ts +0 -39
  98. package/src/components/ThreeDotLoader/styles.module.scss +0 -41
  99. package/src/components/TimeInput/index.ts +0 -129
  100. package/src/components/TimeInput/styles.module.scss +0 -16
  101. package/src/components/Toggle/index.ts +0 -34
  102. package/src/components/Toggle/styles.module.scss +0 -56
  103. package/src/components/Toggle-v2/index.ts +0 -40
  104. package/src/components/Toggle-v2/styles.module.scss +0 -86
  105. package/src/components/Tooltip/index.ts +0 -271
  106. package/src/components/Tooltip/styles.module.scss +0 -105
  107. package/src/components/form/FunctionField/index.ts +0 -816
  108. package/src/components/form/FunctionField/styles.module.scss +0 -478
  109. package/src/components/form/ObjectField/__snapshots__/index.ts.test.tsx.snap +0 -3
  110. package/src/components/form/ObjectField/index.ts +0 -593
  111. package/src/components/form/ObjectField/index.ts.test.tsx +0 -213
  112. package/src/components/form/ObjectField/styles.module.scss +0 -103
  113. package/src/components/form/index.ts +0 -4
  114. package/src/contexts/AppContext.ts +0 -12
  115. package/src/declaration.d.ts +0 -7
  116. package/src/extensions/HMAC.ts +0 -25
  117. package/src/extensions/IntegryAPIError.ts +0 -19
  118. package/src/features/common/AccountDropdown/index.ts +0 -291
  119. package/src/features/common/AccountDropdown/styles.module.scss +0 -19
  120. package/src/features/common/ActionForm/index.ts +0 -2602
  121. package/src/features/common/ActionForm/styles.module.scss +0 -35
  122. package/src/features/common/AppCard/index.ts +0 -207
  123. package/src/features/common/AppCard/styles.module.scss +0 -117
  124. package/src/features/common/AppCardCompact/index.ts +0 -189
  125. package/src/features/common/AppCardCompact/styles.module.scss +0 -141
  126. package/src/features/common/AuthSelector/index.ts +0 -537
  127. package/src/features/common/AuthSelector/styles.module.scss +0 -161
  128. package/src/features/common/AuthSelectorCompact/index.ts +0 -706
  129. package/src/features/common/AuthSelectorCompact/styles.module.scss +0 -219
  130. package/src/features/common/AuthSelectorDropdown/index.ts +0 -704
  131. package/src/features/common/AuthSelectorDropdown/styles.module.scss +0 -361
  132. package/src/features/common/AuthSelectorV2/index.ts +0 -336
  133. package/src/features/common/AuthSelectorV2/styles.module.scss +0 -235
  134. package/src/features/common/DynamicField/index.ts +0 -402
  135. package/src/features/common/DynamicField/styles.module.scss +0 -266
  136. package/src/features/common/DynamicTypedField/index.ts +0 -504
  137. package/src/features/common/DynamicTypedField/styles.module.scss +0 -135
  138. package/src/features/common/FunctionForm/index.ts +0 -1095
  139. package/src/features/common/FunctionForm/styles.module.scss +0 -225
  140. package/src/features/common/MappingUI/index.ts +0 -649
  141. package/src/features/common/MappingUI/styles.module.scss +0 -121
  142. package/src/features/common/MarketplaceAppCard/index.ts +0 -279
  143. package/src/features/common/MarketplaceAppCard/styles.module.scss +0 -231
  144. package/src/features/common/MarketplaceAppCardCompact/index.ts +0 -283
  145. package/src/features/common/MarketplaceAppCardCompact/styles.module.scss +0 -255
  146. package/src/features/common/NewMappingUI/index.ts +0 -515
  147. package/src/features/common/NewMappingUI/styles.module.scss +0 -113
  148. package/src/features/common/RequestAppWidget/RequestAppModal/index.ts +0 -67
  149. package/src/features/common/RequestAppWidget/RequestAppModal/styles.module.scss +0 -23
  150. package/src/features/common/RequestAppWidget/index.ts +0 -48
  151. package/src/features/common/RequestAppWidget/request-app-form.ts +0 -89
  152. package/src/features/common/RequestAppWidget/styles.module.scss +0 -43
  153. package/src/features/common/SectionField/index.ts +0 -272
  154. package/src/features/common/SectionField/styles.module.scss +0 -67
  155. package/src/features/common/Step/index.ts +0 -827
  156. package/src/features/common/Step/styles.module.scss +0 -12
  157. package/src/features/common/StepNavigation/CollapsedSteps.ts +0 -131
  158. package/src/features/common/StepNavigation/NavItem.ts +0 -111
  159. package/src/features/common/StepNavigation/index.ts +0 -261
  160. package/src/features/common/StepNavigation/styles.module.scss +0 -117
  161. package/src/features/common/Steps/index.ts +0 -1140
  162. package/src/features/common/Steps/styles.module.scss +0 -314
  163. package/src/features/containers/AppFlowContainer/AppFlowListing/compactStyles.module.scss +0 -404
  164. package/src/features/containers/AppFlowContainer/AppFlowListing/flow-instance.tsx +0 -367
  165. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCard.test.tsx +0 -58
  166. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCard.tsx +0 -208
  167. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCardCompact.test.tsx +0 -49
  168. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCardCompact.tsx +0 -421
  169. package/src/features/containers/AppFlowContainer/AppFlowListing/flowInstanceCompact.tsx +0 -577
  170. package/src/features/containers/AppFlowContainer/AppFlowListing/index.tsx +0 -83
  171. package/src/features/containers/AppFlowContainer/AppFlowListing/styles.module.scss +0 -233
  172. package/src/features/containers/AppFlowContainer/AppFlowWrap/app-page-loader.tsx +0 -45
  173. package/src/features/containers/AppFlowContainer/AppFlowWrap/index.tsx +0 -1085
  174. package/src/features/containers/AppFlowContainer/AppFlowWrap/styles.module.scss +0 -465
  175. package/src/features/containers/AppFlowContainer/Authentication/index.ts +0 -610
  176. package/src/features/containers/AppFlowContainer/Authentication/styles.module.scss +0 -468
  177. package/src/features/containers/AppFlowContainer/index.ts +0 -114
  178. package/src/features/containers/AppPageContainer/AppPage/index.tsx +0 -262
  179. package/src/features/containers/AppPageContainer/AppPage/styles.module.scss +0 -120
  180. package/src/features/containers/AppPageContainer/IntegrationCard/index.ts +0 -165
  181. package/src/features/containers/AppPageContainer/IntegrationCard/styles.module.scss +0 -81
  182. package/src/features/containers/AppPageContainer/index.tsx +0 -93
  183. package/src/features/containers/AppPageContainer/styles.module.scss +0 -0
  184. package/src/features/containers/AppsForFlows/index.ts +0 -161
  185. package/src/features/containers/AppsForFlows/styles.module.scss +0 -280
  186. package/src/features/containers/AppsForFlowsCompact/index.ts +0 -161
  187. package/src/features/containers/AppsForFlowsCompact/styles.module.scss +0 -279
  188. package/src/features/containers/AuthSetupContainer/AppSelection.ts +0 -73
  189. package/src/features/containers/AuthSetupContainer/AuthTypeSelection.ts +0 -67
  190. package/src/features/containers/AuthSetupContainer/Footer.ts +0 -32
  191. package/src/features/containers/AuthSetupContainer/Header.ts +0 -39
  192. package/src/features/containers/AuthSetupContainer/PostAdditionPopup.ts +0 -27
  193. package/src/features/containers/AuthSetupContainer/index.ts +0 -349
  194. package/src/features/containers/AuthSetupContainer/styles.module.scss +0 -229
  195. package/src/features/containers/FlowSetupContainer/index.ts +0 -391
  196. package/src/features/containers/FlowSetupContainer/styles.module.scss +0 -18
  197. package/src/features/containers/MarkeplaceApps/index.ts +0 -583
  198. package/src/features/containers/MarkeplaceApps/styles.module.scss +0 -558
  199. package/src/features/containers/MarketplaceAppsCompact/index.ts +0 -585
  200. package/src/features/containers/MarketplaceAppsCompact/styles.module.scss +0 -563
  201. package/src/features/containers/MarketplaceAppsContainer/index.ts +0 -91
  202. package/src/features/containers/MarketplaceContainer/AppCard/index.ts +0 -91
  203. package/src/features/containers/MarketplaceContainer/AppCard/styles.module.scss +0 -66
  204. package/src/features/containers/MarketplaceContainer/AppListing/index.ts +0 -34
  205. package/src/features/containers/MarketplaceContainer/AppListing/styles.module.scss +0 -10
  206. package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/index.ts +0 -132
  207. package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/styles.module.scss +0 -117
  208. package/src/features/containers/MarketplaceContainer/index.ts +0 -242
  209. package/src/features/containers/MarketplaceContainer/styles.module.scss +0 -84
  210. package/src/features/containers/SDKContainer/index.ts +0 -817
  211. package/src/features/containers/SDKContainer/styles.module.scss +0 -266
  212. package/src/features/containers/SDKDebugContainer/index.ts +0 -137
  213. package/src/features/containers/SDKDebugContainer/styles.module.scss +0 -37
  214. package/src/features/containers/SDKFailedContainer/index.ts +0 -117
  215. package/src/features/containers/SDKFailedContainer/styles.module.scss +0 -57
  216. package/src/features/integrations/IntegrationRow/Icons.ts +0 -77
  217. package/src/features/integrations/IntegrationRow/index.ts +0 -129
  218. package/src/features/integrations/IntegrationRow/styles.module.scss +0 -62
  219. package/src/features/integrations/IntegrationsHeader/index.ts +0 -34
  220. package/src/features/integrations/IntegrationsHeader/styles.module.scss +0 -47
  221. package/src/features/integrations/IntegrationsList/index.ts +0 -252
  222. package/src/features/integrations/IntegrationsList/styles.module.scss +0 -67
  223. package/src/features/templates/Template/index.ts +0 -295
  224. package/src/features/templates/Template/styles.module.scss +0 -226
  225. package/src/features/templates/TemplatesView/index.ts +0 -368
  226. package/src/features/templates/TemplatesView/styles.module.scss +0 -71
  227. package/src/features/templates/TemplatesViewCompact/index.ts +0 -364
  228. package/src/features/templates/TemplatesViewCompact/styles.module.scss +0 -141
  229. package/src/hooks/useAutosizeTextArea.ts +0 -22
  230. package/src/hooks/useCustomRef.ts +0 -13
  231. package/src/hooks/useDebounce.ts +0 -17
  232. package/src/hooks/useElementResize.ts +0 -40
  233. package/src/hooks/useEventListener.ts +0 -42
  234. package/src/hooks/useHover.ts +0 -40
  235. package/src/hooks/useOnClickOutside.ts +0 -32
  236. package/src/index.ts +0 -2244
  237. package/src/index.umd.ts +0 -13
  238. package/src/interfaces/index.ts +0 -938
  239. package/src/modules/api/index.ts +0 -1325
  240. package/src/modules/api/responseHandler.ts +0 -38
  241. package/src/modules/event-emitter/index.ts +0 -72
  242. package/src/modules/event-emitter/runners/abstract.ts +0 -21
  243. package/src/modules/event-emitter/runners/default.ts +0 -11
  244. package/src/modules/event-emitter/runners/ntimes.ts +0 -28
  245. package/src/modules/event-emitter/types.ts +0 -34
  246. package/src/store/actionFunctions.ts +0 -1578
  247. package/src/store/index.ts +0 -17
  248. package/src/store/initialState.ts +0 -58
  249. package/src/types/index.ts +0 -320
  250. package/src/types/preact-compat.d.ts +0 -4
  251. package/src/types/store.ts +0 -366
  252. package/src/types/utils.ts +0 -19
  253. package/src/utils/ActivityOutputUtils.ts +0 -176
  254. package/src/utils/common.ts +0 -20
  255. package/src/utils/copyToClipboard.ts +0 -24
  256. package/src/utils/datetime.ts +0 -101
  257. package/src/utils/getUrlParam.ts +0 -11
  258. package/src/utils/isAuthMessage.ts +0 -16
  259. package/src/utils/isBrowser.ts +0 -1
  260. package/src/utils/jsonEncodeDecode.ts +0 -15
  261. package/src/utils/objectUtils.ts +0 -117
  262. package/src/utils/popup.ts +0 -30
  263. package/src/utils/searchJson.ts +0 -51
  264. package/src/utils/stepUtils.ts +0 -45
  265. package/src/utils/truncate.ts +0 -6
  266. package/test/setup.ts +0 -1
  267. package/vitest.config.ts +0 -16
@@ -1,1095 +0,0 @@
1
- 'use client';
2
-
3
- /* eslint-disable no-nested-ternary */
4
- import { html, Component } from 'htm/preact';
5
- import { connect } from 'unistore/preact';
6
- import { useContext } from 'preact/hooks';
7
- // import DOMPurify from 'dompurify';
8
- import { ListBox } from '@/components/MultipurposeField/Dropdown';
9
- import { actionFunctions } from '@/store';
10
- import { Button } from '@/components/Button';
11
- import type { StoreType } from '@/types/store';
12
- import { MultipurposeField } from '@/components/MultipurposeField';
13
- import DynamicTypedField from '@/features/common/DynamicTypedField';
14
- import ConfigureFieldWrapper from '@/components/ConfigureFieldWrapper';
15
- import AppContext from '@/contexts/AppContext';
16
- import { ObjectField } from '@/components/form/ObjectField';
17
- import { LargeLoader } from '@/components/LargeLoader';
18
- import {
19
- JSONToActivityOutputData,
20
- JSONToDynamicFieldData,
21
- arrayToNestedJSONWithFirstValue,
22
- } from '@/utils/ActivityOutputUtils';
23
-
24
- import styles from './styles.module.scss';
25
-
26
- interface FunctionFormPropsType extends StoreType {
27
- functionName: string;
28
- connectedAccountId: string;
29
- functionArguments: any;
30
- variables: any;
31
- autoMapVars: boolean;
32
- version?: string | null;
33
- onClose: (response: any) => void;
34
- apiHandler: any;
35
- customSaveCallback?: (response: any) => void; // Optional callback: Helps the implementor to implement their own save button
36
- showMappingMenu?: boolean; // Optional prop to show mapping menu
37
- forceShowAllFields?: boolean; // Optional prop to show all fields including hidden fields
38
- enableAIAssist?: boolean; // New prop for enabling AI assist feature
39
- defaultAIAssistedFields?: string[]; // New prop for field IDs that should have AI assist enabled by default
40
- onAIAssistToggle?: (
41
- fieldId: string,
42
- enabled: boolean,
43
- allAIAssistedFields: string[],
44
- ) => void; // Callback when AI assist toggle changes
45
- allowWorkspaceConnectedAccounts?: boolean;
46
- }
47
-
48
- interface ActionFormStateType {
49
- loading: boolean;
50
- dynamicFieldDataState: any;
51
- isSubmitting: boolean;
52
- functionDetails: any;
53
- invalidFields: any;
54
- parentFields: any;
55
- parentFieldsChanged: boolean;
56
- aiAssistedFields: string[]; // New state to track fields with AI assist enabled
57
- changedParentMachineName?: string; // New prop to track changes in parent machine name
58
- parentChangeVersion?: number; // New prop to track changes in parent machine name
59
- }
60
-
61
- interface StepDataMapping {
62
- [key: string]: any;
63
- }
64
-
65
- type Option = {
66
- id: any;
67
- value: string;
68
- };
69
-
70
- class FunctionForm extends Component<
71
- FunctionFormPropsType,
72
- ActionFormStateType
73
- > {
74
- constructor(props: FunctionFormPropsType) {
75
- super(props);
76
- this.state = {
77
- loading: false,
78
- dynamicFieldDataState: {},
79
- isSubmitting: false,
80
- functionDetails: {},
81
- invalidFields: [],
82
- parentFields: [],
83
- parentFieldsChanged: false,
84
- aiAssistedFields: [], // Initialize empty array for AI assisted fields
85
- changedParentMachineName: '',
86
- parentChangeVersion: 0,
87
- };
88
- }
89
-
90
- getMethod = () => 'POST';
91
-
92
- getBaseUrl = () => 'https://api.integry.io/functions';
93
-
94
- getHeaders = () => ({
95
- 'Content-Type': 'application/json',
96
- });
97
-
98
- componentDidMount() {
99
- this.setState({ loading: true });
100
- this.props.apiHandler
101
- .getFunctionDetails(
102
- this.props.functionName,
103
- this.props.autoMapVars ? this.props.variables : {},
104
- this.props.version,
105
- this.props.allowWorkspaceConnectedAccounts,
106
- )
107
- .then((response: any) => {
108
- this.setState({ functionDetails: response });
109
-
110
- const { functionArguments } = this.props;
111
- const predictedArguments = this.props.autoMapVars
112
- ? response.arguments
113
- : {};
114
- const argumentsData = response.parameters.properties;
115
- const args: { [key: string]: any } = {};
116
-
117
- Object.keys(argumentsData).forEach((key: string) => {
118
- args[key] =
119
- predictedArguments[key] ||
120
- functionArguments[key] ||
121
- argumentsData[key].meta.ui.default_value ||
122
- '';
123
-
124
- // Only add to invalidFields if not AI assisted
125
- if (argumentsData[key].meta.is_required && !args[key]) {
126
- this.setState((prevState) => ({
127
- invalidFields: prevState.invalidFields.includes(key)
128
- ? prevState.invalidFields
129
- : [...prevState.invalidFields, key],
130
- }));
131
- }
132
- if (argumentsData[key].meta.ui.ui_field?.data_source?.body) {
133
- // Extract all the keys in the body
134
- const bodyKeys = Object.keys(
135
- argumentsData[key].meta.ui.ui_field.data_source.body,
136
- );
137
-
138
- // Iterate through the keys and check if the value matches the format {parameters.<parent-field-name>}
139
- bodyKeys.forEach((bodyKey) => {
140
- const value =
141
- argumentsData[key].meta.ui.ui_field.data_source.body[bodyKey];
142
-
143
- // Check if the value matches the format {parameters.<parent-field-name>}
144
- const match = value && value.match(/{parameters\.(.*?)}/);
145
-
146
- if (match && match[1]) {
147
- const parentField = match[1]; // Extract the parent field name
148
-
149
- // Add the parent field to the parentFields array
150
- this.setState((prevState) => ({
151
- parentFields: [...prevState.parentFields, parentField],
152
- }));
153
- }
154
- });
155
- }
156
- });
157
- this.setState({
158
- dynamicFieldDataState: args,
159
- });
160
-
161
- // Enable AI assist for default fields if provided
162
- if (
163
- this.props.enableAIAssist &&
164
- this.props.defaultAIAssistedFields &&
165
- this.props.defaultAIAssistedFields.length > 0
166
- ) {
167
- const validFieldIds = Object.keys(response.parameters.properties);
168
- const defaultAIFields = this.props.defaultAIAssistedFields.filter(
169
- (fieldId) => validFieldIds.includes(fieldId),
170
- );
171
-
172
- if (defaultAIFields.length > 0) {
173
- this.setState((prevState) => {
174
- // Create new arrays to avoid mutating state directly
175
- const newAIAssistedFields = [
176
- ...prevState.aiAssistedFields,
177
- ...defaultAIFields,
178
- ];
179
- const newInvalidFields = prevState.invalidFields.filter(
180
- (fieldId: string) => !defaultAIFields.includes(fieldId),
181
- );
182
-
183
- // Notify parent component about the default AI assisted fields
184
- if (this.props.onAIAssistToggle && defaultAIFields.length > 0) {
185
- // Call once for each field to ensure proper tracking
186
- defaultAIFields.forEach((fieldId) => {
187
- this.props.onAIAssistToggle!(
188
- fieldId,
189
- true,
190
- newAIAssistedFields,
191
- );
192
- });
193
- }
194
-
195
- // If we have a custom save callback, notify it about the changes
196
- if (this.props.customSaveCallback) {
197
- // Get current data state but exclude AI assisted fields
198
- this.props.customSaveCallback({
199
- hasInvalidFields: newInvalidFields.length > 0,
200
- data: args,
201
- });
202
- }
203
-
204
- return {
205
- aiAssistedFields: newAIAssistedFields,
206
- invalidFields: newInvalidFields,
207
- };
208
- });
209
- }
210
- }
211
-
212
- this.setState({ loading: false });
213
- });
214
- }
215
-
216
- private removeLastIfEmpty = (arr: any) => {
217
- if (
218
- arr.length > 0 &&
219
- (arr[arr.length - 1] === '' || arr[arr.length - 1] == null)
220
- ) {
221
- arr.pop(); // Remove the last item if it is empty or null
222
- }
223
- return arr;
224
- };
225
-
226
- private onSubmit = (
227
- event: any,
228
- returnResponse = false,
229
- AIAssistFieldId = '',
230
- ) => {
231
- this.setState({ isSubmitting: true });
232
- const { functionName } = this.props;
233
- const { functionDetails } = this.state;
234
- const args: { [key: string]: any } = {};
235
- const { dynamicFieldDataState, aiAssistedFields } = this.state;
236
-
237
- Object.keys(dynamicFieldDataState).forEach((key: string) => {
238
- const fieldDetails = functionDetails.parameters.properties[key];
239
- let value = dynamicFieldDataState[key] || '';
240
-
241
- // If field is AI assisted, mark it in the submission
242
- if (aiAssistedFields.includes(key) || key === AIAssistFieldId) {
243
- return; // Skip further processing for this field
244
- }
245
-
246
- // Check for field type and cast value
247
- if (fieldDetails) {
248
- switch (fieldDetails.type) {
249
- case 'boolean':
250
- value =
251
- value === 'true' ||
252
- value === true ||
253
- value === '1' ||
254
- value === 1;
255
- break;
256
- case 'number':
257
- break;
258
- case 'string':
259
- value = String(value);
260
- break;
261
- case 'array':
262
- value = this.removeLastIfEmpty(value);
263
- value = value === '' || value === '[]' ? [] : value;
264
- if (fieldDetails.items && fieldDetails.items.type === 'number') {
265
- value = value.map((item: string) => Number(item));
266
- } else if (
267
- fieldDetails.items &&
268
- fieldDetails.items.type === 'string' &&
269
- typeof value === 'string'
270
- ) {
271
- try {
272
- value = JSON.parse(value);
273
- } catch (e) {
274
- value = [];
275
- }
276
- }
277
-
278
- break;
279
- case 'object':
280
- if (typeof value === 'object' && value !== null) {
281
- // If it's already an object, do nothing
282
- break;
283
- } else {
284
- // If it's a string that can be parsed into an object
285
- try {
286
- value = JSON.parse(value);
287
- // Ensure the parsed value is an object
288
- } catch (e) {
289
- if (typeof value === 'string') {
290
- value = {
291
- [fieldDetails.meta.title]: value,
292
- };
293
- } else {
294
- value = {};
295
- }
296
- }
297
- }
298
- break;
299
- default:
300
- value = String(value);
301
- break;
302
- }
303
- }
304
-
305
- // Assign the correctly cast value to args
306
- if (value) {
307
- args[key] = value;
308
- }
309
- });
310
-
311
- if (returnResponse) {
312
- return args;
313
- }
314
-
315
- this.props.onClose(args);
316
- return args;
317
- };
318
-
319
- parseJsonArray = (input: string): any[] => {
320
- // First, try to parse the input as a JSON array
321
- try {
322
- const parsed = JSON.parse(input);
323
- if (Array.isArray(parsed)) {
324
- return parsed; // Return the valid array
325
- }
326
- } catch (error) {
327
- // If parsing fails, continue to the next check
328
- }
329
-
330
- // If the input is a comma-separated string (e.g., "1,2,3")
331
- let trimmedInput = '';
332
- try {
333
- trimmedInput = input.trim();
334
- } catch (error) {
335
- // If the input is not a string, return an empty array
336
- trimmedInput = '';
337
- }
338
- if (trimmedInput.includes(',')) {
339
- // Split by commas and return the values as an array
340
- return trimmedInput.split(',').map((item) => item.trim());
341
- }
342
-
343
- // If the input is a single value (e.g., "yasir@integry.io" or "1")
344
- return [trimmedInput];
345
- };
346
-
347
- onFieldChange = (
348
- fieldId: string,
349
- value: any,
350
- dataType: string,
351
- isRequired?: boolean,
352
- parentFieldId?: string | null,
353
- index = -1,
354
- stopChangePropagation = false,
355
- ) => {
356
- this.setState((prevState) => {
357
- const newState = { ...prevState.dynamicFieldDataState };
358
-
359
- if (parentFieldId) {
360
- // If parentFieldId is not empty, ensure the parent field exists
361
- if (!newState[parentFieldId]) {
362
- if (index !== -1) {
363
- newState[parentFieldId] = [];
364
- newState[parentFieldId][index] = {};
365
- } else {
366
- newState[parentFieldId] = {}; // Create an object if it doesn't exist
367
- }
368
- }
369
- // Add the fieldId and value inside the parentFieldId
370
- if (index !== -1) {
371
- newState[parentFieldId] = value;
372
- } else {
373
- newState[parentFieldId][fieldId] = value;
374
- }
375
- } else if (
376
- stopChangePropagation &&
377
- dataType === 'array' &&
378
- !Array.isArray(value)
379
- ) {
380
- newState[fieldId] = JSON.stringify([value]);
381
- } else {
382
- newState[fieldId] = value;
383
- }
384
-
385
- return {
386
- dynamicFieldDataState: newState,
387
- };
388
- });
389
-
390
- // Skip validation for AI assisted fields
391
- if (this.state.aiAssistedFields.includes(fieldId)) {
392
- return;
393
- }
394
-
395
- const isValid = true;
396
- let hasInvalidFields = Object.keys(this.state.dynamicFieldDataState).some(
397
- (key) =>
398
- key !== fieldId &&
399
- this.state.invalidFields.includes(key) &&
400
- !this.state.aiAssistedFields.includes(key),
401
- );
402
-
403
- if (value && isValid) {
404
- this.setState({
405
- invalidFields: this.state.invalidFields.filter(
406
- (field: string) => field !== fieldId,
407
- ),
408
- });
409
- } else if (isRequired) {
410
- hasInvalidFields = true;
411
- this.setState((prevState) => ({
412
- invalidFields: prevState.invalidFields.includes(fieldId)
413
- ? prevState.invalidFields
414
- : [...prevState.invalidFields, fieldId],
415
- }));
416
- }
417
-
418
- // Check if the field is a parent field
419
- if (this.state.parentFields.includes(fieldId)) {
420
- this.setState({
421
- changedParentMachineName: fieldId,
422
- parentChangeVersion: Date.now(),
423
- });
424
- }
425
-
426
- if (this.props.customSaveCallback) {
427
- const currentDataState = this.onSubmit({}, true);
428
- const updatedDataState = { ...currentDataState, [fieldId]: value };
429
- this.props.customSaveCallback({
430
- hasInvalidFields,
431
- data: updatedDataState,
432
- });
433
- }
434
- };
435
-
436
- // New method to toggle AI assist for a field
437
- toggleAIAssist = (fieldId: string, enabled: boolean) => {
438
- this.setState((prevState) => {
439
- let newAIAssistedFields = [...prevState.aiAssistedFields];
440
- let newInvalidFields = [...prevState.invalidFields];
441
-
442
- if (enabled) {
443
- // Add to AI assisted fields if not already there
444
- if (!newAIAssistedFields.includes(fieldId)) {
445
- newAIAssistedFields.push(fieldId);
446
- }
447
- // Remove from invalid fields if it was there
448
- newInvalidFields = newInvalidFields.filter(
449
- (field) => field !== fieldId,
450
- );
451
- } else {
452
- // Remove from AI assisted fields
453
- newAIAssistedFields = newAIAssistedFields.filter(
454
- (field) => field !== fieldId,
455
- );
456
-
457
- // Check if field should be marked as invalid
458
- const fieldDetails =
459
- prevState.functionDetails.parameters?.properties[fieldId];
460
- const fieldValue = prevState.dynamicFieldDataState[fieldId];
461
-
462
- if (
463
- fieldDetails?.meta.is_required &&
464
- (!fieldValue || fieldValue === '')
465
- ) {
466
- if (!newInvalidFields.includes(fieldId)) {
467
- newInvalidFields.push(fieldId);
468
- }
469
- }
470
- }
471
-
472
- // Call the onAIAssistToggle callback if provided
473
- if (this.props.onAIAssistToggle) {
474
- this.props.onAIAssistToggle(fieldId, enabled, newAIAssistedFields);
475
- }
476
-
477
- if (this.props.customSaveCallback) {
478
- // we have communciate back to the custom save callback with the updated state
479
- const currentDataState = this.onSubmit({}, true, fieldId);
480
- this.props.customSaveCallback({
481
- hasInvalidFields: newInvalidFields.length > 0,
482
- data: currentDataState,
483
- });
484
- }
485
-
486
- return {
487
- aiAssistedFields: newAIAssistedFields,
488
- invalidFields: newInvalidFields,
489
- };
490
- });
491
- };
492
-
493
- replacePlaceholders = (
494
- templateObj: { [key: string]: any },
495
- dictionary: { [key: string]: any },
496
- ): { [key: string]: any } => {
497
- const updatedObj: { [key: string]: any } = {};
498
-
499
- // Use Object.entries to iterate over keys and values
500
- Object.entries(templateObj).forEach(([key, value]) => {
501
- // If the value is a string and contains a placeholder, replace it
502
- if (typeof value === 'string' && value.includes('{parameters.')) {
503
- // Extract the placeholder key between `{parameters.}` and use it to replace with the dictionary value
504
- const placeholderKey = value.match(/{parameters\.(.*?)}/);
505
-
506
- if (placeholderKey && placeholderKey[1]) {
507
- const keyToReplace = placeholderKey[1]; // Extract key name from the placeholder
508
-
509
- // Replace the placeholder with the corresponding value from the dictionary
510
- if (dictionary[keyToReplace] !== undefined) {
511
- updatedObj[key] = value.replace(
512
- placeholderKey[0],
513
- dictionary[keyToReplace],
514
- );
515
- }
516
- }
517
- } else if (typeof value === 'string' && value) {
518
- updatedObj[key] = value;
519
- }
520
- });
521
-
522
- // Return the updated object containing only keys with replaced values
523
- return updatedObj;
524
- };
525
-
526
- getRegex: any = (field: any) => {
527
- if (field.type === 'boolean') {
528
- return '^(true|false)$'; // Matches "true" or "false" as strings
529
- }
530
- if (field.type === 'number') {
531
- return '^\\d+$'; // Matches numeric values only
532
- }
533
- if (
534
- field.type === 'array' &&
535
- field.items &&
536
- field.items.type === 'number'
537
- ) {
538
- return '^\\d+$'; // Matches numeric values only
539
- }
540
-
541
- return ''; // Default to empty string
542
- };
543
-
544
- getRegexErrorMessage: any = (field: any) => {
545
- if (field.type === 'boolean') {
546
- return 'Please enter "true" or "false".'; // Error message for boolean fields
547
- }
548
- if (field.type === 'number') {
549
- return 'Please enter a valid number.'; // Error message for number fields
550
- }
551
- if (
552
- field.type === 'array' &&
553
- field.items &&
554
- field.items.type === 'number'
555
- ) {
556
- return 'Please enter a valid number.'; // Error message for number fields
557
- }
558
-
559
- return 'Invalid input.'; // Default error message
560
- };
561
-
562
- fetchDynamicData = (field: any) => {
563
- const { functionDetails } = this.state;
564
- const { connectedAccountId } = this.props;
565
- const { properties } = functionDetails.parameters;
566
- const { depends_on } = properties[field.id].meta.ui || [];
567
-
568
- const data: { [key: string]: any } = {};
569
-
570
- // Iterate through the dependsOn array and add the corresponding values to the data object
571
- depends_on.forEach((fieldId: string) => {
572
- data[fieldId] = this.state.dynamicFieldDataState[fieldId];
573
- });
574
- return data;
575
- };
576
-
577
- // Custom wrapper for ConfigureFieldWrapper to add AI assist toggle
578
- renderFieldWrapper = (field: any, children: any) => {
579
- const { enableAIAssist } = this.props;
580
- const isAIAssisted = this.state.aiAssistedFields.includes(field.id);
581
-
582
- if (!enableAIAssist) {
583
- return html`<${ConfigureFieldWrapper} field=${field}>${children}<//>`;
584
- }
585
-
586
- // Add AI assist toggle to the field wrapper
587
- return html`
588
- <${ConfigureFieldWrapper} field=${field}>
589
- <div class="${styles.fieldWrapperWithAIAssist}">
590
- <div class="${styles.aiAssistToggleContainer}">
591
- <label class="${styles.aiAssistToggleLabel}">
592
- <span>AI assist</span>
593
- <input
594
- type="checkbox"
595
- class="${styles.aiAssistToggle}"
596
- checked=${isAIAssisted}
597
- onChange=${(e: any) =>
598
- this.toggleAIAssist(field.id, e.target.checked)}
599
- />
600
- </label>
601
- </div>
602
- ${children}
603
- </div>
604
- <//>
605
- `;
606
- };
607
-
608
- renderFields = (
609
- properties: any,
610
- functionArguments: any,
611
- connectedAccount: string,
612
- appName: string,
613
- parentFieldId?: string,
614
- ): any => {
615
- const fields = Object.entries(properties).map(
616
- ([fieldName, fieldDetails]: [string, any], index) => ({
617
- id: fieldName, // assign unique id for each field
618
- title: fieldDetails.meta.title,
619
- type: fieldDetails.meta.ui.ui_field?.type || 'TEXTFIELD',
620
- endpointURL:
621
- fieldDetails.meta.ui.ui_field?.type === 'DYNAMIC_DROPDOWN' ||
622
- fieldDetails.meta.ui.ui_field?.type === 'CUSTOM_FIELDS'
623
- ? fieldDetails.meta.ui.ui_field.data_source?.url || ''
624
- : undefined, // Set endpoint URL for DYNAMIC_DROPDOWN
625
- optionKeyPath:
626
- fieldDetails.meta.ui.ui_field?.type === 'DYNAMIC_DROPDOWN'
627
- ? fieldDetails.meta.ui.ui_field.option_key_path || ''
628
- : undefined,
629
- valueKeyPath:
630
- fieldDetails.meta.ui.ui_field?.type === 'DYNAMIC_DROPDOWN'
631
- ? fieldDetails.meta.ui.ui_field.value_key_path || ''
632
- : undefined,
633
- isMultiSelect:
634
- fieldDetails?.meta?.ui?.ui_field?.is_multiselect || false,
635
-
636
- idKeyPath:
637
- fieldDetails.meta.ui.ui_field?.type === 'CUSTOM_FIELDS'
638
- ? fieldDetails.meta.ui.ui_field.id_key_path || ''
639
- : undefined,
640
- typeKeyPath:
641
- fieldDetails.meta.ui.ui_field?.type === 'CUSTOM_FIELDS'
642
- ? fieldDetails.meta.ui.ui_field.type_key_path || ''
643
- : undefined,
644
- titleKeyPath:
645
- fieldDetails.meta.ui.ui_field?.type === 'CUSTOM_FIELDS'
646
- ? fieldDetails.meta.ui.ui_field.title_key_path || ''
647
- : undefined,
648
- isRequiredKeyPath:
649
- fieldDetails.meta.ui.ui_field?.type === 'CUSTOM_FIELDS'
650
- ? fieldDetails.meta.ui.ui_field.is_required_key_path || ''
651
- : undefined,
652
- dataSourceBody:
653
- fieldDetails.meta.ui.ui_field?.type === 'DYNAMIC_DROPDOWN' ||
654
- fieldDetails.meta.ui.ui_field?.type === 'CUSTOM_FIELDS'
655
- ? fieldDetails.meta.ui.ui_field.data_source?.body || {}
656
- : {}, // Set endpoint URL for DYNAMIC_DROPDOWN
657
- defaultValue: functionArguments[fieldName] || '',
658
- description:
659
- fieldDetails.meta.description_for_users ||
660
- fieldDetails.description ||
661
- '',
662
- is_required: fieldDetails.meta.is_required || false,
663
- is_editable: true,
664
- is_mappable: true,
665
- regex: fieldDetails.meta.ui.regex || this.getRegex(fieldDetails),
666
- regexErrorMessage:
667
- fieldDetails.meta.ui.regex_error_message ||
668
- this.getRegexErrorMessage(fieldDetails),
669
- placeholder:
670
- fieldDetails.meta.ui.placeholder ||
671
- (['DYNAMIC_DROPDOWN', 'STATIC_DROPDOWN'].includes(
672
- fieldDetails.meta.ui.ui_field?.type,
673
- )
674
- ? `Select or enter a value here...`
675
- : `Enter value here...`),
676
- dataType: fieldDetails.type,
677
- options: fieldDetails.meta.ui.ui_field.options || [],
678
- properties:
679
- fieldDetails.type === 'array' && fieldDetails.items.type === 'object'
680
- ? fieldDetails.items.properties || {}
681
- : fieldDetails.properties || {},
682
- dependsOn: fieldDetails.meta.ui?.depends_on || [],
683
- isVisible: fieldDetails.meta.ui?.is_visible,
684
- }),
685
- );
686
-
687
- // Render fields
688
- return fields.map((field) => {
689
- let fieldElement;
690
- let isDynamic = false;
691
- let fieldType = field.type;
692
- if (field.type === 'DYNAMIC_DROPDOWN') {
693
- fieldType = 'SELECT';
694
- }
695
- const options: Option[] = field.options.map((option: any) => ({
696
- id: field.type === 'CHECKBOX' ? (option.id ? '1' : '0') : option.id, // Assign '1'/'0' only if field.type is 'CHECKBOX'
697
- value: option.value,
698
- }));
699
-
700
- if (!field.isVisible && !this.props.forceShowAllFields) {
701
- return null;
702
- }
703
-
704
- // Check if field has AI assist enabled
705
- const isAIAssisted = this.state.aiAssistedFields.includes(field.id);
706
- // Set placeholder text for AI assisted fields
707
- const aiPlaceholder = isAIAssisted
708
- ? field.placeholder
709
- : field.placeholder;
710
-
711
- switch (field.type) {
712
- case 'TEXTFIELD':
713
- fieldElement = html`
714
- <div class="${styles.functionFieldWrap} integry-action-field-wrap">
715
- ${this.renderFieldWrapper(
716
- field,
717
- html`
718
- <${MultipurposeField}
719
- id="${field.id}"
720
- title="${field.title}"
721
- activityOutputData=${arrayToNestedJSONWithFirstValue(
722
- JSONToActivityOutputData(this.props.variables || {}),
723
- JSONToDynamicFieldData(this.props.variables || {}),
724
- )}
725
- activityOutputDataRaw=${JSONToActivityOutputData(
726
- this.props.variables || {},
727
- )}
728
- description="${field.description}"
729
- value=${this.state.dynamicFieldDataState[field.id]}
730
- placeholder="${aiPlaceholder}"
731
- regex=${field.regex}
732
- regexErrorMessage=${field.regexErrorMessage}
733
- isRequired="${field.is_required}"
734
- onChange=${(val: any) => {
735
- this.onFieldChange(
736
- field.id,
737
- val,
738
- field.dataType,
739
- field.is_required,
740
- parentFieldId,
741
- );
742
- }}
743
- type=${fieldType}
744
- isMappable=${this.props.variables &&
745
- Object.entries(this.props.variables).length > 0 &&
746
- field.dataType !== 'array'}
747
- isEditable=${true}
748
- isDisabled=${isAIAssisted}
749
- allowTagsInText=${this.props.variables}
750
- fieldId=${field.id}
751
- isArray=${field.dataType === 'array'}
752
- tagsTree=${this.props.showMappingMenu
753
- ? this.props.variables
754
- : null}
755
- ><//>
756
- `,
757
- )}
758
- </div>
759
- `;
760
- break;
761
- case 'TEXTAREA':
762
- fieldElement = html`
763
- <div class="${styles.functionFieldWrap} integry-action-field-wrap">
764
- ${this.renderFieldWrapper(
765
- field,
766
- html`
767
- <${MultipurposeField}
768
- id="${field.id}"
769
- title="${field.title}"
770
- activityOutputData=${arrayToNestedJSONWithFirstValue(
771
- JSONToActivityOutputData(this.props.variables || {}),
772
- JSONToDynamicFieldData(this.props.variables || {}),
773
- )}
774
- activityOutputDataRaw=${JSONToActivityOutputData(
775
- this.props.variables || {},
776
- )}
777
- description="${field.description}"
778
- value=${this.state.dynamicFieldDataState[field.id]}
779
- placeholder="${aiPlaceholder}"
780
- isRequired=${field.is_required}
781
- isDisabled="${isAIAssisted}"
782
- isEditable="${field.is_editable}"
783
- fieldId=${field.id}
784
- onChange=${(val: any) => {
785
- this.onFieldChange(
786
- field.id,
787
- val,
788
- field.dataType,
789
- field.is_required,
790
- parentFieldId,
791
- );
792
- }}
793
- regex=${field.regex}
794
- regexErrorMessage=${field.regexErrorMessage}
795
- type=${fieldType}
796
- isMappable=${this.props.variables &&
797
- Object.entries(this.props.variables).length > 0}
798
- allowTagsInText=${this.props.variables}
799
- tagsTree=${this.props.showMappingMenu
800
- ? this.props.variables
801
- : null}
802
- ><//>
803
- `,
804
- )}
805
- </div>
806
- `;
807
- break;
808
- case 'DYNAMIC_DROPDOWN':
809
- case 'STATIC_DROPDOWN':
810
- case 'CHECKBOX':
811
- isDynamic = field.type === 'DYNAMIC_DROPDOWN';
812
- fieldElement = html`
813
- <div class="${styles.functionFieldWrap} integry-action-field-wrap">
814
- ${this.renderFieldWrapper(
815
- field,
816
- html`
817
- <${ListBox}
818
- key=${field.id}
819
- fieldId=${field.id}
820
- apiHandler=${this.props.apiHandler}
821
- title=${field.title}
822
- description=${field.description}
823
- placeholder=${aiPlaceholder}
824
- isRequired=${field.is_required}
825
- value=${this.state.dynamicFieldDataState[field.id]}
826
- endpointUrl=${isDynamic
827
- ? field.endpointURL
828
- : JSON.stringify(options)}
829
- isDynamic=${isDynamic}
830
- optionKeyPath=${field.valueKeyPath}
831
- valueKeyPath=${field.optionKeyPath}
832
- endpointData=${field.dependsOn.length > 0
833
- ? JSON.stringify({
834
- authorization_id: `${connectedAccount}`,
835
- ...this.fetchDynamicData(field),
836
- })
837
- : null}
838
- type=${`${fieldType}`}
839
- isDisabled="${isAIAssisted}"
840
- isEditable=${field.type === 'DYNAMIC_DROPDOWN'}
841
- isSearchable=${true}
842
- isMappable=${this.props.showMappingMenu &&
843
- field.type !== 'DYNAMIC_DROPDOWN'}
844
- appName=${`${appName}`}
845
- isMultiSelect=${field.isMultiSelect}
846
- onChange=${(val: any, stopChangePropagation = false) => {
847
- this.onFieldChange(
848
- field.id,
849
- val,
850
- field.dataType,
851
- field.is_required,
852
- parentFieldId,
853
- -1,
854
- stopChangePropagation,
855
- );
856
- }}
857
- dataSourceBody=${this.replacePlaceholders(
858
- field.dataSourceBody,
859
- this.state.dynamicFieldDataState,
860
- )}
861
- selectedAuthId=${`${connectedAccount}`}
862
- tagsTree=${this.props.showMappingMenu
863
- ? this.props.variables
864
- : null}
865
- isReadOnly=${isAIAssisted}
866
- allowWorkspaceConnectedAccounts=${!!this.props
867
- .allowWorkspaceConnectedAccounts}
868
- ><//>
869
- `,
870
- )}
871
- </div>
872
- `;
873
- break;
874
-
875
- case 'CUSTOM_FIELDS':
876
- if (!field.endpointURL) {
877
- break;
878
- }
879
- fieldElement = html`
880
- <div
881
- key=${field.id}
882
- class=${`${styles.actionStepFieldWrap} integry-action-field-wrap`}
883
- >
884
- ${this.renderFieldWrapper(
885
- field,
886
- html`
887
- <${DynamicTypedField}
888
- dynamicField=${field}
889
- endpointData=${JSON.stringify({
890
- authorization_id: `${connectedAccount}`,
891
- })}
892
- placeHolder=${aiPlaceholder}
893
- appName=${`${appName}`}
894
- selectedAuthId=${`${connectedAccount}`}
895
- sourceFlowIntegrataionInvocationUrl=${field.endpointURL}
896
- isMappable=${Object.entries(this.props.variables || {})
897
- .length > 0}
898
- isDisabled=${isAIAssisted}
899
- isEditable=${false}
900
- allowTagsInText=${true}
901
- allowWorkspaceConnectedAccounts=${!!this.props
902
- .allowWorkspaceConnectedAccounts}
903
- apiHandler=${this.props.apiHandler}
904
- idKeyPath=${field.idKeyPath}
905
- typeKeyPath=${field.typeKeyPath}
906
- titleKeyPath=${field.titleKeyPath}
907
- isRequiredKeyPath=${field.isRequiredKeyPath}
908
- onChange=${(val: any) => {
909
- this.onFieldChange(field.id, val, field.dataType, false);
910
- }}
911
- dataSourceBody=${this.replacePlaceholders(
912
- field.dataSourceBody,
913
- this.state.dynamicFieldDataState,
914
- )}
915
- parentFieldsChanged=${field.dependsOn.length > 0 &&
916
- field.dependsOn.includes(
917
- this.state.changedParentMachineName,
918
- )
919
- ? this.state.parentChangeVersion
920
- : 0}
921
- activityOutputData=${arrayToNestedJSONWithFirstValue(
922
- JSONToActivityOutputData(this.props.variables || {}),
923
- JSONToDynamicFieldData(this.props.variables || {}),
924
- )}
925
- activityOutputDataRaw=${JSONToActivityOutputData(
926
- this.props.variables || {},
927
- )}
928
- value=${this.state.dynamicFieldDataState[field.id] || {}}
929
- isDisabled=${isAIAssisted}
930
- dependsOn=${field.dependsOn}
931
- isArray=${field.dataType === 'array'}
932
- />
933
- `,
934
- )}
935
- </div>
936
- `;
937
-
938
- break;
939
- case 'STANDARD_FIELDS':
940
- // Recursively render fields for object type
941
- if (field.properties) {
942
- fieldElement = html`
943
- <div
944
- class="${styles.functionFieldWrap} integry-action-field-wrap"
945
- >
946
- ${this.renderFieldWrapper(
947
- field,
948
- html`
949
- <${ObjectField}
950
- field=${field}
951
- functionArguments=${functionArguments}
952
- connectedAccount=${connectedAccount}
953
- appName=${appName}
954
- onChange=${this.onFieldChange}
955
- apiHandler=${this.props.apiHandler}
956
- isArray=${field.dataType === 'array'}
957
- activityOutputData=${arrayToNestedJSONWithFirstValue(
958
- JSONToActivityOutputData(this.props.variables || {}),
959
- JSONToDynamicFieldData(this.props.variables || {}),
960
- )}
961
- activityOutputDataRaw=${JSONToActivityOutputData(
962
- this.props.variables || {},
963
- )}
964
- isDisabled=${isAIAssisted}
965
- objectValue=${this.state.dynamicFieldDataState[
966
- field.id
967
- ] || {}}
968
- />
969
- `,
970
- )}
971
- </div>
972
- `;
973
- }
974
- break;
975
-
976
- // You can add cases for other field types here
977
- default:
978
- fieldElement = html``;
979
- }
980
-
981
- return html`
982
- <div class="${styles.functionFieldWrap} integry-action-field-wrap">
983
- ${fieldElement}
984
- </div>
985
- `;
986
- });
987
- };
988
-
989
- renderFunctionDetails = (
990
- functionName: string,
991
- functionDetails: any,
992
- functionArguments: any,
993
- ) => {
994
- const context = useContext(AppContext);
995
- if (!functionDetails || !functionDetails.parameters) return null;
996
-
997
- const connectedAccount =
998
- this.props.connectedAccountId ||
999
- functionDetails.meta.app.connected_accounts.length > 0
1000
- ? functionDetails.meta.app.connected_accounts[0].id
1001
- : null;
1002
- return this.renderFields(
1003
- functionDetails.parameters.properties,
1004
- functionArguments,
1005
- connectedAccount,
1006
- functionDetails.meta.app.name,
1007
- );
1008
- };
1009
-
1010
- render() {
1011
- const {
1012
- functionArguments,
1013
- functionName,
1014
- connectedAccountId,
1015
- onClose,
1016
- } = this.props;
1017
- const { functionDetails } = this.state;
1018
-
1019
- return html`
1020
- ${this.state.loading
1021
- ? html`<div class="${styles.functionFormLoader}">
1022
- <${LargeLoader} />
1023
- </div>`
1024
- : functionDetails &&
1025
- functionDetails.meta &&
1026
- html`
1027
- <div class="${styles.functionFormWrap}">
1028
- <div class="${styles.functionHeader}">
1029
- <div class="${styles.name}">
1030
- <div class="${styles.functionIcon}">
1031
- <img
1032
- src=${functionDetails.meta.app.icon_url}
1033
- alt=${functionDetails.meta.app.name}
1034
- />
1035
- </div>
1036
- <div class="${styles.text}">
1037
- ${functionDetails.meta.ui.title}
1038
- </div>
1039
- </div>
1040
- </div>
1041
- <div class="${styles.functionFormContainer}">
1042
- ${functionDetails.meta.app.connected_accounts.length > 0
1043
- ? this.renderFunctionDetails(
1044
- functionName,
1045
- functionDetails,
1046
- functionArguments,
1047
- )
1048
- : html`<div class="${styles.errorMessage}">
1049
- Error: User authorization is missing.
1050
- </div>`}
1051
- </div>
1052
-
1053
- <div class="${styles.btnSubmit}">
1054
- <${Button}
1055
- label="${functionDetails.meta.app.connected_accounts.length >
1056
- 0
1057
- ? 'Submit'
1058
- : 'Close'}"
1059
- position="top-right"
1060
- onClick=${this.onSubmit}
1061
- isLoading=${this.state.isSubmitting}
1062
- disabled=${this.state.invalidFields.length > 0}
1063
- tooltip=${this.state.invalidFields.length > 0
1064
- ? 'Please complete all required fields with valid data.'
1065
- : ''}
1066
- />
1067
- </div>
1068
- </div>
1069
- `}
1070
- `;
1071
- }
1072
- }
1073
-
1074
- export default connect<
1075
- FunctionFormPropsType,
1076
- ActionFormStateType,
1077
- StoreType,
1078
- unknown
1079
- >(
1080
- [
1081
- 'stepState',
1082
- 'stepMapping',
1083
- 'stepDataMapping',
1084
- 'parentChildMapping',
1085
- 'fieldListMapping',
1086
- 'conditionalFieldMapping',
1087
- 'embedConfig',
1088
- 'activityOutputData',
1089
- 'genericData',
1090
- 'userConfig',
1091
- 'authMapping',
1092
- 'showSetupModal',
1093
- ],
1094
- actionFunctions,
1095
- )(FunctionForm);