@greatapps/common 1.1.658 → 1.1.659
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/components/account/sections/TokenSection.mjs +1 -1
- package/dist/components/account/sections/TokenSection.mjs.map +1 -1
- package/dist/components/embeds/CrispEmbed.mjs +8 -29
- package/dist/components/embeds/CrispEmbed.mjs.map +1 -1
- package/dist/modules/cards/hooks/card-by-id.hook.mjs +5 -2
- package/dist/modules/cards/hooks/card-by-id.hook.mjs.map +1 -1
- package/dist/modules/cards/hooks/cards.hook.mjs +5 -2
- package/dist/modules/cards/hooks/cards.hook.mjs.map +1 -1
- package/dist/modules/charges/hooks/charge-by-id.hook.mjs +3 -2
- package/dist/modules/charges/hooks/charge-by-id.hook.mjs.map +1 -1
- package/dist/modules/charges/hooks/charges.hook.mjs +3 -2
- package/dist/modules/charges/hooks/charges.hook.mjs.map +1 -1
- package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs +3 -5
- package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs.map +1 -1
- package/dist/modules/pages/hooks/count-pages.hook.mjs +4 -3
- package/dist/modules/pages/hooks/count-pages.hook.mjs.map +1 -1
- package/dist/modules/plans/hooks/list-plans.hook.mjs +3 -2
- package/dist/modules/plans/hooks/list-plans.hook.mjs.map +1 -1
- package/dist/modules/plans/hooks/use-plan-by-id.hook.mjs +3 -2
- package/dist/modules/plans/hooks/use-plan-by-id.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/find-project.hook.mjs +3 -2
- 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 +3 -2
- package/dist/modules/projects/hooks/list-projects.hook.mjs.map +1 -1
- 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 +3 -5
- package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs.map +1 -1
- package/dist/modules/users/hooks/messages.hook.mjs +6 -7
- package/dist/modules/users/hooks/messages.hook.mjs.map +1 -1
- package/package.json +2 -14
- package/src/components/account/sections/TokenSection.tsx +1 -1
- package/src/components/embeds/CrispEmbed.tsx +11 -34
- package/src/modules/cards/hooks/card-by-id.hook.ts +5 -4
- package/src/modules/cards/hooks/cards.hook.ts +5 -4
- package/src/modules/charges/hooks/charge-by-id.hook.ts +3 -5
- package/src/modules/charges/hooks/charges.hook.ts +4 -5
- package/src/modules/ia-credits/hooks/ia-credits.hook.ts +3 -7
- package/src/modules/pages/hooks/count-pages.hook.ts +4 -3
- package/src/modules/plans/hooks/list-plans.hook.ts +3 -2
- package/src/modules/plans/hooks/use-plan-by-id.hook.ts +3 -4
- package/src/modules/projects/hooks/find-project.hook.ts +3 -3
- package/src/modules/projects/hooks/list-all-account-users.hook.ts +7 -8
- package/src/modules/projects/hooks/list-available-users.hook.ts +7 -8
- package/src/modules/projects/hooks/list-infinite-projects.hook.ts +7 -8
- package/src/modules/projects/hooks/list-project-users.hook.ts +7 -8
- package/src/modules/projects/hooks/list-projects.hook.ts +3 -3
- package/src/modules/subscriptions/hooks/find-active-subscription.hook.ts +5 -8
- package/src/modules/subscriptions/hooks/list-subscriptions.hook.ts +5 -8
- package/src/modules/users/hooks/messages.hook.ts +8 -10
- package/dist/handlers.mjs +0 -33
- package/dist/handlers.mjs.map +0 -1
- package/dist/http.mjs +0 -5
- package/dist/http.mjs.map +0 -1
- package/dist/infra/http/api-fetch.mjs +0 -30
- package/dist/infra/http/api-fetch.mjs.map +0 -1
- package/dist/infra/route/parse-id.mjs +0 -12
- package/dist/infra/route/parse-id.mjs.map +0 -1
- package/dist/infra/route/safe-route-handler.mjs +0 -18
- package/dist/infra/route/safe-route-handler.mjs.map +0 -1
- package/dist/infra/route/search-params.mjs +0 -11
- package/dist/infra/route/search-params.mjs.map +0 -1
- package/dist/modules/cards/handlers/find-card-by-id.handler.mjs +0 -16
- package/dist/modules/cards/handlers/find-card-by-id.handler.mjs.map +0 -1
- package/dist/modules/cards/handlers/list-cards.handler.mjs +0 -12
- package/dist/modules/cards/handlers/list-cards.handler.mjs.map +0 -1
- package/dist/modules/charges/handlers/find-charge-by-id.handler.mjs +0 -15
- package/dist/modules/charges/handlers/find-charge-by-id.handler.mjs.map +0 -1
- package/dist/modules/charges/handlers/list-charges.handler.mjs +0 -15
- package/dist/modules/charges/handlers/list-charges.handler.mjs.map +0 -1
- package/dist/modules/ia-credits/handlers/list-ia-credits.handler.mjs +0 -15
- package/dist/modules/ia-credits/handlers/list-ia-credits.handler.mjs.map +0 -1
- package/dist/modules/pages/handlers/count-pages.handler.mjs +0 -14
- package/dist/modules/pages/handlers/count-pages.handler.mjs.map +0 -1
- package/dist/modules/plans/handlers/find-plan-by-id.handler.mjs +0 -15
- package/dist/modules/plans/handlers/find-plan-by-id.handler.mjs.map +0 -1
- package/dist/modules/plans/handlers/list-plans.handler.mjs +0 -20
- package/dist/modules/plans/handlers/list-plans.handler.mjs.map +0 -1
- package/dist/modules/projects/handlers/find-project.handler.mjs +0 -16
- package/dist/modules/projects/handlers/find-project.handler.mjs.map +0 -1
- package/dist/modules/projects/handlers/list-all-account-users.handler.mjs +0 -17
- package/dist/modules/projects/handlers/list-all-account-users.handler.mjs.map +0 -1
- package/dist/modules/projects/handlers/list-available-users.handler.mjs +0 -20
- package/dist/modules/projects/handlers/list-available-users.handler.mjs.map +0 -1
- package/dist/modules/projects/handlers/list-project-users.handler.mjs +0 -20
- package/dist/modules/projects/handlers/list-project-users.handler.mjs.map +0 -1
- package/dist/modules/projects/handlers/list-projects.handler.mjs +0 -17
- package/dist/modules/projects/handlers/list-projects.handler.mjs.map +0 -1
- package/dist/modules/subscriptions/handlers/list-subscriptions.handler.mjs +0 -17
- package/dist/modules/subscriptions/handlers/list-subscriptions.handler.mjs.map +0 -1
- package/dist/modules/users/handlers/list-messages.handler.mjs +0 -36
- package/dist/modules/users/handlers/list-messages.handler.mjs.map +0 -1
- package/dist/route.mjs +0 -9
- package/dist/route.mjs.map +0 -1
- package/src/handlers.ts +0 -22
- package/src/http.ts +0 -1
- package/src/infra/http/api-fetch.ts +0 -39
- package/src/infra/route/parse-id.ts +0 -9
- package/src/infra/route/safe-route-handler.ts +0 -16
- package/src/infra/route/search-params.ts +0 -9
- package/src/modules/cards/handlers/find-card-by-id.handler.ts +0 -15
- package/src/modules/cards/handlers/list-cards.handler.ts +0 -10
- package/src/modules/charges/handlers/find-charge-by-id.handler.ts +0 -14
- package/src/modules/charges/handlers/list-charges.handler.ts +0 -15
- package/src/modules/ia-credits/handlers/list-ia-credits.handler.ts +0 -14
- package/src/modules/pages/handlers/count-pages.handler.ts +0 -12
- package/src/modules/plans/handlers/find-plan-by-id.handler.ts +0 -14
- package/src/modules/plans/handlers/list-plans.handler.ts +0 -20
- package/src/modules/projects/handlers/find-project.handler.ts +0 -15
- package/src/modules/projects/handlers/list-all-account-users.handler.ts +0 -17
- package/src/modules/projects/handlers/list-available-users.handler.ts +0 -20
- package/src/modules/projects/handlers/list-project-users.handler.ts +0 -20
- package/src/modules/projects/handlers/list-projects.handler.ts +0 -17
- package/src/modules/subscriptions/handlers/list-subscriptions.handler.ts +0 -17
- package/src/modules/users/handlers/list-messages.handler.ts +0 -39
- package/src/route.ts +0 -3
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import "server-only";
|
|
2
|
-
import { safeRouteHandler } from "../../../infra/route/safe-route-handler";
|
|
3
|
-
import { searchParamsToParams } from "../../../infra/route/search-params";
|
|
4
|
-
import { subscriptionsService } from "../services/subscriptions.service";
|
|
5
|
-
function createListSubscriptionsHandler() {
|
|
6
|
-
return async function GET(req) {
|
|
7
|
-
return safeRouteHandler(
|
|
8
|
-
() => subscriptionsService.listSubscriptions(
|
|
9
|
-
searchParamsToParams(req.nextUrl.searchParams)
|
|
10
|
-
)
|
|
11
|
-
);
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
createListSubscriptionsHandler
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=list-subscriptions.handler.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/subscriptions/handlers/list-subscriptions.handler.ts"],"sourcesContent":["import 'server-only';\n\nimport type { NextRequest } from 'next/server';\nimport { safeRouteHandler } from '../../../infra/route/safe-route-handler';\nimport { searchParamsToParams } from '../../../infra/route/search-params';\nimport { subscriptionsService } from '../services/subscriptions.service';\nimport type { FindSubscriptionsParams } from '../types/subscription.type';\n\nexport function createListSubscriptionsHandler() {\n return async function GET(req: NextRequest) {\n return safeRouteHandler(() =>\n subscriptionsService.listSubscriptions(\n searchParamsToParams<FindSubscriptionsParams>(req.nextUrl.searchParams)\n )\n );\n };\n}\n"],"mappings":"AAAA,OAAO;AAGP,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AAG9B,SAAS,iCAAiC;AAC/C,SAAO,eAAe,IAAI,KAAkB;AAC1C,WAAO;AAAA,MAAiB,MACtB,qBAAqB;AAAA,QACnB,qBAA8C,IAAI,QAAQ,YAAY;AAAA,MACxE;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import "server-only";
|
|
2
|
-
import { safeRouteHandler } from "../../../infra/route/safe-route-handler";
|
|
3
|
-
import { searchParamsToParams } from "../../../infra/route/search-params";
|
|
4
|
-
import { messagesService } from "../services/messages.service";
|
|
5
|
-
import { findWhitelabel } from "../../whitelabel/actions/find-whitelabel.action";
|
|
6
|
-
function createListMessagesHandler() {
|
|
7
|
-
return async function GET(req) {
|
|
8
|
-
return safeRouteHandler(async () => {
|
|
9
|
-
const params = searchParamsToParams(req.nextUrl.searchParams);
|
|
10
|
-
const [result, whitelabel] = await Promise.all([
|
|
11
|
-
messagesService.listMessages(params),
|
|
12
|
-
findWhitelabel()
|
|
13
|
-
]);
|
|
14
|
-
const urlMap = {
|
|
15
|
-
pages_url: whitelabel?.pages_url ?? "",
|
|
16
|
-
accounts_url: whitelabel?.accounts_url ?? "",
|
|
17
|
-
editor_url: whitelabel?.editor_url ?? ""
|
|
18
|
-
};
|
|
19
|
-
return {
|
|
20
|
-
data: result.data.map((message) => ({
|
|
21
|
-
...message,
|
|
22
|
-
url: message.url.replace(
|
|
23
|
-
/\{(pages_url|accounts_url|editor_url)\}/g,
|
|
24
|
-
(_, key) => urlMap[key] ?? ""
|
|
25
|
-
)
|
|
26
|
-
})),
|
|
27
|
-
total: result.total,
|
|
28
|
-
totalUnread: result.totalUnread
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export {
|
|
34
|
-
createListMessagesHandler
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=list-messages.handler.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/users/handlers/list-messages.handler.ts"],"sourcesContent":["import 'server-only';\n\nimport type { NextRequest } from 'next/server';\nimport { safeRouteHandler } from '../../../infra/route/safe-route-handler';\nimport { searchParamsToParams } from '../../../infra/route/search-params';\nimport { messagesService } from '../services/messages.service';\nimport type { FindMessagesParams } from '../schema/messages.schema';\nimport { findWhitelabel } from '../../whitelabel/actions/find-whitelabel.action';\n\nexport function createListMessagesHandler() {\n return async function GET(req: NextRequest) {\n return safeRouteHandler(async () => {\n const params = searchParamsToParams<FindMessagesParams>(req.nextUrl.searchParams);\n\n const [result, whitelabel] = await Promise.all([\n messagesService.listMessages(params),\n findWhitelabel(),\n ]);\n\n const urlMap: Record<string, string> = {\n pages_url: whitelabel?.pages_url ?? '',\n accounts_url: whitelabel?.accounts_url ?? '',\n editor_url: whitelabel?.editor_url ?? '',\n };\n\n return {\n data: result.data.map((message) => ({\n ...message,\n url: message.url.replace(\n /\\{(pages_url|accounts_url|editor_url)\\}/g,\n (_, key) => urlMap[key] ?? ''\n ),\n })),\n total: result.total,\n totalUnread: result.totalUnread,\n };\n });\n };\n}\n"],"mappings":"AAAA,OAAO;AAGP,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAEhC,SAAS,sBAAsB;AAExB,SAAS,4BAA4B;AAC1C,SAAO,eAAe,IAAI,KAAkB;AAC1C,WAAO,iBAAiB,YAAY;AAClC,YAAM,SAAS,qBAAyC,IAAI,QAAQ,YAAY;AAEhF,YAAM,CAAC,QAAQ,UAAU,IAAI,MAAM,QAAQ,IAAI;AAAA,QAC7C,gBAAgB,aAAa,MAAM;AAAA,QACnC,eAAe;AAAA,MACjB,CAAC;AAED,YAAM,SAAiC;AAAA,QACrC,WAAW,YAAY,aAAa;AAAA,QACpC,cAAc,YAAY,gBAAgB;AAAA,QAC1C,YAAY,YAAY,cAAc;AAAA,MACxC;AAEA,aAAO;AAAA,QACL,MAAM,OAAO,KAAK,IAAI,CAAC,aAAa;AAAA,UAClC,GAAG;AAAA,UACH,KAAK,QAAQ,IAAI;AAAA,YACf;AAAA,YACA,CAAC,GAAG,QAAQ,OAAO,GAAG,KAAK;AAAA,UAC7B;AAAA,QACF,EAAE;AAAA,QACF,OAAO,OAAO;AAAA,QACd,aAAa,OAAO;AAAA,MACtB;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":[]}
|
package/dist/route.mjs
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { safeRouteHandler } from "./infra/route/safe-route-handler";
|
|
2
|
-
import { searchParamsToParams } from "./infra/route/search-params";
|
|
3
|
-
import { parseId } from "./infra/route/parse-id";
|
|
4
|
-
export {
|
|
5
|
-
parseId,
|
|
6
|
-
safeRouteHandler,
|
|
7
|
-
searchParamsToParams
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=route.mjs.map
|
package/dist/route.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/route.ts"],"sourcesContent":["export { safeRouteHandler } from './infra/route/safe-route-handler';\nexport { searchParamsToParams } from './infra/route/search-params';\nexport { parseId } from './infra/route/parse-id';\n"],"mappings":"AAAA,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AACrC,SAAS,eAAe;","names":[]}
|
package/src/handlers.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export { createListCardsHandler } from './modules/cards/handlers/list-cards.handler';
|
|
2
|
-
export { createFindCardByIdHandler } from './modules/cards/handlers/find-card-by-id.handler';
|
|
3
|
-
|
|
4
|
-
export { createListChargesHandler } from './modules/charges/handlers/list-charges.handler';
|
|
5
|
-
export { createFindChargeByIdHandler } from './modules/charges/handlers/find-charge-by-id.handler';
|
|
6
|
-
|
|
7
|
-
export { createListIaCreditsHandler } from './modules/ia-credits/handlers/list-ia-credits.handler';
|
|
8
|
-
|
|
9
|
-
export { createCountPagesHandler } from './modules/pages/handlers/count-pages.handler';
|
|
10
|
-
|
|
11
|
-
export { createListPlansHandler } from './modules/plans/handlers/list-plans.handler';
|
|
12
|
-
export { createFindPlanByIdHandler } from './modules/plans/handlers/find-plan-by-id.handler';
|
|
13
|
-
|
|
14
|
-
export { createListProjectsHandler } from './modules/projects/handlers/list-projects.handler';
|
|
15
|
-
export { createFindProjectHandler } from './modules/projects/handlers/find-project.handler';
|
|
16
|
-
export { createListProjectUsersHandler } from './modules/projects/handlers/list-project-users.handler';
|
|
17
|
-
export { createListAvailableUsersHandler } from './modules/projects/handlers/list-available-users.handler';
|
|
18
|
-
export { createListAllAccountUsersHandler } from './modules/projects/handlers/list-all-account-users.handler';
|
|
19
|
-
|
|
20
|
-
export { createListSubscriptionsHandler } from './modules/subscriptions/handlers/list-subscriptions.handler';
|
|
21
|
-
|
|
22
|
-
export { createListMessagesHandler } from './modules/users/handlers/list-messages.handler';
|
package/src/http.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { apiFetch } from './infra/http/api-fetch';
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { buildQueryParams } from '../utils/params';
|
|
2
|
-
import type { ActionResult } from '../api/types';
|
|
3
|
-
|
|
4
|
-
type QueryParams = Parameters<typeof buildQueryParams>[0];
|
|
5
|
-
|
|
6
|
-
interface ApiFetchOptions {
|
|
7
|
-
params?: object;
|
|
8
|
-
signal?: AbortSignal;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export async function apiFetch<T>(path: string, options: ApiFetchOptions = {}): Promise<T> {
|
|
12
|
-
const { params, signal } = options;
|
|
13
|
-
const qs = params ? buildQueryParams(params as QueryParams) : '';
|
|
14
|
-
const url = qs ? `${path}?${qs}` : path;
|
|
15
|
-
|
|
16
|
-
const response = await fetch(url, {
|
|
17
|
-
method: 'GET',
|
|
18
|
-
credentials: 'same-origin',
|
|
19
|
-
headers: { Accept: 'application/json' },
|
|
20
|
-
signal,
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
if (!response.ok) {
|
|
24
|
-
let message = `Erro ${response.status}`;
|
|
25
|
-
try {
|
|
26
|
-
const body = (await response.json()) as ActionResult<unknown>;
|
|
27
|
-
if (body && !body.success && body.error) message = body.error;
|
|
28
|
-
} catch {
|
|
29
|
-
// corpo não-JSON — mantém a mensagem genérica
|
|
30
|
-
}
|
|
31
|
-
throw new Error(message);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const body = (await response.json()) as ActionResult<T>;
|
|
35
|
-
if (!body.success) {
|
|
36
|
-
throw new Error(body.error ?? 'Erro desconhecido');
|
|
37
|
-
}
|
|
38
|
-
return body.data as T;
|
|
39
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import 'server-only';
|
|
2
|
-
|
|
3
|
-
import { ApiError } from '../api/types';
|
|
4
|
-
|
|
5
|
-
export async function safeRouteHandler<T>(fn: () => Promise<T>): Promise<Response> {
|
|
6
|
-
try {
|
|
7
|
-
const data = await fn();
|
|
8
|
-
return Response.json({ success: true, data });
|
|
9
|
-
} catch (error) {
|
|
10
|
-
if (error instanceof ApiError) {
|
|
11
|
-
return Response.json({ success: false, error: error.message }, { status: error.statusCode });
|
|
12
|
-
}
|
|
13
|
-
console.error('[safeRouteHandler] erro inesperado', error);
|
|
14
|
-
return Response.json({ success: false, error: 'Erro interno do servidor' }, { status: 500 });
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export function searchParamsToParams<T extends object>(
|
|
2
|
-
searchParams: URLSearchParams
|
|
3
|
-
): Partial<T> {
|
|
4
|
-
const params = Object.create(null) as Partial<Record<keyof T, string>>;
|
|
5
|
-
for (const [key, value] of searchParams.entries()) {
|
|
6
|
-
params[key as keyof T] = value;
|
|
7
|
-
}
|
|
8
|
-
return params as Partial<T>;
|
|
9
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import 'server-only';
|
|
2
|
-
|
|
3
|
-
import type { NextRequest } from 'next/server';
|
|
4
|
-
import { parseId } from '../../../infra/route/parse-id';
|
|
5
|
-
import { safeRouteHandler } from '../../../infra/route/safe-route-handler';
|
|
6
|
-
import { cardsService } from '../services/cards.service';
|
|
7
|
-
|
|
8
|
-
export function createFindCardByIdHandler() {
|
|
9
|
-
return async function GET(_req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
|
|
10
|
-
return safeRouteHandler(async () => {
|
|
11
|
-
const { id } = await params;
|
|
12
|
-
return cardsService.findCardById(parseId(id));
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import 'server-only';
|
|
2
|
-
|
|
3
|
-
import { safeRouteHandler } from '../../../infra/route/safe-route-handler';
|
|
4
|
-
import { cardsService } from '../services/cards.service';
|
|
5
|
-
|
|
6
|
-
export function createListCardsHandler() {
|
|
7
|
-
return async function GET() {
|
|
8
|
-
return safeRouteHandler(() => cardsService.listCards());
|
|
9
|
-
};
|
|
10
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import 'server-only';
|
|
2
|
-
|
|
3
|
-
import type { NextRequest } from 'next/server';
|
|
4
|
-
import { safeRouteHandler } from '../../../infra/route/safe-route-handler';
|
|
5
|
-
import { chargesService } from '../services/charges.service';
|
|
6
|
-
|
|
7
|
-
export function createFindChargeByIdHandler() {
|
|
8
|
-
return async function GET(_req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
|
|
9
|
-
return safeRouteHandler(async () => {
|
|
10
|
-
const { id } = await params;
|
|
11
|
-
return chargesService.findChargeById(id);
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
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 { chargesService } from '../services/charges.service';
|
|
7
|
-
import type { FindChargesParams } from '../types/charge.type';
|
|
8
|
-
|
|
9
|
-
export function createListChargesHandler() {
|
|
10
|
-
return async function GET(req: NextRequest) {
|
|
11
|
-
return safeRouteHandler(() =>
|
|
12
|
-
chargesService.listCharges(searchParamsToParams<FindChargesParams>(req.nextUrl.searchParams))
|
|
13
|
-
);
|
|
14
|
-
};
|
|
15
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import 'server-only';
|
|
2
|
-
|
|
3
|
-
import type { NextRequest } from 'next/server';
|
|
4
|
-
import { safeRouteHandler } from '../../../infra/route/safe-route-handler';
|
|
5
|
-
import { iaCreditsService } from '../services/ia-credits.service';
|
|
6
|
-
|
|
7
|
-
export function createListIaCreditsHandler() {
|
|
8
|
-
return async function GET(_req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
|
|
9
|
-
return safeRouteHandler(async () => {
|
|
10
|
-
const { id } = await params;
|
|
11
|
-
return iaCreditsService.listOperations(id);
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import 'server-only';
|
|
2
|
-
|
|
3
|
-
import { safeRouteHandler } from '../../../infra/route/safe-route-handler';
|
|
4
|
-
import { pagesService } from '../services/pages.service';
|
|
5
|
-
|
|
6
|
-
export function createCountPagesHandler() {
|
|
7
|
-
return async function GET() {
|
|
8
|
-
return safeRouteHandler(async () => ({
|
|
9
|
-
total: await pagesService.countPages(),
|
|
10
|
-
}));
|
|
11
|
-
};
|
|
12
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import 'server-only';
|
|
2
|
-
|
|
3
|
-
import type { NextRequest } from 'next/server';
|
|
4
|
-
import { safeRouteHandler } from '../../../infra/route/safe-route-handler';
|
|
5
|
-
import { plansService } from '../services/plans.service';
|
|
6
|
-
|
|
7
|
-
export function createFindPlanByIdHandler() {
|
|
8
|
-
return async function GET(_req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
|
|
9
|
-
return safeRouteHandler(async () => {
|
|
10
|
-
const { id } = await params;
|
|
11
|
-
return plansService.findById(id);
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import 'server-only';
|
|
2
|
-
|
|
3
|
-
import { safeRouteHandler } from '../../../infra/route/safe-route-handler';
|
|
4
|
-
import { plansService } from '../services/plans.service';
|
|
5
|
-
|
|
6
|
-
export function createListPlansHandler() {
|
|
7
|
-
return async function GET() {
|
|
8
|
-
return safeRouteHandler(async () => {
|
|
9
|
-
const { data: apiPlans } = await plansService.listPlans({
|
|
10
|
-
active: true,
|
|
11
|
-
search: 'client',
|
|
12
|
-
sort: 'id:ASC',
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
if (!apiPlans?.length) return [];
|
|
16
|
-
|
|
17
|
-
return [...apiPlans].sort((a, b) => a.value - b.value);
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import 'server-only';
|
|
2
|
-
|
|
3
|
-
import type { NextRequest } from 'next/server';
|
|
4
|
-
import { parseId } from '../../../infra/route/parse-id';
|
|
5
|
-
import { safeRouteHandler } from '../../../infra/route/safe-route-handler';
|
|
6
|
-
import { projectsService } from '../services/projects.service';
|
|
7
|
-
|
|
8
|
-
export function createFindProjectHandler() {
|
|
9
|
-
return async function GET(_req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
|
|
10
|
-
return safeRouteHandler(async () => {
|
|
11
|
-
const { id } = await params;
|
|
12
|
-
return projectsService.findById(parseId(id));
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
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 { projectUsersService } from '../services/project-users.service';
|
|
7
|
-
import type { ListUsersParams } from '../types';
|
|
8
|
-
|
|
9
|
-
export function createListAllAccountUsersHandler() {
|
|
10
|
-
return async function GET(req: NextRequest) {
|
|
11
|
-
return safeRouteHandler(() =>
|
|
12
|
-
projectUsersService.listAllAccountUsers(
|
|
13
|
-
searchParamsToParams<ListUsersParams>(req.nextUrl.searchParams)
|
|
14
|
-
)
|
|
15
|
-
);
|
|
16
|
-
};
|
|
17
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import 'server-only';
|
|
2
|
-
|
|
3
|
-
import type { NextRequest } from 'next/server';
|
|
4
|
-
import { parseId } from '../../../infra/route/parse-id';
|
|
5
|
-
import { safeRouteHandler } from '../../../infra/route/safe-route-handler';
|
|
6
|
-
import { searchParamsToParams } from '../../../infra/route/search-params';
|
|
7
|
-
import { projectUsersService } from '../services/project-users.service';
|
|
8
|
-
import type { ListUsersParams } from '../types';
|
|
9
|
-
|
|
10
|
-
export function createListAvailableUsersHandler() {
|
|
11
|
-
return async function GET(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
|
|
12
|
-
return safeRouteHandler(async () => {
|
|
13
|
-
const { id } = await params;
|
|
14
|
-
return projectUsersService.listNotInProject(
|
|
15
|
-
parseId(id),
|
|
16
|
-
searchParamsToParams<ListUsersParams>(req.nextUrl.searchParams)
|
|
17
|
-
);
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import 'server-only';
|
|
2
|
-
|
|
3
|
-
import type { NextRequest } from 'next/server';
|
|
4
|
-
import { parseId } from '../../../infra/route/parse-id';
|
|
5
|
-
import { safeRouteHandler } from '../../../infra/route/safe-route-handler';
|
|
6
|
-
import { searchParamsToParams } from '../../../infra/route/search-params';
|
|
7
|
-
import { projectUsersService } from '../services/project-users.service';
|
|
8
|
-
import type { ListUsersParams } from '../types';
|
|
9
|
-
|
|
10
|
-
export function createListProjectUsersHandler() {
|
|
11
|
-
return async function GET(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
|
|
12
|
-
return safeRouteHandler(async () => {
|
|
13
|
-
const { id } = await params;
|
|
14
|
-
return projectUsersService.listInProject(
|
|
15
|
-
parseId(id),
|
|
16
|
-
searchParamsToParams<ListUsersParams>(req.nextUrl.searchParams)
|
|
17
|
-
);
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
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 { projectsService } from '../services/projects.service';
|
|
7
|
-
import type { ListProjectsActionParams } from '../actions/list-projects.action';
|
|
8
|
-
|
|
9
|
-
export function createListProjectsHandler() {
|
|
10
|
-
return async function GET(req: NextRequest) {
|
|
11
|
-
return safeRouteHandler(() =>
|
|
12
|
-
projectsService.list(
|
|
13
|
-
searchParamsToParams<ListProjectsActionParams>(req.nextUrl.searchParams)
|
|
14
|
-
)
|
|
15
|
-
);
|
|
16
|
-
};
|
|
17
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
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,39 +0,0 @@
|
|
|
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
|
-
}
|
package/src/route.ts
DELETED