@greatapps/common 1.1.429 → 1.1.430

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (477) hide show
  1. package/dist/components/account/AccountModals.mjs +18 -0
  2. package/dist/components/account/AccountModals.mjs.map +1 -0
  3. package/dist/components/account/ConfigurationsMyAccountModal.mjs +129 -0
  4. package/dist/components/account/ConfigurationsMyAccountModal.mjs.map +1 -0
  5. package/dist/components/account/ConfirmDeleteAccountModal.mjs +45 -0
  6. package/dist/components/account/ConfirmDeleteAccountModal.mjs.map +1 -0
  7. package/dist/components/account/ConfirmGlobalPreferencesModal.mjs +45 -0
  8. package/dist/components/account/ConfirmGlobalPreferencesModal.mjs.map +1 -0
  9. package/dist/components/account/DeleteAccountModal.mjs +123 -0
  10. package/dist/components/account/DeleteAccountModal.mjs.map +1 -0
  11. package/dist/components/account/DisableTwoFactorAuthModal.mjs +67 -0
  12. package/dist/components/account/DisableTwoFactorAuthModal.mjs.map +1 -0
  13. package/dist/components/account/IsntPossibleDeleteAccountModal.mjs +42 -0
  14. package/dist/components/account/IsntPossibleDeleteAccountModal.mjs.map +1 -0
  15. package/dist/components/account/TwoFactorAuthModal.mjs +182 -0
  16. package/dist/components/account/TwoFactorAuthModal.mjs.map +1 -0
  17. package/dist/components/account/constants.mjs +29 -0
  18. package/dist/components/account/constants.mjs.map +1 -0
  19. package/dist/components/account/hooks/useChangeEmailForm.mjs +53 -0
  20. package/dist/components/account/hooks/useChangeEmailForm.mjs.map +1 -0
  21. package/dist/components/account/hooks/useChangePasswordForm.mjs +47 -0
  22. package/dist/components/account/hooks/useChangePasswordForm.mjs.map +1 -0
  23. package/dist/components/account/hooks/useChangePhoneForm.mjs +91 -0
  24. package/dist/components/account/hooks/useChangePhoneForm.mjs.map +1 -0
  25. package/dist/components/account/hooks/useConfigurationsModal.mjs +34 -0
  26. package/dist/components/account/hooks/useConfigurationsModal.mjs.map +1 -0
  27. package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs +54 -0
  28. package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs.map +1 -0
  29. package/dist/components/account/hooks/useOtpVerification.mjs +94 -0
  30. package/dist/components/account/hooks/useOtpVerification.mjs.map +1 -0
  31. package/dist/components/account/hooks/useTwoFactorAuthForm.mjs +80 -0
  32. package/dist/components/account/hooks/useTwoFactorAuthForm.mjs.map +1 -0
  33. package/dist/components/account/sections/ChangeEmailModal.mjs +181 -0
  34. package/dist/components/account/sections/ChangeEmailModal.mjs.map +1 -0
  35. package/dist/components/account/sections/ChangePasswordSection.mjs +64 -0
  36. package/dist/components/account/sections/ChangePasswordSection.mjs.map +1 -0
  37. package/dist/components/account/sections/ChangePhoneModal.mjs +192 -0
  38. package/dist/components/account/sections/ChangePhoneModal.mjs.map +1 -0
  39. package/dist/components/account/sections/MyProfileSection.mjs +317 -0
  40. package/dist/components/account/sections/MyProfileSection.mjs.map +1 -0
  41. package/dist/components/account/sections/PreferencesSection.mjs +227 -0
  42. package/dist/components/account/sections/PreferencesSection.mjs.map +1 -0
  43. package/dist/components/account/sections/SecuritySection.mjs +31 -0
  44. package/dist/components/account/sections/SecuritySection.mjs.map +1 -0
  45. package/dist/components/embeds/CrispEmbed.mjs +89 -0
  46. package/dist/components/embeds/CrispEmbed.mjs.map +1 -0
  47. package/dist/components/embeds/FrillEmbed.mjs +107 -0
  48. package/dist/components/embeds/FrillEmbed.mjs.map +1 -0
  49. package/dist/components/handlers/SearchParamsHandler.mjs +24 -0
  50. package/dist/components/handlers/SearchParamsHandler.mjs.map +1 -0
  51. package/dist/components/layouts/AppMobileNavBar.mjs +60 -0
  52. package/dist/components/layouts/AppMobileNavBar.mjs.map +1 -0
  53. package/dist/components/layouts/AppNavBar.mjs +37 -0
  54. package/dist/components/layouts/AppNavBar.mjs.map +1 -0
  55. package/dist/components/layouts/CollapsibleSidebar.mjs +65 -0
  56. package/dist/components/layouts/CollapsibleSidebar.mjs.map +1 -0
  57. package/dist/components/layouts/MainLayout.mjs +60 -0
  58. package/dist/components/layouts/MainLayout.mjs.map +1 -0
  59. package/dist/components/layouts/MdSideBarNavigation.mjs +54 -0
  60. package/dist/components/layouts/MdSideBarNavigation.mjs.map +1 -0
  61. package/dist/components/layouts/NavBar.mjs +152 -0
  62. package/dist/components/layouts/NavBar.mjs.map +1 -0
  63. package/dist/components/layouts/NavBarItem.mjs +23 -0
  64. package/dist/components/layouts/NavBarItem.mjs.map +1 -0
  65. package/dist/components/layouts/NotificationsPopover.mjs +97 -0
  66. package/dist/components/layouts/NotificationsPopover.mjs.map +1 -0
  67. package/dist/components/layouts/ProfilePopover.mjs +152 -0
  68. package/dist/components/layouts/ProfilePopover.mjs.map +1 -0
  69. package/dist/components/layouts/SideBarNavigation.mjs +63 -0
  70. package/dist/components/layouts/SideBarNavigation.mjs.map +1 -0
  71. package/dist/components/layouts/UsersSelectorPopover.mjs +210 -0
  72. package/dist/components/layouts/UsersSelectorPopover.mjs.map +1 -0
  73. package/dist/components/layouts/WhitelabelCodes.mjs +50 -0
  74. package/dist/components/layouts/WhitelabelCodes.mjs.map +1 -0
  75. package/dist/components/modals/BuyCreditsModal.mjs +281 -0
  76. package/dist/components/modals/BuyCreditsModal.mjs.map +1 -0
  77. package/dist/components/modals/ModalManager.mjs +19 -0
  78. package/dist/components/modals/ModalManager.mjs.map +1 -0
  79. package/dist/components/modals/Modals.mjs +20 -0
  80. package/dist/components/modals/Modals.mjs.map +1 -0
  81. package/dist/components/modals/PaidPlanRequiredModal.mjs +46 -0
  82. package/dist/components/modals/PaidPlanRequiredModal.mjs.map +1 -0
  83. package/dist/components/modals/cards/AddCardModal.mjs +215 -0
  84. package/dist/components/modals/cards/AddCardModal.mjs.map +1 -0
  85. package/dist/components/modals/cards/CardFormFields.mjs +268 -0
  86. package/dist/components/modals/cards/CardFormFields.mjs.map +1 -0
  87. package/dist/components/navigation/AppNavigation.mjs +33 -0
  88. package/dist/components/navigation/AppNavigation.mjs.map +1 -0
  89. package/dist/components/navigation/AppNavigationContext.mjs +13 -0
  90. package/dist/components/navigation/AppNavigationContext.mjs.map +1 -0
  91. package/dist/components/navigation/CancelledSubscriptionBanner.mjs +52 -0
  92. package/dist/components/navigation/CancelledSubscriptionBanner.mjs.map +1 -0
  93. package/dist/components/navigation/NavItem.mjs +41 -0
  94. package/dist/components/navigation/NavItem.mjs.map +1 -0
  95. package/dist/components/navigation/NavItemsContext.mjs +16 -0
  96. package/dist/components/navigation/NavItemsContext.mjs.map +1 -0
  97. package/dist/components/navigation/ProjectSelectorPopover.mjs +147 -0
  98. package/dist/components/navigation/ProjectSelectorPopover.mjs.map +1 -0
  99. package/dist/components/navigation/shells/DesktopShell.mjs +11 -0
  100. package/dist/components/navigation/shells/DesktopShell.mjs.map +1 -0
  101. package/dist/components/navigation/shells/MdShell.mjs +11 -0
  102. package/dist/components/navigation/shells/MdShell.mjs.map +1 -0
  103. package/dist/components/navigation/shells/MobileShell.mjs +27 -0
  104. package/dist/components/navigation/shells/MobileShell.mjs.map +1 -0
  105. package/dist/components/navigation/shells/TabsMobileShell.mjs +61 -0
  106. package/dist/components/navigation/shells/TabsMobileShell.mjs.map +1 -0
  107. package/dist/components/navigation/subcomponents/BottomLinks.mjs +35 -0
  108. package/dist/components/navigation/subcomponents/BottomLinks.mjs.map +1 -0
  109. package/dist/components/navigation/subcomponents/CreditsCard.mjs +33 -0
  110. package/dist/components/navigation/subcomponents/CreditsCard.mjs.map +1 -0
  111. package/dist/components/navigation/subcomponents/NavItems.mjs +25 -0
  112. package/dist/components/navigation/subcomponents/NavItems.mjs.map +1 -0
  113. package/dist/components/navigation/subcomponents/PlanCard.mjs +25 -0
  114. package/dist/components/navigation/subcomponents/PlanCard.mjs.map +1 -0
  115. package/dist/components/navigation/subcomponents/ProjectSelector.mjs +145 -0
  116. package/dist/components/navigation/subcomponents/ProjectSelector.mjs.map +1 -0
  117. package/dist/components/navigation/types.mjs +1 -0
  118. package/dist/components/navigation/types.mjs.map +1 -0
  119. package/dist/components/pages/NotFoundPage.mjs +47 -0
  120. package/dist/components/pages/NotFoundPage.mjs.map +1 -0
  121. package/dist/components/pages/notifications/Notifications.mjs +159 -0
  122. package/dist/components/pages/notifications/Notifications.mjs.map +1 -0
  123. package/dist/components/ui/buttons/Button.mjs +52 -0
  124. package/dist/components/ui/buttons/Button.mjs.map +1 -0
  125. package/dist/components/ui/buttons/CancelButton.mjs +17 -0
  126. package/dist/components/ui/buttons/CancelButton.mjs.map +1 -0
  127. package/dist/components/ui/buttons/CopyButton.mjs +42 -0
  128. package/dist/components/ui/buttons/CopyButton.mjs.map +1 -0
  129. package/dist/components/ui/data-display/Accordion.mjs +76 -0
  130. package/dist/components/ui/data-display/Accordion.mjs.map +1 -0
  131. package/dist/components/ui/data-display/Badge.mjs +42 -0
  132. package/dist/components/ui/data-display/Badge.mjs.map +1 -0
  133. package/dist/components/ui/data-display/Card.mjs +92 -0
  134. package/dist/components/ui/data-display/Card.mjs.map +1 -0
  135. package/dist/components/ui/data-display/CardBrandIcons.mjs +484 -0
  136. package/dist/components/ui/data-display/CardBrandIcons.mjs.map +1 -0
  137. package/dist/components/ui/data-display/CardItem.mjs +67 -0
  138. package/dist/components/ui/data-display/CardItem.mjs.map +1 -0
  139. package/dist/components/ui/data-display/Pagination.mjs +118 -0
  140. package/dist/components/ui/data-display/Pagination.mjs.map +1 -0
  141. package/dist/components/ui/data-display/PaymentInfoCard.mjs +161 -0
  142. package/dist/components/ui/data-display/PaymentInfoCard.mjs.map +1 -0
  143. package/dist/components/ui/data-display/ScrollArea.mjs +62 -0
  144. package/dist/components/ui/data-display/ScrollArea.mjs.map +1 -0
  145. package/dist/components/ui/data-display/Separator.mjs +28 -0
  146. package/dist/components/ui/data-display/Separator.mjs.map +1 -0
  147. package/dist/components/ui/data-display/Table.mjs +116 -0
  148. package/dist/components/ui/data-display/Table.mjs.map +1 -0
  149. package/dist/components/ui/data-display/Tabs.mjs +69 -0
  150. package/dist/components/ui/data-display/Tabs.mjs.map +1 -0
  151. package/dist/components/ui/data-display/UserAvatar.mjs +49 -0
  152. package/dist/components/ui/data-display/UserAvatar.mjs.map +1 -0
  153. package/dist/components/ui/feedback/CircularProgress.mjs +71 -0
  154. package/dist/components/ui/feedback/CircularProgress.mjs.map +1 -0
  155. package/dist/components/ui/feedback/DefaultCircularProgress.mjs +63 -0
  156. package/dist/components/ui/feedback/DefaultCircularProgress.mjs.map +1 -0
  157. package/dist/components/ui/feedback/LoadingOverlay.mjs +19 -0
  158. package/dist/components/ui/feedback/LoadingOverlay.mjs.map +1 -0
  159. package/dist/components/ui/feedback/Progress.mjs +37 -0
  160. package/dist/components/ui/feedback/Progress.mjs.map +1 -0
  161. package/dist/components/ui/feedback/Skeleton.mjs +9 -0
  162. package/dist/components/ui/feedback/Skeleton.mjs.map +1 -0
  163. package/dist/components/ui/feedback/Toast.mjs +77 -0
  164. package/dist/components/ui/feedback/Toast.mjs.map +1 -0
  165. package/dist/components/ui/form/Calendar.mjs +204 -0
  166. package/dist/components/ui/form/Calendar.mjs.map +1 -0
  167. package/dist/components/ui/form/Checkbox.mjs +33 -0
  168. package/dist/components/ui/form/Checkbox.mjs.map +1 -0
  169. package/dist/components/ui/form/ComboboxField.mjs +130 -0
  170. package/dist/components/ui/form/ComboboxField.mjs.map +1 -0
  171. package/dist/components/ui/form/DatePicker.mjs +82 -0
  172. package/dist/components/ui/form/DatePicker.mjs.map +1 -0
  173. package/dist/components/ui/form/DateRangePicker.mjs +92 -0
  174. package/dist/components/ui/form/DateRangePicker.mjs.map +1 -0
  175. package/dist/components/ui/form/FormField.mjs +103 -0
  176. package/dist/components/ui/form/FormField.mjs.map +1 -0
  177. package/dist/components/ui/form/Input.mjs +21 -0
  178. package/dist/components/ui/form/Input.mjs.map +1 -0
  179. package/dist/components/ui/form/InputOtp.mjs +70 -0
  180. package/dist/components/ui/form/InputOtp.mjs.map +1 -0
  181. package/dist/components/ui/form/PhoneInput.mjs +176 -0
  182. package/dist/components/ui/form/PhoneInput.mjs.map +1 -0
  183. package/dist/components/ui/form/RadioGroup.mjs +37 -0
  184. package/dist/components/ui/form/RadioGroup.mjs.map +1 -0
  185. package/dist/components/ui/form/Select.mjs +179 -0
  186. package/dist/components/ui/form/Select.mjs.map +1 -0
  187. package/dist/components/ui/form/SelectField.mjs +80 -0
  188. package/dist/components/ui/form/SelectField.mjs.map +1 -0
  189. package/dist/components/ui/form/Switch.mjs +33 -0
  190. package/dist/components/ui/form/Switch.mjs.map +1 -0
  191. package/dist/components/ui/form/SwitchOptionFieldWithIcon.mjs +40 -0
  192. package/dist/components/ui/form/SwitchOptionFieldWithIcon.mjs.map +1 -0
  193. package/dist/components/ui/form/TextAreaField.mjs +56 -0
  194. package/dist/components/ui/form/TextAreaField.mjs.map +1 -0
  195. package/dist/components/ui/form/Textarea.mjs +20 -0
  196. package/dist/components/ui/form/Textarea.mjs.map +1 -0
  197. package/dist/components/ui/overlay/Command.mjs +178 -0
  198. package/dist/components/ui/overlay/Command.mjs.map +1 -0
  199. package/dist/components/ui/overlay/Dialog.mjs +142 -0
  200. package/dist/components/ui/overlay/Dialog.mjs.map +1 -0
  201. package/dist/components/ui/overlay/Popover.mjs +46 -0
  202. package/dist/components/ui/overlay/Popover.mjs.map +1 -0
  203. package/dist/components/ui/overlay/Sheet.mjs +149 -0
  204. package/dist/components/ui/overlay/Sheet.mjs.map +1 -0
  205. package/dist/components/ui/overlay/Tooltip.mjs +57 -0
  206. package/dist/components/ui/overlay/Tooltip.mjs.map +1 -0
  207. package/dist/components/widgets/notifications/NotificationCard.mjs +54 -0
  208. package/dist/components/widgets/notifications/NotificationCard.mjs.map +1 -0
  209. package/dist/enums/AccountSectionType.mjs +11 -0
  210. package/dist/enums/AccountSectionType.mjs.map +1 -0
  211. package/dist/hooks/copy-to-clipboard.hook.mjs +52 -0
  212. package/dist/hooks/copy-to-clipboard.hook.mjs.map +1 -0
  213. package/dist/hooks/useCountdownTimer.mjs +29 -0
  214. package/dist/hooks/useCountdownTimer.mjs.map +1 -0
  215. package/dist/hooks/useDebounce.mjs +19 -0
  216. package/dist/hooks/useDebounce.mjs.map +1 -0
  217. package/dist/hooks/useDebounceState.mjs +12 -0
  218. package/dist/hooks/useDebounceState.mjs.map +1 -0
  219. package/dist/hooks/useDebouncedEffect.mjs +44 -0
  220. package/dist/hooks/useDebouncedEffect.mjs.map +1 -0
  221. package/dist/hooks/useIsMobile.mjs +18 -0
  222. package/dist/hooks/useIsMobile.mjs.map +1 -0
  223. package/dist/hooks/usePasswordVisibility.mjs +13 -0
  224. package/dist/hooks/usePasswordVisibility.mjs.map +1 -0
  225. package/dist/index.mjs +528 -0
  226. package/dist/index.mjs.map +1 -0
  227. package/dist/infra/api/client.mjs +162 -0
  228. package/dist/infra/api/client.mjs.map +1 -0
  229. package/dist/infra/api/types.mjs +31 -0
  230. package/dist/infra/api/types.mjs.map +1 -0
  231. package/dist/infra/utils/client-info.mjs +27 -0
  232. package/dist/infra/utils/client-info.mjs.map +1 -0
  233. package/dist/infra/utils/clsx.mjs +9 -0
  234. package/dist/infra/utils/clsx.mjs.map +1 -0
  235. package/dist/infra/utils/date.mjs +11 -0
  236. package/dist/infra/utils/date.mjs.map +1 -0
  237. package/dist/infra/utils/params.mjs +21 -0
  238. package/dist/infra/utils/params.mjs.map +1 -0
  239. package/dist/infra/utils/parser.mjs +24 -0
  240. package/dist/infra/utils/parser.mjs.map +1 -0
  241. package/dist/infra/utils/percentage.mjs +20 -0
  242. package/dist/infra/utils/percentage.mjs.map +1 -0
  243. package/dist/middleware.mjs +10 -0
  244. package/dist/middleware.mjs.map +1 -0
  245. package/dist/middlewares/chain.mjs +37 -0
  246. package/dist/middlewares/chain.mjs.map +1 -0
  247. package/dist/middlewares/create-auth-middleware.mjs +32 -0
  248. package/dist/middlewares/create-auth-middleware.mjs.map +1 -0
  249. package/dist/middlewares/types.mjs +11 -0
  250. package/dist/middlewares/types.mjs.map +1 -0
  251. package/dist/modules/accounts/actions/account-management.action.mjs +98 -0
  252. package/dist/modules/accounts/actions/account-management.action.mjs.map +1 -0
  253. package/dist/modules/accounts/actions/find-current-account.action.mjs +10 -0
  254. package/dist/modules/accounts/actions/find-current-account.action.mjs.map +1 -0
  255. package/dist/modules/accounts/actions/list-currencies.action.mjs +10 -0
  256. package/dist/modules/accounts/actions/list-currencies.action.mjs.map +1 -0
  257. package/dist/modules/accounts/actions/list-timezones.action.mjs +10 -0
  258. package/dist/modules/accounts/actions/list-timezones.action.mjs.map +1 -0
  259. package/dist/modules/accounts/hooks/current-account.hook.mjs +24 -0
  260. package/dist/modules/accounts/hooks/current-account.hook.mjs.map +1 -0
  261. package/dist/modules/accounts/hooks/useAccountManagement.mjs +71 -0
  262. package/dist/modules/accounts/hooks/useAccountManagement.mjs.map +1 -0
  263. package/dist/modules/accounts/hooks/useCurrencies.mjs +17 -0
  264. package/dist/modules/accounts/hooks/useCurrencies.mjs.map +1 -0
  265. package/dist/modules/accounts/hooks/useTimezones.mjs +17 -0
  266. package/dist/modules/accounts/hooks/useTimezones.mjs.map +1 -0
  267. package/dist/modules/accounts/hooks/useViaCep.mjs +19 -0
  268. package/dist/modules/accounts/hooks/useViaCep.mjs.map +1 -0
  269. package/dist/modules/accounts/services/account.service.mjs +182 -0
  270. package/dist/modules/accounts/services/account.service.mjs.map +1 -0
  271. package/dist/modules/accounts/services/currency.service.mjs +24 -0
  272. package/dist/modules/accounts/services/currency.service.mjs.map +1 -0
  273. package/dist/modules/accounts/services/timezone.service.mjs +65 -0
  274. package/dist/modules/accounts/services/timezone.service.mjs.map +1 -0
  275. package/dist/modules/accounts/services/two-factor.service.mjs +78 -0
  276. package/dist/modules/accounts/services/two-factor.service.mjs.map +1 -0
  277. package/dist/modules/accounts/types.mjs +1 -0
  278. package/dist/modules/accounts/types.mjs.map +1 -0
  279. package/dist/modules/auth/actions/login.action.mjs +14 -0
  280. package/dist/modules/auth/actions/login.action.mjs.map +1 -0
  281. package/dist/modules/auth/actions/logout.action.mjs +14 -0
  282. package/dist/modules/auth/actions/logout.action.mjs.map +1 -0
  283. package/dist/modules/auth/actions/register.action.mjs +14 -0
  284. package/dist/modules/auth/actions/register.action.mjs.map +1 -0
  285. package/dist/modules/auth/actions/validate-session.action.mjs +48 -0
  286. package/dist/modules/auth/actions/validate-session.action.mjs.map +1 -0
  287. package/dist/modules/auth/actions/verify-two-factor.action.mjs +17 -0
  288. package/dist/modules/auth/actions/verify-two-factor.action.mjs.map +1 -0
  289. package/dist/modules/auth/hooks/login.hook.mjs +13 -0
  290. package/dist/modules/auth/hooks/login.hook.mjs.map +1 -0
  291. package/dist/modules/auth/hooks/logout.hook.mjs +13 -0
  292. package/dist/modules/auth/hooks/logout.hook.mjs.map +1 -0
  293. package/dist/modules/auth/hooks/register.hook.mjs +13 -0
  294. package/dist/modules/auth/hooks/register.hook.mjs.map +1 -0
  295. package/dist/modules/auth/hooks/useManagementPermissions.mjs +41 -0
  296. package/dist/modules/auth/hooks/useManagementPermissions.mjs.map +1 -0
  297. package/dist/modules/auth/hooks/useUserQuery.mjs +63 -0
  298. package/dist/modules/auth/hooks/useUserQuery.mjs.map +1 -0
  299. package/dist/modules/auth/schema.mjs +1 -0
  300. package/dist/modules/auth/schema.mjs.map +1 -0
  301. package/dist/modules/auth/services/auth.service.mjs +341 -0
  302. package/dist/modules/auth/services/auth.service.mjs.map +1 -0
  303. package/dist/modules/auth/types/management-permission.type.mjs +1 -0
  304. package/dist/modules/auth/types/management-permission.type.mjs.map +1 -0
  305. package/dist/modules/auth/utils/assert-management-permission.mjs +42 -0
  306. package/dist/modules/auth/utils/assert-management-permission.mjs.map +1 -0
  307. package/dist/modules/auth/utils/assert-management-subscription.mjs +33 -0
  308. package/dist/modules/auth/utils/assert-management-subscription.mjs.map +1 -0
  309. package/dist/modules/auth/utils/assert-paid-subscription.mjs +40 -0
  310. package/dist/modules/auth/utils/assert-paid-subscription.mjs.map +1 -0
  311. package/dist/modules/auth/utils/assert-subscription-addon.mjs +35 -0
  312. package/dist/modules/auth/utils/assert-subscription-addon.mjs.map +1 -0
  313. package/dist/modules/auth/utils/build-wl-override.mjs +27 -0
  314. package/dist/modules/auth/utils/build-wl-override.mjs.map +1 -0
  315. package/dist/modules/auth/utils/get-user-context.mjs +25 -0
  316. package/dist/modules/auth/utils/get-user-context.mjs.map +1 -0
  317. package/dist/modules/cards/actions/create-card.action.mjs +10 -0
  318. package/dist/modules/cards/actions/create-card.action.mjs.map +1 -0
  319. package/dist/modules/cards/actions/list-cards.action.mjs +10 -0
  320. package/dist/modules/cards/actions/list-cards.action.mjs.map +1 -0
  321. package/dist/modules/cards/hooks/cards.hook.mjs +16 -0
  322. package/dist/modules/cards/hooks/cards.hook.mjs.map +1 -0
  323. package/dist/modules/cards/hooks/create-card.hook.mjs +18 -0
  324. package/dist/modules/cards/hooks/create-card.hook.mjs.map +1 -0
  325. package/dist/modules/cards/services/cards.service.mjs +44 -0
  326. package/dist/modules/cards/services/cards.service.mjs.map +1 -0
  327. package/dist/modules/cards/types.mjs +27 -0
  328. package/dist/modules/cards/types.mjs.map +1 -0
  329. package/dist/modules/ia-credits/actions/list-ia-credits.action.mjs +10 -0
  330. package/dist/modules/ia-credits/actions/list-ia-credits.action.mjs.map +1 -0
  331. package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs +76 -0
  332. package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs.map +1 -0
  333. package/dist/modules/ia-credits/services/ia-credits.service.mjs +31 -0
  334. package/dist/modules/ia-credits/services/ia-credits.service.mjs.map +1 -0
  335. package/dist/modules/ia-credits/types.mjs +25 -0
  336. package/dist/modules/ia-credits/types.mjs.map +1 -0
  337. package/dist/modules/plans/actions/find-plan-by-id.action.mjs +10 -0
  338. package/dist/modules/plans/actions/find-plan-by-id.action.mjs.map +1 -0
  339. package/dist/modules/plans/hooks/use-has-plan-addon.hook.mjs +13 -0
  340. package/dist/modules/plans/hooks/use-has-plan-addon.hook.mjs.map +1 -0
  341. package/dist/modules/plans/hooks/use-plan-by-id.hook.mjs +15 -0
  342. package/dist/modules/plans/hooks/use-plan-by-id.hook.mjs.map +1 -0
  343. package/dist/modules/plans/services/plans.service.mjs +34 -0
  344. package/dist/modules/plans/services/plans.service.mjs.map +1 -0
  345. package/dist/modules/plans/types/plan.type.mjs +20 -0
  346. package/dist/modules/plans/types/plan.type.mjs.map +1 -0
  347. package/dist/modules/projects/actions/add-project-user.action.mjs +10 -0
  348. package/dist/modules/projects/actions/add-project-user.action.mjs.map +1 -0
  349. package/dist/modules/projects/actions/list-all-account-users.action.mjs +10 -0
  350. package/dist/modules/projects/actions/list-all-account-users.action.mjs.map +1 -0
  351. package/dist/modules/projects/actions/list-available-users.action.mjs +10 -0
  352. package/dist/modules/projects/actions/list-available-users.action.mjs.map +1 -0
  353. package/dist/modules/projects/actions/list-project-users.action.mjs +10 -0
  354. package/dist/modules/projects/actions/list-project-users.action.mjs.map +1 -0
  355. package/dist/modules/projects/actions/remove-project-user.action.mjs +10 -0
  356. package/dist/modules/projects/actions/remove-project-user.action.mjs.map +1 -0
  357. package/dist/modules/projects/hooks/add-project-user.hook.mjs +61 -0
  358. package/dist/modules/projects/hooks/add-project-user.hook.mjs.map +1 -0
  359. package/dist/modules/projects/hooks/list-all-account-users.hook.mjs +35 -0
  360. package/dist/modules/projects/hooks/list-all-account-users.hook.mjs.map +1 -0
  361. package/dist/modules/projects/hooks/list-available-users.hook.mjs +34 -0
  362. package/dist/modules/projects/hooks/list-available-users.hook.mjs.map +1 -0
  363. package/dist/modules/projects/hooks/list-project-users.hook.mjs +34 -0
  364. package/dist/modules/projects/hooks/list-project-users.hook.mjs.map +1 -0
  365. package/dist/modules/projects/hooks/remove-project-user.hook.mjs +61 -0
  366. package/dist/modules/projects/hooks/remove-project-user.hook.mjs.map +1 -0
  367. package/dist/modules/projects/services/project-users.service.mjs +96 -0
  368. package/dist/modules/projects/services/project-users.service.mjs.map +1 -0
  369. package/dist/modules/projects/types.mjs +23 -0
  370. package/dist/modules/projects/types.mjs.map +1 -0
  371. package/dist/modules/subscriptions/actions/calculate-subscription.action.mjs +10 -0
  372. package/dist/modules/subscriptions/actions/calculate-subscription.action.mjs.map +1 -0
  373. package/dist/modules/subscriptions/actions/list-subscriptions.action.mjs +10 -0
  374. package/dist/modules/subscriptions/actions/list-subscriptions.action.mjs.map +1 -0
  375. package/dist/modules/subscriptions/actions/update-subscription-plan.action.mjs +12 -0
  376. package/dist/modules/subscriptions/actions/update-subscription-plan.action.mjs.map +1 -0
  377. package/dist/modules/subscriptions/constants/addons.constants.mjs +24 -0
  378. package/dist/modules/subscriptions/constants/addons.constants.mjs.map +1 -0
  379. package/dist/modules/subscriptions/constants/query-keys.constants.mjs +5 -0
  380. package/dist/modules/subscriptions/constants/query-keys.constants.mjs.map +1 -0
  381. package/dist/modules/subscriptions/hooks/calculate-subscription.hook.mjs +13 -0
  382. package/dist/modules/subscriptions/hooks/calculate-subscription.hook.mjs.map +1 -0
  383. package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs +17 -0
  384. package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs.map +1 -0
  385. package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs +17 -0
  386. package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs.map +1 -0
  387. package/dist/modules/subscriptions/hooks/update-subscription-plan.hook.mjs +22 -0
  388. package/dist/modules/subscriptions/hooks/update-subscription-plan.hook.mjs.map +1 -0
  389. package/dist/modules/subscriptions/hooks/use-cancelled-subscription-guard.mjs +37 -0
  390. package/dist/modules/subscriptions/hooks/use-cancelled-subscription-guard.mjs.map +1 -0
  391. package/dist/modules/subscriptions/services/subscriptions.service.mjs +75 -0
  392. package/dist/modules/subscriptions/services/subscriptions.service.mjs.map +1 -0
  393. package/dist/modules/subscriptions/types/billing-period.type.mjs +1 -0
  394. package/dist/modules/subscriptions/types/billing-period.type.mjs.map +1 -0
  395. package/dist/modules/subscriptions/types/calculate-subscription.type.mjs +72 -0
  396. package/dist/modules/subscriptions/types/calculate-subscription.type.mjs.map +1 -0
  397. package/dist/modules/subscriptions/types/subscription.type.mjs +57 -0
  398. package/dist/modules/subscriptions/types/subscription.type.mjs.map +1 -0
  399. package/dist/modules/subscriptions/utils/build-plan-extras.mjs +37 -0
  400. package/dist/modules/subscriptions/utils/build-plan-extras.mjs.map +1 -0
  401. package/dist/modules/subscriptions/utils/has-subscription-expired.mjs +10 -0
  402. package/dist/modules/subscriptions/utils/has-subscription-expired.mjs.map +1 -0
  403. package/dist/modules/subscriptions/utils/periodicity.mjs +48 -0
  404. package/dist/modules/subscriptions/utils/periodicity.mjs.map +1 -0
  405. package/dist/modules/subscriptions/utils/resolve-plan-extras-prices.mjs +14 -0
  406. package/dist/modules/subscriptions/utils/resolve-plan-extras-prices.mjs.map +1 -0
  407. package/dist/modules/users/action/find-user-by-id.action.mjs +10 -0
  408. package/dist/modules/users/action/find-user-by-id.action.mjs.map +1 -0
  409. package/dist/modules/users/action/list-messages.action.mjs +13 -0
  410. package/dist/modules/users/action/list-messages.action.mjs.map +1 -0
  411. package/dist/modules/users/action/mark-all-messages-as-read.action.mjs +10 -0
  412. package/dist/modules/users/action/mark-all-messages-as-read.action.mjs.map +1 -0
  413. package/dist/modules/users/action/mark-message-as-read.action.mjs +10 -0
  414. package/dist/modules/users/action/mark-message-as-read.action.mjs.map +1 -0
  415. package/dist/modules/users/hooks/messages.hook.mjs +57 -0
  416. package/dist/modules/users/hooks/messages.hook.mjs.map +1 -0
  417. package/dist/modules/users/schema/messages.schema.mjs +21 -0
  418. package/dist/modules/users/schema/messages.schema.mjs.map +1 -0
  419. package/dist/modules/users/schema.mjs +11 -0
  420. package/dist/modules/users/schema.mjs.map +1 -0
  421. package/dist/modules/users/services/messages.service.mjs +35 -0
  422. package/dist/modules/users/services/messages.service.mjs.map +1 -0
  423. package/dist/modules/users/services/user.service.mjs +52 -0
  424. package/dist/modules/users/services/user.service.mjs.map +1 -0
  425. package/dist/modules/whitelabel/actions/find-whitelabel.action.mjs +21 -0
  426. package/dist/modules/whitelabel/actions/find-whitelabel.action.mjs.map +1 -0
  427. package/dist/modules/whitelabel/actions/revalidate-whitelabel.action.mjs +19 -0
  428. package/dist/modules/whitelabel/actions/revalidate-whitelabel.action.mjs.map +1 -0
  429. package/dist/modules/whitelabel/schema.mjs +1 -0
  430. package/dist/modules/whitelabel/schema.mjs.map +1 -0
  431. package/dist/modules/whitelabel/services/whitelabel.service.mjs +146 -0
  432. package/dist/modules/whitelabel/services/whitelabel.service.mjs.map +1 -0
  433. package/dist/modules/whitelabel/utils/normalize-hostname.mjs +35 -0
  434. package/dist/modules/whitelabel/utils/normalize-hostname.mjs.map +1 -0
  435. package/dist/providers/auth.provider.mjs +114 -0
  436. package/dist/providers/auth.provider.mjs.map +1 -0
  437. package/dist/providers/query.provider.mjs +99 -0
  438. package/dist/providers/query.provider.mjs.map +1 -0
  439. package/dist/providers/whitelabel.provider.mjs +42 -0
  440. package/dist/providers/whitelabel.provider.mjs.map +1 -0
  441. package/dist/server.mjs +111 -0
  442. package/dist/server.mjs.map +1 -0
  443. package/dist/store/useAccountModals.mjs +18 -0
  444. package/dist/store/useAccountModals.mjs.map +1 -0
  445. package/dist/store/useBuyCreditsModal.mjs +16 -0
  446. package/dist/store/useBuyCreditsModal.mjs.map +1 -0
  447. package/dist/store/useDesktopSidebarStore.mjs +39 -0
  448. package/dist/store/useDesktopSidebarStore.mjs.map +1 -0
  449. package/dist/store/useMdSidebarStore.mjs +28 -0
  450. package/dist/store/useMdSidebarStore.mjs.map +1 -0
  451. package/dist/store/useMobileNavbarSheet.mjs +14 -0
  452. package/dist/store/useMobileNavbarSheet.mjs.map +1 -0
  453. package/dist/store/useModalManager.mjs +75 -0
  454. package/dist/store/useModalManager.mjs.map +1 -0
  455. package/dist/store/usePaidPlanRequiredModal.mjs +14 -0
  456. package/dist/store/usePaidPlanRequiredModal.mjs.map +1 -0
  457. package/dist/utils/browser/clipboard.mjs +36 -0
  458. package/dist/utils/browser/clipboard.mjs.map +1 -0
  459. package/dist/utils/constants/br-states.mjs +33 -0
  460. package/dist/utils/constants/br-states.mjs.map +1 -0
  461. package/dist/utils/countries.mjs +219 -0
  462. package/dist/utils/countries.mjs.map +1 -0
  463. package/dist/utils/file/index.mjs +9 -0
  464. package/dist/utils/file/index.mjs.map +1 -0
  465. package/dist/utils/format/masks.mjs +67 -0
  466. package/dist/utils/format/masks.mjs.map +1 -0
  467. package/dist/utils/intl/locales.mjs +12 -0
  468. package/dist/utils/intl/locales.mjs.map +1 -0
  469. package/dist/utils/safeServerAction.mjs +16 -0
  470. package/dist/utils/safeServerAction.mjs.map +1 -0
  471. package/dist/utils/validators/account.mjs +27 -0
  472. package/dist/utils/validators/account.mjs.map +1 -0
  473. package/dist/utils/validators/common.mjs +47 -0
  474. package/dist/utils/validators/common.mjs.map +1 -0
  475. package/dist/utils/withAction.mjs +13 -0
  476. package/dist/utils/withAction.mjs.map +1 -0
  477. package/package.json +1 -1
@@ -0,0 +1,162 @@
1
+ import { ApiError } from "./types";
2
+ import { findWhitelabel } from "../../modules/whitelabel/actions/find-whitelabel.action";
3
+ class ApiClient {
4
+ baseUrl;
5
+ apiVersion = "v1";
6
+ apiLocale = "pt-br";
7
+ omitApiVersion;
8
+ emitLogs = false;
9
+ constructor(baseUrl, options) {
10
+ this.baseUrl = baseUrl.replace(/\/$/, "");
11
+ this.omitApiVersion = options?.omitApiVersion ?? false;
12
+ this.emitLogs = options?.emitLogs ?? false;
13
+ }
14
+ async buildUrl(endpoint, whiteLabelId) {
15
+ const wlPath = this.omitApiVersion ? `/${this.apiLocale}/${whiteLabelId}` : `/${this.apiVersion}/${this.apiLocale}/${whiteLabelId}`;
16
+ const path = endpoint.startsWith("/") ? endpoint : `/${endpoint}`;
17
+ const url = `${this.baseUrl}${wlPath}${path}`;
18
+ if (this.emitLogs) {
19
+ console.log("[ApiClient] buildUrl", {
20
+ baseURL: this.baseUrl,
21
+ whiteLabelId,
22
+ endpoint,
23
+ fullUrl: url
24
+ });
25
+ }
26
+ return url;
27
+ }
28
+ async getDefaultHeaders(token, isFormData = false) {
29
+ if (this.emitLogs) {
30
+ console.log("[ApiClient] getDefaultHeaders", {
31
+ token: token.substring(0, 20) + "..."
32
+ });
33
+ }
34
+ const headers = {
35
+ authorization: token
36
+ };
37
+ if (!isFormData) {
38
+ headers["Content-Type"] = "application/json";
39
+ }
40
+ return headers;
41
+ }
42
+ async request(endpoint, config = {}) {
43
+ if (this.emitLogs) {
44
+ console.log("[ApiClient] request called", {
45
+ endpoint,
46
+ method: config.method
47
+ });
48
+ }
49
+ const { timeout = 3e4, responseType = "json", whiteLabelId: overrideWlId, authToken: overrideToken, ...fetchConfig } = config;
50
+ const controller = new AbortController();
51
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
52
+ try {
53
+ if (this.emitLogs) {
54
+ console.log("[ApiClient] Building URL and headers...");
55
+ }
56
+ const { id, token } = await findWhitelabel();
57
+ const [url, defaultHeaders] = await Promise.all([
58
+ this.buildUrl(endpoint, overrideWlId ?? id),
59
+ this.getDefaultHeaders(overrideToken ?? token, fetchConfig.body instanceof FormData)
60
+ ]);
61
+ if (this.emitLogs)
62
+ console.log("[ApiClient] Fetching", {
63
+ url,
64
+ method: fetchConfig.method,
65
+ headers: defaultHeaders
66
+ });
67
+ const response = await fetch(url, {
68
+ ...fetchConfig,
69
+ headers: {
70
+ ...defaultHeaders,
71
+ ...fetchConfig.headers
72
+ },
73
+ signal: controller.signal
74
+ });
75
+ if (this.emitLogs)
76
+ console.log("[ApiClient] Response received", {
77
+ status: response.status,
78
+ ok: response.ok
79
+ });
80
+ if (!response.ok) {
81
+ const errBody = await response.text();
82
+ let message = `HTTP error ${response.status} ${response.statusText} ${errBody}`;
83
+ let code = "HTTP_ERROR";
84
+ try {
85
+ const errorData = JSON.parse(errBody);
86
+ message = errorData.message?.message ?? errorData.message ?? message;
87
+ if (typeof errorData.code === "string") code = errorData.code;
88
+ } catch {
89
+ if (errBody.trim()) message = errBody.trim();
90
+ }
91
+ console.error("[ApiClient] Request failed", {
92
+ status: response.status,
93
+ message
94
+ });
95
+ throw new ApiError(message, code, response.status);
96
+ }
97
+ if (responseType === "text") {
98
+ return await response.text();
99
+ }
100
+ const data = await response.json();
101
+ if (this.emitLogs)
102
+ console.log("[ApiClient] Request successful", { hasData: !!data });
103
+ return data;
104
+ } catch (error) {
105
+ if (this.emitLogs) console.error("[ApiClient] Request error", { error });
106
+ if (error instanceof ApiError) {
107
+ throw error;
108
+ }
109
+ if (error instanceof Error) {
110
+ if (error.name === "AbortError") {
111
+ throw new ApiError("Tempo de requisi\xE7\xE3o excedido", "TIMEOUT", 408);
112
+ }
113
+ throw new ApiError(error.message, "NETWORK_ERROR", 0);
114
+ }
115
+ throw new ApiError("Erro desconhecido", "UNKNOWN_ERROR", 500);
116
+ } finally {
117
+ clearTimeout(timeoutId);
118
+ }
119
+ }
120
+ async get(endpoint, config) {
121
+ return this.request(endpoint, { ...config, method: "GET" });
122
+ }
123
+ async post(endpoint, data, config) {
124
+ return this.request(endpoint, {
125
+ ...config,
126
+ method: "POST",
127
+ body: data instanceof FormData ? data : data ? JSON.stringify(data) : void 0
128
+ });
129
+ }
130
+ async put(endpoint, data, config) {
131
+ return this.request(endpoint, {
132
+ ...config,
133
+ method: "PUT",
134
+ body: data instanceof FormData ? data : data ? JSON.stringify(data) : void 0
135
+ });
136
+ }
137
+ async patch(endpoint, data, config) {
138
+ return this.request(endpoint, {
139
+ ...config,
140
+ method: "PATCH",
141
+ body: data instanceof FormData ? data : data ? JSON.stringify(data) : void 0
142
+ });
143
+ }
144
+ async delete(endpoint, config) {
145
+ return this.request(endpoint, { ...config, method: "DELETE" });
146
+ }
147
+ }
148
+ const api = {
149
+ apps: new ApiClient(
150
+ process.env.GAPPS_R3_API_URL || "https://r3-api.greatapps.dev.br"
151
+ ),
152
+ pages: new ApiClient(
153
+ process.env.GPAGES_R3_API_URL || "https://r3-api.greatpages.dev.br"
154
+ )
155
+ };
156
+ const apiClient = api.apps;
157
+ export {
158
+ ApiClient,
159
+ api,
160
+ apiClient
161
+ };
162
+ //# sourceMappingURL=client.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 /** Habilita logs detalhados das requisições (útil para desenvolvimento) */\r\n emitLogs?: 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 /** Força um whiteLabelId específico na URL, ignorando o findWhitelabel(). */\r\n whiteLabelId?: number;\r\n /** Força um token específico no header Authorization, ignorando o findWhitelabel(). */\r\n authToken?: string;\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 private readonly emitLogs: boolean = false;\r\n\r\n constructor(baseUrl: string, options?: ApiClientOptions) {\r\n this.baseUrl = baseUrl.replace(/\\/$/, \"\");\r\n this.omitApiVersion = options?.omitApiVersion ?? false;\r\n this.emitLogs = options?.emitLogs ?? false;\r\n }\r\n\r\n private async buildUrl(\r\n endpoint: string,\r\n whiteLabelId: number,\r\n ): 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 if (this.emitLogs) {\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 }\r\n return url;\r\n }\r\n\r\n private async getDefaultHeaders(\r\n token: string,\r\n isFormData = false,\r\n ): Promise<HeadersInit> {\r\n if (this.emitLogs) {\r\n console.log(\"[ApiClient] getDefaultHeaders\", {\r\n token: token.substring(0, 20) + \"...\",\r\n });\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 if (this.emitLogs) {\r\n console.log(\"[ApiClient] request called\", {\r\n endpoint,\r\n method: config.method,\r\n });\r\n }\r\n\r\n const { timeout = 30000, responseType = \"json\", whiteLabelId: overrideWlId, authToken: overrideToken, ...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 if (this.emitLogs) {\r\n console.log(\"[ApiClient] Building URL and headers...\");\r\n }\r\n\r\n const { id, token } = await findWhitelabel();\r\n\r\n const [url, defaultHeaders] = await Promise.all([\r\n this.buildUrl(endpoint, overrideWlId ?? id),\r\n this.getDefaultHeaders(overrideToken ?? token, fetchConfig.body instanceof FormData),\r\n ]);\r\n\r\n if (this.emitLogs)\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 if (this.emitLogs)\r\n console.log(\"[ApiClient] Response received\", {\r\n status: response.status,\r\n ok: response.ok,\r\n });\r\n\r\n if (!response.ok) {\r\n const errBody = await response.text();\r\n let message = `HTTP error ${response.status} ${response.statusText} ${errBody}`;\r\n let code = \"HTTP_ERROR\";\r\n try {\r\n const errorData = JSON.parse(errBody) as Record<string, unknown>;\r\n // @ts-ignore -- msg pode ser string ou objeto com .message\r\n message = errorData.message?.message ?? errorData.message ?? 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\", {\r\n status: response.status,\r\n message,\r\n });\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 if (this.emitLogs)\r\n console.log(\"[ApiClient] Request successful\", { hasData: !!data });\r\n return data;\r\n } catch (error) {\r\n if (this.emitLogs) 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>(\r\n endpoint: string,\r\n data?: unknown,\r\n config?: RequestConfig,\r\n ): Promise<T> {\r\n return this.request<T>(endpoint, {\r\n ...config,\r\n method: \"POST\",\r\n body:\r\n data instanceof FormData\r\n ? data\r\n : data\r\n ? JSON.stringify(data)\r\n : undefined,\r\n });\r\n }\r\n\r\n async put<T>(\r\n endpoint: string,\r\n data?: unknown,\r\n config?: RequestConfig,\r\n ): Promise<T> {\r\n return this.request<T>(endpoint, {\r\n ...config,\r\n method: \"PUT\",\r\n body:\r\n data instanceof FormData\r\n ? data\r\n : data\r\n ? JSON.stringify(data)\r\n : undefined,\r\n });\r\n }\r\n\r\n async patch<T>(\r\n endpoint: string,\r\n data?: unknown,\r\n config?: RequestConfig,\r\n ): Promise<T> {\r\n return this.request<T>(endpoint, {\r\n ...config,\r\n method: \"PATCH\",\r\n body:\r\n data instanceof FormData\r\n ? data\r\n : data\r\n ? JSON.stringify(data)\r\n : 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(\r\n process.env.GAPPS_R3_API_URL || \"https://r3-api.greatapps.dev.br\",\r\n ),\r\n pages: new ApiClient(\r\n process.env.GPAGES_R3_API_URL || \"https://r3-api.greatpages.dev.br\",\r\n ),\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":"AAAA,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AAuB/B,MAAM,UAAU;AAAA,EACG;AAAA,EACA,aAAa;AAAA,EACb,YAAY;AAAA,EACZ;AAAA,EACA,WAAoB;AAAA,EAErC,YAAY,SAAiB,SAA4B;AACvD,SAAK,UAAU,QAAQ,QAAQ,OAAO,EAAE;AACxC,SAAK,iBAAiB,SAAS,kBAAkB;AACjD,SAAK,WAAW,SAAS,YAAY;AAAA,EACvC;AAAA,EAEA,MAAc,SACZ,UACA,cACiB;AACjB,UAAM,SAAS,KAAK,iBAChB,IAAI,KAAK,SAAS,IAAI,YAAY,KAClC,IAAI,KAAK,UAAU,IAAI,KAAK,SAAS,IAAI,YAAY;AACzD,UAAM,OAAO,SAAS,WAAW,GAAG,IAAI,WAAW,IAAI,QAAQ;AAC/D,UAAM,MAAM,GAAG,KAAK,OAAO,GAAG,MAAM,GAAG,IAAI;AAC3C,QAAI,KAAK,UAAU;AACjB,cAAQ,IAAI,wBAAwB;AAAA,QAClC,SAAS,KAAK;AAAA,QACd;AAAA,QACA;AAAA,QACA,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,kBACZ,OACA,aAAa,OACS;AACtB,QAAI,KAAK,UAAU;AACjB,cAAQ,IAAI,iCAAiC;AAAA,QAC3C,OAAO,MAAM,UAAU,GAAG,EAAE,IAAI;AAAA,MAClC,CAAC;AAAA,IACH;AAEA,UAAM,UAAuB;AAAA,MAC3B,eAAe;AAAA,IACjB;AAEA,QAAI,CAAC,YAAY;AACf,cAAQ,cAAc,IAAI;AAAA,IAC5B;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,QAAW,UAAkB,SAAwB,CAAC,GAAe;AACzE,QAAI,KAAK,UAAU;AACjB,cAAQ,IAAI,8BAA8B;AAAA,QACxC;AAAA,QACA,QAAQ,OAAO;AAAA,MACjB,CAAC;AAAA,IACH;AAEA,UAAM,EAAE,UAAU,KAAO,eAAe,QAAQ,cAAc,cAAc,WAAW,eAAe,GAAG,YAAY,IAAI;AAEzH,UAAM,aAAa,IAAI,gBAAgB;AACvC,UAAM,YAAY,WAAW,MAAM,WAAW,MAAM,GAAG,OAAO;AAE9D,QAAI;AACF,UAAI,KAAK,UAAU;AACjB,gBAAQ,IAAI,yCAAyC;AAAA,MACvD;AAEA,YAAM,EAAE,IAAI,MAAM,IAAI,MAAM,eAAe;AAE3C,YAAM,CAAC,KAAK,cAAc,IAAI,MAAM,QAAQ,IAAI;AAAA,QAC9C,KAAK,SAAS,UAAU,gBAAgB,EAAE;AAAA,QAC1C,KAAK,kBAAkB,iBAAiB,OAAO,YAAY,gBAAgB,QAAQ;AAAA,MACrF,CAAC;AAED,UAAI,KAAK;AACP,gBAAQ,IAAI,wBAAwB;AAAA,UAClC;AAAA,UACA,QAAQ,YAAY;AAAA,UACpB,SAAS;AAAA,QACX,CAAC;AAEH,YAAM,WAAW,MAAM,MAAM,KAAK;AAAA,QAChC,GAAG;AAAA,QACH,SAAS;AAAA,UACP,GAAG;AAAA,UACH,GAAG,YAAY;AAAA,QACjB;AAAA,QACA,QAAQ,WAAW;AAAA,MACrB,CAAC;AAED,UAAI,KAAK;AACP,gBAAQ,IAAI,iCAAiC;AAAA,UAC3C,QAAQ,SAAS;AAAA,UACjB,IAAI,SAAS;AAAA,QACf,CAAC;AAEH,UAAI,CAAC,SAAS,IAAI;AAChB,cAAM,UAAU,MAAM,SAAS,KAAK;AACpC,YAAI,UAAU,cAAc,SAAS,MAAM,IAAI,SAAS,UAAU,IAAI,OAAO;AAC7E,YAAI,OAAO;AACX,YAAI;AACF,gBAAM,YAAY,KAAK,MAAM,OAAO;AAEpC,oBAAU,UAAU,SAAS,WAAW,UAAU,WAAW;AAC7D,cAAI,OAAO,UAAU,SAAS,SAAU,QAAO,UAAU;AAAA,QAC3D,QAAQ;AACN,cAAI,QAAQ,KAAK,EAAG,WAAU,QAAQ,KAAK;AAAA,QAC7C;AACA,gBAAQ,MAAM,8BAA8B;AAAA,UAC1C,QAAQ,SAAS;AAAA,UACjB;AAAA,QACF,CAAC;AACD,cAAM,IAAI,SAAS,SAAS,MAAM,SAAS,MAAM;AAAA,MACnD;AAEA,UAAI,iBAAiB,QAAQ;AAC3B,eAAQ,MAAM,SAAS,KAAK;AAAA,MAC9B;AAEA,YAAM,OAAQ,MAAM,SAAS,KAAK;AAClC,UAAI,KAAK;AACP,gBAAQ,IAAI,kCAAkC,EAAE,SAAS,CAAC,CAAC,KAAK,CAAC;AACnE,aAAO;AAAA,IACT,SAAS,OAAO;AACd,UAAI,KAAK,SAAU,SAAQ,MAAM,6BAA6B,EAAE,MAAM,CAAC;AAEvE,UAAI,iBAAiB,UAAU;AAC7B,cAAM;AAAA,MACR;AAEA,UAAI,iBAAiB,OAAO;AAC1B,YAAI,MAAM,SAAS,cAAc;AAC/B,gBAAM,IAAI,SAAS,sCAAgC,WAAW,GAAG;AAAA,QACnE;AACA,cAAM,IAAI,SAAS,MAAM,SAAS,iBAAiB,CAAC;AAAA,MACtD;AAEA,YAAM,IAAI,SAAS,qBAAqB,iBAAiB,GAAG;AAAA,IAC9D,UAAE;AACA,mBAAa,SAAS;AAAA,IACxB;AAAA,EACF;AAAA,EAEA,MAAM,IAAO,UAAkB,QAAoC;AACjE,WAAO,KAAK,QAAW,UAAU,EAAE,GAAG,QAAQ,QAAQ,MAAM,CAAC;AAAA,EAC/D;AAAA,EAEA,MAAM,KACJ,UACA,MACA,QACY;AACZ,WAAO,KAAK,QAAW,UAAU;AAAA,MAC/B,GAAG;AAAA,MACH,QAAQ;AAAA,MACR,MACE,gBAAgB,WACZ,OACA,OACE,KAAK,UAAU,IAAI,IACnB;AAAA,IACV,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,IACJ,UACA,MACA,QACY;AACZ,WAAO,KAAK,QAAW,UAAU;AAAA,MAC/B,GAAG;AAAA,MACH,QAAQ;AAAA,MACR,MACE,gBAAgB,WACZ,OACA,OACE,KAAK,UAAU,IAAI,IACnB;AAAA,IACV,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,MACJ,UACA,MACA,QACY;AACZ,WAAO,KAAK,QAAW,UAAU;AAAA,MAC/B,GAAG;AAAA,MACH,QAAQ;AAAA,MACR,MACE,gBAAgB,WACZ,OACA,OACE,KAAK,UAAU,IAAI,IACnB;AAAA,IACV,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,OAAU,UAAkB,QAAoC;AACpE,WAAO,KAAK,QAAW,UAAU,EAAE,GAAG,QAAQ,QAAQ,SAAS,CAAC;AAAA,EAClE;AACF;AAEA,MAAM,MAAM;AAAA,EACV,MAAM,IAAI;AAAA,IACR,QAAQ,IAAI,oBAAoB;AAAA,EAClC;AAAA,EACA,OAAO,IAAI;AAAA,IACT,QAAQ,IAAI,qBAAqB;AAAA,EACnC;AACF;AAGO,MAAM,YAAY,IAAI;","names":[]}
@@ -0,0 +1,31 @@
1
+ import z from "zod";
2
+ const PaginationParamsSchema = z.object({
3
+ page: z.number().min(1).optional().default(1),
4
+ limit: z.number().optional().default(20)
5
+ });
6
+ const SearchParamsSchema = z.object({
7
+ search: z.string().optional()
8
+ });
9
+ const SortParamsSchema = z.object({
10
+ sort: z.string().optional()
11
+ });
12
+ class ApiError extends Error {
13
+ code;
14
+ statusCode;
15
+ constructor(message, code = "UNKNOWN_ERROR", statusCode = 500) {
16
+ super(message);
17
+ this.name = "ApiError";
18
+ this.code = code;
19
+ this.statusCode = statusCode;
20
+ }
21
+ static isApiError(error) {
22
+ return error instanceof ApiError;
23
+ }
24
+ }
25
+ export {
26
+ ApiError,
27
+ PaginationParamsSchema,
28
+ SearchParamsSchema,
29
+ SortParamsSchema
30
+ };
31
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/infra/api/types.ts"],"sourcesContent":["import z from 'zod';\r\n\r\nexport const PaginationParamsSchema = z.object({\n page: z.number().min(1).optional().default(1),\n limit: z.number().optional().default(20),\n});\n\r\nexport interface PaginationParams extends z.infer<typeof PaginationParamsSchema> {}\r\n\r\nexport const SearchParamsSchema = z.object({\r\n search: z.string().optional(),\r\n});\r\n\r\nexport interface SearchParams extends z.infer<typeof SearchParamsSchema> {}\r\n\r\nexport const SortParamsSchema = z.object({\r\n sort: z.string().optional(),\r\n});\r\n\r\nexport interface SortParams extends z.infer<typeof SortParamsSchema> {}\r\n\r\nexport interface ApiSuccessResult<T> {\r\n status: 1;\r\n data?: T;\r\n}\r\n\r\nexport interface ApiPaginatedSuccessResult<T> extends Omit<ApiSuccessResult<T>, 'data'> {\r\n data: T[];\r\n total: number;\r\n}\r\n\r\nexport interface ApiErrorResult {\r\n status: 0;\r\n message: string;\r\n}\r\n\r\nexport type ApiActionResult<T> = ApiSuccessResult<T> | ApiErrorResult;\r\nexport type ApiPaginatedActionResult<T> = ApiPaginatedSuccessResult<T> | ApiErrorResult;\r\n\r\nexport interface SuccessResult<T> {\r\n success: true;\r\n data?: T;\r\n total?: number;\r\n}\r\n\r\nexport interface PaginatedSuccessResult<T> extends Omit<SuccessResult<T>, 'data'> {\r\n data: T[];\r\n total: number;\r\n}\r\n\r\nexport interface ErrorResult {\r\n success: false;\r\n error?: string;\r\n}\r\n\r\nexport type ActionResult<T> = SuccessResult<T> | ErrorResult;\r\nexport type PaginatedActionResult<T> = PaginatedSuccessResult<T> | ErrorResult;\r\n\r\nexport class ApiError extends Error {\r\n public readonly code: string;\r\n public readonly statusCode: number;\r\n\r\n constructor(message: string, code: string = 'UNKNOWN_ERROR', statusCode: number = 500) {\r\n super(message);\r\n this.name = 'ApiError';\r\n this.code = code;\r\n this.statusCode = statusCode;\r\n }\r\n\r\n static isApiError(error: unknown): error is ApiError {\r\n return error instanceof ApiError;\r\n }\r\n}\r\n\r\nexport interface ApiResponse<T = unknown> {\r\n status: 0 | 1;\r\n message?: string;\r\n data?: T;\r\n}\r\n"],"mappings":"AAAA,OAAO,OAAO;AAEP,MAAM,yBAAyB,EAAE,OAAO;AAAA,EAC7C,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC;AAAA,EAC5C,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE;AACzC,CAAC;AAIM,MAAM,qBAAqB,EAAE,OAAO;AAAA,EACzC,QAAQ,EAAE,OAAO,EAAE,SAAS;AAC9B,CAAC;AAIM,MAAM,mBAAmB,EAAE,OAAO;AAAA,EACvC,MAAM,EAAE,OAAO,EAAE,SAAS;AAC5B,CAAC;AAyCM,MAAM,iBAAiB,MAAM;AAAA,EAClB;AAAA,EACA;AAAA,EAEhB,YAAY,SAAiB,OAAe,iBAAiB,aAAqB,KAAK;AACrF,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,aAAa;AAAA,EACpB;AAAA,EAEA,OAAO,WAAW,OAAmC;AACnD,WAAO,iBAAiB;AAAA,EAC1B;AACF;","names":[]}
@@ -0,0 +1,27 @@
1
+ import { headers } from "next/headers";
2
+ async function getClientInfoFromRequest(request) {
3
+ let headerStore;
4
+ if (request) {
5
+ headerStore = request.headers;
6
+ } else {
7
+ const nextHeaders = await headers();
8
+ headerStore = nextHeaders;
9
+ }
10
+ return {
11
+ location: {
12
+ continent: headerStore.get("cf-ipcountry") || headerStore.get("x-vercel-ip-country") || "Unknown",
13
+ country: headerStore.get("x-vercel-ip-country") || "Unknown",
14
+ region: headerStore.get("x-vercel-ip-country-region") || "Unknown",
15
+ city: headerStore.get("x-vercel-ip-city") || "Unknown",
16
+ latitude: headerStore.get("x-vercel-ip-latitude") || "0",
17
+ longitude: headerStore.get("x-vercel-ip-longitude") || "0"
18
+ },
19
+ ip: headerStore.get("cf-connecting-ip") || headerStore.get("x-forwarded-for") || headerStore.get("x-real-ip") || "Unknown",
20
+ timezone: headerStore.get("cf-timezone") || "America/Sao_Paulo",
21
+ agent: headerStore.get("user-agent") || "Unknown"
22
+ };
23
+ }
24
+ export {
25
+ getClientInfoFromRequest
26
+ };
27
+ //# sourceMappingURL=client-info.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/infra/utils/client-info.ts"],"sourcesContent":["import { headers } from 'next/headers';\r\nimport { NextRequest } from 'next/server';\r\nimport { ClientInfo } from '../../modules/auth/schema';\r\n\r\nexport async function getClientInfoFromRequest(request?: NextRequest): Promise<ClientInfo> {\r\n let headerStore: Headers;\r\n\r\n if (request) {\r\n // Middleware context\r\n headerStore = request.headers;\r\n } else {\r\n // Server action context\r\n const nextHeaders = await headers();\r\n headerStore = nextHeaders as unknown as Headers;\r\n }\r\n\r\n return {\r\n location: {\r\n continent:\r\n headerStore.get('cf-ipcountry') || headerStore.get('x-vercel-ip-country') || 'Unknown',\r\n country: headerStore.get('x-vercel-ip-country') || 'Unknown',\r\n region: headerStore.get('x-vercel-ip-country-region') || 'Unknown',\r\n city: headerStore.get('x-vercel-ip-city') || 'Unknown',\r\n latitude: headerStore.get('x-vercel-ip-latitude') || '0',\r\n longitude: headerStore.get('x-vercel-ip-longitude') || '0',\r\n },\r\n ip:\r\n headerStore.get('cf-connecting-ip') ||\r\n headerStore.get('x-forwarded-for') ||\r\n headerStore.get('x-real-ip') ||\r\n 'Unknown',\r\n timezone: headerStore.get('cf-timezone') || 'America/Sao_Paulo',\r\n agent: headerStore.get('user-agent') || 'Unknown',\r\n };\r\n}\r\n"],"mappings":"AAAA,SAAS,eAAe;AAIxB,eAAsB,yBAAyB,SAA4C;AACzF,MAAI;AAEJ,MAAI,SAAS;AAEX,kBAAc,QAAQ;AAAA,EACxB,OAAO;AAEL,UAAM,cAAc,MAAM,QAAQ;AAClC,kBAAc;AAAA,EAChB;AAEA,SAAO;AAAA,IACL,UAAU;AAAA,MACR,WACE,YAAY,IAAI,cAAc,KAAK,YAAY,IAAI,qBAAqB,KAAK;AAAA,MAC/E,SAAS,YAAY,IAAI,qBAAqB,KAAK;AAAA,MACnD,QAAQ,YAAY,IAAI,4BAA4B,KAAK;AAAA,MACzD,MAAM,YAAY,IAAI,kBAAkB,KAAK;AAAA,MAC7C,UAAU,YAAY,IAAI,sBAAsB,KAAK;AAAA,MACrD,WAAW,YAAY,IAAI,uBAAuB,KAAK;AAAA,IACzD;AAAA,IACA,IACE,YAAY,IAAI,kBAAkB,KAClC,YAAY,IAAI,iBAAiB,KACjC,YAAY,IAAI,WAAW,KAC3B;AAAA,IACF,UAAU,YAAY,IAAI,aAAa,KAAK;AAAA,IAC5C,OAAO,YAAY,IAAI,YAAY,KAAK;AAAA,EAC1C;AACF;","names":[]}
@@ -0,0 +1,9 @@
1
+ import { clsx } from "clsx";
2
+ import { twMerge } from "tailwind-merge";
3
+ function cn(...inputs) {
4
+ return twMerge(clsx(inputs));
5
+ }
6
+ export {
7
+ cn
8
+ };
9
+ //# sourceMappingURL=clsx.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/infra/utils/clsx.ts"],"sourcesContent":["import { clsx, type ClassValue } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n"],"mappings":"AAAA,SAAS,YAA6B;AACtC,SAAS,eAAe;AAEjB,SAAS,MAAM,QAAsB;AAC1C,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;","names":[]}
@@ -0,0 +1,11 @@
1
+ function formatShortDate(date) {
2
+ if (!date) return "--";
3
+ const d = new Date(date);
4
+ const day = String(d.getDate()).padStart(2, "0");
5
+ const month = String(d.getMonth() + 1).padStart(2, "0");
6
+ return `${day}/${month}`;
7
+ }
8
+ export {
9
+ formatShortDate
10
+ };
11
+ //# sourceMappingURL=date.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/infra/utils/date.ts"],"sourcesContent":["export function formatShortDate(date: Date | string | null | undefined): string {\n if (!date) return '--';\n const d = new Date(date);\n const day = String(d.getDate()).padStart(2, '0');\n const month = String(d.getMonth() + 1).padStart(2, '0');\n return `${day}/${month}`;\n}\n"],"mappings":"AAAO,SAAS,gBAAgB,MAAgD;AAC9E,MAAI,CAAC,KAAM,QAAO;AAClB,QAAM,IAAI,IAAI,KAAK,IAAI;AACvB,QAAM,MAAM,OAAO,EAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG;AAC/C,QAAM,QAAQ,OAAO,EAAE,SAAS,IAAI,CAAC,EAAE,SAAS,GAAG,GAAG;AACtD,SAAO,GAAG,GAAG,IAAI,KAAK;AACxB;","names":[]}
@@ -0,0 +1,21 @@
1
+ function buildQueryParams(params) {
2
+ if (!params) {
3
+ return "";
4
+ }
5
+ const queryParams = new URLSearchParams();
6
+ for (const [key, value] of Object.entries(params)) {
7
+ if (value === null || value === void 0 || value === "") {
8
+ continue;
9
+ }
10
+ if (Array.isArray(value)) {
11
+ queryParams.set(key, value.join(","));
12
+ } else {
13
+ queryParams.set(key, value.toString());
14
+ }
15
+ }
16
+ return queryParams.toString();
17
+ }
18
+ export {
19
+ buildQueryParams
20
+ };
21
+ //# sourceMappingURL=params.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/infra/utils/params.ts"],"sourcesContent":["export function buildQueryParams(\r\n params?: Record<\r\n string,\r\n string | number | boolean | Date | null | undefined | string[] | number[] | boolean[] | Date[]\r\n >\r\n) {\r\n if (!params) {\r\n return '';\r\n }\r\n\r\n const queryParams = new URLSearchParams();\r\n\r\n for (const [key, value] of Object.entries(params)) {\r\n if (value === null || value === undefined || value === '') {\r\n continue;\r\n }\r\n\r\n if (Array.isArray(value)) {\r\n queryParams.set(key, value.join(','));\r\n } else {\r\n\r\n queryParams.set(key, value.toString());\r\n }\r\n }\r\n\r\n return queryParams.toString();\r\n}\r\n"],"mappings":"AAAO,SAAS,iBACd,QAIA;AACA,MAAI,CAAC,QAAQ;AACX,WAAO;AAAA,EACT;AAEA,QAAM,cAAc,IAAI,gBAAgB;AAExC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjD,QAAI,UAAU,QAAQ,UAAU,UAAa,UAAU,IAAI;AACzD;AAAA,IACF;AAEA,QAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,kBAAY,IAAI,KAAK,MAAM,KAAK,GAAG,CAAC;AAAA,IACtC,OAAO;AAEL,kBAAY,IAAI,KAAK,MAAM,SAAS,CAAC;AAAA,IACvC;AAAA,EACF;AAEA,SAAO,YAAY,SAAS;AAC9B;","names":[]}
@@ -0,0 +1,24 @@
1
+ function parseSchema(schema, data) {
2
+ if (Array.isArray(data)) {
3
+ return data.map((item) => schema.parse(item));
4
+ }
5
+ return schema.parse(data);
6
+ }
7
+ function parseResult(schema, result) {
8
+ if (!result.data) return result;
9
+ if (Array.isArray(result.data)) {
10
+ return {
11
+ ...result,
12
+ data: result.data.map((item) => schema.parse(item))
13
+ };
14
+ }
15
+ return {
16
+ ...result,
17
+ data: schema.parse(result.data)
18
+ };
19
+ }
20
+ export {
21
+ parseResult,
22
+ parseSchema
23
+ };
24
+ //# sourceMappingURL=parser.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/infra/utils/parser.ts"],"sourcesContent":["import z, { ZodTypeAny } from \"zod\";\nimport { PaginatedSuccessResult, SuccessResult } from \"../api/types\";\n\n/* Overloads */\nexport function parseSchema<T extends ZodTypeAny>(\n schema: T,\n data: unknown[]\n): z.infer<T>[];\n\nexport function parseSchema<T extends ZodTypeAny>(\n schema: T,\n data: unknown\n): z.infer<T>;\n\nexport function parseSchema<T extends ZodTypeAny>(\n schema: T,\n data: unknown | unknown[]\n) {\n if (Array.isArray(data)) {\n return data.map(item => schema.parse(item));\n }\n\n return schema.parse(data);\n}\n\nexport function parseResult<T extends ZodTypeAny>(\n schema: T,\n result: PaginatedSuccessResult<unknown>\n): PaginatedSuccessResult<z.infer<T>>;\n\nexport function parseResult<T extends ZodTypeAny>(\n schema: T,\n result: SuccessResult<unknown>\n): SuccessResult<z.infer<T>>;\n\nexport function parseResult<T extends ZodTypeAny>(\n schema: T,\n result: SuccessResult<unknown> | PaginatedSuccessResult<unknown>\n) {\n if (!result.data) return result;\n\n if (Array.isArray(result.data)) {\n return {\n ...result,\n data: result.data.map(item => schema.parse(item)),\n };\n }\n\n return {\n ...result,\n data: schema.parse(result.data),\n };\n}"],"mappings":"AAcO,SAAS,YACZ,QACA,MACF;AACE,MAAI,MAAM,QAAQ,IAAI,GAAG;AACrB,WAAO,KAAK,IAAI,UAAQ,OAAO,MAAM,IAAI,CAAC;AAAA,EAC9C;AAEA,SAAO,OAAO,MAAM,IAAI;AAC5B;AAYO,SAAS,YACZ,QACA,QACF;AACE,MAAI,CAAC,OAAO,KAAM,QAAO;AAEzB,MAAI,MAAM,QAAQ,OAAO,IAAI,GAAG;AAC5B,WAAO;AAAA,MACH,GAAG;AAAA,MACH,MAAM,OAAO,KAAK,IAAI,UAAQ,OAAO,MAAM,IAAI,CAAC;AAAA,IACpD;AAAA,EACJ;AAEA,SAAO;AAAA,IACH,GAAG;AAAA,IACH,MAAM,OAAO,MAAM,OAAO,IAAI;AAAA,EAClC;AACJ;","names":[]}
@@ -0,0 +1,20 @@
1
+ const calculatePercentage = (current, total) => {
2
+ if (total === 0) return 0;
3
+ return current / total * 100;
4
+ };
5
+ const calculateCircumference = (radius) => {
6
+ return 2 * Math.PI * radius;
7
+ };
8
+ const calculateCircularProgressOffset = (percentage, circumference) => {
9
+ return circumference - percentage / 100 * circumference;
10
+ };
11
+ const calculateRadius = (size, strokeWidth) => {
12
+ return (size - strokeWidth) / 2;
13
+ };
14
+ export {
15
+ calculateCircularProgressOffset,
16
+ calculateCircumference,
17
+ calculatePercentage,
18
+ calculateRadius
19
+ };
20
+ //# sourceMappingURL=percentage.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/infra/utils/percentage.ts"],"sourcesContent":["/**\n * Calcula percentual de um valor em relação ao total\n * @param current - Valor atual\n * @param total - Valor total\n * @returns Percentual (0-100)\n */\nexport const calculatePercentage = (current: number, total: number): number => {\n if (total === 0) return 0;\n return (current / total) * 100;\n};\n\n/**\n * Calcula a circunferência de um círculo\n * @param radius - Raio do círculo\n * @returns Circunferência\n */\nexport const calculateCircumference = (radius: number): number => {\n return 2 * Math.PI * radius;\n};\n\n/**\n * Calcula o offset para circular progress\n * @param percentage - Percentual de progresso (0-100)\n * @param circumference - Circunferência do círculo\n * @returns Valor do offset\n */\nexport const calculateCircularProgressOffset = (\n percentage: number,\n circumference: number\n): number => {\n return circumference - (percentage / 100) * circumference;\n};\n\n/**\n * Calcula raio de círculo baseado no tamanho e stroke\n * @param size - Tamanho total\n * @param strokeWidth - Largura do stroke\n * @returns Raio calculado\n */\nexport const calculateRadius = (size: number, strokeWidth: number): number => {\n return (size - strokeWidth) / 2;\n};\n"],"mappings":"AAMO,MAAM,sBAAsB,CAAC,SAAiB,UAA0B;AAC7E,MAAI,UAAU,EAAG,QAAO;AACxB,SAAQ,UAAU,QAAS;AAC7B;AAOO,MAAM,yBAAyB,CAAC,WAA2B;AAChE,SAAO,IAAI,KAAK,KAAK;AACvB;AAQO,MAAM,kCAAkC,CAC7C,YACA,kBACW;AACX,SAAO,gBAAiB,aAAa,MAAO;AAC9C;AAQO,MAAM,kBAAkB,CAAC,MAAc,gBAAgC;AAC5E,UAAQ,OAAO,eAAe;AAChC;","names":[]}
@@ -0,0 +1,10 @@
1
+ import { createAuthMiddleware } from "./middlewares/create-auth-middleware";
2
+ import { createMiddlewareChain } from "./middlewares/chain";
3
+ import { continueChain, stopChain } from "./middlewares/types";
4
+ export {
5
+ continueChain,
6
+ createAuthMiddleware,
7
+ createMiddlewareChain,
8
+ stopChain
9
+ };
10
+ //# sourceMappingURL=middleware.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/middleware.ts"],"sourcesContent":["export { createAuthMiddleware } from './middlewares/create-auth-middleware';\nexport { createMiddlewareChain } from './middlewares/chain';\nexport type { MiddlewareConfig, MiddlewareFunction, MiddlewareResult } from './middlewares/types';\nexport { continueChain, stopChain } from './middlewares/types';\n"],"mappings":"AAAA,SAAS,4BAA4B;AACrC,SAAS,6BAA6B;AAEtC,SAAS,eAAe,iBAAiB;","names":[]}
@@ -0,0 +1,37 @@
1
+ import { NextResponse } from "next/server";
2
+ function shouldProcessPath(pathname, config) {
3
+ const { excludePaths, includePaths } = config;
4
+ if (excludePaths?.length) {
5
+ const isExcluded = excludePaths.some(
6
+ (path) => pathname === path || pathname.startsWith(`${path}/`)
7
+ );
8
+ if (isExcluded) return false;
9
+ }
10
+ if (includePaths?.length) {
11
+ return includePaths.some((path) => pathname === path || pathname.startsWith(`${path}/`));
12
+ }
13
+ return true;
14
+ }
15
+ function createMiddlewareChain(middlewares) {
16
+ return async function chainedMiddleware(request) {
17
+ const { pathname } = request.nextUrl;
18
+ let currentRequest = request;
19
+ for (const middleware of middlewares) {
20
+ if (!shouldProcessPath(pathname, middleware)) {
21
+ continue;
22
+ }
23
+ const result = await middleware.handler(currentRequest);
24
+ if (result.type === "response") {
25
+ return result.response;
26
+ }
27
+ if (result.request) {
28
+ currentRequest = result.request;
29
+ }
30
+ }
31
+ return NextResponse.next();
32
+ };
33
+ }
34
+ export {
35
+ createMiddlewareChain
36
+ };
37
+ //# sourceMappingURL=chain.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/middlewares/chain.ts"],"sourcesContent":["import { NextRequest, NextResponse } from 'next/server';\r\n\r\nimport { MiddlewareConfig } from './types';\r\n\r\nfunction shouldProcessPath(pathname: string, config: MiddlewareConfig): boolean {\r\n const { excludePaths, includePaths } = config;\r\n\r\n if (excludePaths?.length) {\r\n const isExcluded = excludePaths.some(\r\n (path) => pathname === path || pathname.startsWith(`${path}/`)\r\n );\r\n if (isExcluded) return false;\r\n }\r\n\r\n if (includePaths?.length) {\r\n return includePaths.some((path) => pathname === path || pathname.startsWith(`${path}/`));\r\n }\r\n\r\n return true;\r\n}\r\n\r\nexport function createMiddlewareChain(middlewares: MiddlewareConfig[]) {\r\n return async function chainedMiddleware(request: NextRequest): Promise<NextResponse> {\r\n const { pathname } = request.nextUrl;\r\n let currentRequest = request;\r\n\r\n for (const middleware of middlewares) {\r\n if (!shouldProcessPath(pathname, middleware)) {\r\n continue;\r\n }\r\n\r\n const result = await middleware.handler(currentRequest);\r\n\r\n if (result.type === 'response') {\r\n return result.response;\r\n }\r\n\r\n if (result.request) {\r\n currentRequest = result.request;\r\n }\r\n }\r\n\r\n return NextResponse.next();\r\n };\r\n}\r\n"],"mappings":"AAAA,SAAsB,oBAAoB;AAI1C,SAAS,kBAAkB,UAAkB,QAAmC;AAC9E,QAAM,EAAE,cAAc,aAAa,IAAI;AAEvC,MAAI,cAAc,QAAQ;AACxB,UAAM,aAAa,aAAa;AAAA,MAC9B,CAAC,SAAS,aAAa,QAAQ,SAAS,WAAW,GAAG,IAAI,GAAG;AAAA,IAC/D;AACA,QAAI,WAAY,QAAO;AAAA,EACzB;AAEA,MAAI,cAAc,QAAQ;AACxB,WAAO,aAAa,KAAK,CAAC,SAAS,aAAa,QAAQ,SAAS,WAAW,GAAG,IAAI,GAAG,CAAC;AAAA,EACzF;AAEA,SAAO;AACT;AAEO,SAAS,sBAAsB,aAAiC;AACrE,SAAO,eAAe,kBAAkB,SAA6C;AACnF,UAAM,EAAE,SAAS,IAAI,QAAQ;AAC7B,QAAI,iBAAiB;AAErB,eAAW,cAAc,aAAa;AACpC,UAAI,CAAC,kBAAkB,UAAU,UAAU,GAAG;AAC5C;AAAA,MACF;AAEA,YAAM,SAAS,MAAM,WAAW,QAAQ,cAAc;AAEtD,UAAI,OAAO,SAAS,YAAY;AAC9B,eAAO,OAAO;AAAA,MAChB;AAEA,UAAI,OAAO,SAAS;AAClB,yBAAiB,OAAO;AAAA,MAC1B;AAAA,IACF;AAEA,WAAO,aAAa,KAAK;AAAA,EAC3B;AACF;","names":[]}
@@ -0,0 +1,32 @@
1
+ import { NextResponse } from "next/server";
2
+ import { continueChain, stopChain } from "./types";
3
+ import { whitelabelService } from "../modules/whitelabel/services/whitelabel.service";
4
+ function isRouteEquals(pathname, routes) {
5
+ return routes.some((route) => pathname === route || pathname.startsWith(`${route}/`));
6
+ }
7
+ function createAuthMiddleware(options) {
8
+ return async (request) => {
9
+ const { pathname } = request.nextUrl;
10
+ const token = process.env.DUMMY_AUTH_TOKEN || request.cookies.get("greatapps")?.value;
11
+ const isPublicRoute = isRouteEquals(pathname, options?.publicRoutes || []);
12
+ const isAuthRoute = isRouteEquals(pathname, options?.authRoutes || []);
13
+ if (token && isAuthRoute) {
14
+ return stopChain(NextResponse.redirect(new URL("/", request.url)));
15
+ }
16
+ if (!token && !isPublicRoute && !isAuthRoute) {
17
+ const host = request.headers.get("host") || "";
18
+ const whitelabel = await whitelabelService.getTokenByDomain(host).catch(() => null);
19
+ const accountsUrl = whitelabel?.accounts_url;
20
+ const loginUrl = accountsUrl ? new URL("/login", accountsUrl) : new URL("/login", request.url);
21
+ if (pathname !== "/") {
22
+ loginUrl.searchParams.set("redirect", pathname);
23
+ }
24
+ return stopChain(NextResponse.redirect(loginUrl));
25
+ }
26
+ return continueChain();
27
+ };
28
+ }
29
+ export {
30
+ createAuthMiddleware
31
+ };
32
+ //# sourceMappingURL=create-auth-middleware.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/middlewares/create-auth-middleware.ts"],"sourcesContent":["import { NextRequest, NextResponse } from 'next/server';\r\n\r\nimport { continueChain, MiddlewareConfig, MiddlewareFunction, MiddlewareResult, stopChain } from './types';\r\nimport { whitelabelService } from '../modules/whitelabel/services/whitelabel.service';\r\n\r\nfunction isRouteEquals(pathname: string, routes: string[]): boolean {\r\n return routes.some((route) => pathname === route || pathname.startsWith(`${route}/`));\r\n}\r\n\r\ninterface CreateAuthMiddlewareOptions {\r\n publicRoutes?: string[];\r\n authRoutes?: string[];\r\n}\r\n\r\nexport function createAuthMiddleware(options?: CreateAuthMiddlewareOptions): MiddlewareFunction {\r\n return async (request: NextRequest) => {\r\n const { pathname } = request.nextUrl;\r\n const token = process.env.DUMMY_AUTH_TOKEN || request.cookies.get('greatapps')?.value;\r\n const isPublicRoute = isRouteEquals(pathname, options?.publicRoutes || []);\r\n const isAuthRoute = isRouteEquals(pathname, options?.authRoutes || []);\r\n\r\n if (token && isAuthRoute) {\r\n return stopChain(NextResponse.redirect(new URL('/', request.url)));\r\n }\r\n\r\n if (!token && !isPublicRoute && !isAuthRoute) {\r\n const host = request.headers.get('host') || '';\r\n const whitelabel = await whitelabelService.getTokenByDomain(host).catch(() => null);\r\n const accountsUrl = whitelabel?.accounts_url;\r\n\r\n const loginUrl = accountsUrl\r\n ? new URL('/login', accountsUrl)\r\n : new URL('/login', request.url);\r\n\r\n if (pathname !== '/') {\r\n loginUrl.searchParams.set('redirect', pathname);\r\n }\r\n\r\n return stopChain(NextResponse.redirect(loginUrl));\r\n }\r\n\r\n return continueChain();\r\n }\r\n}"],"mappings":"AAAA,SAAsB,oBAAoB;AAE1C,SAAS,eAAuE,iBAAiB;AACjG,SAAS,yBAAyB;AAElC,SAAS,cAAc,UAAkB,QAA2B;AAClE,SAAO,OAAO,KAAK,CAAC,UAAU,aAAa,SAAS,SAAS,WAAW,GAAG,KAAK,GAAG,CAAC;AACtF;AAOO,SAAS,qBAAqB,SAA2D;AAC9F,SAAO,OAAO,YAAyB;AACrC,UAAM,EAAE,SAAS,IAAI,QAAQ;AAC7B,UAAM,QAAQ,QAAQ,IAAI,oBAAoB,QAAQ,QAAQ,IAAI,WAAW,GAAG;AAChF,UAAM,gBAAgB,cAAc,UAAU,SAAS,gBAAgB,CAAC,CAAC;AACzE,UAAM,cAAc,cAAc,UAAU,SAAS,cAAc,CAAC,CAAC;AAErE,QAAI,SAAS,aAAa;AACxB,aAAO,UAAU,aAAa,SAAS,IAAI,IAAI,KAAK,QAAQ,GAAG,CAAC,CAAC;AAAA,IACnE;AAEA,QAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,aAAa;AAC5C,YAAM,OAAO,QAAQ,QAAQ,IAAI,MAAM,KAAK;AAC5C,YAAM,aAAa,MAAM,kBAAkB,iBAAiB,IAAI,EAAE,MAAM,MAAM,IAAI;AAClF,YAAM,cAAc,YAAY;AAEhC,YAAM,WAAW,cACb,IAAI,IAAI,UAAU,WAAW,IAC7B,IAAI,IAAI,UAAU,QAAQ,GAAG;AAEjC,UAAI,aAAa,KAAK;AACpB,iBAAS,aAAa,IAAI,YAAY,QAAQ;AAAA,MAChD;AAEA,aAAO,UAAU,aAAa,SAAS,QAAQ,CAAC;AAAA,IAClD;AAEA,WAAO,cAAc;AAAA,EACvB;AACF;","names":[]}
@@ -0,0 +1,11 @@
1
+ function continueChain(request) {
2
+ return { type: "next", request };
3
+ }
4
+ function stopChain(response) {
5
+ return { type: "response", response };
6
+ }
7
+ export {
8
+ continueChain,
9
+ stopChain
10
+ };
11
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/middlewares/types.ts"],"sourcesContent":["import { NextRequest, NextResponse } from 'next/server';\r\n\r\nexport type MiddlewareResult =\r\n | { type: 'response'; response: NextResponse }\r\n | { type: 'next'; request?: NextRequest };\r\n\r\nexport type MiddlewareFunction = (\r\n request: NextRequest\r\n) => MiddlewareResult | Promise<MiddlewareResult>;\r\n\r\nexport interface MiddlewareConfig {\r\n name: string;\r\n handler: MiddlewareFunction;\r\n excludePaths?: string[];\r\n includePaths?: string[];\r\n}\r\n\r\nexport function continueChain(request?: NextRequest): MiddlewareResult {\r\n return { type: 'next', request };\r\n}\r\n\r\nexport function stopChain(response: NextResponse): MiddlewareResult {\r\n return { type: 'response', response };\r\n}\r\n"],"mappings":"AAiBO,SAAS,cAAc,SAAyC;AACrE,SAAO,EAAE,MAAM,QAAQ,QAAQ;AACjC;AAEO,SAAS,UAAU,UAA0C;AAClE,SAAO,EAAE,MAAM,YAAY,SAAS;AACtC;","names":[]}
@@ -0,0 +1,98 @@
1
+ "use server";
2
+ import { safeServerAction } from "../../../utils/safeServerAction";
3
+ import { accountService } from "../services/account.service";
4
+ import { twoFactorService } from "../services/two-factor.service";
5
+ import { findUserById } from "../../users/action/find-user-by-id.action";
6
+ import { UserProfile } from "../../users/schema";
7
+ import { ApiError } from "../../../infra/api/types";
8
+ async function listAccountUsersAction(params) {
9
+ return safeServerAction(async () => {
10
+ const { users, total } = await accountService.listAccountUsers(params);
11
+ return { data: users, total };
12
+ });
13
+ }
14
+ async function updateUserAction(user) {
15
+ return safeServerAction(() => accountService.updateAccountUser(user));
16
+ }
17
+ async function updateAccountUserByIdAction(userId, user) {
18
+ return safeServerAction(() => accountService.updateAccountUserById(userId, user));
19
+ }
20
+ async function updateAccountAction(data) {
21
+ return safeServerAction(async () => {
22
+ if (data.name !== void 0) {
23
+ const userResult = await findUserById();
24
+ if (!userResult.success || userResult.data?.profile !== UserProfile.owner) {
25
+ throw new ApiError(
26
+ "Apenas o propriet\xE1rio da conta pode alterar o nome da empresa",
27
+ "FORBIDDEN",
28
+ 403
29
+ );
30
+ }
31
+ }
32
+ return accountService.updateAccount(data);
33
+ });
34
+ }
35
+ async function deleteAccountUserAction(userId) {
36
+ return safeServerAction(() => accountService.deleteAccountUser(userId));
37
+ }
38
+ async function deleteAccountAction() {
39
+ return safeServerAction(() => accountService.deleteAccount());
40
+ }
41
+ async function createAccountUserAction(user) {
42
+ return safeServerAction(() => accountService.createAccountUser(user));
43
+ }
44
+ async function changePasswordAction(data) {
45
+ return safeServerAction(() => accountService.changePassword(data));
46
+ }
47
+ async function requestEmailChangeAction(newEmail) {
48
+ return safeServerAction(() => accountService.requestContactReset("email", newEmail));
49
+ }
50
+ async function confirmEmailChangeAction(token, newEmail) {
51
+ return safeServerAction(() => accountService.confirmContactReset("email", token, newEmail));
52
+ }
53
+ async function requestPhoneChangeAction(newPhone, ddi) {
54
+ return safeServerAction(() => accountService.requestContactReset("phone", newPhone, ddi));
55
+ }
56
+ async function confirmPhoneChangeAction(token, newPhone, ddi) {
57
+ return safeServerAction(() => accountService.confirmContactReset("phone", token, newPhone, ddi));
58
+ }
59
+ async function generateTwoFactorAction() {
60
+ return safeServerAction(async () => {
61
+ const result = await twoFactorService.generate();
62
+ return {
63
+ qrcode: result.data.qrcode,
64
+ backupCodes: result.data.backup_codes
65
+ };
66
+ });
67
+ }
68
+ async function confirmTwoFactorAction(code) {
69
+ return safeServerAction(async () => {
70
+ await twoFactorService.confirm(code);
71
+ await accountService.updateAccountUser({ two_factor_authentication: true });
72
+ });
73
+ }
74
+ async function disableTwoFactorAction(code) {
75
+ return safeServerAction(async () => {
76
+ await twoFactorService.verify(code);
77
+ await twoFactorService.disable();
78
+ await accountService.updateAccountUser({ two_factor_authentication: false });
79
+ });
80
+ }
81
+ export {
82
+ changePasswordAction,
83
+ confirmEmailChangeAction,
84
+ confirmPhoneChangeAction,
85
+ confirmTwoFactorAction,
86
+ createAccountUserAction,
87
+ deleteAccountAction,
88
+ deleteAccountUserAction,
89
+ disableTwoFactorAction,
90
+ generateTwoFactorAction,
91
+ listAccountUsersAction,
92
+ requestEmailChangeAction,
93
+ requestPhoneChangeAction,
94
+ updateAccountAction,
95
+ updateAccountUserByIdAction,
96
+ updateUserAction
97
+ };
98
+ //# sourceMappingURL=account-management.action.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/accounts/actions/account-management.action.ts"],"sourcesContent":["'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';\nimport { findUserById } from '../../users/action/find-user-by-id.action';\nimport { UserProfile } from '../../users/schema';\nimport { ApiError } from '../../../infra/api/types';\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(async () => {\n if (data.name !== undefined) {\n const userResult = await findUserById();\n if (!userResult.success || userResult.data?.profile !== UserProfile.owner) {\n throw new ApiError(\n 'Apenas o proprietário da conta pode alterar o nome da empresa',\n 'FORBIDDEN',\n 403\n );\n }\n }\n\n return accountService.updateAccount(data);\n });\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, ddi?: string) {\n return safeServerAction(() => accountService.requestContactReset('phone', newPhone, ddi));\n}\n\nexport async function confirmPhoneChangeAction(token: string, newPhone: string, ddi?: string) {\n return safeServerAction(() => accountService.confirmContactReset('phone', token, newPhone, ddi));\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 await accountService.updateAccountUser({ two_factor_authentication: false });\n });\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAQ/B,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;AAEzB,eAAsB,uBAAuB,QAAuC;AAClF,SAAO,iBAAiB,YAAY;AAClC,UAAM,EAAE,OAAO,MAAM,IAAI,MAAM,eAAe,iBAAiB,MAAM;AACrE,WAAO,EAAE,MAAM,OAAO,MAAM;AAAA,EAC9B,CAAC;AACH;AAEA,eAAsB,iBAAiB,MAAgC;AACrE,SAAO,iBAAiB,MAAM,eAAe,kBAAkB,IAAI,CAAC;AACtE;AAEA,eAAsB,4BACpB,QACA,MACA;AACA,SAAO,iBAAiB,MAAM,eAAe,sBAAsB,QAAQ,IAAI,CAAC;AAClF;AAEA,eAAsB,oBAAoB,MAA4B;AACpE,SAAO,iBAAiB,YAAY;AAClC,QAAI,KAAK,SAAS,QAAW;AAC3B,YAAM,aAAa,MAAM,aAAa;AACtC,UAAI,CAAC,WAAW,WAAW,WAAW,MAAM,YAAY,YAAY,OAAO;AACzE,cAAM,IAAI;AAAA,UACR;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAEA,WAAO,eAAe,cAAc,IAAI;AAAA,EAC1C,CAAC;AACH;AAEA,eAAsB,wBAAwB,QAAgB;AAC5D,SAAO,iBAAiB,MAAM,eAAe,kBAAkB,MAAM,CAAC;AACxE;AAEA,eAAsB,sBAAsB;AAC1C,SAAO,iBAAiB,MAAM,eAAe,cAAc,CAAC;AAC9D;AAEA,eAAsB,wBAAwB,MAAgC;AAC5E,SAAO,iBAAiB,MAAM,eAAe,kBAAkB,IAAI,CAAC;AACtE;AAEA,eAAsB,qBAAqB,MAA6B;AACtE,SAAO,iBAAiB,MAAM,eAAe,eAAe,IAAI,CAAC;AACnE;AAEA,eAAsB,yBAAyB,UAAkB;AAC/D,SAAO,iBAAiB,MAAM,eAAe,oBAAoB,SAAS,QAAQ,CAAC;AACrF;AAEA,eAAsB,yBAAyB,OAAe,UAAkB;AAC9E,SAAO,iBAAiB,MAAM,eAAe,oBAAoB,SAAS,OAAO,QAAQ,CAAC;AAC5F;AAEA,eAAsB,yBAAyB,UAAkB,KAAc;AAC7E,SAAO,iBAAiB,MAAM,eAAe,oBAAoB,SAAS,UAAU,GAAG,CAAC;AAC1F;AAEA,eAAsB,yBAAyB,OAAe,UAAkB,KAAc;AAC5F,SAAO,iBAAiB,MAAM,eAAe,oBAAoB,SAAS,OAAO,UAAU,GAAG,CAAC;AACjG;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;AAC/B,UAAM,eAAe,kBAAkB,EAAE,2BAA2B,MAAM,CAAC;AAAA,EAC7E,CAAC;AACH;","names":[]}
@@ -0,0 +1,10 @@
1
+ "use server";
2
+ import { safeServerAction } from "../../../utils/safeServerAction";
3
+ import { accountService } from "../services/account.service";
4
+ async function findCurrentAccount() {
5
+ return safeServerAction(() => accountService.findCurrentAccount());
6
+ }
7
+ export {
8
+ findCurrentAccount
9
+ };
10
+ //# sourceMappingURL=find-current-account.action.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/accounts/actions/find-current-account.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"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAG/B,eAAsB,qBAAqB;AACzC,SAAO,iBAA0B,MAAM,eAAe,mBAAmB,CAAC;AAC5E;","names":[]}
@@ -0,0 +1,10 @@
1
+ "use server";
2
+ import { safeServerAction } from "../../../utils/safeServerAction";
3
+ import { currencyService } from "../services/currency.service";
4
+ async function listCurrenciesAction() {
5
+ return safeServerAction(() => currencyService.fetchOptions());
6
+ }
7
+ export {
8
+ listCurrenciesAction
9
+ };
10
+ //# sourceMappingURL=list-currencies.action.mjs.map