@oneblink/apps-react 9.0.0-beta.3 → 9.0.0-beta.4

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 (177) hide show
  1. package/dist/OneBlinkForm.d.ts +0 -4
  2. package/dist/OneBlinkForm.js +0 -4
  3. package/dist/OneBlinkForm.js.map +1 -1
  4. package/dist/OneBlinkFormBase.d.ts +1 -1
  5. package/dist/OneBlinkFormBase.js +1 -1
  6. package/dist/OneBlinkFormBase.js.map +1 -1
  7. package/dist/OneBlinkReadOnlyForm.d.ts +1 -1
  8. package/dist/OneBlinkReadOnlyForm.js +1 -1
  9. package/dist/OneBlinkReadOnlyForm.js.map +1 -1
  10. package/dist/PaymentReceipt.d.ts +1 -1
  11. package/dist/PaymentReceipt.js +1 -1
  12. package/dist/PaymentReceipt.js.map +1 -1
  13. package/dist/apps/index.d.ts +18 -18
  14. package/dist/apps/index.js +18 -18
  15. package/dist/apps/index.js.map +1 -1
  16. package/dist/components/ArcGISWebMap.js +1 -1
  17. package/dist/components/ArcGISWebMap.js.map +1 -1
  18. package/dist/components/calendar-bookings/CalendarBookingsCancelForm.js +1 -1
  19. package/dist/components/calendar-bookings/CalendarBookingsCancelForm.js.map +1 -1
  20. package/dist/components/calendar-bookings/CalendarBookingsForm.d.ts +1 -1
  21. package/dist/components/calendar-bookings/CalendarBookingsForm.js +1 -1
  22. package/dist/components/calendar-bookings/CalendarBookingsForm.js.map +1 -1
  23. package/dist/components/calendar-bookings/CalendarBookingsReschedulingForm.js +1 -1
  24. package/dist/components/calendar-bookings/CalendarBookingsReschedulingForm.js.map +1 -1
  25. package/dist/components/calendar-bookings/ErrorModal.d.ts +1 -1
  26. package/dist/components/calendar-bookings/ErrorModal.js +1 -1
  27. package/dist/components/calendar-bookings/ErrorModal.js.map +1 -1
  28. package/dist/components/downloadable-files/index.d.ts +1 -1
  29. package/dist/components/downloadable-files/index.js +1 -1
  30. package/dist/components/downloadable-files/index.js.map +1 -1
  31. package/dist/components/downloadable-files/resource-components.d.ts +1 -1
  32. package/dist/components/downloadable-files/resource-components.js +1 -1
  33. package/dist/components/downloadable-files/resource-components.js.map +1 -1
  34. package/dist/components/formStore/FormStoreTableProvider.js +1 -1
  35. package/dist/components/formStore/FormStoreTableProvider.js.map +1 -1
  36. package/dist/components/formStore/OneBlinkFormStoreClearFiltersButton.js.map +1 -1
  37. package/dist/components/formStore/OneBlinkFormStoreDownloadButton.js +1 -1
  38. package/dist/components/formStore/OneBlinkFormStoreDownloadButton.js.map +1 -1
  39. package/dist/components/formStore/OneBlinkFormStoreProvider.js +1 -1
  40. package/dist/components/formStore/OneBlinkFormStoreProvider.js.map +1 -1
  41. package/dist/components/formStore/OneBlinkFormStoreTable.js.map +1 -1
  42. package/dist/components/formStore/display/ElementDisplay.js +2 -2
  43. package/dist/components/formStore/display/ElementDisplay.js.map +1 -1
  44. package/dist/components/formStore/table/ColumnFilters.js +1 -1
  45. package/dist/components/formStore/table/ColumnFilters.js.map +1 -1
  46. package/dist/components/formStore/table/FormElementTableCell.js +1 -1
  47. package/dist/components/formStore/table/FormElementTableCell.js.map +1 -1
  48. package/dist/components/formStore/table/Pickers.js +1 -1
  49. package/dist/components/formStore/table/Pickers.js.map +1 -1
  50. package/dist/components/formStore/table/generateColumns.d.ts +1 -1
  51. package/dist/components/formStore/table/generateColumns.js.map +1 -1
  52. package/dist/components/formStore/table/useFormStoreTable.d.ts +1 -1
  53. package/dist/components/formStore/table/useFormStoreTable.js +1 -1
  54. package/dist/components/formStore/table/useFormStoreTable.js.map +1 -1
  55. package/dist/components/mfa/MfaDialog.d.ts +1 -1
  56. package/dist/components/mfa/MfaDialog.js +1 -1
  57. package/dist/components/mfa/MfaDialog.js.map +1 -1
  58. package/dist/components/payments/PaymentForm.js +1 -1
  59. package/dist/components/payments/PaymentForm.js.map +1 -1
  60. package/dist/components/payments/WestpacQuickStreamPaymentForm.d.ts +1 -1
  61. package/dist/components/payments/WestpacQuickStreamPaymentForm.js +1 -1
  62. package/dist/components/payments/WestpacQuickStreamPaymentForm.js.map +1 -1
  63. package/dist/components/renderer/AutocompleteDropdown.js +1 -1
  64. package/dist/components/renderer/AutocompleteDropdown.js.map +1 -1
  65. package/dist/components/renderer/LookupNotification.js +2 -2
  66. package/dist/components/renderer/LookupNotification.js.map +1 -1
  67. package/dist/components/renderer/OneBlinkAppsErrorOriginalMessage.js +1 -1
  68. package/dist/components/renderer/OneBlinkAppsErrorOriginalMessage.js.map +1 -1
  69. package/dist/components/renderer/OneBlinkFormElements.js.map +1 -1
  70. package/dist/components/renderer/ReverseGeocode.js +1 -1
  71. package/dist/components/renderer/ReverseGeocode.js.map +1 -1
  72. package/dist/form-elements/FormElementAPINSWLiquorLicence.js +1 -1
  73. package/dist/form-elements/FormElementAPINSWLiquorLicence.js.map +1 -1
  74. package/dist/form-elements/FormElementArcGISWebMap.js.map +1 -1
  75. package/dist/form-elements/FormElementAutocomplete.js +1 -1
  76. package/dist/form-elements/FormElementAutocomplete.js.map +1 -1
  77. package/dist/form-elements/FormElementBSB.js +1 -1
  78. package/dist/form-elements/FormElementBSB.js.map +1 -1
  79. package/dist/form-elements/FormElementCalculation.js +2 -2
  80. package/dist/form-elements/FormElementCalculation.js.map +1 -1
  81. package/dist/form-elements/FormElementCivicaNameRecord.js +1 -1
  82. package/dist/form-elements/FormElementCivicaNameRecord.js.map +1 -1
  83. package/dist/form-elements/FormElementCivicaStreetName.js +1 -1
  84. package/dist/form-elements/FormElementCivicaStreetName.js.map +1 -1
  85. package/dist/form-elements/FormElementCompliance.d.ts +1 -1
  86. package/dist/form-elements/FormElementCompliance.js.map +1 -1
  87. package/dist/form-elements/FormElementDate.js +1 -1
  88. package/dist/form-elements/FormElementDate.js.map +1 -1
  89. package/dist/form-elements/FormElementDateTime.js +1 -1
  90. package/dist/form-elements/FormElementDateTime.js.map +1 -1
  91. package/dist/form-elements/FormElementFile.d.ts +1 -1
  92. package/dist/form-elements/FormElementFile.js.map +1 -1
  93. package/dist/form-elements/FormElementFiles.d.ts +1 -1
  94. package/dist/form-elements/FormElementFiles.js.map +1 -1
  95. package/dist/form-elements/FormElementGeoscapeAddress.js +1 -1
  96. package/dist/form-elements/FormElementGeoscapeAddress.js.map +1 -1
  97. package/dist/form-elements/FormElementGoogleAddress.js +1 -1
  98. package/dist/form-elements/FormElementGoogleAddress.js.map +1 -1
  99. package/dist/form-elements/FormElementLocation.js +1 -1
  100. package/dist/form-elements/FormElementLocation.js.map +1 -1
  101. package/dist/form-elements/FormElementNumber.js +1 -1
  102. package/dist/form-elements/FormElementNumber.js.map +1 -1
  103. package/dist/form-elements/FormElementPointAddress.js +1 -1
  104. package/dist/form-elements/FormElementPointAddress.js.map +1 -1
  105. package/dist/form-elements/FormElementPointAddressV3.js +1 -1
  106. package/dist/form-elements/FormElementPointAddressV3.js.map +1 -1
  107. package/dist/form-elements/FormElementPointCadastralParcel.js +1 -1
  108. package/dist/form-elements/FormElementPointCadastralParcel.js.map +1 -1
  109. package/dist/form-elements/FormElementSummary.js +1 -1
  110. package/dist/form-elements/FormElementSummary.js.map +1 -1
  111. package/dist/form-elements/FormElementTime.js +1 -1
  112. package/dist/form-elements/FormElementTime.js.map +1 -1
  113. package/dist/hooks/attachments/useAttachment.d.ts +1 -1
  114. package/dist/hooks/attachments/useAttachment.js +1 -1
  115. package/dist/hooks/attachments/useAttachment.js.map +1 -1
  116. package/dist/hooks/attachments/useAttachments.d.ts +1 -1
  117. package/dist/hooks/attachments/useAttachments.js.map +1 -1
  118. package/dist/hooks/useAuth.js +1 -1
  119. package/dist/hooks/useAuth.js.map +1 -1
  120. package/dist/hooks/useConditionalLogic.js +1 -1
  121. package/dist/hooks/useConditionalLogic.js.map +1 -1
  122. package/dist/hooks/useDrafts.d.ts +1 -1
  123. package/dist/hooks/useDrafts.js +1 -1
  124. package/dist/hooks/useDrafts.js.map +1 -1
  125. package/dist/hooks/useDynamicOptionsLoaderState.d.ts +1 -1
  126. package/dist/hooks/useDynamicOptionsLoaderState.js +1 -1
  127. package/dist/hooks/useDynamicOptionsLoaderState.js.map +1 -1
  128. package/dist/hooks/useFormElementLookups.d.ts +1 -1
  129. package/dist/hooks/useFormElementLookups.js +1 -1
  130. package/dist/hooks/useFormElementLookups.js.map +1 -1
  131. package/dist/hooks/useFormSubmissionAutoSaveState.d.ts +1 -1
  132. package/dist/hooks/useFormSubmissionAutoSaveState.js +1 -1
  133. package/dist/hooks/useFormSubmissionAutoSaveState.js.map +1 -1
  134. package/dist/hooks/useIsOffline.js +1 -1
  135. package/dist/hooks/useIsOffline.js.map +1 -1
  136. package/dist/hooks/useLogin.js +1 -1
  137. package/dist/hooks/useLogin.js.map +1 -1
  138. package/dist/hooks/useMfa.d.ts +1 -1
  139. package/dist/hooks/useMfa.js +1 -1
  140. package/dist/hooks/useMfa.js.map +1 -1
  141. package/dist/hooks/useOnUploadAttachment.d.ts +1 -1
  142. package/dist/hooks/useOnUploadAttachment.js +1 -1
  143. package/dist/hooks/useOnUploadAttachment.js.map +1 -1
  144. package/dist/hooks/usePendingSubmissions.d.ts +1 -1
  145. package/dist/hooks/usePendingSubmissions.js +1 -1
  146. package/dist/hooks/usePendingSubmissions.js.map +1 -1
  147. package/dist/hooks/useReplaceableText.js +1 -1
  148. package/dist/hooks/useReplaceableText.js.map +1 -1
  149. package/dist/hooks/useSignUp.js +1 -1
  150. package/dist/hooks/useSignUp.js.map +1 -1
  151. package/dist/services/attachments.d.ts +1 -1
  152. package/dist/services/attachments.js +1 -1
  153. package/dist/services/attachments.js.map +1 -1
  154. package/dist/services/blob-utils.js +1 -1
  155. package/dist/services/blob-utils.js.map +1 -1
  156. package/dist/services/checkIfAttachmentsExist.d.ts +1 -1
  157. package/dist/services/checkIfAttachmentsExist.js.map +1 -1
  158. package/dist/services/defaultCoordinates.js +1 -1
  159. package/dist/services/defaultCoordinates.js.map +1 -1
  160. package/dist/services/download-file.d.ts +1 -1
  161. package/dist/services/download-file.js +2 -2
  162. package/dist/services/download-file.js.map +1 -1
  163. package/dist/services/drawTimestampOnCanvas.js +1 -1
  164. package/dist/services/drawTimestampOnCanvas.js.map +1 -1
  165. package/dist/services/form-validation/validateSubmission.js +1 -1
  166. package/dist/services/form-validation/validateSubmission.js.map +1 -1
  167. package/dist/services/form-validation/validators.d.ts +1 -1
  168. package/dist/services/form-validation/validators.js.map +1 -1
  169. package/dist/services/generate-default-data.js +1 -1
  170. package/dist/services/generate-default-data.js.map +1 -1
  171. package/dist/services/injectableOptions.js +1 -1
  172. package/dist/services/injectableOptions.js.map +1 -1
  173. package/dist/types/attachments.d.ts +1 -1
  174. package/dist/types/attachments.js.map +1 -1
  175. package/dist/utils/sendGoogleAnalyticsEvent.js +1 -1
  176. package/dist/utils/sendGoogleAnalyticsEvent.js.map +1 -1
  177. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as React from 'react';
3
- import { authService } from '@oneblink/apps';
3
+ import { authService } from '../apps';
4
4
  export const MfaContext = React.createContext({
5
5
  isExternalIdentityProviderUser: false,
6
6
  isLoading: true,
@@ -1 +1 @@
1
- {"version":3,"file":"useMfa.js","sourceRoot":"","sources":["../../src/hooks/useMfa.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAa5C,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC,aAAa,CAW3C;IACA,8BAA8B,EAAE,KAAK;IACrC,SAAS,EAAE,IAAI;IACf,YAAY,EAAE,KAAK;IACnB,cAAc,EAAE,KAAK;IACrB,cAAc,EAAE,KAAK;IACrB,aAAa,EAAE,GAAG,EAAE,GAAE,CAAC;IACvB,cAAc,EAAE,GAAG,EAAE,GAAE,CAAC;IACxB,gBAAgB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC1B,iBAAiB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC3B,kBAAkB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,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAC/B,OAAO;YACL,GAAG,KAAK;YACR,kBAAkB;YAClB,OAAO;YACP,aAAa;YACb,cAAc;YACd,gBAAgB;YAChB,iBAAiB;YACjB,kBAAkB;YAClB,oBAAoB;SACrB,CAAA;IACH,CAAC,EAAE;QACD,KAAK;QACL,kBAAkB;QAClB,OAAO;QACP,aAAa;QACb,cAAc;QACd,gBAAgB;QAChB,iBAAiB;QACjB,kBAAkB;QAClB,oBAAoB;KACrB,CAAC,CAAA;IAEF,OAAO,KAAC,UAAU,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAuB,CAAA;AAC5E,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,MAAM;IAC5B,OAAO,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;AACrC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,0BAA0B,CAAC,aAAsB;IAC/D,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;IAE5C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,mGAAmG,CACpG,CAAA;IACH,CAAC;IAED,MAAM,EAAE,YAAY,EAAE,8BAA8B,EAAE,GAAG,OAAO,CAAA;IAChE,IAAI,CAAC,aAAa,IAAI,8BAA8B,EAAE,CAAC;QACrD,OAAO,IAAI,CAAA;IACb,CAAC;IACD,OAAO,YAAY,CAAA;AACrB,CAAC","sourcesContent":["import * as React from 'react'\nimport { authService } from '@oneblink/apps'\n\ntype MfaState = {\n isExternalIdentityProviderUser: boolean\n isLoading: boolean\n isMfaEnabled: boolean\n loadingError?: Error\n isSettingUpMfa: boolean\n isDisablingMfa: boolean\n setupError?: Error\n mfaSetup?: Awaited<ReturnType<typeof authService.setupMfa>>\n}\n\nexport const MfaContext = React.createContext<\n MfaState & {\n beginMfaSetup: () => void\n cancelMfaSetup: () => void\n completeMfaSetup: () => void\n beginDisablingMfa: () => void\n cancelDisablingMfa: () => void\n completeDisablingMfa: () => void\n clearMfaSetupError: () => void\n loadMfa: () => void\n }\n>({\n isExternalIdentityProviderUser: false,\n isLoading: true,\n isMfaEnabled: false,\n isSettingUpMfa: false,\n isDisablingMfa: false,\n beginMfaSetup: () => {},\n cancelMfaSetup: () => {},\n completeMfaSetup: () => {},\n beginDisablingMfa: () => {},\n cancelDisablingMfa: () => {},\n completeDisablingMfa: () => {},\n clearMfaSetupError: () => {},\n loadMfa: () => {},\n})\n\n/**\n * React Component that provides the context for the\n * `useUserMeetsMfaRequirement()` hook and `<MultiFactorAuthentication />`\n * component, to be used by components further down your component tree. **It\n * should only be included in your component tree once and ideally at the root\n * of the application.**\n *\n * #### Example\n *\n * ```js\n * import * as React from 'react'\n * import {\n * MfaProvider,\n * useUserMeetsMfaRequirement,\n * } from '@oneblink/apps-react'\n *\n * function Component() {\n * const { isLoading, userMeetsMfaRequirement } =\n * useUserMeetsMfaRequirement(true)\n * // use MFA Requirement details here\n * }\n *\n * function App() {\n * return (\n * <MfaProvider isExternalIdentityProviderUser={false}>\n * <Component />\n * </MfaProvider>\n * )\n * }\n *\n * const root = document.getElementById('root')\n * if (root) {\n * ReactDOM.render(<App />, root)\n * }\n * ```\n *\n * @param props\n * @returns\n * @group Components\n */\nexport function MfaProvider({\n children,\n isExternalIdentityProviderUser,\n}: {\n children: React.ReactNode\n isExternalIdentityProviderUser: boolean\n}) {\n const [state, setState] = React.useState<MfaState>({\n isExternalIdentityProviderUser,\n isLoading: !isExternalIdentityProviderUser,\n isMfaEnabled: false,\n isSettingUpMfa: false,\n isDisablingMfa: false,\n })\n\n const loadMfa = React.useCallback(async (abortSignal?: AbortSignal) => {\n setState((currentState) => ({\n ...currentState,\n isLoading: true,\n isMfaEnabled: false,\n loadingError: undefined,\n }))\n try {\n const newIsMfaEnabled = await authService.checkIsMfaEnabled()\n if (!abortSignal?.aborted) {\n setState((currentState) => ({\n ...currentState,\n isLoading: false,\n isMfaEnabled: newIsMfaEnabled,\n }))\n }\n } catch (error) {\n setState((currentState) => ({\n ...currentState,\n isLoading: false,\n loadingError: error as Error,\n }))\n }\n }, [])\n\n const clearMfaSetupError = React.useCallback(() => {\n setState((currentState) => ({\n ...currentState,\n setupError: undefined,\n }))\n }, [])\n\n const cancelMfaSetup = React.useCallback(() => {\n setState((currentState) => ({\n ...currentState,\n mfaSetup: undefined,\n }))\n }, [])\n\n const completeMfaSetup = React.useCallback(() => {\n setState((currentState) => ({\n ...currentState,\n isMfaEnabled: true,\n mfaSetup: undefined,\n }))\n }, [])\n\n const beginMfaSetup = React.useCallback(async () => {\n setState((currentState) => ({\n ...currentState,\n isSettingUpMfa: true,\n mfaSetup: undefined,\n setupError: undefined,\n }))\n try {\n const newMfaSetup = await authService.setupMfa()\n setState((currentState) => ({\n ...currentState,\n isSettingUpMfa: false,\n mfaSetup: newMfaSetup,\n }))\n } catch (error) {\n setState((currentState) => ({\n ...currentState,\n isSettingUpMfa: false,\n setupError: error as Error,\n }))\n }\n }, [])\n\n const beginDisablingMfa = React.useCallback(() => {\n setState((currentState) => ({\n ...currentState,\n isDisablingMfa: true,\n }))\n }, [])\n\n const cancelDisablingMfa = React.useCallback(() => {\n setState((currentState) => ({\n ...currentState,\n isDisablingMfa: false,\n }))\n }, [])\n\n const completeDisablingMfa = React.useCallback(async () => {\n await authService.disableMfa()\n setState((currentState) => ({\n ...currentState,\n isDisablingMfa: false,\n isMfaEnabled: false,\n }))\n }, [])\n\n React.useEffect(() => {\n if (isExternalIdentityProviderUser) {\n return\n }\n\n loadMfa()\n\n return () => {}\n }, [isExternalIdentityProviderUser, loadMfa])\n\n const value = React.useMemo(() => {\n return {\n ...state,\n clearMfaSetupError,\n loadMfa,\n beginMfaSetup,\n cancelMfaSetup,\n completeMfaSetup,\n beginDisablingMfa,\n cancelDisablingMfa,\n completeDisablingMfa,\n }\n }, [\n state,\n clearMfaSetupError,\n loadMfa,\n beginMfaSetup,\n cancelMfaSetup,\n completeMfaSetup,\n beginDisablingMfa,\n cancelDisablingMfa,\n completeDisablingMfa,\n ])\n\n return <MfaContext.Provider value={value}>{children}</MfaContext.Provider>\n}\n\nexport default function useMfa() {\n return React.useContext(MfaContext)\n}\n\n/**\n * React hook to check if the logged in user meets the MFA requirement of your\n * application. Will throw an Error if used outside of the `<MfaProvider />`\n * component.\n *\n * Example\n *\n * ```js\n * import { useUserMeetsMfaRequirement } from '@oneblink/apps-react'\n *\n * const isMfaRequired = true\n *\n * function Component() {\n * const userMeetsMfaRequirement =\n * useUserMeetsMfaRequirement(isMfaRequired)\n * }\n * ```\n *\n * @returns\n * @group Hooks\n */\nexport function useUserMeetsMfaRequirement(isMfaRequired: boolean) {\n const context = React.useContext(MfaContext)\n\n if (!context) {\n throw new Error(\n `\"useUserMeetsMfaRequirement\" hook was used outside of the \"<MfaProvider />\" component's children.`,\n )\n }\n\n const { isMfaEnabled, isExternalIdentityProviderUser } = context\n if (!isMfaRequired || isExternalIdentityProviderUser) {\n return true\n }\n return isMfaEnabled\n}\n"]}
1
+ {"version":3,"file":"useMfa.js","sourceRoot":"","sources":["../../src/hooks/useMfa.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAarC,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC,aAAa,CAW3C;IACA,8BAA8B,EAAE,KAAK;IACrC,SAAS,EAAE,IAAI;IACf,YAAY,EAAE,KAAK;IACnB,cAAc,EAAE,KAAK;IACrB,cAAc,EAAE,KAAK;IACrB,aAAa,EAAE,GAAG,EAAE,GAAE,CAAC;IACvB,cAAc,EAAE,GAAG,EAAE,GAAE,CAAC;IACxB,gBAAgB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC1B,iBAAiB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC3B,kBAAkB,EAAE,GAAG,EAAE,GAAE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,GAAG,EAAE;QAC/B,OAAO;YACL,GAAG,KAAK;YACR,kBAAkB;YAClB,OAAO;YACP,aAAa;YACb,cAAc;YACd,gBAAgB;YAChB,iBAAiB;YACjB,kBAAkB;YAClB,oBAAoB;SACrB,CAAA;IACH,CAAC,EAAE;QACD,KAAK;QACL,kBAAkB;QAClB,OAAO;QACP,aAAa;QACb,cAAc;QACd,gBAAgB;QAChB,iBAAiB;QACjB,kBAAkB;QAClB,oBAAoB;KACrB,CAAC,CAAA;IAEF,OAAO,KAAC,UAAU,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAuB,CAAA;AAC5E,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,MAAM;IAC5B,OAAO,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;AACrC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,0BAA0B,CAAC,aAAsB;IAC/D,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;IAE5C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,mGAAmG,CACpG,CAAA;IACH,CAAC;IAED,MAAM,EAAE,YAAY,EAAE,8BAA8B,EAAE,GAAG,OAAO,CAAA;IAChE,IAAI,CAAC,aAAa,IAAI,8BAA8B,EAAE,CAAC;QACrD,OAAO,IAAI,CAAA;IACb,CAAC;IACD,OAAO,YAAY,CAAA;AACrB,CAAC","sourcesContent":["import * as React from 'react'\nimport { authService } from '../apps'\n\ntype MfaState = {\n isExternalIdentityProviderUser: boolean\n isLoading: boolean\n isMfaEnabled: boolean\n loadingError?: Error\n isSettingUpMfa: boolean\n isDisablingMfa: boolean\n setupError?: Error\n mfaSetup?: Awaited<ReturnType<typeof authService.setupMfa>>\n}\n\nexport const MfaContext = React.createContext<\n MfaState & {\n beginMfaSetup: () => void\n cancelMfaSetup: () => void\n completeMfaSetup: () => void\n beginDisablingMfa: () => void\n cancelDisablingMfa: () => void\n completeDisablingMfa: () => void\n clearMfaSetupError: () => void\n loadMfa: () => void\n }\n>({\n isExternalIdentityProviderUser: false,\n isLoading: true,\n isMfaEnabled: false,\n isSettingUpMfa: false,\n isDisablingMfa: false,\n beginMfaSetup: () => {},\n cancelMfaSetup: () => {},\n completeMfaSetup: () => {},\n beginDisablingMfa: () => {},\n cancelDisablingMfa: () => {},\n completeDisablingMfa: () => {},\n clearMfaSetupError: () => {},\n loadMfa: () => {},\n})\n\n/**\n * React Component that provides the context for the\n * `useUserMeetsMfaRequirement()` hook and `<MultiFactorAuthentication />`\n * component, to be used by components further down your component tree. **It\n * should only be included in your component tree once and ideally at the root\n * of the application.**\n *\n * #### Example\n *\n * ```js\n * import * as React from 'react'\n * import {\n * MfaProvider,\n * useUserMeetsMfaRequirement,\n * } from '@oneblink/apps-react'\n *\n * function Component() {\n * const { isLoading, userMeetsMfaRequirement } =\n * useUserMeetsMfaRequirement(true)\n * // use MFA Requirement details here\n * }\n *\n * function App() {\n * return (\n * <MfaProvider isExternalIdentityProviderUser={false}>\n * <Component />\n * </MfaProvider>\n * )\n * }\n *\n * const root = document.getElementById('root')\n * if (root) {\n * ReactDOM.render(<App />, root)\n * }\n * ```\n *\n * @param props\n * @returns\n * @group Components\n */\nexport function MfaProvider({\n children,\n isExternalIdentityProviderUser,\n}: {\n children: React.ReactNode\n isExternalIdentityProviderUser: boolean\n}) {\n const [state, setState] = React.useState<MfaState>({\n isExternalIdentityProviderUser,\n isLoading: !isExternalIdentityProviderUser,\n isMfaEnabled: false,\n isSettingUpMfa: false,\n isDisablingMfa: false,\n })\n\n const loadMfa = React.useCallback(async (abortSignal?: AbortSignal) => {\n setState((currentState) => ({\n ...currentState,\n isLoading: true,\n isMfaEnabled: false,\n loadingError: undefined,\n }))\n try {\n const newIsMfaEnabled = await authService.checkIsMfaEnabled()\n if (!abortSignal?.aborted) {\n setState((currentState) => ({\n ...currentState,\n isLoading: false,\n isMfaEnabled: newIsMfaEnabled,\n }))\n }\n } catch (error) {\n setState((currentState) => ({\n ...currentState,\n isLoading: false,\n loadingError: error as Error,\n }))\n }\n }, [])\n\n const clearMfaSetupError = React.useCallback(() => {\n setState((currentState) => ({\n ...currentState,\n setupError: undefined,\n }))\n }, [])\n\n const cancelMfaSetup = React.useCallback(() => {\n setState((currentState) => ({\n ...currentState,\n mfaSetup: undefined,\n }))\n }, [])\n\n const completeMfaSetup = React.useCallback(() => {\n setState((currentState) => ({\n ...currentState,\n isMfaEnabled: true,\n mfaSetup: undefined,\n }))\n }, [])\n\n const beginMfaSetup = React.useCallback(async () => {\n setState((currentState) => ({\n ...currentState,\n isSettingUpMfa: true,\n mfaSetup: undefined,\n setupError: undefined,\n }))\n try {\n const newMfaSetup = await authService.setupMfa()\n setState((currentState) => ({\n ...currentState,\n isSettingUpMfa: false,\n mfaSetup: newMfaSetup,\n }))\n } catch (error) {\n setState((currentState) => ({\n ...currentState,\n isSettingUpMfa: false,\n setupError: error as Error,\n }))\n }\n }, [])\n\n const beginDisablingMfa = React.useCallback(() => {\n setState((currentState) => ({\n ...currentState,\n isDisablingMfa: true,\n }))\n }, [])\n\n const cancelDisablingMfa = React.useCallback(() => {\n setState((currentState) => ({\n ...currentState,\n isDisablingMfa: false,\n }))\n }, [])\n\n const completeDisablingMfa = React.useCallback(async () => {\n await authService.disableMfa()\n setState((currentState) => ({\n ...currentState,\n isDisablingMfa: false,\n isMfaEnabled: false,\n }))\n }, [])\n\n React.useEffect(() => {\n if (isExternalIdentityProviderUser) {\n return\n }\n\n loadMfa()\n\n return () => {}\n }, [isExternalIdentityProviderUser, loadMfa])\n\n const value = React.useMemo(() => {\n return {\n ...state,\n clearMfaSetupError,\n loadMfa,\n beginMfaSetup,\n cancelMfaSetup,\n completeMfaSetup,\n beginDisablingMfa,\n cancelDisablingMfa,\n completeDisablingMfa,\n }\n }, [\n state,\n clearMfaSetupError,\n loadMfa,\n beginMfaSetup,\n cancelMfaSetup,\n completeMfaSetup,\n beginDisablingMfa,\n cancelDisablingMfa,\n completeDisablingMfa,\n ])\n\n return <MfaContext.Provider value={value}>{children}</MfaContext.Provider>\n}\n\nexport default function useMfa() {\n return React.useContext(MfaContext)\n}\n\n/**\n * React hook to check if the logged in user meets the MFA requirement of your\n * application. Will throw an Error if used outside of the `<MfaProvider />`\n * component.\n *\n * Example\n *\n * ```js\n * import { useUserMeetsMfaRequirement } from '@oneblink/apps-react'\n *\n * const isMfaRequired = true\n *\n * function Component() {\n * const userMeetsMfaRequirement =\n * useUserMeetsMfaRequirement(isMfaRequired)\n * }\n * ```\n *\n * @returns\n * @group Hooks\n */\nexport function useUserMeetsMfaRequirement(isMfaRequired: boolean) {\n const context = React.useContext(MfaContext)\n\n if (!context) {\n throw new Error(\n `\"useUserMeetsMfaRequirement\" hook was used outside of the \"<MfaProvider />\" component's children.`,\n )\n }\n\n const { isMfaEnabled, isExternalIdentityProviderUser } = context\n if (!isMfaRequired || isExternalIdentityProviderUser) {\n return true\n }\n return isMfaEnabled\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  import * as React from 'react';
2
- import { attachmentsService } from '@oneblink/apps';
2
+ import { attachmentsService } from '../apps';
3
3
  export declare const OnUploadAttachmentContext: React.Context<typeof attachmentsService.uploadAttachment | undefined>;
4
4
  export default function useOnUploadAttachmentContext(): typeof attachmentsService.uploadAttachment;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { attachmentsService } from '@oneblink/apps';
2
+ import { attachmentsService } from '../apps';
3
3
  export const OnUploadAttachmentContext = React.createContext(undefined);
4
4
  export default function useOnUploadAttachmentContext() {
5
5
  return (React.useContext(OnUploadAttachmentContext) ||
@@ -1 +1 @@
1
- {"version":3,"file":"useOnUploadAttachment.js","sourceRoot":"","sources":["../../src/hooks/useOnUploadAttachment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAEnD,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAK,CAAC,aAAa,CAE1D,SAAS,CAAC,CAAA;AAEZ,MAAM,CAAC,OAAO,UAAU,4BAA4B;IAClD,OAAO,CACL,KAAK,CAAC,UAAU,CAAC,yBAAyB,CAAC;QAC3C,kBAAkB,CAAC,gBAAgB,CACpC,CAAA;AACH,CAAC","sourcesContent":["import * as React from 'react'\nimport { attachmentsService } from '@oneblink/apps'\n\nexport const OnUploadAttachmentContext = React.createContext<\n typeof attachmentsService.uploadAttachment | undefined\n>(undefined)\n\nexport default function useOnUploadAttachmentContext() {\n return (\n React.useContext(OnUploadAttachmentContext) ||\n attachmentsService.uploadAttachment\n )\n}\n"]}
1
+ {"version":3,"file":"useOnUploadAttachment.js","sourceRoot":"","sources":["../../src/hooks/useOnUploadAttachment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAE5C,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAK,CAAC,aAAa,CAE1D,SAAS,CAAC,CAAA;AAEZ,MAAM,CAAC,OAAO,UAAU,4BAA4B;IAClD,OAAO,CACL,KAAK,CAAC,UAAU,CAAC,yBAAyB,CAAC;QAC3C,kBAAkB,CAAC,gBAAgB,CACpC,CAAA;AACH,CAAC","sourcesContent":["import * as React from 'react'\nimport { attachmentsService } from '../apps'\n\nexport const OnUploadAttachmentContext = React.createContext<\n typeof attachmentsService.uploadAttachment | undefined\n>(undefined)\n\nexport default function useOnUploadAttachmentContext() {\n return (\n React.useContext(OnUploadAttachmentContext) ||\n attachmentsService.uploadAttachment\n )\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { submissionService } from '@oneblink/apps';
2
+ import { submissionService } from '../apps';
3
3
  /** The value returned from `usePendingSubmissions()` hook */
4
4
  export type PendingSubmissionsContextValue = {
5
5
  /** `true` if the pending submissions are currently loading */
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as React from 'react';
3
- import { submissionService } from '@oneblink/apps';
3
+ import { submissionService } from '../apps';
4
4
  import useBooleanState from './useBooleanState';
5
5
  import useIsMounted from './useIsMounted';
6
6
  import useIsOffline from './useIsOffline';
@@ -1 +1 @@
1
- {"version":3,"file":"usePendingSubmissions.js","sourceRoot":"","sources":["../../src/hooks/usePendingSubmissions.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAC/C,OAAO,YAAY,MAAM,gBAAgB,CAAA;AACzC,OAAO,YAAY,MAAM,gBAAgB,CAAA;AAqCzC,MAAM,YAAY,GAAG;IACnB,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,IAAI;IACf,kBAAkB,EAAE,EAAE;CACvB,CAAA;AAED,MAAM,yBAAyB,GAAG,KAAK,CAAC,aAAa,CAEnD,SAAS,CAAC,CAAA;AAEZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,UAAU,iCAAiC,CAAC,EAChD,qBAAqB,EACrB,4BAA4B,GAAG,IAAI,EACnC,QAAQ,GAiBT;IACC,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAChC,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAEhC,kEAAkE;IAClE,4DAA4D;IAC5D,MAAM,CAAC,0BAA0B,EAAE,6BAA6B,CAAC,GAC/D,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;IACnB,MAAM,uBAAuB,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QACrD,6BAA6B,CAAC,CAAC,CAAC,CAAA;IAClC,CAAC,EAAE,EAAE,CAAC,CAAA;IACN,MAAM,CACJ,2BAA2B,EAC3B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;AACd,CAAC","sourcesContent":["import * as React from 'react'\nimport { submissionService } from '@oneblink/apps'\nimport useBooleanState from './useBooleanState'\nimport useIsMounted from './useIsMounted'\nimport useIsOffline from './useIsOffline'\n\n/** The value returned from `usePendingSubmissions()` hook */\nexport type PendingSubmissionsContextValue = {\n /** `true` if the pending submissions are currently loading */\n isLoading: boolean\n /** An Error object if loading pending submissions fails */\n loadError: Error | null\n /**\n * The submissions that were submitted offline and can be processed when back\n * online\n */\n pendingSubmissions: submissionService.PendingFormSubmission[]\n /** `true` submissions that where submitted offline are being processed */\n isProcessingPendingQueue: boolean\n /** A function to trigger processing of the pending queue */\n processPendingQueue: () => unknown\n /**\n * A function to trigger loading of the submissions that were submitted\n * offline\n */\n reloadPendingSubmissions: () => unknown\n /** A function to remove a submission from the pending submissions */\n deletePendingSubmission: (pendingTimestamp: string) => unknown\n /** `true` if a submission being processed fails */\n isShowingFailedNotification: boolean\n /** A function to hide the notification when a submission fails to process */\n hideFailedNotification: () => unknown\n /** `true` if a submission being processed completes successfully. */\n isShowingSuccessNotification: boolean\n /**\n * A function to hide the notification after a submission completed\n * successfully\n */\n hideSuccessNotification: () => unknown\n}\n\nconst defaultState = {\n isLoading: false,\n loadError: null,\n pendingSubmissions: [],\n}\n\nconst PendingSubmissionsContext = React.createContext<\n PendingSubmissionsContextValue | undefined\n>(undefined)\n\n/**\n * React Component that provides the context for the `usePendingSubmissions()`\n * hook to be used by components further down your component tree. **It should\n * only be included in your component tree once and ideally at the root of the\n * application.**\n *\n * #### Example\n *\n * ```jsx\n * import * as React from 'react'\n * import {\n * PendingSubmissionsContextProvider,\n * usePendingSubmissions,\n * } from '@oneblink/apps-react'\n *\n * function Component() {\n * const pendingSubmissionsContext = usePendingSubmissions()\n * // use pending submissions here\n * }\n *\n * function App() {\n * return (\n * <PendingSubmissionsContextProvider\n * isPendingQueueEnabled\n * successNotificationTimeoutMs={3000}\n * >\n * <Component />\n * </PendingSubmissionsContextProvider>\n * )\n * }\n *\n * const root = document.getElementById('root')\n * if (root) {\n * ReactDOM.render(<App />, root)\n * }\n * ```\n *\n * @param props\n * @returns\n * @group Components\n */\nexport function PendingSubmissionsContextProvider({\n isPendingQueueEnabled,\n successNotificationTimeoutMs = 5000,\n children,\n}: {\n /**\n * `true` if pending queue is enabled, otherwise `false`. Can be used prevent\n * offline submissions from being processed.\n */\n isPendingQueueEnabled: boolean\n /**\n * When a submission is processed successfully the\n * `isShowingSuccessNotification` will be temporarily set to `true`, it will\n * be set back to `false` after 5 seconds. This prop will allow you to\n * customise how long to wait before hiding the notification with a\n * milliseconds value.\n */\n successNotificationTimeoutMs?: number\n /** Your application components */\n children: React.ReactNode\n}) {\n const isMounted = useIsMounted()\n const isOffline = useIsOffline()\n\n // Using a number as state so we can reset the timer used to close\n // the snack bar each time a pending queue item is processed\n const [submittedNotificationCount, setSubmittedNotificationCount] =\n React.useState(0)\n const hideSuccessNotification = React.useCallback(() => {\n setSubmittedNotificationCount(0)\n }, [])\n const [\n isShowingFailedNotification,\n showFailedNotification,\n hideFailedNotification,\n ] = useBooleanState(false)\n const [isProcessingPendingQueue, setIsProcessingPendingQueue] =\n React.useState(false)\n const [state, setState] = React.useState<{\n isLoading: boolean\n loadError: Error | null\n pendingSubmissions: submissionService.PendingFormSubmission[]\n }>(defaultState)\n\n const processPendingQueue = React.useCallback(async () => {\n if (isMounted.current) {\n setIsProcessingPendingQueue(true)\n }\n\n await submissionService.processPendingQueue({\n shouldRunExternalIdGeneration: true,\n shouldRunServerValidation: true,\n })\n\n if (isMounted.current) {\n setIsProcessingPendingQueue(false)\n }\n }, [isMounted])\n\n const reloadPendingSubmissions = React.useCallback(async () => {\n if (isMounted.current) {\n setState((currentState) => ({\n isLoading: true,\n loadError: null,\n pendingSubmissions: currentState.pendingSubmissions,\n }))\n }\n let newError = null\n let newPendingSubmissions: submissionService.PendingFormSubmission[] = []\n\n try {\n newPendingSubmissions =\n await submissionService.getPendingQueueSubmissions()\n } catch (error) {\n newError = error as Error\n }\n\n if (isMounted.current) {\n setState({\n isLoading: false,\n loadError: newError,\n pendingSubmissions: newPendingSubmissions,\n })\n }\n }, [isMounted])\n\n React.useEffect(() => {\n if (!isPendingQueueEnabled) {\n return\n }\n reloadPendingSubmissions()\n return submissionService.registerPendingQueueListener(\n (pendingSubmissions, action) => {\n switch (action) {\n case 'SUBMIT_SUCCEEDED': {\n setSubmittedNotificationCount((current) => current + 1)\n break\n }\n case 'SUBMIT_FAILED': {\n showFailedNotification()\n break\n }\n case 'SUBMIT_STARTED': {\n hideFailedNotification()\n break\n }\n // EDIT_CANCELLED is here for when beginnning edit offline and then hitting cancel while online\n // among other use cases\n case 'ADDITION':\n case 'EDIT_CANCELLED': {\n processPendingQueue()\n break\n }\n }\n setState({\n isLoading: false,\n pendingSubmissions,\n loadError: null,\n })\n },\n )\n }, [\n hideFailedNotification,\n isPendingQueueEnabled,\n processPendingQueue,\n reloadPendingSubmissions,\n showFailedNotification,\n ])\n\n React.useEffect(() => {\n if (!isOffline) {\n processPendingQueue()\n }\n }, [isOffline, processPendingQueue])\n\n React.useEffect(() => {\n if (submittedNotificationCount > 0) {\n const timeoutId = setTimeout(() => {\n hideSuccessNotification()\n }, successNotificationTimeoutMs)\n return () => {\n clearTimeout(timeoutId)\n }\n }\n }, [\n hideSuccessNotification,\n submittedNotificationCount,\n successNotificationTimeoutMs,\n ])\n\n const value = React.useMemo<PendingSubmissionsContextValue>(\n () => ({\n ...state,\n isShowingFailedNotification,\n hideFailedNotification,\n isProcessingPendingQueue,\n processPendingQueue,\n reloadPendingSubmissions,\n deletePendingSubmission: submissionService.deletePendingQueueSubmission,\n isShowingSuccessNotification: submittedNotificationCount > 0,\n hideSuccessNotification,\n }),\n [\n state,\n isShowingFailedNotification,\n hideFailedNotification,\n isProcessingPendingQueue,\n processPendingQueue,\n reloadPendingSubmissions,\n submittedNotificationCount,\n hideSuccessNotification,\n ],\n )\n\n return (\n <PendingSubmissionsContext.Provider value={value}>\n {children}\n </PendingSubmissionsContext.Provider>\n )\n}\n\n/**\n * React hook to get the context value for Pending Submissions. Will throw an\n * Error if used outside of the `<PendingSubmissionsContextProvider />`\n * component.\n *\n * @returns\n * @group Hooks\n */\nexport default function usePendingSubmissions(): PendingSubmissionsContextValue {\n const value = React.useContext(PendingSubmissionsContext)\n if (!value) {\n throw new Error(\n `\"usePendingSubmissions\" hook was used outside of the \"<PendingSubmissionsContextProvider />\" component's children.`,\n )\n }\n return value\n}\n"]}
1
+ {"version":3,"file":"usePendingSubmissions.js","sourceRoot":"","sources":["../../src/hooks/usePendingSubmissions.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAC/C,OAAO,YAAY,MAAM,gBAAgB,CAAA;AACzC,OAAO,YAAY,MAAM,gBAAgB,CAAA;AAqCzC,MAAM,YAAY,GAAG;IACnB,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,IAAI;IACf,kBAAkB,EAAE,EAAE;CACvB,CAAA;AAED,MAAM,yBAAyB,GAAG,KAAK,CAAC,aAAa,CAEnD,SAAS,CAAC,CAAA;AAEZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,UAAU,iCAAiC,CAAC,EAChD,qBAAqB,EACrB,4BAA4B,GAAG,IAAI,EACnC,QAAQ,GAiBT;IACC,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAChC,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAEhC,kEAAkE;IAClE,4DAA4D;IAC5D,MAAM,CAAC,0BAA0B,EAAE,6BAA6B,CAAC,GAC/D,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;IACnB,MAAM,uBAAuB,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QACrD,6BAA6B,CAAC,CAAC,CAAC,CAAA;IA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,KAAK,CACb,oHAAoH,CACrH,CAAA;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import * as React from 'react'\nimport { submissionService } from '../apps'\nimport useBooleanState from './useBooleanState'\nimport useIsMounted from './useIsMounted'\nimport useIsOffline from './useIsOffline'\n\n/** The value returned from `usePendingSubmissions()` hook */\nexport type PendingSubmissionsContextValue = {\n /** `true` if the pending submissions are currently loading */\n isLoading: boolean\n /** An Error object if loading pending submissions fails */\n loadError: Error | null\n /**\n * The submissions that were submitted offline and can be processed when back\n * online\n */\n pendingSubmissions: submissionService.PendingFormSubmission[]\n /** `true` submissions that where submitted offline are being processed */\n isProcessingPendingQueue: boolean\n /** A function to trigger processing of the pending queue */\n processPendingQueue: () => unknown\n /**\n * A function to trigger loading of the submissions that were submitted\n * offline\n */\n reloadPendingSubmissions: () => unknown\n /** A function to remove a submission from the pending submissions */\n deletePendingSubmission: (pendingTimestamp: string) => unknown\n /** `true` if a submission being processed fails */\n isShowingFailedNotification: boolean\n /** A function to hide the notification when a submission fails to process */\n hideFailedNotification: () => unknown\n /** `true` if a submission being processed completes successfully. */\n isShowingSuccessNotification: boolean\n /**\n * A function to hide the notification after a submission completed\n * successfully\n */\n hideSuccessNotification: () => unknown\n}\n\nconst defaultState = {\n isLoading: false,\n loadError: null,\n pendingSubmissions: [],\n}\n\nconst PendingSubmissionsContext = React.createContext<\n PendingSubmissionsContextValue | undefined\n>(undefined)\n\n/**\n * React Component that provides the context for the `usePendingSubmissions()`\n * hook to be used by components further down your component tree. **It should\n * only be included in your component tree once and ideally at the root of the\n * application.**\n *\n * #### Example\n *\n * ```jsx\n * import * as React from 'react'\n * import {\n * PendingSubmissionsContextProvider,\n * usePendingSubmissions,\n * } from '@oneblink/apps-react'\n *\n * function Component() {\n * const pendingSubmissionsContext = usePendingSubmissions()\n * // use pending submissions here\n * }\n *\n * function App() {\n * return (\n * <PendingSubmissionsContextProvider\n * isPendingQueueEnabled\n * successNotificationTimeoutMs={3000}\n * >\n * <Component />\n * </PendingSubmissionsContextProvider>\n * )\n * }\n *\n * const root = document.getElementById('root')\n * if (root) {\n * ReactDOM.render(<App />, root)\n * }\n * ```\n *\n * @param props\n * @returns\n * @group Components\n */\nexport function PendingSubmissionsContextProvider({\n isPendingQueueEnabled,\n successNotificationTimeoutMs = 5000,\n children,\n}: {\n /**\n * `true` if pending queue is enabled, otherwise `false`. Can be used prevent\n * offline submissions from being processed.\n */\n isPendingQueueEnabled: boolean\n /**\n * When a submission is processed successfully the\n * `isShowingSuccessNotification` will be temporarily set to `true`, it will\n * be set back to `false` after 5 seconds. This prop will allow you to\n * customise how long to wait before hiding the notification with a\n * milliseconds value.\n */\n successNotificationTimeoutMs?: number\n /** Your application components */\n children: React.ReactNode\n}) {\n const isMounted = useIsMounted()\n const isOffline = useIsOffline()\n\n // Using a number as state so we can reset the timer used to close\n // the snack bar each time a pending queue item is processed\n const [submittedNotificationCount, setSubmittedNotificationCount] =\n React.useState(0)\n const hideSuccessNotification = React.useCallback(() => {\n setSubmittedNotificationCount(0)\n }, [])\n const [\n isShowingFailedNotification,\n showFailedNotification,\n hideFailedNotification,\n ] = useBooleanState(false)\n const [isProcessingPendingQueue, setIsProcessingPendingQueue] =\n React.useState(false)\n const [state, setState] = React.useState<{\n isLoading: boolean\n loadError: Error | null\n pendingSubmissions: submissionService.PendingFormSubmission[]\n }>(defaultState)\n\n const processPendingQueue = React.useCallback(async () => {\n if (isMounted.current) {\n setIsProcessingPendingQueue(true)\n }\n\n await submissionService.processPendingQueue({\n shouldRunExternalIdGeneration: true,\n shouldRunServerValidation: true,\n })\n\n if (isMounted.current) {\n setIsProcessingPendingQueue(false)\n }\n }, [isMounted])\n\n const reloadPendingSubmissions = React.useCallback(async () => {\n if (isMounted.current) {\n setState((currentState) => ({\n isLoading: true,\n loadError: null,\n pendingSubmissions: currentState.pendingSubmissions,\n }))\n }\n let newError = null\n let newPendingSubmissions: submissionService.PendingFormSubmission[] = []\n\n try {\n newPendingSubmissions =\n await submissionService.getPendingQueueSubmissions()\n } catch (error) {\n newError = error as Error\n }\n\n if (isMounted.current) {\n setState({\n isLoading: false,\n loadError: newError,\n pendingSubmissions: newPendingSubmissions,\n })\n }\n }, [isMounted])\n\n React.useEffect(() => {\n if (!isPendingQueueEnabled) {\n return\n }\n reloadPendingSubmissions()\n return submissionService.registerPendingQueueListener(\n (pendingSubmissions, action) => {\n switch (action) {\n case 'SUBMIT_SUCCEEDED': {\n setSubmittedNotificationCount((current) => current + 1)\n break\n }\n case 'SUBMIT_FAILED': {\n showFailedNotification()\n break\n }\n case 'SUBMIT_STARTED': {\n hideFailedNotification()\n break\n }\n // EDIT_CANCELLED is here for when beginnning edit offline and then hitting cancel while online\n // among other use cases\n case 'ADDITION':\n case 'EDIT_CANCELLED': {\n processPendingQueue()\n break\n }\n }\n setState({\n isLoading: false,\n pendingSubmissions,\n loadError: null,\n })\n },\n )\n }, [\n hideFailedNotification,\n isPendingQueueEnabled,\n processPendingQueue,\n reloadPendingSubmissions,\n showFailedNotification,\n ])\n\n React.useEffect(() => {\n if (!isOffline) {\n processPendingQueue()\n }\n }, [isOffline, processPendingQueue])\n\n React.useEffect(() => {\n if (submittedNotificationCount > 0) {\n const timeoutId = setTimeout(() => {\n hideSuccessNotification()\n }, successNotificationTimeoutMs)\n return () => {\n clearTimeout(timeoutId)\n }\n }\n }, [\n hideSuccessNotification,\n submittedNotificationCount,\n successNotificationTimeoutMs,\n ])\n\n const value = React.useMemo<PendingSubmissionsContextValue>(\n () => ({\n ...state,\n isShowingFailedNotification,\n hideFailedNotification,\n isProcessingPendingQueue,\n processPendingQueue,\n reloadPendingSubmissions,\n deletePendingSubmission: submissionService.deletePendingQueueSubmission,\n isShowingSuccessNotification: submittedNotificationCount > 0,\n hideSuccessNotification,\n }),\n [\n state,\n isShowingFailedNotification,\n hideFailedNotification,\n isProcessingPendingQueue,\n processPendingQueue,\n reloadPendingSubmissions,\n submittedNotificationCount,\n hideSuccessNotification,\n ],\n )\n\n return (\n <PendingSubmissionsContext.Provider value={value}>\n {children}\n </PendingSubmissionsContext.Provider>\n )\n}\n\n/**\n * React hook to get the context value for Pending Submissions. Will throw an\n * Error if used outside of the `<PendingSubmissionsContextProvider />`\n * component.\n *\n * @returns\n * @group Hooks\n */\nexport default function usePendingSubmissions(): PendingSubmissionsContextValue {\n const value = React.useContext(PendingSubmissionsContext)\n if (!value) {\n throw new Error(\n `\"usePendingSubmissions\" hook was used outside of the \"<PendingSubmissionsContextProvider />\" component's children.`,\n )\n }\n return value\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { localisationService } from '@oneblink/apps';
1
+ import { localisationService } from '../apps';
2
2
  import { useMemo } from 'react';
3
3
  import useFormSubmissionModel from './useFormSubmissionModelContext';
4
4
  import { useRepeatableSetIndexText } from '../form-elements/FormElementRepeatableSet';
@@ -1 +1 @@
1
- {"version":3,"file":"useReplaceableText.js","sourceRoot":"","sources":["../../src/hooks/useReplaceableText.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,sBAAsB,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAA;AACrF,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAC7C,OAAO,4BAA4B,MAAM,gCAAgC,CAAA;AAEzE,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,IAAY;IACrD,MAAM,aAAa,GAAG,yBAAyB,CAAC,IAAI,CAAC,CAAA;IACrD,MAAM,EAAE,mBAAmB,EAAE,QAAQ,EAAE,GAAG,sBAAsB,EAAE,CAAA;IAClE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,iBAAiB,EAAE,GAAG,cAAc,EAAE,CAAA;IAE/D,MAAM,WAAW,GAAG,4BAA4B,EAAE,CAAA;IAElD,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,OAAO,mBAAmB,CAAC,mCAAmC,CAC5D,aAAa,EACb;YACE,UAAU,EAAE,mBAAmB;YAC/B,YAAY,EAAE,QAAQ;YACtB,WAAW;YACX,IAAI;YACJ,SAAS;YACT,iBAAiB;SAClB,CACF,CAAC,IAAI,CAAA;IACR,CAAC,EAAE;QACD,QAAQ;QACR,mBAAmB;QACnB,IAAI;QACJ,SAAS;QACT,iBAAiB;QACjB,aAAa;QACb,WAAW;KACZ,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { localisationService } from '@oneblink/apps'\nimport { useMemo } from 'react'\nimport useFormSubmissionModel from './useFormSubmissionModelContext'\nimport { useRepeatableSetIndexText } from '../form-elements/FormElementRepeatableSet'\nimport useTaskContext from './useTaskContext'\nimport useUserProfileForInjectables from './useUserProfileForInjectables'\n\nexport default function useReplaceableText(text: string) {\n const textWithIndex = useRepeatableSetIndexText(text)\n const { formSubmissionModel, elements } = useFormSubmissionModel()\n const { task, taskGroup, taskGroupInstance } = useTaskContext()\n\n const userProfile = useUserProfileForInjectables()\n\n return useMemo(() => {\n return localisationService.replaceInjectablesWithElementValues(\n textWithIndex,\n {\n submission: formSubmissionModel,\n formElements: elements,\n userProfile,\n task,\n taskGroup,\n taskGroupInstance,\n },\n ).text\n }, [\n elements,\n formSubmissionModel,\n task,\n taskGroup,\n taskGroupInstance,\n textWithIndex,\n userProfile,\n ])\n}\n"]}
1
+ {"version":3,"file":"useReplaceableText.js","sourceRoot":"","sources":["../../src/hooks/useReplaceableText.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,sBAAsB,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAA;AACrF,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAC7C,OAAO,4BAA4B,MAAM,gCAAgC,CAAA;AAEzE,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,IAAY;IACrD,MAAM,aAAa,GAAG,yBAAyB,CAAC,IAAI,CAAC,CAAA;IACrD,MAAM,EAAE,mBAAmB,EAAE,QAAQ,EAAE,GAAG,sBAAsB,EAAE,CAAA;IAClE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,iBAAiB,EAAE,GAAG,cAAc,EAAE,CAAA;IAE/D,MAAM,WAAW,GAAG,4BAA4B,EAAE,CAAA;IAElD,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,OAAO,mBAAmB,CAAC,mCAAmC,CAC5D,aAAa,EACb;YACE,UAAU,EAAE,mBAAmB;YAC/B,YAAY,EAAE,QAAQ;YACtB,WAAW;YACX,IAAI;YACJ,SAAS;YACT,iBAAiB;SAClB,CACF,CAAC,IAAI,CAAA;IACR,CAAC,EAAE;QACD,QAAQ;QACR,mBAAmB;QACnB,IAAI;QACJ,SAAS;QACT,iBAAiB;QACjB,aAAa;QACb,WAAW;KACZ,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { localisationService } from '../apps'\nimport { useMemo } from 'react'\nimport useFormSubmissionModel from './useFormSubmissionModelContext'\nimport { useRepeatableSetIndexText } from '../form-elements/FormElementRepeatableSet'\nimport useTaskContext from './useTaskContext'\nimport useUserProfileForInjectables from './useUserProfileForInjectables'\n\nexport default function useReplaceableText(text: string) {\n const textWithIndex = useRepeatableSetIndexText(text)\n const { formSubmissionModel, elements } = useFormSubmissionModel()\n const { task, taskGroup, taskGroupInstance } = useTaskContext()\n\n const userProfile = useUserProfileForInjectables()\n\n return useMemo(() => {\n return localisationService.replaceInjectablesWithElementValues(\n textWithIndex,\n {\n submission: formSubmissionModel,\n formElements: elements,\n userProfile,\n task,\n taskGroup,\n taskGroupInstance,\n },\n ).text\n }, [\n elements,\n formSubmissionModel,\n task,\n taskGroup,\n taskGroupInstance,\n textWithIndex,\n userProfile,\n ])\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { authService, Sentry } from '@oneblink/apps';
2
+ import { authService, Sentry } from '../apps';
3
3
  /**
4
4
  * @param options
5
5
  * @returns
@@ -1 +1 @@
1
- {"version":3,"file":"useSignUp.js","sourceRoot":"","sources":["../../src/hooks/useSignUp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEpD;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,UAAU,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,SAAS,EACT,OAAO,GAQR;IACC,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAC5C,qIAAqI;QACrI,OAAO;YACL,SAAS,EAAE,CAAC,QAAQ,CAAC,KAAK,CACxB,sEAAsE,CACvE;SACF,CAAA;IACH,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAA;IAEd,MAAM,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,EAAE,cAAc,CAAC,GAClE,KAAK,CAAC,QAAQ,CAIX;QACD,WAAW,EAAE,KAAK;QAClB,WAAW,EAAE,IAAI;QACjB,cAAc,EAAE,KAAK;KACtB,CAAC,CAAA;IAEJ,MAAM,gBAAgB,GAAG,KAAK,CAAC,WAAW,CACxC,GAAG,EAAE,CACH,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAC3B,GAAG,OAAO;QACV,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC,EACL,EAAE,CACH,CAAA;IAED,MAAM,qBAAqB,GAAG,KAAK,CAAC,WAAW,CAAC,KAAK,IAAI,EAAE;QACzD,IAAI,kBAAkB,CAAC,SAAS,EAAE,CAAC;YACjC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;gBAC3B,GAAG,OAAO;gBACV,WAAW,EAAE,IAAI,KAAK,CAAC,oCAAoC,CAAC;aAC7D,CAAC,CAAC,CAAA;YACH,OAAM;QACR,CAAC;QAED,cAAc,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;YAChC,GAAG,YAAY;YACf,WAAW,EAAE,IAAI;YACjB,WAAW,EAAE,IAAI;SAClB,CAAC,CAAC,CAAA;QAEH,IAAI,CAAC;YACH,MAAM,WAAW,CAAC,MAAM,CAAC;gBACvB,UAAU;gBACV,KAAK,EAAE,QAAQ;gBACf,SAAS;gBACT,QAAQ;aACT,CAAC,CAAA;YAEF,cAAc,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;gBAChC,GAAG,YAAY;gBACf,WAAW,EAAE,KAAK;gBAClB,cAAc,EAAE,IAAI;aACrB,CAAC,CAAC,CAAA;YACH,SAAS,aAAT,SAAS,uBAAT,SAAS,EAAI,CAAA;QACf,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;YAC9B,cAAc,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;gBAChC,GAAG,YAAY;gBACf,WAAW,EAAE,KAAK;gBAClB,WAAW,EAAE,KAAc;aAC5B,CAAC,CAAC,CAAA;YACH,OAAO,aAAP,OAAO,uBAAP,OAAO,EAAI,CAAA;QACb,CAAC;IACH,CAAC,EAAE;QACD,SAAS;QACT,UAAU;QACV,QAAQ;QACR,OAAO;QACP,SAAS;QACT,QAAQ;QACR,kBAAkB,CAAC,SAAS;KAC7B,CAAC,CAAA;IAEF,OAAO;QACL,qBAAqB;QACrB,gBAAgB;QAChB,WAAW;QACX,WAAW;QACX,cAAc;QACd,kBAAkB;KACnB,CAAA;AACH,CAAC","sourcesContent":["import * as React from 'react'\nimport { authService, Sentry } from '@oneblink/apps'\n\n/**\n * @param options\n * @returns\n * @group Hooks\n */\nexport default function useSignUp({\n formsAppId,\n username,\n firstName,\n lastName,\n onSuccess,\n onError,\n}: {\n formsAppId: number\n username: string\n firstName?: string\n lastName?: string\n onSuccess?: () => void\n onError?: () => void\n}) {\n const usernameValidation = React.useMemo(() => {\n // regex source: https://www.w3resource.com/javascript/form/email-validation.php#:~:text=To%20get%20a%20valid%20email,%5D%2B)*%24%2F.\n return {\n isInvalid: !username.match(\n /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$/,\n ),\n }\n }, [username])\n\n const [{ isSigningUp, signUpError, signUpComplete }, setSignUpState] =\n React.useState<{\n isSigningUp: boolean\n signUpError: Error | null\n signUpComplete: boolean\n }>({\n isSigningUp: false,\n signUpError: null,\n signUpComplete: false,\n })\n\n const clearSignUpError = React.useCallback(\n () =>\n setSignUpState((current) => ({\n ...current,\n signUpError: null,\n })),\n [],\n )\n\n const signUpWithUserDetails = React.useCallback(async () => {\n if (usernameValidation.isInvalid) {\n setSignUpState((current) => ({\n ...current,\n signUpError: new Error('Please enter a valid email address'),\n }))\n return\n }\n\n setSignUpState((currentState) => ({\n ...currentState,\n isSigningUp: true,\n signUpError: null,\n }))\n\n try {\n await authService.signUp({\n formsAppId,\n email: username,\n firstName,\n lastName,\n })\n\n setSignUpState((currentState) => ({\n ...currentState,\n isSigningUp: false,\n signUpComplete: true,\n }))\n onSuccess?.()\n } catch (error) {\n Sentry.captureException(error)\n setSignUpState((currentState) => ({\n ...currentState,\n isSigningUp: false,\n signUpError: error as Error,\n }))\n onError?.()\n }\n }, [\n firstName,\n formsAppId,\n lastName,\n onError,\n onSuccess,\n username,\n usernameValidation.isInvalid,\n ])\n\n return {\n signUpWithUserDetails,\n clearSignUpError,\n isSigningUp,\n signUpError,\n signUpComplete,\n usernameValidation,\n }\n}\n"]}
1
+ {"version":3,"file":"useSignUp.js","sourceRoot":"","sources":["../../src/hooks/useSignUp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAA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C;YACH,MAAM,WAAW,CAAC,MAAM,CAAC;gBACvB,UAAU;gBACV,KAAK,EAAE,QAAQ;gBACf,SAAS;gBACT,QAAQ;aACT,CAAC,CAAA;YAEF,cAAc,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;gBAChC,GAAG,YAAY;gBACf,WAAW,EAAE,KAAK;gBAClB,cAAc,EAAE,IAAI;aACrB,CAAC,CAAC,CAAA;YACH,SAAS,aAAT,SAAS,uBAAT,SAAS,EAAI,CAAA;QACf,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;YAC9B,cAAc,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;gBAChC,GAAG,YAAY;gBACf,WAAW,EAAE,KAAK;gBAClB,WAAW,EAAE,KAAc;aAC5B,CAAC,CAAC,CAAA;YACH,OAAO,aAAP,OAAO,uBAAP,OAAO,EAAI,CAAA;QACb,CAAC;IACH,CAAC,EAAE;QACD,SAAS;QACT,UAAU;QACV,QAAQ;QACR,OAAO;QACP,SAAS;QACT,QAAQ;QACR,kBAAkB,CAAC,SAAS;KAC7B,CAAC,CAAA;IAEF,OAAO;QACL,qBAAqB;QACrB,gBAAgB;QAChB,WAAW;QACX,WAAW;QACX,cAAc;QACd,kBAAkB;KACnB,CAAA;AACH,CAAC","sourcesContent":["import * as React from 'react'\nimport { authService, Sentry } from '../apps'\n\n/**\n * @param options\n * @returns\n * @group Hooks\n */\nexport default function useSignUp({\n formsAppId,\n username,\n firstName,\n lastName,\n onSuccess,\n onError,\n}: {\n formsAppId: number\n username: string\n firstName?: string\n lastName?: string\n onSuccess?: () => void\n onError?: () => void\n}) {\n const usernameValidation = React.useMemo(() => {\n // regex source: https://www.w3resource.com/javascript/form/email-validation.php#:~:text=To%20get%20a%20valid%20email,%5D%2B)*%24%2F.\n return {\n isInvalid: !username.match(\n /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$/,\n ),\n }\n }, [username])\n\n const [{ isSigningUp, signUpError, signUpComplete }, setSignUpState] =\n React.useState<{\n isSigningUp: boolean\n signUpError: Error | null\n signUpComplete: boolean\n }>({\n isSigningUp: false,\n signUpError: null,\n signUpComplete: false,\n })\n\n const clearSignUpError = React.useCallback(\n () =>\n setSignUpState((current) => ({\n ...current,\n signUpError: null,\n })),\n [],\n )\n\n const signUpWithUserDetails = React.useCallback(async () => {\n if (usernameValidation.isInvalid) {\n setSignUpState((current) => ({\n ...current,\n signUpError: new Error('Please enter a valid email address'),\n }))\n return\n }\n\n setSignUpState((currentState) => ({\n ...currentState,\n isSigningUp: true,\n signUpError: null,\n }))\n\n try {\n await authService.signUp({\n formsAppId,\n email: username,\n firstName,\n lastName,\n })\n\n setSignUpState((currentState) => ({\n ...currentState,\n isSigningUp: false,\n signUpComplete: true,\n }))\n onSuccess?.()\n } catch (error) {\n Sentry.captureException(error)\n setSignUpState((currentState) => ({\n ...currentState,\n isSigningUp: false,\n signUpError: error as Error,\n }))\n onError?.()\n }\n }, [\n firstName,\n formsAppId,\n lastName,\n onError,\n onSuccess,\n username,\n usernameValidation.isInvalid,\n ])\n\n return {\n signUpWithUserDetails,\n clearSignUpError,\n isSigningUp,\n signUpError,\n signUpComplete,\n usernameValidation,\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { FormTypes } from '@oneblink/types';
2
- import { attachmentsService } from '@oneblink/apps';
2
+ import { attachmentsService } from '../apps';
3
3
  export declare function generateErrorAttachment(blob: Blob | undefined, fileName: string, element: FormTypes.FormElementBinaryStorage, errorMessage: string, errorType?: attachmentsService.AttachmentError['errorType']): attachmentsService.AttachmentError;
4
4
  export declare function prepareNewAttachment(blob: Blob, fileName: string, element: FormTypes.FormElementBinaryStorage): attachmentsService.AttachmentNew;
5
5
  export declare function checkIfContentTypeIsImage(contentType: string): boolean;
@@ -1,4 +1,4 @@
1
- import { Sentry } from '@oneblink/apps';
1
+ import { Sentry } from '../apps';
2
2
  import { v4 as uuid } from 'uuid';
3
3
  import { blobToCanvas, getBlobOrientation } from './blob-utils';
4
4
  export function generateErrorAttachment(blob, fileName, element, errorMessage, errorType) {
@@ -1 +1 @@
1
- {"version":3,"file":"attachments.js","sourceRoot":"","sources":["../../src/services/attachments.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAsB,MAAM,gBAAgB,CAAA;AAC3D,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAE/D,MAAM,UAAU,uBAAuB,CACrC,IAAsB,EACtB,QAAgB,EAChB,OAA2C,EAC3C,YAAoB,EACpB,SAA2D;IAE3D,OAAO;QACL,GAAG,EAAE,IAAI,EAAE;QACX,IAAI,EAAE,IAAI;QACV,QAAQ;QACR,SAAS,EAAE,OAAO,CAAC,WAAW,KAAK,QAAQ;QAC3C,IAAI,EAAE,OAAO;QACb,YAAY;QACZ,SAAS;KACV,CAAA;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,IAAU,EACV,QAAgB,EAChB,OAA2C;IAE3C,OAAO;QACL,GAAG,EAAE,IAAI,EAAE;QACX,IAAI,EAAE,IAAI;QACV,QAAQ;QACR,SAAS,EAAE,OAAO,CAAC,WAAW,KAAK,QAAQ;QAC3C,IAAI,EAAE,KAAK;KACZ,CAAA;AACH,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,WAAmB;IAC3D,OAAO,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AAC5C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,KAAa,EACb,gBAAkE;IAElE,MAAM,WAAW,GAIZ,EAAE,CAAA;IAEP,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,MAAM,sBA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,GAAG,MAAM,kBAAkB,CAAC,IAAI,CAAC,CAAA;QAClD,IACE,CAAC,OAAO,WAAW,KAAK,QAAQ,IAAI,WAAW,KAAK,CAAC,CAAC;YACtD,CAAC,gBAAgB,EACjB,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAA;YACxD,OAAO,IAAI,CAAA;QACb,CAAC;QAED,OAAO,CAAC,GAAG,CACT,wEAAwE,EACxE,EAAE,WAAW,EAAE,CAChB,CAAA;QACD,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;QACpD,IAAI,gBAAgB,EAAE,CAAC;YACrB,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QAChC,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,6CAA6C,EAAE,GAAG,CAAC,CAAA;QAChE,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAA;QAC5B,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC","sourcesContent":["import { FormTypes } from '@oneblink/types'\nimport { Sentry, attachmentsService } from '@oneblink/apps'\nimport { v4 as uuid } from 'uuid'\nimport { blobToCanvas, getBlobOrientation } from './blob-utils'\n\nexport function generateErrorAttachment(\n blob: Blob | undefined,\n fileName: string,\n element: FormTypes.FormElementBinaryStorage,\n errorMessage: string,\n errorType?: attachmentsService.AttachmentError['errorType'],\n): attachmentsService.AttachmentError {\n return {\n _id: uuid(),\n data: blob,\n fileName,\n isPrivate: element.storageType !== 'public',\n type: 'ERROR',\n errorMessage,\n errorType,\n }\n}\n\nexport function prepareNewAttachment(\n blob: Blob,\n fileName: string,\n element: FormTypes.FormElementBinaryStorage,\n): attachmentsService.AttachmentNew {\n return {\n _id: uuid(),\n data: blob,\n fileName,\n isPrivate: element.storageType !== 'public',\n type: 'NEW',\n }\n}\n\nexport function checkIfContentTypeIsImage(contentType: string) {\n return contentType.indexOf('image/') === 0\n}\n\nexport async function parseFilesAsAttachmentsLegacy(\n files: File[],\n onAnnotateCanvas?: (file: File, canvas: HTMLCanvasElement) => void,\n): Promise<Array<{ data: string; fileName: string; contentType: string }>> {\n const attachments: Array<{\n data: string\n fileName: string\n contentType: string\n }> = []\n\n for (const file of files) {\n const result = await correctFileOrientation(file, onAnnotateCanvas)\n\n if (result instanceof Blob) {\n console.log('Attempting to parse File as attachment', file)\n\n const base64data = await new Promise<string>((resolve, reject) => {\n const reader = new FileReader()\n reader.onload = function () {\n resolve(reader.result as string)\n }\n reader.onerror = function () {\n reject(new Error('Could not read file from data url'))\n }\n reader.readAsDataURL(file)\n })\n\n attachments.push({\n fileName: file.name,\n contentType: file.type,\n data: base64data,\n })\n } else {\n attachments.push({\n fileName: file.name,\n contentType: file.type,\n data: result.toDataURL(),\n })\n }\n }\n\n return attachments\n}\n\nexport async function correctFileOrientation(\n file: File,\n onAnnotateCanvas?: (file: File, canvas: HTMLCanvasElement) => void,\n): Promise<Blob | HTMLCanvasElement> {\n try {\n if (!checkIfContentTypeIsImage(file.type)) {\n return file\n }\n\n console.log('Attempting to parse File as image attachment', file)\n\n const orientation = await getBlobOrientation(file)\n if (\n (typeof orientation !== 'number' || orientation === 1) &&\n !onAnnotateCanvas\n ) {\n console.log('Skipping orientation correction for image')\n return file\n }\n\n console.log(\n 'Loading image onto canvas to correct orientation using image meta data',\n { orientation },\n )\n const canvas = await blobToCanvas(file, orientation)\n if (onAnnotateCanvas) {\n onAnnotateCanvas(file, canvas)\n }\n return canvas\n } catch (err) {\n console.warn('Failed to rotate the orientation of a file:', err)\n Sentry.captureException(err)\n return file\n }\n}\n"]}
1
+ {"version":3,"file":"attachments.js","sourceRoot":"","sources":["../../src/services/attachments.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAsB,MAAM,SAAS,CAAA;AACpD,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,C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AAY,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;QACpD,IAAI,gBAAgB,EAAE,CAAC;YACrB,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QAChC,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,6CAA6C,EAAE,GAAG,CAAC,CAAA;QAChE,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAA;QAC5B,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC","sourcesContent":["import { FormTypes } from '@oneblink/types'\nimport { Sentry, attachmentsService } from '../apps'\nimport { v4 as uuid } from 'uuid'\nimport { blobToCanvas, getBlobOrientation } from './blob-utils'\n\nexport function generateErrorAttachment(\n blob: Blob | undefined,\n fileName: string,\n element: FormTypes.FormElementBinaryStorage,\n errorMessage: string,\n errorType?: attachmentsService.AttachmentError['errorType'],\n): attachmentsService.AttachmentError {\n return {\n _id: uuid(),\n data: blob,\n fileName,\n isPrivate: element.storageType !== 'public',\n type: 'ERROR',\n errorMessage,\n errorType,\n }\n}\n\nexport function prepareNewAttachment(\n blob: Blob,\n fileName: string,\n element: FormTypes.FormElementBinaryStorage,\n): attachmentsService.AttachmentNew {\n return {\n _id: uuid(),\n data: blob,\n fileName,\n isPrivate: element.storageType !== 'public',\n type: 'NEW',\n }\n}\n\nexport function checkIfContentTypeIsImage(contentType: string) {\n return contentType.indexOf('image/') === 0\n}\n\nexport async function parseFilesAsAttachmentsLegacy(\n files: File[],\n onAnnotateCanvas?: (file: File, canvas: HTMLCanvasElement) => void,\n): Promise<Array<{ data: string; fileName: string; contentType: string }>> {\n const attachments: Array<{\n data: string\n fileName: string\n contentType: string\n }> = []\n\n for (const file of files) {\n const result = await correctFileOrientation(file, onAnnotateCanvas)\n\n if (result instanceof Blob) {\n console.log('Attempting to parse File as attachment', file)\n\n const base64data = await new Promise<string>((resolve, reject) => {\n const reader = new FileReader()\n reader.onload = function () {\n resolve(reader.result as string)\n }\n reader.onerror = function () {\n reject(new Error('Could not read file from data url'))\n }\n reader.readAsDataURL(file)\n })\n\n attachments.push({\n fileName: file.name,\n contentType: file.type,\n data: base64data,\n })\n } else {\n attachments.push({\n fileName: file.name,\n contentType: file.type,\n data: result.toDataURL(),\n })\n }\n }\n\n return attachments\n}\n\nexport async function correctFileOrientation(\n file: File,\n onAnnotateCanvas?: (file: File, canvas: HTMLCanvasElement) => void,\n): Promise<Blob | HTMLCanvasElement> {\n try {\n if (!checkIfContentTypeIsImage(file.type)) {\n return file\n }\n\n console.log('Attempting to parse File as image attachment', file)\n\n const orientation = await getBlobOrientation(file)\n if (\n (typeof orientation !== 'number' || orientation === 1) &&\n !onAnnotateCanvas\n ) {\n console.log('Skipping orientation correction for image')\n return file\n }\n\n console.log(\n 'Loading image onto canvas to correct orientation using image meta data',\n { orientation },\n )\n const canvas = await blobToCanvas(file, orientation)\n if (onAnnotateCanvas) {\n onAnnotateCanvas(file, canvas)\n }\n return canvas\n } catch (err) {\n console.warn('Failed to rotate the orientation of a file:', err)\n Sentry.captureException(err)\n return file\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { authService } from '@oneblink/apps';
1
+ import { authService } from '../apps';
2
2
  import loadImage from 'blueimp-load-image';
3
3
  // Copied from https://stackoverflow.com/questions/16245767/creating-a-blob-from-a-base64-string-in-javascript
4
4
  const b64toBlob = (b64Data, contentType = '', sliceSize = 512) => {
@@ -1 +1 @@
1
- {"version":3,"file":"blob-utils.js","sourceRoot":"","sources":["../../src/services/blob-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,SAAS,MAAM,oBAAoB,CAAA;AAE1C,8GAA8G;AAC9G,MAAM,SAAS,GAAG,CAAC,OAAe,EAAE,WAAW,GAAG,EAAE,EAAE,SAAS,GAAG,GAAG,EAAE,EAAE;IACvE,MAAM,cAAc,GAAG,IAAI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,kBAAkB,CACtC,IAAU;;IAEV,MAAM,aAAa,GAAuB,MAAM,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;IAC7E,MAAM,WAAW,GAAG,MAAA,aAAa,CAAC,IAAI,0CAAE,GAAG,CAAC,aAAa,CAAC,CAAA;IAC1D,OAAO,WAAiC,CAAA;AAC1C,CAAC","sourcesContent":["import { authService } from '@oneblink/apps'\nimport loadImage from 'blueimp-load-image'\n\n// Copied from https://stackoverflow.com/questions/16245767/creating-a-blob-from-a-base64-string-in-javascript\nconst b64toBlob = (b64Data: string, contentType = '', sliceSize = 512) => {\n const byteCharacters = atob(b64Data)\n const byteArrays = []\n\n for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {\n const slice = byteCharacters.slice(offset, offset + sliceSize)\n\n const byteNumbers = new Array(slice.length)\n for (let i = 0; i < slice.length; i++) {\n byteNumbers[i] = slice.charCodeAt(i)\n }\n\n const byteArray = new Uint8Array(byteNumbers)\n byteArrays.push(byteArray)\n }\n\n const blob = new Blob(byteArrays, { type: contentType })\n return blob\n}\n\nexport function dataUriToBlobSync(dataUri: string) {\n const [prefix, b64Data] = dataUri.split(',')\n const matches = prefix.match(/data:(.*);base64/)\n const [, contentType] = matches || []\n return b64toBlob(b64Data, contentType)\n}\n\nasync function generateRequestInit(\n abortSignal?: AbortSignal,\n): Promise<RequestInit | undefined> {\n const idToken = await authService.getIdToken()\n if (idToken) {\n return {\n signal: abortSignal,\n headers: {\n Authorization: `Bearer ${idToken}`,\n },\n }\n }\n}\n\nexport async function urlToBlobAsync(url: string, abortSignal?: AbortSignal) {\n const requestInit = await generateRequestInit(abortSignal)\n const response = await fetch(url, requestInit)\n if (!response.ok) {\n throw new Error(\n `Unable to download file. HTTP Status Code: ${response.status}`,\n )\n }\n return await response.blob()\n}\n\nexport async function blobToCanvas(\n blob: Blob,\n orientation?: number,\n): Promise<HTMLCanvasElement> {\n const loadImageResult = await loadImage(blob, {\n canvas: true,\n orientation: orientation,\n })\n // @ts-expect-error this it always be a HTMLCanvasElement because we passed `canvas: true` above\n const canvas: HTMLCanvasElement = loadImageResult.image\n return canvas\n}\n\nexport async function canvasToBlob(canvas: HTMLCanvasElement) {\n const blob: Blob = await new Promise((resolve, reject) => {\n canvas.toBlob((blob) => {\n if (blob) resolve(blob)\n reject(new Error('Failed to convert canvas back to blob.'))\n })\n })\n return blob\n}\n\nexport async function getBlobOrientation(\n blob: Blob,\n): Promise<number | undefined> {\n const imageMetaData: loadImage.MetaData = await loadImage.parseMetaData(blob)\n const orientation = imageMetaData.exif?.get('Orientation')\n return orientation as number | undefined\n}\n"]}
1
+ {"version":3,"file":"blob-utils.js","sourceRoot":"","sources":["../../src/services/blob-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,SAAS,MAAM,oBAAoB,CAAA;AAE1C,8GAA8G;AAC9G,MAAM,SAAS,GAAG,CAAC,OAAe,EAAE,WAAW,GAAG,EAAE,EAAE,SAAS,GAAG,GAAG,EAAE,EAAE;IACvE,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,CAAA;IACpC,MAAM,UAAU,GAAG,EAAE,CAAA;IAErB,KAAK,IAAI,MAAM,GAAG,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC,MAAM,EAAE,MAAM,IAAI,SAAS,EAAE,CAAC;QACzE,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;QAE9D,MAAM,WAAW,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,WAAW,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;QACtC,CAAC;QAED,MAAM,SAAS,G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M,CAAC,KAAK,UAAU,YAAY,CAChC,IAAU,EACV,WAAoB;IAEpB,MAAM,eAAe,GAAG,MAAM,SAAS,CAAC,IAAI,EAAE;QAC5C,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,WAAW;KACzB,CAAC,CAAA;IACF,gGAAgG;IAChG,MAAM,MAAM,GAAsB,eAAe,CAAC,KAAK,CAAA;IACvD,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,MAAyB;IAC1D,MAAM,IAAI,GAAS,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACvD,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;YACrB,IAAI,IAAI;gBAAE,OAAO,CAAC,IAAI,CAAC,CAAA;YACvB,MAAM,CAAC,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC,CAAA;QAC7D,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IACF,OAAO,IAAI,CAAA;AACb,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,IAAU;;IAEV,MAAM,aAAa,GAAuB,MAAM,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;IAC7E,MAAM,WAAW,GAAG,MAAA,aAAa,CAAC,IAAI,0CAAE,GAAG,CAAC,aAAa,CAAC,CAAA;IAC1D,OAAO,WAAiC,CAAA;AAC1C,CAAC","sourcesContent":["import { authService } from '../apps'\nimport loadImage from 'blueimp-load-image'\n\n// Copied from https://stackoverflow.com/questions/16245767/creating-a-blob-from-a-base64-string-in-javascript\nconst b64toBlob = (b64Data: string, contentType = '', sliceSize = 512) => {\n const byteCharacters = atob(b64Data)\n const byteArrays = []\n\n for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {\n const slice = byteCharacters.slice(offset, offset + sliceSize)\n\n const byteNumbers = new Array(slice.length)\n for (let i = 0; i < slice.length; i++) {\n byteNumbers[i] = slice.charCodeAt(i)\n }\n\n const byteArray = new Uint8Array(byteNumbers)\n byteArrays.push(byteArray)\n }\n\n const blob = new Blob(byteArrays, { type: contentType })\n return blob\n}\n\nexport function dataUriToBlobSync(dataUri: string) {\n const [prefix, b64Data] = dataUri.split(',')\n const matches = prefix.match(/data:(.*);base64/)\n const [, contentType] = matches || []\n return b64toBlob(b64Data, contentType)\n}\n\nasync function generateRequestInit(\n abortSignal?: AbortSignal,\n): Promise<RequestInit | undefined> {\n const idToken = await authService.getIdToken()\n if (idToken) {\n return {\n signal: abortSignal,\n headers: {\n Authorization: `Bearer ${idToken}`,\n },\n }\n }\n}\n\nexport async function urlToBlobAsync(url: string, abortSignal?: AbortSignal) {\n const requestInit = await generateRequestInit(abortSignal)\n const response = await fetch(url, requestInit)\n if (!response.ok) {\n throw new Error(\n `Unable to download file. HTTP Status Code: ${response.status}`,\n )\n }\n return await response.blob()\n}\n\nexport async function blobToCanvas(\n blob: Blob,\n orientation?: number,\n): Promise<HTMLCanvasElement> {\n const loadImageResult = await loadImage(blob, {\n canvas: true,\n orientation: orientation,\n })\n // @ts-expect-error this it always be a HTMLCanvasElement because we passed `canvas: true` above\n const canvas: HTMLCanvasElement = loadImageResult.image\n return canvas\n}\n\nexport async function canvasToBlob(canvas: HTMLCanvasElement) {\n const blob: Blob = await new Promise((resolve, reject) => {\n canvas.toBlob((blob) => {\n if (blob) resolve(blob)\n reject(new Error('Failed to convert canvas back to blob.'))\n })\n })\n return blob\n}\n\nexport async function getBlobOrientation(\n blob: Blob,\n): Promise<number | undefined> {\n const imageMetaData: loadImage.MetaData = await loadImage.parseMetaData(blob)\n const orientation = imageMetaData.exif?.get('Orientation')\n return orientation as number | undefined\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  import { FormTypes, SubmissionTypes } from '@oneblink/types';
2
- import { attachmentsService } from '@oneblink/apps';
2
+ import { attachmentsService } from '../apps';
3
3
  export declare function validateAttachmentExists(attachment: attachmentsService.Attachment, attachmentRetentionInDays: number | undefined): attachmentsService.AttachmentError | void;
4
4
  export default function checkIfAttachmentsExist(form: FormTypes.Form, submission: SubmissionTypes.S3SubmissionData['submission'], attachmentRetentionInDays: number | undefined): SubmissionTypes.S3SubmissionData['submission'] | void;
@@ -1 +1 @@
1
- {"version":3,"file":"checkIfAttachmentsExist.js","sourceRoot":"","sources":["../../src/services/checkIfAttachmentsExist.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAA;AAKjC,MAAM,UAAU,wBAAwB,CACtC,UAAyC,EACzC,yBAA6C;IAE7C,IAAI,UAAU,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,IAAI,CAAC,yBAAyB,EAAE,CAAC;QAC5E,OAAM;IACR,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;IAClD,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;IACjD,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,yBAAyB,CAAC,CAAA;IACnE,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;IACtB,OAAO,CAAC,GAAG,CAAC,qCAAqC,EAAE;QACjD,UAAU;QACV,SAAS;QACT,UAAU;KACX,CAAC,CAAA;IACF,6BAA6B;IAC7B,IAAI,SAAS,GAAG,GAAG,EAAE,CAAC;QACpB,OAAM;IACR,CAAC;IAED,MAAM,eAAe,GAAuC;QAC1D,IAAI,EAAE,OAAO;QACb,YAAY,EACV,6HAA6H;QAC/H,GAAG,EAAE,IAAI,EAAE;QACX,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,SAAS,EAAE,UAAU,CAAC,SAAS;KAChC,CAAA;IACD,OAAO,eAAe,CAAA;AACxB,CAAC;AAED,SAAS,yBAAyB,CAChC,WAAoB,EACpB,yBAA6C;IAE7C,IAAI,CAAC,KAAK,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CAAC;wBACD,MAAK;oBACP,CAAC;oBACD,KAAK,cAAc,CAAC,CAAC,CAAC;wBACpB,MAAM,wBAAwB,GAC5B,KAA6C,CAAA;wBAC/C,MAAM,cAAc,GAAG,yBAAyB,CAC9C,wBAAwB,CAAC,cAAc,EACvC,yBAAyB,CAC1B,CAAA;wBACD,IAAI,cAAc,EAAE,CAAC;4BACnB,UAAU,GAAG,IAAI,CAAA;4BACjB,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG;gCACzB,GAAG,KAAK;gCACR,cAAc;6BACf,CAAA;wBACH,CAAC;wBACD,MAAK;oBACP,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,MAAM,CAAA;IACf,CAAC;AACH,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAC7C,IAAoB,EACpB,UAA0D,EAC1D,yBAA6C;IAE7C,OAAO,sCAAsC,CAC3C,IAAI,CAAC,QAAQ,EACb,UAAU,EACV,yBAAyB,CAC1B,CAAA;AACH,CAAC","sourcesContent":["import { ArcGISTypes, FormTypes, SubmissionTypes } from '@oneblink/types'\nimport { v4 as uuid } from 'uuid'\nimport { attachmentsService } from '@oneblink/apps'\n\nimport { Value as FormElementComplianceValue } from '../form-elements/FormElementCompliance'\n\nexport function validateAttachmentExists(\n attachment: attachmentsService.Attachment,\n attachmentRetentionInDays: number | undefined,\n): attachmentsService.AttachmentError | void {\n if (attachment.type || !attachment.uploadedAt || !attachmentRetentionInDays) {\n return\n }\n\n const uploadedAt = new Date(attachment.uploadedAt)\n const expiresAt = new Date(attachment.uploadedAt)\n expiresAt.setDate(uploadedAt.getDate() + attachmentRetentionInDays)\n const now = new Date()\n console.log('Checking if attachment still exists', {\n uploadedAt,\n expiresAt,\n attachment,\n })\n // check if attachment exists\n if (expiresAt > now) {\n return\n }\n\n const attachmentError: attachmentsService.AttachmentError = {\n type: 'ERROR',\n errorMessage:\n \"This attachment has been removed based on your administrator's data retention policy, please remove it and upload it again.\",\n _id: uuid(),\n fileName: attachment.fileName,\n isPrivate: attachment.isPrivate,\n }\n return attachmentError\n}\n\nfunction validateAttachmentsExists(\n attachments: unknown,\n attachmentRetentionInDays: number | undefined,\n): attachmentsService.Attachment[] | void {\n if (!Array.isArray(attachments)) {\n return\n }\n const newAttachments = [...attachments]\n let hasChanges = false\n for (let index = 0; index < newAttachments.length; index++) {\n const attachmentError = validateAttachmentExists(\n newAttachments[index] as attachmentsService.Attachment,\n attachmentRetentionInDays,\n )\n if (attachmentError) {\n hasChanges = true\n newAttachments[index] = attachmentError\n }\n }\n if (hasChanges) {\n return newAttachments\n }\n}\n\nfunction checkIfAttachmentsExistForFormElements(\n formElements: FormTypes.FormElement[],\n submission: SubmissionTypes.S3SubmissionData['submission'],\n attachmentRetentionInDays: number | undefined,\n): SubmissionTypes.S3SubmissionData['submission'] | void {\n const result: SubmissionTypes.S3SubmissionData['submission'] = {\n ...submission,\n }\n let hasChanges = false\n for (const formElement of formElements) {\n switch (formElement.type) {\n case 'section':\n case 'page': {\n const newSubmission = checkIfAttachmentsExistForFormElements(\n formElement.elements,\n result,\n attachmentRetentionInDays,\n )\n if (newSubmission) {\n hasChanges = true\n Object.assign(result, newSubmission)\n }\n break\n }\n case 'form': {\n const nestedSubmission = submission[formElement.name]\n if (!nestedSubmission || typeof nestedSubmission !== 'object') {\n break\n }\n const newSubmission = checkIfAttachmentsExistForFormElements(\n formElement.elements || [],\n nestedSubmission as SubmissionTypes.S3SubmissionData['submission'],\n attachmentRetentionInDays,\n )\n if (newSubmission) {\n hasChanges = true\n result[formElement.name] = newSubmission\n }\n break\n }\n case 'repeatableSet': {\n const entries = submission[formElement.name]\n if (!Array.isArray(entries)) {\n break\n }\n const newEntries = [...entries]\n let hasEntryChanges = false\n for (let index = 0; index < entries.length; index++) {\n const entry = entries[index]\n if (typeof entry === 'object') {\n const newEntry = checkIfAttachmentsExistForFormElements(\n formElement.elements,\n entry,\n attachmentRetentionInDays,\n )\n if (newEntry) {\n hasEntryChanges = true\n newEntries[index] = newEntry\n }\n }\n }\n if (hasEntryChanges) {\n hasChanges = true\n result[formElement.name] = newEntries\n }\n break\n }\n case 'arcGISWebMap':\n case 'camera':\n case 'draw':\n case 'compliance':\n case 'files': {\n const value = submission[formElement.name]\n if (!value) {\n break\n }\n\n // If the attachment has a type, it has not finished uploading\n switch (formElement.type) {\n case 'camera':\n case 'draw': {\n const attachmentError = validateAttachmentExists(\n value as attachmentsService.Attachment,\n attachmentRetentionInDays,\n )\n if (attachmentError) {\n hasChanges = true\n result[formElement.name] = attachmentError\n }\n break\n }\n case 'compliance': {\n const newAttachments = validateAttachmentsExists(\n (value as FormElementComplianceValue).files,\n attachmentRetentionInDays,\n )\n if (newAttachments) {\n hasChanges = true\n result[formElement.name] = {\n ...(value as FormElementComplianceValue),\n files: newAttachments,\n }\n }\n break\n }\n case 'files': {\n const newAttachments = validateAttachmentsExists(\n value,\n attachmentRetentionInDays,\n )\n if (newAttachments) {\n hasChanges = true\n result[formElement.name] = newAttachments\n }\n break\n }\n case 'arcGISWebMap': {\n const arcGISWebMapElementValue =\n value as ArcGISTypes.ArcGISWebMapElementValue\n const snapshotImages = validateAttachmentsExists(\n arcGISWebMapElementValue.snapshotImages,\n attachmentRetentionInDays,\n )\n if (snapshotImages) {\n hasChanges = true\n result[formElement.name] = {\n ...value,\n snapshotImages,\n }\n }\n break\n }\n }\n }\n }\n }\n if (hasChanges) {\n return result\n }\n}\n\nexport default function checkIfAttachmentsExist(\n form: FormTypes.Form,\n submission: SubmissionTypes.S3SubmissionData['submission'],\n attachmentRetentionInDays: number | undefined,\n): SubmissionTypes.S3SubmissionData['submission'] | void {\n return checkIfAttachmentsExistForFormElements(\n form.elements,\n submission,\n attachmentRetentionInDays,\n )\n}\n"]}
1
+ {"version":3,"file":"checkIfAttachmentsExist.js","sourceRoot":"","sources":["../../src/services/checkIfAttachmentsExist.ts"],"names":[],"mappings":"AACA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;4BACjB,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG;gCACzB,GAAG,KAAK;gCACR,cAAc;6BACf,CAAA;wBACH,CAAC;wBACD,MAAK;oBACP,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,MAAM,CAAA;IACf,CAAC;AACH,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAC7C,IAAoB,EACpB,UAA0D,EAC1D,yBAA6C;IAE7C,OAAO,sCAAsC,CAC3C,IAAI,CAAC,QAAQ,EACb,UAAU,EACV,yBAAyB,CAC1B,CAAA;AACH,CAAC","sourcesContent":["import { ArcGISTypes, FormTypes, SubmissionTypes } from '@oneblink/types'\nimport { v4 as uuid } from 'uuid'\nimport { attachmentsService } from '../apps'\n\nimport { Value as FormElementComplianceValue } from '../form-elements/FormElementCompliance'\n\nexport function validateAttachmentExists(\n attachment: attachmentsService.Attachment,\n attachmentRetentionInDays: number | undefined,\n): attachmentsService.AttachmentError | void {\n if (attachment.type || !attachment.uploadedAt || !attachmentRetentionInDays) {\n return\n }\n\n const uploadedAt = new Date(attachment.uploadedAt)\n const expiresAt = new Date(attachment.uploadedAt)\n expiresAt.setDate(uploadedAt.getDate() + attachmentRetentionInDays)\n const now = new Date()\n console.log('Checking if attachment still exists', {\n uploadedAt,\n expiresAt,\n attachment,\n })\n // check if attachment exists\n if (expiresAt > now) {\n return\n }\n\n const attachmentError: attachmentsService.AttachmentError = {\n type: 'ERROR',\n errorMessage:\n \"This attachment has been removed based on your administrator's data retention policy, please remove it and upload it again.\",\n _id: uuid(),\n fileName: attachment.fileName,\n isPrivate: attachment.isPrivate,\n }\n return attachmentError\n}\n\nfunction validateAttachmentsExists(\n attachments: unknown,\n attachmentRetentionInDays: number | undefined,\n): attachmentsService.Attachment[] | void {\n if (!Array.isArray(attachments)) {\n return\n }\n const newAttachments = [...attachments]\n let hasChanges = false\n for (let index = 0; index < newAttachments.length; index++) {\n const attachmentError = validateAttachmentExists(\n newAttachments[index] as attachmentsService.Attachment,\n attachmentRetentionInDays,\n )\n if (attachmentError) {\n hasChanges = true\n newAttachments[index] = attachmentError\n }\n }\n if (hasChanges) {\n return newAttachments\n }\n}\n\nfunction checkIfAttachmentsExistForFormElements(\n formElements: FormTypes.FormElement[],\n submission: SubmissionTypes.S3SubmissionData['submission'],\n attachmentRetentionInDays: number | undefined,\n): SubmissionTypes.S3SubmissionData['submission'] | void {\n const result: SubmissionTypes.S3SubmissionData['submission'] = {\n ...submission,\n }\n let hasChanges = false\n for (const formElement of formElements) {\n switch (formElement.type) {\n case 'section':\n case 'page': {\n const newSubmission = checkIfAttachmentsExistForFormElements(\n formElement.elements,\n result,\n attachmentRetentionInDays,\n )\n if (newSubmission) {\n hasChanges = true\n Object.assign(result, newSubmission)\n }\n break\n }\n case 'form': {\n const nestedSubmission = submission[formElement.name]\n if (!nestedSubmission || typeof nestedSubmission !== 'object') {\n break\n }\n const newSubmission = checkIfAttachmentsExistForFormElements(\n formElement.elements || [],\n nestedSubmission as SubmissionTypes.S3SubmissionData['submission'],\n attachmentRetentionInDays,\n )\n if (newSubmission) {\n hasChanges = true\n result[formElement.name] = newSubmission\n }\n break\n }\n case 'repeatableSet': {\n const entries = submission[formElement.name]\n if (!Array.isArray(entries)) {\n break\n }\n const newEntries = [...entries]\n let hasEntryChanges = false\n for (let index = 0; index < entries.length; index++) {\n const entry = entries[index]\n if (typeof entry === 'object') {\n const newEntry = checkIfAttachmentsExistForFormElements(\n formElement.elements,\n entry,\n attachmentRetentionInDays,\n )\n if (newEntry) {\n hasEntryChanges = true\n newEntries[index] = newEntry\n }\n }\n }\n if (hasEntryChanges) {\n hasChanges = true\n result[formElement.name] = newEntries\n }\n break\n }\n case 'arcGISWebMap':\n case 'camera':\n case 'draw':\n case 'compliance':\n case 'files': {\n const value = submission[formElement.name]\n if (!value) {\n break\n }\n\n // If the attachment has a type, it has not finished uploading\n switch (formElement.type) {\n case 'camera':\n case 'draw': {\n const attachmentError = validateAttachmentExists(\n value as attachmentsService.Attachment,\n attachmentRetentionInDays,\n )\n if (attachmentError) {\n hasChanges = true\n result[formElement.name] = attachmentError\n }\n break\n }\n case 'compliance': {\n const newAttachments = validateAttachmentsExists(\n (value as FormElementComplianceValue).files,\n attachmentRetentionInDays,\n )\n if (newAttachments) {\n hasChanges = true\n result[formElement.name] = {\n ...(value as FormElementComplianceValue),\n files: newAttachments,\n }\n }\n break\n }\n case 'files': {\n const newAttachments = validateAttachmentsExists(\n value,\n attachmentRetentionInDays,\n )\n if (newAttachments) {\n hasChanges = true\n result[formElement.name] = newAttachments\n }\n break\n }\n case 'arcGISWebMap': {\n const arcGISWebMapElementValue =\n value as ArcGISTypes.ArcGISWebMapElementValue\n const snapshotImages = validateAttachmentsExists(\n arcGISWebMapElementValue.snapshotImages,\n attachmentRetentionInDays,\n )\n if (snapshotImages) {\n hasChanges = true\n result[formElement.name] = {\n ...value,\n snapshotImages,\n }\n }\n break\n }\n }\n }\n }\n }\n if (hasChanges) {\n return result\n }\n}\n\nexport default function checkIfAttachmentsExist(\n form: FormTypes.Form,\n submission: SubmissionTypes.S3SubmissionData['submission'],\n attachmentRetentionInDays: number | undefined,\n): SubmissionTypes.S3SubmissionData['submission'] | void {\n return checkIfAttachmentsExistForFormElements(\n form.elements,\n submission,\n attachmentRetentionInDays,\n )\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { localisationService } from '@oneblink/apps';
1
+ import { localisationService } from '../apps';
2
2
  const usCoords = { latitude: 40.75764768718219, longitude: -73.98578582987093 }; //TIMES SQUARE, NY
3
3
  const auCoords = {
4
4
  latitude: -33.861146727854496,
@@ -1 +1 @@
1
- {"version":3,"file":"defaultCoordinates.js","sourceRoot":"","sources":["../../src/services/defaultCoordinates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,QAAQ,GAAG,EAAE,QAAQ,EAAE,iBAAiB,EAAE,SAAS,EAAE,CAAC,iBAAiB,EAAE,CAAA,CAAC,kBAAkB;AAClG,MAAM,QAAQ,GAAG;IACf,QAAQ,EAAE,CAAC,kBAAkB;IAC7B,SAAS,EAAE,kBAAkB;CAC9B,CAAA,CAAC,uBAAuB;AACzB,MAAM,MAAM,GAAG,GAAG,EAAE,CAClB,mBAAmB,CAAC,SAAS,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAA;AAEnE,eAAe,MAAM,CAAA","sourcesContent":["import { localisationService } from '@oneblink/apps'\n\nconst usCoords = { latitude: 40.75764768718219, longitude: -73.98578582987093 } //TIMES SQUARE, NY\nconst auCoords = {\n latitude: -33.861146727854496,\n longitude: 151.20863228242192,\n} //CIRCULAR QUAY, SYDNEY\nconst coords = () =>\n localisationService.getLocale() === 'en-US' ? usCoords : auCoords\n\nexport default coords\n"]}
1
+ {"version":3,"file":"defaultCoordinates.js","sourceRoot":"","sources":["../../src/services/defaultCoordinates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAE7C,MAAM,QAAQ,GAAG,EAAE,QAAQ,EAAE,iBAAiB,EAAE,SAAS,EAAE,CAAC,iBAAiB,EAAE,CAAA,CAAC,kBAAkB;AAClG,MAAM,QAAQ,GAAG;IACf,QAAQ,EAAE,CAAC,kBAAkB;IAC7B,SAAS,EAAE,kBAAkB;CAC9B,CAAA,CAAC,uBAAuB;AACzB,MAAM,MAAM,GAAG,GAAG,EAAE,CAClB,mBAAmB,CAAC,SAAS,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAA;AAEnE,eAAe,MAAM,CAAA","sourcesContent":["import { localisationService } from '../apps'\n\nconst usCoords = { latitude: 40.75764768718219, longitude: -73.98578582987093 } //TIMES SQUARE, NY\nconst auCoords = {\n latitude: -33.861146727854496,\n longitude: 151.20863228242192,\n} //CIRCULAR QUAY, SYDNEY\nconst coords = () =>\n localisationService.getLocale() === 'en-US' ? usCoords : auCoords\n\nexport default coords\n"]}
@@ -1,3 +1,3 @@
1
- import { attachmentsService } from '@oneblink/apps';
1
+ import { attachmentsService } from '../apps';
2
2
  export declare function downloadFileLegacy(dataURI: string, fileName: string): Promise<void>;
3
3
  export default function downloadAttachment(attachment: attachmentsService.Attachment): Promise<void>;
@@ -1,8 +1,8 @@
1
- import { Sentry } from '@oneblink/apps';
1
+ import { Sentry } from '../apps';
2
2
  import * as bulmaToast from 'bulma-toast';
3
3
  import fileSaver from 'file-saver';
4
4
  import { urlToBlobAsync } from './blob-utils';
5
- import tenants from '@oneblink/apps/tenants';
5
+ import tenants from '../apps/tenants';
6
6
  async function downloadFile(data, fileName) {
7
7
  if (window.cordova) {
8
8
  const file = typeof data === 'string' ? await urlToBlobAsync(data) : data;
@@ -1 +1 @@
1
- {"version":3,"file":"download-file.js","sourceRoot":"","sources":["../../src/services/download-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAsB,MAAM,gBAAgB,CAAA;AAC3D,OAAO,KAAK,UAAU,MAAM,aAAa,CAAA;AACzC,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,OAAO,MAAM,wBAAwB,CAAA;AAE5C,KAAK,UAAU,YAAY,CAAC,IAAmB,EAAE,QAAgB;IAC/D,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,MAAM,IAAI,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QACzE,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACpC,MAAM,CAAC,iBAAiB,CACtB,MAAM,CAAC,UAAU,EACjB,CAAC,EACD,CAAC,EAAE,EAA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AAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;QACnD,iBAAiB,CAAC,QAAQ,GAAG,mBAAmB,CAAC,QAAQ,CAAA;QACzD,MAAM,IAAI,GAAG,MAAM,cAAc,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA;QACzD,OAAO,MAAM,YAAY,CAAC,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAA;IACtD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAc,CAAC,CAAA;IAC7B,CAAC;AACH,CAAC","sourcesContent":["import { Sentry, attachmentsService } from '@oneblink/apps'\nimport * as bulmaToast from 'bulma-toast'\nimport fileSaver from 'file-saver'\nimport { urlToBlobAsync } from './blob-utils'\nimport tenants from '@oneblink/apps/tenants'\n\nasync function downloadFile(data: Blob | string, fileName: string) {\n if (window.cordova) {\n const file = typeof data === 'string' ? await urlToBlobAsync(data) : data\n await new Promise((resolve, reject) => {\n window.requestFileSystem(\n window.PERSISTENT,\n 0,\n (fs) => {\n fs.root.getFile(\n fileName,\n {\n create: true,\n exclusive: false,\n },\n (fileEntry) => {\n // Create a FileWriter object for our FileEntry\n fileEntry.createWriter(\n (fileWriter) => {\n fileWriter.onwriteend = () => {\n // @ts-expect-error ???\n window.cordova.plugins.fileOpener2.open(\n // @ts-expect-error ???\n fileEntry.nativeURL,\n file.type,\n {\n error: (error: Error) => {\n console.log(\n 'An error occurred opening the downloaded file',\n )\n reject(error)\n },\n success: () => resolve(undefined),\n },\n )\n }\n\n fileWriter.onerror = (error) => {\n console.log(\n 'An error occurred writing the file to file system',\n )\n reject(error)\n }\n\n fileWriter.write(file)\n },\n (error) => {\n console.log(\n 'An error attempting to create file writer for new file',\n )\n reject(error)\n },\n )\n },\n (error) => {\n console.log(\n 'An error occurred getting new file data from file system',\n )\n reject(error)\n },\n )\n },\n (error) => {\n console.log('An error occurred requesting access to the file system')\n reject(error)\n },\n )\n })\n return\n } else {\n fileSaver.saveAs(data, fileName)\n }\n}\n\nconst handleError = (error?: Error) => {\n if (error) {\n console.warn('An error occurred attempting to download file:', error)\n Sentry.captureException(error)\n bulmaToast.toast({\n message:\n 'Sorry, there was an issue downloading your file, please try again.',\n // @ts-expect-error bulma sets this string as a class, so we are hacking in our own classes\n type: 'ob-toast is-danger cypress-download-file-toast',\n dismissible: true,\n closeOnClick: true,\n })\n }\n}\n\nexport async function downloadFileLegacy(dataURI: string, fileName: string) {\n try {\n return await downloadFile(dataURI, fileName)\n } catch (error) {\n handleError(error as Error)\n }\n}\n\nexport default async function downloadAttachment(\n attachment: attachmentsService.Attachment,\n) {\n try {\n if (attachment.type) {\n if (attachment.data) {\n await downloadFile(attachment.data, attachment.fileName)\n }\n return\n }\n const safeAttachmentUrl = new URL(tenants.current.apiOrigin)\n const unsafeAttachmentUrl = new URL(attachment.url)\n safeAttachmentUrl.pathname = unsafeAttachmentUrl.pathname\n const blob = await urlToBlobAsync(safeAttachmentUrl.href)\n return await downloadFile(blob, attachment.fileName)\n } catch (error) {\n handleError(error as Error)\n }\n}\n"]}
1
+ {"version":3,"file":"download-file.js","sourceRoot":"","sources":["../../src/services/download-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAsB,MAAM,SAAS,CAAA;AACpD,OAAO,KAAK,UAAU,MAAM,aAAa,CAAA;AACzC,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,OAAO,MAAM,iBAAiB,CAAA;AAErC,KAAK,UAAU,YAAY,CAAC,IAAmB,EAAE,QAAgB;IAC/D,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,MAAM,IAAI,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QACzE,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE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,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QAC5D,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;QACnD,iBAAiB,CAAC,QAAQ,GAAG,mBAAmB,CAAC,QAAQ,CAAA;QACzD,MAAM,IAAI,GAAG,MAAM,cAAc,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA;QACzD,OAAO,MAAM,YAAY,CAAC,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAA;IACtD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAc,CAAC,CAAA;IAC7B,CAAC;AACH,CAAC","sourcesContent":["import { Sentry, attachmentsService } from '../apps'\nimport * as bulmaToast from 'bulma-toast'\nimport fileSaver from 'file-saver'\nimport { urlToBlobAsync } from './blob-utils'\nimport tenants from '../apps/tenants'\n\nasync function downloadFile(data: Blob | string, fileName: string) {\n if (window.cordova) {\n const file = typeof data === 'string' ? await urlToBlobAsync(data) : data\n await new Promise((resolve, reject) => {\n window.requestFileSystem(\n window.PERSISTENT,\n 0,\n (fs) => {\n fs.root.getFile(\n fileName,\n {\n create: true,\n exclusive: false,\n },\n (fileEntry) => {\n // Create a FileWriter object for our FileEntry\n fileEntry.createWriter(\n (fileWriter) => {\n fileWriter.onwriteend = () => {\n // @ts-expect-error ???\n window.cordova.plugins.fileOpener2.open(\n // @ts-expect-error ???\n fileEntry.nativeURL,\n file.type,\n {\n error: (error: Error) => {\n console.log(\n 'An error occurred opening the downloaded file',\n )\n reject(error)\n },\n success: () => resolve(undefined),\n },\n )\n }\n\n fileWriter.onerror = (error) => {\n console.log(\n 'An error occurred writing the file to file system',\n )\n reject(error)\n }\n\n fileWriter.write(file)\n },\n (error) => {\n console.log(\n 'An error attempting to create file writer for new file',\n )\n reject(error)\n },\n )\n },\n (error) => {\n console.log(\n 'An error occurred getting new file data from file system',\n )\n reject(error)\n },\n )\n },\n (error) => {\n console.log('An error occurred requesting access to the file system')\n reject(error)\n },\n )\n })\n return\n } else {\n fileSaver.saveAs(data, fileName)\n }\n}\n\nconst handleError = (error?: Error) => {\n if (error) {\n console.warn('An error occurred attempting to download file:', error)\n Sentry.captureException(error)\n bulmaToast.toast({\n message:\n 'Sorry, there was an issue downloading your file, please try again.',\n // @ts-expect-error bulma sets this string as a class, so we are hacking in our own classes\n type: 'ob-toast is-danger cypress-download-file-toast',\n dismissible: true,\n closeOnClick: true,\n })\n }\n}\n\nexport async function downloadFileLegacy(dataURI: string, fileName: string) {\n try {\n return await downloadFile(dataURI, fileName)\n } catch (error) {\n handleError(error as Error)\n }\n}\n\nexport default async function downloadAttachment(\n attachment: attachmentsService.Attachment,\n) {\n try {\n if (attachment.type) {\n if (attachment.data) {\n await downloadFile(attachment.data, attachment.fileName)\n }\n return\n }\n const safeAttachmentUrl = new URL(tenants.current.apiOrigin)\n const unsafeAttachmentUrl = new URL(attachment.url)\n safeAttachmentUrl.pathname = unsafeAttachmentUrl.pathname\n const blob = await urlToBlobAsync(safeAttachmentUrl.href)\n return await downloadFile(blob, attachment.fileName)\n } catch (error) {\n handleError(error as Error)\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { localisationService } from '@oneblink/apps';
1
+ import { localisationService } from '../apps';
2
2
  export default function (file, canvas) {
3
3
  const ctx = canvas.getContext('2d');
4
4
  if (ctx) {
@@ -1 +1 @@
1
- {"version":3,"file":"drawTimestampOnCanvas.js","sourceRoot":"","sources":["../../src/services/drawTimestampOnCanvas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,CAAC,OAAO,WAAW,IAAU,EAAE,MAAyB;IAC5D,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IACnC,IAAI,GAAG,EAAE,CAAC;QACR,MAAM,GAAG,GAAG,mBAAmB,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAA;QAC3E,MAAM,gCAAgC,GAAG,MAAM,CAAA;QAC/C,MAAM,qBAAqB,GAAG,EAAE,CAAA;QAChC,MAAM,2BAA2B,GAAG,EAAE,CAAA;QAEtC,MAAM,UAAU,GACd,gCAAgC,GAAG,MAAM,CAAC,MAAM,GAAG,qBAAqB,CAAA;QAE1E,MAAM,gBAAgB,GACpB,gCAAgC;YAChC,MAAM,CAAC,MAAM;YACb,2BAA2B,CAAA;QAE7B,GAAG,CAAC,IAAI,GAAG,GAAG,UAAU,UAAU,CAAA;QAClC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;QAEjD,MAAM,eAAe,GAAG,gBAAgB,GAAG,CAAC,GAAG,SAAS,CAAA;QACxD,MAAM,gBAAgB,GAAG,gBAAgB,GAAG,CAAC,GAAG,UAAU,CAAA;QAE1D,GAAG,CAAC,SAAS,GAAG,uBAAuB,CAAA;QACvC,GAAG,CAAC,QAAQ,CACV,MAAM,CAAC,KAAK,GAAG,eAAe,GAAG,gBAAgB,EACjD,MAAM,CAAC,MAAM,GAAG,gBAAgB,GAAG,gBAAgB,EACnD,eAAe,EACf,gBAAgB,CACjB,CAAA;QAED,GAAG,CAAC,SAAS,GAAG,MAAM,CAAA;QACtB,GAAG,CAAC,QAAQ,CACV,GAAG,EACH,MAAM,CAAC,KAAK,GAAG,SAAS,GAAG,gBAAgB,GAAG,CAAC,EAC/C,MAAM,CAAC,MAAM,GAAG,UAAU,GAAG,gBAAgB,GAAG,CAAC,CAClD,CAAA;IACH,CAAC;AACH,CAAC","sourcesContent":["import { localisationService } from '@oneblink/apps'\n\nexport default function (file: File, canvas: HTMLCanvasElement): void {\n const ctx = canvas.getContext('2d')\n if (ctx) {\n const now = localisationService.formatDatetime(new Date(file.lastModified))\n const imageHeightMultiplierCoefficient = 0.0021\n const textHeightCoefficient = 20\n const backgroundMarginCoefficient = 10\n\n const textHeight =\n imageHeightMultiplierCoefficient * canvas.height * textHeightCoefficient\n\n const backgroundMargin =\n imageHeightMultiplierCoefficient *\n canvas.height *\n backgroundMarginCoefficient\n\n ctx.font = `${textHeight}px Arial`\n const { width: textWidth } = ctx.measureText(now)\n\n const backgroundWidth = backgroundMargin * 2 + textWidth\n const backgroundHeight = backgroundMargin * 2 + textHeight\n\n ctx.fillStyle = 'rgba(20, 20, 20, 0.6)'\n ctx.fillRect(\n canvas.width - backgroundWidth - backgroundMargin,\n canvas.height - backgroundHeight - backgroundMargin,\n backgroundWidth,\n backgroundHeight,\n )\n\n ctx.fillStyle = '#FFF'\n ctx.fillText(\n now,\n canvas.width - textWidth - backgroundMargin * 2,\n canvas.height - textHeight - backgroundMargin / 3,\n )\n }\n}\n"]}
1
+ {"version":3,"file":"drawTimestampOnCanvas.js","sourceRoot":"","sources":["../../src/services/drawTimestampOnCanvas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAE7C,MAAM,CAAC,OAAO,WAAW,IAAU,EAAE,MAAyB;IAC5D,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IACnC,IAAI,GAAG,EAAE,CAAC;QACR,MAAM,GAAG,GAAG,mBAAmB,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAA;QAC3E,MAAM,gCAAgC,GAAG,MAAM,CAAA;QAC/C,MAAM,qBAAqB,GAAG,EAAE,CAAA;QAChC,MAAM,2BAA2B,GAAG,EAAE,CAAA;QAEtC,MAAM,UAAU,GACd,gCAAgC,GAAG,MAAM,CAAC,MAAM,GAAG,qBAAqB,CAAA;QAE1E,MAAM,gBAAgB,GACpB,gCAAgC;YAChC,MAAM,CAAC,MAAM;YACb,2BAA2B,CAAA;QAE7B,GAAG,CAAC,IAAI,GAAG,GAAG,UAAU,UAAU,CAAA;QAClC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;QAEjD,MAAM,eAAe,GAAG,gBAAgB,GAAG,CAAC,GAAG,SAAS,CAAA;QACxD,MAAM,gBAAgB,GAAG,gBAAgB,GAAG,CAAC,GAAG,UAAU,CAAA;QAE1D,GAAG,CAAC,SAAS,GAAG,uBAAuB,CAAA;QACvC,GAAG,CAAC,QAAQ,CACV,MAAM,CAAC,KAAK,GAAG,eAAe,GAAG,gBAAgB,EACjD,MAAM,CAAC,MAAM,GAAG,gBAAgB,GAAG,gBAAgB,EACnD,eAAe,EACf,gBAAgB,CACjB,CAAA;QAED,GAAG,CAAC,SAAS,GAAG,MAAM,CAAA;QACtB,GAAG,CAAC,QAAQ,CACV,GAAG,EACH,MAAM,CAAC,KAAK,GAAG,SAAS,GAAG,gBAAgB,GAAG,CAAC,EAC/C,MAAM,CAAC,MAAM,GAAG,UAAU,GAAG,gBAAgB,GAAG,CAAC,CAClD,CAAA;IACH,CAAC;AACH,CAAC","sourcesContent":["import { localisationService } from '../apps'\n\nexport default function (file: File, canvas: HTMLCanvasElement): void {\n const ctx = canvas.getContext('2d')\n if (ctx) {\n const now = localisationService.formatDatetime(new Date(file.lastModified))\n const imageHeightMultiplierCoefficient = 0.0021\n const textHeightCoefficient = 20\n const backgroundMarginCoefficient = 10\n\n const textHeight =\n imageHeightMultiplierCoefficient * canvas.height * textHeightCoefficient\n\n const backgroundMargin =\n imageHeightMultiplierCoefficient *\n canvas.height *\n backgroundMarginCoefficient\n\n ctx.font = `${textHeight}px Arial`\n const { width: textWidth } = ctx.measureText(now)\n\n const backgroundWidth = backgroundMargin * 2 + textWidth\n const backgroundHeight = backgroundMargin * 2 + textHeight\n\n ctx.fillStyle = 'rgba(20, 20, 20, 0.6)'\n ctx.fillRect(\n canvas.width - backgroundWidth - backgroundMargin,\n canvas.height - backgroundHeight - backgroundMargin,\n backgroundWidth,\n backgroundHeight,\n )\n\n ctx.fillStyle = '#FFF'\n ctx.fillText(\n now,\n canvas.width - textWidth - backgroundMargin * 2,\n canvas.height - textHeight - backgroundMargin / 3,\n )\n }\n}\n"]}
@@ -4,7 +4,7 @@ import { checkFileNameExtensionIsValid, checkFileNameIsValid, getCleanRepeatable
4
4
  import generateCivicaNameRecordElements from '../generateCivicaNameRecordElements';
5
5
  import generateFreshdeskDependentFieldElements from '../generateFreshdeskDependentFieldElements';
6
6
  import { parseDateValue } from '../generate-default-data';
7
- import { localisationService } from '@oneblink/apps';
7
+ import { localisationService } from '../../apps';
8
8
  import { generateConfirmationFormElementName } from '../dynamic-elements';
9
9
  import { determineLookupButtonIsRequired } from './determineLookupButtonIsRequired';
10
10
  import { defaultAutoSnapshotButtonLabel, generateArcGISAutomatedSnapshotFileName, } from '../../form-elements/FormElementArcGISWebMap';