@amp-labs/react 1.0.2 → 1.2.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/README.md +1 -1
- package/build/generated-sources/api/src/apis/AllowedDomainApi.d.ts +79 -0
- package/build/generated-sources/api/src/apis/AllowedDomainApi.js +101 -0
- package/build/generated-sources/api/src/apis/ConnectionApi.d.ts +82 -0
- package/build/generated-sources/api/src/apis/ConnectionApi.js +107 -0
- package/build/generated-sources/api/src/apis/ConsumerApi.d.ts +52 -0
- package/build/generated-sources/api/src/apis/ConsumerApi.js +75 -0
- package/build/generated-sources/api/src/apis/DestinationApi.d.ts +78 -0
- package/build/generated-sources/api/src/apis/DestinationApi.js +102 -0
- package/build/generated-sources/api/src/apis/GroupApi.d.ts +52 -0
- package/build/generated-sources/api/src/apis/GroupApi.js +75 -0
- package/build/generated-sources/api/src/apis/InstallationApi.d.ts +168 -0
- package/build/generated-sources/api/src/apis/InstallationApi.js +205 -0
- package/build/generated-sources/api/src/apis/IntegrationApi.d.ts +128 -0
- package/build/generated-sources/api/src/apis/IntegrationApi.js +154 -0
- package/build/generated-sources/api/src/apis/OAuthApi.d.ts +76 -0
- package/build/generated-sources/api/src/apis/OAuthApi.js +102 -0
- package/build/generated-sources/api/src/apis/OperationApi.d.ts +80 -0
- package/build/generated-sources/api/src/apis/OperationApi.js +104 -0
- package/build/generated-sources/api/src/apis/OperationLogApi.d.ts +55 -0
- package/build/generated-sources/api/src/apis/OperationLogApi.js +76 -0
- package/build/generated-sources/api/src/apis/ProjectApi.d.ts +124 -0
- package/build/generated-sources/api/src/apis/ProjectApi.js +148 -0
- package/build/generated-sources/api/src/apis/ProjectMembershipApi.d.ts +126 -0
- package/build/generated-sources/api/src/apis/ProjectMembershipApi.js +154 -0
- package/build/generated-sources/api/src/apis/ProviderAppApi.d.ts +130 -0
- package/build/generated-sources/api/src/apis/ProviderAppApi.js +158 -0
- package/build/generated-sources/api/src/apis/RevisionApi.d.ts +87 -0
- package/build/generated-sources/api/src/apis/RevisionApi.js +113 -0
- package/build/generated-sources/api/src/apis/UploadURLApi.d.ts +46 -0
- package/build/generated-sources/api/src/apis/UploadURLApi.js +68 -0
- package/build/generated-sources/api/src/apis/index.d.ts +15 -1
- package/build/generated-sources/api/src/apis/index.js +15 -1
- package/build/generated-sources/api/src/models/CreateInstallationRequest.d.ts +2 -2
- package/build/generated-sources/api/src/models/CreateInstallationRequest.js +2 -2
- package/build/generated-sources/api/src/models/CreateInstallationRequestConfig.d.ts +3 -3
- package/build/generated-sources/api/src/models/CreateInstallationRequestConfig.js +3 -4
- package/build/generated-sources/api/src/models/Destination.d.ts +44 -0
- package/build/generated-sources/api/src/models/Destination.js +57 -0
- package/build/generated-sources/api/src/models/DestinationMetadata.d.ts +39 -0
- package/build/generated-sources/api/src/models/{CreateDestinationRequestMetadata.js → DestinationMetadata.js} +11 -11
- package/build/generated-sources/api/src/models/OauthConnectRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/OauthConnectRequest.js +1 -2
- package/build/generated-sources/api/src/models/Operation.d.ts +6 -12
- package/build/generated-sources/api/src/models/Operation.js +3 -6
- package/build/generated-sources/api/src/models/OperationLog.d.ts +43 -0
- package/build/generated-sources/api/src/models/OperationLog.js +56 -0
- package/build/generated-sources/api/src/models/ProviderApp.d.ts +6 -0
- package/build/generated-sources/api/src/models/ProviderApp.js +2 -0
- package/build/generated-sources/api/src/models/index.d.ts +3 -2
- package/build/generated-sources/api/src/models/index.js +3 -2
- package/build/src/assets/TrashIcon.js +3 -1
- package/build/src/components/Configure/InstallIntegration.d.ts +4 -1
- package/build/src/components/Configure/InstallIntegration.js +10 -23
- package/build/src/components/Configure/actions/onSaveReadCreateInstallation.d.ts +3 -0
- package/build/src/components/Configure/actions/{onSaveCreate.js → onSaveReadCreateInstallation.js} +7 -6
- package/build/src/components/Configure/actions/onSaveReadUpdateInstallation.d.ts +3 -0
- package/build/src/components/Configure/actions/{onSaveUpdate.js → onSaveReadUpdateInstallation.js} +13 -8
- package/build/src/components/Configure/actions/write/generateConfigWriteObjects.d.ts +26 -0
- package/build/src/components/Configure/actions/write/generateConfigWriteObjects.js +41 -0
- package/build/src/components/Configure/actions/write/onSaveWriteCreateInstallation.d.ts +3 -0
- package/build/src/components/Configure/actions/write/onSaveWriteCreateInstallation.js +85 -0
- package/build/src/components/Configure/actions/write/onSaveWriteUpdateInstallation.d.ts +3 -0
- package/build/src/components/Configure/actions/write/onSaveWriteUpdateInstallation.js +60 -0
- package/build/src/components/Configure/{ConfigureInstallationBase.d.ts → content/ConfigureInstallationBase.d.ts} +2 -1
- package/build/src/components/Configure/content/ConfigureInstallationBase.js +36 -0
- package/build/src/components/Configure/content/CreateInstallation.js +83 -0
- package/build/src/components/Configure/content/InstallationContent.d.ts +1 -0
- package/build/src/components/Configure/content/InstallationContent.js +20 -0
- package/build/src/components/Configure/{UninstallContent.js → content/UninstallContent.js} +15 -7
- package/build/src/components/Configure/{UpdateInstallation.d.ts → content/UpdateInstallation.d.ts} +1 -1
- package/build/src/components/Configure/{UpdateInstallation.js → content/UpdateInstallation.js} +42 -28
- package/build/src/components/Configure/{fields → content/fields}/FieldMappings/FieldMapping.d.ts +1 -1
- package/build/src/components/Configure/{fields → content/fields}/FieldMappings/FieldMapping.js +4 -7
- package/build/src/components/Configure/{fields → content/fields}/FieldMappings/RequiredFieldMappings.js +10 -11
- package/build/src/components/Configure/{fields → content/fields}/FieldMappings/setFieldMapping.d.ts +1 -1
- package/build/src/components/Configure/content/fields/FieldMappings/setFieldMapping.js +21 -0
- package/build/src/components/Configure/{fields → content/fields}/OptionalFields/OptionalFields.js +9 -14
- package/build/src/components/Configure/{fields → content/fields}/OptionalFields/setOptionalField.d.ts +1 -1
- package/build/src/components/Configure/content/fields/OptionalFields/setOptionalField.js +27 -0
- package/build/src/components/Configure/content/fields/ReadFields.d.ts +1 -0
- package/build/src/components/Configure/content/fields/ReadFields.js +11 -0
- package/build/src/components/Configure/content/fields/RequiredFields.js +23 -0
- package/build/src/components/Configure/content/fields/WriteFields/WriteFields.d.ts +1 -0
- package/build/src/components/Configure/content/fields/WriteFields/WriteFields.js +22 -0
- package/build/src/components/Configure/content/fields/WriteFields/index.d.ts +2 -0
- package/build/src/components/Configure/content/fields/WriteFields/index.js +5 -0
- package/build/src/components/Configure/content/fields/WriteFields/setNonConfigurableWriteField.d.ts +3 -0
- package/build/src/components/Configure/content/fields/WriteFields/setNonConfigurableWriteField.js +32 -0
- package/build/src/components/Configure/content/useMutateInstallation.d.ts +23 -0
- package/build/src/components/Configure/content/useMutateInstallation.js +47 -0
- package/build/src/components/Configure/content/useSelectedConfigureState.d.ts +72 -0
- package/build/src/components/Configure/content/useSelectedConfigureState.js +24 -0
- package/build/src/components/Configure/{ProtectedConnectionLayout.d.ts → layout/ProtectedConnectionLayout.d.ts} +2 -1
- package/build/src/components/Configure/layout/ProtectedConnectionLayout.js +34 -0
- package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/NavObjectItem.d.ts +1 -0
- package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/NavObjectItem.js +3 -3
- package/build/src/components/Configure/nav/ObjectManagementNav/OtherTab.d.ts +7 -0
- package/build/src/components/Configure/nav/ObjectManagementNav/OtherTab.js +11 -0
- package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/UninstallInstallation.d.ts +1 -1
- package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/UninstallInstallation.js +2 -2
- package/build/src/components/Configure/nav/ObjectManagementNav/constant.d.ts +1 -0
- package/build/src/components/Configure/nav/ObjectManagementNav/constant.js +4 -0
- package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/index.d.ts +1 -0
- package/build/src/components/Configure/nav/ObjectManagementNav/index.js +61 -0
- package/build/src/components/Configure/state/ConfigurationStateProvider.d.ts +70 -42
- package/build/src/components/Configure/state/ConfigurationStateProvider.js +39 -17
- package/build/src/components/Configure/state/HydratedRevisionContext.js +11 -9
- package/build/src/components/Configure/state/utils.d.ts +2 -2
- package/build/src/components/Configure/state/utils.js +44 -19
- package/build/src/components/Configure/types.d.ts +22 -6
- package/build/src/components/Configure/utils.d.ts +3 -2
- package/build/src/components/Configure/utils.js +25 -5
- package/build/src/components/Connect/ConnectProvider.d.ts +3 -1
- package/build/src/components/Connect/ConnectProvider.js +6 -12
- package/build/src/components/Connect/ConnectedSuccessBox.d.ts +5 -0
- package/build/src/components/Connect/ConnectedSuccessBox.js +13 -0
- package/build/src/components/Connect/useConnectionHandler.d.ts +10 -0
- package/build/src/components/Connect/useConnectionHandler.js +24 -0
- package/build/src/components/ErrorTextBox.js +11 -0
- package/build/src/components/Oauth/NoSubdomainEntry/LandingContent.d.ts +8 -0
- package/build/src/components/Oauth/NoSubdomainEntry/LandingContent.js +11 -0
- package/build/src/components/Oauth/NoSubdomainEntry/NoSubdomainOauthFlow.d.ts +16 -0
- package/build/src/components/Oauth/NoSubdomainEntry/NoSubdomainOauthFlow.js +50 -0
- package/build/src/components/Oauth/OAuthErrorAlert.d.ts +5 -0
- package/build/src/components/Oauth/OAuthErrorAlert.js +12 -0
- package/build/src/components/{Connect → Oauth}/OAuthPopup.js +8 -10
- package/build/src/components/{Salesforce → Oauth/Salesforce}/SalesforceOauthFlow.d.ts +2 -2
- package/build/src/components/Oauth/Salesforce/SalesforceOauthFlow.js +57 -0
- package/build/src/components/Oauth/Salesforce/SubdomainEntry.d.ts +8 -0
- package/build/src/components/Oauth/Salesforce/SubdomainEntry.js +12 -0
- package/build/src/components/Oauth/fetchOAuthCallbackURL.d.ts +1 -0
- package/build/src/components/Oauth/fetchOAuthCallbackURL.js +28 -0
- package/build/src/components/RedirectHandler/RedirectHandler.d.ts +15 -0
- package/build/src/components/RedirectHandler/RedirectHandler.js +31 -0
- package/build/src/components/RedirectHandler/index.d.ts +1 -0
- package/build/src/components/RedirectHandler/index.js +5 -0
- package/build/src/constants.d.ts +1 -0
- package/build/src/constants.js +2 -1
- package/build/src/{components/AmpersandProvider/AmpersandProvider.js → context/AmpersandContextProvider/AmpersandContextProvider.js} +6 -6
- package/build/src/context/AmpersandContextProvider/index.d.ts +1 -0
- package/build/src/{components/AmpersandProvider → context/AmpersandContextProvider}/index.js +1 -1
- package/build/src/context/{ConnectionsContext.js → ConnectionsContextProvider.js} +11 -10
- package/build/src/context/{InstallIntegrationContext.d.ts → InstallIntegrationContextProvider.d.ts} +7 -2
- package/build/src/context/{InstallIntegrationContext.js → InstallIntegrationContextProvider.js} +29 -14
- package/build/src/context/{IntegrationListContext.js → IntegrationListContextProvider.js} +4 -4
- package/build/src/context/{ProjectContext.js → ProjectContextProvider.js} +4 -4
- package/build/src/hooks/useIsIntegrationInstalled.js +7 -7
- package/build/src/index.d.ts +1 -2
- package/build/src/index.js +1 -2
- package/build/src/public/index.d.ts +7 -0
- package/build/src/{components → public}/index.js +7 -3
- package/build/src/services/ApiService.d.ts +27 -0
- package/build/src/services/ApiService.js +34 -0
- package/build/src/services/api.d.ts +5 -4
- package/build/src/services/api.js +11 -6
- package/package.json +3 -3
- package/build/generated-sources/api/src/apis/DefaultApi.d.ts +0 -904
- package/build/generated-sources/api/src/apis/DefaultApi.js +0 -992
- package/build/generated-sources/api/src/models/CreateDestinationRequest.d.ts +0 -44
- package/build/generated-sources/api/src/models/CreateDestinationRequest.js +0 -57
- package/build/generated-sources/api/src/models/CreateDestinationRequestMetadata.d.ts +0 -39
- package/build/src/components/AmpersandProvider/index.d.ts +0 -1
- package/build/src/components/CenteredTextBox/CenteredTextBox.d.ts +0 -5
- package/build/src/components/CenteredTextBox/CenteredTextBox.js +0 -8
- package/build/src/components/Configure/ConfigureInstallationBase.js +0 -29
- package/build/src/components/Configure/CreateInstallation.js +0 -70
- package/build/src/components/Configure/ErrorTextBox.js +0 -9
- package/build/src/components/Configure/ObjectManagementNav/index.js +0 -52
- package/build/src/components/Configure/ProtectedConnectionLayout.js +0 -33
- package/build/src/components/Configure/actions/onSaveCreate.d.ts +0 -3
- package/build/src/components/Configure/actions/onSaveUpdate.d.ts +0 -3
- package/build/src/components/Configure/fields/FieldMappings/setFieldMapping.js +0 -18
- package/build/src/components/Configure/fields/OptionalFields/setOptionalField.js +0 -21
- package/build/src/components/Configure/fields/RequiredFields.js +0 -27
- package/build/src/components/Salesforce/SalesforceOauthFlow.js +0 -89
- package/build/src/components/index.d.ts +0 -3
- /package/build/src/components/Configure/{CreateInstallation.d.ts → content/CreateInstallation.d.ts} +0 -0
- /package/build/src/components/Configure/{UninstallContent.d.ts → content/UninstallContent.d.ts} +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/FieldHeader.d.ts +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/FieldHeader.js +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/FieldMappings/RequiredFieldMappings.d.ts +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/FieldMappings/index.d.ts +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/FieldMappings/index.js +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/OptionalFields/OptionalFields.d.ts +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/OptionalFields/index.d.ts +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/OptionalFields/index.js +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/RequiredFields.d.ts +0 -0
- /package/build/src/components/{Configure/ErrorTextBox.d.ts → ErrorTextBox.d.ts} +0 -0
- /package/build/src/components/{Connect → Oauth}/OAuthPopup.d.ts +0 -0
- /package/build/src/{components/AmpersandProvider/AmpersandProvider.d.ts → context/AmpersandContextProvider/AmpersandContextProvider.d.ts} +0 -0
- /package/build/src/context/{ApiKeyProvider.d.ts → ApiKeyContextProvider.d.ts} +0 -0
- /package/build/src/context/{ApiKeyProvider.js → ApiKeyContextProvider.js} +0 -0
- /package/build/src/context/{ConnectionsContext.d.ts → ConnectionsContextProvider.d.ts} +0 -0
- /package/build/src/context/{IntegrationListContext.d.ts → IntegrationListContextProvider.d.ts} +0 -0
- /package/build/src/context/{ProjectContext.d.ts → ProjectContextProvider.d.ts} +0 -0
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
import { HydratedIntegrationField, HydratedIntegrationFieldExistent, IntegrationFieldMapping } from '../../services/api';
|
|
1
|
+
import { HydratedIntegrationField, HydratedIntegrationFieldExistent, HydratedIntegrationWriteObject, IntegrationFieldMapping } from '../../services/api';
|
|
2
|
+
export type SelectedNonConfigurableWriteFields = {
|
|
3
|
+
[key: string]: boolean;
|
|
4
|
+
};
|
|
5
|
+
type SavedWriteConfigureState = {
|
|
6
|
+
selectedNonConfigurableWriteFields: SelectedNonConfigurableWriteFields;
|
|
7
|
+
};
|
|
8
|
+
export type ConfigureStateWrite = {
|
|
9
|
+
writeObjects: HydratedIntegrationWriteObject[] | null;
|
|
10
|
+
selectedNonConfigurableWriteFields: SelectedNonConfigurableWriteFields | null;
|
|
11
|
+
isWriteModified: boolean;
|
|
12
|
+
savedConfig: SavedWriteConfigureState;
|
|
13
|
+
};
|
|
2
14
|
export type SelectOptionalFields = {
|
|
3
15
|
[key: string]: boolean;
|
|
4
16
|
};
|
|
5
17
|
export type SelectMappingFields = {
|
|
6
18
|
[key: string]: string | undefined;
|
|
7
19
|
};
|
|
8
|
-
type
|
|
9
|
-
optionalFields: SelectOptionalFields;
|
|
10
|
-
requiredMapFields: SelectMappingFields;
|
|
11
|
-
};
|
|
12
|
-
export type ConfigureState = {
|
|
20
|
+
export type ConfigureStateRead = {
|
|
13
21
|
allFields: HydratedIntegrationFieldExistent[] | null;
|
|
14
22
|
requiredFields: HydratedIntegrationField[] | null;
|
|
15
23
|
optionalFields: HydratedIntegrationField[] | null;
|
|
@@ -20,6 +28,14 @@ export type ConfigureState = {
|
|
|
20
28
|
isRequiredMapFieldsModified: boolean;
|
|
21
29
|
savedConfig: SavedConfigureState;
|
|
22
30
|
};
|
|
31
|
+
type SavedConfigureState = {
|
|
32
|
+
optionalFields: SelectOptionalFields;
|
|
33
|
+
requiredMapFields: SelectMappingFields;
|
|
34
|
+
};
|
|
35
|
+
export type ConfigureState = {
|
|
36
|
+
read: ConfigureStateRead | null;
|
|
37
|
+
write: ConfigureStateWrite | null;
|
|
38
|
+
};
|
|
23
39
|
export type ObjectConfigurationsState = Record<string, ConfigureState>;
|
|
24
40
|
export type NavObject = {
|
|
25
41
|
name: string;
|
|
@@ -11,7 +11,7 @@ export declare function isIntegrationFieldMapping(field: HydratedIntegrationFiel
|
|
|
11
11
|
/**
|
|
12
12
|
*
|
|
13
13
|
* @param action HydratedIntegrationAction
|
|
14
|
-
* @param objectName string (account,
|
|
14
|
+
* @param objectName string (account, contact, etc...)
|
|
15
15
|
* @returns HydratedIntegrationObject | null
|
|
16
16
|
*/
|
|
17
17
|
export declare function getStandardObjectFromAction(action: HydratedIntegrationRead, objectName: string): HydratedIntegrationObject | null;
|
|
@@ -20,7 +20,8 @@ export declare function getRequiredMapFieldsFromObject(object: HydratedIntegrati
|
|
|
20
20
|
export declare function getOptionalFieldsFromObject(object: HydratedIntegrationObject): HydratedIntegrationField[] | null;
|
|
21
21
|
export declare const getReadObject: (config: Config, objectName: string) => any;
|
|
22
22
|
export declare function getFieldKeyValue(field: HydratedIntegrationField): string;
|
|
23
|
+
export declare const generateOtherNavObject: (config: Config | undefined) => NavObject;
|
|
23
24
|
export declare function generateNavObjects(config: Config | undefined, hydratedRevision: HydratedRevision): NavObject[];
|
|
24
|
-
export declare function validateFieldMappings(requiredMapFields: IntegrationFieldMapping[] | null, selectedRequiredMapFields: SelectMappingFields | null, setErrors: (boundary: ErrorBoundary, errors: string[]) => void): {
|
|
25
|
+
export declare function validateFieldMappings(requiredMapFields: IntegrationFieldMapping[] | null | undefined, selectedRequiredMapFields: SelectMappingFields | null | undefined, setErrors: (boundary: ErrorBoundary, errors: string[]) => void): {
|
|
25
26
|
errorList: string[];
|
|
26
27
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateFieldMappings = exports.generateNavObjects = exports.getFieldKeyValue = exports.getReadObject = exports.getOptionalFieldsFromObject = exports.getRequiredMapFieldsFromObject = exports.getRequiredFieldsFromObject = exports.getStandardObjectFromAction = exports.isIntegrationFieldMapping = void 0;
|
|
3
|
+
exports.validateFieldMappings = exports.generateNavObjects = exports.generateOtherNavObject = exports.getFieldKeyValue = exports.getReadObject = exports.getOptionalFieldsFromObject = exports.getRequiredMapFieldsFromObject = exports.getRequiredFieldsFromObject = exports.getStandardObjectFromAction = exports.isIntegrationFieldMapping = void 0;
|
|
4
4
|
const ErrorContextProvider_1 = require("../../context/ErrorContextProvider");
|
|
5
|
+
const constant_1 = require("./nav/ObjectManagementNav/constant");
|
|
5
6
|
/**
|
|
6
7
|
* type guard for IntegrationFieldMapping | IntegrationFieldExistent
|
|
7
8
|
*
|
|
@@ -16,7 +17,7 @@ exports.isIntegrationFieldMapping = isIntegrationFieldMapping;
|
|
|
16
17
|
/**
|
|
17
18
|
*
|
|
18
19
|
* @param action HydratedIntegrationAction
|
|
19
|
-
* @param objectName string (account,
|
|
20
|
+
* @param objectName string (account, contact, etc...)
|
|
20
21
|
* @returns HydratedIntegrationObject | null
|
|
21
22
|
*/
|
|
22
23
|
function getStandardObjectFromAction(action, objectName) {
|
|
@@ -50,11 +51,16 @@ function getFieldKeyValue(field) {
|
|
|
50
51
|
if (isIntegrationFieldMapping(field)) {
|
|
51
52
|
return field.mapToName; // custom mapping
|
|
52
53
|
}
|
|
53
|
-
return field.fieldName; //
|
|
54
|
+
return field.fieldName; // existent field
|
|
54
55
|
}
|
|
55
56
|
exports.getFieldKeyValue = getFieldKeyValue;
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
/**
|
|
58
|
+
* generates Nav Objects for read action
|
|
59
|
+
* @param config
|
|
60
|
+
* @param hydratedRevision
|
|
61
|
+
* @returns NavObject[]
|
|
62
|
+
*/
|
|
63
|
+
const generateReadNavObjects = (config, hydratedRevision) => {
|
|
58
64
|
var _a, _b, _c;
|
|
59
65
|
const navObjects = [];
|
|
60
66
|
(_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) => {
|
|
@@ -66,6 +72,20 @@ function generateNavObjects(config, hydratedRevision) {
|
|
|
66
72
|
});
|
|
67
73
|
});
|
|
68
74
|
return navObjects;
|
|
75
|
+
};
|
|
76
|
+
const generateOtherNavObject = (config) => {
|
|
77
|
+
var _a;
|
|
78
|
+
const navObject = {
|
|
79
|
+
name: constant_1.OTHER_CONST,
|
|
80
|
+
completed: config ? !!((_a = config === null || config === void 0 ? void 0 : config.content) === null || _a === void 0 ? void 0 : _a.write) : false,
|
|
81
|
+
};
|
|
82
|
+
return navObject;
|
|
83
|
+
};
|
|
84
|
+
exports.generateOtherNavObject = generateOtherNavObject;
|
|
85
|
+
// generates standard objects and whether they are complete based on config and hydrated revision
|
|
86
|
+
function generateNavObjects(config, hydratedRevision) {
|
|
87
|
+
const navObjects = generateReadNavObjects(config, hydratedRevision);
|
|
88
|
+
return navObjects;
|
|
69
89
|
}
|
|
70
90
|
exports.generateNavObjects = generateNavObjects;
|
|
71
91
|
// validates whether required fields are filled out or throws error
|
|
@@ -4,6 +4,8 @@ interface ConnectProviderProps {
|
|
|
4
4
|
consumerName?: string;
|
|
5
5
|
groupRef: string;
|
|
6
6
|
groupName?: string;
|
|
7
|
+
redirectUrl?: string;
|
|
8
|
+
onSuccess?: (connectionID: string) => void;
|
|
7
9
|
}
|
|
8
|
-
export declare function ConnectProvider({ provider, consumerRef, consumerName, groupRef, groupName, }: ConnectProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function ConnectProvider({ provider, consumerRef, consumerName, groupRef, groupName, redirectUrl, onSuccess, }: ConnectProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
9
11
|
export {};
|
|
@@ -2,17 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConnectProvider = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
function ConnectedSuccessBox({ provider }) {
|
|
12
|
-
const { appName } = (0, ProjectContext_1.useProject)();
|
|
13
|
-
return ((0, jsx_runtime_1.jsx)(react_1.Container, { children: (0, jsx_runtime_1.jsxs)(react_1.Box, { p: 8, maxWidth: "600px", minHeight: "290px", borderWidth: 1, borderRadius: 8, boxShadow: "lg", margin: "auto", marginTop: "40px", bgColor: "white", paddingTop: "100px", children: [(0, jsx_runtime_1.jsx)(react_1.Box, { width: "100%", display: "flex", alignContent: "center", justifyContent: "center", children: (0, jsx_runtime_1.jsx)(react_1.Box, { margin: "auto", children: NavIcon_1.CheckMarkIcon }) }), (0, jsx_runtime_1.jsx)(react_1.Box, { textAlign: "center", paddingTop: "25px", children: `You've successfully connected ${(0, utils_1.capitalize)(provider)} to ${appName}.` })] }) }));
|
|
14
|
-
}
|
|
15
|
-
function ConnectProvider({ provider, consumerRef, consumerName, groupRef, groupName, }) {
|
|
16
|
-
return ((0, jsx_runtime_1.jsx)(ConnectionsContext_1.ConnectionsProvider, { provider: provider, groupRef: groupRef, children: (0, jsx_runtime_1.jsx)(ProtectedConnectionLayout_1.ProtectedConnectionLayout, { provider: provider, consumerRef: consumerRef, consumerName: consumerName, groupRef: groupRef, groupName: groupName, children: (0, jsx_runtime_1.jsx)(ConnectedSuccessBox, { provider: provider }) }) }));
|
|
5
|
+
const ConnectionsContextProvider_1 = require("../../context/ConnectionsContextProvider");
|
|
6
|
+
const ProtectedConnectionLayout_1 = require("../Configure/layout/ProtectedConnectionLayout");
|
|
7
|
+
const RedirectHandler_1 = require("../RedirectHandler");
|
|
8
|
+
const ConnectedSuccessBox_1 = require("./ConnectedSuccessBox");
|
|
9
|
+
function ConnectProvider({ provider, consumerRef, consumerName, groupRef, groupName, redirectUrl, onSuccess, }) {
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)(ConnectionsContextProvider_1.ConnectionsProvider, { provider: provider, groupRef: groupRef, children: (0, jsx_runtime_1.jsx)(ProtectedConnectionLayout_1.ProtectedConnectionLayout, { provider: provider, consumerRef: consumerRef, consumerName: consumerName, groupRef: groupRef, groupName: groupName, onSuccess: onSuccess, children: (0, jsx_runtime_1.jsx)(RedirectHandler_1.RedirectHandler, { redirectURL: redirectUrl, children: (0, jsx_runtime_1.jsx)(ConnectedSuccessBox_1.ConnectedSuccessBox, { provider: provider }) }) }) }));
|
|
17
11
|
}
|
|
18
12
|
exports.ConnectProvider = ConnectProvider;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectedSuccessBox = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@chakra-ui/react");
|
|
6
|
+
const NavIcon_1 = require("../../assets/NavIcon");
|
|
7
|
+
const ProjectContextProvider_1 = require("../../context/ProjectContextProvider");
|
|
8
|
+
const utils_1 = require("../../utils");
|
|
9
|
+
function ConnectedSuccessBox({ provider }) {
|
|
10
|
+
const { appName } = (0, ProjectContextProvider_1.useProject)();
|
|
11
|
+
return ((0, jsx_runtime_1.jsx)(react_1.Container, { children: (0, jsx_runtime_1.jsxs)(react_1.Box, { p: 8, maxWidth: "600px", minHeight: "290px", borderWidth: 1, borderRadius: 8, boxShadow: "lg", margin: "auto", marginTop: "40px", bgColor: "white", paddingTop: "100px", children: [(0, jsx_runtime_1.jsx)(react_1.Box, { width: "100%", display: "flex", alignContent: "center", justifyContent: "center", children: (0, jsx_runtime_1.jsx)(react_1.Box, { margin: "auto", children: NavIcon_1.CheckMarkIcon }) }), (0, jsx_runtime_1.jsx)(react_1.Box, { textAlign: "center", paddingTop: "25px", children: `You've successfully connected ${(0, utils_1.capitalize)(provider)} to ${appName}.` })] }) }));
|
|
12
|
+
}
|
|
13
|
+
exports.ConnectedSuccessBox = ConnectedSuccessBox;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type ConnectionHandlerPropsProps = {
|
|
2
|
+
onSuccess?: (connectionID: string) => void;
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* ConnectionHandler is a component that handles onSuccess and onError callbacks
|
|
6
|
+
* @param onSuccess - callback function to be called when a connection is successful
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function useConnectionHandler({ onSuccess }: ConnectionHandlerPropsProps): void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useConnectionHandler = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const ConnectionsContextProvider_1 = require("../../context/ConnectionsContextProvider");
|
|
6
|
+
function useOnSuccessHandler(onSuccess) {
|
|
7
|
+
const { selectedConnection } = (0, ConnectionsContextProvider_1.useConnections)();
|
|
8
|
+
(0, react_1.useEffect)(() => {
|
|
9
|
+
// Check if a onSuccess callback is present
|
|
10
|
+
if (onSuccess && selectedConnection) {
|
|
11
|
+
// call callback when connection is selected
|
|
12
|
+
onSuccess(selectedConnection.id);
|
|
13
|
+
}
|
|
14
|
+
}, [onSuccess, selectedConnection]);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* ConnectionHandler is a component that handles onSuccess and onError callbacks
|
|
18
|
+
* @param onSuccess - callback function to be called when a connection is successful
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
function useConnectionHandler({ onSuccess }) {
|
|
22
|
+
useOnSuccessHandler(onSuccess);
|
|
23
|
+
}
|
|
24
|
+
exports.useConnectionHandler = useConnectionHandler;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErrorTextBox = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@chakra-ui/react");
|
|
6
|
+
function ErrorTextBox({ message }) {
|
|
7
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Box, { minHeight: "300px", padding: "30px", display: "flex", flexDirection: "column", justifyContent: "space-evenly", alignItems: "center", children: [(0, jsx_runtime_1.jsxs)("svg", { width: "48", height: "48", viewBox: "0 0 48 48", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [(0, jsx_runtime_1.jsx)("path", {
|
|
8
|
+
// eslint-disable-next-line max-len
|
|
9
|
+
d: "M20.5796 7.72236L3.63955 36.0024C3.29029 36.6072 3.10549 37.293 3.10353 37.9914C3.10158 38.6898 3.28254 39.3766 3.62841 39.9834C3.97428 40.5902 4.473 41.0959 5.07497 41.4501C5.67693 41.8043 6.36115 41.9947 7.05955 42.0024H40.9396C41.638 41.9947 42.3222 41.8043 42.9241 41.4501C43.5261 41.0959 44.0248 40.5902 44.3707 39.9834C44.7166 39.3766 44.8975 38.6898 44.8956 37.9914C44.8936 37.293 44.7088 36.6072 44.3596 36.0024L27.4196 7.72236C27.063 7.13458 26.561 6.6486 25.9619 6.31133C25.3629 5.97406 24.687 5.79688 23.9996 5.79688C23.3121 5.79688 22.6362 5.97406 22.0372 6.31133C21.4381 6.6486 20.9361 7.13458 20.5796 7.72236Z", stroke: "#7F1D1D", strokeWidth: "4", strokeLinecap: "round", strokeLinejoin: "round" }), (0, jsx_runtime_1.jsx)("path", { d: "M24 18V26", stroke: "#7F1D1D", strokeWidth: "4", strokeLinecap: "round", strokeLinejoin: "round" }), (0, jsx_runtime_1.jsx)("path", { d: "M24 34H24.02", stroke: "#7F1D1D", strokeWidth: "4", strokeLinecap: "round", strokeLinejoin: "round" })] }), (0, jsx_runtime_1.jsx)(react_1.Box, { boxSizing: "border-box", display: "flex", justifyContent: "center", alignItems: "center", "align-self": "stretch", padding: "12px 50px 12px 50px", borderRadius: "8px", border: "2px solid #FECACA", background: "#FEF2F2", children: (0, jsx_runtime_1.jsx)(react_1.Text, { color: "#991B1B", children: message }) })] }));
|
|
10
|
+
}
|
|
11
|
+
exports.ErrorTextBox = ErrorTextBox;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type LandingContentProps = {
|
|
2
|
+
provider: string;
|
|
3
|
+
handleSubmit: () => void;
|
|
4
|
+
error: string | null;
|
|
5
|
+
isButtonDisabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function LandingContent({ provider, handleSubmit, error, isButtonDisabled, }: LandingContentProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LandingContent = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@chakra-ui/react");
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const OAuthErrorAlert_1 = require("../OAuthErrorAlert");
|
|
8
|
+
function LandingContent({ provider, handleSubmit, error, isButtonDisabled, }) {
|
|
9
|
+
return ((0, jsx_runtime_1.jsx)(react_1.Container, { children: (0, jsx_runtime_1.jsx)(react_1.Box, { p: 8, maxWidth: "600px", borderWidth: 1, borderRadius: 8, boxShadow: "lg", textAlign: ['left'], margin: "auto", marginTop: "40px", bgColor: "white", children: (0, jsx_runtime_1.jsxs)(react_1.FormControl, { children: [(0, jsx_runtime_1.jsx)(react_1.FormLabel, { marginTop: "16", marginBottom: "0", children: (0, jsx_runtime_1.jsx)(react_1.Heading, { as: "h4", size: "md", children: `Set up ${(0, utils_1.capitalize)(provider)} integration` }) }), (0, jsx_runtime_1.jsx)(OAuthErrorAlert_1.OAuthErrorAlert, { error: error }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)(react_1.Button, { isDisabled: isButtonDisabled, width: "100%", type: "submit", onClick: handleSubmit, children: "Next" })] }) }) }));
|
|
10
|
+
}
|
|
11
|
+
exports.LandingContent = LandingContent;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth flow for any providers that do not require the consumer to enter a subdomain first.
|
|
3
|
+
*/
|
|
4
|
+
interface NoSubdomainOauthFlowProps {
|
|
5
|
+
provider: string;
|
|
6
|
+
consumerRef: string;
|
|
7
|
+
consumerName?: string;
|
|
8
|
+
groupRef: string;
|
|
9
|
+
groupName?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* NoSubdomainOauthFlow first prompts user with a next button,
|
|
13
|
+
* then launches a popup with the OAuth flow.
|
|
14
|
+
*/
|
|
15
|
+
export declare function NoSubdomainOauthFlow({ provider, consumerRef, consumerName, groupRef, groupName, }: NoSubdomainOauthFlowProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
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.NoSubdomainOauthFlow = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
/**
|
|
9
|
+
* OAuth flow for any providers that do not require the consumer to enter a subdomain first.
|
|
10
|
+
*/
|
|
11
|
+
const react_1 = require("react");
|
|
12
|
+
const ApiKeyContextProvider_1 = require("../../../context/ApiKeyContextProvider");
|
|
13
|
+
const ProjectContextProvider_1 = require("../../../context/ProjectContextProvider");
|
|
14
|
+
const utils_1 = require("../../../utils");
|
|
15
|
+
const fetchOAuthCallbackURL_1 = require("../fetchOAuthCallbackURL");
|
|
16
|
+
const OAuthPopup_1 = __importDefault(require("../OAuthPopup"));
|
|
17
|
+
const LandingContent_1 = require("./LandingContent");
|
|
18
|
+
/**
|
|
19
|
+
* NoSubdomainOauthFlow first prompts user with a next button,
|
|
20
|
+
* then launches a popup with the OAuth flow.
|
|
21
|
+
*/
|
|
22
|
+
function NoSubdomainOauthFlow({ provider, consumerRef, consumerName, groupRef, groupName, }) {
|
|
23
|
+
const { projectId } = (0, ProjectContextProvider_1.useProject)();
|
|
24
|
+
const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
|
|
25
|
+
const [oAuthCallbackURL, setOAuthCallbackURL] = (0, react_1.useState)(null);
|
|
26
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
27
|
+
// 1. fetch provider apps
|
|
28
|
+
// 2. find matching app to provider
|
|
29
|
+
// 3. fetch OAuth callback URL from connection so that oath popup can be launched
|
|
30
|
+
const handleSubmit = async () => {
|
|
31
|
+
var _a;
|
|
32
|
+
setError(null);
|
|
33
|
+
if (consumerName && groupName && apiKey) {
|
|
34
|
+
try {
|
|
35
|
+
const url = await (0, fetchOAuthCallbackURL_1.fetchOAuthCallbackURL)(projectId, consumerRef, groupRef, consumerName, groupName, apiKey, provider);
|
|
36
|
+
setOAuthCallbackURL(url);
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
console.error(err);
|
|
40
|
+
setError((_a = err.message) !== null && _a !== void 0 ? _a : 'Unexpected error');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const onClose = (0, react_1.useCallback)((err) => {
|
|
45
|
+
setError(err);
|
|
46
|
+
setOAuthCallbackURL(null);
|
|
47
|
+
}, []);
|
|
48
|
+
return ((0, jsx_runtime_1.jsx)(OAuthPopup_1.default, { title: `Connect to ${(0, utils_1.capitalize)(provider)}`, url: oAuthCallbackURL, onClose: onClose, children: (0, jsx_runtime_1.jsx)(LandingContent_1.LandingContent, { provider: provider, handleSubmit: handleSubmit, error: error }) }));
|
|
49
|
+
}
|
|
50
|
+
exports.NoSubdomainOauthFlow = NoSubdomainOauthFlow;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OAuthErrorAlert = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@chakra-ui/react");
|
|
6
|
+
function OAuthErrorAlert({ error }) {
|
|
7
|
+
if (error) {
|
|
8
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Alert, { status: "error", marginTop: "2em", children: [(0, jsx_runtime_1.jsx)(react_1.AlertIcon, {}), (0, jsx_runtime_1.jsx)(react_1.AlertDescription, { children: error })] }));
|
|
9
|
+
}
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
exports.OAuthErrorAlert = OAuthErrorAlert;
|
|
@@ -7,9 +7,9 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
7
7
|
* Takes a URL and creates a popup showing that page.
|
|
8
8
|
*/
|
|
9
9
|
const react_1 = require("react");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
10
|
+
const ApiKeyContextProvider_1 = require("../../context/ApiKeyContextProvider");
|
|
11
|
+
const ConnectionsContextProvider_1 = require("../../context/ConnectionsContextProvider");
|
|
12
|
+
const ProjectContextProvider_1 = require("../../context/ProjectContextProvider");
|
|
13
13
|
const api_1 = require("../../services/api");
|
|
14
14
|
const DEFAULT_WIDTH = 600; // px
|
|
15
15
|
const DEFAULT_HEIGHT = 600; // px
|
|
@@ -23,21 +23,19 @@ const createPopup = ({ url, title, }) => {
|
|
|
23
23
|
return popup;
|
|
24
24
|
};
|
|
25
25
|
function OAuthPopup({ title = '', url, children, onClose, }) {
|
|
26
|
-
const { projectId } = (0,
|
|
27
|
-
const apiKey = (0,
|
|
26
|
+
const { projectId } = (0, ProjectContextProvider_1.useProject)();
|
|
27
|
+
const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
|
|
28
28
|
const [externalWindow, setExternalWindow] = (0, react_1.useState)();
|
|
29
29
|
const intervalRef = (0, react_1.useRef)();
|
|
30
30
|
const clearTimer = () => window.clearInterval(intervalRef.current);
|
|
31
|
-
const { setSelectedConnection } = (0,
|
|
31
|
+
const { setSelectedConnection } = (0, ConnectionsContextProvider_1.useConnections)();
|
|
32
32
|
(0, react_1.useEffect)(() => {
|
|
33
33
|
if (url)
|
|
34
34
|
setExternalWindow(createPopup({ url, title }));
|
|
35
35
|
}, [url, title]);
|
|
36
36
|
const refreshConnections = (0, react_1.useCallback)(async (connectionId) => {
|
|
37
|
-
const connection = await (0, api_1.api)().getConnection({ projectId, connectionId }, {
|
|
38
|
-
headers: {
|
|
39
|
-
'X-Api-Key': apiKey !== null && apiKey !== void 0 ? apiKey : '',
|
|
40
|
-
},
|
|
37
|
+
const connection = await (0, api_1.api)().connectionApi.getConnection({ projectId, connectionId }, {
|
|
38
|
+
headers: { 'X-Api-Key': apiKey !== null && apiKey !== void 0 ? apiKey : '' },
|
|
41
39
|
});
|
|
42
40
|
setSelectedConnection(connection);
|
|
43
41
|
}, [projectId, apiKey, setSelectedConnection]);
|
|
@@ -12,5 +12,5 @@ interface SalesforceOauthFlowProps {
|
|
|
12
12
|
* SalesforceOauthFlow first prompts user for their workspace ("subdomain" in Salesforce lingo),
|
|
13
13
|
* then launches a popup with the OAuth flow.
|
|
14
14
|
*/
|
|
15
|
-
declare function SalesforceOauthFlow({ consumerRef, consumerName, groupRef, groupName, }: SalesforceOauthFlowProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
-
export
|
|
15
|
+
export declare function SalesforceOauthFlow({ consumerRef, consumerName, groupRef, groupName, }: SalesforceOauthFlowProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
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.SalesforceOauthFlow = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
/**
|
|
9
|
+
* Prompts customer to input their Salesforce subdomain, then creates an OAuth connection to
|
|
10
|
+
* that Salesforce instance.
|
|
11
|
+
*/
|
|
12
|
+
const react_1 = require("react");
|
|
13
|
+
const constants_1 = require("../../../constants");
|
|
14
|
+
const ApiKeyContextProvider_1 = require("../../../context/ApiKeyContextProvider");
|
|
15
|
+
const ProjectContextProvider_1 = require("../../../context/ProjectContextProvider");
|
|
16
|
+
const fetchOAuthCallbackURL_1 = require("../fetchOAuthCallbackURL");
|
|
17
|
+
const OAuthPopup_1 = __importDefault(require("../OAuthPopup"));
|
|
18
|
+
const SubdomainEntry_1 = require("./SubdomainEntry");
|
|
19
|
+
/**
|
|
20
|
+
* SalesforceOauthFlow first prompts user for their workspace ("subdomain" in Salesforce lingo),
|
|
21
|
+
* then launches a popup with the OAuth flow.
|
|
22
|
+
*/
|
|
23
|
+
function SalesforceOauthFlow({ consumerRef, consumerName, groupRef, groupName, }) {
|
|
24
|
+
const { projectId } = (0, ProjectContextProvider_1.useProject)();
|
|
25
|
+
const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
|
|
26
|
+
const [workspace, setWorkspace] = (0, react_1.useState)('');
|
|
27
|
+
const [oAuthCallbackURL, setOAuthCallbackURL] = (0, react_1.useState)(null);
|
|
28
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
29
|
+
const isButtonDisabled = workspace.length === 0;
|
|
30
|
+
const provider = constants_1.PROVIDER_SALESFORCE;
|
|
31
|
+
// 1. fetch provider apps
|
|
32
|
+
// 2. find matching app to provider
|
|
33
|
+
// 3. fetch OAuth callback URL from connection so that oath popup can be launched
|
|
34
|
+
const handleSubmit = async () => {
|
|
35
|
+
var _a;
|
|
36
|
+
setError(null);
|
|
37
|
+
if (workspace && consumerName && groupName && apiKey) {
|
|
38
|
+
try {
|
|
39
|
+
const url = await (0, fetchOAuthCallbackURL_1.fetchOAuthCallbackURL)(projectId, consumerRef, groupRef, consumerName, groupName, apiKey, provider, workspace);
|
|
40
|
+
setOAuthCallbackURL(url);
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
console.error(err);
|
|
44
|
+
setError((_a = err.message) !== null && _a !== void 0 ? _a : 'Unexpected error');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
setError('missing required fields');
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const onClose = (0, react_1.useCallback)((err) => {
|
|
52
|
+
setError(err);
|
|
53
|
+
setOAuthCallbackURL(null);
|
|
54
|
+
}, []);
|
|
55
|
+
return ((0, jsx_runtime_1.jsx)(OAuthPopup_1.default, { title: "Connect to Salesforce", url: oAuthCallbackURL, onClose: onClose, children: (0, jsx_runtime_1.jsx)(SubdomainEntry_1.SubdomainEntry, { handleSubmit: handleSubmit, setWorkspace: setWorkspace, error: error, isButtonDisabled: isButtonDisabled }) }));
|
|
56
|
+
}
|
|
57
|
+
exports.SalesforceOauthFlow = SalesforceOauthFlow;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type SubdomainEntryProps = {
|
|
2
|
+
handleSubmit: () => void;
|
|
3
|
+
setWorkspace: (workspace: string) => void;
|
|
4
|
+
error: string | null;
|
|
5
|
+
isButtonDisabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function SubdomainEntry({ handleSubmit, setWorkspace, error, isButtonDisabled, }: SubdomainEntryProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SubdomainEntry = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const icons_1 = require("@chakra-ui/icons");
|
|
6
|
+
const react_1 = require("@chakra-ui/react");
|
|
7
|
+
const OAuthErrorAlert_1 = require("../OAuthErrorAlert");
|
|
8
|
+
const SALESFORCE_HELP_URL = 'https://help.salesforce.com/articleView?id=domain_name_not_found.htm&type=5';
|
|
9
|
+
function SubdomainEntry({ handleSubmit, setWorkspace, error, isButtonDisabled, }) {
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)(react_1.Container, { children: (0, jsx_runtime_1.jsx)(react_1.Box, { p: 8, maxWidth: "600px", borderWidth: 1, borderRadius: 8, boxShadow: "lg", textAlign: ['left'], margin: "auto", marginTop: "40px", bgColor: "white", children: (0, jsx_runtime_1.jsxs)(react_1.FormControl, { children: [(0, jsx_runtime_1.jsx)(react_1.FormLabel, { marginTop: "16", marginBottom: "0", children: (0, jsx_runtime_1.jsx)(react_1.Heading, { as: "h4", size: "md", children: "Enter your Salesforce subdomain" }) }), (0, jsx_runtime_1.jsxs)(react_1.Link, { href: SALESFORCE_HELP_URL, color: "blackAlpha.600", isExternal: true, children: ["What is my Salesforce subdomain?", (0, jsx_runtime_1.jsx)(icons_1.ExternalLinkIcon, { mx: "2px" })] }), (0, jsx_runtime_1.jsx)(OAuthErrorAlert_1.OAuthErrorAlert, { error: error }), (0, jsx_runtime_1.jsxs)(react_1.Flex, { marginTop: "1em", children: [(0, jsx_runtime_1.jsx)(react_1.Input, { placeholder: "MyDomain", onChange: (event) => setWorkspace(event.currentTarget.value) }), (0, jsx_runtime_1.jsx)(react_1.Text, { lineHeight: "2.2em", marginLeft: "0.4em", children: ".my.salesforce.com" })] }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)(react_1.Button, { isDisabled: isButtonDisabled, width: "100%", type: "submit", onClick: handleSubmit, children: "Next" })] }) }) }));
|
|
11
|
+
}
|
|
12
|
+
exports.SubdomainEntry = SubdomainEntry;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fetchOAuthCallbackURL: (projectId: string, consumerRef: string, groupRef: string, consumerName: string, groupName: string, apiKey: string, provider: string, workspace?: string) => Promise<string>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchOAuthCallbackURL = void 0;
|
|
4
|
+
const api_1 = require("../../services/api");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
const fetchOAuthCallbackURL = async (projectId, consumerRef, groupRef, consumerName, groupName, apiKey, provider, workspace) => {
|
|
7
|
+
const providerApps = await (0, api_1.api)().providerAppApi.listProviderApps({ projectId }, {
|
|
8
|
+
headers: { 'X-Api-Key': apiKey !== null && apiKey !== void 0 ? apiKey : '' },
|
|
9
|
+
});
|
|
10
|
+
const app = providerApps.find((a) => a.provider === provider);
|
|
11
|
+
if (!app) {
|
|
12
|
+
throw new Error(`You must first set up a ${(0, utils_1.capitalize)(provider)} Connected App using the Ampersand Console.`);
|
|
13
|
+
}
|
|
14
|
+
const url = await (0, api_1.api)().oAuthApi.oauthConnect({
|
|
15
|
+
connectOAuthParams: {
|
|
16
|
+
providerWorkspaceRef: workspace,
|
|
17
|
+
projectId,
|
|
18
|
+
groupRef,
|
|
19
|
+
groupName,
|
|
20
|
+
consumerRef,
|
|
21
|
+
consumerName,
|
|
22
|
+
providerAppId: app.id,
|
|
23
|
+
provider,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
return url;
|
|
27
|
+
};
|
|
28
|
+
exports.fetchOAuthCallbackURL = fetchOAuthCallbackURL;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type RedirectHandlerProps = {
|
|
3
|
+
redirectURL?: string;
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* RedirectHandler is a component that redirects to a specified URL when mounted or
|
|
8
|
+
* will render the children if no redirect URL is present.
|
|
9
|
+
*
|
|
10
|
+
* @param redirectURL
|
|
11
|
+
* @param children
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export declare function RedirectHandler({ redirectURL, children }: RedirectHandlerProps): string | number | boolean | Iterable<React.ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedirectHandler = 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 LoadingIcon_1 = require("../../assets/LoadingIcon");
|
|
8
|
+
/**
|
|
9
|
+
* RedirectHandler is a component that redirects to a specified URL when mounted or
|
|
10
|
+
* will render the children if no redirect URL is present.
|
|
11
|
+
*
|
|
12
|
+
* @param redirectURL
|
|
13
|
+
* @param children
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
function RedirectHandler({ redirectURL, children }) {
|
|
17
|
+
(0, react_1.useEffect)(() => {
|
|
18
|
+
// Check if a redirect URL is present
|
|
19
|
+
if (redirectURL) {
|
|
20
|
+
// Redirect to the specified URL
|
|
21
|
+
window.location.replace(redirectURL);
|
|
22
|
+
}
|
|
23
|
+
}, [redirectURL]);
|
|
24
|
+
// show a loading message if a redirect URL is present
|
|
25
|
+
if (redirectURL) {
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(react_2.Box, { display: "flex", alignItems: "center", justifyContent: "center", children: (0, jsx_runtime_1.jsx)(LoadingIcon_1.LoadingIcon, { message: "Redirecting..." }) }));
|
|
27
|
+
}
|
|
28
|
+
// render children if no redirect URL is present
|
|
29
|
+
return children;
|
|
30
|
+
}
|
|
31
|
+
exports.RedirectHandler = RedirectHandler;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RedirectHandler } from './RedirectHandler';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedirectHandler = void 0;
|
|
4
|
+
var RedirectHandler_1 = require("./RedirectHandler");
|
|
5
|
+
Object.defineProperty(exports, "RedirectHandler", { enumerable: true, get: function () { return RedirectHandler_1.RedirectHandler; } });
|
package/build/src/constants.d.ts
CHANGED
package/build/src/constants.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PROVIDER_SALESFORCE = void 0;
|
|
3
|
+
exports.PROVIDER_HUBSPOT = exports.PROVIDER_SALESFORCE = void 0;
|
|
4
4
|
exports.PROVIDER_SALESFORCE = 'salesforce';
|
|
5
|
+
exports.PROVIDER_HUBSPOT = 'hubspot';
|
|
@@ -9,14 +9,14 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
9
9
|
* Also optionally accepts theme styles object with CSS values.
|
|
10
10
|
*/
|
|
11
11
|
const react_1 = require("react");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
12
|
+
const ThemeProvider_1 = require("../../components/ThemeProvider");
|
|
13
|
+
const ApiKeyContextProvider_1 = require("../ApiKeyContextProvider");
|
|
14
|
+
const ErrorContextProvider_1 = require("../ErrorContextProvider");
|
|
15
|
+
const IntegrationListContextProvider_1 = require("../IntegrationListContextProvider");
|
|
16
|
+
const ProjectContextProvider_1 = require("../ProjectContextProvider");
|
|
17
17
|
function AmpersandProvider(props) {
|
|
18
18
|
const { options: { apiKey, projectId }, children } = props;
|
|
19
|
-
return ((0, jsx_runtime_1.jsx)(ThemeProvider_1.ThemeProvider, { children: (0, jsx_runtime_1.jsx)(ErrorContextProvider_1.ErrorStateProvider, { children: (0, jsx_runtime_1.jsx)(
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(ThemeProvider_1.ThemeProvider, { children: (0, jsx_runtime_1.jsx)(ErrorContextProvider_1.ErrorStateProvider, { children: (0, jsx_runtime_1.jsx)(ApiKeyContextProvider_1.ApiKeyProvider, { value: apiKey, children: (0, jsx_runtime_1.jsx)(ProjectContextProvider_1.ProjectProvider, { projectId: projectId, children: (0, jsx_runtime_1.jsx)(IntegrationListContextProvider_1.IntegrationListProvider, { projectId: projectId, children: children }) }) }) }) }));
|
|
20
20
|
}
|
|
21
21
|
exports.AmpersandProvider = AmpersandProvider;
|
|
22
22
|
exports.AmpersandContext = (0, react_1.createContext)(null);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AmpersandContextProvider';
|
package/build/src/{components/AmpersandProvider → context/AmpersandContextProvider}/index.js
RENAMED
|
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./AmpersandContextProvider"), exports);
|