@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
|
@@ -4,12 +4,12 @@ exports.ConnectionsProvider = exports.useConnections = exports.ConnectionsContex
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const LoadingIcon_1 = require("../assets/LoadingIcon");
|
|
7
|
-
const ErrorTextBox_1 = require("../components/
|
|
7
|
+
const ErrorTextBox_1 = require("../components/ErrorTextBox");
|
|
8
8
|
const api_1 = require("../services/api");
|
|
9
|
-
const
|
|
9
|
+
const ApiKeyContextProvider_1 = require("./ApiKeyContextProvider");
|
|
10
10
|
const ErrorContextProvider_1 = require("./ErrorContextProvider");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const InstallIntegrationContextProvider_1 = require("./InstallIntegrationContextProvider");
|
|
12
|
+
const ProjectContextProvider_1 = require("./ProjectContextProvider");
|
|
13
13
|
exports.ConnectionsContext = (0, react_1.createContext)({
|
|
14
14
|
connections: null,
|
|
15
15
|
selectedConnection: null,
|
|
@@ -25,21 +25,22 @@ const useConnections = () => {
|
|
|
25
25
|
};
|
|
26
26
|
exports.useConnections = useConnections;
|
|
27
27
|
function ConnectionsProvider({ provider, groupRef, children, }) {
|
|
28
|
-
const apiKey = (0,
|
|
29
|
-
const { projectId } = (0,
|
|
28
|
+
const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
|
|
29
|
+
const { projectId } = (0, ProjectContextProvider_1.useProject)();
|
|
30
30
|
const [connections, setConnections] = (0, react_1.useState)(null);
|
|
31
31
|
const [selectedConnection, setSelectedConnection] = (0, react_1.useState)(null);
|
|
32
32
|
const [isLoading, setLoadingState] = (0, react_1.useState)(true);
|
|
33
33
|
const { setError, isError } = (0, ErrorContextProvider_1.useErrorState)();
|
|
34
|
-
const { provider: providerFromProps } = (0,
|
|
34
|
+
const { provider: providerFromProps } = (0, InstallIntegrationContextProvider_1.useInstallIntegrationProps)();
|
|
35
35
|
if (!projectId) {
|
|
36
36
|
throw new Error('ConnectionsProvider must be used within AmpersandProvider');
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
const selectedProvider = provider || providerFromProps;
|
|
39
|
+
if (!selectedProvider) {
|
|
39
40
|
throw new Error('ConnectionsProvider must be given a provider prop or be used within InstallIntegrationProvider');
|
|
40
41
|
}
|
|
41
42
|
(0, react_1.useEffect)(() => {
|
|
42
|
-
(0, api_1.api)().listConnections({ projectId, groupRef, provider }, {
|
|
43
|
+
(0, api_1.api)().connectionApi.listConnections({ projectId, groupRef, provider: selectedProvider }, {
|
|
43
44
|
headers: {
|
|
44
45
|
'X-Api-Key': apiKey !== null && apiKey !== void 0 ? apiKey : '',
|
|
45
46
|
},
|
|
@@ -51,7 +52,7 @@ function ConnectionsProvider({ provider, groupRef, children, }) {
|
|
|
51
52
|
setError(ErrorContextProvider_1.ErrorBoundary.CONNECTION_LIST, projectId);
|
|
52
53
|
console.error(`Error retrieving existing OAuth connections for group ID ${groupRef}:`, err);
|
|
53
54
|
});
|
|
54
|
-
}, [projectId, apiKey, groupRef,
|
|
55
|
+
}, [projectId, apiKey, groupRef, selectedProvider, setError]);
|
|
55
56
|
const contextValue = (0, react_1.useMemo)(() => ({
|
|
56
57
|
connections,
|
|
57
58
|
selectedConnection,
|
package/build/src/context/{InstallIntegrationContext.d.ts → InstallIntegrationContextProvider.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Installation, Integration } from '../services/api';
|
|
2
|
+
import { Config, Installation, Integration } from '../services/api';
|
|
3
3
|
interface InstallIntegrationContextValue {
|
|
4
4
|
integrationId: string;
|
|
5
5
|
provider: string;
|
|
@@ -11,7 +11,10 @@ interface InstallIntegrationContextValue {
|
|
|
11
11
|
installation?: Installation;
|
|
12
12
|
setInstallation: (installationObj: Installation) => void;
|
|
13
13
|
resetInstallations: () => void;
|
|
14
|
+
onInstallSuccess?: (installationId: string, config: Config) => void;
|
|
15
|
+
onUpdateSuccess?: (installationId: string, config: Config) => void;
|
|
14
16
|
}
|
|
17
|
+
export declare const InstallIntegrationContext: import("react").Context<InstallIntegrationContextValue>;
|
|
15
18
|
export declare function useInstallIntegrationProps(): InstallIntegrationContextValue;
|
|
16
19
|
interface InstallIntegrationProviderProps {
|
|
17
20
|
integration: string;
|
|
@@ -20,6 +23,8 @@ interface InstallIntegrationProviderProps {
|
|
|
20
23
|
groupRef: string;
|
|
21
24
|
groupName?: string;
|
|
22
25
|
children: React.ReactNode;
|
|
26
|
+
onInstallSuccess?: (installationId: string, config: Config) => void;
|
|
27
|
+
onUpdateSuccess?: (installationId: string, config: Config) => void;
|
|
23
28
|
}
|
|
24
|
-
export declare function InstallIntegrationProvider({ children, integration, consumerRef, consumerName, groupRef, groupName, }: InstallIntegrationProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export declare function InstallIntegrationProvider({ children, integration, consumerRef, consumerName, groupRef, groupName, onInstallSuccess, onUpdateSuccess, }: InstallIntegrationProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
25
30
|
export {};
|
package/build/src/context/{InstallIntegrationContext.js → InstallIntegrationContextProvider.js}
RENAMED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InstallIntegrationProvider = exports.useInstallIntegrationProps = void 0;
|
|
3
|
+
exports.InstallIntegrationProvider = exports.useInstallIntegrationProps = exports.InstallIntegrationContext = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const LoadingIcon_1 = require("../assets/LoadingIcon");
|
|
7
|
-
const ErrorTextBox_1 = require("../components/
|
|
7
|
+
const ErrorTextBox_1 = require("../components/ErrorTextBox");
|
|
8
8
|
const api_1 = require("../services/api");
|
|
9
9
|
const utils_1 = require("../utils");
|
|
10
|
-
const
|
|
10
|
+
const ApiKeyContextProvider_1 = require("./ApiKeyContextProvider");
|
|
11
11
|
const ErrorContextProvider_1 = require("./ErrorContextProvider");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
12
|
+
const IntegrationListContextProvider_1 = require("./IntegrationListContextProvider");
|
|
13
|
+
const ProjectContextProvider_1 = require("./ProjectContextProvider");
|
|
14
14
|
// Create a context to pass down the props
|
|
15
|
-
|
|
15
|
+
exports.InstallIntegrationContext = (0, react_1.createContext)({
|
|
16
16
|
integrationId: '',
|
|
17
17
|
provider: '',
|
|
18
18
|
integrationObj: undefined,
|
|
@@ -23,10 +23,12 @@ const InstallIntegrationContext = (0, react_1.createContext)({
|
|
|
23
23
|
installation: undefined,
|
|
24
24
|
setInstallation: () => { },
|
|
25
25
|
resetInstallations: () => { },
|
|
26
|
+
onInstallSuccess: undefined,
|
|
27
|
+
onUpdateSuccess: undefined,
|
|
26
28
|
});
|
|
27
29
|
// Create a custom hook to access the props
|
|
28
30
|
function useInstallIntegrationProps() {
|
|
29
|
-
const context = (0, react_1.useContext)(InstallIntegrationContext);
|
|
31
|
+
const context = (0, react_1.useContext)(exports.InstallIntegrationContext);
|
|
30
32
|
if (!context) {
|
|
31
33
|
throw new Error('useInstallIntegrationProps must be used within an InstallIntegrationProvider');
|
|
32
34
|
}
|
|
@@ -34,10 +36,10 @@ function useInstallIntegrationProps() {
|
|
|
34
36
|
}
|
|
35
37
|
exports.useInstallIntegrationProps = useInstallIntegrationProps;
|
|
36
38
|
// Wrap your parent component with the context provider
|
|
37
|
-
function InstallIntegrationProvider({ children, integration, consumerRef, consumerName, groupRef, groupName, }) {
|
|
38
|
-
const apiKey = (0,
|
|
39
|
-
const { projectId } = (0,
|
|
40
|
-
const { integrations } = (0,
|
|
39
|
+
function InstallIntegrationProvider({ children, integration, consumerRef, consumerName, groupRef, groupName, onInstallSuccess, onUpdateSuccess, }) {
|
|
40
|
+
const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
|
|
41
|
+
const { projectId } = (0, ProjectContextProvider_1.useProject)();
|
|
42
|
+
const { integrations } = (0, IntegrationListContextProvider_1.useIntegrationList)();
|
|
41
43
|
const [installations, setInstallations] = (0, react_1.useState)([]);
|
|
42
44
|
const [isLoading, setLoadingState] = (0, react_1.useState)(true);
|
|
43
45
|
const { setError, isError } = (0, ErrorContextProvider_1.useErrorState)();
|
|
@@ -56,7 +58,11 @@ function InstallIntegrationProvider({ children, integration, consumerRef, consum
|
|
|
56
58
|
const resetInstallations = (0, react_1.useCallback)(() => {
|
|
57
59
|
if (integrationObj === null || integrationObj === void 0 ? void 0 : integrationObj.id) {
|
|
58
60
|
// check if installation exists on selected integration
|
|
59
|
-
(0, api_1.api)().listInstallations({
|
|
61
|
+
(0, api_1.api)().installationApi.listInstallations({
|
|
62
|
+
projectId,
|
|
63
|
+
integrationId: integrationObj.id,
|
|
64
|
+
groupRef,
|
|
65
|
+
}, {
|
|
60
66
|
headers: {
|
|
61
67
|
'X-Api-Key': apiKey !== null && apiKey !== void 0 ? apiKey : '',
|
|
62
68
|
},
|
|
@@ -88,8 +94,17 @@ function InstallIntegrationProvider({ children, integration, consumerRef, consum
|
|
|
88
94
|
installation,
|
|
89
95
|
setInstallation,
|
|
90
96
|
resetInstallations,
|
|
97
|
+
onInstallSuccess,
|
|
98
|
+
onUpdateSuccess,
|
|
91
99
|
}), [integrationObj, consumerRef, consumerName, groupRef,
|
|
92
|
-
groupName, installation, setInstallation, resetInstallations]);
|
|
93
|
-
|
|
100
|
+
groupName, installation, setInstallation, resetInstallations, onInstallSuccess, onUpdateSuccess]);
|
|
101
|
+
if (integrationObj !== null) {
|
|
102
|
+
const errorMessage = 'Error retrieving installation information for integration '
|
|
103
|
+
+ `"${(integrationObj === null || integrationObj === void 0 ? void 0 : integrationObj.name) || 'unknown'}"`;
|
|
104
|
+
return (isError(ErrorContextProvider_1.ErrorBoundary.INSTALLATION_LIST, integrationErrorKey))
|
|
105
|
+
? (0, jsx_runtime_1.jsx)(ErrorTextBox_1.ErrorTextBox, { message: errorMessage }) : ((0, jsx_runtime_1.jsx)(exports.InstallIntegrationContext.Provider, { value: props, children: isLoading ? (0, jsx_runtime_1.jsx)(LoadingIcon_1.LoadingIcon, {}) : children }));
|
|
106
|
+
}
|
|
107
|
+
// if integration not found, return error message
|
|
108
|
+
return (0, jsx_runtime_1.jsx)(ErrorTextBox_1.ErrorTextBox, { message: `Integration "${integration}" not found` });
|
|
94
109
|
}
|
|
95
110
|
exports.InstallIntegrationProvider = InstallIntegrationProvider;
|
|
@@ -4,9 +4,9 @@ exports.IntegrationListProvider = exports.useIntegrationList = exports.Integrati
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const LoadingIcon_1 = require("../assets/LoadingIcon");
|
|
7
|
-
const ErrorTextBox_1 = require("../components/
|
|
7
|
+
const ErrorTextBox_1 = require("../components/ErrorTextBox");
|
|
8
8
|
const api_1 = require("../services/api");
|
|
9
|
-
const
|
|
9
|
+
const ApiKeyContextProvider_1 = require("./ApiKeyContextProvider");
|
|
10
10
|
const ErrorContextProvider_1 = require("./ErrorContextProvider");
|
|
11
11
|
exports.IntegrationListContext = (0, react_1.createContext)({
|
|
12
12
|
integrations: null,
|
|
@@ -20,12 +20,12 @@ const useIntegrationList = () => {
|
|
|
20
20
|
};
|
|
21
21
|
exports.useIntegrationList = useIntegrationList;
|
|
22
22
|
function IntegrationListProvider({ projectId, children }) {
|
|
23
|
-
const apiKey = (0,
|
|
23
|
+
const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
|
|
24
24
|
const { setError, isError } = (0, ErrorContextProvider_1.useErrorState)();
|
|
25
25
|
const [integrations, setIntegrations] = (0, react_1.useState)(null);
|
|
26
26
|
const [isLoading, setLoadingState] = (0, react_1.useState)(true);
|
|
27
27
|
(0, react_1.useEffect)(() => {
|
|
28
|
-
(0, api_1.api)().listIntegrations({ projectId }, {
|
|
28
|
+
(0, api_1.api)().integrationApi.listIntegrations({ projectId }, {
|
|
29
29
|
headers: {
|
|
30
30
|
'X-Api-Key': apiKey !== null && apiKey !== void 0 ? apiKey : '',
|
|
31
31
|
},
|
|
@@ -4,9 +4,9 @@ exports.ProjectProvider = exports.useProject = exports.ProjectContext = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const LoadingIcon_1 = require("../assets/LoadingIcon");
|
|
7
|
-
const ErrorTextBox_1 = require("../components/
|
|
7
|
+
const ErrorTextBox_1 = require("../components/ErrorTextBox");
|
|
8
8
|
const api_1 = require("../services/api");
|
|
9
|
-
const
|
|
9
|
+
const ApiKeyContextProvider_1 = require("./ApiKeyContextProvider");
|
|
10
10
|
const ErrorContextProvider_1 = require("./ErrorContextProvider");
|
|
11
11
|
exports.ProjectContext = (0, react_1.createContext)({
|
|
12
12
|
project: null,
|
|
@@ -22,12 +22,12 @@ const useProject = () => {
|
|
|
22
22
|
};
|
|
23
23
|
exports.useProject = useProject;
|
|
24
24
|
function ProjectProvider({ projectId, children }) {
|
|
25
|
-
const apiKey = (0,
|
|
25
|
+
const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
|
|
26
26
|
const { isError, setError } = (0, ErrorContextProvider_1.useErrorState)();
|
|
27
27
|
const [project, setProject] = (0, react_1.useState)(null);
|
|
28
28
|
const [isLoading, setLoadingState] = (0, react_1.useState)(true);
|
|
29
29
|
(0, react_1.useEffect)(() => {
|
|
30
|
-
(0, api_1.api)().getProject({ projectId }, {
|
|
30
|
+
(0, api_1.api)().projectApi.getProject({ projectId }, {
|
|
31
31
|
headers: {
|
|
32
32
|
'X-Api-Key': apiKey !== null && apiKey !== void 0 ? apiKey : '',
|
|
33
33
|
},
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useIsIntegrationInstalled = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
5
|
+
const ApiKeyContextProvider_1 = require("../context/ApiKeyContextProvider");
|
|
6
|
+
const IntegrationListContextProvider_1 = require("../context/IntegrationListContextProvider");
|
|
7
|
+
const ProjectContextProvider_1 = require("../context/ProjectContextProvider");
|
|
8
8
|
const api_1 = require("../services/api");
|
|
9
9
|
const useIsIntegrationInstalled = (integration, groupRef) => {
|
|
10
|
-
const apiKey = (0,
|
|
11
|
-
const { projectId } = (0,
|
|
12
|
-
const { integrations } = (0,
|
|
10
|
+
const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
|
|
11
|
+
const { projectId } = (0, ProjectContextProvider_1.useProject)();
|
|
12
|
+
const { integrations } = (0, IntegrationListContextProvider_1.useIntegrationList)();
|
|
13
13
|
const [isLoaded, setIsLoaded] = (0, react_1.useState)(false);
|
|
14
14
|
const [isIntegrationInstalled, setIsIntegrationInstalled] = (0, react_1.useState)(null);
|
|
15
15
|
if (!apiKey || !projectId) {
|
|
@@ -27,7 +27,7 @@ const useIsIntegrationInstalled = (integration, groupRef) => {
|
|
|
27
27
|
(0, react_1.useEffect)(() => {
|
|
28
28
|
if (!integrationToCheck)
|
|
29
29
|
return;
|
|
30
|
-
(0, api_1.api)().listInstallations({
|
|
30
|
+
(0, api_1.api)().installationApi.listInstallations({
|
|
31
31
|
projectId,
|
|
32
32
|
integrationId: integrationToCheck.id,
|
|
33
33
|
groupRef,
|
package/build/src/index.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './hooks';
|
|
1
|
+
export * from './public';
|
package/build/src/index.js
CHANGED
|
@@ -14,5 +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("./
|
|
18
|
-
__exportStar(require("./hooks"), exports);
|
|
17
|
+
__exportStar(require("./public"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contains all the features to be exported out of the library
|
|
3
|
+
*/
|
|
4
|
+
export * from '../context/AmpersandContextProvider';
|
|
5
|
+
export * from '../components/Configure';
|
|
6
|
+
export * from '../components/Connect/ConnectProvider';
|
|
7
|
+
export * from '../hooks/useIsIntegrationInstalled';
|
|
@@ -14,6 +14,10 @@ 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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Contains all the features to be exported out of the library
|
|
19
|
+
*/
|
|
20
|
+
__exportStar(require("../context/AmpersandContextProvider"), exports);
|
|
21
|
+
__exportStar(require("../components/Configure"), exports);
|
|
22
|
+
__exportStar(require("../components/Connect/ConnectProvider"), exports);
|
|
23
|
+
__exportStar(require("../hooks/useIsIntegrationInstalled"), exports);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AllowedDomainApi, Configuration, ConnectionApi, ConsumerApi, DestinationApi, GroupApi, InstallationApi, IntegrationApi, OAuthApi, OperationApi, OperationLogApi, ProjectApi, ProjectMembershipApi, ProviderAppApi, RevisionApi, UploadURLApi } from '../../generated-sources/api/src';
|
|
2
|
+
/**
|
|
3
|
+
* ApiService is a wrapper around the generated API client, which exposes
|
|
4
|
+
* all generated api services as properties.
|
|
5
|
+
* This allows us to inject the configuration object into every api service.
|
|
6
|
+
*
|
|
7
|
+
* New or legacy services need to be added or deleted here after services are generated.
|
|
8
|
+
* Note: some services are not used in this repo.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ApiService {
|
|
11
|
+
allowedDomainApi: AllowedDomainApi;
|
|
12
|
+
connectionApi: ConnectionApi;
|
|
13
|
+
consumerApi: ConsumerApi;
|
|
14
|
+
destinationApi: DestinationApi;
|
|
15
|
+
groupApi: GroupApi;
|
|
16
|
+
installationApi: InstallationApi;
|
|
17
|
+
integrationApi: IntegrationApi;
|
|
18
|
+
oAuthApi: OAuthApi;
|
|
19
|
+
operationApi: OperationApi;
|
|
20
|
+
operationLogApi: OperationLogApi;
|
|
21
|
+
projectApi: ProjectApi;
|
|
22
|
+
projectMembershipApi: ProjectMembershipApi;
|
|
23
|
+
providerAppApi: ProviderAppApi;
|
|
24
|
+
revisionApi: RevisionApi;
|
|
25
|
+
uploadURLApi: UploadURLApi;
|
|
26
|
+
constructor(config: Configuration);
|
|
27
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiService = void 0;
|
|
4
|
+
/* eslint-disable import/no-relative-packages */
|
|
5
|
+
// currently not using a bundler to support alias imports
|
|
6
|
+
const src_1 = require("../../generated-sources/api/src");
|
|
7
|
+
/**
|
|
8
|
+
* ApiService is a wrapper around the generated API client, which exposes
|
|
9
|
+
* all generated api services as properties.
|
|
10
|
+
* This allows us to inject the configuration object into every api service.
|
|
11
|
+
*
|
|
12
|
+
* New or legacy services need to be added or deleted here after services are generated.
|
|
13
|
+
* Note: some services are not used in this repo.
|
|
14
|
+
*/
|
|
15
|
+
class ApiService {
|
|
16
|
+
constructor(config) {
|
|
17
|
+
this.allowedDomainApi = new src_1.AllowedDomainApi(config);
|
|
18
|
+
this.connectionApi = new src_1.ConnectionApi(config);
|
|
19
|
+
this.consumerApi = new src_1.ConsumerApi(config);
|
|
20
|
+
this.destinationApi = new src_1.DestinationApi(config);
|
|
21
|
+
this.groupApi = new src_1.GroupApi(config);
|
|
22
|
+
this.installationApi = new src_1.InstallationApi(config);
|
|
23
|
+
this.integrationApi = new src_1.IntegrationApi(config);
|
|
24
|
+
this.oAuthApi = new src_1.OAuthApi(config);
|
|
25
|
+
this.operationApi = new src_1.OperationApi(config);
|
|
26
|
+
this.operationLogApi = new src_1.OperationLogApi(config);
|
|
27
|
+
this.projectApi = new src_1.ProjectApi(config);
|
|
28
|
+
this.projectMembershipApi = new src_1.ProjectMembershipApi(config);
|
|
29
|
+
this.providerAppApi = new src_1.ProviderAppApi(config);
|
|
30
|
+
this.revisionApi = new src_1.RevisionApi(config);
|
|
31
|
+
this.uploadURLApi = new src_1.UploadURLApi(config);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.ApiService = ApiService;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Config, Connection, CreateInstallationOperationRequest, CreateInstallationRequestConfig,
|
|
1
|
+
import { Config, Connection, CreateInstallationOperationRequest, CreateInstallationRequestConfig, HydratedIntegrationField, HydratedIntegrationFieldExistent, HydratedIntegrationObject, HydratedIntegrationRead, HydratedIntegrationWrite, HydratedIntegrationWriteObject, HydratedRevision, Installation, Integration, IntegrationFieldMapping, Project, ProviderApp, UpdateInstallationOperationRequest, UpdateInstallationRequestInstallationConfig } from '../../generated-sources/api/src';
|
|
2
|
+
import { ApiService } from './ApiService';
|
|
2
3
|
export declare const AMP_SERVER: string;
|
|
3
4
|
export declare const AMP_API_ROOT: string;
|
|
4
|
-
export declare const setApi: (api:
|
|
5
|
-
export declare const api: () =>
|
|
5
|
+
export declare const setApi: (api: ApiService) => void;
|
|
6
|
+
export declare const api: () => ApiService;
|
|
6
7
|
/**
|
|
7
8
|
* Types exported from generated api
|
|
8
9
|
*/
|
|
9
|
-
export type { Config, Connection, CreateInstallationOperationRequest, CreateInstallationRequestConfig, HydratedIntegrationRead, HydratedIntegrationObject, HydratedIntegrationField, HydratedRevision, Installation, Integration, HydratedIntegrationFieldExistent, IntegrationFieldMapping, Project, ProviderApp, UpdateInstallationOperationRequest, UpdateInstallationRequestInstallationConfig, };
|
|
10
|
+
export type { Config, Connection, CreateInstallationOperationRequest, CreateInstallationRequestConfig, HydratedIntegrationRead, HydratedIntegrationWrite, HydratedIntegrationWriteObject, HydratedIntegrationObject, HydratedIntegrationField, HydratedRevision, Installation, Integration, HydratedIntegrationFieldExistent, IntegrationFieldMapping, Project, ProviderApp, UpdateInstallationOperationRequest, UpdateInstallationRequestInstallationConfig, };
|
|
@@ -4,6 +4,7 @@ exports.api = exports.setApi = exports.AMP_API_ROOT = exports.AMP_SERVER = void
|
|
|
4
4
|
/* eslint-disable import/no-relative-packages */
|
|
5
5
|
// currently not using a bundler to support alias imports
|
|
6
6
|
const src_1 = require("../../generated-sources/api/src");
|
|
7
|
+
const ApiService_1 = require("./ApiService");
|
|
7
8
|
/**
|
|
8
9
|
* To update the api you need to
|
|
9
10
|
* 1. git clone `https://github.com/amp-labs/server` into a sibling directory
|
|
@@ -17,8 +18,12 @@ const src_1 = require("../../generated-sources/api/src");
|
|
|
17
18
|
* */
|
|
18
19
|
const VERSION = 'v1';
|
|
19
20
|
function getApiEndpoint() {
|
|
20
|
-
var _a;
|
|
21
|
-
|
|
21
|
+
var _a, _b, _c;
|
|
22
|
+
const prodEndpoint = 'https://api.withampersand.com';
|
|
23
|
+
if (typeof process === 'undefined') {
|
|
24
|
+
return prodEndpoint;
|
|
25
|
+
}
|
|
26
|
+
switch ((_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a.REACT_APP_AMP_SERVER) {
|
|
22
27
|
case 'local':
|
|
23
28
|
return 'http://localhost:8080';
|
|
24
29
|
case 'dev':
|
|
@@ -26,15 +31,15 @@ function getApiEndpoint() {
|
|
|
26
31
|
case 'staging':
|
|
27
32
|
return 'https://staging-api.withampersand.com';
|
|
28
33
|
case 'prod':
|
|
29
|
-
return
|
|
34
|
+
return prodEndpoint;
|
|
30
35
|
case 'mock':
|
|
31
36
|
return 'http://127.0.0.1:4010';
|
|
32
37
|
case '':
|
|
33
|
-
return
|
|
38
|
+
return prodEndpoint;
|
|
34
39
|
default:
|
|
35
40
|
// The user may provide an arbitrary URL here if they want to, or else the
|
|
36
41
|
// default prod url will be used.
|
|
37
|
-
return (
|
|
42
|
+
return (_c = (_b = process === null || process === void 0 ? void 0 : process.env) === null || _b === void 0 ? void 0 : _b.REACT_APP_AMP_SERVER) !== null && _c !== void 0 ? _c : prodEndpoint;
|
|
38
43
|
}
|
|
39
44
|
}
|
|
40
45
|
const getApiRoot = (server, version) => `${server}/${version}`;
|
|
@@ -54,7 +59,7 @@ exports.AMP_API_ROOT = assignRoot();
|
|
|
54
59
|
const config = new src_1.Configuration({
|
|
55
60
|
basePath: exports.AMP_API_ROOT,
|
|
56
61
|
});
|
|
57
|
-
let apiValue = new
|
|
62
|
+
let apiValue = new ApiService_1.ApiService(config);
|
|
58
63
|
// For testing, etc. we may want to use a different API configuration than the default
|
|
59
64
|
const setApi = (api) => {
|
|
60
65
|
apiValue = api;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amp-labs/react",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"description": "Ampersand React library",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Ampersand React library.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Ampersand Labs",
|
|
7
7
|
"url": "http://withampersand.com"
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"eslint-plugin-promise": "^6.1.1",
|
|
62
62
|
"eslint-plugin-react": "^7.33.2",
|
|
63
63
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
64
|
-
"eslint-plugin-simple-import-sort": "^
|
|
64
|
+
"eslint-plugin-simple-import-sort": "^12.0.0",
|
|
65
65
|
"jest": "^29.7.0",
|
|
66
66
|
"react-test-renderer": "^18.2.0",
|
|
67
67
|
"typescript": "^5.2.2"
|