@greatapps/common 1.1.133 → 1.1.135
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/MMQ4R4NB-B36VHW65.mjs +61 -0
- package/dist/MMQ4R4NB-B36VHW65.mjs.map +1 -0
- package/dist/V4HPSUGU-6BOE4IPH.mjs +51 -0
- package/dist/V4HPSUGU-6BOE4IPH.mjs.map +1 -0
- package/dist/account-management.action-7QQCACDJ.mjs +40 -0
- package/dist/account.service-XTZDEIPS.mjs +9 -0
- package/dist/{modules/auth/services/auth.service.mjs → chunk-7MBVHKTC.mjs} +46 -13
- package/dist/chunk-7MBVHKTC.mjs.map +1 -0
- package/dist/{modules/users/services/user.service.mjs → chunk-B2W2HK7C.mjs} +13 -8
- package/dist/chunk-B2W2HK7C.mjs.map +1 -0
- package/dist/{modules/auth/actions/validate-session.action.mjs → chunk-EC3T7NF6.mjs} +8 -4
- package/dist/chunk-EC3T7NF6.mjs.map +1 -0
- package/dist/chunk-EKZZ2RWJ.mjs +12701 -0
- package/dist/chunk-EKZZ2RWJ.mjs.map +1 -0
- package/dist/chunk-ICUZDG2N.mjs +283 -0
- package/dist/chunk-ICUZDG2N.mjs.map +1 -0
- package/dist/{utils/safeServerAction.mjs → chunk-JW4XRHLX.mjs} +7 -2
- package/dist/chunk-JW4XRHLX.mjs.map +1 -0
- package/dist/chunk-QEFMNBSY.mjs +165 -0
- package/dist/chunk-QEFMNBSY.mjs.map +1 -0
- package/dist/{infra/api/client.mjs → chunk-RV7ECGIH.mjs} +12 -7
- package/dist/chunk-RV7ECGIH.mjs.map +1 -0
- package/dist/chunk-S53NE5H4.mjs +2928 -0
- package/dist/chunk-S53NE5H4.mjs.map +1 -0
- package/dist/{modules/whitelabel/services/whitelabel.service.mjs → chunk-UEWT6VFS.mjs} +57 -9
- package/dist/chunk-UEWT6VFS.mjs.map +1 -0
- package/dist/chunk-XY4LNPBR.mjs +16 -0
- package/dist/chunk-XY4LNPBR.mjs.map +1 -0
- package/dist/{modules/accounts/services/account.service.mjs → chunk-Z3Q2LLBS.mjs} +64 -9
- package/dist/chunk-Z3Q2LLBS.mjs.map +1 -0
- package/dist/find-user-by-id.action-BUFTU3ZY.mjs +11 -0
- package/dist/index.mjs +9584 -258
- package/dist/index.mjs.map +1 -1
- package/dist/modern-4YXF5ES3.mjs +426 -0
- package/dist/modern-4YXF5ES3.mjs.map +1 -0
- package/dist/server.mjs +140 -36
- package/dist/server.mjs.map +1 -1
- package/dist/user.service-VDR4JKHO.mjs +8 -0
- package/dist/validate-session.action-K7RWN2GE.mjs +11 -0
- package/dist/{modules/auth/actions/verify-two-factor.action.mjs → verify-two-factor.action-V6JQATK2.mjs} +12 -4
- package/dist/verify-two-factor.action-V6JQATK2.mjs.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +0 -1
- 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 -150
- 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 -236
- 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/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/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/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/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.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/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.map +0 -1
- package/dist/modules/auth/actions/verify-two-factor.action.mjs.map +0 -1
- package/dist/modules/auth/hooks/login.hook.mjs +0 -18
- 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/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.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/services/whitelabel-styles.service.mjs +0 -76
- package/dist/modules/whitelabel/services/whitelabel-styles.service.mjs.map +0 -1
- package/dist/modules/whitelabel/services/whitelabel.service.mjs.map +0 -1
- package/dist/modules/whitelabel/styles-schema.mjs +0 -1
- package/dist/providers/auth.provider.mjs +0 -94
- 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/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.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
- /package/dist/{components/navigation/types.mjs.map → account-management.action-7QQCACDJ.mjs.map} +0 -0
- /package/dist/{modules/accounts/types.mjs.map → account.service-XTZDEIPS.mjs.map} +0 -0
- /package/dist/{modules/auth/schema.mjs.map → find-user-by-id.action-BUFTU3ZY.mjs.map} +0 -0
- /package/dist/{modules/whitelabel/schema.mjs.map → user.service-VDR4JKHO.mjs.map} +0 -0
- /package/dist/{modules/whitelabel/styles-schema.mjs.map → validate-session.action-K7RWN2GE.mjs.map} +0 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import {
|
|
2
|
+
safeServerAction
|
|
3
|
+
} from "./chunk-JW4XRHLX.mjs";
|
|
4
|
+
import {
|
|
5
|
+
accountService,
|
|
6
|
+
buildQueryParams,
|
|
7
|
+
getUserContext
|
|
8
|
+
} from "./chunk-Z3Q2LLBS.mjs";
|
|
9
|
+
import {
|
|
10
|
+
api
|
|
11
|
+
} from "./chunk-RV7ECGIH.mjs";
|
|
12
|
+
import {
|
|
13
|
+
ApiError
|
|
14
|
+
} from "./chunk-UEWT6VFS.mjs";
|
|
15
|
+
|
|
16
|
+
// src/modules/accounts/actions/find-current-account.action.ts
|
|
17
|
+
async function findCurrentAccount() {
|
|
18
|
+
return safeServerAction(() => accountService.findCurrentAccount());
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// src/modules/projects/services/project-users.service.ts
|
|
22
|
+
import "server-only";
|
|
23
|
+
|
|
24
|
+
// src/modules/projects/types.ts
|
|
25
|
+
import { z } from "zod";
|
|
26
|
+
var ProjectUserSchema = z.object({
|
|
27
|
+
id_user: z.union([z.number(), z.string()]).transform(Number),
|
|
28
|
+
id_account: z.union([z.number(), z.string()]).transform(Number),
|
|
29
|
+
id_project: z.union([z.number(), z.string()]).transform(Number),
|
|
30
|
+
name: z.string().nullable(),
|
|
31
|
+
email: z.string().nullable(),
|
|
32
|
+
profile: z.string().nullable().optional().default("viewer"),
|
|
33
|
+
photo: z.string().nullable().optional()
|
|
34
|
+
});
|
|
35
|
+
var AccountUserSchema = z.object({
|
|
36
|
+
id: z.union([z.number(), z.string()]).transform(Number),
|
|
37
|
+
name: z.string().nullable(),
|
|
38
|
+
email: z.string().nullable(),
|
|
39
|
+
profile: z.string().nullable().optional().default("viewer"),
|
|
40
|
+
photo: z.string().nullable().optional()
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// src/modules/projects/services/project-users.service.ts
|
|
44
|
+
var ProjectUsersService = class {
|
|
45
|
+
async listInProject(projectId, params = {}) {
|
|
46
|
+
const { id_account, id_user } = await getUserContext();
|
|
47
|
+
const query = buildQueryParams(params);
|
|
48
|
+
const url = `/account/${id_account}/user/${id_user}/projects/${projectId}/users${query ? `?${query}` : ""}`;
|
|
49
|
+
const response = await api.apps.get(url);
|
|
50
|
+
if (response.status === 0) {
|
|
51
|
+
throw new ApiError(
|
|
52
|
+
response.message || "Erro ao listar usu\xE1rios do projeto",
|
|
53
|
+
"LIST_PROJECT_USERS_FAILED",
|
|
54
|
+
400
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
data: response.data.map((item) => ProjectUserSchema.parse(item)),
|
|
59
|
+
total: response.total,
|
|
60
|
+
page: params.page ?? 1
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
async listNotInProject(projectId, params = {}) {
|
|
64
|
+
const { id_account } = await getUserContext();
|
|
65
|
+
const query = buildQueryParams({ notInProject: projectId, ...params });
|
|
66
|
+
const url = `/accounts/${id_account}/users${query ? `?${query}` : ""}`;
|
|
67
|
+
const response = await api.apps.get(url);
|
|
68
|
+
if (response.status === 0) {
|
|
69
|
+
throw new ApiError(
|
|
70
|
+
response.message || "Erro ao listar usu\xE1rios dispon\xEDveis",
|
|
71
|
+
"LIST_AVAILABLE_USERS_FAILED",
|
|
72
|
+
400
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
data: response.data.map((item) => AccountUserSchema.parse(item)),
|
|
77
|
+
total: response.total,
|
|
78
|
+
page: params.page ?? 1
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
async addToProject({ projectId, users }) {
|
|
82
|
+
const { id_account, id_user } = await getUserContext();
|
|
83
|
+
const url = `/account/${id_account}/user/${id_user}/projects/${projectId}/users`;
|
|
84
|
+
const response = await api.apps.post(url, { users });
|
|
85
|
+
if (response.status === 0) {
|
|
86
|
+
throw new ApiError(
|
|
87
|
+
response.message || "Erro ao adicionar usu\xE1rio ao projeto",
|
|
88
|
+
"ADD_PROJECT_USER_FAILED",
|
|
89
|
+
400
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async removeFromProject({ projectId, users }) {
|
|
94
|
+
const { id_account, id_user } = await getUserContext();
|
|
95
|
+
const url = `/account/${id_account}/user/${id_user}/projects/${projectId}/users`;
|
|
96
|
+
const response = await api.apps.delete(url, {
|
|
97
|
+
body: JSON.stringify({ users })
|
|
98
|
+
});
|
|
99
|
+
if (response.status === 0) {
|
|
100
|
+
throw new ApiError(
|
|
101
|
+
response.message || "Erro ao remover usu\xE1rio do projeto",
|
|
102
|
+
"REMOVE_PROJECT_USER_FAILED",
|
|
103
|
+
400
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
var projectUsersService = new ProjectUsersService();
|
|
109
|
+
|
|
110
|
+
// src/modules/projects/actions/list-project-users.action.ts
|
|
111
|
+
async function listProjectUsersAction(projectId, params = {}) {
|
|
112
|
+
return safeServerAction(() => projectUsersService.listInProject(projectId, params));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// src/modules/projects/actions/list-available-users.action.ts
|
|
116
|
+
async function listAvailableUsersAction(projectId, params = {}) {
|
|
117
|
+
return safeServerAction(() => projectUsersService.listNotInProject(projectId, params));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// src/modules/subscriptions/types.ts
|
|
121
|
+
import z2 from "zod";
|
|
122
|
+
var SubscriptionItemSchema = z2.object({
|
|
123
|
+
id: z2.union([z2.number(), z2.string()]),
|
|
124
|
+
deleted: z2.number(),
|
|
125
|
+
datetime_alt: z2.coerce.date().nullable().optional(),
|
|
126
|
+
datetime_del: z2.coerce.date().nullable().optional(),
|
|
127
|
+
datetime_add: z2.coerce.date(),
|
|
128
|
+
id_wl: z2.number(),
|
|
129
|
+
id_subscription: z2.union([z2.number(), z2.string()]),
|
|
130
|
+
id_addon: z2.number().nullable(),
|
|
131
|
+
addon_name: z2.string().optional(),
|
|
132
|
+
value: z2.number(),
|
|
133
|
+
currency: z2.string(),
|
|
134
|
+
quantity: z2.number(),
|
|
135
|
+
payment_status: z2.number(),
|
|
136
|
+
id_charge: z2.union([z2.number(), z2.string()]).nullable(),
|
|
137
|
+
trial: z2.boolean(),
|
|
138
|
+
trial_ends_at: z2.coerce.date().nullable().optional()
|
|
139
|
+
});
|
|
140
|
+
var SubscriptionSchema = z2.object({
|
|
141
|
+
id: z2.union([z2.number(), z2.string()]),
|
|
142
|
+
deleted: z2.number(),
|
|
143
|
+
datetime_alt: z2.coerce.date().nullable().optional(),
|
|
144
|
+
datetime_del: z2.coerce.date().nullable().optional(),
|
|
145
|
+
datetime_add: z2.coerce.date(),
|
|
146
|
+
id_wl: z2.number(),
|
|
147
|
+
id_account: z2.union([z2.number(), z2.string()]),
|
|
148
|
+
id_card: z2.union([z2.number(), z2.string()]).nullable(),
|
|
149
|
+
id_coupon: z2.union([z2.number(), z2.string()]).nullable(),
|
|
150
|
+
type: z2.string(),
|
|
151
|
+
payment_method: z2.number().nullable(),
|
|
152
|
+
periodicity: z2.union([z2.number(), z2.string()]).nullable(),
|
|
153
|
+
value: z2.number().nullable(),
|
|
154
|
+
id_product: z2.number(),
|
|
155
|
+
id_plan: z2.number(),
|
|
156
|
+
plan_name: z2.string().nullable().optional(),
|
|
157
|
+
id_gateway: z2.union([z2.number(), z2.string()]).nullable(),
|
|
158
|
+
gateway_account: z2.string().nullable(),
|
|
159
|
+
date_hiring: z2.coerce.date().nullable(),
|
|
160
|
+
date_due: z2.coerce.date(),
|
|
161
|
+
date_cancellation: z2.coerce.date().nullable(),
|
|
162
|
+
date_verification: z2.coerce.date().nullable(),
|
|
163
|
+
cancellation_reason: z2.string().nullable(),
|
|
164
|
+
cancellation_description: z2.string().nullable(),
|
|
165
|
+
active: z2.boolean(),
|
|
166
|
+
charged: z2.boolean(),
|
|
167
|
+
datetime_last_update_periodicity: z2.coerce.date().nullable().optional(),
|
|
168
|
+
card_name: z2.string().nullable().optional(),
|
|
169
|
+
card_brand: z2.string().nullable().optional(),
|
|
170
|
+
card_number: z2.string().nullable().optional(),
|
|
171
|
+
items: z2.array(SubscriptionItemSchema)
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
// src/modules/subscriptions/services/subscriptions.service.ts
|
|
175
|
+
import "server-only";
|
|
176
|
+
var SubscriptionsService = class {
|
|
177
|
+
async listSubscriptions(params) {
|
|
178
|
+
const { id_account } = await getUserContext();
|
|
179
|
+
const query = buildQueryParams(params);
|
|
180
|
+
const url = `/accounts/${id_account}/subscriptions${query ? `?${query}` : ""}`;
|
|
181
|
+
const response = await api.apps.get(url);
|
|
182
|
+
if (response.status === 0) {
|
|
183
|
+
throw new ApiError(
|
|
184
|
+
response.message || "Erro ao listar assinaturas",
|
|
185
|
+
"LIST_SUBSCRIPTIONS_FAILED",
|
|
186
|
+
400
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
const data = response.data.map((item) => SubscriptionSchema.parse(item));
|
|
190
|
+
return {
|
|
191
|
+
data,
|
|
192
|
+
total: response.total,
|
|
193
|
+
success: true
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
var subscriptionsService = new SubscriptionsService();
|
|
198
|
+
|
|
199
|
+
// src/modules/subscriptions/actions/list-subscriptions.action.ts
|
|
200
|
+
async function listSubscriptionsAction(params) {
|
|
201
|
+
return safeServerAction(() => subscriptionsService.listSubscriptions(params));
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// src/modules/ia-credits/services/ia-credits.service.ts
|
|
205
|
+
import "server-only";
|
|
206
|
+
|
|
207
|
+
// src/modules/ia-credits/types.ts
|
|
208
|
+
import z3 from "zod";
|
|
209
|
+
var IaCreditOperationSchema = z3.object({
|
|
210
|
+
id: z3.union([z3.number(), z3.string()]),
|
|
211
|
+
deleted: z3.number(),
|
|
212
|
+
datetime_add: z3.coerce.date().nullable(),
|
|
213
|
+
id_wl: z3.number(),
|
|
214
|
+
id_subscription: z3.union([z3.number(), z3.string()]),
|
|
215
|
+
id_addon: z3.number(),
|
|
216
|
+
operation: z3.string(),
|
|
217
|
+
// 'add' | 'subtract'
|
|
218
|
+
operation_value: z3.union([z3.number(), z3.string()]).transform((v) => Number(v)),
|
|
219
|
+
balance_after_operation: z3.union([z3.number(), z3.string()]).optional(),
|
|
220
|
+
balance_before_operation: z3.union([z3.number(), z3.string()]).optional(),
|
|
221
|
+
operation_ref: z3.string().nullable().optional(),
|
|
222
|
+
operation_origin: z3.string().nullable().optional(),
|
|
223
|
+
expiration_time: z3.string().nullable(),
|
|
224
|
+
has_expired: z3.boolean(),
|
|
225
|
+
consumed_from_add_id: z3.union([z3.number(), z3.string()]).nullable(),
|
|
226
|
+
id_user_add: z3.union([z3.number(), z3.string()]).nullable(),
|
|
227
|
+
user_name: z3.string().nullable().optional()
|
|
228
|
+
}).passthrough();
|
|
229
|
+
|
|
230
|
+
// src/modules/ia-credits/services/ia-credits.service.ts
|
|
231
|
+
var IaCreditsService = class {
|
|
232
|
+
async listOperations(subscriptionId) {
|
|
233
|
+
const { id_account } = await getUserContext();
|
|
234
|
+
const endpoint = `/accounts/${id_account}/subscriptions/${subscriptionId}/items/balance/list?page=1&limit=20&sort=id:DESC`;
|
|
235
|
+
const response = await api.apps.get(endpoint);
|
|
236
|
+
if (response.status === 0) {
|
|
237
|
+
throw new ApiError(
|
|
238
|
+
response.message || "Erro ao listar cr\xE9ditos de IA",
|
|
239
|
+
"LIST_IA_CREDITS_FAILED",
|
|
240
|
+
400
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
const raw = response.data ?? [];
|
|
244
|
+
const data = raw.map((item) => IaCreditOperationSchema.parse(item));
|
|
245
|
+
return {
|
|
246
|
+
data,
|
|
247
|
+
total: response.total ?? data.length,
|
|
248
|
+
success: true
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
var iaCreditsService = new IaCreditsService();
|
|
253
|
+
|
|
254
|
+
// src/modules/ia-credits/actions/list-ia-credits.action.ts
|
|
255
|
+
async function listIaCreditsAction(subscriptionId) {
|
|
256
|
+
return safeServerAction(() => iaCreditsService.listOperations(subscriptionId));
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// src/modules/projects/actions/add-project-user.action.ts
|
|
260
|
+
async function addProjectUserAction(params) {
|
|
261
|
+
return safeServerAction(() => projectUsersService.addToProject(params));
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// src/modules/projects/actions/remove-project-user.action.ts
|
|
265
|
+
async function removeProjectUserAction(params) {
|
|
266
|
+
return safeServerAction(() => projectUsersService.removeFromProject(params));
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export {
|
|
270
|
+
findCurrentAccount,
|
|
271
|
+
projectUsersService,
|
|
272
|
+
listProjectUsersAction,
|
|
273
|
+
listAvailableUsersAction,
|
|
274
|
+
SubscriptionItemSchema,
|
|
275
|
+
SubscriptionSchema,
|
|
276
|
+
subscriptionsService,
|
|
277
|
+
listSubscriptionsAction,
|
|
278
|
+
iaCreditsService,
|
|
279
|
+
listIaCreditsAction,
|
|
280
|
+
addProjectUserAction,
|
|
281
|
+
removeProjectUserAction
|
|
282
|
+
};
|
|
283
|
+
//# sourceMappingURL=chunk-ICUZDG2N.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/modules/accounts/actions/find-current-account.action.ts","../src/modules/projects/services/project-users.service.ts","../src/modules/projects/types.ts","../src/modules/projects/actions/list-project-users.action.ts","../src/modules/projects/actions/list-available-users.action.ts","../src/modules/subscriptions/types.ts","../src/modules/subscriptions/services/subscriptions.service.ts","../src/modules/subscriptions/actions/list-subscriptions.action.ts","../src/modules/ia-credits/services/ia-credits.service.ts","../src/modules/ia-credits/types.ts","../src/modules/ia-credits/actions/list-ia-credits.action.ts","../src/modules/projects/actions/add-project-user.action.ts","../src/modules/projects/actions/remove-project-user.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { accountService } from '../services/account.service';\nimport type { Account } from '../types';\n\nexport async function findCurrentAccount() {\n return safeServerAction<Account>(() => accountService.findCurrentAccount());\n}\n","import 'server-only';\r\n\r\nimport { api } from '../../../infra/api/client';\r\nimport { ApiError } from '../../../infra/api/types';\r\nimport { buildQueryParams } from '../../../infra/utils/params';\r\nimport { getUserContext } from '../../auth/utils/get-user-context';\r\nimport {\r\n AccountUser,\r\n AccountUserSchema,\r\n AddRemoveProjectUsersParams,\r\n ListUsersParams,\r\n ProjectUser,\r\n ProjectUserSchema,\r\n UsersPage,\r\n} from '../types';\r\n\r\ninterface ApiListResponse<T> {\r\n data: T[];\r\n total: number;\r\n status: number;\r\n message?: string;\r\n}\r\n\r\ninterface ApiActionResponse {\r\n status: number;\r\n message?: string;\r\n}\r\n\r\nclass ProjectUsersService {\r\n async listInProject(projectId: number, params: ListUsersParams = {}): Promise<UsersPage<ProjectUser>> {\r\n const { id_account, id_user } = await getUserContext();\r\n const query = buildQueryParams(params as Record<string, string | number | boolean | undefined>);\r\n const url = `/account/${id_account}/user/${id_user}/projects/${projectId}/users${query ? `?${query}` : ''}`;\r\n\r\n const response = await api.apps.get<ApiListResponse<ProjectUser>>(url);\r\n\r\n if (response.status === 0) {\r\n throw new ApiError(\r\n response.message || 'Erro ao listar usuários do projeto',\r\n 'LIST_PROJECT_USERS_FAILED',\r\n 400\r\n );\r\n }\r\n\r\n return {\r\n data: response.data.map((item) => ProjectUserSchema.parse(item)),\r\n total: response.total,\r\n page: params.page ?? 1,\r\n };\r\n }\r\n\r\n async listNotInProject(projectId: number, params: ListUsersParams = {}): Promise<UsersPage<AccountUser>> {\r\n const { id_account } = await getUserContext();\r\n const query = buildQueryParams({ notInProject: projectId, ...params } as Record<string, string | number | boolean | undefined>);\r\n const url = `/accounts/${id_account}/users${query ? `?${query}` : ''}`;\r\n\r\n const response = await api.apps.get<ApiListResponse<AccountUser>>(url);\r\n\r\n if (response.status === 0) {\r\n throw new ApiError(\r\n response.message || 'Erro ao listar usuários disponíveis',\r\n 'LIST_AVAILABLE_USERS_FAILED',\r\n 400\r\n );\r\n }\r\n\r\n return {\r\n data: response.data.map((item) => AccountUserSchema.parse(item)),\r\n total: response.total,\r\n page: params.page ?? 1,\r\n };\r\n }\r\n\r\n async addToProject({ projectId, users }: AddRemoveProjectUsersParams): Promise<void> {\r\n const { id_account, id_user } = await getUserContext();\r\n const url = `/account/${id_account}/user/${id_user}/projects/${projectId}/users`;\r\n\r\n const response = await api.apps.post<ApiActionResponse>(url, { users });\r\n\r\n if (response.status === 0) {\r\n throw new ApiError(\r\n response.message || 'Erro ao adicionar usuário ao projeto',\r\n 'ADD_PROJECT_USER_FAILED',\r\n 400\r\n );\r\n }\r\n }\r\n\r\n async removeFromProject({ projectId, users }: AddRemoveProjectUsersParams): Promise<void> {\r\n const { id_account, id_user } = await getUserContext();\r\n const url = `/account/${id_account}/user/${id_user}/projects/${projectId}/users`;\r\n\r\n const response = await api.apps.delete<ApiActionResponse>(url, {\r\n body: JSON.stringify({ users }),\r\n });\r\n\r\n if (response.status === 0) {\r\n throw new ApiError(\r\n response.message || 'Erro ao remover usuário do projeto',\r\n 'REMOVE_PROJECT_USER_FAILED',\r\n 400\r\n );\r\n }\r\n }\r\n}\r\n\r\nexport const projectUsersService = new ProjectUsersService();\r\n","import { z } from \"zod\";\r\n\r\nexport const ProjectUserSchema = z.object({\r\n id_user: z.union([z.number(), z.string()]).transform(Number),\r\n id_account: z.union([z.number(), z.string()]).transform(Number),\r\n id_project: z.union([z.number(), z.string()]).transform(Number),\r\n name: z.string().nullable(),\r\n email: z.string().nullable(),\r\n profile: z.string().nullable().optional().default(\"viewer\"),\r\n photo: z.string().nullable().optional(),\r\n});\r\n\r\nexport type ProjectUser = z.infer<typeof ProjectUserSchema>;\r\n\r\nexport const AccountUserSchema = z.object({\r\n id: z.union([z.number(), z.string()]).transform(Number),\r\n name: z.string().nullable(),\r\n email: z.string().nullable(),\r\n profile: z.string().nullable().optional().default(\"viewer\"),\r\n photo: z.string().nullable().optional(),\r\n});\r\n\r\nexport type AccountUser = z.infer<typeof AccountUserSchema>;\r\n\r\nexport interface AddRemoveProjectUsersParams {\r\n projectId: number;\r\n users: number[];\r\n}\r\n\r\nexport interface ListUsersParams {\r\n search?: string;\r\n page?: number;\r\n limit?: number;\r\n}\r\n\r\nexport interface UsersPage<T> {\r\n data: T[];\r\n total: number;\r\n page: number;\r\n}\r\n","'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { projectUsersService } from '../services/project-users.service';\nimport type { ListUsersParams } from '../types';\n\nexport async function listProjectUsersAction(projectId: number, params: ListUsersParams = {}) {\n return safeServerAction(() => projectUsersService.listInProject(projectId, params));\n}\n","'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","import z from 'zod';\r\n\r\nexport const SubscriptionItemSchema = z.object({\r\n id: z.union([z.number(), z.string()]),\r\n deleted: z.number(),\r\n datetime_alt: z.coerce.date().nullable().optional(),\r\n datetime_del: z.coerce.date().nullable().optional(),\r\n datetime_add: z.coerce.date(),\r\n id_wl: z.number(),\r\n id_subscription: z.union([z.number(), z.string()]),\r\n id_addon: z.number().nullable(),\r\n addon_name: z.string().optional(),\r\n value: z.number(),\r\n currency: z.string(),\r\n quantity: z.number(),\r\n payment_status: z.number(),\r\n id_charge: z.union([z.number(), z.string()]).nullable(),\r\n trial: z.boolean(),\r\n trial_ends_at: z.coerce.date().nullable().optional(),\r\n});\r\n\r\nexport type SubscriptionItem = z.infer<typeof SubscriptionItemSchema>;\r\n\r\nexport const SubscriptionSchema = z.object({\r\n id: z.union([z.number(), z.string()]),\r\n deleted: z.number(),\r\n datetime_alt: z.coerce.date().nullable().optional(),\r\n datetime_del: z.coerce.date().nullable().optional(),\r\n datetime_add: z.coerce.date(),\r\n id_wl: z.number(),\r\n id_account: z.union([z.number(), z.string()]),\r\n id_card: z.union([z.number(), z.string()]).nullable(),\r\n id_coupon: z.union([z.number(), z.string()]).nullable(),\r\n type: z.string(),\r\n payment_method: z.number().nullable(),\r\n periodicity: z.union([z.number(), z.string()]).nullable(),\r\n value: z.number().nullable(),\r\n id_product: z.number(),\r\n id_plan: z.number(),\r\n plan_name: z.string().nullable().optional(),\r\n id_gateway: z.union([z.number(), z.string()]).nullable(),\r\n gateway_account: z.string().nullable(),\r\n date_hiring: z.coerce.date().nullable(),\r\n date_due: z.coerce.date(),\r\n date_cancellation: z.coerce.date().nullable(),\r\n date_verification: z.coerce.date().nullable(),\r\n cancellation_reason: z.string().nullable(),\r\n cancellation_description: z.string().nullable(),\r\n active: z.boolean(),\r\n charged: z.boolean(),\r\n datetime_last_update_periodicity: z.coerce.date().nullable().optional(),\r\n card_name: z.string().nullable().optional(),\r\n card_brand: z.string().nullable().optional(),\r\n card_number: z.string().nullable().optional(),\r\n items: z.array(SubscriptionItemSchema),\r\n});\r\n\r\nexport type Subscription = z.infer<typeof SubscriptionSchema>;\r\n\r\nexport interface FindSubscriptionsParams {\r\n active?: boolean;\r\n trial?: boolean;\r\n date_start?: string;\r\n date_end?: string;\r\n date_hiring_start?: string;\r\n date_hiring_end?: string;\r\n}\r\n","import 'server-only';\r\n\r\nimport { api } from '../../../infra/api/client';\r\nimport { ApiError, ApiPaginatedActionResult, PaginatedSuccessResult } from '../../../infra/api/types';\r\nimport { buildQueryParams } from '../../../infra/utils/params';\r\nimport { getUserContext } from '../../auth/utils/get-user-context';\r\nimport { Subscription, SubscriptionSchema, FindSubscriptionsParams } from '../types';\r\n\r\nclass SubscriptionsService {\r\n async listSubscriptions(\r\n params?: Partial<FindSubscriptionsParams>\r\n ): Promise<PaginatedSuccessResult<Subscription>> {\r\n const { id_account } = await getUserContext();\r\n\r\n const query = buildQueryParams(params as Record<string, string | boolean | undefined>);\r\n const url = `/accounts/${id_account}/subscriptions${query ? `?${query}` : ''}`;\r\n\r\n const response = await api.apps.get<ApiPaginatedActionResult<Subscription>>(url);\r\n\r\n if (response.status === 0) {\r\n throw new ApiError(\r\n response.message || 'Erro ao listar assinaturas',\r\n 'LIST_SUBSCRIPTIONS_FAILED',\r\n 400\r\n );\r\n }\r\n\r\n const data = response.data.map((item) => SubscriptionSchema.parse(item));\r\n\r\n return {\r\n data,\r\n total: response.total,\r\n success: true,\r\n } satisfies PaginatedSuccessResult<Subscription>;\r\n }\r\n}\r\n\r\nexport const subscriptionsService = new SubscriptionsService();\r\n","'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport type { FindSubscriptionsParams } from '../types';\nimport { subscriptionsService } from '../services/subscriptions.service';\n\nexport async function listSubscriptionsAction(params?: Partial<FindSubscriptionsParams>) {\n return safeServerAction(() => subscriptionsService.listSubscriptions(params));\n}\n","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","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","'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","'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","'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { projectUsersService } from '../services/project-users.service';\nimport type { AddRemoveProjectUsersParams } from '../types';\n\nexport async function removeProjectUserAction(params: AddRemoveProjectUsersParams) {\n return safeServerAction(() => projectUsersService.removeFromProject(params));\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAMA,eAAsB,qBAAqB;AACzC,SAAO,iBAA0B,MAAM,eAAe,mBAAmB,CAAC;AAC5E;;;ACRA,OAAO;;;ACAP,SAAS,SAAS;AAEX,IAAM,oBAAoB,EAAE,OAAO;AAAA,EACxC,SAAS,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,UAAU,MAAM;AAAA,EAC3D,YAAY,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,UAAU,MAAM;AAAA,EAC9D,YAAY,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,UAAU,MAAM;AAAA,EAC9D,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,EAC1B,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA,EAC3B,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,QAAQ;AAAA,EAC1D,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AACxC,CAAC;AAIM,IAAM,oBAAoB,EAAE,OAAO;AAAA,EACxC,IAAI,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,UAAU,MAAM;AAAA,EACtD,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,EAC1B,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA,EAC3B,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,QAAQ;AAAA,EAC1D,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AACxC,CAAC;;;ADQD,IAAM,sBAAN,MAA0B;AAAA,EACxB,MAAM,cAAc,WAAmB,SAA0B,CAAC,GAAoC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 -1,5 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ApiError
|
|
3
|
+
} from "./chunk-UEWT6VFS.mjs";
|
|
4
|
+
|
|
5
|
+
// src/utils/safeServerAction.ts
|
|
1
6
|
import { isRedirectError } from "next/dist/client/components/redirect-error";
|
|
2
|
-
import { ApiError } from "../infra/api/types";
|
|
3
7
|
async function safeServerAction(fn) {
|
|
4
8
|
try {
|
|
5
9
|
const data = await fn();
|
|
@@ -10,7 +14,8 @@ async function safeServerAction(fn) {
|
|
|
10
14
|
return { success: false, error: message };
|
|
11
15
|
}
|
|
12
16
|
}
|
|
17
|
+
|
|
13
18
|
export {
|
|
14
19
|
safeServerAction
|
|
15
20
|
};
|
|
16
|
-
//# sourceMappingURL=
|
|
21
|
+
//# sourceMappingURL=chunk-JW4XRHLX.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/safeServerAction.ts"],"sourcesContent":["import { isRedirectError } from 'next/dist/client/components/redirect-error';\nimport { ApiError } from '../infra/api/types';\nimport type { ActionResult } from '../infra/api/types';\n\nexport async function safeServerAction<T>(\n fn: () => Promise<T>\n): Promise<ActionResult<T>> {\n try {\n const data = await fn();\n return { success: true, data };\n } catch (error) {\n if (isRedirectError(error)) throw error;\n const message =\n error instanceof ApiError\n ? error.message\n : error instanceof Error\n ? error.message\n : 'Erro desconhecido';\n return { success: false, error: message };\n }\n}\n"],"mappings":";;;;;AAAA,SAAS,uBAAuB;AAIhC,eAAsB,iBACpB,IAC0B;AAC1B,MAAI;AACF,UAAM,OAAO,MAAM,GAAG;AACtB,WAAO,EAAE,SAAS,MAAM,KAAK;AAAA,EAC/B,SAAS,OAAO;AACd,QAAI,gBAAgB,KAAK,EAAG,OAAM;AAClC,UAAM,UACJ,iBAAiB,WACb,MAAM,UACN,iBAAiB,QACf,MAAM,UACN;AACR,WAAO,EAAE,SAAS,OAAO,OAAO,QAAQ;AAAA,EAC1C;AACF;","names":[]}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import {
|
|
2
|
+
safeServerAction
|
|
3
|
+
} from "./chunk-JW4XRHLX.mjs";
|
|
4
|
+
import {
|
|
5
|
+
accountService,
|
|
6
|
+
getUserContext
|
|
7
|
+
} from "./chunk-Z3Q2LLBS.mjs";
|
|
8
|
+
import {
|
|
9
|
+
ApiError,
|
|
10
|
+
findWhitelabel
|
|
11
|
+
} from "./chunk-UEWT6VFS.mjs";
|
|
12
|
+
|
|
13
|
+
// src/modules/accounts/services/two-factor.service.ts
|
|
14
|
+
import "server-only";
|
|
15
|
+
var TWO_FA_BASE_URL = process.env.R2_2FA_URL || "https://r2-2fa.greatapps.dev.br";
|
|
16
|
+
var TwoFactorService = class {
|
|
17
|
+
async request(path, body) {
|
|
18
|
+
const { id, token } = await findWhitelabel();
|
|
19
|
+
const { id_account, id_user } = await getUserContext();
|
|
20
|
+
const url = `${TWO_FA_BASE_URL}/v1/${id}/account/${id_account}/users/${id_user}/2fa/${path}`;
|
|
21
|
+
const response = await fetch(url, {
|
|
22
|
+
method: "POST",
|
|
23
|
+
headers: {
|
|
24
|
+
"Content-Type": "application/json",
|
|
25
|
+
authorization: token
|
|
26
|
+
},
|
|
27
|
+
body: body ? JSON.stringify(body) : void 0
|
|
28
|
+
});
|
|
29
|
+
if (!response.ok) {
|
|
30
|
+
const errorData = await response.json().catch(() => ({}));
|
|
31
|
+
throw new ApiError(
|
|
32
|
+
errorData.message || `HTTP error ${response.status}`,
|
|
33
|
+
"HTTP_ERROR",
|
|
34
|
+
response.status
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
return response.json();
|
|
38
|
+
}
|
|
39
|
+
async generate() {
|
|
40
|
+
const response = await this.request("generate");
|
|
41
|
+
if (response.status === 0) {
|
|
42
|
+
throw new ApiError(response.message || "Erro ao gerar QR Code", "GENERATE_2FA_FAILED", 400);
|
|
43
|
+
}
|
|
44
|
+
return response;
|
|
45
|
+
}
|
|
46
|
+
async confirm(code) {
|
|
47
|
+
const response = await this.request("confirm", { code });
|
|
48
|
+
if (response.status === 0) {
|
|
49
|
+
throw new ApiError(response.message || "C\xF3digo inv\xE1lido", "CONFIRM_2FA_FAILED", 400);
|
|
50
|
+
}
|
|
51
|
+
return response;
|
|
52
|
+
}
|
|
53
|
+
async verify(code) {
|
|
54
|
+
const response = await this.request("verify", { code });
|
|
55
|
+
if (response.status === 0) {
|
|
56
|
+
throw new ApiError(response.message || "C\xF3digo inv\xE1lido", "VERIFY_2FA_FAILED", 400);
|
|
57
|
+
}
|
|
58
|
+
return response;
|
|
59
|
+
}
|
|
60
|
+
async disable() {
|
|
61
|
+
const { id, token } = await findWhitelabel();
|
|
62
|
+
const { id_account, id_user } = await getUserContext();
|
|
63
|
+
const url = `${TWO_FA_BASE_URL}/v1/${id}/account/${id_account}/users/${id_user}/2fa`;
|
|
64
|
+
const response = await fetch(url, {
|
|
65
|
+
method: "DELETE",
|
|
66
|
+
headers: { authorization: token }
|
|
67
|
+
});
|
|
68
|
+
if (!response.ok) {
|
|
69
|
+
const errorData = await response.json().catch(() => ({}));
|
|
70
|
+
throw new ApiError(
|
|
71
|
+
errorData.message || `HTTP error ${response.status}`,
|
|
72
|
+
"HTTP_ERROR",
|
|
73
|
+
response.status
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
const data = await response.json();
|
|
77
|
+
if (data.status === 0) {
|
|
78
|
+
throw new ApiError(data.message || "Erro ao desabilitar 2FA", "DISABLE_2FA_FAILED", 400);
|
|
79
|
+
}
|
|
80
|
+
return data;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
var twoFactorService = new TwoFactorService();
|
|
84
|
+
|
|
85
|
+
// src/modules/accounts/actions/account-management.action.ts
|
|
86
|
+
async function listAccountUsersAction(params) {
|
|
87
|
+
return safeServerAction(async () => {
|
|
88
|
+
const { users, total } = await accountService.listAccountUsers(params);
|
|
89
|
+
return { data: users, total };
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
async function updateUserAction(user) {
|
|
93
|
+
return safeServerAction(() => accountService.updateAccountUser(user));
|
|
94
|
+
}
|
|
95
|
+
async function updateAccountUserByIdAction(userId, user) {
|
|
96
|
+
return safeServerAction(() => accountService.updateAccountUserById(userId, user));
|
|
97
|
+
}
|
|
98
|
+
async function updateAccountAction(data) {
|
|
99
|
+
return safeServerAction(() => accountService.updateAccount(data));
|
|
100
|
+
}
|
|
101
|
+
async function deleteAccountUserAction(userId) {
|
|
102
|
+
return safeServerAction(() => accountService.deleteAccountUser(userId));
|
|
103
|
+
}
|
|
104
|
+
async function deleteAccountAction() {
|
|
105
|
+
return safeServerAction(() => accountService.deleteAccount());
|
|
106
|
+
}
|
|
107
|
+
async function createAccountUserAction(user) {
|
|
108
|
+
return safeServerAction(() => accountService.createAccountUser(user));
|
|
109
|
+
}
|
|
110
|
+
async function changePasswordAction(data) {
|
|
111
|
+
return safeServerAction(() => accountService.changePassword(data));
|
|
112
|
+
}
|
|
113
|
+
async function requestEmailChangeAction(newEmail) {
|
|
114
|
+
return safeServerAction(() => accountService.requestContactReset("email", newEmail));
|
|
115
|
+
}
|
|
116
|
+
async function confirmEmailChangeAction(token, newEmail) {
|
|
117
|
+
return safeServerAction(() => accountService.confirmContactReset("email", token, newEmail));
|
|
118
|
+
}
|
|
119
|
+
async function requestPhoneChangeAction(newPhone) {
|
|
120
|
+
return safeServerAction(() => accountService.requestContactReset("phone", newPhone));
|
|
121
|
+
}
|
|
122
|
+
async function confirmPhoneChangeAction(token, newPhone) {
|
|
123
|
+
return safeServerAction(() => accountService.confirmContactReset("phone", token, newPhone));
|
|
124
|
+
}
|
|
125
|
+
async function generateTwoFactorAction() {
|
|
126
|
+
return safeServerAction(async () => {
|
|
127
|
+
const result = await twoFactorService.generate();
|
|
128
|
+
return {
|
|
129
|
+
qrcode: result.data.qrcode,
|
|
130
|
+
backupCodes: result.data.backup_codes
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
async function confirmTwoFactorAction(code) {
|
|
135
|
+
return safeServerAction(async () => {
|
|
136
|
+
await twoFactorService.confirm(code);
|
|
137
|
+
await accountService.updateAccountUser({ two_factor_authentication: true });
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
async function disableTwoFactorAction(code) {
|
|
141
|
+
return safeServerAction(async () => {
|
|
142
|
+
await twoFactorService.verify(code);
|
|
143
|
+
await twoFactorService.disable();
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export {
|
|
148
|
+
twoFactorService,
|
|
149
|
+
listAccountUsersAction,
|
|
150
|
+
updateUserAction,
|
|
151
|
+
updateAccountUserByIdAction,
|
|
152
|
+
updateAccountAction,
|
|
153
|
+
deleteAccountUserAction,
|
|
154
|
+
deleteAccountAction,
|
|
155
|
+
createAccountUserAction,
|
|
156
|
+
changePasswordAction,
|
|
157
|
+
requestEmailChangeAction,
|
|
158
|
+
confirmEmailChangeAction,
|
|
159
|
+
requestPhoneChangeAction,
|
|
160
|
+
confirmPhoneChangeAction,
|
|
161
|
+
generateTwoFactorAction,
|
|
162
|
+
confirmTwoFactorAction,
|
|
163
|
+
disableTwoFactorAction
|
|
164
|
+
};
|
|
165
|
+
//# sourceMappingURL=chunk-QEFMNBSY.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/modules/accounts/services/two-factor.service.ts","../src/modules/accounts/actions/account-management.action.ts"],"sourcesContent":["import 'server-only';\r\n\r\nimport { ApiError } from '../../../infra/api/types';\r\nimport { getUserContext } from '../../auth/utils/get-user-context';\r\nimport { findWhitelabel } from '../../whitelabel/actions/find-whitelabel.action';\r\nimport type { TwoFactorActionResponse, TwoFactorGenerateResponse } from '../types';\r\n\r\nconst TWO_FA_BASE_URL = process.env.R2_2FA_URL || 'https://r2-2fa.greatapps.dev.br';\r\n\r\nclass TwoFactorService {\r\n private async request<T>(path: string, body?: object): Promise<T> {\r\n const { id, token } = await findWhitelabel();\r\n const { id_account, id_user } = await getUserContext();\r\n\r\n const url = `${TWO_FA_BASE_URL}/v1/${id}/account/${id_account}/users/${id_user}/2fa/${path}`;\r\n\r\n const response = await fetch(url, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n authorization: token,\r\n },\r\n body: body ? JSON.stringify(body) : undefined,\r\n });\r\n\r\n if (!response.ok) {\r\n const errorData = await response.json().catch(() => ({})) as Record<string, unknown>;\r\n throw new ApiError(\r\n (errorData.message as string) || `HTTP error ${response.status}`,\r\n 'HTTP_ERROR',\r\n response.status\r\n );\r\n }\r\n\r\n return response.json() as Promise<T>;\r\n }\r\n\r\n async generate(): Promise<TwoFactorGenerateResponse> {\r\n const response = await this.request<TwoFactorGenerateResponse>('generate');\r\n\r\n if (response.status === 0) {\r\n throw new ApiError(response.message || 'Erro ao gerar QR Code', 'GENERATE_2FA_FAILED', 400);\r\n }\r\n\r\n return response;\r\n }\r\n\r\n async confirm(code: string): Promise<TwoFactorActionResponse> {\r\n const response = await this.request<TwoFactorActionResponse>('confirm', { code });\r\n\r\n if (response.status === 0) {\r\n throw new ApiError(response.message || 'Código inválido', 'CONFIRM_2FA_FAILED', 400);\r\n }\r\n\r\n return response;\r\n }\r\n\r\n async verify(code: string): Promise<TwoFactorActionResponse> {\r\n const response = await this.request<TwoFactorActionResponse>('verify', { code });\r\n\r\n if (response.status === 0) {\r\n throw new ApiError(response.message || 'Código inválido', 'VERIFY_2FA_FAILED', 400);\r\n }\r\n\r\n return response;\r\n }\r\n\r\n async disable(): Promise<TwoFactorActionResponse> {\r\n const { id, token } = await findWhitelabel();\r\n const { id_account, id_user } = await getUserContext();\r\n\r\n const url = `${TWO_FA_BASE_URL}/v1/${id}/account/${id_account}/users/${id_user}/2fa`;\r\n\r\n const response = await fetch(url, {\r\n method: 'DELETE',\r\n headers: { authorization: token },\r\n });\r\n\r\n if (!response.ok) {\r\n const errorData = await response.json().catch(() => ({})) as Record<string, unknown>;\r\n throw new ApiError(\r\n (errorData.message as string) || `HTTP error ${response.status}`,\r\n 'HTTP_ERROR',\r\n response.status\r\n );\r\n }\r\n\r\n const data = await response.json() as TwoFactorActionResponse;\r\n\r\n if (data.status === 0) {\r\n throw new ApiError(data.message || 'Erro ao desabilitar 2FA', 'DISABLE_2FA_FAILED', 400);\r\n }\r\n\r\n return data;\r\n }\r\n}\r\n\r\nexport const twoFactorService = new TwoFactorService();\r\n","'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { accountService } from '../services/account.service';\nimport type {\n AccountUsersPaginationParams,\n ChangePasswordRequest,\n CreateAccountUserRequest,\n UpdateAccountRequest,\n UpdateAccountUserRequest,\n} from '../types';\nimport { twoFactorService } from '../services/two-factor.service';\n\nexport async function listAccountUsersAction(params?: AccountUsersPaginationParams) {\n return safeServerAction(async () => {\n const { users, total } = await accountService.listAccountUsers(params);\n return { data: users, total };\n });\n}\n\nexport async function updateUserAction(user: UpdateAccountUserRequest) {\n return safeServerAction(() => accountService.updateAccountUser(user));\n}\n\nexport async function updateAccountUserByIdAction(\n userId: number,\n user: UpdateAccountUserRequest\n) {\n return safeServerAction(() => accountService.updateAccountUserById(userId, user));\n}\n\nexport async function updateAccountAction(data: UpdateAccountRequest) {\n return safeServerAction(() => accountService.updateAccount(data));\n}\n\nexport async function deleteAccountUserAction(userId: number) {\n return safeServerAction(() => accountService.deleteAccountUser(userId));\n}\n\nexport async function deleteAccountAction() {\n return safeServerAction(() => accountService.deleteAccount());\n}\n\nexport async function createAccountUserAction(user: CreateAccountUserRequest) {\n return safeServerAction(() => accountService.createAccountUser(user));\n}\n\nexport async function changePasswordAction(data: ChangePasswordRequest) {\n return safeServerAction(() => accountService.changePassword(data));\n}\n\nexport async function requestEmailChangeAction(newEmail: string) {\n return safeServerAction(() => accountService.requestContactReset('email', newEmail));\n}\n\nexport async function confirmEmailChangeAction(token: string, newEmail: string) {\n return safeServerAction(() => accountService.confirmContactReset('email', token, newEmail));\n}\n\nexport async function requestPhoneChangeAction(newPhone: string) {\n return safeServerAction(() => accountService.requestContactReset('phone', newPhone));\n}\n\nexport async function confirmPhoneChangeAction(token: string, newPhone: string) {\n return safeServerAction(() => accountService.confirmContactReset('phone', token, newPhone));\n}\n\nexport async function generateTwoFactorAction() {\n return safeServerAction(async () => {\n const result = await twoFactorService.generate();\n return {\n qrcode: result.data.qrcode,\n backupCodes: result.data.backup_codes,\n };\n });\n}\n\nexport async function confirmTwoFactorAction(code: string) {\n return safeServerAction(async () => {\n await twoFactorService.confirm(code);\n await accountService.updateAccountUser({ two_factor_authentication: true });\n });\n}\n\nexport async function disableTwoFactorAction(code: string) {\n return safeServerAction(async () => {\n await twoFactorService.verify(code);\n await twoFactorService.disable();\n });\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,OAAO;AAOP,IAAM,kBAAkB,QAAQ,IAAI,cAAc;AAElD,IAAM,mBAAN,MAAuB;AAAA,EACrB,MAAc,QAAW,MAAc,MAA2B;AAChE,UAAM,EAAE,IAAI,MAAM,IAAI,MAAM,eAAe;AAC3C,UAAM,EAAE,YAAY,QAAQ,IAAI,MAAM,eAAe;AAErD,UAAM,MAAM,GAAG,eAAe,OAAO,EAAE,YAAY,UAAU,UAAU,OAAO,QAAQ,IAAI;AAE1F,UAAM,WAAW,MAAM,MAAM,KAAK;AAAA,MAChC,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,QAChB,eAAe;AAAA,MACjB;AAAA,MACA,MAAM,OAAO,KAAK,UAAU,IAAI,IAAI;AAAA,IACtC,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,YAAY,MAAM,SAAS,KAAK,EAAE,MAAM,OAAO,CAAC,EAAE;AACxD,YAAM,IAAI;AAAA,QACP,UAAU,WAAsB,cAAc,SAAS,MAAM;AAAA,QAC9D;AAAA,QACA,SAAS;AAAA,MACX;AAAA,IACF;AAEA,WAAO,SAAS,KAAK;AAAA,EACvB;AAAA,EAEA,MAAM,WAA+C;AACnD,UAAM,WAAW,MAAM,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S,OAAO,QAAQ,CAAC;AAC5F;AAEA,eAAsB,0BAA0B;AAC9C,SAAO,iBAAiB,YAAY;AAClC,UAAM,SAAS,MAAM,iBAAiB,SAAS;AAC/C,WAAO;AAAA,MACL,QAAQ,OAAO,KAAK;AAAA,MACpB,aAAa,OAAO,KAAK;AAAA,IAC3B;AAAA,EACF,CAAC;AACH;AAEA,eAAsB,uBAAuB,MAAc;AACzD,SAAO,iBAAiB,YAAY;AAClC,UAAM,iBAAiB,QAAQ,IAAI;AACnC,UAAM,eAAe,kBAAkB,EAAE,2BAA2B,KAAK,CAAC;AAAA,EAC5E,CAAC;AACH;AAEA,eAAsB,uBAAuB,MAAc;AACzD,SAAO,iBAAiB,YAAY;AAClC,UAAM,iBAAiB,OAAO,IAAI;AAClC,UAAM,iBAAiB,QAAQ;AAAA,EACjC,CAAC;AACH;","names":[]}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
ApiError,
|
|
3
|
+
findWhitelabel
|
|
4
|
+
} from "./chunk-UEWT6VFS.mjs";
|
|
5
|
+
|
|
6
|
+
// src/infra/api/client.ts
|
|
7
|
+
var ApiClient = class {
|
|
4
8
|
baseUrl;
|
|
5
9
|
apiVersion = "v1";
|
|
6
10
|
apiLocale = "pt-br";
|
|
@@ -122,15 +126,16 @@ class ApiClient {
|
|
|
122
126
|
async delete(endpoint, config) {
|
|
123
127
|
return this.request(endpoint, { ...config, method: "DELETE" });
|
|
124
128
|
}
|
|
125
|
-
}
|
|
126
|
-
|
|
129
|
+
};
|
|
130
|
+
var api = {
|
|
127
131
|
apps: new ApiClient(process.env.GAPPS_R3_API_URL || "https://r3-api.greatapps.dev.br"),
|
|
128
132
|
pages: new ApiClient(process.env.GPAGES_R3_API_URL || "https://r3-api.greatpages.dev.br")
|
|
129
133
|
};
|
|
130
|
-
|
|
134
|
+
var apiClient = api.apps;
|
|
135
|
+
|
|
131
136
|
export {
|
|
132
137
|
ApiClient,
|
|
133
138
|
api,
|
|
134
139
|
apiClient
|
|
135
140
|
};
|
|
136
|
-
//# sourceMappingURL=
|
|
141
|
+
//# sourceMappingURL=chunk-RV7ECGIH.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/infra/api/client.ts"],"sourcesContent":["import { ApiError } from './types';\r\nimport { findWhitelabel } from '../../modules/whitelabel/actions/find-whitelabel.action';\r\n\r\nexport interface ApiClientOptions {\r\n /**\r\n * Quando true, monta `{base}/{locale}/{wlId}{endpoint}` (ex.: r2-clone).\r\n * Padrão false: `{base}/v1/{locale}/{wlId}{endpoint}`.\r\n */\r\n omitApiVersion?: boolean;\r\n}\r\n\r\nexport interface RequestConfig extends RequestInit {\r\n timeout?: number;\r\n /** Padrão `json`. Use `text` quando a API devolve corpo não-JSON. */\r\n responseType?: 'json' | 'text';\r\n}\r\n\r\nclass ApiClient {\r\n private readonly baseUrl: string;\r\n private readonly apiVersion = 'v1';\r\n private readonly apiLocale = 'pt-br';\r\n private readonly omitApiVersion: boolean;\r\n\r\n constructor(baseUrl: string, options?: ApiClientOptions) {\r\n this.baseUrl = baseUrl.replace(/\\/$/, '');\r\n this.omitApiVersion = options?.omitApiVersion ?? false;\r\n }\r\n\r\n private async buildUrl(endpoint: string, whiteLabelId: number): Promise<string> {\r\n const wlPath = this.omitApiVersion\r\n ? `/${this.apiLocale}/${whiteLabelId}`\r\n : `/${this.apiVersion}/${this.apiLocale}/${whiteLabelId}`;\r\n const path = endpoint.startsWith('/') ? endpoint : `/${endpoint}`;\r\n const url = `${this.baseUrl}${wlPath}${path}`;\r\n console.log('[ApiClient] buildUrl', {\r\n baseURL: this.baseUrl,\r\n whiteLabelId,\r\n endpoint,\r\n fullUrl: url,\r\n });\r\n return url;\r\n }\r\n\r\n private async getDefaultHeaders(token: string, isFormData = false): Promise<HeadersInit> {\r\n console.log('[ApiClient] getDefaultHeaders', {\r\n token: token.substring(0, 20) + '...',\r\n });\r\n\r\n const headers: HeadersInit = {\r\n authorization: token,\r\n };\r\n\r\n if (!isFormData) {\r\n headers['Content-Type'] = 'application/json';\r\n }\r\n\r\n return headers;\r\n }\r\n\r\n async request<T>(endpoint: string, config: RequestConfig = {}): Promise<T> {\r\n console.log('[ApiClient] request called', { endpoint, method: config.method });\r\n\r\n const { timeout = 30000, responseType = 'json', ...fetchConfig } = config;\r\n\r\n const controller = new AbortController();\r\n const timeoutId = setTimeout(() => controller.abort(), timeout);\r\n\r\n try {\r\n console.log('[ApiClient] Building URL and headers...');\r\n\r\n const { id, token } = await findWhitelabel();\r\n\r\n const [url, defaultHeaders] = await Promise.all([\r\n this.buildUrl(endpoint, id),\r\n this.getDefaultHeaders(token, fetchConfig.body instanceof FormData),\r\n ]);\r\n\r\n console.log('[ApiClient] Fetching', {\r\n url,\r\n method: fetchConfig.method,\r\n headers: defaultHeaders,\r\n });\r\n\r\n const response = await fetch(url, {\r\n ...fetchConfig,\r\n headers: {\r\n ...defaultHeaders,\r\n ...fetchConfig.headers,\r\n },\r\n signal: controller.signal,\r\n });\r\n\r\n console.log('[ApiClient] Response received', { status: response.status, ok: response.ok });\r\n\r\n if (!response.ok) {\r\n const errBody = await response.text();\r\n let message = `HTTP error ${response.status}`;\r\n let code = 'HTTP_ERROR';\r\n try {\r\n const errorData = JSON.parse(errBody) as Record<string, unknown>;\r\n if (typeof errorData.message === 'string') message = errorData.message;\r\n if (typeof errorData.code === 'string') code = errorData.code;\r\n } catch {\r\n if (errBody.trim()) message = errBody.trim();\r\n }\r\n console.error('[ApiClient] Request failed', { status: response.status, message });\r\n throw new ApiError(message, code, response.status);\r\n }\r\n\r\n if (responseType === 'text') {\r\n return (await response.text()) as T;\r\n }\r\n\r\n const data = (await response.json()) as T;\r\n console.log('[ApiClient] Request successful', { hasData: !!data });\r\n return data;\r\n } catch (error) {\r\n console.error('[ApiClient] Request error', { error });\r\n\r\n if (error instanceof ApiError) {\r\n throw error;\r\n }\r\n\r\n if (error instanceof Error) {\r\n if (error.name === 'AbortError') {\r\n throw new ApiError('Tempo de requisição excedido', 'TIMEOUT', 408);\r\n }\r\n throw new ApiError(error.message, 'NETWORK_ERROR', 0);\r\n }\r\n\r\n throw new ApiError('Erro desconhecido', 'UNKNOWN_ERROR', 500);\r\n } finally {\r\n clearTimeout(timeoutId);\r\n }\r\n }\r\n\r\n async get<T>(endpoint: string, config?: RequestConfig): Promise<T> {\r\n return this.request<T>(endpoint, { ...config, method: 'GET' });\r\n }\r\n\r\n async post<T>(endpoint: string, data?: unknown, config?: RequestConfig): Promise<T> {\r\n return this.request<T>(endpoint, {\r\n ...config,\r\n method: 'POST',\r\n body: data instanceof FormData ? data : data ? JSON.stringify(data) : undefined,\r\n });\r\n }\r\n\r\n async put<T>(endpoint: string, data?: unknown, config?: RequestConfig): Promise<T> {\r\n return this.request<T>(endpoint, {\r\n ...config,\r\n method: 'PUT',\r\n body: data instanceof FormData ? data : data ? JSON.stringify(data) : undefined,\r\n });\r\n }\r\n\r\n async patch<T>(endpoint: string, data?: unknown, config?: RequestConfig): Promise<T> {\r\n return this.request<T>(endpoint, {\r\n ...config,\r\n method: 'PATCH',\r\n body: data instanceof FormData ? data : data ? JSON.stringify(data) : undefined,\r\n });\r\n }\r\n\r\n async delete<T>(endpoint: string, config?: RequestConfig): Promise<T> {\r\n return this.request<T>(endpoint, { ...config, method: 'DELETE' });\r\n }\r\n}\r\n\r\nconst api = {\r\n apps: new ApiClient(process.env.GAPPS_R3_API_URL || 'https://r3-api.greatapps.dev.br'),\r\n pages: new ApiClient(process.env.GPAGES_R3_API_URL || 'https://r3-api.greatpages.dev.br'),\r\n}\r\n\r\n/** @deprecated use api.apps */\r\nexport const apiClient = api.apps;\r\n\r\nexport { api, ApiClient };\r\n"],"mappings":";;;;;;AAiBA,IAAM,YAAN,MAAgB;AAAA,EACG;AAAA,EACA,aAAa;AAAA,EACb,YAAY;AAAA,EACZ;AAAA,EAEjB,YAAY,SAAiB,SAA4B;AACvD,S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