nextjs-cms 0.9.36 → 0.9.37

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 (113) hide show
  1. package/dist/api/actions/pages.d.ts +3 -3
  2. package/dist/api/trpc/root.d.ts +3 -3
  3. package/dist/api/trpc/routers/navigation.d.ts +3 -3
  4. package/dist/api/trpc/server.d.ts +9 -9
  5. package/dist/cli/lib/update-sections.d.ts.map +1 -1
  6. package/dist/cli/lib/update-sections.js +43 -10
  7. package/dist/core/config/config-loader.d.ts +2 -2
  8. package/dist/core/fields/date-range.d.ts +4 -4
  9. package/dist/core/fields/slug.d.ts +55 -3
  10. package/dist/core/fields/slug.d.ts.map +1 -1
  11. package/dist/core/fields/slug.js +56 -2
  12. package/dist/core/sections/category.d.ts +4 -4
  13. package/dist/core/sections/hasItems.d.ts +4 -4
  14. package/dist/core/sections/section.d.ts +3 -3
  15. package/dist/core/sections/simple.d.ts +4 -4
  16. package/dist/translations/base/en.d.ts +3 -0
  17. package/dist/translations/base/en.d.ts.map +1 -1
  18. package/dist/translations/base/en.js +3 -0
  19. package/dist/translations/client.d.ts +40 -4
  20. package/dist/translations/client.d.ts.map +1 -1
  21. package/dist/translations/server.d.ts +40 -4
  22. package/dist/translations/server.d.ts.map +1 -1
  23. package/package.json +6 -3
  24. package/dist/api/axios/axiosInstance.d.ts +0 -2
  25. package/dist/api/axios/axiosInstance.d.ts.map +0 -1
  26. package/dist/api/axios/axiosInstance.js +0 -8
  27. package/dist/api/client.d.ts +0 -30
  28. package/dist/api/client.d.ts.map +0 -1
  29. package/dist/api/client.js +0 -82
  30. package/dist/api/index.d.ts +0 -2
  31. package/dist/api/index.d.ts.map +0 -1
  32. package/dist/api/index.js +0 -0
  33. package/dist/api/lib/serverActions.d.ts +0 -338
  34. package/dist/api/lib/serverActions.d.ts.map +0 -1
  35. package/dist/api/lib/serverActions.js +0 -1517
  36. package/dist/api/root.d.ts +0 -19
  37. package/dist/api/root.d.ts.map +0 -1
  38. package/dist/api/root.js +0 -50
  39. package/dist/api/routers/accountSettings.d.ts +0 -66
  40. package/dist/api/routers/accountSettings.d.ts.map +0 -1
  41. package/dist/api/routers/accountSettings.js +0 -202
  42. package/dist/api/routers/admins.d.ts +0 -112
  43. package/dist/api/routers/admins.d.ts.map +0 -1
  44. package/dist/api/routers/admins.js +0 -323
  45. package/dist/api/routers/auth.d.ts +0 -54
  46. package/dist/api/routers/auth.d.ts.map +0 -1
  47. package/dist/api/routers/auth.js +0 -50
  48. package/dist/api/routers/categorySection.d.ts +0 -105
  49. package/dist/api/routers/categorySection.d.ts.map +0 -1
  50. package/dist/api/routers/categorySection.js +0 -49
  51. package/dist/api/routers/config.d.ts +0 -48
  52. package/dist/api/routers/config.d.ts.map +0 -1
  53. package/dist/api/routers/config.js +0 -18
  54. package/dist/api/routers/cpanel.d.ts +0 -82
  55. package/dist/api/routers/cpanel.d.ts.map +0 -1
  56. package/dist/api/routers/cpanel.js +0 -216
  57. package/dist/api/routers/fields.d.ts +0 -35
  58. package/dist/api/routers/fields.d.ts.map +0 -1
  59. package/dist/api/routers/fields.js +0 -81
  60. package/dist/api/routers/files.d.ts +0 -34
  61. package/dist/api/routers/files.d.ts.map +0 -1
  62. package/dist/api/routers/files.js +0 -14
  63. package/dist/api/routers/gallery.d.ts +0 -35
  64. package/dist/api/routers/gallery.d.ts.map +0 -1
  65. package/dist/api/routers/gallery.js +0 -92
  66. package/dist/api/routers/hasItemsSection.d.ts +0 -194
  67. package/dist/api/routers/hasItemsSection.d.ts.map +0 -1
  68. package/dist/api/routers/hasItemsSection.js +0 -86
  69. package/dist/api/routers/logs.d.ts +0 -59
  70. package/dist/api/routers/logs.d.ts.map +0 -1
  71. package/dist/api/routers/logs.js +0 -76
  72. package/dist/api/routers/navigation.d.ts +0 -50
  73. package/dist/api/routers/navigation.d.ts.map +0 -1
  74. package/dist/api/routers/navigation.js +0 -11
  75. package/dist/api/routers/simpleSection.d.ts +0 -93
  76. package/dist/api/routers/simpleSection.d.ts.map +0 -1
  77. package/dist/api/routers/simpleSection.js +0 -54
  78. package/dist/api/server.d.ts +0 -2748
  79. package/dist/api/server.d.ts.map +0 -1
  80. package/dist/api/server.js +0 -100
  81. package/dist/api/trpc/error-logging.d.ts +0 -14
  82. package/dist/api/trpc/error-logging.d.ts.map +0 -1
  83. package/dist/api/trpc/error-logging.js +0 -75
  84. package/dist/api/trpc.d.ts +0 -111
  85. package/dist/api/trpc.d.ts.map +0 -1
  86. package/dist/api/trpc.js +0 -99
  87. package/dist/api/utils/async-caller-proxy.d.ts +0 -2
  88. package/dist/api/utils/async-caller-proxy.d.ts.map +0 -1
  89. package/dist/api/utils/async-caller-proxy.js +0 -36
  90. package/dist/api/utils/lazy-caller-proxy.d.ts +0 -2
  91. package/dist/api/utils/lazy-caller-proxy.d.ts.map +0 -1
  92. package/dist/api/utils/lazy-caller-proxy.js +0 -36
  93. package/dist/api/utils/router-types.d.ts +0 -7
  94. package/dist/api/utils/router-types.d.ts.map +0 -1
  95. package/dist/api/utils/router-types.js +0 -0
  96. package/dist/auth/axios/axiosInstance.d.ts +0 -2
  97. package/dist/auth/axios/axiosInstance.d.ts.map +0 -1
  98. package/dist/auth/axios/axiosInstance.js +0 -8
  99. package/dist/auth/hooks/useAxiosPrivate.d.ts +0 -5
  100. package/dist/auth/hooks/useAxiosPrivate.d.ts.map +0 -1
  101. package/dist/auth/hooks/useAxiosPrivate.js +0 -74
  102. package/dist/auth/trpc.d.ts +0 -6
  103. package/dist/auth/trpc.d.ts.map +0 -1
  104. package/dist/auth/trpc.js +0 -81
  105. package/dist/plugins/manifest.d.ts +0 -28
  106. package/dist/plugins/manifest.d.ts.map +0 -1
  107. package/dist/plugins/manifest.js +0 -83
  108. package/dist/plugins/registry.d.ts +0 -22
  109. package/dist/plugins/registry.d.ts.map +0 -1
  110. package/dist/plugins/registry.js +0 -25
  111. package/dist/utils/log.d.ts +0 -18
  112. package/dist/utils/log.d.ts.map +0 -1
  113.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G,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAA7o+B,CAAC;;;;;+BAAsE,CAAC;;;;;;+BAA2G,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAxF10Z,OAAO,CAAC,SAAS,CAAC;EAqFvD;AAED,YAAY,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA"}
@@ -1,100 +0,0 @@
1
- import 'server-only';
2
- import { createHydrationHelpers } from '@trpc/react-query/rsc';
3
- import { fetchRequestHandler } from '@trpc/server/adapters/fetch';
4
- import { headers } from 'next/headers';
5
- import { cache } from 'react';
6
- import { getConfigImportVersion } from '../core/config/index.js';
7
- import { loadPlugins } from '../plugins/loader.js';
8
- import { coreRouters } from './root.js';
9
- import { createCallerFactory, createTRPCContext, router } from './trpc.js';
10
- import { createQueryClient } from './trpc/query-client.js';
11
- import { createAsyncCallerProxy } from './utils/async-caller-proxy.js';
12
- export function createTRPCRouter(opts = {}) {
13
- const userRouters = (opts.routers ?? {});
14
- for (const key of Object.keys(userRouters)) {
15
- if (key in coreRouters) {
16
- throw new Error(`[trpc] Router key "${key}" conflicts with a core router.`);
17
- }
18
- }
19
- const appRouter = router({
20
- ...coreRouters,
21
- ...userRouters,
22
- });
23
- let cachedRouter = null;
24
- let pendingRouter = null;
25
- let cachedVersion = -1;
26
- let pendingVersion = -1;
27
- async function getMergedRouter() {
28
- const currentVersion = getConfigImportVersion();
29
- if (cachedRouter && cachedVersion === currentVersion) {
30
- return cachedRouter;
31
- }
32
- if (pendingRouter && pendingVersion === currentVersion) {
33
- return pendingRouter;
34
- }
35
- cachedRouter = null;
36
- pendingVersion = currentVersion;
37
- pendingRouter = (async () => {
38
- const loadedPlugins = await loadPlugins();
39
- const pluginRouters = {};
40
- const seen = new Set([...Object.keys(coreRouters), ...Object.keys(userRouters)]);
41
- for (const plugin of loadedPlugins) {
42
- if (!plugin.plugin.router)
43
- continue;
44
- if (seen.has(plugin.routerKey)) {
45
- const message = `[plugins] Router key "${plugin.routerKey}" conflicts with core/user router. Skipping.`;
46
- throw new Error(message);
47
- }
48
- pluginRouters[plugin.routerKey] = plugin.plugin.router;
49
- seen.add(plugin.routerKey);
50
- }
51
- const mergedRouter = router({
52
- ...coreRouters,
53
- ...pluginRouters,
54
- ...userRouters,
55
- });
56
- cachedRouter = mergedRouter;
57
- cachedVersion = currentVersion;
58
- return mergedRouter;
59
- })();
60
- try {
61
- return await pendingRouter;
62
- }
63
- finally {
64
- if (pendingVersion === currentVersion) {
65
- pendingRouter = null;
66
- }
67
- }
68
- }
69
- const createContext = cache(async () => {
70
- const heads = new Headers(await headers());
71
- heads.set('x-trpc-source', 'rsc');
72
- return createTRPCContext({
73
- headers: heads,
74
- });
75
- });
76
- const getQueryClient = cache(createQueryClient);
77
- const getCaller = cache(async () => (await getMergedRouter()).createCaller(await createContext()));
78
- const callerProxy = createAsyncCallerProxy(getCaller);
79
- const helpers = createHydrationHelpers(callerProxy, getQueryClient);
80
- const handler = async (req) => fetchRequestHandler({
81
- endpoint: '/api/trpc',
82
- req,
83
- router: await getMergedRouter(),
84
- createContext: () => createTRPCContext({ headers: req.headers }),
85
- onError: opts.onError ??
86
- (process.env.NODE_ENV === 'development'
87
- ? ({ path, error }) => {
88
- console.error(`tRPC failed on ${path ?? '<no-path>'}: ${error.message}`);
89
- }
90
- : undefined),
91
- });
92
- return {
93
- appRouter,
94
- handler: { GET: handler, POST: handler },
95
- api: helpers.trpc,
96
- HydrateClient: helpers.HydrateClient,
97
- createCaller: createCallerFactory(appRouter),
98
- getRouter: getMergedRouter,
99
- };
100
- }
@@ -1,14 +0,0 @@
1
- type TRPCLogPhase = 'trpc-http-handler' | 'trpc-router-load' | 'trpc-procedure';
2
- interface LogTRPCErrorOptions {
3
- phase: TRPCLogPhase;
4
- error: unknown;
5
- path?: string | null;
6
- type?: string;
7
- input?: unknown;
8
- req?: Request;
9
- source?: string | null;
10
- }
11
- export declare function getHeaderValue(headers: unknown, name: string): string | null;
12
- export declare function logTRPCError({ phase, error, path, type, input, req, source }: LogTRPCErrorOptions): void;
13
- export {};
14
- //# sourceMappingURL=error-logging.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error-logging.d.ts","sourceRoot":"","sources":["../../../src/api/trpc/error-logging.ts"],"names":[],"mappings":"AAEA,KAAK,YAAY,GAAG,mBAAmB,GAAG,kBAAkB,GAAG,gBAAgB,CAAA;AAE/E,UAAU,mBAAmB;IACzB,KAAK,EAAE,YAAY,CAAA;IACnB,KAAK,EAAE,OAAO,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB;AAkDD,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAO5E;AAED,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,mBAAmB,GAAG,IAAI,CA4BxG"}
@@ -1,75 +0,0 @@
1
- import { inspect } from 'node:util';
2
- const SENSITIVE_KEY_PATTERN = /authorization|cookie|csrf|credential|password|secret|token|key/i;
3
- const MAX_REDACTION_DEPTH = 8;
4
- function shouldLogTRPCErrors() {
5
- return process.env.NODE_ENV !== 'test' || process.env.NEXTJS_CMS_DEBUG_TRPC === '1';
6
- }
7
- function redactSensitiveValues(value, depth = 0, seen = new WeakSet()) {
8
- if (depth > MAX_REDACTION_DEPTH)
9
- return '[MaxDepth]';
10
- if (value === null || typeof value !== 'object')
11
- return value;
12
- if (value instanceof Date)
13
- return value.toISOString();
14
- if (value instanceof Error)
15
- return serializeError(value);
16
- if (Array.isArray(value))
17
- return value.map((item) => redactSensitiveValues(item, depth + 1, seen));
18
- if (seen.has(value))
19
- return '[Circular]';
20
- seen.add(value);
21
- return Object.fromEntries(Object.entries(value).map(([key, entry]) => [
22
- key,
23
- SENSITIVE_KEY_PATTERN.test(key) ? '[Redacted]' : redactSensitiveValues(entry, depth + 1, seen),
24
- ]));
25
- }
26
- function serializeError(error) {
27
- if (!(error instanceof Error)) {
28
- return inspect(error, { colors: false, depth: null });
29
- }
30
- const errorWithMetadata = error;
31
- return {
32
- name: error.name,
33
- message: error.message,
34
- code: errorWithMetadata.code,
35
- digest: errorWithMetadata.digest,
36
- stack: error.stack,
37
- cause: errorWithMetadata.cause ? serializeError(errorWithMetadata.cause) : undefined,
38
- inspected: inspect(error, { colors: false, depth: null }),
39
- };
40
- }
41
- export function getHeaderValue(headers, name) {
42
- if (headers instanceof Headers)
43
- return headers.get(name);
44
- if (!headers || typeof headers !== 'object')
45
- return null;
46
- const value = headers[name] ?? headers[name.toLowerCase()];
47
- if (Array.isArray(value))
48
- return value.join(', ');
49
- return typeof value === 'string' ? value : null;
50
- }
51
- export function logTRPCError({ phase, error, path, type, input, req, source }) {
52
- if (!shouldLogTRPCErrors())
53
- return;
54
- const payload = {
55
- phase,
56
- path: path ?? '<no-path>',
57
- type,
58
- input: input === undefined ? undefined : redactSensitiveValues(input),
59
- request: req
60
- ? {
61
- url: req.url,
62
- method: req.method,
63
- trpcSource: req.headers.get('x-trpc-source'),
64
- }
65
- : undefined,
66
- trpcSource: source,
67
- error: serializeError(error),
68
- };
69
- console.error('[nextjs-cms] tRPC error', inspect(payload, {
70
- colors: false,
71
- compact: false,
72
- depth: null,
73
- breakLength: 120,
74
- }));
75
- }
@@ -1,111 +0,0 @@
1
- import superjson from 'superjson';
2
- /**
3
- * Creates context for an incoming request
4
- * @link https://trpc.io/docs/v11/context
5
- */
6
- export declare const createTRPCContext: (opts: {
7
- headers: Headers;
8
- }) => Promise<{
9
- headers: Headers;
10
- db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../db/schema.js")> & {
11
- $client: import("mysql2/promise").Pool;
12
- };
13
- session: import("../index.js").Session | null;
14
- }>;
15
- type Context = Awaited<ReturnType<typeof createTRPCContext>>;
16
- export type TRPCContext = Context;
17
- export declare const transformer: {
18
- input: typeof superjson;
19
- output: typeof superjson;
20
- };
21
- /**
22
- * Create a server-side caller
23
- * @see https://trpc.io/docs/server/server-side-calls
24
- */
25
- export declare const createCallerFactory: import("@trpc/server").TRPCRouterCallerFactory<{
26
- ctx: {
27
- headers: Headers;
28
- db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../db/schema.js")> & {
29
- $client: import("mysql2/promise").Pool;
30
- };
31
- session: import("../index.js").Session | null;
32
- };
33
- meta: object;
34
- errorShape: {
35
- data: {
36
- zodError: import("zod").ZodFlattenedError<unknown, string> | null;
37
- code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
38
- httpStatus: number;
39
- path?: string;
40
- stack?: string;
41
- };
42
- message: string;
43
- code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
44
- };
45
- transformer: true;
46
- }>;
47
- /**
48
- * This is how you create new routers and sub-routers in your tRPC API
49
- * @see https://trpc.io/docs/router
50
- */
51
- export declare const router: import("@trpc/server").TRPCRouterBuilder<{
52
- ctx: {
53
- headers: Headers;
54
- db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../db/schema.js")> & {
55
- $client: import("mysql2/promise").Pool;
56
- };
57
- session: import("../index.js").Session | null;
58
- };
59
- meta: object;
60
- errorShape: {
61
- data: {
62
- zodError: import("zod").ZodFlattenedError<unknown, string> | null;
63
- code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
64
- httpStatus: number;
65
- path?: string;
66
- stack?: string;
67
- };
68
- message: string;
69
- code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
70
- };
71
- transformer: true;
72
- }>;
73
- /**
74
- * Public procedure that doesn't require authentication
75
- */
76
- export declare const publicProcedure: import("@trpc/server").TRPCProcedureBuilder<{
77
- headers: Headers;
78
- db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../db/schema.js")> & {
79
- $client: import("mysql2/promise").Pool;
80
- };
81
- session: import("../index.js").Session | null;
82
- }, object, object, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, false>;
83
- /**
84
- * Private procedure that uses the `isAuthedMiddleware` middleware to require authentication
85
- * @see https://trpc.io/docs/procedures
86
- */
87
- export declare const privateProcedure: import("@trpc/server").TRPCProcedureBuilder<{
88
- headers: Headers;
89
- db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../db/schema.js")> & {
90
- $client: import("mysql2/promise").Pool;
91
- };
92
- session: import("../index.js").Session | null;
93
- }, object, {
94
- session: {
95
- user: import("../index.js").User;
96
- };
97
- }, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, false>;
98
- type PrivilegeOperation = 'C' | 'U' | 'D';
99
- export declare const pluginProcedure: (sectionName: string, requiredRole?: PrivilegeOperation) => import("@trpc/server").TRPCProcedureBuilder<{
100
- headers: Headers;
101
- db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../db/schema.js")> & {
102
- $client: import("mysql2/promise").Pool;
103
- };
104
- session: import("../index.js").Session | null;
105
- }, object, {
106
- session: {
107
- user: import("../index.js").User;
108
- };
109
- }, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, false>;
110
- export {};
111
- //# sourceMappingURL=trpc.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trpc.d.ts","sourceRoot":"","sources":["../../src/api/trpc.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,WAAW,CAAA;AASjC;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAU,MAAM;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE;aAAT,OAAO;;;;;EAQ/D,CAAA;AAED,KAAK,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC,CAAA;AAC5D,MAAM,MAAM,WAAW,GAAG,OAAO,CAAA;AAEjC,eAAO,MAAM,WAAW;;;CAGvB,CAAA;AAkBD;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;iBAtCyB,OAAO;;;;;;;;;;;;;;;;;;;EAsCR,CAAA;AAiBxD;;;GAGG;AACH,eAAO,MAAM,MAAM;;iBA3DsC,OAAO;;;;;;;;;;;;;;;;;;;EA2DlC,CAAA;AAE9B;;GAEG;AACH,eAAO,MAAM,eAAe;aAhE6B,OAAO;;;;;yLAgEtB,CAAA;AAE1C;;;GAGG;AACH,eAAO,MAAM,gBAAgB;aAtE4B,OAAO;;;;;;;;;yKAsEG,CAAA;AAEnE,KAAK,kBAAkB,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;AAoCzC,eAAO,MAAM,eAAe,GAAI,aAAa,MAAM,EAAE,eAAe,kBAAkB;aA5G7B,OAAO;;;;;;;;;yKA6GO,CAAA"}
package/dist/api/trpc.js DELETED
@@ -1,99 +0,0 @@
1
- import { initTRPC, TRPCError } from '@trpc/server';
2
- import superjson from 'superjson';
3
- import { ZodError } from 'zod';
4
- import auth from '../auth/index.js';
5
- import { db } from '../db/client.js';
6
- import { and, eq } from 'drizzle-orm';
7
- import { AdminPrivilegesTable } from '../db/schema.js';
8
- import getString from '../translations/index.js';
9
- import { isDashboardOverridePlugin } from '../plugins/loader.js';
10
- /**
11
- * Creates context for an incoming request
12
- * @link https://trpc.io/docs/v11/context
13
- */
14
- export const createTRPCContext = async (opts) => {
15
- const session = await auth();
16
- return {
17
- db,
18
- session,
19
- ...opts,
20
- };
21
- };
22
- export const transformer = {
23
- input: superjson,
24
- output: superjson,
25
- };
26
- const t = initTRPC.context().create({
27
- transformer: transformer,
28
- errorFormatter({ shape, error }) {
29
- return {
30
- ...shape,
31
- data: {
32
- ...shape.data,
33
- zodError: error.cause instanceof ZodError ? error.cause.flatten() : null,
34
- },
35
- };
36
- },
37
- /*errorFormatter({ shape }) {
38
- return shape
39
- },*/
40
- });
41
- /**
42
- * Create a server-side caller
43
- * @see https://trpc.io/docs/server/server-side-calls
44
- */
45
- export const createCallerFactory = t.createCallerFactory;
46
- const isAuthedMiddleware = t.middleware(async ({ ctx, next }) => {
47
- if (!ctx.session || !ctx.session.user)
48
- throw new TRPCError({ code: 'UNAUTHORIZED', message: getString('noTokenProvided', 'en') });
49
- return next({
50
- /*ctx: {
51
- user: user,
52
- headers: ctx.opts.headers,
53
- },*/
54
- ctx: {
55
- // infers the `session` as non-nullable
56
- session: { ...ctx.session, user: ctx.session.user },
57
- },
58
- });
59
- });
60
- /**
61
- * This is how you create new routers and sub-routers in your tRPC API
62
- * @see https://trpc.io/docs/router
63
- */
64
- export const router = t.router;
65
- /**
66
- * Public procedure that doesn't require authentication
67
- */
68
- export const publicProcedure = t.procedure;
69
- /**
70
- * Private procedure that uses the `isAuthedMiddleware` middleware to require authentication
71
- * @see https://trpc.io/docs/procedures
72
- */
73
- export const privateProcedure = t.procedure.use(isAuthedMiddleware);
74
- const accessControlMiddleware = (sectionName, requiredRole) => isAuthedMiddleware.unstable_pipe(async ({ ctx, next }) => {
75
- // Bypass privilege check for dashboard override plugin
76
- if (await isDashboardOverridePlugin(sectionName)) {
77
- return next();
78
- }
79
- const privilege = await db
80
- .select()
81
- .from(AdminPrivilegesTable)
82
- .where(and(eq(AdminPrivilegesTable.adminId, ctx.session.user.id), eq(AdminPrivilegesTable.sectionName, sectionName)))
83
- .limit(1);
84
- const allowed = privilege[0];
85
- if (!allowed) {
86
- throw new TRPCError({
87
- code: 'NOT_FOUND',
88
- message: getString('sectionNotFound', ctx.session.user.language),
89
- });
90
- }
91
- if (requiredRole && !allowed.operations.includes(requiredRole)) {
92
- throw new TRPCError({
93
- code: 'NOT_FOUND',
94
- message: getString('noAccessToThisOperation', ctx.session.user.language),
95
- });
96
- }
97
- return next();
98
- });
99
- export const pluginProcedure = (sectionName, requiredRole) => t.procedure.use(accessControlMiddleware(sectionName, requiredRole));
@@ -1,2 +0,0 @@
1
- export declare function createAsyncCallerProxy<TCaller>(getCaller: () => Promise<TCaller>): TCaller;
2
- //# sourceMappingURL=async-caller-proxy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"async-caller-proxy.d.ts","sourceRoot":"","sources":["../../../src/api/utils/async-caller-proxy.ts"],"names":[],"mappings":"AAWA,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAyB1F"}
@@ -1,36 +0,0 @@
1
- const resolveCallerPath = (root, path) => {
2
- let current = root;
3
- for (const key of path) {
4
- if (!current || (typeof current !== 'object' && typeof current !== 'function')) {
5
- return undefined;
6
- }
7
- current = current[key];
8
- }
9
- return current;
10
- };
11
- export function createAsyncCallerProxy(getCaller) {
12
- const callProcedure = async (path, args) => {
13
- const caller = await getCaller();
14
- const proc = resolveCallerPath(caller, path);
15
- if (typeof proc !== 'function') {
16
- throw new Error(`tRPC procedure not found: ${path.join('.')}`);
17
- }
18
- return proc(...args);
19
- };
20
- const createCallerProxy = (path = []) => {
21
- const proxyTarget = (...args) => callProcedure(path, args);
22
- return new Proxy(proxyTarget, {
23
- get(_target, prop) {
24
- if (prop === 'then')
25
- return undefined;
26
- if (typeof prop !== 'string')
27
- return undefined;
28
- return createCallerProxy([...path, prop]);
29
- },
30
- apply(_target, _thisArg, args) {
31
- return callProcedure(path, args);
32
- },
33
- });
34
- };
35
- return createCallerProxy();
36
- }
@@ -1,2 +0,0 @@
1
- export declare function createLazyCallerProxy<TCaller>(getCaller: () => Promise<TCaller>): TCaller;
2
- //# sourceMappingURL=lazy-caller-proxy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lazy-caller-proxy.d.ts","sourceRoot":"","sources":["../../../src/api/utils/lazy-caller-proxy.ts"],"names":[],"mappings":"AAWA,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAyBzF"}
@@ -1,36 +0,0 @@
1
- const resolveCallerPath = (root, path) => {
2
- let current = root;
3
- for (const key of path) {
4
- if (!current || (typeof current !== 'object' && typeof current !== 'function')) {
5
- return undefined;
6
- }
7
- current = current[key];
8
- }
9
- return current;
10
- };
11
- export function createLazyCallerProxy(getCaller) {
12
- const callProcedure = async (path, args) => {
13
- const caller = await getCaller();
14
- const proc = resolveCallerPath(caller, path);
15
- if (typeof proc !== 'function') {
16
- throw new Error(`tRPC procedure not found: ${path.join('.')}`);
17
- }
18
- return proc(...args);
19
- };
20
- const createCallerProxy = (path = []) => {
21
- const proxyTarget = (...args) => callProcedure(path, args);
22
- return new Proxy(proxyTarget, {
23
- get(_target, prop) {
24
- if (prop === 'then')
25
- return undefined;
26
- if (typeof prop !== 'string')
27
- return undefined;
28
- return createCallerProxy([...path, prop]);
29
- },
30
- apply(_target, _thisArg, args) {
31
- return callProcedure(path, args);
32
- },
33
- });
34
- };
35
- return createCallerProxy();
36
- }
@@ -1,7 +0,0 @@
1
- import type { AnyRouter } from '@trpc/server';
2
- import type { CoreRouters } from '../root.js';
3
- export type RouterRecord = Record<string, AnyRouter>;
4
- export type NonConflictingRouterRecord<TUser extends RouterRecord> = Extract<keyof TUser, keyof CoreRouters> extends never ? TUser : {
5
- [K in keyof TUser]: K extends keyof CoreRouters ? never : TUser[K];
6
- };
7
- //# sourceMappingURL=router-types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"router-types.d.ts","sourceRoot":"","sources":["../../../src/api/utils/router-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;AAEpD,MAAM,MAAM,0BAA0B,CAAC,KAAK,SAAS,YAAY,IAC7D,OAAO,CAAC,MAAM,KAAK,EAAE,MAAM,WAAW,CAAC,SAAS,KAAK,GAC/C,KAAK,GACL;KACK,CAAC,IAAI,MAAM,KAAK,GAAG,CAAC,SAAS,MAAM,WAAW,GAAG,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC;CACrE,CAAA"}
File without changes
@@ -1,2 +0,0 @@
1
- export declare const axiosPrivate: import("axios").AxiosInstance;
2
- //# sourceMappingURL=axiosInstance.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"axiosInstance.d.ts","sourceRoot":"","sources":["../../../src/auth/axios/axiosInstance.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,+BAMvB,CAAA"}
@@ -1,8 +0,0 @@
1
- import axios from 'axios';
2
- export const axiosPrivate = axios.create({
3
- baseURL: '/api',
4
- headers: {
5
- 'Content-Type': 'application/json',
6
- },
7
- withCredentials: true,
8
- });
@@ -1,5 +0,0 @@
1
- declare const useAxiosPrivate: (options?: {
2
- refreshTokenOn?: 401 | 404;
3
- }) => import("axios").AxiosInstance;
4
- export default useAxiosPrivate;
5
- //# sourceMappingURL=useAxiosPrivate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useAxiosPrivate.d.ts","sourceRoot":"","sources":["../../../src/auth/hooks/useAxiosPrivate.tsx"],"names":[],"mappings":"AAMA,QAAA,MAAM,eAAe,GAAI,UAAU;IAAE,cAAc,CAAC,EAAE,GAAG,GAAG,GAAG,CAAA;CAAE,kCAgFhE,CAAA;AAED,eAAe,eAAe,CAAA"}
@@ -1,74 +0,0 @@
1
- import { axiosPrivate } from '../axios/axiosInstance.js';
2
- import { useEffect } from 'react';
3
- import useRefreshToken from './useRefreshToken.js';
4
- import axios from 'axios';
5
- import { getCsrfToken } from '../react.js';
6
- const useAxiosPrivate = (options) => {
7
- const refresh = useRefreshToken();
8
- const { refreshTokenOn = 401 } = options || {};
9
- useEffect(() => {
10
- /**
11
- * Add a request interceptor
12
- */
13
- const requestIntercept = axiosPrivate.interceptors.request.use(
14
- /**
15
- * Do something before request is sent
16
- * @param config The request config object
17
- */
18
- async (config) => {
19
- if (config.method && ['post', 'put', 'delete'].includes(config.method.toLowerCase())) {
20
- /**
21
- * If the request is a POST, PUT, or DELETE request, the XSRF-TOKEN header is added to the request.
22
- */
23
- config.headers['x-csrf-token'] = await getCsrfToken();
24
- }
25
- /**
26
- * Return the config object
27
- */
28
- return config;
29
- }, (error) => Promise.reject(error));
30
- /**
31
- * This is the response interceptor
32
- */
33
- const responseIntercept = axiosPrivate.interceptors.response.use((response) => response, // Do nothing if the request is successful,
34
- async (error) => {
35
- // If the access token has expired, refresh it and retry the request
36
- const prevRequest = error?.config; // The request that caused the error (the one that returned 401) is saved in the error object
37
- if (error?.response?.status === refreshTokenOn && !prevRequest?.sent) {
38
- // If the error is 401 and the request hasn't been sent before
39
- prevRequest.sent = true; // Prevent infinite loops
40
- const refreshStatus = await refresh(); // Refresh the access token cookie
41
- if (refreshStatus === false)
42
- return Promise.reject(error); // If the refresh failed, reject the promise
43
- // NOTICE: This is needed to send the request as multipart form data,
44
- // because resending the request with axios resets the Content-Type to application/json for some reason
45
- // Use transformRequest to set Content-Type and include boundary for multipart form data
46
- prevRequest.headers['Content-Type'] = 'multipart/form-data';
47
- prevRequest.transformRequest = [
48
- (data, headers) => {
49
- // If the request data is FormData, set the boundary
50
- if (data instanceof FormData) {
51
- // @ts-ignore
52
- headers['Content-Type'] += `; boundary=${data._boundary}`;
53
- }
54
- return data;
55
- },
56
- ...axios.defaults.transformRequest, // Keep the default transformRequest functions
57
- ];
58
- return axiosPrivate(prevRequest); // The request that returned 401 is retried with the new access token
59
- }
60
- return Promise.reject(error);
61
- });
62
- // Remove the interceptors when the component unmounts
63
- // This is needed to prevent memory leaks
64
- return () => {
65
- // Eject the interceptors
66
- axiosPrivate.interceptors.request.eject(requestIntercept);
67
- axiosPrivate.interceptors.response.eject(responseIntercept);
68
- };
69
- }, [
70
- /*auth, refresh*/
71
- ]);
72
- return axiosPrivate;
73
- };
74
- export default useAxiosPrivate;
@@ -1,6 +0,0 @@
1
- import type { TRPCLink } from '@trpc/client';
2
- /**
3
- * tRPC link that refreshes the token if it's expired
4
- */
5
- export declare const refreshTokenLink: () => TRPCLink<any>;
6
- //# sourceMappingURL=trpc.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trpc.d.ts","sourceRoot":"","sources":["../../src/auth/trpc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAK5C;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAAO,QAAQ,CAAC,GAAG,CA6E/C,CAAA"}