nextjs-cms 0.9.35 → 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 (114) 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/core/submit/ItemEditSubmit.js +5 -5
  17. package/dist/translations/base/en.d.ts +3 -0
  18. package/dist/translations/base/en.d.ts.map +1 -1
  19. package/dist/translations/base/en.js +3 -0
  20. package/dist/translations/client.d.ts +40 -4
  21. package/dist/translations/client.d.ts.map +1 -1
  22. package/dist/translations/server.d.ts +40 -4
  23. package/dist/translations/server.d.ts.map +1 -1
  24. package/package.json +6 -3
  25. package/dist/api/axios/axiosInstance.d.ts +0 -2
  26. package/dist/api/axios/axiosInstance.d.ts.map +0 -1
  27. package/dist/api/axios/axiosInstance.js +0 -8
  28. package/dist/api/client.d.ts +0 -30
  29. package/dist/api/client.d.ts.map +0 -1
  30. package/dist/api/client.js +0 -82
  31. package/dist/api/index.d.ts +0 -2
  32. package/dist/api/index.d.ts.map +0 -1
  33. package/dist/api/index.js +0 -0
  34. package/dist/api/lib/serverActions.d.ts +0 -338
  35. package/dist/api/lib/serverActions.d.ts.map +0 -1
  36. package/dist/api/lib/serverActions.js +0 -1517
  37. package/dist/api/root.d.ts +0 -19
  38. package/dist/api/root.d.ts.map +0 -1
  39. package/dist/api/root.js +0 -50
  40. package/dist/api/routers/accountSettings.d.ts +0 -66
  41. package/dist/api/routers/accountSettings.d.ts.map +0 -1
  42. package/dist/api/routers/accountSettings.js +0 -202
  43. package/dist/api/routers/admins.d.ts +0 -112
  44. package/dist/api/routers/admins.d.ts.map +0 -1
  45. package/dist/api/routers/admins.js +0 -323
  46. package/dist/api/routers/auth.d.ts +0 -54
  47. package/dist/api/routers/auth.d.ts.map +0 -1
  48. package/dist/api/routers/auth.js +0 -50
  49. package/dist/api/routers/categorySection.d.ts +0 -105
  50. package/dist/api/routers/categorySection.d.ts.map +0 -1
  51. package/dist/api/routers/categorySection.js +0 -49
  52. package/dist/api/routers/config.d.ts +0 -48
  53. package/dist/api/routers/config.d.ts.map +0 -1
  54. package/dist/api/routers/config.js +0 -18
  55. package/dist/api/routers/cpanel.d.ts +0 -82
  56. package/dist/api/routers/cpanel.d.ts.map +0 -1
  57. package/dist/api/routers/cpanel.js +0 -216
  58. package/dist/api/routers/fields.d.ts +0 -35
  59. package/dist/api/routers/fields.d.ts.map +0 -1
  60. package/dist/api/routers/fields.js +0 -81
  61. package/dist/api/routers/files.d.ts +0 -34
  62. package/dist/api/routers/files.d.ts.map +0 -1
  63. package/dist/api/routers/files.js +0 -14
  64. package/dist/api/routers/gallery.d.ts +0 -35
  65. package/dist/api/routers/gallery.d.ts.map +0 -1
  66. package/dist/api/routers/gallery.js +0 -92
  67. package/dist/api/routers/hasItemsSection.d.ts +0 -194
  68. package/dist/api/routers/hasItemsSection.d.ts.map +0 -1
  69. package/dist/api/routers/hasItemsSection.js +0 -86
  70. package/dist/api/routers/logs.d.ts +0 -59
  71. package/dist/api/routers/logs.d.ts.map +0 -1
  72. package/dist/api/routers/logs.js +0 -76
  73. package/dist/api/routers/navigation.d.ts +0 -50
  74. package/dist/api/routers/navigation.d.ts.map +0 -1
  75. package/dist/api/routers/navigation.js +0 -11
  76. package/dist/api/routers/simpleSection.d.ts +0 -93
  77. package/dist/api/routers/simpleSection.d.ts.map +0 -1
  78. package/dist/api/routers/simpleSection.js +0 -54
  79. package/dist/api/server.d.ts +0 -2748
  80. package/dist/api/server.d.ts.map +0 -1
  81. package/dist/api/server.js +0 -100
  82. package/dist/api/trpc/error-logging.d.ts +0 -14
  83. package/dist/api/trpc/error-logging.d.ts.map +0 -1
  84. package/dist/api/trpc/error-logging.js +0 -75
  85. package/dist/api/trpc.d.ts +0 -111
  86. package/dist/api/trpc.d.ts.map +0 -1
  87. package/dist/api/trpc.js +0 -99
  88. package/dist/api/utils/async-caller-proxy.d.ts +0 -2
  89. package/dist/api/utils/async-caller-proxy.d.ts.map +0 -1
  90. package/dist/api/utils/async-caller-proxy.js +0 -36
  91. package/dist/api/utils/lazy-caller-proxy.d.ts +0 -2
  92. package/dist/api/utils/lazy-caller-proxy.d.ts.map +0 -1
  93. package/dist/api/utils/lazy-caller-proxy.js +0 -36
  94. package/dist/api/utils/router-types.d.ts +0 -7
  95. package/dist/api/utils/router-types.d.ts.map +0 -1
  96. package/dist/api/utils/router-types.js +0 -0
  97. package/dist/auth/axios/axiosInstance.d.ts +0 -2
  98. package/dist/auth/axios/axiosInstance.d.ts.map +0 -1
  99. package/dist/auth/axios/axiosInstance.js +0 -8
  100. package/dist/auth/hooks/useAxiosPrivate.d.ts +0 -5
  101. package/dist/auth/hooks/useAxiosPrivate.d.ts.map +0 -1
  102. package/dist/auth/hooks/useAxiosPrivate.js +0 -74
  103. package/dist/auth/trpc.d.ts +0 -6
  104. package/dist/auth/trpc.d.ts.map +0 -1
  105. package/dist/auth/trpc.js +0 -81
  106. package/dist/plugins/manifest.d.ts +0 -28
  107. package/dist/plugins/manifest.d.ts.map +0 -1
  108. package/dist/plugins/manifest.js +0 -83
  109. package/dist/plugins/registry.d.ts +0 -22
  110. package/dist/plugins/registry.d.ts.map +0 -1
  111. package/dist/plugins/registry.js +0 -25
  112. package/dist/utils/log.d.ts +0 -18
  113. package/dist/utils/log.d.ts.map +0 -1
  114. package/dist/utils/log.js +0 -28
@@ -1,323 +0,0 @@
1
- import { router, privateProcedure } from '../trpc.js';
2
- import * as z from 'zod';
3
- import { getAdminsList, getAllPrivileges, isAccessAllowed } from '../lib/serverActions.js';
4
- import { db } from '../../db/client.js';
5
- import { AdminPrivilegesTable, AdminsTable } from '../../db/schema.js';
6
- import { eq } from 'drizzle-orm';
7
- import { TRPCError } from '@trpc/server';
8
- import bcrypt from 'bcrypt';
9
- import { customAlphabet } from 'nanoid';
10
- import getString from '../../translations/index.js';
11
- import path from 'path';
12
- import fs from 'fs';
13
- import { getCMSConfig } from '../../core/config/index.js';
14
- import { getRequestMetadataFromHeaders, recordLog } from '../../logging/index.js';
15
- export const adminsRouter = router({
16
- list: privateProcedure.query(async ({ ctx }) => {
17
- const accessAllowed = await isAccessAllowed({
18
- sectionName: 'admins',
19
- userId: ctx.session.user.id,
20
- });
21
- if (!accessAllowed) {
22
- return {
23
- error: {
24
- message: getString('sectionNotFound', ctx.session.user.language),
25
- },
26
- };
27
- }
28
- const data = await Promise.all([getAdminsList(), getAllPrivileges(ctx.session)]);
29
- const adminList = data[0];
30
- const privileges = data[1];
31
- return {
32
- admins: adminList,
33
- privileges: privileges,
34
- };
35
- }),
36
- get: privateProcedure.input(z.string()).query(async (opts) => {
37
- const accessAllowed = await isAccessAllowed({
38
- sectionName: 'admins',
39
- userId: opts.ctx.session.user.id,
40
- });
41
- if (!accessAllowed) {
42
- throw new TRPCError({
43
- code: 'NOT_FOUND',
44
- message: getString('sectionNotFound', opts.ctx.session.user.language),
45
- });
46
- }
47
- const data = await Promise.all([
48
- db
49
- .select({
50
- id: AdminsTable.id,
51
- user: AdminsTable.user,
52
- })
53
- .from(AdminsTable)
54
- .where(eq(AdminsTable.id, opts.input)),
55
- db
56
- .select({
57
- sectionName: AdminPrivilegesTable.sectionName,
58
- operations: AdminPrivilegesTable.operations,
59
- publisher: AdminPrivilegesTable.publisher,
60
- })
61
- .from(AdminPrivilegesTable)
62
- .where(eq(AdminPrivilegesTable.adminId, opts.input)),
63
- getAllPrivileges(opts.ctx.session),
64
- ]);
65
- const adminRows = data[0];
66
- const adminRoles = data[1];
67
- const allRoles = data[2];
68
- const adminData = adminRows[0];
69
- if (!adminData) {
70
- throw new TRPCError({
71
- code: 'BAD_REQUEST',
72
- message: 'Admin not found',
73
- });
74
- }
75
- return {
76
- admin: adminData,
77
- adminRoles: adminRoles,
78
- allRoles: allRoles,
79
- };
80
- }),
81
- create: privateProcedure
82
- .input(z.object({
83
- username: z.string(),
84
- password: z.string(),
85
- privileges: z.array(z.object({
86
- sectionName: z.string(),
87
- publisher: z.boolean().nullable(),
88
- operations: z.string(),
89
- })),
90
- }))
91
- .mutation(async ({ ctx, input }) => {
92
- const requestMetadata = getRequestMetadataFromHeaders(ctx.headers);
93
- const accessAllowed = await isAccessAllowed({
94
- sectionName: 'admins',
95
- userId: ctx.session.user.id,
96
- });
97
- if (!accessAllowed) {
98
- throw new TRPCError({
99
- code: 'NOT_FOUND',
100
- message: getString('sectionNotFound', ctx.session.user.language),
101
- });
102
- }
103
- /**
104
- * First, let's check if the username already exists
105
- */
106
- const usernameExists = await db.select().from(AdminsTable).where(eq(AdminsTable.user, input.username));
107
- /**
108
- * If the username already exists, throw an error
109
- */
110
- if (usernameExists.length > 0) {
111
- throw new TRPCError({
112
- code: 'BAD_REQUEST',
113
- message: getString('adminAlreadyExists', ctx.session.user.language),
114
- });
115
- }
116
- /**
117
- * Let's filter the privileges to remove the ones that has operations set to 'none'
118
- */
119
- const filteredPrivileges = input.privileges.filter((privilege) => privilege.operations !== 'none');
120
- /**
121
- * If the filtered privileges are empty, throw an error
122
- */
123
- if (filteredPrivileges.length === 0) {
124
- throw new TRPCError({
125
- code: 'BAD_REQUEST',
126
- message: getString('selectAtLeastOnePrivilege', ctx.session.user.language),
127
- });
128
- }
129
- /**
130
- * Hash password with bcrypt
131
- */
132
- const hashedPassword = await bcrypt.hash(input.password, 10);
133
- const id = customAlphabet('1234567890', 25)();
134
- const adminCreation = await db.insert(AdminsTable).values({
135
- id: id,
136
- pass: hashedPassword,
137
- user: input.username,
138
- });
139
- /**
140
- * Now, let's prepare the rows to be inserted into the admin_privileges table
141
- */
142
- const rows = filteredPrivileges.map((privilege) => ({
143
- adminId: id,
144
- sectionName: privilege.sectionName,
145
- operations: privilege.operations,
146
- publisher: privilege.publisher,
147
- }));
148
- /**
149
- * Insert the privileges into the admin_privileges table
150
- */
151
- await db.insert(AdminPrivilegesTable).values(rows);
152
- await recordLog({
153
- eventType: 'admin.section.create',
154
- actorId: ctx.session.user.id,
155
- actorUsername: ctx.session.user.name ?? null,
156
- entityType: 'admin',
157
- entityId: id,
158
- entityLabel: input.username,
159
- sectionName: 'admins',
160
- metadata: {
161
- privileges: rows.map((privilege) => ({
162
- sectionName: privilege.sectionName,
163
- operations: privilege.operations,
164
- publisher: privilege.publisher,
165
- })),
166
- },
167
- requestMetadata,
168
- });
169
- return {
170
- status: 'success',
171
- id,
172
- };
173
- }),
174
- update: privateProcedure
175
- .input(z.object({
176
- id: z.string(),
177
- privileges: z.array(z.object({
178
- sectionName: z.string(),
179
- publisher: z.boolean().nullable(),
180
- operations: z.string(),
181
- })),
182
- }))
183
- .mutation(async ({ ctx, input }) => {
184
- const requestMetadata = getRequestMetadataFromHeaders(ctx.headers);
185
- const accessAllowed = await isAccessAllowed({
186
- sectionName: 'admins',
187
- userId: ctx.session.user.id,
188
- });
189
- if (!accessAllowed) {
190
- throw new TRPCError({
191
- code: 'NOT_FOUND',
192
- message: getString('sectionNotFound', ctx.session.user.language),
193
- });
194
- }
195
- /**
196
- * First, let's check if the admin exists
197
- */
198
- const adminRows = await db.select().from(AdminsTable).where(eq(AdminsTable.id, input.id));
199
- const admin = adminRows[0];
200
- /**
201
- * If the admin doens't exist, throw an error
202
- */
203
- if (!admin) {
204
- throw new TRPCError({
205
- code: 'BAD_REQUEST',
206
- message: getString('adminDoesNotExist', ctx.session.user.language),
207
- });
208
- }
209
- /**
210
- * Let's filter the privileges to remove the ones that has operations set to 'none'
211
- */
212
- const filteredPrivileges = input.privileges.filter((privilege) => privilege.operations !== 'none');
213
- /**
214
- * If the filtered privileges are empty, throw an error
215
- */
216
- if (filteredPrivileges.length === 0) {
217
- throw new TRPCError({
218
- code: 'BAD_REQUEST',
219
- message: getString('selectAtLeastOnePrivilege', ctx.session.user.language),
220
- });
221
- }
222
- /**
223
- * Now, let's prepare the rows to be inserted into the admin_privileges table
224
- */
225
- const rows = filteredPrivileges.map((privilege) => ({
226
- adminId: input.id,
227
- sectionName: privilege.sectionName,
228
- operations: privilege.operations,
229
- publisher: privilege.publisher,
230
- }));
231
- /**
232
- * Delete and then insert the privileges into the admin_privileges table
233
- */
234
- await db.delete(AdminPrivilegesTable).where(eq(AdminPrivilegesTable.adminId, input.id));
235
- await db.insert(AdminPrivilegesTable).values(rows);
236
- await recordLog({
237
- eventType: 'admin.section.update',
238
- actorId: ctx.session.user.id,
239
- actorUsername: ctx.session.user.name ?? null,
240
- entityType: 'admin',
241
- entityId: input.id,
242
- entityLabel: admin.user ?? null,
243
- sectionName: 'admins',
244
- metadata: {
245
- privileges: rows.map((privilege) => ({
246
- sectionName: privilege.sectionName,
247
- operations: privilege.operations,
248
- publisher: privilege.publisher,
249
- })),
250
- },
251
- requestMetadata,
252
- });
253
- return {
254
- status: 'success',
255
- };
256
- }),
257
- remove: privateProcedure
258
- .input(z.object({
259
- id: z.string(),
260
- }))
261
- .mutation(async ({ ctx, input }) => {
262
- const requestMetadata = getRequestMetadataFromHeaders(ctx.headers);
263
- const accessAllowed = await isAccessAllowed({
264
- sectionName: 'admins',
265
- userId: ctx.session.user.id,
266
- });
267
- if (!accessAllowed) {
268
- throw new TRPCError({
269
- code: 'NOT_FOUND',
270
- message: getString('sectionNotFound', ctx.session.user.language),
271
- });
272
- }
273
- const uploadsFolder = (await getCMSConfig()).media.upload.path;
274
- /**
275
- * Check if the admin is not the master admin
276
- */
277
- if (input.id === '1') {
278
- throw new TRPCError({
279
- code: 'BAD_REQUEST',
280
- message: getString('masterAdminCannotBeDeleted', ctx.session.user.language),
281
- });
282
- }
283
- /**
284
- * Check if the admin exists
285
- */
286
- const adminResult = await db.select().from(AdminsTable).where(eq(AdminsTable.id, input.id));
287
- const admin = adminResult[0];
288
- if (!admin) {
289
- throw new TRPCError({
290
- code: 'BAD_REQUEST',
291
- message: getString('adminNotFound', ctx.session.user.language),
292
- });
293
- }
294
- /**
295
- * Delete the admin roles from the admin_privileges table
296
- */
297
- await db.delete(AdminPrivilegesTable).where(eq(AdminPrivilegesTable.adminId, input.id));
298
- /**
299
- * Delete the admin from the admins table
300
- */
301
- await db.delete(AdminsTable).where(eq(AdminsTable.id, input.id));
302
- /**
303
- * Remove the admin avatar as well
304
- */
305
- if (admin.coverphoto) {
306
- await fs.promises.unlink(path.join(uploadsFolder, '.thumbs', 'admins', admin.coverphoto));
307
- }
308
- await recordLog({
309
- eventType: 'admin.section.delete',
310
- actorId: ctx.session.user.id,
311
- actorUsername: ctx.session.user.name ?? null,
312
- entityType: 'admin',
313
- entityId: input.id,
314
- entityLabel: admin.user ?? null,
315
- sectionName: 'admins',
316
- metadata: {
317
- hadAvatar: Boolean(admin.coverphoto),
318
- },
319
- requestMetadata,
320
- });
321
- return true;
322
- }),
323
- });
@@ -1,54 +0,0 @@
1
- import * as z from 'zod';
2
- export declare const authRouter: import("@trpc/server").TRPCBuiltRouter<{
3
- ctx: {
4
- headers: Headers;
5
- db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../../db/schema.js")> & {
6
- $client: import("mysql2/promise").Pool;
7
- };
8
- session: import("../../index.js").Session | null;
9
- };
10
- meta: object;
11
- errorShape: {
12
- data: {
13
- zodError: z.core.$ZodFlattenedError<unknown, string> | null;
14
- code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
15
- httpStatus: number;
16
- path?: string;
17
- stack?: string;
18
- };
19
- message: string;
20
- code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
21
- };
22
- transformer: true;
23
- }, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
24
- login: import("@trpc/server").TRPCMutationProcedure<{
25
- input: {
26
- username: string;
27
- password: string;
28
- };
29
- output: {
30
- status: number;
31
- session: {
32
- user: {
33
- id: string;
34
- name: string;
35
- language: string;
36
- };
37
- };
38
- user: {
39
- id: string;
40
- username: string;
41
- lang: string;
42
- avatar: string | null;
43
- };
44
- accessToken: string;
45
- };
46
- meta: object;
47
- }>;
48
- logout: import("@trpc/server").TRPCMutationProcedure<{
49
- input: void;
50
- output: boolean;
51
- meta: object;
52
- }>;
53
- }>>;
54
- //# sourceMappingURL=auth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/api/routers/auth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAKxB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDrB,CAAA"}
@@ -1,50 +0,0 @@
1
- import { privateProcedure, publicProcedure, router } from '../trpc.js';
2
- import * as z from 'zod';
3
- import { TRPCError } from '@trpc/server';
4
- import { deleteSession, login } from '../../auth/lib/index.js';
5
- import { getRequestMetadataFromHeaders, recordLog } from '../../logging/index.js';
6
- export const authRouter = router({
7
- login: publicProcedure
8
- .input(z.object({
9
- username: z.string(),
10
- password: z.string(),
11
- }))
12
- .mutation(async (opts) => {
13
- try {
14
- const requestMetadata = getRequestMetadataFromHeaders(opts.ctx.headers);
15
- const result = await login(opts.input);
16
- await recordLog({
17
- eventType: 'auth.login',
18
- actorId: result.user?.id ?? null,
19
- actorUsername: result.user?.username ?? null,
20
- entityType: 'admin',
21
- entityId: result.user?.id ?? null,
22
- entityLabel: result.user?.username ?? null,
23
- sectionName: 'auth',
24
- requestMetadata,
25
- });
26
- return result;
27
- }
28
- catch (error) {
29
- throw new TRPCError({
30
- code: 'BAD_REQUEST',
31
- message: error.message,
32
- });
33
- }
34
- }),
35
- logout: privateProcedure.mutation(async (opts) => {
36
- const requestMetadata = getRequestMetadataFromHeaders(opts.ctx.headers);
37
- const result = await deleteSession(opts.ctx.session);
38
- await recordLog({
39
- eventType: 'auth.logout',
40
- actorId: opts.ctx.session.user.id,
41
- actorUsername: opts.ctx.session.user.name ?? null,
42
- entityType: 'admin',
43
- entityId: opts.ctx.session.user.id,
44
- entityLabel: opts.ctx.session.user.name ?? null,
45
- sectionName: 'auth',
46
- requestMetadata,
47
- });
48
- return result;
49
- }),
50
- });
@@ -1,105 +0,0 @@
1
- import * as z from 'zod';
2
- export declare const categorySectionRouter: import("@trpc/server").TRPCBuiltRouter<{
3
- ctx: {
4
- headers: Headers;
5
- db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../../db/schema.js")> & {
6
- $client: import("mysql2/promise").Pool;
7
- };
8
- session: import("../../index.js").Session | null;
9
- };
10
- meta: object;
11
- errorShape: {
12
- data: {
13
- zodError: z.core.$ZodFlattenedError<unknown, string> | null;
14
- code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
15
- httpStatus: number;
16
- path?: string;
17
- stack?: string;
18
- };
19
- message: string;
20
- code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
21
- };
22
- transformer: true;
23
- }, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
24
- get: import("@trpc/server").TRPCQueryProcedure<{
25
- input: {
26
- sectionName: string;
27
- };
28
- output: {
29
- error: {
30
- message: string;
31
- };
32
- section?: undefined;
33
- data?: undefined;
34
- } | {
35
- section: {
36
- tableName: string;
37
- sectionName: string;
38
- title: {
39
- section: string;
40
- singular: string;
41
- plural: string;
42
- };
43
- };
44
- data: {
45
- options: {
46
- value: string | number;
47
- label: string;
48
- }[] | undefined;
49
- required: boolean;
50
- name: string;
51
- label: string;
52
- value: {
53
- value: string | number;
54
- label: string;
55
- }[] | undefined;
56
- parentId: string | number | undefined;
57
- level: number;
58
- depth: number | undefined;
59
- sectionName: string;
60
- allowRecursiveDelete: boolean | undefined;
61
- };
62
- error?: undefined;
63
- };
64
- meta: object;
65
- }>;
66
- getChildren: import("@trpc/server").TRPCMutationProcedure<{
67
- input: {
68
- sectionName: string;
69
- parentId: string | number | undefined;
70
- level: number;
71
- };
72
- output: {
73
- error: {
74
- message: string;
75
- };
76
- options?: undefined;
77
- parentId?: undefined;
78
- level?: undefined;
79
- } | {
80
- options: null;
81
- parentId: string | number;
82
- level: number;
83
- error?: undefined;
84
- } | {
85
- options: {
86
- value: any;
87
- label: any;
88
- }[];
89
- parentId: string | number;
90
- level: number;
91
- error?: undefined;
92
- } | undefined;
93
- meta: object;
94
- }>;
95
- deleteItem: import("@trpc/server").TRPCMutationProcedure<{
96
- input: {
97
- sectionName: string;
98
- sectionItemId: string | number;
99
- deleteChildren?: boolean | undefined;
100
- };
101
- output: boolean;
102
- meta: object;
103
- }>;
104
- }>>;
105
- //# sourceMappingURL=categorySection.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"categorySection.d.ts","sourceRoot":"","sources":["../../../src/api/routers/categorySection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAKxB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DhC,CAAA"}
@@ -1,49 +0,0 @@
1
- import { privateProcedure, router } from '../trpc.js';
2
- import * as z from 'zod';
3
- import { deleteSectionItem, getCategorySection, getCategorySectionChildren } from '../lib/serverActions.js';
4
- import { getRequestMetadataFromHeaders } from '../../logging/index.js';
5
- import { TRPCError } from '@trpc/server';
6
- export const categorySectionRouter = router({
7
- get: privateProcedure
8
- .input(z.object({
9
- sectionName: z.string(),
10
- }))
11
- .query(async ({ ctx, input }) => {
12
- return await getCategorySection(ctx.session, input.sectionName);
13
- }),
14
- getChildren: privateProcedure
15
- .input(z.object({
16
- sectionName: z.string(),
17
- parentId: z.number().or(z.string()).or(z.undefined()),
18
- level: z.number(),
19
- }))
20
- .mutation(async ({ ctx, input }) => {
21
- if (input.parentId === undefined) {
22
- return undefined;
23
- }
24
- return await getCategorySectionChildren({
25
- session: ctx.session,
26
- sectionName: input.sectionName,
27
- id: input.parentId,
28
- level: input.level,
29
- });
30
- }),
31
- deleteItem: privateProcedure
32
- .input(z.object({
33
- sectionName: z.string(),
34
- sectionItemId: z.number().or(z.string()),
35
- deleteChildren: z.boolean().optional(),
36
- }))
37
- .mutation(async ({ ctx, input }) => {
38
- const requestMetadata = getRequestMetadataFromHeaders(ctx.headers);
39
- const result = await deleteSectionItem(ctx.session, input.sectionName, input.sectionItemId, input.deleteChildren, requestMetadata);
40
- if (result && typeof result === 'object' && 'error' in result) {
41
- const message = result.error?.message ?? 'Failed to delete section item';
42
- throw new TRPCError({
43
- code: 'BAD_REQUEST',
44
- message,
45
- });
46
- }
47
- return result;
48
- }),
49
- });
@@ -1,48 +0,0 @@
1
- /**
2
- * Config router. Exposes non-sensitive config (e.g. i18n) to authenticated clients.
3
- */
4
- export declare const configRouter: import("@trpc/server").TRPCBuiltRouter<{
5
- ctx: {
6
- headers: Headers;
7
- db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../../db/schema.js")> & {
8
- $client: import("mysql2/promise").Pool;
9
- };
10
- session: import("../../index.js").Session | null;
11
- };
12
- meta: object;
13
- errorShape: {
14
- data: {
15
- zodError: import("zod").ZodFlattenedError<unknown, string> | null;
16
- code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
17
- httpStatus: number;
18
- path?: string;
19
- stack?: string;
20
- };
21
- message: string;
22
- code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
23
- };
24
- transformer: true;
25
- }, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
26
- getI18n: import("@trpc/server").TRPCQueryProcedure<{
27
- input: void;
28
- output: {
29
- supportedLanguages: readonly string[];
30
- fallbackLanguage: string;
31
- };
32
- meta: object;
33
- }>;
34
- getLocalization: import("@trpc/server").TRPCQueryProcedure<{
35
- input: void;
36
- output: {
37
- enabled: boolean;
38
- locales: {
39
- code: string;
40
- label: string;
41
- rtl?: boolean;
42
- }[];
43
- defaultLocale: string;
44
- } | null;
45
- meta: object;
46
- }>;
47
- }>>;
48
- //# sourceMappingURL=config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/api/routers/config.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAaozZ,CAAC;;;;;;GAD50Z,CAAA"}
@@ -1,18 +0,0 @@
1
- import { privateProcedure, router } from '../trpc.js';
2
- import { getCMSConfig } from '../../core/config/index.js';
3
- /**
4
- * Config router. Exposes non-sensitive config (e.g. i18n) to authenticated clients.
5
- */
6
- export const configRouter = router({
7
- getI18n: privateProcedure.query(async () => {
8
- const config = await getCMSConfig();
9
- return {
10
- supportedLanguages: config.i18n.supportedLanguages,
11
- fallbackLanguage: config.i18n.fallbackLanguage,
12
- };
13
- }),
14
- getLocalization: privateProcedure.query(async () => {
15
- const config = await getCMSConfig();
16
- return config.localization;
17
- }),
18
- });