@greatapps/common 1.1.170 → 1.1.173
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/package.json +1 -1
- package/src/modules/auth/schema.ts +1 -0
- package/src/modules/auth/services/auth.service.ts +1 -0
- package/dist/components/account/AccountModals.mjs +0 -18
- package/dist/components/account/AccountModals.mjs.map +0 -1
- package/dist/components/account/ConfigurationsMyAccountModal.mjs +0 -132
- package/dist/components/account/ConfigurationsMyAccountModal.mjs.map +0 -1
- package/dist/components/account/ConfirmDeleteAccountModal.mjs +0 -45
- package/dist/components/account/ConfirmDeleteAccountModal.mjs.map +0 -1
- package/dist/components/account/ConfirmGlobalPreferencesModal.mjs +0 -45
- package/dist/components/account/ConfirmGlobalPreferencesModal.mjs.map +0 -1
- package/dist/components/account/DeleteAccountModal.mjs +0 -123
- package/dist/components/account/DeleteAccountModal.mjs.map +0 -1
- package/dist/components/account/DisableTwoFactorAuthModal.mjs +0 -67
- package/dist/components/account/DisableTwoFactorAuthModal.mjs.map +0 -1
- package/dist/components/account/IsntPossibleDeleteAccountModal.mjs +0 -42
- package/dist/components/account/IsntPossibleDeleteAccountModal.mjs.map +0 -1
- package/dist/components/account/TwoFactorAuthModal.mjs +0 -190
- package/dist/components/account/TwoFactorAuthModal.mjs.map +0 -1
- package/dist/components/account/constants.mjs +0 -29
- package/dist/components/account/constants.mjs.map +0 -1
- package/dist/components/account/hooks/useChangeEmailForm.mjs +0 -53
- package/dist/components/account/hooks/useChangeEmailForm.mjs.map +0 -1
- package/dist/components/account/hooks/useChangePasswordForm.mjs +0 -47
- package/dist/components/account/hooks/useChangePasswordForm.mjs.map +0 -1
- package/dist/components/account/hooks/useChangePhoneForm.mjs +0 -64
- package/dist/components/account/hooks/useChangePhoneForm.mjs.map +0 -1
- package/dist/components/account/hooks/useConfigurationsModal.mjs +0 -33
- package/dist/components/account/hooks/useConfigurationsModal.mjs.map +0 -1
- package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs +0 -54
- package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs.map +0 -1
- package/dist/components/account/hooks/useOtpVerification.mjs +0 -94
- package/dist/components/account/hooks/useOtpVerification.mjs.map +0 -1
- package/dist/components/account/hooks/useTwoFactorAuthForm.mjs +0 -80
- package/dist/components/account/hooks/useTwoFactorAuthForm.mjs.map +0 -1
- package/dist/components/account/sections/ChangeEmailModal.mjs +0 -180
- package/dist/components/account/sections/ChangeEmailModal.mjs.map +0 -1
- package/dist/components/account/sections/ChangePasswordSection.mjs +0 -64
- package/dist/components/account/sections/ChangePasswordSection.mjs.map +0 -1
- package/dist/components/account/sections/ChangePhoneModal.mjs +0 -182
- package/dist/components/account/sections/ChangePhoneModal.mjs.map +0 -1
- package/dist/components/account/sections/MyProfileSection.mjs +0 -303
- package/dist/components/account/sections/MyProfileSection.mjs.map +0 -1
- package/dist/components/account/sections/PreferencesSection.mjs +0 -250
- package/dist/components/account/sections/PreferencesSection.mjs.map +0 -1
- package/dist/components/account/sections/SecuritySection.mjs +0 -147
- package/dist/components/account/sections/SecuritySection.mjs.map +0 -1
- package/dist/components/handlers/SearchParamsHandler.mjs +0 -24
- package/dist/components/handlers/SearchParamsHandler.mjs.map +0 -1
- package/dist/components/layouts/AppMobileNavBar.mjs +0 -115
- package/dist/components/layouts/AppMobileNavBar.mjs.map +0 -1
- package/dist/components/layouts/AppNavBar.mjs +0 -49
- package/dist/components/layouts/AppNavBar.mjs.map +0 -1
- package/dist/components/layouts/MainLayout.mjs +0 -60
- package/dist/components/layouts/MainLayout.mjs.map +0 -1
- package/dist/components/layouts/MdSideBarNavigation.mjs +0 -54
- package/dist/components/layouts/MdSideBarNavigation.mjs.map +0 -1
- package/dist/components/layouts/NavBar.mjs +0 -132
- package/dist/components/layouts/NavBar.mjs.map +0 -1
- package/dist/components/layouts/NavBarItem.mjs +0 -23
- package/dist/components/layouts/NavBarItem.mjs.map +0 -1
- package/dist/components/layouts/NotificationsPopover.mjs +0 -97
- package/dist/components/layouts/NotificationsPopover.mjs.map +0 -1
- package/dist/components/layouts/ProfilePopover.mjs +0 -149
- package/dist/components/layouts/ProfilePopover.mjs.map +0 -1
- package/dist/components/layouts/SideBarNavigation.mjs +0 -22
- package/dist/components/layouts/SideBarNavigation.mjs.map +0 -1
- package/dist/components/layouts/UsersSelectorPopover.mjs +0 -230
- package/dist/components/layouts/UsersSelectorPopover.mjs.map +0 -1
- package/dist/components/modals/ModalManager.mjs +0 -19
- package/dist/components/modals/ModalManager.mjs.map +0 -1
- package/dist/components/modals/Modals.mjs +0 -20
- package/dist/components/modals/Modals.mjs.map +0 -1
- package/dist/components/navigation/AppNavigation.mjs +0 -30
- package/dist/components/navigation/AppNavigation.mjs.map +0 -1
- package/dist/components/navigation/AppNavigationContext.mjs +0 -13
- package/dist/components/navigation/AppNavigationContext.mjs.map +0 -1
- package/dist/components/navigation/CancelledSubscriptionBanner.mjs +0 -59
- package/dist/components/navigation/CancelledSubscriptionBanner.mjs.map +0 -1
- package/dist/components/navigation/NavItem.mjs +0 -35
- package/dist/components/navigation/NavItem.mjs.map +0 -1
- package/dist/components/navigation/NavItemsContext.mjs +0 -16
- package/dist/components/navigation/NavItemsContext.mjs.map +0 -1
- package/dist/components/navigation/ProjectSelectorPopover.mjs +0 -128
- package/dist/components/navigation/ProjectSelectorPopover.mjs.map +0 -1
- package/dist/components/navigation/shells/DesktopShell.mjs +0 -11
- package/dist/components/navigation/shells/DesktopShell.mjs.map +0 -1
- package/dist/components/navigation/shells/MdShell.mjs +0 -11
- package/dist/components/navigation/shells/MdShell.mjs.map +0 -1
- package/dist/components/navigation/shells/MobileShell.mjs +0 -27
- package/dist/components/navigation/shells/MobileShell.mjs.map +0 -1
- package/dist/components/navigation/shells/TabsMobileShell.mjs +0 -59
- package/dist/components/navigation/shells/TabsMobileShell.mjs.map +0 -1
- package/dist/components/navigation/subcomponents/CreditsCard.mjs +0 -30
- package/dist/components/navigation/subcomponents/CreditsCard.mjs.map +0 -1
- package/dist/components/navigation/subcomponents/NavItems.mjs +0 -25
- package/dist/components/navigation/subcomponents/NavItems.mjs.map +0 -1
- package/dist/components/navigation/subcomponents/PlanCard.mjs +0 -25
- package/dist/components/navigation/subcomponents/PlanCard.mjs.map +0 -1
- package/dist/components/navigation/subcomponents/ProjectSelector.mjs +0 -130
- package/dist/components/navigation/subcomponents/ProjectSelector.mjs.map +0 -1
- package/dist/components/navigation/types.mjs +0 -1
- package/dist/components/navigation/types.mjs.map +0 -1
- package/dist/components/pages/notifications/Notifications.mjs +0 -156
- package/dist/components/pages/notifications/Notifications.mjs.map +0 -1
- package/dist/components/ui/buttons/Button.mjs +0 -52
- package/dist/components/ui/buttons/Button.mjs.map +0 -1
- package/dist/components/ui/buttons/CancelButton.mjs +0 -17
- package/dist/components/ui/buttons/CancelButton.mjs.map +0 -1
- package/dist/components/ui/buttons/CopyButton.mjs +0 -42
- package/dist/components/ui/buttons/CopyButton.mjs.map +0 -1
- package/dist/components/ui/data-display/Accordion.mjs +0 -76
- package/dist/components/ui/data-display/Accordion.mjs.map +0 -1
- package/dist/components/ui/data-display/Badge.mjs +0 -42
- package/dist/components/ui/data-display/Badge.mjs.map +0 -1
- package/dist/components/ui/data-display/Card.mjs +0 -92
- package/dist/components/ui/data-display/Card.mjs.map +0 -1
- package/dist/components/ui/data-display/Pagination.mjs +0 -118
- package/dist/components/ui/data-display/Pagination.mjs.map +0 -1
- package/dist/components/ui/data-display/ScrollArea.mjs +0 -62
- package/dist/components/ui/data-display/ScrollArea.mjs.map +0 -1
- package/dist/components/ui/data-display/Separator.mjs +0 -28
- package/dist/components/ui/data-display/Separator.mjs.map +0 -1
- package/dist/components/ui/data-display/Table.mjs +0 -116
- package/dist/components/ui/data-display/Table.mjs.map +0 -1
- package/dist/components/ui/data-display/Tabs.mjs +0 -69
- package/dist/components/ui/data-display/Tabs.mjs.map +0 -1
- package/dist/components/ui/data-display/UserAvatar.mjs +0 -49
- package/dist/components/ui/data-display/UserAvatar.mjs.map +0 -1
- package/dist/components/ui/feedback/CircularProgress.mjs +0 -71
- package/dist/components/ui/feedback/CircularProgress.mjs.map +0 -1
- package/dist/components/ui/feedback/DefaultCircularProgress.mjs +0 -50
- package/dist/components/ui/feedback/DefaultCircularProgress.mjs.map +0 -1
- package/dist/components/ui/feedback/LoadingOverlay.mjs +0 -19
- package/dist/components/ui/feedback/LoadingOverlay.mjs.map +0 -1
- package/dist/components/ui/feedback/Progress.mjs +0 -37
- package/dist/components/ui/feedback/Progress.mjs.map +0 -1
- package/dist/components/ui/feedback/Toast.mjs +0 -77
- package/dist/components/ui/feedback/Toast.mjs.map +0 -1
- package/dist/components/ui/form/Calendar.mjs +0 -204
- package/dist/components/ui/form/Calendar.mjs.map +0 -1
- package/dist/components/ui/form/Checkbox.mjs +0 -33
- package/dist/components/ui/form/Checkbox.mjs.map +0 -1
- package/dist/components/ui/form/ComboboxField.mjs +0 -130
- package/dist/components/ui/form/ComboboxField.mjs.map +0 -1
- package/dist/components/ui/form/DatePicker.mjs +0 -82
- package/dist/components/ui/form/DatePicker.mjs.map +0 -1
- package/dist/components/ui/form/DateRangePicker.mjs +0 -92
- package/dist/components/ui/form/DateRangePicker.mjs.map +0 -1
- package/dist/components/ui/form/FormField.mjs +0 -103
- package/dist/components/ui/form/FormField.mjs.map +0 -1
- package/dist/components/ui/form/Input.mjs +0 -21
- package/dist/components/ui/form/Input.mjs.map +0 -1
- package/dist/components/ui/form/InputOtp.mjs +0 -70
- package/dist/components/ui/form/InputOtp.mjs.map +0 -1
- package/dist/components/ui/form/PhoneInput.mjs +0 -78
- package/dist/components/ui/form/PhoneInput.mjs.map +0 -1
- package/dist/components/ui/form/RadioGroup.mjs +0 -37
- package/dist/components/ui/form/RadioGroup.mjs.map +0 -1
- package/dist/components/ui/form/Select.mjs +0 -179
- package/dist/components/ui/form/Select.mjs.map +0 -1
- package/dist/components/ui/form/SelectField.mjs +0 -80
- package/dist/components/ui/form/SelectField.mjs.map +0 -1
- package/dist/components/ui/form/Switch.mjs +0 -33
- package/dist/components/ui/form/Switch.mjs.map +0 -1
- package/dist/components/ui/form/SwitchOptionFieldWithIcon.mjs +0 -40
- package/dist/components/ui/form/SwitchOptionFieldWithIcon.mjs.map +0 -1
- package/dist/components/ui/form/TextAreaField.mjs +0 -56
- package/dist/components/ui/form/TextAreaField.mjs.map +0 -1
- package/dist/components/ui/form/Textarea.mjs +0 -20
- package/dist/components/ui/form/Textarea.mjs.map +0 -1
- package/dist/components/ui/overlay/Command.mjs +0 -178
- package/dist/components/ui/overlay/Command.mjs.map +0 -1
- package/dist/components/ui/overlay/Dialog.mjs +0 -142
- package/dist/components/ui/overlay/Dialog.mjs.map +0 -1
- package/dist/components/ui/overlay/Popover.mjs +0 -46
- package/dist/components/ui/overlay/Popover.mjs.map +0 -1
- package/dist/components/ui/overlay/Sheet.mjs +0 -142
- package/dist/components/ui/overlay/Sheet.mjs.map +0 -1
- package/dist/components/ui/overlay/Tooltip.mjs +0 -57
- package/dist/components/ui/overlay/Tooltip.mjs.map +0 -1
- package/dist/components/widgets/notifications/NotificationCard.mjs +0 -54
- package/dist/components/widgets/notifications/NotificationCard.mjs.map +0 -1
- package/dist/enums/AccountSectionType.mjs +0 -11
- package/dist/enums/AccountSectionType.mjs.map +0 -1
- package/dist/hooks/copy-to-clipboard.hook.mjs +0 -52
- package/dist/hooks/copy-to-clipboard.hook.mjs.map +0 -1
- package/dist/hooks/useCountdownTimer.mjs +0 -29
- package/dist/hooks/useCountdownTimer.mjs.map +0 -1
- package/dist/hooks/useDebounce.mjs +0 -19
- package/dist/hooks/useDebounce.mjs.map +0 -1
- package/dist/hooks/useDebounceState.mjs +0 -12
- package/dist/hooks/useDebounceState.mjs.map +0 -1
- package/dist/hooks/useDebouncedEffect.mjs +0 -44
- package/dist/hooks/useDebouncedEffect.mjs.map +0 -1
- package/dist/hooks/useIsMobile.mjs +0 -18
- package/dist/hooks/useIsMobile.mjs.map +0 -1
- package/dist/hooks/usePasswordVisibility.mjs +0 -13
- package/dist/hooks/usePasswordVisibility.mjs.map +0 -1
- package/dist/index.mjs +0 -457
- package/dist/index.mjs.map +0 -1
- package/dist/infra/api/client.mjs +0 -136
- package/dist/infra/api/client.mjs.map +0 -1
- package/dist/infra/api/types.mjs +0 -31
- package/dist/infra/api/types.mjs.map +0 -1
- package/dist/infra/utils/client-info.mjs +0 -27
- package/dist/infra/utils/client-info.mjs.map +0 -1
- package/dist/infra/utils/clsx.mjs +0 -9
- package/dist/infra/utils/clsx.mjs.map +0 -1
- package/dist/infra/utils/params.mjs +0 -21
- package/dist/infra/utils/params.mjs.map +0 -1
- package/dist/infra/utils/parser.mjs +0 -24
- package/dist/infra/utils/parser.mjs.map +0 -1
- package/dist/infra/utils/percentage.mjs +0 -20
- package/dist/infra/utils/percentage.mjs.map +0 -1
- package/dist/middleware.mjs +0 -10
- package/dist/middleware.mjs.map +0 -1
- package/dist/middlewares/chain.mjs +0 -37
- package/dist/middlewares/chain.mjs.map +0 -1
- package/dist/middlewares/create-auth-middleware.mjs +0 -28
- package/dist/middlewares/create-auth-middleware.mjs.map +0 -1
- package/dist/middlewares/types.mjs +0 -11
- package/dist/middlewares/types.mjs.map +0 -1
- package/dist/modules/accounts/actions/account-management.action.mjs +0 -82
- package/dist/modules/accounts/actions/account-management.action.mjs.map +0 -1
- package/dist/modules/accounts/actions/find-current-account.action.mjs +0 -10
- package/dist/modules/accounts/actions/find-current-account.action.mjs.map +0 -1
- package/dist/modules/accounts/actions/list-currencies.action.mjs +0 -10
- package/dist/modules/accounts/actions/list-currencies.action.mjs.map +0 -1
- package/dist/modules/accounts/actions/list-timezones.action.mjs +0 -10
- package/dist/modules/accounts/actions/list-timezones.action.mjs.map +0 -1
- package/dist/modules/accounts/hooks/current-account.hook.mjs +0 -24
- package/dist/modules/accounts/hooks/current-account.hook.mjs.map +0 -1
- package/dist/modules/accounts/hooks/useAccountManagement.mjs +0 -71
- package/dist/modules/accounts/hooks/useAccountManagement.mjs.map +0 -1
- package/dist/modules/accounts/hooks/useCurrencies.mjs +0 -17
- package/dist/modules/accounts/hooks/useCurrencies.mjs.map +0 -1
- package/dist/modules/accounts/hooks/useTimezones.mjs +0 -17
- package/dist/modules/accounts/hooks/useTimezones.mjs.map +0 -1
- package/dist/modules/accounts/services/account.service.mjs +0 -180
- package/dist/modules/accounts/services/account.service.mjs.map +0 -1
- package/dist/modules/accounts/services/currency.service.mjs +0 -24
- package/dist/modules/accounts/services/currency.service.mjs.map +0 -1
- package/dist/modules/accounts/services/timezone.service.mjs +0 -65
- package/dist/modules/accounts/services/timezone.service.mjs.map +0 -1
- package/dist/modules/accounts/services/two-factor.service.mjs +0 -77
- package/dist/modules/accounts/services/two-factor.service.mjs.map +0 -1
- package/dist/modules/accounts/types.mjs +0 -1
- package/dist/modules/accounts/types.mjs.map +0 -1
- package/dist/modules/auth/actions/login.action.mjs +0 -14
- package/dist/modules/auth/actions/login.action.mjs.map +0 -1
- package/dist/modules/auth/actions/logout.action.mjs +0 -14
- package/dist/modules/auth/actions/logout.action.mjs.map +0 -1
- package/dist/modules/auth/actions/register.action.mjs +0 -14
- package/dist/modules/auth/actions/register.action.mjs.map +0 -1
- package/dist/modules/auth/actions/validate-session.action.mjs +0 -60
- package/dist/modules/auth/actions/validate-session.action.mjs.map +0 -1
- package/dist/modules/auth/actions/verify-two-factor.action.mjs +0 -17
- package/dist/modules/auth/actions/verify-two-factor.action.mjs.map +0 -1
- package/dist/modules/auth/hooks/login.hook.mjs +0 -13
- package/dist/modules/auth/hooks/login.hook.mjs.map +0 -1
- package/dist/modules/auth/hooks/logout.hook.mjs +0 -13
- package/dist/modules/auth/hooks/logout.hook.mjs.map +0 -1
- package/dist/modules/auth/hooks/register.hook.mjs +0 -13
- package/dist/modules/auth/hooks/register.hook.mjs.map +0 -1
- package/dist/modules/auth/hooks/useUserQuery.mjs +0 -63
- package/dist/modules/auth/hooks/useUserQuery.mjs.map +0 -1
- package/dist/modules/auth/schema.mjs +0 -1
- package/dist/modules/auth/schema.mjs.map +0 -1
- package/dist/modules/auth/services/auth.service.mjs +0 -293
- package/dist/modules/auth/services/auth.service.mjs.map +0 -1
- package/dist/modules/auth/utils/get-user-context.mjs +0 -24
- package/dist/modules/auth/utils/get-user-context.mjs.map +0 -1
- package/dist/modules/ia-credits/actions/list-ia-credits.action.mjs +0 -10
- package/dist/modules/ia-credits/actions/list-ia-credits.action.mjs.map +0 -1
- package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs +0 -76
- package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs.map +0 -1
- package/dist/modules/ia-credits/services/ia-credits.service.mjs +0 -31
- package/dist/modules/ia-credits/services/ia-credits.service.mjs.map +0 -1
- package/dist/modules/ia-credits/types.mjs +0 -25
- package/dist/modules/ia-credits/types.mjs.map +0 -1
- package/dist/modules/projects/actions/add-project-user.action.mjs +0 -10
- package/dist/modules/projects/actions/add-project-user.action.mjs.map +0 -1
- package/dist/modules/projects/actions/list-available-users.action.mjs +0 -10
- package/dist/modules/projects/actions/list-available-users.action.mjs.map +0 -1
- package/dist/modules/projects/actions/list-project-users.action.mjs +0 -10
- package/dist/modules/projects/actions/list-project-users.action.mjs.map +0 -1
- package/dist/modules/projects/actions/remove-project-user.action.mjs +0 -10
- package/dist/modules/projects/actions/remove-project-user.action.mjs.map +0 -1
- package/dist/modules/projects/hooks/list-available-users.hook.mjs +0 -34
- package/dist/modules/projects/hooks/list-available-users.hook.mjs.map +0 -1
- package/dist/modules/projects/hooks/list-project-users.hook.mjs +0 -34
- package/dist/modules/projects/hooks/list-project-users.hook.mjs.map +0 -1
- package/dist/modules/projects/services/project-users.service.mjs +0 -78
- package/dist/modules/projects/services/project-users.service.mjs.map +0 -1
- package/dist/modules/projects/types.mjs +0 -22
- package/dist/modules/projects/types.mjs.map +0 -1
- package/dist/modules/subscriptions/actions/list-subscriptions.action.mjs +0 -10
- package/dist/modules/subscriptions/actions/list-subscriptions.action.mjs.map +0 -1
- package/dist/modules/subscriptions/constants/addons.constants.mjs +0 -12
- package/dist/modules/subscriptions/constants/addons.constants.mjs.map +0 -1
- package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs +0 -20
- package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs.map +0 -1
- package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs +0 -18
- package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs.map +0 -1
- package/dist/modules/subscriptions/services/subscriptions.service.mjs +0 -32
- package/dist/modules/subscriptions/services/subscriptions.service.mjs.map +0 -1
- package/dist/modules/subscriptions/types.mjs +0 -57
- package/dist/modules/subscriptions/types.mjs.map +0 -1
- package/dist/modules/users/action/find-user-by-id.action.mjs +0 -10
- package/dist/modules/users/action/find-user-by-id.action.mjs.map +0 -1
- package/dist/modules/users/action/list-messages.action.mjs +0 -13
- package/dist/modules/users/action/list-messages.action.mjs.map +0 -1
- package/dist/modules/users/action/mark-all-messages-as-read.action.mjs +0 -10
- package/dist/modules/users/action/mark-all-messages-as-read.action.mjs.map +0 -1
- package/dist/modules/users/action/mark-message-as-read.action.mjs +0 -10
- package/dist/modules/users/action/mark-message-as-read.action.mjs.map +0 -1
- package/dist/modules/users/hooks/messages.hook.mjs +0 -57
- package/dist/modules/users/hooks/messages.hook.mjs.map +0 -1
- package/dist/modules/users/schema/messages.schema.mjs +0 -21
- package/dist/modules/users/schema/messages.schema.mjs.map +0 -1
- package/dist/modules/users/schema.mjs +0 -11
- package/dist/modules/users/schema.mjs.map +0 -1
- package/dist/modules/users/services/messages.service.mjs +0 -35
- package/dist/modules/users/services/messages.service.mjs.map +0 -1
- package/dist/modules/users/services/user.service.mjs +0 -50
- package/dist/modules/users/services/user.service.mjs.map +0 -1
- package/dist/modules/whitelabel/actions/find-whitelabel-styles.action.mjs +0 -15
- package/dist/modules/whitelabel/actions/find-whitelabel-styles.action.mjs.map +0 -1
- package/dist/modules/whitelabel/actions/find-whitelabel.action.mjs +0 -21
- package/dist/modules/whitelabel/actions/find-whitelabel.action.mjs.map +0 -1
- package/dist/modules/whitelabel/schema.mjs +0 -1
- package/dist/modules/whitelabel/schema.mjs.map +0 -1
- package/dist/modules/whitelabel/services/whitelabel-styles.service.mjs +0 -81
- package/dist/modules/whitelabel/services/whitelabel-styles.service.mjs.map +0 -1
- package/dist/modules/whitelabel/services/whitelabel.service.mjs +0 -61
- package/dist/modules/whitelabel/services/whitelabel.service.mjs.map +0 -1
- package/dist/modules/whitelabel/styles-schema.mjs +0 -1
- package/dist/modules/whitelabel/styles-schema.mjs.map +0 -1
- package/dist/providers/auth.provider.mjs +0 -100
- package/dist/providers/auth.provider.mjs.map +0 -1
- package/dist/providers/query.provider.mjs +0 -99
- package/dist/providers/query.provider.mjs.map +0 -1
- package/dist/providers/whitelabel.provider.mjs +0 -31
- package/dist/providers/whitelabel.provider.mjs.map +0 -1
- package/dist/server.mjs +0 -84
- package/dist/server.mjs.map +0 -1
- package/dist/store/useAccountModals.mjs +0 -18
- package/dist/store/useAccountModals.mjs.map +0 -1
- package/dist/store/useMdSidebarStore.mjs +0 -11
- package/dist/store/useMdSidebarStore.mjs.map +0 -1
- package/dist/store/useMobileNavbarSheet.mjs +0 -14
- package/dist/store/useMobileNavbarSheet.mjs.map +0 -1
- package/dist/store/useModalManager.mjs +0 -75
- package/dist/store/useModalManager.mjs.map +0 -1
- package/dist/utils/browser/clipboard.mjs +0 -36
- package/dist/utils/browser/clipboard.mjs.map +0 -1
- package/dist/utils/file/index.mjs +0 -9
- package/dist/utils/file/index.mjs.map +0 -1
- package/dist/utils/format/masks.mjs +0 -56
- package/dist/utils/format/masks.mjs.map +0 -1
- package/dist/utils/intl/locales.mjs +0 -12
- package/dist/utils/intl/locales.mjs.map +0 -1
- package/dist/utils/safeServerAction.mjs +0 -16
- package/dist/utils/safeServerAction.mjs.map +0 -1
- package/dist/utils/validators/account.mjs +0 -26
- package/dist/utils/validators/account.mjs.map +0 -1
- package/dist/utils/validators/common.mjs +0 -47
- package/dist/utils/validators/common.mjs.map +0 -1
- package/dist/utils/withAction.mjs +0 -13
- package/dist/utils/withAction.mjs.map +0 -1
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
|
-
import { withAction } from "../../../utils/withAction";
|
|
4
|
-
const USER_QUERY_KEY = ["user"];
|
|
5
|
-
async function fetchUser() {
|
|
6
|
-
const { findUserById: getUserDataAction } = await import("../../users/action/find-user-by-id.action");
|
|
7
|
-
const result = await getUserDataAction();
|
|
8
|
-
return result.success && result.data ? result.data : null;
|
|
9
|
-
}
|
|
10
|
-
async function validateUserSession() {
|
|
11
|
-
const { validateSessionAction } = await import("../actions/validate-session.action");
|
|
12
|
-
return await validateSessionAction();
|
|
13
|
-
}
|
|
14
|
-
function useUserQuery() {
|
|
15
|
-
return useQuery({
|
|
16
|
-
queryKey: USER_QUERY_KEY,
|
|
17
|
-
queryFn: fetchUser,
|
|
18
|
-
staleTime: 5 * 60 * 1e3,
|
|
19
|
-
gcTime: 10 * 60 * 1e3,
|
|
20
|
-
retry: false
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
function useUserValidateSession(options) {
|
|
24
|
-
return useQuery({
|
|
25
|
-
queryKey: ["user-validate-session"],
|
|
26
|
-
queryFn: validateUserSession,
|
|
27
|
-
retry: false,
|
|
28
|
-
staleTime: 5 * 60 * 1e3,
|
|
29
|
-
...options,
|
|
30
|
-
refetchOnMount: "always",
|
|
31
|
-
refetchOnWindowFocus: true
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
function useTwoFactorVerify() {
|
|
35
|
-
const queryClient = useQueryClient();
|
|
36
|
-
return useMutation({
|
|
37
|
-
mutationFn: async ({ cookie, code }) => {
|
|
38
|
-
const { verifyTwoFactorAction } = await import("../actions/verify-two-factor.action");
|
|
39
|
-
return withAction(() => verifyTwoFactorAction(cookie, code))();
|
|
40
|
-
},
|
|
41
|
-
onSuccess: () => {
|
|
42
|
-
queryClient.invalidateQueries({ queryKey: USER_QUERY_KEY });
|
|
43
|
-
queryClient.invalidateQueries({ queryKey: ["two-factor-pending"] });
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
function useInvalidateUser() {
|
|
48
|
-
const queryClient = useQueryClient();
|
|
49
|
-
return () => queryClient.invalidateQueries({ queryKey: USER_QUERY_KEY });
|
|
50
|
-
}
|
|
51
|
-
function useSetUserData() {
|
|
52
|
-
const queryClient = useQueryClient();
|
|
53
|
-
return (user) => queryClient.setQueryData(USER_QUERY_KEY, user);
|
|
54
|
-
}
|
|
55
|
-
export {
|
|
56
|
-
USER_QUERY_KEY,
|
|
57
|
-
useInvalidateUser,
|
|
58
|
-
useSetUserData,
|
|
59
|
-
useTwoFactorVerify,
|
|
60
|
-
useUserQuery,
|
|
61
|
-
useUserValidateSession
|
|
62
|
-
};
|
|
63
|
-
//# sourceMappingURL=useUserQuery.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/auth/hooks/useUserQuery.ts"],"sourcesContent":["'use client';\r\n\r\nimport { useMutation, useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query';\r\nimport { User } from '../../users/schema';\r\nimport { withAction } from '../../../utils/withAction';\r\n\r\nexport const USER_QUERY_KEY = ['user'];\r\n\r\nasync function fetchUser(): Promise<User | null> {\r\n const { findUserById: getUserDataAction } = await import('../../users/action/find-user-by-id.action');\r\n const result = await getUserDataAction();\r\n return result.success && result.data ? result.data : null;\r\n}\r\n\r\nasync function validateUserSession(): Promise<boolean> {\r\n const { validateSessionAction } = await import('../actions/validate-session.action');\r\n return await validateSessionAction();\r\n}\r\n\r\nexport function useUserQuery() {\r\n return useQuery({\r\n queryKey: USER_QUERY_KEY,\r\n queryFn: fetchUser,\r\n staleTime: 5 * 60 * 1000,\r\n gcTime: 10 * 60 * 1000,\r\n retry: false,\r\n });\r\n}\r\n\r\nexport function useUserValidateSession(options?: UseQueryOptions) {\r\n return useQuery({\r\n queryKey: ['user-validate-session'],\r\n queryFn: validateUserSession,\r\n retry: false,\r\n staleTime: 5 * 60 * 1000,\r\n ...options,\r\n refetchOnMount: 'always',\r\n refetchOnWindowFocus: true,\r\n });\r\n}\r\n\r\nexport function useTwoFactorVerify() {\r\n const queryClient = useQueryClient();\r\n\r\n return useMutation({\r\n mutationFn: async ({ cookie, code }: { cookie: string; code: string }) => {\r\n const { verifyTwoFactorAction } = await import('../actions/verify-two-factor.action');\r\n return withAction(() => verifyTwoFactorAction(cookie, code))();\r\n },\r\n onSuccess: () => {\r\n queryClient.invalidateQueries({ queryKey: USER_QUERY_KEY });\r\n queryClient.invalidateQueries({ queryKey: ['two-factor-pending'] });\r\n },\r\n });\r\n}\r\n\r\nexport function useInvalidateUser() {\r\n const queryClient = useQueryClient();\r\n return () => queryClient.invalidateQueries({ queryKey: USER_QUERY_KEY });\r\n}\r\n\r\nexport function useSetUserData() {\r\n const queryClient = useQueryClient();\r\n return (user: User | null) => queryClient.setQueryData(USER_QUERY_KEY, user);\r\n}\r\n"],"mappings":";AAEA,SAAS,aAAa,UAAU,sBAAuC;AAEvE,SAAS,kBAAkB;AAEpB,MAAM,iBAAiB,CAAC,MAAM;AAErC,eAAe,YAAkC;AAC/C,QAAM,EAAE,cAAc,kBAAkB,IAAI,MAAM,OAAO,2CAA2C;AACpG,QAAM,SAAS,MAAM,kBAAkB;AACvC,SAAO,OAAO,WAAW,OAAO,OAAO,OAAO,OAAO;AACvD;AAEA,eAAe,sBAAwC;AACrD,QAAM,EAAE,sBAAsB,IAAI,MAAM,OAAO,oCAAoC;AACnF,SAAO,MAAM,sBAAsB;AACrC;AAEO,SAAS,eAAe;AAC7B,SAAO,SAAS;AAAA,IACd,UAAU;AAAA,IACV,SAAS;AAAA,IACT,WAAW,IAAI,KAAK;AAAA,IACpB,QAAQ,KAAK,KAAK;AAAA,IAClB,OAAO;AAAA,EACT,CAAC;AACH;AAEO,SAAS,uBAAuB,SAA2B;AAChE,SAAO,SAAS;AAAA,IACd,UAAU,CAAC,uBAAuB;AAAA,IAClC,SAAS;AAAA,IACT,OAAO;AAAA,IACP,WAAW,IAAI,KAAK;AAAA,IACpB,GAAG;AAAA,IACH,gBAAgB;AAAA,IAChB,sBAAsB;AAAA,EACxB,CAAC;AACH;AAEO,SAAS,qBAAqB;AACnC,QAAM,cAAc,eAAe;AAEnC,SAAO,YAAY;AAAA,IACjB,YAAY,OAAO,EAAE,QAAQ,KAAK,MAAwC;AACxE,YAAM,EAAE,sBAAsB,IAAI,MAAM,OAAO,qCAAqC;AACpF,aAAO,WAAW,MAAM,sBAAsB,QAAQ,IAAI,CAAC,EAAE;AAAA,IAC/D;AAAA,IACA,WAAW,MAAM;AACf,kBAAY,kBAAkB,EAAE,UAAU,eAAe,CAAC;AAC1D,kBAAY,kBAAkB,EAAE,UAAU,CAAC,oBAAoB,EAAE,CAAC;AAAA,IACpE;AAAA,EACF,CAAC;AACH;AAEO,SAAS,oBAAoB;AAClC,QAAM,cAAc,eAAe;AACnC,SAAO,MAAM,YAAY,kBAAkB,EAAE,UAAU,eAAe,CAAC;AACzE;AAEO,SAAS,iBAAiB;AAC/B,QAAM,cAAc,eAAe;AACnC,SAAO,CAAC,SAAsB,YAAY,aAAa,gBAAgB,IAAI;AAC7E;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=schema.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
import { cookies } from "next/headers";
|
|
2
|
-
import { api } from "../../../infra/api/client";
|
|
3
|
-
import { ApiError } from "../../../infra/api/types";
|
|
4
|
-
const AUTH_COOKIE_NAME = "greatapps";
|
|
5
|
-
const COOKIE_MAX_AGE = 60 * 60 * 24 * 30;
|
|
6
|
-
const COOKIE_OPTIONS = {
|
|
7
|
-
httpOnly: true,
|
|
8
|
-
secure: process.env.NODE_ENV === "production",
|
|
9
|
-
sameSite: "lax",
|
|
10
|
-
path: "/",
|
|
11
|
-
domain: process.env.DOMAIN_COOKIE
|
|
12
|
-
};
|
|
13
|
-
class AuthService {
|
|
14
|
-
async login(credentials, clientInfo) {
|
|
15
|
-
const response = await api.apps.post("/auth/login", {
|
|
16
|
-
email: credentials.email,
|
|
17
|
-
password: credentials.password,
|
|
18
|
-
location: clientInfo.location,
|
|
19
|
-
ip: clientInfo.ip,
|
|
20
|
-
timezone: clientInfo.timezone,
|
|
21
|
-
agent: clientInfo.agent
|
|
22
|
-
});
|
|
23
|
-
console.log("[AuthService.login] response", JSON.stringify(response));
|
|
24
|
-
if (response.status === 0) {
|
|
25
|
-
throw new ApiError(
|
|
26
|
-
response.message || "E-mail ou senha incorretos",
|
|
27
|
-
response.code || "LOGIN_FAILED",
|
|
28
|
-
401
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
if (!response.cookie) {
|
|
32
|
-
throw new ApiError(
|
|
33
|
-
"Resposta de autentica\xE7\xE3o inv\xE1lida",
|
|
34
|
-
"INVALID_RESPONSE",
|
|
35
|
-
500
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
if (response.two_factor_required) {
|
|
39
|
-
return { result: "two_factor_required", cookie: response.cookie };
|
|
40
|
-
}
|
|
41
|
-
await this.setAuthCookie(response.cookie);
|
|
42
|
-
const [{ userService }, { accountService }] = await Promise.all([
|
|
43
|
-
import("../../users/services/user.service"),
|
|
44
|
-
import("../../accounts/services/account.service")
|
|
45
|
-
]);
|
|
46
|
-
const [user, account] = await Promise.all([
|
|
47
|
-
userService.findById(),
|
|
48
|
-
accountService.findCurrentAccount()
|
|
49
|
-
]);
|
|
50
|
-
return {
|
|
51
|
-
result: "success",
|
|
52
|
-
user,
|
|
53
|
-
account,
|
|
54
|
-
accessToken: response.cookie,
|
|
55
|
-
refreshToken: "",
|
|
56
|
-
expiresAt: new Date(Date.now() + COOKIE_MAX_AGE * 1e3).toISOString()
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
async verifyTwoFactor(cookie, code, clientInfo) {
|
|
60
|
-
const payload = {
|
|
61
|
-
location: clientInfo.location,
|
|
62
|
-
ip: clientInfo.ip,
|
|
63
|
-
timezone: clientInfo.timezone,
|
|
64
|
-
agent: clientInfo.agent,
|
|
65
|
-
cookie,
|
|
66
|
-
code
|
|
67
|
-
};
|
|
68
|
-
const response = await api.apps.post(
|
|
69
|
-
"/auth/code",
|
|
70
|
-
payload
|
|
71
|
-
);
|
|
72
|
-
if (response.status === 0) {
|
|
73
|
-
throw new ApiError("C\xF3digo 2FA inv\xE1lido", "TWO_FACTOR_FAILED", 401);
|
|
74
|
-
}
|
|
75
|
-
if (!response?.data?.cookie) {
|
|
76
|
-
throw new ApiError(
|
|
77
|
-
"Resposta de autentica\xE7\xE3o inv\xE1lida ap\xF3s 2FA",
|
|
78
|
-
"INVALID_RESPONSE",
|
|
79
|
-
500
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
await this.setAuthCookie(response.data.cookie);
|
|
83
|
-
return { status: 1 };
|
|
84
|
-
}
|
|
85
|
-
async register(data, clientInfo) {
|
|
86
|
-
const today = /* @__PURE__ */ new Date();
|
|
87
|
-
const trialEndDate = new Date(today);
|
|
88
|
-
trialEndDate.setDate(today.getDate() + 7);
|
|
89
|
-
const idPlan = await this.resolvePlanId(data.idPlan);
|
|
90
|
-
const payload = {
|
|
91
|
-
name: data.accountName,
|
|
92
|
-
bussiness_type: data.businessType ?? 0,
|
|
93
|
-
language: "pt-br",
|
|
94
|
-
timezone: "America/Sao_Paulo",
|
|
95
|
-
currency: "BRL",
|
|
96
|
-
location: clientInfo.location,
|
|
97
|
-
ip: clientInfo.ip,
|
|
98
|
-
agent: clientInfo.agent,
|
|
99
|
-
user: {
|
|
100
|
-
id_api: "",
|
|
101
|
-
name: data.name,
|
|
102
|
-
last_name: data.lastName || "",
|
|
103
|
-
rg: data.rg || "",
|
|
104
|
-
cpf: data.cpf || "",
|
|
105
|
-
gender: data.gender,
|
|
106
|
-
email: data.email,
|
|
107
|
-
phone: data.phone,
|
|
108
|
-
password: data.password,
|
|
109
|
-
profile: "owner",
|
|
110
|
-
language: "pt-br"
|
|
111
|
-
},
|
|
112
|
-
subscription: {
|
|
113
|
-
type: "trial",
|
|
114
|
-
id_cupom: data.couponCode || "",
|
|
115
|
-
id_plan: idPlan,
|
|
116
|
-
due_date: trialEndDate.toISOString().split("T")[0],
|
|
117
|
-
id_product: 1
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
const response = await api.apps.post(
|
|
121
|
-
"/accounts",
|
|
122
|
-
payload
|
|
123
|
-
);
|
|
124
|
-
if (response.status === 0) {
|
|
125
|
-
throw new ApiError(
|
|
126
|
-
response.message || "Erro ao criar conta",
|
|
127
|
-
"REGISTER_FAILED",
|
|
128
|
-
400
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
if (!response.data || response.data.length === 0) {
|
|
132
|
-
throw new ApiError(
|
|
133
|
-
"Resposta de registro inv\xE1lida",
|
|
134
|
-
"INVALID_RESPONSE",
|
|
135
|
-
500
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
if (!response.cookie) {
|
|
139
|
-
throw new ApiError(
|
|
140
|
-
"Resposta de autentica\xE7\xE3o inv\xE1lida",
|
|
141
|
-
"INVALID_RESPONSE",
|
|
142
|
-
500
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
const accountData = response.data[0];
|
|
146
|
-
await this.setAuthCookie(response.cookie);
|
|
147
|
-
const [{ userService }, { accountService }] = await Promise.all([
|
|
148
|
-
import("../../users/services/user.service"),
|
|
149
|
-
import("../../accounts/services/account.service")
|
|
150
|
-
]);
|
|
151
|
-
const [user, account] = await Promise.all([
|
|
152
|
-
userService.findById(),
|
|
153
|
-
accountService.findCurrentAccount()
|
|
154
|
-
]);
|
|
155
|
-
return {
|
|
156
|
-
user,
|
|
157
|
-
account,
|
|
158
|
-
accessToken: response.cookie,
|
|
159
|
-
refreshToken: "",
|
|
160
|
-
expiresAt: new Date(Date.now() + COOKIE_MAX_AGE * 1e3).toISOString(),
|
|
161
|
-
requiresEmailVerification: !accountData.verified
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
async logout(clientInfo) {
|
|
165
|
-
const cookie = await this.getToken();
|
|
166
|
-
if (!cookie) {
|
|
167
|
-
throw new ApiError(
|
|
168
|
-
"Usu\xE1rio n\xE3o autenticado",
|
|
169
|
-
"NOT_AUTHENTICATED_LOGOUT",
|
|
170
|
-
401
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
const payload = {
|
|
174
|
-
location: clientInfo.location,
|
|
175
|
-
ip: clientInfo.ip,
|
|
176
|
-
timezone: clientInfo.timezone,
|
|
177
|
-
agent: clientInfo.agent,
|
|
178
|
-
cookie
|
|
179
|
-
};
|
|
180
|
-
try {
|
|
181
|
-
const response = await api.apps.post(
|
|
182
|
-
"/auth/logout",
|
|
183
|
-
payload
|
|
184
|
-
);
|
|
185
|
-
if (response.status === 0) {
|
|
186
|
-
throw new ApiError(
|
|
187
|
-
response.message || "Erro ao realizar logout",
|
|
188
|
-
response.code || "LOGOUT_FAILED",
|
|
189
|
-
400
|
|
190
|
-
);
|
|
191
|
-
}
|
|
192
|
-
} finally {
|
|
193
|
-
await this.removeAuthCookie();
|
|
194
|
-
}
|
|
195
|
-
return {
|
|
196
|
-
success: true
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
async forgotPassword(_data) {
|
|
200
|
-
throw new ApiError(
|
|
201
|
-
"Recupera\xE7\xE3o de senha n\xE3o implementada",
|
|
202
|
-
"NOT_IMPLEMENTED",
|
|
203
|
-
501
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
|
-
async resetPassword(_data) {
|
|
207
|
-
throw new ApiError(
|
|
208
|
-
"Redefini\xE7\xE3o de senha n\xE3o implementada",
|
|
209
|
-
"NOT_IMPLEMENTED",
|
|
210
|
-
501
|
|
211
|
-
);
|
|
212
|
-
}
|
|
213
|
-
async verifyEmail(_data) {
|
|
214
|
-
throw new ApiError(
|
|
215
|
-
"Verifica\xE7\xE3o de email n\xE3o implementada",
|
|
216
|
-
"NOT_IMPLEMENTED",
|
|
217
|
-
501
|
|
218
|
-
);
|
|
219
|
-
}
|
|
220
|
-
async resendVerification(_data) {
|
|
221
|
-
throw new ApiError(
|
|
222
|
-
"Reenvio de verifica\xE7\xE3o n\xE3o implementado",
|
|
223
|
-
"NOT_IMPLEMENTED",
|
|
224
|
-
501
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
async validateSession(clientInfo) {
|
|
228
|
-
const cookie = await this.getToken();
|
|
229
|
-
if (!cookie) {
|
|
230
|
-
return false;
|
|
231
|
-
}
|
|
232
|
-
try {
|
|
233
|
-
const payload = {
|
|
234
|
-
location: clientInfo.location,
|
|
235
|
-
ip: clientInfo.ip,
|
|
236
|
-
timezone: clientInfo.timezone,
|
|
237
|
-
agent: clientInfo.agent,
|
|
238
|
-
cookie
|
|
239
|
-
};
|
|
240
|
-
const response = await api.apps.post(
|
|
241
|
-
"/auth/keep",
|
|
242
|
-
payload
|
|
243
|
-
);
|
|
244
|
-
return response.status === 1;
|
|
245
|
-
} catch (error) {
|
|
246
|
-
console.error("[AuthService] validateSession error", error);
|
|
247
|
-
return false;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
async isAuthenticated() {
|
|
251
|
-
const token = await this.getToken();
|
|
252
|
-
return !!token;
|
|
253
|
-
}
|
|
254
|
-
async getToken() {
|
|
255
|
-
if (process.env.DUMMY_AUTH_TOKEN) return process.env.DUMMY_AUTH_TOKEN;
|
|
256
|
-
const cookieStore = await cookies();
|
|
257
|
-
return cookieStore.get(AUTH_COOKIE_NAME)?.value;
|
|
258
|
-
}
|
|
259
|
-
async resolvePlanId(idPlan) {
|
|
260
|
-
if (idPlan === void 0 || idPlan === null) return 1;
|
|
261
|
-
if (typeof idPlan === "number") return idPlan;
|
|
262
|
-
const response = await api.apps.get(
|
|
263
|
-
`/plans?search=${encodeURIComponent(idPlan)}`
|
|
264
|
-
);
|
|
265
|
-
if (response.status === 0 || !response.data || response.data.length === 0) {
|
|
266
|
-
throw new ApiError(
|
|
267
|
-
`Plano "${idPlan}" n\xE3o encontrado`,
|
|
268
|
-
"PLAN_NOT_FOUND",
|
|
269
|
-
404
|
|
270
|
-
);
|
|
271
|
-
}
|
|
272
|
-
return response.data[0].id;
|
|
273
|
-
}
|
|
274
|
-
async setAuthCookie(token) {
|
|
275
|
-
const cookieStore = await cookies();
|
|
276
|
-
cookieStore.set(AUTH_COOKIE_NAME, token, {
|
|
277
|
-
...COOKIE_OPTIONS,
|
|
278
|
-
maxAge: COOKIE_MAX_AGE
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
async removeAuthCookie() {
|
|
282
|
-
const cookieStore = await cookies();
|
|
283
|
-
cookieStore.delete({
|
|
284
|
-
name: AUTH_COOKIE_NAME,
|
|
285
|
-
...COOKIE_OPTIONS
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
const authService = new AuthService();
|
|
290
|
-
export {
|
|
291
|
-
authService
|
|
292
|
-
};
|
|
293
|
-
//# sourceMappingURL=auth.service.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/auth/services/auth.service.ts"],"sourcesContent":["import { cookies } from \"next/headers\";\r\n\r\nimport { api } from \"../../../infra/api/client\";\r\nimport { ApiError } from \"../../../infra/api/types\";\r\nimport {\r\n ClientInfo,\r\n ForgotPasswordRequest,\r\n ForgotPasswordResponse,\r\n GeoLocation,\r\n LoginApiResponse,\r\n LoginRequest,\r\n LoginResponse,\r\n LogoutApiResponse,\r\n LogoutRequest,\r\n LogoutResponse,\r\n RegisterApiRequest,\r\n RegisterApiResponse,\r\n RegisterRequest,\r\n RegisterResponse,\r\n ResendVerificationRequest,\r\n ResendVerificationResponse,\r\n ResetPasswordRequest,\r\n ResetPasswordResponse,\r\n SearchPlansApiResponse,\r\n SessionKeepRequest,\r\n SessionKeepResponse,\r\n TwoFactorApiResponse,\r\n TwoFactorRequest,\r\n TwoFactorResponse,\r\n VerifyEmailRequest,\r\n VerifyEmailResponse,\r\n} from \"../schema\";\r\n\r\nconst AUTH_COOKIE_NAME = \"greatapps\";\r\nconst COOKIE_MAX_AGE = 60 * 60 * 24 * 30;\r\n\r\nconst COOKIE_OPTIONS = {\r\n httpOnly: true,\r\n secure: process.env.NODE_ENV === \"production\",\r\n sameSite: \"lax\" as const,\r\n path: \"/\",\r\n domain: process.env.DOMAIN_COOKIE,\r\n};\r\n\r\nclass AuthService {\r\n async login(\r\n credentials: LoginRequest,\r\n clientInfo: ClientInfo\r\n ): Promise<LoginResponse> {\r\n const response = await api.apps.post<LoginApiResponse>(\"/auth/login\", {\r\n email: credentials.email,\r\n password: credentials.password,\r\n location: clientInfo.location,\r\n ip: clientInfo.ip,\r\n timezone: clientInfo.timezone,\r\n agent: clientInfo.agent,\r\n });\r\n\r\n console.log(\"[AuthService.login] response\", JSON.stringify(response));\r\n\r\n if (response.status === 0) {\r\n throw new ApiError(\r\n response.message || \"E-mail ou senha incorretos\",\r\n response.code || \"LOGIN_FAILED\",\r\n 401\r\n );\r\n }\r\n\r\n if (!response.cookie) {\r\n throw new ApiError(\r\n \"Resposta de autenticação inválida\",\r\n \"INVALID_RESPONSE\",\r\n 500\r\n );\r\n }\r\n\r\n if (response.two_factor_required) {\r\n return { result: 'two_factor_required', cookie: response.cookie };\r\n }\r\n\r\n await this.setAuthCookie(response.cookie);\r\n\r\n const [{ userService }, { accountService }] = await Promise.all([\r\n import('../../users/services/user.service'),\r\n import('../../accounts/services/account.service'),\r\n ]);\r\n const [user, account] = await Promise.all([\r\n userService.findById(),\r\n accountService.findCurrentAccount(),\r\n ]);\r\n\r\n return {\r\n result: 'success',\r\n user,\r\n account,\r\n accessToken: response.cookie,\r\n refreshToken: \"\",\r\n expiresAt: new Date(Date.now() + COOKIE_MAX_AGE * 1000).toISOString(),\r\n };\r\n }\r\n\r\n async verifyTwoFactor(\r\n cookie: string,\r\n code: string,\r\n clientInfo: ClientInfo\r\n ): Promise<TwoFactorResponse> {\r\n const payload: TwoFactorRequest = {\r\n location: clientInfo.location,\r\n ip: clientInfo.ip,\r\n timezone: clientInfo.timezone,\r\n agent: clientInfo.agent,\r\n cookie,\r\n code,\r\n };\r\n\r\n const response = await api.apps.post<TwoFactorApiResponse>(\r\n \"/auth/code\",\r\n payload\r\n );\r\n\r\n if (response.status === 0) {\r\n throw new ApiError(\"Código 2FA inválido\", \"TWO_FACTOR_FAILED\", 401);\r\n }\r\n\r\n if (!response?.data?.cookie) {\r\n throw new ApiError(\r\n \"Resposta de autenticação inválida após 2FA\",\r\n \"INVALID_RESPONSE\",\r\n 500\r\n );\r\n }\r\n\r\n await this.setAuthCookie(response.data.cookie);\r\n\r\n return { status: 1 };\r\n }\r\n async register(data: RegisterRequest, clientInfo: ClientInfo): Promise<RegisterResponse> {\r\n const today = new Date();\r\n const trialEndDate = new Date(today);\r\n trialEndDate.setDate(today.getDate() + 7); // 7 dias de trial\r\n\r\n const idPlan = await this.resolvePlanId(data.idPlan);\r\n\r\n const payload: RegisterApiRequest = {\r\n name: data.accountName,\r\n bussiness_type: data.businessType ?? 0,\r\n language: \"pt-br\",\r\n timezone: \"America/Sao_Paulo\",\r\n currency: \"BRL\",\r\n location: clientInfo.location,\r\n ip: clientInfo.ip,\r\n agent: clientInfo.agent,\r\n user: {\r\n id_api: \"\",\r\n name: data.name,\r\n last_name: data.lastName || \"\",\r\n rg: data.rg || \"\",\r\n cpf: data.cpf || \"\",\r\n gender: data.gender,\r\n email: data.email,\r\n phone: data.phone,\r\n password: data.password,\r\n profile: \"owner\",\r\n language: \"pt-br\",\r\n },\r\n subscription: {\r\n type: \"trial\",\r\n id_cupom: data.couponCode || \"\",\r\n id_plan: idPlan,\r\n due_date: trialEndDate.toISOString().split(\"T\")[0],\r\n id_product: 1,\r\n },\r\n };\r\n\r\n const response = await api.apps.post<RegisterApiResponse>(\r\n \"/accounts\",\r\n payload\r\n );\r\n\r\n if (response.status === 0) {\r\n throw new ApiError(\r\n response.message || \"Erro ao criar conta\",\r\n \"REGISTER_FAILED\",\r\n 400\r\n );\r\n }\r\n\r\n if (!response.data || response.data.length === 0) {\r\n throw new ApiError(\r\n \"Resposta de registro inválida\",\r\n \"INVALID_RESPONSE\",\r\n 500\r\n );\r\n }\r\n\r\n if (!response.cookie) {\r\n throw new ApiError(\r\n \"Resposta de autenticação inválida\",\r\n \"INVALID_RESPONSE\",\r\n 500\r\n );\r\n }\r\n\r\n const accountData = response.data[0];\r\n\r\n await this.setAuthCookie(response.cookie);\r\n\r\n const [{ userService }, { accountService }] = await Promise.all([\r\n import('../../users/services/user.service'),\r\n import('../../accounts/services/account.service'),\r\n ]);\r\n const [user, account] = await Promise.all([\r\n userService.findById(),\r\n accountService.findCurrentAccount(),\r\n ]);\r\n\r\n return {\r\n user,\r\n account,\r\n accessToken: response.cookie,\r\n refreshToken: \"\",\r\n expiresAt: new Date(Date.now() + COOKIE_MAX_AGE * 1000).toISOString(),\r\n requiresEmailVerification: !accountData.verified,\r\n };\r\n }\r\n\r\n async logout(clientInfo: ClientInfo): Promise<LogoutResponse> {\r\n const cookie = await this.getToken();\r\n\r\n if (!cookie) {\r\n throw new ApiError(\r\n \"Usuário não autenticado\",\r\n \"NOT_AUTHENTICATED_LOGOUT\",\r\n 401\r\n );\r\n }\r\n\r\n const payload: LogoutRequest = {\r\n location: clientInfo.location,\r\n ip: clientInfo.ip,\r\n timezone: clientInfo.timezone,\r\n agent: clientInfo.agent,\r\n cookie,\r\n };\r\n\r\n try {\r\n const response = await api.apps.post<LogoutApiResponse>(\r\n \"/auth/logout\",\r\n payload\r\n );\r\n\r\n if (response.status === 0) {\r\n throw new ApiError(\r\n response.message || \"Erro ao realizar logout\",\r\n response.code || \"LOGOUT_FAILED\",\r\n 400\r\n );\r\n }\r\n } finally {\r\n await this.removeAuthCookie();\r\n }\r\n\r\n return {\r\n success: true,\r\n };\r\n }\r\n\r\n async forgotPassword(\r\n _data: ForgotPasswordRequest\r\n ): Promise<ForgotPasswordResponse> {\r\n throw new ApiError(\r\n \"Recuperação de senha não implementada\",\r\n \"NOT_IMPLEMENTED\",\r\n 501\r\n );\r\n }\r\n\r\n async resetPassword(\r\n _data: ResetPasswordRequest\r\n ): Promise<ResetPasswordResponse> {\r\n throw new ApiError(\r\n \"Redefinição de senha não implementada\",\r\n \"NOT_IMPLEMENTED\",\r\n 501\r\n );\r\n }\r\n\r\n async verifyEmail(_data: VerifyEmailRequest): Promise<VerifyEmailResponse> {\r\n throw new ApiError(\r\n \"Verificação de email não implementada\",\r\n \"NOT_IMPLEMENTED\",\r\n 501\r\n );\r\n }\r\n\r\n async resendVerification(\r\n _data: ResendVerificationRequest\r\n ): Promise<ResendVerificationResponse> {\r\n throw new ApiError(\r\n \"Reenvio de verificação não implementado\",\r\n \"NOT_IMPLEMENTED\",\r\n 501\r\n );\r\n }\r\n\r\n async validateSession(clientInfo: ClientInfo): Promise<boolean> {\r\n const cookie = await this.getToken();\r\n\r\n if (!cookie) {\r\n return false;\r\n }\r\n\r\n try {\r\n const payload: SessionKeepRequest = {\r\n location: clientInfo.location,\r\n ip: clientInfo.ip,\r\n timezone: clientInfo.timezone,\r\n agent: clientInfo.agent,\r\n cookie,\r\n };\r\n\r\n const response = await api.apps.post<SessionKeepResponse>(\r\n \"/auth/keep\",\r\n payload\r\n );\r\n\r\n return response.status === 1;\r\n } catch (error) {\r\n console.error(\"[AuthService] validateSession error\", error);\r\n return false;\r\n }\r\n }\r\n\r\n async isAuthenticated(): Promise<boolean> {\r\n const token = await this.getToken();\r\n return !!token;\r\n }\r\n\r\n async getToken(): Promise<string | undefined> {\r\n if (process.env.DUMMY_AUTH_TOKEN) return process.env.DUMMY_AUTH_TOKEN;\r\n const cookieStore = await cookies();\r\n return cookieStore.get(AUTH_COOKIE_NAME)?.value;\r\n }\r\n\r\n private async resolvePlanId(idPlan?: number | string): Promise<number> {\r\n if (idPlan === undefined || idPlan === null) return 1;\r\n if (typeof idPlan === 'number') return idPlan;\r\n\r\n const response = await api.apps.get<SearchPlansApiResponse>(\r\n `/plans?search=${encodeURIComponent(idPlan)}`\r\n );\r\n\r\n if (response.status === 0 || !response.data || response.data.length === 0) {\r\n throw new ApiError(\r\n `Plano \"${idPlan}\" não encontrado`,\r\n \"PLAN_NOT_FOUND\",\r\n 404\r\n );\r\n }\r\n\r\n return response.data[0].id;\r\n }\r\n\r\n private async setAuthCookie(token: string): Promise<void> {\r\n const cookieStore = await cookies();\r\n cookieStore.set(AUTH_COOKIE_NAME, token, {\r\n ...COOKIE_OPTIONS,\r\n maxAge: COOKIE_MAX_AGE,\r\n });\r\n }\r\n\r\n async removeAuthCookie(): Promise<void> {\r\n const cookieStore = await cookies();\r\n cookieStore.delete({\r\n name: AUTH_COOKIE_NAME,\r\n ...COOKIE_OPTIONS,\r\n });\r\n }\r\n}\r\n\r\nexport const authService = new AuthService();\r\n\r\nexport type { ClientInfo, GeoLocation };\r\n"],"mappings":"AAAA,SAAS,eAAe;AAExB,SAAS,WAAW;AACpB,SAAS,gBAAgB;AA8BzB,MAAM,mBAAmB;AACzB,MAAM,iBAAiB,KAAK,KAAK,KAAK;AAEtC,MAAM,iBAAiB;AAAA,EACrB,UAAU;AAAA,EACV,QAAQ,QAAQ,IAAI,aAAa;AAAA,EACjC,UAAU;AAAA,EACV,MAAM;AAAA,EACN,QAAQ,QAAQ,IAAI;AACtB;AAEA,MAAM,YAAY;AAAA,EAChB,MAAM,MACJ,aACA,YACwB;AACxB,UAAM,WAAW,MAAM,IAAI,KAAK,KAAuB,eAAe;AAAA,MACpE,OAAO,YAAY;AAAA,MACnB,UAAU,YAAY;AAAA,MACtB,UAAU,WAAW;AAAA,MACrB,IAAI,WAAW;AAAA,MACf,UAAU,WAAW;AAAA,MACrB,OAAO,WAAW;AAAA,IACpB,CAAC;AAED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I;AACrD,UAAM,cAAc,MAAM,QAAQ;AAClC,WAAO,YAAY,IAAI,gBAAgB,GAAG;AAAA,EAC5C;AAAA,EAEA,MAAc,cAAc,QAA2C;AACrE,QAAI,WAAW,UAAa,WAAW,KAAM,QAAO;AACpD,QAAI,OAAO,WAAW,SAAU,QAAO;AAEvC,UAAM,WAAW,MAAM,IAAI,KAAK;AAAA,MAC9B,iBAAiB,mBAAmB,MAAM,CAAC;AAAA,IAC7C;AAEA,QAAI,SAAS,WAAW,KAAK,CAAC,SAAS,QAAQ,SAAS,KAAK,WAAW,GAAG;AACzE,YAAM,IAAI;AAAA,QACR,UAAU,MAAM;AAAA,QAChB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,WAAO,SAAS,KAAK,CAAC,EAAE;AAAA,EAC1B;AAAA,EAEA,MAAc,cAAc,OAA8B;AACxD,UAAM,cAAc,MAAM,QAAQ;AAClC,gBAAY,IAAI,kBAAkB,OAAO;AAAA,MACvC,GAAG;AAAA,MACH,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,mBAAkC;AACtC,UAAM,cAAc,MAAM,QAAQ;AAClC,gBAAY,OAAO;AAAA,MACjB,MAAM;AAAA,MACN,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;AAEO,MAAM,cAAc,IAAI,YAAY;","names":[]}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import "server-only";
|
|
2
|
-
import { cookies } from "next/headers";
|
|
3
|
-
import { ApiError } from "../../../infra/api/types";
|
|
4
|
-
const AUTH_COOKIE_NAME = "greatapps";
|
|
5
|
-
async function getUserContext() {
|
|
6
|
-
const cookieStore = await cookies();
|
|
7
|
-
const token = process.env.DUMMY_AUTH_TOKEN || cookieStore.get(AUTH_COOKIE_NAME)?.value;
|
|
8
|
-
if (!token) {
|
|
9
|
-
throw new ApiError("Usu\xE1rio n\xE3o autenticado", "NOT_AUTHENTICATED_GUC", 401);
|
|
10
|
-
}
|
|
11
|
-
try {
|
|
12
|
-
const payload = JSON.parse(atob(token.split(".")[1]));
|
|
13
|
-
return {
|
|
14
|
-
id_account: payload.id_account,
|
|
15
|
-
id_user: payload.id_user
|
|
16
|
-
};
|
|
17
|
-
} catch {
|
|
18
|
-
throw new ApiError("Token inv\xE1lido", "INVALID_TOKEN", 401);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
export {
|
|
22
|
-
getUserContext
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=get-user-context.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/auth/utils/get-user-context.ts"],"sourcesContent":["import 'server-only';\r\n\r\nimport { cookies } from 'next/headers';\r\nimport { ApiError } from '../../../infra/api/types';\r\nimport { JWTPayload } from '../../users/schema';\r\n\r\nconst AUTH_COOKIE_NAME = 'greatapps';\r\n\r\nexport async function getUserContext(): Promise<{\r\n id_account: number;\r\n id_user: number;\r\n}> {\r\n const cookieStore = await cookies();\r\n const token = process.env.DUMMY_AUTH_TOKEN || cookieStore.get(AUTH_COOKIE_NAME)?.value;\r\n\r\n if (!token) {\r\n throw new ApiError('Usuário não autenticado', 'NOT_AUTHENTICATED_GUC', 401);\r\n }\r\n\r\n try {\r\n const payload = JSON.parse(atob(token.split('.')[1])) as JWTPayload;\r\n\r\n return {\r\n id_account: payload.id_account,\r\n id_user: payload.id_user,\r\n };\r\n } catch {\r\n throw new ApiError('Token inválido', 'INVALID_TOKEN', 401);\r\n }\r\n}\r\n"],"mappings":"AAAA,OAAO;AAEP,SAAS,eAAe;AACxB,SAAS,gBAAgB;AAGzB,MAAM,mBAAmB;AAEzB,eAAsB,iBAGnB;AACD,QAAM,cAAc,MAAM,QAAQ;AAClC,QAAM,QAAQ,QAAQ,IAAI,oBAAoB,YAAY,IAAI,gBAAgB,GAAG;AAEjF,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,SAAS,iCAA2B,yBAAyB,GAAG;AAAA,EAC5E;AAEA,MAAI;AACF,UAAM,UAAU,KAAK,MAAM,KAAK,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC;AAEpD,WAAO;AAAA,MACL,YAAY,QAAQ;AAAA,MACpB,SAAS,QAAQ;AAAA,IACnB;AAAA,EACF,QAAQ;AACN,UAAM,IAAI,SAAS,qBAAkB,iBAAiB,GAAG;AAAA,EAC3D;AACF;","names":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use server";
|
|
2
|
-
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
|
-
import { iaCreditsService } from "../services/ia-credits.service";
|
|
4
|
-
async function listIaCreditsAction(subscriptionId) {
|
|
5
|
-
return safeServerAction(() => iaCreditsService.listOperations(subscriptionId));
|
|
6
|
-
}
|
|
7
|
-
export {
|
|
8
|
-
listIaCreditsAction
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=list-ia-credits.action.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/ia-credits/actions/list-ia-credits.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { iaCreditsService } from '../services/ia-credits.service';\n\nexport async function listIaCreditsAction(subscriptionId: number | string) {\n return safeServerAction(() => iaCreditsService.listOperations(subscriptionId));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AAEjC,eAAsB,oBAAoB,gBAAiC;AACzE,SAAO,iBAAiB,MAAM,iBAAiB,eAAe,cAAc,CAAC;AAC/E;","names":[]}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import { useQuery } from "@tanstack/react-query";
|
|
4
|
-
import { listIaCreditsAction } from "../actions/list-ia-credits.action";
|
|
5
|
-
import { useActiveSubscription } from "../../subscriptions/hooks/find-active-subscription.hook";
|
|
6
|
-
import { withAction } from "../../../utils/withAction";
|
|
7
|
-
function calculateSummary(operations) {
|
|
8
|
-
const today = /* @__PURE__ */ new Date();
|
|
9
|
-
const todayDate = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
10
|
-
const adds = operations.filter((op) => op.operation === "add");
|
|
11
|
-
const subtracts = operations.filter((op) => op.operation === "subtract");
|
|
12
|
-
let totalCredits = 0;
|
|
13
|
-
let usedCredits = 0;
|
|
14
|
-
let nextExpirationInDays = null;
|
|
15
|
-
let nextExpiringCredits = null;
|
|
16
|
-
for (const add of adds) {
|
|
17
|
-
const expirationRaw = add.expiration_time;
|
|
18
|
-
if (!expirationRaw) continue;
|
|
19
|
-
const expiration = new Date(expirationRaw);
|
|
20
|
-
const expirationDate = new Date(
|
|
21
|
-
expiration.getFullYear(),
|
|
22
|
-
expiration.getMonth(),
|
|
23
|
-
expiration.getDate()
|
|
24
|
-
);
|
|
25
|
-
const expiredByDate = expirationDate.getTime() < todayDate.getTime();
|
|
26
|
-
const hasExpired = add.has_expired || expiredByDate;
|
|
27
|
-
if (hasExpired) continue;
|
|
28
|
-
const addedCredits = add.operation_value;
|
|
29
|
-
const consumedForAdd = subtracts.filter((sub) => String(sub.consumed_from_add_id) === String(add.id)).reduce((sum, sub) => sum + sub.operation_value, 0);
|
|
30
|
-
const remainingForAdd = Math.max(0, addedCredits - consumedForAdd);
|
|
31
|
-
totalCredits += addedCredits;
|
|
32
|
-
usedCredits += consumedForAdd;
|
|
33
|
-
const diffMs = expirationDate.getTime() - todayDate.getTime();
|
|
34
|
-
const days = Math.max(0, Math.ceil(diffMs / (1e3 * 60 * 60 * 24)));
|
|
35
|
-
if (remainingForAdd > 0) {
|
|
36
|
-
if (nextExpirationInDays === null || days < nextExpirationInDays) {
|
|
37
|
-
nextExpirationInDays = days;
|
|
38
|
-
nextExpiringCredits = remainingForAdd;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
const availableCredits = Math.max(0, totalCredits - usedCredits);
|
|
43
|
-
return {
|
|
44
|
-
totalCredits,
|
|
45
|
-
usedCredits,
|
|
46
|
-
availableCredits,
|
|
47
|
-
nextExpiringCredits,
|
|
48
|
-
nextExpirationInDays
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
function useIaCredits() {
|
|
52
|
-
const { data: subscriptionData, isPending: isSubscriptionLoading } = useActiveSubscription();
|
|
53
|
-
const subscription = subscriptionData?.data?.[0] ?? null;
|
|
54
|
-
const subscriptionId = subscription?.id;
|
|
55
|
-
const query = useQuery({
|
|
56
|
-
queryKey: ["ia-credits", subscriptionId],
|
|
57
|
-
queryFn: withAction(() => listIaCreditsAction(subscriptionId)),
|
|
58
|
-
enabled: subscriptionId != null
|
|
59
|
-
});
|
|
60
|
-
const operations = query.data?.data ?? [];
|
|
61
|
-
const summary = useMemo(() => calculateSummary(operations), [operations]);
|
|
62
|
-
return {
|
|
63
|
-
subscription,
|
|
64
|
-
operations,
|
|
65
|
-
summary,
|
|
66
|
-
isLoading: isSubscriptionLoading || query.isPending,
|
|
67
|
-
isSubscriptionLoading,
|
|
68
|
-
isCreditsLoading: query.isPending,
|
|
69
|
-
isError: query.isError,
|
|
70
|
-
error: query.error
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
export {
|
|
74
|
-
useIaCredits
|
|
75
|
-
};
|
|
76
|
-
//# sourceMappingURL=ia-credits.hook.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/ia-credits/hooks/ia-credits.hook.ts"],"sourcesContent":["'use client';\r\n\r\nimport { useMemo } from 'react';\r\nimport { useQuery } from '@tanstack/react-query';\r\nimport { listIaCreditsAction } from '../actions/list-ia-credits.action';\r\nimport type { IaCreditOperation, IaCreditsSummary } from '../types';\r\nimport { useActiveSubscription } from '../../subscriptions/hooks/find-active-subscription.hook';\r\nimport { withAction } from '../../../utils/withAction';\r\n\r\nfunction calculateSummary(operations: IaCreditOperation[]): IaCreditsSummary {\r\n const today = new Date();\r\n const todayDate = new Date(today.getFullYear(), today.getMonth(), today.getDate());\r\n\r\n const adds = operations.filter((op) => op.operation === 'add');\r\n const subtracts = operations.filter((op) => op.operation === 'subtract');\r\n\r\n let totalCredits = 0;\r\n let usedCredits = 0;\r\n let nextExpirationInDays: number | null = null;\r\n let nextExpiringCredits: number | null = null;\r\n\r\n for (const add of adds) {\r\n const expirationRaw = add.expiration_time;\r\n if (!expirationRaw) continue;\r\n\r\n const expiration = new Date(expirationRaw);\r\n const expirationDate = new Date(\r\n expiration.getFullYear(),\r\n expiration.getMonth(),\r\n expiration.getDate()\r\n );\r\n\r\n const expiredByDate = expirationDate.getTime() < todayDate.getTime();\r\n const hasExpired = add.has_expired || expiredByDate;\r\n\r\n if (hasExpired) continue;\r\n\r\n const addedCredits = add.operation_value;\r\n\r\n const consumedForAdd = subtracts\r\n .filter((sub) => String(sub.consumed_from_add_id) === String(add.id))\r\n .reduce((sum, sub) => sum + sub.operation_value, 0);\r\n\r\n const remainingForAdd = Math.max(0, addedCredits - consumedForAdd);\r\n\r\n totalCredits += addedCredits;\r\n usedCredits += consumedForAdd;\r\n\r\n const diffMs = expirationDate.getTime() - todayDate.getTime();\r\n const days = Math.max(0, Math.ceil(diffMs / (1000 * 60 * 60 * 24)));\r\n\r\n if (remainingForAdd > 0) {\r\n if (nextExpirationInDays === null || days < nextExpirationInDays) {\r\n nextExpirationInDays = days;\r\n nextExpiringCredits = remainingForAdd;\r\n }\r\n }\r\n }\r\n\r\n const availableCredits = Math.max(0, totalCredits - usedCredits);\r\n\r\n return {\r\n totalCredits,\r\n usedCredits,\r\n availableCredits,\r\n nextExpiringCredits,\r\n nextExpirationInDays,\r\n };\r\n}\r\n\r\nexport function useIaCredits() {\r\n const { data: subscriptionData, isPending: isSubscriptionLoading } = useActiveSubscription();\r\n const subscription = subscriptionData?.data?.[0] ?? null;\r\n const subscriptionId = subscription?.id;\r\n\r\n const query = useQuery({\r\n queryKey: ['ia-credits', subscriptionId],\r\n queryFn: withAction(() => listIaCreditsAction(subscriptionId!)),\r\n enabled: subscriptionId != null,\r\n });\r\n\r\n const operations = query.data?.data ?? [];\r\n\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n const summary = useMemo(() => calculateSummary(operations), [operations]);\r\n\r\n return {\r\n subscription,\r\n operations,\r\n summary,\r\n isLoading: isSubscriptionLoading || query.isPending,\r\n isSubscriptionLoading,\r\n isCreditsLoading: query.isPending,\r\n isError: query.isError,\r\n error: query.error,\r\n };\r\n}\r\n"],"mappings":";AAEA,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,2BAA2B;AAEpC,SAAS,6BAA6B;AACtC,SAAS,kBAAkB;AAE3B,SAAS,iBAAiB,YAAmD;AAC3E,QAAM,QAAQ,oBAAI,KAAK;AACvB,QAAM,YAAY,IAAI,KAAK,MAAM,YAAY,GAAG,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC;AAEjF,QAAM,OAAO,WAAW,OAAO,CAAC,OAAO,GAAG,cAAc,KAAK;AAC7D,QAAM,YAAY,WAAW,OAAO,CAAC,OAAO,GAAG,cAAc,UAAU;AAEvE,MAAI,eAAe;AACnB,MAAI,cAAc;AAClB,MAAI,uBAAsC;AAC1C,MAAI,sBAAqC;AAEzC,aAAW,OAAO,MAAM;AACtB,UAAM,gBAAgB,IAAI;AAC1B,QAAI,CAAC,cAAe;AAEpB,UAAM,aAAa,IAAI,KAAK,aAAa;AACzC,UAAM,iBAAiB,IAAI;AAAA,MACzB,WAAW,YAAY;AAAA,MACvB,WAAW,SAAS;AAAA,MACpB,WAAW,QAAQ;AAAA,IACrB;AAEA,UAAM,gBAAgB,eAAe,QAAQ,IAAI,UAAU,QAAQ;AACnE,UAAM,aAAa,IAAI,eAAe;AAEtC,QAAI,WAAY;AAEhB,UAAM,eAAe,IAAI;AAEzB,UAAM,iBAAiB,UACpB,OAAO,CAAC,QAAQ,OAAO,IAAI,oBAAoB,MAAM,OAAO,IAAI,EAAE,CAAC,EACnE,OAAO,CAAC,K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../../../infra/api/types";
|
|
4
|
-
import { getUserContext } from "../../auth/utils/get-user-context";
|
|
5
|
-
import { IaCreditOperationSchema } from "../types";
|
|
6
|
-
class IaCreditsService {
|
|
7
|
-
async listOperations(subscriptionId) {
|
|
8
|
-
const { id_account } = await getUserContext();
|
|
9
|
-
const endpoint = `/accounts/${id_account}/subscriptions/${subscriptionId}/items/balance/list?page=1&limit=20&sort=id:DESC`;
|
|
10
|
-
const response = await api.apps.get(endpoint);
|
|
11
|
-
if (response.status === 0) {
|
|
12
|
-
throw new ApiError(
|
|
13
|
-
response.message || "Erro ao listar cr\xE9ditos de IA",
|
|
14
|
-
"LIST_IA_CREDITS_FAILED",
|
|
15
|
-
400
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
const raw = response.data ?? [];
|
|
19
|
-
const data = raw.map((item) => IaCreditOperationSchema.parse(item));
|
|
20
|
-
return {
|
|
21
|
-
data,
|
|
22
|
-
total: response.total ?? data.length,
|
|
23
|
-
success: true
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
const iaCreditsService = new IaCreditsService();
|
|
28
|
-
export {
|
|
29
|
-
iaCreditsService
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=ia-credits.service.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/ia-credits/services/ia-credits.service.ts"],"sourcesContent":["import 'server-only';\r\n\r\nimport { api } from '../../../infra/api/client';\r\nimport { ApiError, ApiPaginatedActionResult, PaginatedSuccessResult } from '../../../infra/api/types';\r\nimport { getUserContext } from '../../auth/utils/get-user-context';\r\nimport { IaCreditOperation, IaCreditOperationSchema } from '../types';\r\n\r\nclass IaCreditsService {\r\n async listOperations(\r\n subscriptionId: number | string\r\n ): Promise<PaginatedSuccessResult<IaCreditOperation>> {\r\n const { id_account } = await getUserContext();\r\n\r\n const endpoint = `/accounts/${id_account}/subscriptions/${subscriptionId}/items/balance/list?page=1&limit=20&sort=id:DESC`;\r\n\r\n const response = await api.apps.get<ApiPaginatedActionResult<IaCreditOperation>>(endpoint);\r\n\r\n if (response.status === 0) {\r\n throw new ApiError(\r\n response.message || 'Erro ao listar créditos de IA',\r\n 'LIST_IA_CREDITS_FAILED',\r\n 400\r\n );\r\n }\r\n\r\n const raw = response.data ?? [];\r\n const data = raw.map((item) => IaCreditOperationSchema.parse(item));\r\n\r\n return {\r\n data,\r\n total: response.total ?? data.length,\r\n success: true,\r\n };\r\n }\r\n}\r\n\r\nexport const iaCreditsService = new IaCreditsService();\r\n"],"mappings":"AAAA,OAAO;AAEP,SAAS,WAAW;AACpB,SAAS,gBAAkE;AAC3E,SAAS,sBAAsB;AAC/B,SAA4B,+BAA+B;AAE3D,MAAM,iBAAiB;AAAA,EACrB,MAAM,eACJ,gBACoD;AACpD,UAAM,EAAE,WAAW,IAAI,MAAM,eAAe;AAE5C,UAAM,WAAW,aAAa,UAAU,kBAAkB,cAAc;AAExE,UAAM,WAAW,MAAM,IAAI,KAAK,IAAiD,QAAQ;AAEzF,QAAI,SAAS,WAAW,GAAG;AACzB,YAAM,IAAI;AAAA,QACR,SAAS,WAAW;AAAA,QACpB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,UAAM,MAAM,SAAS,QAAQ,CAAC;AAC9B,UAAM,OAAO,IAAI,IAAI,CAAC,SAAS,wBAAwB,MAAM,IAAI,CAAC;AAElE,WAAO;AAAA,MACL;AAAA,MACA,OAAO,SAAS,SAAS,KAAK;AAAA,MAC9B,SAAS;AAAA,IACX;AAAA,EACF;AACF;AAEO,MAAM,mBAAmB,IAAI,iBAAiB;","names":[]}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import z from "zod";
|
|
2
|
-
const IaCreditOperationSchema = z.object({
|
|
3
|
-
id: z.union([z.number(), z.string()]),
|
|
4
|
-
deleted: z.number(),
|
|
5
|
-
datetime_add: z.coerce.date().nullable(),
|
|
6
|
-
id_wl: z.number(),
|
|
7
|
-
id_subscription: z.union([z.number(), z.string()]),
|
|
8
|
-
id_addon: z.number(),
|
|
9
|
-
operation: z.string(),
|
|
10
|
-
// 'add' | 'subtract'
|
|
11
|
-
operation_value: z.union([z.number(), z.string()]).transform((v) => Number(v)),
|
|
12
|
-
balance_after_operation: z.union([z.number(), z.string()]).optional(),
|
|
13
|
-
balance_before_operation: z.union([z.number(), z.string()]).optional(),
|
|
14
|
-
operation_ref: z.string().nullable().optional(),
|
|
15
|
-
operation_origin: z.string().nullable().optional(),
|
|
16
|
-
expiration_time: z.string().nullable(),
|
|
17
|
-
has_expired: z.boolean(),
|
|
18
|
-
consumed_from_add_id: z.union([z.number(), z.string()]).nullable(),
|
|
19
|
-
id_user_add: z.union([z.number(), z.string()]).nullable(),
|
|
20
|
-
user_name: z.string().nullable().optional()
|
|
21
|
-
}).passthrough();
|
|
22
|
-
export {
|
|
23
|
-
IaCreditOperationSchema
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=types.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/modules/ia-credits/types.ts"],"sourcesContent":["import z from 'zod';\r\n\r\nexport const IaCreditOperationSchema = z\r\n .object({\r\n id: z.union([z.number(), z.string()]),\r\n deleted: z.number(),\r\n datetime_add: z.coerce.date().nullable(),\r\n id_wl: z.number(),\r\n id_subscription: z.union([z.number(), z.string()]),\r\n id_addon: z.number(),\r\n operation: z.string(), // 'add' | 'subtract'\r\n operation_value: z.union([z.number(), z.string()]).transform((v) => Number(v)),\r\n balance_after_operation: z.union([z.number(), z.string()]).optional(),\r\n balance_before_operation: z.union([z.number(), z.string()]).optional(),\r\n operation_ref: z.string().nullable().optional(),\r\n operation_origin: z.string().nullable().optional(),\r\n expiration_time: z.string().nullable(),\r\n has_expired: z.boolean(),\r\n consumed_from_add_id: z.union([z.number(), z.string()]).nullable(),\r\n id_user_add: z.union([z.number(), z.string()]).nullable(),\r\n user_name: z.string().nullable().optional(),\r\n })\r\n .passthrough();\r\n\r\nexport type IaCreditOperation = z.infer<typeof IaCreditOperationSchema>;\r\n\r\nexport type IaCreditsSummary = {\r\n totalCredits: number;\r\n usedCredits: number;\r\n availableCredits: number;\r\n nextExpiringCredits: number | null;\r\n nextExpirationInDays: number | null;\r\n};\r\n"],"mappings":"AAAA,OAAO,OAAO;AAEP,MAAM,0BAA0B,EACpC,OAAO;AAAA,EACN,IAAI,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC;AAAA,EACpC,SAAS,EAAE,OAAO;AAAA,EAClB,cAAc,EAAE,OAAO,KAAK,EAAE,SAAS;AAAA,EACvC,OAAO,EAAE,OAAO;AAAA,EAChB,iBAAiB,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC;AAAA,EACjD,UAAU,EAAE,OAAO;AAAA,EACnB,WAAW,EAAE,OAAO;AAAA;AAAA,EACpB,iBAAiB,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,UAAU,CAAC,MAAM,OAAO,CAAC,CAAC;AAAA,EAC7E,yBAAyB,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS;AAAA,EACpE,0BAA0B,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS;AAAA,EACrE,eAAe,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA,EAC9C,kBAAkB,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA,EACjD,iBAAiB,EAAE,OAAO,EAAE,SAAS;AAAA,EACrC,aAAa,EAAE,QAAQ;AAAA,EACvB,sBAAsB,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS;AAAA,EACjE,aAAa,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS;AAAA,EACxD,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAC5C,CAAC,EACA,YAAY;","names":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use server";
|
|
2
|
-
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
|
-
import { projectUsersService } from "../services/project-users.service";
|
|
4
|
-
async function addProjectUserAction(params) {
|
|
5
|
-
return safeServerAction(() => projectUsersService.addToProject(params));
|
|
6
|
-
}
|
|
7
|
-
export {
|
|
8
|
-
addProjectUserAction
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=add-project-user.action.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/projects/actions/add-project-user.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { projectUsersService } from '../services/project-users.service';\nimport type { AddRemoveProjectUsersParams } from '../types';\n\nexport async function addProjectUserAction(params: AddRemoveProjectUsersParams) {\n return safeServerAction(() => projectUsersService.addToProject(params));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AAGpC,eAAsB,qBAAqB,QAAqC;AAC9E,SAAO,iBAAiB,MAAM,oBAAoB,aAAa,MAAM,CAAC;AACxE;","names":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use server";
|
|
2
|
-
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
|
-
import { projectUsersService } from "../services/project-users.service";
|
|
4
|
-
async function listAvailableUsersAction(projectId, params = {}) {
|
|
5
|
-
return safeServerAction(() => projectUsersService.listNotInProject(projectId, params));
|
|
6
|
-
}
|
|
7
|
-
export {
|
|
8
|
-
listAvailableUsersAction
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=list-available-users.action.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/projects/actions/list-available-users.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { projectUsersService } from '../services/project-users.service';\nimport type { ListUsersParams } from '../types';\n\nexport async function listAvailableUsersAction(projectId: number, params: ListUsersParams = {}) {\n return safeServerAction(() => projectUsersService.listNotInProject(projectId, params));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AAGpC,eAAsB,yBAAyB,WAAmB,SAA0B,CAAC,GAAG;AAC9F,SAAO,iBAAiB,MAAM,oBAAoB,iBAAiB,WAAW,MAAM,CAAC;AACvF;","names":[]}
|