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.
Files changed (53) hide show
  1. package/dist/api/index.d.ts +9 -99
  2. package/dist/api/index.d.ts.map +1 -1
  3. package/dist/api/index.js +5 -4
  4. package/dist/api/lib/serverActions.d.ts +6 -0
  5. package/dist/api/lib/serverActions.d.ts.map +1 -1
  6. package/dist/api/lib/serverActions.js +73 -20
  7. package/dist/api/root.d.ts +56 -213
  8. package/dist/api/root.d.ts.map +1 -1
  9. package/dist/api/root.js +88 -8
  10. package/dist/api/routers/admins.d.ts.map +1 -1
  11. package/dist/api/routers/admins.js +53 -3
  12. package/dist/api/routers/categorySection.js +1 -1
  13. package/dist/api/routers/gallery.d.ts.map +1 -1
  14. package/dist/api/routers/gallery.js +1 -0
  15. package/dist/api/routers/hasItemsSection.js +1 -1
  16. package/dist/api/trpc/client.d.ts +4 -0
  17. package/dist/api/trpc/client.d.ts.map +1 -0
  18. package/dist/api/trpc/client.js +3 -0
  19. package/dist/api/trpc/server.d.ts.map +1 -1
  20. package/dist/api/trpc/server.js +41 -3
  21. package/dist/api/trpc.d.ts +15 -0
  22. package/dist/api/trpc.d.ts.map +1 -1
  23. package/dist/api/trpc.js +24 -0
  24. package/dist/core/config/config-loader.d.ts +8 -0
  25. package/dist/core/config/config-loader.d.ts.map +1 -1
  26. package/dist/core/config/config-loader.js +17 -0
  27. package/dist/core/config/loader.d.ts +1 -1
  28. package/dist/core/config/loader.d.ts.map +1 -1
  29. package/dist/core/config/loader.js +1 -1
  30. package/dist/core/factories/SectionFactory.d.ts +1 -1
  31. package/dist/core/factories/SectionFactory.d.ts.map +1 -1
  32. package/dist/core/factories/SectionFactory.js +1 -1
  33. package/dist/core/factories/section-factory-with-esbuild.d.ts +0 -4
  34. package/dist/core/factories/section-factory-with-esbuild.d.ts.map +1 -1
  35. package/dist/core/factories/section-factory-with-esbuild.js +1 -5
  36. package/dist/core/factories/section-factory-with-jiti.d.ts +0 -4
  37. package/dist/core/factories/section-factory-with-jiti.d.ts.map +1 -1
  38. package/dist/core/factories/section-factory-with-jiti.js +1 -5
  39. package/dist/core/submit/ItemEditSubmit.d.ts.map +1 -1
  40. package/dist/plugins/index.d.ts +3 -0
  41. package/dist/plugins/index.d.ts.map +1 -0
  42. package/dist/plugins/index.js +1 -0
  43. package/dist/plugins/loader.d.ts +71 -0
  44. package/dist/plugins/loader.d.ts.map +1 -0
  45. package/dist/plugins/loader.js +187 -0
  46. package/dist/plugins/server.d.ts +2 -0
  47. package/dist/plugins/server.d.ts.map +1 -0
  48. package/dist/plugins/server.js +1 -0
  49. package/dist/translations/index.js +2 -2
  50. package/package.json +19 -3
  51. package/dist/api/routers/googleAnalytics.d.ts +0 -29
  52. package/dist/api/routers/googleAnalytics.d.ts.map +0 -1
  53. package/dist/api/routers/googleAnalytics.js +0 -7
@@ -1,7 +1,7 @@
1
1
  import type { inferRouterInputs, inferRouterOutputs } from '@trpc/server';
2
2
  import type { AppRouter } from './root.js';
3
- import { appRouter } from './root.js';
4
- import { createTRPCContext } from './trpc.js';
3
+ import { appRouter, createCallerWithPlugins, getAppRouter } from './root.js';
4
+ import { createTRPCContext, privateProcedure, publicProcedure, router, pluginProcedure } from './trpc.js';
5
5
  /**
6
6
  * Create a server-side caller for the tRPC API
7
7
  * @example
@@ -759,7 +759,7 @@ declare const createCaller: import("@trpc/server").TRPCRouterCaller<{
759
759
  meta: object;
760
760
  }>;
761
761
  }>>;
762
- cpanel: import("@trpc/server").TRPCBuiltRouter<{
762
+ plugins: import("@trpc/server").TRPCBuiltRouter<{
763
763
  ctx: {
764
764
  headers: Headers;
765
765
  db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../db/schema.js")> & {
@@ -781,105 +781,14 @@ declare const createCaller: import("@trpc/server").TRPCRouterCaller<{
781
781
  };
782
782
  transformer: true;
783
783
  }, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
784
- getData: import("@trpc/server").TRPCQueryProcedure<{
785
- input: void;
786
- output: {
787
- dbsLimit: number;
788
- dbsCount: number;
789
- bandwidthUsage: number;
790
- bandwidthLimit: number;
791
- diskSpaceUsage: number;
792
- diskSpaceLimit: number;
793
- emailsUsage: number;
794
- emailsLimit: number;
795
- dbInfo: any;
796
- dbsList: any;
797
- phpVersion: any;
798
- passengerAppList: never[];
799
- documentRoot: any;
800
- };
801
- meta: object;
802
- }>;
803
- getEmails: import("@trpc/server").TRPCQueryProcedure<{
804
- input: void;
805
- output: {
806
- emails: any;
807
- };
808
- meta: object;
809
- }>;
810
- createEmail: import("@trpc/server").TRPCMutationProcedure<{
811
- input: {
812
- email: string;
813
- password: string;
814
- quota: string;
815
- };
816
- output: any;
817
- meta: object;
818
- }>;
819
- quotaChange: import("@trpc/server").TRPCMutationProcedure<{
784
+ checkRoute: import("@trpc/server").TRPCQueryProcedure<{
820
785
  input: {
821
- email: string;
822
- quota: string;
823
- };
824
- output: any;
825
- meta: object;
826
- }>;
827
- passwordChange: import("@trpc/server").TRPCMutationProcedure<{
828
- input: {
829
- email: string;
830
- password: string;
831
- passwordConfirm: string;
832
- };
833
- output: any;
834
- meta: object;
835
- }>;
836
- deleteEmail: import("@trpc/server").TRPCMutationProcedure<{
837
- input: string;
838
- output: any;
839
- meta: object;
840
- }>;
841
- }>>;
842
- googleAnalytics: import("@trpc/server").TRPCBuiltRouter<{
843
- ctx: {
844
- headers: Headers;
845
- db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../db/schema.js")> & {
846
- $client: import("mysql2/promise").Pool;
847
- };
848
- session: import("../index.js").Session | null;
849
- };
850
- meta: object;
851
- errorShape: {
852
- data: {
853
- zodError: import("zod").ZodFlattenedError<unknown, string> | null;
854
- code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
855
- httpStatus: number;
856
- path?: string;
857
- stack?: string;
786
+ path: string;
858
787
  };
859
- message: string;
860
- code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
861
- };
862
- transformer: true;
863
- }, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
864
- test: import("@trpc/server").TRPCQueryProcedure<{
865
- input: void;
866
- output: boolean;
788
+ output: import("../plugins/loader.js").LoadedPluginRoute | null;
867
789
  meta: object;
868
790
  }>;
869
791
  }>>;
870
- getHello1: import("@trpc/server").TRPCQueryProcedure<{
871
- input: void;
872
- output: {
873
- headers: Headers;
874
- db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../db/schema.js")> & {
875
- $client: import("mysql2/promise").Pool;
876
- };
877
- session: {
878
- user: import("../index.js").User;
879
- };
880
- };
881
- meta: object;
882
- }>;
883
792
  }>>;
884
793
  /**
885
794
  * Inference helpers for input types
@@ -895,7 +804,8 @@ type RouterInputs = inferRouterInputs<AppRouter>;
895
804
  * ^? Post[]
896
805
  **/
897
806
  type RouterOutputs = inferRouterOutputs<AppRouter>;
898
- export { createTRPCContext, appRouter, createCaller };
807
+ export { createTRPCContext, appRouter, createCaller, createCallerWithPlugins, getAppRouter };
808
+ export { router, publicProcedure, privateProcedure, pluginProcedure };
899
809
  export type { AppRouter, RouterInputs, RouterOutputs };
900
- export { axiosPrivate } from './axios/axiosInstance';
810
+ export { axiosPrivate } from './axios/axiosInstance.js';
901
811
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAuB,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAElE;;;;;;GAMG;AACH,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAiC,CAAA;AAEnD;;;;;IAKI;AACJ,KAAK,YAAY,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAA;AAEhD;;;;;IAKI;AACJ,KAAK,aAAa,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAA;AAElD,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,YAAY,EAAE,uBAAuB,EAAE,YAAY,EAAE,CAAA;AAC5F,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAA;AACrE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA"}
package/dist/api/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { appRouter } from './root.js';
2
- import { createCallerFactory, createTRPCContext } from './trpc.js';
1
+ import { appRouter, createCallerWithPlugins, getAppRouter } from './root.js';
2
+ import { createCallerFactory, createTRPCContext, privateProcedure, publicProcedure, router, pluginProcedure, } from './trpc.js';
3
3
  /**
4
4
  * Create a server-side caller for the tRPC API
5
5
  * @example
@@ -8,5 +8,6 @@ import { createCallerFactory, createTRPCContext } from './trpc.js';
8
8
  * ^? Post[]
9
9
  */
10
10
  const createCaller = createCallerFactory(appRouter);
11
- export { createTRPCContext, appRouter, createCaller };
12
- export { axiosPrivate } from './axios/axiosInstance';
11
+ export { createTRPCContext, appRouter, createCaller, createCallerWithPlugins, getAppRouter };
12
+ export { router, publicProcedure, privateProcedure, pluginProcedure };
13
+ export { axiosPrivate } from './axios/axiosInstance.js';
@@ -1,4 +1,9 @@
1
1
  import type { Session } from '../../auth/index.js';
2
+ export declare const isAccessAllowed: ({ sectionName, role, userId, }: {
3
+ sectionName: string;
4
+ role?: "C" | "U" | "D";
5
+ userId: string;
6
+ }) => Promise<boolean>;
2
7
  export declare const getDocument: (session: Session, input: {
3
8
  name: string;
4
9
  sectionName: string;
@@ -22,6 +27,7 @@ export declare const getVideo: (input: {
22
27
  sectionName: string;
23
28
  fieldName: string;
24
29
  }) => Promise<never>;
30
+ export declare const getAdminPrivileges: (adminId: string) => Promise<Set<string>>;
25
31
  export declare const getAllPrivileges: () => Promise<{
26
32
  title: string;
27
33
  order: number;
@@ -1 +1 @@
1
- {"version":3,"file":"serverActions.d.ts","sourceRoot":"","sources":["../../../src/api/lib/serverActions.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAQlD,eAAO,MAAM,WAAW,GACpB,SAAS,OAAO,EAChB,OAAO;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE;;;EAqGlE,CAAA;AA8BD,eAAO,MAAM,QAAQ,GAAU,OAAO;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,oBAgDxF,CAAA;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,wDAyB3F;AAED,eAAO,MAAM,QAAQ,GAAU,OAAO;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,mBAE7F,CAAA;AAED,eAAO,MAAM,gBAAgB;WAKd,MAAM;WACN,MAAM;iBACA,MAAM;iBACN,MAAM;IAoB1B,CAAA;AAED,eAAO,MAAM,aAAa;QAcd,MAAM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E,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;CAChB;;;;;;;;;;;;;;;;;;;;EA2DA,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAU,SAAS,OAAO,EAAE,aAAa,MAAM;;;;;;;;;;;;;;;;;;;;;;kBA+C/C,MAAM,GAAG,MAAM,GAAG,SAAS;;;;;;EAgBzD,CAAA;AAED,eAAO,MAAM,aAAa,GAAU,SAAS,OAAO,EAAE,aAAa,MAAM,EAAE,OAAM,MAAU,EAAE,IAAI,MAAM;;;;;;;;;;;;;;YA6EnF,MAAM,GAAG,MAAM;sBACL,MAAM;oBACR,MAAM,GAAG,IAAI;mBACd,MAAM;mBACN,MAAM;oBACL,MAAM;;;;EAKjC,CAAA;AAED,eAAO,MAAM,UAAU,GAAU,SAAS,OAAO;;;;;;;;;;;;;;;;;;;;;EA+DhD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GACnB,MAAM,MAAM,EACZ,UAAU;IACN,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;CACf,KACF,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAcpC,CAAA"}
@@ -13,7 +13,26 @@ import sharp from 'sharp';
13
13
  import { readChunk } from 'read-chunk';
14
14
  import { fileTypeFromBuffer } from 'file-type';
15
15
  import { getCMSConfig } from '../../core/config/index.js';
16
+ import { getPluginRoutes } from '../../plugins/loader.js';
16
17
  import through2 from 'through2';
18
+ export const isAccessAllowed = async ({ sectionName, role, userId, }) => {
19
+ /**
20
+ * Check admin privileges
21
+ */
22
+ const _res = await db
23
+ .select()
24
+ .from(AdminPrivilegesTable)
25
+ .where(and(eq(AdminPrivilegesTable.adminId, userId), eq(AdminPrivilegesTable.sectionName, sectionName)))
26
+ .limit(1);
27
+ const allowed = _res[0];
28
+ if (!allowed)
29
+ return false;
30
+ if (role) {
31
+ if (!allowed.operations.includes(role))
32
+ return false;
33
+ }
34
+ return true;
35
+ };
17
36
  export const getDocument = async (session, input) => {
18
37
  const { name, sectionName, fieldName } = input;
19
38
  // Sanitize the inputs
@@ -198,8 +217,15 @@ export async function streamPhoto(input) {
198
217
  export const getVideo = async (input) => {
199
218
  throw new Error('Please use the /api/video route');
200
219
  };
220
+ export const getAdminPrivileges = async (adminId) => {
221
+ const rows = await db
222
+ .select({ sectionName: AdminPrivilegesTable.sectionName })
223
+ .from(AdminPrivilegesTable)
224
+ .where(eq(AdminPrivilegesTable.adminId, adminId));
225
+ return new Set(rows.map((row) => row.sectionName));
226
+ };
201
227
  export const getAllPrivileges = async () => {
202
- const sections = await SectionFactory.getSections();
228
+ const [sections, pluginRoutes] = await Promise.all([SectionFactory.getSections(), getPluginRoutes()]);
203
229
  // First, let's assign the static privileges
204
230
  const privilegesList = [];
205
231
  // Now, let's add the rest of the privileges to the list
@@ -211,7 +237,23 @@ export const getAllPrivileges = async () => {
211
237
  sectionType: section.type,
212
238
  });
213
239
  });
214
- privilegesList.push({ title: 'Admins', order: 0, sectionName: 'admins', sectionType: 'static' }, { title: 'Emails', order: 1, sectionName: 'emails', sectionType: 'static' }, { title: 'Log', order: 2, sectionName: 'log', sectionType: 'static' });
240
+ const pluginPrivileges = new Map();
241
+ pluginRoutes.forEach((route) => {
242
+ if (pluginPrivileges.has(route.pluginName))
243
+ return;
244
+ pluginPrivileges.set(route.pluginName, {
245
+ title: route.pluginTitle,
246
+ });
247
+ });
248
+ Array.from(pluginPrivileges.entries()).forEach(([pluginName, meta], index) => {
249
+ privilegesList.push({
250
+ title: meta.title,
251
+ order: sections.length + index,
252
+ sectionName: pluginName,
253
+ sectionType: 'plugin',
254
+ });
255
+ });
256
+ privilegesList.push({ title: 'Admins', order: 0, sectionName: 'admins', sectionType: 'static' }, { title: 'Log', order: 2, sectionName: 'log', sectionType: 'static' });
215
257
  return privilegesList;
216
258
  };
217
259
  export const getAdminsList = async () => {
@@ -309,13 +351,14 @@ export const deleteSectionItem = async (session, sectionName, sectionItemId, rec
309
351
  name: sectionName,
310
352
  admin: {
311
353
  id: session.user.id,
354
+ requiredRole: 'D',
312
355
  },
313
356
  });
314
357
  const section = _s?.build();
315
358
  if (!section) {
316
359
  return {
317
360
  error: {
318
- message: 'Section not found or you do not have access to it',
361
+ message: 'Section not found or you do not have access to this operation',
319
362
  },
320
363
  };
321
364
  }
@@ -623,7 +666,7 @@ export const getCategorySectionChildren = async ({ session, id, sectionName, lev
623
666
  if (!section) {
624
667
  return {
625
668
  error: {
626
- message: 'Section not found or you do not have access to it',
669
+ message: 'Section not found or you do not have access to this operation',
627
670
  },
628
671
  };
629
672
  }
@@ -671,7 +714,7 @@ export const getCategorySection = async (session, sectionName) => {
671
714
  if (!section) {
672
715
  throw new TRPCError({
673
716
  code: 'NOT_FOUND',
674
- message: 'Section not found or you do not have access to it',
717
+ message: 'Section not found or you do not have access to this operation',
675
718
  });
676
719
  }
677
720
  const tableName = section.db.table;
@@ -729,7 +772,7 @@ export const getBrowsePage = async (session, sectionName, page = 1, q) => {
729
772
  if (!section) {
730
773
  return {
731
774
  error: {
732
- message: 'Section not found or you do not have access to it',
775
+ message: 'Section not found or you do not have access to this operation',
733
776
  },
734
777
  };
735
778
  }
@@ -795,6 +838,9 @@ export const getSidebar = async (session) => {
795
838
  const { simple, has_items, category, fixed } = await SectionFactory.getSectionsForAdmin({
796
839
  admin: { id: session.user.id },
797
840
  });
841
+ const pluginRoutes = await getPluginRoutes();
842
+ const privilegeSet = await getAdminPrivileges(session.user.id);
843
+ const allowedPluginRoutes = pluginRoutes.filter(({ pluginName }) => privilegeSet.has(pluginName));
798
844
  // Let's loop through the sections and add path, icon and title to each section item
799
845
  const simpleSectionItems = simple.map((section) => {
800
846
  return {
@@ -817,21 +863,28 @@ export const getSidebar = async (session) => {
817
863
  icon: section.icon,
818
864
  };
819
865
  });
866
+ const pluginSections = allowedPluginRoutes.map((route) => ({
867
+ title: route.title,
868
+ path: route.path,
869
+ icon: route.icon ?? '',
870
+ }));
871
+ const fixedSections = [
872
+ /**
873
+ * Add the default dashboard section
874
+ */
875
+ {
876
+ title: 'Dashboard',
877
+ path: '/dashboard',
878
+ icon: 'home',
879
+ },
880
+ /**
881
+ * Add the plugin sections
882
+ */
883
+ ...pluginSections,
884
+ ...fixed.map((section) => ({ title: section, path: `/${section}`, icon: '' })),
885
+ ];
820
886
  return {
821
- fixed_sections: [
822
- {
823
- title: 'Dashboard',
824
- path: '/dashboard',
825
- icon: 'home',
826
- },
827
- ...fixed.map((section) => {
828
- return {
829
- title: section,
830
- path: `/${section}`,
831
- icon: 'home',
832
- };
833
- }),
834
- ],
887
+ fixed_sections: fixedSections,
835
888
  cat_sections: categorySectionsItems,
836
889
  has_items_sections: hasItemsSectionItems,
837
890
  simple_sections: simpleSectionItems,