@amp-labs/react 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +138 -0
- package/build/generated-sources/api/src/apis/DefaultApi.d.ts +858 -0
- package/build/generated-sources/api/src/apis/DefaultApi.js +942 -0
- package/build/generated-sources/api/src/apis/index.d.ts +1 -0
- package/build/generated-sources/api/src/apis/index.js +19 -0
- package/build/generated-sources/api/src/index.d.ts +3 -0
- package/build/generated-sources/api/src/index.js +21 -0
- package/build/generated-sources/api/src/models/BaseConfigContent.d.ts +38 -0
- package/build/generated-sources/api/src/models/BaseConfigContent.js +53 -0
- package/build/generated-sources/api/src/models/BaseReadConfig.d.ts +34 -0
- package/build/generated-sources/api/src/models/BaseReadConfig.js +51 -0
- package/build/generated-sources/api/src/models/BaseReadConfigStandardObject.d.ts +59 -0
- package/build/generated-sources/api/src/models/BaseReadConfigStandardObject.js +58 -0
- package/build/generated-sources/api/src/models/BatchUpsertIntegrationsRequest.d.ts +31 -0
- package/build/generated-sources/api/src/models/BatchUpsertIntegrationsRequest.js +50 -0
- package/build/generated-sources/api/src/models/Config.d.ts +56 -0
- package/build/generated-sources/api/src/models/Config.js +63 -0
- package/build/generated-sources/api/src/models/ConfigContent.d.ts +37 -0
- package/build/generated-sources/api/src/models/ConfigContent.js +53 -0
- package/build/generated-sources/api/src/models/ConfigContentAllOf.d.ts +31 -0
- package/build/generated-sources/api/src/models/ConfigContentAllOf.js +50 -0
- package/build/generated-sources/api/src/models/Connection.d.ts +82 -0
- package/build/generated-sources/api/src/models/Connection.js +76 -0
- package/build/generated-sources/api/src/models/Consumer.d.ts +55 -0
- package/build/generated-sources/api/src/models/Consumer.js +62 -0
- package/build/generated-sources/api/src/models/CreateConsumerRequest.d.ts +37 -0
- package/build/generated-sources/api/src/models/CreateConsumerRequest.js +53 -0
- package/build/generated-sources/api/src/models/CreateDestinationRequest.d.ts +44 -0
- package/build/generated-sources/api/src/models/CreateDestinationRequest.js +57 -0
- package/build/generated-sources/api/src/models/CreateDestinationRequestMetadata.d.ts +39 -0
- package/build/generated-sources/api/src/models/CreateDestinationRequestMetadata.js +52 -0
- package/build/generated-sources/api/src/models/CreateGroupRequest.d.ts +37 -0
- package/build/generated-sources/api/src/models/CreateGroupRequest.js +53 -0
- package/build/generated-sources/api/src/models/CreateInstallationRequest.d.ts +44 -0
- package/build/generated-sources/api/src/models/CreateInstallationRequest.js +57 -0
- package/build/generated-sources/api/src/models/CreateInstallationRequestConfig.d.ts +44 -0
- package/build/generated-sources/api/src/models/CreateInstallationRequestConfig.js +57 -0
- package/build/generated-sources/api/src/models/CreateIntegrationRequest.d.ts +44 -0
- package/build/generated-sources/api/src/models/CreateIntegrationRequest.js +57 -0
- package/build/generated-sources/api/src/models/CreateIntegrationRequestLatestRevision.d.ts +31 -0
- package/build/generated-sources/api/src/models/CreateIntegrationRequestLatestRevision.js +50 -0
- package/build/generated-sources/api/src/models/CreateProjectRequest.d.ts +37 -0
- package/build/generated-sources/api/src/models/CreateProjectRequest.js +53 -0
- package/build/generated-sources/api/src/models/CreateProviderAppRequest.d.ts +49 -0
- package/build/generated-sources/api/src/models/CreateProviderAppRequest.js +59 -0
- package/build/generated-sources/api/src/models/Group.d.ts +55 -0
- package/build/generated-sources/api/src/models/Group.js +62 -0
- package/build/generated-sources/api/src/models/HydratedIntegration.d.ts +50 -0
- package/build/generated-sources/api/src/models/HydratedIntegration.js +59 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationField.d.ts +22 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationField.js +45 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationFieldExistent.d.ts +37 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationFieldExistent.js +53 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationObject.d.ts +75 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationObject.js +70 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationRead.d.ts +32 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationRead.js +51 -0
- package/build/generated-sources/api/src/models/HydratedRevision.d.ts +50 -0
- package/build/generated-sources/api/src/models/HydratedRevision.js +60 -0
- package/build/generated-sources/api/src/models/ImportConnectionRequest.d.ts +85 -0
- package/build/generated-sources/api/src/models/ImportConnectionRequest.js +75 -0
- package/build/generated-sources/api/src/models/ImportInstallationRequest.d.ts +39 -0
- package/build/generated-sources/api/src/models/ImportInstallationRequest.js +55 -0
- package/build/generated-sources/api/src/models/ImportInstallationRequestConfig.d.ts +38 -0
- package/build/generated-sources/api/src/models/ImportInstallationRequestConfig.js +54 -0
- package/build/generated-sources/api/src/models/Installation.d.ts +88 -0
- package/build/generated-sources/api/src/models/Installation.js +79 -0
- package/build/generated-sources/api/src/models/Integration.d.ts +68 -0
- package/build/generated-sources/api/src/models/Integration.js +69 -0
- package/build/generated-sources/api/src/models/Integration1.d.ts +50 -0
- package/build/generated-sources/api/src/models/Integration1.js +59 -0
- package/build/generated-sources/api/src/models/IntegrationField.d.ts +22 -0
- package/build/generated-sources/api/src/models/IntegrationField.js +45 -0
- package/build/generated-sources/api/src/models/IntegrationFieldExistent.d.ts +31 -0
- package/build/generated-sources/api/src/models/IntegrationFieldExistent.js +50 -0
- package/build/generated-sources/api/src/models/IntegrationFieldMapping.d.ts +49 -0
- package/build/generated-sources/api/src/models/IntegrationFieldMapping.js +57 -0
- package/build/generated-sources/api/src/models/IntegrationObject.d.ts +63 -0
- package/build/generated-sources/api/src/models/IntegrationObject.js +65 -0
- package/build/generated-sources/api/src/models/IntegrationRead.d.ts +32 -0
- package/build/generated-sources/api/src/models/IntegrationRead.js +51 -0
- package/build/generated-sources/api/src/models/OauthConnectRequest.d.ts +73 -0
- package/build/generated-sources/api/src/models/OauthConnectRequest.js +70 -0
- package/build/generated-sources/api/src/models/Operation.d.ts +80 -0
- package/build/generated-sources/api/src/models/Operation.js +73 -0
- package/build/generated-sources/api/src/models/OperationError.d.ts +49 -0
- package/build/generated-sources/api/src/models/OperationError.js +56 -0
- package/build/generated-sources/api/src/models/OptionalFieldsAutoOption.d.ts +22 -0
- package/build/generated-sources/api/src/models/OptionalFieldsAutoOption.js +35 -0
- package/build/generated-sources/api/src/models/Project.d.ts +55 -0
- package/build/generated-sources/api/src/models/Project.js +62 -0
- package/build/generated-sources/api/src/models/ProjectMembership.d.ts +56 -0
- package/build/generated-sources/api/src/models/ProjectMembership.js +63 -0
- package/build/generated-sources/api/src/models/ProviderApp.d.ts +67 -0
- package/build/generated-sources/api/src/models/ProviderApp.js +67 -0
- package/build/generated-sources/api/src/models/Revision.d.ts +50 -0
- package/build/generated-sources/api/src/models/Revision.js +60 -0
- package/build/generated-sources/api/src/models/UpdateInstallationConfigContent.d.ts +38 -0
- package/build/generated-sources/api/src/models/UpdateInstallationConfigContent.js +53 -0
- package/build/generated-sources/api/src/models/UpdateInstallationRequest.d.ts +38 -0
- package/build/generated-sources/api/src/models/UpdateInstallationRequest.js +54 -0
- package/build/generated-sources/api/src/models/UpdateInstallationRequestInstallation.d.ts +38 -0
- package/build/generated-sources/api/src/models/UpdateInstallationRequestInstallation.js +53 -0
- package/build/generated-sources/api/src/models/UpdateInstallationRequestInstallationConfig.d.ts +44 -0
- package/build/generated-sources/api/src/models/UpdateInstallationRequestInstallationConfig.js +55 -0
- package/build/generated-sources/api/src/models/UpdateProjectRequest.d.ts +38 -0
- package/build/generated-sources/api/src/models/UpdateProjectRequest.js +54 -0
- package/build/generated-sources/api/src/models/UpdateProjectRequestProject.d.ts +37 -0
- package/build/generated-sources/api/src/models/UpdateProjectRequestProject.js +52 -0
- package/build/generated-sources/api/src/models/UpdateProviderAppRequest.d.ts +38 -0
- package/build/generated-sources/api/src/models/UpdateProviderAppRequest.js +54 -0
- package/build/generated-sources/api/src/models/UpdateProviderAppRequestProviderApp.d.ts +49 -0
- package/build/generated-sources/api/src/models/UpdateProviderAppRequestProviderApp.js +56 -0
- package/build/generated-sources/api/src/models/UpsertProjectMembershipRequest.d.ts +37 -0
- package/build/generated-sources/api/src/models/UpsertProjectMembershipRequest.js +53 -0
- package/build/generated-sources/api/src/models/index.d.ts +54 -0
- package/build/generated-sources/api/src/models/index.js +72 -0
- package/build/generated-sources/api/src/runtime.d.ts +182 -0
- package/build/generated-sources/api/src/runtime.js +317 -0
- package/build/src/assets/LoadingIcon.d.ts +5 -0
- package/build/src/assets/LoadingIcon.js +9 -0
- package/build/src/assets/NavIcon.d.ts +1 -0
- package/build/src/assets/NavIcon.js +23 -0
- package/build/src/components/AmpersandProvider/AmpersandProvider.d.ts +19 -0
- package/build/src/components/AmpersandProvider/AmpersandProvider.js +31 -0
- package/build/src/components/AmpersandProvider/index.d.ts +1 -0
- package/build/src/components/AmpersandProvider/index.js +17 -0
- package/build/src/components/CenteredTextBox/CenteredTextBox.d.ts +5 -0
- package/build/src/components/CenteredTextBox/CenteredTextBox.js +8 -0
- package/build/src/components/Configure/ConfigureInstallationBase.d.ts +8 -0
- package/build/src/components/Configure/ConfigureInstallationBase.js +17 -0
- package/build/src/components/Configure/CreateInstallation.d.ts +1 -0
- package/build/src/components/Configure/CreateInstallation.js +73 -0
- package/build/src/components/Configure/ErrorTextBox.d.ts +5 -0
- package/build/src/components/Configure/ErrorTextBox.js +9 -0
- package/build/src/components/Configure/InstallIntegration.d.ts +9 -0
- package/build/src/components/Configure/InstallIntegration.js +40 -0
- package/build/src/components/Configure/ObjectManagementNav/NavObjectItem.d.ts +8 -0
- package/build/src/components/Configure/ObjectManagementNav/NavObjectItem.js +14 -0
- package/build/src/components/Configure/ObjectManagementNav/index.d.ts +9 -0
- package/build/src/components/Configure/ObjectManagementNav/index.js +45 -0
- package/build/src/components/Configure/ProtectedConnectionLayout.d.ts +6 -0
- package/build/src/components/Configure/ProtectedConnectionLayout.js +28 -0
- package/build/src/components/Configure/UpdateInstallation.d.ts +7 -0
- package/build/src/components/Configure/UpdateInstallation.js +87 -0
- package/build/src/components/Configure/actions/onSaveCreate.d.ts +3 -0
- package/build/src/components/Configure/actions/onSaveCreate.js +90 -0
- package/build/src/components/Configure/actions/onSaveUpdate.d.ts +3 -0
- package/build/src/components/Configure/actions/onSaveUpdate.js +74 -0
- package/build/src/components/Configure/fields/FieldHeader.d.ts +5 -0
- package/build/src/components/Configure/fields/FieldHeader.js +9 -0
- package/build/src/components/Configure/fields/FieldMapping.d.ts +10 -0
- package/build/src/components/Configure/fields/FieldMapping.js +28 -0
- package/build/src/components/Configure/fields/OptionalFields.d.ts +1 -0
- package/build/src/components/Configure/fields/OptionalFields.js +45 -0
- package/build/src/components/Configure/fields/RequiredFieldMappings.d.ts +1 -0
- package/build/src/components/Configure/fields/RequiredFieldMappings.js +40 -0
- package/build/src/components/Configure/fields/RequiredFields.d.ts +1 -0
- package/build/src/components/Configure/fields/RequiredFields.js +27 -0
- package/build/src/components/Configure/index.d.ts +1 -0
- package/build/src/components/Configure/index.js +5 -0
- package/build/src/components/Configure/state/ConfigurationStateProvider.d.ts +13 -0
- package/build/src/components/Configure/state/ConfigurationStateProvider.js +54 -0
- package/build/src/components/Configure/state/HydratedRevisionContext.d.ts +14 -0
- package/build/src/components/Configure/state/HydratedRevisionContext.js +82 -0
- package/build/src/components/Configure/state/utils.d.ts +34 -0
- package/build/src/components/Configure/state/utils.js +146 -0
- package/build/src/components/Configure/types.d.ts +31 -0
- package/build/src/components/Configure/types.js +2 -0
- package/build/src/components/Configure/utils.d.ts +24 -0
- package/build/src/components/Configure/utils.js +82 -0
- package/build/src/components/OAuthPopup/OAuthPopup.d.ts +14 -0
- package/build/src/components/OAuthPopup/OAuthPopup.js +85 -0
- package/build/src/components/Salesforce/SalesforceOauthFlow.d.ts +16 -0
- package/build/src/components/Salesforce/SalesforceOauthFlow.js +78 -0
- package/build/src/components/ThemeProvider/index.d.ts +6 -0
- package/build/src/components/ThemeProvider/index.js +37 -0
- package/build/src/components/index.d.ts +2 -0
- package/build/src/components/index.js +18 -0
- package/build/src/constants.d.ts +1 -0
- package/build/src/constants.js +4 -0
- package/build/src/context/ApiKeyContext.d.ts +3 -0
- package/build/src/context/ApiKeyContext.js +6 -0
- package/build/src/context/ConnectionsContext.d.ts +16 -0
- package/build/src/context/ConnectionsContext.js +57 -0
- package/build/src/context/ErrorContextProvider.d.ts +37 -0
- package/build/src/context/ErrorContextProvider.js +72 -0
- package/build/src/context/InstallIntegrationContext.d.ts +24 -0
- package/build/src/context/InstallIntegrationContext.js +90 -0
- package/build/src/context/IntegrationListContext.d.ts +13 -0
- package/build/src/context/IntegrationListContext.js +48 -0
- package/build/src/context/ProjectContext.d.ts +15 -0
- package/build/src/context/ProjectContext.js +50 -0
- package/build/src/hooks/index.d.ts +1 -0
- package/build/src/hooks/index.js +17 -0
- package/build/src/hooks/useIsIntegrationInstalled.d.ts +6 -0
- package/build/src/hooks/useIsIntegrationInstalled.js +48 -0
- package/build/src/index.d.ts +2 -0
- package/build/src/index.js +18 -0
- package/build/src/services/api.d.ts +9 -0
- package/build/src/services/api.js +64 -0
- package/build/src/utils/index.d.ts +10 -0
- package/build/src/utils/index.js +21 -0
- package/package.json +80 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProjectProvider = exports.useProject = exports.ProjectContext = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const LoadingIcon_1 = require("../assets/LoadingIcon");
|
|
7
|
+
const ErrorTextBox_1 = require("../components/Configure/ErrorTextBox");
|
|
8
|
+
const api_1 = require("../services/api");
|
|
9
|
+
const ApiKeyContext_1 = require("./ApiKeyContext");
|
|
10
|
+
const ErrorContextProvider_1 = require("./ErrorContextProvider");
|
|
11
|
+
exports.ProjectContext = (0, react_1.createContext)({
|
|
12
|
+
project: null,
|
|
13
|
+
appName: '',
|
|
14
|
+
projectId: '',
|
|
15
|
+
});
|
|
16
|
+
const useProject = () => {
|
|
17
|
+
const context = (0, react_1.useContext)(exports.ProjectContext);
|
|
18
|
+
if (!context) {
|
|
19
|
+
throw new Error('useProject must be used within a ProjectProvider');
|
|
20
|
+
}
|
|
21
|
+
return context;
|
|
22
|
+
};
|
|
23
|
+
exports.useProject = useProject;
|
|
24
|
+
function ProjectProvider({ projectId, children }) {
|
|
25
|
+
const [project, setProject] = (0, react_1.useState)(null);
|
|
26
|
+
const apiKey = (0, react_1.useContext)(ApiKeyContext_1.ApiKeyContext);
|
|
27
|
+
const [isLoading, setLoadingState] = (0, react_1.useState)(true);
|
|
28
|
+
const { isError, setError } = (0, ErrorContextProvider_1.useErrorState)();
|
|
29
|
+
(0, react_1.useEffect)(() => {
|
|
30
|
+
(0, api_1.api)().getProject({ projectId }, {
|
|
31
|
+
headers: {
|
|
32
|
+
'X-Api-Key': apiKey !== null && apiKey !== void 0 ? apiKey : '',
|
|
33
|
+
},
|
|
34
|
+
}).then((_project) => {
|
|
35
|
+
setLoadingState(false);
|
|
36
|
+
setProject(_project);
|
|
37
|
+
}).catch((err) => {
|
|
38
|
+
setError(ErrorContextProvider_1.ErrorBoundary.PROJECT, projectId);
|
|
39
|
+
setLoadingState(false);
|
|
40
|
+
console.error('Error loading Ampersand project: ', err);
|
|
41
|
+
});
|
|
42
|
+
}, [projectId, apiKey, setLoadingState, setError]);
|
|
43
|
+
const contextValue = (0, react_1.useMemo)(() => ({
|
|
44
|
+
projectId, project, appName: (project === null || project === void 0 ? void 0 : project.appName) || '',
|
|
45
|
+
}), [projectId, project]);
|
|
46
|
+
return (isError(ErrorContextProvider_1.ErrorBoundary.PROJECT, projectId)
|
|
47
|
+
? (0, jsx_runtime_1.jsx)(ErrorTextBox_1.ErrorTextBox, { message: `Error loading project ${projectId}` })
|
|
48
|
+
: ((0, jsx_runtime_1.jsx)(exports.ProjectContext.Provider, { value: contextValue, children: isLoading ? (0, jsx_runtime_1.jsx)(LoadingIcon_1.LoadingIcon, {}) : children })));
|
|
49
|
+
}
|
|
50
|
+
exports.ProjectProvider = ProjectProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useIsIntegrationInstalled';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useIsIntegrationInstalled"), exports);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useIsIntegrationInstalled = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const ApiKeyContext_1 = require("../context/ApiKeyContext");
|
|
6
|
+
const IntegrationListContext_1 = require("../context/IntegrationListContext");
|
|
7
|
+
const ProjectContext_1 = require("../context/ProjectContext");
|
|
8
|
+
const api_1 = require("../services/api");
|
|
9
|
+
const useIsIntegrationInstalled = (integration, groupRef) => {
|
|
10
|
+
const apiKey = (0, react_1.useContext)(ApiKeyContext_1.ApiKeyContext);
|
|
11
|
+
const { projectId } = (0, ProjectContext_1.useProject)();
|
|
12
|
+
const { integrations } = (0, IntegrationListContext_1.useIntegrationList)();
|
|
13
|
+
const [isLoaded, setIsLoaded] = (0, react_1.useState)(false);
|
|
14
|
+
const [isIntegrationInstalled, setIsIntegrationInstalled] = (0, react_1.useState)(null);
|
|
15
|
+
if (!apiKey || !projectId) {
|
|
16
|
+
throw new Error('useIsIntegrationInstalled must be used within AmpersandProvider');
|
|
17
|
+
}
|
|
18
|
+
if (!integration) {
|
|
19
|
+
throw new Error('useIsIntegrationInstalled requires an integration name');
|
|
20
|
+
}
|
|
21
|
+
if (!groupRef) {
|
|
22
|
+
throw new Error('useIsIntegrationInstalled requires a groupRef');
|
|
23
|
+
}
|
|
24
|
+
const integrationToCheck = (0, react_1.useMemo)(() => integrations === null || integrations === void 0 ? void 0 : integrations.reduce((acc, _integration) => ((_integration === null || _integration === void 0 ? void 0 : _integration.name) === integration
|
|
25
|
+
? _integration
|
|
26
|
+
: acc), {}), [integrations, integration]);
|
|
27
|
+
(0, react_1.useEffect)(() => {
|
|
28
|
+
if (!integrationToCheck)
|
|
29
|
+
return;
|
|
30
|
+
(0, api_1.api)().listInstallations({
|
|
31
|
+
projectId,
|
|
32
|
+
integrationId: integrationToCheck.id,
|
|
33
|
+
groupRef,
|
|
34
|
+
}, {
|
|
35
|
+
headers: {
|
|
36
|
+
'x-api-key': apiKey,
|
|
37
|
+
},
|
|
38
|
+
}).then((installationList) => {
|
|
39
|
+
setIsLoaded(true);
|
|
40
|
+
setIsIntegrationInstalled(installationList.length > 0);
|
|
41
|
+
}).catch((err) => {
|
|
42
|
+
console.error('Error listing installations: ', err);
|
|
43
|
+
setIsLoaded(true);
|
|
44
|
+
});
|
|
45
|
+
}, [groupRef, apiKey, projectId, integrationToCheck]);
|
|
46
|
+
return { isLoaded, isIntegrationInstalled };
|
|
47
|
+
};
|
|
48
|
+
exports.useIsIntegrationInstalled = useIsIntegrationInstalled;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./components"), exports);
|
|
18
|
+
__exportStar(require("./hooks"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Config, Connection, CreateInstallationOperationRequest, CreateInstallationRequestConfig, DefaultApi, HydratedIntegrationField, HydratedIntegrationFieldExistent, HydratedIntegrationObject, HydratedIntegrationRead, HydratedRevision, Installation, Integration, IntegrationFieldMapping, Project, ProviderApp, UpdateInstallationOperationRequest, UpdateInstallationRequestInstallationConfig } from '../../generated-sources/api/src';
|
|
2
|
+
export declare const AMP_SERVER: string;
|
|
3
|
+
export declare const AMP_API_ROOT: string;
|
|
4
|
+
export declare const setApi: (api: DefaultApi) => void;
|
|
5
|
+
export declare const api: () => DefaultApi;
|
|
6
|
+
/**
|
|
7
|
+
* Types exported from generated api
|
|
8
|
+
*/
|
|
9
|
+
export type { Config, Connection, CreateInstallationOperationRequest, CreateInstallationRequestConfig, HydratedIntegrationRead, HydratedIntegrationObject, HydratedIntegrationField, HydratedRevision, Installation, Integration, HydratedIntegrationFieldExistent, IntegrationFieldMapping, Project, ProviderApp, UpdateInstallationOperationRequest, UpdateInstallationRequestInstallationConfig, };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.api = exports.setApi = exports.AMP_API_ROOT = exports.AMP_SERVER = 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
|
+
* To update the api you need to
|
|
9
|
+
* 1. git clone `https://github.com/amp-labs/server` into a sibling directory
|
|
10
|
+
* 2. run `yarn generate-api`
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* When we run ```prism mock -d ./openapi/api.yaml```, prism will mock a server
|
|
15
|
+
* based on the api.yaml swagger (open-api v2) spec
|
|
16
|
+
*
|
|
17
|
+
* */
|
|
18
|
+
const VERSION = 'v1';
|
|
19
|
+
function getApiEndpoint() {
|
|
20
|
+
var _a;
|
|
21
|
+
switch (process.env.REACT_APP_AMP_SERVER) {
|
|
22
|
+
case 'local':
|
|
23
|
+
return 'http://localhost:8080';
|
|
24
|
+
case 'dev':
|
|
25
|
+
return 'https://dev-api.withampersand.com';
|
|
26
|
+
case 'staging':
|
|
27
|
+
return 'https://staging-api.withampersand.com';
|
|
28
|
+
case 'prod':
|
|
29
|
+
return 'https://api.withampersand.com';
|
|
30
|
+
case 'mock':
|
|
31
|
+
return 'http://127.0.0.1:4010';
|
|
32
|
+
case '':
|
|
33
|
+
return 'https://api.withampersand.com';
|
|
34
|
+
default:
|
|
35
|
+
// The user may provide an arbitrary URL here if they want to, or else the
|
|
36
|
+
// default prod url will be used.
|
|
37
|
+
return (_a = process.env.REACT_APP_AMP_SERVER) !== null && _a !== void 0 ? _a : 'https://api.withampersand.com';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const getApiRoot = (server, version) => `${server}/${version}`;
|
|
41
|
+
// REACT_APP_AMP_SERVER=local npm start will use the local server
|
|
42
|
+
function assignRoot() {
|
|
43
|
+
return getApiRoot(getApiEndpoint(), VERSION);
|
|
44
|
+
}
|
|
45
|
+
exports.AMP_SERVER = getApiEndpoint();
|
|
46
|
+
exports.AMP_API_ROOT = assignRoot();
|
|
47
|
+
/**
|
|
48
|
+
* we can modify the authentication, baseURL and other configurations to access
|
|
49
|
+
* our API in the future
|
|
50
|
+
*
|
|
51
|
+
* When in dev mode we want to mock the PRISM_MOCK_URL
|
|
52
|
+
*
|
|
53
|
+
* */
|
|
54
|
+
const config = new src_1.Configuration({
|
|
55
|
+
basePath: exports.AMP_API_ROOT,
|
|
56
|
+
});
|
|
57
|
+
let apiValue = new src_1.DefaultApi(config);
|
|
58
|
+
// For testing, etc. we may want to use a different API configuration than the default
|
|
59
|
+
const setApi = (api) => {
|
|
60
|
+
apiValue = api;
|
|
61
|
+
};
|
|
62
|
+
exports.setApi = setApi;
|
|
63
|
+
const api = () => apiValue;
|
|
64
|
+
exports.api = api;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Integration } from '../services/api';
|
|
2
|
+
export declare function capitalize(str: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* Given the name of an integration, return the integration object
|
|
5
|
+
*
|
|
6
|
+
* @param integrationName {string} Name of the integration.
|
|
7
|
+
* @param integrations {Integration[]} List of integrations.
|
|
8
|
+
* @returns {Integration | null}
|
|
9
|
+
*/
|
|
10
|
+
export declare const findIntegrationFromList: (integrationName: string, integrations: Integration[]) => Integration | null;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findIntegrationFromList = exports.capitalize = void 0;
|
|
4
|
+
function capitalize(str) {
|
|
5
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
6
|
+
}
|
|
7
|
+
exports.capitalize = capitalize;
|
|
8
|
+
/**
|
|
9
|
+
* Given the name of an integration, return the integration object
|
|
10
|
+
*
|
|
11
|
+
* @param integrationName {string} Name of the integration.
|
|
12
|
+
* @param integrations {Integration[]} List of integrations.
|
|
13
|
+
* @returns {Integration | null}
|
|
14
|
+
*/
|
|
15
|
+
const findIntegrationFromList = (integrationName, integrations) => {
|
|
16
|
+
var _a;
|
|
17
|
+
if ((integrations === null || integrations === void 0 ? void 0 : integrations.length) === 0 || !integrationName)
|
|
18
|
+
return null;
|
|
19
|
+
return (_a = integrations.find((s) => s.name === integrationName)) !== null && _a !== void 0 ? _a : null;
|
|
20
|
+
};
|
|
21
|
+
exports.findIntegrationFromList = findIntegrationFromList;
|
package/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@amp-labs/react",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Ampersand React library.",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Ampersand Labs",
|
|
7
|
+
"url": "http://withampersand.com"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/amp-labs/react/issues"
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public",
|
|
15
|
+
"registry": "https://registry.npmjs.org/"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://github.com/amp-labs/react#readme",
|
|
18
|
+
"main": "build/src/index.js",
|
|
19
|
+
"typings": "build/src/index.d.ts",
|
|
20
|
+
"files": [
|
|
21
|
+
"/build"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"test": "jest",
|
|
25
|
+
"watch": "npm run prepbuild && tsc -p tsconfig.json --watch",
|
|
26
|
+
"build": "npm run prepbuild && tsc -p tsconfig.json",
|
|
27
|
+
"prepbuild": "npm run clean",
|
|
28
|
+
"clean": "rm -rf ./build/",
|
|
29
|
+
"assets": "mkdir ./build/ && cp -R ./src/public/ ./build/public/",
|
|
30
|
+
"lint": "eslint --ext .ts,.tsx -c .eslintrc.cjs src/ --fix",
|
|
31
|
+
"lint:dry": "eslint --ext .ts,.tsx -c .eslintrc.cjs src/",
|
|
32
|
+
"generate-api": "openapi-generator-cli generate -i ../server/openapi/api.yaml -g typescript-fetch -o generated-sources/api --additional-properties=npmName=amp-labs-generated-rest-sdk,supportsES6=true,withInterfaces=true"
|
|
33
|
+
},
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/amp-labs/react.git"
|
|
37
|
+
},
|
|
38
|
+
"jest": {
|
|
39
|
+
"testPathIgnorePatterns": [
|
|
40
|
+
"build"
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@babel/preset-env": "^7.23.2",
|
|
45
|
+
"@babel/preset-react": "^7.22.15",
|
|
46
|
+
"@babel/preset-typescript": "^7.23.2",
|
|
47
|
+
"@chakra-ui/react": "^2.8.1",
|
|
48
|
+
"@jest/globals": "^29.5.0",
|
|
49
|
+
"@openapitools/openapi-generator-cli": "^2.7.0",
|
|
50
|
+
"@types/lodash.isequal": "^4.5.7",
|
|
51
|
+
"@types/react": "^18.2.33",
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^6.9.1",
|
|
53
|
+
"@typescript-eslint/parser": "^6.9.1",
|
|
54
|
+
"babel-jest": "^29.7.0",
|
|
55
|
+
"eslint": "^8.52.0",
|
|
56
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
57
|
+
"eslint-config-airbnb-typescript": "^17.1.0",
|
|
58
|
+
"eslint-plugin-import": "^2.29.0",
|
|
59
|
+
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
60
|
+
"eslint-plugin-n": "^16.2.0",
|
|
61
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
62
|
+
"eslint-plugin-react": "^7.33.2",
|
|
63
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
64
|
+
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
65
|
+
"jest": "^29.7.0",
|
|
66
|
+
"react-test-renderer": "^18.2.0",
|
|
67
|
+
"typescript": "^5.2.2"
|
|
68
|
+
},
|
|
69
|
+
"peerDependencies": {
|
|
70
|
+
"@chakra-ui/react": "^2.4.4",
|
|
71
|
+
"@emotion/react": "^x.x.x",
|
|
72
|
+
"@emotion/styled": "^x.x.x",
|
|
73
|
+
"framer-motion": "^x.x.x",
|
|
74
|
+
"react": "^18.0.0"
|
|
75
|
+
},
|
|
76
|
+
"dependencies": {
|
|
77
|
+
"@chakra-ui/icons": "^2.1.1",
|
|
78
|
+
"lodash.isequal": "^4.5.0"
|
|
79
|
+
}
|
|
80
|
+
}
|