@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.
- package/dist/handlers.mjs +33 -0
- package/dist/handlers.mjs.map +1 -0
- package/dist/http.mjs +5 -0
- package/dist/http.mjs.map +1 -0
- package/dist/infra/http/api-fetch.mjs +30 -0
- package/dist/infra/http/api-fetch.mjs.map +1 -0
- package/dist/infra/route/parse-id.mjs +12 -0
- package/dist/infra/route/parse-id.mjs.map +1 -0
- package/dist/infra/route/safe-route-handler.mjs +18 -0
- package/dist/infra/route/safe-route-handler.mjs.map +1 -0
- package/dist/infra/route/search-params.mjs +11 -0
- package/dist/infra/route/search-params.mjs.map +1 -0
- package/dist/modules/cards/handlers/find-card-by-id.handler.mjs +16 -0
- package/dist/modules/cards/handlers/find-card-by-id.handler.mjs.map +1 -0
- package/dist/modules/cards/handlers/list-cards.handler.mjs +12 -0
- package/dist/modules/cards/handlers/list-cards.handler.mjs.map +1 -0
- package/dist/modules/cards/hooks/card-by-id.hook.mjs +2 -5
- package/dist/modules/cards/hooks/card-by-id.hook.mjs.map +1 -1
- package/dist/modules/cards/hooks/cards.hook.mjs +2 -5
- package/dist/modules/cards/hooks/cards.hook.mjs.map +1 -1
- package/dist/modules/charges/handlers/find-charge-by-id.handler.mjs +15 -0
- package/dist/modules/charges/handlers/find-charge-by-id.handler.mjs.map +1 -0
- package/dist/modules/charges/handlers/list-charges.handler.mjs +15 -0
- package/dist/modules/charges/handlers/list-charges.handler.mjs.map +1 -0
- package/dist/modules/charges/hooks/charge-by-id.hook.mjs +2 -3
- package/dist/modules/charges/hooks/charge-by-id.hook.mjs.map +1 -1
- package/dist/modules/charges/hooks/charges.hook.mjs +2 -3
- package/dist/modules/charges/hooks/charges.hook.mjs.map +1 -1
- package/dist/modules/ia-credits/handlers/list-ia-credits.handler.mjs +15 -0
- package/dist/modules/ia-credits/handlers/list-ia-credits.handler.mjs.map +1 -0
- package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs +5 -3
- package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs.map +1 -1
- package/dist/modules/pages/handlers/count-pages.handler.mjs +14 -0
- package/dist/modules/pages/handlers/count-pages.handler.mjs.map +1 -0
- package/dist/modules/pages/hooks/count-pages.hook.mjs +3 -4
- package/dist/modules/pages/hooks/count-pages.hook.mjs.map +1 -1
- package/dist/modules/plans/handlers/find-plan-by-id.handler.mjs +15 -0
- package/dist/modules/plans/handlers/find-plan-by-id.handler.mjs.map +1 -0
- package/dist/modules/plans/handlers/list-plans.handler.mjs +20 -0
- package/dist/modules/plans/handlers/list-plans.handler.mjs.map +1 -0
- package/dist/modules/plans/hooks/list-plans.hook.mjs +2 -3
- package/dist/modules/plans/hooks/list-plans.hook.mjs.map +1 -1
- package/dist/modules/plans/hooks/use-plan-by-id.hook.mjs +2 -3
- package/dist/modules/plans/hooks/use-plan-by-id.hook.mjs.map +1 -1
- package/dist/modules/projects/handlers/find-project.handler.mjs +16 -0
- package/dist/modules/projects/handlers/find-project.handler.mjs.map +1 -0
- package/dist/modules/projects/handlers/list-all-account-users.handler.mjs +17 -0
- package/dist/modules/projects/handlers/list-all-account-users.handler.mjs.map +1 -0
- package/dist/modules/projects/handlers/list-available-users.handler.mjs +20 -0
- package/dist/modules/projects/handlers/list-available-users.handler.mjs.map +1 -0
- package/dist/modules/projects/handlers/list-project-users.handler.mjs +20 -0
- package/dist/modules/projects/handlers/list-project-users.handler.mjs.map +1 -0
- package/dist/modules/projects/handlers/list-projects.handler.mjs +17 -0
- package/dist/modules/projects/handlers/list-projects.handler.mjs.map +1 -0
- package/dist/modules/projects/hooks/find-project.hook.mjs +2 -3
- package/dist/modules/projects/hooks/find-project.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/list-all-account-users.hook.mjs +6 -6
- package/dist/modules/projects/hooks/list-all-account-users.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/list-available-users.hook.mjs +6 -6
- package/dist/modules/projects/hooks/list-available-users.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/list-infinite-projects.hook.mjs +6 -6
- package/dist/modules/projects/hooks/list-infinite-projects.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/list-project-users.hook.mjs +6 -6
- package/dist/modules/projects/hooks/list-project-users.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/list-projects.hook.mjs +2 -3
- package/dist/modules/projects/hooks/list-projects.hook.mjs.map +1 -1
- package/dist/modules/subscriptions/handlers/list-subscriptions.handler.mjs +17 -0
- package/dist/modules/subscriptions/handlers/list-subscriptions.handler.mjs.map +1 -0
- package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs +5 -5
- package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs.map +1 -1
- package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs +5 -3
- package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs.map +1 -1
- package/dist/modules/users/handlers/list-messages.handler.mjs +36 -0
- package/dist/modules/users/handlers/list-messages.handler.mjs.map +1 -0
- package/dist/modules/users/hooks/messages.hook.mjs +7 -6
- package/dist/modules/users/hooks/messages.hook.mjs.map +1 -1
- package/dist/route.mjs +9 -0
- package/dist/route.mjs.map +1 -0
- package/package.json +14 -2
- package/src/handlers.ts +22 -0
- package/src/http.ts +1 -0
- package/src/infra/http/api-fetch.ts +39 -0
- package/src/infra/route/parse-id.ts +9 -0
- package/src/infra/route/safe-route-handler.ts +16 -0
- package/src/infra/route/search-params.ts +9 -0
- package/src/modules/cards/handlers/find-card-by-id.handler.ts +15 -0
- package/src/modules/cards/handlers/list-cards.handler.ts +10 -0
- package/src/modules/cards/hooks/card-by-id.hook.ts +4 -5
- package/src/modules/cards/hooks/cards.hook.ts +4 -5
- package/src/modules/charges/handlers/find-charge-by-id.handler.ts +14 -0
- package/src/modules/charges/handlers/list-charges.handler.ts +15 -0
- package/src/modules/charges/hooks/charge-by-id.hook.ts +5 -3
- package/src/modules/charges/hooks/charges.hook.ts +5 -4
- package/src/modules/ia-credits/handlers/list-ia-credits.handler.ts +14 -0
- package/src/modules/ia-credits/hooks/ia-credits.hook.ts +7 -3
- package/src/modules/pages/handlers/count-pages.handler.ts +12 -0
- package/src/modules/pages/hooks/count-pages.hook.ts +3 -4
- package/src/modules/plans/handlers/find-plan-by-id.handler.ts +14 -0
- package/src/modules/plans/handlers/list-plans.handler.ts +20 -0
- package/src/modules/plans/hooks/list-plans.hook.ts +2 -3
- package/src/modules/plans/hooks/use-plan-by-id.hook.ts +4 -3
- package/src/modules/projects/handlers/find-project.handler.ts +15 -0
- package/src/modules/projects/handlers/list-all-account-users.handler.ts +17 -0
- package/src/modules/projects/handlers/list-available-users.handler.ts +20 -0
- package/src/modules/projects/handlers/list-project-users.handler.ts +20 -0
- package/src/modules/projects/handlers/list-projects.handler.ts +17 -0
- package/src/modules/projects/hooks/find-project.hook.ts +3 -3
- package/src/modules/projects/hooks/list-all-account-users.hook.ts +8 -7
- package/src/modules/projects/hooks/list-available-users.hook.ts +8 -7
- package/src/modules/projects/hooks/list-infinite-projects.hook.ts +8 -7
- package/src/modules/projects/hooks/list-project-users.hook.ts +8 -7
- package/src/modules/projects/hooks/list-projects.hook.ts +3 -3
- package/src/modules/subscriptions/handlers/list-subscriptions.handler.ts +17 -0
- package/src/modules/subscriptions/hooks/find-active-subscription.hook.ts +8 -5
- package/src/modules/subscriptions/hooks/list-subscriptions.hook.ts +8 -5
- package/src/modules/users/handlers/list-messages.handler.ts +39 -0
- package/src/modules/users/hooks/messages.hook.ts +10 -8
- package/src/route.ts +3 -0
- package/src/server.ts +0 -8
- package/src/modules/cards/actions/find-card-by-id.action.ts +0 -8
- package/src/modules/cards/actions/list-cards.action.ts +0 -8
- package/src/modules/charges/actions/find-charge-by-id.action.ts +0 -8
- package/src/modules/charges/actions/list-charges.action.ts +0 -9
- package/src/modules/ia-credits/actions/list-ia-credits.action.ts +0 -8
- package/src/modules/pages/actions/count-pages.action.ts +0 -10
- package/src/modules/plans/actions/find-plan-by-id.action.ts +0 -8
- package/src/modules/plans/actions/list-plans.action.ts +0 -17
- package/src/modules/projects/actions/list-all-account-users.action.ts +0 -9
- package/src/modules/projects/actions/list-available-users.action.ts +0 -9
- 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 {
|
|
5
|
-
import {
|
|
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
|
-
|
|
25
|
-
|
|
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 {
|
|
4
|
+
import { apiFetch } from '../../../infra/http/api-fetch';
|
|
5
5
|
import type { ListProjectsActionParams } from '../actions/list-projects.action';
|
|
6
|
-
import {
|
|
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:
|
|
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 {
|
|
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:
|
|
15
|
-
|
|
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 {
|
|
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(
|
|
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 {
|
|
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:
|
|
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
|
-
|
|
31
|
-
|
|
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
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 { 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
|
-
}
|