@amp-labs/react 1.1.0 → 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.
Files changed (180) hide show
  1. package/build/generated-sources/api/src/apis/AllowedDomainApi.d.ts +79 -0
  2. package/build/generated-sources/api/src/apis/AllowedDomainApi.js +101 -0
  3. package/build/generated-sources/api/src/apis/ConnectionApi.d.ts +82 -0
  4. package/build/generated-sources/api/src/apis/ConnectionApi.js +107 -0
  5. package/build/generated-sources/api/src/apis/ConsumerApi.d.ts +52 -0
  6. package/build/generated-sources/api/src/apis/ConsumerApi.js +75 -0
  7. package/build/generated-sources/api/src/apis/DestinationApi.d.ts +78 -0
  8. package/build/generated-sources/api/src/apis/DestinationApi.js +102 -0
  9. package/build/generated-sources/api/src/apis/GroupApi.d.ts +52 -0
  10. package/build/generated-sources/api/src/apis/GroupApi.js +75 -0
  11. package/build/generated-sources/api/src/apis/InstallationApi.d.ts +168 -0
  12. package/build/generated-sources/api/src/apis/InstallationApi.js +205 -0
  13. package/build/generated-sources/api/src/apis/IntegrationApi.d.ts +128 -0
  14. package/build/generated-sources/api/src/apis/IntegrationApi.js +154 -0
  15. package/build/generated-sources/api/src/apis/OAuthApi.d.ts +76 -0
  16. package/build/generated-sources/api/src/apis/OAuthApi.js +102 -0
  17. package/build/generated-sources/api/src/apis/OperationApi.d.ts +80 -0
  18. package/build/generated-sources/api/src/apis/OperationApi.js +104 -0
  19. package/build/generated-sources/api/src/apis/OperationLogApi.d.ts +55 -0
  20. package/build/generated-sources/api/src/apis/OperationLogApi.js +76 -0
  21. package/build/generated-sources/api/src/apis/ProjectApi.d.ts +124 -0
  22. package/build/generated-sources/api/src/apis/ProjectApi.js +148 -0
  23. package/build/generated-sources/api/src/apis/ProjectMembershipApi.d.ts +126 -0
  24. package/build/generated-sources/api/src/apis/ProjectMembershipApi.js +154 -0
  25. package/build/generated-sources/api/src/apis/ProviderAppApi.d.ts +130 -0
  26. package/build/generated-sources/api/src/apis/ProviderAppApi.js +158 -0
  27. package/build/generated-sources/api/src/apis/RevisionApi.d.ts +87 -0
  28. package/build/generated-sources/api/src/apis/RevisionApi.js +113 -0
  29. package/build/generated-sources/api/src/apis/UploadURLApi.d.ts +46 -0
  30. package/build/generated-sources/api/src/apis/UploadURLApi.js +68 -0
  31. package/build/generated-sources/api/src/apis/index.d.ts +15 -1
  32. package/build/generated-sources/api/src/apis/index.js +15 -1
  33. package/build/generated-sources/api/src/models/Destination.d.ts +44 -0
  34. package/build/generated-sources/api/src/models/Destination.js +57 -0
  35. package/build/generated-sources/api/src/models/DestinationMetadata.d.ts +39 -0
  36. package/build/generated-sources/api/src/models/{CreateDestinationRequestMetadata.js → DestinationMetadata.js} +11 -11
  37. package/build/generated-sources/api/src/models/OperationLog.d.ts +43 -0
  38. package/build/generated-sources/api/src/models/OperationLog.js +56 -0
  39. package/build/generated-sources/api/src/models/ProviderApp.d.ts +6 -0
  40. package/build/generated-sources/api/src/models/ProviderApp.js +2 -0
  41. package/build/generated-sources/api/src/models/index.d.ts +3 -2
  42. package/build/generated-sources/api/src/models/index.js +3 -2
  43. package/build/src/assets/TrashIcon.js +3 -1
  44. package/build/src/components/Configure/InstallIntegration.d.ts +4 -1
  45. package/build/src/components/Configure/InstallIntegration.js +10 -23
  46. package/build/src/components/Configure/actions/onSaveReadCreateInstallation.d.ts +3 -0
  47. package/build/src/components/Configure/actions/{onSaveCreate.js → onSaveReadCreateInstallation.js} +7 -6
  48. package/build/src/components/Configure/actions/onSaveReadUpdateInstallation.d.ts +3 -0
  49. package/build/src/components/Configure/actions/{onSaveUpdate.js → onSaveReadUpdateInstallation.js} +13 -8
  50. package/build/src/components/Configure/actions/write/generateConfigWriteObjects.d.ts +26 -0
  51. package/build/src/components/Configure/actions/write/generateConfigWriteObjects.js +41 -0
  52. package/build/src/components/Configure/actions/write/onSaveWriteCreateInstallation.d.ts +3 -0
  53. package/build/src/components/Configure/actions/write/onSaveWriteCreateInstallation.js +85 -0
  54. package/build/src/components/Configure/actions/write/onSaveWriteUpdateInstallation.d.ts +3 -0
  55. package/build/src/components/Configure/actions/write/onSaveWriteUpdateInstallation.js +60 -0
  56. package/build/src/components/Configure/{ConfigureInstallationBase.d.ts → content/ConfigureInstallationBase.d.ts} +2 -1
  57. package/build/src/components/Configure/content/ConfigureInstallationBase.js +36 -0
  58. package/build/src/components/Configure/content/CreateInstallation.js +83 -0
  59. package/build/src/components/Configure/content/InstallationContent.d.ts +1 -0
  60. package/build/src/components/Configure/content/InstallationContent.js +20 -0
  61. package/build/src/components/Configure/{UninstallContent.js → content/UninstallContent.js} +10 -9
  62. package/build/src/components/Configure/{UpdateInstallation.d.ts → content/UpdateInstallation.d.ts} +1 -1
  63. package/build/src/components/Configure/{UpdateInstallation.js → content/UpdateInstallation.js} +42 -28
  64. package/build/src/components/Configure/{fields → content/fields}/FieldMappings/FieldMapping.d.ts +1 -1
  65. package/build/src/components/Configure/{fields → content/fields}/FieldMappings/FieldMapping.js +4 -7
  66. package/build/src/components/Configure/{fields → content/fields}/FieldMappings/RequiredFieldMappings.js +10 -11
  67. package/build/src/components/Configure/{fields → content/fields}/FieldMappings/setFieldMapping.d.ts +1 -1
  68. package/build/src/components/Configure/content/fields/FieldMappings/setFieldMapping.js +21 -0
  69. package/build/src/components/Configure/{fields → content/fields}/OptionalFields/OptionalFields.js +9 -14
  70. package/build/src/components/Configure/{fields → content/fields}/OptionalFields/setOptionalField.d.ts +1 -1
  71. package/build/src/components/Configure/content/fields/OptionalFields/setOptionalField.js +27 -0
  72. package/build/src/components/Configure/content/fields/ReadFields.d.ts +1 -0
  73. package/build/src/components/Configure/content/fields/ReadFields.js +11 -0
  74. package/build/src/components/Configure/content/fields/RequiredFields.js +23 -0
  75. package/build/src/components/Configure/content/fields/WriteFields/WriteFields.d.ts +1 -0
  76. package/build/src/components/Configure/content/fields/WriteFields/WriteFields.js +22 -0
  77. package/build/src/components/Configure/content/fields/WriteFields/index.d.ts +2 -0
  78. package/build/src/components/Configure/content/fields/WriteFields/index.js +5 -0
  79. package/build/src/components/Configure/content/fields/WriteFields/setNonConfigurableWriteField.d.ts +3 -0
  80. package/build/src/components/Configure/content/fields/WriteFields/setNonConfigurableWriteField.js +32 -0
  81. package/build/src/components/Configure/content/useMutateInstallation.d.ts +23 -0
  82. package/build/src/components/Configure/content/useMutateInstallation.js +47 -0
  83. package/build/src/components/Configure/content/useSelectedConfigureState.d.ts +72 -0
  84. package/build/src/components/Configure/content/useSelectedConfigureState.js +24 -0
  85. package/build/src/components/Configure/{ProtectedConnectionLayout.d.ts → layout/ProtectedConnectionLayout.d.ts} +2 -1
  86. package/build/src/components/Configure/{ProtectedConnectionLayout.js → layout/ProtectedConnectionLayout.js} +13 -13
  87. package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/NavObjectItem.d.ts +1 -0
  88. package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/NavObjectItem.js +3 -3
  89. package/build/src/components/Configure/nav/ObjectManagementNav/OtherTab.d.ts +7 -0
  90. package/build/src/components/Configure/nav/ObjectManagementNav/OtherTab.js +11 -0
  91. package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/UninstallInstallation.d.ts +1 -1
  92. package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/UninstallInstallation.js +2 -2
  93. package/build/src/components/Configure/nav/ObjectManagementNav/constant.d.ts +1 -0
  94. package/build/src/components/Configure/nav/ObjectManagementNav/constant.js +4 -0
  95. package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/index.d.ts +1 -0
  96. package/build/src/components/Configure/nav/ObjectManagementNav/index.js +61 -0
  97. package/build/src/components/Configure/state/ConfigurationStateProvider.d.ts +70 -42
  98. package/build/src/components/Configure/state/ConfigurationStateProvider.js +39 -17
  99. package/build/src/components/Configure/state/HydratedRevisionContext.js +11 -9
  100. package/build/src/components/Configure/state/utils.d.ts +2 -2
  101. package/build/src/components/Configure/state/utils.js +44 -19
  102. package/build/src/components/Configure/types.d.ts +22 -6
  103. package/build/src/components/Configure/utils.d.ts +3 -2
  104. package/build/src/components/Configure/utils.js +25 -5
  105. package/build/src/components/Connect/ConnectProvider.d.ts +3 -1
  106. package/build/src/components/Connect/ConnectProvider.js +6 -12
  107. package/build/src/components/Connect/ConnectedSuccessBox.d.ts +5 -0
  108. package/build/src/components/Connect/ConnectedSuccessBox.js +13 -0
  109. package/build/src/components/Connect/useConnectionHandler.d.ts +10 -0
  110. package/build/src/components/Connect/useConnectionHandler.js +24 -0
  111. package/build/src/components/ErrorTextBox.js +11 -0
  112. package/build/src/components/Oauth/NoSubdomainEntry/LandingContent.d.ts +8 -0
  113. package/build/src/components/Oauth/{Hubspot/HubspotLandingContent.js → NoSubdomainEntry/LandingContent.js} +5 -4
  114. package/build/src/components/Oauth/NoSubdomainEntry/NoSubdomainOauthFlow.d.ts +16 -0
  115. package/build/src/components/Oauth/{Hubspot/HubspotOauthFlow.js → NoSubdomainEntry/NoSubdomainOauthFlow.js} +14 -14
  116. package/build/src/components/{Connect → Oauth}/OAuthPopup.js +8 -10
  117. package/build/src/components/Oauth/Salesforce/SalesforceOauthFlow.js +5 -5
  118. package/build/src/components/Oauth/fetchOAuthCallbackURL.d.ts +1 -1
  119. package/build/src/components/Oauth/fetchOAuthCallbackURL.js +3 -4
  120. package/build/src/components/RedirectHandler/RedirectHandler.d.ts +15 -0
  121. package/build/src/components/RedirectHandler/RedirectHandler.js +31 -0
  122. package/build/src/components/RedirectHandler/index.d.ts +1 -0
  123. package/build/src/components/RedirectHandler/index.js +5 -0
  124. package/build/src/{components/AmpersandProvider/AmpersandProvider.js → context/AmpersandContextProvider/AmpersandContextProvider.js} +6 -6
  125. package/build/src/context/AmpersandContextProvider/index.d.ts +1 -0
  126. package/build/src/{components/AmpersandProvider → context/AmpersandContextProvider}/index.js +1 -1
  127. package/build/src/context/{ConnectionsContext.js → ConnectionsContextProvider.js} +11 -10
  128. package/build/src/context/{InstallIntegrationContext.d.ts → InstallIntegrationContextProvider.d.ts} +7 -2
  129. package/build/src/context/{InstallIntegrationContext.js → InstallIntegrationContextProvider.js} +29 -14
  130. package/build/src/context/{IntegrationListContext.js → IntegrationListContextProvider.js} +4 -4
  131. package/build/src/context/{ProjectContext.js → ProjectContextProvider.js} +4 -4
  132. package/build/src/hooks/useIsIntegrationInstalled.js +7 -7
  133. package/build/src/index.d.ts +1 -2
  134. package/build/src/index.js +1 -2
  135. package/build/src/public/index.d.ts +7 -0
  136. package/build/src/{components → public}/index.js +7 -3
  137. package/build/src/services/ApiService.d.ts +27 -0
  138. package/build/src/services/ApiService.js +34 -0
  139. package/build/src/services/api.d.ts +5 -4
  140. package/build/src/services/api.js +11 -6
  141. package/package.json +2 -2
  142. package/build/generated-sources/api/src/apis/DefaultApi.d.ts +0 -930
  143. package/build/generated-sources/api/src/apis/DefaultApi.js +0 -1019
  144. package/build/generated-sources/api/src/models/CreateDestinationRequest.d.ts +0 -44
  145. package/build/generated-sources/api/src/models/CreateDestinationRequest.js +0 -57
  146. package/build/generated-sources/api/src/models/CreateDestinationRequestMetadata.d.ts +0 -39
  147. package/build/src/components/AmpersandProvider/index.d.ts +0 -1
  148. package/build/src/components/CenteredTextBox/CenteredTextBox.d.ts +0 -5
  149. package/build/src/components/CenteredTextBox/CenteredTextBox.js +0 -8
  150. package/build/src/components/Configure/ConfigureInstallationBase.js +0 -29
  151. package/build/src/components/Configure/CreateInstallation.js +0 -70
  152. package/build/src/components/Configure/ErrorTextBox.js +0 -9
  153. package/build/src/components/Configure/ObjectManagementNav/index.js +0 -53
  154. package/build/src/components/Configure/actions/onSaveCreate.d.ts +0 -3
  155. package/build/src/components/Configure/actions/onSaveUpdate.d.ts +0 -3
  156. package/build/src/components/Configure/fields/FieldMappings/setFieldMapping.js +0 -18
  157. package/build/src/components/Configure/fields/OptionalFields/setOptionalField.js +0 -21
  158. package/build/src/components/Configure/fields/RequiredFields.js +0 -27
  159. package/build/src/components/Oauth/Hubspot/HubspotLandingContent.d.ts +0 -7
  160. package/build/src/components/Oauth/Hubspot/HubspotOauthFlow.d.ts +0 -15
  161. package/build/src/components/index.d.ts +0 -3
  162. /package/build/src/components/Configure/{CreateInstallation.d.ts → content/CreateInstallation.d.ts} +0 -0
  163. /package/build/src/components/Configure/{UninstallContent.d.ts → content/UninstallContent.d.ts} +0 -0
  164. /package/build/src/components/Configure/{fields → content/fields}/FieldHeader.d.ts +0 -0
  165. /package/build/src/components/Configure/{fields → content/fields}/FieldHeader.js +0 -0
  166. /package/build/src/components/Configure/{fields → content/fields}/FieldMappings/RequiredFieldMappings.d.ts +0 -0
  167. /package/build/src/components/Configure/{fields → content/fields}/FieldMappings/index.d.ts +0 -0
  168. /package/build/src/components/Configure/{fields → content/fields}/FieldMappings/index.js +0 -0
  169. /package/build/src/components/Configure/{fields → content/fields}/OptionalFields/OptionalFields.d.ts +0 -0
  170. /package/build/src/components/Configure/{fields → content/fields}/OptionalFields/index.d.ts +0 -0
  171. /package/build/src/components/Configure/{fields → content/fields}/OptionalFields/index.js +0 -0
  172. /package/build/src/components/Configure/{fields → content/fields}/RequiredFields.d.ts +0 -0
  173. /package/build/src/components/{Configure/ErrorTextBox.d.ts → ErrorTextBox.d.ts} +0 -0
  174. /package/build/src/components/{Connect → Oauth}/OAuthPopup.d.ts +0 -0
  175. /package/build/src/{components/AmpersandProvider/AmpersandProvider.d.ts → context/AmpersandContextProvider/AmpersandContextProvider.d.ts} +0 -0
  176. /package/build/src/context/{ApiKeyProvider.d.ts → ApiKeyContextProvider.d.ts} +0 -0
  177. /package/build/src/context/{ApiKeyProvider.js → ApiKeyContextProvider.js} +0 -0
  178. /package/build/src/context/{ConnectionsContext.d.ts → ConnectionsContextProvider.d.ts} +0 -0
  179. /package/build/src/context/{IntegrationListContext.d.ts → IntegrationListContextProvider.d.ts} +0 -0
  180. /package/build/src/context/{ProjectContext.d.ts → ProjectContextProvider.d.ts} +0 -0
@@ -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 ApiKeyProvider_1 = require("../../context/ApiKeyProvider");
11
- const ConnectionsContext_1 = require("../../context/ConnectionsContext");
12
- const ProjectContext_1 = require("../../context/ProjectContext");
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, ProjectContext_1.useProject)();
27
- const apiKey = (0, ApiKeyProvider_1.useApiKey)();
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, ConnectionsContext_1.useConnections)();
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]);
@@ -11,18 +11,18 @@ const jsx_runtime_1 = require("react/jsx-runtime");
11
11
  */
12
12
  const react_1 = require("react");
13
13
  const constants_1 = require("../../../constants");
14
- const ApiKeyProvider_1 = require("../../../context/ApiKeyProvider");
15
- const ProjectContext_1 = require("../../../context/ProjectContext");
16
- const OAuthPopup_1 = __importDefault(require("../../Connect/OAuthPopup"));
14
+ const ApiKeyContextProvider_1 = require("../../../context/ApiKeyContextProvider");
15
+ const ProjectContextProvider_1 = require("../../../context/ProjectContextProvider");
17
16
  const fetchOAuthCallbackURL_1 = require("../fetchOAuthCallbackURL");
17
+ const OAuthPopup_1 = __importDefault(require("../OAuthPopup"));
18
18
  const SubdomainEntry_1 = require("./SubdomainEntry");
19
19
  /**
20
20
  * SalesforceOauthFlow first prompts user for their workspace ("subdomain" in Salesforce lingo),
21
21
  * then launches a popup with the OAuth flow.
22
22
  */
23
23
  function SalesforceOauthFlow({ consumerRef, consumerName, groupRef, groupName, }) {
24
- const { projectId } = (0, ProjectContext_1.useProject)();
25
- const apiKey = (0, ApiKeyProvider_1.useApiKey)();
24
+ const { projectId } = (0, ProjectContextProvider_1.useProject)();
25
+ const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
26
26
  const [workspace, setWorkspace] = (0, react_1.useState)('');
27
27
  const [oAuthCallbackURL, setOAuthCallbackURL] = (0, react_1.useState)(null);
28
28
  const [error, setError] = (0, react_1.useState)(null);
@@ -1 +1 @@
1
- export declare const fetchOAuthCallbackURL: (projectId: string, consumerRef: string, groupRef: string, consumerName: string, groupName: string, apiKey: string, provider?: string, workspace?: string) => Promise<string>;
1
+ export declare const fetchOAuthCallbackURL: (projectId: string, consumerRef: string, groupRef: string, consumerName: string, groupName: string, apiKey: string, provider: string, workspace?: string) => Promise<string>;
@@ -1,18 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fetchOAuthCallbackURL = void 0;
4
- const constants_1 = require("../../constants");
5
4
  const api_1 = require("../../services/api");
6
5
  const utils_1 = require("../../utils");
7
- const fetchOAuthCallbackURL = async (projectId, consumerRef, groupRef, consumerName, groupName, apiKey, provider = constants_1.PROVIDER_SALESFORCE, workspace) => {
8
- const providerApps = await (0, api_1.api)().listProviderApps({ projectId }, {
6
+ const fetchOAuthCallbackURL = async (projectId, consumerRef, groupRef, consumerName, groupName, apiKey, provider, workspace) => {
7
+ const providerApps = await (0, api_1.api)().providerAppApi.listProviderApps({ projectId }, {
9
8
  headers: { 'X-Api-Key': apiKey !== null && apiKey !== void 0 ? apiKey : '' },
10
9
  });
11
10
  const app = providerApps.find((a) => a.provider === provider);
12
11
  if (!app) {
13
12
  throw new Error(`You must first set up a ${(0, utils_1.capitalize)(provider)} Connected App using the Ampersand Console.`);
14
13
  }
15
- const url = await (0, api_1.api)().oauthConnect({
14
+ const url = await (0, api_1.api)().oAuthApi.oauthConnect({
16
15
  connectOAuthParams: {
17
16
  providerWorkspaceRef: workspace,
18
17
  projectId,
@@ -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; } });
@@ -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 ApiKeyProvider_1 = require("../../context/ApiKeyProvider");
13
- const ErrorContextProvider_1 = require("../../context/ErrorContextProvider");
14
- const IntegrationListContext_1 = require("../../context/IntegrationListContext");
15
- const ProjectContext_1 = require("../../context/ProjectContext");
16
- const ThemeProvider_1 = require("../ThemeProvider");
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)(ApiKeyProvider_1.ApiKeyProvider, { value: apiKey, children: (0, jsx_runtime_1.jsx)(ProjectContext_1.ProjectProvider, { projectId: projectId, children: (0, jsx_runtime_1.jsx)(IntegrationListContext_1.IntegrationListProvider, { projectId: projectId, children: children }) }) }) }) }));
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';
@@ -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("./AmpersandProvider"), exports);
17
+ __exportStar(require("./AmpersandContextProvider"), exports);
@@ -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/Configure/ErrorTextBox");
7
+ const ErrorTextBox_1 = require("../components/ErrorTextBox");
8
8
  const api_1 = require("../services/api");
9
- const ApiKeyProvider_1 = require("./ApiKeyProvider");
9
+ const ApiKeyContextProvider_1 = require("./ApiKeyContextProvider");
10
10
  const ErrorContextProvider_1 = require("./ErrorContextProvider");
11
- const InstallIntegrationContext_1 = require("./InstallIntegrationContext");
12
- const ProjectContext_1 = require("./ProjectContext");
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, ApiKeyProvider_1.useApiKey)();
29
- const { projectId } = (0, ProjectContext_1.useProject)();
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, InstallIntegrationContext_1.useInstallIntegrationProps)();
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
- if (!provider && !providerFromProps) {
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, provider, setError]);
55
+ }, [projectId, apiKey, groupRef, selectedProvider, setError]);
55
56
  const contextValue = (0, react_1.useMemo)(() => ({
56
57
  connections,
57
58
  selectedConnection,
@@ -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 {};
@@ -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/Configure/ErrorTextBox");
7
+ const ErrorTextBox_1 = require("../components/ErrorTextBox");
8
8
  const api_1 = require("../services/api");
9
9
  const utils_1 = require("../utils");
10
- const ApiKeyProvider_1 = require("./ApiKeyProvider");
10
+ const ApiKeyContextProvider_1 = require("./ApiKeyContextProvider");
11
11
  const ErrorContextProvider_1 = require("./ErrorContextProvider");
12
- const IntegrationListContext_1 = require("./IntegrationListContext");
13
- const ProjectContext_1 = require("./ProjectContext");
12
+ const IntegrationListContextProvider_1 = require("./IntegrationListContextProvider");
13
+ const ProjectContextProvider_1 = require("./ProjectContextProvider");
14
14
  // Create a context to pass down the props
15
- const InstallIntegrationContext = (0, react_1.createContext)({
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, ApiKeyProvider_1.useApiKey)();
39
- const { projectId } = (0, ProjectContext_1.useProject)();
40
- const { integrations } = (0, IntegrationListContext_1.useIntegrationList)();
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({ projectId, integrationId: integrationObj.id, groupRef }, {
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
- return (isError(ErrorContextProvider_1.ErrorBoundary.INSTALLATION_LIST, integrationErrorKey)) ? (0, jsx_runtime_1.jsx)(ErrorTextBox_1.ErrorTextBox, { message: `Error retrieving installation information for integration "${(integrationObj === null || integrationObj === void 0 ? void 0 : integrationObj.name) || 'unknown'}"` }) : ((0, jsx_runtime_1.jsx)(InstallIntegrationContext.Provider, { value: props, children: isLoading ? (0, jsx_runtime_1.jsx)(LoadingIcon_1.LoadingIcon, {}) : children }));
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/Configure/ErrorTextBox");
7
+ const ErrorTextBox_1 = require("../components/ErrorTextBox");
8
8
  const api_1 = require("../services/api");
9
- const ApiKeyProvider_1 = require("./ApiKeyProvider");
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, ApiKeyProvider_1.useApiKey)();
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/Configure/ErrorTextBox");
7
+ const ErrorTextBox_1 = require("../components/ErrorTextBox");
8
8
  const api_1 = require("../services/api");
9
- const ApiKeyProvider_1 = require("./ApiKeyProvider");
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, ApiKeyProvider_1.useApiKey)();
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 ApiKeyProvider_1 = require("../context/ApiKeyProvider");
6
- const IntegrationListContext_1 = require("../context/IntegrationListContext");
7
- const ProjectContext_1 = require("../context/ProjectContext");
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, ApiKeyProvider_1.useApiKey)();
11
- const { projectId } = (0, ProjectContext_1.useProject)();
12
- const { integrations } = (0, IntegrationListContext_1.useIntegrationList)();
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,
@@ -1,2 +1 @@
1
- export * from './components';
2
- export * from './hooks';
1
+ export * from './public';
@@ -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("./components"), exports);
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
- __exportStar(require("./AmpersandProvider"), exports);
18
- __exportStar(require("./Configure"), exports);
19
- __exportStar(require("./Connect/ConnectProvider"), exports);
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, DefaultApi, HydratedIntegrationField, HydratedIntegrationFieldExistent, HydratedIntegrationObject, HydratedIntegrationRead, HydratedRevision, Installation, Integration, IntegrationFieldMapping, Project, ProviderApp, UpdateInstallationOperationRequest, UpdateInstallationRequestInstallationConfig } from '../../generated-sources/api/src';
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: DefaultApi) => void;
5
- export declare const api: () => DefaultApi;
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
- switch (process.env.REACT_APP_AMP_SERVER) {
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 'https://api.withampersand.com';
34
+ return prodEndpoint;
30
35
  case 'mock':
31
36
  return 'http://127.0.0.1:4010';
32
37
  case '':
33
- return 'https://api.withampersand.com';
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 (_a = process.env.REACT_APP_AMP_SERVER) !== null && _a !== void 0 ? _a : 'https://api.withampersand.com';
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 src_1.DefaultApi(config);
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;