@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,816 +0,0 @@
1
- import { html } from 'htm/preact';
2
- import { useState, useRef, useEffect } from 'preact/hooks';
3
- import { ListBox } from '@/components/MultipurposeField/Dropdown';
4
- import FunctionForm from '@/features/common/FunctionForm';
5
- import AuthSelectorV2 from '@/features/common/AuthSelectorV2';
6
- import { LargeLoader } from '@/components/LargeLoader';
7
- import { Hint } from '@/components/Tooltip';
8
- import styles from './styles.module.scss';
9
-
10
- // Types for our component
11
- type Authorization = {
12
- id: number;
13
- display_name: string;
14
- };
15
-
16
- type FunctionFieldProps = {
17
- onChange: (value: any) => void;
18
- value?: any;
19
- label?: string;
20
- name: string;
21
- description?: string;
22
- field: Record<string, any>;
23
- apiHandler?: any;
24
- isArray?: boolean; // New prop for array support
25
- tagsTree?: any;
26
- isReadOnly?: boolean;
27
- };
28
-
29
- const FunctionField = (props: FunctionFieldProps) => {
30
- const {
31
- value,
32
- label,
33
- description,
34
- field,
35
- isArray = false,
36
- tagsTree,
37
- isReadOnly,
38
- } = props;
39
- const [isOpen, setIsOpen] = useState(false);
40
- const [editingIndex, setEditingIndex] = useState<number | null>(null);
41
- const [selectedFunction, setSelectedFunction] = useState<string>('');
42
- const [activeTab, setActiveTab] = useState('authorization');
43
- const [functionDetails, setFunctionDetails] = useState<any>(null);
44
- const [loadingFunctionDetails, setLoadingFunctionDetails] = useState<boolean>(
45
- false,
46
- );
47
- const [connectedAccountId, setConnectedAccountId] = useState<number | null>(
48
- null,
49
- );
50
- const [connectedAccounts, setConnectedAccounts] = useState<any>([]);
51
- const [visibleFields, setVisibleFields] = useState<any>([]);
52
-
53
- // Track AI-assisted fields
54
- const [aiAssistedFields, setAIAssistedFields] = useState<string[]>([]);
55
-
56
- // Modified to support array of values
57
- const [functionValues, setFunctionValues] = useState<any[]>(() => {
58
- if (isArray && Array.isArray(value)) {
59
- return value;
60
- }
61
- if (value) {
62
- return [value];
63
- }
64
- return [];
65
- });
66
-
67
- const [formHasInvalidFields, setFormHasInvalidFields] = useState<boolean>(
68
- false,
69
- );
70
- const [userFilledData, setUserFilledData] = useState<any>({});
71
-
72
- const modalRef = useRef<HTMLDivElement | null>(null);
73
- const FUNCTIONS_LIST_URL = `https://api.integry.io/functions/list/`;
74
-
75
- // Reset state when opening modal for a new action
76
- const resetModalState = () => {
77
- setSelectedFunction('');
78
- setActiveTab('authorization');
79
- setFunctionDetails(null);
80
- setConnectedAccountId(null);
81
- setUserFilledData({});
82
- setFormHasInvalidFields(false);
83
- setAIAssistedFields([]); // Reset AI-assisted fields
84
- };
85
-
86
- // Handle clicking outside the modal to close it
87
- useEffect(() => {
88
- function handleClickOutside(event: MouseEvent) {
89
- if (
90
- modalRef.current &&
91
- !modalRef.current.contains(event.target as Node)
92
- ) {
93
- setIsOpen(false);
94
- }
95
- }
96
-
97
- if (isOpen) {
98
- document.addEventListener('mousedown', handleClickOutside);
99
- }
100
-
101
- return () => {
102
- document.removeEventListener('mousedown', handleClickOutside);
103
- };
104
- }, [isOpen]);
105
-
106
- // Open modal for adding a new action
107
- const handleOpenModal = () => {
108
- resetModalState();
109
- setEditingIndex(null);
110
- setIsOpen(true);
111
- };
112
-
113
- const getVisibleFields = (properties: any[]) => {
114
- const response: any[] = [];
115
-
116
- Object.entries(properties).forEach(([key, property]) => {
117
- response.push({ key, ...property });
118
- });
119
-
120
- return response;
121
- };
122
-
123
- const getInvalidFields = (properties: any[]) => {
124
- const response: any[] = [];
125
-
126
- Object.entries(properties).forEach(([key, property]) => {
127
- if (
128
- property.meta?.ui?.is_visible &&
129
- property.meta?.is_required &&
130
- !userFilledData[key] &&
131
- !aiAssistedFields.includes(key) // Don't mark AI-assisted fields as invalid
132
- ) {
133
- response.push({ key, ...property });
134
- }
135
- });
136
-
137
- return response;
138
- };
139
-
140
- // Open modal for editing an existing action
141
- const handleEditAction = (index: number) => {
142
- const actionToEdit = functionValues[index];
143
- setEditingIndex(index);
144
- setSelectedFunction(actionToEdit?.json_schema?.function.name || '');
145
- setUserFilledData(actionToEdit?.default_arguments || {});
146
-
147
- // Load AI-assisted fields from meta if available
148
- if (actionToEdit?.meta?.ai_assisted_fields) {
149
- setAIAssistedFields(actionToEdit.meta.ai_assisted_fields);
150
- } else {
151
- setAIAssistedFields([]);
152
- }
153
-
154
- // Load function details for the selected function
155
- setLoadingFunctionDetails(true);
156
- props.apiHandler
157
- .getFunctionDetails(actionToEdit?.json_schema?.function.name, {})
158
- .then((response: any) => {
159
- setFunctionDetails(response);
160
- setLoadingFunctionDetails(false);
161
- setConnectedAccounts(response?.meta?.app?.connected_accounts || []);
162
- setVisibleFields(
163
- getVisibleFields(response?.parameters?.properties || []),
164
- );
165
- setFormHasInvalidFields(
166
- getInvalidFields(response?.parameters?.properties || []).length > 0,
167
- );
168
- setConnectedAccountId(actionToEdit?.meta?.connected_account_id || null);
169
- setActiveTab('authorization');
170
- });
171
-
172
- setIsOpen(true);
173
- };
174
-
175
- const handleCloseModal = () => {
176
- setIsOpen(false);
177
- };
178
-
179
- const handleFunctionSelect = (val: any) => {
180
- setSelectedFunction(val);
181
- setActiveTab('authorization');
182
- setLoadingFunctionDetails(true);
183
- props.apiHandler.getFunctionDetails(val, {}).then((response: any) => {
184
- setFunctionDetails(response);
185
- setLoadingFunctionDetails(false);
186
- setConnectedAccounts(response?.meta?.app?.connected_accounts || []);
187
- setVisibleFields(
188
- getVisibleFields(response?.parameters?.properties || []),
189
- );
190
- setFormHasInvalidFields(
191
- getInvalidFields(response?.parameters?.properties || []).length > 0,
192
- );
193
- if (response && response.meta?.app?.connected_accounts?.length > 0) {
194
- setConnectedAccountId(response.meta.app.connected_accounts[0].id);
195
- } else {
196
- setConnectedAccountId(null);
197
- }
198
- });
199
- };
200
-
201
- const removeMeta = (obj: any): any => {
202
- if (Array.isArray(obj)) {
203
- return obj.map(removeMeta);
204
- }
205
- if (typeof obj === 'object' && obj !== null) {
206
- const newObj: any = {};
207
- Object.keys(obj).forEach((key) => {
208
- if (key !== 'meta') {
209
- newObj[key] = removeMeta(obj[key]);
210
- }
211
- });
212
- return newObj;
213
- }
214
- return obj;
215
- };
216
-
217
- // Handle AI assist toggle changes
218
- const handleAIAssistToggle = (
219
- fieldId: string,
220
- enabled: boolean,
221
- allAIAssistedFields: string[],
222
- ) => {
223
- setAIAssistedFields(allAIAssistedFields);
224
-
225
- // Update form validation since AI-assisted fields should not be marked as invalid
226
- if (
227
- functionDetails &&
228
- functionDetails.parameters &&
229
- functionDetails.parameters.properties
230
- ) {
231
- const invalidFields = getInvalidFields(
232
- functionDetails.parameters.properties,
233
- );
234
- setFormHasInvalidFields(invalidFields.length > 0);
235
- }
236
- };
237
-
238
- // Modified to handle array of values and include AI-assisted fields in meta
239
- const handleSave = () => {
240
- if (selectedFunction && functionDetails) {
241
- const schema = {
242
- json_schema: {
243
- type: 'function',
244
- function: removeMeta(functionDetails),
245
- },
246
- meta: {
247
- id: functionDetails.meta.id,
248
- version: functionDetails.meta.version,
249
- connected_account_id: connectedAccountId,
250
- form_page_machine_name: null,
251
- name: functionDetails.name,
252
- title: functionDetails.meta.ui.title,
253
- app_name: functionDetails.meta.app.title,
254
- app_icon_url: functionDetails.meta.app.icon_url,
255
- ai_assisted_fields: aiAssistedFields, // Store AI-assisted fields in meta
256
- },
257
- default_arguments: userFilledData,
258
- parameters_visible_to_user: {},
259
- };
260
-
261
- // Update or add the function value
262
- let updatedValues;
263
- if (editingIndex !== null) {
264
- // Update existing action
265
- updatedValues = [...functionValues];
266
- updatedValues[editingIndex] = schema;
267
- } else {
268
- // Add new action
269
- updatedValues = [...functionValues, schema];
270
- }
271
-
272
- setFunctionValues(updatedValues);
273
-
274
- // Call onChange with the updated values
275
- if (props.onChange) {
276
- props.onChange(isArray ? updatedValues : updatedValues[0]);
277
- }
278
-
279
- setIsOpen(false);
280
- }
281
- };
282
-
283
- // Delete a specific action from the array
284
- const handleDeleteAction = (index: number) => {
285
- const updatedValues = functionValues.filter((_, i) => i !== index);
286
- setFunctionValues(updatedValues);
287
-
288
- // Call onChange with the updated values
289
- if (props.onChange) {
290
- props.onChange(isArray ? updatedValues : updatedValues[0] || null);
291
- }
292
- };
293
-
294
- const handleAuthCreated = (auth: Authorization) => {
295
- setActiveTab('input');
296
- const existingAuth = connectedAccounts.find(
297
- (account: Authorization) => account.id === auth.id,
298
- );
299
- if (!existingAuth) {
300
- setConnectedAccounts((prev: Authorization[]) => [...prev, auth]);
301
- setConnectedAccountId(auth.id);
302
- }
303
- };
304
-
305
- const handleAuthDeleted = (authId: number) => {
306
- setConnectedAccounts((prev: Authorization[]) =>
307
- prev.filter((account: Authorization) => account.id !== authId),
308
- );
309
- setConnectedAccountId(null);
310
- };
311
-
312
- const handleCustomaSave = (customSaveResponse: any) => {
313
- setFormHasInvalidFields(customSaveResponse.hasInvalidFields);
314
- setUserFilledData(customSaveResponse.data);
315
- };
316
-
317
- const handleNextTab = () => {
318
- setActiveTab('input');
319
- };
320
-
321
- // Get default AI-assisted fields based on the current function
322
- const getDefaultAIAssistedFields = () => {
323
- // If editing an existing function, use the stored AI-assisted fields
324
- if (
325
- editingIndex !== null &&
326
- functionValues[editingIndex]?.meta?.ai_assisted_fields
327
- ) {
328
- return functionValues[editingIndex].meta.ai_assisted_fields;
329
- }
330
-
331
- return [];
332
- };
333
-
334
- const loadAuthorizationTabContent = () => {
335
- let content;
336
-
337
- if (loadingFunctionDetails) {
338
- content = html`
339
- <div class=${styles.loader || 'function-field-loader'}>
340
- <${LargeLoader} />
341
- </div>
342
- `;
343
- } else if (functionDetails) {
344
- const selectedAuthId =
345
- connectedAccountId ||
346
- (functionDetails.meta.app.connected_accounts.length > 0
347
- ? functionDetails.meta.app.connected_accounts[0]?.id
348
- : null);
349
-
350
- content = html`
351
- <${AuthSelectorV2}
352
- authorizations=${connectedAccounts}
353
- appName=${functionDetails.meta.app.title}
354
- apiHandler=${props.apiHandler}
355
- onAuthSelected=${(authId: number) => {
356
- setConnectedAccountId(authId);
357
- }}
358
- onAuthCreated=${handleAuthCreated}
359
- onAuthDeleted=${handleAuthDeleted}
360
- selectedAuthId=${selectedAuthId}
361
- loginUrl=${functionDetails.meta.app.login_url}
362
- isReadOnly=${isReadOnly}
363
- />
364
- `;
365
- }
366
-
367
- return content;
368
- };
369
-
370
- return html`
371
- <div class=${styles.functionFieldContainer || 'function-field-container'}>
372
- ${label
373
- ? html`
374
- <label class=${styles.functionFieldLabel || 'function-field-label'}>
375
- ${label}
376
- ${description
377
- ? html`
378
- <div
379
- class=${styles.functionFieldDescription ||
380
- 'function-field-description'}
381
- >
382
- ${description}
383
- </div>
384
- `
385
- : null}
386
- </label>
387
- `
388
- : null}
389
- ${isArray && functionValues.length > 0
390
- ? html`
391
- <div class=${styles.functionFieldArray || 'function-field-array'}>
392
- ${functionValues.map(
393
- (functionValue, index) => html`
394
- <div
395
- key=${index}
396
- class=${styles.functionFieldSummary ||
397
- 'function-field-summary'}
398
- style="margin-bottom: 8px;"
399
- >
400
- <div
401
- class=${styles.functionFieldSelected ||
402
- 'function-field-selected'}
403
- >
404
- <div
405
- class=${styles.functionFieldInfo ||
406
- 'function-field-info'}
407
- >
408
- <img
409
- src=${functionValue?.meta?.app_icon_url}
410
- alt=${functionValue.meta?.app_name || 'App'}
411
- class=${styles.functionFieldAppIcon ||
412
- 'function-field-app-icon'}
413
- />
414
- <div
415
- class=${styles.functionFieldNameContainer ||
416
- 'function-field-name-container'}
417
- >
418
- <span
419
- class=${styles.functionFieldName ||
420
- 'function-field-name'}
421
- >
422
- ${functionValue.meta?.title || 'Function'}
423
- </span>
424
- <span
425
- class=${styles.functionFieldAppName ||
426
- 'function-field-app-name'}
427
- >
428
- ${functionValue.meta?.name || ''}
429
- </span>
430
- </div>
431
- </div>
432
- <div
433
- class=${styles.functionFieldActions ||
434
- 'function-field-actions'}
435
- >
436
- <button
437
- type="button"
438
- disabled=${isReadOnly}
439
- class=${styles.functionFieldDeleteBtn ||
440
- 'function-field-delete-btn'}
441
- onClick=${(e: any) => {
442
- e.stopPropagation();
443
- handleDeleteAction(index);
444
- }}
445
- aria-label="Delete"
446
- >
447
- <svg
448
- width="16"
449
- height="16"
450
- viewBox="0 0 24 24"
451
- fill="none"
452
- xmlns="http://www.w3.org/2000/svg"
453
- >
454
- <path
455
- d="M3 6H5H21"
456
- stroke="currentColor"
457
- strokeWidth="2"
458
- strokeLinecap="round"
459
- strokeLinejoin="round"
460
- />
461
- <path
462
- d="M8 6V4C8 3.46957 8.21071 2.96086 8.58579 2.58579C8.96086 2.21071 9.46957 2 10 2H14C14.5304 2 15.0391 2.21071 15.4142 2.58579C15.7893 2.96086 16 3.46957 16 4V6M19 6V20C19 20.5304 18.7893 21.0391 18.4142 21.4142C18.0391 21.7893 17.5304 22 17 22H7C6.46957 22 5.96086 21.7893 5.58579 21.4142C5.21071 21.0391 5 20.5304 5 20V6H19Z"
463
- stroke="currentColor"
464
- strokeWidth="2"
465
- strokeLinecap="round"
466
- strokeLinejoin="round"
467
- />
468
- </svg>
469
- </button>
470
- <button
471
- type="button"
472
- class=${styles.functionFieldEditBtn ||
473
- 'function-field-edit-btn'}
474
- onClick=${() => handleEditAction(index)}
475
- >
476
- ${isReadOnly ? 'View' : 'Edit'}
477
- </button>
478
- </div>
479
- </div>
480
- </div>
481
- `,
482
- )}
483
- </div>
484
- `
485
- : null}
486
- ${!isArray && functionValues.length > 0
487
- ? html`
488
- <div
489
- class=${styles.functionFieldSummary || 'function-field-summary'}
490
- >
491
- <div
492
- class=${styles.functionFieldSelected ||
493
- 'function-field-selected'}
494
- >
495
- <div class=${styles.functionFieldInfo || 'function-field-info'}>
496
- <img
497
- src=${functionValues[0]?.meta?.app_icon_url}
498
- alt=${functionValues[0].meta?.app_name || 'App'}
499
- class=${styles.functionFieldAppIcon ||
500
- 'function-field-app-icon'}
501
- />
502
- <div
503
- class=${styles.functionFieldNameContainer ||
504
- 'function-field-name-container'}
505
- >
506
- <span
507
- class=${styles.functionFieldName || 'function-field-name'}
508
- >
509
- ${functionValues[0].meta?.title || 'Function'}
510
- </span>
511
- <span
512
- class=${styles.functionFieldAppName ||
513
- 'function-field-app-name'}
514
- >
515
- ${functionValues[0].meta?.name || ''}
516
- </span>
517
- </div>
518
- </div>
519
- <div
520
- class=${styles.functionFieldActions ||
521
- 'function-field-actions'}
522
- >
523
- <button
524
- type="button"
525
- class=${styles.functionFieldDeleteBtn ||
526
- 'function-field-delete-btn'}
527
- onClick=${(e: any) => {
528
- e.stopPropagation();
529
- handleDeleteAction(0);
530
- }}
531
- aria-label="Delete"
532
- >
533
- <svg
534
- width="16"
535
- height="16"
536
- viewBox="0 0 24 24"
537
- fill="none"
538
- xmlns="http://www.w3.org/2000/svg"
539
- >
540
- <path
541
- d="M3 6H5H21"
542
- stroke="currentColor"
543
- strokeWidth="2"
544
- strokeLinecap="round"
545
- strokeLinejoin="round"
546
- />
547
- <path
548
- d="M8 6V4C8 3.46957 8.21071 2.96086 8.58579 2.58579C8.96086 2.21071 9.46957 2 10 2H14C14.5304 2 15.0391 2.21071 15.4142 2.58579C15.7893 2.96086 16 3.46957 16 4V6M19 6V20C19 20.5304 18.7893 21.0391 18.4142 21.4142C18.0391 21.7893 17.5304 22 17 22H7C6.46957 22 5.96086 21.7893 5.58579 21.4142C5.21071 21.0391 5 20.5304 5 20V6H19Z"
549
- stroke="currentColor"
550
- strokeWidth="2"
551
- strokeLinecap="round"
552
- strokeLinejoin="round"
553
- />
554
- </svg>
555
- </button>
556
- <button
557
- type="button"
558
- class=${styles.functionFieldEditBtn ||
559
- 'function-field-edit-btn'}
560
- onClick=${() => handleEditAction(0)}
561
- >
562
- Edit
563
- </button>
564
- </div>
565
- </div>
566
- </div>
567
- `
568
- : null}
569
- ${isArray || functionValues.length === 0
570
- ? html`
571
- <div
572
- class=${styles.functionFieldActions || 'function-field-actions'}
573
- style="margin-top: ${functionValues.length > 0 ? '8px' : '0'}"
574
- >
575
- <button
576
- type="button"
577
- disabled=${isReadOnly}
578
- class=${styles.functionFieldAddBtn || 'function-field-add-btn'}
579
- onClick=${handleOpenModal}
580
- >
581
- ${isArray && functionValues.length > 0
582
- ? 'Add another'
583
- : 'Add action'}
584
- </button>
585
- </div>
586
- `
587
- : null}
588
- ${isOpen
589
- ? html`
590
- <div
591
- class=${styles.functionFieldOverlay || 'function-field-overlay'}
592
- >
593
- <div
594
- class=${styles.functionFieldModal || 'function-field-modal'}
595
- ref=${modalRef}
596
- >
597
- <div
598
- class=${styles.functionFieldModalHeader ||
599
- 'function-field-modal-header'}
600
- >
601
- <h3
602
- class=${styles.functionFieldModalTitle ||
603
- 'function-field-modal-title'}
604
- >
605
- ${editingIndex !== null
606
- ? `${isReadOnly ? 'View' : 'Edit'} action`
607
- : 'Add action'}
608
- </h3>
609
- <p
610
- class=${styles.functionFieldModalDescription ||
611
- 'function-field-modal-description'}
612
- >
613
- The AI will use this action
614
- </p>
615
- <button
616
- type="button"
617
- class=${styles.functionFieldCloseBtn ||
618
- 'function-field-close-btn'}
619
- onClick=${handleCloseModal}
620
- >
621
- ×
622
- </button>
623
- </div>
624
-
625
- <div
626
- class=${styles.functionFieldModalBody ||
627
- 'function-field-modal-body'}
628
- >
629
- <div
630
- class=${styles.functionFieldInlineGroup ||
631
- 'function-field-inline-group'}
632
- >
633
- <${ListBox}
634
- key=${field.activity_field?.id}
635
- fieldId=${field.activity_field?.id ||
636
- field.id ||
637
- field?.activity_field?.machine_name}
638
- title=${`Action`}
639
- placeholder=${`Select an action to use`}
640
- isRequired=${true}
641
- isHidden=${false}
642
- isSearchable=${true}
643
- value=${selectedFunction}
644
- onChange=${handleFunctionSelect}
645
- isDynamic=${true}
646
- endpointUrl=${FUNCTIONS_LIST_URL}
647
- endpointData=${`{"include": "meta", "include_private": true, "page_size": 20}`}
648
- apiHandler=${props.apiHandler}
649
- optionKeyPath=${`name`}
650
- valueKeyPath=${`meta.ui.title`}
651
- enableServerSideSearch=${true}
652
- serverSideSearchParamName=${`search`}
653
- iconKeyPath=${`meta.app.icon_url`}
654
- optionDescriptionKeyPath=${`description`}
655
- />
656
- </div>
657
-
658
- ${selectedFunction
659
- ? html`
660
- <div class=${
661
- styles.functionFieldConfig || 'function-field-config'
662
- }>
663
- <div class=${
664
- styles.functionFieldTabs || 'function-field-tabs'
665
- }>
666
- <button
667
- type="button"
668
- class=${`${
669
- styles.functionFieldTab || 'function-field-tab'
670
- } ${
671
- activeTab === 'authorization'
672
- ? styles.functionFieldTabActive ||
673
- 'function-field-tab-active'
674
- : ''
675
- }`}
676
- onClick=${() => setActiveTab('authorization')}
677
- >
678
- Authorization
679
- </button>
680
- <${Hint} dismissOnClick=${false} position="top" deltaY=${0}>
681
- <button
682
- data-hint=${
683
- connectedAccountId
684
- ? ''
685
- : `Please connect your account to proceed.`
686
- }
687
- type="button"
688
- class=${`${
689
- styles.functionFieldTab || 'function-field-tab'
690
- } ${
691
- activeTab === 'input'
692
- ? styles.functionFieldTabActive ||
693
- 'function-field-tab-active'
694
- : ''
695
- } ${connectedAccountId ? '' : styles.disabled}`}
696
- onClick=${() => {
697
- if (connectedAccountId) {
698
- setActiveTab('input');
699
- }
700
- }}
701
- >
702
- Input
703
- ${
704
- visibleFields.length > 0
705
- ? ` (${visibleFields.length})`
706
- : ''
707
- }
708
- </button>
709
- </${Hint}>
710
- </div>
711
-
712
- <div class=${
713
- styles.functionFieldTabContent ||
714
- 'function-field-tab-content'
715
- }>
716
- ${
717
- activeTab === 'authorization'
718
- ? html`
719
- <div
720
- class=${styles.functionFieldAuthContent ||
721
- 'function-field-auth-content'}
722
- >
723
- ${html`${loadAuthorizationTabContent()}`}
724
- </div>
725
- `
726
- : html`
727
- <div
728
- class=${styles.functionFieldInputContent ||
729
- 'function-field-input-content'}
730
- >
731
- <${FunctionForm}
732
- functionName=${selectedFunction}
733
- apiHandler=${props.apiHandler}
734
- functionArguments=${userFilledData}
735
- connectedAccountId=${connectedAccountId}
736
- customSaveCallback=${handleCustomaSave}
737
- variables=${tagsTree}
738
- showMappingMenu=${true}
739
- forceShowAllFields=${true}
740
- enableAIAssist=${true}
741
- defaultAIAssistedFields=${getDefaultAIAssistedFields()}
742
- onAIAssistToggle=${handleAIAssistToggle}
743
- />
744
- </div>
745
- `
746
- }
747
- </div>
748
- </div>
749
- `
750
- : null}
751
- </div>
752
-
753
- ${activeTab === 'input'
754
- ? html`
755
- <div
756
- class=${styles.functionFieldModalFooter ||
757
- 'function-field-modal-footer'}
758
- >
759
- <button
760
- type="button"
761
- class=${styles.functionFieldCancelBtn ||
762
- 'function-field-cancel-btn'}
763
- onClick=${handleCloseModal}
764
- >
765
- Cancel
766
- </button>
767
- <button
768
- type="button"
769
- class=${styles.functionFieldSaveBtn ||
770
- 'function-field-save-btn'}
771
- onClick=${handleSave}
772
- disabled=${!selectedFunction ||
773
- formHasInvalidFields ||
774
- !connectedAccountId ||
775
- isReadOnly}
776
- >
777
- Save
778
- </button>
779
- </div>
780
- `
781
- : null}
782
- ${activeTab === 'authorization' && selectedFunction
783
- ? html`
784
- <div
785
- class=${styles.functionFieldModalFooter ||
786
- 'function-field-modal-footer'}
787
- >
788
- <button
789
- type="button"
790
- class=${styles.functionFieldCancelBtn ||
791
- 'function-field-cancel-btn'}
792
- onClick=${handleCloseModal}
793
- >
794
- Cancel
795
- </button>
796
- <button
797
- type="button"
798
- class=${styles.functionFieldSaveBtn ||
799
- 'function-field-save-btn'}
800
- onClick=${handleNextTab}
801
- disabled=${!selectedFunction || !connectedAccountId}
802
- >
803
- Next
804
- </button>
805
- </div>
806
- `
807
- : null}
808
- </div>
809
- </div>
810
- `
811
- : null}
812
- </div>
813
- `;
814
- };
815
-
816
- export { FunctionField, FunctionFieldProps };