@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.
Files changed (196) hide show
  1. package/README.md +1 -1
  2. package/build/generated-sources/api/src/apis/AllowedDomainApi.d.ts +79 -0
  3. package/build/generated-sources/api/src/apis/AllowedDomainApi.js +101 -0
  4. package/build/generated-sources/api/src/apis/ConnectionApi.d.ts +82 -0
  5. package/build/generated-sources/api/src/apis/ConnectionApi.js +107 -0
  6. package/build/generated-sources/api/src/apis/ConsumerApi.d.ts +52 -0
  7. package/build/generated-sources/api/src/apis/ConsumerApi.js +75 -0
  8. package/build/generated-sources/api/src/apis/DestinationApi.d.ts +78 -0
  9. package/build/generated-sources/api/src/apis/DestinationApi.js +102 -0
  10. package/build/generated-sources/api/src/apis/GroupApi.d.ts +52 -0
  11. package/build/generated-sources/api/src/apis/GroupApi.js +75 -0
  12. package/build/generated-sources/api/src/apis/InstallationApi.d.ts +168 -0
  13. package/build/generated-sources/api/src/apis/InstallationApi.js +205 -0
  14. package/build/generated-sources/api/src/apis/IntegrationApi.d.ts +128 -0
  15. package/build/generated-sources/api/src/apis/IntegrationApi.js +154 -0
  16. package/build/generated-sources/api/src/apis/OAuthApi.d.ts +76 -0
  17. package/build/generated-sources/api/src/apis/OAuthApi.js +102 -0
  18. package/build/generated-sources/api/src/apis/OperationApi.d.ts +80 -0
  19. package/build/generated-sources/api/src/apis/OperationApi.js +104 -0
  20. package/build/generated-sources/api/src/apis/OperationLogApi.d.ts +55 -0
  21. package/build/generated-sources/api/src/apis/OperationLogApi.js +76 -0
  22. package/build/generated-sources/api/src/apis/ProjectApi.d.ts +124 -0
  23. package/build/generated-sources/api/src/apis/ProjectApi.js +148 -0
  24. package/build/generated-sources/api/src/apis/ProjectMembershipApi.d.ts +126 -0
  25. package/build/generated-sources/api/src/apis/ProjectMembershipApi.js +154 -0
  26. package/build/generated-sources/api/src/apis/ProviderAppApi.d.ts +130 -0
  27. package/build/generated-sources/api/src/apis/ProviderAppApi.js +158 -0
  28. package/build/generated-sources/api/src/apis/RevisionApi.d.ts +87 -0
  29. package/build/generated-sources/api/src/apis/RevisionApi.js +113 -0
  30. package/build/generated-sources/api/src/apis/UploadURLApi.d.ts +46 -0
  31. package/build/generated-sources/api/src/apis/UploadURLApi.js +68 -0
  32. package/build/generated-sources/api/src/apis/index.d.ts +15 -1
  33. package/build/generated-sources/api/src/apis/index.js +15 -1
  34. package/build/generated-sources/api/src/models/CreateInstallationRequest.d.ts +2 -2
  35. package/build/generated-sources/api/src/models/CreateInstallationRequest.js +2 -2
  36. package/build/generated-sources/api/src/models/CreateInstallationRequestConfig.d.ts +3 -3
  37. package/build/generated-sources/api/src/models/CreateInstallationRequestConfig.js +3 -4
  38. package/build/generated-sources/api/src/models/Destination.d.ts +44 -0
  39. package/build/generated-sources/api/src/models/Destination.js +57 -0
  40. package/build/generated-sources/api/src/models/DestinationMetadata.d.ts +39 -0
  41. package/build/generated-sources/api/src/models/{CreateDestinationRequestMetadata.js → DestinationMetadata.js} +11 -11
  42. package/build/generated-sources/api/src/models/OauthConnectRequest.d.ts +1 -1
  43. package/build/generated-sources/api/src/models/OauthConnectRequest.js +1 -2
  44. package/build/generated-sources/api/src/models/Operation.d.ts +6 -12
  45. package/build/generated-sources/api/src/models/Operation.js +3 -6
  46. package/build/generated-sources/api/src/models/OperationLog.d.ts +43 -0
  47. package/build/generated-sources/api/src/models/OperationLog.js +56 -0
  48. package/build/generated-sources/api/src/models/ProviderApp.d.ts +6 -0
  49. package/build/generated-sources/api/src/models/ProviderApp.js +2 -0
  50. package/build/generated-sources/api/src/models/index.d.ts +3 -2
  51. package/build/generated-sources/api/src/models/index.js +3 -2
  52. package/build/src/assets/TrashIcon.js +3 -1
  53. package/build/src/components/Configure/InstallIntegration.d.ts +4 -1
  54. package/build/src/components/Configure/InstallIntegration.js +10 -23
  55. package/build/src/components/Configure/actions/onSaveReadCreateInstallation.d.ts +3 -0
  56. package/build/src/components/Configure/actions/{onSaveCreate.js → onSaveReadCreateInstallation.js} +7 -6
  57. package/build/src/components/Configure/actions/onSaveReadUpdateInstallation.d.ts +3 -0
  58. package/build/src/components/Configure/actions/{onSaveUpdate.js → onSaveReadUpdateInstallation.js} +13 -8
  59. package/build/src/components/Configure/actions/write/generateConfigWriteObjects.d.ts +26 -0
  60. package/build/src/components/Configure/actions/write/generateConfigWriteObjects.js +41 -0
  61. package/build/src/components/Configure/actions/write/onSaveWriteCreateInstallation.d.ts +3 -0
  62. package/build/src/components/Configure/actions/write/onSaveWriteCreateInstallation.js +85 -0
  63. package/build/src/components/Configure/actions/write/onSaveWriteUpdateInstallation.d.ts +3 -0
  64. package/build/src/components/Configure/actions/write/onSaveWriteUpdateInstallation.js +60 -0
  65. package/build/src/components/Configure/{ConfigureInstallationBase.d.ts → content/ConfigureInstallationBase.d.ts} +2 -1
  66. package/build/src/components/Configure/content/ConfigureInstallationBase.js +36 -0
  67. package/build/src/components/Configure/content/CreateInstallation.js +83 -0
  68. package/build/src/components/Configure/content/InstallationContent.d.ts +1 -0
  69. package/build/src/components/Configure/content/InstallationContent.js +20 -0
  70. package/build/src/components/Configure/{UninstallContent.js → content/UninstallContent.js} +15 -7
  71. package/build/src/components/Configure/{UpdateInstallation.d.ts → content/UpdateInstallation.d.ts} +1 -1
  72. package/build/src/components/Configure/{UpdateInstallation.js → content/UpdateInstallation.js} +42 -28
  73. package/build/src/components/Configure/{fields → content/fields}/FieldMappings/FieldMapping.d.ts +1 -1
  74. package/build/src/components/Configure/{fields → content/fields}/FieldMappings/FieldMapping.js +4 -7
  75. package/build/src/components/Configure/{fields → content/fields}/FieldMappings/RequiredFieldMappings.js +10 -11
  76. package/build/src/components/Configure/{fields → content/fields}/FieldMappings/setFieldMapping.d.ts +1 -1
  77. package/build/src/components/Configure/content/fields/FieldMappings/setFieldMapping.js +21 -0
  78. package/build/src/components/Configure/{fields → content/fields}/OptionalFields/OptionalFields.js +9 -14
  79. package/build/src/components/Configure/{fields → content/fields}/OptionalFields/setOptionalField.d.ts +1 -1
  80. package/build/src/components/Configure/content/fields/OptionalFields/setOptionalField.js +27 -0
  81. package/build/src/components/Configure/content/fields/ReadFields.d.ts +1 -0
  82. package/build/src/components/Configure/content/fields/ReadFields.js +11 -0
  83. package/build/src/components/Configure/content/fields/RequiredFields.js +23 -0
  84. package/build/src/components/Configure/content/fields/WriteFields/WriteFields.d.ts +1 -0
  85. package/build/src/components/Configure/content/fields/WriteFields/WriteFields.js +22 -0
  86. package/build/src/components/Configure/content/fields/WriteFields/index.d.ts +2 -0
  87. package/build/src/components/Configure/content/fields/WriteFields/index.js +5 -0
  88. package/build/src/components/Configure/content/fields/WriteFields/setNonConfigurableWriteField.d.ts +3 -0
  89. package/build/src/components/Configure/content/fields/WriteFields/setNonConfigurableWriteField.js +32 -0
  90. package/build/src/components/Configure/content/useMutateInstallation.d.ts +23 -0
  91. package/build/src/components/Configure/content/useMutateInstallation.js +47 -0
  92. package/build/src/components/Configure/content/useSelectedConfigureState.d.ts +72 -0
  93. package/build/src/components/Configure/content/useSelectedConfigureState.js +24 -0
  94. package/build/src/components/Configure/{ProtectedConnectionLayout.d.ts → layout/ProtectedConnectionLayout.d.ts} +2 -1
  95. package/build/src/components/Configure/layout/ProtectedConnectionLayout.js +34 -0
  96. package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/NavObjectItem.d.ts +1 -0
  97. package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/NavObjectItem.js +3 -3
  98. package/build/src/components/Configure/nav/ObjectManagementNav/OtherTab.d.ts +7 -0
  99. package/build/src/components/Configure/nav/ObjectManagementNav/OtherTab.js +11 -0
  100. package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/UninstallInstallation.d.ts +1 -1
  101. package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/UninstallInstallation.js +2 -2
  102. package/build/src/components/Configure/nav/ObjectManagementNav/constant.d.ts +1 -0
  103. package/build/src/components/Configure/nav/ObjectManagementNav/constant.js +4 -0
  104. package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/index.d.ts +1 -0
  105. package/build/src/components/Configure/nav/ObjectManagementNav/index.js +61 -0
  106. package/build/src/components/Configure/state/ConfigurationStateProvider.d.ts +70 -42
  107. package/build/src/components/Configure/state/ConfigurationStateProvider.js +39 -17
  108. package/build/src/components/Configure/state/HydratedRevisionContext.js +11 -9
  109. package/build/src/components/Configure/state/utils.d.ts +2 -2
  110. package/build/src/components/Configure/state/utils.js +44 -19
  111. package/build/src/components/Configure/types.d.ts +22 -6
  112. package/build/src/components/Configure/utils.d.ts +3 -2
  113. package/build/src/components/Configure/utils.js +25 -5
  114. package/build/src/components/Connect/ConnectProvider.d.ts +3 -1
  115. package/build/src/components/Connect/ConnectProvider.js +6 -12
  116. package/build/src/components/Connect/ConnectedSuccessBox.d.ts +5 -0
  117. package/build/src/components/Connect/ConnectedSuccessBox.js +13 -0
  118. package/build/src/components/Connect/useConnectionHandler.d.ts +10 -0
  119. package/build/src/components/Connect/useConnectionHandler.js +24 -0
  120. package/build/src/components/ErrorTextBox.js +11 -0
  121. package/build/src/components/Oauth/NoSubdomainEntry/LandingContent.d.ts +8 -0
  122. package/build/src/components/Oauth/NoSubdomainEntry/LandingContent.js +11 -0
  123. package/build/src/components/Oauth/NoSubdomainEntry/NoSubdomainOauthFlow.d.ts +16 -0
  124. package/build/src/components/Oauth/NoSubdomainEntry/NoSubdomainOauthFlow.js +50 -0
  125. package/build/src/components/Oauth/OAuthErrorAlert.d.ts +5 -0
  126. package/build/src/components/Oauth/OAuthErrorAlert.js +12 -0
  127. package/build/src/components/{Connect → Oauth}/OAuthPopup.js +8 -10
  128. package/build/src/components/{Salesforce → Oauth/Salesforce}/SalesforceOauthFlow.d.ts +2 -2
  129. package/build/src/components/Oauth/Salesforce/SalesforceOauthFlow.js +57 -0
  130. package/build/src/components/Oauth/Salesforce/SubdomainEntry.d.ts +8 -0
  131. package/build/src/components/Oauth/Salesforce/SubdomainEntry.js +12 -0
  132. package/build/src/components/Oauth/fetchOAuthCallbackURL.d.ts +1 -0
  133. package/build/src/components/Oauth/fetchOAuthCallbackURL.js +28 -0
  134. package/build/src/components/RedirectHandler/RedirectHandler.d.ts +15 -0
  135. package/build/src/components/RedirectHandler/RedirectHandler.js +31 -0
  136. package/build/src/components/RedirectHandler/index.d.ts +1 -0
  137. package/build/src/components/RedirectHandler/index.js +5 -0
  138. package/build/src/constants.d.ts +1 -0
  139. package/build/src/constants.js +2 -1
  140. package/build/src/{components/AmpersandProvider/AmpersandProvider.js → context/AmpersandContextProvider/AmpersandContextProvider.js} +6 -6
  141. package/build/src/context/AmpersandContextProvider/index.d.ts +1 -0
  142. package/build/src/{components/AmpersandProvider → context/AmpersandContextProvider}/index.js +1 -1
  143. package/build/src/context/{ConnectionsContext.js → ConnectionsContextProvider.js} +11 -10
  144. package/build/src/context/{InstallIntegrationContext.d.ts → InstallIntegrationContextProvider.d.ts} +7 -2
  145. package/build/src/context/{InstallIntegrationContext.js → InstallIntegrationContextProvider.js} +29 -14
  146. package/build/src/context/{IntegrationListContext.js → IntegrationListContextProvider.js} +4 -4
  147. package/build/src/context/{ProjectContext.js → ProjectContextProvider.js} +4 -4
  148. package/build/src/hooks/useIsIntegrationInstalled.js +7 -7
  149. package/build/src/index.d.ts +1 -2
  150. package/build/src/index.js +1 -2
  151. package/build/src/public/index.d.ts +7 -0
  152. package/build/src/{components → public}/index.js +7 -3
  153. package/build/src/services/ApiService.d.ts +27 -0
  154. package/build/src/services/ApiService.js +34 -0
  155. package/build/src/services/api.d.ts +5 -4
  156. package/build/src/services/api.js +11 -6
  157. package/package.json +3 -3
  158. package/build/generated-sources/api/src/apis/DefaultApi.d.ts +0 -904
  159. package/build/generated-sources/api/src/apis/DefaultApi.js +0 -992
  160. package/build/generated-sources/api/src/models/CreateDestinationRequest.d.ts +0 -44
  161. package/build/generated-sources/api/src/models/CreateDestinationRequest.js +0 -57
  162. package/build/generated-sources/api/src/models/CreateDestinationRequestMetadata.d.ts +0 -39
  163. package/build/src/components/AmpersandProvider/index.d.ts +0 -1
  164. package/build/src/components/CenteredTextBox/CenteredTextBox.d.ts +0 -5
  165. package/build/src/components/CenteredTextBox/CenteredTextBox.js +0 -8
  166. package/build/src/components/Configure/ConfigureInstallationBase.js +0 -29
  167. package/build/src/components/Configure/CreateInstallation.js +0 -70
  168. package/build/src/components/Configure/ErrorTextBox.js +0 -9
  169. package/build/src/components/Configure/ObjectManagementNav/index.js +0 -52
  170. package/build/src/components/Configure/ProtectedConnectionLayout.js +0 -33
  171. package/build/src/components/Configure/actions/onSaveCreate.d.ts +0 -3
  172. package/build/src/components/Configure/actions/onSaveUpdate.d.ts +0 -3
  173. package/build/src/components/Configure/fields/FieldMappings/setFieldMapping.js +0 -18
  174. package/build/src/components/Configure/fields/OptionalFields/setOptionalField.js +0 -21
  175. package/build/src/components/Configure/fields/RequiredFields.js +0 -27
  176. package/build/src/components/Salesforce/SalesforceOauthFlow.js +0 -89
  177. package/build/src/components/index.d.ts +0 -3
  178. /package/build/src/components/Configure/{CreateInstallation.d.ts → content/CreateInstallation.d.ts} +0 -0
  179. /package/build/src/components/Configure/{UninstallContent.d.ts → content/UninstallContent.d.ts} +0 -0
  180. /package/build/src/components/Configure/{fields → content/fields}/FieldHeader.d.ts +0 -0
  181. /package/build/src/components/Configure/{fields → content/fields}/FieldHeader.js +0 -0
  182. /package/build/src/components/Configure/{fields → content/fields}/FieldMappings/RequiredFieldMappings.d.ts +0 -0
  183. /package/build/src/components/Configure/{fields → content/fields}/FieldMappings/index.d.ts +0 -0
  184. /package/build/src/components/Configure/{fields → content/fields}/FieldMappings/index.js +0 -0
  185. /package/build/src/components/Configure/{fields → content/fields}/OptionalFields/OptionalFields.d.ts +0 -0
  186. /package/build/src/components/Configure/{fields → content/fields}/OptionalFields/index.d.ts +0 -0
  187. /package/build/src/components/Configure/{fields → content/fields}/OptionalFields/index.js +0 -0
  188. /package/build/src/components/Configure/{fields → content/fields}/RequiredFields.d.ts +0 -0
  189. /package/build/src/components/{Configure/ErrorTextBox.d.ts → ErrorTextBox.d.ts} +0 -0
  190. /package/build/src/components/{Connect → Oauth}/OAuthPopup.d.ts +0 -0
  191. /package/build/src/{components/AmpersandProvider/AmpersandProvider.d.ts → context/AmpersandContextProvider/AmpersandContextProvider.d.ts} +0 -0
  192. /package/build/src/context/{ApiKeyProvider.d.ts → ApiKeyContextProvider.d.ts} +0 -0
  193. /package/build/src/context/{ApiKeyProvider.js → ApiKeyContextProvider.js} +0 -0
  194. /package/build/src/context/{ConnectionsContext.d.ts → ConnectionsContextProvider.d.ts} +0 -0
  195. /package/build/src/context/{IntegrationListContext.d.ts → IntegrationListContextProvider.d.ts} +0 -0
  196. /package/build/src/context/{ProjectContext.d.ts → ProjectContextProvider.d.ts} +0 -0
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useSelectedConfigureState = void 0;
4
+ const ProjectContextProvider_1 = require("../../../context/ProjectContextProvider");
5
+ const ObjectManagementNav_1 = require("../nav/ObjectManagementNav");
6
+ const ConfigurationStateProvider_1 = require("../state/ConfigurationStateProvider");
7
+ const utils_1 = require("../state/utils");
8
+ /**
9
+ *
10
+ * @returns {object} configureState for the selected object in nav
11
+ */
12
+ const useSelectedConfigureState = () => {
13
+ const { appName } = (0, ProjectContextProvider_1.useProject)();
14
+ const { objectConfigurationsState, setConfigureState } = (0, ConfigurationStateProvider_1.useObjectsConfigureState)();
15
+ const { selectedObjectName } = (0, ObjectManagementNav_1.useSelectedObjectName)();
16
+ const configureState = (0, utils_1.getConfigureState)(selectedObjectName || '', objectConfigurationsState);
17
+ return {
18
+ appName,
19
+ configureState,
20
+ setConfigureState,
21
+ selectedObjectName,
22
+ };
23
+ };
24
+ exports.useSelectedConfigureState = useSelectedConfigureState;
@@ -5,7 +5,8 @@ interface ProtectedConnectionLayoutProps {
5
5
  consumerName?: string;
6
6
  groupRef: string;
7
7
  groupName?: string;
8
+ onSuccess?: (connectionID: string) => void;
8
9
  children: JSX.Element;
9
10
  }
10
- export declare function ProtectedConnectionLayout({ provider, consumerRef, consumerName, groupRef, groupName, children, }: ProtectedConnectionLayoutProps): import("react/jsx-runtime").JSX.Element;
11
+ export declare function ProtectedConnectionLayout({ provider, consumerRef, consumerName, groupRef, groupName, children, onSuccess, }: ProtectedConnectionLayoutProps): import("react/jsx-runtime").JSX.Element;
11
12
  export {};
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProtectedConnectionLayout = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const constants_1 = require("../../../constants");
7
+ const ConnectionsContextProvider_1 = require("../../../context/ConnectionsContextProvider");
8
+ const InstallIntegrationContextProvider_1 = require("../../../context/InstallIntegrationContextProvider");
9
+ const useConnectionHandler_1 = require("../../Connect/useConnectionHandler");
10
+ const NoSubdomainOauthFlow_1 = require("../../Oauth/NoSubdomainEntry/NoSubdomainOauthFlow");
11
+ const SalesforceOauthFlow_1 = require("../../Oauth/Salesforce/SalesforceOauthFlow");
12
+ function ProtectedConnectionLayout({ provider, consumerRef, consumerName, groupRef, groupName, children, onSuccess, }) {
13
+ const { provider: providerFromProps } = (0, InstallIntegrationContextProvider_1.useInstallIntegrationProps)();
14
+ const { selectedConnection, setSelectedConnection, connections } = (0, ConnectionsContextProvider_1.useConnections)();
15
+ (0, useConnectionHandler_1.useConnectionHandler)({ onSuccess });
16
+ (0, react_1.useEffect)(() => {
17
+ if (!selectedConnection && connections && connections.length > 0) {
18
+ const [connection] = connections;
19
+ setSelectedConnection(connection);
20
+ }
21
+ }, [connections, selectedConnection, setSelectedConnection]);
22
+ if (!provider && !providerFromProps) {
23
+ throw new Error('ProtectedConnectionLayout must be given a provider prop or be used within InstallIntegrationProvider');
24
+ }
25
+ // a selected connection exists, render children
26
+ if (selectedConnection)
27
+ return children;
28
+ const selectedProvider = provider || providerFromProps;
29
+ if (selectedProvider === constants_1.PROVIDER_SALESFORCE) {
30
+ return ((0, jsx_runtime_1.jsx)(SalesforceOauthFlow_1.SalesforceOauthFlow, { consumerRef: consumerRef, consumerName: consumerName, groupRef: groupRef, groupName: groupName }));
31
+ }
32
+ return ((0, jsx_runtime_1.jsx)(NoSubdomainOauthFlow_1.NoSubdomainOauthFlow, { provider: selectedProvider, consumerRef: consumerRef, consumerName: consumerName, groupRef: groupRef, groupName: groupName }));
33
+ }
34
+ exports.ProtectedConnectionLayout = ProtectedConnectionLayout;
@@ -3,6 +3,7 @@ interface NavObjectItemProps {
3
3
  objectName: string;
4
4
  completed: boolean;
5
5
  pending?: boolean;
6
+ displayName?: string;
6
7
  }
7
8
  export declare const NavObjectItem: import("react").ForwardRefExoticComponent<NavObjectItemProps & import("react").RefAttributes<HTMLButtonElement>>;
8
9
  export {};
@@ -4,11 +4,11 @@ exports.NavObjectItem = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const react_2 = require("@chakra-ui/react");
7
- const NavIcon_1 = require("../../../assets/NavIcon");
8
- exports.NavObjectItem = (0, react_1.forwardRef)(({ objectName, completed, pending }, ref) => {
7
+ const NavIcon_1 = require("../../../../assets/NavIcon");
8
+ exports.NavObjectItem = (0, react_1.forwardRef)(({ objectName, completed, pending, displayName, }, ref) => {
9
9
  // 1. Reuse the `useTab` hook
10
10
  const tabProps = (0, react_2.useTab)({ ref });
11
11
  // 2. Hook into the Tabs `size`, `variant`, props
12
12
  const styles = (0, react_2.useMultiStyleConfig)('Tabs', tabProps);
13
- return ((0, jsx_runtime_1.jsxs)(react_2.Button, Object.assign({ __css: styles.tab }, tabProps, { variant: "outline", minHeight: 15, children: [(0, jsx_runtime_1.jsxs)(react_2.Box, { as: "span", display: "flex", alignItems: "center", gap: 2, mr: "3", children: [(0, NavIcon_1.NavIcon)(completed, pending), (0, jsx_runtime_1.jsxs)(react_2.Box, { textAlign: "left", children: [(0, jsx_runtime_1.jsx)(react_2.Text, { children: objectName }), pending && (0, jsx_runtime_1.jsx)(react_2.Text, { fontSize: 10, fontStyle: "italic", children: "pending" })] })] }), tabProps.children] })));
13
+ return ((0, jsx_runtime_1.jsxs)(react_2.Button, Object.assign({ __css: styles.tab }, tabProps, { variant: "outline", minHeight: 15, children: [(0, jsx_runtime_1.jsxs)(react_2.Box, { as: "span", display: "flex", alignItems: "center", gap: 2, mr: "3", children: [(0, NavIcon_1.NavIcon)(completed, pending), (0, jsx_runtime_1.jsxs)(react_2.Box, { textAlign: "left", children: [(0, jsx_runtime_1.jsx)(react_2.Text, { children: displayName || objectName }), pending && (0, jsx_runtime_1.jsx)(react_2.Text, { fontSize: 10, fontStyle: "italic", children: "pending" })] })] }), tabProps.children] })));
14
14
  });
@@ -0,0 +1,7 @@
1
+ type OtherTabProps = {
2
+ pending?: boolean;
3
+ completed: boolean;
4
+ displayName?: 'other' | 'write';
5
+ };
6
+ export declare function OtherTab({ pending, completed, displayName }: OtherTabProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OtherTab = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("@chakra-ui/react");
6
+ const constant_1 = require("./constant");
7
+ const NavObjectItem_1 = require("./NavObjectItem");
8
+ function OtherTab({ pending, completed, displayName }) {
9
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_1.Divider, { marginY: 3 }), (0, jsx_runtime_1.jsx)(NavObjectItem_1.NavObjectItem, { objectName: constant_1.OTHER_CONST, completed: completed, pending: pending, displayName: displayName }, "other-write")] }));
10
+ }
11
+ exports.OtherTab = OtherTab;
@@ -2,6 +2,6 @@
2
2
  interface NavObjectItemProps {
3
3
  text?: string;
4
4
  }
5
- export declare const UNINSTALL_INSTALLATION_CONST = "uninstall-intallation";
5
+ export declare const UNINSTALL_INSTALLATION_CONST = "uninstall-installation";
6
6
  export declare const UninstallInstallation: import("react").ForwardRefExoticComponent<NavObjectItemProps & import("react").RefAttributes<HTMLButtonElement>>;
7
7
  export {};
@@ -4,8 +4,8 @@ exports.UninstallInstallation = exports.UNINSTALL_INSTALLATION_CONST = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const react_2 = require("@chakra-ui/react");
7
- const TrashIcon_1 = require("../../../assets/TrashIcon");
8
- exports.UNINSTALL_INSTALLATION_CONST = 'uninstall-intallation';
7
+ const TrashIcon_1 = require("../../../../assets/TrashIcon");
8
+ exports.UNINSTALL_INSTALLATION_CONST = 'uninstall-installation';
9
9
  exports.UninstallInstallation = (0, react_1.forwardRef)(({ text = 'Uninstall' }, ref) => {
10
10
  // 1. Reuse the `useTab` hook
11
11
  const tabProps = (0, react_2.useTab)({ ref });
@@ -0,0 +1 @@
1
+ export declare const OTHER_CONST = "other";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OTHER_CONST = void 0;
4
+ exports.OTHER_CONST = 'other';
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ export declare const SelectedObjectNameContext: import("react").Context<string | null | undefined>;
2
3
  export declare function useSelectedObjectName(): {
3
4
  selectedObjectName: string | undefined;
4
5
  };
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ObjectManagementNav = exports.useSelectedObjectName = exports.SelectedObjectNameContext = 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 InstallIntegrationContextProvider_1 = require("../../../../context/InstallIntegrationContextProvider");
8
+ const ProjectContextProvider_1 = require("../../../../context/ProjectContextProvider");
9
+ const utils_1 = require("../../../../utils");
10
+ const ConfigurationStateProvider_1 = require("../../state/ConfigurationStateProvider");
11
+ const HydratedRevisionContext_1 = require("../../state/HydratedRevisionContext");
12
+ const utils_2 = require("../../utils");
13
+ const NavObjectItem_1 = require("./NavObjectItem");
14
+ const OtherTab_1 = require("./OtherTab");
15
+ const UninstallInstallation_1 = require("./UninstallInstallation");
16
+ // Create a context for the selected navObject's name
17
+ exports.SelectedObjectNameContext = (0, react_1.createContext)(null);
18
+ // Custom hook to access the selected navObject's name
19
+ function useSelectedObjectName() {
20
+ const selectedNavObjectName = (0, react_1.useContext)(exports.SelectedObjectNameContext);
21
+ if (selectedNavObjectName === null) {
22
+ throw new Error('useSelectedNavObjectName must be used within a SelectedNavObjectNameProvider');
23
+ }
24
+ return { selectedObjectName: selectedNavObjectName }; // Return as an object
25
+ }
26
+ exports.useSelectedObjectName = useSelectedObjectName;
27
+ function getSelectedObject(navObjects, tabIndex) {
28
+ if (navObjects === null || navObjects === void 0 ? void 0 : navObjects[tabIndex]) {
29
+ // read tabs
30
+ return navObjects[tabIndex];
31
+ }
32
+ // uninstall tab
33
+ return { name: UninstallInstallation_1.UNINSTALL_INSTALLATION_CONST, completed: false };
34
+ }
35
+ // note: when the object key exists in the config; the user has already completed the object before
36
+ function ObjectManagementNav({ children, }) {
37
+ var _a, _b, _c;
38
+ const { project } = (0, ProjectContextProvider_1.useProject)();
39
+ const { installation, provider } = (0, InstallIntegrationContextProvider_1.useInstallIntegrationProps)();
40
+ const { hydratedRevision } = (0, HydratedRevisionContext_1.useHydratedRevision)();
41
+ const { objectConfigurationsState } = (0, ConfigurationStateProvider_1.useObjectsConfigureState)();
42
+ // Object Nav Tab Index
43
+ const [tabIndex, setTabIndex] = (0, react_1.useState)(0);
44
+ const appName = (project === null || project === void 0 ? void 0 : project.appName) || '';
45
+ const config = installation === null || installation === void 0 ? void 0 : installation.config;
46
+ const readNavObjects = hydratedRevision && (0, utils_2.generateNavObjects)(config, hydratedRevision);
47
+ const isNavObjectsReady = readNavObjects !== null; // null = hydratedRevision/config is not ready
48
+ const isWriteSupported = !!((_a = hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) === null || _a === void 0 ? void 0 : _a.write);
49
+ const otherNavObject = isWriteSupported ? (0, utils_2.generateOtherNavObject)(config) : undefined;
50
+ const allNavObjects = [...(readNavObjects || [])];
51
+ if (otherNavObject && isWriteSupported) {
52
+ allNavObjects.push(otherNavObject);
53
+ }
54
+ const selectedObject = getSelectedObject(allNavObjects, tabIndex);
55
+ return ((0, jsx_runtime_1.jsx)(exports.SelectedObjectNameContext.Provider, { value: selectedObject === null || selectedObject === void 0 ? void 0 : selectedObject.name, children: (0, jsx_runtime_1.jsxs)(react_2.Box, { p: 8, maxWidth: "55rem", border: "1px solid #EFEFEF", borderRadius: 6, boxShadow: "md", margin: "auto", bgColor: "whitesmoke", display: "flex", gap: "6", minHeight: "100%", children: [(0, jsx_runtime_1.jsxs)(react_2.Box, { width: "20rem", children: [(0, jsx_runtime_1.jsxs)(react_2.Text, { children: [(0, utils_1.capitalize)(provider), " integration"] }), (0, jsx_runtime_1.jsx)(react_2.Text, { marginBottom: "20px", fontSize: "1.125rem", fontWeight: "500", children: appName }), isNavObjectsReady && ((0, jsx_runtime_1.jsxs)(react_2.Tabs, { index: tabIndex, onChange: setTabIndex, orientation: "horizontal", children: [readNavObjects.map((object) => {
56
+ var _a, _b, _c, _d;
57
+ return ((0, jsx_runtime_1.jsx)(NavObjectItem_1.NavObjectItem, { objectName: object.name, completed: object.completed, pending: ((_b = (_a = objectConfigurationsState[object.name]) === null || _a === void 0 ? void 0 : _a.read) === null || _b === void 0 ? void 0 : _b.isOptionalFieldsModified)
58
+ || ((_d = (_c = objectConfigurationsState[object.name]) === null || _c === void 0 ? void 0 : _c.read) === null || _d === void 0 ? void 0 : _d.isRequiredMapFieldsModified) }, object.name));
59
+ }), isWriteSupported && otherNavObject && ((0, jsx_runtime_1.jsx)(OtherTab_1.OtherTab, { completed: otherNavObject.completed, pending: (_c = (_b = objectConfigurationsState === null || objectConfigurationsState === void 0 ? void 0 : objectConfigurationsState.other) === null || _b === void 0 ? void 0 : _b.write) === null || _c === void 0 ? void 0 : _c.isWriteModified, displayName: (readNavObjects === null || readNavObjects === void 0 ? void 0 : readNavObjects.length) ? 'other' : 'write' })), installation && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_2.Divider, { marginTop: 10, marginBottom: 3 }), (0, jsx_runtime_1.jsx)(UninstallInstallation_1.UninstallInstallation, { text: "Uninstall" }, "uninstall-installation")] }))] }))] }), children] }) }));
60
+ }
61
+ exports.ObjectManagementNav = ObjectManagementNav;
@@ -1,53 +1,81 @@
1
1
  import React from 'react';
2
+ import { Draft } from 'immer';
2
3
  import { ConfigureState, ObjectConfigurationsState } from '../types';
3
- export declare function useConfigureState(): {
4
+ export declare const ConfigurationContext: React.Context<{
5
+ objectConfigurationsState: ObjectConfigurationsState;
6
+ setObjectConfigurationsState: React.Dispatch<React.SetStateAction<ObjectConfigurationsState>>;
7
+ setConfigureState: (objectName: string, producer: (draft: Draft<ConfigureState>) => void) => void;
8
+ resetConfigureState: (objectName: string, configureState: ConfigureState) => void;
9
+ resetPendingConfigurationState: (objectName: string) => void;
10
+ } | undefined>;
11
+ /**
12
+ * Custom hook to access and update the configuration state for all objects
13
+ */
14
+ export declare function useObjectsConfigureState(): {
4
15
  objectConfigurationsState: ObjectConfigurationsState;
5
16
  setObjectConfigurationsState: React.Dispatch<React.SetStateAction<ObjectConfigurationsState>>;
6
17
  setConfigureState: (objectName: string, producer: (draft: {
7
- allFields: {
8
- fieldName: string;
9
- displayName: string;
10
- }[] | null;
11
- requiredFields: ({
12
- fieldName: string;
13
- displayName: string;
14
- } | {
15
- mapToName: string;
16
- mapToDisplayName?: string | undefined;
17
- _default?: string | undefined;
18
- prompt?: string | undefined;
19
- })[] | null;
20
- optionalFields: ({
21
- fieldName: string;
22
- displayName: string;
23
- } | {
24
- mapToName: string;
25
- mapToDisplayName?: string | undefined;
26
- _default?: string | undefined;
27
- prompt?: string | undefined;
28
- })[] | null;
29
- requiredMapFields: {
30
- mapToName: string;
31
- mapToDisplayName?: string | undefined;
32
- _default?: string | undefined;
33
- prompt?: string | undefined;
34
- }[] | null;
35
- selectedOptionalFields: {
36
- [x: string]: boolean;
37
- } | null;
38
- selectedFieldMappings: {
39
- [x: string]: string | undefined;
40
- } | null;
41
- isOptionalFieldsModified: boolean;
42
- isRequiredMapFieldsModified: boolean;
43
- savedConfig: {
44
- optionalFields: {
45
- [x: string]: boolean;
46
- };
18
+ read: {
19
+ allFields: {
20
+ fieldName: string;
21
+ displayName: string;
22
+ }[] | null;
23
+ requiredFields: ({
24
+ fieldName: string;
25
+ displayName: string;
26
+ } | {
27
+ mapToName: string;
28
+ mapToDisplayName?: string | undefined;
29
+ _default?: string | undefined;
30
+ prompt?: string | undefined;
31
+ })[] | null;
32
+ optionalFields: ({
33
+ fieldName: string;
34
+ displayName: string;
35
+ } | {
36
+ mapToName: string;
37
+ mapToDisplayName?: string | undefined;
38
+ _default?: string | undefined;
39
+ prompt?: string | undefined;
40
+ })[] | null;
47
41
  requiredMapFields: {
42
+ mapToName: string;
43
+ mapToDisplayName?: string | undefined;
44
+ _default?: string | undefined;
45
+ prompt?: string | undefined;
46
+ }[] | null;
47
+ selectedOptionalFields: {
48
+ [x: string]: boolean;
49
+ } | null;
50
+ selectedFieldMappings: {
48
51
  [x: string]: string | undefined;
52
+ } | null;
53
+ isOptionalFieldsModified: boolean;
54
+ isRequiredMapFieldsModified: boolean;
55
+ savedConfig: {
56
+ optionalFields: {
57
+ [x: string]: boolean;
58
+ };
59
+ requiredMapFields: {
60
+ [x: string]: string | undefined;
61
+ };
62
+ };
63
+ } | null;
64
+ write: {
65
+ writeObjects: {
66
+ objectName: string;
67
+ displayName: string;
68
+ }[] | null;
69
+ selectedNonConfigurableWriteFields: {
70
+ [x: string]: boolean;
71
+ } | null;
72
+ isWriteModified: boolean;
73
+ savedConfig: {
74
+ selectedNonConfigurableWriteFields: {
75
+ [x: string]: boolean;
76
+ };
49
77
  };
50
- };
78
+ } | null;
51
79
  }) => void) => void;
52
80
  resetConfigureState: (objectName: string, configureState: ConfigureState) => void;
53
81
  resetPendingConfigurationState: (objectName: string) => void;
@@ -1,27 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConfigurationProvider = exports.useConfigureState = void 0;
3
+ exports.ConfigurationProvider = exports.useObjectsConfigureState = exports.ConfigurationContext = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const immer_1 = require("immer");
7
- const InstallIntegrationContext_1 = require("../../../context/InstallIntegrationContext");
7
+ const InstallIntegrationContextProvider_1 = require("../../../context/InstallIntegrationContextProvider");
8
+ const constant_1 = require("../nav/ObjectManagementNav/constant");
8
9
  const HydratedRevisionContext_1 = require("./HydratedRevisionContext");
9
10
  const utils_1 = require("./utils");
10
11
  // Create a context for the configuration state
11
- const ConfigurationContext = (0, react_1.createContext)(undefined);
12
+ exports.ConfigurationContext = (0, react_1.createContext)(undefined);
12
13
  const initialObjectConfigurationsState = {};
13
- // Custom hook to access and update the configuration state
14
- function useConfigureState() {
15
- const context = (0, react_1.useContext)(ConfigurationContext);
14
+ /**
15
+ * Custom hook to access and update the configuration state for all objects
16
+ */
17
+ function useObjectsConfigureState() {
18
+ const context = (0, react_1.useContext)(exports.ConfigurationContext);
16
19
  if (!context) {
17
- throw new Error('useConfigureState must be used within a ConfigurationProvider');
20
+ throw new Error('useObjectsConfigureState must be used within a ConfigurationProvider');
18
21
  }
19
22
  return context;
20
23
  }
21
- exports.useConfigureState = useConfigureState;
24
+ exports.useObjectsConfigureState = useObjectsConfigureState;
22
25
  // Create a provider component for the configuration context
23
26
  function ConfigurationProvider({ children }) {
24
- const { installation } = (0, InstallIntegrationContext_1.useInstallIntegrationProps)();
27
+ const { installation } = (0, InstallIntegrationContextProvider_1.useInstallIntegrationProps)();
25
28
  const { hydratedRevision, loading } = (0, HydratedRevisionContext_1.useHydratedRevision)();
26
29
  // 1. get config from installations (contains form selection state)
27
30
  // 2. get the hydrated revision from installation revisionId (contains full form)
@@ -53,16 +56,35 @@ function ConfigurationProvider({ children }) {
53
56
  draft[objectName] = configureState;
54
57
  }));
55
58
  }, [setObjectConfigurationsState]);
56
- // set configure state of single object
57
- const resetPendingConfigurationState = (0, react_1.useCallback)((objectName) => {
59
+ const resetWritePendingConfigurationState = (0, react_1.useCallback)(() => {
58
60
  setObjectConfigurationsState((0, immer_1.produce)((draft) => {
59
- // immer exception when mutating a draft
60
- // eslint-disable-next-line no-param-reassign
61
- draft[objectName].isOptionalFieldsModified = false;
62
- // eslint-disable-next-line no-param-reassign
63
- draft[objectName].isRequiredMapFieldsModified = false;
61
+ const writeDraft = draft.other.write;
62
+ if (writeDraft) {
63
+ writeDraft.isWriteModified = false;
64
+ }
65
+ }));
66
+ }, [setObjectConfigurationsState]);
67
+ const resetReadPendingConfigurationState = (0, react_1.useCallback)((objectName) => {
68
+ setObjectConfigurationsState((0, immer_1.produce)((draft) => {
69
+ var _a;
70
+ const readDraft = (_a = draft[objectName]) === null || _a === void 0 ? void 0 : _a.read;
71
+ if (readDraft) {
72
+ readDraft.isOptionalFieldsModified = false;
73
+ readDraft.isRequiredMapFieldsModified = false;
74
+ }
64
75
  }));
65
76
  }, [setObjectConfigurationsState]);
77
+ // set configure state of single object
78
+ const resetPendingConfigurationState = (0, react_1.useCallback)((objectName) => {
79
+ // write case
80
+ if (objectName === constant_1.OTHER_CONST) {
81
+ resetWritePendingConfigurationState();
82
+ }
83
+ else {
84
+ // read case
85
+ resetReadPendingConfigurationState(objectName);
86
+ }
87
+ }, [resetReadPendingConfigurationState, resetWritePendingConfigurationState]);
66
88
  const contextValue = (0, react_1.useMemo)(() => ({
67
89
  objectConfigurationsState,
68
90
  setObjectConfigurationsState,
@@ -71,6 +93,6 @@ function ConfigurationProvider({ children }) {
71
93
  resetPendingConfigurationState,
72
94
  }), [objectConfigurationsState,
73
95
  resetConfigureState, resetPendingConfigurationState, setConfigureState]);
74
- return ((0, jsx_runtime_1.jsx)(ConfigurationContext.Provider, { value: contextValue, children: children }));
96
+ return ((0, jsx_runtime_1.jsx)(exports.ConfigurationContext.Provider, { value: contextValue, children: children }));
75
97
  }
76
98
  exports.ConfigurationProvider = ConfigurationProvider;
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HydratedRevisionProvider = exports.useHydratedRevision = exports.HydratedRevisionContext = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
- const ApiKeyProvider_1 = require("../../../context/ApiKeyProvider");
7
- const ConnectionsContext_1 = require("../../../context/ConnectionsContext");
6
+ const ApiKeyContextProvider_1 = require("../../../context/ApiKeyContextProvider");
7
+ const ConnectionsContextProvider_1 = require("../../../context/ConnectionsContextProvider");
8
8
  const ErrorContextProvider_1 = require("../../../context/ErrorContextProvider");
9
- const InstallIntegrationContext_1 = require("../../../context/InstallIntegrationContext");
9
+ const InstallIntegrationContextProvider_1 = require("../../../context/InstallIntegrationContextProvider");
10
10
  const api_1 = require("../../../services/api");
11
- const ErrorTextBox_1 = require("../ErrorTextBox");
11
+ const ErrorTextBox_1 = require("../../ErrorTextBox");
12
12
  exports.HydratedRevisionContext = (0, react_1.createContext)({
13
13
  hydratedRevision: null,
14
14
  loading: false,
@@ -23,12 +23,12 @@ const useHydratedRevision = () => {
23
23
  exports.useHydratedRevision = useHydratedRevision;
24
24
  function HydratedRevisionProvider({ projectId, children, }) {
25
25
  var _a;
26
- const { selectedConnection } = (0, ConnectionsContext_1.useConnections)();
27
- const { integrationId, integrationObj } = (0, InstallIntegrationContext_1.useInstallIntegrationProps)();
26
+ const { selectedConnection } = (0, ConnectionsContextProvider_1.useConnections)();
27
+ const { integrationId, integrationObj } = (0, InstallIntegrationContextProvider_1.useInstallIntegrationProps)();
28
28
  const [hydratedRevision, setHydratedRevision] = (0, react_1.useState)(null);
29
29
  const [loading, setLoading] = (0, react_1.useState)(true);
30
30
  const { isError, removeError, setError } = (0, ErrorContextProvider_1.useErrorState)();
31
- const apiKey = (0, ApiKeyProvider_1.useApiKey)();
31
+ const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
32
32
  const connectionId = selectedConnection === null || selectedConnection === void 0 ? void 0 : selectedConnection.id;
33
33
  const revisionId = (_a = integrationObj === null || integrationObj === void 0 ? void 0 : integrationObj.latestRevision) === null || _a === void 0 ? void 0 : _a.id;
34
34
  const errorIntegrationIdentifier = (integrationObj === null || integrationObj === void 0 ? void 0 : integrationObj.name) || integrationId;
@@ -39,7 +39,7 @@ function HydratedRevisionProvider({ projectId, children, }) {
39
39
  && revisionId
40
40
  && connectionId
41
41
  && apiKey) {
42
- (0, api_1.api)().getHydratedRevision({
42
+ (0, api_1.api)().revisionApi.getHydratedRevision({
43
43
  projectId,
44
44
  integrationId,
45
45
  revisionId,
@@ -74,6 +74,8 @@ function HydratedRevisionProvider({ projectId, children, }) {
74
74
  hydratedRevision,
75
75
  loading,
76
76
  }), [hydratedRevision, loading]);
77
- return ((0, jsx_runtime_1.jsx)(exports.HydratedRevisionContext.Provider, { value: contextValue, children: isError(ErrorContextProvider_1.ErrorBoundary.HYDRATED_REVISION, errorIntegrationIdentifier) ? (0, jsx_runtime_1.jsx)(ErrorTextBox_1.ErrorTextBox, { message: `Error retrieving integration details for '${(integrationObj === null || integrationObj === void 0 ? void 0 : integrationObj.name) || integrationId || 'unknown integration'}. This is sometimes caused by insufficient permissions with your credentials'` }) : children }));
77
+ const errorMsg = `Error retrieving integration details for '${(integrationObj === null || integrationObj === void 0 ? void 0 : integrationObj.name) || integrationId || 'unknown integration'}. This is sometimes caused by insufficient permissions with your credentials'`;
78
+ return ((0, jsx_runtime_1.jsx)(exports.HydratedRevisionContext.Provider, { value: contextValue, children: isError(ErrorContextProvider_1.ErrorBoundary.HYDRATED_REVISION, errorIntegrationIdentifier)
79
+ ? (0, jsx_runtime_1.jsx)(ErrorTextBox_1.ErrorTextBox, { message: errorMsg }) : children }));
78
80
  }
79
81
  exports.HydratedRevisionProvider = HydratedRevisionProvider;
@@ -1,7 +1,7 @@
1
- import { Config, HydratedIntegrationRead, HydratedRevision } from '../../../services/api';
1
+ import { Config, HydratedRevision } from '../../../services/api';
2
2
  import { ConfigureState, ObjectConfigurationsState, SelectMappingFields, SelectOptionalFields } from '../types';
3
3
  export declare function isFieldObjectEqual(prevFields: SelectMappingFields | SelectOptionalFields, currentFields: SelectMappingFields | SelectOptionalFields): boolean;
4
- export declare function generateConfigurationState(action: HydratedIntegrationRead, objectName: string, config?: Config): ConfigureState;
4
+ export declare function generateConfigurationState(hydratedRevision: HydratedRevision, objectName: string, config?: Config): ConfigureState;
5
5
  export declare const setHydrateConfigState: (hydratedRevision: HydratedRevision, config: Config | undefined, selectedObjectName: string, setConfigureState: (objectName: string, configureState: ConfigureState) => void) => void;
6
6
  /**
7
7
  * resets configure state for all objects in hydrated revision to hydrated revision values
@@ -11,18 +11,22 @@ function isFieldObjectEqual(prevFields, currentFields) {
11
11
  return (0, lodash_isequal_1.default)(prevFields, currentFields);
12
12
  }
13
13
  exports.isFieldObjectEqual = isFieldObjectEqual;
14
- function generateConfigurationState(action, objectName, config) {
15
- var _a, _b, _c, _d, _e, _f, _g, _h;
14
+ const generateConfigurationStateRead = (readAction, objectName, config) => {
15
+ var _a, _b, _c, _d, _e, _f;
16
+ if (!readAction) {
17
+ return null;
18
+ }
16
19
  // refactor this section to be immutable at hydrated revision level
17
- const object = (0, utils_1.getStandardObjectFromAction)(action, objectName);
20
+ const object = (0, utils_1.getStandardObjectFromAction)(readAction, objectName);
18
21
  const requiredFields = object && (0, utils_1.getRequiredFieldsFromObject)(object);
19
22
  const optionalFields = object && (0, utils_1.getOptionalFieldsFromObject)(object);
20
23
  const requiredMapFields = object && (0, utils_1.getRequiredMapFieldsFromObject)(object);
21
24
  /// //////////////////////////////////////////////////////////////////////
22
25
  const allFields = (object === null || object === void 0 ? void 0 : object.allFields) || [];
23
- const selectedFields = ((_d = (_c = (_b = (_a = config === null || config === void 0 ? void 0 : config.content) === null || _a === void 0 ? void 0 : _a.read) === null || _b === void 0 ? void 0 : _b.standardObjects) === null || _c === void 0 ? void 0 : _c[objectName]) === null || _d === void 0 ? void 0 : _d.selectedFields) || {};
24
- const selectedFieldMappings = ((_h = (_g = (_f = (_e = config === null || config === void 0 ? void 0 : config.content) === null || _e === void 0 ? void 0 : _e.read) === null || _f === void 0 ? void 0 : _f.standardObjects) === null || _g === void 0 ? void 0 : _g[objectName]) === null || _h === void 0 ? void 0 : _h.selectedFieldMappings) || {};
25
- const optionalFieldsSaved = Object.assign({}, selectedFields);
26
+ const content = config === null || config === void 0 ? void 0 : config.content;
27
+ const readSelectedFields = ((_c = (_b = (_a = content === null || content === void 0 ? void 0 : content.read) === null || _a === void 0 ? void 0 : _a.standardObjects) === null || _b === void 0 ? void 0 : _b[objectName]) === null || _c === void 0 ? void 0 : _c.selectedFields) || {};
28
+ const selectedFieldMappings = ((_f = (_e = (_d = content === null || content === void 0 ? void 0 : content.read) === null || _d === void 0 ? void 0 : _d.standardObjects) === null || _e === void 0 ? void 0 : _e[objectName]) === null || _f === void 0 ? void 0 : _f.selectedFieldMappings) || {};
29
+ const optionalFieldsSaved = Object.assign({}, readSelectedFields);
26
30
  const requiredMapFieldsSaved = Object.assign({}, selectedFieldMappings);
27
31
  return {
28
32
  allFields,
@@ -30,7 +34,7 @@ function generateConfigurationState(action, objectName, config) {
30
34
  optionalFields,
31
35
  requiredMapFields,
32
36
  // selected state
33
- selectedOptionalFields: selectedFields,
37
+ selectedOptionalFields: readSelectedFields,
34
38
  selectedFieldMappings,
35
39
  isOptionalFieldsModified: false,
36
40
  isRequiredMapFieldsModified: false,
@@ -39,16 +43,39 @@ function generateConfigurationState(action, objectName, config) {
39
43
  requiredMapFields: requiredMapFieldsSaved, // from config
40
44
  },
41
45
  };
46
+ };
47
+ const generateConfigurationStateWrite = (writeAction, config) => {
48
+ var _a, _b;
49
+ if (!writeAction) {
50
+ return null;
51
+ }
52
+ const writeObjects = (_b = (_a = config === null || config === void 0 ? void 0 : config.content) === null || _a === void 0 ? void 0 : _a.write) === null || _b === void 0 ? void 0 : _b.objects;
53
+ const fields = Object.keys(writeObjects || {});
54
+ const selectedWriteFields = {};
55
+ fields.forEach((field) => { selectedWriteFields[field] = true; });
56
+ const savedFields = Object.assign({}, selectedWriteFields);
57
+ return {
58
+ writeObjects: (writeAction === null || writeAction === void 0 ? void 0 : writeAction.objects) || [],
59
+ selectedNonConfigurableWriteFields: selectedWriteFields,
60
+ isWriteModified: false,
61
+ savedConfig: {
62
+ selectedNonConfigurableWriteFields: savedFields,
63
+ },
64
+ };
65
+ };
66
+ function generateConfigurationState(hydratedRevision, objectName, config) {
67
+ var _a, _b;
68
+ const readAction = (_a = hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) === null || _a === void 0 ? void 0 : _a.read;
69
+ const writeAction = (_b = hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) === null || _b === void 0 ? void 0 : _b.write;
70
+ return {
71
+ read: generateConfigurationStateRead(readAction, objectName, config),
72
+ write: generateConfigurationStateWrite(writeAction, config),
73
+ };
42
74
  }
43
75
  exports.generateConfigurationState = generateConfigurationState;
44
76
  // resets configure state for single object to hydrated revision values
45
77
  const setHydrateConfigState = (hydratedRevision, config, selectedObjectName, setConfigureState) => {
46
- var _a;
47
- const readAction = (_a = hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) === null || _a === void 0 ? void 0 : _a.read;
48
- if (!readAction) {
49
- return;
50
- }
51
- const state = generateConfigurationState(readAction, selectedObjectName, config);
78
+ const state = generateConfigurationState(hydratedRevision, selectedObjectName, config);
52
79
  setConfigureState(selectedObjectName, state);
53
80
  };
54
81
  exports.setHydrateConfigState = setHydrateConfigState;
@@ -59,10 +86,8 @@ const resetAllObjectsConfigurationState = (hydratedRevision, config, setObjectCo
59
86
  const navObjects = (0, utils_1.generateNavObjects)(config, hydratedRevision);
60
87
  const objectConfigurationsState = {};
61
88
  navObjects.forEach(({ name, completed }) => {
62
- var _a;
63
- const readAction = (_a = hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) === null || _a === void 0 ? void 0 : _a.read;
64
- if (completed && readAction) {
65
- objectConfigurationsState[name] = generateConfigurationState(readAction, name, config);
89
+ if (completed) {
90
+ objectConfigurationsState[name] = generateConfigurationState(hydratedRevision, name, config);
66
91
  }
67
92
  });
68
93
  setObjectConfiguresState(objectConfigurationsState);
@@ -74,7 +99,7 @@ exports.resetAllObjectsConfigurationState = resetAllObjectsConfigurationState;
74
99
  * @returns
75
100
  */
76
101
  const generateSelectedFieldsFromConfigureState = (configureState) => {
77
- const { requiredFields, selectedOptionalFields } = configureState;
102
+ const { requiredFields, selectedOptionalFields } = (configureState === null || configureState === void 0 ? void 0 : configureState.read) || {};
78
103
  const fields = new Set();
79
104
  requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.forEach((field) => fields.add((0, utils_1.getFieldKeyValue)(field)));
80
105
  // convert set to object for config
@@ -88,7 +113,7 @@ exports.generateSelectedFieldsFromConfigureState = generateSelectedFieldsFromCon
88
113
  * @returns
89
114
  */
90
115
  const generateSelectedFieldMappingsFromConfigureState = (configureState) => {
91
- const { selectedFieldMappings: selectedRequiredMapFields } = configureState;
116
+ const { selectedFieldMappings: selectedRequiredMapFields } = (configureState === null || configureState === void 0 ? void 0 : configureState.read) || {};
92
117
  // filter out undefined values of selectedRequiredMapFields
93
118
  const selectedRequiredMapFieldsSubmit = {};
94
119
  if (selectedRequiredMapFields) {