nextjs-cms 0.5.68 → 0.5.70
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/api/index.d.ts +6 -34
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +2 -2
- package/dist/api/lib/serverActions.d.ts +6 -0
- package/dist/api/lib/serverActions.d.ts.map +1 -1
- package/dist/api/lib/serverActions.js +64 -9
- package/dist/api/root.d.ts +34 -89
- package/dist/api/root.d.ts.map +1 -1
- package/dist/api/root.js +15 -18
- package/dist/api/routers/admins.d.ts.map +1 -1
- package/dist/api/routers/admins.js +53 -3
- package/dist/api/routers/gallery.d.ts.map +1 -1
- package/dist/api/routers/gallery.js +1 -0
- package/dist/api/trpc/client.d.ts +4 -0
- package/dist/api/trpc/client.d.ts.map +1 -0
- package/dist/api/trpc/client.js +3 -0
- package/dist/api/trpc.d.ts +12 -0
- package/dist/api/trpc.d.ts.map +1 -1
- package/dist/api/trpc.js +24 -0
- package/dist/core/config/loader.d.ts +1 -1
- package/dist/core/config/loader.d.ts.map +1 -1
- package/dist/core/config/loader.js +1 -1
- package/dist/core/factories/SectionFactory.d.ts +1 -1
- package/dist/core/factories/SectionFactory.d.ts.map +1 -1
- package/dist/core/factories/SectionFactory.js +1 -1
- package/dist/core/factories/section-factory-with-esbuild.d.ts +0 -4
- package/dist/core/factories/section-factory-with-esbuild.d.ts.map +1 -1
- package/dist/core/factories/section-factory-with-esbuild.js +1 -5
- package/dist/core/factories/section-factory-with-jiti.d.ts +0 -4
- package/dist/core/factories/section-factory-with-jiti.d.ts.map +1 -1
- package/dist/core/factories/section-factory-with-jiti.js +1 -5
- package/dist/core/submit/ItemEditSubmit.d.ts.map +1 -1
- package/dist/plugins/blank.d.ts +6 -0
- package/dist/plugins/blank.d.ts.map +1 -0
- package/dist/plugins/blank.js +7 -0
- package/dist/plugins/index.d.ts +2 -1
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/loader.d.ts +32 -6
- package/dist/plugins/loader.d.ts.map +1 -1
- package/dist/plugins/loader.js +34 -8
- package/package.json +9 -1
- package/dist/api/routers/googleAnalytics.d.ts +0 -29
- package/dist/api/routers/googleAnalytics.d.ts.map +0 -1
- package/dist/api/routers/googleAnalytics.js +0 -7
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { router, privateProcedure } from '../trpc.js';
|
|
2
2
|
import * as z from 'zod';
|
|
3
|
-
import { getAdminsList, getAllPrivileges } from '../lib/serverActions.js';
|
|
3
|
+
import { getAdminsList, getAllPrivileges, isAccessAllowed } from '../lib/serverActions.js';
|
|
4
4
|
import { db } from '../../db/client.js';
|
|
5
5
|
import { AdminPrivilegesTable, AdminsTable } from '../../db/schema.js';
|
|
6
6
|
import { eq } from 'drizzle-orm';
|
|
@@ -12,7 +12,17 @@ import path from 'path';
|
|
|
12
12
|
import fs from 'fs';
|
|
13
13
|
import { getCMSConfig } from '../../core/config/index.js';
|
|
14
14
|
export const adminsRouter = router({
|
|
15
|
-
list: privateProcedure.query(async () => {
|
|
15
|
+
list: privateProcedure.query(async ({ ctx }) => {
|
|
16
|
+
const accessAllowed = await isAccessAllowed({
|
|
17
|
+
sectionName: 'admins',
|
|
18
|
+
userId: ctx.session.user.id,
|
|
19
|
+
});
|
|
20
|
+
if (!accessAllowed) {
|
|
21
|
+
throw new TRPCError({
|
|
22
|
+
code: 'NOT_FOUND',
|
|
23
|
+
message: 'Section not found or you do not have access to this operation',
|
|
24
|
+
});
|
|
25
|
+
}
|
|
16
26
|
const data = await Promise.all([getAdminsList(), getAllPrivileges()]);
|
|
17
27
|
const adminList = data[0];
|
|
18
28
|
const privileges = data[1];
|
|
@@ -22,6 +32,16 @@ export const adminsRouter = router({
|
|
|
22
32
|
};
|
|
23
33
|
}),
|
|
24
34
|
get: privateProcedure.input(z.string()).query(async (opts) => {
|
|
35
|
+
const accessAllowed = await isAccessAllowed({
|
|
36
|
+
sectionName: 'admins',
|
|
37
|
+
userId: opts.ctx.session.user.id,
|
|
38
|
+
});
|
|
39
|
+
if (!accessAllowed) {
|
|
40
|
+
throw new TRPCError({
|
|
41
|
+
code: 'NOT_FOUND',
|
|
42
|
+
message: 'Section not found or you do not have access to this operation',
|
|
43
|
+
});
|
|
44
|
+
}
|
|
25
45
|
const data = await Promise.all([
|
|
26
46
|
db
|
|
27
47
|
.select({
|
|
@@ -67,6 +87,16 @@ export const adminsRouter = router({
|
|
|
67
87
|
})),
|
|
68
88
|
}))
|
|
69
89
|
.mutation(async ({ ctx, input }) => {
|
|
90
|
+
const accessAllowed = await isAccessAllowed({
|
|
91
|
+
sectionName: 'admins',
|
|
92
|
+
userId: ctx.session.user.id,
|
|
93
|
+
});
|
|
94
|
+
if (!accessAllowed) {
|
|
95
|
+
throw new TRPCError({
|
|
96
|
+
code: 'NOT_FOUND',
|
|
97
|
+
message: 'Section not found or you do not have access to this operation',
|
|
98
|
+
});
|
|
99
|
+
}
|
|
70
100
|
/**
|
|
71
101
|
* First, let's check if the username already exists
|
|
72
102
|
*/
|
|
@@ -130,6 +160,16 @@ export const adminsRouter = router({
|
|
|
130
160
|
})),
|
|
131
161
|
}))
|
|
132
162
|
.mutation(async ({ ctx, input }) => {
|
|
163
|
+
const accessAllowed = await isAccessAllowed({
|
|
164
|
+
sectionName: 'admins',
|
|
165
|
+
userId: ctx.session.user.id,
|
|
166
|
+
});
|
|
167
|
+
if (!accessAllowed) {
|
|
168
|
+
throw new TRPCError({
|
|
169
|
+
code: 'NOT_FOUND',
|
|
170
|
+
message: 'Section not found or you do not have access to this operation',
|
|
171
|
+
});
|
|
172
|
+
}
|
|
133
173
|
/**
|
|
134
174
|
* First, let's check if the admin exists
|
|
135
175
|
*/
|
|
@@ -178,7 +218,17 @@ export const adminsRouter = router({
|
|
|
178
218
|
.input(z.object({
|
|
179
219
|
id: z.string(),
|
|
180
220
|
}))
|
|
181
|
-
.mutation(async ({ input }) => {
|
|
221
|
+
.mutation(async ({ ctx, input }) => {
|
|
222
|
+
const accessAllowed = await isAccessAllowed({
|
|
223
|
+
sectionName: 'admins',
|
|
224
|
+
userId: ctx.session.user.id,
|
|
225
|
+
});
|
|
226
|
+
if (!accessAllowed) {
|
|
227
|
+
throw new TRPCError({
|
|
228
|
+
code: 'NOT_FOUND',
|
|
229
|
+
message: 'Section not found or you do not have access to this operation',
|
|
230
|
+
});
|
|
231
|
+
}
|
|
182
232
|
const uploadsFolder = (await getCMSConfig()).media.upload.path;
|
|
183
233
|
/**
|
|
184
234
|
* Check if the admin is not the master admin
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gallery.d.ts","sourceRoot":"","sources":["../../../src/api/routers/gallery.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAWxB,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"gallery.d.ts","sourceRoot":"","sources":["../../../src/api/routers/gallery.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAWxB,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DxB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/api/trpc/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE3C,eAAO,MAAM,IAAI,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,SAAS,CAAC,CAAgC,CAAA"}
|
package/dist/api/trpc.d.ts
CHANGED
|
@@ -95,5 +95,17 @@ export declare const privateProcedure: import("@trpc/server").TRPCProcedureBuild
|
|
|
95
95
|
user: import("../index.js").User;
|
|
96
96
|
};
|
|
97
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>;
|
|
98
110
|
export {};
|
|
99
111
|
//# sourceMappingURL=trpc.d.ts.map
|
package/dist/api/trpc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trpc.d.ts","sourceRoot":"","sources":["../../src/api/trpc.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"trpc.d.ts","sourceRoot":"","sources":["../../src/api/trpc.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,WAAW,CAAA;AAOjC;;;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;AA+BzC,eAAO,MAAM,eAAe,GAAI,aAAa,MAAM,EAAE,eAAe,kBAAkB;aAvG7B,OAAO;;;;;;;;;yKAwGO,CAAA"}
|
package/dist/api/trpc.js
CHANGED
|
@@ -3,6 +3,8 @@ import superjson from 'superjson';
|
|
|
3
3
|
import { ZodError } from 'zod';
|
|
4
4
|
import auth from '../auth/index.js';
|
|
5
5
|
import { db } from '../db/client.js';
|
|
6
|
+
import { and, eq } from 'drizzle-orm';
|
|
7
|
+
import { AdminPrivilegesTable } from '../db/schema.js';
|
|
6
8
|
/**
|
|
7
9
|
* Creates context for an incoming request
|
|
8
10
|
* @link https://trpc.io/docs/v11/context
|
|
@@ -67,3 +69,25 @@ export const publicProcedure = t.procedure;
|
|
|
67
69
|
* @see https://trpc.io/docs/procedures
|
|
68
70
|
*/
|
|
69
71
|
export const privateProcedure = t.procedure.use(isAuthedMiddleware);
|
|
72
|
+
const accessControlMiddleware = (sectionName, requiredRole) => isAuthedMiddleware.unstable_pipe(async ({ ctx, next }) => {
|
|
73
|
+
const privilege = await db
|
|
74
|
+
.select()
|
|
75
|
+
.from(AdminPrivilegesTable)
|
|
76
|
+
.where(and(eq(AdminPrivilegesTable.adminId, ctx.session.user.id), eq(AdminPrivilegesTable.sectionName, sectionName)))
|
|
77
|
+
.limit(1);
|
|
78
|
+
const allowed = privilege[0];
|
|
79
|
+
if (!allowed) {
|
|
80
|
+
throw new TRPCError({
|
|
81
|
+
code: 'NOT_FOUND',
|
|
82
|
+
message: 'Section not found or you do not have access to this operation',
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if (requiredRole && !allowed.operations.includes(requiredRole)) {
|
|
86
|
+
throw new TRPCError({
|
|
87
|
+
code: 'NOT_FOUND',
|
|
88
|
+
message: 'You do not have access to this operation',
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return next();
|
|
92
|
+
});
|
|
93
|
+
export const pluginProcedure = (sectionName, requiredRole) => t.procedure.use(accessControlMiddleware(sectionName, requiredRole));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './loader-with-
|
|
1
|
+
export * from './loader-with-jiti.js';
|
|
2
2
|
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/core/config/loader.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/core/config/loader.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './loader-with-
|
|
1
|
+
export * from './loader-with-jiti.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './section-factory-with-
|
|
1
|
+
export * from './section-factory-with-jiti.js';
|
|
2
2
|
//# sourceMappingURL=SectionFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SectionFactory.d.ts","sourceRoot":"","sources":["../../../src/core/factories/SectionFactory.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"SectionFactory.d.ts","sourceRoot":"","sources":["../../../src/core/factories/SectionFactory.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './section-factory-with-
|
|
1
|
+
export * from './section-factory-with-jiti.js';
|
|
@@ -4,10 +4,6 @@ import type { SectionTypes } from '../types/index.js';
|
|
|
4
4
|
export declare const getSectionImportVersion: () => number;
|
|
5
5
|
type AnySectionConfig = HasItemsSectionConfig | SimpleSectionConfig | CategorySectionConfig;
|
|
6
6
|
export declare class SectionFactory {
|
|
7
|
-
/**
|
|
8
|
-
* These are the fixed sections that can not be present in the sections folder.
|
|
9
|
-
*/
|
|
10
|
-
static readonly fixedSections: string[];
|
|
11
7
|
private static readonly isDev;
|
|
12
8
|
private static readonly isProd;
|
|
13
9
|
private static isCLI;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"section-factory-with-esbuild.d.ts","sourceRoot":"","sources":["../../../src/core/factories/section-factory-with-esbuild.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtF,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC7G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AA2CrD,eAAO,MAAM,uBAAuB,cAAoC,CAAA;AAsHxE,KAAK,gBAAgB,GAAG,qBAAqB,GAAG,mBAAmB,GAAG,qBAAqB,CAAA;AAE3F,qBAAa,cAAc;IACvB
|
|
1
|
+
{"version":3,"file":"section-factory-with-esbuild.d.ts","sourceRoot":"","sources":["../../../src/core/factories/section-factory-with-esbuild.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtF,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC7G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AA2CrD,eAAO,MAAM,uBAAuB,cAAoC,CAAA;AAsHxE,KAAK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AE,CAAA;QAC7B,SAAS,EAAE,qBAAqB,EAAE,CAAA;QAClC,QAAQ,EAAE,qBAAqB,EAAE,CAAA;QACjC,KAAK,EAAE,MAAM,EAAE,CAAA;KAClB,CAAC;IA+BF;;;;;OAKG;WACU,UAAU,CAAC,EACpB,IAAI,EACJ,IAAI,GACP,EAAE;QACC,IAAI,EAAE,MAAM,CAAA;QACZ,IAAI,CAAC,EAAE,YAAY,GAAG,YAAY,EAAE,CAAA;KACvC,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAKpC;;;;;;OAMG;WACU,kBAAkB,CAAC,EAC5B,IAAI,EACJ,IAAI,EACJ,KAAK,GACR,EAAE;QACC,IAAI,EAAE,MAAM,CAAA;QACZ,IAAI,CAAC,EAAE,YAAY,GAAG,YAAY,EAAE,CAAA;QACpC,KAAK,EAAE;YACH,EAAE,EAAE,MAAM,CAAA;YACV,YAAY,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;SACjC,CAAA;KACJ,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAKpC;;;;;;;;;;OAUG;IACH,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;QAClB,KAAK,EAAE,MAAM,eAAe,GAAG,aAAa,GAAG,eAAe,CAAA;QAC9D,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KACrB,GAAG,eAAe,GAAG,aAAa,GAAG,eAAe;IAYrD;;;;;;;;;OASG;mBACkB,GAAG;IA6FxB;;;;OAIG;mBACkB,eAAe;IAmKpC,OAAO,CAAC,MAAM,CAAC,YAAY;IAqD3B,OAAO,CAAC,MAAM,CAAC,IAAI;CAatB"}
|
|
@@ -131,10 +131,6 @@ const loadSectionModuleRuntime = async (absPath) => {
|
|
|
131
131
|
return mod?.default;
|
|
132
132
|
};
|
|
133
133
|
export class SectionFactory {
|
|
134
|
-
/**
|
|
135
|
-
* These are the fixed sections that can not be present in the sections folder.
|
|
136
|
-
*/
|
|
137
|
-
static fixedSections = ['admins', 'analytics', 'emails', 'dashboard'];
|
|
138
134
|
static isDev = process.env.NODE_ENV !== 'production';
|
|
139
135
|
static isProd = !this.isDev;
|
|
140
136
|
static isCLI = false;
|
|
@@ -237,7 +233,7 @@ export class SectionFactory {
|
|
|
237
233
|
.from(AdminPrivilegesTable)
|
|
238
234
|
.where(eq(AdminPrivilegesTable.adminId, admin.id));
|
|
239
235
|
const fixedSections = privileges
|
|
240
|
-
.filter((privilege) =>
|
|
236
|
+
.filter((privilege) => ['admins'].includes(privilege.sectionName))
|
|
241
237
|
.map((privilege) => privilege.sectionName);
|
|
242
238
|
const simpleSections = sections.filter((section) => section.type === 'simple');
|
|
243
239
|
const hasItemsSections = sections.filter((section) => section.type === 'has_items');
|
|
@@ -4,10 +4,6 @@ import type { SectionTypes } from '../types/index.js';
|
|
|
4
4
|
export declare const getSectionImportVersion: () => number;
|
|
5
5
|
type AnySectionConfig = HasItemsSectionConfig | SimpleSectionConfig | CategorySectionConfig;
|
|
6
6
|
export declare class SectionFactory {
|
|
7
|
-
/**
|
|
8
|
-
* These are the fixed sections that can not be present in the sections folder.
|
|
9
|
-
*/
|
|
10
|
-
static readonly fixedSections: string[];
|
|
11
7
|
private static readonly isDev;
|
|
12
8
|
private static readonly isProd;
|
|
13
9
|
private static isCLI;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"section-factory-with-jiti.d.ts","sourceRoot":"","sources":["../../../src/core/factories/section-factory-with-jiti.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtF,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC7G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AA+BrD,eAAO,MAAM,uBAAuB,cAAoC,CAAA;AAiExE,KAAK,gBAAgB,GAA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a,GAAG,eAAe,CAAA;QAC9D,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KACrB,GAAG,eAAe,GAAG,aAAa,GAAG,eAAe;IAYrD;;;;;;;;;OASG;mBACkB,GAAG;IA6FxB;;;;OAIG;mBACkB,eAAe;IAmKpC,OAAO,CAAC,MAAM,CAAC,YAAY;IAwE3B;;;OAGG;IACH,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IA0D5C,OAAO,CAAC,MAAM,CAAC,IAAI;CAatB"}
|
|
@@ -75,10 +75,6 @@ const loadSectionModuleRuntime = async (absPath) => {
|
|
|
75
75
|
return mod?.default ?? mod;
|
|
76
76
|
};
|
|
77
77
|
export class SectionFactory {
|
|
78
|
-
/**
|
|
79
|
-
* These are the fixed sections that can not be present in the sections folder.
|
|
80
|
-
*/
|
|
81
|
-
static fixedSections = ['admins', 'analytics', 'emails', 'dashboard'];
|
|
82
78
|
static isDev = process.env.NODE_ENV !== 'production';
|
|
83
79
|
static isProd = !this.isDev;
|
|
84
80
|
static isCLI = false;
|
|
@@ -180,7 +176,7 @@ export class SectionFactory {
|
|
|
180
176
|
.from(AdminPrivilegesTable)
|
|
181
177
|
.where(eq(AdminPrivilegesTable.adminId, admin.id));
|
|
182
178
|
const fixedSections = privileges
|
|
183
|
-
.filter((privilege) =>
|
|
179
|
+
.filter((privilege) => ['admins'].includes(privilege.sectionName))
|
|
184
180
|
.map((privilege) => privilege.sectionName);
|
|
185
181
|
const simpleSections = sections.filter((section) => section.type === 'simple');
|
|
186
182
|
const hasItemsSections = sections.filter((section) => section.type === 'has_items');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemEditSubmit.d.ts","sourceRoot":"","sources":["../../../src/core/submit/ItemEditSubmit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"ItemEditSubmit.d.ts","sourceRoot":"","sources":["../../../src/core/submit/Item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;AACH,wBAAsB,KAAK,kBAE1B"}
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export type { CMSPlugin, LoadedPlugin, LoadedPluginRoute, PluginInitContext, PluginModule, PluginRoute, } from './loader.js';
|
|
1
|
+
export type { CMSPlugin, CMSPluginMultiRoute, CMSPluginSingleRoute, LoadedPlugin, LoadedPluginRoute, PluginInitContext, PluginModule, PluginRoute, PluginRouteWithoutComponent, PluginRouteWithComponent, } from './loader.js';
|
|
2
|
+
export { definePlugin } from './loader.js';
|
|
2
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACR,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACR,SAAS,EACT,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,2BAA2B,EAC3B,wBAAwB,GAC3B,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA"}
|
package/dist/plugins/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { definePlugin } from './loader.js';
|
package/dist/plugins/loader.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import type { PluginConfigEntry } from '../core/config/config-loader.js';
|
|
2
2
|
export interface CMSPlugin {
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* The human facing title of the plugin.
|
|
5
|
+
* @example 'Some Plugin Title'
|
|
6
|
+
*/
|
|
7
|
+
title: string;
|
|
8
|
+
/**
|
|
9
|
+
* The internal name of the plugin.
|
|
10
|
+
* It should start with 'plugin_' and be in snake_case.
|
|
11
|
+
* @example 'plugin_cpanel_emails'
|
|
12
|
+
*/
|
|
13
|
+
name: string;
|
|
14
|
+
registryName: string;
|
|
4
15
|
version?: string;
|
|
5
16
|
router?: any;
|
|
6
17
|
routes?: PluginRoute[];
|
|
@@ -24,17 +35,32 @@ export interface PluginRoute {
|
|
|
24
35
|
path: string;
|
|
25
36
|
title: string;
|
|
26
37
|
icon?: string;
|
|
27
|
-
component
|
|
28
|
-
prefetch?: (helpers: {
|
|
29
|
-
api: unknown;
|
|
30
|
-
}) => Promise<void> | void;
|
|
38
|
+
component?: string;
|
|
31
39
|
}
|
|
40
|
+
export type PluginRouteWithoutComponent = Omit<PluginRoute, 'component'> & {
|
|
41
|
+
component?: never;
|
|
42
|
+
};
|
|
43
|
+
export type PluginRouteWithComponent = PluginRoute & {
|
|
44
|
+
component: string;
|
|
45
|
+
};
|
|
32
46
|
export interface LoadedPluginRoute extends PluginRoute {
|
|
33
47
|
pluginId: string;
|
|
34
|
-
pluginName
|
|
48
|
+
pluginName: string;
|
|
49
|
+
pluginRegistryName: string;
|
|
50
|
+
pluginTitle: string;
|
|
35
51
|
}
|
|
52
|
+
type CMSPluginBase = Omit<CMSPlugin, 'routes'>;
|
|
53
|
+
export type CMSPluginSingleRoute = CMSPluginBase & {
|
|
54
|
+
routes?: [] | [PluginRouteWithoutComponent];
|
|
55
|
+
};
|
|
56
|
+
export type CMSPluginMultiRoute = CMSPluginBase & {
|
|
57
|
+
routes: [PluginRouteWithComponent, PluginRouteWithComponent, ...PluginRouteWithComponent[]];
|
|
58
|
+
};
|
|
59
|
+
export declare function definePlugin(plugin: CMSPluginSingleRoute): CMSPluginSingleRoute;
|
|
60
|
+
export declare function definePlugin(plugin: CMSPluginMultiRoute): CMSPluginMultiRoute;
|
|
36
61
|
export declare const loadPluginModule: (pluginPackage: string) => Promise<unknown>;
|
|
37
62
|
export declare function loadPlugins(): Promise<LoadedPlugin[]>;
|
|
38
63
|
export declare function getPluginRoutes(): Promise<LoadedPluginRoute[]>;
|
|
39
64
|
export declare function findPluginRouteByPath(path: string): Promise<LoadedPluginRoute | null>;
|
|
65
|
+
export {};
|
|
40
66
|
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/plugins/loader.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/plugins/loader.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAIxE,MAAM,WAAW,SAAS;IACtB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,GAAG,CAAA;IACZ,MAAM,CAAC,EAAE,WAAW,EAAE,CAAA;IACtB,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;CAC1D;AAED,MAAM,WAAW,iBAAiB;IAC9B,MAAM,EAAE,iBAAiB,CAAA;CAC5B;AAED,MAAM,WAAW,YAAY;IACzB,MAAM,EAAE,iBAAiB,CAAA;IACzB,MAAM,EAAE,SAAS,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,YAAY;IACzB,YAAY,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,SAAS,CAAA;IAC/D,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,OAAO,CAAC,EAA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I,OAAO,CAAC,iBAAiB,EAAE,CAAC,CA8BpE;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAI3F"}
|
package/dist/plugins/loader.js
CHANGED
|
@@ -5,6 +5,10 @@ if (typeof window !== 'undefined') {
|
|
|
5
5
|
import { createRequire } from 'module';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import { getCMSConfig, getConfigImportVersion } from '../core/config/index.js';
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
export function definePlugin(plugin) {
|
|
10
|
+
return plugin;
|
|
11
|
+
}
|
|
8
12
|
const deriveRouterKey = (packageName) => {
|
|
9
13
|
const baseName = packageName.split('/').pop() ?? packageName;
|
|
10
14
|
const withoutPrefix = baseName.startsWith('plugin-') ? baseName.slice('plugin-'.length) : baseName;
|
|
@@ -69,8 +73,14 @@ function resolvePluginInstance(registration, mod) {
|
|
|
69
73
|
console.warn(`[plugins] Plugin "${registration.package}" did not return a plugin instance`);
|
|
70
74
|
return null;
|
|
71
75
|
}
|
|
76
|
+
if (!candidate.name || !candidate.title) {
|
|
77
|
+
console.warn(`[plugins] Plugin "${registration.package}" is missing required "name" or "title". Skipping.`);
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
72
80
|
return {
|
|
73
|
-
|
|
81
|
+
title: candidate.title,
|
|
82
|
+
name: candidate.name,
|
|
83
|
+
registryName: candidate.registryName,
|
|
74
84
|
version: candidate.version,
|
|
75
85
|
router: candidate.router,
|
|
76
86
|
routes: candidate.routes ?? [],
|
|
@@ -92,6 +102,12 @@ export async function loadPlugins() {
|
|
|
92
102
|
const seenRouterKeys = new Set();
|
|
93
103
|
const loaded = [];
|
|
94
104
|
for (const registration of registrations) {
|
|
105
|
+
if (!registration.package) {
|
|
106
|
+
console.warn(`[plugins] Plugin registration is missing "package" field.`);
|
|
107
|
+
console.warn(`[plugins] Please check your cms.config.ts file.`);
|
|
108
|
+
console.warn(`[plugins] Skipping this plugin registration.`);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
95
111
|
const mod = await loadPluginModule(registration.package);
|
|
96
112
|
if (!mod)
|
|
97
113
|
continue;
|
|
@@ -138,13 +154,23 @@ export async function loadPlugins() {
|
|
|
138
154
|
export async function getPluginRoutes() {
|
|
139
155
|
const loaded = await loadPlugins();
|
|
140
156
|
return loaded.flatMap((entry) => {
|
|
141
|
-
const
|
|
142
|
-
const
|
|
143
|
-
return
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
157
|
+
const routes = entry.plugin.routes ?? [];
|
|
158
|
+
const requireComponent = routes.length > 1;
|
|
159
|
+
return routes.map((route) => {
|
|
160
|
+
if (requireComponent && !route.component) {
|
|
161
|
+
console.warn(chalk.red(`[plugins] Route "${route.path}" from "${entry.config.package}" should set "component" because the plugin defines multiple routes.`));
|
|
162
|
+
}
|
|
163
|
+
if (!requireComponent && route.component) {
|
|
164
|
+
console.warn(chalk.gray(`[plugins] Route "${route.path}" from "${entry.config.package}" should omit "component" and export a default component, because the plugin defines a single route.`));
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
...route,
|
|
168
|
+
pluginId: entry.config.package,
|
|
169
|
+
pluginName: entry.plugin.name,
|
|
170
|
+
pluginRegistryName: entry.plugin.registryName,
|
|
171
|
+
pluginTitle: entry.plugin.title,
|
|
172
|
+
};
|
|
173
|
+
});
|
|
148
174
|
});
|
|
149
175
|
}
|
|
150
176
|
export async function findPluginRouteByPath(path) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nextjs-cms",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.70",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -26,6 +26,10 @@
|
|
|
26
26
|
"types": "./dist/api/trpc/server.d.ts",
|
|
27
27
|
"default": "./dist/api/trpc/server.js"
|
|
28
28
|
},
|
|
29
|
+
"./api/trpc/client": {
|
|
30
|
+
"types": "./dist/api/trpc/client.d.ts",
|
|
31
|
+
"default": "./dist/api/trpc/client.js"
|
|
32
|
+
},
|
|
29
33
|
"./auth": {
|
|
30
34
|
"types": "./dist/auth/index.d.ts",
|
|
31
35
|
"default": "./dist/auth/index.js"
|
|
@@ -113,6 +117,10 @@
|
|
|
113
117
|
"./plugins/server": {
|
|
114
118
|
"types": "./dist/plugins/server.d.ts",
|
|
115
119
|
"default": "./dist/plugins/server.js"
|
|
120
|
+
},
|
|
121
|
+
"./plugins/blank-component": {
|
|
122
|
+
"types": "./dist/plugins/blank.d.ts",
|
|
123
|
+
"default": "./dist/plugins/blank.js"
|
|
116
124
|
}
|
|
117
125
|
},
|
|
118
126
|
"files": [
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export declare const googleAnalyticsRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
2
|
-
ctx: {
|
|
3
|
-
headers: Headers;
|
|
4
|
-
db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../../db/schema.js")> & {
|
|
5
|
-
$client: import("mysql2/promise").Pool;
|
|
6
|
-
};
|
|
7
|
-
session: import("../../index.js").Session | null;
|
|
8
|
-
};
|
|
9
|
-
meta: object;
|
|
10
|
-
errorShape: {
|
|
11
|
-
data: {
|
|
12
|
-
zodError: import("zod").ZodFlattenedError<unknown, string> | null;
|
|
13
|
-
code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
|
|
14
|
-
httpStatus: number;
|
|
15
|
-
path?: string;
|
|
16
|
-
stack?: string;
|
|
17
|
-
};
|
|
18
|
-
message: string;
|
|
19
|
-
code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
|
|
20
|
-
};
|
|
21
|
-
transformer: true;
|
|
22
|
-
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
23
|
-
test: import("@trpc/server").TRPCQueryProcedure<{
|
|
24
|
-
input: void;
|
|
25
|
-
output: boolean;
|
|
26
|
-
meta: object;
|
|
27
|
-
}>;
|
|
28
|
-
}>>;
|
|
29
|
-
//# sourceMappingURL=googleAnalytics.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"googleAnalytics.d.ts","sourceRoot":"","sources":["../../../src/api/routers/googleAnalytics.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;GAIhC,CAAA"}
|