@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.
- package/dist/esm/index.csm.js +1 -1
- package/dist/umd/index.umd.js +1 -1
- package/package.json +6 -1
- package/.eslintignore +0 -1
- package/.vscode/launch.json +0 -17
- package/CHANGELOG_INTERNAL.md +0 -134
- package/README_INTERNAL.md +0 -176
- package/THIRD_PARTY_LICENSES +0 -525
- package/generateTests.js +0 -80
- package/jest.config.cjs +0 -10
- package/src/components/AddTagButton/index.ts +0 -23
- package/src/components/BasicSelect/index.ts +0 -123
- package/src/components/BasicSelect/styles.module.scss +0 -44
- package/src/components/Button/index.ts +0 -97
- package/src/components/Button/styles.module.scss +0 -152
- package/src/components/CheckboxGroup/Checkbox.ts +0 -104
- package/src/components/CheckboxGroup/index.ts +0 -190
- package/src/components/CheckboxGroup/styles.module.scss +0 -63
- package/src/components/CollapsedMenu/index.ts +0 -104
- package/src/components/CollapsedMenu/styles.module.scss +0 -46
- package/src/components/ConfigureFieldWrapper/index.ts +0 -85
- package/src/components/ConfigureFieldWrapper/styles.module.scss +0 -57
- package/src/components/EditableText/index.ts +0 -121
- package/src/components/EditableText/styles.module.scss +0 -38
- package/src/components/EditableTextArea/index.ts +0 -143
- package/src/components/EditableTextArea/styles.module.scss +0 -91
- package/src/components/ErrorMessage/index.ts +0 -16
- package/src/components/ErrorMessage/styles.module.scss +0 -19
- package/src/components/ErrorPage/index.ts +0 -42
- package/src/components/ErrorPage/styles.module.scss +0 -26
- package/src/components/Footer/index.ts +0 -41
- package/src/components/Footer/styles.module.scss +0 -40
- package/src/components/HTMLContent/index.tsx +0 -205
- package/src/components/HTMLContent/styles.module.scss +0 -3
- package/src/components/InfoBox/index.ts +0 -48
- package/src/components/InfoBox/styles.module.scss +0 -21
- package/src/components/Input/BaseInput/index.ts +0 -170
- package/src/components/Input/BaseInput/styles.module.scss +0 -95
- package/src/components/Input/DateInput/index.ts +0 -103
- package/src/components/Input/DateInput/styles.module.scss +0 -50
- package/src/components/Input/Input/index.ts +0 -225
- package/src/components/Input/Input/styles.module.scss +0 -16
- package/src/components/Input/PasswordInput/index.ts +0 -164
- package/src/components/Input/PasswordInput/styles.module.scss +0 -37
- package/src/components/Input/index.ts +0 -7
- package/src/components/Label/index.ts +0 -61
- package/src/components/Label/styles.module.scss +0 -41
- package/src/components/LargeLoader/index.ts +0 -25
- package/src/components/LargeLoader/styles.module.scss +0 -16
- package/src/components/Listbox/ListBoxItem.ts +0 -57
- package/src/components/Listbox/index.ts +0 -488
- package/src/components/Listbox/styles.module.scss +0 -197
- package/src/components/Loader/index.ts +0 -25
- package/src/components/Loader/styles.module.scss +0 -16
- package/src/components/MediaGallery/MediaGalleryModal.ts +0 -82
- package/src/components/MediaGallery/MediaSlider.ts +0 -76
- package/src/components/MediaGallery/index.ts +0 -92
- package/src/components/MediaGallery/styles.module.scss +0 -156
- package/src/components/MediaUpload/index.ts +0 -233
- package/src/components/MediaUpload/styles.module.scss +0 -118
- package/src/components/Modal/index.ts +0 -87
- package/src/components/Modal/styles.module.scss +0 -441
- package/src/components/MultipurposeField/Dropdown/ListBoxItem.tsx +0 -59
- package/src/components/MultipurposeField/Dropdown/index.tsx +0 -1202
- package/src/components/MultipurposeField/Dropdown/styles.module.scss +0 -215
- package/src/components/MultipurposeField/TagMenu/index.ts +0 -536
- package/src/components/MultipurposeField/TagMenu/styles.module.scss +0 -175
- package/src/components/MultipurposeField/TagOptions/index.tsx +0 -83
- package/src/components/MultipurposeField/TagOptions/styles.module.scss +0 -95
- package/src/components/MultipurposeField/index.tsx +0 -944
- package/src/components/MultipurposeField/styles.module.scss +0 -77
- package/src/components/NewModal/index.ts +0 -69
- package/src/components/NewModal/styles.module.scss +0 -70
- package/src/components/OverflowTooltip/index.tsx +0 -59
- package/src/components/PopUp/ConfirmationPopUp/index.ts +0 -58
- package/src/components/PopUp/ConfirmationPopUp/styles.module.scss +0 -49
- package/src/components/PopUp/SuccessPopUp/index.ts +0 -62
- package/src/components/PopUp/SuccessPopUp/styles.module.scss +0 -38
- package/src/components/RadioGroup/Radio.ts +0 -128
- package/src/components/RadioGroup/index.ts +0 -169
- package/src/components/RadioGroup/styles.module.scss +0 -81
- package/src/components/Search/index.ts +0 -69
- package/src/components/Search/styles.module.scss +0 -149
- package/src/components/TabBar/Tab.ts +0 -33
- package/src/components/TabBar/index.ts +0 -64
- package/src/components/TabBar/styles.module.scss +0 -43
- package/src/components/Tag/index.ts +0 -29
- package/src/components/Tag/styles.module.scss +0 -57
- package/src/components/TagsMenu/index.ts +0 -1697
- package/src/components/TagsMenu/styles.module.scss +0 -350
- package/src/components/TestComponent/index.ts +0 -71
- package/src/components/TestComponent/styles.module.scss +0 -152
- package/src/components/TextArea/index.ts +0 -172
- package/src/components/TextArea/styles.module.scss +0 -72
- package/src/components/TextContent/index.tsx +0 -128
- package/src/components/TextContent/styles.module.scss +0 -6
- package/src/components/ThreeDotLoader/index.ts +0 -39
- package/src/components/ThreeDotLoader/styles.module.scss +0 -41
- package/src/components/TimeInput/index.ts +0 -129
- package/src/components/TimeInput/styles.module.scss +0 -16
- package/src/components/Toggle/index.ts +0 -34
- package/src/components/Toggle/styles.module.scss +0 -56
- package/src/components/Toggle-v2/index.ts +0 -40
- package/src/components/Toggle-v2/styles.module.scss +0 -86
- package/src/components/Tooltip/index.ts +0 -271
- package/src/components/Tooltip/styles.module.scss +0 -105
- package/src/components/form/FunctionField/index.ts +0 -816
- package/src/components/form/FunctionField/styles.module.scss +0 -478
- package/src/components/form/ObjectField/__snapshots__/index.ts.test.tsx.snap +0 -3
- package/src/components/form/ObjectField/index.ts +0 -593
- package/src/components/form/ObjectField/index.ts.test.tsx +0 -213
- package/src/components/form/ObjectField/styles.module.scss +0 -103
- package/src/components/form/index.ts +0 -4
- package/src/contexts/AppContext.ts +0 -12
- package/src/declaration.d.ts +0 -7
- package/src/extensions/HMAC.ts +0 -25
- package/src/extensions/IntegryAPIError.ts +0 -19
- package/src/features/common/AccountDropdown/index.ts +0 -291
- package/src/features/common/AccountDropdown/styles.module.scss +0 -19
- package/src/features/common/ActionForm/index.ts +0 -2602
- package/src/features/common/ActionForm/styles.module.scss +0 -35
- package/src/features/common/AppCard/index.ts +0 -207
- package/src/features/common/AppCard/styles.module.scss +0 -117
- package/src/features/common/AppCardCompact/index.ts +0 -189
- package/src/features/common/AppCardCompact/styles.module.scss +0 -141
- package/src/features/common/AuthSelector/index.ts +0 -537
- package/src/features/common/AuthSelector/styles.module.scss +0 -161
- package/src/features/common/AuthSelectorCompact/index.ts +0 -706
- package/src/features/common/AuthSelectorCompact/styles.module.scss +0 -219
- package/src/features/common/AuthSelectorDropdown/index.ts +0 -704
- package/src/features/common/AuthSelectorDropdown/styles.module.scss +0 -361
- package/src/features/common/AuthSelectorV2/index.ts +0 -336
- package/src/features/common/AuthSelectorV2/styles.module.scss +0 -235
- package/src/features/common/DynamicField/index.ts +0 -402
- package/src/features/common/DynamicField/styles.module.scss +0 -266
- package/src/features/common/DynamicTypedField/index.ts +0 -504
- package/src/features/common/DynamicTypedField/styles.module.scss +0 -135
- package/src/features/common/FunctionForm/index.ts +0 -1095
- package/src/features/common/FunctionForm/styles.module.scss +0 -225
- package/src/features/common/MappingUI/index.ts +0 -649
- package/src/features/common/MappingUI/styles.module.scss +0 -121
- package/src/features/common/MarketplaceAppCard/index.ts +0 -279
- package/src/features/common/MarketplaceAppCard/styles.module.scss +0 -231
- package/src/features/common/MarketplaceAppCardCompact/index.ts +0 -283
- package/src/features/common/MarketplaceAppCardCompact/styles.module.scss +0 -255
- package/src/features/common/NewMappingUI/index.ts +0 -515
- package/src/features/common/NewMappingUI/styles.module.scss +0 -113
- package/src/features/common/RequestAppWidget/RequestAppModal/index.ts +0 -67
- package/src/features/common/RequestAppWidget/RequestAppModal/styles.module.scss +0 -23
- package/src/features/common/RequestAppWidget/index.ts +0 -48
- package/src/features/common/RequestAppWidget/request-app-form.ts +0 -89
- package/src/features/common/RequestAppWidget/styles.module.scss +0 -43
- package/src/features/common/SectionField/index.ts +0 -272
- package/src/features/common/SectionField/styles.module.scss +0 -67
- package/src/features/common/Step/index.ts +0 -827
- package/src/features/common/Step/styles.module.scss +0 -12
- package/src/features/common/StepNavigation/CollapsedSteps.ts +0 -131
- package/src/features/common/StepNavigation/NavItem.ts +0 -111
- package/src/features/common/StepNavigation/index.ts +0 -261
- package/src/features/common/StepNavigation/styles.module.scss +0 -117
- package/src/features/common/Steps/index.ts +0 -1140
- package/src/features/common/Steps/styles.module.scss +0 -314
- package/src/features/containers/AppFlowContainer/AppFlowListing/compactStyles.module.scss +0 -404
- package/src/features/containers/AppFlowContainer/AppFlowListing/flow-instance.tsx +0 -367
- package/src/features/containers/AppFlowContainer/AppFlowListing/flowCard.test.tsx +0 -58
- package/src/features/containers/AppFlowContainer/AppFlowListing/flowCard.tsx +0 -208
- package/src/features/containers/AppFlowContainer/AppFlowListing/flowCardCompact.test.tsx +0 -49
- package/src/features/containers/AppFlowContainer/AppFlowListing/flowCardCompact.tsx +0 -421
- package/src/features/containers/AppFlowContainer/AppFlowListing/flowInstanceCompact.tsx +0 -577
- package/src/features/containers/AppFlowContainer/AppFlowListing/index.tsx +0 -83
- package/src/features/containers/AppFlowContainer/AppFlowListing/styles.module.scss +0 -233
- package/src/features/containers/AppFlowContainer/AppFlowWrap/app-page-loader.tsx +0 -45
- package/src/features/containers/AppFlowContainer/AppFlowWrap/index.tsx +0 -1085
- package/src/features/containers/AppFlowContainer/AppFlowWrap/styles.module.scss +0 -465
- package/src/features/containers/AppFlowContainer/Authentication/index.ts +0 -610
- package/src/features/containers/AppFlowContainer/Authentication/styles.module.scss +0 -468
- package/src/features/containers/AppFlowContainer/index.ts +0 -114
- package/src/features/containers/AppPageContainer/AppPage/index.tsx +0 -262
- package/src/features/containers/AppPageContainer/AppPage/styles.module.scss +0 -120
- package/src/features/containers/AppPageContainer/IntegrationCard/index.ts +0 -165
- package/src/features/containers/AppPageContainer/IntegrationCard/styles.module.scss +0 -81
- package/src/features/containers/AppPageContainer/index.tsx +0 -93
- package/src/features/containers/AppPageContainer/styles.module.scss +0 -0
- package/src/features/containers/AppsForFlows/index.ts +0 -161
- package/src/features/containers/AppsForFlows/styles.module.scss +0 -280
- package/src/features/containers/AppsForFlowsCompact/index.ts +0 -161
- package/src/features/containers/AppsForFlowsCompact/styles.module.scss +0 -279
- package/src/features/containers/AuthSetupContainer/AppSelection.ts +0 -73
- package/src/features/containers/AuthSetupContainer/AuthTypeSelection.ts +0 -67
- package/src/features/containers/AuthSetupContainer/Footer.ts +0 -32
- package/src/features/containers/AuthSetupContainer/Header.ts +0 -39
- package/src/features/containers/AuthSetupContainer/PostAdditionPopup.ts +0 -27
- package/src/features/containers/AuthSetupContainer/index.ts +0 -349
- package/src/features/containers/AuthSetupContainer/styles.module.scss +0 -229
- package/src/features/containers/FlowSetupContainer/index.ts +0 -391
- package/src/features/containers/FlowSetupContainer/styles.module.scss +0 -18
- package/src/features/containers/MarkeplaceApps/index.ts +0 -583
- package/src/features/containers/MarkeplaceApps/styles.module.scss +0 -558
- package/src/features/containers/MarketplaceAppsCompact/index.ts +0 -585
- package/src/features/containers/MarketplaceAppsCompact/styles.module.scss +0 -563
- package/src/features/containers/MarketplaceAppsContainer/index.ts +0 -91
- package/src/features/containers/MarketplaceContainer/AppCard/index.ts +0 -91
- package/src/features/containers/MarketplaceContainer/AppCard/styles.module.scss +0 -66
- package/src/features/containers/MarketplaceContainer/AppListing/index.ts +0 -34
- package/src/features/containers/MarketplaceContainer/AppListing/styles.module.scss +0 -10
- package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/index.ts +0 -132
- package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/styles.module.scss +0 -117
- package/src/features/containers/MarketplaceContainer/index.ts +0 -242
- package/src/features/containers/MarketplaceContainer/styles.module.scss +0 -84
- package/src/features/containers/SDKContainer/index.ts +0 -817
- package/src/features/containers/SDKContainer/styles.module.scss +0 -266
- package/src/features/containers/SDKDebugContainer/index.ts +0 -137
- package/src/features/containers/SDKDebugContainer/styles.module.scss +0 -37
- package/src/features/containers/SDKFailedContainer/index.ts +0 -117
- package/src/features/containers/SDKFailedContainer/styles.module.scss +0 -57
- package/src/features/integrations/IntegrationRow/Icons.ts +0 -77
- package/src/features/integrations/IntegrationRow/index.ts +0 -129
- package/src/features/integrations/IntegrationRow/styles.module.scss +0 -62
- package/src/features/integrations/IntegrationsHeader/index.ts +0 -34
- package/src/features/integrations/IntegrationsHeader/styles.module.scss +0 -47
- package/src/features/integrations/IntegrationsList/index.ts +0 -252
- package/src/features/integrations/IntegrationsList/styles.module.scss +0 -67
- package/src/features/templates/Template/index.ts +0 -295
- package/src/features/templates/Template/styles.module.scss +0 -226
- package/src/features/templates/TemplatesView/index.ts +0 -368
- package/src/features/templates/TemplatesView/styles.module.scss +0 -71
- package/src/features/templates/TemplatesViewCompact/index.ts +0 -364
- package/src/features/templates/TemplatesViewCompact/styles.module.scss +0 -141
- package/src/hooks/useAutosizeTextArea.ts +0 -22
- package/src/hooks/useCustomRef.ts +0 -13
- package/src/hooks/useDebounce.ts +0 -17
- package/src/hooks/useElementResize.ts +0 -40
- package/src/hooks/useEventListener.ts +0 -42
- package/src/hooks/useHover.ts +0 -40
- package/src/hooks/useOnClickOutside.ts +0 -32
- package/src/index.ts +0 -2244
- package/src/index.umd.ts +0 -13
- package/src/interfaces/index.ts +0 -938
- package/src/modules/api/index.ts +0 -1325
- package/src/modules/api/responseHandler.ts +0 -38
- package/src/modules/event-emitter/index.ts +0 -72
- package/src/modules/event-emitter/runners/abstract.ts +0 -21
- package/src/modules/event-emitter/runners/default.ts +0 -11
- package/src/modules/event-emitter/runners/ntimes.ts +0 -28
- package/src/modules/event-emitter/types.ts +0 -34
- package/src/store/actionFunctions.ts +0 -1578
- package/src/store/index.ts +0 -17
- package/src/store/initialState.ts +0 -58
- package/src/types/index.ts +0 -320
- package/src/types/preact-compat.d.ts +0 -4
- package/src/types/store.ts +0 -366
- package/src/types/utils.ts +0 -19
- package/src/utils/ActivityOutputUtils.ts +0 -176
- package/src/utils/common.ts +0 -20
- package/src/utils/copyToClipboard.ts +0 -24
- package/src/utils/datetime.ts +0 -101
- package/src/utils/getUrlParam.ts +0 -11
- package/src/utils/isAuthMessage.ts +0 -16
- package/src/utils/isBrowser.ts +0 -1
- package/src/utils/jsonEncodeDecode.ts +0 -15
- package/src/utils/objectUtils.ts +0 -117
- package/src/utils/popup.ts +0 -30
- package/src/utils/searchJson.ts +0 -51
- package/src/utils/stepUtils.ts +0 -45
- package/src/utils/truncate.ts +0 -6
- package/test/setup.ts +0 -1
- package/vitest.config.ts +0 -16
package/src/types/store.ts
DELETED
|
@@ -1,366 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-cycle */
|
|
2
|
-
import { FlowCardProps } from '@/features/templates/Template';
|
|
3
|
-
import { VNode } from 'preact';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
Integration,
|
|
7
|
-
IntegrationResponse,
|
|
8
|
-
PreviewMetadata,
|
|
9
|
-
TemplateStep,
|
|
10
|
-
Template,
|
|
11
|
-
BundleResponse,
|
|
12
|
-
TemplateField,
|
|
13
|
-
App,
|
|
14
|
-
MarketplaceDetail,
|
|
15
|
-
MarketplaceAppAuthorizationType,
|
|
16
|
-
NestedObject,
|
|
17
|
-
IncomingWebhookPayload,
|
|
18
|
-
} from '../interfaces';
|
|
19
|
-
|
|
20
|
-
export interface ConfirmationStep {
|
|
21
|
-
type: 'CONFIRMATION';
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface StepStateStep {
|
|
25
|
-
stepId: number;
|
|
26
|
-
title: string;
|
|
27
|
-
description?: string;
|
|
28
|
-
iconUrl: string;
|
|
29
|
-
type: 'AUTH' | 'CONFIGURATION' | 'SECTION' | 'CONFIRMATION';
|
|
30
|
-
isCompleted: boolean;
|
|
31
|
-
isCurrentlyOpen: boolean;
|
|
32
|
-
requiredFields: number[];
|
|
33
|
-
isValid: boolean;
|
|
34
|
-
invalidFields: {
|
|
35
|
-
[fieldId: number]: string | null;
|
|
36
|
-
};
|
|
37
|
-
itemIndex: number;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
type StepState = {
|
|
41
|
-
steps: StepStateStep[];
|
|
42
|
-
currentStep: StepStateStep | ConfirmationStep | null;
|
|
43
|
-
fieldsListData:
|
|
44
|
-
| {
|
|
45
|
-
id: string;
|
|
46
|
-
sample_data: string;
|
|
47
|
-
tag: string;
|
|
48
|
-
title: string;
|
|
49
|
-
}[]
|
|
50
|
-
| null;
|
|
51
|
-
stepIndex: number;
|
|
52
|
-
showValidation: boolean;
|
|
53
|
-
allStepsCompleted: boolean;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export type Authorization = {
|
|
57
|
-
authorizationId: number;
|
|
58
|
-
userIdentity: string;
|
|
59
|
-
disableLink: string;
|
|
60
|
-
authType: string;
|
|
61
|
-
isVerified: boolean;
|
|
62
|
-
didFetchStatus: boolean;
|
|
63
|
-
isVerifying: boolean;
|
|
64
|
-
isDeleting: boolean;
|
|
65
|
-
error: string;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export type EditFieldData = {
|
|
69
|
-
fieldId: number | string;
|
|
70
|
-
is_hidden?: boolean;
|
|
71
|
-
description?: string;
|
|
72
|
-
default_value?: string | null;
|
|
73
|
-
stepId?: number;
|
|
74
|
-
is_mappable?: boolean;
|
|
75
|
-
is_editable?: boolean;
|
|
76
|
-
allow_tags_in_text?: boolean;
|
|
77
|
-
is_default_value_auto_mapped?: boolean;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
type State = {
|
|
81
|
-
genericData: {
|
|
82
|
-
dFlag?: string;
|
|
83
|
-
deploymentId?: number | null;
|
|
84
|
-
authConnection?: {
|
|
85
|
-
appId?: number | null;
|
|
86
|
-
authTypeId?: number | null;
|
|
87
|
-
};
|
|
88
|
-
templateId: number | null;
|
|
89
|
-
stepWithActivityOutput: TemplateStep | null;
|
|
90
|
-
implicitAuthEnabled: boolean;
|
|
91
|
-
brandingApp: App | null;
|
|
92
|
-
isPreviewMode: boolean;
|
|
93
|
-
name: string;
|
|
94
|
-
authModalId: string;
|
|
95
|
-
isAnonymous: boolean;
|
|
96
|
-
showAppAuthModal: boolean;
|
|
97
|
-
isReadOnly?: boolean;
|
|
98
|
-
marketplaceId?: number | null;
|
|
99
|
-
marketplaceDetail?: MarketplaceDetail | null;
|
|
100
|
-
IUAccountsData?: MarketplaceAppAuthorizationType | null;
|
|
101
|
-
app_id?: number | string | null;
|
|
102
|
-
currentIntegrationStatus?: string;
|
|
103
|
-
isTestIntegration?: boolean;
|
|
104
|
-
showTemplates?: boolean;
|
|
105
|
-
keepBackButtonForFlows?: boolean;
|
|
106
|
-
showApps?: boolean;
|
|
107
|
-
skipOnDemand?: boolean;
|
|
108
|
-
skipAccountConnectionOnLoad?: boolean;
|
|
109
|
-
deploymentIdFromConfig?: number | null;
|
|
110
|
-
testMultipurpose?: boolean;
|
|
111
|
-
viewStyle?: string;
|
|
112
|
-
selfAppName?: string;
|
|
113
|
-
selfAppId?: number;
|
|
114
|
-
customerAppName?: string;
|
|
115
|
-
flowDescription?: string;
|
|
116
|
-
customFlowSetupRender?: boolean;
|
|
117
|
-
userVariables?: any;
|
|
118
|
-
userVariablesValidation?: boolean;
|
|
119
|
-
storage?: any;
|
|
120
|
-
flowParameters?: any;
|
|
121
|
-
flowParametersData?: any;
|
|
122
|
-
};
|
|
123
|
-
stepState: StepState;
|
|
124
|
-
stepMapping: {
|
|
125
|
-
[stepId: string]: {
|
|
126
|
-
step: TemplateStep;
|
|
127
|
-
integrationStepId: number | null;
|
|
128
|
-
isAuthVerified: boolean;
|
|
129
|
-
authorizations: Authorization[];
|
|
130
|
-
selectedAuthId: number;
|
|
131
|
-
isUserinfoRequired: boolean;
|
|
132
|
-
};
|
|
133
|
-
};
|
|
134
|
-
authMapping: {
|
|
135
|
-
[appId: string]: {
|
|
136
|
-
app: App;
|
|
137
|
-
isAuthVerified: boolean;
|
|
138
|
-
authorizations: any[];
|
|
139
|
-
selectedAuthId: number | null;
|
|
140
|
-
isUserinfoRequired: boolean;
|
|
141
|
-
};
|
|
142
|
-
};
|
|
143
|
-
selectedAuthByAppId: {
|
|
144
|
-
[appId: string]: number | null;
|
|
145
|
-
};
|
|
146
|
-
stepDataMapping: {
|
|
147
|
-
[stepId: number]: {
|
|
148
|
-
[fieldId: number]: {
|
|
149
|
-
integrationFieldId: number | null;
|
|
150
|
-
fieldId: number;
|
|
151
|
-
value: string | null;
|
|
152
|
-
objectValue: Record<string, string | number> | null;
|
|
153
|
-
machineName: string;
|
|
154
|
-
isRequired: boolean;
|
|
155
|
-
isVisible: boolean;
|
|
156
|
-
isDynamic: boolean;
|
|
157
|
-
type: string;
|
|
158
|
-
isAddedInMapping: boolean;
|
|
159
|
-
regex: string | null;
|
|
160
|
-
regexErrorMessage: string | null;
|
|
161
|
-
passesRegexTest: boolean;
|
|
162
|
-
isChanged: boolean;
|
|
163
|
-
changedDynamicFields: string[] | null;
|
|
164
|
-
};
|
|
165
|
-
};
|
|
166
|
-
};
|
|
167
|
-
parentChildMapping: {
|
|
168
|
-
[stepId: number]: {
|
|
169
|
-
[machineName: string]: {
|
|
170
|
-
stepId: number;
|
|
171
|
-
fieldId: number;
|
|
172
|
-
childFields: string[];
|
|
173
|
-
parentFields: string[];
|
|
174
|
-
};
|
|
175
|
-
};
|
|
176
|
-
};
|
|
177
|
-
conditionalFieldMapping: {
|
|
178
|
-
[step_id: number]: {
|
|
179
|
-
[machineName: string]: {
|
|
180
|
-
value: string;
|
|
181
|
-
parentMachineName: string;
|
|
182
|
-
parentFieldId: number;
|
|
183
|
-
}[];
|
|
184
|
-
};
|
|
185
|
-
};
|
|
186
|
-
fieldListMapping: {
|
|
187
|
-
[machineName: string]: TemplateField & { stepId: number };
|
|
188
|
-
};
|
|
189
|
-
activityOutputData?: {
|
|
190
|
-
value: string;
|
|
191
|
-
text: string;
|
|
192
|
-
}[];
|
|
193
|
-
appsAuthData?: {
|
|
194
|
-
appId: number;
|
|
195
|
-
isVerified: boolean;
|
|
196
|
-
}[];
|
|
197
|
-
dynamicFieldData?: {
|
|
198
|
-
[fieldId: string]: (string | Record<string, string>)[];
|
|
199
|
-
};
|
|
200
|
-
incomingWebhookPayload?: IncomingWebhookPayload;
|
|
201
|
-
userConfig?: {
|
|
202
|
-
availableFlowsLabel?: string;
|
|
203
|
-
myFlowsLabel?: string;
|
|
204
|
-
hideWebhookUrlScreen?: boolean;
|
|
205
|
-
hideAppConnectionModal?: boolean;
|
|
206
|
-
autoRedirectToMyFlows?: boolean;
|
|
207
|
-
marketplaceModalTitle?: string;
|
|
208
|
-
buttonLabelToSaveIntegration?: string;
|
|
209
|
-
objects?: NestedObject;
|
|
210
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
211
|
-
[other: string]: any;
|
|
212
|
-
};
|
|
213
|
-
showSetupModal?: boolean;
|
|
214
|
-
showSetupInline?: boolean;
|
|
215
|
-
showFlowsListModal?: boolean;
|
|
216
|
-
showAppsListModal?: boolean;
|
|
217
|
-
showAppPageModal?: boolean;
|
|
218
|
-
integrations: Integration[];
|
|
219
|
-
integrationIdToEdit: number | null;
|
|
220
|
-
fetchingIntegrations: boolean;
|
|
221
|
-
fetchingTemplates: boolean;
|
|
222
|
-
templates: Template[];
|
|
223
|
-
mappingInfo: {
|
|
224
|
-
isNewMapping?: boolean;
|
|
225
|
-
customFieldsKey?: string;
|
|
226
|
-
} | null;
|
|
227
|
-
customComponents?: {
|
|
228
|
-
flowCard?: (props: FlowCardProps) => VNode;
|
|
229
|
-
};
|
|
230
|
-
activatedTab: string;
|
|
231
|
-
showMarketplaceModal?: boolean;
|
|
232
|
-
showRequestAppModal?: boolean;
|
|
233
|
-
requestAppFormData?: {
|
|
234
|
-
appField?: string;
|
|
235
|
-
descriptionField?: string;
|
|
236
|
-
};
|
|
237
|
-
showMarketplaceAppPageId?: number | null;
|
|
238
|
-
dFlag?: string;
|
|
239
|
-
editFieldData?: EditFieldData;
|
|
240
|
-
xIntegryConfig?: any;
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
type Actions = {
|
|
244
|
-
setStoreState(key: Partial<State>): void;
|
|
245
|
-
setBaseData(bundleResponse: BundleResponse): void;
|
|
246
|
-
setSteps(templateSteps: TemplateStep[]): void;
|
|
247
|
-
setIntegrationData(data: IntegrationResponse): void;
|
|
248
|
-
gotoNextStep(): void;
|
|
249
|
-
gotoPreviousStep(): void;
|
|
250
|
-
gotoStep(stepIndex: number): void;
|
|
251
|
-
setStepMapping(steps: TemplateStep[], integrationId?: number): void;
|
|
252
|
-
setParentChildMapping(steps: TemplateStep[]): void;
|
|
253
|
-
setConditionalFieldMapping(steps: TemplateStep[]): void;
|
|
254
|
-
setStepAuthorization(
|
|
255
|
-
stepId: number | null,
|
|
256
|
-
selectedAuthId: number | null,
|
|
257
|
-
isVerified: boolean,
|
|
258
|
-
fieldsToReset: number[],
|
|
259
|
-
override: boolean,
|
|
260
|
-
): void;
|
|
261
|
-
setStepFieldData(data: {
|
|
262
|
-
stepId: string;
|
|
263
|
-
fieldId: string;
|
|
264
|
-
value: string;
|
|
265
|
-
isRequired: boolean;
|
|
266
|
-
passesRegexTest?: boolean;
|
|
267
|
-
}): void;
|
|
268
|
-
setStepMappingData(data: {
|
|
269
|
-
stepId: number;
|
|
270
|
-
fieldId: number;
|
|
271
|
-
id: string;
|
|
272
|
-
value: string | null;
|
|
273
|
-
}): void;
|
|
274
|
-
setGenericData(
|
|
275
|
-
genericData: Partial<{
|
|
276
|
-
deploymentId?: number;
|
|
277
|
-
templateId: number;
|
|
278
|
-
isPreviewMode: boolean;
|
|
279
|
-
name: string;
|
|
280
|
-
showAppAuthModal: boolean;
|
|
281
|
-
isReadOnly?: boolean;
|
|
282
|
-
marketplaceId?: number;
|
|
283
|
-
marketplaceDetail?: MarketplaceDetail;
|
|
284
|
-
IUAccountsData?: MarketplaceAppAuthorizationType;
|
|
285
|
-
currentIntegrationStatus?: string;
|
|
286
|
-
isTestIntegration?: boolean;
|
|
287
|
-
app_id?: number | string | null;
|
|
288
|
-
showTemplates?: boolean;
|
|
289
|
-
keepBackButtonForFlows?: boolean;
|
|
290
|
-
skipAccountConnectionOnLoad?: boolean;
|
|
291
|
-
testMultipurpose?: boolean;
|
|
292
|
-
selfAppName: string;
|
|
293
|
-
selfAppId: number;
|
|
294
|
-
customerAppName: string;
|
|
295
|
-
}>,
|
|
296
|
-
): void;
|
|
297
|
-
setActivityOutputData(data: {
|
|
298
|
-
activityOutputData: {
|
|
299
|
-
text: string;
|
|
300
|
-
value: string;
|
|
301
|
-
}[];
|
|
302
|
-
}): void;
|
|
303
|
-
setAppsAuthData(data: {
|
|
304
|
-
appsAuthData: {
|
|
305
|
-
appId: number;
|
|
306
|
-
isVerified: boolean;
|
|
307
|
-
}[];
|
|
308
|
-
}): void;
|
|
309
|
-
setDynamicFieldData(data: {
|
|
310
|
-
dynamicFieldData: {
|
|
311
|
-
[fieldId: string]: (string | Record<string, string>)[];
|
|
312
|
-
};
|
|
313
|
-
}): void;
|
|
314
|
-
setIncomingWebhookPayload(data: {
|
|
315
|
-
incomingWebhookPayload: IncomingWebhookPayload;
|
|
316
|
-
}): void;
|
|
317
|
-
addAuthorization(params: { stepId: number; authData: Authorization }): void;
|
|
318
|
-
addAppAuthorization(params: { appId: number; authData: Authorization }): void;
|
|
319
|
-
setSelectedAuthByAppId: (params: { appId: number; authId: number }) => void;
|
|
320
|
-
removeAuthorization(params: { stepId: number; authId: number }): void;
|
|
321
|
-
removeAppAuthorization(params: { appId: number; authId: number }): void;
|
|
322
|
-
toggleVerifyAuthorizationFlag(params: {
|
|
323
|
-
stepId: number;
|
|
324
|
-
authId: number;
|
|
325
|
-
isVerifying: boolean;
|
|
326
|
-
}): void;
|
|
327
|
-
toggleVerifyAppAuthorizationFlag(params: {
|
|
328
|
-
appId: number;
|
|
329
|
-
authId: number;
|
|
330
|
-
isVerifying: boolean;
|
|
331
|
-
}): void;
|
|
332
|
-
setIntegrationLoadingState(data: {
|
|
333
|
-
integrationId: number;
|
|
334
|
-
isLoading: boolean;
|
|
335
|
-
op: 'edit' | 'delete' | 'edit-name';
|
|
336
|
-
nextVal?: boolean;
|
|
337
|
-
updatedName?: string;
|
|
338
|
-
}): void;
|
|
339
|
-
toggleDeleteAuthorizationFlag(params: {
|
|
340
|
-
stepId: number;
|
|
341
|
-
authId: number;
|
|
342
|
-
isDeleting: boolean;
|
|
343
|
-
error: string;
|
|
344
|
-
}): void;
|
|
345
|
-
toggleDeleteAppAuthorizationFlag(params: {
|
|
346
|
-
appId: number;
|
|
347
|
-
authId: number;
|
|
348
|
-
isDeleting: boolean;
|
|
349
|
-
error: string;
|
|
350
|
-
}): void;
|
|
351
|
-
setStepAuthId(params: { stepId: number; authId: number }): void;
|
|
352
|
-
setAppStepAuthId(params: { appId: number; authId: number }): void;
|
|
353
|
-
showStepValidationState(): void;
|
|
354
|
-
hideStepValidationState(): void;
|
|
355
|
-
gotoStepInPreview(previewMetadata: PreviewMetadata): void;
|
|
356
|
-
verifyStepValidity(stepId: number): void;
|
|
357
|
-
resetCustomMappingData(stepId: number): void;
|
|
358
|
-
reset(): void;
|
|
359
|
-
resetTemplateFields(): void;
|
|
360
|
-
clearChildFields(data: { stepId: number; fieldId: number }): void;
|
|
361
|
-
setEditFieldData(data: { fieldId: number }): void;
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
type StoreType = State & Actions;
|
|
365
|
-
|
|
366
|
-
export { State, StepState, Actions, StoreType };
|
package/src/types/utils.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility types
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export type OrNull<Type> = Type | null;
|
|
6
|
-
|
|
7
|
-
export type OneOrMany<Type> = Type | Type[];
|
|
8
|
-
|
|
9
|
-
export type OneOrManyOrNull<Type> = OrNull<OneOrMany<Type>>;
|
|
10
|
-
|
|
11
|
-
export type Merge<A, B> = {
|
|
12
|
-
[K in keyof (A | B)]: K extends keyof B ? B[K] : A[K];
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export function notEmpty<TValue>(
|
|
16
|
-
value: TValue | null | undefined,
|
|
17
|
-
): value is TValue {
|
|
18
|
-
return value !== null && value !== undefined;
|
|
19
|
-
}
|
|
@@ -1,176 +0,0 @@
|
|
|
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
|
-
obj: any,
|
|
57
|
-
parentKey = '',
|
|
58
|
-
sourceStepKey = '',
|
|
59
|
-
): Record<string, string[]> {
|
|
60
|
-
let result: Record<string, string[]> = {};
|
|
61
|
-
|
|
62
|
-
Object.keys(obj).forEach((key) => {
|
|
63
|
-
let currentKey = sourceStepKey ? `${sourceStepKey}` : '';
|
|
64
|
-
currentKey += parentKey ? `${parentKey}.${key}` : key;
|
|
65
|
-
|
|
66
|
-
const value = obj[key];
|
|
67
|
-
|
|
68
|
-
if (value === null || value === undefined) {
|
|
69
|
-
result[currentKey] = [''];
|
|
70
|
-
} else if (typeof value === 'object') {
|
|
71
|
-
if (Array.isArray(value)) {
|
|
72
|
-
// Handle array elements individually
|
|
73
|
-
value.forEach((item, index) => {
|
|
74
|
-
const indexedKey = `${currentKey}.${index}`;
|
|
75
|
-
if (typeof item === 'object' && item !== null) {
|
|
76
|
-
// Recursively flatten array item
|
|
77
|
-
const flattened = JSONToDynamicFieldData(item, indexedKey);
|
|
78
|
-
result = { ...result, ...flattened };
|
|
79
|
-
} else {
|
|
80
|
-
result[indexedKey] = [item];
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
} else {
|
|
84
|
-
// Regular nested object
|
|
85
|
-
try {
|
|
86
|
-
result[currentKey] = [JSON.stringify(value)];
|
|
87
|
-
} catch {
|
|
88
|
-
result[currentKey] = [''];
|
|
89
|
-
}
|
|
90
|
-
const flattened = JSONToDynamicFieldData(value, currentKey);
|
|
91
|
-
result = { ...result, ...flattened };
|
|
92
|
-
}
|
|
93
|
-
} else {
|
|
94
|
-
result[currentKey] = [value];
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
return result;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export function removeCurlyBraces(value: string): string {
|
|
102
|
-
value.replace(/^{(.*)}$/, '$1');
|
|
103
|
-
return value;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export function isNotJSON(obj: any): boolean {
|
|
107
|
-
try {
|
|
108
|
-
if (Array.isArray(obj) && obj.length > 0 && typeof obj[0] === 'object') {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
JSON.parse(obj);
|
|
112
|
-
if (Number(obj)) {
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
return false;
|
|
116
|
-
} catch (e) {
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export function arrayToNestedJSONWithFirstValue(
|
|
122
|
-
array: any,
|
|
123
|
-
valueObj: any,
|
|
124
|
-
): any {
|
|
125
|
-
let tempValueObj: any = {};
|
|
126
|
-
let arrayUpdated = [];
|
|
127
|
-
if (array && Array.isArray(array)) {
|
|
128
|
-
arrayUpdated = array;
|
|
129
|
-
}
|
|
130
|
-
Object.keys(valueObj || {}).forEach((i) => {
|
|
131
|
-
const key = removeCurlyBraces(i);
|
|
132
|
-
tempValueObj = {
|
|
133
|
-
...tempValueObj,
|
|
134
|
-
[key]: valueObj[i] || '',
|
|
135
|
-
};
|
|
136
|
-
});
|
|
137
|
-
let flatForm = {};
|
|
138
|
-
(arrayUpdated || []).forEach((arr: any) => {
|
|
139
|
-
flatForm = {
|
|
140
|
-
...flatForm,
|
|
141
|
-
[arr.text]: valueObj[arr.value] || '',
|
|
142
|
-
};
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
const result = {};
|
|
146
|
-
(arrayUpdated || []).forEach((item: any) => {
|
|
147
|
-
if (!item.text || !item.value) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
const keys = item.text.split('.');
|
|
151
|
-
let currentLevel: any = result;
|
|
152
|
-
keys.forEach((key: any, index: any) => {
|
|
153
|
-
if (!currentLevel[key]) {
|
|
154
|
-
if (index === keys.length - 1) {
|
|
155
|
-
if (tempValueObj[item.value]) {
|
|
156
|
-
if (
|
|
157
|
-
tempValueObj[item.value][0] &&
|
|
158
|
-
isNotJSON(tempValueObj[item.value][0])
|
|
159
|
-
) {
|
|
160
|
-
// eslint-disable-next-line prefer-destructuring
|
|
161
|
-
currentLevel[key] = tempValueObj[item.value][0] || '';
|
|
162
|
-
} else {
|
|
163
|
-
currentLevel[key] = '';
|
|
164
|
-
}
|
|
165
|
-
} else {
|
|
166
|
-
currentLevel[key] = '';
|
|
167
|
-
}
|
|
168
|
-
} else {
|
|
169
|
-
currentLevel[key] = {};
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
currentLevel = currentLevel[key];
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
return result;
|
|
176
|
-
}
|
package/src/utils/common.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
};
|
package/src/utils/datetime.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
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 };
|