nextjs-cms 0.5.67 → 0.5.69
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 +9 -99
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +5 -4
- 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 +73 -20
- package/dist/api/root.d.ts +56 -213
- package/dist/api/root.d.ts.map +1 -1
- package/dist/api/root.js +88 -8
- package/dist/api/routers/admins.d.ts.map +1 -1
- package/dist/api/routers/admins.js +53 -3
- package/dist/api/routers/categorySection.js +1 -1
- package/dist/api/routers/gallery.d.ts.map +1 -1
- package/dist/api/routers/gallery.js +1 -0
- package/dist/api/routers/hasItemsSection.js +1 -1
- 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/server.d.ts.map +1 -1
- package/dist/api/trpc/server.js +41 -3
- package/dist/api/trpc.d.ts +15 -0
- package/dist/api/trpc.d.ts.map +1 -1
- package/dist/api/trpc.js +24 -0
- package/dist/core/config/config-loader.d.ts +8 -0
- package/dist/core/config/config-loader.d.ts.map +1 -1
- package/dist/core/config/config-loader.js +17 -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/index.d.ts +3 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/loader.d.ts +71 -0
- package/dist/plugins/loader.d.ts.map +1 -0
- package/dist/plugins/loader.js +187 -0
- package/dist/plugins/server.d.ts +2 -0
- package/dist/plugins/server.d.ts.map +1 -0
- package/dist/plugins/server.js +1 -0
- package/dist/translations/index.js +2 -2
- package/package.json +19 -3
- 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,6 +1,6 @@
|
|
|
1
1
|
import { privateProcedure, router } from '../trpc.js';
|
|
2
2
|
import * as z from 'zod';
|
|
3
|
-
import { deleteSectionItem, getCategorySection, getCategorySectionChildren } from '../lib/serverActions';
|
|
3
|
+
import { deleteSectionItem, getCategorySection, getCategorySectionChildren } from '../lib/serverActions.js';
|
|
4
4
|
export const categorySectionRouter = router({
|
|
5
5
|
get: privateProcedure
|
|
6
6
|
.input(z.object({
|
|
@@ -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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { privateProcedure, router } from '../trpc.js';
|
|
2
2
|
import * as z from 'zod';
|
|
3
|
-
import { createEditPage, createNewPage, deleteSectionItem, getBrowsePage } from '../lib/serverActions';
|
|
3
|
+
import { createEditPage, createNewPage, deleteSectionItem, getBrowsePage } from '../lib/serverActions.js';
|
|
4
4
|
export const hasItemsSectionRouter = router({
|
|
5
5
|
listItems: privateProcedure
|
|
6
6
|
.input(z.object({
|
|
@@ -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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/api/trpc/server.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAI9D,OAAO,EAAgB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/api/trpc/server.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAI9D,OAAO,EAAgB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAA;AA8DzD,eAAO,MAAM,GAAG,EAAc,UAAU,CAAC,OAAO,sBAAsB,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;AAC1F,eAAO,MAAM,aAAa;;iCAAmB,CAAA"}
|
package/dist/api/trpc/server.js
CHANGED
|
@@ -2,7 +2,7 @@ import 'server-only';
|
|
|
2
2
|
import { createHydrationHelpers } from '@trpc/react-query/rsc';
|
|
3
3
|
import { headers } from 'next/headers';
|
|
4
4
|
import { cache } from 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { getAppRouter } from '../root.js';
|
|
6
6
|
import { createTRPCContext } from '../trpc.js';
|
|
7
7
|
import { createQueryClient } from './query-client.js';
|
|
8
8
|
/**
|
|
@@ -17,7 +17,45 @@ const createContext = cache(async () => {
|
|
|
17
17
|
});
|
|
18
18
|
});
|
|
19
19
|
const getQueryClient = cache(createQueryClient);
|
|
20
|
-
const
|
|
21
|
-
const
|
|
20
|
+
const getCaller = cache(async () => {
|
|
21
|
+
const routerWithPlugins = await getAppRouter();
|
|
22
|
+
return routerWithPlugins.createCaller(await createContext());
|
|
23
|
+
});
|
|
24
|
+
const resolveCallerPath = (root, path) => {
|
|
25
|
+
let current = root;
|
|
26
|
+
for (const key of path) {
|
|
27
|
+
if (!current || (typeof current !== 'object' && typeof current !== 'function')) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
current = current[key];
|
|
31
|
+
}
|
|
32
|
+
return current;
|
|
33
|
+
};
|
|
34
|
+
const callProcedure = async (path, args) => {
|
|
35
|
+
const caller = await getCaller();
|
|
36
|
+
const proc = resolveCallerPath(caller, path);
|
|
37
|
+
if (typeof proc !== 'function') {
|
|
38
|
+
throw new Error(`tRPC procedure not found: ${path.join('.')}`);
|
|
39
|
+
}
|
|
40
|
+
return proc(...args);
|
|
41
|
+
};
|
|
42
|
+
const createCallerProxy = (path = []) => {
|
|
43
|
+
const proxyTarget = (...args) => callProcedure(path, args);
|
|
44
|
+
return new Proxy(proxyTarget, {
|
|
45
|
+
get(_target, prop) {
|
|
46
|
+
if (prop === 'then')
|
|
47
|
+
return undefined;
|
|
48
|
+
if (typeof prop !== 'string')
|
|
49
|
+
return undefined;
|
|
50
|
+
return createCallerProxy([...path, prop]);
|
|
51
|
+
},
|
|
52
|
+
apply(_target, _thisArg, args) {
|
|
53
|
+
return callProcedure(path, args);
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
// Lazily resolves the caller so plugin routers are available without top-level await.
|
|
58
|
+
const callerProxy = createCallerProxy();
|
|
59
|
+
const _t = createHydrationHelpers(callerProxy, getQueryClient);
|
|
22
60
|
export const api = _t.trpc;
|
|
23
61
|
export const HydrateClient = _t.HydrateClient;
|
package/dist/api/trpc.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export declare const createTRPCContext: (opts: {
|
|
|
12
12
|
};
|
|
13
13
|
session: import("../index.js").Session | null;
|
|
14
14
|
}>;
|
|
15
|
+
type Context = Awaited<ReturnType<typeof createTRPCContext>>;
|
|
16
|
+
export type TRPCContext = Context;
|
|
15
17
|
export declare const transformer: {
|
|
16
18
|
input: typeof superjson;
|
|
17
19
|
output: typeof superjson;
|
|
@@ -93,4 +95,17 @@ export declare const privateProcedure: import("@trpc/server").TRPCProcedureBuild
|
|
|
93
95
|
user: import("../index.js").User;
|
|
94
96
|
};
|
|
95
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 {};
|
|
96
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));
|
|
@@ -47,8 +47,15 @@ declare const cmsConfigSchema: z.ZodObject<{
|
|
|
47
47
|
}, z.core.$strip>>;
|
|
48
48
|
}, z.core.$strip>>;
|
|
49
49
|
}, z.core.$strip>>;
|
|
50
|
+
plugins: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
51
|
+
package: z.ZodString;
|
|
52
|
+
}, z.core.$strip>>>;
|
|
50
53
|
}, z.core.$strip>;
|
|
51
54
|
export type CMSConfig = z.infer<typeof cmsConfigSchema>;
|
|
55
|
+
export interface PluginConfigEntry {
|
|
56
|
+
package: string;
|
|
57
|
+
options?: Record<string, unknown>;
|
|
58
|
+
}
|
|
52
59
|
export interface ComputedCMSConfig {
|
|
53
60
|
ui: {
|
|
54
61
|
title: string;
|
|
@@ -89,6 +96,7 @@ export interface ComputedCMSConfig {
|
|
|
89
96
|
};
|
|
90
97
|
};
|
|
91
98
|
};
|
|
99
|
+
plugins: PluginConfigEntry[];
|
|
92
100
|
}
|
|
93
101
|
/**
|
|
94
102
|
* Gets the CMS configuration, loading it lazily on first access.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../../src/core/config/config-loader.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAIxB,QAAA,MAAM,eAAe
|
|
1
|
+
{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../../src/core/config/config-loader.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAIxB,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiKnB,CAAA;AAGF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAEvD,MAAM,WAAW,iBAAiB;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACpC;AAGD,MAAM,WAAW,iBAAiB;IAC9B,EAAE,EAAE;QACA,KAAK,EAAE,MAAM,CAAA;QACb,YAAY,EAAE,MAAM,CAAA;QACpB,IAAI,EAAE,MAAM,CAAA;KACf,CAAA;IACD,KAAK,EAAE,OAAO,CAAA;IACd,QAAQ,EAAE;QACN,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,OAAO,CAAA;QACf,QAAQ,EAAE;YACN,oBAAoB,EAAE,OAAO,CAAA;SAChC,CAAA;KACJ,CAAA;IACD,KAAK,EAAE;QACH,MAAM,EAAE;YACJ,IAAI,EAAE,MAAM,CAAA;YACZ,iBAAiB,EAAE,OAAO,CAAA;SAC7B,CAAA;QACD,MAAM,EAAE;YACJ,SAAS,EAAE;gBACP,KAAK,EAAE,MAAM,CAAA;gBACb,MAAM,EAAE,MAAM,CAAA;gBACd,IAAI,EAAE,OAAO,CAAA;gBACb,OAAO,EAAE,MAAM,CAAA;aAClB,CAAA;YACD,SAAS,EAAE,OAAO,CAAA;SACrB,CAAA;KACJ,CAAA;IACD,gBAAgB,EAAE;QACd,OAAO,EAAE;YACL,OAAO,EAAE,OAAO,CAAA;YAChB,MAAM,EAAE,MAAM,CAAA;YACd,QAAQ,EAAE,MAAM,CAAA;YAChB,MAAM,EAAE;gBACJ,MAAM,EAAE,WAAW,GAAG,WAAW,GAAG,YAAY,CAAA;gBAChD,OAAO,EAAE,WAAW,GAAG,WAAW,GAAG,YAAY,CAAA;aACpD,CAAA;SACJ,CAAA;KACJ,CAAA;IACD,OAAO,EAAE,iBAAiB,EAAE,CAAA;CAC/B;AAsID;;;;;;GAMG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAazE"}
|
|
@@ -143,6 +143,21 @@ const cmsConfigSchema = z.object({
|
|
|
143
143
|
.optional(),
|
|
144
144
|
})
|
|
145
145
|
.optional(),
|
|
146
|
+
/**
|
|
147
|
+
* Plugins configuration
|
|
148
|
+
*/
|
|
149
|
+
plugins: z
|
|
150
|
+
.array(z.object({
|
|
151
|
+
/**
|
|
152
|
+
* The npm package name of the plugin to load
|
|
153
|
+
*/
|
|
154
|
+
package: z.string(),
|
|
155
|
+
/**
|
|
156
|
+
* Arbitrary options passed to the plugin factory
|
|
157
|
+
*/
|
|
158
|
+
// options: z.record(z.unknown()).optional(),
|
|
159
|
+
}))
|
|
160
|
+
.optional(),
|
|
146
161
|
});
|
|
147
162
|
// Merge utility function
|
|
148
163
|
function mergeConfig(defaults, userConfig) {
|
|
@@ -189,6 +204,7 @@ function mergeConfig(defaults, userConfig) {
|
|
|
189
204
|
},
|
|
190
205
|
},
|
|
191
206
|
},
|
|
207
|
+
plugins: userConfig.plugins ?? defaults.plugins,
|
|
192
208
|
};
|
|
193
209
|
}
|
|
194
210
|
// Default configuration values
|
|
@@ -232,6 +248,7 @@ const defaultConfig = {
|
|
|
232
248
|
},
|
|
233
249
|
},
|
|
234
250
|
},
|
|
251
|
+
plugins: [],
|
|
235
252
|
};
|
|
236
253
|
/*const error = (error: string, greyMsg = ''): string => {
|
|
237
254
|
return `${chalk.bgRed.bold(' Error ')} ${error} ${greyMsg ? chalk.grey(greyMsg) : ''}`.trim()
|
|
@@ -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/fact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,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,GAAG,qBAAqB,GAAG,mBAAmB,GAAG,qBAAqB,CAAA;AAE3F,qBAAa,cAAc;IACvB
|
|
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,GAAG,qBAAqB,GAAG,mBAAmB,GAAG,qBAAqB,CAAA;AAE3F,qBAAa,cAAc;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAwC;IACrE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAc;IAC5C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAQ;IAC5B,OAAO,CAAC,MAAM,CAAC,QAAQ;IAIvB,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAA+B;IACrE,OAAO,CAAC,MAAM,CAAC,qBAAqB,CAA+B;IACnE,OAAO,CAAC,MAAM,CAAC,UAAU,CAAI;IAE7B;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAA2C;IA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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;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/ItemEditSubmit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAItC,OAAO,KAAK,EAAuB,KAAK,EAAE,MAAM,WAAW,CAAA;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,OAAO,EAAE,UAAU,EAAM,MAAM,YAAY,CAAA;AAC3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAOtC,KAAK,eAAe,GAAG;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,IAAI,CAAA;IACV,QAAQ,EAAE,QAAQ,CAAA;IAClB,SAAS,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,qBAAa,UAAW,SAAQ,MAAM;IAClC,gBAAyB,CAAC,UAAU,CAAC,EAAE,MAAM,CAAe;IAC5D,mBAA4B,OAAO,EAAE,MAAM,CAAA;IAC3C,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAK;IAE3C;;OAEG;gBACS,MAAM,EAAE,eAAe;IAKnC;;;OAGG;IACmB,UAAU;YASlB,qBAAqB;IAuBnC;;;OAGG;YACW,aAAa;YAQb,sBAAsB;IAoBpC;;;;;OAKG;cACsB,kBAAkB;IAI3C;;;;;OAKG;cACsB,cAAc;IAUvC;;;OAGG;cACgB,aAAa,IAAI,GAAG,GAAG,SAAS;IAmBnD;;;;OAIG;IACM,aAAa,CAAC,KAAK,EAAE,KAAK;IAmBnC;;;;OAIG;IACY,WAAW,CAAC,KAAK,EAAE,KAAK;IAQvC;;OAEG;IACM,iBAAiB;IAI1B;;;;OAIG;IACM,aAAa,CAAC,KAAK,EAAE,KAAK;CAgBtC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type { CMSPlugin, CMSPluginMultiRoute, CMSPluginSingleRoute, LoadedPlugin, LoadedPluginRoute, PluginInitContext, PluginModule, PluginRoute, PluginRouteWithoutComponent, PluginRouteWithComponent, } from './loader.js';
|
|
2
|
+
export { definePlugin } from './loader.js';
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { definePlugin } from './loader.js';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { PluginConfigEntry } from '../core/config/config-loader.js';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
export interface CMSPlugin {
|
|
4
|
+
/**
|
|
5
|
+
* The human facing title of the plugin.
|
|
6
|
+
* @example 'Some Plugin Title'
|
|
7
|
+
*/
|
|
8
|
+
title: string;
|
|
9
|
+
/**
|
|
10
|
+
* The internal name of the plugin.
|
|
11
|
+
* It should start with 'plugin_' and be in snake_case.
|
|
12
|
+
* @example 'plugin_cpanel_emails'
|
|
13
|
+
*/
|
|
14
|
+
name: string;
|
|
15
|
+
version?: string;
|
|
16
|
+
router?: any;
|
|
17
|
+
routes?: PluginRoute[];
|
|
18
|
+
init?: (ctx: PluginInitContext) => Promise<void> | void;
|
|
19
|
+
}
|
|
20
|
+
export interface PluginInitContext {
|
|
21
|
+
config: PluginConfigEntry;
|
|
22
|
+
}
|
|
23
|
+
export interface LoadedPlugin {
|
|
24
|
+
config: PluginConfigEntry;
|
|
25
|
+
plugin: CMSPlugin;
|
|
26
|
+
moduleName: string;
|
|
27
|
+
routerKey: string;
|
|
28
|
+
}
|
|
29
|
+
export interface PluginModule {
|
|
30
|
+
createPlugin?: (options?: Record<string, unknown>) => CMSPlugin;
|
|
31
|
+
plugin?: CMSPlugin;
|
|
32
|
+
default?: CMSPlugin | (() => CMSPlugin);
|
|
33
|
+
}
|
|
34
|
+
export interface PluginRoute {
|
|
35
|
+
path: string;
|
|
36
|
+
title: string;
|
|
37
|
+
icon?: string;
|
|
38
|
+
component?: string;
|
|
39
|
+
}
|
|
40
|
+
export type PluginRouteWithoutComponent = Omit<PluginRoute, 'component'> & {
|
|
41
|
+
component?: never;
|
|
42
|
+
};
|
|
43
|
+
export type PluginRouteWithComponent = PluginRoute & {
|
|
44
|
+
component: string;
|
|
45
|
+
};
|
|
46
|
+
export interface LoadedPluginRoute extends PluginRoute {
|
|
47
|
+
pluginId: string;
|
|
48
|
+
pluginName: string;
|
|
49
|
+
pluginTitle: string;
|
|
50
|
+
}
|
|
51
|
+
type CMSPluginBase = Omit<CMSPlugin, 'routes'>;
|
|
52
|
+
export type CMSPluginSingleRoute = CMSPluginBase & {
|
|
53
|
+
routes?: [] | [PluginRouteWithoutComponent];
|
|
54
|
+
};
|
|
55
|
+
export type CMSPluginMultiRoute = CMSPluginBase & {
|
|
56
|
+
routes: [PluginRouteWithComponent, PluginRouteWithComponent, ...PluginRouteWithComponent[]];
|
|
57
|
+
};
|
|
58
|
+
export declare function definePlugin(plugin: CMSPluginSingleRoute): CMSPluginSingleRoute;
|
|
59
|
+
export declare function definePlugin(plugin: CMSPluginMultiRoute): CMSPluginMultiRoute;
|
|
60
|
+
export declare const loadPluginModule: (pluginPackage: string) => Promise<unknown>;
|
|
61
|
+
export declare function loadPlugins(): Promise<LoadedPlugin[]>;
|
|
62
|
+
export declare function getPluginRoutes(): Promise<LoadedPluginRoute[]>;
|
|
63
|
+
export declare function findPluginRouteByPath(path: string): Promise<LoadedPluginRoute | null>;
|
|
64
|
+
type PluginServerComponent = (props?: Record<string, unknown>) => ReactNode | Promise<ReactNode>;
|
|
65
|
+
type PluginServerModule = {
|
|
66
|
+
default?: PluginServerComponent;
|
|
67
|
+
[key: string]: unknown;
|
|
68
|
+
};
|
|
69
|
+
export declare const pluginServerLoaders: Record<string, () => Promise<PluginServerModule>>;
|
|
70
|
+
export {};
|
|
71
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +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;AAGxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,MAAM,WAAW,SAAS;IACtB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ,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,EAA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