@greatapps/common 1.1.429 → 1.1.430
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/components/account/AccountModals.mjs +18 -0
- package/dist/components/account/AccountModals.mjs.map +1 -0
- package/dist/components/account/ConfigurationsMyAccountModal.mjs +129 -0
- package/dist/components/account/ConfigurationsMyAccountModal.mjs.map +1 -0
- package/dist/components/account/ConfirmDeleteAccountModal.mjs +45 -0
- package/dist/components/account/ConfirmDeleteAccountModal.mjs.map +1 -0
- package/dist/components/account/ConfirmGlobalPreferencesModal.mjs +45 -0
- package/dist/components/account/ConfirmGlobalPreferencesModal.mjs.map +1 -0
- package/dist/components/account/DeleteAccountModal.mjs +123 -0
- package/dist/components/account/DeleteAccountModal.mjs.map +1 -0
- package/dist/components/account/DisableTwoFactorAuthModal.mjs +67 -0
- package/dist/components/account/DisableTwoFactorAuthModal.mjs.map +1 -0
- package/dist/components/account/IsntPossibleDeleteAccountModal.mjs +42 -0
- package/dist/components/account/IsntPossibleDeleteAccountModal.mjs.map +1 -0
- package/dist/components/account/TwoFactorAuthModal.mjs +182 -0
- package/dist/components/account/TwoFactorAuthModal.mjs.map +1 -0
- package/dist/components/account/constants.mjs +29 -0
- package/dist/components/account/constants.mjs.map +1 -0
- package/dist/components/account/hooks/useChangeEmailForm.mjs +53 -0
- package/dist/components/account/hooks/useChangeEmailForm.mjs.map +1 -0
- package/dist/components/account/hooks/useChangePasswordForm.mjs +47 -0
- package/dist/components/account/hooks/useChangePasswordForm.mjs.map +1 -0
- package/dist/components/account/hooks/useChangePhoneForm.mjs +91 -0
- package/dist/components/account/hooks/useChangePhoneForm.mjs.map +1 -0
- package/dist/components/account/hooks/useConfigurationsModal.mjs +34 -0
- package/dist/components/account/hooks/useConfigurationsModal.mjs.map +1 -0
- package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs +54 -0
- package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs.map +1 -0
- package/dist/components/account/hooks/useOtpVerification.mjs +94 -0
- package/dist/components/account/hooks/useOtpVerification.mjs.map +1 -0
- package/dist/components/account/hooks/useTwoFactorAuthForm.mjs +80 -0
- package/dist/components/account/hooks/useTwoFactorAuthForm.mjs.map +1 -0
- package/dist/components/account/sections/ChangeEmailModal.mjs +181 -0
- package/dist/components/account/sections/ChangeEmailModal.mjs.map +1 -0
- package/dist/components/account/sections/ChangePasswordSection.mjs +64 -0
- package/dist/components/account/sections/ChangePasswordSection.mjs.map +1 -0
- package/dist/components/account/sections/ChangePhoneModal.mjs +192 -0
- package/dist/components/account/sections/ChangePhoneModal.mjs.map +1 -0
- package/dist/components/account/sections/MyProfileSection.mjs +317 -0
- package/dist/components/account/sections/MyProfileSection.mjs.map +1 -0
- package/dist/components/account/sections/PreferencesSection.mjs +227 -0
- package/dist/components/account/sections/PreferencesSection.mjs.map +1 -0
- package/dist/components/account/sections/SecuritySection.mjs +31 -0
- package/dist/components/account/sections/SecuritySection.mjs.map +1 -0
- package/dist/components/embeds/CrispEmbed.mjs +89 -0
- package/dist/components/embeds/CrispEmbed.mjs.map +1 -0
- package/dist/components/embeds/FrillEmbed.mjs +107 -0
- package/dist/components/embeds/FrillEmbed.mjs.map +1 -0
- package/dist/components/handlers/SearchParamsHandler.mjs +24 -0
- package/dist/components/handlers/SearchParamsHandler.mjs.map +1 -0
- package/dist/components/layouts/AppMobileNavBar.mjs +60 -0
- package/dist/components/layouts/AppMobileNavBar.mjs.map +1 -0
- package/dist/components/layouts/AppNavBar.mjs +37 -0
- package/dist/components/layouts/AppNavBar.mjs.map +1 -0
- package/dist/components/layouts/CollapsibleSidebar.mjs +65 -0
- package/dist/components/layouts/CollapsibleSidebar.mjs.map +1 -0
- package/dist/components/layouts/MainLayout.mjs +60 -0
- package/dist/components/layouts/MainLayout.mjs.map +1 -0
- package/dist/components/layouts/MdSideBarNavigation.mjs +54 -0
- package/dist/components/layouts/MdSideBarNavigation.mjs.map +1 -0
- package/dist/components/layouts/NavBar.mjs +152 -0
- package/dist/components/layouts/NavBar.mjs.map +1 -0
- package/dist/components/layouts/NavBarItem.mjs +23 -0
- package/dist/components/layouts/NavBarItem.mjs.map +1 -0
- package/dist/components/layouts/NotificationsPopover.mjs +97 -0
- package/dist/components/layouts/NotificationsPopover.mjs.map +1 -0
- package/dist/components/layouts/ProfilePopover.mjs +152 -0
- package/dist/components/layouts/ProfilePopover.mjs.map +1 -0
- package/dist/components/layouts/SideBarNavigation.mjs +63 -0
- package/dist/components/layouts/SideBarNavigation.mjs.map +1 -0
- package/dist/components/layouts/UsersSelectorPopover.mjs +210 -0
- package/dist/components/layouts/UsersSelectorPopover.mjs.map +1 -0
- package/dist/components/layouts/WhitelabelCodes.mjs +50 -0
- package/dist/components/layouts/WhitelabelCodes.mjs.map +1 -0
- package/dist/components/modals/BuyCreditsModal.mjs +281 -0
- package/dist/components/modals/BuyCreditsModal.mjs.map +1 -0
- package/dist/components/modals/ModalManager.mjs +19 -0
- package/dist/components/modals/ModalManager.mjs.map +1 -0
- package/dist/components/modals/Modals.mjs +20 -0
- package/dist/components/modals/Modals.mjs.map +1 -0
- package/dist/components/modals/PaidPlanRequiredModal.mjs +46 -0
- package/dist/components/modals/PaidPlanRequiredModal.mjs.map +1 -0
- package/dist/components/modals/cards/AddCardModal.mjs +215 -0
- package/dist/components/modals/cards/AddCardModal.mjs.map +1 -0
- package/dist/components/modals/cards/CardFormFields.mjs +268 -0
- package/dist/components/modals/cards/CardFormFields.mjs.map +1 -0
- package/dist/components/navigation/AppNavigation.mjs +33 -0
- package/dist/components/navigation/AppNavigation.mjs.map +1 -0
- package/dist/components/navigation/AppNavigationContext.mjs +13 -0
- package/dist/components/navigation/AppNavigationContext.mjs.map +1 -0
- package/dist/components/navigation/CancelledSubscriptionBanner.mjs +52 -0
- package/dist/components/navigation/CancelledSubscriptionBanner.mjs.map +1 -0
- package/dist/components/navigation/NavItem.mjs +41 -0
- package/dist/components/navigation/NavItem.mjs.map +1 -0
- package/dist/components/navigation/NavItemsContext.mjs +16 -0
- package/dist/components/navigation/NavItemsContext.mjs.map +1 -0
- package/dist/components/navigation/ProjectSelectorPopover.mjs +147 -0
- package/dist/components/navigation/ProjectSelectorPopover.mjs.map +1 -0
- package/dist/components/navigation/shells/DesktopShell.mjs +11 -0
- package/dist/components/navigation/shells/DesktopShell.mjs.map +1 -0
- package/dist/components/navigation/shells/MdShell.mjs +11 -0
- package/dist/components/navigation/shells/MdShell.mjs.map +1 -0
- package/dist/components/navigation/shells/MobileShell.mjs +27 -0
- package/dist/components/navigation/shells/MobileShell.mjs.map +1 -0
- package/dist/components/navigation/shells/TabsMobileShell.mjs +61 -0
- package/dist/components/navigation/shells/TabsMobileShell.mjs.map +1 -0
- package/dist/components/navigation/subcomponents/BottomLinks.mjs +35 -0
- package/dist/components/navigation/subcomponents/BottomLinks.mjs.map +1 -0
- package/dist/components/navigation/subcomponents/CreditsCard.mjs +33 -0
- package/dist/components/navigation/subcomponents/CreditsCard.mjs.map +1 -0
- package/dist/components/navigation/subcomponents/NavItems.mjs +25 -0
- package/dist/components/navigation/subcomponents/NavItems.mjs.map +1 -0
- package/dist/components/navigation/subcomponents/PlanCard.mjs +25 -0
- package/dist/components/navigation/subcomponents/PlanCard.mjs.map +1 -0
- package/dist/components/navigation/subcomponents/ProjectSelector.mjs +145 -0
- package/dist/components/navigation/subcomponents/ProjectSelector.mjs.map +1 -0
- package/dist/components/navigation/types.mjs +1 -0
- package/dist/components/navigation/types.mjs.map +1 -0
- package/dist/components/pages/NotFoundPage.mjs +47 -0
- package/dist/components/pages/NotFoundPage.mjs.map +1 -0
- package/dist/components/pages/notifications/Notifications.mjs +159 -0
- package/dist/components/pages/notifications/Notifications.mjs.map +1 -0
- package/dist/components/ui/buttons/Button.mjs +52 -0
- package/dist/components/ui/buttons/Button.mjs.map +1 -0
- package/dist/components/ui/buttons/CancelButton.mjs +17 -0
- package/dist/components/ui/buttons/CancelButton.mjs.map +1 -0
- package/dist/components/ui/buttons/CopyButton.mjs +42 -0
- package/dist/components/ui/buttons/CopyButton.mjs.map +1 -0
- package/dist/components/ui/data-display/Accordion.mjs +76 -0
- package/dist/components/ui/data-display/Accordion.mjs.map +1 -0
- package/dist/components/ui/data-display/Badge.mjs +42 -0
- package/dist/components/ui/data-display/Badge.mjs.map +1 -0
- package/dist/components/ui/data-display/Card.mjs +92 -0
- package/dist/components/ui/data-display/Card.mjs.map +1 -0
- package/dist/components/ui/data-display/CardBrandIcons.mjs +484 -0
- package/dist/components/ui/data-display/CardBrandIcons.mjs.map +1 -0
- package/dist/components/ui/data-display/CardItem.mjs +67 -0
- package/dist/components/ui/data-display/CardItem.mjs.map +1 -0
- package/dist/components/ui/data-display/Pagination.mjs +118 -0
- package/dist/components/ui/data-display/Pagination.mjs.map +1 -0
- package/dist/components/ui/data-display/PaymentInfoCard.mjs +161 -0
- package/dist/components/ui/data-display/PaymentInfoCard.mjs.map +1 -0
- package/dist/components/ui/data-display/ScrollArea.mjs +62 -0
- package/dist/components/ui/data-display/ScrollArea.mjs.map +1 -0
- package/dist/components/ui/data-display/Separator.mjs +28 -0
- package/dist/components/ui/data-display/Separator.mjs.map +1 -0
- package/dist/components/ui/data-display/Table.mjs +116 -0
- package/dist/components/ui/data-display/Table.mjs.map +1 -0
- package/dist/components/ui/data-display/Tabs.mjs +69 -0
- package/dist/components/ui/data-display/Tabs.mjs.map +1 -0
- package/dist/components/ui/data-display/UserAvatar.mjs +49 -0
- package/dist/components/ui/data-display/UserAvatar.mjs.map +1 -0
- package/dist/components/ui/feedback/CircularProgress.mjs +71 -0
- package/dist/components/ui/feedback/CircularProgress.mjs.map +1 -0
- package/dist/components/ui/feedback/DefaultCircularProgress.mjs +63 -0
- package/dist/components/ui/feedback/DefaultCircularProgress.mjs.map +1 -0
- package/dist/components/ui/feedback/LoadingOverlay.mjs +19 -0
- package/dist/components/ui/feedback/LoadingOverlay.mjs.map +1 -0
- package/dist/components/ui/feedback/Progress.mjs +37 -0
- package/dist/components/ui/feedback/Progress.mjs.map +1 -0
- package/dist/components/ui/feedback/Skeleton.mjs +9 -0
- package/dist/components/ui/feedback/Skeleton.mjs.map +1 -0
- package/dist/components/ui/feedback/Toast.mjs +77 -0
- package/dist/components/ui/feedback/Toast.mjs.map +1 -0
- package/dist/components/ui/form/Calendar.mjs +204 -0
- package/dist/components/ui/form/Calendar.mjs.map +1 -0
- package/dist/components/ui/form/Checkbox.mjs +33 -0
- package/dist/components/ui/form/Checkbox.mjs.map +1 -0
- package/dist/components/ui/form/ComboboxField.mjs +130 -0
- package/dist/components/ui/form/ComboboxField.mjs.map +1 -0
- package/dist/components/ui/form/DatePicker.mjs +82 -0
- package/dist/components/ui/form/DatePicker.mjs.map +1 -0
- package/dist/components/ui/form/DateRangePicker.mjs +92 -0
- package/dist/components/ui/form/DateRangePicker.mjs.map +1 -0
- package/dist/components/ui/form/FormField.mjs +103 -0
- package/dist/components/ui/form/FormField.mjs.map +1 -0
- package/dist/components/ui/form/Input.mjs +21 -0
- package/dist/components/ui/form/Input.mjs.map +1 -0
- package/dist/components/ui/form/InputOtp.mjs +70 -0
- package/dist/components/ui/form/InputOtp.mjs.map +1 -0
- package/dist/components/ui/form/PhoneInput.mjs +176 -0
- package/dist/components/ui/form/PhoneInput.mjs.map +1 -0
- package/dist/components/ui/form/RadioGroup.mjs +37 -0
- package/dist/components/ui/form/RadioGroup.mjs.map +1 -0
- package/dist/components/ui/form/Select.mjs +179 -0
- package/dist/components/ui/form/Select.mjs.map +1 -0
- package/dist/components/ui/form/SelectField.mjs +80 -0
- package/dist/components/ui/form/SelectField.mjs.map +1 -0
- package/dist/components/ui/form/Switch.mjs +33 -0
- package/dist/components/ui/form/Switch.mjs.map +1 -0
- package/dist/components/ui/form/SwitchOptionFieldWithIcon.mjs +40 -0
- package/dist/components/ui/form/SwitchOptionFieldWithIcon.mjs.map +1 -0
- package/dist/components/ui/form/TextAreaField.mjs +56 -0
- package/dist/components/ui/form/TextAreaField.mjs.map +1 -0
- package/dist/components/ui/form/Textarea.mjs +20 -0
- package/dist/components/ui/form/Textarea.mjs.map +1 -0
- package/dist/components/ui/overlay/Command.mjs +178 -0
- package/dist/components/ui/overlay/Command.mjs.map +1 -0
- package/dist/components/ui/overlay/Dialog.mjs +142 -0
- package/dist/components/ui/overlay/Dialog.mjs.map +1 -0
- package/dist/components/ui/overlay/Popover.mjs +46 -0
- package/dist/components/ui/overlay/Popover.mjs.map +1 -0
- package/dist/components/ui/overlay/Sheet.mjs +149 -0
- package/dist/components/ui/overlay/Sheet.mjs.map +1 -0
- package/dist/components/ui/overlay/Tooltip.mjs +57 -0
- package/dist/components/ui/overlay/Tooltip.mjs.map +1 -0
- package/dist/components/widgets/notifications/NotificationCard.mjs +54 -0
- package/dist/components/widgets/notifications/NotificationCard.mjs.map +1 -0
- package/dist/enums/AccountSectionType.mjs +11 -0
- package/dist/enums/AccountSectionType.mjs.map +1 -0
- package/dist/hooks/copy-to-clipboard.hook.mjs +52 -0
- package/dist/hooks/copy-to-clipboard.hook.mjs.map +1 -0
- package/dist/hooks/useCountdownTimer.mjs +29 -0
- package/dist/hooks/useCountdownTimer.mjs.map +1 -0
- package/dist/hooks/useDebounce.mjs +19 -0
- package/dist/hooks/useDebounce.mjs.map +1 -0
- package/dist/hooks/useDebounceState.mjs +12 -0
- package/dist/hooks/useDebounceState.mjs.map +1 -0
- package/dist/hooks/useDebouncedEffect.mjs +44 -0
- package/dist/hooks/useDebouncedEffect.mjs.map +1 -0
- package/dist/hooks/useIsMobile.mjs +18 -0
- package/dist/hooks/useIsMobile.mjs.map +1 -0
- package/dist/hooks/usePasswordVisibility.mjs +13 -0
- package/dist/hooks/usePasswordVisibility.mjs.map +1 -0
- package/dist/index.mjs +528 -0
- package/dist/index.mjs.map +1 -0
- package/dist/infra/api/client.mjs +162 -0
- package/dist/infra/api/client.mjs.map +1 -0
- package/dist/infra/api/types.mjs +31 -0
- package/dist/infra/api/types.mjs.map +1 -0
- package/dist/infra/utils/client-info.mjs +27 -0
- package/dist/infra/utils/client-info.mjs.map +1 -0
- package/dist/infra/utils/clsx.mjs +9 -0
- package/dist/infra/utils/clsx.mjs.map +1 -0
- package/dist/infra/utils/date.mjs +11 -0
- package/dist/infra/utils/date.mjs.map +1 -0
- package/dist/infra/utils/params.mjs +21 -0
- package/dist/infra/utils/params.mjs.map +1 -0
- package/dist/infra/utils/parser.mjs +24 -0
- package/dist/infra/utils/parser.mjs.map +1 -0
- package/dist/infra/utils/percentage.mjs +20 -0
- package/dist/infra/utils/percentage.mjs.map +1 -0
- package/dist/middleware.mjs +10 -0
- package/dist/middleware.mjs.map +1 -0
- package/dist/middlewares/chain.mjs +37 -0
- package/dist/middlewares/chain.mjs.map +1 -0
- package/dist/middlewares/create-auth-middleware.mjs +32 -0
- package/dist/middlewares/create-auth-middleware.mjs.map +1 -0
- package/dist/middlewares/types.mjs +11 -0
- package/dist/middlewares/types.mjs.map +1 -0
- package/dist/modules/accounts/actions/account-management.action.mjs +98 -0
- package/dist/modules/accounts/actions/account-management.action.mjs.map +1 -0
- package/dist/modules/accounts/actions/find-current-account.action.mjs +10 -0
- package/dist/modules/accounts/actions/find-current-account.action.mjs.map +1 -0
- package/dist/modules/accounts/actions/list-currencies.action.mjs +10 -0
- package/dist/modules/accounts/actions/list-currencies.action.mjs.map +1 -0
- package/dist/modules/accounts/actions/list-timezones.action.mjs +10 -0
- package/dist/modules/accounts/actions/list-timezones.action.mjs.map +1 -0
- package/dist/modules/accounts/hooks/current-account.hook.mjs +24 -0
- package/dist/modules/accounts/hooks/current-account.hook.mjs.map +1 -0
- package/dist/modules/accounts/hooks/useAccountManagement.mjs +71 -0
- package/dist/modules/accounts/hooks/useAccountManagement.mjs.map +1 -0
- package/dist/modules/accounts/hooks/useCurrencies.mjs +17 -0
- package/dist/modules/accounts/hooks/useCurrencies.mjs.map +1 -0
- package/dist/modules/accounts/hooks/useTimezones.mjs +17 -0
- package/dist/modules/accounts/hooks/useTimezones.mjs.map +1 -0
- package/dist/modules/accounts/hooks/useViaCep.mjs +19 -0
- package/dist/modules/accounts/hooks/useViaCep.mjs.map +1 -0
- package/dist/modules/accounts/services/account.service.mjs +182 -0
- package/dist/modules/accounts/services/account.service.mjs.map +1 -0
- package/dist/modules/accounts/services/currency.service.mjs +24 -0
- package/dist/modules/accounts/services/currency.service.mjs.map +1 -0
- package/dist/modules/accounts/services/timezone.service.mjs +65 -0
- package/dist/modules/accounts/services/timezone.service.mjs.map +1 -0
- package/dist/modules/accounts/services/two-factor.service.mjs +78 -0
- package/dist/modules/accounts/services/two-factor.service.mjs.map +1 -0
- package/dist/modules/accounts/types.mjs +1 -0
- package/dist/modules/accounts/types.mjs.map +1 -0
- package/dist/modules/auth/actions/login.action.mjs +14 -0
- package/dist/modules/auth/actions/login.action.mjs.map +1 -0
- package/dist/modules/auth/actions/logout.action.mjs +14 -0
- package/dist/modules/auth/actions/logout.action.mjs.map +1 -0
- package/dist/modules/auth/actions/register.action.mjs +14 -0
- package/dist/modules/auth/actions/register.action.mjs.map +1 -0
- package/dist/modules/auth/actions/validate-session.action.mjs +48 -0
- package/dist/modules/auth/actions/validate-session.action.mjs.map +1 -0
- package/dist/modules/auth/actions/verify-two-factor.action.mjs +17 -0
- package/dist/modules/auth/actions/verify-two-factor.action.mjs.map +1 -0
- package/dist/modules/auth/hooks/login.hook.mjs +13 -0
- package/dist/modules/auth/hooks/login.hook.mjs.map +1 -0
- package/dist/modules/auth/hooks/logout.hook.mjs +13 -0
- package/dist/modules/auth/hooks/logout.hook.mjs.map +1 -0
- package/dist/modules/auth/hooks/register.hook.mjs +13 -0
- package/dist/modules/auth/hooks/register.hook.mjs.map +1 -0
- package/dist/modules/auth/hooks/useManagementPermissions.mjs +41 -0
- package/dist/modules/auth/hooks/useManagementPermissions.mjs.map +1 -0
- package/dist/modules/auth/hooks/useUserQuery.mjs +63 -0
- package/dist/modules/auth/hooks/useUserQuery.mjs.map +1 -0
- package/dist/modules/auth/schema.mjs +1 -0
- package/dist/modules/auth/schema.mjs.map +1 -0
- package/dist/modules/auth/services/auth.service.mjs +341 -0
- package/dist/modules/auth/services/auth.service.mjs.map +1 -0
- package/dist/modules/auth/types/management-permission.type.mjs +1 -0
- package/dist/modules/auth/types/management-permission.type.mjs.map +1 -0
- package/dist/modules/auth/utils/assert-management-permission.mjs +42 -0
- package/dist/modules/auth/utils/assert-management-permission.mjs.map +1 -0
- package/dist/modules/auth/utils/assert-management-subscription.mjs +33 -0
- package/dist/modules/auth/utils/assert-management-subscription.mjs.map +1 -0
- package/dist/modules/auth/utils/assert-paid-subscription.mjs +40 -0
- package/dist/modules/auth/utils/assert-paid-subscription.mjs.map +1 -0
- package/dist/modules/auth/utils/assert-subscription-addon.mjs +35 -0
- package/dist/modules/auth/utils/assert-subscription-addon.mjs.map +1 -0
- package/dist/modules/auth/utils/build-wl-override.mjs +27 -0
- package/dist/modules/auth/utils/build-wl-override.mjs.map +1 -0
- package/dist/modules/auth/utils/get-user-context.mjs +25 -0
- package/dist/modules/auth/utils/get-user-context.mjs.map +1 -0
- package/dist/modules/cards/actions/create-card.action.mjs +10 -0
- package/dist/modules/cards/actions/create-card.action.mjs.map +1 -0
- package/dist/modules/cards/actions/list-cards.action.mjs +10 -0
- package/dist/modules/cards/actions/list-cards.action.mjs.map +1 -0
- package/dist/modules/cards/hooks/cards.hook.mjs +16 -0
- package/dist/modules/cards/hooks/cards.hook.mjs.map +1 -0
- package/dist/modules/cards/hooks/create-card.hook.mjs +18 -0
- package/dist/modules/cards/hooks/create-card.hook.mjs.map +1 -0
- package/dist/modules/cards/services/cards.service.mjs +44 -0
- package/dist/modules/cards/services/cards.service.mjs.map +1 -0
- package/dist/modules/cards/types.mjs +27 -0
- package/dist/modules/cards/types.mjs.map +1 -0
- package/dist/modules/ia-credits/actions/list-ia-credits.action.mjs +10 -0
- package/dist/modules/ia-credits/actions/list-ia-credits.action.mjs.map +1 -0
- package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs +76 -0
- package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs.map +1 -0
- package/dist/modules/ia-credits/services/ia-credits.service.mjs +31 -0
- package/dist/modules/ia-credits/services/ia-credits.service.mjs.map +1 -0
- package/dist/modules/ia-credits/types.mjs +25 -0
- package/dist/modules/ia-credits/types.mjs.map +1 -0
- package/dist/modules/plans/actions/find-plan-by-id.action.mjs +10 -0
- package/dist/modules/plans/actions/find-plan-by-id.action.mjs.map +1 -0
- package/dist/modules/plans/hooks/use-has-plan-addon.hook.mjs +13 -0
- package/dist/modules/plans/hooks/use-has-plan-addon.hook.mjs.map +1 -0
- package/dist/modules/plans/hooks/use-plan-by-id.hook.mjs +15 -0
- package/dist/modules/plans/hooks/use-plan-by-id.hook.mjs.map +1 -0
- package/dist/modules/plans/services/plans.service.mjs +34 -0
- package/dist/modules/plans/services/plans.service.mjs.map +1 -0
- package/dist/modules/plans/types/plan.type.mjs +20 -0
- package/dist/modules/plans/types/plan.type.mjs.map +1 -0
- package/dist/modules/projects/actions/add-project-user.action.mjs +10 -0
- package/dist/modules/projects/actions/add-project-user.action.mjs.map +1 -0
- package/dist/modules/projects/actions/list-all-account-users.action.mjs +10 -0
- package/dist/modules/projects/actions/list-all-account-users.action.mjs.map +1 -0
- package/dist/modules/projects/actions/list-available-users.action.mjs +10 -0
- package/dist/modules/projects/actions/list-available-users.action.mjs.map +1 -0
- package/dist/modules/projects/actions/list-project-users.action.mjs +10 -0
- package/dist/modules/projects/actions/list-project-users.action.mjs.map +1 -0
- package/dist/modules/projects/actions/remove-project-user.action.mjs +10 -0
- package/dist/modules/projects/actions/remove-project-user.action.mjs.map +1 -0
- package/dist/modules/projects/hooks/add-project-user.hook.mjs +61 -0
- package/dist/modules/projects/hooks/add-project-user.hook.mjs.map +1 -0
- package/dist/modules/projects/hooks/list-all-account-users.hook.mjs +35 -0
- package/dist/modules/projects/hooks/list-all-account-users.hook.mjs.map +1 -0
- package/dist/modules/projects/hooks/list-available-users.hook.mjs +34 -0
- package/dist/modules/projects/hooks/list-available-users.hook.mjs.map +1 -0
- package/dist/modules/projects/hooks/list-project-users.hook.mjs +34 -0
- package/dist/modules/projects/hooks/list-project-users.hook.mjs.map +1 -0
- package/dist/modules/projects/hooks/remove-project-user.hook.mjs +61 -0
- package/dist/modules/projects/hooks/remove-project-user.hook.mjs.map +1 -0
- package/dist/modules/projects/services/project-users.service.mjs +96 -0
- package/dist/modules/projects/services/project-users.service.mjs.map +1 -0
- package/dist/modules/projects/types.mjs +23 -0
- package/dist/modules/projects/types.mjs.map +1 -0
- package/dist/modules/subscriptions/actions/calculate-subscription.action.mjs +10 -0
- package/dist/modules/subscriptions/actions/calculate-subscription.action.mjs.map +1 -0
- package/dist/modules/subscriptions/actions/list-subscriptions.action.mjs +10 -0
- package/dist/modules/subscriptions/actions/list-subscriptions.action.mjs.map +1 -0
- package/dist/modules/subscriptions/actions/update-subscription-plan.action.mjs +12 -0
- package/dist/modules/subscriptions/actions/update-subscription-plan.action.mjs.map +1 -0
- package/dist/modules/subscriptions/constants/addons.constants.mjs +24 -0
- package/dist/modules/subscriptions/constants/addons.constants.mjs.map +1 -0
- package/dist/modules/subscriptions/constants/query-keys.constants.mjs +5 -0
- package/dist/modules/subscriptions/constants/query-keys.constants.mjs.map +1 -0
- package/dist/modules/subscriptions/hooks/calculate-subscription.hook.mjs +13 -0
- package/dist/modules/subscriptions/hooks/calculate-subscription.hook.mjs.map +1 -0
- package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs +17 -0
- package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs.map +1 -0
- package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs +17 -0
- package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs.map +1 -0
- package/dist/modules/subscriptions/hooks/update-subscription-plan.hook.mjs +22 -0
- package/dist/modules/subscriptions/hooks/update-subscription-plan.hook.mjs.map +1 -0
- package/dist/modules/subscriptions/hooks/use-cancelled-subscription-guard.mjs +37 -0
- package/dist/modules/subscriptions/hooks/use-cancelled-subscription-guard.mjs.map +1 -0
- package/dist/modules/subscriptions/services/subscriptions.service.mjs +75 -0
- package/dist/modules/subscriptions/services/subscriptions.service.mjs.map +1 -0
- package/dist/modules/subscriptions/types/billing-period.type.mjs +1 -0
- package/dist/modules/subscriptions/types/billing-period.type.mjs.map +1 -0
- package/dist/modules/subscriptions/types/calculate-subscription.type.mjs +72 -0
- package/dist/modules/subscriptions/types/calculate-subscription.type.mjs.map +1 -0
- package/dist/modules/subscriptions/types/subscription.type.mjs +57 -0
- package/dist/modules/subscriptions/types/subscription.type.mjs.map +1 -0
- package/dist/modules/subscriptions/utils/build-plan-extras.mjs +37 -0
- package/dist/modules/subscriptions/utils/build-plan-extras.mjs.map +1 -0
- package/dist/modules/subscriptions/utils/has-subscription-expired.mjs +10 -0
- package/dist/modules/subscriptions/utils/has-subscription-expired.mjs.map +1 -0
- package/dist/modules/subscriptions/utils/periodicity.mjs +48 -0
- package/dist/modules/subscriptions/utils/periodicity.mjs.map +1 -0
- package/dist/modules/subscriptions/utils/resolve-plan-extras-prices.mjs +14 -0
- package/dist/modules/subscriptions/utils/resolve-plan-extras-prices.mjs.map +1 -0
- package/dist/modules/users/action/find-user-by-id.action.mjs +10 -0
- package/dist/modules/users/action/find-user-by-id.action.mjs.map +1 -0
- package/dist/modules/users/action/list-messages.action.mjs +13 -0
- package/dist/modules/users/action/list-messages.action.mjs.map +1 -0
- package/dist/modules/users/action/mark-all-messages-as-read.action.mjs +10 -0
- package/dist/modules/users/action/mark-all-messages-as-read.action.mjs.map +1 -0
- package/dist/modules/users/action/mark-message-as-read.action.mjs +10 -0
- package/dist/modules/users/action/mark-message-as-read.action.mjs.map +1 -0
- package/dist/modules/users/hooks/messages.hook.mjs +57 -0
- package/dist/modules/users/hooks/messages.hook.mjs.map +1 -0
- package/dist/modules/users/schema/messages.schema.mjs +21 -0
- package/dist/modules/users/schema/messages.schema.mjs.map +1 -0
- package/dist/modules/users/schema.mjs +11 -0
- package/dist/modules/users/schema.mjs.map +1 -0
- package/dist/modules/users/services/messages.service.mjs +35 -0
- package/dist/modules/users/services/messages.service.mjs.map +1 -0
- package/dist/modules/users/services/user.service.mjs +52 -0
- package/dist/modules/users/services/user.service.mjs.map +1 -0
- package/dist/modules/whitelabel/actions/find-whitelabel.action.mjs +21 -0
- package/dist/modules/whitelabel/actions/find-whitelabel.action.mjs.map +1 -0
- package/dist/modules/whitelabel/actions/revalidate-whitelabel.action.mjs +19 -0
- package/dist/modules/whitelabel/actions/revalidate-whitelabel.action.mjs.map +1 -0
- package/dist/modules/whitelabel/schema.mjs +1 -0
- package/dist/modules/whitelabel/schema.mjs.map +1 -0
- package/dist/modules/whitelabel/services/whitelabel.service.mjs +146 -0
- package/dist/modules/whitelabel/services/whitelabel.service.mjs.map +1 -0
- package/dist/modules/whitelabel/utils/normalize-hostname.mjs +35 -0
- package/dist/modules/whitelabel/utils/normalize-hostname.mjs.map +1 -0
- package/dist/providers/auth.provider.mjs +114 -0
- package/dist/providers/auth.provider.mjs.map +1 -0
- package/dist/providers/query.provider.mjs +99 -0
- package/dist/providers/query.provider.mjs.map +1 -0
- package/dist/providers/whitelabel.provider.mjs +42 -0
- package/dist/providers/whitelabel.provider.mjs.map +1 -0
- package/dist/server.mjs +111 -0
- package/dist/server.mjs.map +1 -0
- package/dist/store/useAccountModals.mjs +18 -0
- package/dist/store/useAccountModals.mjs.map +1 -0
- package/dist/store/useBuyCreditsModal.mjs +16 -0
- package/dist/store/useBuyCreditsModal.mjs.map +1 -0
- package/dist/store/useDesktopSidebarStore.mjs +39 -0
- package/dist/store/useDesktopSidebarStore.mjs.map +1 -0
- package/dist/store/useMdSidebarStore.mjs +28 -0
- package/dist/store/useMdSidebarStore.mjs.map +1 -0
- package/dist/store/useMobileNavbarSheet.mjs +14 -0
- package/dist/store/useMobileNavbarSheet.mjs.map +1 -0
- package/dist/store/useModalManager.mjs +75 -0
- package/dist/store/useModalManager.mjs.map +1 -0
- package/dist/store/usePaidPlanRequiredModal.mjs +14 -0
- package/dist/store/usePaidPlanRequiredModal.mjs.map +1 -0
- package/dist/utils/browser/clipboard.mjs +36 -0
- package/dist/utils/browser/clipboard.mjs.map +1 -0
- package/dist/utils/constants/br-states.mjs +33 -0
- package/dist/utils/constants/br-states.mjs.map +1 -0
- package/dist/utils/countries.mjs +219 -0
- package/dist/utils/countries.mjs.map +1 -0
- package/dist/utils/file/index.mjs +9 -0
- package/dist/utils/file/index.mjs.map +1 -0
- package/dist/utils/format/masks.mjs +67 -0
- package/dist/utils/format/masks.mjs.map +1 -0
- package/dist/utils/intl/locales.mjs +12 -0
- package/dist/utils/intl/locales.mjs.map +1 -0
- package/dist/utils/safeServerAction.mjs +16 -0
- package/dist/utils/safeServerAction.mjs.map +1 -0
- package/dist/utils/validators/account.mjs +27 -0
- package/dist/utils/validators/account.mjs.map +1 -0
- package/dist/utils/validators/common.mjs +47 -0
- package/dist/utils/validators/common.mjs.map +1 -0
- package/dist/utils/withAction.mjs +13 -0
- package/dist/utils/withAction.mjs.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/subscriptions/utils/periodicity.ts"],"sourcesContent":["import type { BillingPeriod } from '../types/billing-period.type';\nimport type { CalculateSubscriptionResponse } from '../types/calculate-subscription.type';\n\nexport function periodicityToBillingPeriod(\n periodicity: number | string | null | undefined\n): BillingPeriod | null {\n if (periodicity === 30 || periodicity === 1 || periodicity === 'monthly') return 'monthly';\n if (periodicity === 180 || periodicity === 3 || periodicity === 'semiannual') return 'semiannual';\n if (periodicity === 365 || periodicity === 2 || periodicity === 'annual') return 'annual';\n return null;\n}\n\nexport function billingPeriodToNumeric(billingPeriod: BillingPeriod): 30 | 180 | 365 {\n if (billingPeriod === 'semiannual') return 180;\n if (billingPeriod === 'annual') return 365;\n return 30;\n}\n\nexport function getPeriodicityLabel(periodicity: number | string | null | undefined): string {\n const period = periodicityToBillingPeriod(periodicity);\n if (period === 'semiannual') return 'Semestral';\n if (period === 'annual') return 'Anual';\n return 'Mensal';\n}\n\nexport function getBillingPeriodSuffix(billingPeriod: BillingPeriod): string {\n if (billingPeriod === 'semiannual') return '/semestre';\n if (billingPeriod === 'annual') return '/ano';\n return '/mês';\n}\n\nexport function getBillingPeriodLabel(billingPeriod: BillingPeriod): string {\n if (billingPeriod === 'semiannual') return 'semestral';\n if (billingPeriod === 'annual') return 'anual';\n return 'mensal';\n}\n\nexport function getBillingPeriodMonths(billingPeriod: BillingPeriod): number {\n if (billingPeriod === 'semiannual') return 6;\n if (billingPeriod === 'annual') return 12;\n return 1;\n}\n\nexport function getPriceFromCalculatedData(\n data: CalculateSubscriptionResponse,\n periodicity: number | string | null | undefined\n): number {\n const period = periodicityToBillingPeriod(periodicity);\n if (period === 'annual') return data.year;\n if (period === 'semiannual') return data.semmester;\n return data.month;\n}\n"],"mappings":"AAGO,SAAS,2BACd,aACsB;AACtB,MAAI,gBAAgB,MAAM,gBAAgB,KAAK,gBAAgB,UAAW,QAAO;AACjF,MAAI,gBAAgB,OAAO,gBAAgB,KAAK,gBAAgB,aAAc,QAAO;AACrF,MAAI,gBAAgB,OAAO,gBAAgB,KAAK,gBAAgB,SAAU,QAAO;AACjF,SAAO;AACT;AAEO,SAAS,uBAAuB,eAA8C;AACnF,MAAI,kBAAkB,aAAc,QAAO;AAC3C,MAAI,kBAAkB,SAAU,QAAO;AACvC,SAAO;AACT;AAEO,SAAS,oBAAoB,aAAyD;AAC3F,QAAM,SAAS,2BAA2B,WAAW;AACrD,MAAI,WAAW,aAAc,QAAO;AACpC,MAAI,WAAW,SAAU,QAAO;AAChC,SAAO;AACT;AAEO,SAAS,uBAAuB,eAAsC;AAC3E,MAAI,kBAAkB,aAAc,QAAO;AAC3C,MAAI,kBAAkB,SAAU,QAAO;AACvC,SAAO;AACT;AAEO,SAAS,sBAAsB,eAAsC;AAC1E,MAAI,kBAAkB,aAAc,QAAO;AAC3C,MAAI,kBAAkB,SAAU,QAAO;AACvC,SAAO;AACT;AAEO,SAAS,uBAAuB,eAAsC;AAC3E,MAAI,kBAAkB,aAAc,QAAO;AAC3C,MAAI,kBAAkB,SAAU,QAAO;AACvC,SAAO;AACT;AAEO,SAAS,2BACd,MACA,aACQ;AACR,QAAM,SAAS,2BAA2B,WAAW;AACrD,MAAI,WAAW,SAAU,QAAO,KAAK;AACrC,MAAI,WAAW,aAAc,QAAO,KAAK;AACzC,SAAO,KAAK;AACd;","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
function resolvePlanExtrasPrices(extras, subscriptionItems) {
|
|
3
|
+
return extras.map((extra) => {
|
|
4
|
+
const item = subscriptionItems.find((i) => i.id_addon === extra.id_addon);
|
|
5
|
+
if (item) {
|
|
6
|
+
return { ...extra, value: item.value };
|
|
7
|
+
}
|
|
8
|
+
return { ...extra, value: extra.value ?? 0 };
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
resolvePlanExtrasPrices
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=resolve-plan-extras-prices.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/subscriptions/utils/resolve-plan-extras-prices.ts"],"sourcesContent":["import 'server-only';\n\nimport type { SubscriptionItem } from '../types/subscription.type';\n\ninterface PlanExtraInput {\n id_addon: number;\n value?: number;\n quantity: number;\n [key: string]: unknown;\n}\n\nexport function resolvePlanExtrasPrices<T extends PlanExtraInput>(\n extras: T[],\n subscriptionItems: SubscriptionItem[]\n): T[] {\n return extras.map((extra) => {\n const item = subscriptionItems.find((i) => i.id_addon === extra.id_addon);\n if (item) {\n return { ...extra, value: item.value };\n }\n return { ...extra, value: extra.value ?? 0 };\n });\n}\n"],"mappings":"AAAA,OAAO;AAWA,SAAS,wBACd,QACA,mBACK;AACL,SAAO,OAAO,IAAI,CAAC,UAAU;AAC3B,UAAM,OAAO,kBAAkB,KAAK,CAAC,MAAM,EAAE,aAAa,MAAM,QAAQ;AACxE,QAAI,MAAM;AACR,aAAO,EAAE,GAAG,OAAO,OAAO,KAAK,MAAM;AAAA,IACvC;AACA,WAAO,EAAE,GAAG,OAAO,OAAO,MAAM,SAAS,EAAE;AAAA,EAC7C,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
|
+
import { userService } from "../services/user.service";
|
|
4
|
+
async function findUserById() {
|
|
5
|
+
return safeServerAction(() => userService.findById());
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
findUserById
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=find-user-by-id.action.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/users/action/find-user-by-id.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { userService } from '../services/user.service';\n\nexport async function findUserById() {\n return safeServerAction(() => userService.findById());\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAE5B,eAAsB,eAAe;AACnC,SAAO,iBAAiB,MAAM,YAAY,SAAS,CAAC;AACtD;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
|
+
import { messagesService } from "../services/messages.service";
|
|
4
|
+
async function listMessagesAction(params) {
|
|
5
|
+
return safeServerAction(async () => {
|
|
6
|
+
const result = await messagesService.listMessages(params);
|
|
7
|
+
return { data: result.data, total: result.total, totalUnread: result.totalUnread };
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
listMessagesAction
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=list-messages.action.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/users/action/list-messages.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { messagesService } from '../services/messages.service';\nimport type { FindMessagesParams } from '../schema/messages.schema';\n\nexport async function listMessagesAction(params?: Partial<FindMessagesParams>) {\n return safeServerAction(async () => {\n const result = await messagesService.listMessages(params);\n return { data: result.data, total: result.total, totalUnread: result.totalUnread };\n });\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAGhC,eAAsB,mBAAmB,QAAsC;AAC7E,SAAO,iBAAiB,YAAY;AAClC,UAAM,SAAS,MAAM,gBAAgB,aAAa,MAAM;AACxD,WAAO,EAAE,MAAM,OAAO,MAAM,OAAO,OAAO,OAAO,aAAa,OAAO,YAAY;AAAA,EACnF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
|
+
import { messagesService } from "../services/messages.service";
|
|
4
|
+
async function markAllMessagesAsReadAction() {
|
|
5
|
+
return safeServerAction(() => messagesService.markAllAsRead());
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
markAllMessagesAsReadAction
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=mark-all-messages-as-read.action.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/users/action/mark-all-messages-as-read.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { messagesService } from '../services/messages.service';\n\nexport async function markAllMessagesAsReadAction() {\n return safeServerAction(() => messagesService.markAllAsRead());\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAEhC,eAAsB,8BAA8B;AAClD,SAAO,iBAAiB,MAAM,gBAAgB,cAAc,CAAC;AAC/D;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
|
+
import { messagesService } from "../services/messages.service";
|
|
4
|
+
async function markMessageAsReadAction(messageId) {
|
|
5
|
+
return safeServerAction(() => messagesService.markAsRead(messageId));
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
markMessageAsReadAction
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=mark-message-as-read.action.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/users/action/mark-message-as-read.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { messagesService } from '../services/messages.service';\n\nexport async function markMessageAsReadAction(messageId: string) {\n return safeServerAction(() => messagesService.markAsRead(messageId));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAEhC,eAAsB,wBAAwB,WAAmB;AAC/D,SAAO,iBAAiB,MAAM,gBAAgB,WAAW,SAAS,CAAC;AACrE;","names":[]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { listMessagesAction } from "../action/list-messages.action";
|
|
4
|
+
import { markMessageAsReadAction } from "../action/mark-message-as-read.action";
|
|
5
|
+
import { markAllMessagesAsReadAction } from "../action/mark-all-messages-as-read.action";
|
|
6
|
+
import { withAction } from "../../../utils/withAction";
|
|
7
|
+
const MESSAGES_QUERY_KEY = ["messages"];
|
|
8
|
+
const INFINITE_MESSAGES_PAGE_SIZE = 10;
|
|
9
|
+
function useMessages(params) {
|
|
10
|
+
return useQuery({
|
|
11
|
+
queryKey: [...MESSAGES_QUERY_KEY, params],
|
|
12
|
+
queryFn: withAction(() => listMessagesAction(params))
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function useInfiniteMessages(params) {
|
|
16
|
+
return useInfiniteQuery({
|
|
17
|
+
queryKey: [...MESSAGES_QUERY_KEY, "infinite", params],
|
|
18
|
+
queryFn: ({ pageParam }) => withAction(
|
|
19
|
+
() => listMessagesAction({
|
|
20
|
+
...params,
|
|
21
|
+
page: pageParam,
|
|
22
|
+
limit: INFINITE_MESSAGES_PAGE_SIZE
|
|
23
|
+
})
|
|
24
|
+
)(),
|
|
25
|
+
getNextPageParam: (lastPage, allPages) => {
|
|
26
|
+
const loaded = allPages.reduce((sum, p) => sum + p.data.length, 0);
|
|
27
|
+
return loaded < lastPage.total ? allPages.length + 1 : void 0;
|
|
28
|
+
},
|
|
29
|
+
initialPageParam: 1
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function useMarkMessageAsRead() {
|
|
33
|
+
const queryClient = useQueryClient();
|
|
34
|
+
return useMutation({
|
|
35
|
+
mutationFn: withAction(markMessageAsReadAction),
|
|
36
|
+
onSuccess: () => {
|
|
37
|
+
queryClient.invalidateQueries({ queryKey: MESSAGES_QUERY_KEY });
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function useMarkAllMessagesAsRead() {
|
|
42
|
+
const queryClient = useQueryClient();
|
|
43
|
+
return useMutation({
|
|
44
|
+
mutationFn: withAction(markAllMessagesAsReadAction),
|
|
45
|
+
onSuccess: () => {
|
|
46
|
+
queryClient.invalidateQueries({ queryKey: MESSAGES_QUERY_KEY });
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
MESSAGES_QUERY_KEY,
|
|
52
|
+
useInfiniteMessages,
|
|
53
|
+
useMarkAllMessagesAsRead,
|
|
54
|
+
useMarkMessageAsRead,
|
|
55
|
+
useMessages
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=messages.hook.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/users/hooks/messages.hook.ts"],"sourcesContent":["'use client';\n\nimport { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { listMessagesAction } from '../action/list-messages.action';\nimport { markMessageAsReadAction } from '../action/mark-message-as-read.action';\nimport { markAllMessagesAsReadAction } from '../action/mark-all-messages-as-read.action';\nimport { withAction } from '../../../utils/withAction';\nimport type { FindMessagesParams } from '../schema/messages.schema';\n\nexport const MESSAGES_QUERY_KEY = ['messages'];\n\nconst INFINITE_MESSAGES_PAGE_SIZE = 10;\n\nexport function useMessages(params?: Partial<FindMessagesParams>) {\n return useQuery({\n queryKey: [...MESSAGES_QUERY_KEY, params],\n queryFn: withAction(() => listMessagesAction(params)),\n });\n}\n\nexport function useInfiniteMessages(params?: Partial<Omit<FindMessagesParams, 'page' | 'limit'>>) {\n return useInfiniteQuery({\n queryKey: [...MESSAGES_QUERY_KEY, 'infinite', params],\n queryFn: ({ pageParam }) =>\n withAction(() =>\n listMessagesAction({\n ...params,\n page: pageParam as number,\n limit: INFINITE_MESSAGES_PAGE_SIZE,\n })\n )(),\n getNextPageParam: (lastPage, allPages) => {\n const loaded = allPages.reduce((sum, p) => sum + p.data.length, 0);\n return loaded < lastPage.total ? allPages.length + 1 : undefined;\n },\n initialPageParam: 1,\n });\n}\n\nexport function useMarkMessageAsRead() {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: withAction(markMessageAsReadAction),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: MESSAGES_QUERY_KEY });\n },\n });\n}\n\nexport function useMarkAllMessagesAsRead() {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: withAction(markAllMessagesAsReadAction),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: MESSAGES_QUERY_KEY });\n },\n });\n}\n"],"mappings":";AAEA,SAAS,kBAAkB,aAAa,UAAU,sBAAsB;AACxE,SAAS,0BAA0B;AACnC,SAAS,+BAA+B;AACxC,SAAS,mCAAmC;AAC5C,SAAS,kBAAkB;AAGpB,MAAM,qBAAqB,CAAC,UAAU;AAE7C,MAAM,8BAA8B;AAE7B,SAAS,YAAY,QAAsC;AAChE,SAAO,SAAS;AAAA,IACd,UAAU,CAAC,GAAG,oBAAoB,MAAM;AAAA,IACxC,SAAS,WAAW,MAAM,mBAAmB,MAAM,CAAC;AAAA,EACtD,CAAC;AACH;AAEO,SAAS,oBAAoB,QAA8D;AAChG,SAAO,iBAAiB;AAAA,IACtB,UAAU,CAAC,GAAG,oBAAoB,YAAY,MAAM;AAAA,IACpD,SAAS,CAAC,EAAE,UAAU,MACpB;AAAA,MAAW,MACT,mBAAmB;AAAA,QACjB,GAAG;AAAA,QACH,MAAM;AAAA,QACN,OAAO;AAAA,MACT,CAAC;AAAA,IACH,EAAE;AAAA,IACJ,kBAAkB,CAAC,UAAU,aAAa;AACxC,YAAM,SAAS,SAAS,OAAO,CAAC,KAAK,MAAM,MAAM,EAAE,KAAK,QAAQ,CAAC;AACjE,aAAO,SAAS,SAAS,QAAQ,SAAS,SAAS,IAAI;AAAA,IACzD;AAAA,IACA,kBAAkB;AAAA,EACpB,CAAC;AACH;AAEO,SAAS,uBAAuB;AACrC,QAAM,cAAc,eAAe;AAEnC,SAAO,YAAY;AAAA,IACjB,YAAY,WAAW,uBAAuB;AAAA,IAC9C,WAAW,MAAM;AACf,kBAAY,kBAAkB,EAAE,UAAU,mBAAmB,CAAC;AAAA,IAChE;AAAA,EACF,CAAC;AACH;AAEO,SAAS,2BAA2B;AACzC,QAAM,cAAc,eAAe;AAEnC,SAAO,YAAY;AAAA,IACjB,YAAY,WAAW,2BAA2B;AAAA,IAClD,WAAW,MAAM;AACf,kBAAY,kBAAkB,EAAE,UAAU,mBAAmB,CAAC;AAAA,IAChE;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const MessageSchema = z.object({
|
|
3
|
+
id: z.string(),
|
|
4
|
+
deleted: z.number(),
|
|
5
|
+
datetime_alt: z.string().nullable(),
|
|
6
|
+
datetime_del: z.string().nullable(),
|
|
7
|
+
datetime_add: z.string(),
|
|
8
|
+
id_wl: z.number(),
|
|
9
|
+
id_account: z.number(),
|
|
10
|
+
id_user: z.number(),
|
|
11
|
+
status: z.number().nullable(),
|
|
12
|
+
type: z.string(),
|
|
13
|
+
subject: z.string(),
|
|
14
|
+
message: z.string(),
|
|
15
|
+
to: z.string(),
|
|
16
|
+
url: z.string()
|
|
17
|
+
});
|
|
18
|
+
export {
|
|
19
|
+
MessageSchema
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=messages.schema.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/users/schema/messages.schema.ts"],"sourcesContent":["import { z } from 'zod';\r\n\r\nexport const MessageSchema = z.object({\r\n id: z.string(),\r\n deleted: z.number(),\r\n datetime_alt: z.string().nullable(),\r\n datetime_del: z.string().nullable(),\r\n datetime_add: z.string(),\r\n id_wl: z.number(),\r\n id_account: z.number(),\r\n id_user: z.number(),\r\n status: z.number().nullable(),\r\n type: z.string(),\r\n subject: z.string(),\r\n message: z.string(),\r\n to: z.string(),\r\n url: z.string(),\r\n});\r\n\r\nexport type Message = z.infer<typeof MessageSchema>;\r\n\r\nexport interface FindMessagesParams {\r\n id_user: number;\r\n type: string;\r\n limit: number;\r\n page: number;\r\n status: number;\r\n readed: boolean;\r\n order: 'asc' | 'desc';\r\n}\r\n\r\nexport interface ListMessagesApiResponse {\r\n status: 0 | 1;\r\n total: number;\r\n data: Message[];\r\n totalUnread: number;\r\n message?: string;\r\n}\r\n\r\nexport interface MarkAsReadApiResponse {\r\n status: 0 | 1;\r\n message?: string;\r\n}\r\n\r\nexport interface MarkAllAsReadApiResponse {\r\n status: 0 | 1;\r\n message?: string;\r\n}\r\n"],"mappings":"AAAA,SAAS,SAAS;AAEX,MAAM,gBAAgB,EAAE,OAAO;AAAA,EACpC,IAAI,EAAE,OAAO;AAAA,EACb,SAAS,EAAE,OAAO;AAAA,EAClB,cAAc,EAAE,OAAO,EAAE,SAAS;AAAA,EAClC,cAAc,EAAE,OAAO,EAAE,SAAS;AAAA,EAClC,cAAc,EAAE,OAAO;AAAA,EACvB,OAAO,EAAE,OAAO;AAAA,EAChB,YAAY,EAAE,OAAO;AAAA,EACrB,SAAS,EAAE,OAAO;AAAA,EAClB,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,MAAM,EAAE,OAAO;AAAA,EACf,SAAS,EAAE,OAAO;AAAA,EAClB,SAAS,EAAE,OAAO;AAAA,EAClB,IAAI,EAAE,OAAO;AAAA,EACb,KAAK,EAAE,OAAO;AAChB,CAAC;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var UserProfile = /* @__PURE__ */ ((UserProfile2) => {
|
|
2
|
+
UserProfile2["viewer"] = "viewer";
|
|
3
|
+
UserProfile2["collaborator"] = "collaborator";
|
|
4
|
+
UserProfile2["admin"] = "admin";
|
|
5
|
+
UserProfile2["owner"] = "owner";
|
|
6
|
+
return UserProfile2;
|
|
7
|
+
})(UserProfile || {});
|
|
8
|
+
export {
|
|
9
|
+
UserProfile
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=schema.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/modules/users/schema.ts"],"sourcesContent":["export enum UserProfile {\r\n viewer = 'viewer',\r\n collaborator = 'collaborator',\r\n admin = 'admin',\r\n owner = 'owner',\r\n}\r\n\r\nexport interface User {\r\n // Identificação\r\n id: number;\r\n id_wl: number;\r\n id_account: number;\r\n id_api: number;\r\n\r\n // Dados pessoais\r\n name: string;\r\n last_name: string;\r\n email: string;\r\n ddi: string;\r\n phone: string;\r\n rg: string | null;\r\n cpf: string | null;\r\n gender: number;\r\n\r\n // Autenticação e segurança\r\n two_factor_authentication: boolean;\r\n\r\n // Perfil e permissões\r\n profile: UserProfile;\r\n\r\n // Preferências\r\n language: string;\r\n receive_sms: boolean;\r\n receive_email: boolean;\r\n photo: string | null;\r\n\r\n // Metadados\r\n deleted: number;\r\n datetime_alt: string;\r\n datetime_del: string | null;\r\n datetime_add: string;\r\n\r\n total_projects: number;\r\n projects: { id: number; title: string }[];\r\n\r\n initials?: string;\r\n emailVerified?: boolean;\r\n createdAt?: string;\r\n updatedAt?: string;\r\n}\r\n\r\nexport interface GetUserDataResponse {\r\n status: 0 | 1;\r\n total: number;\r\n data: User[];\r\n}\r\n\r\nexport interface JWTPayload {\r\n session: {\r\n location: {\r\n continent: string;\r\n country: string;\r\n region: string;\r\n city: string;\r\n latitude: string;\r\n longitude: string;\r\n };\r\n ip: string;\r\n timezone: string;\r\n agent: string;\r\n code: string | null;\r\n };\r\n id_wl: string;\r\n id_account: number;\r\n id_user: number;\r\n iss: string;\r\n aud: string;\r\n iat: number;\r\n}\r\n"],"mappings":"AAAO,IAAK,cAAL,kBAAKA,iBAAL;AACL,EAAAA,aAAA,YAAS;AACT,EAAAA,aAAA,kBAAe;AACf,EAAAA,aAAA,WAAQ;AACR,EAAAA,aAAA,WAAQ;AAJE,SAAAA;AAAA,GAAA;","names":["UserProfile"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { api } from "../../../infra/api/client";
|
|
3
|
+
import { buildQueryParams } from "../../../infra/utils/params";
|
|
4
|
+
import { getUserContext } from "../../auth/utils/get-user-context";
|
|
5
|
+
class MessagesService {
|
|
6
|
+
async listMessages(params) {
|
|
7
|
+
const { id_account, id_user } = await getUserContext();
|
|
8
|
+
const query = buildQueryParams({
|
|
9
|
+
id_account,
|
|
10
|
+
id_user,
|
|
11
|
+
type: "notification",
|
|
12
|
+
limit: 20,
|
|
13
|
+
page: 1,
|
|
14
|
+
order: "desc",
|
|
15
|
+
...params
|
|
16
|
+
});
|
|
17
|
+
const url = `/accounts/${id_account}/messages${query ? `?${query}` : ""}`;
|
|
18
|
+
return api.apps.get(url);
|
|
19
|
+
}
|
|
20
|
+
async markAsRead(messageId) {
|
|
21
|
+
const { id_account } = await getUserContext();
|
|
22
|
+
const url = `/accounts/${id_account}/messages/${messageId}/action/markAsRead`;
|
|
23
|
+
return api.apps.put(url);
|
|
24
|
+
}
|
|
25
|
+
async markAllAsRead() {
|
|
26
|
+
const { id_account, id_user } = await getUserContext();
|
|
27
|
+
const url = `/accounts/${id_account}/messages/action/markAllAsRead`;
|
|
28
|
+
return api.apps.put(url, { id_user });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const messagesService = new MessagesService();
|
|
32
|
+
export {
|
|
33
|
+
messagesService
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=messages.service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/users/services/messages.service.ts"],"sourcesContent":["import 'server-only';\n\nimport { api } from '../../../infra/api/client';\nimport { buildQueryParams } from '../../../infra/utils/params';\nimport { getUserContext } from '../../auth/utils/get-user-context';\nimport {\n FindMessagesParams,\n ListMessagesApiResponse,\n MarkAsReadApiResponse,\n MarkAllAsReadApiResponse,\n} from '../schema/messages.schema';\n\nclass MessagesService {\n async listMessages(\n params?: Partial<FindMessagesParams>\n ): Promise<ListMessagesApiResponse> {\n const { id_account, id_user } = await getUserContext();\n\n const query = buildQueryParams({\n id_account,\n id_user,\n type: 'notification',\n limit: 20,\n page: 1,\n order: 'desc',\n ...params,\n });\n\n const url = `/accounts/${id_account}/messages${query ? `?${query}` : ''}`;\n return api.apps.get<ListMessagesApiResponse>(url);\n }\n\n async markAsRead(messageId: string): Promise<MarkAsReadApiResponse> {\n const { id_account } = await getUserContext();\n\n const url = `/accounts/${id_account}/messages/${messageId}/action/markAsRead`;\n return api.apps.put<MarkAsReadApiResponse>(url);\n }\n\n async markAllAsRead(): Promise<MarkAllAsReadApiResponse> {\n const { id_account, id_user } = await getUserContext();\n\n const url = `/accounts/${id_account}/messages/action/markAllAsRead`;\n return api.apps.put<MarkAllAsReadApiResponse>(url, { id_user });\n }\n}\n\nexport const messagesService = new MessagesService();\n"],"mappings":"AAAA,OAAO;AAEP,SAAS,WAAW;AACpB,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAQ/B,MAAM,gBAAgB;AAAA,EACpB,MAAM,aACJ,QACkC;AAClC,UAAM,EAAE,YAAY,QAAQ,IAAI,MAAM,eAAe;AAErD,UAAM,QAAQ,iBAAiB;AAAA,MAC7B;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN,OAAO;AAAA,MACP,MAAM;AAAA,MACN,OAAO;AAAA,MACP,GAAG;AAAA,IACL,CAAC;AAED,UAAM,MAAM,aAAa,UAAU,YAAY,QAAQ,IAAI,KAAK,KAAK,EAAE;AACvE,WAAO,IAAI,KAAK,IAA6B,GAAG;AAAA,EAClD;AAAA,EAEA,MAAM,WAAW,WAAmD;AAClE,UAAM,EAAE,WAAW,IAAI,MAAM,eAAe;AAE5C,UAAM,MAAM,aAAa,UAAU,aAAa,SAAS;AACzD,WAAO,IAAI,KAAK,IAA2B,GAAG;AAAA,EAChD;AAAA,EAEA,MAAM,gBAAmD;AACvD,UAAM,EAAE,YAAY,QAAQ,IAAI,MAAM,eAAe;AAErD,UAAM,MAAM,aAAa,UAAU;AACnC,WAAO,IAAI,KAAK,IAA8B,KAAK,EAAE,QAAQ,CAAC;AAAA,EAChE;AACF;AAEO,MAAM,kBAAkB,IAAI,gBAAgB;","names":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { cookies } from "next/headers";
|
|
2
|
+
import { ApiError } from "../../../infra/api/types";
|
|
3
|
+
import { findWhitelabel } from "../../whitelabel/actions/find-whitelabel.action";
|
|
4
|
+
import { buildWlOverride } from "../../auth/utils/build-wl-override";
|
|
5
|
+
const AUTH_COOKIE_NAME = "greatapps";
|
|
6
|
+
const API_BASE_URL = process.env.GAPPS_R3_API_URL || "https://r3-api.greatapps.dev.br";
|
|
7
|
+
class UserService {
|
|
8
|
+
async getAuthToken() {
|
|
9
|
+
if (process.env.DUMMY_AUTH_TOKEN) return process.env.DUMMY_AUTH_TOKEN;
|
|
10
|
+
const cookieStore = await cookies();
|
|
11
|
+
const token = cookieStore.get(AUTH_COOKIE_NAME)?.value;
|
|
12
|
+
if (!token) {
|
|
13
|
+
throw new ApiError("N\xE3o autenticado", "NOT_AUTHENTICATED_GAT", 401);
|
|
14
|
+
}
|
|
15
|
+
return token;
|
|
16
|
+
}
|
|
17
|
+
decodeJWT(token) {
|
|
18
|
+
try {
|
|
19
|
+
return JSON.parse(atob(token.split(".")[1]));
|
|
20
|
+
} catch {
|
|
21
|
+
throw new ApiError("Token inv\xE1lido", "INVALID_TOKEN", 401);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async findById(overrides) {
|
|
25
|
+
const token = await this.getAuthToken();
|
|
26
|
+
const payload = this.decodeJWT(token);
|
|
27
|
+
const { id_wl, id_account, id_user } = payload;
|
|
28
|
+
const wlOverride = overrides ? void 0 : await buildWlOverride(Number(id_wl));
|
|
29
|
+
const wlToken = overrides?.authToken ?? wlOverride?.authToken ?? (await findWhitelabel()).token;
|
|
30
|
+
const url = `${API_BASE_URL}/v1/pt-br/${id_wl}/accounts/${id_account}/users/${id_user}`;
|
|
31
|
+
const response = await fetch(url, {
|
|
32
|
+
method: "GET",
|
|
33
|
+
headers: {
|
|
34
|
+
"Content-Type": "application/json",
|
|
35
|
+
authorization: wlToken
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
if (!response.ok) {
|
|
39
|
+
throw new ApiError("Erro ao buscar dados do usu\xE1rio", "FETCH_ERROR", response.status);
|
|
40
|
+
}
|
|
41
|
+
const data = await response.json();
|
|
42
|
+
if (data.status === 0 || !data.data || data.data.length === 0) {
|
|
43
|
+
throw new ApiError("Dados do usu\xE1rio n\xE3o encontrados", "USER_NOT_FOUND", 404);
|
|
44
|
+
}
|
|
45
|
+
return data.data[0];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const userService = new UserService();
|
|
49
|
+
export {
|
|
50
|
+
userService
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=user.service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/users/services/user.service.ts"],"sourcesContent":["\r\nimport { cookies } from 'next/headers';\r\n\r\nimport { ApiError } from '../../../infra/api/types';\r\nimport { GetUserDataResponse, JWTPayload, User } from '../schema';\r\nimport { findWhitelabel } from '../../whitelabel/actions/find-whitelabel.action';\r\nimport { buildWlOverride } from '../../auth/utils/build-wl-override';\r\n\r\nconst AUTH_COOKIE_NAME = 'greatapps';\r\nconst API_BASE_URL = process.env.GAPPS_R3_API_URL || 'https://r3-api.greatapps.dev.br';\r\n\r\nclass UserService {\r\n private async getAuthToken(): Promise<string> {\r\n if (process.env.DUMMY_AUTH_TOKEN) return process.env.DUMMY_AUTH_TOKEN;\r\n const cookieStore = await cookies();\r\n const token = cookieStore.get(AUTH_COOKIE_NAME)?.value;\r\n\r\n if (!token) {\r\n throw new ApiError('Não autenticado', 'NOT_AUTHENTICATED_GAT', 401);\r\n }\r\n\r\n return token;\r\n }\r\n\r\n private decodeJWT(token: string): JWTPayload {\r\n try {\r\n return JSON.parse(atob(token.split('.')[1])) as JWTPayload;\r\n } catch {\r\n throw new ApiError('Token inválido', 'INVALID_TOKEN', 401);\r\n }\r\n }\r\n\r\n async findById(overrides?: { authToken?: string }): Promise<User> {\r\n const token = await this.getAuthToken();\r\n const payload = this.decodeJWT(token);\r\n\r\n const { id_wl, id_account, id_user } = payload;\r\n const wlOverride = overrides ? undefined : await buildWlOverride(Number(id_wl));\r\n const wlToken = overrides?.authToken ?? wlOverride?.authToken ?? (await findWhitelabel()).token;\r\n\r\n const url = `${API_BASE_URL}/v1/pt-br/${id_wl}/accounts/${id_account}/users/${id_user}`;\r\n\r\n const response = await fetch(url, {\r\n method: 'GET',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n authorization: wlToken,\r\n },\r\n });\r\n\r\n if (!response.ok) {\r\n throw new ApiError('Erro ao buscar dados do usuário', 'FETCH_ERROR', response.status);\r\n }\r\n\r\n const data = (await response.json()) as GetUserDataResponse;\r\n\r\n if (data.status === 0 || !data.data || data.data.length === 0) {\r\n throw new ApiError('Dados do usuário não encontrados', 'USER_NOT_FOUND', 404);\r\n }\r\n\r\n return data.data[0];\r\n }\r\n}\r\n\r\nexport const userService = new UserService();\r\n"],"mappings":"AACA,SAAS,eAAe;AAExB,SAAS,gBAAgB;AAEzB,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAEhC,MAAM,mBAAmB;AACzB,MAAM,eAAe,QAAQ,IAAI,oBAAoB;AAErD,MAAM,YAAY;AAAA,EAChB,MAAc,eAAgC;AAC5C,QAAI,QAAQ,IAAI,iBAAkB,QAAO,QAAQ,IAAI;AACrD,UAAM,cAAc,MAAM,QAAQ;AAClC,UAAM,QAAQ,YAAY,IAAI,gBAAgB,GAAG;AAEjD,QAAI,CAAC,OAAO;AACV,YAAM,IAAI,SAAS,sBAAmB,yBAAyB,GAAG;AAAA,IACpE;AAEA,WAAO;AAAA,EACT;AAAA,EAEQ,UAAU,OAA2B;AAC3C,QAAI;AACF,aAAO,KAAK,MAAM,KAAK,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC;AAAA,IAC7C,QAAQ;AACN,YAAM,IAAI,SAAS,qBAAkB,iBAAiB,GAAG;AAAA,IAC3D;AAAA,EACF;AAAA,EAEA,MAAM,SAAS,WAAmD;AAChE,UAAM,QAAQ,MAAM,KAAK,aAAa;AACtC,UAAM,UAAU,KAAK,UAAU,KAAK;AAEpC,UAAM,EAAE,OAAO,YAAY,QAAQ,IAAI;AACvC,UAAM,aAAa,YAAY,SAAY,MAAM,gBAAgB,OAAO,KAAK,CAAC;AAC9E,UAAM,UAAU,WAAW,aAAa,YAAY,cAAc,MAAM,eAAe,GAAG;AAE1F,UAAM,MAAM,GAAG,YAAY,aAAa,KAAK,aAAa,UAAU,UAAU,OAAO;AAErF,UAAM,WAAW,MAAM,MAAM,KAAK;AAAA,MAChC,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,QAChB,eAAe;AAAA,MACjB;AAAA,IACF,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,IAAI,SAAS,sCAAmC,eAAe,SAAS,MAAM;AAAA,IACtF;AAEA,UAAM,OAAQ,MAAM,SAAS,KAAK;AAElC,QAAI,KAAK,WAAW,KAAK,CAAC,KAAK,QAAQ,KAAK,KAAK,WAAW,GAAG;AAC7D,YAAM,IAAI,SAAS,0CAAoC,kBAAkB,GAAG;AAAA,IAC9E;AAEA,WAAO,KAAK,KAAK,CAAC;AAAA,EACpB;AACF;AAEO,MAAM,cAAc,IAAI,YAAY;","names":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { headers } from "next/headers";
|
|
3
|
+
import { whitelabelService } from "../services/whitelabel.service";
|
|
4
|
+
import { ApiError } from "../../../infra/api/types";
|
|
5
|
+
import { cache } from "react";
|
|
6
|
+
const findWhitelabel = cache(async () => {
|
|
7
|
+
const headersList = await headers();
|
|
8
|
+
const host = headersList.get("host");
|
|
9
|
+
if (!host) {
|
|
10
|
+
throw new ApiError("Host header not found", "HOST_NOT_FOUND", 400);
|
|
11
|
+
}
|
|
12
|
+
const whitelabel = await whitelabelService.getTokenByDomain(host);
|
|
13
|
+
if (!whitelabel) {
|
|
14
|
+
throw new ApiError("Whitelabel not found", "WL_NOT_FOUND", 404);
|
|
15
|
+
}
|
|
16
|
+
return whitelabel;
|
|
17
|
+
});
|
|
18
|
+
export {
|
|
19
|
+
findWhitelabel
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=find-whitelabel.action.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/whitelabel/actions/find-whitelabel.action.ts"],"sourcesContent":["'use server';\n\n\nimport { headers } from \"next/headers\";\nimport { whitelabelService } from \"../services/whitelabel.service\";\nimport { ApiError } from \"../../../infra/api/types\";\nimport { cache } from \"react\";\n\nexport const findWhitelabel = cache(async () => {\n const headersList = await headers();\n const host = headersList.get('host');\n\n if (!host) {\n throw new ApiError('Host header not found', 'HOST_NOT_FOUND', 400);\n }\n\n const whitelabel = await whitelabelService.getTokenByDomain(host);\n\n if (!whitelabel) {\n throw new ApiError('Whitelabel not found', 'WL_NOT_FOUND', 404);\n }\n\n return whitelabel;\n});"],"mappings":";AAGA,SAAS,eAAe;AACxB,SAAS,yBAAyB;AAClC,SAAS,gBAAgB;AACzB,SAAS,aAAa;AAEf,MAAM,iBAAiB,MAAM,YAAY;AAC5C,QAAM,cAAc,MAAM,QAAQ;AAClC,QAAM,OAAO,YAAY,IAAI,MAAM;AAEnC,MAAI,CAAC,MAAM;AACP,UAAM,IAAI,SAAS,yBAAyB,kBAAkB,GAAG;AAAA,EACrE;AAEA,QAAM,aAAa,MAAM,kBAAkB,iBAAiB,IAAI;AAEhE,MAAI,CAAC,YAAY;AACb,UAAM,IAAI,SAAS,wBAAwB,gBAAgB,GAAG;AAAA,EAClE;AAEA,SAAO;AACX,CAAC;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { headers } from "next/headers";
|
|
3
|
+
import { whitelabelService } from "../services/whitelabel.service";
|
|
4
|
+
import { ApiError } from "../../../infra/api/types";
|
|
5
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
6
|
+
async function revalidateWhitelabelAction() {
|
|
7
|
+
return safeServerAction(async () => {
|
|
8
|
+
const headersList = await headers();
|
|
9
|
+
const host = headersList.get("host");
|
|
10
|
+
if (!host) {
|
|
11
|
+
throw new ApiError("Host header not found", "HOST_NOT_FOUND", 400);
|
|
12
|
+
}
|
|
13
|
+
return whitelabelService.revalidateByDomain(host);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
revalidateWhitelabelAction
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=revalidate-whitelabel.action.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/whitelabel/actions/revalidate-whitelabel.action.ts"],"sourcesContent":["'use server';\n\nimport { headers } from 'next/headers';\nimport { whitelabelService } from '../services/whitelabel.service';\nimport { ApiError } from '../../../infra/api/types';\nimport { safeServerAction } from '../../../utils/safeServerAction';\n\nexport async function revalidateWhitelabelAction() {\n return safeServerAction(async () => {\n const headersList = await headers();\n const host = headersList.get('host');\n\n if (!host) {\n throw new ApiError('Host header not found', 'HOST_NOT_FOUND', 400);\n }\n\n return whitelabelService.revalidateByDomain(host);\n });\n}\n"],"mappings":";AAEA,SAAS,eAAe;AACxB,SAAS,yBAAyB;AAClC,SAAS,gBAAgB;AACzB,SAAS,wBAAwB;AAEjC,eAAsB,6BAA6B;AACjD,SAAO,iBAAiB,YAAY;AAClC,UAAM,cAAc,MAAM,QAAQ;AAClC,UAAM,OAAO,YAAY,IAAI,MAAM;AAEnC,QAAI,CAAC,MAAM;AACT,YAAM,IAAI,SAAS,yBAAyB,kBAAkB,GAAG;AAAA,IACnE;AAEA,WAAO,kBAAkB,mBAAmB,IAAI;AAAA,EAClD,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=schema.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import greatCache from "@greatapps/cache";
|
|
2
|
+
import { ApiError } from "../../../infra/api/types";
|
|
3
|
+
import { normalizeHostname } from "../utils/normalize-hostname";
|
|
4
|
+
class WhitelabelService {
|
|
5
|
+
getApiUrl() {
|
|
6
|
+
const apiUrl = process.env.GAPPS_R3_API_URL;
|
|
7
|
+
if (!apiUrl) {
|
|
8
|
+
throw new ApiError(
|
|
9
|
+
"GAPPS_R3_API_URL not configured",
|
|
10
|
+
"CONFIG_ERROR",
|
|
11
|
+
500
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
return apiUrl;
|
|
15
|
+
}
|
|
16
|
+
getToken() {
|
|
17
|
+
const token = process.env.WHITELABEL_TOKEN_MASTER;
|
|
18
|
+
if (!token) {
|
|
19
|
+
throw new ApiError(
|
|
20
|
+
"WHITELABEL_TOKEN_MASTER not configured",
|
|
21
|
+
"CONFIG_ERROR",
|
|
22
|
+
500
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
return token;
|
|
26
|
+
}
|
|
27
|
+
createCache() {
|
|
28
|
+
return new greatCache({
|
|
29
|
+
service: "whitelabel-service",
|
|
30
|
+
version: "1.0",
|
|
31
|
+
domain: "whitelabel-cache.greatapps.com.br",
|
|
32
|
+
ambient: process.env.NODE_ENV || "development"
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
getCacheKey(hostname) {
|
|
36
|
+
return `whitelabel-token-${hostname}`;
|
|
37
|
+
}
|
|
38
|
+
async fetchFromApi(hostname) {
|
|
39
|
+
const apiUrl = this.getApiUrl();
|
|
40
|
+
const whitelabelMasterToken = this.getToken();
|
|
41
|
+
const url = `${apiUrl}/v1/pt-br/1/whitelabel/${hostname}/token`;
|
|
42
|
+
console.log("[WhitelabelService] Fetching token for domain", { url });
|
|
43
|
+
const response = await fetch(url, {
|
|
44
|
+
method: "GET",
|
|
45
|
+
headers: {
|
|
46
|
+
authorization: whitelabelMasterToken
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
if (!response.ok) {
|
|
50
|
+
console.error("[WhitelabelService] Failed to fetch whitelabel token", {
|
|
51
|
+
response
|
|
52
|
+
});
|
|
53
|
+
throw new ApiError(
|
|
54
|
+
`Failed to fetch whitelabel token: ${response.status}`,
|
|
55
|
+
"FETCH_ERROR",
|
|
56
|
+
response.status
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
const result = await response.json();
|
|
60
|
+
if (result.status !== 1 || !result.data?.length) {
|
|
61
|
+
throw new ApiError("Whitelabel token not found", "TOKEN_NOT_FOUND", 404);
|
|
62
|
+
}
|
|
63
|
+
return result.data[0];
|
|
64
|
+
}
|
|
65
|
+
async getTokenByDomain(hostname) {
|
|
66
|
+
hostname = `${normalizeHostname(process.env.WHITELABEL_DOMAIN || hostname)}`;
|
|
67
|
+
console.debug("[WhitelabelService] Getting token for domain", {
|
|
68
|
+
hostname,
|
|
69
|
+
byEnv: process.env.WHITELABEL_DOMAIN
|
|
70
|
+
});
|
|
71
|
+
const cache = this.createCache();
|
|
72
|
+
const cacheKey = this.getCacheKey(hostname);
|
|
73
|
+
const cachedData = await cache.select(cacheKey);
|
|
74
|
+
console.debug("[WhitelabelService] Cache lookup for domain", {
|
|
75
|
+
cacheKey,
|
|
76
|
+
cachedData
|
|
77
|
+
});
|
|
78
|
+
if (cachedData.status == 1 && "data" in cachedData && cachedData.data) {
|
|
79
|
+
console.log("[WhitelabelService] Cache hit for domain", { hostname });
|
|
80
|
+
return JSON.parse(cachedData.data);
|
|
81
|
+
}
|
|
82
|
+
const data = await this.fetchFromApi(hostname);
|
|
83
|
+
await cache.insert(cacheKey, JSON.stringify(data), 604800);
|
|
84
|
+
return data;
|
|
85
|
+
}
|
|
86
|
+
async getTokenByWhitelabelId(idWl) {
|
|
87
|
+
const apiUrl = this.getApiUrl();
|
|
88
|
+
const masterToken = this.getToken();
|
|
89
|
+
const url = `${apiUrl}/v1/pt-br/${idWl}/tokens?limit=1&page=1&sort=id:desc`;
|
|
90
|
+
console.debug("[WhitelabelService] Fetching token by whitelabel ID", {
|
|
91
|
+
url,
|
|
92
|
+
config: {
|
|
93
|
+
method: "GET",
|
|
94
|
+
headers: { authorization: masterToken }
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
const response = await fetch(url, {
|
|
98
|
+
method: "GET",
|
|
99
|
+
headers: { authorization: masterToken }
|
|
100
|
+
});
|
|
101
|
+
console.debug("[WhitelabelService] Response received for whitelabel ID", {
|
|
102
|
+
response
|
|
103
|
+
});
|
|
104
|
+
if (!response.ok) {
|
|
105
|
+
throw new ApiError(
|
|
106
|
+
`Failed to fetch whitelabel token: ${response.status}`,
|
|
107
|
+
"WL_TOKEN_NOT_FOUND",
|
|
108
|
+
response.status
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
const result = await response.json();
|
|
112
|
+
if (result.status !== 1 || !result.data?.length) {
|
|
113
|
+
throw new ApiError(
|
|
114
|
+
"Token do whitelabel n\xE3o encontrado",
|
|
115
|
+
"WL_TOKEN_NOT_FOUND",
|
|
116
|
+
404
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
return result.data[0].token;
|
|
120
|
+
}
|
|
121
|
+
async revalidateByDomain(hostname) {
|
|
122
|
+
hostname = `${normalizeHostname(process.env.WHITELABEL_DOMAIN || hostname)}`;
|
|
123
|
+
console.debug("[WhitelabelService] Getting token for domain", {
|
|
124
|
+
hostname,
|
|
125
|
+
byEnv: process.env.WHITELABEL_DOMAIN
|
|
126
|
+
});
|
|
127
|
+
const cache = this.createCache();
|
|
128
|
+
const cacheKey = this.getCacheKey(hostname);
|
|
129
|
+
console.log("[WhitelabelService] Revalidating cache for domain", {
|
|
130
|
+
hostname,
|
|
131
|
+
cacheKey
|
|
132
|
+
});
|
|
133
|
+
await cache.delete(cacheKey);
|
|
134
|
+
const data = await this.fetchFromApi(hostname);
|
|
135
|
+
await cache.insert(cacheKey, JSON.stringify(data), 604800);
|
|
136
|
+
console.log("[WhitelabelService] Cache revalidated for domain", {
|
|
137
|
+
hostname
|
|
138
|
+
});
|
|
139
|
+
return data;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const whitelabelService = new WhitelabelService();
|
|
143
|
+
export {
|
|
144
|
+
whitelabelService
|
|
145
|
+
};
|
|
146
|
+
//# sourceMappingURL=whitelabel.service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/whitelabel/services/whitelabel.service.ts"],"sourcesContent":["import greatCache from \"@greatapps/cache\";\r\nimport { ApiError } from \"../../../infra/api/types\";\r\nimport { WhitelabelTokenApiResponse, WhitelabelTokenData } from \"../schema\";\r\nimport { normalizeHostname } from \"../utils/normalize-hostname\";\r\n\r\nclass WhitelabelService {\r\n private getApiUrl(): string {\r\n const apiUrl = process.env.GAPPS_R3_API_URL;\r\n if (!apiUrl) {\r\n throw new ApiError(\r\n \"GAPPS_R3_API_URL not configured\",\r\n \"CONFIG_ERROR\",\r\n 500,\r\n );\r\n }\r\n return apiUrl;\r\n }\r\n\r\n private getToken(): string {\r\n const token = process.env.WHITELABEL_TOKEN_MASTER;\r\n if (!token) {\r\n throw new ApiError(\r\n \"WHITELABEL_TOKEN_MASTER not configured\",\r\n \"CONFIG_ERROR\",\r\n 500,\r\n );\r\n }\r\n return token;\r\n }\r\n\r\n private createCache() {\r\n return new greatCache({\r\n service: \"whitelabel-service\",\r\n version: \"1.0\",\r\n domain: \"whitelabel-cache.greatapps.com.br\",\r\n ambient: process.env.NODE_ENV || \"development\",\r\n });\r\n }\r\n\r\n private getCacheKey(hostname: string): string {\r\n return `whitelabel-token-${hostname}`;\r\n }\r\n\r\n private async fetchFromApi(hostname: string): Promise<WhitelabelTokenData> {\r\n const apiUrl = this.getApiUrl();\r\n const whitelabelMasterToken = this.getToken();\r\n const url = `${apiUrl}/v1/pt-br/1/whitelabel/${hostname}/token`;\r\n\r\n console.log(\"[WhitelabelService] Fetching token for domain\", { url });\r\n\r\n const response = await fetch(url, {\r\n method: \"GET\",\r\n headers: {\r\n authorization: whitelabelMasterToken,\r\n },\r\n });\r\n\r\n if (!response.ok) {\r\n console.error(\"[WhitelabelService] Failed to fetch whitelabel token\", {\r\n response,\r\n });\r\n throw new ApiError(\r\n `Failed to fetch whitelabel token: ${response.status}`,\r\n \"FETCH_ERROR\",\r\n response.status,\r\n );\r\n }\r\n\r\n const result: WhitelabelTokenApiResponse = await response.json();\r\n\r\n if (result.status !== 1 || !result.data?.length) {\r\n throw new ApiError(\"Whitelabel token not found\", \"TOKEN_NOT_FOUND\", 404);\r\n }\r\n\r\n return result.data[0];\r\n }\r\n\r\n async getTokenByDomain(hostname: string): Promise<WhitelabelTokenData> {\r\n hostname = `${normalizeHostname(process.env.WHITELABEL_DOMAIN || hostname)}`;\r\n console.debug(\"[WhitelabelService] Getting token for domain\", {\r\n hostname,\r\n byEnv: process.env.WHITELABEL_DOMAIN,\r\n });\r\n\r\n const cache = this.createCache();\r\n const cacheKey = this.getCacheKey(hostname);\r\n\r\n const cachedData = await cache.select(cacheKey);\r\n console.debug(\"[WhitelabelService] Cache lookup for domain\", {\r\n cacheKey,\r\n cachedData,\r\n });\r\n\r\n if (cachedData.status == 1 && \"data\" in cachedData && cachedData.data) {\r\n console.log(\"[WhitelabelService] Cache hit for domain\", { hostname });\r\n return JSON.parse(cachedData.data) as WhitelabelTokenData;\r\n }\r\n\r\n const data = await this.fetchFromApi(hostname);\r\n\r\n await cache.insert(cacheKey, JSON.stringify(data), 604800);\r\n\r\n return data;\r\n }\r\n\r\n async getTokenByWhitelabelId(idWl: number): Promise<string> {\r\n const apiUrl = this.getApiUrl();\r\n const masterToken = this.getToken();\r\n const url = `${apiUrl}/v1/pt-br/${idWl}/tokens?limit=1&page=1&sort=id:desc`;\r\n console.debug(\"[WhitelabelService] Fetching token by whitelabel ID\", {\r\n url,\r\n config: {\r\n method: \"GET\",\r\n headers: { authorization: masterToken },\r\n },\r\n });\r\n\r\n const response = await fetch(url, {\r\n method: \"GET\",\r\n headers: { authorization: masterToken },\r\n });\r\n\r\n console.debug(\"[WhitelabelService] Response received for whitelabel ID\", {\r\n response,\r\n });\r\n\r\n if (!response.ok) {\r\n throw new ApiError(\r\n `Failed to fetch whitelabel token: ${response.status}`,\r\n \"WL_TOKEN_NOT_FOUND\",\r\n response.status,\r\n );\r\n }\r\n\r\n const result: WhitelabelTokenApiResponse = await response.json();\r\n\r\n if (result.status !== 1 || !result.data?.length) {\r\n throw new ApiError(\r\n \"Token do whitelabel não encontrado\",\r\n \"WL_TOKEN_NOT_FOUND\",\r\n 404,\r\n );\r\n }\r\n\r\n return result.data[0].token;\r\n }\r\n\r\n async revalidateByDomain(hostname: string): Promise<WhitelabelTokenData> {\r\n hostname = `${normalizeHostname(process.env.WHITELABEL_DOMAIN || hostname)}`;\r\n console.debug(\"[WhitelabelService] Getting token for domain\", {\r\n hostname,\r\n byEnv: process.env.WHITELABEL_DOMAIN,\r\n });\r\n\r\n const cache = this.createCache();\r\n const cacheKey = this.getCacheKey(hostname);\r\n\r\n console.log(\"[WhitelabelService] Revalidating cache for domain\", {\r\n hostname,\r\n cacheKey,\r\n });\r\n \r\n await cache.delete(cacheKey);\r\n\r\n const data = await this.fetchFromApi(hostname);\r\n\r\n await cache.insert(cacheKey, JSON.stringify(data), 604800);\r\n\r\n console.log(\"[WhitelabelService] Cache revalidated for domain\", {\r\n hostname,\r\n });\r\n\r\n return data;\r\n }\r\n}\r\n\r\nexport const whitelabelService = new WhitelabelService();\r\n"],"mappings":"AAAA,OAAO,gBAAgB;AACvB,SAAS,gBAAgB;AAEzB,SAAS,yBAAyB;AAElC,MAAM,kBAAkB;AAAA,EACd,YAAoB;AAC1B,UAAM,SAAS,QAAQ,IAAI;AAC3B,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI;AAAA,QACR;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EAEQ,WAAmB;AACzB,UAAM,QAAQ,QAAQ,IAAI;AAC1B,QAAI,CAAC,OAAO;AACV,YAAM,IAAI;AAAA,QACR;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EAEQ,cAAc;AACpB,WAAO,IAAI,WAAW;AAAA,MACpB,SAAS;AAAA,MACT,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,SAAS,QAAQ,IAAI,YAAY;AAAA,IACnC,CAAC;AAAA,EACH;AAAA,EAEQ,YAAY,UAA0B;AAC5C,WAAO,oBAAoB,QAAQ;AAAA,EACrC;AAAA,EAEA,MAAc,aAAa,UAAgD;AACzE,UAAM,SAAS,KAAK,UAAU;AAC9B,UAAM,wBAAwB,KAAK,SAAS;AAC5C,UAAM,MAAM,GAAG,MAAM,0BAA0B,QAAQ;AAEvD,YAAQ,IAAI,iDAAiD,EAAE,IAAI,CAAC;AAEpE,UAAM,WAAW,MAAM,MAAM,KAAK;AAAA,MAChC,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,eAAe;AAAA,MACjB;AAAA,IACF,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,cAAQ,MAAM,wDAAwD;AAAA,QACpE;AAAA,MACF,CAAC;AACD,YAAM,IAAI;AAAA,QACR,qCAAqC,SAAS,MAAM;AAAA,QACpD;AAAA,QACA,SAAS;AAAA,MACX;AAAA,IACF;AAEA,UAAM,SAAqC,MAAM,SAAS,KAAK;AAE/D,QAAI,OAAO,WAAW,KAAK,CAAC,OAAO,MAAM,QAAQ;AAC/C,YAAM,IAAI,SAAS,8BAA8B,mBAAmB,GAAG;AAAA,IACzE;AAEA,WAAO,OAAO,KAAK,CAAC;AAAA,EACtB;AAAA,EAEA,MAAM,iBAAiB,UAAgD;AACrE,eAAW,GAAG,kBAAkB,QAAQ,IAAI,qBAAqB,QAAQ,CAAC;AAC1E,YAAQ,MAAM,gDAAgD;AAAA,MAC5D;AAAA,MACA,OAAO,QAAQ,IAAI;AAAA,IACrB,CAAC;AAED,UAAM,QAAQ,KAAK,YAAY;AAC/B,UAAM,WAAW,KAAK,YAAY,QAAQ;AAE1C,UAAM,aAAa,MAAM,MAAM,OAAO,QAAQ;AAC9C,YAAQ,MAAM,+CAA+C;AAAA,MAC3D;AAAA,MACA;AAAA,IACF,CAAC;AAED,QAAI,WAAW,UAAU,KAAK,UAAU,cAAc,WAAW,MAAM;AACrE,cAAQ,IAAI,4CAA4C,EAAE,SAAS,CAAC;AACpE,aAAO,KAAK,MAAM,WAAW,IAAI;AAAA,IACnC;AAEA,UAAM,OAAO,MAAM,KAAK,aAAa,QAAQ;AAE7C,UAAM,MAAM,OAAO,UAAU,KAAK,UAAU,IAAI,GAAG,MAAM;AAEzD,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,uBAAuB,MAA+B;AAC1D,UAAM,SAAS,KAAK,UAAU;AAC9B,UAAM,cAAc,KAAK,SAAS;AAClC,UAAM,MAAM,GAAG,MAAM,aAAa,IAAI;AACtC,YAAQ,MAAM,uDAAuD;AAAA,MACnE;AAAA,MACA,QAAQ;AAAA,QACN,QAAQ;AAAA,QACR,SAAS,EAAE,eAAe,YAAY;AAAA,MACxC;AAAA,IACF,CAAC;AAED,UAAM,WAAW,MAAM,MAAM,KAAK;AAAA,MAChC,QAAQ;AAAA,MACR,SAAS,EAAE,eAAe,YAAY;AAAA,IACxC,CAAC;AAED,YAAQ,MAAM,2DAA2D;AAAA,MACvE;AAAA,IACF,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,IAAI;AAAA,QACR,qCAAqC,SAAS,MAAM;AAAA,QACpD;AAAA,QACA,SAAS;AAAA,MACX;AAAA,IACF;AAEA,UAAM,SAAqC,MAAM,SAAS,KAAK;AAE/D,QAAI,OAAO,WAAW,KAAK,CAAC,OAAO,MAAM,QAAQ;AAC/C,YAAM,IAAI;AAAA,QACR;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,WAAO,OAAO,KAAK,CAAC,EAAE;AAAA,EACxB;AAAA,EAEA,MAAM,mBAAmB,UAAgD;AACvE,eAAW,GAAG,kBAAkB,QAAQ,IAAI,qBAAqB,QAAQ,CAAC;AAC1E,YAAQ,MAAM,gDAAgD;AAAA,MAC5D;AAAA,MACA,OAAO,QAAQ,IAAI;AAAA,IACrB,CAAC;AAED,UAAM,QAAQ,KAAK,YAAY;AAC/B,UAAM,WAAW,KAAK,YAAY,QAAQ;AAE1C,YAAQ,IAAI,qDAAqD;AAAA,MAC/D;AAAA,MACA;AAAA,IACF,CAAC;AAED,UAAM,MAAM,OAAO,QAAQ;AAE3B,UAAM,OAAO,MAAM,KAAK,aAAa,QAAQ;AAE7C,UAAM,MAAM,OAAO,UAAU,KAAK,UAAU,IAAI,GAAG,MAAM;AAEzD,YAAQ,IAAI,oDAAoD;AAAA,MAC9D;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AACF;AAEO,MAAM,oBAAoB,IAAI,kBAAkB;","names":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const CATEGORY_PREFIXES = /* @__PURE__ */ new Set([
|
|
2
|
+
"com",
|
|
3
|
+
"dev",
|
|
4
|
+
"net",
|
|
5
|
+
"org",
|
|
6
|
+
"edu",
|
|
7
|
+
"gov",
|
|
8
|
+
"mil",
|
|
9
|
+
"co",
|
|
10
|
+
"art",
|
|
11
|
+
"inf",
|
|
12
|
+
"blog",
|
|
13
|
+
"wiki",
|
|
14
|
+
"app",
|
|
15
|
+
"online",
|
|
16
|
+
"site"
|
|
17
|
+
]);
|
|
18
|
+
const SIMPLE_TLDS = /* @__PURE__ */ new Set(["online"]);
|
|
19
|
+
function normalizeHostname(hostname) {
|
|
20
|
+
const parts = hostname.split(".");
|
|
21
|
+
if (parts.length <= 2) return hostname;
|
|
22
|
+
const last = parts[parts.length - 1];
|
|
23
|
+
const secondLast = parts[parts.length - 2];
|
|
24
|
+
const isCompoundTld = last.length <= 3 && CATEGORY_PREFIXES.has(secondLast);
|
|
25
|
+
const rootParts = isCompoundTld ? 3 : 2;
|
|
26
|
+
if (SIMPLE_TLDS.has(last) || !isCompoundTld) {
|
|
27
|
+
return parts.slice(-2).join(".");
|
|
28
|
+
}
|
|
29
|
+
if (parts.length <= rootParts) return hostname;
|
|
30
|
+
return parts.slice(-rootParts).join(".");
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
normalizeHostname
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=normalize-hostname.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/whitelabel/utils/normalize-hostname.ts"],"sourcesContent":["const CATEGORY_PREFIXES = new Set([\n \"com\", \"dev\", \"net\", \"org\", \"edu\", \"gov\",\n \"mil\", \"co\", \"art\", \"inf\", \"blog\", \"wiki\", \"app\", \"online\", \"site\"\n]);\n\nconst SIMPLE_TLDS = new Set([\"online\"]);\n\nexport function normalizeHostname(hostname: string): string {\n const parts = hostname.split(\".\");\n if (parts.length <= 2) return hostname;\n\n const last = parts[parts.length - 1];\n const secondLast = parts[parts.length - 2];\n\n const isCompoundTld =\n last.length <= 3 && CATEGORY_PREFIXES.has(secondLast);\n\n const rootParts = isCompoundTld ? 3 : 2;\n\n if (SIMPLE_TLDS.has(last) || !isCompoundTld) {\n return parts.slice(-2).join(\".\");\n }\n\n if (parts.length <= rootParts) return hostname;\n return parts.slice(-rootParts).join(\".\");\n}\n"],"mappings":"AAAA,MAAM,oBAAoB,oBAAI,IAAI;AAAA,EAChC;AAAA,EAAO;AAAA,EAAO;AAAA,EAAO;AAAA,EAAO;AAAA,EAAO;AAAA,EACnC;AAAA,EAAO;AAAA,EAAM;AAAA,EAAO;AAAA,EAAO;AAAA,EAAQ;AAAA,EAAQ;AAAA,EAAO;AAAA,EAAU;AAC9D,CAAC;AAED,MAAM,cAAc,oBAAI,IAAI,CAAC,QAAQ,CAAC;AAE/B,SAAS,kBAAkB,UAA0B;AAC1D,QAAM,QAAQ,SAAS,MAAM,GAAG;AAChC,MAAI,MAAM,UAAU,EAAG,QAAO;AAE9B,QAAM,OAAO,MAAM,MAAM,SAAS,CAAC;AACnC,QAAM,aAAa,MAAM,MAAM,SAAS,CAAC;AAEzC,QAAM,gBACJ,KAAK,UAAU,KAAK,kBAAkB,IAAI,UAAU;AAEtD,QAAM,YAAY,gBAAgB,IAAI;AAEtC,MAAI,YAAY,IAAI,IAAI,KAAK,CAAC,eAAe;AAC3C,WAAO,MAAM,MAAM,EAAE,EAAE,KAAK,GAAG;AAAA,EACjC;AAEA,MAAI,MAAM,UAAU,UAAW,QAAO;AACtC,SAAO,MAAM,MAAM,CAAC,SAAS,EAAE,KAAK,GAAG;AACzC;","names":[]}
|