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,19 +0,0 @@
1
- export declare const coreRouters: {
2
- auth: any;
3
- admins: any;
4
- config: any;
5
- hasItemsSections: any;
6
- simpleSections: any;
7
- categorySections: any;
8
- files: any;
9
- gallery: any;
10
- navigation: any;
11
- accountSettings: any;
12
- fields: any;
13
- logs: any;
14
- plugins: any;
15
- };
16
- export type CoreRouters = typeof coreRouters;
17
- export declare const coreAppRouter: any;
18
- export type CoreAppRouter = typeof coreAppRouter;
19
- //# sourceMappingURL=root.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../src/api/root.ts"],"names":[],"mappings":"AAoCA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;CAcvB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAA;AAI5C,eAAO,MAAM,aAAa,KAAsB,CAAA;AAEhD,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAA"}
package/dist/api/root.js DELETED
@@ -1,50 +0,0 @@
1
- import { privateProcedure, router } from './trpc.js';
2
- import { adminsRouter } from './trpc/routers/admins.js';
3
- import { hasItemsSectionRouter } from './trpc/routers/hasItemsSection.js';
4
- import { filesRouter } from './trpc/routers/files.js';
5
- import { authRouter } from './trpc/routers/auth.js';
6
- import { configRouter } from './trpc/routers/config.js';
7
- import { navRouter } from './trpc/routers/navigation.js';
8
- import { simpleSectionRouter } from './trpc/routers/simpleSection.js';
9
- import { categorySectionRouter } from './trpc/routers/categorySection.js';
10
- import { accountSettings } from './trpc/routers/accountSettings.js';
11
- import { galleryRouter } from './trpc/routers/gallery.js';
12
- import { logsRouter } from './trpc/routers/logs.js';
13
- import { fieldsRouter } from './trpc/routers/fields.js';
14
- import { getPluginRoutes } from '../plugins/loader.js';
15
- import { z } from 'zod';
16
- import { getAdminPrivileges } from './lib/serverActions.js';
17
- const pluginsRouter = router({
18
- checkRoute: privateProcedure
19
- .input(z.object({
20
- path: z.string(),
21
- }))
22
- .query(async ({ ctx, input }) => {
23
- const routes = await getPluginRoutes();
24
- const privilegeSet = await getAdminPrivileges(ctx.session.user.id);
25
- const filteredRoutes = routes.filter(({ pluginName }) => privilegeSet.has(pluginName));
26
- const plugin = filteredRoutes.find(({ path }) => path === input.path);
27
- if (!plugin) {
28
- return null;
29
- }
30
- return plugin;
31
- }),
32
- });
33
- export const coreRouters = {
34
- auth: authRouter,
35
- admins: adminsRouter,
36
- config: configRouter,
37
- hasItemsSections: hasItemsSectionRouter,
38
- simpleSections: simpleSectionRouter,
39
- categorySections: categorySectionRouter,
40
- files: filesRouter,
41
- gallery: galleryRouter,
42
- navigation: navRouter,
43
- accountSettings: accountSettings,
44
- fields: fieldsRouter,
45
- logs: logsRouter,
46
- plugins: pluginsRouter,
47
- };
48
- // Core-only router used for package-level type helpers.
49
- // App-owned routers should be created with createTRPCRouter().
50
- export const coreAppRouter = router(coreRouters);
@@ -1,66 +0,0 @@
1
- import * as z from 'zod';
2
- export declare const accountSettings: 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: void;
26
- output: {
27
- id: string;
28
- username: string;
29
- emailAddress: string | null;
30
- fullName: string | null;
31
- avatar: string | null;
32
- phoneNumber: string | null;
33
- } | undefined;
34
- meta: object;
35
- }>;
36
- /**
37
- * No avatar for now, if you want to include it, you have to use the api route,
38
- * because trpc doesn't support file uploads.
39
- */
40
- save: import("@trpc/server").TRPCMutationProcedure<{
41
- input: {
42
- emailAddress: string;
43
- fullName: string;
44
- phoneNumber: string;
45
- };
46
- output: boolean;
47
- meta: object;
48
- }>;
49
- changePassword: import("@trpc/server").TRPCMutationProcedure<{
50
- input: {
51
- oldPassword: string;
52
- newPassword: string;
53
- confirmPassword: string;
54
- };
55
- output: boolean;
56
- meta: object;
57
- }>;
58
- updateLanguage: import("@trpc/server").TRPCMutationProcedure<{
59
- input: {
60
- language: string;
61
- };
62
- output: boolean;
63
- meta: object;
64
- }>;
65
- }>>;
66
- //# sourceMappingURL=accountSettings.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"accountSettings.d.ts","sourceRoot":"","sources":["../../../src/api/routers/accountSettings.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAOxB,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkBxB;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;;;GAwML,CAAA"}
@@ -1,202 +0,0 @@
1
- import { privateProcedure, router } from '../trpc.js';
2
- import { db } from '../../db/client.js';
3
- import { AdminsTable } from '../../db/schema.js';
4
- import { eq } from 'drizzle-orm';
5
- import * as z from 'zod';
6
- import bcrypt from 'bcrypt';
7
- import { TRPCError } from '@trpc/server';
8
- import { getRequestMetadataFromHeaders, recordLog } from '../../logging/index.js';
9
- import { getCMSConfig } from '../../core/config/index.js';
10
- import getString from '../../translations/index.js';
11
- export const accountSettings = router({
12
- get: privateProcedure.query(async ({ ctx }) => {
13
- const admin = await db
14
- .select({
15
- id: AdminsTable.id,
16
- username: AdminsTable.user,
17
- emailAddress: AdminsTable.emailAddress,
18
- fullName: AdminsTable.fullName,
19
- avatar: AdminsTable.coverphoto,
20
- phoneNumber: AdminsTable.phoneNumber,
21
- })
22
- .from(AdminsTable)
23
- .where(eq(AdminsTable.id, ctx.session.user.id))
24
- .limit(1);
25
- return admin[0];
26
- }),
27
- /**
28
- * No avatar for now, if you want to include it, you have to use the api route,
29
- * because trpc doesn't support file uploads.
30
- */
31
- save: privateProcedure
32
- .input(z.object({
33
- emailAddress: z.string(),
34
- fullName: z.string(),
35
- phoneNumber: z.string(),
36
- }))
37
- .mutation(async ({ ctx, input }) => {
38
- const requestMetadata = getRequestMetadataFromHeaders(ctx.headers);
39
- const existing = await db
40
- .select({
41
- emailAddress: AdminsTable.emailAddress,
42
- fullName: AdminsTable.fullName,
43
- phoneNumber: AdminsTable.phoneNumber,
44
- username: AdminsTable.user,
45
- })
46
- .from(AdminsTable)
47
- .where(eq(AdminsTable.id, ctx.session.user.id))
48
- .limit(1);
49
- const admin = existing[0];
50
- if (!admin) {
51
- throw new TRPCError({
52
- code: 'NOT_FOUND',
53
- message: getString('adminNotFound', ctx.session.user.language),
54
- });
55
- }
56
- const updates = {};
57
- const changedFields = [];
58
- if (admin.emailAddress !== input.emailAddress) {
59
- updates.emailAddress = input.emailAddress;
60
- changedFields.push('emailAddress');
61
- }
62
- if (admin.fullName !== input.fullName) {
63
- updates.fullName = input.fullName;
64
- changedFields.push('fullName');
65
- }
66
- if (admin.phoneNumber !== input.phoneNumber) {
67
- updates.phoneNumber = input.phoneNumber;
68
- changedFields.push('phoneNumber');
69
- }
70
- if (changedFields.length === 0) {
71
- return true;
72
- }
73
- await db
74
- .update(AdminsTable)
75
- .set({
76
- ...updates,
77
- })
78
- .where(eq(AdminsTable.id, ctx.session.user.id))
79
- .execute();
80
- await recordLog({
81
- eventType: 'admin.settings.change',
82
- actorId: ctx.session.user.id,
83
- actorUsername: ctx.session.user.name ?? admin.username ?? null,
84
- entityType: 'admin',
85
- entityId: ctx.session.user.id,
86
- entityLabel: admin.username ?? null,
87
- sectionName: 'settings',
88
- metadata: {
89
- fields: changedFields,
90
- },
91
- requestMetadata,
92
- });
93
- return true;
94
- }),
95
- changePassword: privateProcedure
96
- .input(z.object({
97
- oldPassword: z.string(),
98
- newPassword: z.string(),
99
- confirmPassword: z.string(),
100
- }))
101
- .mutation(async ({ ctx, input }) => {
102
- const requestMetadata = getRequestMetadataFromHeaders(ctx.headers);
103
- /**
104
- * Check if old password is correct
105
- */
106
- const result = await db
107
- .select({
108
- password: AdminsTable.pass,
109
- username: AdminsTable.user,
110
- })
111
- .from(AdminsTable)
112
- .where(eq(AdminsTable.id, ctx.session.user.id))
113
- .limit(1);
114
- const admin = result[0];
115
- /**
116
- * Check if admin exists
117
- */
118
- if (!admin) {
119
- throw new TRPCError({
120
- code: 'NOT_FOUND',
121
- message: getString('adminNotFound', ctx.session.user.language),
122
- });
123
- }
124
- /**
125
- * Check password with bcrypt
126
- */
127
- const match = await bcrypt.compare(input.oldPassword, admin.password);
128
- if (!match) {
129
- throw new TRPCError({
130
- code: 'UNAUTHORIZED',
131
- message: getString('oldPasswordIncorrect', ctx.session.user.language),
132
- });
133
- }
134
- /**
135
- * Check if new password and confirm password are the same
136
- */
137
- if (input.newPassword !== input.confirmPassword) {
138
- throw new TRPCError({
139
- code: 'BAD_REQUEST',
140
- message: getString('passwordsDoNotMatch', ctx.session.user.language),
141
- });
142
- }
143
- /**
144
- * Hash new password
145
- */
146
- const hashedPassword = await bcrypt.hash(input.newPassword, 10);
147
- /**
148
- * Update password
149
- */
150
- await db
151
- .update(AdminsTable)
152
- .set({
153
- pass: hashedPassword,
154
- })
155
- .where(eq(AdminsTable.id, ctx.session.user.id))
156
- .execute();
157
- await recordLog({
158
- eventType: 'admin.settings.change',
159
- actorId: ctx.session.user.id,
160
- actorUsername: ctx.session.user.name ?? admin.username ?? null,
161
- entityType: 'admin',
162
- entityId: ctx.session.user.id,
163
- entityLabel: admin.username ?? null,
164
- sectionName: 'settings',
165
- metadata: {
166
- fields: ['password'],
167
- },
168
- requestMetadata,
169
- });
170
- return true;
171
- }),
172
- updateLanguage: privateProcedure
173
- .input(z.object({ language: z.string() }))
174
- .mutation(async ({ ctx, input }) => {
175
- const requestMetadata = getRequestMetadataFromHeaders(ctx.headers);
176
- const config = await getCMSConfig();
177
- const supported = new Set(config.i18n.supportedLanguages);
178
- if (!supported.has(input.language)) {
179
- throw new TRPCError({
180
- code: 'BAD_REQUEST',
181
- message: getString('languageNotSupported', ctx.session.user.language),
182
- });
183
- }
184
- await db
185
- .update(AdminsTable)
186
- .set({ language: input.language })
187
- .where(eq(AdminsTable.id, ctx.session.user.id))
188
- .execute();
189
- await recordLog({
190
- eventType: 'admin.settings.change',
191
- actorId: ctx.session.user.id,
192
- actorUsername: ctx.session.user.name ?? null,
193
- entityType: 'admin',
194
- entityId: ctx.session.user.id,
195
- entityLabel: ctx.session.user.name ?? null,
196
- sectionName: 'settings',
197
- metadata: { fields: ['language'], language: input.language },
198
- requestMetadata,
199
- });
200
- return true;
201
- }),
202
- });
@@ -1,112 +0,0 @@
1
- import * as z from 'zod';
2
- export declare const adminsRouter: 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
- list: import("@trpc/server").TRPCQueryProcedure<{
25
- input: void;
26
- output: {
27
- error: {
28
- message: string;
29
- };
30
- admins?: undefined;
31
- privileges?: undefined;
32
- } | {
33
- admins: {
34
- id: string;
35
- username: string;
36
- avatar: string | null;
37
- roles: {
38
- operations: "C" | "U" | "D" | "CU" | "CD" | "UD" | "CUD";
39
- publisher: boolean | null;
40
- sectionName: string;
41
- }[];
42
- }[];
43
- privileges: {
44
- title: string;
45
- order: number;
46
- sectionType: string;
47
- sectionName: string;
48
- }[];
49
- error?: undefined;
50
- };
51
- meta: object;
52
- }>;
53
- get: import("@trpc/server").TRPCQueryProcedure<{
54
- input: string;
55
- output: {
56
- admin: {
57
- id: string;
58
- user: string;
59
- };
60
- adminRoles: {
61
- sectionName: string;
62
- operations: "C" | "U" | "D" | "CU" | "CD" | "UD" | "CUD";
63
- publisher: boolean | null;
64
- }[];
65
- allRoles: {
66
- title: string;
67
- order: number;
68
- sectionType: string;
69
- sectionName: string;
70
- }[];
71
- };
72
- meta: object;
73
- }>;
74
- create: import("@trpc/server").TRPCMutationProcedure<{
75
- input: {
76
- username: string;
77
- password: string;
78
- privileges: {
79
- sectionName: string;
80
- publisher: boolean | null;
81
- operations: string;
82
- }[];
83
- };
84
- output: {
85
- status: string;
86
- id: string;
87
- };
88
- meta: object;
89
- }>;
90
- update: import("@trpc/server").TRPCMutationProcedure<{
91
- input: {
92
- id: string;
93
- privileges: {
94
- sectionName: string;
95
- publisher: boolean | null;
96
- operations: string;
97
- }[];
98
- };
99
- output: {
100
- status: string;
101
- };
102
- meta: object;
103
- }>;
104
- remove: import("@trpc/server").TRPCMutationProcedure<{
105
- input: {
106
- id: string;
107
- };
108
- output: boolean;
109
- meta: object;
110
- }>;
111
- }>>;
112
- //# sourceMappingURL=admins.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"admins.d.ts","sourceRoot":"","sources":["../../../src/api/routers/admins.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAcxB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0VvB,CAAA"}