@amp-labs/react 1.0.0
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/LICENSE.md +21 -0
- package/README.md +138 -0
- package/build/generated-sources/api/src/apis/DefaultApi.d.ts +858 -0
- package/build/generated-sources/api/src/apis/DefaultApi.js +942 -0
- package/build/generated-sources/api/src/apis/index.d.ts +1 -0
- package/build/generated-sources/api/src/apis/index.js +19 -0
- package/build/generated-sources/api/src/index.d.ts +3 -0
- package/build/generated-sources/api/src/index.js +21 -0
- package/build/generated-sources/api/src/models/BaseConfigContent.d.ts +38 -0
- package/build/generated-sources/api/src/models/BaseConfigContent.js +53 -0
- package/build/generated-sources/api/src/models/BaseReadConfig.d.ts +34 -0
- package/build/generated-sources/api/src/models/BaseReadConfig.js +51 -0
- package/build/generated-sources/api/src/models/BaseReadConfigStandardObject.d.ts +59 -0
- package/build/generated-sources/api/src/models/BaseReadConfigStandardObject.js +58 -0
- package/build/generated-sources/api/src/models/BatchUpsertIntegrationsRequest.d.ts +31 -0
- package/build/generated-sources/api/src/models/BatchUpsertIntegrationsRequest.js +50 -0
- package/build/generated-sources/api/src/models/Config.d.ts +56 -0
- package/build/generated-sources/api/src/models/Config.js +63 -0
- package/build/generated-sources/api/src/models/ConfigContent.d.ts +37 -0
- package/build/generated-sources/api/src/models/ConfigContent.js +53 -0
- package/build/generated-sources/api/src/models/ConfigContentAllOf.d.ts +31 -0
- package/build/generated-sources/api/src/models/ConfigContentAllOf.js +50 -0
- package/build/generated-sources/api/src/models/Connection.d.ts +82 -0
- package/build/generated-sources/api/src/models/Connection.js +76 -0
- package/build/generated-sources/api/src/models/Consumer.d.ts +55 -0
- package/build/generated-sources/api/src/models/Consumer.js +62 -0
- package/build/generated-sources/api/src/models/CreateConsumerRequest.d.ts +37 -0
- package/build/generated-sources/api/src/models/CreateConsumerRequest.js +53 -0
- package/build/generated-sources/api/src/models/CreateDestinationRequest.d.ts +44 -0
- package/build/generated-sources/api/src/models/CreateDestinationRequest.js +57 -0
- package/build/generated-sources/api/src/models/CreateDestinationRequestMetadata.d.ts +39 -0
- package/build/generated-sources/api/src/models/CreateDestinationRequestMetadata.js +52 -0
- package/build/generated-sources/api/src/models/CreateGroupRequest.d.ts +37 -0
- package/build/generated-sources/api/src/models/CreateGroupRequest.js +53 -0
- package/build/generated-sources/api/src/models/CreateInstallationRequest.d.ts +44 -0
- package/build/generated-sources/api/src/models/CreateInstallationRequest.js +57 -0
- package/build/generated-sources/api/src/models/CreateInstallationRequestConfig.d.ts +44 -0
- package/build/generated-sources/api/src/models/CreateInstallationRequestConfig.js +57 -0
- package/build/generated-sources/api/src/models/CreateIntegrationRequest.d.ts +44 -0
- package/build/generated-sources/api/src/models/CreateIntegrationRequest.js +57 -0
- package/build/generated-sources/api/src/models/CreateIntegrationRequestLatestRevision.d.ts +31 -0
- package/build/generated-sources/api/src/models/CreateIntegrationRequestLatestRevision.js +50 -0
- package/build/generated-sources/api/src/models/CreateProjectRequest.d.ts +37 -0
- package/build/generated-sources/api/src/models/CreateProjectRequest.js +53 -0
- package/build/generated-sources/api/src/models/CreateProviderAppRequest.d.ts +49 -0
- package/build/generated-sources/api/src/models/CreateProviderAppRequest.js +59 -0
- package/build/generated-sources/api/src/models/Group.d.ts +55 -0
- package/build/generated-sources/api/src/models/Group.js +62 -0
- package/build/generated-sources/api/src/models/HydratedIntegration.d.ts +50 -0
- package/build/generated-sources/api/src/models/HydratedIntegration.js +59 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationField.d.ts +22 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationField.js +45 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationFieldExistent.d.ts +37 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationFieldExistent.js +53 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationObject.d.ts +75 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationObject.js +70 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationRead.d.ts +32 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationRead.js +51 -0
- package/build/generated-sources/api/src/models/HydratedRevision.d.ts +50 -0
- package/build/generated-sources/api/src/models/HydratedRevision.js +60 -0
- package/build/generated-sources/api/src/models/ImportConnectionRequest.d.ts +85 -0
- package/build/generated-sources/api/src/models/ImportConnectionRequest.js +75 -0
- package/build/generated-sources/api/src/models/ImportInstallationRequest.d.ts +39 -0
- package/build/generated-sources/api/src/models/ImportInstallationRequest.js +55 -0
- package/build/generated-sources/api/src/models/ImportInstallationRequestConfig.d.ts +38 -0
- package/build/generated-sources/api/src/models/ImportInstallationRequestConfig.js +54 -0
- package/build/generated-sources/api/src/models/Installation.d.ts +88 -0
- package/build/generated-sources/api/src/models/Installation.js +79 -0
- package/build/generated-sources/api/src/models/Integration.d.ts +68 -0
- package/build/generated-sources/api/src/models/Integration.js +69 -0
- package/build/generated-sources/api/src/models/Integration1.d.ts +50 -0
- package/build/generated-sources/api/src/models/Integration1.js +59 -0
- package/build/generated-sources/api/src/models/IntegrationField.d.ts +22 -0
- package/build/generated-sources/api/src/models/IntegrationField.js +45 -0
- package/build/generated-sources/api/src/models/IntegrationFieldExistent.d.ts +31 -0
- package/build/generated-sources/api/src/models/IntegrationFieldExistent.js +50 -0
- package/build/generated-sources/api/src/models/IntegrationFieldMapping.d.ts +49 -0
- package/build/generated-sources/api/src/models/IntegrationFieldMapping.js +57 -0
- package/build/generated-sources/api/src/models/IntegrationObject.d.ts +63 -0
- package/build/generated-sources/api/src/models/IntegrationObject.js +65 -0
- package/build/generated-sources/api/src/models/IntegrationRead.d.ts +32 -0
- package/build/generated-sources/api/src/models/IntegrationRead.js +51 -0
- package/build/generated-sources/api/src/models/OauthConnectRequest.d.ts +73 -0
- package/build/generated-sources/api/src/models/OauthConnectRequest.js +70 -0
- package/build/generated-sources/api/src/models/Operation.d.ts +80 -0
- package/build/generated-sources/api/src/models/Operation.js +73 -0
- package/build/generated-sources/api/src/models/OperationError.d.ts +49 -0
- package/build/generated-sources/api/src/models/OperationError.js +56 -0
- package/build/generated-sources/api/src/models/OptionalFieldsAutoOption.d.ts +22 -0
- package/build/generated-sources/api/src/models/OptionalFieldsAutoOption.js +35 -0
- package/build/generated-sources/api/src/models/Project.d.ts +55 -0
- package/build/generated-sources/api/src/models/Project.js +62 -0
- package/build/generated-sources/api/src/models/ProjectMembership.d.ts +56 -0
- package/build/generated-sources/api/src/models/ProjectMembership.js +63 -0
- package/build/generated-sources/api/src/models/ProviderApp.d.ts +67 -0
- package/build/generated-sources/api/src/models/ProviderApp.js +67 -0
- package/build/generated-sources/api/src/models/Revision.d.ts +50 -0
- package/build/generated-sources/api/src/models/Revision.js +60 -0
- package/build/generated-sources/api/src/models/UpdateInstallationConfigContent.d.ts +38 -0
- package/build/generated-sources/api/src/models/UpdateInstallationConfigContent.js +53 -0
- package/build/generated-sources/api/src/models/UpdateInstallationRequest.d.ts +38 -0
- package/build/generated-sources/api/src/models/UpdateInstallationRequest.js +54 -0
- package/build/generated-sources/api/src/models/UpdateInstallationRequestInstallation.d.ts +38 -0
- package/build/generated-sources/api/src/models/UpdateInstallationRequestInstallation.js +53 -0
- package/build/generated-sources/api/src/models/UpdateInstallationRequestInstallationConfig.d.ts +44 -0
- package/build/generated-sources/api/src/models/UpdateInstallationRequestInstallationConfig.js +55 -0
- package/build/generated-sources/api/src/models/UpdateProjectRequest.d.ts +38 -0
- package/build/generated-sources/api/src/models/UpdateProjectRequest.js +54 -0
- package/build/generated-sources/api/src/models/UpdateProjectRequestProject.d.ts +37 -0
- package/build/generated-sources/api/src/models/UpdateProjectRequestProject.js +52 -0
- package/build/generated-sources/api/src/models/UpdateProviderAppRequest.d.ts +38 -0
- package/build/generated-sources/api/src/models/UpdateProviderAppRequest.js +54 -0
- package/build/generated-sources/api/src/models/UpdateProviderAppRequestProviderApp.d.ts +49 -0
- package/build/generated-sources/api/src/models/UpdateProviderAppRequestProviderApp.js +56 -0
- package/build/generated-sources/api/src/models/UpsertProjectMembershipRequest.d.ts +37 -0
- package/build/generated-sources/api/src/models/UpsertProjectMembershipRequest.js +53 -0
- package/build/generated-sources/api/src/models/index.d.ts +54 -0
- package/build/generated-sources/api/src/models/index.js +72 -0
- package/build/generated-sources/api/src/runtime.d.ts +182 -0
- package/build/generated-sources/api/src/runtime.js +317 -0
- package/build/src/assets/LoadingIcon.d.ts +5 -0
- package/build/src/assets/LoadingIcon.js +9 -0
- package/build/src/assets/NavIcon.d.ts +1 -0
- package/build/src/assets/NavIcon.js +23 -0
- package/build/src/components/AmpersandProvider/AmpersandProvider.d.ts +19 -0
- package/build/src/components/AmpersandProvider/AmpersandProvider.js +31 -0
- package/build/src/components/AmpersandProvider/index.d.ts +1 -0
- package/build/src/components/AmpersandProvider/index.js +17 -0
- package/build/src/components/CenteredTextBox/CenteredTextBox.d.ts +5 -0
- package/build/src/components/CenteredTextBox/CenteredTextBox.js +8 -0
- package/build/src/components/Configure/ConfigureInstallationBase.d.ts +8 -0
- package/build/src/components/Configure/ConfigureInstallationBase.js +17 -0
- package/build/src/components/Configure/CreateInstallation.d.ts +1 -0
- package/build/src/components/Configure/CreateInstallation.js +73 -0
- package/build/src/components/Configure/ErrorTextBox.d.ts +5 -0
- package/build/src/components/Configure/ErrorTextBox.js +9 -0
- package/build/src/components/Configure/InstallIntegration.d.ts +9 -0
- package/build/src/components/Configure/InstallIntegration.js +40 -0
- package/build/src/components/Configure/ObjectManagementNav/NavObjectItem.d.ts +8 -0
- package/build/src/components/Configure/ObjectManagementNav/NavObjectItem.js +14 -0
- package/build/src/components/Configure/ObjectManagementNav/index.d.ts +9 -0
- package/build/src/components/Configure/ObjectManagementNav/index.js +45 -0
- package/build/src/components/Configure/ProtectedConnectionLayout.d.ts +6 -0
- package/build/src/components/Configure/ProtectedConnectionLayout.js +28 -0
- package/build/src/components/Configure/UpdateInstallation.d.ts +7 -0
- package/build/src/components/Configure/UpdateInstallation.js +87 -0
- package/build/src/components/Configure/actions/onSaveCreate.d.ts +3 -0
- package/build/src/components/Configure/actions/onSaveCreate.js +90 -0
- package/build/src/components/Configure/actions/onSaveUpdate.d.ts +3 -0
- package/build/src/components/Configure/actions/onSaveUpdate.js +74 -0
- package/build/src/components/Configure/fields/FieldHeader.d.ts +5 -0
- package/build/src/components/Configure/fields/FieldHeader.js +9 -0
- package/build/src/components/Configure/fields/FieldMapping.d.ts +10 -0
- package/build/src/components/Configure/fields/FieldMapping.js +28 -0
- package/build/src/components/Configure/fields/OptionalFields.d.ts +1 -0
- package/build/src/components/Configure/fields/OptionalFields.js +45 -0
- package/build/src/components/Configure/fields/RequiredFieldMappings.d.ts +1 -0
- package/build/src/components/Configure/fields/RequiredFieldMappings.js +40 -0
- package/build/src/components/Configure/fields/RequiredFields.d.ts +1 -0
- package/build/src/components/Configure/fields/RequiredFields.js +27 -0
- package/build/src/components/Configure/index.d.ts +1 -0
- package/build/src/components/Configure/index.js +5 -0
- package/build/src/components/Configure/state/ConfigurationStateProvider.d.ts +13 -0
- package/build/src/components/Configure/state/ConfigurationStateProvider.js +54 -0
- package/build/src/components/Configure/state/HydratedRevisionContext.d.ts +14 -0
- package/build/src/components/Configure/state/HydratedRevisionContext.js +82 -0
- package/build/src/components/Configure/state/utils.d.ts +34 -0
- package/build/src/components/Configure/state/utils.js +146 -0
- package/build/src/components/Configure/types.d.ts +31 -0
- package/build/src/components/Configure/types.js +2 -0
- package/build/src/components/Configure/utils.d.ts +24 -0
- package/build/src/components/Configure/utils.js +82 -0
- package/build/src/components/OAuthPopup/OAuthPopup.d.ts +14 -0
- package/build/src/components/OAuthPopup/OAuthPopup.js +85 -0
- package/build/src/components/Salesforce/SalesforceOauthFlow.d.ts +16 -0
- package/build/src/components/Salesforce/SalesforceOauthFlow.js +78 -0
- package/build/src/components/ThemeProvider/index.d.ts +6 -0
- package/build/src/components/ThemeProvider/index.js +37 -0
- package/build/src/components/index.d.ts +2 -0
- package/build/src/components/index.js +18 -0
- package/build/src/constants.d.ts +1 -0
- package/build/src/constants.js +4 -0
- package/build/src/context/ApiKeyContext.d.ts +3 -0
- package/build/src/context/ApiKeyContext.js +6 -0
- package/build/src/context/ConnectionsContext.d.ts +16 -0
- package/build/src/context/ConnectionsContext.js +57 -0
- package/build/src/context/ErrorContextProvider.d.ts +37 -0
- package/build/src/context/ErrorContextProvider.js +72 -0
- package/build/src/context/InstallIntegrationContext.d.ts +24 -0
- package/build/src/context/InstallIntegrationContext.js +90 -0
- package/build/src/context/IntegrationListContext.d.ts +13 -0
- package/build/src/context/IntegrationListContext.js +48 -0
- package/build/src/context/ProjectContext.d.ts +15 -0
- package/build/src/context/ProjectContext.js +50 -0
- package/build/src/hooks/index.d.ts +1 -0
- package/build/src/hooks/index.js +17 -0
- package/build/src/hooks/useIsIntegrationInstalled.d.ts +6 -0
- package/build/src/hooks/useIsIntegrationInstalled.js +48 -0
- package/build/src/index.d.ts +2 -0
- package/build/src/index.js +18 -0
- package/build/src/services/api.d.ts +9 -0
- package/build/src/services/api.js +64 -0
- package/build/src/utils/index.d.ts +10 -0
- package/build/src/utils/index.js +21 -0
- package/package.json +80 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OptionalFields = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@chakra-ui/react");
|
|
6
|
+
const ProjectContext_1 = require("../../../context/ProjectContext");
|
|
7
|
+
const ObjectManagementNav_1 = require("../ObjectManagementNav");
|
|
8
|
+
const ConfigurationStateProvider_1 = require("../state/ConfigurationStateProvider");
|
|
9
|
+
const utils_1 = require("../state/utils");
|
|
10
|
+
const utils_2 = require("../utils");
|
|
11
|
+
const FieldHeader_1 = require("./FieldHeader");
|
|
12
|
+
function OptionalFields() {
|
|
13
|
+
var _a;
|
|
14
|
+
const { appName } = (0, ProjectContext_1.useProject)();
|
|
15
|
+
const { objectConfigurationsState, setConfigureState } = (0, ConfigurationStateProvider_1.useConfigureState)();
|
|
16
|
+
const { selectedObjectName } = (0, ObjectManagementNav_1.useSelectedObjectName)();
|
|
17
|
+
const configureState = (0, utils_1.getConfigureState)(selectedObjectName || '', objectConfigurationsState);
|
|
18
|
+
const { selectedOptionalFields } = configureState || {};
|
|
19
|
+
const onCheckboxChange = (e) => {
|
|
20
|
+
var _a;
|
|
21
|
+
const { name, checked } = e.target;
|
|
22
|
+
if (selectedObjectName && configureState) {
|
|
23
|
+
// Update the value property to new checked value
|
|
24
|
+
const updatedSelectOptionalFields = Object.assign(Object.assign({}, selectedOptionalFields), { [name]: checked });
|
|
25
|
+
// removed from check fields if not checked
|
|
26
|
+
if (!checked) {
|
|
27
|
+
delete updatedSelectOptionalFields[name];
|
|
28
|
+
}
|
|
29
|
+
// Compare saved fields from updated fields
|
|
30
|
+
const savedOptionalFields = (_a = configureState.savedConfig) === null || _a === void 0 ? void 0 : _a.optionalFields;
|
|
31
|
+
// Check if the optionalFields are modified
|
|
32
|
+
const isModified = !(0, utils_1.checkFieldsEquality)(savedOptionalFields, updatedSelectOptionalFields);
|
|
33
|
+
// update state
|
|
34
|
+
setConfigureState(selectedObjectName, Object.assign(Object.assign({}, configureState), { selectedOptionalFields: updatedSelectOptionalFields, isOptionalFieldsModified: isModified }));
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const shouldRender = !!((configureState === null || configureState === void 0 ? void 0 : configureState.optionalFields) && (configureState === null || configureState === void 0 ? void 0 : configureState.optionalFields));
|
|
38
|
+
return (shouldRender && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(FieldHeader_1.FieldHeader, { string: `${appName} reads the following optional fields` }), (0, jsx_runtime_1.jsx)(react_1.Stack, { marginBottom: 10, height: 300, overflowY: "scroll", border: "2px solid #EFEFEF", borderRadius: 8, padding: 4, children: (_a = configureState === null || configureState === void 0 ? void 0 : configureState.optionalFields) === null || _a === void 0 ? void 0 : _a.map((field) => {
|
|
39
|
+
if (!(0, utils_2.isIntegrationFieldMapping)(field)) {
|
|
40
|
+
return ((0, jsx_runtime_1.jsx)(react_1.Box, { display: "flex", gap: "5px", borderBottom: "1px", borderColor: "gray.100", children: (0, jsx_runtime_1.jsx)(react_1.Checkbox, { name: field.fieldName, id: field.fieldName, isChecked: !!(selectedOptionalFields === null || selectedOptionalFields === void 0 ? void 0 : selectedOptionalFields[field === null || field === void 0 ? void 0 : field.fieldName]), onChange: onCheckboxChange, children: field.displayName }) }, field.fieldName));
|
|
41
|
+
}
|
|
42
|
+
return null; // fallback for customed mapped fields
|
|
43
|
+
}) })] })));
|
|
44
|
+
}
|
|
45
|
+
exports.OptionalFields = OptionalFields;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function RequiredFieldMappings(): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RequiredFieldMappings = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const react_2 = require("@chakra-ui/react");
|
|
7
|
+
const ErrorContextProvider_1 = require("../../../context/ErrorContextProvider");
|
|
8
|
+
const ObjectManagementNav_1 = require("../ObjectManagementNav");
|
|
9
|
+
const ConfigurationStateProvider_1 = require("../state/ConfigurationStateProvider");
|
|
10
|
+
const utils_1 = require("../state/utils");
|
|
11
|
+
const utils_2 = require("../utils");
|
|
12
|
+
const FieldHeader_1 = require("./FieldHeader");
|
|
13
|
+
const FieldMapping_1 = require("./FieldMapping");
|
|
14
|
+
function RequiredFieldMappings() {
|
|
15
|
+
const { selectedObjectName } = (0, ObjectManagementNav_1.useSelectedObjectName)();
|
|
16
|
+
const { objectConfigurationsState, setConfigureState } = (0, ConfigurationStateProvider_1.useConfigureState)();
|
|
17
|
+
const configureState = (0, utils_1.getConfigureState)(selectedObjectName || '', objectConfigurationsState);
|
|
18
|
+
const { isError, removeError } = (0, ErrorContextProvider_1.useErrorState)();
|
|
19
|
+
const onSelectChange = (e) => {
|
|
20
|
+
const { value, name } = e.target;
|
|
21
|
+
if (!value) {
|
|
22
|
+
// if place holder value is chosen, we don't change state
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const { isUpdated, newState } = (0, utils_1.setRequiredCustomMapFieldValue)(name, value, configureState);
|
|
26
|
+
if (isUpdated && selectedObjectName) {
|
|
27
|
+
setConfigureState(selectedObjectName, newState);
|
|
28
|
+
}
|
|
29
|
+
if (isError(ErrorContextProvider_1.ErrorBoundary.MAPPING, name)) {
|
|
30
|
+
removeError(ErrorContextProvider_1.ErrorBoundary.MAPPING, name);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const integrationFieldMappings = (0, react_1.useMemo)(() => {
|
|
34
|
+
var _a;
|
|
35
|
+
return ((_a = configureState === null || configureState === void 0 ? void 0 : configureState.requiredMapFields) === null || _a === void 0 ? void 0 : _a.filter(utils_2.isIntegrationFieldMapping)) || [];
|
|
36
|
+
}, [configureState]);
|
|
37
|
+
return (integrationFieldMappings.length ? ((0, jsx_runtime_1.jsxs)(react_2.Box, { children: [(0, jsx_runtime_1.jsx)(FieldHeader_1.FieldHeader, { string: "Map the following fields (required)" }), (0, jsx_runtime_1.jsx)(react_2.Stack, { children: integrationFieldMappings.map((field) => ((0, jsx_runtime_1.jsxs)(react_2.FormControl, { isInvalid: isError(ErrorContextProvider_1.ErrorBoundary.MAPPING, field.mapToName), children: [(0, jsx_runtime_1.jsx)(FieldMapping_1.FieldMapping, { allFields: configureState.allFields || [], field: field, onSelectChange: onSelectChange }), (0, jsx_runtime_1.jsx)(react_2.FormErrorMessage, { children: " * required" })] }, field.mapToName))) })] }))
|
|
38
|
+
: null);
|
|
39
|
+
}
|
|
40
|
+
exports.RequiredFieldMappings = RequiredFieldMappings;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function RequiredFields(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RequiredFields = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@chakra-ui/react");
|
|
6
|
+
const ProjectContext_1 = require("../../../context/ProjectContext");
|
|
7
|
+
const ObjectManagementNav_1 = require("../ObjectManagementNav");
|
|
8
|
+
const ConfigurationStateProvider_1 = require("../state/ConfigurationStateProvider");
|
|
9
|
+
const utils_1 = require("../state/utils");
|
|
10
|
+
const utils_2 = require("../utils");
|
|
11
|
+
const FieldHeader_1 = require("./FieldHeader");
|
|
12
|
+
function RequiredFields() {
|
|
13
|
+
var _a;
|
|
14
|
+
const { selectedObjectName } = (0, ObjectManagementNav_1.useSelectedObjectName)();
|
|
15
|
+
const { objectConfigurationsState } = (0, ConfigurationStateProvider_1.useConfigureState)();
|
|
16
|
+
const configureState = (0, utils_1.getConfigureState)(selectedObjectName || '', objectConfigurationsState);
|
|
17
|
+
const { appName } = (0, ProjectContext_1.useProject)();
|
|
18
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(FieldHeader_1.FieldHeader, { string: `${appName} reads the following ${selectedObjectName} fields` }), (0, jsx_runtime_1.jsx)(react_1.Box, { marginBottom: "20px", children: ((_a = configureState === null || configureState === void 0 ? void 0 : configureState.requiredFields) === null || _a === void 0 ? void 0 : _a.length)
|
|
19
|
+
? (configureState.requiredFields.map((field) => {
|
|
20
|
+
if (!(0, utils_2.isIntegrationFieldMapping)(field)) {
|
|
21
|
+
return (0, jsx_runtime_1.jsx)(react_1.Tag, { children: field.displayName }, field.fieldName);
|
|
22
|
+
}
|
|
23
|
+
return null; // fallback for customed mapped fields
|
|
24
|
+
}))
|
|
25
|
+
: 'There are no required fields.' })] }));
|
|
26
|
+
}
|
|
27
|
+
exports.RequiredFields = RequiredFields;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { InstallIntegration } from './InstallIntegration';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InstallIntegration = void 0;
|
|
4
|
+
var InstallIntegration_1 = require("./InstallIntegration");
|
|
5
|
+
Object.defineProperty(exports, "InstallIntegration", { enumerable: true, get: function () { return InstallIntegration_1.InstallIntegration; } });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ConfigureState, ObjectConfigurationsState } from '../types';
|
|
3
|
+
export declare function useConfigureState(): {
|
|
4
|
+
objectConfigurationsState: ObjectConfigurationsState;
|
|
5
|
+
setObjectConfigurationsState: React.Dispatch<React.SetStateAction<ObjectConfigurationsState>>;
|
|
6
|
+
setConfigureState: (objectName: string, configureState: ConfigureState) => void;
|
|
7
|
+
resetPendingConfigurationState: (objectName: string) => void;
|
|
8
|
+
};
|
|
9
|
+
type ConfigurationProviderProps = {
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
};
|
|
12
|
+
export declare function ConfigurationProvider({ children }: ConfigurationProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConfigurationProvider = exports.useConfigureState = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const InstallIntegrationContext_1 = require("../../../context/InstallIntegrationContext");
|
|
7
|
+
const HydratedRevisionContext_1 = require("./HydratedRevisionContext");
|
|
8
|
+
const utils_1 = require("./utils");
|
|
9
|
+
// Create a context for the configuration state
|
|
10
|
+
const ConfigurationContext = (0, react_1.createContext)(undefined);
|
|
11
|
+
const initialObjectConfigurationsState = {};
|
|
12
|
+
// Custom hook to access and update the configuration state
|
|
13
|
+
function useConfigureState() {
|
|
14
|
+
const context = (0, react_1.useContext)(ConfigurationContext);
|
|
15
|
+
if (!context) {
|
|
16
|
+
throw new Error('useConfigureState must be used within a ConfigurationProvider');
|
|
17
|
+
}
|
|
18
|
+
return context;
|
|
19
|
+
}
|
|
20
|
+
exports.useConfigureState = useConfigureState;
|
|
21
|
+
// Create a provider component for the configuration context
|
|
22
|
+
function ConfigurationProvider({ children }) {
|
|
23
|
+
const { installation } = (0, InstallIntegrationContext_1.useInstallIntegrationProps)();
|
|
24
|
+
const { hydratedRevision, loading } = (0, HydratedRevisionContext_1.useHydratedRevision)();
|
|
25
|
+
// 1. get config from installations (contains form selection state)
|
|
26
|
+
// 2. get the hydrated revision from installation revisionId (contains full form)
|
|
27
|
+
// 3. generate the configuration state from the hydrated revision and config
|
|
28
|
+
const [objectConfigurationsState, setObjectConfigurationsState,] = (0, react_1.useState)(initialObjectConfigurationsState);
|
|
29
|
+
const config = installation === null || installation === void 0 ? void 0 : installation.config;
|
|
30
|
+
(0, react_1.useEffect)(() => {
|
|
31
|
+
// set configurationState when hydratedRevision is loaded
|
|
32
|
+
// only reset when objectConfigurationsState does not exist
|
|
33
|
+
if ((hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) && !loading && config && !objectConfigurationsState) {
|
|
34
|
+
(0, utils_1.resetAllObjectsConfigurationState)(hydratedRevision, config, setObjectConfigurationsState);
|
|
35
|
+
}
|
|
36
|
+
}, [hydratedRevision, loading, config, objectConfigurationsState]);
|
|
37
|
+
// set configure state of single object
|
|
38
|
+
const setConfigureState = (0, react_1.useCallback)((objectName, configureState) => {
|
|
39
|
+
// consider moving check modified state here
|
|
40
|
+
setObjectConfigurationsState((prevState) => (Object.assign(Object.assign({}, prevState), { [objectName]: configureState })));
|
|
41
|
+
}, [setObjectConfigurationsState]);
|
|
42
|
+
// set configure state of single object
|
|
43
|
+
const resetPendingConfigurationState = (0, react_1.useCallback)((objectName) => {
|
|
44
|
+
setObjectConfigurationsState((prevObjectsConfigurationsState) => (Object.assign(Object.assign({}, prevObjectsConfigurationsState), { [objectName]: Object.assign(Object.assign({}, prevObjectsConfigurationsState[objectName]), { isOptionalFieldsModified: false, isRequiredMapFieldsModified: false }) })));
|
|
45
|
+
}, [setObjectConfigurationsState]);
|
|
46
|
+
const contextValue = (0, react_1.useMemo)(() => ({
|
|
47
|
+
objectConfigurationsState,
|
|
48
|
+
setObjectConfigurationsState,
|
|
49
|
+
setConfigureState,
|
|
50
|
+
resetPendingConfigurationState,
|
|
51
|
+
}), [objectConfigurationsState, resetPendingConfigurationState, setConfigureState]);
|
|
52
|
+
return ((0, jsx_runtime_1.jsx)(ConfigurationContext.Provider, { value: contextValue, children: children }));
|
|
53
|
+
}
|
|
54
|
+
exports.ConfigurationProvider = ConfigurationProvider;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { HydratedRevision } from '../../../services/api';
|
|
3
|
+
interface HydratedRevisionContextValue {
|
|
4
|
+
hydratedRevision: HydratedRevision | null;
|
|
5
|
+
loading: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const HydratedRevisionContext: React.Context<HydratedRevisionContextValue>;
|
|
8
|
+
export declare const useHydratedRevision: () => HydratedRevisionContextValue;
|
|
9
|
+
type HydratedRevisionProviderProps = {
|
|
10
|
+
projectId?: string | null;
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
};
|
|
13
|
+
export declare function HydratedRevisionProvider({ projectId, children, }: HydratedRevisionProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HydratedRevisionProvider = exports.useHydratedRevision = exports.HydratedRevisionContext = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const ApiKeyContext_1 = require("../../../context/ApiKeyContext");
|
|
7
|
+
const ConnectionsContext_1 = require("../../../context/ConnectionsContext");
|
|
8
|
+
const ErrorContextProvider_1 = require("../../../context/ErrorContextProvider");
|
|
9
|
+
const InstallIntegrationContext_1 = require("../../../context/InstallIntegrationContext");
|
|
10
|
+
const IntegrationListContext_1 = require("../../../context/IntegrationListContext");
|
|
11
|
+
const api_1 = require("../../../services/api");
|
|
12
|
+
const ErrorTextBox_1 = require("../ErrorTextBox");
|
|
13
|
+
exports.HydratedRevisionContext = (0, react_1.createContext)({
|
|
14
|
+
hydratedRevision: null,
|
|
15
|
+
loading: false,
|
|
16
|
+
});
|
|
17
|
+
const useHydratedRevision = () => {
|
|
18
|
+
const context = (0, react_1.useContext)(exports.HydratedRevisionContext);
|
|
19
|
+
if (!context) {
|
|
20
|
+
throw new Error('useHydratedRevision must be used within a HydratedRevisionProvider');
|
|
21
|
+
}
|
|
22
|
+
return context;
|
|
23
|
+
};
|
|
24
|
+
exports.useHydratedRevision = useHydratedRevision;
|
|
25
|
+
function HydratedRevisionProvider({ projectId, children, }) {
|
|
26
|
+
var _a;
|
|
27
|
+
const { integrationId, integrationObj } = (0, InstallIntegrationContext_1.useInstallIntegrationProps)();
|
|
28
|
+
const { integrations } = (0, IntegrationListContext_1.useIntegrationList)();
|
|
29
|
+
const [hydratedRevision, setHydratedRevision] = (0, react_1.useState)(null);
|
|
30
|
+
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
31
|
+
const { isError, removeError, setError } = (0, ErrorContextProvider_1.useErrorState)();
|
|
32
|
+
const apiKey = (0, react_1.useContext)(ApiKeyContext_1.ApiKeyContext);
|
|
33
|
+
const { selectedConnection } = (0, ConnectionsContext_1.useConnections)();
|
|
34
|
+
const connectionId = selectedConnection === null || selectedConnection === void 0 ? void 0 : selectedConnection.id;
|
|
35
|
+
const revisionId = (_a = integrationObj === null || integrationObj === void 0 ? void 0 : integrationObj.latestRevision) === null || _a === void 0 ? void 0 : _a.id;
|
|
36
|
+
const errorIntegrationIdentifier = (integrationObj === null || integrationObj === void 0 ? void 0 : integrationObj.name) || integrationId;
|
|
37
|
+
(0, react_1.useEffect)(() => {
|
|
38
|
+
// Fetch the hydrated revision data using your API call
|
|
39
|
+
if (projectId
|
|
40
|
+
&& integrationId
|
|
41
|
+
&& revisionId
|
|
42
|
+
&& connectionId
|
|
43
|
+
&& apiKey) {
|
|
44
|
+
(0, api_1.api)().getHydratedRevision({
|
|
45
|
+
projectId,
|
|
46
|
+
integrationId,
|
|
47
|
+
revisionId,
|
|
48
|
+
connectionId,
|
|
49
|
+
}, {
|
|
50
|
+
headers: {
|
|
51
|
+
'X-Api-Key': apiKey !== null && apiKey !== void 0 ? apiKey : '',
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
.then((data) => {
|
|
55
|
+
setHydratedRevision(data);
|
|
56
|
+
setLoading(false);
|
|
57
|
+
removeError(ErrorContextProvider_1.ErrorBoundary.HYDRATED_REVISION, errorIntegrationIdentifier);
|
|
58
|
+
})
|
|
59
|
+
.catch((err) => {
|
|
60
|
+
console.error(`Error loading integration ${errorIntegrationIdentifier}`, err);
|
|
61
|
+
setLoading(false);
|
|
62
|
+
setError(ErrorContextProvider_1.ErrorBoundary.HYDRATED_REVISION, errorIntegrationIdentifier);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}, [
|
|
66
|
+
projectId,
|
|
67
|
+
integrationId,
|
|
68
|
+
revisionId,
|
|
69
|
+
connectionId,
|
|
70
|
+
apiKey,
|
|
71
|
+
integrations,
|
|
72
|
+
removeError,
|
|
73
|
+
setError,
|
|
74
|
+
errorIntegrationIdentifier
|
|
75
|
+
]);
|
|
76
|
+
const contextValue = (0, react_1.useMemo)(() => ({
|
|
77
|
+
hydratedRevision,
|
|
78
|
+
loading,
|
|
79
|
+
}), [hydratedRevision, loading]);
|
|
80
|
+
return ((0, jsx_runtime_1.jsx)(exports.HydratedRevisionContext.Provider, { value: contextValue, children: isError(ErrorContextProvider_1.ErrorBoundary.HYDRATED_REVISION, errorIntegrationIdentifier) ? (0, jsx_runtime_1.jsx)(ErrorTextBox_1.ErrorTextBox, { message: `Error retrieving integration details for '${(integrationObj === null || integrationObj === void 0 ? void 0 : integrationObj.name) || integrationId || 'unknown integration'}. This is sometimes caused by insufficient permissions with your credentials'` }) : children }));
|
|
81
|
+
}
|
|
82
|
+
exports.HydratedRevisionProvider = HydratedRevisionProvider;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Config, HydratedIntegrationRead, HydratedRevision } from '../../../services/api';
|
|
2
|
+
import { ConfigureState, ConfigureStateMappingIntegrationField, ObjectConfigurationsState, SavedConfigureFields } from '../types';
|
|
3
|
+
export declare function createSavedFields(fields: ConfigureStateMappingIntegrationField[] | null | undefined): SavedConfigureFields;
|
|
4
|
+
export declare function checkFieldsEquality(prevFields: SavedConfigureFields, currentFields: SavedConfigureFields): boolean;
|
|
5
|
+
export declare function generateConfigurationState(action: HydratedIntegrationRead, objectName: string, config?: Config): ConfigureState;
|
|
6
|
+
export declare const resetConfigurationState: (hydratedRevision: HydratedRevision, config: Config | undefined, selectedObjectName: string, setConfigureState: (objectName: string, configureState: ConfigureState) => void) => void;
|
|
7
|
+
/**
|
|
8
|
+
* resets configure state for all objects in hydrated revision to hydrated revision values
|
|
9
|
+
*/
|
|
10
|
+
export declare const resetAllObjectsConfigurationState: (hydratedRevision: HydratedRevision, config: Config | undefined, setObjectConfiguresState: React.Dispatch<React.SetStateAction<ObjectConfigurationsState>>) => void;
|
|
11
|
+
/**
|
|
12
|
+
* generates selectedFields object for Config from configureState
|
|
13
|
+
* @param configureState
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export declare const generateSelectedFieldsFromConfigureState: (configureState: ConfigureState) => {};
|
|
17
|
+
/**
|
|
18
|
+
* generates selectedFieldMappings object for Config from configureState
|
|
19
|
+
* @param configureState
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
export declare const generateSelectedFieldMappingsFromConfigureState: (configureState: ConfigureState) => {};
|
|
23
|
+
/**
|
|
24
|
+
* returns a new configure state with one of its FieldMappings updated with a new value.
|
|
25
|
+
* @param fieldKey
|
|
26
|
+
* @param value
|
|
27
|
+
* @param configureState
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
export declare const setRequiredCustomMapFieldValue: (fieldKey: string, value: string, configureState: ConfigureState) => {
|
|
31
|
+
isUpdated: boolean;
|
|
32
|
+
newState: ConfigureState;
|
|
33
|
+
};
|
|
34
|
+
export declare function getConfigureState(objectName: string, objectConfigurationsState: ObjectConfigurationsState): ConfigureState;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getConfigureState = exports.setRequiredCustomMapFieldValue = exports.generateSelectedFieldMappingsFromConfigureState = exports.generateSelectedFieldsFromConfigureState = exports.resetAllObjectsConfigurationState = exports.resetConfigurationState = exports.generateConfigurationState = exports.checkFieldsEquality = exports.createSavedFields = void 0;
|
|
7
|
+
const lodash_isequal_1 = __importDefault(require("lodash.isequal"));
|
|
8
|
+
const utils_1 = require("../utils");
|
|
9
|
+
function createSavedFields(fields) {
|
|
10
|
+
const savedFields = {};
|
|
11
|
+
fields === null || fields === void 0 ? void 0 : fields.forEach((field) => {
|
|
12
|
+
const { value } = field;
|
|
13
|
+
if (value) {
|
|
14
|
+
savedFields[field.mapToName] = value;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return savedFields;
|
|
18
|
+
}
|
|
19
|
+
exports.createSavedFields = createSavedFields;
|
|
20
|
+
// uses lodash deep equality check to compare two saved fields objects
|
|
21
|
+
function checkFieldsEquality(prevFields, currentFields) {
|
|
22
|
+
return (0, lodash_isequal_1.default)(prevFields, currentFields);
|
|
23
|
+
}
|
|
24
|
+
exports.checkFieldsEquality = checkFieldsEquality;
|
|
25
|
+
function generateConfigurationState(action, objectName, config) {
|
|
26
|
+
var _a, _b, _c, _d, _e;
|
|
27
|
+
const object = (0, utils_1.getStandardObjectFromAction)(action, objectName);
|
|
28
|
+
const requiredFields = object && (0, utils_1.getRequiredFieldsFromObject)(object);
|
|
29
|
+
const optionalFields = object && (0, utils_1.getOptionalFieldsFromObject)(object);
|
|
30
|
+
// todo refactor requiredMapFields to separate form state from hydrated revision
|
|
31
|
+
// map over requiredMapFields and get value from config
|
|
32
|
+
const requiredMapFields = object ? (_a = (0, utils_1.getRequiredMapFieldsFromObject)(object)) === null || _a === void 0 ? void 0 : _a.map((field) => (Object.assign(Object.assign({}, field), { value: config ? (0, utils_1.getValueFromConfigCustomMapping)(config, objectName,
|
|
33
|
+
// should only use mapToName for custom mapping fields
|
|
34
|
+
(0, utils_1.getFieldKeyValue)(field)) : '' }))) : null; // type hack - TODO fix
|
|
35
|
+
const allFields = (object === null || object === void 0 ? void 0 : object.allFields) || [];
|
|
36
|
+
const selectedFields = ((_e = (_d = (_c = (_b = config === null || config === void 0 ? void 0 : config.content) === null || _b === void 0 ? void 0 : _b.read) === null || _c === void 0 ? void 0 : _c.standardObjects) === null || _d === void 0 ? void 0 : _d[objectName]) === null || _e === void 0 ? void 0 : _e.selectedFields) || {};
|
|
37
|
+
const optionalFieldsSaved = Object.assign({}, selectedFields);
|
|
38
|
+
const requiredMapFieldsSaved = createSavedFields(requiredMapFields);
|
|
39
|
+
return {
|
|
40
|
+
allFields,
|
|
41
|
+
requiredFields,
|
|
42
|
+
optionalFields,
|
|
43
|
+
requiredMapFields,
|
|
44
|
+
selectedOptionalFields: selectedFields,
|
|
45
|
+
isOptionalFieldsModified: false,
|
|
46
|
+
isRequiredMapFieldsModified: false,
|
|
47
|
+
savedConfig: {
|
|
48
|
+
optionalFields: optionalFieldsSaved,
|
|
49
|
+
requiredMapFields: requiredMapFieldsSaved, // from config
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
exports.generateConfigurationState = generateConfigurationState;
|
|
54
|
+
// resets configure state for single object to hydrated revision values
|
|
55
|
+
const resetConfigurationState = (hydratedRevision, config, selectedObjectName, setConfigureState) => {
|
|
56
|
+
var _a;
|
|
57
|
+
const readAction = (_a = hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) === null || _a === void 0 ? void 0 : _a.read;
|
|
58
|
+
if (!readAction) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const state = generateConfigurationState(readAction, selectedObjectName, config);
|
|
62
|
+
setConfigureState(selectedObjectName, state);
|
|
63
|
+
};
|
|
64
|
+
exports.resetConfigurationState = resetConfigurationState;
|
|
65
|
+
/**
|
|
66
|
+
* resets configure state for all objects in hydrated revision to hydrated revision values
|
|
67
|
+
*/
|
|
68
|
+
const resetAllObjectsConfigurationState = (hydratedRevision, config, setObjectConfiguresState) => {
|
|
69
|
+
const navObjects = (0, utils_1.generateNavObjects)(config, hydratedRevision);
|
|
70
|
+
const objectConfigurationsState = {};
|
|
71
|
+
navObjects.forEach(({ name, completed }) => {
|
|
72
|
+
var _a;
|
|
73
|
+
const readAction = (_a = hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) === null || _a === void 0 ? void 0 : _a.read;
|
|
74
|
+
if (completed && readAction) {
|
|
75
|
+
objectConfigurationsState[name] = generateConfigurationState(readAction, name, config);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
setObjectConfiguresState(objectConfigurationsState);
|
|
79
|
+
};
|
|
80
|
+
exports.resetAllObjectsConfigurationState = resetAllObjectsConfigurationState;
|
|
81
|
+
/**
|
|
82
|
+
* generates selectedFields object for Config from configureState
|
|
83
|
+
* @param configureState
|
|
84
|
+
* @returns
|
|
85
|
+
*/
|
|
86
|
+
const generateSelectedFieldsFromConfigureState = (configureState) => {
|
|
87
|
+
const { requiredFields, selectedOptionalFields } = configureState;
|
|
88
|
+
const fields = new Set();
|
|
89
|
+
requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.forEach((field) => fields.add((0, utils_1.getFieldKeyValue)(field)));
|
|
90
|
+
// convert set to object for config
|
|
91
|
+
const selectedFields = Array.from(fields).reduce((acc, field) => (Object.assign(Object.assign({}, acc), { [field]: true })), {});
|
|
92
|
+
return Object.assign(Object.assign({}, selectedFields), (selectedOptionalFields || {}));
|
|
93
|
+
};
|
|
94
|
+
exports.generateSelectedFieldsFromConfigureState = generateSelectedFieldsFromConfigureState;
|
|
95
|
+
/**
|
|
96
|
+
* generates selectedFieldMappings object for Config from configureState
|
|
97
|
+
* @param configureState
|
|
98
|
+
* @returns
|
|
99
|
+
*/
|
|
100
|
+
const generateSelectedFieldMappingsFromConfigureState = (configureState) => {
|
|
101
|
+
const { requiredMapFields } = configureState;
|
|
102
|
+
const requiredMapFieldsConfig = (requiredMapFields || []).reduce((acc, field) => {
|
|
103
|
+
const key = (0, utils_1.getFieldKeyValue)(field);
|
|
104
|
+
return Object.assign(Object.assign({}, acc), { [key]: field.value });
|
|
105
|
+
}, {});
|
|
106
|
+
return requiredMapFieldsConfig;
|
|
107
|
+
};
|
|
108
|
+
exports.generateSelectedFieldMappingsFromConfigureState = generateSelectedFieldMappingsFromConfigureState;
|
|
109
|
+
/**
|
|
110
|
+
* returns a new configure state with one of its FieldMappings updated with a new value.
|
|
111
|
+
* @param fieldKey
|
|
112
|
+
* @param value
|
|
113
|
+
* @param configureState
|
|
114
|
+
* @returns
|
|
115
|
+
*/
|
|
116
|
+
const setRequiredCustomMapFieldValue = (fieldKey, value, configureState) => {
|
|
117
|
+
const { requiredMapFields } = configureState;
|
|
118
|
+
if (requiredMapFields === null) {
|
|
119
|
+
return { isUpdated: false, newState: configureState };
|
|
120
|
+
}
|
|
121
|
+
// flag to know if field was updated
|
|
122
|
+
let isUpdated = false;
|
|
123
|
+
const updatedRequiredMapFields = requiredMapFields.map((field) => {
|
|
124
|
+
// updated field
|
|
125
|
+
if (field.mapToName === fieldKey) {
|
|
126
|
+
isUpdated = true;
|
|
127
|
+
return Object.assign(Object.assign({}, field), { value });
|
|
128
|
+
}
|
|
129
|
+
// else return a copy of the field
|
|
130
|
+
return Object.assign({}, field);
|
|
131
|
+
});
|
|
132
|
+
if (isUpdated) {
|
|
133
|
+
const savedFields = configureState.savedConfig.requiredMapFields;
|
|
134
|
+
const updatedFields = createSavedFields(updatedRequiredMapFields);
|
|
135
|
+
const isModified = !checkFieldsEquality(savedFields, updatedFields);
|
|
136
|
+
const newState = Object.assign(Object.assign({}, configureState), { requiredMapFields: updatedRequiredMapFields, isRequiredMapFieldsModified: isModified });
|
|
137
|
+
return { isUpdated, newState };
|
|
138
|
+
}
|
|
139
|
+
return { isUpdated: false, newState: configureState };
|
|
140
|
+
};
|
|
141
|
+
exports.setRequiredCustomMapFieldValue = setRequiredCustomMapFieldValue;
|
|
142
|
+
// get configure state of single object
|
|
143
|
+
function getConfigureState(objectName, objectConfigurationsState) {
|
|
144
|
+
return objectConfigurationsState[objectName] || undefined;
|
|
145
|
+
}
|
|
146
|
+
exports.getConfigureState = getConfigureState;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { HydratedIntegrationField, HydratedIntegrationFieldExistent, IntegrationFieldMapping } from '../../services/api';
|
|
2
|
+
export type ConfigureStateIntegrationField = HydratedIntegrationFieldExistent & {
|
|
3
|
+
value: string | number | boolean | null;
|
|
4
|
+
};
|
|
5
|
+
export type ConfigureStateMappingIntegrationField = IntegrationFieldMapping & {
|
|
6
|
+
value: string | number | undefined;
|
|
7
|
+
};
|
|
8
|
+
export type SelectOptionalFields = {
|
|
9
|
+
[key: string]: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type SavedConfigureFields = Record<string, string | number | boolean | null>;
|
|
12
|
+
type SavedConfigureState = {
|
|
13
|
+
optionalFields: SelectOptionalFields;
|
|
14
|
+
requiredMapFields: SavedConfigureFields;
|
|
15
|
+
};
|
|
16
|
+
export type ConfigureState = {
|
|
17
|
+
allFields: HydratedIntegrationFieldExistent[] | null;
|
|
18
|
+
requiredFields: HydratedIntegrationField[] | null;
|
|
19
|
+
optionalFields: HydratedIntegrationField[] | null;
|
|
20
|
+
requiredMapFields: ConfigureStateMappingIntegrationField[] | null;
|
|
21
|
+
selectedOptionalFields: SelectOptionalFields | null;
|
|
22
|
+
isOptionalFieldsModified: boolean;
|
|
23
|
+
isRequiredMapFieldsModified: boolean;
|
|
24
|
+
savedConfig: SavedConfigureState;
|
|
25
|
+
};
|
|
26
|
+
export type ObjectConfigurationsState = Record<string, ConfigureState>;
|
|
27
|
+
export type NavObject = {
|
|
28
|
+
name: string;
|
|
29
|
+
completed: boolean;
|
|
30
|
+
};
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Config, HydratedIntegrationField, HydratedIntegrationObject, HydratedIntegrationRead, HydratedRevision, IntegrationFieldMapping } from '../../services/api';
|
|
2
|
+
import { NavObject } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* type guard for IntegrationFieldMapping | IntegrationFieldExistent
|
|
5
|
+
*
|
|
6
|
+
* @param field HydratedIntegrationField
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function isIntegrationFieldMapping(field: HydratedIntegrationField): field is IntegrationFieldMapping;
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param action HydratedIntegrationAction
|
|
13
|
+
* @param objectName string (account, contect, etc...)
|
|
14
|
+
* @returns HydratedIntegrationObject | null
|
|
15
|
+
*/
|
|
16
|
+
export declare function getStandardObjectFromAction(action: HydratedIntegrationRead, objectName: string): HydratedIntegrationObject | null;
|
|
17
|
+
export declare function getRequiredFieldsFromObject(object: HydratedIntegrationObject): HydratedIntegrationField[] | null;
|
|
18
|
+
export declare function getRequiredMapFieldsFromObject(object: HydratedIntegrationObject): HydratedIntegrationField[] | null;
|
|
19
|
+
export declare function getOptionalFieldsFromObject(object: HydratedIntegrationObject): HydratedIntegrationField[] | null;
|
|
20
|
+
export declare const getReadObject: (config: Config, objectName: string) => any;
|
|
21
|
+
export declare function getValueFromConfigExist(config: Config, objectName: string, key: string): boolean;
|
|
22
|
+
export declare function getValueFromConfigCustomMapping(config: Config, objectName: string, key: string): string;
|
|
23
|
+
export declare function getFieldKeyValue(field: HydratedIntegrationField): string;
|
|
24
|
+
export declare function generateNavObjects(config: Config | undefined, hydratedRevision: HydratedRevision): NavObject[];
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateNavObjects = exports.getFieldKeyValue = exports.getValueFromConfigCustomMapping = exports.getValueFromConfigExist = exports.getReadObject = exports.getOptionalFieldsFromObject = exports.getRequiredMapFieldsFromObject = exports.getRequiredFieldsFromObject = exports.getStandardObjectFromAction = exports.isIntegrationFieldMapping = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* type guard for IntegrationFieldMapping | IntegrationFieldExistent
|
|
6
|
+
*
|
|
7
|
+
* @param field HydratedIntegrationField
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
function isIntegrationFieldMapping(field) {
|
|
11
|
+
return field.mapToName !== undefined;
|
|
12
|
+
}
|
|
13
|
+
exports.isIntegrationFieldMapping = isIntegrationFieldMapping;
|
|
14
|
+
// 1. get standard object
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param action HydratedIntegrationAction
|
|
18
|
+
* @param objectName string (account, contect, etc...)
|
|
19
|
+
* @returns HydratedIntegrationObject | null
|
|
20
|
+
*/
|
|
21
|
+
function getStandardObjectFromAction(action, objectName) {
|
|
22
|
+
var _a;
|
|
23
|
+
return ((_a = action === null || action === void 0 ? void 0 : action.standardObjects) === null || _a === void 0 ? void 0 : _a.find((object) => object.objectName === objectName)) || null;
|
|
24
|
+
}
|
|
25
|
+
exports.getStandardObjectFromAction = getStandardObjectFromAction;
|
|
26
|
+
// 2a. get required fields
|
|
27
|
+
function getRequiredFieldsFromObject(object) {
|
|
28
|
+
var _a;
|
|
29
|
+
return ((_a = object === null || object === void 0 ? void 0 : object.requiredFields) === null || _a === void 0 ? void 0 : _a.filter((rf) => !isIntegrationFieldMapping(rf) && !!rf.fieldName)) || null;
|
|
30
|
+
}
|
|
31
|
+
exports.getRequiredFieldsFromObject = getRequiredFieldsFromObject;
|
|
32
|
+
// 2b. get required custom mapping fields
|
|
33
|
+
function getRequiredMapFieldsFromObject(object) {
|
|
34
|
+
var _a;
|
|
35
|
+
return ((_a = object === null || object === void 0 ? void 0 : object.requiredFields) === null || _a === void 0 ? void 0 : _a.filter((rf) => isIntegrationFieldMapping(rf) && !!rf.mapToName)) || null;
|
|
36
|
+
}
|
|
37
|
+
exports.getRequiredMapFieldsFromObject = getRequiredMapFieldsFromObject;
|
|
38
|
+
// 3. get optional fields
|
|
39
|
+
function getOptionalFieldsFromObject(object) {
|
|
40
|
+
var _a;
|
|
41
|
+
return ((_a = object === null || object === void 0 ? void 0 : object.optionalFields) === null || _a === void 0 ? void 0 : _a.filter((rf) => !isIntegrationFieldMapping(rf) && !!rf.fieldName)) || null;
|
|
42
|
+
}
|
|
43
|
+
exports.getOptionalFieldsFromObject = getOptionalFieldsFromObject;
|
|
44
|
+
const getReadObject = (config, objectName) => { var _a, _b, _c; return (_c = (_b = (_a = config === null || config === void 0 ? void 0 : config.content) === null || _a === void 0 ? void 0 : _a.read) === null || _b === void 0 ? void 0 : _b.standardObjects) === null || _c === void 0 ? void 0 : _c[objectName]; };
|
|
45
|
+
exports.getReadObject = getReadObject;
|
|
46
|
+
// 4a. get value for field
|
|
47
|
+
function getValueFromConfigExist(config, objectName, key) {
|
|
48
|
+
var _a;
|
|
49
|
+
const object = (0, exports.getReadObject)(config, objectName);
|
|
50
|
+
return ((_a = object === null || object === void 0 ? void 0 : object.selectedFields) === null || _a === void 0 ? void 0 : _a[key]) || false;
|
|
51
|
+
}
|
|
52
|
+
exports.getValueFromConfigExist = getValueFromConfigExist;
|
|
53
|
+
// 4b. get value for custom mapping field
|
|
54
|
+
function getValueFromConfigCustomMapping(config, objectName, key) {
|
|
55
|
+
var _a;
|
|
56
|
+
const object = (0, exports.getReadObject)(config, objectName);
|
|
57
|
+
return ((_a = object === null || object === void 0 ? void 0 : object.selectedFieldMappings) === null || _a === void 0 ? void 0 : _a[key]) || '';
|
|
58
|
+
}
|
|
59
|
+
exports.getValueFromConfigCustomMapping = getValueFromConfigCustomMapping;
|
|
60
|
+
// aux. get field value based on type guard
|
|
61
|
+
function getFieldKeyValue(field) {
|
|
62
|
+
if (isIntegrationFieldMapping(field)) {
|
|
63
|
+
return field.mapToName; // custom mapping
|
|
64
|
+
}
|
|
65
|
+
return field.fieldName; // existant field
|
|
66
|
+
}
|
|
67
|
+
exports.getFieldKeyValue = getFieldKeyValue;
|
|
68
|
+
// generates standard objects and whether they are complete based on config and hydrated revision
|
|
69
|
+
function generateNavObjects(config, hydratedRevision) {
|
|
70
|
+
var _a, _b, _c;
|
|
71
|
+
const navObjects = [];
|
|
72
|
+
(_c = (_b = (_a = hydratedRevision.content) === null || _a === void 0 ? void 0 : _a.read) === null || _b === void 0 ? void 0 : _b.standardObjects) === null || _c === void 0 ? void 0 : _c.forEach((object) => {
|
|
73
|
+
navObjects.push({
|
|
74
|
+
name: object === null || object === void 0 ? void 0 : object.objectName,
|
|
75
|
+
// if no config, object is not completed
|
|
76
|
+
// object is completed if the key exists in the config
|
|
77
|
+
completed: config ? !!(0, exports.getReadObject)(config, object.objectName) : false,
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
return navObjects;
|
|
81
|
+
}
|
|
82
|
+
exports.generateNavObjects = generateNavObjects;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuthPopup.tsx
|
|
3
|
+
*
|
|
4
|
+
* Takes a URL and creates a popup showing that page.
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
type PopupProps = {
|
|
8
|
+
url: string | null;
|
|
9
|
+
title: string;
|
|
10
|
+
onClose: (err: string | null) => void;
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
};
|
|
13
|
+
declare function OAuthPopup({ title, url, children, onClose, }: PopupProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export default OAuthPopup;
|