@greatapps/common 1.1.659 → 1.1.661

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 (130) hide show
  1. package/dist/handlers.mjs +33 -0
  2. package/dist/handlers.mjs.map +1 -0
  3. package/dist/http.mjs +5 -0
  4. package/dist/http.mjs.map +1 -0
  5. package/dist/infra/http/api-fetch.mjs +30 -0
  6. package/dist/infra/http/api-fetch.mjs.map +1 -0
  7. package/dist/infra/route/parse-id.mjs +12 -0
  8. package/dist/infra/route/parse-id.mjs.map +1 -0
  9. package/dist/infra/route/safe-route-handler.mjs +18 -0
  10. package/dist/infra/route/safe-route-handler.mjs.map +1 -0
  11. package/dist/infra/route/search-params.mjs +11 -0
  12. package/dist/infra/route/search-params.mjs.map +1 -0
  13. package/dist/modules/cards/handlers/find-card-by-id.handler.mjs +16 -0
  14. package/dist/modules/cards/handlers/find-card-by-id.handler.mjs.map +1 -0
  15. package/dist/modules/cards/handlers/list-cards.handler.mjs +12 -0
  16. package/dist/modules/cards/handlers/list-cards.handler.mjs.map +1 -0
  17. package/dist/modules/cards/hooks/card-by-id.hook.mjs +2 -5
  18. package/dist/modules/cards/hooks/card-by-id.hook.mjs.map +1 -1
  19. package/dist/modules/cards/hooks/cards.hook.mjs +2 -5
  20. package/dist/modules/cards/hooks/cards.hook.mjs.map +1 -1
  21. package/dist/modules/charges/handlers/find-charge-by-id.handler.mjs +15 -0
  22. package/dist/modules/charges/handlers/find-charge-by-id.handler.mjs.map +1 -0
  23. package/dist/modules/charges/handlers/list-charges.handler.mjs +15 -0
  24. package/dist/modules/charges/handlers/list-charges.handler.mjs.map +1 -0
  25. package/dist/modules/charges/hooks/charge-by-id.hook.mjs +2 -3
  26. package/dist/modules/charges/hooks/charge-by-id.hook.mjs.map +1 -1
  27. package/dist/modules/charges/hooks/charges.hook.mjs +2 -3
  28. package/dist/modules/charges/hooks/charges.hook.mjs.map +1 -1
  29. package/dist/modules/ia-credits/handlers/list-ia-credits.handler.mjs +15 -0
  30. package/dist/modules/ia-credits/handlers/list-ia-credits.handler.mjs.map +1 -0
  31. package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs +5 -3
  32. package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs.map +1 -1
  33. package/dist/modules/pages/handlers/count-pages.handler.mjs +14 -0
  34. package/dist/modules/pages/handlers/count-pages.handler.mjs.map +1 -0
  35. package/dist/modules/pages/hooks/count-pages.hook.mjs +3 -4
  36. package/dist/modules/pages/hooks/count-pages.hook.mjs.map +1 -1
  37. package/dist/modules/plans/handlers/find-plan-by-id.handler.mjs +15 -0
  38. package/dist/modules/plans/handlers/find-plan-by-id.handler.mjs.map +1 -0
  39. package/dist/modules/plans/handlers/list-plans.handler.mjs +20 -0
  40. package/dist/modules/plans/handlers/list-plans.handler.mjs.map +1 -0
  41. package/dist/modules/plans/hooks/list-plans.hook.mjs +2 -3
  42. package/dist/modules/plans/hooks/list-plans.hook.mjs.map +1 -1
  43. package/dist/modules/plans/hooks/use-plan-by-id.hook.mjs +2 -3
  44. package/dist/modules/plans/hooks/use-plan-by-id.hook.mjs.map +1 -1
  45. package/dist/modules/projects/handlers/find-project.handler.mjs +16 -0
  46. package/dist/modules/projects/handlers/find-project.handler.mjs.map +1 -0
  47. package/dist/modules/projects/handlers/list-all-account-users.handler.mjs +17 -0
  48. package/dist/modules/projects/handlers/list-all-account-users.handler.mjs.map +1 -0
  49. package/dist/modules/projects/handlers/list-available-users.handler.mjs +20 -0
  50. package/dist/modules/projects/handlers/list-available-users.handler.mjs.map +1 -0
  51. package/dist/modules/projects/handlers/list-project-users.handler.mjs +20 -0
  52. package/dist/modules/projects/handlers/list-project-users.handler.mjs.map +1 -0
  53. package/dist/modules/projects/handlers/list-projects.handler.mjs +17 -0
  54. package/dist/modules/projects/handlers/list-projects.handler.mjs.map +1 -0
  55. package/dist/modules/projects/hooks/find-project.hook.mjs +2 -3
  56. package/dist/modules/projects/hooks/find-project.hook.mjs.map +1 -1
  57. package/dist/modules/projects/hooks/list-all-account-users.hook.mjs +6 -6
  58. package/dist/modules/projects/hooks/list-all-account-users.hook.mjs.map +1 -1
  59. package/dist/modules/projects/hooks/list-available-users.hook.mjs +6 -6
  60. package/dist/modules/projects/hooks/list-available-users.hook.mjs.map +1 -1
  61. package/dist/modules/projects/hooks/list-infinite-projects.hook.mjs +6 -6
  62. package/dist/modules/projects/hooks/list-infinite-projects.hook.mjs.map +1 -1
  63. package/dist/modules/projects/hooks/list-project-users.hook.mjs +6 -6
  64. package/dist/modules/projects/hooks/list-project-users.hook.mjs.map +1 -1
  65. package/dist/modules/projects/hooks/list-projects.hook.mjs +2 -3
  66. package/dist/modules/projects/hooks/list-projects.hook.mjs.map +1 -1
  67. package/dist/modules/subscriptions/handlers/list-subscriptions.handler.mjs +17 -0
  68. package/dist/modules/subscriptions/handlers/list-subscriptions.handler.mjs.map +1 -0
  69. package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs +5 -5
  70. package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs.map +1 -1
  71. package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs +5 -3
  72. package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs.map +1 -1
  73. package/dist/modules/users/handlers/list-messages.handler.mjs +36 -0
  74. package/dist/modules/users/handlers/list-messages.handler.mjs.map +1 -0
  75. package/dist/modules/users/hooks/messages.hook.mjs +7 -6
  76. package/dist/modules/users/hooks/messages.hook.mjs.map +1 -1
  77. package/dist/route.mjs +9 -0
  78. package/dist/route.mjs.map +1 -0
  79. package/package.json +14 -2
  80. package/src/handlers.ts +22 -0
  81. package/src/http.ts +1 -0
  82. package/src/infra/http/api-fetch.ts +39 -0
  83. package/src/infra/route/parse-id.ts +9 -0
  84. package/src/infra/route/safe-route-handler.ts +16 -0
  85. package/src/infra/route/search-params.ts +9 -0
  86. package/src/modules/cards/handlers/find-card-by-id.handler.ts +15 -0
  87. package/src/modules/cards/handlers/list-cards.handler.ts +10 -0
  88. package/src/modules/cards/hooks/card-by-id.hook.ts +4 -5
  89. package/src/modules/cards/hooks/cards.hook.ts +4 -5
  90. package/src/modules/charges/handlers/find-charge-by-id.handler.ts +14 -0
  91. package/src/modules/charges/handlers/list-charges.handler.ts +15 -0
  92. package/src/modules/charges/hooks/charge-by-id.hook.ts +5 -3
  93. package/src/modules/charges/hooks/charges.hook.ts +5 -4
  94. package/src/modules/ia-credits/handlers/list-ia-credits.handler.ts +14 -0
  95. package/src/modules/ia-credits/hooks/ia-credits.hook.ts +7 -3
  96. package/src/modules/pages/handlers/count-pages.handler.ts +12 -0
  97. package/src/modules/pages/hooks/count-pages.hook.ts +3 -4
  98. package/src/modules/plans/handlers/find-plan-by-id.handler.ts +14 -0
  99. package/src/modules/plans/handlers/list-plans.handler.ts +20 -0
  100. package/src/modules/plans/hooks/list-plans.hook.ts +2 -3
  101. package/src/modules/plans/hooks/use-plan-by-id.hook.ts +4 -3
  102. package/src/modules/projects/handlers/find-project.handler.ts +15 -0
  103. package/src/modules/projects/handlers/list-all-account-users.handler.ts +17 -0
  104. package/src/modules/projects/handlers/list-available-users.handler.ts +20 -0
  105. package/src/modules/projects/handlers/list-project-users.handler.ts +20 -0
  106. package/src/modules/projects/handlers/list-projects.handler.ts +17 -0
  107. package/src/modules/projects/hooks/find-project.hook.ts +3 -3
  108. package/src/modules/projects/hooks/list-all-account-users.hook.ts +8 -7
  109. package/src/modules/projects/hooks/list-available-users.hook.ts +8 -7
  110. package/src/modules/projects/hooks/list-infinite-projects.hook.ts +8 -7
  111. package/src/modules/projects/hooks/list-project-users.hook.ts +8 -7
  112. package/src/modules/projects/hooks/list-projects.hook.ts +3 -3
  113. package/src/modules/subscriptions/handlers/list-subscriptions.handler.ts +17 -0
  114. package/src/modules/subscriptions/hooks/find-active-subscription.hook.ts +8 -5
  115. package/src/modules/subscriptions/hooks/list-subscriptions.hook.ts +8 -5
  116. package/src/modules/users/handlers/list-messages.handler.ts +39 -0
  117. package/src/modules/users/hooks/messages.hook.ts +10 -8
  118. package/src/route.ts +3 -0
  119. package/src/server.ts +0 -8
  120. package/src/modules/cards/actions/find-card-by-id.action.ts +0 -8
  121. package/src/modules/cards/actions/list-cards.action.ts +0 -8
  122. package/src/modules/charges/actions/find-charge-by-id.action.ts +0 -8
  123. package/src/modules/charges/actions/list-charges.action.ts +0 -9
  124. package/src/modules/ia-credits/actions/list-ia-credits.action.ts +0 -8
  125. package/src/modules/pages/actions/count-pages.action.ts +0 -10
  126. package/src/modules/plans/actions/find-plan-by-id.action.ts +0 -8
  127. package/src/modules/plans/actions/list-plans.action.ts +0 -17
  128. package/src/modules/projects/actions/list-all-account-users.action.ts +0 -9
  129. package/src/modules/projects/actions/list-available-users.action.ts +0 -9
  130. package/src/modules/users/action/list-messages.action.ts +0 -26
@@ -1,8 +1,8 @@
1
1
  'use client';
2
2
 
3
3
  import { useInfiniteQuery } from '@tanstack/react-query';
4
- import { listProjectUsersAction } from '../actions/list-project-users.action';
5
- import { withAction } from '../../../utils/withAction';
4
+ import { apiFetch } from '../../../infra/http/api-fetch';
5
+ import type { ProjectUser, UsersPage } from '../types';
6
6
  import { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';
7
7
 
8
8
  const PAGE_SIZE = 20;
@@ -20,14 +20,15 @@ export function useListProjectUsers(projectId: number, search: string = '') {
20
20
 
21
21
  return useInfiniteQuery({
22
22
  queryKey,
23
- queryFn: ({ pageParam }) =>
24
- withAction(() =>
25
- listProjectUsersAction(projectId, {
23
+ queryFn: ({ pageParam, signal }) =>
24
+ apiFetch<UsersPage<ProjectUser>>(`/api/projects/${projectId}/users`, {
25
+ params: {
26
26
  search: search || undefined,
27
27
  page: pageParam as number,
28
28
  limit: PAGE_SIZE,
29
- })
30
- )(),
29
+ },
30
+ signal,
31
+ }),
31
32
  getNextPageParam: (lastPage, allPages) => {
32
33
  const loaded = allPages.reduce((sum, p) => sum + p.data.length, 0);
33
34
  return loaded < lastPage.total ? allPages.length + 1 : undefined;
@@ -1,9 +1,9 @@
1
1
  'use client';
2
2
 
3
3
  import { useQuery, keepPreviousData } from '@tanstack/react-query';
4
- import { listProjectsAction } from '../actions/list-projects.action';
4
+ import { apiFetch } from '../../../infra/http/api-fetch';
5
5
  import type { ListProjectsActionParams } from '../actions/list-projects.action';
6
- import { withAction } from '../../../utils/withAction';
6
+ import type { ProjectsPage } from '../types';
7
7
  import { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';
8
8
 
9
9
  export const PROJECTS_BASE_KEY = ['projects'] as const;
@@ -16,7 +16,7 @@ export function useProjects(params?: ListProjectsActionParams) {
16
16
 
17
17
  return useQuery({
18
18
  queryKey,
19
- queryFn: withAction(() => listProjectsAction(params)),
19
+ queryFn: ({ signal }) => apiFetch<ProjectsPage>('/api/projects', { params, signal }),
20
20
  staleTime: 10_000,
21
21
  placeholderData: keepPreviousData,
22
22
  });
@@ -0,0 +1,17 @@
1
+ import 'server-only';
2
+
3
+ import type { NextRequest } from 'next/server';
4
+ import { safeRouteHandler } from '../../../infra/route/safe-route-handler';
5
+ import { searchParamsToParams } from '../../../infra/route/search-params';
6
+ import { subscriptionsService } from '../services/subscriptions.service';
7
+ import type { FindSubscriptionsParams } from '../types/subscription.type';
8
+
9
+ export function createListSubscriptionsHandler() {
10
+ return async function GET(req: NextRequest) {
11
+ return safeRouteHandler(() =>
12
+ subscriptionsService.listSubscriptions(
13
+ searchParamsToParams<FindSubscriptionsParams>(req.nextUrl.searchParams)
14
+ )
15
+ );
16
+ };
17
+ }
@@ -1,9 +1,10 @@
1
1
  "use client";
2
2
 
3
3
  import { useQuery } from "@tanstack/react-query";
4
- import { listSubscriptionsAction } from "../actions/list-subscriptions.action";
4
+ import { apiFetch } from "../../../infra/http/api-fetch";
5
+ import type { PaginatedSuccessResult } from "../../../infra/api/types";
6
+ import type { Subscription } from "../types/subscription.type";
5
7
  import { SUBSCRIPTIONS_QUERY_KEY } from "../constants/query-keys.constants";
6
- import { withAction } from "../../../utils/withAction";
7
8
  import { useAuthQueryKey } from "../../../hooks/useAuthQueryKey";
8
9
 
9
10
  export function useActiveSubscription() {
@@ -11,9 +12,11 @@ export function useActiveSubscription() {
11
12
 
12
13
  return useQuery({
13
14
  queryKey,
14
- queryFn: async () => {
15
- return await withAction(listSubscriptionsAction)({ limit: 1 });
16
- },
15
+ queryFn: ({ signal }) =>
16
+ apiFetch<PaginatedSuccessResult<Subscription>>('/api/subscriptions', {
17
+ params: { limit: 1 },
18
+ signal,
19
+ }),
17
20
  staleTime: 10_000,
18
21
  });
19
22
  }
@@ -1,10 +1,10 @@
1
1
  'use client';
2
2
 
3
3
  import { useQuery } from '@tanstack/react-query';
4
- import { listSubscriptionsAction } from '../actions/list-subscriptions.action';
4
+ import { apiFetch } from '../../../infra/http/api-fetch';
5
+ import type { PaginatedSuccessResult } from '../../../infra/api/types';
5
6
  import { parseResult } from '../../../infra/utils/parser';
6
- import { SubscriptionSchema, type FindSubscriptionsParams } from '../types/subscription.type';
7
- import { withAction } from '../../../utils/withAction';
7
+ import { SubscriptionSchema, type Subscription, type FindSubscriptionsParams } from '../types/subscription.type';
8
8
  import { SUBSCRIPTIONS_QUERY_KEY } from '../constants/query-keys.constants';
9
9
  import { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';
10
10
 
@@ -13,7 +13,10 @@ export function useSubscriptions(params?: Partial<FindSubscriptionsParams>) {
13
13
 
14
14
  return useQuery({
15
15
  queryKey,
16
- queryFn: async () =>
17
- parseResult(SubscriptionSchema, await withAction(() => listSubscriptionsAction(params))()),
16
+ queryFn: async ({ signal }) =>
17
+ parseResult(
18
+ SubscriptionSchema,
19
+ await apiFetch<PaginatedSuccessResult<Subscription>>('/api/subscriptions', { params, signal })
20
+ ),
18
21
  });
19
22
  }
@@ -0,0 +1,39 @@
1
+ import 'server-only';
2
+
3
+ import type { NextRequest } from 'next/server';
4
+ import { safeRouteHandler } from '../../../infra/route/safe-route-handler';
5
+ import { searchParamsToParams } from '../../../infra/route/search-params';
6
+ import { messagesService } from '../services/messages.service';
7
+ import type { FindMessagesParams } from '../schema/messages.schema';
8
+ import { findWhitelabel } from '../../whitelabel/actions/find-whitelabel.action';
9
+
10
+ export function createListMessagesHandler() {
11
+ return async function GET(req: NextRequest) {
12
+ return safeRouteHandler(async () => {
13
+ const params = searchParamsToParams<FindMessagesParams>(req.nextUrl.searchParams);
14
+
15
+ const [result, whitelabel] = await Promise.all([
16
+ messagesService.listMessages(params),
17
+ findWhitelabel(),
18
+ ]);
19
+
20
+ const urlMap: Record<string, string> = {
21
+ pages_url: whitelabel?.pages_url ?? '',
22
+ accounts_url: whitelabel?.accounts_url ?? '',
23
+ editor_url: whitelabel?.editor_url ?? '',
24
+ };
25
+
26
+ return {
27
+ data: result.data.map((message) => ({
28
+ ...message,
29
+ url: message.url.replace(
30
+ /\{(pages_url|accounts_url|editor_url)\}/g,
31
+ (_, key) => urlMap[key] ?? ''
32
+ ),
33
+ })),
34
+ total: result.total,
35
+ totalUnread: result.totalUnread,
36
+ };
37
+ });
38
+ };
39
+ }
@@ -1,11 +1,11 @@
1
1
  'use client';
2
2
 
3
3
  import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
4
- import { listMessagesAction } from '../action/list-messages.action';
4
+ import { apiFetch } from '../../../infra/http/api-fetch';
5
5
  import { markMessageAsReadAction } from '../action/mark-message-as-read.action';
6
6
  import { markAllMessagesAsReadAction } from '../action/mark-all-messages-as-read.action';
7
7
  import { withAction } from '../../../utils/withAction';
8
- import type { FindMessagesParams } from '../schema/messages.schema';
8
+ import type { FindMessagesParams, ListMessagesApiResponse } from '../schema/messages.schema';
9
9
  import { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';
10
10
 
11
11
  export const MESSAGES_QUERY_KEY = ['messages'] as const;
@@ -17,7 +17,8 @@ export function useMessages(params?: Partial<FindMessagesParams>) {
17
17
 
18
18
  return useQuery({
19
19
  queryKey,
20
- queryFn: withAction(() => listMessagesAction(params)),
20
+ queryFn: ({ signal }) =>
21
+ apiFetch<ListMessagesApiResponse>('/api/messages', { params, signal }),
21
22
  });
22
23
  }
23
24
 
@@ -26,14 +27,15 @@ export function useInfiniteMessages(params?: Partial<Omit<FindMessagesParams, 'p
26
27
 
27
28
  return useInfiniteQuery({
28
29
  queryKey,
29
- queryFn: ({ pageParam }) =>
30
- withAction(() =>
31
- listMessagesAction({
30
+ queryFn: ({ pageParam, signal }) =>
31
+ apiFetch<ListMessagesApiResponse>('/api/messages', {
32
+ params: {
32
33
  ...params,
33
34
  page: pageParam as number,
34
35
  limit: INFINITE_MESSAGES_PAGE_SIZE,
35
- })
36
- )(),
36
+ },
37
+ signal,
38
+ }),
37
39
  getNextPageParam: (lastPage, allPages) => {
38
40
  const loaded = allPages.reduce((sum, p) => sum + p.data.length, 0);
39
41
  return loaded < lastPage.total ? allPages.length + 1 : undefined;
package/src/route.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { safeRouteHandler } from './infra/route/safe-route-handler';
2
+ export { searchParamsToParams } from './infra/route/search-params';
3
+ export { parseId } from './infra/route/parse-id';
package/src/server.ts CHANGED
@@ -27,21 +27,14 @@ export { findUserById } from './modules/users/action/find-user-by-id.action';
27
27
  export { findCurrentAccount } from './modules/accounts/actions/find-current-account.action';
28
28
  export { getAccountTokenAction } from './modules/accounts/actions/get-account-token.action';
29
29
  export { listSubscriptionsAction } from './modules/subscriptions/actions/list-subscriptions.action';
30
- export { findPlanByIdAction } from './modules/plans/actions/find-plan-by-id.action';
31
- export { listPlansAction } from './modules/plans/actions/list-plans.action';
32
30
  export { calculateSubscriptionAction } from './modules/subscriptions/actions/calculate-subscription.action';
33
31
  export { updateSubscriptionPlanAction } from './modules/subscriptions/actions/update-subscription-plan.action';
34
32
  export { updateSubscriptionPaymentAction } from './modules/subscriptions/actions/update-subscription-payment.action';
35
- export { listCardsAction } from './modules/cards/actions/list-cards.action';
36
33
  export { createCardAction } from './modules/cards/actions/create-card.action';
37
34
  export { createSetupIntentAction } from './modules/cards/actions/create-setup-intent.action';
38
- export { listChargesAction } from './modules/charges/actions/list-charges.action';
39
- export { findChargeByIdAction } from './modules/charges/actions/find-charge-by-id.action';
40
35
  export { chargeActionAction } from './modules/charges/actions/charge-action.action';
41
36
  export { resolvePlanExtrasPrices } from './modules/subscriptions/utils/resolve-plan-extras-prices';
42
37
  export { hasSubscriptionExpired } from './modules/subscriptions/utils/has-subscription-expired';
43
- export { listIaCreditsAction } from './modules/ia-credits/actions/list-ia-credits.action';
44
- export { countPagesAction } from './modules/pages/actions/count-pages.action';
45
38
 
46
39
  // Project Services & Actions (server-only)
47
40
  export { projectsService } from './modules/projects/services/projects.service';
@@ -54,7 +47,6 @@ export { deleteProjectAction } from './modules/projects/actions/delete-project.a
54
47
  // Project Users Services & Actions (server-only)
55
48
  export { projectUsersService } from './modules/projects/services/project-users.service';
56
49
  export { listProjectUsersAction } from './modules/projects/actions/list-project-users.action';
57
- export { listAvailableUsersAction } from './modules/projects/actions/list-available-users.action';
58
50
  export { addProjectUserAction } from './modules/projects/actions/add-project-user.action';
59
51
  export { removeProjectUserAction } from './modules/projects/actions/remove-project-user.action';
60
52
 
@@ -1,8 +0,0 @@
1
- 'use server';
2
-
3
- import { safeServerAction } from '../../../utils/safeServerAction';
4
- import { cardsService } from '../services/cards.service';
5
-
6
- export async function findCardByIdAction(id: number) {
7
- return safeServerAction(() => cardsService.findCardById(id));
8
- }
@@ -1,8 +0,0 @@
1
- 'use server';
2
-
3
- import { safeServerAction } from '../../../utils/safeServerAction';
4
- import { cardsService } from '../services/cards.service';
5
-
6
- export async function listCardsAction() {
7
- return safeServerAction(() => cardsService.listCards());
8
- }
@@ -1,8 +0,0 @@
1
- 'use server';
2
-
3
- import { safeServerAction } from '../../../utils/safeServerAction';
4
- import { chargesService } from '../services/charges.service';
5
-
6
- export async function findChargeByIdAction(chargeId: string | number) {
7
- return safeServerAction(() => chargesService.findChargeById(chargeId));
8
- }
@@ -1,9 +0,0 @@
1
- 'use server';
2
-
3
- import { safeServerAction } from '../../../utils/safeServerAction';
4
- import type { FindChargesParams } from '../types/charge.type';
5
- import { chargesService } from '../services/charges.service';
6
-
7
- export async function listChargesAction(params?: Partial<FindChargesParams>) {
8
- return safeServerAction(() => chargesService.listCharges(params));
9
- }
@@ -1,8 +0,0 @@
1
- 'use server';
2
-
3
- import { safeServerAction } from '../../../utils/safeServerAction';
4
- import { iaCreditsService } from '../services/ia-credits.service';
5
-
6
- export async function listIaCreditsAction(subscriptionId: number | string) {
7
- return safeServerAction(() => iaCreditsService.listOperations(subscriptionId));
8
- }
@@ -1,10 +0,0 @@
1
- 'use server';
2
-
3
- import { safeServerAction } from '../../../utils/safeServerAction';
4
- import { pagesService } from '../services/pages.service';
5
-
6
- export async function countPagesAction() {
7
- return safeServerAction(async () => ({
8
- total: await pagesService.countPages(),
9
- }));
10
- }
@@ -1,8 +0,0 @@
1
- 'use server';
2
-
3
- import { safeServerAction } from '../../../utils/safeServerAction';
4
- import { plansService } from '../services/plans.service';
5
-
6
- export async function findPlanByIdAction(idPlan: number | string) {
7
- return safeServerAction(() => plansService.findById(idPlan));
8
- }
@@ -1,17 +0,0 @@
1
- 'use server';
2
-
3
- import { plansService, safeServerAction } from '@greatapps/common/server';
4
-
5
- export async function listPlansAction() {
6
- return safeServerAction(async () => {
7
- const { data: apiPlans } = await plansService.listPlans({
8
- active: true,
9
- search: 'client',
10
- sort: 'id:ASC',
11
- });
12
-
13
- if (!apiPlans?.length) return [];
14
-
15
- return [...apiPlans].sort((a, b) => a.value - b.value);
16
- });
17
- }
@@ -1,9 +0,0 @@
1
- 'use server';
2
-
3
- import { safeServerAction } from '../../../utils/safeServerAction';
4
- import { projectUsersService } from '../services/project-users.service';
5
- import type { ListUsersParams } from '../types';
6
-
7
- export async function listAllAccountUsersAction(params: ListUsersParams = {}) {
8
- return safeServerAction(() => projectUsersService.listAllAccountUsers(params));
9
- }
@@ -1,9 +0,0 @@
1
- 'use server';
2
-
3
- import { safeServerAction } from '../../../utils/safeServerAction';
4
- import { projectUsersService } from '../services/project-users.service';
5
- import type { ListUsersParams } from '../types';
6
-
7
- export async function listAvailableUsersAction(projectId: number, params: ListUsersParams = {}) {
8
- return safeServerAction(() => projectUsersService.listNotInProject(projectId, params));
9
- }
@@ -1,26 +0,0 @@
1
- 'use server';
2
-
3
- import { safeServerAction } from '../../../utils/safeServerAction';
4
- import { messagesService } from '../services/messages.service';
5
- import type { FindMessagesParams } from '../schema/messages.schema';
6
- import { findWhitelabel } from '../../whitelabel/actions/find-whitelabel.action';
7
-
8
- export async function listMessagesAction(params?: Partial<FindMessagesParams>) {
9
- return safeServerAction(async () => {
10
- const [result, whitelabel] = await Promise.all([
11
- messagesService.listMessages(params),
12
- findWhitelabel(),
13
- ]);
14
-
15
- const urlMap: Record<string, string> = {
16
- pages_url: whitelabel?.pages_url ?? '',
17
- accounts_url: whitelabel?.accounts_url ?? '',
18
- editor_url: whitelabel?.editor_url ?? '',
19
- };
20
-
21
- return { data: result.data.map((message) => ({
22
- ...message,
23
- url: message.url.replace(/\{(pages_url|accounts_url|editor_url)\}/g, (_, key) => urlMap[key] ?? ''),
24
- })), total: result.total, totalUnread: result.totalUnread };
25
- });
26
- }