@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,649 +0,0 @@
1
- import { html } from 'htm/preact';
2
- import { connect } from 'unistore/preact';
3
- import { useContext, useEffect, useMemo, useRef, useState } from 'preact/hooks';
4
- import { IncomingWebhookObject, TemplateField } from '@/interfaces';
5
- import AppContext from '@/contexts/AppContext';
6
- import { StoreType } from '@/types/store';
7
- import { LargeLoader } from '@/components/LargeLoader';
8
- import { actionFunctions } from '@/store';
9
- import { Label } from '@/components/Label';
10
- import { ListBox } from '@/components/Listbox';
11
- import { Tag } from '@/components/Tag';
12
- import { Select } from '@/components/BasicSelect';
13
- import { MultipurposeField } from '@/components/MultipurposeField';
14
- import {
15
- JSONToActivityOutputData,
16
- JSONToDynamicFieldData,
17
- } from '@/utils/ActivityOutputUtils';
18
- import { areParentValuesValid } from '@/utils/stepUtils';
19
-
20
- import styles from './styles.module.scss';
21
-
22
- export type MappingUiProps = {
23
- stepId: number;
24
- templateFields: TemplateField[];
25
- showStepValidation?: boolean;
26
- endpointData: {
27
- authId: number;
28
- fieldsData: Record<string, string | number>;
29
- };
30
- } & StoreType;
31
-
32
- interface DynamicDataItem {
33
- fieldId: number;
34
- id: string | null;
35
- title: string | null;
36
- type: string;
37
- isNotDynamic?: boolean;
38
- }
39
-
40
- const MappingUI = (props: MappingUiProps) => {
41
- const [loading, setLoading] = useState<boolean>(true);
42
- const [rootDataLoading, setRootDataLoading] = useState<boolean>(false);
43
- const [dynamicDataLoading, setDynamicDataLoading] = useState<boolean>(false);
44
- const [fieldsRef, setFieldsRef] = useState<number[]>([]);
45
- const [dynamicItems, setDynamicItems] = useState<DynamicDataItem[]>([]);
46
- const [dynamicListId, setDynamicListId] = useState('');
47
- const [incommingWebhookApp, setIncommingWebhookApp] = useState<{
48
- id: number;
49
- name: string;
50
- icon_url: string;
51
- } | null>(null);
52
- // const [additionalData, setAdditionalData] = useState({});
53
-
54
- const context = useContext(AppContext);
55
- const isReadOnly = context?.isReadOnly;
56
-
57
- const dynamicFieldIdRef = useRef('');
58
-
59
- const shouldShowField = (field: any) => {
60
- const { stepId, conditionalFieldMapping } = props;
61
- const fieldConditions = conditionalFieldMapping[stepId][
62
- field.id
63
- ];
64
- let isConditionValid = true;
65
-
66
- if (fieldConditions) {
67
- isConditionValid = areParentValuesValid(
68
- stepId,
69
- fieldConditions,
70
- props.stepDataMapping,
71
- );
72
- }
73
- return isConditionValid;
74
- };
75
-
76
- useEffect(() => {
77
- if (dynamicItems.length > 0) {
78
- // eslint-disable-next-line array-callback-return
79
- dynamicItems.map((el, index) => {
80
- const ele = props.stepDataMapping[props.stepId][el.fieldId];
81
- if (ele && !ele.isDynamic && ele.value) {
82
- const parsedValue = ele.value.slice(1, -1);
83
- if (parsedValue) setFieldsRef((prev) => [...prev, index]);
84
- } else if (ele && ele.isDynamic && ele.objectValue && el.id) {
85
- const parsedValues = ele.objectValue || {};
86
- if (parsedValues[el.id]) {
87
- setFieldsRef((prev) => [...prev, index]);
88
- }
89
- }
90
- });
91
- }
92
- }, [dynamicItems]);
93
-
94
- useEffect(() => {
95
- const triggerStep = props.genericData.stepWithActivityOutput;
96
- if (triggerStep) {
97
- const { id: triggerStepId } = triggerStep;
98
- // eslint-disable-next-line no-use-before-define
99
- const data = getVisibleFieldsDataOnRootStep(triggerStepId);
100
- // eslint-disable-next-line no-use-before-define
101
- setRootStepData(data);
102
- }
103
- }, []);
104
-
105
- useEffect(() => {
106
- // fetch the dynamic field in case it exists
107
- const dynamicFieldToRender = props.templateFields.filter(
108
- (el) => el.activity_field && el.activity_field.type === 'DYNAMIC',
109
- )[0];
110
-
111
- if (dynamicFieldToRender) {
112
- // set our dynamic list ID
113
- setDynamicListId(`${dynamicFieldToRender.id}`);
114
- }
115
-
116
- // get a list of text fields that will be part of the mapping
117
- const textFieldsToRender = props.templateFields
118
- .filter(
119
- (el) =>
120
- el.activity_field &&
121
- el.activity_field.type === 'TEXTFIELD' &&
122
- el.is_visible,
123
- )
124
- .map((el) => ({
125
- fieldId: el.id,
126
- id: el.activity_field && el.activity_field.machine_name,
127
- title: el.activity_field && el.activity_field.title,
128
- type: 'text',
129
- isNotDynamic: true,
130
- }));
131
-
132
- const filteredTextFieldsToRender: any = [];
133
-
134
- textFieldsToRender.forEach(fieldToRender => {
135
- if(shouldShowField(fieldToRender)) {
136
- filteredTextFieldsToRender.push(fieldToRender);
137
- }
138
- });
139
- // grab activity output data since that is used in both cases
140
- // if (!props.activityOutputData) {
141
- // console.log('props.activity output data is null');
142
- // // eslint-disable-next-line no-use-before-define
143
- // setRootStepData();
144
- // }
145
-
146
- // if dynamic field exists, fetch the fields and show those
147
- if (
148
- dynamicFieldToRender &&
149
- dynamicFieldToRender.activity_field // &&
150
- // dynamicFieldToRender.id !== Number(dynamicListId)
151
- ) {
152
- const mappingField =
153
- props.parentChildMapping[props.stepId][
154
- dynamicFieldToRender.activity_field.machine_name
155
- ];
156
-
157
- let valuesMapField = '';
158
- if (mappingField) {
159
- const valuesMap = mappingField.parentFields?.reduce((prev, next) => {
160
- const parentFieldId =
161
- props.parentChildMapping[props.stepId][next].fieldId;
162
- return {
163
- ...prev,
164
- [parentFieldId]:
165
- props.stepDataMapping[props.stepId][parentFieldId].value,
166
- };
167
- }, {});
168
- valuesMapField = JSON.stringify(valuesMap);
169
- }
170
-
171
- // in case the parent field value changes, refetch the custom fields
172
- if (
173
- valuesMapField !== dynamicFieldIdRef.current ||
174
- dynamicFieldToRender.id !== Number(dynamicListId)
175
- ) {
176
- setLoading(true);
177
-
178
- // eslint-disable-next-line no-use-before-define
179
- fetchDynamicFieldData(dynamicFieldToRender)
180
- ?.then((res) => {
181
- setLoading(false);
182
- // props.resetCustomMappingData(props.stepId);
183
- setFieldsRef([]);
184
- dynamicFieldIdRef.current = valuesMapField;
185
- if (Array.isArray(res)) {
186
- setDynamicItems([
187
- ...filteredTextFieldsToRender,
188
- ...res.map((el) => ({
189
- ...el,
190
- fieldId: dynamicFieldToRender.id,
191
- fetchedFromAOU: true,
192
- })),
193
- ]);
194
- } else {
195
- setDynamicItems(filteredTextFieldsToRender);
196
- }
197
- })
198
- .catch((err) => {
199
- console.error(err)
200
- setDynamicItems([...filteredTextFieldsToRender]);
201
- setLoading(false);
202
- });
203
- }
204
- } else if (!dynamicItems.length) {
205
- // we dont have any dynamic fields so,
206
- // just set the text fields as items to render
207
- setDynamicItems([...filteredTextFieldsToRender]);
208
- setLoading(false);
209
- } else if (dynamicItems.length > 0) {
210
- const tempFields: any = [];
211
- const cleanedDynamicFields: any = [];
212
- // remove all items from dynamicItems which has fetchedFromAOU = false
213
- dynamicItems.forEach((item: any) => {
214
- if (item.fetchedFromAOU) {
215
- cleanedDynamicFields.push(item);
216
- }
217
- });
218
-
219
- filteredTextFieldsToRender.forEach((item: any) => {
220
- let fieldExist = false;
221
- cleanedDynamicFields.forEach((dynamicItem: any) => {
222
- if(dynamicItem.fieldId === item.fieldId || dynamicItem.fetchedFromAOU) {
223
- fieldExist = true;
224
- }
225
- });
226
- if (!fieldExist) {
227
- tempFields.push(item);
228
- }
229
- });
230
- setDynamicItems([...filteredTextFieldsToRender, ...cleanedDynamicFields]);
231
- setLoading(false);
232
- }
233
- }, [props.stepDataMapping[props.stepId]]);
234
-
235
- const getVisibleFieldsDataOnRootStep = (
236
- stepId: number,
237
- ): {
238
- [machineName: string]: string;
239
- } => {
240
- const fields = props.stepDataMapping[stepId];
241
- const requiredFieldsWithValues = Object.keys(fields)
242
- .filter((el) => fields[Number(el)].value)
243
- .reduce((prev, curr) => {
244
- const currentItem = fields[Number(curr)];
245
- return {
246
- ...prev,
247
- [currentItem.machineName]: currentItem.value,
248
- };
249
- }, {});
250
-
251
- return requiredFieldsWithValues;
252
- };
253
-
254
- const setRootStepData = async (
255
- additionalData: Record<string, string> | undefined,
256
- ) => {
257
- const triggerStep = props.genericData.stepWithActivityOutput;
258
- const integryObject = triggerStep?.template_fields.find(
259
- (el) => el.activity_field?.machine_name === 'integry_webhook_object',
260
- )?.default_value;
261
-
262
- if (triggerStep) {
263
- const { id: triggerStepId } = triggerStep;
264
-
265
- if (triggerStep.activity.activity_output_url) {
266
- setRootDataLoading(true);
267
- context?.apiHandler
268
- .callDynamicDataEndpoint<
269
- {
270
- text: string;
271
- value: string;
272
- }[]
273
- >(new URL(triggerStep.activity.activity_output_url), {
274
- authorization_id: `${props.stepMapping[triggerStepId].selectedAuthId}`,
275
- ...additionalData,
276
- })
277
- .then((res) => {
278
- setRootDataLoading(false);
279
- if (res)
280
- props.setActivityOutputData({
281
- activityOutputData: res,
282
- });
283
- });
284
- } else {
285
- setRootDataLoading(false);
286
- }
287
-
288
- if (integryObject) {
289
- try {
290
- const parsedIntegryObject = JSON.parse(
291
- integryObject,
292
- ) as IncomingWebhookObject;
293
- let objectPaylaod = {};
294
- if (props.userConfig?.objects?.[parsedIntegryObject.name]) {
295
- objectPaylaod =
296
- props.userConfig?.objects?.[parsedIntegryObject.name];
297
- } else {
298
- objectPaylaod = JSON.parse(parsedIntegryObject.payload);
299
- }
300
- const activityOutputData = JSONToActivityOutputData(objectPaylaod);
301
- const dynamicFieldData = JSONToDynamicFieldData(objectPaylaod);
302
- props.setIncomingWebhookPayload({
303
- incomingWebhookPayload: objectPaylaod,
304
- });
305
- props.setActivityOutputData({
306
- activityOutputData: activityOutputData || [],
307
- });
308
- props.setDynamicFieldData({
309
- dynamicFieldData: dynamicFieldData || {},
310
- });
311
- } catch (e) {
312
- console.error(e);
313
- }
314
- try {
315
- const incommingWebhookAppTemp = triggerStep?.template_fields.find(
316
- (el) => el.activity_field?.machine_name === 'app',
317
- )?.default_value;
318
- setIncommingWebhookApp(JSON.parse(incommingWebhookAppTemp || '{}'));
319
- } catch (e) {
320
- console.error('Failed to get incoming webhook app', e);
321
- }
322
- }
323
-
324
- if (triggerStep.activity.dynamic_field_data_endpoint) {
325
- setDynamicDataLoading(true);
326
- context?.apiHandler
327
- .callDynamicDataEndpoint<{
328
- [fieldId: string]: (string | Record<string, string>)[];
329
- }>(new URL(triggerStep.activity.dynamic_field_data_endpoint), {
330
- authorization_id: `${props.stepMapping[triggerStepId].selectedAuthId}`,
331
- ...additionalData,
332
- })
333
- .then((res) => {
334
- setDynamicDataLoading(false);
335
- if (res)
336
- props.setDynamicFieldData({
337
- dynamicFieldData: res,
338
- });
339
- });
340
- } else {
341
- setDynamicDataLoading(false);
342
- }
343
- }
344
- };
345
-
346
- const fetchDynamicFieldData = (templateField: TemplateField) => {
347
- const dynamicEndpoint = `${templateField.activity_field?.dynamic_field_src}`;
348
- return context?.apiHandler.callDynamicDataEndpoint<DynamicDataItem[]>(
349
- new URL(dynamicEndpoint),
350
- {
351
- authorization_id: `${props.endpointData.authId}`,
352
- ...props.endpointData.fieldsData,
353
- },
354
- );
355
- };
356
-
357
- const onMappingValueSelected = (
358
- index: number,
359
- item: DynamicDataItem,
360
- isRequired: boolean,
361
- rowIndex: number,
362
- ) => {
363
- const activityOutputObject = props.activityOutputData?.[index];
364
- const arrayIndex = fieldsRef.findIndex((el) => el === rowIndex);
365
- if (index < 0) {
366
- setFieldsRef((prev) => prev.filter((el) => el !== rowIndex));
367
- if (item.isNotDynamic) {
368
- props.setStepFieldData({
369
- stepId: `${props.stepId}`,
370
- fieldId: `${item.fieldId}`,
371
- value: '',
372
- isRequired,
373
- });
374
- } else if (dynamicListId) {
375
- props.setStepMappingData({
376
- stepId: props.stepId,
377
- fieldId: Number(dynamicListId),
378
- id: `${item.id}`,
379
- value: null,
380
- });
381
- }
382
- } else if (activityOutputObject) {
383
- if (arrayIndex < 0) {
384
- setFieldsRef((prev) => [...prev, rowIndex]);
385
- }
386
- if (item.isNotDynamic) {
387
- props.setStepFieldData({
388
- stepId: `${props.stepId}`,
389
- fieldId: `${item.fieldId}`,
390
- value: `{${activityOutputObject.value}}`,
391
- isRequired,
392
- });
393
- } else if (dynamicListId) {
394
- props.setStepMappingData({
395
- stepId: props.stepId,
396
- fieldId: Number(dynamicListId),
397
- id: `${item.id}`,
398
- value: `{${activityOutputObject.value}}`,
399
- });
400
- }
401
- }
402
- props.verifyStepValidity(props.stepId);
403
- };
404
-
405
- const triggerApp = useMemo(
406
- () =>
407
- Object.keys(props.stepMapping)
408
- ?.map((stepId) => props.stepMapping[stepId])
409
- ?.filter(
410
- (el) =>
411
- el.step.activity.type === 'TRIGGER' ||
412
- el.step.activity.type === 'QUERY',
413
- )[0],
414
- [],
415
- );
416
- const triggerAppInfo = {
417
- icon_url:
418
- incommingWebhookApp?.icon_url ||
419
- triggerApp?.step.activity.app.icon_url ||
420
- props.genericData.brandingApp?.icon_url,
421
- name:
422
- incommingWebhookApp?.name ||
423
- triggerApp?.step.activity.app.name ||
424
- props.genericData.brandingApp?.name,
425
- };
426
-
427
- const removeCurlyBraces = (value: string): string => value.replace(/^{(.*)}$/, '$1')
428
-
429
- const arrayToNestedJSONWithFirstValue = (array: any, valueObj: any) => {
430
- let tempValueObj: any = {};
431
- Object.keys(valueObj).forEach(i => {
432
- const key = removeCurlyBraces(i);
433
- tempValueObj = {
434
- ...tempValueObj,
435
- [key]: valueObj[i] || '',
436
- };
437
- });
438
-
439
- const result = {};
440
- array.forEach((item: any) => {
441
- const keys = item.value.split('.');
442
- let currentLevel: any = result;
443
-
444
- keys.forEach((key: any, index: any) => {
445
- if (!currentLevel[key]) {
446
- if (index === keys.length - 1) {
447
- // eslint-disable-next-line prefer-destructuring
448
- currentLevel[key] = tempValueObj[item.value][0];
449
- } else {
450
- currentLevel[key] = {};
451
- }
452
- }
453
- currentLevel = currentLevel[key];
454
- });
455
- });
456
- return result;
457
- }
458
-
459
- if ((dynamicItems || []).length === 0) {
460
- return html``;
461
- }
462
- return html`
463
- <div>
464
- <${Label}
465
- title="Map data"
466
- description="Please map fields you want to use from both apps"
467
- />
468
- <div>
469
- ${loading || rootDataLoading || dynamicDataLoading
470
- ? html`<div class=${styles.loader}><${LargeLoader} /></div>`
471
- : html`
472
- <div class=${styles.mappingWrap}>
473
- ${html`
474
- <div class=${styles.mappingRow}>
475
- <div class=${styles.mappingHeaderItem}>
476
- <img
477
- src=${props.stepMapping[props.stepId].step.activity.app
478
- .icon_url}
479
- />
480
- <div>
481
- ${`${
482
- props.stepMapping[props.stepId].step.activity.app.name
483
- } Field`}
484
- </div>
485
- </div>
486
- ${html`<div class=${styles.sampleData}>Sample Data</div>`}
487
- <div class=${styles.mappingHeaderItem}>
488
- <img src=${triggerAppInfo?.icon_url} />
489
- <div>${`${triggerAppInfo.name} Field`}</div>
490
- </div>
491
- ${isReadOnly && html`<div class=${styles.tagColumn}></div>`}
492
- </div>`}
493
- ${dynamicItems.map((el, itemIndex) => {
494
- const slug = el.id || '';
495
- const ele = props.stepDataMapping[props.stepId][el.fieldId];
496
- let isFieldValueChanged = false;
497
- let selectVal;
498
- let parsedVal: string | Record<string, string | number>;
499
- if (ele) {
500
- if (ele.isDynamic) {
501
- parsedVal = ele.objectValue as Record<
502
- string,
503
- string | number
504
- >;
505
- if (ele.changedDynamicFields) {
506
- isFieldValueChanged = ele.changedDynamicFields.includes(
507
- slug,
508
- );
509
- }
510
- } else {
511
- parsedVal = ele.value?.slice(1, -1) as string;
512
- }
513
- if (!ele.isDynamic && parsedVal) {
514
- selectVal = parsedVal;
515
- isFieldValueChanged = ele.isChanged;
516
- } else if (
517
- el.id &&
518
- ele.isDynamic &&
519
- ele.objectValue &&
520
- (parsedVal as Record<string, string | number>)[slug]
521
- ) {
522
- selectVal = `${
523
- (parsedVal as Record<string, string | number>)[slug]
524
- }`.slice(1, -1);
525
- }
526
- }
527
- return html`
528
- <div class=${styles.mappingRow}>
529
- <div class=${styles.title}>
530
- ${el.title}${ele?.isRequired && html`<span>*</span>`}
531
- </div>
532
- ${html`
533
- <div class=${styles.sampleData}>
534
- ${props.dynamicFieldData &&
535
- selectVal &&
536
- (props.dynamicFieldData || {})[
537
- `{${selectVal}}`
538
- ]?.map((sample: string | Record<string, string>) =>
539
- sample ? html`<pre>${sample}</pre>` : html``,
540
- )}
541
- </div>
542
- `}
543
- <div class=${styles.selectBox}>
544
- ${html`
545
- <${Select}
546
- ariaLabel="Map a value"
547
- placeholder="Please map a value"
548
- options=${Array.isArray(props.activityOutputData)
549
- ? props.activityOutputData?.map((item) => ({
550
- key: item.value,
551
- label: item.text,
552
- }))
553
- : []}
554
- value=${selectVal}
555
- isRequired=${ele?.isRequired}
556
- showStepValidation=${props.showStepValidation}
557
- showUnselectedValue=${true}
558
- unselectedText="Skip"
559
- onChange=${(index: number) =>
560
- onMappingValueSelected(
561
- index,
562
- el,
563
- ele?.isRequired ?? false,
564
- itemIndex,
565
- )}
566
- isReadOnly=${isReadOnly}
567
- ><//>
568
- `}
569
- ${false && html`
570
- <${MultipurposeField}
571
- activityOutputData=${arrayToNestedJSONWithFirstValue(props.activityOutputData, props.dynamicFieldData)}
572
- placeholder=${'Please map a value'}
573
- value=${selectVal}
574
- type=${`TEXT`}
575
- isMappable=${true}
576
- allowTagsInText=${true}
577
- />
578
- `}
579
- ${false && html`<${ListBox}
580
- ariaLabel="Map a value"
581
- placeholder="Please map a value"
582
- showStepValidation=${props.showStepValidation}
583
- isReadOnly=${isReadOnly}
584
- value=${selectVal}
585
- onChange=${(selectedValue: string) => {
586
- const index = (props.activityOutputData || []).findIndex(obj => obj.value === selectedValue);
587
- onMappingValueSelected(
588
- index,
589
- el,
590
- ele?.isRequired ?? false,
591
- itemIndex,
592
- );
593
- }}
594
- items=${Array.isArray(props.activityOutputData)
595
- ? props.activityOutputData?.map((item) => ({
596
- id: item.value,
597
- value: item.text,
598
- }))
599
- : []}
600
- ><//>`}
601
- </div>
602
- ${isReadOnly &&
603
- html`<div class=${styles.tagColumn}>
604
- ${isFieldValueChanged &&
605
- html`<${Tag} label="Changed" />`}
606
- </div>`}
607
- </div>
608
- `;
609
- })}
610
- <div class=${styles.mappingInfo}>
611
- <div>
612
- <span>Mapped</span>
613
- <span
614
- >${fieldsRef.length}${' '}
615
- field${fieldsRef.length !== 1 ? 's' : ''}</span
616
- >
617
- </div>
618
- <div>
619
- <span>Ignored</span>
620
- <span
621
- >${dynamicItems.length - fieldsRef.length}${' '}
622
- field${dynamicItems.length - fieldsRef.length !== 1
623
- ? 's'
624
- : ''}</span
625
- >
626
- </div>
627
- </div>
628
- </div>
629
- `}
630
- </div>
631
- </div>
632
- `;
633
- };
634
-
635
- export default connect<MappingUiProps, unknown, StoreType, unknown>(
636
- [
637
- 'stepState',
638
- 'genericData',
639
- 'stepMapping',
640
- 'stepDataMapping',
641
- 'activityOutputData',
642
- 'dynamicFieldData',
643
- 'stepDataMapping',
644
- 'parentChildMapping',
645
- 'userConfig',
646
- 'conditionalFieldMapping',
647
- ],
648
- actionFunctions,
649
- )(MappingUI);