nextjs-cms 0.9.30 → 0.9.31
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/LICENSE +21 -21
- package/README.md +279 -279
- package/dist/api/actions/pages.d.ts +3 -3
- package/dist/api/client.d.ts +30 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +82 -0
- package/dist/api/index.d.ts +1 -974
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +0 -13
- package/dist/api/lib/serverActions.d.ts +13 -49
- package/dist/api/lib/serverActions.d.ts.map +1 -1
- package/dist/api/lib/serverActions.js +103 -31
- package/dist/api/root.d.ts +18 -1916
- package/dist/api/root.d.ts.map +1 -1
- package/dist/api/root.js +18 -83
- package/dist/api/routers/config.d.ts.map +1 -1
- package/dist/api/routers/gallery.d.ts +1 -0
- package/dist/api/routers/gallery.d.ts.map +1 -1
- package/dist/api/routers/gallery.js +36 -8
- package/dist/api/routers/hasItemsSection.d.ts +5 -30
- package/dist/api/routers/hasItemsSection.d.ts.map +1 -1
- package/dist/api/routers/navigation.d.ts +3 -3
- package/dist/api/routers/simpleSection.d.ts +3 -15
- package/dist/api/routers/simpleSection.d.ts.map +1 -1
- package/dist/api/server.d.ts +2748 -0
- package/dist/api/server.d.ts.map +1 -0
- package/dist/api/server.js +100 -0
- package/dist/api/trpc/error-logging.d.ts +14 -0
- package/dist/api/trpc/error-logging.d.ts.map +1 -0
- package/dist/api/trpc/error-logging.js +75 -0
- package/dist/api/trpc/root.d.ts +3 -3
- package/dist/api/trpc/root.d.ts.map +1 -1
- package/dist/api/trpc/routers/config.d.ts.map +1 -1
- package/dist/api/trpc/routers/hasItemsSection.d.ts.map +1 -1
- package/dist/api/trpc/routers/navigation.d.ts +3 -3
- package/dist/api/trpc/routers/simpleSection.d.ts.map +1 -1
- package/dist/api/trpc/server.d.ts +9 -9
- package/dist/api/trpc/server.d.ts.map +1 -1
- package/dist/api/utils/async-caller-proxy.d.ts +2 -0
- package/dist/api/utils/async-caller-proxy.d.ts.map +1 -0
- package/dist/api/utils/async-caller-proxy.js +36 -0
- package/dist/api/utils/lazy-caller-proxy.d.ts +2 -0
- package/dist/api/utils/lazy-caller-proxy.d.ts.map +1 -0
- package/dist/api/utils/lazy-caller-proxy.js +36 -0
- package/dist/api/utils/router-types.d.ts +7 -0
- package/dist/api/utils/router-types.d.ts.map +1 -0
- package/dist/api/utils/router-types.js +0 -0
- package/dist/auth/trpc.d.ts +1 -1
- package/dist/auth/trpc.d.ts.map +1 -1
- package/dist/auth/trpc.js +0 -1
- package/dist/cli/lib/db-config.js +10 -10
- package/dist/cli/lib/update-sections.d.ts.map +1 -1
- package/dist/cli/lib/update-sections.js +29 -24
- package/dist/core/db/table-checker/MysqlTable.js +10 -10
- package/dist/core/factories/section-factory-with-esbuild.js +9 -9
- package/dist/core/factories/section-factory-with-jiti.js +9 -9
- package/dist/core/sections/category.d.ts +42 -42
- package/dist/core/sections/hasItems.d.ts +42 -42
- package/dist/core/sections/section.d.ts +22 -22
- package/dist/core/sections/simple.d.ts +8 -8
- package/dist/plugins/loader.d.ts +3 -1
- package/dist/plugins/loader.d.ts.map +1 -1
- package/dist/plugins/loader.js +28 -6
- package/dist/plugins/manifest.d.ts +28 -0
- package/dist/plugins/manifest.d.ts.map +1 -0
- package/dist/plugins/manifest.js +83 -0
- package/dist/plugins/registry.d.ts +22 -0
- package/dist/plugins/registry.d.ts.map +1 -0
- package/dist/plugins/registry.js +25 -0
- package/dist/translations/client.d.ts +4 -4
- package/dist/utils/log.d.ts +18 -0
- package/dist/utils/log.d.ts.map +1 -0
- package/dist/utils/log.js +28 -0
- package/package.json +3 -3
- package/dist/core/fields/dateRange.d.ts +0 -115
- package/dist/core/fields/dateRange.d.ts.map +0 -1
- package/dist/core/fields/dateRange.js +0 -149
- package/dist/translations/locale-cookie.d.ts +0 -24
- package/dist/translations/locale-cookie.d.ts.map +0 -1
- package/dist/translations/locale-cookie.js +0 -44
- package/dist/translations/locale-utils.d.ts +0 -8
- package/dist/translations/locale-utils.d.ts.map +0 -1
- package/dist/translations/locale-utils.js +0 -11
- package/dist/translations/localization.d.ts +0 -40
- package/dist/translations/localization.d.ts.map +0 -1
- package/dist/translations/localization.js +0 -48
- package/dist/validators/dateRange.d.ts +0 -11
- package/dist/validators/dateRange.d.ts.map +0 -1
- package/dist/validators/dateRange.js +0 -16
package/dist/api/root.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../src/api/root.ts"],"names":[],"mappings":"
|
|
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
CHANGED
|
@@ -1,29 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { adminsRouter } from './routers/admins.js';
|
|
3
|
-
import { hasItemsSectionRouter } from './routers/hasItemsSection.js';
|
|
4
|
-
import { filesRouter } from './routers/files.js';
|
|
5
|
-
import { authRouter } from './routers/auth.js';
|
|
6
|
-
import { configRouter } from './routers/config.js';
|
|
7
|
-
import { navRouter } from './routers/navigation.js';
|
|
8
|
-
import { simpleSectionRouter } from './routers/simpleSection.js';
|
|
9
|
-
import { categorySectionRouter } from './routers/categorySection.js';
|
|
10
|
-
import { accountSettings } from './routers/accountSettings.js';
|
|
11
|
-
import { galleryRouter } from './routers/gallery.js';
|
|
12
|
-
import { logsRouter } from './routers/logs.js';
|
|
13
|
-
import { fieldsRouter } from './routers/fields.js';
|
|
14
|
-
import {
|
|
15
|
-
import { getPluginRoutes, loadPlugins } from '../plugins/loader.js';
|
|
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';
|
|
16
15
|
import { z } from 'zod';
|
|
17
16
|
import { getAdminPrivileges } from './lib/serverActions.js';
|
|
18
|
-
async function getPluginRouters() {
|
|
19
|
-
const loadedPlugins = await loadPlugins();
|
|
20
|
-
return loadedPlugins.reduce((acc, current) => {
|
|
21
|
-
if (current.plugin.router) {
|
|
22
|
-
acc[current.routerKey] = current.plugin.router;
|
|
23
|
-
}
|
|
24
|
-
return acc;
|
|
25
|
-
}, {});
|
|
26
|
-
}
|
|
27
17
|
const pluginsRouter = router({
|
|
28
18
|
checkRoute: privateProcedure
|
|
29
19
|
.input(z.object({
|
|
@@ -40,7 +30,7 @@ const pluginsRouter = router({
|
|
|
40
30
|
return plugin;
|
|
41
31
|
}),
|
|
42
32
|
});
|
|
43
|
-
const coreRouters = {
|
|
33
|
+
export const coreRouters = {
|
|
44
34
|
auth: authRouter,
|
|
45
35
|
admins: adminsRouter,
|
|
46
36
|
config: configRouter,
|
|
@@ -55,61 +45,6 @@ const coreRouters = {
|
|
|
55
45
|
logs: logsRouter,
|
|
56
46
|
plugins: pluginsRouter,
|
|
57
47
|
};
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
let appRouterConfigVersion = -1;
|
|
62
|
-
async function createAppRouterWithPlugins() {
|
|
63
|
-
const currentVersion = getConfigImportVersion();
|
|
64
|
-
if (appRouterConfigVersion !== currentVersion) {
|
|
65
|
-
_appRouter = null;
|
|
66
|
-
routerInitPromise = null;
|
|
67
|
-
}
|
|
68
|
-
if (_appRouter) {
|
|
69
|
-
return _appRouter;
|
|
70
|
-
}
|
|
71
|
-
if (routerInitPromise) {
|
|
72
|
-
return routerInitPromise;
|
|
73
|
-
}
|
|
74
|
-
routerInitPromise = (async () => {
|
|
75
|
-
const pluginRouters = await getPluginRouters();
|
|
76
|
-
const safePluginRouters = Object.entries(pluginRouters).reduce((acc, [key, pluginRouter]) => {
|
|
77
|
-
if (key in coreRouters) {
|
|
78
|
-
console.error(`[plugins] Router key "${key}" conflicts with a core router. Skipping.`);
|
|
79
|
-
return acc;
|
|
80
|
-
}
|
|
81
|
-
acc[key] = pluginRouter;
|
|
82
|
-
return acc;
|
|
83
|
-
}, {});
|
|
84
|
-
const routerInstance = router({
|
|
85
|
-
...coreRouters,
|
|
86
|
-
...safePluginRouters,
|
|
87
|
-
});
|
|
88
|
-
_appRouter = routerInstance;
|
|
89
|
-
appRouterConfigVersion = currentVersion;
|
|
90
|
-
return routerInstance;
|
|
91
|
-
})();
|
|
92
|
-
return routerInitPromise;
|
|
93
|
-
}
|
|
94
|
-
// Create router synchronously with core routes only
|
|
95
|
-
// This allows the module to load without top-level await
|
|
96
|
-
// NOTE: Plugin routes will not be available until plugins are loaded
|
|
97
|
-
// For now, we export the core router. Plugin routes should be added
|
|
98
|
-
// via the plugins router's list/routes procedures
|
|
99
|
-
export const appRouter = router(coreRouters);
|
|
100
|
-
// Start loading plugins in the background (non-blocking)
|
|
101
|
-
// Plugin routes can be accessed through the plugins.list/routes procedures
|
|
102
|
-
createAppRouterWithPlugins().catch((error) => {
|
|
103
|
-
console.error('Failed to load plugins for router:', error);
|
|
104
|
-
});
|
|
105
|
-
// Export a function to get the full router with plugins
|
|
106
|
-
// This should be used in server contexts where async is allowed
|
|
107
|
-
export async function getAppRouter() {
|
|
108
|
-
return createAppRouterWithPlugins();
|
|
109
|
-
}
|
|
110
|
-
export async function createCallerWithPlugins(ctx) {
|
|
111
|
-
const routerWithPlugins = await getAppRouter();
|
|
112
|
-
return routerWithPlugins.createCaller(ctx);
|
|
113
|
-
}
|
|
114
|
-
// createCaller factory
|
|
115
|
-
export const createCaller = createCallerFactory(appRouter);
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/api/routers/config.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/api/routers/config.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAaozZ,CAAC;;;;;;GAD50Z,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gallery.d.ts","sourceRoot":"","sources":["../../../src/api/routers/gallery.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gallery.d.ts","sourceRoot":"","sources":["../../../src/api/routers/gallery.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAUxB,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0FxB,CAAA"}
|
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
import { privateProcedure, router } from '../trpc.js';
|
|
2
|
-
import * as z from 'zod';
|
|
3
1
|
import fs from 'fs';
|
|
4
2
|
import path from 'path';
|
|
5
|
-
import { SectionFactory } from '../../core/factories/index.js';
|
|
6
3
|
import { TRPCError } from '@trpc/server';
|
|
7
|
-
import getString from '../../translations/index.js';
|
|
8
|
-
import { db } from '../../db/client.js';
|
|
9
4
|
import { sql } from 'drizzle-orm';
|
|
10
|
-
import
|
|
5
|
+
import * as z from 'zod';
|
|
11
6
|
import { getCMSConfig } from '../../core/config/index.js';
|
|
7
|
+
import { MysqlTableChecker } from '../../core/db/index.js';
|
|
8
|
+
import { SectionFactory } from '../../core/factories/index.js';
|
|
9
|
+
import { resolveLocale } from '../../core/localization/index.js';
|
|
10
|
+
import { db } from '../../db/client.js';
|
|
11
|
+
import getString from '../../translations/index.js';
|
|
12
|
+
import { privateProcedure, router } from '../trpc.js';
|
|
12
13
|
export const galleryRouter = router({
|
|
13
14
|
deletePhoto: privateProcedure
|
|
14
15
|
.input(z.object({
|
|
15
16
|
sectionName: z.string(),
|
|
16
17
|
photoName: z.string(),
|
|
17
18
|
referenceId: z.string(),
|
|
19
|
+
locale: z.string().optional(),
|
|
18
20
|
}))
|
|
19
21
|
.mutation(async ({ ctx, input }) => {
|
|
20
|
-
const
|
|
22
|
+
const cmsConfig = await getCMSConfig();
|
|
23
|
+
const uploadsFolder = cmsConfig.media.upload.path;
|
|
21
24
|
/**
|
|
22
25
|
* Get the section information
|
|
23
26
|
*/
|
|
@@ -43,7 +46,32 @@ export const galleryRouter = router({
|
|
|
43
46
|
const columns = await MysqlTableChecker.getColumns(gallery.db.tableName);
|
|
44
47
|
if (columns.includes(gallery.db.photoNameField) &&
|
|
45
48
|
columns.includes(gallery.db.referenceIdentifierField)) {
|
|
46
|
-
|
|
49
|
+
const galleryIsLocalized = gallery.localized === true && cmsConfig.localization?.enabled === true;
|
|
50
|
+
if (galleryIsLocalized) {
|
|
51
|
+
const localeResult = resolveLocale({
|
|
52
|
+
localization: cmsConfig.localization,
|
|
53
|
+
locale: input.locale,
|
|
54
|
+
});
|
|
55
|
+
if (!input.locale || !localeResult.resolvedLocale) {
|
|
56
|
+
throw new TRPCError({
|
|
57
|
+
code: 'BAD_REQUEST',
|
|
58
|
+
message: getString('invalidLocale', ctx.session.user.language, {
|
|
59
|
+
locale: input.locale ?? '',
|
|
60
|
+
locales: localeResult.availableLocales.map((l) => l.code).join(', '),
|
|
61
|
+
}),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (!columns.includes('locale')) {
|
|
65
|
+
throw new TRPCError({
|
|
66
|
+
code: 'BAD_REQUEST',
|
|
67
|
+
message: getString('galleryTableNotSetUp', ctx.session.user.language),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
await db.execute(sql `DELETE FROM ${sql.raw(gallery.db.tableName)} WHERE ${sql.raw(gallery.db.photoNameField)} = ${input.photoName} AND ${sql.raw(gallery.db.referenceIdentifierField)} = ${input.referenceId} AND \`locale\` = ${localeResult.resolvedLocale.code}`);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
await db.execute(sql `DELETE FROM ${sql.raw(gallery.db.tableName)} WHERE ${sql.raw(gallery.db.photoNameField)} = ${input.photoName} AND ${sql.raw(gallery.db.referenceIdentifierField)} = ${input.referenceId}`);
|
|
74
|
+
}
|
|
47
75
|
}
|
|
48
76
|
}
|
|
49
77
|
/**
|
|
@@ -72,21 +72,7 @@ export declare const hasItemsSectionRouter: import("@trpc/server").TRPCBuiltRout
|
|
|
72
72
|
singular: string;
|
|
73
73
|
plural: string;
|
|
74
74
|
};
|
|
75
|
-
gallery:
|
|
76
|
-
db: {
|
|
77
|
-
tableName: string;
|
|
78
|
-
referenceIdentifierField: string;
|
|
79
|
-
photoNameField: string;
|
|
80
|
-
metaField: string;
|
|
81
|
-
};
|
|
82
|
-
watermark?: boolean;
|
|
83
|
-
thumbnail?: {
|
|
84
|
-
width: number;
|
|
85
|
-
height: number;
|
|
86
|
-
fit: "cover" | "contain";
|
|
87
|
-
quality: number;
|
|
88
|
-
};
|
|
89
|
-
} | undefined;
|
|
75
|
+
gallery: import("../../index.js").SectionGallery | undefined;
|
|
90
76
|
variants: import("../../core/types/index.js").Variant[] | undefined;
|
|
91
77
|
configFile: string;
|
|
92
78
|
};
|
|
@@ -129,21 +115,7 @@ export declare const hasItemsSectionRouter: import("@trpc/server").TRPCBuiltRout
|
|
|
129
115
|
singular: string;
|
|
130
116
|
plural: string;
|
|
131
117
|
};
|
|
132
|
-
gallery:
|
|
133
|
-
db: {
|
|
134
|
-
tableName: string;
|
|
135
|
-
referenceIdentifierField: string;
|
|
136
|
-
photoNameField: string;
|
|
137
|
-
metaField: string;
|
|
138
|
-
};
|
|
139
|
-
watermark?: boolean;
|
|
140
|
-
thumbnail?: {
|
|
141
|
-
width: number;
|
|
142
|
-
height: number;
|
|
143
|
-
fit: "cover" | "contain";
|
|
144
|
-
quality: number;
|
|
145
|
-
};
|
|
146
|
-
} | undefined;
|
|
118
|
+
gallery: import("../../index.js").SectionGallery | undefined;
|
|
147
119
|
variants: import("../../core/types/index.js").Variant[] | undefined;
|
|
148
120
|
configFile: string;
|
|
149
121
|
};
|
|
@@ -167,6 +139,7 @@ export declare const hasItemsSectionRouter: import("@trpc/server").TRPCBuiltRout
|
|
|
167
139
|
referenceId: string;
|
|
168
140
|
photo: string;
|
|
169
141
|
meta: any;
|
|
142
|
+
locale?: string;
|
|
170
143
|
}[];
|
|
171
144
|
localization: {
|
|
172
145
|
defaultLocale: {
|
|
@@ -185,6 +158,8 @@ export declare const hasItemsSectionRouter: import("@trpc/server").TRPCBuiltRout
|
|
|
185
158
|
label: string;
|
|
186
159
|
rtl?: boolean;
|
|
187
160
|
}[];
|
|
161
|
+
localeSwitcherEnabled: boolean;
|
|
162
|
+
developerNoteEnabled: boolean;
|
|
188
163
|
} | null;
|
|
189
164
|
error?: undefined;
|
|
190
165
|
} | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasItemsSection.d.ts","sourceRoot":"","sources":["../../../src/api/routers/hasItemsSection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAcxB,eAAO,MAAM,qBAAqB
|
|
1
|
+
{"version":3,"file":"hasItemsSection.d.ts","sourceRoot":"","sources":["../../../src/api/routers/hasItemsSection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAcxB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAwG+53C,CAAC;;;;;uBAAyE,CAAC;;;;;;uBAA8G,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GADzn4C,CAAA"}
|