@pagamio/frontend-commons-lib 0.8.175 → 0.8.183
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/lib/api/client.d.ts +88 -0
- package/lib/api/client.js +339 -0
- package/lib/api/context.d.ts +112 -0
- package/lib/api/context.js +105 -0
- package/lib/api/index.d.ts +4 -0
- package/lib/api/index.js +4 -0
- package/lib/api/swr.d.ts +46 -0
- package/lib/api/swr.js +124 -0
- package/lib/api/types.d.ts +145 -0
- package/lib/api/types.js +10 -0
- package/lib/auth/authenticators/AuthenticatorFactory.d.ts +25 -0
- package/lib/auth/authenticators/AuthenticatorFactory.js +32 -0
- package/lib/auth/authenticators/index.d.ts +7 -0
- package/lib/auth/authenticators/index.js +7 -0
- package/lib/auth/authenticators/processors/DefaultAuthenticatorProcessor.d.ts +21 -0
- package/lib/auth/authenticators/processors/DefaultAuthenticatorProcessor.js +26 -0
- package/lib/auth/authenticators/processors/StrapiAuthenticatorProcessor.d.ts +74 -0
- package/lib/auth/authenticators/processors/StrapiAuthenticatorProcessor.js +99 -0
- package/lib/auth/authenticators/types.d.ts +26 -0
- package/lib/auth/authenticators/types.js +9 -0
- package/lib/auth/components/AppBanner.d.ts +7 -0
- package/lib/auth/components/AppBanner.js +9 -0
- package/lib/auth/components/AuthCard.d.ts +8 -0
- package/lib/auth/components/AuthCard.js +14 -0
- package/lib/auth/components/AuthFormUtils.d.ts +58 -0
- package/lib/auth/components/AuthFormUtils.js +52 -0
- package/lib/auth/components/AuthPageLayout.d.ts +45 -0
- package/lib/auth/components/AuthPageLayout.js +12 -0
- package/lib/auth/components/ChangePasswordPage.d.ts +12 -0
- package/lib/auth/components/ChangePasswordPage.js +59 -0
- package/lib/auth/components/CustomerRegistrationPage.d.ts +50 -0
- package/lib/auth/components/CustomerRegistrationPage.js +140 -0
- package/lib/auth/components/ForgotPasswordPage.d.ts +38 -0
- package/lib/auth/components/ForgotPasswordPage.js +76 -0
- package/lib/auth/components/LoginPage.d.ts +73 -0
- package/lib/auth/components/LoginPage.js +115 -0
- package/lib/auth/components/LogoutButton.d.ts +30 -0
- package/lib/auth/components/LogoutButton.js +47 -0
- package/lib/auth/components/ResetPasswordPage.d.ts +42 -0
- package/lib/auth/components/ResetPasswordPage.js +88 -0
- package/lib/auth/components/hooks/useChangeUserPassword.d.ts +26 -0
- package/lib/auth/components/hooks/useChangeUserPassword.js +63 -0
- package/lib/auth/components/index.d.ts +8 -0
- package/lib/auth/components/index.js +7 -0
- package/lib/auth/context/AuthContext.d.ts +65 -0
- package/lib/auth/context/AuthContext.js +150 -0
- package/lib/auth/context/index.d.ts +1 -0
- package/lib/auth/context/index.js +1 -0
- package/lib/auth/index.d.ts +7 -0
- package/lib/auth/index.js +7 -0
- package/lib/auth/services/AuthService.d.ts +230 -0
- package/lib/auth/services/AuthService.js +475 -0
- package/lib/auth/services/LogoutService.d.ts +27 -0
- package/lib/auth/services/LogoutService.js +98 -0
- package/lib/auth/services/index.d.ts +2 -0
- package/lib/auth/services/index.js +2 -0
- package/lib/auth/shared/index.d.ts +1 -0
- package/lib/auth/shared/index.js +1 -0
- package/lib/auth/shared/layout/AuthPageLayout.d.ts +10 -0
- package/lib/auth/shared/layout/AuthPageLayout.js +16 -0
- package/lib/auth/shared/layout/index.d.ts +1 -0
- package/lib/auth/shared/layout/index.js +1 -0
- package/lib/auth/types/auth.types.d.ts +234 -0
- package/lib/auth/types/auth.types.js +14 -0
- package/lib/auth/types/index.d.ts +1 -0
- package/lib/auth/types/index.js +1 -0
- package/lib/auth/utils/TokenManager.d.ts +43 -0
- package/lib/auth/utils/TokenManager.js +171 -0
- package/lib/auth/utils/Transformers.d.ts +158 -0
- package/lib/auth/utils/Transformers.js +263 -0
- package/lib/auth/utils/errorDetection.d.ts +22 -0
- package/lib/auth/utils/errorDetection.js +190 -0
- package/lib/auth/utils/index.d.ts +3 -0
- package/lib/auth/utils/index.js +3 -0
- package/lib/components/charts/LineGraph.d.ts +15 -0
- package/lib/components/charts/LineGraph.js +131 -0
- package/lib/components/icons/Icon.d.ts +8 -0
- package/lib/components/icons/Icon.js +13 -0
- package/lib/components/icons/index.d.ts +2 -0
- package/lib/components/icons/index.js +2 -0
- package/lib/components/icons/types.d.ts +26 -0
- package/lib/components/icons/types.js +33 -0
- package/lib/components/index.d.ts +3 -0
- package/lib/components/index.js +3 -0
- package/lib/components/layout/AppLayout.d.ts +34 -0
- package/lib/components/layout/AppLayout.js +19 -0
- package/lib/components/layout/AuthPageLayout.d.ts +13 -0
- package/lib/components/layout/AuthPageLayout.js +15 -0
- package/lib/components/layout/BreadcrumbNav.d.ts +2 -0
- package/lib/components/layout/BreadcrumbNav.js +10 -0
- package/lib/components/layout/LayoutContent.d.ts +6 -0
- package/lib/components/layout/LayoutContent.js +10 -0
- package/lib/components/layout/Navbar.d.ts +106 -0
- package/lib/components/layout/Navbar.js +66 -0
- package/lib/components/layout/PageHeader.d.ts +8 -0
- package/lib/components/layout/PageHeader.js +7 -0
- package/lib/components/layout/SessionExpiryModal.d.ts +10 -0
- package/lib/components/layout/SessionExpiryModal.js +9 -0
- package/lib/components/layout/Sidebar.d.ts +6 -0
- package/lib/components/layout/Sidebar.js +87 -0
- package/lib/components/layout/VerticalTabsLayout.d.ts +12 -0
- package/lib/components/layout/VerticalTabsLayout.js +14 -0
- package/lib/components/layout/index.d.ts +9 -0
- package/lib/components/layout/index.js +9 -0
- package/lib/components/ui/Avatar.d.ts +6 -0
- package/lib/components/ui/Avatar.js +11 -0
- package/lib/components/ui/AvatarIcon.d.ts +4 -0
- package/lib/components/ui/AvatarIcon.js +6 -0
- package/lib/components/ui/Button.d.ts +14 -0
- package/lib/components/ui/Button.js +30 -0
- package/lib/components/ui/Calendar.d.ts +9 -0
- package/lib/components/ui/Calendar.js +35 -0
- package/lib/components/ui/Card.d.ts +16 -0
- package/lib/components/ui/Card.js +6 -0
- package/lib/components/ui/Chart.d.ts +2 -0
- package/lib/components/ui/Chart.js +16 -0
- package/lib/components/ui/Checkbox.d.ts +4 -0
- package/lib/components/ui/Checkbox.js +8 -0
- package/lib/components/ui/Command.d.ts +80 -0
- package/lib/components/ui/Command.js +28 -0
- package/lib/components/ui/ContainedTab.d.ts +21 -0
- package/lib/components/ui/ContainedTab.js +37 -0
- package/lib/components/ui/DateFormat.d.ts +6 -0
- package/lib/components/ui/DateFormat.js +8 -0
- package/lib/components/ui/DatePicker.d.ts +14 -0
- package/lib/components/ui/DatePicker.js +91 -0
- package/lib/components/ui/DateRangeModal.d.ts +38 -0
- package/lib/components/ui/DateRangeModal.js +89 -0
- package/lib/components/ui/DetailsCard.d.ts +16 -0
- package/lib/components/ui/DetailsCard.js +14 -0
- package/lib/components/ui/DetailsPage.d.ts +36 -0
- package/lib/components/ui/DetailsPage.js +50 -0
- package/lib/components/ui/Dialog.d.ts +19 -0
- package/lib/components/ui/Dialog.js +22 -0
- package/lib/components/ui/EmptyState.d.ts +6 -0
- package/lib/components/ui/EmptyState.js +6 -0
- package/lib/components/ui/FilterComponent.d.ts +30 -0
- package/lib/components/ui/FilterComponent.js +80 -0
- package/lib/components/ui/FilterList.d.ts +52 -0
- package/lib/components/ui/FilterList.js +62 -0
- package/lib/components/ui/FilterSection.d.ts +31 -0
- package/lib/components/ui/FilterSection.js +21 -0
- package/lib/components/ui/FilterWrapper.d.ts +6 -0
- package/lib/components/ui/FilterWrapper.js +7 -0
- package/lib/components/ui/Form.d.ts +23 -0
- package/lib/components/ui/Form.js +62 -0
- package/lib/components/ui/HoverableValue.d.ts +7 -0
- package/lib/components/ui/HoverableValue.js +8 -0
- package/lib/components/ui/IconButton.d.ts +10 -0
- package/lib/components/ui/IconButton.js +10 -0
- package/lib/components/ui/ImageComponent.d.ts +8 -0
- package/lib/components/ui/ImageComponent.js +5 -0
- package/lib/components/ui/ImageUploader.d.ts +17 -0
- package/lib/components/ui/ImageUploader.js +144 -0
- package/lib/components/ui/Input.d.ts +4 -0
- package/lib/components/ui/Input.js +8 -0
- package/lib/components/ui/Label.d.ts +5 -0
- package/lib/components/ui/Label.js +9 -0
- package/lib/components/ui/Loader.d.ts +10 -0
- package/lib/components/ui/Loader.js +7 -0
- package/lib/components/ui/Modal.d.ts +72 -0
- package/lib/components/ui/Modal.js +31 -0
- package/lib/components/ui/MultiSelect.d.ts +16 -0
- package/lib/components/ui/MultiSelect.js +59 -0
- package/lib/components/ui/NotificationModal.d.ts +18 -0
- package/lib/components/ui/NotificationModal.js +40 -0
- package/lib/components/ui/PhoneInput.d.ts +12 -0
- package/lib/components/ui/PhoneInput.js +58 -0
- package/lib/components/ui/Popover.d.ts +7 -0
- package/lib/components/ui/Popover.js +10 -0
- package/lib/components/ui/Progress.d.ts +7 -0
- package/lib/components/ui/Progress.js +7 -0
- package/lib/components/ui/Radio.d.ts +5 -0
- package/lib/components/ui/Radio.js +14 -0
- package/lib/components/ui/RangeDatePicker.d.ts +78 -0
- package/lib/components/ui/RangeDatePicker.js +68 -0
- package/lib/components/ui/Select.d.ts +13 -0
- package/lib/components/ui/Select.js +57 -0
- package/lib/components/ui/Separator.d.ts +4 -0
- package/lib/components/ui/Separator.js +7 -0
- package/lib/components/ui/Sheet.d.ts +26 -0
- package/lib/components/ui/Sheet.js +37 -0
- package/lib/components/ui/StatusCell.d.ts +9 -0
- package/lib/components/ui/StatusCell.js +6 -0
- package/lib/components/ui/Switch.d.ts +10 -0
- package/lib/components/ui/Switch.js +22 -0
- package/lib/components/ui/Tab.d.ts +15 -0
- package/lib/components/ui/Tab.js +13 -0
- package/lib/components/ui/TableDownload.d.ts +11 -0
- package/lib/components/ui/TableDownload.js +82 -0
- package/lib/components/ui/TailwindIndicator.d.ts +1 -0
- package/lib/components/ui/TailwindIndicator.js +6 -0
- package/lib/components/ui/TextField.d.ts +60 -0
- package/lib/components/ui/TextField.js +42 -0
- package/lib/components/ui/Textarea.d.ts +5 -0
- package/lib/components/ui/Textarea.js +8 -0
- package/lib/components/ui/Toast.d.ts +12 -0
- package/lib/components/ui/Toast.js +25 -0
- package/lib/components/ui/UploadField.d.ts +15 -0
- package/lib/components/ui/UploadField.js +45 -0
- package/lib/components/ui/VerticalTab.d.ts +16 -0
- package/lib/components/ui/VerticalTab.js +13 -0
- package/lib/components/ui/index.d.ts +49 -0
- package/lib/components/ui/index.js +47 -0
- package/lib/context/BreadcrumbContext.d.ts +28 -0
- package/lib/context/BreadcrumbContext.js +238 -0
- package/lib/context/FormEngineDrawerProvider.d.ts +21 -0
- package/lib/context/FormEngineDrawerProvider.js +38 -0
- package/lib/context/MultiFormEngineDrawerProvider.d.ts +25 -0
- package/lib/context/MultiFormEngineDrawerProvider.js +89 -0
- package/lib/context/SidebarContext.d.ts +65 -0
- package/lib/context/SidebarContext.js +47 -0
- package/lib/context/ToastContext.d.ts +17 -0
- package/lib/context/ToastContext.js +29 -0
- package/lib/context/index.d.ts +5 -0
- package/lib/context/index.js +5 -0
- package/lib/dashboard-visuals/components/BaseChart.d.ts +55 -0
- package/lib/dashboard-visuals/components/BaseChart.js +201 -0
- package/lib/dashboard-visuals/components/CardWrapper.d.ts +10 -0
- package/lib/dashboard-visuals/components/CardWrapper.js +13 -0
- package/lib/dashboard-visuals/components/ChartDetailsModal.d.ts +57 -0
- package/lib/dashboard-visuals/components/ChartDetailsModal.js +27 -0
- package/lib/dashboard-visuals/components/ChartDetailsModalWrapper.d.ts +29 -0
- package/lib/dashboard-visuals/components/ChartDetailsModalWrapper.js +4 -0
- package/lib/dashboard-visuals/components/ChartFormatter.d.ts +22 -0
- package/lib/dashboard-visuals/components/ChartFormatter.js +46 -0
- package/lib/dashboard-visuals/components/ChartWrapper.d.ts +11 -0
- package/lib/dashboard-visuals/components/ChartWrapper.js +14 -0
- package/lib/dashboard-visuals/components/DashboardFilter.d.ts +8 -0
- package/lib/dashboard-visuals/components/DashboardFilter.js +17 -0
- package/lib/dashboard-visuals/components/DataTable.d.ts +3 -0
- package/lib/dashboard-visuals/components/DataTable.js +57 -0
- package/lib/dashboard-visuals/components/EmptyState.d.ts +6 -0
- package/lib/dashboard-visuals/components/EmptyState.js +6 -0
- package/lib/dashboard-visuals/components/ErrorState.d.ts +7 -0
- package/lib/dashboard-visuals/components/ErrorState.js +5 -0
- package/lib/dashboard-visuals/components/FilterComponentSkeleton.d.ts +3 -0
- package/lib/dashboard-visuals/components/FilterComponentSkeleton.js +11 -0
- package/lib/dashboard-visuals/components/Pagination.d.ts +10 -0
- package/lib/dashboard-visuals/components/Pagination.js +7 -0
- package/lib/dashboard-visuals/components/Switch.d.ts +8 -0
- package/lib/dashboard-visuals/components/Switch.js +10 -0
- package/lib/dashboard-visuals/components/TileSkeleton.d.ts +2 -0
- package/lib/dashboard-visuals/components/TileSkeleton.js +5 -0
- package/lib/dashboard-visuals/components/molecules/Analytics.d.ts +11 -0
- package/lib/dashboard-visuals/components/molecules/Analytics.js +9 -0
- package/lib/dashboard-visuals/components/molecules/DataGrid.d.ts +15 -0
- package/lib/dashboard-visuals/components/molecules/DataGrid.js +124 -0
- package/lib/dashboard-visuals/components/molecules/NoChartData.d.ts +6 -0
- package/lib/dashboard-visuals/components/molecules/NoChartData.js +6 -0
- package/lib/dashboard-visuals/components/molecules/VisualChart.d.ts +16 -0
- package/lib/dashboard-visuals/components/molecules/VisualChart.js +8 -0
- package/lib/dashboard-visuals/components/types.d.ts +62 -0
- package/lib/dashboard-visuals/components/types.js +1 -0
- package/lib/dashboard-visuals/hooks/useChartData.d.ts +15 -0
- package/lib/dashboard-visuals/hooks/useChartData.js +82 -0
- package/lib/dashboard-visuals/hooks/useTooltipFormatter.d.ts +13 -0
- package/lib/dashboard-visuals/hooks/useTooltipFormatter.js +10 -0
- package/lib/dashboard-visuals/index.d.ts +39 -0
- package/lib/dashboard-visuals/index.js +168 -0
- package/lib/dashboard-visuals/types/index.d.ts +83 -0
- package/lib/dashboard-visuals/types/index.js +1 -0
- package/lib/dashboard-visuals/types/metricDetailData.d.ts +25 -0
- package/lib/dashboard-visuals/types/metricDetailData.js +1 -0
- package/lib/dashboard-visuals/utils/api.d.ts +5 -0
- package/lib/dashboard-visuals/utils/api.js +6 -0
- package/lib/dashboard-visuals/utils/chartOptions.d.ts +481 -0
- package/lib/dashboard-visuals/utils/chartOptions.js +393 -0
- package/lib/dashboard-visuals/utils/chunkArray.d.ts +1 -0
- package/lib/dashboard-visuals/utils/chunkArray.js +7 -0
- package/lib/dashboard-visuals/utils/defaultColors.d.ts +1 -0
- package/lib/dashboard-visuals/utils/defaultColors.js +1 -0
- package/lib/dashboard-visuals/utils/formatUtil.d.ts +203 -0
- package/lib/dashboard-visuals/utils/formatUtil.js +472 -0
- package/lib/dashboard-visuals/utils/gridUtil.d.ts +11 -0
- package/lib/dashboard-visuals/utils/gridUtil.js +32 -0
- package/lib/dashboard-visuals/utils/index.d.ts +6 -0
- package/lib/dashboard-visuals/utils/index.js +6 -0
- package/lib/dashboard-visuals/utils/tooltipUtils.d.ts +11 -0
- package/lib/dashboard-visuals/utils/tooltipUtils.js +180 -0
- package/lib/dashboard-visuals/visualRegistry.d.ts +4 -0
- package/lib/dashboard-visuals/visualRegistry.js +41 -0
- package/lib/dashboard-visuals/visuals/BarChart.d.ts +58 -0
- package/lib/dashboard-visuals/visuals/BarChart.js +95 -0
- package/lib/dashboard-visuals/visuals/BarLineHybridChart.d.ts +33 -0
- package/lib/dashboard-visuals/visuals/BarLineHybridChart.js +60 -0
- package/lib/dashboard-visuals/visuals/BubbleChart.d.ts +25 -0
- package/lib/dashboard-visuals/visuals/BubbleChart.js +101 -0
- package/lib/dashboard-visuals/visuals/DistributionChart.d.ts +11 -0
- package/lib/dashboard-visuals/visuals/DistributionChart.js +48 -0
- package/lib/dashboard-visuals/visuals/DonutChart.d.ts +50 -0
- package/lib/dashboard-visuals/visuals/DonutChart.js +105 -0
- package/lib/dashboard-visuals/visuals/GaugeChart.d.ts +32 -0
- package/lib/dashboard-visuals/visuals/GaugeChart.js +53 -0
- package/lib/dashboard-visuals/visuals/GroupedBarChart.d.ts +47 -0
- package/lib/dashboard-visuals/visuals/GroupedBarChart.js +131 -0
- package/lib/dashboard-visuals/visuals/HeatmapChart.d.ts +79 -0
- package/lib/dashboard-visuals/visuals/HeatmapChart.js +146 -0
- package/lib/dashboard-visuals/visuals/HorizontalBarChart.d.ts +50 -0
- package/lib/dashboard-visuals/visuals/HorizontalBarChart.js +131 -0
- package/lib/dashboard-visuals/visuals/ItemPerformanceCard.d.ts +30 -0
- package/lib/dashboard-visuals/visuals/ItemPerformanceCard.js +31 -0
- package/lib/dashboard-visuals/visuals/LineChart.d.ts +56 -0
- package/lib/dashboard-visuals/visuals/LineChart.js +80 -0
- package/lib/dashboard-visuals/visuals/LineGraph.d.ts +50 -0
- package/lib/dashboard-visuals/visuals/LineGraph.js +189 -0
- package/lib/dashboard-visuals/visuals/MetricSummaryCard.d.ts +14 -0
- package/lib/dashboard-visuals/visuals/MetricSummaryCard.js +8 -0
- package/lib/dashboard-visuals/visuals/MultiGaugeChart.d.ts +39 -0
- package/lib/dashboard-visuals/visuals/MultiGaugeChart.js +119 -0
- package/lib/dashboard-visuals/visuals/PieChart.d.ts +59 -0
- package/lib/dashboard-visuals/visuals/PieChart.js +194 -0
- package/lib/dashboard-visuals/visuals/SelectedEventTile.d.ts +14 -0
- package/lib/dashboard-visuals/visuals/SelectedEventTile.js +35 -0
- package/lib/dashboard-visuals/visuals/SpeedometerChart.d.ts +53 -0
- package/lib/dashboard-visuals/visuals/SpeedometerChart.js +94 -0
- package/lib/dashboard-visuals/visuals/Table.d.ts +26 -0
- package/lib/dashboard-visuals/visuals/Table.js +113 -0
- package/lib/dashboard-visuals/visuals/Tile.d.ts +16 -0
- package/lib/dashboard-visuals/visuals/Tile.js +16 -0
- package/lib/dashboard-visuals/visuals/TreeMap.d.ts +25 -0
- package/lib/dashboard-visuals/visuals/TreeMap.js +45 -0
- package/lib/dashboard-visuals/visuals/WaterfallChart.d.ts +52 -0
- package/lib/dashboard-visuals/visuals/WaterfallChart.js +266 -0
- package/lib/form-engine/Form.d.ts +4 -0
- package/lib/form-engine/Form.js +14 -0
- package/lib/form-engine/FormEngine.d.ts +3 -0
- package/lib/form-engine/FormEngine.js +121 -0
- package/lib/form-engine/components/FieldWrapper.d.ts +18 -0
- package/lib/form-engine/components/FieldWrapper.js +63 -0
- package/lib/form-engine/components/index.d.ts +2 -0
- package/lib/form-engine/components/index.js +2 -0
- package/lib/form-engine/components/inputs/card-expiry-input/CardExpiryInput.d.ts +16 -0
- package/lib/form-engine/components/inputs/card-expiry-input/CardExpiryInput.js +48 -0
- package/lib/form-engine/components/inputs/checkbox-input/CheckboxInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/checkbox-input/CheckboxInput.js +5 -0
- package/lib/form-engine/components/inputs/credit-card-input/CreditCardInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/credit-card-input/CreditCardInput.js +82 -0
- package/lib/form-engine/components/inputs/date-input/DateInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/date-input/DateInput.js +7 -0
- package/lib/form-engine/components/inputs/date-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/date-input/index.js +1 -0
- package/lib/form-engine/components/inputs/email-input/EmailInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/email-input/EmailInput.js +5 -0
- package/lib/form-engine/components/inputs/email-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/email-input/index.js +1 -0
- package/lib/form-engine/components/inputs/index.d.ts +13 -0
- package/lib/form-engine/components/inputs/index.js +13 -0
- package/lib/form-engine/components/inputs/label-input/LabelInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/label-input/LabelInput.js +7 -0
- package/lib/form-engine/components/inputs/label-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/label-input/index.js +1 -0
- package/lib/form-engine/components/inputs/multi-select-input/MultiSelectInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/multi-select-input/MultiSelectInput.js +5 -0
- package/lib/form-engine/components/inputs/number-input/NumberInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/number-input/NumberInput.js +5 -0
- package/lib/form-engine/components/inputs/number-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/number-input/index.js +1 -0
- package/lib/form-engine/components/inputs/password-input/PasswordInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/password-input/PasswordInput.js +9 -0
- package/lib/form-engine/components/inputs/password-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/password-input/index.js +1 -0
- package/lib/form-engine/components/inputs/radio-button/RadioInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/radio-button/RadioInput.js +6 -0
- package/lib/form-engine/components/inputs/radio-button/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/radio-button/index.js +1 -0
- package/lib/form-engine/components/inputs/select/SelectInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/select/SelectInput.js +6 -0
- package/lib/form-engine/components/inputs/select/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/select/index.js +1 -0
- package/lib/form-engine/components/inputs/textarea-input/TextareaInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/textarea-input/TextareaInput.js +5 -0
- package/lib/form-engine/components/inputs/textarea-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/textarea-input/index.js +1 -0
- package/lib/form-engine/components/inputs/time-input/TimeInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/time-input/TimeInput.js +5 -0
- package/lib/form-engine/components/inputs/time-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/time-input/index.js +1 -0
- package/lib/form-engine/components/inputs/toggle-switch-input/ToggleSwitchInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/toggle-switch-input/ToggleSwitchInput.js +7 -0
- package/lib/form-engine/components/inputs/toggle-switch-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/toggle-switch-input/index.js +1 -0
- package/lib/form-engine/components/inputs/upload-field/UploadFieldForm.d.ts +4 -0
- package/lib/form-engine/components/inputs/upload-field/UploadFieldForm.js +59 -0
- package/lib/form-engine/components/inputs/upload-field/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/upload-field/index.js +1 -0
- package/lib/form-engine/hooks/useFormPersistence.d.ts +11 -0
- package/lib/form-engine/hooks/useFormPersistence.js +46 -0
- package/lib/form-engine/index.d.ts +5 -0
- package/lib/form-engine/index.js +5 -0
- package/lib/form-engine/registry/RegisterComponents.d.ts +1 -0
- package/lib/form-engine/registry/RegisterComponents.js +35 -0
- package/lib/form-engine/registry/Registry.d.ts +5 -0
- package/lib/form-engine/registry/Registry.js +13 -0
- package/lib/form-engine/registry/index.d.ts +2 -0
- package/lib/form-engine/registry/index.js +2 -0
- package/lib/form-engine/types/index.d.ts +311 -0
- package/lib/form-engine/types/index.js +1 -0
- package/lib/helpers/index.d.ts +2 -0
- package/lib/helpers/index.js +2 -0
- package/lib/helpers/utils.d.ts +37 -0
- package/lib/helpers/utils.js +77 -0
- package/lib/helpers/validations.d.ts +80 -0
- package/lib/helpers/validations.js +39 -0
- package/lib/index.d.ts +21 -0
- package/lib/index.js +30 -0
- package/lib/mocks/mockApiRequestsConfig.d.ts +2 -0
- package/lib/mocks/mockApiRequestsConfig.js +343 -0
- package/lib/pagamio-drawer/TopUpWalletDrawer/TopUpWalletContent.d.ts +14 -0
- package/lib/pagamio-drawer/TopUpWalletDrawer/TopUpWalletContent.js +40 -0
- package/lib/pagamio-drawer/TopUpWalletDrawer/index.d.ts +11 -0
- package/lib/pagamio-drawer/TopUpWalletDrawer/index.js +7 -0
- package/lib/pagamio-drawer/components/BaseDrawer.d.ts +11 -0
- package/lib/pagamio-drawer/components/BaseDrawer.js +10 -0
- package/lib/pagamio-drawer/components/DrawerContent.d.ts +27 -0
- package/lib/pagamio-drawer/components/DrawerContent.js +237 -0
- package/lib/pagamio-drawer/index.d.ts +22 -0
- package/lib/pagamio-drawer/index.js +133 -0
- package/lib/pagamio-table/data-table/ExportButton.d.ts +57 -0
- package/lib/pagamio-table/data-table/ExportButton.js +96 -0
- package/lib/pagamio-table/data-table/MantineCoreTable.d.ts +44 -0
- package/lib/pagamio-table/data-table/MantineCoreTable.js +129 -0
- package/lib/pagamio-table/data-table/Pagination.d.ts +10 -0
- package/lib/pagamio-table/data-table/Pagination.js +5 -0
- package/lib/pagamio-table/data-table/TableDownload.d.ts +8 -0
- package/lib/pagamio-table/data-table/TableDownload.js +81 -0
- package/lib/pagamio-table/data-table/TableToolbar.d.ts +3 -0
- package/lib/pagamio-table/data-table/TableToolbar.js +16 -0
- package/lib/pagamio-table/data-table/exportUtils.d.ts +42 -0
- package/lib/pagamio-table/data-table/exportUtils.js +782 -0
- package/lib/pagamio-table/data-table/index.d.ts +5 -0
- package/lib/pagamio-table/data-table/index.js +11 -0
- package/lib/pagamio-table/data-table/pdfExportUtils.d.ts +111 -0
- package/lib/pagamio-table/data-table/pdfExportUtils.js +113 -0
- package/lib/pagamio-table/data-table/types.d.ts +169 -0
- package/lib/pagamio-table/data-table/types.js +1 -0
- package/lib/pagamio-table/index.d.ts +4 -0
- package/lib/pagamio-table/index.js +4 -0
- package/lib/pagamio-table/utils/functionHelper.d.ts +12 -0
- package/lib/pagamio-table/utils/functionHelper.js +24 -0
- package/lib/pagamio-table/utils/index.d.ts +1 -0
- package/lib/pagamio-table/utils/index.js +1 -0
- package/lib/rbac/hooks.d.ts +39 -0
- package/lib/rbac/hooks.js +51 -0
- package/lib/rbac/index.d.ts +8 -0
- package/lib/rbac/index.js +11 -0
- package/lib/rbac/store.d.ts +24 -0
- package/lib/rbac/store.js +37 -0
- package/lib/rbac/types.d.ts +39 -0
- package/lib/rbac/types.js +4 -0
- package/lib/rbac/utils.d.ts +44 -0
- package/lib/rbac/utils.js +117 -0
- package/lib/shared/constants/index.d.ts +2 -0
- package/lib/shared/constants/index.js +2 -0
- package/lib/shared/hooks/index.d.ts +4 -0
- package/lib/shared/hooks/index.js +4 -0
- package/lib/shared/hooks/useAnyDrawerOpen.d.ts +4 -0
- package/lib/shared/hooks/useAnyDrawerOpen.js +18 -0
- package/lib/shared/hooks/useContainerWidth.d.ts +2 -0
- package/lib/shared/hooks/useContainerWidth.js +18 -0
- package/lib/shared/hooks/useImageUpload.d.ts +15 -0
- package/lib/shared/hooks/useImageUpload.js +66 -0
- package/lib/shared/hooks/useMediaQueries.d.ts +5 -0
- package/lib/shared/hooks/useMediaQueries.js +35 -0
- package/lib/shared/hooks/usePagamioTable.d.ts +158 -0
- package/lib/shared/hooks/usePagamioTable.js +475 -0
- package/lib/shared/hooks/useSessionTimer.d.ts +33 -0
- package/lib/shared/hooks/useSessionTimer.js +96 -0
- package/lib/shared/index.d.ts +4 -0
- package/lib/shared/index.js +4 -0
- package/lib/shared/types/index.d.ts +1 -0
- package/lib/shared/types/index.js +1 -0
- package/lib/shared/url/index.d.ts +9 -0
- package/lib/shared/url/index.js +20 -0
- package/lib/shared/utils/filterUtils.d.ts +5 -0
- package/lib/shared/utils/filterUtils.js +31 -0
- package/lib/shared/utils/functionHelper.d.ts +27 -0
- package/lib/shared/utils/functionHelper.js +124 -0
- package/lib/shared/utils/index.d.ts +2 -0
- package/lib/shared/utils/index.js +2 -0
- package/lib/shared/utils/localStorage.d.ts +53 -0
- package/lib/shared/utils/localStorage.js +139 -0
- package/lib/styles.css +6247 -0
- package/lib/translations/components/LocaleSwitcher.d.ts +7 -0
- package/lib/translations/components/LocaleSwitcher.js +18 -0
- package/lib/translations/components/index.d.ts +1 -0
- package/lib/translations/components/index.js +1 -0
- package/lib/translations/context/TranslationContext.d.ts +5 -0
- package/lib/translations/context/TranslationContext.js +151 -0
- package/lib/translations/context/index.d.ts +1 -0
- package/lib/translations/context/index.js +1 -0
- package/lib/translations/hooks/index.d.ts +2 -0
- package/lib/translations/hooks/index.js +2 -0
- package/lib/translations/hooks/useLibTranslations.d.ts +7 -0
- package/lib/translations/hooks/useLibTranslations.js +46 -0
- package/lib/translations/hooks/useTranslation.d.ts +7 -0
- package/lib/translations/hooks/useTranslation.js +11 -0
- package/lib/translations/index.d.ts +91 -0
- package/lib/translations/index.js +11 -0
- package/lib/translations/locales/en.json +21 -0
- package/lib/translations/locales/es.json +21 -0
- package/lib/translations/locales/fr.json +21 -0
- package/lib/translations/locales/pt.json +21 -0
- package/lib/translations/types/index.d.ts +24 -0
- package/lib/translations/types/index.js +1 -0
- package/lib/translations/utils/index.d.ts +6 -0
- package/lib/translations/utils/index.js +25 -0
- package/package.json +9 -1
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { ApiResponseTransformer, AuthResponse, EventsAppAuthConfig, VasAppAuthConfig } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Transforms authentication responses from the Events App API format into a standardized AuthResponse.
|
|
4
|
+
* This transformer handles responses that include a single token and role-based user information.
|
|
5
|
+
*
|
|
6
|
+
* Expected API response format:
|
|
7
|
+
* ```typescript
|
|
8
|
+
* {
|
|
9
|
+
* token: string;
|
|
10
|
+
* firstName: string;
|
|
11
|
+
* lastName: string;
|
|
12
|
+
* username: string;
|
|
13
|
+
* roles: string[] | null;
|
|
14
|
+
* roleName: string;
|
|
15
|
+
* roleDesc: string;
|
|
16
|
+
* vendorId: number;
|
|
17
|
+
* promoterId: number | null;
|
|
18
|
+
* company: string;
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @implements {ApiResponseTransformer<EventsAppAuthConfig>}
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const transformer = new EventsAppResponseTransformer();
|
|
27
|
+
* const response = {
|
|
28
|
+
* token: "jwt.token.here",
|
|
29
|
+
* firstName: "John",
|
|
30
|
+
* lastName: "Doe",
|
|
31
|
+
* username: "john.doe",
|
|
32
|
+
* roleName: "ADMIN"
|
|
33
|
+
* // ... other fields
|
|
34
|
+
* };
|
|
35
|
+
*
|
|
36
|
+
* if (transformer.canHandle(response)) {
|
|
37
|
+
* const authResponse = transformer.transform(response);
|
|
38
|
+
* // Use transformed response
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare class EventsAppResponseTransformer implements ApiResponseTransformer<EventsAppAuthConfig> {
|
|
43
|
+
/**
|
|
44
|
+
* Checks if the given response matches the Event App API format.
|
|
45
|
+
* Verifies the presence of required fields specific to Event App responses.
|
|
46
|
+
*
|
|
47
|
+
* @param response - The raw API response to check
|
|
48
|
+
* @returns True if the response contains 'token' and 'roleName' fields
|
|
49
|
+
*/
|
|
50
|
+
canHandle(response: any): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Transforms a Event App API response into the standardized AuthResponse format.
|
|
53
|
+
* Maps API-specific fields to the common auth response structure.
|
|
54
|
+
*
|
|
55
|
+
* @param response - The raw API response to transform
|
|
56
|
+
* @param remember
|
|
57
|
+
* @returns Standardized auth response with user and token information
|
|
58
|
+
* @throws Error if required fields are missing from the response
|
|
59
|
+
*/
|
|
60
|
+
transform(response: any, remember?: boolean): AuthResponse<EventsAppAuthConfig>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Transforms authentication responses from the Vas App API format into a standardized AuthResponse.
|
|
64
|
+
* This transformer handles responses that include both access and refresh tokens.
|
|
65
|
+
*
|
|
66
|
+
* Expected API response format:
|
|
67
|
+
* ```typescript
|
|
68
|
+
* {
|
|
69
|
+
* accessToken: string;
|
|
70
|
+
* refreshToken: string;
|
|
71
|
+
* accessTokenExpiresIn: number;
|
|
72
|
+
* refreshTokenExpiresIn: number;
|
|
73
|
+
* username: string;
|
|
74
|
+
* roles: string[];
|
|
75
|
+
* userId: number;
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @implements {ApiResponseTransformer<VasAppAuthConfig>}
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* const transformer = new VasAppResponseTransformer();
|
|
84
|
+
* const response = {
|
|
85
|
+
* accessToken: "access.token.here",
|
|
86
|
+
* refreshToken: "refresh.token.here",
|
|
87
|
+
* accessTokenExpiresIn: 3600,
|
|
88
|
+
* username: "vendor_user"
|
|
89
|
+
* // ... other fields
|
|
90
|
+
* };
|
|
91
|
+
*
|
|
92
|
+
* if (transformer.canHandle(response)) {
|
|
93
|
+
* const authResponse = transformer.transform(response);
|
|
94
|
+
* // Use transformed response
|
|
95
|
+
* }
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare class VasAppResponseTransformer implements ApiResponseTransformer<VasAppAuthConfig> {
|
|
99
|
+
/**
|
|
100
|
+
* Checks if the given response matches the Vas App API format.
|
|
101
|
+
* Verifies the presence of required fields specific to Vendor responses.
|
|
102
|
+
*
|
|
103
|
+
* @param response - The raw API response to check
|
|
104
|
+
* @returns True if the response contains both 'accessToken' and 'refreshToken' fields
|
|
105
|
+
*/
|
|
106
|
+
canHandle(response: any): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Transforms a Vas App API response into the standardized AuthResponse format.
|
|
109
|
+
* Maps API-specific fields to the common auth response structure.
|
|
110
|
+
*
|
|
111
|
+
* @param response - The raw API response to transform
|
|
112
|
+
* @param remember
|
|
113
|
+
* @returns Standardized auth response with user and token information
|
|
114
|
+
* @throws Error if required fields are missing from the response
|
|
115
|
+
*/
|
|
116
|
+
transform(response: any, remember?: boolean): AuthResponse<VasAppAuthConfig>;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Factory class for creating and managing response transformers.
|
|
120
|
+
* Implements the Factory pattern to dynamically select the appropriate transformer
|
|
121
|
+
* based on the API response format.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* const apiResponse = await fetchFromApi();
|
|
126
|
+
* const transformer = ResponseTransformerFactory.getTransformer(apiResponse);
|
|
127
|
+
* const authResponse = transformer.transform(apiResponse);
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export declare class ResponseTransformerFactory {
|
|
131
|
+
/**
|
|
132
|
+
* Collection of available transformers.
|
|
133
|
+
* Add new transformer instances here to support additional API response formats.
|
|
134
|
+
*
|
|
135
|
+
* @private
|
|
136
|
+
* @static
|
|
137
|
+
*/
|
|
138
|
+
private static readonly transformers;
|
|
139
|
+
/**
|
|
140
|
+
* Gets the appropriate transformer for the given API response.
|
|
141
|
+
* Iterates through available transformers and returns the first one that can handle the response.
|
|
142
|
+
*
|
|
143
|
+
* @param response - The raw API response to find a transformer for
|
|
144
|
+
* @returns The first transformer that can handle the response format
|
|
145
|
+
* @throws Error if no suitable transformer is found
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* try {
|
|
150
|
+
* const transformer = ResponseTransformerFactory.getTransformer(apiResponse);
|
|
151
|
+
* const authResponse = transformer.transform(apiResponse);
|
|
152
|
+
* } catch (error) {
|
|
153
|
+
* console.error('No suitable transformer found:', error);
|
|
154
|
+
* }
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
static getTransformer(response: any): ApiResponseTransformer<any>;
|
|
158
|
+
}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { jwtDecode } from 'jwt-decode';
|
|
2
|
+
/**
|
|
3
|
+
* Transforms authentication responses from the Events App API format into a standardized AuthResponse.
|
|
4
|
+
* This transformer handles responses that include a single token and role-based user information.
|
|
5
|
+
*
|
|
6
|
+
* Expected API response format:
|
|
7
|
+
* ```typescript
|
|
8
|
+
* {
|
|
9
|
+
* token: string;
|
|
10
|
+
* firstName: string;
|
|
11
|
+
* lastName: string;
|
|
12
|
+
* username: string;
|
|
13
|
+
* roles: string[] | null;
|
|
14
|
+
* roleName: string;
|
|
15
|
+
* roleDesc: string;
|
|
16
|
+
* vendorId: number;
|
|
17
|
+
* promoterId: number | null;
|
|
18
|
+
* company: string;
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @implements {ApiResponseTransformer<EventsAppAuthConfig>}
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const transformer = new EventsAppResponseTransformer();
|
|
27
|
+
* const response = {
|
|
28
|
+
* token: "jwt.token.here",
|
|
29
|
+
* firstName: "John",
|
|
30
|
+
* lastName: "Doe",
|
|
31
|
+
* username: "john.doe",
|
|
32
|
+
* roleName: "ADMIN"
|
|
33
|
+
* // ... other fields
|
|
34
|
+
* };
|
|
35
|
+
*
|
|
36
|
+
* if (transformer.canHandle(response)) {
|
|
37
|
+
* const authResponse = transformer.transform(response);
|
|
38
|
+
* // Use transformed response
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export class EventsAppResponseTransformer {
|
|
43
|
+
/**
|
|
44
|
+
* Checks if the given response matches the Event App API format.
|
|
45
|
+
* Verifies the presence of required fields specific to Event App responses.
|
|
46
|
+
*
|
|
47
|
+
* @param response - The raw API response to check
|
|
48
|
+
* @returns True if the response contains 'token' and 'roleName' fields
|
|
49
|
+
*/
|
|
50
|
+
canHandle(response) {
|
|
51
|
+
return response.hasOwnProperty('token') && response.hasOwnProperty('roleName');
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Transforms a Event App API response into the standardized AuthResponse format.
|
|
55
|
+
* Maps API-specific fields to the common auth response structure.
|
|
56
|
+
*
|
|
57
|
+
* @param response - The raw API response to transform
|
|
58
|
+
* @param remember
|
|
59
|
+
* @returns Standardized auth response with user and token information
|
|
60
|
+
* @throws Error if required fields are missing from the response
|
|
61
|
+
*/
|
|
62
|
+
transform(response, remember) {
|
|
63
|
+
// Decode the token using jwt-decode
|
|
64
|
+
let decodedToken;
|
|
65
|
+
try {
|
|
66
|
+
decodedToken = jwtDecode(response.token);
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
console.error('Error decoding JWT token:', error);
|
|
70
|
+
throw new Error('Failed to decode JWT token. Please check the token format.');
|
|
71
|
+
}
|
|
72
|
+
if (!decodedToken.exp) {
|
|
73
|
+
throw new Error('Token does not contain an expiry time (exp claim)');
|
|
74
|
+
}
|
|
75
|
+
let expiresIn;
|
|
76
|
+
if (remember) {
|
|
77
|
+
// 7 days in seconds
|
|
78
|
+
expiresIn = 7 * 24 * 60 * 60;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
// 30 minutes in seconds
|
|
82
|
+
expiresIn = 30 * 60;
|
|
83
|
+
}
|
|
84
|
+
if (expiresIn <= 0) {
|
|
85
|
+
throw new Error('Token has already expired');
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
user: {
|
|
89
|
+
id: response.userId,
|
|
90
|
+
userName: response.username,
|
|
91
|
+
firstName: response.firstName,
|
|
92
|
+
lastName: response.lastName,
|
|
93
|
+
roles: response.roles,
|
|
94
|
+
roleName: response.roleName,
|
|
95
|
+
roleDesc: response.roleDesc,
|
|
96
|
+
vendorId: response.vendorId,
|
|
97
|
+
promoterId: response.promoterId,
|
|
98
|
+
company: response.company,
|
|
99
|
+
hasIQRetailAccess: response.hasIQRetailAccess ?? false,
|
|
100
|
+
},
|
|
101
|
+
auth: {
|
|
102
|
+
accessToken: {
|
|
103
|
+
token: response.token,
|
|
104
|
+
expiresIn: expiresIn ?? 36000000,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Transforms authentication responses from the Vas App API format into a standardized AuthResponse.
|
|
112
|
+
* This transformer handles responses that include both access and refresh tokens.
|
|
113
|
+
*
|
|
114
|
+
* Expected API response format:
|
|
115
|
+
* ```typescript
|
|
116
|
+
* {
|
|
117
|
+
* accessToken: string;
|
|
118
|
+
* refreshToken: string;
|
|
119
|
+
* accessTokenExpiresIn: number;
|
|
120
|
+
* refreshTokenExpiresIn: number;
|
|
121
|
+
* username: string;
|
|
122
|
+
* roles: string[];
|
|
123
|
+
* userId: number;
|
|
124
|
+
* }
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
127
|
+
* @implements {ApiResponseTransformer<VasAppAuthConfig>}
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* const transformer = new VasAppResponseTransformer();
|
|
132
|
+
* const response = {
|
|
133
|
+
* accessToken: "access.token.here",
|
|
134
|
+
* refreshToken: "refresh.token.here",
|
|
135
|
+
* accessTokenExpiresIn: 3600,
|
|
136
|
+
* username: "vendor_user"
|
|
137
|
+
* // ... other fields
|
|
138
|
+
* };
|
|
139
|
+
*
|
|
140
|
+
* if (transformer.canHandle(response)) {
|
|
141
|
+
* const authResponse = transformer.transform(response);
|
|
142
|
+
* // Use transformed response
|
|
143
|
+
* }
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
export class VasAppResponseTransformer {
|
|
147
|
+
/**
|
|
148
|
+
* Checks if the given response matches the Vas App API format.
|
|
149
|
+
* Verifies the presence of required fields specific to Vendor responses.
|
|
150
|
+
*
|
|
151
|
+
* @param response - The raw API response to check
|
|
152
|
+
* @returns True if the response contains both 'accessToken' and 'refreshToken' fields
|
|
153
|
+
*/
|
|
154
|
+
canHandle(response) {
|
|
155
|
+
return response.hasOwnProperty('accessToken') && response.hasOwnProperty('refreshToken');
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Transforms a Vas App API response into the standardized AuthResponse format.
|
|
159
|
+
* Maps API-specific fields to the common auth response structure.
|
|
160
|
+
*
|
|
161
|
+
* @param response - The raw API response to transform
|
|
162
|
+
* @param remember
|
|
163
|
+
* @returns Standardized auth response with user and token information
|
|
164
|
+
* @throws Error if required fields are missing from the response
|
|
165
|
+
*/
|
|
166
|
+
transform(response, remember) {
|
|
167
|
+
let decodedToken;
|
|
168
|
+
try {
|
|
169
|
+
decodedToken = jwtDecode(response.accessToken);
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
console.error('Error decoding JWT access token:', error);
|
|
173
|
+
throw new Error('Failed to decode JWT access token. Please check the token format.');
|
|
174
|
+
}
|
|
175
|
+
if (!decodedToken.exp) {
|
|
176
|
+
throw new Error('Access token does not contain an expiry time (exp claim)');
|
|
177
|
+
}
|
|
178
|
+
let accessExpiresIn;
|
|
179
|
+
if (remember) {
|
|
180
|
+
// 7 days in seconds
|
|
181
|
+
accessExpiresIn = 7 * 24 * 60 * 60;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
// 30 minutes in seconds
|
|
185
|
+
accessExpiresIn = 30 * 60;
|
|
186
|
+
}
|
|
187
|
+
if (accessExpiresIn <= 0) {
|
|
188
|
+
throw new Error('Access token has already expired');
|
|
189
|
+
}
|
|
190
|
+
const refreshExpiresIn = remember ? 30 * 24 * 60 * 60 : 24 * 60 * 60; // 30 days or 1 day
|
|
191
|
+
return {
|
|
192
|
+
user: {
|
|
193
|
+
id: response.userId,
|
|
194
|
+
userName: response.username,
|
|
195
|
+
roles: response.roles,
|
|
196
|
+
userId: response.userId,
|
|
197
|
+
userType: response.userType,
|
|
198
|
+
userTypeId: response.userTypeId,
|
|
199
|
+
hasWallet: response.hasWallet ?? false,
|
|
200
|
+
},
|
|
201
|
+
auth: {
|
|
202
|
+
accessToken: {
|
|
203
|
+
token: response.accessToken,
|
|
204
|
+
expiresIn: accessExpiresIn,
|
|
205
|
+
},
|
|
206
|
+
refreshToken: {
|
|
207
|
+
token: response.refreshToken,
|
|
208
|
+
expiresIn: refreshExpiresIn,
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Factory class for creating and managing response transformers.
|
|
216
|
+
* Implements the Factory pattern to dynamically select the appropriate transformer
|
|
217
|
+
* based on the API response format.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```typescript
|
|
221
|
+
* const apiResponse = await fetchFromApi();
|
|
222
|
+
* const transformer = ResponseTransformerFactory.getTransformer(apiResponse);
|
|
223
|
+
* const authResponse = transformer.transform(apiResponse);
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
export class ResponseTransformerFactory {
|
|
227
|
+
/**
|
|
228
|
+
* Collection of available transformers.
|
|
229
|
+
* Add new transformer instances here to support additional API response formats.
|
|
230
|
+
*
|
|
231
|
+
* @private
|
|
232
|
+
* @static
|
|
233
|
+
*/
|
|
234
|
+
static transformers = [
|
|
235
|
+
new EventsAppResponseTransformer(),
|
|
236
|
+
new VasAppResponseTransformer(),
|
|
237
|
+
];
|
|
238
|
+
/**
|
|
239
|
+
* Gets the appropriate transformer for the given API response.
|
|
240
|
+
* Iterates through available transformers and returns the first one that can handle the response.
|
|
241
|
+
*
|
|
242
|
+
* @param response - The raw API response to find a transformer for
|
|
243
|
+
* @returns The first transformer that can handle the response format
|
|
244
|
+
* @throws Error if no suitable transformer is found
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```typescript
|
|
248
|
+
* try {
|
|
249
|
+
* const transformer = ResponseTransformerFactory.getTransformer(apiResponse);
|
|
250
|
+
* const authResponse = transformer.transform(apiResponse);
|
|
251
|
+
* } catch (error) {
|
|
252
|
+
* console.error('No suitable transformer found:', error);
|
|
253
|
+
* }
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
static getTransformer(response) {
|
|
257
|
+
const transformer = this.transformers.find((t) => t.canHandle(response));
|
|
258
|
+
if (!transformer) {
|
|
259
|
+
throw new Error('No suitable transformer found for response format');
|
|
260
|
+
}
|
|
261
|
+
return transformer;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Different types of errors that can occur during authentication
|
|
3
|
+
*/
|
|
4
|
+
export declare enum AuthErrorType {
|
|
5
|
+
NETWORK = "NETWORK",
|
|
6
|
+
AUTHENTICATION = "AUTHENTICATION",
|
|
7
|
+
SERVER = "SERVER",
|
|
8
|
+
VALIDATION = "VALIDATION",
|
|
9
|
+
UNKNOWN = "UNKNOWN"
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Structured error information
|
|
13
|
+
*/
|
|
14
|
+
export interface AuthErrorInfo {
|
|
15
|
+
type: AuthErrorType;
|
|
16
|
+
message: string;
|
|
17
|
+
originalError?: Error;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Detects the type of error and returns appropriate user-friendly message
|
|
21
|
+
*/
|
|
22
|
+
export declare function detectErrorType(error: unknown): AuthErrorInfo;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Different types of errors that can occur during authentication
|
|
3
|
+
*/
|
|
4
|
+
export var AuthErrorType;
|
|
5
|
+
(function (AuthErrorType) {
|
|
6
|
+
AuthErrorType["NETWORK"] = "NETWORK";
|
|
7
|
+
AuthErrorType["AUTHENTICATION"] = "AUTHENTICATION";
|
|
8
|
+
AuthErrorType["SERVER"] = "SERVER";
|
|
9
|
+
AuthErrorType["VALIDATION"] = "VALIDATION";
|
|
10
|
+
AuthErrorType["UNKNOWN"] = "UNKNOWN";
|
|
11
|
+
})(AuthErrorType || (AuthErrorType = {}));
|
|
12
|
+
/**
|
|
13
|
+
* Network error indicators
|
|
14
|
+
*/
|
|
15
|
+
const NETWORK_ERROR_INDICATORS = {
|
|
16
|
+
ERROR_MESSAGES: ['NetworkError', 'Failed to fetch', 'ERR_NETWORK', 'ERR_INTERNET_DISCONNECTED'],
|
|
17
|
+
STRING_INDICATORS: [
|
|
18
|
+
'network error',
|
|
19
|
+
'connection failed',
|
|
20
|
+
'timeout',
|
|
21
|
+
'unreachable',
|
|
22
|
+
'no internet',
|
|
23
|
+
'connection refused',
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Authentication error indicators
|
|
28
|
+
*/
|
|
29
|
+
const AUTH_ERROR_INDICATORS = ['invalid credentials', 'invalid username', 'invalid password', 'unauthorized'];
|
|
30
|
+
/**
|
|
31
|
+
* Common network error message
|
|
32
|
+
*/
|
|
33
|
+
const NETWORK_ERROR_MESSAGE = 'Unable to connect. Please check your internet connection and try again.';
|
|
34
|
+
/**
|
|
35
|
+
* Checks if the error is a network-related error
|
|
36
|
+
*/
|
|
37
|
+
function isNetworkError(error) {
|
|
38
|
+
// Handle fetch/network errors
|
|
39
|
+
if (error instanceof TypeError && error.message.includes('fetch')) {
|
|
40
|
+
return {
|
|
41
|
+
type: AuthErrorType.NETWORK,
|
|
42
|
+
message: NETWORK_ERROR_MESSAGE,
|
|
43
|
+
originalError: error,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
// Handle network timeout
|
|
47
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
48
|
+
return {
|
|
49
|
+
type: AuthErrorType.NETWORK,
|
|
50
|
+
message: 'Connection timed out. Please check your internet connection and try again.',
|
|
51
|
+
originalError: error,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
// Handle offline detection
|
|
55
|
+
if (!navigator.onLine) {
|
|
56
|
+
return {
|
|
57
|
+
type: AuthErrorType.NETWORK,
|
|
58
|
+
message: 'You appear to be offline. Please check your internet connection and try again.',
|
|
59
|
+
originalError: error instanceof Error ? error : undefined,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
// Handle Error objects with network indicators
|
|
63
|
+
if (error instanceof Error) {
|
|
64
|
+
const hasNetworkIndicator = NETWORK_ERROR_INDICATORS.ERROR_MESSAGES.some((indicator) => error.message.includes(indicator));
|
|
65
|
+
if (hasNetworkIndicator) {
|
|
66
|
+
return {
|
|
67
|
+
type: AuthErrorType.NETWORK,
|
|
68
|
+
message: NETWORK_ERROR_MESSAGE,
|
|
69
|
+
originalError: error,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Handle string errors with network indicators
|
|
74
|
+
if (typeof error === 'string') {
|
|
75
|
+
const lowercaseError = error.toLowerCase();
|
|
76
|
+
const hasNetworkIndicator = NETWORK_ERROR_INDICATORS.STRING_INDICATORS.some((indicator) => lowercaseError.includes(indicator));
|
|
77
|
+
if (hasNetworkIndicator) {
|
|
78
|
+
return {
|
|
79
|
+
type: AuthErrorType.NETWORK,
|
|
80
|
+
message: NETWORK_ERROR_MESSAGE,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Checks if the error is an authentication-related custom error
|
|
88
|
+
*/
|
|
89
|
+
function isCustomAuthError(customError) {
|
|
90
|
+
if (customError.code !== 'UNKNOWN_ERROR') {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
const message = customError.message.toLowerCase();
|
|
94
|
+
return AUTH_ERROR_INDICATORS.some((indicator) => message.includes(indicator));
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Creates error info object
|
|
98
|
+
*/
|
|
99
|
+
function createErrorInfo(type, message, originalError) {
|
|
100
|
+
return {
|
|
101
|
+
type,
|
|
102
|
+
message,
|
|
103
|
+
originalError: originalError instanceof Error ? originalError : undefined,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Handles custom server error format
|
|
108
|
+
*/
|
|
109
|
+
function handleCustomError(error) {
|
|
110
|
+
// Handle authentication errors
|
|
111
|
+
if (isCustomAuthError(error)) {
|
|
112
|
+
return createErrorInfo(AuthErrorType.AUTHENTICATION, 'Invalid credentials. Please check your username and password.', error);
|
|
113
|
+
}
|
|
114
|
+
// Handle validation errors
|
|
115
|
+
if (error.code === 'VALIDATION_ERROR') {
|
|
116
|
+
return createErrorInfo(AuthErrorType.VALIDATION, error.message || 'Please check your input and try again.', error);
|
|
117
|
+
}
|
|
118
|
+
// For other custom errors, use the server message
|
|
119
|
+
return createErrorInfo(AuthErrorType.UNKNOWN, error.message || 'An error occurred. Please try again.', error);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Maps HTTP status to error type and message
|
|
123
|
+
*/
|
|
124
|
+
function getHttpErrorMapping(status) {
|
|
125
|
+
if (status === 401 || status === 403) {
|
|
126
|
+
return {
|
|
127
|
+
type: AuthErrorType.AUTHENTICATION,
|
|
128
|
+
message: 'Invalid credentials. Please check your username and password.',
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
if (status === 422) {
|
|
132
|
+
return {
|
|
133
|
+
type: AuthErrorType.VALIDATION,
|
|
134
|
+
message: 'Please check your input and try again.',
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
if (status === 500 || status === 502 || status === 503) {
|
|
138
|
+
return {
|
|
139
|
+
type: AuthErrorType.SERVER,
|
|
140
|
+
message: 'Server is temporarily unavailable. Please try again later.',
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
if (status >= 500) {
|
|
144
|
+
return {
|
|
145
|
+
type: AuthErrorType.SERVER,
|
|
146
|
+
message: 'Server error occurred. Please try again later.',
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Handles HTTP status code errors
|
|
153
|
+
*/
|
|
154
|
+
function handleHttpError(httpError) {
|
|
155
|
+
const mapping = getHttpErrorMapping(httpError.status);
|
|
156
|
+
if (!mapping) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
const message = httpError.status === 422 && httpError.message ? httpError.message : mapping.message;
|
|
160
|
+
return createErrorInfo(mapping.type, message, httpError);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Detects the type of error and returns appropriate user-friendly message
|
|
164
|
+
*/
|
|
165
|
+
export function detectErrorType(error) {
|
|
166
|
+
// Check for network errors first
|
|
167
|
+
const networkError = isNetworkError(error);
|
|
168
|
+
if (networkError) {
|
|
169
|
+
return networkError;
|
|
170
|
+
}
|
|
171
|
+
// Handle custom error format
|
|
172
|
+
if (error && typeof error === 'object' && 'code' in error && 'message' in error) {
|
|
173
|
+
const customError = error;
|
|
174
|
+
return handleCustomError(customError);
|
|
175
|
+
}
|
|
176
|
+
// Handle HTTP errors
|
|
177
|
+
if (error && typeof error === 'object' && 'status' in error) {
|
|
178
|
+
const httpError = error;
|
|
179
|
+
const httpResult = handleHttpError(httpError);
|
|
180
|
+
if (httpResult) {
|
|
181
|
+
return httpResult;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// Handle generic Error objects
|
|
185
|
+
if (error instanceof Error) {
|
|
186
|
+
return createErrorInfo(AuthErrorType.UNKNOWN, error.message || 'An unexpected error occurred. Please try again.', error);
|
|
187
|
+
}
|
|
188
|
+
// Fallback
|
|
189
|
+
return createErrorInfo(AuthErrorType.UNKNOWN, 'An unexpected error occurred. Please try again.');
|
|
190
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface DataPoint {
|
|
3
|
+
date: string | Date;
|
|
4
|
+
value: number;
|
|
5
|
+
}
|
|
6
|
+
interface LineGraphProps {
|
|
7
|
+
data: DataPoint[];
|
|
8
|
+
title?: string;
|
|
9
|
+
yAxisLabel?: string;
|
|
10
|
+
color?: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
loading?: boolean;
|
|
13
|
+
}
|
|
14
|
+
declare const LineGraph: React.FC<LineGraphProps>;
|
|
15
|
+
export default LineGraph;
|