@integry/sdk 4.5.2 → 4.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/launch.json +2 -2
- package/THIRD_PARTY_LICENSES +0 -37
- package/dist/esm/index.csm.d.ts +12 -2
- package/dist/esm/index.csm.js +7262 -1
- package/dist/umd/index.umd.d.ts +9 -1
- package/dist/umd/index.umd.js +7262 -1
- package/jest.config.cjs +10 -0
- package/package.json +10 -4
- package/src/components/AddTagButton/index.ts +23 -0
- package/src/components/BasicSelect/index.ts +114 -0
- package/src/components/BasicSelect/styles.module.scss +44 -0
- package/src/components/Button/index.ts +94 -0
- package/src/components/Button/styles.module.scss +152 -0
- package/src/components/CheckboxGroup/Checkbox.ts +104 -0
- package/src/components/CheckboxGroup/index.ts +190 -0
- package/src/components/CheckboxGroup/styles.module.scss +63 -0
- package/src/components/CollapsedMenu/index.ts +101 -0
- package/src/components/CollapsedMenu/styles.module.scss +46 -0
- package/src/components/ConfigureFieldWrapper/index.ts +85 -0
- package/src/components/ConfigureFieldWrapper/styles.module.scss +57 -0
- package/src/components/EditableText/index.ts +121 -0
- package/src/components/EditableText/styles.module.scss +38 -0
- package/src/components/EditableTextArea/index.ts +143 -0
- package/src/components/EditableTextArea/styles.module.scss +91 -0
- package/src/components/ErrorMessage/index.ts +16 -0
- package/src/components/ErrorMessage/styles.module.scss +19 -0
- package/src/components/ErrorPage/index.ts +42 -0
- package/src/components/ErrorPage/styles.module.scss +26 -0
- package/src/components/Footer/index.ts +41 -0
- package/src/components/Footer/styles.module.scss +40 -0
- package/src/components/HTMLContent/index.tsx +275 -0
- package/src/components/HTMLContent/styles.module.scss +3 -0
- package/src/components/InfoBox/index.ts +48 -0
- package/src/components/InfoBox/styles.module.scss +21 -0
- package/src/components/Input/BaseInput/index.ts +170 -0
- package/src/components/Input/BaseInput/styles.module.scss +94 -0
- package/src/components/Input/DateInput/index.ts +103 -0
- package/src/components/Input/DateInput/styles.module.scss +50 -0
- package/src/components/Input/Input/index.ts +206 -0
- package/src/components/Input/Input/styles.module.scss +14 -0
- package/src/components/Input/PasswordInput/index.ts +164 -0
- package/src/components/Input/PasswordInput/styles.module.scss +37 -0
- package/src/components/Input/index.ts +7 -0
- package/src/components/Label/index.ts +61 -0
- package/src/components/Label/styles.module.scss +41 -0
- package/src/components/LargeLoader/index.ts +25 -0
- package/src/components/LargeLoader/styles.module.scss +16 -0
- package/src/components/Listbox/ListBoxItem.ts +57 -0
- package/src/components/Listbox/index.ts +479 -0
- package/src/components/Listbox/styles.module.scss +197 -0
- package/src/components/Loader/index.ts +25 -0
- package/src/components/Loader/styles.module.scss +16 -0
- package/src/components/MediaGallery/MediaGalleryModal.ts +82 -0
- package/src/components/MediaGallery/MediaSlider.ts +76 -0
- package/src/components/MediaGallery/index.ts +92 -0
- package/src/components/MediaGallery/styles.module.scss +156 -0
- package/src/components/MediaUpload/index.ts +233 -0
- package/src/components/MediaUpload/styles.module.scss +118 -0
- package/src/components/Modal/index.ts +87 -0
- package/src/components/Modal/styles.module.scss +441 -0
- package/src/components/MultipurposeField/Dropdown/ListBoxItem.tsx +58 -0
- package/src/components/MultipurposeField/Dropdown/index.tsx +981 -0
- package/src/components/MultipurposeField/Dropdown/styles.module.scss +208 -0
- package/src/components/MultipurposeField/TagMenu/index.ts +384 -0
- package/src/components/MultipurposeField/TagMenu/styles.module.scss +136 -0
- package/src/components/MultipurposeField/TagOptions/index.tsx +83 -0
- package/src/components/MultipurposeField/TagOptions/styles.module.scss +95 -0
- package/src/components/MultipurposeField/index.tsx +687 -0
- package/src/components/MultipurposeField/styles.module.scss +56 -0
- package/src/components/NewModal/index.ts +69 -0
- package/src/components/NewModal/styles.module.scss +70 -0
- package/src/components/OverflowTooltip/index.tsx +59 -0
- package/src/components/PopUp/ConfirmationPopUp/index.ts +58 -0
- package/src/components/PopUp/ConfirmationPopUp/styles.module.scss +49 -0
- package/src/components/PopUp/SuccessPopUp/index.ts +62 -0
- package/src/components/PopUp/SuccessPopUp/styles.module.scss +38 -0
- package/src/components/RadioGroup/Radio.ts +129 -0
- package/src/components/RadioGroup/index.ts +169 -0
- package/src/components/RadioGroup/styles.module.scss +81 -0
- package/src/components/Search/index.ts +69 -0
- package/src/components/Search/styles.module.scss +149 -0
- package/src/components/TabBar/Tab.ts +33 -0
- package/src/components/TabBar/index.ts +64 -0
- package/src/components/TabBar/styles.module.scss +43 -0
- package/src/components/Tag/index.ts +29 -0
- package/src/components/Tag/styles.module.scss +57 -0
- package/src/components/TextArea/index.ts +172 -0
- package/src/components/TextArea/styles.module.scss +70 -0
- package/src/components/TextContent/index.tsx +128 -0
- package/src/components/TextContent/styles.module.scss +6 -0
- package/src/components/ThreeDotLoader/index.ts +39 -0
- package/src/components/ThreeDotLoader/styles.module.scss +41 -0
- package/src/components/TimeInput/index.ts +129 -0
- package/src/components/TimeInput/styles.module.scss +16 -0
- package/src/components/Toggle/index.ts +34 -0
- package/src/components/Toggle/styles.module.scss +56 -0
- package/src/components/Toggle-v2/index.ts +40 -0
- package/src/components/Toggle-v2/styles.module.scss +86 -0
- package/src/components/Tooltip/index.ts +271 -0
- package/src/components/Tooltip/styles.module.scss +105 -0
- package/src/components/form/ObjectField/index.ts +364 -0
- package/src/components/form/ObjectField/styles.module.scss +103 -0
- package/src/components/form/index.ts +3 -0
- package/src/contexts/AppContext.ts +12 -0
- package/src/declaration.d.ts +7 -0
- package/src/extensions/HMAC.ts +25 -0
- package/src/extensions/IntegryAPIError.ts +19 -0
- package/src/features/common/AccountDropdown/index.ts +291 -0
- package/src/features/common/AccountDropdown/styles.module.scss +19 -0
- package/src/features/common/ActionForm/index.ts +1818 -0
- package/src/features/common/ActionForm/styles.module.scss +23 -0
- package/src/features/common/AppCard/index.ts +207 -0
- package/src/features/common/AppCard/styles.module.scss +117 -0
- package/src/features/common/AppCardCompact/index.ts +189 -0
- package/src/features/common/AppCardCompact/styles.module.scss +141 -0
- package/src/features/common/AuthSelector/index.ts +537 -0
- package/src/features/common/AuthSelector/styles.module.scss +161 -0
- package/src/features/common/AuthSelectorCompact/index.ts +706 -0
- package/src/features/common/AuthSelectorCompact/styles.module.scss +219 -0
- package/src/features/common/AuthSelectorDropdown/index.ts +704 -0
- package/src/features/common/AuthSelectorDropdown/styles.module.scss +361 -0
- package/src/features/common/DynamicField/index.ts +229 -0
- package/src/features/common/DynamicField/styles.module.scss +67 -0
- package/src/features/common/DynamicTypedField/index.ts +217 -0
- package/src/features/common/DynamicTypedField/styles.module.scss +67 -0
- package/src/features/common/FunctionForm/index.ts +862 -0
- package/src/features/common/FunctionForm/styles.module.scss +163 -0
- package/src/features/common/MappingUI/index.ts +649 -0
- package/src/features/common/MappingUI/styles.module.scss +121 -0
- package/src/features/common/MarketplaceAppCard/index.ts +279 -0
- package/src/features/common/MarketplaceAppCard/styles.module.scss +231 -0
- package/src/features/common/MarketplaceAppCardCompact/index.ts +283 -0
- package/src/features/common/MarketplaceAppCardCompact/styles.module.scss +255 -0
- package/src/features/common/NewMappingUI/index.ts +515 -0
- package/src/features/common/NewMappingUI/styles.module.scss +113 -0
- package/src/features/common/RequestAppWidget/RequestAppModal/index.ts +67 -0
- package/src/features/common/RequestAppWidget/RequestAppModal/styles.module.scss +23 -0
- package/src/features/common/RequestAppWidget/index.ts +48 -0
- package/src/features/common/RequestAppWidget/request-app-form.ts +89 -0
- package/src/features/common/RequestAppWidget/styles.module.scss +43 -0
- package/src/features/common/SectionField/index.ts +272 -0
- package/src/features/common/SectionField/styles.module.scss +67 -0
- package/src/features/common/Step/index.ts +827 -0
- package/src/features/common/Step/styles.module.scss +12 -0
- package/src/features/common/StepNavigation/CollapsedSteps.ts +125 -0
- package/src/features/common/StepNavigation/NavItem.ts +111 -0
- package/src/features/common/StepNavigation/index.ts +257 -0
- package/src/features/common/StepNavigation/styles.module.scss +117 -0
- package/src/features/common/Steps/index.ts +1139 -0
- package/src/features/common/Steps/styles.module.scss +314 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/compactStyles.module.scss +383 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/flow-instance.tsx +367 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/flowCard.tsx +194 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/flowCardCompact.tsx +389 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/flowInstanceCompact.tsx +577 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/index.tsx +83 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/styles.module.scss +212 -0
- package/src/features/containers/AppFlowContainer/AppFlowWrap/app-page-loader.tsx +45 -0
- package/src/features/containers/AppFlowContainer/AppFlowWrap/index.tsx +1081 -0
- package/src/features/containers/AppFlowContainer/AppFlowWrap/styles.module.scss +452 -0
- package/src/features/containers/AppFlowContainer/Authentication/index.ts +610 -0
- package/src/features/containers/AppFlowContainer/Authentication/styles.module.scss +468 -0
- package/src/features/containers/AppFlowContainer/index.ts +114 -0
- package/src/features/containers/AppPageContainer/AppPage/index.tsx +262 -0
- package/src/features/containers/AppPageContainer/AppPage/styles.module.scss +120 -0
- package/src/features/containers/AppPageContainer/IntegrationCard/index.ts +165 -0
- package/src/features/containers/AppPageContainer/IntegrationCard/styles.module.scss +81 -0
- package/src/features/containers/AppPageContainer/index.tsx +93 -0
- package/src/features/containers/AppPageContainer/styles.module.scss +0 -0
- package/src/features/containers/AppsForFlows/index.ts +161 -0
- package/src/features/containers/AppsForFlows/styles.module.scss +280 -0
- package/src/features/containers/AppsForFlowsCompact/index.ts +161 -0
- package/src/features/containers/AppsForFlowsCompact/styles.module.scss +279 -0
- package/src/features/containers/AuthSetupContainer/AppSelection.ts +73 -0
- package/src/features/containers/AuthSetupContainer/AuthTypeSelection.ts +67 -0
- package/src/features/containers/AuthSetupContainer/Footer.ts +32 -0
- package/src/features/containers/AuthSetupContainer/Header.ts +39 -0
- package/src/features/containers/AuthSetupContainer/PostAdditionPopup.ts +27 -0
- package/src/features/containers/AuthSetupContainer/index.ts +349 -0
- package/src/features/containers/AuthSetupContainer/styles.module.scss +229 -0
- package/src/features/containers/FlowSetupContainer/index.ts +390 -0
- package/src/features/containers/FlowSetupContainer/styles.module.scss +18 -0
- package/src/features/containers/MarkeplaceApps/index.ts +574 -0
- package/src/features/containers/MarkeplaceApps/styles.module.scss +559 -0
- package/src/features/containers/MarketplaceAppsCompact/index.ts +576 -0
- package/src/features/containers/MarketplaceAppsCompact/styles.module.scss +546 -0
- package/src/features/containers/MarketplaceAppsContainer/index.ts +83 -0
- package/src/features/containers/MarketplaceContainer/AppCard/index.ts +91 -0
- package/src/features/containers/MarketplaceContainer/AppCard/styles.module.scss +66 -0
- package/src/features/containers/MarketplaceContainer/AppListing/index.ts +34 -0
- package/src/features/containers/MarketplaceContainer/AppListing/styles.module.scss +10 -0
- package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/index.ts +132 -0
- package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/styles.module.scss +117 -0
- package/src/features/containers/MarketplaceContainer/index.ts +242 -0
- package/src/features/containers/MarketplaceContainer/styles.module.scss +84 -0
- package/src/features/containers/SDKContainer/index.ts +817 -0
- package/src/features/containers/SDKContainer/styles.module.scss +266 -0
- package/src/features/containers/SDKDebugContainer/index.ts +137 -0
- package/src/features/containers/SDKDebugContainer/styles.module.scss +37 -0
- package/src/features/containers/SDKFailedContainer/index.ts +117 -0
- package/src/features/containers/SDKFailedContainer/styles.module.scss +57 -0
- package/src/features/integrations/IntegrationRow/Icons.ts +77 -0
- package/src/features/integrations/IntegrationRow/index.ts +129 -0
- package/src/features/integrations/IntegrationRow/styles.module.scss +62 -0
- package/src/features/integrations/IntegrationsHeader/index.ts +34 -0
- package/src/features/integrations/IntegrationsHeader/styles.module.scss +47 -0
- package/src/features/integrations/IntegrationsList/index.ts +252 -0
- package/src/features/integrations/IntegrationsList/styles.module.scss +67 -0
- package/src/features/templates/Template/index.ts +295 -0
- package/src/features/templates/Template/styles.module.scss +226 -0
- package/src/features/templates/TemplatesView/index.ts +368 -0
- package/src/features/templates/TemplatesView/styles.module.scss +71 -0
- package/src/features/templates/TemplatesViewCompact/index.ts +364 -0
- package/src/features/templates/TemplatesViewCompact/styles.module.scss +141 -0
- package/src/hooks/useAutosizeTextArea.ts +22 -0
- package/src/hooks/useCustomRef.ts +13 -0
- package/src/hooks/useDebounce.ts +17 -0
- package/src/hooks/useElementResize.ts +40 -0
- package/src/hooks/useEventListener.ts +44 -0
- package/src/hooks/useHover.ts +40 -0
- package/src/hooks/useOnClickOutside.ts +32 -0
- package/src/index.ts +2051 -0
- package/src/index.umd.ts +13 -0
- package/src/interfaces/index.ts +924 -0
- package/src/modules/api/index.ts +1315 -0
- package/src/modules/api/responseHandler.ts +38 -0
- package/src/modules/event-emitter/index.ts +72 -0
- package/src/modules/event-emitter/runners/abstract.ts +21 -0
- package/src/modules/event-emitter/runners/default.ts +11 -0
- package/src/modules/event-emitter/runners/ntimes.ts +28 -0
- package/src/modules/event-emitter/types.ts +34 -0
- package/src/store/actionFunctions.ts +1573 -0
- package/src/store/index.ts +17 -0
- package/src/store/initialState.ts +58 -0
- package/src/stories/Button.stories.tsx +83 -0
- package/src/stories/Checkbox/Checkbox.stories.tsx +41 -0
- package/src/stories/Checkbox/CheckboxGroup.stories.tsx +46 -0
- package/src/stories/EditableText.stories.tsx +35 -0
- package/src/stories/Input/BaseInput.stories.tsx +48 -0
- package/src/stories/Input/DateInput.stories.tsx +28 -0
- package/src/stories/Input/Input.stories.tsx +24 -0
- package/src/stories/Input/PasswordInput.stories.tsx +26 -0
- package/src/stories/Introduction.stories.mdx +211 -0
- package/src/stories/Label.stories.tsx +27 -0
- package/src/stories/Listbox.stories.tsx +122 -0
- package/src/stories/Radio/Radio.stories.tsx +39 -0
- package/src/stories/Radio/RadioGroup.stories.tsx +46 -0
- package/src/stories/StepNavigation/NavItem.stories.tsx +31 -0
- package/src/stories/StepNavigation/StepNavigation.stories.tsx +50 -0
- package/src/stories/TabBar.stories.tsx +31 -0
- package/src/stories/TextArea.stories.tsx +23 -0
- package/src/stories/TimeInput.stories.tsx +37 -0
- package/src/stories/Toggle.stories.tsx +33 -0
- package/src/stories/assets/code-brackets.svg +1 -0
- package/src/stories/assets/colors.svg +1 -0
- package/src/stories/assets/comments.svg +1 -0
- package/src/stories/assets/direction.svg +1 -0
- package/src/stories/assets/flow.svg +1 -0
- package/src/stories/assets/plugin.svg +1 -0
- package/src/stories/assets/repo.svg +1 -0
- package/src/stories/assets/stackalt.svg +1 -0
- package/src/types/index.ts +293 -0
- package/src/types/store.ts +366 -0
- package/src/types/utils.ts +19 -0
- package/src/utils/ActivityOutputUtils.ts +163 -0
- package/src/utils/common.ts +20 -0
- package/src/utils/copyToClipboard.ts +24 -0
- package/src/utils/datetime.ts +101 -0
- package/src/utils/getUrlParam.ts +11 -0
- package/src/utils/isAuthMessage.ts +16 -0
- package/src/utils/isBrowser.ts +1 -0
- package/src/utils/jsonEncodeDecode.ts +15 -0
- package/src/utils/objectUtils.ts +116 -0
- package/src/utils/popup.ts +30 -0
- package/src/utils/searchJson.ts +51 -0
- package/src/utils/stepUtils.ts +45 -0
- package/src/utils/truncate.ts +6 -0
- package/test/setup.ts +1 -0
- package/vitest.config.ts +10 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { StoreType } from '@/types/store';
|
|
2
|
+
|
|
3
|
+
function makeHumanReadable(str: string) {
|
|
4
|
+
// Step 1: Add space before capital letters not preceded by a dot
|
|
5
|
+
const formattedStr = str.replace(/(?<!\.)[A-Z]/g, (match) => `${match}`);
|
|
6
|
+
|
|
7
|
+
// Step 2: Capitalize the first letter after a dot or the first character
|
|
8
|
+
const capitalizedStr = formattedStr.replace(/(?:^|\.)\s*\w/g, (match) =>
|
|
9
|
+
match.toUpperCase(),
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
// Step 3: Return the updated string
|
|
13
|
+
return capitalizedStr;
|
|
14
|
+
}
|
|
15
|
+
export function JSONToActivityOutputData(
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
obj: any,
|
|
18
|
+
parentKey = '',
|
|
19
|
+
sourceStepKey = '',
|
|
20
|
+
): StoreType['activityOutputData'] {
|
|
21
|
+
const options: StoreType['activityOutputData'] = [];
|
|
22
|
+
Object.keys(obj).forEach((key) => {
|
|
23
|
+
if (key in obj) {
|
|
24
|
+
const value = obj[key];
|
|
25
|
+
const currentKey = parentKey ? `${parentKey}.${key}` : key;
|
|
26
|
+
if (value && typeof value === 'object') {
|
|
27
|
+
const nestedOptions = JSONToActivityOutputData(
|
|
28
|
+
value,
|
|
29
|
+
currentKey,
|
|
30
|
+
sourceStepKey,
|
|
31
|
+
);
|
|
32
|
+
if (nestedOptions) {
|
|
33
|
+
options.push({
|
|
34
|
+
value: sourceStepKey
|
|
35
|
+
? `${sourceStepKey}${currentKey}`
|
|
36
|
+
: `${currentKey}`,
|
|
37
|
+
text: makeHumanReadable(currentKey),
|
|
38
|
+
});
|
|
39
|
+
options.push(...nestedOptions);
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
options.push({
|
|
43
|
+
value: sourceStepKey
|
|
44
|
+
? `${sourceStepKey}${currentKey}`
|
|
45
|
+
: `${currentKey}`,
|
|
46
|
+
text: makeHumanReadable(currentKey),
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return options;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function JSONToDynamicFieldData(
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
+
obj: any,
|
|
58
|
+
parentKey = '',
|
|
59
|
+
sourceStepKey = '',
|
|
60
|
+
): StoreType['dynamicFieldData'] {
|
|
61
|
+
let result: StoreType['dynamicFieldData'] = {};
|
|
62
|
+
Object.keys(obj).forEach((key) => {
|
|
63
|
+
if (key in obj) {
|
|
64
|
+
let currentKey = sourceStepKey ? `${sourceStepKey}` : '';
|
|
65
|
+
currentKey += parentKey ? `${parentKey}.${key}` : key;
|
|
66
|
+
if (
|
|
67
|
+
obj[key] &&
|
|
68
|
+
typeof obj[key] === 'object' &&
|
|
69
|
+
!Array.isArray(obj[key])
|
|
70
|
+
) {
|
|
71
|
+
const flattened = JSONToDynamicFieldData(obj[key], currentKey);
|
|
72
|
+
if (result) {
|
|
73
|
+
try {
|
|
74
|
+
result[currentKey] = [JSON.stringify(obj[key])];
|
|
75
|
+
} catch (e) {
|
|
76
|
+
result[currentKey] = [''];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
result = { ...result, ...flattened };
|
|
80
|
+
} else if (result) {
|
|
81
|
+
result[currentKey] = [obj[key]];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function removeCurlyBraces(value: string): string {
|
|
89
|
+
value.replace(/^{(.*)}$/, '$1');
|
|
90
|
+
return value;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function isNotJSON(obj: any): boolean {
|
|
94
|
+
try {
|
|
95
|
+
if (Array.isArray(obj) && obj.length > 0 && typeof obj[0] === 'object') {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
JSON.parse(obj);
|
|
99
|
+
if (Number(obj)) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
} catch (e) {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function arrayToNestedJSONWithFirstValue(
|
|
109
|
+
array: any,
|
|
110
|
+
valueObj: any,
|
|
111
|
+
): any {
|
|
112
|
+
let tempValueObj: any = {};
|
|
113
|
+
let arrayUpdated = [];
|
|
114
|
+
if (array && Array.isArray(array)) {
|
|
115
|
+
arrayUpdated = array;
|
|
116
|
+
}
|
|
117
|
+
Object.keys(valueObj || {}).forEach((i) => {
|
|
118
|
+
const key = removeCurlyBraces(i);
|
|
119
|
+
tempValueObj = {
|
|
120
|
+
...tempValueObj,
|
|
121
|
+
[key]: valueObj[i] || '',
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
let flatForm = {};
|
|
125
|
+
(arrayUpdated || []).forEach((arr: any) => {
|
|
126
|
+
flatForm = {
|
|
127
|
+
...flatForm,
|
|
128
|
+
[arr.text]: valueObj[arr.value] || '',
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
const result = {};
|
|
133
|
+
(arrayUpdated || []).forEach((item: any) => {
|
|
134
|
+
if (!item.text || !item.value) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const keys = item.text.split('.');
|
|
138
|
+
let currentLevel: any = result;
|
|
139
|
+
keys.forEach((key: any, index: any) => {
|
|
140
|
+
if (!currentLevel[key]) {
|
|
141
|
+
if (index === keys.length - 1) {
|
|
142
|
+
if (tempValueObj[item.value]) {
|
|
143
|
+
if (
|
|
144
|
+
tempValueObj[item.value][0] &&
|
|
145
|
+
isNotJSON(tempValueObj[item.value][0])
|
|
146
|
+
) {
|
|
147
|
+
// eslint-disable-next-line prefer-destructuring
|
|
148
|
+
currentLevel[key] = tempValueObj[item.value][0] || '';
|
|
149
|
+
} else {
|
|
150
|
+
currentLevel[key] = '';
|
|
151
|
+
}
|
|
152
|
+
} else {
|
|
153
|
+
currentLevel[key] = '';
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
currentLevel[key] = {};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
currentLevel = currentLevel[key];
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const isScrolledIntoView = (
|
|
2
|
+
el: HTMLElement,
|
|
3
|
+
scrollableDivId: string,
|
|
4
|
+
): boolean => {
|
|
5
|
+
const rect = el.getBoundingClientRect();
|
|
6
|
+
// const elemTop = rect.top;
|
|
7
|
+
const elemBottom = rect.bottom;
|
|
8
|
+
|
|
9
|
+
const scrollableContainer = document.getElementById(scrollableDivId);
|
|
10
|
+
|
|
11
|
+
const containerRect = scrollableContainer?.getBoundingClientRect();
|
|
12
|
+
const docViewTop = containerRect?.top;
|
|
13
|
+
const docViewBottom = containerRect?.bottom;
|
|
14
|
+
|
|
15
|
+
if (docViewTop && docViewBottom) {
|
|
16
|
+
return elemBottom <= docViewBottom && elemBottom >= docViewTop;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return true;
|
|
20
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const copyStringToClipboard = (str: string) => {
|
|
2
|
+
if (!navigator.clipboard) {
|
|
3
|
+
// Create new element
|
|
4
|
+
const el = document.createElement('textarea');
|
|
5
|
+
// Set value (string to be copied)
|
|
6
|
+
el.value = str;
|
|
7
|
+
// Set non-editable to avoid focus and move outside of view
|
|
8
|
+
el.setAttribute('readonly', '');
|
|
9
|
+
|
|
10
|
+
el.style.position = 'absolute';
|
|
11
|
+
el.style.left = '-9999px';
|
|
12
|
+
document.body.appendChild(el);
|
|
13
|
+
// Select text inside element
|
|
14
|
+
el.select();
|
|
15
|
+
// Copy text to clipboard
|
|
16
|
+
document.execCommand('copy');
|
|
17
|
+
// Remove temporary element
|
|
18
|
+
document.body.removeChild(el);
|
|
19
|
+
} else {
|
|
20
|
+
navigator.clipboard.writeText(str).catch(() => {
|
|
21
|
+
console.error('Could not copy to clipboard'); // error
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param length Array length to generate
|
|
5
|
+
* @returns String array like ['00', '01', '02' ...]
|
|
6
|
+
*/
|
|
7
|
+
function generateDoubleDigitStringArr(length: number): string[] {
|
|
8
|
+
return Array.from({ length }, (_, i) => {
|
|
9
|
+
if (i < 10) return `0${i}`;
|
|
10
|
+
return `${i + 1}`;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param date Input date
|
|
17
|
+
* @returns {string} Date string formatted as YYYY-MM-DD
|
|
18
|
+
*/
|
|
19
|
+
function getDateFormat(date: Date): string {
|
|
20
|
+
return new Date(date.getTime() - date.getTimezoneOffset() * 60000)
|
|
21
|
+
.toISOString()
|
|
22
|
+
.split('T')[0];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const timeAgo = (date: Date) => {
|
|
26
|
+
const intervals = [
|
|
27
|
+
{ label: 'year', seconds: 31536000 },
|
|
28
|
+
{ label: 'month', seconds: 2592000 },
|
|
29
|
+
{ label: 'day', seconds: 86400 },
|
|
30
|
+
{ label: 'hour', seconds: 3600 },
|
|
31
|
+
{ label: 'minute', seconds: 60 },
|
|
32
|
+
{ label: 'A few second', seconds: 0 },
|
|
33
|
+
];
|
|
34
|
+
const seconds = Math.floor((Date.now() - date.getTime()) / 1000);
|
|
35
|
+
let interval = intervals.find((i) => i.seconds <= seconds);
|
|
36
|
+
if (seconds && interval === undefined) {
|
|
37
|
+
interval = intervals.find((i) => i.seconds === 0)
|
|
38
|
+
}
|
|
39
|
+
if (interval !== undefined) { // interval can be 0 seconds, need to explicitly check undefined
|
|
40
|
+
let count = Math.floor(seconds / interval.seconds);
|
|
41
|
+
if (!Number.isInteger(count)) count = 0;
|
|
42
|
+
return `${count > 0 ? count : ''} ${interval.label}${
|
|
43
|
+
count !== 1 ? 's' : ''
|
|
44
|
+
} ago`;
|
|
45
|
+
}
|
|
46
|
+
return `Cannot be formatted with interval ${interval}`;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const convertDateToStandard = (datetime: string) => {
|
|
50
|
+
const dateString = datetime;
|
|
51
|
+
try {
|
|
52
|
+
const dateObj = new Date(datetime);
|
|
53
|
+
return dateObj.toLocaleString('en-US', {
|
|
54
|
+
month: 'short',
|
|
55
|
+
day: '2-digit',
|
|
56
|
+
hour: '2-digit',
|
|
57
|
+
minute: '2-digit'
|
|
58
|
+
});
|
|
59
|
+
} catch (err) {
|
|
60
|
+
console.error(err);
|
|
61
|
+
}
|
|
62
|
+
return dateString;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const calculateDatetimeDifference = (datetimeString1: string | undefined, datetimeString2: string): {
|
|
66
|
+
days: number;
|
|
67
|
+
hours: number;
|
|
68
|
+
minutes: number;
|
|
69
|
+
seconds: number;
|
|
70
|
+
milliseconds: number;
|
|
71
|
+
} => {
|
|
72
|
+
// Parse the datetime strings into Date objects
|
|
73
|
+
const date1 = new Date(datetimeString1 || new Date().toISOString());
|
|
74
|
+
const date2 = new Date(datetimeString2);
|
|
75
|
+
|
|
76
|
+
// Calculate the time difference in milliseconds
|
|
77
|
+
const timeDifference = Math.abs(date1.getTime() - date2.getTime());
|
|
78
|
+
|
|
79
|
+
// Convert the time difference to a more human-readable format
|
|
80
|
+
const millisecondsPerSecond = 1000;
|
|
81
|
+
const millisecondsPerMinute = 60 * millisecondsPerSecond;
|
|
82
|
+
const millisecondsPerHour = 60 * millisecondsPerMinute;
|
|
83
|
+
const millisecondsPerDay = 24 * millisecondsPerHour;
|
|
84
|
+
|
|
85
|
+
const days = Math.floor(timeDifference / millisecondsPerDay);
|
|
86
|
+
const hours = Math.floor((timeDifference % millisecondsPerDay) / millisecondsPerHour);
|
|
87
|
+
const minutes = Math.floor((timeDifference % millisecondsPerHour) / millisecondsPerMinute);
|
|
88
|
+
const seconds = Math.floor((timeDifference % millisecondsPerMinute) / millisecondsPerSecond);
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
days,
|
|
92
|
+
hours,
|
|
93
|
+
minutes,
|
|
94
|
+
seconds,
|
|
95
|
+
milliseconds: timeDifference % millisecondsPerSecond,
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
export { generateDoubleDigitStringArr, getDateFormat, timeAgo, convertDateToStandard, calculateDatetimeDifference };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
interface AuthData {
|
|
2
|
+
activity_name: string;
|
|
3
|
+
already_exists: boolean;
|
|
4
|
+
authorization_id: number;
|
|
5
|
+
user_identity: string;
|
|
6
|
+
external_id?: string;
|
|
7
|
+
app_id: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function isAuthMessage(
|
|
11
|
+
msg: MessageEvent<AuthData>,
|
|
12
|
+
): msg is MessageEvent<AuthData> {
|
|
13
|
+
return (msg as MessageEvent<AuthData>) !== undefined;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { isAuthMessage, AuthData };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default () => ![typeof window, typeof document].includes('undefined');
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const decodeJSON = (jsonString: string) => {
|
|
2
|
+
try {
|
|
3
|
+
return JSON.parse(jsonString);
|
|
4
|
+
} catch (e) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const encodeJSON = (json: never): string => {
|
|
10
|
+
try {
|
|
11
|
+
return JSON.stringify(json);
|
|
12
|
+
} catch (e) {
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
const get = (obj: any, path: string, defaultValue = undefined) => {
|
|
2
|
+
const travel = (regexp: any) =>
|
|
3
|
+
String.prototype.split
|
|
4
|
+
.call(path, regexp)
|
|
5
|
+
.filter(Boolean)
|
|
6
|
+
.reduce(
|
|
7
|
+
(res, key) => (res !== null && res !== undefined ? res[key] : res),
|
|
8
|
+
obj,
|
|
9
|
+
);
|
|
10
|
+
const result = travel(/[,[\]]+?/) || travel(/[,[\].]+?/);
|
|
11
|
+
return result === undefined || result === obj ? defaultValue : result;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const extractTags = (input: string): string[] => {
|
|
15
|
+
const regex = /\{([^}]+)\}/g;
|
|
16
|
+
const matches = input.match(regex);
|
|
17
|
+
|
|
18
|
+
if (matches) {
|
|
19
|
+
return matches.map((match) => match.slice(1, -1));
|
|
20
|
+
}
|
|
21
|
+
return [];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const extractTagsFromStepDataMapping = (
|
|
25
|
+
stepDataMapping: any,
|
|
26
|
+
): string[] => {
|
|
27
|
+
const tags: string[] = [];
|
|
28
|
+
Object.keys(stepDataMapping).forEach((stepId) => {
|
|
29
|
+
let skipStep = false;
|
|
30
|
+
Object.keys(stepDataMapping[stepId]).forEach((fieldId) => {
|
|
31
|
+
const field = stepDataMapping[stepId][fieldId];
|
|
32
|
+
if (field.machineName === 'integry_webhook_object') {
|
|
33
|
+
skipStep = true;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
if (!skipStep) {
|
|
37
|
+
Object.keys(stepDataMapping[stepId]).forEach((fieldId) => {
|
|
38
|
+
const field = stepDataMapping[stepId][fieldId];
|
|
39
|
+
if (
|
|
40
|
+
typeof field.value === 'string' &&
|
|
41
|
+
field.value.includes('{') &&
|
|
42
|
+
field.value.includes('}')
|
|
43
|
+
) {
|
|
44
|
+
tags.push(...extractTags(field.value));
|
|
45
|
+
} else if (
|
|
46
|
+
(field.value === null || field.value === '') &&
|
|
47
|
+
field.objectValue !== null
|
|
48
|
+
) {
|
|
49
|
+
Object.keys(field.objectValue).forEach((objectKey) => {
|
|
50
|
+
const objectFieldVal = field.objectValue[objectKey];
|
|
51
|
+
if (
|
|
52
|
+
objectFieldVal &&
|
|
53
|
+
objectFieldVal.includes('{') &&
|
|
54
|
+
objectFieldVal.includes('}')
|
|
55
|
+
) {
|
|
56
|
+
tags.push(...extractTags(objectFieldVal));
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
return tags;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const createMappedObject = (object: any, tags: string[]) => {
|
|
67
|
+
const result = {} as any;
|
|
68
|
+
|
|
69
|
+
tags.forEach((tag) => {
|
|
70
|
+
let currentObj = result;
|
|
71
|
+
const keyArray = tag.split('.');
|
|
72
|
+
const value = get(object, tag);
|
|
73
|
+
for (let i = 0; i < keyArray.length; i += 1) {
|
|
74
|
+
const key = keyArray[i];
|
|
75
|
+
if (i === keyArray.length - 1) {
|
|
76
|
+
// If it's the last key, assign the value
|
|
77
|
+
currentObj[key] = value;
|
|
78
|
+
} else if (currentObj[key]) {
|
|
79
|
+
currentObj = currentObj[key];
|
|
80
|
+
} else {
|
|
81
|
+
// Create an empty object or array if the next key is a number
|
|
82
|
+
currentObj[key] = Number.isNaN(Number(keyArray[i + 1])) ? {} : [];
|
|
83
|
+
currentObj = currentObj[key];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
return result;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const getIntegryObject = (triggerStep: any, userConfig: any): any => {
|
|
92
|
+
let objectPayload = {};
|
|
93
|
+
let objectName = '';
|
|
94
|
+
let integryObject = triggerStep?.template_fields.find(
|
|
95
|
+
(el: any) => el.activity_field?.machine_name === 'integry_webhook_object',
|
|
96
|
+
)?.default_value;
|
|
97
|
+
|
|
98
|
+
if (integryObject) {
|
|
99
|
+
try {
|
|
100
|
+
integryObject = integryObject.replaceAll('\\n', '');
|
|
101
|
+
const parsedIntegryObject = JSON.parse(integryObject);
|
|
102
|
+
objectName = parsedIntegryObject.name;
|
|
103
|
+
|
|
104
|
+
if (userConfig?.objects?.[parsedIntegryObject.name]) {
|
|
105
|
+
objectPayload = userConfig?.objects?.[parsedIntegryObject.name];
|
|
106
|
+
} else {
|
|
107
|
+
objectPayload = JSON.parse(parsedIntegryObject.payload);
|
|
108
|
+
}
|
|
109
|
+
} catch (e) {
|
|
110
|
+
// eslint-disable-next-line no-console
|
|
111
|
+
console.log('error parsing object.');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return { name: objectName, payload: objectPayload };
|
|
116
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param url Url to open in this popup window
|
|
4
|
+
* @param windowName Given name
|
|
5
|
+
* @param win Original window reference
|
|
6
|
+
* @param w Width in px
|
|
7
|
+
* @param h Height in px
|
|
8
|
+
* @returns Reference to the newly created popup window
|
|
9
|
+
*/
|
|
10
|
+
function openPopupWindow(
|
|
11
|
+
url: string,
|
|
12
|
+
windowName: string,
|
|
13
|
+
win: Window,
|
|
14
|
+
w: number,
|
|
15
|
+
h: number,
|
|
16
|
+
): Window | null {
|
|
17
|
+
if (win.top) {
|
|
18
|
+
const y = win.top.outerHeight / 2 + win.top.screenY - h / 2;
|
|
19
|
+
const x = win.top.outerWidth / 2 + win.top.screenX - w / 2;
|
|
20
|
+
(window as any).top.MyAltWindow = win.open(
|
|
21
|
+
url,
|
|
22
|
+
windowName,
|
|
23
|
+
`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=${w}, height=${h}, top=${y}, left=${x}`,
|
|
24
|
+
);
|
|
25
|
+
return (window as any).top.MyAltWindow
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { openPopupWindow };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const removeTextBetweenBraces = (str: string) => {
|
|
2
|
+
const braceIndex = str.indexOf('{');
|
|
3
|
+
if (braceIndex !== -1) {
|
|
4
|
+
return str.slice(braceIndex).replace(/\{[^}]*\}\s*/g, '');
|
|
5
|
+
}
|
|
6
|
+
return str.replace(/\{[^}]*\}\s*/g, '')
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const removeBraces = (str: string) => {
|
|
10
|
+
let tempStr = str;
|
|
11
|
+
// Remove starting "{"
|
|
12
|
+
tempStr = tempStr.replace(/^{\s*/, '');
|
|
13
|
+
|
|
14
|
+
// Remove ending "}"
|
|
15
|
+
tempStr = tempStr.replace(/\s*}$/, '');
|
|
16
|
+
|
|
17
|
+
return tempStr;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const searchJSON = (obj: any, searchTerm: any): any => {
|
|
21
|
+
let tempSearchTerm = searchTerm;
|
|
22
|
+
if (tempSearchTerm === '') {
|
|
23
|
+
return obj;
|
|
24
|
+
}
|
|
25
|
+
if (tempSearchTerm.includes('{') || tempSearchTerm.includes('}')) {
|
|
26
|
+
tempSearchTerm = removeBraces(tempSearchTerm);
|
|
27
|
+
}
|
|
28
|
+
let tempObj = {};
|
|
29
|
+
try {
|
|
30
|
+
Object.keys(obj).forEach((key) => {
|
|
31
|
+
if (typeof obj[key] === 'object' && obj[key] !== null) {
|
|
32
|
+
const tempNestedObj = searchJSON(obj[key], tempSearchTerm);
|
|
33
|
+
if (Object.keys(tempNestedObj).length > 0) {
|
|
34
|
+
tempObj = {
|
|
35
|
+
...tempObj,
|
|
36
|
+
[key]: tempNestedObj,
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
} else if (typeof obj[key] !== 'object' && key.toLowerCase().includes(tempSearchTerm.toLowerCase())) {
|
|
40
|
+
tempObj = {
|
|
41
|
+
...tempObj,
|
|
42
|
+
[key]: obj[key],
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error(error);
|
|
48
|
+
return obj;
|
|
49
|
+
}
|
|
50
|
+
return tempObj;
|
|
51
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/* eslint-disable import/no-cycle */
|
|
2
|
+
import { StoreType } from '@/types/store';
|
|
3
|
+
import { TemplateField } from '@/interfaces';
|
|
4
|
+
import { TagProps } from '@/components/Tag';
|
|
5
|
+
|
|
6
|
+
export const areParentValuesValid = (
|
|
7
|
+
stepId: number,
|
|
8
|
+
fieldConditions: {
|
|
9
|
+
value: string;
|
|
10
|
+
parentMachineName: string;
|
|
11
|
+
parentFieldId: number;
|
|
12
|
+
}[],
|
|
13
|
+
stepDataMapping: StoreType['stepDataMapping'],
|
|
14
|
+
) => {
|
|
15
|
+
let valid = false;
|
|
16
|
+
// check if all parent fields have values required to show the field
|
|
17
|
+
for (let index = 0; index < fieldConditions.length; index += 1) {
|
|
18
|
+
const { parentFieldId, value } = fieldConditions[index];
|
|
19
|
+
const parentField =
|
|
20
|
+
stepDataMapping[stepId] && stepDataMapping[stepId][parentFieldId];
|
|
21
|
+
if (parentField && parentField.value === value) {
|
|
22
|
+
valid = true;
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return valid;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const getFieldLabelTags = (
|
|
30
|
+
field: TemplateField,
|
|
31
|
+
isConfigMode = false,
|
|
32
|
+
) => {
|
|
33
|
+
const { is_hidden, is_default_value_auto_mapped } = field;
|
|
34
|
+
const tags: TagProps[] = [];
|
|
35
|
+
if (!isConfigMode) {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
if (is_hidden) {
|
|
39
|
+
tags.push({ label: 'Hidden', type: 'grey' });
|
|
40
|
+
}
|
|
41
|
+
if (is_default_value_auto_mapped) {
|
|
42
|
+
tags.push({ label: 'AI mapped', type: 'grey' });
|
|
43
|
+
}
|
|
44
|
+
return tags;
|
|
45
|
+
};
|
package/test/setup.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
package/vitest.config.ts
ADDED