@oneblink/apps-react 9.0.0-beta.2 → 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.
- package/dist/OneBlinkForm.d.ts +6 -10
- package/dist/OneBlinkForm.js +0 -4
- package/dist/OneBlinkForm.js.map +1 -1
- package/dist/OneBlinkFormBase.d.ts +1 -1
- package/dist/OneBlinkFormBase.js +2 -1
- package/dist/OneBlinkFormBase.js.map +1 -1
- package/dist/OneBlinkReadOnlyForm.d.ts +1 -1
- package/dist/OneBlinkReadOnlyForm.js +1 -1
- package/dist/OneBlinkReadOnlyForm.js.map +1 -1
- package/dist/PaymentReceipt.d.ts +1 -1
- package/dist/PaymentReceipt.js +1 -1
- package/dist/PaymentReceipt.js.map +1 -1
- package/dist/apps/Sentry.d.ts +7 -0
- package/dist/apps/Sentry.js +16 -0
- package/dist/apps/Sentry.js.map +1 -0
- package/dist/apps/approvals-service.d.ts +390 -0
- package/dist/apps/approvals-service.js +987 -0
- package/dist/apps/approvals-service.js.map +1 -0
- package/dist/apps/attachments-service.d.ts +49 -0
- package/dist/apps/attachments-service.js +134 -0
- package/dist/apps/attachments-service.js.map +1 -0
- package/dist/apps/auth-service.d.ts +114 -0
- package/dist/apps/auth-service.js +194 -0
- package/dist/apps/auth-service.js.map +1 -0
- package/dist/apps/auto-save-service.d.ts +82 -0
- package/dist/apps/auto-save-service.js +105 -0
- package/dist/apps/auto-save-service.js.map +1 -0
- package/dist/apps/draft-service.d.ts +148 -0
- package/dist/apps/draft-service.js +583 -0
- package/dist/apps/draft-service.js.map +1 -0
- package/dist/apps/form-service.d.ts +204 -0
- package/dist/apps/form-service.js +718 -0
- package/dist/apps/form-service.js.map +1 -0
- package/dist/apps/form-store-service.d.ts +141 -0
- package/dist/apps/form-store-service.js +114 -0
- package/dist/apps/form-store-service.js.map +1 -0
- package/dist/apps/forms-app-environment-service.d.ts +19 -0
- package/dist/apps/forms-app-environment-service.js +55 -0
- package/dist/apps/forms-app-environment-service.js.map +1 -0
- package/dist/apps/forms-app-service.d.ts +18 -0
- package/dist/apps/forms-app-service.js +53 -0
- package/dist/apps/forms-app-service.js.map +1 -0
- package/dist/apps/index.d.ts +252 -0
- package/dist/apps/index.js +254 -0
- package/dist/apps/index.js.map +1 -0
- package/dist/apps/job-service.d.ts +20 -0
- package/dist/apps/job-service.js +95 -0
- package/dist/apps/job-service.js.map +1 -0
- package/dist/apps/localisation-service.d.ts +207 -0
- package/dist/apps/localisation-service.js +321 -0
- package/dist/apps/localisation-service.js.map +1 -0
- package/dist/apps/notification-service.d.ts +83 -0
- package/dist/apps/notification-service.js +315 -0
- package/dist/apps/notification-service.js.map +1 -0
- package/dist/apps/offline-service.d.ts +18 -0
- package/dist/apps/offline-service.js +25 -0
- package/dist/apps/offline-service.js.map +1 -0
- package/dist/apps/payment-service.d.ts +110 -0
- package/dist/apps/payment-service.js +182 -0
- package/dist/apps/payment-service.js.map +1 -0
- package/dist/apps/prefill-service.d.ts +14 -0
- package/dist/apps/prefill-service.js +19 -0
- package/dist/apps/prefill-service.js.map +1 -0
- package/dist/apps/scheduled-tasks-service.d.ts +127 -0
- package/dist/apps/scheduled-tasks-service.js +240 -0
- package/dist/apps/scheduled-tasks-service.js.map +1 -0
- package/dist/apps/scheduling-service.d.ts +101 -0
- package/dist/apps/scheduling-service.js +171 -0
- package/dist/apps/scheduling-service.js.map +1 -0
- package/dist/apps/services/AWSCognitoClient.d.ts +55 -0
- package/dist/apps/services/AWSCognitoClient.js +436 -0
- package/dist/apps/services/AWSCognitoClient.js.map +1 -0
- package/dist/apps/services/api/drafts.d.ts +7 -0
- package/dist/apps/services/api/drafts.js +236 -0
- package/dist/apps/services/api/drafts.js.map +1 -0
- package/dist/apps/services/api/notifications.d.ts +3 -0
- package/dist/apps/services/api/notifications.js +60 -0
- package/dist/apps/services/api/notifications.js.map +1 -0
- package/dist/apps/services/api/payment.d.ts +23 -0
- package/dist/apps/services/api/payment.js +235 -0
- package/dist/apps/services/api/payment.js.map +1 -0
- package/dist/apps/services/api/post-submission-attachment-urls.d.ts +7 -0
- package/dist/apps/services/api/post-submission-attachment-urls.js +19 -0
- package/dist/apps/services/api/post-submission-attachment-urls.js.map +1 -0
- package/dist/apps/services/api/prefill.d.ts +1 -0
- package/dist/apps/services/api/prefill.js +70 -0
- package/dist/apps/services/api/prefill.js.map +1 -0
- package/dist/apps/services/api/receipt-id.d.ts +2 -0
- package/dist/apps/services/api/receipt-id.js +54 -0
- package/dist/apps/services/api/receipt-id.js.map +1 -0
- package/dist/apps/services/api/scheduling.d.ts +38 -0
- package/dist/apps/services/api/scheduling.js +142 -0
- package/dist/apps/services/api/scheduling.js.map +1 -0
- package/dist/apps/services/api/submissions.d.ts +18 -0
- package/dist/apps/services/api/submissions.js +166 -0
- package/dist/apps/services/api/submissions.js.map +1 -0
- package/dist/apps/services/cognito.d.ts +302 -0
- package/dist/apps/services/cognito.js +441 -0
- package/dist/apps/services/cognito.js.map +1 -0
- package/dist/apps/services/draft-data-store.d.ts +16 -0
- package/dist/apps/services/draft-data-store.js +115 -0
- package/dist/apps/services/draft-data-store.js.map +1 -0
- package/dist/apps/services/errors/oneBlinkAppsError.d.ts +35 -0
- package/dist/apps/services/errors/oneBlinkAppsError.js +32 -0
- package/dist/apps/services/errors/oneBlinkAppsError.js.map +1 -0
- package/dist/apps/services/external-id-generation.d.ts +4 -0
- package/dist/apps/services/external-id-generation.js +59 -0
- package/dist/apps/services/external-id-generation.js.map +1 -0
- package/dist/apps/services/fetch.d.ts +12 -0
- package/dist/apps/services/fetch.js +95 -0
- package/dist/apps/services/fetch.js.map +1 -0
- package/dist/apps/services/forms-key.d.ts +51 -0
- package/dist/apps/services/forms-key.js +83 -0
- package/dist/apps/services/forms-key.js.map +1 -0
- package/dist/apps/services/generate-generic-error.d.ts +3 -0
- package/dist/apps/services/generate-generic-error.js +52 -0
- package/dist/apps/services/generate-generic-error.js.map +1 -0
- package/dist/apps/services/generateOneBlinkDownloader.d.ts +2 -0
- package/dist/apps/services/generateOneBlinkDownloader.js +11 -0
- package/dist/apps/services/generateOneBlinkDownloader.js.map +1 -0
- package/dist/apps/services/generateOneBlinkUploader.d.ts +2 -0
- package/dist/apps/services/generateOneBlinkUploader.js +11 -0
- package/dist/apps/services/generateOneBlinkUploader.js.map +1 -0
- package/dist/apps/services/getDeviceInformation.d.ts +17 -0
- package/dist/apps/services/getDeviceInformation.js +38 -0
- package/dist/apps/services/getDeviceInformation.js.map +1 -0
- package/dist/apps/services/integration-elements.d.ts +383 -0
- package/dist/apps/services/integration-elements.js +761 -0
- package/dist/apps/services/integration-elements.js.map +1 -0
- package/dist/apps/services/job-prefill.d.ts +40 -0
- package/dist/apps/services/job-prefill.js +78 -0
- package/dist/apps/services/job-prefill.js.map +1 -0
- package/dist/apps/services/payment-providers/BPOINTPaymentProvider.d.ts +29 -0
- package/dist/apps/services/payment-providers/BPOINTPaymentProvider.js +59 -0
- package/dist/apps/services/payment-providers/BPOINTPaymentProvider.js.map +1 -0
- package/dist/apps/services/payment-providers/CPPayPaymentProvider.d.ts +27 -0
- package/dist/apps/services/payment-providers/CPPayPaymentProvider.js +63 -0
- package/dist/apps/services/payment-providers/CPPayPaymentProvider.js.map +1 -0
- package/dist/apps/services/payment-providers/NSWGovPayPaymentProvider.d.ts +30 -0
- package/dist/apps/services/payment-providers/NSWGovPayPaymentProvider.js +116 -0
- package/dist/apps/services/payment-providers/NSWGovPayPaymentProvider.js.map +1 -0
- package/dist/apps/services/payment-providers/WestpacQuickStreamPaymentProvider.d.ts +49 -0
- package/dist/apps/services/payment-providers/WestpacQuickStreamPaymentProvider.js +116 -0
- package/dist/apps/services/payment-providers/WestpacQuickStreamPaymentProvider.js.map +1 -0
- package/dist/apps/services/payment-providers/receipt-items.d.ts +8 -0
- package/dist/apps/services/payment-providers/receipt-items.js +58 -0
- package/dist/apps/services/payment-providers/receipt-items.js.map +1 -0
- package/dist/apps/services/pending-queue.d.ts +150 -0
- package/dist/apps/services/pending-queue.js +316 -0
- package/dist/apps/services/pending-queue.js.map +1 -0
- package/dist/apps/services/prepareSubmissionData.d.ts +2 -0
- package/dist/apps/services/prepareSubmissionData.js +113 -0
- package/dist/apps/services/prepareSubmissionData.js.map +1 -0
- package/dist/apps/services/query-string.d.ts +1 -0
- package/dist/apps/services/query-string.js +16 -0
- package/dist/apps/services/query-string.js.map +1 -0
- package/dist/apps/services/replaceInjectablesWithSubmissionValues.d.ts +3 -0
- package/dist/apps/services/replaceInjectablesWithSubmissionValues.js +18 -0
- package/dist/apps/services/replaceInjectablesWithSubmissionValues.js.map +1 -0
- package/dist/apps/services/schedulingHandlers.d.ts +36 -0
- package/dist/apps/services/schedulingHandlers.js +76 -0
- package/dist/apps/services/schedulingHandlers.js.map +1 -0
- package/dist/apps/services/server-validation.d.ts +2 -0
- package/dist/apps/services/server-validation.js +36 -0
- package/dist/apps/services/server-validation.js.map +1 -0
- package/dist/apps/services/serverRequest.d.ts +5 -0
- package/dist/apps/services/serverRequest.js +24 -0
- package/dist/apps/services/serverRequest.js.map +1 -0
- package/dist/apps/services/submit.d.ts +19 -0
- package/dist/apps/services/submit.js +219 -0
- package/dist/apps/services/submit.js.map +1 -0
- package/dist/apps/services/uploadAttachment.d.ts +52 -0
- package/dist/apps/services/uploadAttachment.js +73 -0
- package/dist/apps/services/uploadAttachment.js.map +1 -0
- package/dist/apps/services/user-token.d.ts +27 -0
- package/dist/apps/services/user-token.js +33 -0
- package/dist/apps/services/user-token.js.map +1 -0
- package/dist/apps/services/utils.d.ts +12 -0
- package/dist/apps/services/utils.js +100 -0
- package/dist/apps/services/utils.js.map +1 -0
- package/dist/apps/submission-service.d.ts +226 -0
- package/dist/apps/submission-service.js +425 -0
- package/dist/apps/submission-service.js.map +1 -0
- package/dist/apps/tenants.d.ts +29 -0
- package/dist/apps/tenants.js +127 -0
- package/dist/apps/tenants.js.map +1 -0
- package/dist/apps/types/form.d.ts +4 -0
- package/dist/apps/types/form.js +2 -0
- package/dist/apps/types/form.js.map +1 -0
- package/dist/apps/types/payments.d.ts +45 -0
- package/dist/apps/types/payments.js +2 -0
- package/dist/apps/types/payments.js.map +1 -0
- package/dist/apps/types/scheduling.d.ts +5 -0
- package/dist/apps/types/scheduling.js +2 -0
- package/dist/apps/types/scheduling.js.map +1 -0
- package/dist/apps/types/submissions.d.ts +175 -0
- package/dist/apps/types/submissions.js +2 -0
- package/dist/apps/types/submissions.js.map +1 -0
- package/dist/components/ArcGISWebMap.js +1 -1
- package/dist/components/ArcGISWebMap.js.map +1 -1
- package/dist/components/CustomAccordion.d.ts +3 -3
- package/dist/components/Lists.d.ts +4 -1
- package/dist/components/calendar-bookings/CalendarBookingsCancelForm.js +1 -1
- package/dist/components/calendar-bookings/CalendarBookingsCancelForm.js.map +1 -1
- package/dist/components/calendar-bookings/CalendarBookingsForm.d.ts +1 -1
- package/dist/components/calendar-bookings/CalendarBookingsForm.js +1 -1
- package/dist/components/calendar-bookings/CalendarBookingsForm.js.map +1 -1
- package/dist/components/calendar-bookings/CalendarBookingsReschedulingForm.js +1 -1
- package/dist/components/calendar-bookings/CalendarBookingsReschedulingForm.js.map +1 -1
- package/dist/components/calendar-bookings/ErrorModal.d.ts +1 -1
- package/dist/components/calendar-bookings/ErrorModal.js +1 -1
- package/dist/components/calendar-bookings/ErrorModal.js.map +1 -1
- package/dist/components/downloadable-files/index.d.ts +1 -1
- package/dist/components/downloadable-files/index.js +1 -1
- package/dist/components/downloadable-files/index.js.map +1 -1
- package/dist/components/downloadable-files/resource-components.d.ts +1 -1
- package/dist/components/downloadable-files/resource-components.js +1 -1
- package/dist/components/downloadable-files/resource-components.js.map +1 -1
- package/dist/components/formStore/FormStoreTableProvider.js +1 -1
- package/dist/components/formStore/FormStoreTableProvider.js.map +1 -1
- package/dist/components/formStore/OneBlinkFormStoreClearFiltersButton.js.map +1 -1
- package/dist/components/formStore/OneBlinkFormStoreDownloadButton.js +1 -1
- package/dist/components/formStore/OneBlinkFormStoreDownloadButton.js.map +1 -1
- package/dist/components/formStore/OneBlinkFormStoreProvider.js +1 -1
- package/dist/components/formStore/OneBlinkFormStoreProvider.js.map +1 -1
- package/dist/components/formStore/OneBlinkFormStoreTable.js.map +1 -1
- package/dist/components/formStore/display/ElementDisplay.js +2 -2
- package/dist/components/formStore/display/ElementDisplay.js.map +1 -1
- package/dist/components/formStore/table/ColumnFilters.js +1 -1
- package/dist/components/formStore/table/ColumnFilters.js.map +1 -1
- package/dist/components/formStore/table/FormElementTableCell.js +1 -1
- package/dist/components/formStore/table/FormElementTableCell.js.map +1 -1
- package/dist/components/formStore/table/Pickers.js +1 -1
- package/dist/components/formStore/table/Pickers.js.map +1 -1
- package/dist/components/formStore/table/generateColumns.d.ts +1 -1
- package/dist/components/formStore/table/generateColumns.js.map +1 -1
- package/dist/components/formStore/table/useFormStoreTable.d.ts +1 -1
- package/dist/components/formStore/table/useFormStoreTable.js +1 -1
- package/dist/components/formStore/table/useFormStoreTable.js.map +1 -1
- package/dist/components/formStore/useFormStoreTableContext.d.ts +2 -2
- package/dist/components/mfa/MfaDialog.d.ts +1 -1
- package/dist/components/mfa/MfaDialog.js +1 -1
- package/dist/components/mfa/MfaDialog.js.map +1 -1
- package/dist/components/mfa/MultiFactorAuthentication.d.ts +1 -1
- package/dist/components/payments/PaymentForm.js +1 -1
- package/dist/components/payments/PaymentForm.js.map +1 -1
- package/dist/components/payments/WestpacQuickStreamPaymentForm.d.ts +1 -1
- package/dist/components/payments/WestpacQuickStreamPaymentForm.js +1 -1
- package/dist/components/payments/WestpacQuickStreamPaymentForm.js.map +1 -1
- package/dist/components/renderer/AutocompleteDropdown.js +1 -1
- package/dist/components/renderer/AutocompleteDropdown.js.map +1 -1
- package/dist/components/renderer/LookupNotification.js +2 -2
- package/dist/components/renderer/LookupNotification.js.map +1 -1
- package/dist/components/renderer/OneBlinkAppsErrorOriginalMessage.js +1 -1
- package/dist/components/renderer/OneBlinkAppsErrorOriginalMessage.js.map +1 -1
- package/dist/components/renderer/OneBlinkFormElements.js.map +1 -1
- package/dist/components/renderer/ReverseGeocode.js +1 -1
- package/dist/components/renderer/ReverseGeocode.js.map +1 -1
- package/dist/form-elements/FormElementAPINSWLiquorLicence.js +1 -1
- package/dist/form-elements/FormElementAPINSWLiquorLicence.js.map +1 -1
- package/dist/form-elements/FormElementArcGISWebMap.js.map +1 -1
- package/dist/form-elements/FormElementAutocomplete.js +1 -1
- package/dist/form-elements/FormElementAutocomplete.js.map +1 -1
- package/dist/form-elements/FormElementBSB.js +1 -1
- package/dist/form-elements/FormElementBSB.js.map +1 -1
- package/dist/form-elements/FormElementCalculation.js +2 -2
- package/dist/form-elements/FormElementCalculation.js.map +1 -1
- package/dist/form-elements/FormElementCivicaNameRecord.js +1 -1
- package/dist/form-elements/FormElementCivicaNameRecord.js.map +1 -1
- package/dist/form-elements/FormElementCivicaStreetName.js +1 -1
- package/dist/form-elements/FormElementCivicaStreetName.js.map +1 -1
- package/dist/form-elements/FormElementCompliance.d.ts +1 -1
- package/dist/form-elements/FormElementCompliance.js.map +1 -1
- package/dist/form-elements/FormElementDate.js +1 -1
- package/dist/form-elements/FormElementDate.js.map +1 -1
- package/dist/form-elements/FormElementDateTime.js +1 -1
- package/dist/form-elements/FormElementDateTime.js.map +1 -1
- package/dist/form-elements/FormElementFile.d.ts +1 -1
- package/dist/form-elements/FormElementFile.js.map +1 -1
- package/dist/form-elements/FormElementFiles.d.ts +1 -1
- package/dist/form-elements/FormElementFiles.js.map +1 -1
- package/dist/form-elements/FormElementGeoscapeAddress.js +1 -1
- package/dist/form-elements/FormElementGeoscapeAddress.js.map +1 -1
- package/dist/form-elements/FormElementGoogleAddress.js +1 -1
- package/dist/form-elements/FormElementGoogleAddress.js.map +1 -1
- package/dist/form-elements/FormElementLocation.js +1 -1
- package/dist/form-elements/FormElementLocation.js.map +1 -1
- package/dist/form-elements/FormElementNumber.js +1 -1
- package/dist/form-elements/FormElementNumber.js.map +1 -1
- package/dist/form-elements/FormElementPointAddress.js +1 -1
- package/dist/form-elements/FormElementPointAddress.js.map +1 -1
- package/dist/form-elements/FormElementPointAddressV3.js +1 -1
- package/dist/form-elements/FormElementPointAddressV3.js.map +1 -1
- package/dist/form-elements/FormElementPointCadastralParcel.js +1 -1
- package/dist/form-elements/FormElementPointCadastralParcel.js.map +1 -1
- package/dist/form-elements/FormElementSummary.js +1 -1
- package/dist/form-elements/FormElementSummary.js.map +1 -1
- package/dist/form-elements/FormElementTime.js +1 -1
- package/dist/form-elements/FormElementTime.js.map +1 -1
- package/dist/hooks/attachments/useAttachment.d.ts +1 -1
- package/dist/hooks/attachments/useAttachment.js +1 -1
- package/dist/hooks/attachments/useAttachment.js.map +1 -1
- package/dist/hooks/attachments/useAttachments.d.ts +1 -1
- package/dist/hooks/attachments/useAttachments.js.map +1 -1
- package/dist/hooks/useAuth.js +1 -1
- package/dist/hooks/useAuth.js.map +1 -1
- package/dist/hooks/useConditionalLogic.js +1 -1
- package/dist/hooks/useConditionalLogic.js.map +1 -1
- package/dist/hooks/useDrafts.d.ts +1 -1
- package/dist/hooks/useDrafts.js +1 -1
- package/dist/hooks/useDrafts.js.map +1 -1
- package/dist/hooks/useDynamicOptionsLoaderState.d.ts +1 -1
- package/dist/hooks/useDynamicOptionsLoaderState.js +1 -1
- package/dist/hooks/useDynamicOptionsLoaderState.js.map +1 -1
- package/dist/hooks/useFormElementLookups.d.ts +1 -1
- package/dist/hooks/useFormElementLookups.js +1 -1
- package/dist/hooks/useFormElementLookups.js.map +1 -1
- package/dist/hooks/useFormSubmissionAutoSaveState.d.ts +1 -1
- package/dist/hooks/useFormSubmissionAutoSaveState.js +1 -1
- package/dist/hooks/useFormSubmissionAutoSaveState.js.map +1 -1
- package/dist/hooks/useIsOffline.js +1 -1
- package/dist/hooks/useIsOffline.js.map +1 -1
- package/dist/hooks/useLogin.js +1 -1
- package/dist/hooks/useLogin.js.map +1 -1
- package/dist/hooks/useMfa.d.ts +1 -1
- package/dist/hooks/useMfa.js +1 -1
- package/dist/hooks/useMfa.js.map +1 -1
- package/dist/hooks/useOnUploadAttachment.d.ts +1 -1
- package/dist/hooks/useOnUploadAttachment.js +1 -1
- package/dist/hooks/useOnUploadAttachment.js.map +1 -1
- package/dist/hooks/usePendingSubmissions.d.ts +1 -1
- package/dist/hooks/usePendingSubmissions.js +1 -1
- package/dist/hooks/usePendingSubmissions.js.map +1 -1
- package/dist/hooks/useReplaceableText.js +1 -1
- package/dist/hooks/useReplaceableText.js.map +1 -1
- package/dist/hooks/useSignUp.js +1 -1
- package/dist/hooks/useSignUp.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/services/attachments.d.ts +1 -1
- package/dist/services/attachments.js +1 -1
- package/dist/services/attachments.js.map +1 -1
- package/dist/services/blob-utils.js +1 -1
- package/dist/services/blob-utils.js.map +1 -1
- package/dist/services/checkIfAttachmentsExist.d.ts +1 -1
- package/dist/services/checkIfAttachmentsExist.js.map +1 -1
- package/dist/services/defaultCoordinates.js +1 -1
- package/dist/services/defaultCoordinates.js.map +1 -1
- package/dist/services/download-file.d.ts +1 -1
- package/dist/services/download-file.js +2 -2
- package/dist/services/download-file.js.map +1 -1
- package/dist/services/drawTimestampOnCanvas.js +1 -1
- package/dist/services/drawTimestampOnCanvas.js.map +1 -1
- package/dist/services/form-validation/validateSubmission.js +1 -1
- package/dist/services/form-validation/validateSubmission.js.map +1 -1
- package/dist/services/form-validation/validators.d.ts +1 -1
- package/dist/services/form-validation/validators.js.map +1 -1
- package/dist/services/generate-default-data.js +1 -1
- package/dist/services/generate-default-data.js.map +1 -1
- package/dist/services/injectableOptions.js +1 -1
- package/dist/services/injectableOptions.js.map +1 -1
- package/dist/styles.css +208 -204
- package/dist/types/attachments.d.ts +1 -1
- package/dist/types/attachments.js.map +1 -1
- package/dist/utils/sendGoogleAnalyticsEvent.js +1 -1
- package/dist/utils/sendGoogleAnalyticsEvent.js.map +1 -1
- package/package.json +42 -34
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import OneBlinkAppsError from './services/errors/oneBlinkAppsError';
|
|
2
|
+
import { createNotificationsSubscription, deleteNotificationsSubscription, } from './services/api/notifications';
|
|
3
|
+
import { isOffline } from './offline-service';
|
|
4
|
+
import tenants from './tenants';
|
|
5
|
+
import Sentry from './Sentry';
|
|
6
|
+
import { getRequest, putRequest } from './services/fetch';
|
|
7
|
+
function urlB64ToUint8Array(base64String) {
|
|
8
|
+
const padding = '='.repeat((4 - (base64String.length % 4)) % 4);
|
|
9
|
+
const base64 = (base64String + padding)
|
|
10
|
+
// eslint-disable-next-line no-useless-escape
|
|
11
|
+
.replace(/\-/g, '+')
|
|
12
|
+
.replace(/_/g, '/');
|
|
13
|
+
const rawData = window.atob(base64);
|
|
14
|
+
const outputArray = new Uint8Array(rawData.length);
|
|
15
|
+
for (let i = 0; i < rawData.length; ++i) {
|
|
16
|
+
outputArray[i] = rawData.charCodeAt(i);
|
|
17
|
+
}
|
|
18
|
+
return outputArray;
|
|
19
|
+
}
|
|
20
|
+
let applicationServerKey = null;
|
|
21
|
+
let _isInitialised = false;
|
|
22
|
+
let _swRegistration = null;
|
|
23
|
+
async function getServiceWorkerRegistration() {
|
|
24
|
+
if (_isInitialised) {
|
|
25
|
+
return _swRegistration;
|
|
26
|
+
}
|
|
27
|
+
applicationServerKey = urlB64ToUint8Array(tenants.current.vapidPublicKey);
|
|
28
|
+
if ('serviceWorker' in navigator && navigator.serviceWorker) {
|
|
29
|
+
try {
|
|
30
|
+
_swRegistration = await navigator.serviceWorker.ready;
|
|
31
|
+
console.log('Service Worker is registered', _swRegistration);
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
Sentry.captureException(error);
|
|
35
|
+
console.error('Notifications Service init error', error);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
_isInitialised = true;
|
|
39
|
+
return _swRegistration;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Check if the user is currently subscribed to notifications
|
|
43
|
+
*
|
|
44
|
+
* #### Example
|
|
45
|
+
*
|
|
46
|
+
* ```js
|
|
47
|
+
* const isSubscribed = await notificationService.isSubscribed()
|
|
48
|
+
* // Allow user to subscribe or unsubscribe
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
async function isSubscribed() {
|
|
54
|
+
const swRegistration = await getServiceWorkerRegistration();
|
|
55
|
+
if (!swRegistration) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
const subscription = await swRegistration.pushManager.getSubscription();
|
|
59
|
+
return !!subscription;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Subscribe the current user to notifications
|
|
63
|
+
*
|
|
64
|
+
* #### Example
|
|
65
|
+
*
|
|
66
|
+
* ```js
|
|
67
|
+
* const formsAppId = 1
|
|
68
|
+
* const isSubscribed = await notificationService.subscribe(formsAppId)
|
|
69
|
+
* // isSubscribed will be false if user denied permission to push notifications
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @param formsAppId
|
|
73
|
+
* @returns
|
|
74
|
+
*/
|
|
75
|
+
async function subscribe(formsAppId) {
|
|
76
|
+
if (isOffline()) {
|
|
77
|
+
throw new OneBlinkAppsError('You are currently offline, please connect to the internet and try again.', {
|
|
78
|
+
isOffline: true,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
const swRegistration = await getServiceWorkerRegistration();
|
|
82
|
+
if (!swRegistration) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
if (!('Notification' in window) ||
|
|
86
|
+
!swRegistration.pushManager ||
|
|
87
|
+
!swRegistration.pushManager.subscribe) {
|
|
88
|
+
throw new OneBlinkAppsError('Sorry, push notifications are not support for your device.', {
|
|
89
|
+
title: 'Unsupported Device',
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
const key = applicationServerKey;
|
|
94
|
+
if (!key) {
|
|
95
|
+
throw new Error('Notifications have not been configured for your application.');
|
|
96
|
+
}
|
|
97
|
+
const permission = await Notification.requestPermission();
|
|
98
|
+
// If the user accepts, create subscription
|
|
99
|
+
if (permission !== 'granted') {
|
|
100
|
+
throw new OneBlinkAppsError('It looks like you may have denied this app permission to send you push notifications. Please grant this app the notifications permission and try again.', {
|
|
101
|
+
title: 'Permission Required',
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
console.log('User has granted notifications permission');
|
|
105
|
+
const subscription = await swRegistration.pushManager.subscribe({
|
|
106
|
+
userVisibleOnly: true,
|
|
107
|
+
applicationServerKey: key,
|
|
108
|
+
});
|
|
109
|
+
console.log('Subscribed to Service Worker Push:', subscription);
|
|
110
|
+
try {
|
|
111
|
+
await createNotificationsSubscription(formsAppId, subscription);
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
await subscription.unsubscribe();
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
console.log('Successfully subscribed to push notifications');
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
console.warn('Failed to subscribe the user:', error);
|
|
122
|
+
if (Notification.permission === 'denied') {
|
|
123
|
+
console.warn('Permission for notifications was denied');
|
|
124
|
+
throw new OneBlinkAppsError('It looks like you may have denied this app permission to send you push notifications. Please grant this app the notifications permission and try again.', {
|
|
125
|
+
title: 'Permission Required',
|
|
126
|
+
originalError: error,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
if (error instanceof OneBlinkAppsError) {
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
132
|
+
Sentry.captureException(error);
|
|
133
|
+
throw new OneBlinkAppsError('We were unable to subscribe you to push notifications, please try again and contact support if the problem persists.', {
|
|
134
|
+
title: 'Permission Required',
|
|
135
|
+
originalError: error,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Subscribe the current user to notifications
|
|
141
|
+
*
|
|
142
|
+
* #### Example
|
|
143
|
+
*
|
|
144
|
+
* ```js
|
|
145
|
+
* const formsAppId = 1
|
|
146
|
+
* await notificationService.unsubscribe(formsAppId)
|
|
147
|
+
* // isSubscribed will be false if user denied permission to push notifications
|
|
148
|
+
* ```
|
|
149
|
+
*
|
|
150
|
+
* @param formsAppId
|
|
151
|
+
* @returns
|
|
152
|
+
*/
|
|
153
|
+
async function unsubscribe(formsAppId) {
|
|
154
|
+
if (isOffline()) {
|
|
155
|
+
throw new OneBlinkAppsError('You are currently offline, please connect to the internet and try again.', {
|
|
156
|
+
isOffline: true,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
const swRegistration = await getServiceWorkerRegistration();
|
|
160
|
+
if (!swRegistration) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
console.log('Checking for subscription to unsubscribe');
|
|
164
|
+
try {
|
|
165
|
+
const subscription = await swRegistration.pushManager.getSubscription();
|
|
166
|
+
if (!subscription) {
|
|
167
|
+
console.log('No subscription');
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
await subscription.unsubscribe();
|
|
171
|
+
console.log('Unsubscribed from Service Worker Push subscription', subscription);
|
|
172
|
+
await deleteNotificationsSubscription(formsAppId, subscription).catch((error) => {
|
|
173
|
+
Sentry.captureException(error);
|
|
174
|
+
// Ignore this error as the server should remove
|
|
175
|
+
// this subscription the next time it tries to use it.
|
|
176
|
+
console.warn('Could not delete subscription on server', error);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
Sentry.captureException(error);
|
|
181
|
+
console.warn('Failed to unsubscribe the user:', error);
|
|
182
|
+
throw new OneBlinkAppsError('We were unable to unsubscribe you from push notifications, please try again and contact support if the problem persists.', {
|
|
183
|
+
originalError: error,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Get the current users email subscriptions for a single forms app.
|
|
189
|
+
*
|
|
190
|
+
* #### Example
|
|
191
|
+
*
|
|
192
|
+
* ```js
|
|
193
|
+
* const formsAppId = 1
|
|
194
|
+
* const emailSubscriptions =
|
|
195
|
+
* await approvalsService.getEmailSubscriptions(formsAppId)
|
|
196
|
+
* ```
|
|
197
|
+
*
|
|
198
|
+
* @param formsAppId
|
|
199
|
+
* @param abortSignal
|
|
200
|
+
* @returns
|
|
201
|
+
*/
|
|
202
|
+
export async function getEmailSubscriptions(formsAppId, abortSignal) {
|
|
203
|
+
try {
|
|
204
|
+
const { emailSubscriptions } = await getRequest(`${tenants.current.apiOrigin}/forms-apps/${formsAppId}/my-preferences`, abortSignal);
|
|
205
|
+
return emailSubscriptions;
|
|
206
|
+
}
|
|
207
|
+
catch (err) {
|
|
208
|
+
console.error('Error retrieving preferences for current user', err);
|
|
209
|
+
Sentry.captureException(err);
|
|
210
|
+
const error = err;
|
|
211
|
+
if (isOffline()) {
|
|
212
|
+
throw new OneBlinkAppsError('You are currently offline, please connect to the internet and try again', {
|
|
213
|
+
originalError: error,
|
|
214
|
+
isOffline: true,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
switch (error.status) {
|
|
218
|
+
case 401: {
|
|
219
|
+
throw new OneBlinkAppsError('You cannot access your email subscriptions without first logging in. Please login and try again.', {
|
|
220
|
+
originalError: error,
|
|
221
|
+
requiresLogin: true,
|
|
222
|
+
httpStatusCode: error.status,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
case 403: {
|
|
226
|
+
throw new OneBlinkAppsError('You do not have access to this application. Please contact your administrator to gain the correct level of access.', {
|
|
227
|
+
originalError: error,
|
|
228
|
+
requiresAccessRequest: true,
|
|
229
|
+
httpStatusCode: error.status,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
case 400:
|
|
233
|
+
case 404: {
|
|
234
|
+
throw new OneBlinkAppsError(error.message, {
|
|
235
|
+
title: 'Invalid Request',
|
|
236
|
+
httpStatusCode: error.status,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
default: {
|
|
240
|
+
throw new OneBlinkAppsError('An unknown error has occurred. Please contact support if the problem persists.', {
|
|
241
|
+
originalError: error,
|
|
242
|
+
httpStatusCode: error.status,
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Update the current users email subscriptions for a single forms app.
|
|
250
|
+
*
|
|
251
|
+
* #### Example
|
|
252
|
+
*
|
|
253
|
+
* ```js
|
|
254
|
+
* const emailSubscriptions = {
|
|
255
|
+
* newApproval: true,
|
|
256
|
+
* clarificationReceived: true,
|
|
257
|
+
* }
|
|
258
|
+
* const savedFormsAppUserSubscription =
|
|
259
|
+
* await approvalsService.updateFormsAppUserSubscription(
|
|
260
|
+
* emailSubscriptions,
|
|
261
|
+
* )
|
|
262
|
+
* ```
|
|
263
|
+
*
|
|
264
|
+
* @param formsAppId
|
|
265
|
+
* @param emailSubscriptions
|
|
266
|
+
* @param abortSignal
|
|
267
|
+
* @returns
|
|
268
|
+
*/
|
|
269
|
+
export async function updateEmailSubscriptions(formsAppId, emailSubscriptions, abortSignal) {
|
|
270
|
+
try {
|
|
271
|
+
await putRequest(`${tenants.current.apiOrigin}/forms-apps/${formsAppId}/my-preferences`, { emailSubscriptions }, abortSignal);
|
|
272
|
+
}
|
|
273
|
+
catch (err) {
|
|
274
|
+
console.error('Error retrieving preferences for current user', err);
|
|
275
|
+
Sentry.captureException(err);
|
|
276
|
+
const error = err;
|
|
277
|
+
if (isOffline()) {
|
|
278
|
+
throw new OneBlinkAppsError('You are currently offline, please connect to the internet and try again', {
|
|
279
|
+
originalError: error,
|
|
280
|
+
isOffline: true,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
switch (error.status) {
|
|
284
|
+
case 401: {
|
|
285
|
+
throw new OneBlinkAppsError('You cannot update your email subscriptions without first logging in. Please login and try again.', {
|
|
286
|
+
originalError: error,
|
|
287
|
+
requiresLogin: true,
|
|
288
|
+
httpStatusCode: error.status,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
case 403: {
|
|
292
|
+
throw new OneBlinkAppsError('You do not have access to this application. Please contact your administrator to gain the correct level of access.', {
|
|
293
|
+
originalError: error,
|
|
294
|
+
requiresAccessRequest: true,
|
|
295
|
+
httpStatusCode: error.status,
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
case 400:
|
|
299
|
+
case 404: {
|
|
300
|
+
throw new OneBlinkAppsError(error.message, {
|
|
301
|
+
title: 'Invalid Request',
|
|
302
|
+
httpStatusCode: error.status,
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
default: {
|
|
306
|
+
throw new OneBlinkAppsError('An unknown error has occurred. Please contact support if the problem persists.', {
|
|
307
|
+
originalError: error,
|
|
308
|
+
httpStatusCode: error.status,
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
export { isSubscribed, subscribe, unsubscribe };
|
|
315
|
+
//# sourceMappingURL=notification-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-service.js","sourceRoot":"","sources":["../../src/apps/notification-service.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,qCAAqC,CAAA;AACnE,OAAO,EACL,+BAA+B,EAC/B,+BAA+B,GAChC,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,OAAO,MAAM,WAAW,CAAA;AAC/B,OAAO,MAAM,MAAM,UAAU,CAAA;AAE7B,OAAO,EAAE,UAAU,EAAa,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAEpE,SAAS,kBAAkB,CAAC,YAAoB;IAC9C,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,C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CAAC,CAAC;gBACT,MAAM,IAAI,iBAAiB,CAAC,KAAK,CAAC,OAAO,EAAE;oBACzC,KAAK,EAAE,iBAAiB;oBACxB,cAAc,EAAE,KAAK,CAAC,MAAM;iBAC7B,CAAC,CAAA;YACJ,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM,IAAI,iBAAiB,CACzB,gFAAgF,EAChF;oBACE,aAAa,EAAE,KAAK;oBACpB,cAAc,EAAE,KAAK,CAAC,MAAM;iBAC7B,CACF,CAAA;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,CAAA","sourcesContent":["import OneBlinkAppsError from './services/errors/oneBlinkAppsError'\nimport {\n createNotificationsSubscription,\n deleteNotificationsSubscription,\n} from './services/api/notifications'\nimport { isOffline } from './offline-service'\nimport tenants from './tenants'\nimport Sentry from './Sentry'\nimport { FormsAppsTypes } from '@oneblink/types'\nimport { getRequest, HTTPError, putRequest } from './services/fetch'\n\nfunction urlB64ToUint8Array(base64String: string) {\n const padding = '='.repeat((4 - (base64String.length % 4)) % 4)\n const base64 = (base64String + padding)\n // eslint-disable-next-line no-useless-escape\n .replace(/\\-/g, '+')\n .replace(/_/g, '/')\n\n const rawData = window.atob(base64)\n const outputArray = new Uint8Array(rawData.length)\n\n for (let i = 0; i < rawData.length; ++i) {\n outputArray[i] = rawData.charCodeAt(i)\n }\n return outputArray\n}\n\nlet applicationServerKey: null | Uint8Array = null\nlet _isInitialised = false\nlet _swRegistration: null | ServiceWorkerRegistration = null\n\nasync function getServiceWorkerRegistration(): Promise<ServiceWorkerRegistration | null> {\n if (_isInitialised) {\n return _swRegistration\n }\n\n applicationServerKey = urlB64ToUint8Array(tenants.current.vapidPublicKey)\n\n if ('serviceWorker' in navigator && navigator.serviceWorker) {\n try {\n _swRegistration = await navigator.serviceWorker.ready\n console.log('Service Worker is registered', _swRegistration)\n } catch (error) {\n Sentry.captureException(error)\n console.error('Notifications Service init error', error)\n }\n }\n\n _isInitialised = true\n return _swRegistration\n}\n\n/**\n * Check if the user is currently subscribed to notifications\n *\n * #### Example\n *\n * ```js\n * const isSubscribed = await notificationService.isSubscribed()\n * // Allow user to subscribe or unsubscribe\n * ```\n *\n * @returns\n */\nasync function isSubscribed(): Promise<boolean> {\n const swRegistration = await getServiceWorkerRegistration()\n if (!swRegistration) {\n return false\n }\n\n const subscription = await swRegistration.pushManager.getSubscription()\n return !!subscription\n}\n\n/**\n * Subscribe the current user to notifications\n *\n * #### Example\n *\n * ```js\n * const formsAppId = 1\n * const isSubscribed = await notificationService.subscribe(formsAppId)\n * // isSubscribed will be false if user denied permission to push notifications\n * ```\n *\n * @param formsAppId\n * @returns\n */\nasync function subscribe(formsAppId: number): Promise<boolean> {\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again.',\n {\n isOffline: true,\n },\n )\n }\n\n const swRegistration = await getServiceWorkerRegistration()\n if (!swRegistration) {\n return false\n }\n\n if (\n !('Notification' in window) ||\n !swRegistration.pushManager ||\n !swRegistration.pushManager.subscribe\n ) {\n throw new OneBlinkAppsError(\n 'Sorry, push notifications are not support for your device.',\n {\n title: 'Unsupported Device',\n },\n )\n }\n\n try {\n const key = applicationServerKey\n if (!key) {\n throw new Error(\n 'Notifications have not been configured for your application.',\n )\n }\n\n const permission = await Notification.requestPermission()\n // If the user accepts, create subscription\n if (permission !== 'granted') {\n throw new OneBlinkAppsError(\n 'It looks like you may have denied this app permission to send you push notifications. Please grant this app the notifications permission and try again.',\n {\n title: 'Permission Required',\n },\n )\n }\n\n console.log('User has granted notifications permission')\n\n const subscription = await swRegistration.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: key as BufferSource,\n })\n console.log('Subscribed to Service Worker Push:', subscription)\n try {\n await createNotificationsSubscription(formsAppId, subscription)\n } catch (error) {\n await subscription.unsubscribe()\n throw error\n }\n console.log('Successfully subscribed to push notifications')\n return true\n } catch (error) {\n console.warn('Failed to subscribe the user:', error)\n\n if (Notification.permission === 'denied') {\n console.warn('Permission for notifications was denied')\n throw new OneBlinkAppsError(\n 'It looks like you may have denied this app permission to send you push notifications. Please grant this app the notifications permission and try again.',\n {\n title: 'Permission Required',\n originalError: error as Error,\n },\n )\n }\n\n if (error instanceof OneBlinkAppsError) {\n throw error\n }\n\n Sentry.captureException(error)\n\n throw new OneBlinkAppsError(\n 'We were unable to subscribe you to push notifications, please try again and contact support if the problem persists.',\n {\n title: 'Permission Required',\n originalError: error as Error,\n },\n )\n }\n}\n\n/**\n * Subscribe the current user to notifications\n *\n * #### Example\n *\n * ```js\n * const formsAppId = 1\n * await notificationService.unsubscribe(formsAppId)\n * // isSubscribed will be false if user denied permission to push notifications\n * ```\n *\n * @param formsAppId\n * @returns\n */\nasync function unsubscribe(formsAppId: number): Promise<void> {\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again.',\n {\n isOffline: true,\n },\n )\n }\n\n const swRegistration = await getServiceWorkerRegistration()\n if (!swRegistration) {\n return\n }\n\n console.log('Checking for subscription to unsubscribe')\n try {\n const subscription = await swRegistration.pushManager.getSubscription()\n if (!subscription) {\n console.log('No subscription')\n return\n }\n\n await subscription.unsubscribe()\n console.log(\n 'Unsubscribed from Service Worker Push subscription',\n subscription,\n )\n\n await deleteNotificationsSubscription(formsAppId, subscription).catch(\n (error) => {\n Sentry.captureException(error)\n // Ignore this error as the server should remove\n // this subscription the next time it tries to use it.\n console.warn('Could not delete subscription on server', error)\n },\n )\n } catch (error) {\n Sentry.captureException(error)\n console.warn('Failed to unsubscribe the user:', error)\n throw new OneBlinkAppsError(\n 'We were unable to unsubscribe you from push notifications, please try again and contact support if the problem persists.',\n {\n originalError: error as Error,\n },\n )\n }\n}\n\n/**\n * Get the current users email subscriptions for a single forms app.\n *\n * #### Example\n *\n * ```js\n * const formsAppId = 1\n * const emailSubscriptions =\n * await approvalsService.getEmailSubscriptions(formsAppId)\n * ```\n *\n * @param formsAppId\n * @param abortSignal\n * @returns\n */\nexport async function getEmailSubscriptions(\n formsAppId: number,\n abortSignal?: AbortSignal,\n): Promise<FormsAppsTypes.FormsAppUserSubscription['emailSubscriptions']> {\n try {\n const { emailSubscriptions } =\n await getRequest<FormsAppsTypes.FormsAppUserSubscription>(\n `${tenants.current.apiOrigin}/forms-apps/${formsAppId}/my-preferences`,\n abortSignal,\n )\n return emailSubscriptions\n } catch (err) {\n console.error('Error retrieving preferences for current user', err)\n Sentry.captureException(err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot access your email subscriptions without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Update the current users email subscriptions for a single forms app.\n *\n * #### Example\n *\n * ```js\n * const emailSubscriptions = {\n * newApproval: true,\n * clarificationReceived: true,\n * }\n * const savedFormsAppUserSubscription =\n * await approvalsService.updateFormsAppUserSubscription(\n * emailSubscriptions,\n * )\n * ```\n *\n * @param formsAppId\n * @param emailSubscriptions\n * @param abortSignal\n * @returns\n */\nexport async function updateEmailSubscriptions(\n formsAppId: number,\n emailSubscriptions: FormsAppsTypes.FormsAppUserSubscription['emailSubscriptions'],\n abortSignal?: AbortSignal,\n): Promise<void> {\n try {\n await putRequest<FormsAppsTypes.FormsAppUserSubscription>(\n `${tenants.current.apiOrigin}/forms-apps/${formsAppId}/my-preferences`,\n { emailSubscriptions },\n abortSignal,\n )\n } catch (err) {\n console.error('Error retrieving preferences for current user', err)\n Sentry.captureException(err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot update your email subscriptions without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\nexport { isSubscribed, subscribe, unsubscribe }\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
cordova: unknown;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Check if the user is currently offline
|
|
8
|
+
*
|
|
9
|
+
* #### Example
|
|
10
|
+
*
|
|
11
|
+
* ```js
|
|
12
|
+
* const isOffline = offlineService.isOffline()
|
|
13
|
+
* // handle user being offline
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
export declare function isOffline(): boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if the user is currently offline
|
|
3
|
+
*
|
|
4
|
+
* #### Example
|
|
5
|
+
*
|
|
6
|
+
* ```js
|
|
7
|
+
* const isOffline = offlineService.isOffline()
|
|
8
|
+
* // handle user being offline
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export function isOffline() {
|
|
14
|
+
if (!window.navigator) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (window.cordova) {
|
|
18
|
+
// @ts-expect-error
|
|
19
|
+
return window.navigator.connection.type === 'none';
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return !window.navigator.onLine;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=offline-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"offline-service.js","sourceRoot":"","sources":["../../src/apps/offline-service.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,SAAS;IACvB,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QACtB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,mBAAmB;QACnB,OAAO,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,KAAK,MAAM,CAAA;IACpD,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAA;IACjC,CAAC;AACH,CAAC","sourcesContent":["declare global {\n interface Window {\n cordova: unknown\n }\n}\n\n/**\n * Check if the user is currently offline\n *\n * #### Example\n *\n * ```js\n * const isOffline = offlineService.isOffline()\n * // handle user being offline\n * ```\n *\n * @returns\n */\nexport function isOffline(): boolean {\n if (!window.navigator) {\n return false\n }\n\n if (window.cordova) {\n // @ts-expect-error\n return window.navigator.connection.type === 'none'\n } else {\n return !window.navigator.onLine\n }\n}\n"]}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { SubmissionEventTypes, SubmissionTypes } from '@oneblink/types';
|
|
2
|
+
import { FormSubmission, FormSubmissionResult } from './types/submissions';
|
|
3
|
+
import { HandlePaymentResult, PaymentReceiptItem } from './types/payments';
|
|
4
|
+
import * as westpacQuickStream from './services/payment-providers/WestpacQuickStreamPaymentProvider';
|
|
5
|
+
export { HandlePaymentResult, PaymentReceiptItem, westpacQuickStream };
|
|
6
|
+
/**
|
|
7
|
+
* Pass in query string parameters after a redirect back to your app after a
|
|
8
|
+
* payment is processed. This function will handle all payment submission events
|
|
9
|
+
* supported by OneBlink. Will return a Transaction and the submission result
|
|
10
|
+
* that was returned from `handlePaymentSubmissionEvent()` before redirecting to
|
|
11
|
+
* `payment.hostedFormUrl`.
|
|
12
|
+
*
|
|
13
|
+
* #### Example
|
|
14
|
+
*
|
|
15
|
+
* ```js
|
|
16
|
+
* import queryString from 'query-string'
|
|
17
|
+
*
|
|
18
|
+
* const query = queryString.parse(window.location.search)
|
|
19
|
+
* const { transaction, submissionResult } =
|
|
20
|
+
* await paymentService.handlePaymentQuerystring(query)
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param query
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
export declare function handlePaymentQuerystring(query: Record<string, unknown>): Promise<HandlePaymentResult>;
|
|
27
|
+
export declare function checkForPaymentSubmissionEvent(formSubmission: FormSubmission): {
|
|
28
|
+
paymentSubmissionEvent: SubmissionEventTypes.FormPaymentEvent;
|
|
29
|
+
amount: number;
|
|
30
|
+
} | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Handle a submission result with a payment submission event. Will throw an
|
|
33
|
+
* error if a transaction has already been made using this submission result.
|
|
34
|
+
* Will return `undefined` if the submission does not have an amount. Will
|
|
35
|
+
* return the submission result passed in with a `payment` property if the
|
|
36
|
+
* submission requires processing.
|
|
37
|
+
*
|
|
38
|
+
* #### Example
|
|
39
|
+
*
|
|
40
|
+
* ```js
|
|
41
|
+
* const formSubmissionResult = {
|
|
42
|
+
* submissionId: '89c6e98e-f56f-45fc-84fe-c4fc62331d34',
|
|
43
|
+
* submissionTimestamp: '2020-07-29T01:03:26.573Z'
|
|
44
|
+
* formsAppId: 1,
|
|
45
|
+
* submission: {
|
|
46
|
+
* form: 'data',
|
|
47
|
+
* goes: 'here',
|
|
48
|
+
* amount: 1.50,
|
|
49
|
+
* }
|
|
50
|
+
* definition: OneBlinkForm,
|
|
51
|
+
* payment: null,
|
|
52
|
+
* }
|
|
53
|
+
* const paymentSubmissionEvent = {
|
|
54
|
+
* type: 'CP_PAY',
|
|
55
|
+
* configuration: {
|
|
56
|
+
* elementId: '12663efc-4c6a-4e72-8505-559edfe3e92e',
|
|
57
|
+
* gatewayId: '6658c5c4-e0db-483b-8af7-6a6464fe772c',
|
|
58
|
+
* },
|
|
59
|
+
* }
|
|
60
|
+
* const paymentReceiptUrl = `${window.location.origin}/payment-receipt`
|
|
61
|
+
* const paymentSubmissionResult = await paymentService.handlePaymentSubmissionEvent({
|
|
62
|
+
* formSubmissionResult,
|
|
63
|
+
* paymentSubmissionEvent,
|
|
64
|
+
* paymentReceiptUrl,
|
|
65
|
+
* })
|
|
66
|
+
* if (paymentSubmissionResult) {
|
|
67
|
+
* window.location.href = paymentSubmissionResult.payment.hostedFormUrl
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @param options
|
|
72
|
+
* @returns
|
|
73
|
+
*/
|
|
74
|
+
export declare function handlePaymentSubmissionEvent({ amount, formSubmissionResult, paymentSubmissionEvent, paymentReceiptUrl, paymentFormUrl, }: {
|
|
75
|
+
amount: number;
|
|
76
|
+
formSubmissionResult: FormSubmissionResult;
|
|
77
|
+
paymentSubmissionEvent: SubmissionEventTypes.FormPaymentEvent;
|
|
78
|
+
paymentReceiptUrl: string;
|
|
79
|
+
paymentFormUrl: string | undefined;
|
|
80
|
+
}): Promise<FormSubmissionResult['payment']>;
|
|
81
|
+
export declare function getFormSubmissionResultPayment(): Promise<{
|
|
82
|
+
formSubmissionResult: FormSubmissionResult;
|
|
83
|
+
paymentSubmissionEvent: SubmissionEventTypes.FormPaymentEvent;
|
|
84
|
+
}>;
|
|
85
|
+
/**
|
|
86
|
+
* Retrieve an array of detail items from a form submission payment.
|
|
87
|
+
*
|
|
88
|
+
* #### Example
|
|
89
|
+
*
|
|
90
|
+
* ```js
|
|
91
|
+
* const detailItems =
|
|
92
|
+
* paymentService.getDisplayDetailsFromFormSubmissionPayment(
|
|
93
|
+
* formSubmissionPayment,
|
|
94
|
+
* )
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @param formSubmissionPayment
|
|
98
|
+
* @returns
|
|
99
|
+
*/
|
|
100
|
+
export declare function getDisplayDetailsFromFormSubmissionPayment(formSubmissionPayment: SubmissionTypes.FormSubmissionPayment): {
|
|
101
|
+
amount: {
|
|
102
|
+
value: number;
|
|
103
|
+
formatted: string;
|
|
104
|
+
};
|
|
105
|
+
paymentDisplayDetails: {
|
|
106
|
+
label: string;
|
|
107
|
+
value: string;
|
|
108
|
+
key: SubmissionEventTypes.PaymentDisplayDetailKey;
|
|
109
|
+
}[];
|
|
110
|
+
} | undefined;
|