@greatapps/common 1.1.237 → 1.1.239

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 (73) hide show
  1. package/dist/components/modals/BuyCreditsModal.mjs +277 -0
  2. package/dist/components/modals/BuyCreditsModal.mjs.map +1 -0
  3. package/dist/components/navigation/subcomponents/CreditsCard.mjs +5 -2
  4. package/dist/components/navigation/subcomponents/CreditsCard.mjs.map +1 -1
  5. package/dist/components/ui/data-display/CardBrandIcons.mjs +484 -0
  6. package/dist/components/ui/data-display/CardBrandIcons.mjs.map +1 -0
  7. package/dist/components/ui/data-display/CardItem.mjs +67 -0
  8. package/dist/components/ui/data-display/CardItem.mjs.map +1 -0
  9. package/dist/components/ui/data-display/PaymentInfoCard.mjs +161 -0
  10. package/dist/components/ui/data-display/PaymentInfoCard.mjs.map +1 -0
  11. package/dist/components/ui/feedback/Skeleton.mjs +9 -0
  12. package/dist/components/ui/feedback/Skeleton.mjs.map +1 -0
  13. package/dist/index.mjs +57 -29
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/modules/cards/actions/list-cards.action.mjs +10 -0
  16. package/dist/modules/cards/actions/list-cards.action.mjs.map +1 -0
  17. package/dist/modules/cards/hooks/cards.hook.mjs +16 -0
  18. package/dist/modules/cards/hooks/cards.hook.mjs.map +1 -0
  19. package/dist/modules/cards/services/cards.service.mjs +29 -0
  20. package/dist/modules/cards/services/cards.service.mjs.map +1 -0
  21. package/dist/modules/cards/types.mjs +27 -0
  22. package/dist/modules/cards/types.mjs.map +1 -0
  23. package/dist/modules/subscriptions/actions/calculate-subscription.action.mjs +27 -0
  24. package/dist/modules/subscriptions/actions/calculate-subscription.action.mjs.map +1 -0
  25. package/dist/modules/subscriptions/actions/update-subscription-plan.action.mjs +21 -0
  26. package/dist/modules/subscriptions/actions/update-subscription-plan.action.mjs.map +1 -0
  27. package/dist/modules/subscriptions/constants/addons.constants.mjs +13 -1
  28. package/dist/modules/subscriptions/constants/addons.constants.mjs.map +1 -1
  29. package/dist/modules/subscriptions/hooks/calculate-subscription.hook.mjs +13 -0
  30. package/dist/modules/subscriptions/hooks/calculate-subscription.hook.mjs.map +1 -0
  31. package/dist/modules/subscriptions/hooks/update-subscription-plan.hook.mjs +22 -0
  32. package/dist/modules/subscriptions/hooks/update-subscription-plan.hook.mjs.map +1 -0
  33. package/dist/modules/subscriptions/services/subscriptions.service.mjs +36 -0
  34. package/dist/modules/subscriptions/services/subscriptions.service.mjs.map +1 -1
  35. package/dist/modules/subscriptions/types/billing-period.type.mjs +1 -0
  36. package/dist/modules/subscriptions/types/billing-period.type.mjs.map +1 -0
  37. package/dist/modules/subscriptions/types/calculate-subscription.type.mjs +72 -0
  38. package/dist/modules/subscriptions/types/calculate-subscription.type.mjs.map +1 -0
  39. package/dist/modules/subscriptions/utils/build-plan-extras.mjs +34 -0
  40. package/dist/modules/subscriptions/utils/build-plan-extras.mjs.map +1 -0
  41. package/dist/modules/subscriptions/utils/periodicity.mjs +48 -0
  42. package/dist/modules/subscriptions/utils/periodicity.mjs.map +1 -0
  43. package/dist/modules/subscriptions/utils/resolve-plan-extras-prices.mjs +14 -0
  44. package/dist/modules/subscriptions/utils/resolve-plan-extras-prices.mjs.map +1 -0
  45. package/dist/server.mjs +10 -0
  46. package/dist/server.mjs.map +1 -1
  47. package/dist/store/useBuyCreditsModal.mjs +18 -0
  48. package/dist/store/useBuyCreditsModal.mjs.map +1 -0
  49. package/package.json +1 -1
  50. package/src/components/modals/BuyCreditsModal.tsx +304 -0
  51. package/src/components/navigation/subcomponents/CreditsCard.tsx +5 -2
  52. package/src/components/ui/data-display/CardBrandIcons.tsx +336 -0
  53. package/src/components/ui/data-display/CardItem.tsx +75 -0
  54. package/src/components/ui/data-display/PaymentInfoCard.tsx +186 -0
  55. package/src/components/ui/feedback/Skeleton.tsx +5 -0
  56. package/src/index.ts +21 -2
  57. package/src/modules/cards/actions/list-cards.action.ts +8 -0
  58. package/src/modules/cards/hooks/cards.hook.ts +14 -0
  59. package/src/modules/cards/services/cards.service.ts +32 -0
  60. package/src/modules/cards/types.ts +32 -0
  61. package/src/modules/subscriptions/actions/calculate-subscription.action.ts +32 -0
  62. package/src/modules/subscriptions/actions/update-subscription-plan.action.ts +26 -0
  63. package/src/modules/subscriptions/constants/addons.constants.ts +18 -0
  64. package/src/modules/subscriptions/hooks/calculate-subscription.hook.ts +13 -0
  65. package/src/modules/subscriptions/hooks/update-subscription-plan.hook.ts +25 -0
  66. package/src/modules/subscriptions/services/subscriptions.service.ts +52 -1
  67. package/src/modules/subscriptions/types/billing-period.type.ts +1 -0
  68. package/src/modules/subscriptions/types/calculate-subscription.type.ts +75 -0
  69. package/src/modules/subscriptions/utils/build-plan-extras.ts +53 -0
  70. package/src/modules/subscriptions/utils/periodicity.ts +52 -0
  71. package/src/modules/subscriptions/utils/resolve-plan-extras-prices.ts +23 -0
  72. package/src/server.ts +5 -0
  73. package/src/store/useBuyCreditsModal.ts +25 -0
@@ -0,0 +1,10 @@
1
+ "use server";
2
+ import { safeServerAction } from "../../../utils/safeServerAction";
3
+ import { cardsService } from "../services/cards.service";
4
+ async function listCardsAction() {
5
+ return safeServerAction(() => cardsService.listCards());
6
+ }
7
+ export {
8
+ listCardsAction
9
+ };
10
+ //# sourceMappingURL=list-cards.action.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/cards/actions/list-cards.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { cardsService } from '../services/cards.service';\n\nexport async function listCardsAction() {\n return safeServerAction(() => cardsService.listCards());\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAE7B,eAAsB,kBAAkB;AACtC,SAAO,iBAAiB,MAAM,aAAa,UAAU,CAAC;AACxD;","names":[]}
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { withAction } from "../../../utils/withAction";
4
+ import { listCardsAction } from "../actions/list-cards.action";
5
+ const CARDS_QUERY_KEY = ["cards"];
6
+ function useCards() {
7
+ return useQuery({
8
+ queryKey: CARDS_QUERY_KEY,
9
+ queryFn: withAction(listCardsAction)
10
+ });
11
+ }
12
+ export {
13
+ CARDS_QUERY_KEY,
14
+ useCards
15
+ };
16
+ //# sourceMappingURL=cards.hook.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/cards/hooks/cards.hook.ts"],"sourcesContent":["'use client';\n\nimport { useQuery } from '@tanstack/react-query';\nimport { withAction } from '../../../utils/withAction';\nimport { listCardsAction } from '../actions/list-cards.action';\n\nexport const CARDS_QUERY_KEY = ['cards'];\n\nexport function useCards() {\n return useQuery({\n queryKey: CARDS_QUERY_KEY,\n queryFn: withAction(listCardsAction),\n });\n}\n"],"mappings":";AAEA,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAEzB,MAAM,kBAAkB,CAAC,OAAO;AAEhC,SAAS,WAAW;AACzB,SAAO,SAAS;AAAA,IACd,UAAU;AAAA,IACV,SAAS,WAAW,eAAe;AAAA,EACrC,CAAC;AACH;","names":[]}
@@ -0,0 +1,29 @@
1
+ import "server-only";
2
+ import { api } from "../../../infra/api/client";
3
+ import { ApiError } from "../../../infra/api/types";
4
+ import { buildQueryParams } from "../../../infra/utils/params";
5
+ import { getUserContext } from "../../auth/utils/get-user-context";
6
+ import { CardSchema } from "../types";
7
+ class CardsService {
8
+ async listCards() {
9
+ const { id_account } = await getUserContext();
10
+ const query = buildQueryParams({ id_account });
11
+ const response = await api.apps.get(
12
+ `/accounts/${id_account}/cards?${query}`
13
+ );
14
+ if (response.status === 0) {
15
+ throw new ApiError(
16
+ response.message || "Erro ao listar cart\xF5es",
17
+ "LIST_CARDS_FAILED",
18
+ 400
19
+ );
20
+ }
21
+ const data = response.data.map((item) => CardSchema.parse(item));
22
+ return { data, total: response.total, success: true };
23
+ }
24
+ }
25
+ const cardsService = new CardsService();
26
+ export {
27
+ cardsService
28
+ };
29
+ //# sourceMappingURL=cards.service.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/cards/services/cards.service.ts"],"sourcesContent":["import 'server-only';\n\nimport { api } from '../../../infra/api/client';\nimport { ApiError, ApiPaginatedActionResult, PaginatedSuccessResult } from '../../../infra/api/types';\nimport { buildQueryParams } from '../../../infra/utils/params';\nimport { getUserContext } from '../../auth/utils/get-user-context';\nimport { Card, CardSchema } from '../types';\n\nclass CardsService {\n async listCards(): Promise<PaginatedSuccessResult<Card>> {\n const { id_account } = await getUserContext();\n\n const query = buildQueryParams({ id_account });\n const response = await api.apps.get<ApiPaginatedActionResult<Card>>(\n `/accounts/${id_account}/cards?${query}`\n );\n\n if (response.status === 0) {\n throw new ApiError(\n response.message || 'Erro ao listar cartões',\n 'LIST_CARDS_FAILED',\n 400\n );\n }\n\n const data = response.data.map((item) => CardSchema.parse(item));\n\n return { data, total: response.total, success: true };\n }\n}\n\nexport const cardsService = new CardsService();\n"],"mappings":"AAAA,OAAO;AAEP,SAAS,WAAW;AACpB,SAAS,gBAAkE;AAC3E,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAe,kBAAkB;AAEjC,MAAM,aAAa;AAAA,EACjB,MAAM,YAAmD;AACvD,UAAM,EAAE,WAAW,IAAI,MAAM,eAAe;AAE5C,UAAM,QAAQ,iBAAiB,EAAE,WAAW,CAAC;AAC7C,UAAM,WAAW,MAAM,IAAI,KAAK;AAAA,MAC9B,aAAa,UAAU,UAAU,KAAK;AAAA,IACxC;AAEA,QAAI,SAAS,WAAW,GAAG;AACzB,YAAM,IAAI;AAAA,QACR,SAAS,WAAW;AAAA,QACpB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,UAAM,OAAO,SAAS,KAAK,IAAI,CAAC,SAAS,WAAW,MAAM,IAAI,CAAC;AAE/D,WAAO,EAAE,MAAM,OAAO,SAAS,OAAO,SAAS,KAAK;AAAA,EACtD;AACF;AAEO,MAAM,eAAe,IAAI,aAAa;","names":[]}
@@ -0,0 +1,27 @@
1
+ import z from "zod";
2
+ const CardSchema = z.object({
3
+ id: z.union([z.number(), z.string()]),
4
+ id_wl: z.number().optional(),
5
+ id_account: z.union([z.number(), z.string()]).optional(),
6
+ id_gateway: z.union([z.number(), z.string()]).optional(),
7
+ gateway_account: z.string().optional(),
8
+ gateway_card: z.string().optional(),
9
+ brand: z.string(),
10
+ name: z.string(),
11
+ number: z.string(),
12
+ date: z.string().optional(),
13
+ deleted: z.number().transform((val) => val === 1).optional().default(false),
14
+ is_default: z.boolean().optional().default(false),
15
+ datetime_add: z.union([z.date(), z.coerce.date()]).nullable().optional(),
16
+ datetime_alt: z.union([z.date(), z.coerce.date()]).nullable().optional(),
17
+ datetime_del: z.union([z.date(), z.coerce.date()]).nullable().optional()
18
+ });
19
+ const CreateCardRequestSchema = z.object({
20
+ payment_method_id: z.string().min(1, "payment_method_id \xE9 obrigat\xF3rio"),
21
+ set_default: z.boolean().optional()
22
+ });
23
+ export {
24
+ CardSchema,
25
+ CreateCardRequestSchema
26
+ };
27
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/modules/cards/types.ts"],"sourcesContent":["import z from 'zod';\n\nexport const CardSchema = z.object({\n id: z.union([z.number(), z.string()]),\n id_wl: z.number().optional(),\n id_account: z.union([z.number(), z.string()]).optional(),\n id_gateway: z.union([z.number(), z.string()]).optional(),\n gateway_account: z.string().optional(),\n gateway_card: z.string().optional(),\n brand: z.string(),\n name: z.string(),\n number: z.string(),\n date: z.string().optional(),\n deleted: z\n .number()\n .transform((val) => val === 1)\n .optional()\n .default(false),\n is_default: z.boolean().optional().default(false),\n datetime_add: z.union([z.date(), z.coerce.date()]).nullable().optional(),\n datetime_alt: z.union([z.date(), z.coerce.date()]).nullable().optional(),\n datetime_del: z.union([z.date(), z.coerce.date()]).nullable().optional(),\n});\n\nexport type Card = z.infer<typeof CardSchema>;\n\nexport const CreateCardRequestSchema = z.object({\n payment_method_id: z.string().min(1, 'payment_method_id é obrigatório'),\n set_default: z.boolean().optional(),\n});\n\nexport type CreateCardRequest = z.infer<typeof CreateCardRequestSchema>;\n"],"mappings":"AAAA,OAAO,OAAO;AAEP,MAAM,aAAa,EAAE,OAAO;AAAA,EACjC,IAAI,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC;AAAA,EACpC,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA,EAC3B,YAAY,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS;AAAA,EACvD,YAAY,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS;AAAA,EACvD,iBAAiB,EAAE,OAAO,EAAE,SAAS;AAAA,EACrC,cAAc,EAAE,OAAO,EAAE,SAAS;AAAA,EAClC,OAAO,EAAE,OAAO;AAAA,EAChB,MAAM,EAAE,OAAO;AAAA,EACf,QAAQ,EAAE,OAAO;AAAA,EACjB,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,EAC1B,SAAS,EACN,OAAO,EACP,UAAU,CAAC,QAAQ,QAAQ,CAAC,EAC5B,SAAS,EACT,QAAQ,KAAK;AAAA,EAChB,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,KAAK;AAAA,EAChD,cAAc,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS;AAAA,EACvE,cAAc,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS;AAAA,EACvE,cAAc,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS;AACzE,CAAC;AAIM,MAAM,0BAA0B,EAAE,OAAO;AAAA,EAC9C,mBAAmB,EAAE,OAAO,EAAE,IAAI,GAAG,uCAAiC;AAAA,EACtE,aAAa,EAAE,QAAQ,EAAE,SAAS;AACpC,CAAC;","names":[]}
@@ -0,0 +1,27 @@
1
+ "use server";
2
+ import { safeServerAction } from "../../../utils/safeServerAction";
3
+ import { subscriptionsService } from "../services/subscriptions.service";
4
+ import { resolvePlanExtrasPrices } from "../utils/resolve-plan-extras-prices";
5
+ async function calculateSubscriptionAction(data) {
6
+ return safeServerAction(async () => {
7
+ if (data.plan_extras?.length) {
8
+ let subscriptionItems = [];
9
+ if (data.id_subscription) {
10
+ const { data: subscriptions } = await subscriptionsService.listSubscriptions({
11
+ active: true
12
+ });
13
+ const subscription = subscriptions.find((s) => String(s.id) === String(data.id_subscription)) ?? subscriptions[0];
14
+ subscriptionItems = subscription?.items ?? [];
15
+ }
16
+ data = {
17
+ ...data,
18
+ plan_extras: resolvePlanExtrasPrices(data.plan_extras, subscriptionItems)
19
+ };
20
+ }
21
+ return subscriptionsService.calculateSubscription(data);
22
+ });
23
+ }
24
+ export {
25
+ calculateSubscriptionAction
26
+ };
27
+ //# sourceMappingURL=calculate-subscription.action.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/subscriptions/actions/calculate-subscription.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport type { CalculateSubscriptionRequest } from '../types/calculate-subscription.type';\nimport type { SubscriptionItem } from '../types';\nimport { subscriptionsService } from '../services/subscriptions.service';\nimport { resolvePlanExtrasPrices } from '../utils/resolve-plan-extras-prices';\n\nexport async function calculateSubscriptionAction(data: CalculateSubscriptionRequest) {\n return safeServerAction(async () => {\n if (data.plan_extras?.length) {\n let subscriptionItems: SubscriptionItem[] = [];\n\n if (data.id_subscription) {\n const { data: subscriptions } = await subscriptionsService.listSubscriptions({\n active: true,\n });\n const subscription =\n subscriptions.find((s) => String(s.id) === String(data.id_subscription)) ??\n subscriptions[0];\n subscriptionItems = subscription?.items ?? [];\n }\n\n data = {\n ...data,\n plan_extras: resolvePlanExtrasPrices(data.plan_extras, subscriptionItems),\n };\n }\n\n return subscriptionsService.calculateSubscription(data);\n });\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AAGjC,SAAS,4BAA4B;AACrC,SAAS,+BAA+B;AAExC,eAAsB,4BAA4B,MAAoC;AACpF,SAAO,iBAAiB,YAAY;AAClC,QAAI,KAAK,aAAa,QAAQ;AAC5B,UAAI,oBAAwC,CAAC;AAE7C,UAAI,KAAK,iBAAiB;AACxB,cAAM,EAAE,MAAM,cAAc,IAAI,MAAM,qBAAqB,kBAAkB;AAAA,UAC3E,QAAQ;AAAA,QACV,CAAC;AACD,cAAM,eACJ,cAAc,KAAK,CAAC,MAAM,OAAO,EAAE,EAAE,MAAM,OAAO,KAAK,eAAe,CAAC,KACvE,cAAc,CAAC;AACjB,4BAAoB,cAAc,SAAS,CAAC;AAAA,MAC9C;AAEA,aAAO;AAAA,QACL,GAAG;AAAA,QACH,aAAa,wBAAwB,KAAK,aAAa,iBAAiB;AAAA,MAC1E;AAAA,IACF;AAEA,WAAO,qBAAqB,sBAAsB,IAAI;AAAA,EACxD,CAAC;AACH;","names":[]}
@@ -0,0 +1,21 @@
1
+ "use server";
2
+ import { safeServerAction } from "../../../utils/safeServerAction";
3
+ import { subscriptionsService } from "../services/subscriptions.service";
4
+ import { resolvePlanExtrasPrices } from "../utils/resolve-plan-extras-prices";
5
+ async function updateSubscriptionPlanAction(subscriptionId, data) {
6
+ return safeServerAction(async () => {
7
+ if (data.plan_extras?.length) {
8
+ const { data: subscriptions } = await subscriptionsService.listSubscriptions({ active: true });
9
+ const subscription = subscriptions.find((s) => String(s.id) === String(subscriptionId)) ?? subscriptions[0];
10
+ data = {
11
+ ...data,
12
+ plan_extras: resolvePlanExtrasPrices(data.plan_extras, subscription?.items ?? [])
13
+ };
14
+ }
15
+ return subscriptionsService.updateSubscriptionPlan(subscriptionId, data);
16
+ });
17
+ }
18
+ export {
19
+ updateSubscriptionPlanAction
20
+ };
21
+ //# sourceMappingURL=update-subscription-plan.action.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/subscriptions/actions/update-subscription-plan.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport type { UpdateSubscriptionPlanRequest } from '../types/calculate-subscription.type';\nimport { subscriptionsService } from '../services/subscriptions.service';\nimport { resolvePlanExtrasPrices } from '../utils/resolve-plan-extras-prices';\n\nexport async function updateSubscriptionPlanAction(\n subscriptionId: number | string,\n data: UpdateSubscriptionPlanRequest\n) {\n return safeServerAction(async () => {\n if (data.plan_extras?.length) {\n const { data: subscriptions } = await subscriptionsService.listSubscriptions({ active: true });\n const subscription =\n subscriptions.find((s) => String(s.id) === String(subscriptionId)) ?? subscriptions[0];\n\n data = {\n ...data,\n plan_extras: resolvePlanExtrasPrices(data.plan_extras, subscription?.items ?? []),\n };\n }\n\n return subscriptionsService.updateSubscriptionPlan(subscriptionId, data);\n });\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AAEjC,SAAS,4BAA4B;AACrC,SAAS,+BAA+B;AAExC,eAAsB,6BACpB,gBACA,MACA;AACA,SAAO,iBAAiB,YAAY;AAClC,QAAI,KAAK,aAAa,QAAQ;AAC5B,YAAM,EAAE,MAAM,cAAc,IAAI,MAAM,qBAAqB,kBAAkB,EAAE,QAAQ,KAAK,CAAC;AAC7F,YAAM,eACJ,cAAc,KAAK,CAAC,MAAM,OAAO,EAAE,EAAE,MAAM,OAAO,cAAc,CAAC,KAAK,cAAc,CAAC;AAEvF,aAAO;AAAA,QACL,GAAG;AAAA,QACH,aAAa,wBAAwB,KAAK,aAAa,cAAc,SAAS,CAAC,CAAC;AAAA,MAClF;AAAA,IACF;AAEA,WAAO,qBAAqB,uBAAuB,gBAAgB,IAAI;AAAA,EACzE,CAAC;AACH;","names":[]}
@@ -6,7 +6,19 @@ const ADDON_IDS = {
6
6
  HEATMAP: 5,
7
7
  AI: 6
8
8
  };
9
+ const AI_CREDIT_OPTIONS = [
10
+ { credits: 0, price: 0, priceLabel: "R$ 0,00" },
11
+ { credits: 250, price: 9.99, priceLabel: "R$ 9,99" },
12
+ { credits: 500, price: 19.98, priceLabel: "R$ 19,98" },
13
+ { credits: 1e3, price: 39.96, priceLabel: "R$ 39,96" },
14
+ { credits: 2500, price: 99.9, priceLabel: "R$ 99,90" },
15
+ { credits: 5e3, price: 199.8, priceLabel: "R$ 199,80" },
16
+ { credits: 1e4, price: 399.6, priceLabel: "R$ 399,60" }
17
+ ];
18
+ const AI_CREDIT_VALUES = new Set(AI_CREDIT_OPTIONS.map((opt) => opt.credits));
9
19
  export {
10
- ADDON_IDS
20
+ ADDON_IDS,
21
+ AI_CREDIT_OPTIONS,
22
+ AI_CREDIT_VALUES
11
23
  };
12
24
  //# sourceMappingURL=addons.constants.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/modules/subscriptions/constants/addons.constants.ts"],"sourcesContent":["export const ADDON_IDS = {\r\n DOMAINS: 1,\r\n PAGES: 2,\r\n PROJECTS: 3,\r\n AB_TEST: 4,\r\n HEATMAP: 5,\r\n AI: 6,\r\n} as const;\r\n\r\nexport type AddonKindEnum = (typeof ADDON_IDS)[keyof typeof ADDON_IDS];\r\n"],"mappings":"AAAO,MAAM,YAAY;AAAA,EACvB,SAAS;AAAA,EACT,OAAO;AAAA,EACP,UAAU;AAAA,EACV,SAAS;AAAA,EACT,SAAS;AAAA,EACT,IAAI;AACN;","names":[]}
1
+ {"version":3,"sources":["../../../../src/modules/subscriptions/constants/addons.constants.ts"],"sourcesContent":["export const ADDON_IDS = {\r\n DOMAINS: 1,\r\n PAGES: 2,\r\n PROJECTS: 3,\r\n AB_TEST: 4,\r\n HEATMAP: 5,\r\n AI: 6,\r\n} as const;\r\n\r\nexport type AddonKindEnum = (typeof ADDON_IDS)[keyof typeof ADDON_IDS];\r\n\r\nexport interface AiCreditOption {\r\n credits: number;\r\n price: number;\r\n priceLabel: string;\r\n}\r\n\r\nexport const AI_CREDIT_OPTIONS: AiCreditOption[] = [\r\n { credits: 0, price: 0, priceLabel: 'R$ 0,00' },\r\n { credits: 250, price: 9.99, priceLabel: 'R$ 9,99' },\r\n { credits: 500, price: 19.98, priceLabel: 'R$ 19,98' },\r\n { credits: 1000, price: 39.96, priceLabel: 'R$ 39,96' },\r\n { credits: 2500, price: 99.90, priceLabel: 'R$ 99,90' },\r\n { credits: 5000, price: 199.80, priceLabel: 'R$ 199,80' },\r\n { credits: 10000, price: 399.60, priceLabel: 'R$ 399,60' },\r\n];\r\n\r\nexport const AI_CREDIT_VALUES = new Set(AI_CREDIT_OPTIONS.map((opt) => opt.credits));\r\n"],"mappings":"AAAO,MAAM,YAAY;AAAA,EACvB,SAAS;AAAA,EACT,OAAO;AAAA,EACP,UAAU;AAAA,EACV,SAAS;AAAA,EACT,SAAS;AAAA,EACT,IAAI;AACN;AAUO,MAAM,oBAAsC;AAAA,EACjD,EAAE,SAAS,GAAG,OAAO,GAAG,YAAY,UAAU;AAAA,EAC9C,EAAE,SAAS,KAAK,OAAO,MAAM,YAAY,UAAU;AAAA,EACnD,EAAE,SAAS,KAAK,OAAO,OAAO,YAAY,WAAW;AAAA,EACrD,EAAE,SAAS,KAAM,OAAO,OAAO,YAAY,WAAW;AAAA,EACtD,EAAE,SAAS,MAAM,OAAO,MAAO,YAAY,WAAW;AAAA,EACtD,EAAE,SAAS,KAAM,OAAO,OAAQ,YAAY,YAAY;AAAA,EACxD,EAAE,SAAS,KAAO,OAAO,OAAQ,YAAY,YAAY;AAC3D;AAEO,MAAM,mBAAmB,IAAI,IAAI,kBAAkB,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC;","names":[]}
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import { useMutation } from "@tanstack/react-query";
3
+ import { withAction } from "../../../utils/withAction";
4
+ import { calculateSubscriptionAction } from "../actions/calculate-subscription.action";
5
+ function useCalculateSubscription() {
6
+ return useMutation({
7
+ mutationFn: (data) => withAction(calculateSubscriptionAction)(data)
8
+ });
9
+ }
10
+ export {
11
+ useCalculateSubscription
12
+ };
13
+ //# sourceMappingURL=calculate-subscription.hook.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/subscriptions/hooks/calculate-subscription.hook.ts"],"sourcesContent":["'use client';\n\nimport { useMutation } from '@tanstack/react-query';\nimport { withAction } from '../../../utils/withAction';\nimport { calculateSubscriptionAction } from '../actions/calculate-subscription.action';\nimport type { CalculateSubscriptionRequest } from '../types/calculate-subscription.type';\n\nexport function useCalculateSubscription() {\n return useMutation({\n mutationFn: (data: CalculateSubscriptionRequest) =>\n withAction(calculateSubscriptionAction)(data),\n });\n}\n"],"mappings":";AAEA,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,mCAAmC;AAGrC,SAAS,2BAA2B;AACzC,SAAO,YAAY;AAAA,IACjB,YAAY,CAAC,SACX,WAAW,2BAA2B,EAAE,IAAI;AAAA,EAChD,CAAC;AACH;","names":[]}
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { withAction } from "../../../utils/withAction";
4
+ import { updateSubscriptionPlanAction } from "../actions/update-subscription-plan.action";
5
+ import { SUBSCRIPTIONS_QUERY_KEY } from "./list-subscriptions.hook";
6
+ function useUpdateSubscriptionPlan() {
7
+ const queryClient = useQueryClient();
8
+ return useMutation({
9
+ mutationFn: ({
10
+ subscriptionId,
11
+ data
12
+ }) => withAction(updateSubscriptionPlanAction)(subscriptionId, data),
13
+ onSuccess: () => {
14
+ queryClient.invalidateQueries({ queryKey: SUBSCRIPTIONS_QUERY_KEY });
15
+ queryClient.invalidateQueries({ queryKey: ["charges"] });
16
+ }
17
+ });
18
+ }
19
+ export {
20
+ useUpdateSubscriptionPlan
21
+ };
22
+ //# sourceMappingURL=update-subscription-plan.hook.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/subscriptions/hooks/update-subscription-plan.hook.ts"],"sourcesContent":["'use client';\n\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { withAction } from '../../../utils/withAction';\nimport { updateSubscriptionPlanAction } from '../actions/update-subscription-plan.action';\nimport { SUBSCRIPTIONS_QUERY_KEY } from './list-subscriptions.hook';\nimport type { UpdateSubscriptionPlanRequest } from '../types/calculate-subscription.type';\n\nexport function useUpdateSubscriptionPlan() {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: ({\n subscriptionId,\n data,\n }: {\n subscriptionId: number | string;\n data: UpdateSubscriptionPlanRequest;\n }) => withAction(updateSubscriptionPlanAction)(subscriptionId, data),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: SUBSCRIPTIONS_QUERY_KEY });\n queryClient.invalidateQueries({ queryKey: ['charges'] });\n },\n });\n}\n"],"mappings":";AAEA,SAAS,aAAa,sBAAsB;AAC5C,SAAS,kBAAkB;AAC3B,SAAS,oCAAoC;AAC7C,SAAS,+BAA+B;AAGjC,SAAS,4BAA4B;AAC1C,QAAM,cAAc,eAAe;AAEnC,SAAO,YAAY;AAAA,IACjB,YAAY,CAAC;AAAA,MACX;AAAA,MACA;AAAA,IACF,MAGM,WAAW,4BAA4B,EAAE,gBAAgB,IAAI;AAAA,IACnE,WAAW,MAAM;AACf,kBAAY,kBAAkB,EAAE,UAAU,wBAAwB,CAAC;AACnE,kBAAY,kBAAkB,EAAE,UAAU,CAAC,SAAS,EAAE,CAAC;AAAA,IACzD;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -4,6 +4,9 @@ import { ApiError } from "../../../infra/api/types";
4
4
  import { buildQueryParams } from "../../../infra/utils/params";
5
5
  import { getUserContext } from "../../auth/utils/get-user-context";
6
6
  import { SubscriptionSchema } from "../types";
7
+ import {
8
+ CalculateSubscriptionResponseSchema
9
+ } from "../types/calculate-subscription.type";
7
10
  class SubscriptionsService {
8
11
  async listSubscriptions(params) {
9
12
  const { id_account } = await getUserContext();
@@ -24,6 +27,39 @@ class SubscriptionsService {
24
27
  success: true
25
28
  };
26
29
  }
30
+ async calculateSubscription(data) {
31
+ const { id_account } = await getUserContext();
32
+ const response = await api.apps.post(
33
+ `/accounts/${id_account}/subscriptions/action/calculate`,
34
+ data
35
+ );
36
+ if (response.status === 0) {
37
+ throw new ApiError(
38
+ response.message || "Erro ao calcular assinatura",
39
+ "CALCULATE_SUBSCRIPTION_FAILED",
40
+ 400
41
+ );
42
+ }
43
+ return {
44
+ success: true,
45
+ data: CalculateSubscriptionResponseSchema.parse(response.data)
46
+ };
47
+ }
48
+ async updateSubscriptionPlan(subscriptionId, data) {
49
+ const { id_account } = await getUserContext();
50
+ const response = await api.apps.put(
51
+ `/accounts/${id_account}/subscriptions/${subscriptionId}/action/plan`,
52
+ data
53
+ );
54
+ if (response.status === 0) {
55
+ throw new ApiError(
56
+ response.message || "Erro ao atualizar plano",
57
+ "UPDATE_SUBSCRIPTION_PLAN_FAILED",
58
+ 400
59
+ );
60
+ }
61
+ return { success: true };
62
+ }
27
63
  }
28
64
  const subscriptionsService = new SubscriptionsService();
29
65
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/modules/subscriptions/services/subscriptions.service.ts"],"sourcesContent":["import 'server-only';\r\n\r\nimport { api } from '../../../infra/api/client';\r\nimport { ApiError, ApiPaginatedActionResult, PaginatedSuccessResult } from '../../../infra/api/types';\r\nimport { 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"],"mappings":"AAAA,OAAO;AAEP,SAAS,WAAW;AACpB,SAAS,gBAAkE;AAC3E,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAuB,0BAAmD;AAE1E,MAAM,qBAAqB;AAAA,EACzB,MAAM,kBACJ,QAC+C;AAC/C,UAAM,EAAE,WAAW,IAAI,MAAM,eAAe;AAE5C,UAAM,QAAQ,iBAAiB,MAAsD;AACrF,UAAM,MAAM,aAAa,UAAU,iBAAiB,QAAQ,IAAI,KAAK,KAAK,EAAE;AAE5E,UAAM,WAAW,MAAM,IAAI,KAAK,IAA4C,GAAG;AAE/E,QAAI,SAAS,WAAW,GAAG;AACzB,YAAM,IAAI;AAAA,QACR,SAAS,WAAW;AAAA,QACpB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,UAAM,OAAO,SAAS,KAAK,IAAI,CAAC,SAAS,mBAAmB,MAAM,IAAI,CAAC;AAEvE,WAAO;AAAA,MACL;AAAA,MACA,OAAO,SAAS;AAAA,MAChB,SAAS;AAAA,IACX;AAAA,EACF;AACF;AAEO,MAAM,uBAAuB,IAAI,qBAAqB;","names":[]}
1
+ {"version":3,"sources":["../../../../src/modules/subscriptions/services/subscriptions.service.ts"],"sourcesContent":["import 'server-only';\r\n\r\nimport { api } from '../../../infra/api/client';\r\nimport { ApiError, ApiActionResult, ApiPaginatedActionResult, PaginatedSuccessResult, SuccessResult } 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\nimport {\r\n type CalculateSubscriptionRequest,\r\n type CalculateSubscriptionResponse,\r\n type UpdateSubscriptionPlanRequest,\r\n CalculateSubscriptionResponseSchema,\r\n} from '../types/calculate-subscription.type';\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 async calculateSubscription(\r\n data: CalculateSubscriptionRequest\r\n ): Promise<SuccessResult<CalculateSubscriptionResponse>> {\r\n const { id_account } = await getUserContext();\r\n\r\n const response = await api.apps.post<ApiActionResult<CalculateSubscriptionResponse>>(\r\n `/accounts/${id_account}/subscriptions/action/calculate`,\r\n data\r\n );\r\n\r\n if (response.status === 0) {\r\n throw new ApiError(\r\n response.message || 'Erro ao calcular assinatura',\r\n 'CALCULATE_SUBSCRIPTION_FAILED',\r\n 400\r\n );\r\n }\r\n\r\n return {\r\n success: true,\r\n data: CalculateSubscriptionResponseSchema.parse(response.data),\r\n };\r\n }\r\n\r\n async updateSubscriptionPlan(\r\n subscriptionId: number | string,\r\n data: UpdateSubscriptionPlanRequest\r\n ): Promise<SuccessResult<void>> {\r\n const { id_account } = await getUserContext();\r\n\r\n const response = await api.apps.put<ApiActionResult<void>>(\r\n `/accounts/${id_account}/subscriptions/${subscriptionId}/action/plan`,\r\n data\r\n );\r\n\r\n if (response.status === 0) {\r\n throw new ApiError(\r\n response.message || 'Erro ao atualizar plano',\r\n 'UPDATE_SUBSCRIPTION_PLAN_FAILED',\r\n 400\r\n );\r\n }\r\n\r\n return { success: true };\r\n }\r\n}\r\n\r\nexport const subscriptionsService = new SubscriptionsService();\r\n"],"mappings":"AAAA,OAAO;AAEP,SAAS,WAAW;AACpB,SAAS,gBAAkG;AAC3G,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAuB,0BAAmD;AAC1E;AAAA,EAIE;AAAA,OACK;AAEP,MAAM,qBAAqB;AAAA,EACzB,MAAM,kBACJ,QAC+C;AAC/C,UAAM,EAAE,WAAW,IAAI,MAAM,eAAe;AAE5C,UAAM,QAAQ,iBAAiB,MAAsD;AACrF,UAAM,MAAM,aAAa,UAAU,iBAAiB,QAAQ,IAAI,KAAK,KAAK,EAAE;AAE5E,UAAM,WAAW,MAAM,IAAI,KAAK,IAA4C,GAAG;AAE/E,QAAI,SAAS,WAAW,GAAG;AACzB,YAAM,IAAI;AAAA,QACR,SAAS,WAAW;AAAA,QACpB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,UAAM,OAAO,SAAS,KAAK,IAAI,CAAC,SAAS,mBAAmB,MAAM,IAAI,CAAC;AAEvE,WAAO;AAAA,MACL;AAAA,MACA,OAAO,SAAS;AAAA,MAChB,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA,MAAM,sBACJ,MACuD;AACvD,UAAM,EAAE,WAAW,IAAI,MAAM,eAAe;AAE5C,UAAM,WAAW,MAAM,IAAI,KAAK;AAAA,MAC9B,aAAa,UAAU;AAAA,MACvB;AAAA,IACF;AAEA,QAAI,SAAS,WAAW,GAAG;AACzB,YAAM,IAAI;AAAA,QACR,SAAS,WAAW;AAAA,QACpB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,WAAO;AAAA,MACL,SAAS;AAAA,MACT,MAAM,oCAAoC,MAAM,SAAS,IAAI;AAAA,IAC/D;AAAA,EACF;AAAA,EAEA,MAAM,uBACJ,gBACA,MAC8B;AAC9B,UAAM,EAAE,WAAW,IAAI,MAAM,eAAe;AAE5C,UAAM,WAAW,MAAM,IAAI,KAAK;AAAA,MAC9B,aAAa,UAAU,kBAAkB,cAAc;AAAA,MACvD;AAAA,IACF;AAEA,QAAI,SAAS,WAAW,GAAG;AACzB,YAAM,IAAI;AAAA,QACR,SAAS,WAAW;AAAA,QACpB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,WAAO,EAAE,SAAS,KAAK;AAAA,EACzB;AACF;AAEO,MAAM,uBAAuB,IAAI,qBAAqB;","names":[]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=billing-period.type.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,72 @@
1
+ import z from "zod";
2
+ const CalculateSubscriptionPlanExtraRequestSchema = z.object({
3
+ id_addon: z.number(),
4
+ value: z.number(),
5
+ quantity: z.number(),
6
+ currency: z.string()
7
+ });
8
+ const CalculateSubscriptionRequestSchema = z.object({
9
+ id_product: z.number(),
10
+ id_plan: z.number().optional(),
11
+ id_subscription: z.union([z.number(), z.string()]).optional(),
12
+ id_coupon: z.number().optional(),
13
+ plan_extras: z.array(CalculateSubscriptionPlanExtraRequestSchema.partial({ value: true })).optional()
14
+ });
15
+ const CalculateSubscriptionPlanExtraResponseSchema = z.object({
16
+ id_addon: z.number(),
17
+ value: z.number(),
18
+ value_original: z.number().optional().default(0),
19
+ value_discount: z.number().optional().default(0),
20
+ quantity: z.number(),
21
+ currency: z.string()
22
+ });
23
+ const CalculateSubscriptionResponseSchema = z.object({
24
+ name: z.string(),
25
+ month: z.number(),
26
+ month_discount: z.number(),
27
+ month_discount_coupom: z.number().optional().default(0),
28
+ month_original: z.number(),
29
+ month_original_discount: z.number().optional().default(0),
30
+ month_original_discount_cupom: z.number().optional().default(0),
31
+ semmester: z.number(),
32
+ semmester_price: z.number().optional().default(0),
33
+ semmester_discount: z.number(),
34
+ semmester_discount_coupom: z.number().optional().default(0),
35
+ semmester_original: z.number(),
36
+ semmester_original_discount: z.number().optional().default(0),
37
+ semmester_original_discount_cupom: z.number().optional().default(0),
38
+ year: z.number(),
39
+ year_discount: z.number(),
40
+ year_discount_coupom: z.number().optional().default(0),
41
+ year_original: z.number(),
42
+ year_original_discount: z.number().optional().default(0),
43
+ year_original_discount_cupom: z.number().optional().default(0),
44
+ plan_extras: z.array(CalculateSubscriptionPlanExtraResponseSchema)
45
+ });
46
+ const UpdateSubscriptionPlanExtraSchema = z.object({
47
+ id_addon: z.number(),
48
+ value: z.number().optional(),
49
+ quantity: z.number(),
50
+ price: z.string().optional(),
51
+ trial: z.boolean().optional(),
52
+ trial_days: z.number().optional()
53
+ });
54
+ const UpdateSubscriptionPlanRequestSchema = z.object({
55
+ id_plan: z.number().optional(),
56
+ id_coupon: z.union([z.number(), z.null()]).optional(),
57
+ date_due: z.string().optional(),
58
+ type: z.string().optional(),
59
+ active: z.boolean().optional(),
60
+ periodicity: z.number().optional(),
61
+ plan_extras: z.array(UpdateSubscriptionPlanExtraSchema).optional(),
62
+ enable_charge: z.boolean().optional()
63
+ });
64
+ export {
65
+ CalculateSubscriptionPlanExtraRequestSchema,
66
+ CalculateSubscriptionPlanExtraResponseSchema,
67
+ CalculateSubscriptionRequestSchema,
68
+ CalculateSubscriptionResponseSchema,
69
+ UpdateSubscriptionPlanExtraSchema,
70
+ UpdateSubscriptionPlanRequestSchema
71
+ };
72
+ //# sourceMappingURL=calculate-subscription.type.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/subscriptions/types/calculate-subscription.type.ts"],"sourcesContent":["import z from 'zod';\n\nexport const CalculateSubscriptionPlanExtraRequestSchema = z.object({\n id_addon: z.number(),\n value: z.number(),\n quantity: z.number(),\n currency: z.string(),\n});\n\nexport const CalculateSubscriptionRequestSchema = z.object({\n id_product: z.number(),\n id_plan: z.number().optional(),\n id_subscription: z.union([z.number(), z.string()]).optional(),\n id_coupon: z.number().optional(),\n plan_extras: z.array(CalculateSubscriptionPlanExtraRequestSchema.partial({ value: true })).optional(),\n});\n\nexport type CalculateSubscriptionRequest = z.infer<typeof CalculateSubscriptionRequestSchema>;\n\nexport const CalculateSubscriptionPlanExtraResponseSchema = z.object({\n id_addon: z.number(),\n value: z.number(),\n value_original: z.number().optional().default(0),\n value_discount: z.number().optional().default(0),\n quantity: z.number(),\n currency: z.string(),\n});\n\nexport const CalculateSubscriptionResponseSchema = z.object({\n name: z.string(),\n month: z.number(),\n month_discount: z.number(),\n month_discount_coupom: z.number().optional().default(0),\n month_original: z.number(),\n month_original_discount: z.number().optional().default(0),\n month_original_discount_cupom: z.number().optional().default(0),\n semmester: z.number(),\n semmester_price: z.number().optional().default(0),\n semmester_discount: z.number(),\n semmester_discount_coupom: z.number().optional().default(0),\n semmester_original: z.number(),\n semmester_original_discount: z.number().optional().default(0),\n semmester_original_discount_cupom: z.number().optional().default(0),\n year: z.number(),\n year_discount: z.number(),\n year_discount_coupom: z.number().optional().default(0),\n year_original: z.number(),\n year_original_discount: z.number().optional().default(0),\n year_original_discount_cupom: z.number().optional().default(0),\n plan_extras: z.array(CalculateSubscriptionPlanExtraResponseSchema),\n});\n\nexport type CalculateSubscriptionResponse = z.infer<typeof CalculateSubscriptionResponseSchema>;\n\nexport const UpdateSubscriptionPlanExtraSchema = z.object({\n id_addon: z.number(),\n value: z.number().optional(),\n quantity: z.number(),\n price: z.string().optional(),\n trial: z.boolean().optional(),\n trial_days: z.number().optional(),\n});\n\nexport const UpdateSubscriptionPlanRequestSchema = z.object({\n id_plan: z.number().optional(),\n id_coupon: z.union([z.number(), z.null()]).optional(),\n date_due: z.string().optional(),\n type: z.string().optional(),\n active: z.boolean().optional(),\n periodicity: z.number().optional(),\n plan_extras: z.array(UpdateSubscriptionPlanExtraSchema).optional(),\n enable_charge: z.boolean().optional(),\n});\n\nexport type UpdateSubscriptionPlanRequest = z.infer<typeof UpdateSubscriptionPlanRequestSchema>;\n"],"mappings":"AAAA,OAAO,OAAO;AAEP,MAAM,8CAA8C,EAAE,OAAO;AAAA,EAClE,UAAU,EAAE,OAAO;AAAA,EACnB,OAAO,EAAE,OAAO;AAAA,EAChB,UAAU,EAAE,OAAO;AAAA,EACnB,UAAU,EAAE,OAAO;AACrB,CAAC;AAEM,MAAM,qCAAqC,EAAE,OAAO;AAAA,EACzD,YAAY,EAAE,OAAO;AAAA,EACrB,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,iBAAiB,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS;AAAA,EAC5D,WAAW,EAAE,OAAO,EAAE,SAAS;AAAA,EAC/B,aAAa,EAAE,MAAM,4CAA4C,QAAQ,EAAE,OAAO,KAAK,CAAC,CAAC,EAAE,SAAS;AACtG,CAAC;AAIM,MAAM,+CAA+C,EAAE,OAAO;AAAA,EACnE,UAAU,EAAE,OAAO;AAAA,EACnB,OAAO,EAAE,OAAO;AAAA,EAChB,gBAAgB,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC;AAAA,EAC/C,gBAAgB,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC;AAAA,EAC/C,UAAU,EAAE,OAAO;AAAA,EACnB,UAAU,EAAE,OAAO;AACrB,CAAC;AAEM,MAAM,sCAAsC,EAAE,OAAO;AAAA,EAC1D,MAAM,EAAE,OAAO;AAAA,EACf,OAAO,EAAE,OAAO;AAAA,EAChB,gBAAgB,EAAE,OAAO;AAAA,EACzB,uBAAuB,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC;AAAA,EACtD,gBAAgB,EAAE,OAAO;AAAA,EACzB,yBAAyB,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC;AAAA,EACxD,+BAA+B,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC;AAAA,EAC9D,WAAW,EAAE,OAAO;AAAA,EACpB,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC;AAAA,EAChD,oBAAoB,EAAE,OAAO;AAAA,EAC7B,2BAA2B,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC;AAAA,EAC1D,oBAAoB,EAAE,OAAO;AAAA,EAC7B,6BAA6B,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC;AAAA,EAC5D,mCAAmC,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC;AAAA,EAClE,MAAM,EAAE,OAAO;AAAA,EACf,eAAe,EAAE,OAAO;AAAA,EACxB,sBAAsB,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC;AAAA,EACrD,eAAe,EAAE,OAAO;AAAA,EACxB,wBAAwB,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC;AAAA,EACvD,8BAA8B,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC;AAAA,EAC7D,aAAa,EAAE,MAAM,4CAA4C;AACnE,CAAC;AAIM,MAAM,oCAAoC,EAAE,OAAO;AAAA,EACxD,UAAU,EAAE,OAAO;AAAA,EACnB,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA,EAC3B,UAAU,EAAE,OAAO;AAAA,EACnB,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA,EAC3B,OAAO,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC5B,YAAY,EAAE,OAAO,EAAE,SAAS;AAClC,CAAC;AAEM,MAAM,sCAAsC,EAAE,OAAO;AAAA,EAC1D,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,WAAW,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,SAAS;AAAA,EACpD,UAAU,EAAE,OAAO,EAAE,SAAS;AAAA,EAC9B,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,EAC1B,QAAQ,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC7B,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,aAAa,EAAE,MAAM,iCAAiC,EAAE,SAAS;AAAA,EACjE,eAAe,EAAE,QAAQ,EAAE,SAAS;AACtC,CAAC;","names":[]}
@@ -0,0 +1,34 @@
1
+ function buildPlanExtras(items, overrides) {
2
+ const overrideMap = new Map(overrides.map((o) => [o.id_addon, o]));
3
+ const extras = items.filter((item) => item.id_addon != null).map((item) => {
4
+ const override = overrideMap.get(item.id_addon);
5
+ if (override) {
6
+ overrideMap.delete(item.id_addon);
7
+ return {
8
+ id_addon: override.id_addon,
9
+ value: 0,
10
+ quantity: override.quantity,
11
+ currency: override.currency
12
+ };
13
+ }
14
+ return {
15
+ id_addon: item.id_addon,
16
+ value: item.value,
17
+ quantity: item.quantity,
18
+ currency: item.currency
19
+ };
20
+ });
21
+ for (const override of overrideMap.values()) {
22
+ extras.push({
23
+ id_addon: override.id_addon,
24
+ value: 0,
25
+ quantity: override.quantity,
26
+ currency: override.currency
27
+ });
28
+ }
29
+ return extras;
30
+ }
31
+ export {
32
+ buildPlanExtras
33
+ };
34
+ //# sourceMappingURL=build-plan-extras.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/subscriptions/utils/build-plan-extras.ts"],"sourcesContent":["import type { SubscriptionItem } from '../types';\n\nexport interface PlanExtraOverride {\n id_addon: number;\n quantity: number;\n currency: string;\n}\n\nexport interface PlanExtra {\n id_addon: number;\n value: number;\n quantity: number;\n currency: string;\n}\n\nexport function buildPlanExtras(\n items: SubscriptionItem[],\n overrides: PlanExtraOverride[]\n): PlanExtra[] {\n const overrideMap = new Map(overrides.map((o) => [o.id_addon, o]));\n\n const extras: PlanExtra[] = items\n .filter((item) => item.id_addon != null)\n .map((item) => {\n const override = overrideMap.get(item.id_addon!);\n if (override) {\n overrideMap.delete(item.id_addon!);\n return {\n id_addon: override.id_addon,\n value: 0,\n quantity: override.quantity,\n currency: override.currency,\n };\n }\n return {\n id_addon: item.id_addon!,\n value: item.value,\n quantity: item.quantity,\n currency: item.currency,\n };\n });\n\n for (const override of overrideMap.values()) {\n extras.push({\n id_addon: override.id_addon,\n value: 0,\n quantity: override.quantity,\n currency: override.currency,\n });\n }\n\n return extras;\n}\n"],"mappings":"AAeO,SAAS,gBACd,OACA,WACa;AACb,QAAM,cAAc,IAAI,IAAI,UAAU,IAAI,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;AAEjE,QAAM,SAAsB,MACzB,OAAO,CAAC,SAAS,KAAK,YAAY,IAAI,EACtC,IAAI,CAAC,SAAS;AACb,UAAM,WAAW,YAAY,IAAI,KAAK,QAAS;AAC/C,QAAI,UAAU;AACZ,kBAAY,OAAO,KAAK,QAAS;AACjC,aAAO;AAAA,QACL,UAAU,SAAS;AAAA,QACnB,OAAO;AAAA,QACP,UAAU,SAAS;AAAA,QACnB,UAAU,SAAS;AAAA,MACrB;AAAA,IACF;AACA,WAAO;AAAA,MACL,UAAU,KAAK;AAAA,MACf,OAAO,KAAK;AAAA,MACZ,UAAU,KAAK;AAAA,MACf,UAAU,KAAK;AAAA,IACjB;AAAA,EACF,CAAC;AAEH,aAAW,YAAY,YAAY,OAAO,GAAG;AAC3C,WAAO,KAAK;AAAA,MACV,UAAU,SAAS;AAAA,MACnB,OAAO;AAAA,MACP,UAAU,SAAS;AAAA,MACnB,UAAU,SAAS;AAAA,IACrB,CAAC;AAAA,EACH;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,48 @@
1
+ function periodicityToBillingPeriod(periodicity) {
2
+ if (periodicity === 30 || periodicity === 1 || periodicity === "monthly") return "monthly";
3
+ if (periodicity === 180 || periodicity === 3 || periodicity === "semiannual") return "semiannual";
4
+ if (periodicity === 365 || periodicity === 2 || periodicity === "annual") return "annual";
5
+ return null;
6
+ }
7
+ function billingPeriodToNumeric(billingPeriod) {
8
+ if (billingPeriod === "semiannual") return 180;
9
+ if (billingPeriod === "annual") return 365;
10
+ return 30;
11
+ }
12
+ function getPeriodicityLabel(periodicity) {
13
+ const period = periodicityToBillingPeriod(periodicity);
14
+ if (period === "semiannual") return "Semestral";
15
+ if (period === "annual") return "Anual";
16
+ return "Mensal";
17
+ }
18
+ function getBillingPeriodSuffix(billingPeriod) {
19
+ if (billingPeriod === "semiannual") return "/semestre";
20
+ if (billingPeriod === "annual") return "/ano";
21
+ return "/m\xEAs";
22
+ }
23
+ function getBillingPeriodLabel(billingPeriod) {
24
+ if (billingPeriod === "semiannual") return "semestral";
25
+ if (billingPeriod === "annual") return "anual";
26
+ return "mensal";
27
+ }
28
+ function getBillingPeriodMonths(billingPeriod) {
29
+ if (billingPeriod === "semiannual") return 6;
30
+ if (billingPeriod === "annual") return 12;
31
+ return 1;
32
+ }
33
+ function getPriceFromCalculatedData(data, periodicity) {
34
+ const period = periodicityToBillingPeriod(periodicity);
35
+ if (period === "annual") return data.year;
36
+ if (period === "semiannual") return data.semmester;
37
+ return data.month;
38
+ }
39
+ export {
40
+ billingPeriodToNumeric,
41
+ getBillingPeriodLabel,
42
+ getBillingPeriodMonths,
43
+ getBillingPeriodSuffix,
44
+ getPeriodicityLabel,
45
+ getPriceFromCalculatedData,
46
+ periodicityToBillingPeriod
47
+ };
48
+ //# sourceMappingURL=periodicity.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/subscriptions/utils/periodicity.ts"],"sourcesContent":["import type { BillingPeriod } from '../types/billing-period.type';\nimport type { CalculateSubscriptionResponse } from '../types/calculate-subscription.type';\n\nexport function periodicityToBillingPeriod(\n periodicity: number | string | null | undefined\n): BillingPeriod | null {\n if (periodicity === 30 || periodicity === 1 || periodicity === 'monthly') return 'monthly';\n if (periodicity === 180 || periodicity === 3 || periodicity === 'semiannual') return 'semiannual';\n if (periodicity === 365 || periodicity === 2 || periodicity === 'annual') return 'annual';\n return null;\n}\n\nexport function billingPeriodToNumeric(billingPeriod: BillingPeriod): 30 | 180 | 365 {\n if (billingPeriod === 'semiannual') return 180;\n if (billingPeriod === 'annual') return 365;\n return 30;\n}\n\nexport function getPeriodicityLabel(periodicity: number | string | null | undefined): string {\n const period = periodicityToBillingPeriod(periodicity);\n if (period === 'semiannual') return 'Semestral';\n if (period === 'annual') return 'Anual';\n return 'Mensal';\n}\n\nexport function getBillingPeriodSuffix(billingPeriod: BillingPeriod): string {\n if (billingPeriod === 'semiannual') return '/semestre';\n if (billingPeriod === 'annual') return '/ano';\n return '/mês';\n}\n\nexport function getBillingPeriodLabel(billingPeriod: BillingPeriod): string {\n if (billingPeriod === 'semiannual') return 'semestral';\n if (billingPeriod === 'annual') return 'anual';\n return 'mensal';\n}\n\nexport function getBillingPeriodMonths(billingPeriod: BillingPeriod): number {\n if (billingPeriod === 'semiannual') return 6;\n if (billingPeriod === 'annual') return 12;\n return 1;\n}\n\nexport function getPriceFromCalculatedData(\n data: CalculateSubscriptionResponse,\n periodicity: number | string | null | undefined\n): number {\n const period = periodicityToBillingPeriod(periodicity);\n if (period === 'annual') return data.year;\n if (period === 'semiannual') return data.semmester;\n return data.month;\n}\n"],"mappings":"AAGO,SAAS,2BACd,aACsB;AACtB,MAAI,gBAAgB,MAAM,gBAAgB,KAAK,gBAAgB,UAAW,QAAO;AACjF,MAAI,gBAAgB,OAAO,gBAAgB,KAAK,gBAAgB,aAAc,QAAO;AACrF,MAAI,gBAAgB,OAAO,gBAAgB,KAAK,gBAAgB,SAAU,QAAO;AACjF,SAAO;AACT;AAEO,SAAS,uBAAuB,eAA8C;AACnF,MAAI,kBAAkB,aAAc,QAAO;AAC3C,MAAI,kBAAkB,SAAU,QAAO;AACvC,SAAO;AACT;AAEO,SAAS,oBAAoB,aAAyD;AAC3F,QAAM,SAAS,2BAA2B,WAAW;AACrD,MAAI,WAAW,aAAc,QAAO;AACpC,MAAI,WAAW,SAAU,QAAO;AAChC,SAAO;AACT;AAEO,SAAS,uBAAuB,eAAsC;AAC3E,MAAI,kBAAkB,aAAc,QAAO;AAC3C,MAAI,kBAAkB,SAAU,QAAO;AACvC,SAAO;AACT;AAEO,SAAS,sBAAsB,eAAsC;AAC1E,MAAI,kBAAkB,aAAc,QAAO;AAC3C,MAAI,kBAAkB,SAAU,QAAO;AACvC,SAAO;AACT;AAEO,SAAS,uBAAuB,eAAsC;AAC3E,MAAI,kBAAkB,aAAc,QAAO;AAC3C,MAAI,kBAAkB,SAAU,QAAO;AACvC,SAAO;AACT;AAEO,SAAS,2BACd,MACA,aACQ;AACR,QAAM,SAAS,2BAA2B,WAAW;AACrD,MAAI,WAAW,SAAU,QAAO,KAAK;AACrC,MAAI,WAAW,aAAc,QAAO,KAAK;AACzC,SAAO,KAAK;AACd;","names":[]}
@@ -0,0 +1,14 @@
1
+ import "server-only";
2
+ function resolvePlanExtrasPrices(extras, subscriptionItems) {
3
+ return extras.map((extra) => {
4
+ const item = subscriptionItems.find((i) => i.id_addon === extra.id_addon);
5
+ if (item) {
6
+ return { ...extra, value: item.value };
7
+ }
8
+ return { ...extra, value: extra.value ?? 0 };
9
+ });
10
+ }
11
+ export {
12
+ resolvePlanExtrasPrices
13
+ };
14
+ //# sourceMappingURL=resolve-plan-extras-prices.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/subscriptions/utils/resolve-plan-extras-prices.ts"],"sourcesContent":["import 'server-only';\n\nimport type { SubscriptionItem } from '../types';\n\ninterface PlanExtraInput {\n id_addon: number;\n value?: number;\n quantity: number;\n [key: string]: unknown;\n}\n\nexport function resolvePlanExtrasPrices<T extends PlanExtraInput>(\n extras: T[],\n subscriptionItems: SubscriptionItem[]\n): T[] {\n return extras.map((extra) => {\n const item = subscriptionItems.find((i) => i.id_addon === extra.id_addon);\n if (item) {\n return { ...extra, value: item.value };\n }\n return { ...extra, value: extra.value ?? 0 };\n });\n}\n"],"mappings":"AAAA,OAAO;AAWA,SAAS,wBACd,QACA,mBACK;AACL,SAAO,OAAO,IAAI,CAAC,UAAU;AAC3B,UAAM,OAAO,kBAAkB,KAAK,CAAC,MAAM,EAAE,aAAa,MAAM,QAAQ;AACxE,QAAI,MAAM;AACR,aAAO,EAAE,GAAG,OAAO,OAAO,KAAK,MAAM;AAAA,IACvC;AACA,WAAO,EAAE,GAAG,OAAO,OAAO,MAAM,SAAS,EAAE;AAAA,EAC7C,CAAC;AACH;","names":[]}
package/dist/server.mjs CHANGED
@@ -6,6 +6,7 @@ import { whitelabelStylesService } from "./modules/whitelabel/services/whitelabe
6
6
  import { findWhitelabelStyles } from "./modules/whitelabel/actions/find-whitelabel-styles.action";
7
7
  import { subscriptionsService } from "./modules/subscriptions/services/subscriptions.service";
8
8
  import { plansService } from "./modules/subscriptions/services/plans.service";
9
+ import { cardsService } from "./modules/cards/services/cards.service";
9
10
  import { iaCreditsService } from "./modules/ia-credits/services/ia-credits.service";
10
11
  import { findWhitelabel } from "./modules/whitelabel/actions/find-whitelabel.action";
11
12
  import { validateSessionAction } from "./modules/auth/actions/validate-session.action";
@@ -13,6 +14,10 @@ import { findUserById } from "./modules/users/action/find-user-by-id.action";
13
14
  import { findCurrentAccount } from "./modules/accounts/actions/find-current-account.action";
14
15
  import { listSubscriptionsAction } from "./modules/subscriptions/actions/list-subscriptions.action";
15
16
  import { findPlanByIdAction } from "./modules/subscriptions/actions/find-plan-by-id.action";
17
+ import { calculateSubscriptionAction } from "./modules/subscriptions/actions/calculate-subscription.action";
18
+ import { updateSubscriptionPlanAction } from "./modules/subscriptions/actions/update-subscription-plan.action";
19
+ import { listCardsAction } from "./modules/cards/actions/list-cards.action";
20
+ import { resolvePlanExtrasPrices } from "./modules/subscriptions/utils/resolve-plan-extras-prices";
16
21
  import { listIaCreditsAction } from "./modules/ia-credits/actions/list-ia-credits.action";
17
22
  import { projectUsersService } from "./modules/projects/services/project-users.service";
18
23
  import { listProjectUsersAction } from "./modules/projects/actions/list-project-users.action";
@@ -48,6 +53,8 @@ export {
48
53
  api,
49
54
  apiClient,
50
55
  authService,
56
+ calculateSubscriptionAction,
57
+ cardsService,
51
58
  changePasswordAction,
52
59
  confirmEmailChangeAction,
53
60
  confirmPhoneChangeAction,
@@ -67,6 +74,7 @@ export {
67
74
  iaCreditsService,
68
75
  listAccountUsersAction,
69
76
  listAvailableUsersAction,
77
+ listCardsAction,
70
78
  listIaCreditsAction,
71
79
  listProjectUsersAction,
72
80
  listSubscriptionsAction,
@@ -75,11 +83,13 @@ export {
75
83
  removeProjectUserAction,
76
84
  requestEmailChangeAction,
77
85
  requestPhoneChangeAction,
86
+ resolvePlanExtrasPrices,
78
87
  safeServerAction,
79
88
  subscriptionsService,
80
89
  twoFactorService,
81
90
  updateAccountAction,
82
91
  updateAccountUserByIdAction,
92
+ updateSubscriptionPlanAction,
83
93
  updateUserAction,
84
94
  validateSessionAction,
85
95
  whitelabelService,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server.ts"],"sourcesContent":["import 'server-only';\r\n\r\n// API Client\r\nexport { ApiClient, api, apiClient } from './infra/api/client';\r\n\r\n// Services\r\nexport { authService } from './modules/auth/services/auth.service';\r\nexport { whitelabelService } from './modules/whitelabel/services/whitelabel.service';\r\nexport { whitelabelStylesService } from './modules/whitelabel/services/whitelabel-styles.service';\r\nexport { findWhitelabelStyles } from './modules/whitelabel/actions/find-whitelabel-styles.action';\r\nexport { subscriptionsService } from './modules/subscriptions/services/subscriptions.service';\r\nexport { plansService } from './modules/subscriptions/services/plans.service';\r\nexport { iaCreditsService } from './modules/ia-credits/services/ia-credits.service';\r\n\r\n// Actions\r\nexport { findWhitelabel } from './modules/whitelabel/actions/find-whitelabel.action';\r\nexport { validateSessionAction } from './modules/auth/actions/validate-session.action';\r\nexport { findUserById } from './modules/users/action/find-user-by-id.action';\r\nexport { findCurrentAccount } from './modules/accounts/actions/find-current-account.action';\r\nexport { listSubscriptionsAction } from './modules/subscriptions/actions/list-subscriptions.action';\r\nexport { findPlanByIdAction } from './modules/subscriptions/actions/find-plan-by-id.action';\r\nexport { listIaCreditsAction } from './modules/ia-credits/actions/list-ia-credits.action';\r\n\r\n// Project Users Services & Actions (server-only)\r\nexport { projectUsersService } from './modules/projects/services/project-users.service';\r\nexport { listProjectUsersAction } from './modules/projects/actions/list-project-users.action';\r\nexport { listAvailableUsersAction } from './modules/projects/actions/list-available-users.action';\r\nexport { addProjectUserAction } from './modules/projects/actions/add-project-user.action';\r\nexport { removeProjectUserAction } from './modules/projects/actions/remove-project-user.action';\r\n\r\n// Account Services & Actions (server-only)\r\nexport { accountService } from './modules/accounts/services/account.service';\r\nexport { twoFactorService } from './modules/accounts/services/two-factor.service';\r\nexport {\r\n listAccountUsersAction,\r\n updateUserAction,\r\n updateAccountAction,\r\n updateAccountUserByIdAction,\r\n deleteAccountUserAction,\r\n deleteAccountAction,\r\n createAccountUserAction,\r\n changePasswordAction,\r\n requestEmailChangeAction,\r\n confirmEmailChangeAction,\r\n requestPhoneChangeAction,\r\n confirmPhoneChangeAction,\r\n generateTwoFactorAction,\r\n confirmTwoFactorAction,\r\n disableTwoFactorAction,\r\n} from './modules/accounts/actions/account-management.action';\r\n\r\n// Server Utils\r\nexport { getClientInfoFromRequest } from './infra/utils/client-info';\r\nexport { getUserContext } from './modules/auth/utils/get-user-context';\r\nexport { safeServerAction } from './utils/safeServerAction';\r\n"],"mappings":"AAAA,OAAO;AAGP,SAAS,WAAW,KAAK,iBAAiB;AAG1C,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAClC,SAAS,+BAA+B;AACxC,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AAGjC,SAAS,sBAAsB;AAC/B,SAAS,6BAA6B;AACtC,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AACnC,SAAS,+BAA+B;AACxC,SAAS,0BAA0B;AACnC,SAAS,2BAA2B;AAGpC,SAAS,2BAA2B;AACpC,SAAS,8BAA8B;AACvC,SAAS,gCAAgC;AACzC,SAAS,4BAA4B;AACrC,SAAS,+BAA+B;AAGxC,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,gCAAgC;AACzC,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;","names":[]}
1
+ {"version":3,"sources":["../src/server.ts"],"sourcesContent":["import 'server-only';\r\n\r\n// API Client\r\nexport { ApiClient, api, apiClient } from './infra/api/client';\r\n\r\n// Services\r\nexport { authService } from './modules/auth/services/auth.service';\r\nexport { whitelabelService } from './modules/whitelabel/services/whitelabel.service';\r\nexport { whitelabelStylesService } from './modules/whitelabel/services/whitelabel-styles.service';\r\nexport { findWhitelabelStyles } from './modules/whitelabel/actions/find-whitelabel-styles.action';\r\nexport { subscriptionsService } from './modules/subscriptions/services/subscriptions.service';\r\nexport { plansService } from './modules/subscriptions/services/plans.service';\r\nexport { cardsService } from './modules/cards/services/cards.service';\r\nexport { iaCreditsService } from './modules/ia-credits/services/ia-credits.service';\r\n\r\n// Actions\r\nexport { findWhitelabel } from './modules/whitelabel/actions/find-whitelabel.action';\r\nexport { validateSessionAction } from './modules/auth/actions/validate-session.action';\r\nexport { findUserById } from './modules/users/action/find-user-by-id.action';\r\nexport { findCurrentAccount } from './modules/accounts/actions/find-current-account.action';\r\nexport { listSubscriptionsAction } from './modules/subscriptions/actions/list-subscriptions.action';\r\nexport { findPlanByIdAction } from './modules/subscriptions/actions/find-plan-by-id.action';\r\nexport { calculateSubscriptionAction } from './modules/subscriptions/actions/calculate-subscription.action';\r\nexport { updateSubscriptionPlanAction } from './modules/subscriptions/actions/update-subscription-plan.action';\r\nexport { listCardsAction } from './modules/cards/actions/list-cards.action';\r\nexport { resolvePlanExtrasPrices } from './modules/subscriptions/utils/resolve-plan-extras-prices';\r\nexport { listIaCreditsAction } from './modules/ia-credits/actions/list-ia-credits.action';\r\n\r\n// Project Users Services & Actions (server-only)\r\nexport { projectUsersService } from './modules/projects/services/project-users.service';\r\nexport { listProjectUsersAction } from './modules/projects/actions/list-project-users.action';\r\nexport { listAvailableUsersAction } from './modules/projects/actions/list-available-users.action';\r\nexport { addProjectUserAction } from './modules/projects/actions/add-project-user.action';\r\nexport { removeProjectUserAction } from './modules/projects/actions/remove-project-user.action';\r\n\r\n// Account Services & Actions (server-only)\r\nexport { accountService } from './modules/accounts/services/account.service';\r\nexport { twoFactorService } from './modules/accounts/services/two-factor.service';\r\nexport {\r\n listAccountUsersAction,\r\n updateUserAction,\r\n updateAccountAction,\r\n updateAccountUserByIdAction,\r\n deleteAccountUserAction,\r\n deleteAccountAction,\r\n createAccountUserAction,\r\n changePasswordAction,\r\n requestEmailChangeAction,\r\n confirmEmailChangeAction,\r\n requestPhoneChangeAction,\r\n confirmPhoneChangeAction,\r\n generateTwoFactorAction,\r\n confirmTwoFactorAction,\r\n disableTwoFactorAction,\r\n} from './modules/accounts/actions/account-management.action';\r\n\r\n// Server Utils\r\nexport { getClientInfoFromRequest } from './infra/utils/client-info';\r\nexport { getUserContext } from './modules/auth/utils/get-user-context';\r\nexport { safeServerAction } from './utils/safeServerAction';\r\n"],"mappings":"AAAA,OAAO;AAGP,SAAS,WAAW,KAAK,iBAAiB;AAG1C,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAClC,SAAS,+BAA+B;AACxC,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AAGjC,SAAS,sBAAsB;AAC/B,SAAS,6BAA6B;AACtC,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AACnC,SAAS,+BAA+B;AACxC,SAAS,0BAA0B;AACnC,SAAS,mCAAmC;AAC5C,SAAS,oCAAoC;AAC7C,SAAS,uBAAuB;AAChC,SAAS,+BAA+B;AACxC,SAAS,2BAA2B;AAGpC,SAAS,2BAA2B;AACpC,SAAS,8BAA8B;AACvC,SAAS,gCAAgC;AACzC,SAAS,4BAA4B;AACrC,SAAS,+BAA+B;AAGxC,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,gCAAgC;AACzC,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;","names":[]}