@sonicjs-cms/core 2.0.7 → 2.0.9
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/README.md +1 -1
- package/dist/{chunk-OOV64BK4.cjs → chunk-4I25AGUR.cjs} +349 -267
- package/dist/chunk-4I25AGUR.cjs.map +1 -0
- package/dist/chunk-6FR25MPC.js.map +1 -1
- package/dist/{chunk-JB2NUJJ5.js → chunk-ABYMIXRN.js} +193 -111
- package/dist/chunk-ABYMIXRN.js.map +1 -0
- package/dist/{chunk-4MBTSUI6.js → chunk-COBUPOMD.js} +22 -6
- package/dist/chunk-COBUPOMD.js.map +1 -0
- package/dist/chunk-DOR2IU73.cjs.map +1 -1
- package/dist/{chunk-3R7EQNGO.cjs → chunk-DYYAXDXI.cjs} +6 -6
- package/dist/chunk-DYYAXDXI.cjs.map +1 -0
- package/dist/{chunk-7XEESVSX.cjs → chunk-EYMHWJTW.cjs} +2 -2
- package/dist/chunk-EYMHWJTW.cjs.map +1 -0
- package/dist/{chunk-HJZOA2O5.cjs → chunk-F5ESJXI2.cjs} +25 -3
- package/dist/chunk-F5ESJXI2.cjs.map +1 -0
- package/dist/chunk-FICTAGD4.js.map +1 -1
- package/dist/{chunk-EAELJXRV.js → chunk-HKEK7UNV.js} +25 -3
- package/dist/chunk-HKEK7UNV.js.map +1 -0
- package/dist/{chunk-KHNSPJ6X.cjs → chunk-MABBKINE.cjs} +5 -5
- package/dist/{chunk-KHNSPJ6X.cjs.map → chunk-MABBKINE.cjs.map} +1 -1
- package/dist/{chunk-YGVWY6KO.cjs → chunk-NBDPIRQS.cjs} +22 -5
- package/dist/chunk-NBDPIRQS.cjs.map +1 -0
- package/dist/{chunk-O7LMFJMZ.js → chunk-OKPDQO2Y.js} +3 -3
- package/dist/chunk-OKPDQO2Y.js.map +1 -0
- package/dist/{chunk-LS5CMDNL.js → chunk-OPGDMS7L.js} +3 -3
- package/dist/{chunk-LS5CMDNL.js.map → chunk-OPGDMS7L.js.map} +1 -1
- package/dist/chunk-RCQ2HIQD.cjs.map +1 -1
- package/dist/{chunk-RSFXIU6A.cjs → chunk-TMIRVVQ7.cjs} +4 -4
- package/dist/chunk-TMIRVVQ7.cjs.map +1 -0
- package/dist/{chunk-YHLLVUJC.js → chunk-VEC5MLT3.js} +2 -2
- package/dist/chunk-VEC5MLT3.js.map +1 -0
- package/dist/{chunk-YURRY22X.js → chunk-WRRLB6KG.js} +4 -4
- package/dist/chunk-WRRLB6KG.js.map +1 -0
- package/dist/index.cjs +108 -104
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/dist/middleware.cjs +23 -23
- package/dist/middleware.js +2 -2
- package/dist/plugins.cjs +7 -7
- package/dist/plugins.js +1 -1
- package/dist/routes.cjs +25 -25
- package/dist/routes.js +5 -5
- package/dist/services.cjs +18 -14
- package/dist/services.js +1 -1
- package/dist/templates.cjs +18 -18
- package/dist/templates.js +2 -2
- package/dist/utils.cjs +11 -11
- package/dist/utils.js +1 -1
- package/migrations/019_remove_blog_posts_collection.sql +15 -0
- package/package.json +2 -2
- package/dist/chunk-3R7EQNGO.cjs.map +0 -1
- package/dist/chunk-4MBTSUI6.js.map +0 -1
- package/dist/chunk-7XEESVSX.cjs.map +0 -1
- package/dist/chunk-EAELJXRV.js.map +0 -1
- package/dist/chunk-HJZOA2O5.cjs.map +0 -1
- package/dist/chunk-JB2NUJJ5.js.map +0 -1
- package/dist/chunk-O7LMFJMZ.js.map +0 -1
- package/dist/chunk-OOV64BK4.cjs.map +0 -1
- package/dist/chunk-RSFXIU6A.cjs.map +0 -1
- package/dist/chunk-YGVWY6KO.cjs.map +0 -1
- package/dist/chunk-YHLLVUJC.js.map +0 -1
- package/dist/chunk-YURRY22X.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkDOR2IU73_cjs = require('./chunk-DOR2IU73.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
4
|
+
var chunkDYYAXDXI_cjs = require('./chunk-DYYAXDXI.cjs');
|
|
5
|
+
var chunkNBDPIRQS_cjs = require('./chunk-NBDPIRQS.cjs');
|
|
6
|
+
var chunkEYMHWJTW_cjs = require('./chunk-EYMHWJTW.cjs');
|
|
7
|
+
var chunkTMIRVVQ7_cjs = require('./chunk-TMIRVVQ7.cjs');
|
|
8
8
|
var chunkRCQ2HIQD_cjs = require('./chunk-RCQ2HIQD.cjs');
|
|
9
9
|
var hono = require('hono');
|
|
10
10
|
var cors = require('hono/cors');
|
|
@@ -43,7 +43,7 @@ apiContentCrudRoutes.get("/:id", async (c) => {
|
|
|
43
43
|
}, 500);
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
|
-
apiContentCrudRoutes.post("/",
|
|
46
|
+
apiContentCrudRoutes.post("/", chunkDYYAXDXI_cjs.requireAuth(), async (c) => {
|
|
47
47
|
try {
|
|
48
48
|
const db = c.env.DB;
|
|
49
49
|
const user = c.get("user");
|
|
@@ -109,7 +109,7 @@ apiContentCrudRoutes.post("/", chunk3R7EQNGO_cjs.requireAuth(), async (c) => {
|
|
|
109
109
|
}, 500);
|
|
110
110
|
}
|
|
111
111
|
});
|
|
112
|
-
apiContentCrudRoutes.put("/:id",
|
|
112
|
+
apiContentCrudRoutes.put("/:id", chunkDYYAXDXI_cjs.requireAuth(), async (c) => {
|
|
113
113
|
try {
|
|
114
114
|
const id = c.req.param("id");
|
|
115
115
|
const db = c.env.DB;
|
|
@@ -173,7 +173,7 @@ apiContentCrudRoutes.put("/:id", chunk3R7EQNGO_cjs.requireAuth(), async (c) => {
|
|
|
173
173
|
}, 500);
|
|
174
174
|
}
|
|
175
175
|
});
|
|
176
|
-
apiContentCrudRoutes.delete("/:id",
|
|
176
|
+
apiContentCrudRoutes.delete("/:id", chunkDYYAXDXI_cjs.requireAuth(), async (c) => {
|
|
177
177
|
try {
|
|
178
178
|
const id = c.req.param("id");
|
|
179
179
|
const db = c.env.DB;
|
|
@@ -209,7 +209,7 @@ apiRoutes.use("*", async (c, next) => {
|
|
|
209
209
|
c.header("X-Response-Time", `${totalTime}ms`);
|
|
210
210
|
});
|
|
211
211
|
apiRoutes.use("*", async (c, next) => {
|
|
212
|
-
const cacheEnabled = await
|
|
212
|
+
const cacheEnabled = await chunkDYYAXDXI_cjs.isPluginActive(c.env.DB, "core-cache");
|
|
213
213
|
c.set("cacheEnabled", cacheEnabled);
|
|
214
214
|
await next();
|
|
215
215
|
});
|
|
@@ -334,12 +334,12 @@ apiRoutes.get("/content", async (c) => {
|
|
|
334
334
|
});
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
|
-
const filter =
|
|
337
|
+
const filter = chunkTMIRVVQ7_cjs.QueryFilterBuilder.parseFromQuery(queryParams);
|
|
338
338
|
if (!filter.limit) {
|
|
339
339
|
filter.limit = 50;
|
|
340
340
|
}
|
|
341
341
|
filter.limit = Math.min(filter.limit, 1e3);
|
|
342
|
-
const builder = new
|
|
342
|
+
const builder = new chunkTMIRVVQ7_cjs.QueryFilterBuilder();
|
|
343
343
|
const queryResult = builder.build("content", filter);
|
|
344
344
|
if (queryResult.errors.length > 0) {
|
|
345
345
|
return c.json({
|
|
@@ -426,7 +426,7 @@ apiRoutes.get("/collections/:collection/content", async (c) => {
|
|
|
426
426
|
if (!collectionResult) {
|
|
427
427
|
return c.json({ error: "Collection not found" }, 404);
|
|
428
428
|
}
|
|
429
|
-
const filter =
|
|
429
|
+
const filter = chunkTMIRVVQ7_cjs.QueryFilterBuilder.parseFromQuery(queryParams);
|
|
430
430
|
if (!filter.where) {
|
|
431
431
|
filter.where = { and: [] };
|
|
432
432
|
}
|
|
@@ -442,7 +442,7 @@ apiRoutes.get("/collections/:collection/content", async (c) => {
|
|
|
442
442
|
filter.limit = 50;
|
|
443
443
|
}
|
|
444
444
|
filter.limit = Math.min(filter.limit, 1e3);
|
|
445
|
-
const builder = new
|
|
445
|
+
const builder = new chunkTMIRVVQ7_cjs.QueryFilterBuilder();
|
|
446
446
|
const queryResult = builder.build("content", filter);
|
|
447
447
|
if (queryResult.errors.length > 0) {
|
|
448
448
|
return c.json({
|
|
@@ -567,7 +567,7 @@ var fileValidationSchema = zod.z.object({
|
|
|
567
567
|
// 50MB max
|
|
568
568
|
});
|
|
569
569
|
var apiMediaRoutes = new hono.Hono();
|
|
570
|
-
apiMediaRoutes.use("*",
|
|
570
|
+
apiMediaRoutes.use("*", chunkDYYAXDXI_cjs.requireAuth());
|
|
571
571
|
apiMediaRoutes.post("/upload", async (c) => {
|
|
572
572
|
try {
|
|
573
573
|
const user = c.get("user");
|
|
@@ -1086,10 +1086,10 @@ apiMediaRoutes.patch("/:id", async (c) => {
|
|
|
1086
1086
|
const allowedFields = ["alt", "caption", "tags", "folder"];
|
|
1087
1087
|
const updates = [];
|
|
1088
1088
|
const values = [];
|
|
1089
|
-
for (const [key,
|
|
1089
|
+
for (const [key, value2] of Object.entries(body)) {
|
|
1090
1090
|
if (allowedFields.includes(key)) {
|
|
1091
1091
|
updates.push(`${key} = ?`);
|
|
1092
|
-
values.push(key === "tags" ? JSON.stringify(
|
|
1092
|
+
values.push(key === "tags" ? JSON.stringify(value2) : value2);
|
|
1093
1093
|
}
|
|
1094
1094
|
}
|
|
1095
1095
|
if (updates.length === 0) {
|
|
@@ -1311,8 +1311,8 @@ apiSystemRoutes.get("/env", (c) => {
|
|
|
1311
1311
|
});
|
|
1312
1312
|
var api_system_default = apiSystemRoutes;
|
|
1313
1313
|
var adminApiRoutes = new hono.Hono();
|
|
1314
|
-
adminApiRoutes.use("*",
|
|
1315
|
-
adminApiRoutes.use("*",
|
|
1314
|
+
adminApiRoutes.use("*", chunkDYYAXDXI_cjs.requireAuth());
|
|
1315
|
+
adminApiRoutes.use("*", chunkDYYAXDXI_cjs.requireRole(["admin", "editor"]));
|
|
1316
1316
|
adminApiRoutes.get("/stats", async (c) => {
|
|
1317
1317
|
try {
|
|
1318
1318
|
const db = c.env.DB;
|
|
@@ -1570,7 +1570,7 @@ adminApiRoutes.post("/collections", async (c) => {
|
|
|
1570
1570
|
}
|
|
1571
1571
|
const validatedData = validation.data;
|
|
1572
1572
|
const db = c.env.DB;
|
|
1573
|
-
const
|
|
1573
|
+
const ____user = c.get("user");
|
|
1574
1574
|
const displayName = validatedData.displayName || validatedData.display_name || "";
|
|
1575
1575
|
const existingStmt = db.prepare("SELECT id FROM collections WHERE name = ?");
|
|
1576
1576
|
const existing = await existingStmt.bind(validatedData.name).first();
|
|
@@ -1778,8 +1778,8 @@ function renderLoginPage(data, demoLoginActive = false) {
|
|
|
1778
1778
|
<div class="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
|
|
1779
1779
|
<div class="bg-zinc-900 shadow-sm ring-1 ring-white/10 rounded-xl px-6 py-8 sm:px-10">
|
|
1780
1780
|
<!-- Alerts -->
|
|
1781
|
-
${data.error ? `<div class="mb-6">${
|
|
1782
|
-
${data.message ? `<div class="mb-6">${
|
|
1781
|
+
${data.error ? `<div class="mb-6">${chunkEYMHWJTW_cjs.renderAlert({ type: "error", message: data.error })}</div>` : ""}
|
|
1782
|
+
${data.message ? `<div class="mb-6">${chunkEYMHWJTW_cjs.renderAlert({ type: "success", message: data.message })}</div>` : ""}
|
|
1783
1783
|
|
|
1784
1784
|
<!-- Form Response (HTMX target) -->
|
|
1785
1785
|
<div id="form-response" class="mb-6"></div>
|
|
@@ -1943,7 +1943,7 @@ function renderRegisterPage(data) {
|
|
|
1943
1943
|
<div class="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
|
|
1944
1944
|
<div class="bg-zinc-900 shadow-sm ring-1 ring-white/10 rounded-xl px-6 py-8 sm:px-10">
|
|
1945
1945
|
<!-- Alerts -->
|
|
1946
|
-
${data.error ? `<div class="mb-6">${
|
|
1946
|
+
${data.error ? `<div class="mb-6">${chunkEYMHWJTW_cjs.renderAlert({ type: "error", message: data.error })}</div>` : ""}
|
|
1947
1947
|
|
|
1948
1948
|
<!-- Form -->
|
|
1949
1949
|
<form
|
|
@@ -2142,7 +2142,7 @@ authRoutes.post(
|
|
|
2142
2142
|
if (existingUser) {
|
|
2143
2143
|
return c.json({ error: "User with this email or username already exists" }, 400);
|
|
2144
2144
|
}
|
|
2145
|
-
const passwordHash = await
|
|
2145
|
+
const passwordHash = await chunkDYYAXDXI_cjs.AuthManager.hashPassword(password);
|
|
2146
2146
|
const userId = crypto.randomUUID();
|
|
2147
2147
|
const now = /* @__PURE__ */ new Date();
|
|
2148
2148
|
await db.prepare(`
|
|
@@ -2162,7 +2162,7 @@ authRoutes.post(
|
|
|
2162
2162
|
now.getTime(),
|
|
2163
2163
|
now.getTime()
|
|
2164
2164
|
).run();
|
|
2165
|
-
const token = await
|
|
2165
|
+
const token = await chunkDYYAXDXI_cjs.AuthManager.generateToken(userId, normalizedEmail, "viewer");
|
|
2166
2166
|
cookie.setCookie(c, "auth_token", token, {
|
|
2167
2167
|
httpOnly: true,
|
|
2168
2168
|
secure: true,
|
|
@@ -2209,11 +2209,11 @@ authRoutes.post("/login", async (c) => {
|
|
|
2209
2209
|
if (!user) {
|
|
2210
2210
|
return c.json({ error: "Invalid email or password" }, 401);
|
|
2211
2211
|
}
|
|
2212
|
-
const isValidPassword = await
|
|
2212
|
+
const isValidPassword = await chunkDYYAXDXI_cjs.AuthManager.verifyPassword(password, user.password_hash);
|
|
2213
2213
|
if (!isValidPassword) {
|
|
2214
2214
|
return c.json({ error: "Invalid email or password" }, 401);
|
|
2215
2215
|
}
|
|
2216
|
-
const token = await
|
|
2216
|
+
const token = await chunkDYYAXDXI_cjs.AuthManager.generateToken(user.id, user.email, user.role);
|
|
2217
2217
|
cookie.setCookie(c, "auth_token", token, {
|
|
2218
2218
|
httpOnly: true,
|
|
2219
2219
|
secure: true,
|
|
@@ -2262,7 +2262,7 @@ authRoutes.get("/logout", (c) => {
|
|
|
2262
2262
|
});
|
|
2263
2263
|
return c.redirect("/auth/login?message=You have been logged out successfully");
|
|
2264
2264
|
});
|
|
2265
|
-
authRoutes.get("/me",
|
|
2265
|
+
authRoutes.get("/me", chunkDYYAXDXI_cjs.requireAuth(), async (c) => {
|
|
2266
2266
|
try {
|
|
2267
2267
|
const user = c.get("user");
|
|
2268
2268
|
if (!user) {
|
|
@@ -2279,13 +2279,13 @@ authRoutes.get("/me", chunk3R7EQNGO_cjs.requireAuth(), async (c) => {
|
|
|
2279
2279
|
return c.json({ error: "Failed to get user" }, 500);
|
|
2280
2280
|
}
|
|
2281
2281
|
});
|
|
2282
|
-
authRoutes.post("/refresh",
|
|
2282
|
+
authRoutes.post("/refresh", chunkDYYAXDXI_cjs.requireAuth(), async (c) => {
|
|
2283
2283
|
try {
|
|
2284
2284
|
const user = c.get("user");
|
|
2285
2285
|
if (!user) {
|
|
2286
2286
|
return c.json({ error: "Not authenticated" }, 401);
|
|
2287
2287
|
}
|
|
2288
|
-
const token = await
|
|
2288
|
+
const token = await chunkDYYAXDXI_cjs.AuthManager.generateToken(user.userId, user.email, user.role);
|
|
2289
2289
|
cookie.setCookie(c, "auth_token", token, {
|
|
2290
2290
|
httpOnly: true,
|
|
2291
2291
|
secure: true,
|
|
@@ -2322,7 +2322,6 @@ authRoutes.post("/register/form", async (c) => {
|
|
|
2322
2322
|
`);
|
|
2323
2323
|
}
|
|
2324
2324
|
const validatedData = validation.data;
|
|
2325
|
-
const email = validatedData.email;
|
|
2326
2325
|
const password = validatedData.password;
|
|
2327
2326
|
const username = validatedData.username || authValidationService.generateDefaultValue("username", validatedData);
|
|
2328
2327
|
const firstName = validatedData.firstName || authValidationService.generateDefaultValue("firstName", validatedData);
|
|
@@ -2335,7 +2334,7 @@ authRoutes.post("/register/form", async (c) => {
|
|
|
2335
2334
|
</div>
|
|
2336
2335
|
`);
|
|
2337
2336
|
}
|
|
2338
|
-
const passwordHash = await
|
|
2337
|
+
const passwordHash = await chunkDYYAXDXI_cjs.AuthManager.hashPassword(password);
|
|
2339
2338
|
const userId = crypto.randomUUID();
|
|
2340
2339
|
const now = /* @__PURE__ */ new Date();
|
|
2341
2340
|
await db.prepare(`
|
|
@@ -2355,7 +2354,7 @@ authRoutes.post("/register/form", async (c) => {
|
|
|
2355
2354
|
now.getTime(),
|
|
2356
2355
|
now.getTime()
|
|
2357
2356
|
).run();
|
|
2358
|
-
const token = await
|
|
2357
|
+
const token = await chunkDYYAXDXI_cjs.AuthManager.generateToken(userId, normalizedEmail, "admin");
|
|
2359
2358
|
cookie.setCookie(c, "auth_token", token, {
|
|
2360
2359
|
httpOnly: true,
|
|
2361
2360
|
secure: false,
|
|
@@ -2406,7 +2405,7 @@ authRoutes.post("/login/form", async (c) => {
|
|
|
2406
2405
|
</div>
|
|
2407
2406
|
`);
|
|
2408
2407
|
}
|
|
2409
|
-
const isValidPassword = await
|
|
2408
|
+
const isValidPassword = await chunkDYYAXDXI_cjs.AuthManager.verifyPassword(password, user.password_hash);
|
|
2410
2409
|
if (!isValidPassword) {
|
|
2411
2410
|
return c.html(html.html`
|
|
2412
2411
|
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded">
|
|
@@ -2414,7 +2413,7 @@ authRoutes.post("/login/form", async (c) => {
|
|
|
2414
2413
|
</div>
|
|
2415
2414
|
`);
|
|
2416
2415
|
}
|
|
2417
|
-
const token = await
|
|
2416
|
+
const token = await chunkDYYAXDXI_cjs.AuthManager.generateToken(user.id, user.email, user.role);
|
|
2418
2417
|
cookie.setCookie(c, "auth_token", token, {
|
|
2419
2418
|
httpOnly: true,
|
|
2420
2419
|
secure: false,
|
|
@@ -2483,7 +2482,7 @@ authRoutes.post("/seed-admin", async (c) => {
|
|
|
2483
2482
|
}
|
|
2484
2483
|
});
|
|
2485
2484
|
}
|
|
2486
|
-
const passwordHash = await
|
|
2485
|
+
const passwordHash = await chunkDYYAXDXI_cjs.AuthManager.hashPassword("admin123");
|
|
2487
2486
|
const userId = "admin-user-id";
|
|
2488
2487
|
const now = Date.now();
|
|
2489
2488
|
const adminEmail = "admin@sonicjs.com".toLowerCase();
|
|
@@ -2703,7 +2702,7 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
2703
2702
|
if (existingUsername) {
|
|
2704
2703
|
return c.json({ error: "Username is already taken" }, 400);
|
|
2705
2704
|
}
|
|
2706
|
-
const passwordHash = await
|
|
2705
|
+
const passwordHash = await chunkDYYAXDXI_cjs.AuthManager.hashPassword(password);
|
|
2707
2706
|
const updateStmt = db.prepare(`
|
|
2708
2707
|
UPDATE users SET
|
|
2709
2708
|
username = ?,
|
|
@@ -2722,7 +2721,7 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
2722
2721
|
Date.now(),
|
|
2723
2722
|
invitedUser.id
|
|
2724
2723
|
).run();
|
|
2725
|
-
const authToken = await
|
|
2724
|
+
const authToken = await chunkDYYAXDXI_cjs.AuthManager.generateToken(invitedUser.id, invitedUser.email, invitedUser.role);
|
|
2726
2725
|
cookie.setCookie(c, "auth_token", authToken, {
|
|
2727
2726
|
httpOnly: true,
|
|
2728
2727
|
secure: true,
|
|
@@ -2952,7 +2951,7 @@ authRoutes.post("/reset-password", async (c) => {
|
|
|
2952
2951
|
if (Date.now() > user.password_reset_expires) {
|
|
2953
2952
|
return c.json({ error: "Reset token has expired" }, 400);
|
|
2954
2953
|
}
|
|
2955
|
-
const newPasswordHash = await
|
|
2954
|
+
const newPasswordHash = await chunkDYYAXDXI_cjs.AuthManager.hashPassword(password);
|
|
2956
2955
|
try {
|
|
2957
2956
|
const historyStmt = db.prepare(`
|
|
2958
2957
|
INSERT INTO password_history (id, user_id, password_hash, created_at)
|
|
@@ -2989,11 +2988,11 @@ authRoutes.post("/reset-password", async (c) => {
|
|
|
2989
2988
|
var auth_default = authRoutes;
|
|
2990
2989
|
|
|
2991
2990
|
// src/templates/pages/admin-content-form.template.ts
|
|
2992
|
-
|
|
2991
|
+
chunkEYMHWJTW_cjs.init_admin_layout_catalyst_template();
|
|
2993
2992
|
|
|
2994
2993
|
// src/templates/components/dynamic-field.template.ts
|
|
2995
2994
|
function renderDynamicField(field, options = {}) {
|
|
2996
|
-
const { value = "", errors = [], disabled = false, className = "" } = options;
|
|
2995
|
+
const { value: value2 = "", errors = [], disabled = false, className = "" } = options;
|
|
2997
2996
|
const opts = field.field_options || {};
|
|
2998
2997
|
const required = field.is_required ? "required" : "";
|
|
2999
2998
|
const baseClasses = `w-full rounded-lg px-3 py-2 text-sm text-zinc-950 dark:text-white bg-white dark:bg-zinc-800 shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow ${className}`;
|
|
@@ -3050,7 +3049,7 @@ function renderDynamicField(field, options = {}) {
|
|
|
3050
3049
|
type="text"
|
|
3051
3050
|
id="${fieldId}"
|
|
3052
3051
|
name="${fieldName}"
|
|
3053
|
-
value="${escapeHtml2(
|
|
3052
|
+
value="${escapeHtml2(value2)}"
|
|
3054
3053
|
placeholder="${opts.placeholder || ""}"
|
|
3055
3054
|
maxlength="${opts.maxLength || ""}"
|
|
3056
3055
|
${opts.pattern ? `data-pattern="${opts.pattern}"` : ""}
|
|
@@ -3095,7 +3094,7 @@ function renderDynamicField(field, options = {}) {
|
|
|
3095
3094
|
class="${baseClasses} ${errorClasses} min-h-[${opts.height || 300}px]"
|
|
3096
3095
|
${required}
|
|
3097
3096
|
${disabled ? "disabled" : ""}
|
|
3098
|
-
>${escapeHtml2(
|
|
3097
|
+
>${escapeHtml2(value2)}</textarea>
|
|
3099
3098
|
<script>
|
|
3100
3099
|
// Initialize TinyMCE for this field
|
|
3101
3100
|
if (typeof tinymce !== 'undefined') {
|
|
@@ -3129,7 +3128,7 @@ function renderDynamicField(field, options = {}) {
|
|
|
3129
3128
|
type="number"
|
|
3130
3129
|
id="${fieldId}"
|
|
3131
3130
|
name="${fieldName}"
|
|
3132
|
-
value="${
|
|
3131
|
+
value="${value2}"
|
|
3133
3132
|
min="${opts.min || ""}"
|
|
3134
3133
|
max="${opts.max || ""}"
|
|
3135
3134
|
step="${opts.step || ""}"
|
|
@@ -3141,7 +3140,7 @@ function renderDynamicField(field, options = {}) {
|
|
|
3141
3140
|
`;
|
|
3142
3141
|
break;
|
|
3143
3142
|
case "boolean":
|
|
3144
|
-
const checked =
|
|
3143
|
+
const checked = value2 === true || value2 === "true" || value2 === "1" ? "checked" : "";
|
|
3145
3144
|
fieldHTML = `
|
|
3146
3145
|
<div class="flex items-center space-x-3">
|
|
3147
3146
|
<input
|
|
@@ -3166,7 +3165,7 @@ function renderDynamicField(field, options = {}) {
|
|
|
3166
3165
|
type="date"
|
|
3167
3166
|
id="${fieldId}"
|
|
3168
3167
|
name="${fieldName}"
|
|
3169
|
-
value="${
|
|
3168
|
+
value="${value2}"
|
|
3170
3169
|
min="${opts.min || ""}"
|
|
3171
3170
|
max="${opts.max || ""}"
|
|
3172
3171
|
class="${baseClasses} ${errorClasses}"
|
|
@@ -3178,7 +3177,7 @@ function renderDynamicField(field, options = {}) {
|
|
|
3178
3177
|
case "select":
|
|
3179
3178
|
const options2 = opts.options || [];
|
|
3180
3179
|
const multiple = opts.multiple ? "multiple" : "";
|
|
3181
|
-
const selectedValues = Array.isArray(
|
|
3180
|
+
const selectedValues = Array.isArray(value2) ? value2 : [value2];
|
|
3182
3181
|
fieldHTML = `
|
|
3183
3182
|
<select
|
|
3184
3183
|
id="${fieldId}"
|
|
@@ -3211,9 +3210,9 @@ function renderDynamicField(field, options = {}) {
|
|
|
3211
3210
|
case "media":
|
|
3212
3211
|
fieldHTML = `
|
|
3213
3212
|
<div class="media-field-container">
|
|
3214
|
-
<input type="hidden" id="${fieldId}" name="${fieldName}" value="${
|
|
3215
|
-
<div class="media-preview ${
|
|
3216
|
-
${
|
|
3213
|
+
<input type="hidden" id="${fieldId}" name="${fieldName}" value="${value2}">
|
|
3214
|
+
<div class="media-preview ${value2 ? "" : "hidden"}" id="${fieldId}-preview">
|
|
3215
|
+
${value2 ? `<img src="${value2}" alt="Selected media" class="w-32 h-32 object-cover rounded-lg border border-white/20">` : ""}
|
|
3217
3216
|
</div>
|
|
3218
3217
|
<div class="media-actions mt-2 space-x-2">
|
|
3219
3218
|
<button
|
|
@@ -3227,7 +3226,7 @@ function renderDynamicField(field, options = {}) {
|
|
|
3227
3226
|
</svg>
|
|
3228
3227
|
Select Media
|
|
3229
3228
|
</button>
|
|
3230
|
-
${
|
|
3229
|
+
${value2 ? `
|
|
3231
3230
|
<button
|
|
3232
3231
|
type="button"
|
|
3233
3232
|
onclick="clearMediaField('${fieldId}')"
|
|
@@ -3248,7 +3247,7 @@ function renderDynamicField(field, options = {}) {
|
|
|
3248
3247
|
type="text"
|
|
3249
3248
|
id="${fieldId}"
|
|
3250
3249
|
name="${fieldName}"
|
|
3251
|
-
value="${escapeHtml2(
|
|
3250
|
+
value="${escapeHtml2(value2)}"
|
|
3252
3251
|
class="${baseClasses} bg-zinc-100 dark:bg-zinc-800/50 cursor-not-allowed"
|
|
3253
3252
|
readonly
|
|
3254
3253
|
disabled
|
|
@@ -3258,7 +3257,7 @@ function renderDynamicField(field, options = {}) {
|
|
|
3258
3257
|
<path stroke-linecap="round" stroke-linejoin="round" d="M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"/>
|
|
3259
3258
|
</svg>
|
|
3260
3259
|
<div class="text-xs text-zinc-600 dark:text-zinc-400">
|
|
3261
|
-
${
|
|
3260
|
+
${value2 ? "This unique identifier was automatically generated and cannot be changed." : "A unique identifier (UUID) will be automatically generated when you save this content."}
|
|
3262
3261
|
</div>
|
|
3263
3262
|
</div>
|
|
3264
3263
|
</div>
|
|
@@ -3270,7 +3269,7 @@ function renderDynamicField(field, options = {}) {
|
|
|
3270
3269
|
type="text"
|
|
3271
3270
|
id="${fieldId}"
|
|
3272
3271
|
name="${fieldName}"
|
|
3273
|
-
value="${escapeHtml2(
|
|
3272
|
+
value="${escapeHtml2(value2)}"
|
|
3274
3273
|
class="${baseClasses} ${errorClasses}"
|
|
3275
3274
|
${required}
|
|
3276
3275
|
${disabled ? "disabled" : ""}
|
|
@@ -3393,8 +3392,8 @@ function renderContentFormPage(data) {
|
|
|
3393
3392
|
<!-- Form Content -->
|
|
3394
3393
|
<div class="px-6 py-6">
|
|
3395
3394
|
<div id="form-messages">
|
|
3396
|
-
${data.error ?
|
|
3397
|
-
${data.success ?
|
|
3395
|
+
${data.error ? chunkEYMHWJTW_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
|
|
3396
|
+
${data.success ? chunkEYMHWJTW_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
|
|
3398
3397
|
</div>
|
|
3399
3398
|
|
|
3400
3399
|
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
|
@@ -3629,7 +3628,7 @@ function renderContentFormPage(data) {
|
|
|
3629
3628
|
</div>
|
|
3630
3629
|
|
|
3631
3630
|
<!-- Confirmation Dialogs -->
|
|
3632
|
-
${
|
|
3631
|
+
${chunkEYMHWJTW_cjs.renderConfirmationDialog({
|
|
3633
3632
|
id: "duplicate-content-confirm",
|
|
3634
3633
|
title: "Duplicate Content",
|
|
3635
3634
|
message: "Create a copy of this content?",
|
|
@@ -3640,7 +3639,7 @@ function renderContentFormPage(data) {
|
|
|
3640
3639
|
onConfirm: "performDuplicateContent()"
|
|
3641
3640
|
})}
|
|
3642
3641
|
|
|
3643
|
-
${
|
|
3642
|
+
${chunkEYMHWJTW_cjs.renderConfirmationDialog({
|
|
3644
3643
|
id: "delete-content-confirm",
|
|
3645
3644
|
title: "Delete Content",
|
|
3646
3645
|
message: "Are you sure you want to delete this content? This action cannot be undone.",
|
|
@@ -3651,7 +3650,7 @@ function renderContentFormPage(data) {
|
|
|
3651
3650
|
onConfirm: `performDeleteContent('${data.id}')`
|
|
3652
3651
|
})}
|
|
3653
3652
|
|
|
3654
|
-
${
|
|
3653
|
+
${chunkEYMHWJTW_cjs.getConfirmationDialogScript()}
|
|
3655
3654
|
|
|
3656
3655
|
<!-- TinyMCE CDN -->
|
|
3657
3656
|
<script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script>
|
|
@@ -3939,11 +3938,11 @@ function renderContentFormPage(data) {
|
|
|
3939
3938
|
content: pageContent,
|
|
3940
3939
|
version: data.version
|
|
3941
3940
|
};
|
|
3942
|
-
return
|
|
3941
|
+
return chunkEYMHWJTW_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
3943
3942
|
}
|
|
3944
3943
|
|
|
3945
3944
|
// src/templates/pages/admin-content-list.template.ts
|
|
3946
|
-
|
|
3945
|
+
chunkEYMHWJTW_cjs.init_admin_layout_catalyst_template();
|
|
3947
3946
|
function renderContentListPage(data) {
|
|
3948
3947
|
const urlParams = new URLSearchParams();
|
|
3949
3948
|
if (data.modelName && data.modelName !== "all") urlParams.set("model", data.modelName);
|
|
@@ -3958,9 +3957,9 @@ function renderContentListPage(data) {
|
|
|
3958
3957
|
name: "model",
|
|
3959
3958
|
label: "Model",
|
|
3960
3959
|
options: [
|
|
3961
|
-
{
|
|
3960
|
+
{ __value: "all", label: "All Models", selected: data.modelName === "all" },
|
|
3962
3961
|
...data.models.map((model) => ({
|
|
3963
|
-
|
|
3962
|
+
__value: model.name,
|
|
3964
3963
|
label: model.displayName,
|
|
3965
3964
|
selected: data.modelName === model.name
|
|
3966
3965
|
}))
|
|
@@ -3970,13 +3969,13 @@ function renderContentListPage(data) {
|
|
|
3970
3969
|
name: "status",
|
|
3971
3970
|
label: "Status",
|
|
3972
3971
|
options: [
|
|
3973
|
-
{
|
|
3974
|
-
{
|
|
3975
|
-
{
|
|
3976
|
-
{
|
|
3977
|
-
{
|
|
3978
|
-
{
|
|
3979
|
-
{
|
|
3972
|
+
{ __value: "all", label: "All Status", selected: data.status === "all" },
|
|
3973
|
+
{ __value: "draft", label: "Draft", selected: data.status === "draft" },
|
|
3974
|
+
{ __value: "review", label: "Under Review", selected: data.status === "review" },
|
|
3975
|
+
{ __value: "scheduled", label: "Scheduled", selected: data.status === "scheduled" },
|
|
3976
|
+
{ __value: "published", label: "Published", selected: data.status === "published" },
|
|
3977
|
+
{ __value: "archived", label: "Archived", selected: data.status === "archived" },
|
|
3978
|
+
{ __value: "deleted", label: "Deleted", selected: data.status === "deleted" }
|
|
3980
3979
|
]
|
|
3981
3980
|
}
|
|
3982
3981
|
],
|
|
@@ -3988,9 +3987,9 @@ function renderContentListPage(data) {
|
|
|
3988
3987
|
}
|
|
3989
3988
|
],
|
|
3990
3989
|
bulkActions: [
|
|
3991
|
-
{ label: "Publish",
|
|
3992
|
-
{ label: "Unpublish",
|
|
3993
|
-
{ label: "Delete",
|
|
3990
|
+
{ label: "Publish", ___value: "publish", icon: "check-circle" },
|
|
3991
|
+
{ label: "Unpublish", ___value: "unpublish", icon: "x-circle" },
|
|
3992
|
+
{ label: "Delete", ___value: "delete", icon: "trash", className: "text-pink-600" }
|
|
3994
3993
|
]
|
|
3995
3994
|
};
|
|
3996
3995
|
const tableColumns = [
|
|
@@ -3999,7 +3998,7 @@ function renderContentListPage(data) {
|
|
|
3999
3998
|
label: "Title",
|
|
4000
3999
|
sortable: true,
|
|
4001
4000
|
sortType: "string",
|
|
4002
|
-
render: (
|
|
4001
|
+
render: (value2, row) => `
|
|
4003
4002
|
<div class="flex items-center">
|
|
4004
4003
|
<div>
|
|
4005
4004
|
<div class="text-sm font-medium text-zinc-950 dark:text-white">
|
|
@@ -4022,7 +4021,7 @@ function renderContentListPage(data) {
|
|
|
4022
4021
|
label: "Status",
|
|
4023
4022
|
sortable: true,
|
|
4024
4023
|
sortType: "string",
|
|
4025
|
-
render: (
|
|
4024
|
+
render: (value2) => value2
|
|
4026
4025
|
},
|
|
4027
4026
|
{
|
|
4028
4027
|
key: "authorName",
|
|
@@ -4043,7 +4042,7 @@ function renderContentListPage(data) {
|
|
|
4043
4042
|
label: "Actions",
|
|
4044
4043
|
sortable: false,
|
|
4045
4044
|
className: "text-sm font-medium",
|
|
4046
|
-
render: (
|
|
4045
|
+
render: (value2, row) => `
|
|
4047
4046
|
<div class="flex space-x-2">
|
|
4048
4047
|
<button
|
|
4049
4048
|
class="inline-flex items-center justify-center p-1.5 rounded-lg bg-cyan-50 dark:bg-cyan-500/10 text-cyan-700 dark:text-cyan-400 ring-1 ring-inset ring-cyan-600/20 dark:ring-cyan-500/20 hover:bg-cyan-100 dark:hover:bg-cyan-500/20 transition-colors"
|
|
@@ -4339,8 +4338,8 @@ function renderContentListPage(data) {
|
|
|
4339
4338
|
|
|
4340
4339
|
<!-- Content List -->
|
|
4341
4340
|
<div id="content-list">
|
|
4342
|
-
${
|
|
4343
|
-
${
|
|
4341
|
+
${chunkEYMHWJTW_cjs.renderTable(tableData)}
|
|
4342
|
+
${chunkEYMHWJTW_cjs.renderPagination(paginationData)}
|
|
4344
4343
|
</div>
|
|
4345
4344
|
|
|
4346
4345
|
</div>
|
|
@@ -4549,7 +4548,7 @@ function renderContentListPage(data) {
|
|
|
4549
4548
|
</script>
|
|
4550
4549
|
|
|
4551
4550
|
<!-- Confirmation Dialog for Bulk Actions -->
|
|
4552
|
-
${
|
|
4551
|
+
${chunkEYMHWJTW_cjs.renderConfirmationDialog({
|
|
4553
4552
|
id: "bulk-action-confirm",
|
|
4554
4553
|
title: "Confirm Bulk Action",
|
|
4555
4554
|
message: "Are you sure you want to perform this action? This operation will affect multiple items.",
|
|
@@ -4561,7 +4560,7 @@ function renderContentListPage(data) {
|
|
|
4561
4560
|
})}
|
|
4562
4561
|
|
|
4563
4562
|
<!-- Confirmation Dialog Script -->
|
|
4564
|
-
${
|
|
4563
|
+
${chunkEYMHWJTW_cjs.getConfirmationDialogScript()}
|
|
4565
4564
|
`;
|
|
4566
4565
|
const layoutData = {
|
|
4567
4566
|
title: "Content Management",
|
|
@@ -4571,7 +4570,7 @@ function renderContentListPage(data) {
|
|
|
4571
4570
|
version: data.version,
|
|
4572
4571
|
content: pageContent
|
|
4573
4572
|
};
|
|
4574
|
-
return
|
|
4573
|
+
return chunkEYMHWJTW_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
4575
4574
|
}
|
|
4576
4575
|
|
|
4577
4576
|
// src/templates/components/version-history.template.ts
|
|
@@ -4757,7 +4756,7 @@ var isPluginActive2 = () => false;
|
|
|
4757
4756
|
|
|
4758
4757
|
// src/routes/admin-content.ts
|
|
4759
4758
|
var adminContentRoutes = new hono.Hono();
|
|
4760
|
-
adminContentRoutes.use("*",
|
|
4759
|
+
adminContentRoutes.use("*", chunkDYYAXDXI_cjs.requireAuth());
|
|
4761
4760
|
async function getCollectionFields(db, collectionId) {
|
|
4762
4761
|
const cache = chunkDOR2IU73_cjs.getCacheService(chunkDOR2IU73_cjs.CACHE_CONFIGS.collection);
|
|
4763
4762
|
return cache.getOrSet(
|
|
@@ -5142,7 +5141,7 @@ adminContentRoutes.post("/", async (c) => {
|
|
|
5142
5141
|
const data = {};
|
|
5143
5142
|
const errors = {};
|
|
5144
5143
|
for (const field of fields) {
|
|
5145
|
-
const
|
|
5144
|
+
const value2 = formData.get(field.field_name);
|
|
5146
5145
|
if (field.field_type === "guid") {
|
|
5147
5146
|
const options = field.field_options || {};
|
|
5148
5147
|
if (options.autoGenerate) {
|
|
@@ -5150,33 +5149,33 @@ adminContentRoutes.post("/", async (c) => {
|
|
|
5150
5149
|
continue;
|
|
5151
5150
|
}
|
|
5152
5151
|
}
|
|
5153
|
-
if (field.is_required && (!
|
|
5152
|
+
if (field.is_required && (!value2 || value2.toString().trim() === "")) {
|
|
5154
5153
|
errors[field.field_name] = [`${field.field_label} is required`];
|
|
5155
5154
|
continue;
|
|
5156
5155
|
}
|
|
5157
5156
|
switch (field.field_type) {
|
|
5158
5157
|
case "number":
|
|
5159
|
-
if (
|
|
5158
|
+
if (value2 && isNaN(Number(value2))) {
|
|
5160
5159
|
errors[field.field_name] = [`${field.field_label} must be a valid number`];
|
|
5161
5160
|
} else {
|
|
5162
|
-
data[field.field_name] =
|
|
5161
|
+
data[field.field_name] = value2 ? Number(value2) : null;
|
|
5163
5162
|
}
|
|
5164
5163
|
break;
|
|
5165
5164
|
case "boolean":
|
|
5166
|
-
data[field.field_name] = formData.get(`${field.field_name}_submitted`) ?
|
|
5165
|
+
data[field.field_name] = formData.get(`${field.field_name}_submitted`) ? value2 === "true" : false;
|
|
5167
5166
|
break;
|
|
5168
5167
|
case "select":
|
|
5169
5168
|
if (field.field_options?.multiple) {
|
|
5170
5169
|
data[field.field_name] = formData.getAll(`${field.field_name}[]`);
|
|
5171
5170
|
} else {
|
|
5172
|
-
data[field.field_name] =
|
|
5171
|
+
data[field.field_name] = value2;
|
|
5173
5172
|
}
|
|
5174
5173
|
break;
|
|
5175
5174
|
case "guid":
|
|
5176
|
-
data[field.field_name] =
|
|
5175
|
+
data[field.field_name] = value2 || null;
|
|
5177
5176
|
break;
|
|
5178
5177
|
default:
|
|
5179
|
-
data[field.field_name] =
|
|
5178
|
+
data[field.field_name] = value2;
|
|
5180
5179
|
}
|
|
5181
5180
|
}
|
|
5182
5181
|
if (Object.keys(errors).length > 0) {
|
|
@@ -5304,31 +5303,31 @@ adminContentRoutes.put("/:id", async (c) => {
|
|
|
5304
5303
|
const data = {};
|
|
5305
5304
|
const errors = {};
|
|
5306
5305
|
for (const field of fields) {
|
|
5307
|
-
const
|
|
5308
|
-
if (field.is_required && (!
|
|
5306
|
+
const value2 = formData.get(field.field_name);
|
|
5307
|
+
if (field.is_required && (!value2 || value2.toString().trim() === "")) {
|
|
5309
5308
|
errors[field.field_name] = [`${field.field_label} is required`];
|
|
5310
5309
|
continue;
|
|
5311
5310
|
}
|
|
5312
5311
|
switch (field.field_type) {
|
|
5313
5312
|
case "number":
|
|
5314
|
-
if (
|
|
5313
|
+
if (value2 && isNaN(Number(value2))) {
|
|
5315
5314
|
errors[field.field_name] = [`${field.field_label} must be a valid number`];
|
|
5316
5315
|
} else {
|
|
5317
|
-
data[field.field_name] =
|
|
5316
|
+
data[field.field_name] = value2 ? Number(value2) : null;
|
|
5318
5317
|
}
|
|
5319
5318
|
break;
|
|
5320
5319
|
case "boolean":
|
|
5321
|
-
data[field.field_name] = formData.get(`${field.field_name}_submitted`) ?
|
|
5320
|
+
data[field.field_name] = formData.get(`${field.field_name}_submitted`) ? value2 === "true" : false;
|
|
5322
5321
|
break;
|
|
5323
5322
|
case "select":
|
|
5324
5323
|
if (field.field_options?.multiple) {
|
|
5325
5324
|
data[field.field_name] = formData.getAll(`${field.field_name}[]`);
|
|
5326
5325
|
} else {
|
|
5327
|
-
data[field.field_name] =
|
|
5326
|
+
data[field.field_name] = value2;
|
|
5328
5327
|
}
|
|
5329
5328
|
break;
|
|
5330
5329
|
default:
|
|
5331
|
-
data[field.field_name] =
|
|
5330
|
+
data[field.field_name] = value2;
|
|
5332
5331
|
}
|
|
5333
5332
|
}
|
|
5334
5333
|
if (Object.keys(errors).length > 0) {
|
|
@@ -5445,23 +5444,23 @@ adminContentRoutes.post("/preview", async (c) => {
|
|
|
5445
5444
|
const fields = await getCollectionFields(db, collectionId);
|
|
5446
5445
|
const data = {};
|
|
5447
5446
|
for (const field of fields) {
|
|
5448
|
-
const
|
|
5447
|
+
const value2 = formData.get(field.field_name);
|
|
5449
5448
|
switch (field.field_type) {
|
|
5450
5449
|
case "number":
|
|
5451
|
-
data[field.field_name] =
|
|
5450
|
+
data[field.field_name] = value2 ? Number(value2) : null;
|
|
5452
5451
|
break;
|
|
5453
5452
|
case "boolean":
|
|
5454
|
-
data[field.field_name] =
|
|
5453
|
+
data[field.field_name] = value2 === "true";
|
|
5455
5454
|
break;
|
|
5456
5455
|
case "select":
|
|
5457
5456
|
if (field.field_options?.multiple) {
|
|
5458
5457
|
data[field.field_name] = formData.getAll(`${field.field_name}[]`);
|
|
5459
5458
|
} else {
|
|
5460
|
-
data[field.field_name] =
|
|
5459
|
+
data[field.field_name] = value2;
|
|
5461
5460
|
}
|
|
5462
5461
|
break;
|
|
5463
5462
|
default:
|
|
5464
|
-
data[field.field_name] =
|
|
5463
|
+
data[field.field_name] = value2;
|
|
5465
5464
|
}
|
|
5466
5465
|
}
|
|
5467
5466
|
const previewHTML = `
|
|
@@ -5892,7 +5891,7 @@ ${JSON.stringify(data, null, 2)}
|
|
|
5892
5891
|
var admin_content_default = adminContentRoutes;
|
|
5893
5892
|
|
|
5894
5893
|
// src/templates/pages/admin-profile.template.ts
|
|
5895
|
-
|
|
5894
|
+
chunkEYMHWJTW_cjs.init_admin_layout_catalyst_template();
|
|
5896
5895
|
function renderAvatarImage(avatarUrl, firstName, lastName) {
|
|
5897
5896
|
return `<div id="avatar-image-container" class="w-24 h-24 rounded-full mx-auto mb-4 overflow-hidden bg-gradient-to-br from-cyan-400 to-purple-400 flex items-center justify-center ring-4 ring-zinc-950/5 dark:ring-white/10">
|
|
5898
5897
|
${avatarUrl ? `<img src="${avatarUrl}" alt="Profile picture" class="w-full h-full object-cover">` : `<span class="text-2xl font-bold text-white">${firstName.charAt(0)}${lastName.charAt(0)}</span>`}
|
|
@@ -5912,8 +5911,8 @@ function renderProfilePage(data) {
|
|
|
5912
5911
|
</div>
|
|
5913
5912
|
|
|
5914
5913
|
<!-- Alert Messages -->
|
|
5915
|
-
${data.error ?
|
|
5916
|
-
${data.success ?
|
|
5914
|
+
${data.error ? chunkEYMHWJTW_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
|
|
5915
|
+
${data.success ? chunkEYMHWJTW_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
|
|
5917
5916
|
|
|
5918
5917
|
<!-- Profile Form -->
|
|
5919
5918
|
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
|
|
@@ -6300,7 +6299,7 @@ function renderProfilePage(data) {
|
|
|
6300
6299
|
version: data.version,
|
|
6301
6300
|
content: pageContent
|
|
6302
6301
|
};
|
|
6303
|
-
return
|
|
6302
|
+
return chunkEYMHWJTW_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
6304
6303
|
}
|
|
6305
6304
|
|
|
6306
6305
|
// src/templates/components/alert.template.ts
|
|
@@ -6583,7 +6582,7 @@ function renderActivityLogsPage(data) {
|
|
|
6583
6582
|
user: data.user,
|
|
6584
6583
|
content: pageContent
|
|
6585
6584
|
};
|
|
6586
|
-
return
|
|
6585
|
+
return chunkEYMHWJTW_cjs.renderAdminLayout(layoutData);
|
|
6587
6586
|
}
|
|
6588
6587
|
function getActionBadgeClass(action) {
|
|
6589
6588
|
if (action.includes("login") || action.includes("logout")) {
|
|
@@ -6603,7 +6602,7 @@ function formatAction(action) {
|
|
|
6603
6602
|
}
|
|
6604
6603
|
|
|
6605
6604
|
// src/templates/pages/admin-user-edit.template.ts
|
|
6606
|
-
|
|
6605
|
+
chunkEYMHWJTW_cjs.init_admin_layout_catalyst_template();
|
|
6607
6606
|
|
|
6608
6607
|
// src/templates/components/confirmation-dialog.template.ts
|
|
6609
6608
|
function renderConfirmationDialog2(options) {
|
|
@@ -6724,8 +6723,8 @@ function renderUserEditPage(data) {
|
|
|
6724
6723
|
|
|
6725
6724
|
<!-- Alert Messages -->
|
|
6726
6725
|
<div id="form-messages">
|
|
6727
|
-
${data.error ?
|
|
6728
|
-
${data.success ?
|
|
6726
|
+
${data.error ? chunkEYMHWJTW_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
|
|
6727
|
+
${data.success ? chunkEYMHWJTW_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
|
|
6729
6728
|
</div>
|
|
6730
6729
|
|
|
6731
6730
|
<!-- User Edit Form -->
|
|
@@ -6744,7 +6743,7 @@ function renderUserEditPage(data) {
|
|
|
6744
6743
|
<input
|
|
6745
6744
|
type="text"
|
|
6746
6745
|
name="first_name"
|
|
6747
|
-
value="${
|
|
6746
|
+
value="${chunkTMIRVVQ7_cjs.escapeHtml(data.userToEdit.firstName || "")}"
|
|
6748
6747
|
required
|
|
6749
6748
|
class="w-full rounded-lg bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-950 dark:text-white shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow"
|
|
6750
6749
|
/>
|
|
@@ -6755,7 +6754,7 @@ function renderUserEditPage(data) {
|
|
|
6755
6754
|
<input
|
|
6756
6755
|
type="text"
|
|
6757
6756
|
name="last_name"
|
|
6758
|
-
value="${
|
|
6757
|
+
value="${chunkTMIRVVQ7_cjs.escapeHtml(data.userToEdit.lastName || "")}"
|
|
6759
6758
|
required
|
|
6760
6759
|
class="w-full rounded-lg bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-950 dark:text-white shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow"
|
|
6761
6760
|
/>
|
|
@@ -6766,7 +6765,7 @@ function renderUserEditPage(data) {
|
|
|
6766
6765
|
<input
|
|
6767
6766
|
type="text"
|
|
6768
6767
|
name="username"
|
|
6769
|
-
value="${
|
|
6768
|
+
value="${chunkTMIRVVQ7_cjs.escapeHtml(data.userToEdit.username || "")}"
|
|
6770
6769
|
required
|
|
6771
6770
|
class="w-full rounded-lg bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-950 dark:text-white shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow"
|
|
6772
6771
|
/>
|
|
@@ -6777,7 +6776,7 @@ function renderUserEditPage(data) {
|
|
|
6777
6776
|
<input
|
|
6778
6777
|
type="email"
|
|
6779
6778
|
name="email"
|
|
6780
|
-
value="${
|
|
6779
|
+
value="${chunkTMIRVVQ7_cjs.escapeHtml(data.userToEdit.email || "")}"
|
|
6781
6780
|
required
|
|
6782
6781
|
class="w-full rounded-lg bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-950 dark:text-white shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow"
|
|
6783
6782
|
/>
|
|
@@ -6788,7 +6787,7 @@ function renderUserEditPage(data) {
|
|
|
6788
6787
|
<input
|
|
6789
6788
|
type="tel"
|
|
6790
6789
|
name="phone"
|
|
6791
|
-
value="${
|
|
6790
|
+
value="${chunkTMIRVVQ7_cjs.escapeHtml(data.userToEdit.phone || "")}"
|
|
6792
6791
|
class="w-full rounded-lg bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-950 dark:text-white shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow"
|
|
6793
6792
|
/>
|
|
6794
6793
|
</div>
|
|
@@ -6802,7 +6801,7 @@ function renderUserEditPage(data) {
|
|
|
6802
6801
|
class="col-start-1 row-start-1 w-full appearance-none rounded-md bg-white/5 dark:bg-white/5 py-1.5 pl-3 pr-8 text-base text-zinc-950 dark:text-white outline outline-1 -outline-offset-1 outline-zinc-500/30 dark:outline-zinc-400/30 *:bg-white dark:*:bg-zinc-800 focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-zinc-500 dark:focus-visible:outline-zinc-400 sm:text-sm/6"
|
|
6803
6802
|
>
|
|
6804
6803
|
${data.roles.map((role) => `
|
|
6805
|
-
<option value="${
|
|
6804
|
+
<option value="${chunkTMIRVVQ7_cjs.escapeHtml(role.value)}" ${data.userToEdit.role === role.value ? "selected" : ""}>${chunkTMIRVVQ7_cjs.escapeHtml(role.label)}</option>
|
|
6806
6805
|
`).join("")}
|
|
6807
6806
|
</select>
|
|
6808
6807
|
<svg viewBox="0 0 16 16" fill="currentColor" data-slot="icon" aria-hidden="true" class="pointer-events-none col-start-1 row-start-1 mr-2 size-5 self-center justify-self-end text-zinc-600 dark:text-zinc-400 sm:size-4">
|
|
@@ -6818,7 +6817,7 @@ function renderUserEditPage(data) {
|
|
|
6818
6817
|
name="bio"
|
|
6819
6818
|
rows="3"
|
|
6820
6819
|
class="w-full rounded-lg bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-950 dark:text-white shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow"
|
|
6821
|
-
>${
|
|
6820
|
+
>${chunkTMIRVVQ7_cjs.escapeHtml(data.userToEdit.bio || "")}</textarea>
|
|
6822
6821
|
</div>
|
|
6823
6822
|
</div>
|
|
6824
6823
|
|
|
@@ -7018,11 +7017,11 @@ function renderUserEditPage(data) {
|
|
|
7018
7017
|
user: data.user,
|
|
7019
7018
|
content: pageContent
|
|
7020
7019
|
};
|
|
7021
|
-
return
|
|
7020
|
+
return chunkEYMHWJTW_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
7022
7021
|
}
|
|
7023
7022
|
|
|
7024
7023
|
// src/templates/pages/admin-user-new.template.ts
|
|
7025
|
-
|
|
7024
|
+
chunkEYMHWJTW_cjs.init_admin_layout_catalyst_template();
|
|
7026
7025
|
function renderUserNewPage(data) {
|
|
7027
7026
|
const pageContent = `
|
|
7028
7027
|
<div>
|
|
@@ -7061,8 +7060,8 @@ function renderUserNewPage(data) {
|
|
|
7061
7060
|
|
|
7062
7061
|
<!-- Alert Messages -->
|
|
7063
7062
|
<div id="form-messages">
|
|
7064
|
-
${data.error ?
|
|
7065
|
-
${data.success ?
|
|
7063
|
+
${data.error ? chunkEYMHWJTW_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
|
|
7064
|
+
${data.success ? chunkEYMHWJTW_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
|
|
7066
7065
|
</div>
|
|
7067
7066
|
|
|
7068
7067
|
<!-- User New Form -->
|
|
@@ -7306,11 +7305,11 @@ function renderUserNewPage(data) {
|
|
|
7306
7305
|
user: data.user,
|
|
7307
7306
|
content: pageContent
|
|
7308
7307
|
};
|
|
7309
|
-
return
|
|
7308
|
+
return chunkEYMHWJTW_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
7310
7309
|
}
|
|
7311
7310
|
|
|
7312
7311
|
// src/templates/pages/admin-users-list.template.ts
|
|
7313
|
-
|
|
7312
|
+
chunkEYMHWJTW_cjs.init_admin_layout_catalyst_template();
|
|
7314
7313
|
function renderUsersListPage(data) {
|
|
7315
7314
|
const columns = [
|
|
7316
7315
|
{
|
|
@@ -7318,10 +7317,10 @@ function renderUsersListPage(data) {
|
|
|
7318
7317
|
label: "",
|
|
7319
7318
|
className: "w-12",
|
|
7320
7319
|
sortable: false,
|
|
7321
|
-
render: (
|
|
7320
|
+
render: (value2, row) => {
|
|
7322
7321
|
const initials = `${row.firstName.charAt(0)}${row.lastName.charAt(0)}`.toUpperCase();
|
|
7323
|
-
if (
|
|
7324
|
-
return `<img src="${
|
|
7322
|
+
if (value2) {
|
|
7323
|
+
return `<img src="${value2}" alt="${row.firstName} ${row.lastName}" class="w-8 h-8 rounded-full">`;
|
|
7325
7324
|
}
|
|
7326
7325
|
return `
|
|
7327
7326
|
<div class="w-8 h-8 bg-gradient-to-br from-cyan-400 to-blue-500 dark:from-cyan-300 dark:to-blue-400 rounded-full flex items-center justify-center">
|
|
@@ -7335,7 +7334,7 @@ function renderUsersListPage(data) {
|
|
|
7335
7334
|
label: "Name",
|
|
7336
7335
|
sortable: true,
|
|
7337
7336
|
sortType: "string",
|
|
7338
|
-
render: (
|
|
7337
|
+
render: (_value, row) => {
|
|
7339
7338
|
const escapeHtml7 = (text) => text.replace(/[&<>"']/g, (char) => ({
|
|
7340
7339
|
"&": "&",
|
|
7341
7340
|
"<": "<",
|
|
@@ -7362,7 +7361,7 @@ function renderUsersListPage(data) {
|
|
|
7362
7361
|
label: "Email",
|
|
7363
7362
|
sortable: true,
|
|
7364
7363
|
sortType: "string",
|
|
7365
|
-
render: (
|
|
7364
|
+
render: (value2) => {
|
|
7366
7365
|
const escapeHtml7 = (text) => text.replace(/[&<>"']/g, (char) => ({
|
|
7367
7366
|
"&": "&",
|
|
7368
7367
|
"<": "<",
|
|
@@ -7370,7 +7369,7 @@ function renderUsersListPage(data) {
|
|
|
7370
7369
|
'"': """,
|
|
7371
7370
|
"'": "'"
|
|
7372
7371
|
})[char] || char);
|
|
7373
|
-
const escapedEmail = escapeHtml7(
|
|
7372
|
+
const escapedEmail = escapeHtml7(value2);
|
|
7374
7373
|
return `<a href="mailto:${escapedEmail}" class="text-cyan-600 dark:text-cyan-400 hover:text-cyan-700 dark:hover:text-cyan-300 transition-colors">${escapedEmail}</a>`;
|
|
7375
7374
|
}
|
|
7376
7375
|
},
|
|
@@ -7379,7 +7378,7 @@ function renderUsersListPage(data) {
|
|
|
7379
7378
|
label: "Role",
|
|
7380
7379
|
sortable: true,
|
|
7381
7380
|
sortType: "string",
|
|
7382
|
-
render: (
|
|
7381
|
+
render: (_value) => {
|
|
7383
7382
|
const roleColors = {
|
|
7384
7383
|
admin: "bg-red-50 dark:bg-red-500/10 text-red-700 dark:text-red-400 ring-1 ring-inset ring-red-700/10 dark:ring-red-500/20",
|
|
7385
7384
|
editor: "bg-blue-50 dark:bg-blue-500/10 text-blue-700 dark:text-blue-400 ring-1 ring-inset ring-blue-700/10 dark:ring-blue-500/20",
|
|
@@ -7395,7 +7394,7 @@ function renderUsersListPage(data) {
|
|
|
7395
7394
|
label: "Last Login",
|
|
7396
7395
|
sortable: true,
|
|
7397
7396
|
sortType: "date",
|
|
7398
|
-
render: (
|
|
7397
|
+
render: (_value) => {
|
|
7399
7398
|
if (!value) return '<span class="text-zinc-500 dark:text-zinc-400">Never</span>';
|
|
7400
7399
|
return `<span class="text-sm text-zinc-500 dark:text-zinc-400">${new Date(value).toLocaleDateString()}</span>`;
|
|
7401
7400
|
}
|
|
@@ -7405,14 +7404,14 @@ function renderUsersListPage(data) {
|
|
|
7405
7404
|
label: "Created",
|
|
7406
7405
|
sortable: true,
|
|
7407
7406
|
sortType: "date",
|
|
7408
|
-
render: (
|
|
7407
|
+
render: (_value) => `<span class="text-sm text-zinc-500 dark:text-zinc-400">${new Date(value).toLocaleDateString()}</span>`
|
|
7409
7408
|
},
|
|
7410
7409
|
{
|
|
7411
7410
|
key: "actions",
|
|
7412
7411
|
label: "Actions",
|
|
7413
7412
|
className: "text-right",
|
|
7414
7413
|
sortable: false,
|
|
7415
|
-
render: (
|
|
7414
|
+
render: (_value, row) => `
|
|
7416
7415
|
<div class="flex justify-end space-x-2">
|
|
7417
7416
|
${row.isActive ? `<button onclick="toggleUserStatus('${row.id}', false)" title="Deactivate user" class="inline-flex items-center justify-center p-2 text-sm font-medium rounded-lg bg-gradient-to-r from-red-500 to-pink-500 dark:from-red-400 dark:to-pink-400 text-white hover:from-red-600 hover:to-pink-600 dark:hover:from-red-500 dark:hover:to-pink-500 shadow-sm transition-all duration-200">
|
|
7418
7417
|
<svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
@@ -7461,8 +7460,8 @@ function renderUsersListPage(data) {
|
|
|
7461
7460
|
</div>
|
|
7462
7461
|
|
|
7463
7462
|
<!-- Alert Messages -->
|
|
7464
|
-
${data.error ?
|
|
7465
|
-
${data.success ?
|
|
7463
|
+
${data.error ? chunkEYMHWJTW_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
|
|
7464
|
+
${data.success ? chunkEYMHWJTW_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
|
|
7466
7465
|
|
|
7467
7466
|
<!-- Stats -->
|
|
7468
7467
|
<div class="mb-6">
|
|
@@ -7639,10 +7638,10 @@ function renderUsersListPage(data) {
|
|
|
7639
7638
|
</div>
|
|
7640
7639
|
|
|
7641
7640
|
<!-- Users Table -->
|
|
7642
|
-
${
|
|
7641
|
+
${chunkEYMHWJTW_cjs.renderTable(tableData)}
|
|
7643
7642
|
|
|
7644
7643
|
<!-- Pagination -->
|
|
7645
|
-
${data.pagination ?
|
|
7644
|
+
${data.pagination ? chunkEYMHWJTW_cjs.renderPagination(data.pagination) : ""}
|
|
7646
7645
|
</div>
|
|
7647
7646
|
|
|
7648
7647
|
<script>
|
|
@@ -7713,12 +7712,12 @@ function renderUsersListPage(data) {
|
|
|
7713
7712
|
version: data.version,
|
|
7714
7713
|
content: pageContent
|
|
7715
7714
|
};
|
|
7716
|
-
return
|
|
7715
|
+
return chunkEYMHWJTW_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
7717
7716
|
}
|
|
7718
7717
|
|
|
7719
7718
|
// src/routes/admin-users.ts
|
|
7720
7719
|
var userRoutes = new hono.Hono();
|
|
7721
|
-
userRoutes.use("*",
|
|
7720
|
+
userRoutes.use("*", chunkDYYAXDXI_cjs.requireAuth());
|
|
7722
7721
|
userRoutes.get("/", (c) => {
|
|
7723
7722
|
return c.redirect("/admin/dashboard");
|
|
7724
7723
|
});
|
|
@@ -7817,12 +7816,12 @@ userRoutes.put("/profile", async (c) => {
|
|
|
7817
7816
|
const db = c.env.DB;
|
|
7818
7817
|
try {
|
|
7819
7818
|
const formData = await c.req.formData();
|
|
7820
|
-
const firstName =
|
|
7821
|
-
const lastName =
|
|
7822
|
-
const username =
|
|
7819
|
+
const firstName = chunkTMIRVVQ7_cjs.sanitizeInput(formData.get("first_name")?.toString());
|
|
7820
|
+
const lastName = chunkTMIRVVQ7_cjs.sanitizeInput(formData.get("last_name")?.toString());
|
|
7821
|
+
const username = chunkTMIRVVQ7_cjs.sanitizeInput(formData.get("username")?.toString());
|
|
7823
7822
|
const email = formData.get("email")?.toString()?.trim().toLowerCase() || "";
|
|
7824
|
-
const phone =
|
|
7825
|
-
const bio =
|
|
7823
|
+
const phone = chunkTMIRVVQ7_cjs.sanitizeInput(formData.get("phone")?.toString()) || null;
|
|
7824
|
+
const bio = chunkTMIRVVQ7_cjs.sanitizeInput(formData.get("bio")?.toString()) || null;
|
|
7826
7825
|
const timezone = formData.get("timezone")?.toString() || "UTC";
|
|
7827
7826
|
const language = formData.get("language")?.toString() || "en";
|
|
7828
7827
|
const emailNotifications = formData.get("email_notifications") === "1";
|
|
@@ -7873,7 +7872,7 @@ userRoutes.put("/profile", async (c) => {
|
|
|
7873
7872
|
Date.now(),
|
|
7874
7873
|
user.userId
|
|
7875
7874
|
).run();
|
|
7876
|
-
await
|
|
7875
|
+
await chunkDYYAXDXI_cjs.logActivity(
|
|
7877
7876
|
db,
|
|
7878
7877
|
user.userId,
|
|
7879
7878
|
"profile.update",
|
|
@@ -7903,7 +7902,7 @@ userRoutes.post("/profile/avatar", async (c) => {
|
|
|
7903
7902
|
try {
|
|
7904
7903
|
const formData = await c.req.formData();
|
|
7905
7904
|
const avatarFile = formData.get("avatar");
|
|
7906
|
-
if (!avatarFile || !avatarFile.name) {
|
|
7905
|
+
if (!avatarFile || !(avatarFile instanceof File) || !avatarFile.name) {
|
|
7907
7906
|
return c.html(renderAlert2({
|
|
7908
7907
|
type: "error",
|
|
7909
7908
|
message: "Please select an image file.",
|
|
@@ -7936,7 +7935,7 @@ userRoutes.post("/profile/avatar", async (c) => {
|
|
|
7936
7935
|
SELECT first_name, last_name FROM users WHERE id = ?
|
|
7937
7936
|
`);
|
|
7938
7937
|
const userData = await userStmt.bind(user.userId).first();
|
|
7939
|
-
await
|
|
7938
|
+
await chunkDYYAXDXI_cjs.logActivity(
|
|
7940
7939
|
db,
|
|
7941
7940
|
user.userId,
|
|
7942
7941
|
"profile.avatar_update",
|
|
@@ -8007,7 +8006,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
8007
8006
|
dismissible: true
|
|
8008
8007
|
}));
|
|
8009
8008
|
}
|
|
8010
|
-
const validPassword = await
|
|
8009
|
+
const validPassword = await chunkDYYAXDXI_cjs.AuthManager.verifyPassword(currentPassword, userData.password_hash);
|
|
8011
8010
|
if (!validPassword) {
|
|
8012
8011
|
return c.html(renderAlert2({
|
|
8013
8012
|
type: "error",
|
|
@@ -8015,13 +8014,13 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
8015
8014
|
dismissible: true
|
|
8016
8015
|
}));
|
|
8017
8016
|
}
|
|
8018
|
-
const newPasswordHash = await
|
|
8017
|
+
const newPasswordHash = await chunkDYYAXDXI_cjs.AuthManager.hashPassword(newPassword);
|
|
8019
8018
|
const historyStmt = db.prepare(`
|
|
8020
8019
|
INSERT INTO password_history (id, user_id, password_hash, created_at)
|
|
8021
8020
|
VALUES (?, ?, ?, ?)
|
|
8022
8021
|
`);
|
|
8023
8022
|
await historyStmt.bind(
|
|
8024
|
-
|
|
8023
|
+
crypto.randomUUID(),
|
|
8025
8024
|
user.userId,
|
|
8026
8025
|
userData.password_hash,
|
|
8027
8026
|
Date.now()
|
|
@@ -8031,7 +8030,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
8031
8030
|
WHERE id = ?
|
|
8032
8031
|
`);
|
|
8033
8032
|
await updateStmt.bind(newPasswordHash, Date.now(), user.userId).run();
|
|
8034
|
-
await
|
|
8033
|
+
await chunkDYYAXDXI_cjs.logActivity(
|
|
8035
8034
|
db,
|
|
8036
8035
|
user.userId,
|
|
8037
8036
|
"profile.password_change",
|
|
@@ -8098,7 +8097,7 @@ userRoutes.get("/users", async (c) => {
|
|
|
8098
8097
|
`);
|
|
8099
8098
|
const countResult = await countStmt.bind(...params).first();
|
|
8100
8099
|
const totalUsers = countResult?.total || 0;
|
|
8101
|
-
await
|
|
8100
|
+
await chunkDYYAXDXI_cjs.logActivity(
|
|
8102
8101
|
db,
|
|
8103
8102
|
user.userId,
|
|
8104
8103
|
"users.list_view",
|
|
@@ -8200,12 +8199,12 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
8200
8199
|
const user = c.get("user");
|
|
8201
8200
|
try {
|
|
8202
8201
|
const formData = await c.req.formData();
|
|
8203
|
-
const firstName =
|
|
8204
|
-
const lastName =
|
|
8205
|
-
const username =
|
|
8202
|
+
const firstName = chunkTMIRVVQ7_cjs.sanitizeInput(formData.get("first_name")?.toString());
|
|
8203
|
+
const lastName = chunkTMIRVVQ7_cjs.sanitizeInput(formData.get("last_name")?.toString());
|
|
8204
|
+
const username = chunkTMIRVVQ7_cjs.sanitizeInput(formData.get("username")?.toString());
|
|
8206
8205
|
const email = formData.get("email")?.toString()?.trim().toLowerCase() || "";
|
|
8207
|
-
const phone =
|
|
8208
|
-
const bio =
|
|
8206
|
+
const phone = chunkTMIRVVQ7_cjs.sanitizeInput(formData.get("phone")?.toString()) || null;
|
|
8207
|
+
const bio = chunkTMIRVVQ7_cjs.sanitizeInput(formData.get("bio")?.toString()) || null;
|
|
8209
8208
|
const role = formData.get("role")?.toString() || "viewer";
|
|
8210
8209
|
const password = formData.get("password")?.toString() || "";
|
|
8211
8210
|
const confirmPassword = formData.get("confirm_password")?.toString() || "";
|
|
@@ -8252,8 +8251,8 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
8252
8251
|
dismissible: true
|
|
8253
8252
|
}));
|
|
8254
8253
|
}
|
|
8255
|
-
const passwordHash = await
|
|
8256
|
-
const userId =
|
|
8254
|
+
const passwordHash = await chunkDYYAXDXI_cjs.AuthManager.hashPassword(password);
|
|
8255
|
+
const userId = crypto.randomUUID();
|
|
8257
8256
|
const createStmt = db.prepare(`
|
|
8258
8257
|
INSERT INTO users (
|
|
8259
8258
|
id, email, username, first_name, last_name, phone, bio,
|
|
@@ -8275,7 +8274,7 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
8275
8274
|
Date.now(),
|
|
8276
8275
|
Date.now()
|
|
8277
8276
|
).run();
|
|
8278
|
-
await
|
|
8277
|
+
await chunkDYYAXDXI_cjs.logActivity(
|
|
8279
8278
|
db,
|
|
8280
8279
|
user.userId,
|
|
8281
8280
|
"user!.create",
|
|
@@ -8313,7 +8312,7 @@ userRoutes.get("/users/:id", async (c) => {
|
|
|
8313
8312
|
if (!userRecord) {
|
|
8314
8313
|
return c.json({ error: "User not found" }, 404);
|
|
8315
8314
|
}
|
|
8316
|
-
await
|
|
8315
|
+
await chunkDYYAXDXI_cjs.logActivity(
|
|
8317
8316
|
db,
|
|
8318
8317
|
user.userId,
|
|
8319
8318
|
"user!.view",
|
|
@@ -8406,12 +8405,12 @@ userRoutes.put("/users/:id", async (c) => {
|
|
|
8406
8405
|
const userId = c.req.param("id");
|
|
8407
8406
|
try {
|
|
8408
8407
|
const formData = await c.req.formData();
|
|
8409
|
-
const firstName =
|
|
8410
|
-
const lastName =
|
|
8411
|
-
const username =
|
|
8408
|
+
const firstName = chunkTMIRVVQ7_cjs.sanitizeInput(formData.get("first_name")?.toString());
|
|
8409
|
+
const lastName = chunkTMIRVVQ7_cjs.sanitizeInput(formData.get("last_name")?.toString());
|
|
8410
|
+
const username = chunkTMIRVVQ7_cjs.sanitizeInput(formData.get("username")?.toString());
|
|
8412
8411
|
const email = formData.get("email")?.toString()?.trim().toLowerCase() || "";
|
|
8413
|
-
const phone =
|
|
8414
|
-
const bio =
|
|
8412
|
+
const phone = chunkTMIRVVQ7_cjs.sanitizeInput(formData.get("phone")?.toString()) || null;
|
|
8413
|
+
const bio = chunkTMIRVVQ7_cjs.sanitizeInput(formData.get("bio")?.toString()) || null;
|
|
8415
8414
|
const role = formData.get("role")?.toString() || "viewer";
|
|
8416
8415
|
const isActive = formData.get("is_active") === "1";
|
|
8417
8416
|
const emailVerified = formData.get("email_verified") === "1";
|
|
@@ -8462,7 +8461,7 @@ userRoutes.put("/users/:id", async (c) => {
|
|
|
8462
8461
|
Date.now(),
|
|
8463
8462
|
userId
|
|
8464
8463
|
).run();
|
|
8465
|
-
await
|
|
8464
|
+
await chunkDYYAXDXI_cjs.logActivity(
|
|
8466
8465
|
db,
|
|
8467
8466
|
user.userId,
|
|
8468
8467
|
"user!.update",
|
|
@@ -8508,7 +8507,7 @@ userRoutes.delete("/users/:id", async (c) => {
|
|
|
8508
8507
|
DELETE FROM users WHERE id = ?
|
|
8509
8508
|
`);
|
|
8510
8509
|
await deleteStmt.bind(userId).run();
|
|
8511
|
-
await
|
|
8510
|
+
await chunkDYYAXDXI_cjs.logActivity(
|
|
8512
8511
|
db,
|
|
8513
8512
|
user.userId,
|
|
8514
8513
|
"user!.hard_delete",
|
|
@@ -8527,7 +8526,7 @@ userRoutes.delete("/users/:id", async (c) => {
|
|
|
8527
8526
|
UPDATE users SET is_active = 0, updated_at = ? WHERE id = ?
|
|
8528
8527
|
`);
|
|
8529
8528
|
await deleteStmt.bind(Date.now(), userId).run();
|
|
8530
|
-
await
|
|
8529
|
+
await chunkDYYAXDXI_cjs.logActivity(
|
|
8531
8530
|
db,
|
|
8532
8531
|
user.userId,
|
|
8533
8532
|
"user!.soft_delete",
|
|
@@ -8554,8 +8553,8 @@ userRoutes.post("/invite-user", async (c) => {
|
|
|
8554
8553
|
const formData = await c.req.formData();
|
|
8555
8554
|
const email = formData.get("email")?.toString()?.trim().toLowerCase() || "";
|
|
8556
8555
|
const role = formData.get("role")?.toString()?.trim() || "viewer";
|
|
8557
|
-
const firstName =
|
|
8558
|
-
const lastName =
|
|
8556
|
+
const firstName = chunkTMIRVVQ7_cjs.sanitizeInput(formData.get("first_name")?.toString());
|
|
8557
|
+
const lastName = chunkTMIRVVQ7_cjs.sanitizeInput(formData.get("last_name")?.toString());
|
|
8559
8558
|
if (!email || !firstName || !lastName) {
|
|
8560
8559
|
return c.json({ error: "Email, first name, and last name are required" }, 400);
|
|
8561
8560
|
}
|
|
@@ -8570,9 +8569,8 @@ userRoutes.post("/invite-user", async (c) => {
|
|
|
8570
8569
|
if (existingUser) {
|
|
8571
8570
|
return c.json({ error: "A user with this email already exists" }, 400);
|
|
8572
8571
|
}
|
|
8573
|
-
const invitationToken =
|
|
8574
|
-
const
|
|
8575
|
-
const userId = globalThis.crypto.randomUUID();
|
|
8572
|
+
const invitationToken = crypto.randomUUID();
|
|
8573
|
+
const userId = crypto.randomUUID();
|
|
8576
8574
|
const createUserStmt = db.prepare(`
|
|
8577
8575
|
INSERT INTO users (
|
|
8578
8576
|
id, email, first_name, last_name, role,
|
|
@@ -8594,7 +8592,7 @@ userRoutes.post("/invite-user", async (c) => {
|
|
|
8594
8592
|
Date.now(),
|
|
8595
8593
|
Date.now()
|
|
8596
8594
|
).run();
|
|
8597
|
-
await
|
|
8595
|
+
await chunkDYYAXDXI_cjs.logActivity(
|
|
8598
8596
|
db,
|
|
8599
8597
|
user.userId,
|
|
8600
8598
|
"user!.invite_sent",
|
|
@@ -8637,7 +8635,7 @@ userRoutes.post("/resend-invitation/:id", async (c) => {
|
|
|
8637
8635
|
if (!invitedUser) {
|
|
8638
8636
|
return c.json({ error: "User not found or invitation not valid" }, 404);
|
|
8639
8637
|
}
|
|
8640
|
-
const newInvitationToken =
|
|
8638
|
+
const newInvitationToken = crypto.randomUUID();
|
|
8641
8639
|
const updateStmt = db.prepare(`
|
|
8642
8640
|
UPDATE users SET
|
|
8643
8641
|
invitation_token = ?,
|
|
@@ -8651,7 +8649,7 @@ userRoutes.post("/resend-invitation/:id", async (c) => {
|
|
|
8651
8649
|
Date.now(),
|
|
8652
8650
|
userId
|
|
8653
8651
|
).run();
|
|
8654
|
-
await
|
|
8652
|
+
await chunkDYYAXDXI_cjs.logActivity(
|
|
8655
8653
|
db,
|
|
8656
8654
|
user.userId,
|
|
8657
8655
|
"user!.invitation_resent",
|
|
@@ -8687,7 +8685,7 @@ userRoutes.delete("/cancel-invitation/:id", async (c) => {
|
|
|
8687
8685
|
}
|
|
8688
8686
|
const deleteStmt = db.prepare(`DELETE FROM users WHERE id = ?`);
|
|
8689
8687
|
await deleteStmt.bind(userId).run();
|
|
8690
|
-
await
|
|
8688
|
+
await chunkDYYAXDXI_cjs.logActivity(
|
|
8691
8689
|
db,
|
|
8692
8690
|
user.userId,
|
|
8693
8691
|
"user!.invitation_cancelled",
|
|
@@ -8770,7 +8768,7 @@ userRoutes.get("/activity-logs", async (c) => {
|
|
|
8770
8768
|
...log,
|
|
8771
8769
|
details: log.details ? JSON.parse(log.details) : null
|
|
8772
8770
|
}));
|
|
8773
|
-
await
|
|
8771
|
+
await chunkDYYAXDXI_cjs.logActivity(
|
|
8774
8772
|
db,
|
|
8775
8773
|
user.userId,
|
|
8776
8774
|
"activity.logs_viewed",
|
|
@@ -8877,7 +8875,7 @@ userRoutes.get("/activity-logs/export", async (c) => {
|
|
|
8877
8875
|
csvRows.push(row.join(","));
|
|
8878
8876
|
}
|
|
8879
8877
|
const csvContent = csvRows.join("\n");
|
|
8880
|
-
await
|
|
8878
|
+
await chunkDYYAXDXI_cjs.logActivity(
|
|
8881
8879
|
db,
|
|
8882
8880
|
user.userId,
|
|
8883
8881
|
"activity.logs_exported",
|
|
@@ -9095,7 +9093,7 @@ function getFileIcon(mimeType) {
|
|
|
9095
9093
|
}
|
|
9096
9094
|
|
|
9097
9095
|
// src/templates/pages/admin-media-library.template.ts
|
|
9098
|
-
|
|
9096
|
+
chunkEYMHWJTW_cjs.init_admin_layout_catalyst_template();
|
|
9099
9097
|
function renderMediaLibraryPage(data) {
|
|
9100
9098
|
const pageContent = `
|
|
9101
9099
|
<div>
|
|
@@ -10030,7 +10028,7 @@ function renderMediaLibraryPage(data) {
|
|
|
10030
10028
|
version: data.version,
|
|
10031
10029
|
content: pageContent
|
|
10032
10030
|
};
|
|
10033
|
-
return
|
|
10031
|
+
return chunkEYMHWJTW_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
10034
10032
|
}
|
|
10035
10033
|
|
|
10036
10034
|
// src/templates/components/media-file-details.template.ts
|
|
@@ -10216,7 +10214,7 @@ var fileValidationSchema2 = zod.z.object({
|
|
|
10216
10214
|
// 50MB max
|
|
10217
10215
|
});
|
|
10218
10216
|
var adminMediaRoutes = new hono.Hono();
|
|
10219
|
-
adminMediaRoutes.use("*",
|
|
10217
|
+
adminMediaRoutes.use("*", chunkDYYAXDXI_cjs.requireAuth());
|
|
10220
10218
|
adminMediaRoutes.get("/", async (c) => {
|
|
10221
10219
|
try {
|
|
10222
10220
|
const user = c.get("user");
|
|
@@ -10225,7 +10223,7 @@ adminMediaRoutes.get("/", async (c) => {
|
|
|
10225
10223
|
const type = searchParams.get("type") || "all";
|
|
10226
10224
|
const view = searchParams.get("view") || "grid";
|
|
10227
10225
|
const page = parseInt(searchParams.get("page") || "1");
|
|
10228
|
-
const
|
|
10226
|
+
const ____cacheBust = searchParams.get("t");
|
|
10229
10227
|
const limit = 24;
|
|
10230
10228
|
const offset = (page - 1) * limit;
|
|
10231
10229
|
const db = c.env.DB;
|
|
@@ -10651,7 +10649,7 @@ adminMediaRoutes.post("/upload", async (c) => {
|
|
|
10651
10649
|
});
|
|
10652
10650
|
}
|
|
10653
10651
|
}
|
|
10654
|
-
let
|
|
10652
|
+
let __mediaGridHTML = "";
|
|
10655
10653
|
if (uploadResults.length > 0) {
|
|
10656
10654
|
try {
|
|
10657
10655
|
const folder = formData.get("folder") || "uploads";
|
|
@@ -10795,7 +10793,7 @@ adminMediaRoutes.put("/:id", async (c) => {
|
|
|
10795
10793
|
`);
|
|
10796
10794
|
}
|
|
10797
10795
|
});
|
|
10798
|
-
adminMediaRoutes.delete("/cleanup",
|
|
10796
|
+
adminMediaRoutes.delete("/cleanup", chunkDYYAXDXI_cjs.requireRole("admin"), async (c) => {
|
|
10799
10797
|
try {
|
|
10800
10798
|
const db = c.env.DB;
|
|
10801
10799
|
const allMediaStmt = db.prepare("SELECT id, r2_key, filename FROM media WHERE deleted_at IS NULL");
|
|
@@ -11044,7 +11042,7 @@ function formatFileSize(bytes) {
|
|
|
11044
11042
|
}
|
|
11045
11043
|
|
|
11046
11044
|
// src/templates/pages/admin-plugins-list.template.ts
|
|
11047
|
-
|
|
11045
|
+
chunkEYMHWJTW_cjs.init_admin_layout_catalyst_template();
|
|
11048
11046
|
function renderPluginsListPage(data) {
|
|
11049
11047
|
const pageContent = `
|
|
11050
11048
|
<div>
|
|
@@ -11418,7 +11416,7 @@ function renderPluginsListPage(data) {
|
|
|
11418
11416
|
version: data.version,
|
|
11419
11417
|
content: pageContent
|
|
11420
11418
|
};
|
|
11421
|
-
return
|
|
11419
|
+
return chunkEYMHWJTW_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
11422
11420
|
}
|
|
11423
11421
|
function renderPluginCard(plugin) {
|
|
11424
11422
|
const statusColors = {
|
|
@@ -12068,7 +12066,7 @@ function renderPluginSettingsPage(data) {
|
|
|
12068
12066
|
user,
|
|
12069
12067
|
content: pageContent
|
|
12070
12068
|
};
|
|
12071
|
-
return
|
|
12069
|
+
return chunkEYMHWJTW_cjs.renderAdminLayout(layoutData);
|
|
12072
12070
|
}
|
|
12073
12071
|
function renderStatusBadge(status) {
|
|
12074
12072
|
const statusColors = {
|
|
@@ -12147,10 +12145,10 @@ function renderSettingsTab(plugin) {
|
|
|
12147
12145
|
`;
|
|
12148
12146
|
}
|
|
12149
12147
|
function renderSettingsFields(settings) {
|
|
12150
|
-
return Object.entries(settings).map(([key,
|
|
12148
|
+
return Object.entries(settings).map(([key, value2]) => {
|
|
12151
12149
|
const fieldId = `setting_${key}`;
|
|
12152
12150
|
const displayName = key.replace(/([A-Z])/g, " $1").replace(/^./, (str) => str.toUpperCase());
|
|
12153
|
-
if (typeof
|
|
12151
|
+
if (typeof value2 === "boolean") {
|
|
12154
12152
|
return `
|
|
12155
12153
|
<div class="flex items-center justify-between">
|
|
12156
12154
|
<div>
|
|
@@ -12158,12 +12156,12 @@ function renderSettingsFields(settings) {
|
|
|
12158
12156
|
<p class="text-xs text-gray-400">Enable or disable this feature</p>
|
|
12159
12157
|
</div>
|
|
12160
12158
|
<label class="relative inline-flex items-center cursor-pointer">
|
|
12161
|
-
<input type="checkbox" name="${fieldId}" id="${fieldId}" ${
|
|
12159
|
+
<input type="checkbox" name="${fieldId}" id="${fieldId}" ${value2 ? "checked" : ""} class="sr-only peer">
|
|
12162
12160
|
<div class="w-11 h-6 bg-gray-600 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-800 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"></div>
|
|
12163
12161
|
</label>
|
|
12164
12162
|
</div>
|
|
12165
12163
|
`;
|
|
12166
|
-
} else if (typeof
|
|
12164
|
+
} else if (typeof value2 === "number") {
|
|
12167
12165
|
return `
|
|
12168
12166
|
<div>
|
|
12169
12167
|
<label for="${fieldId}" class="block text-sm font-medium text-gray-300 mb-2">${displayName}</label>
|
|
@@ -12171,7 +12169,7 @@ function renderSettingsFields(settings) {
|
|
|
12171
12169
|
type="number"
|
|
12172
12170
|
name="${fieldId}"
|
|
12173
12171
|
id="${fieldId}"
|
|
12174
|
-
value="${
|
|
12172
|
+
value="${value2}"
|
|
12175
12173
|
class="backdrop-blur-sm bg-white/10 border border-white/20 rounded-lg px-3 py-2 text-white placeholder-gray-300 focus:border-blue-400 focus:outline-none transition-colors w-full"
|
|
12176
12174
|
>
|
|
12177
12175
|
</div>
|
|
@@ -12184,7 +12182,7 @@ function renderSettingsFields(settings) {
|
|
|
12184
12182
|
type="text"
|
|
12185
12183
|
name="${fieldId}"
|
|
12186
12184
|
id="${fieldId}"
|
|
12187
|
-
value="${
|
|
12185
|
+
value="${value2}"
|
|
12188
12186
|
class="backdrop-blur-sm bg-white/10 border border-white/20 rounded-lg px-3 py-2 text-white placeholder-gray-300 focus:border-blue-400 focus:outline-none transition-colors w-full"
|
|
12189
12187
|
>
|
|
12190
12188
|
</div>
|
|
@@ -12331,7 +12329,7 @@ function formatTimestamp(timestamp) {
|
|
|
12331
12329
|
|
|
12332
12330
|
// src/routes/admin-plugins.ts
|
|
12333
12331
|
var adminPluginRoutes = new hono.Hono();
|
|
12334
|
-
adminPluginRoutes.use("*",
|
|
12332
|
+
adminPluginRoutes.use("*", chunkDYYAXDXI_cjs.requireAuth());
|
|
12335
12333
|
adminPluginRoutes.get("/", async (c) => {
|
|
12336
12334
|
try {
|
|
12337
12335
|
const user = c.get("user");
|
|
@@ -12339,7 +12337,7 @@ adminPluginRoutes.get("/", async (c) => {
|
|
|
12339
12337
|
if (user?.role !== "admin") {
|
|
12340
12338
|
return c.text("Access denied", 403);
|
|
12341
12339
|
}
|
|
12342
|
-
const pluginService = new
|
|
12340
|
+
const pluginService = new chunkNBDPIRQS_cjs.PluginService(db);
|
|
12343
12341
|
let plugins = [];
|
|
12344
12342
|
let stats = { total: 0, active: 0, inactive: 0, errors: 0 };
|
|
12345
12343
|
try {
|
|
@@ -12389,7 +12387,7 @@ adminPluginRoutes.get("/:id", async (c) => {
|
|
|
12389
12387
|
if (user?.role !== "admin") {
|
|
12390
12388
|
return c.redirect("/admin/plugins");
|
|
12391
12389
|
}
|
|
12392
|
-
const pluginService = new
|
|
12390
|
+
const pluginService = new chunkNBDPIRQS_cjs.PluginService(db);
|
|
12393
12391
|
const plugin = await pluginService.getPlugin(pluginId);
|
|
12394
12392
|
if (!plugin) {
|
|
12395
12393
|
return c.text("Plugin not found", 404);
|
|
@@ -12443,7 +12441,7 @@ adminPluginRoutes.post("/:id/activate", async (c) => {
|
|
|
12443
12441
|
if (user?.role !== "admin") {
|
|
12444
12442
|
return c.json({ error: "Access denied" }, 403);
|
|
12445
12443
|
}
|
|
12446
|
-
const pluginService = new
|
|
12444
|
+
const pluginService = new chunkNBDPIRQS_cjs.PluginService(db);
|
|
12447
12445
|
await pluginService.activatePlugin(pluginId);
|
|
12448
12446
|
return c.json({ success: true });
|
|
12449
12447
|
} catch (error) {
|
|
@@ -12460,7 +12458,7 @@ adminPluginRoutes.post("/:id/deactivate", async (c) => {
|
|
|
12460
12458
|
if (user?.role !== "admin") {
|
|
12461
12459
|
return c.json({ error: "Access denied" }, 403);
|
|
12462
12460
|
}
|
|
12463
|
-
const pluginService = new
|
|
12461
|
+
const pluginService = new chunkNBDPIRQS_cjs.PluginService(db);
|
|
12464
12462
|
await pluginService.deactivatePlugin(pluginId);
|
|
12465
12463
|
return c.json({ success: true });
|
|
12466
12464
|
} catch (error) {
|
|
@@ -12477,7 +12475,7 @@ adminPluginRoutes.post("/install", async (c) => {
|
|
|
12477
12475
|
return c.json({ error: "Access denied" }, 403);
|
|
12478
12476
|
}
|
|
12479
12477
|
const body = await c.req.json();
|
|
12480
|
-
const pluginService = new
|
|
12478
|
+
const pluginService = new chunkNBDPIRQS_cjs.PluginService(db);
|
|
12481
12479
|
if (body.name === "faq-plugin") {
|
|
12482
12480
|
const faqPlugin = await pluginService.installPlugin({
|
|
12483
12481
|
id: "third-party-faq",
|
|
@@ -12627,7 +12625,7 @@ adminPluginRoutes.post("/:id/uninstall", async (c) => {
|
|
|
12627
12625
|
if (user?.role !== "admin") {
|
|
12628
12626
|
return c.json({ error: "Access denied" }, 403);
|
|
12629
12627
|
}
|
|
12630
|
-
const pluginService = new
|
|
12628
|
+
const pluginService = new chunkNBDPIRQS_cjs.PluginService(db);
|
|
12631
12629
|
await pluginService.uninstallPlugin(pluginId);
|
|
12632
12630
|
return c.json({ success: true });
|
|
12633
12631
|
} catch (error) {
|
|
@@ -12645,7 +12643,7 @@ adminPluginRoutes.post("/:id/settings", async (c) => {
|
|
|
12645
12643
|
return c.json({ error: "Access denied" }, 403);
|
|
12646
12644
|
}
|
|
12647
12645
|
const settings = await c.req.json();
|
|
12648
|
-
const pluginService = new
|
|
12646
|
+
const pluginService = new chunkNBDPIRQS_cjs.PluginService(db);
|
|
12649
12647
|
await pluginService.updatePluginSettings(pluginId, settings);
|
|
12650
12648
|
return c.json({ success: true });
|
|
12651
12649
|
} catch (error) {
|
|
@@ -12666,7 +12664,7 @@ function formatLastUpdated(timestamp) {
|
|
|
12666
12664
|
}
|
|
12667
12665
|
|
|
12668
12666
|
// src/templates/pages/admin-logs-list.template.ts
|
|
12669
|
-
|
|
12667
|
+
chunkEYMHWJTW_cjs.init_admin_layout_catalyst_template();
|
|
12670
12668
|
function renderLogsListPage(data) {
|
|
12671
12669
|
const { logs, pagination, filters, user } = data;
|
|
12672
12670
|
const content = `
|
|
@@ -12977,7 +12975,7 @@ function renderLogsListPage(data) {
|
|
|
12977
12975
|
user,
|
|
12978
12976
|
content
|
|
12979
12977
|
};
|
|
12980
|
-
return
|
|
12978
|
+
return chunkEYMHWJTW_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
12981
12979
|
}
|
|
12982
12980
|
function renderLogDetailsPage(data) {
|
|
12983
12981
|
const { log, user } = data;
|
|
@@ -13189,7 +13187,7 @@ function renderLogDetailsPage(data) {
|
|
|
13189
13187
|
</div>
|
|
13190
13188
|
</div>
|
|
13191
13189
|
`;
|
|
13192
|
-
return
|
|
13190
|
+
return chunkEYMHWJTW_cjs.adminLayoutV2({
|
|
13193
13191
|
title: `Log Details - ${log.id}`,
|
|
13194
13192
|
user,
|
|
13195
13193
|
content
|
|
@@ -13432,7 +13430,7 @@ function renderLogConfigPage(data) {
|
|
|
13432
13430
|
|
|
13433
13431
|
<script src="https://unpkg.com/htmx.org@1.9.6"></script>
|
|
13434
13432
|
`;
|
|
13435
|
-
return
|
|
13433
|
+
return chunkEYMHWJTW_cjs.adminLayoutV2({
|
|
13436
13434
|
title: "Log Configuration",
|
|
13437
13435
|
user,
|
|
13438
13436
|
content
|
|
@@ -13441,7 +13439,7 @@ function renderLogConfigPage(data) {
|
|
|
13441
13439
|
|
|
13442
13440
|
// src/routes/admin-logs.ts
|
|
13443
13441
|
var adminLogsRoutes = new hono.Hono();
|
|
13444
|
-
adminLogsRoutes.use("*",
|
|
13442
|
+
adminLogsRoutes.use("*", chunkDYYAXDXI_cjs.requireAuth());
|
|
13445
13443
|
adminLogsRoutes.get("/", async (c) => {
|
|
13446
13444
|
try {
|
|
13447
13445
|
const user = c.get("user");
|
|
@@ -13813,7 +13811,7 @@ adminDesignRoutes.get("/", (c) => {
|
|
|
13813
13811
|
role: user.role
|
|
13814
13812
|
} : void 0
|
|
13815
13813
|
};
|
|
13816
|
-
return c.html(
|
|
13814
|
+
return c.html(chunkEYMHWJTW_cjs.renderDesignPage(pageData));
|
|
13817
13815
|
});
|
|
13818
13816
|
var adminCheckboxRoutes = new hono.Hono();
|
|
13819
13817
|
adminCheckboxRoutes.get("/", (c) => {
|
|
@@ -13825,7 +13823,7 @@ adminCheckboxRoutes.get("/", (c) => {
|
|
|
13825
13823
|
role: user.role
|
|
13826
13824
|
} : void 0
|
|
13827
13825
|
};
|
|
13828
|
-
return c.html(
|
|
13826
|
+
return c.html(chunkEYMHWJTW_cjs.renderCheckboxPage(pageData));
|
|
13829
13827
|
});
|
|
13830
13828
|
|
|
13831
13829
|
// src/templates/pages/admin-faq-form.template.ts
|
|
@@ -13853,7 +13851,7 @@ function renderFAQForm(data) {
|
|
|
13853
13851
|
</div>
|
|
13854
13852
|
</div>
|
|
13855
13853
|
|
|
13856
|
-
${message ?
|
|
13854
|
+
${message ? chunkEYMHWJTW_cjs.renderAlert({ type: messageType || "info", message, dismissible: true }) : ""}
|
|
13857
13855
|
|
|
13858
13856
|
<!-- Form -->
|
|
13859
13857
|
<div class="backdrop-blur-xl bg-white/10 rounded-xl border border-white/20 shadow-2xl">
|
|
@@ -14066,7 +14064,7 @@ function renderFAQForm(data) {
|
|
|
14066
14064
|
user: data.user,
|
|
14067
14065
|
content: pageContent
|
|
14068
14066
|
};
|
|
14069
|
-
return
|
|
14067
|
+
return chunkEYMHWJTW_cjs.renderAdminLayout(layoutData);
|
|
14070
14068
|
}
|
|
14071
14069
|
function escapeHtml4(unsafe) {
|
|
14072
14070
|
return unsafe.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
@@ -14091,7 +14089,7 @@ adminFAQRoutes.get("/", async (c) => {
|
|
|
14091
14089
|
const offset = (currentPage - 1) * limit;
|
|
14092
14090
|
const db = c.env?.DB;
|
|
14093
14091
|
if (!db) {
|
|
14094
|
-
return c.html(
|
|
14092
|
+
return c.html(chunkEYMHWJTW_cjs.renderFAQList({
|
|
14095
14093
|
faqs: [],
|
|
14096
14094
|
totalCount: 0,
|
|
14097
14095
|
currentPage: 1,
|
|
@@ -14131,7 +14129,7 @@ adminFAQRoutes.get("/", async (c) => {
|
|
|
14131
14129
|
`;
|
|
14132
14130
|
const { results: faqs } = await db.prepare(dataQuery).bind(...params, limit, offset).all();
|
|
14133
14131
|
const totalPages = Math.ceil(totalCount / limit);
|
|
14134
|
-
return c.html(
|
|
14132
|
+
return c.html(chunkEYMHWJTW_cjs.renderFAQList({
|
|
14135
14133
|
faqs: faqs || [],
|
|
14136
14134
|
totalCount,
|
|
14137
14135
|
currentPage,
|
|
@@ -14145,7 +14143,7 @@ adminFAQRoutes.get("/", async (c) => {
|
|
|
14145
14143
|
} catch (error) {
|
|
14146
14144
|
console.error("Error fetching FAQs:", error);
|
|
14147
14145
|
const user = c.get("user");
|
|
14148
|
-
return c.html(
|
|
14146
|
+
return c.html(chunkEYMHWJTW_cjs.renderFAQList({
|
|
14149
14147
|
faqs: [],
|
|
14150
14148
|
totalCount: 0,
|
|
14151
14149
|
currentPage: 1,
|
|
@@ -14458,7 +14456,7 @@ function renderTestimonialsForm(data) {
|
|
|
14458
14456
|
</div>
|
|
14459
14457
|
</div>
|
|
14460
14458
|
|
|
14461
|
-
${message ?
|
|
14459
|
+
${message ? chunkEYMHWJTW_cjs.renderAlert({ type: messageType || "info", message, dismissible: true }) : ""}
|
|
14462
14460
|
|
|
14463
14461
|
<!-- Form -->
|
|
14464
14462
|
<div class="backdrop-blur-xl bg-white/10 rounded-xl border border-white/20 shadow-2xl">
|
|
@@ -14687,7 +14685,7 @@ function renderTestimonialsForm(data) {
|
|
|
14687
14685
|
user: data.user,
|
|
14688
14686
|
content: pageContent
|
|
14689
14687
|
};
|
|
14690
|
-
return
|
|
14688
|
+
return chunkEYMHWJTW_cjs.renderAdminLayout(layoutData);
|
|
14691
14689
|
}
|
|
14692
14690
|
function escapeHtml5(unsafe) {
|
|
14693
14691
|
return unsafe.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
@@ -14713,7 +14711,7 @@ adminTestimonialsRoutes.get("/", async (c) => {
|
|
|
14713
14711
|
const offset = (currentPage - 1) * limit;
|
|
14714
14712
|
const db = c.env?.DB;
|
|
14715
14713
|
if (!db) {
|
|
14716
|
-
return c.html(
|
|
14714
|
+
return c.html(chunkEYMHWJTW_cjs.renderTestimonialsList({
|
|
14717
14715
|
testimonials: [],
|
|
14718
14716
|
totalCount: 0,
|
|
14719
14717
|
currentPage: 1,
|
|
@@ -14753,7 +14751,7 @@ adminTestimonialsRoutes.get("/", async (c) => {
|
|
|
14753
14751
|
`;
|
|
14754
14752
|
const { results: testimonials } = await db.prepare(dataQuery).bind(...params, limit, offset).all();
|
|
14755
14753
|
const totalPages = Math.ceil(totalCount / limit);
|
|
14756
|
-
return c.html(
|
|
14754
|
+
return c.html(chunkEYMHWJTW_cjs.renderTestimonialsList({
|
|
14757
14755
|
testimonials: testimonials || [],
|
|
14758
14756
|
totalCount,
|
|
14759
14757
|
currentPage,
|
|
@@ -14767,7 +14765,7 @@ adminTestimonialsRoutes.get("/", async (c) => {
|
|
|
14767
14765
|
} catch (error) {
|
|
14768
14766
|
console.error("Error fetching testimonials:", error);
|
|
14769
14767
|
const user = c.get("user");
|
|
14770
|
-
return c.html(
|
|
14768
|
+
return c.html(chunkEYMHWJTW_cjs.renderTestimonialsList({
|
|
14771
14769
|
testimonials: [],
|
|
14772
14770
|
totalCount: 0,
|
|
14773
14771
|
currentPage: 1,
|
|
@@ -15086,7 +15084,7 @@ function renderCodeExamplesForm(data) {
|
|
|
15086
15084
|
</div>
|
|
15087
15085
|
</div>
|
|
15088
15086
|
|
|
15089
|
-
${message ?
|
|
15087
|
+
${message ? chunkEYMHWJTW_cjs.renderAlert({ type: messageType || "info", message, dismissible: true }) : ""}
|
|
15090
15088
|
|
|
15091
15089
|
<!-- Form -->
|
|
15092
15090
|
<div class="backdrop-blur-xl bg-white/10 rounded-xl border border-white/20 shadow-2xl">
|
|
@@ -15356,7 +15354,7 @@ function renderCodeExamplesForm(data) {
|
|
|
15356
15354
|
user: data.user,
|
|
15357
15355
|
content: pageContent
|
|
15358
15356
|
};
|
|
15359
|
-
return
|
|
15357
|
+
return chunkEYMHWJTW_cjs.renderAdminLayout(layoutData);
|
|
15360
15358
|
}
|
|
15361
15359
|
function escapeHtml6(unsafe) {
|
|
15362
15360
|
return unsafe.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
@@ -15383,7 +15381,7 @@ adminCodeExamplesRoutes.get("/", async (c) => {
|
|
|
15383
15381
|
const offset = (currentPage - 1) * limit;
|
|
15384
15382
|
const db = c.env?.DB;
|
|
15385
15383
|
if (!db) {
|
|
15386
|
-
return c.html(
|
|
15384
|
+
return c.html(chunkEYMHWJTW_cjs.renderCodeExamplesList({
|
|
15387
15385
|
codeExamples: [],
|
|
15388
15386
|
totalCount: 0,
|
|
15389
15387
|
currentPage: 1,
|
|
@@ -15423,7 +15421,7 @@ adminCodeExamplesRoutes.get("/", async (c) => {
|
|
|
15423
15421
|
`;
|
|
15424
15422
|
const { results: codeExamples } = await db.prepare(dataQuery).bind(...params, limit, offset).all();
|
|
15425
15423
|
const totalPages = Math.ceil(totalCount / limit);
|
|
15426
|
-
return c.html(
|
|
15424
|
+
return c.html(chunkEYMHWJTW_cjs.renderCodeExamplesList({
|
|
15427
15425
|
codeExamples: codeExamples || [],
|
|
15428
15426
|
totalCount,
|
|
15429
15427
|
currentPage,
|
|
@@ -15437,7 +15435,7 @@ adminCodeExamplesRoutes.get("/", async (c) => {
|
|
|
15437
15435
|
} catch (error) {
|
|
15438
15436
|
console.error("Error fetching code examples:", error);
|
|
15439
15437
|
const user = c.get("user");
|
|
15440
|
-
return c.html(
|
|
15438
|
+
return c.html(chunkEYMHWJTW_cjs.renderCodeExamplesList({
|
|
15441
15439
|
codeExamples: [],
|
|
15442
15440
|
totalCount: 0,
|
|
15443
15441
|
currentPage: 1,
|
|
@@ -15826,7 +15824,7 @@ function renderDashboardPage(data) {
|
|
|
15826
15824
|
version: data.version,
|
|
15827
15825
|
content: pageContent
|
|
15828
15826
|
};
|
|
15829
|
-
return
|
|
15827
|
+
return chunkEYMHWJTW_cjs.renderAdminLayout(layoutData);
|
|
15830
15828
|
}
|
|
15831
15829
|
function renderStatsCards(stats) {
|
|
15832
15830
|
const cards = [
|
|
@@ -16374,9 +16372,9 @@ function renderStorageUsage(databaseSizeBytes, mediaSizeBytes) {
|
|
|
16374
16372
|
}
|
|
16375
16373
|
|
|
16376
16374
|
// src/routes/admin-dashboard.ts
|
|
16377
|
-
var VERSION =
|
|
16375
|
+
var VERSION = chunkTMIRVVQ7_cjs.getCoreVersion();
|
|
16378
16376
|
var router = new hono.Hono();
|
|
16379
|
-
router.use("*",
|
|
16377
|
+
router.use("*", chunkDYYAXDXI_cjs.requireAuth());
|
|
16380
16378
|
router.get("/", async (c) => {
|
|
16381
16379
|
const user = c.get("user");
|
|
16382
16380
|
try {
|
|
@@ -16601,7 +16599,7 @@ router.get("/system-status", async (c) => {
|
|
|
16601
16599
|
});
|
|
16602
16600
|
|
|
16603
16601
|
// src/templates/pages/admin-collections-list.template.ts
|
|
16604
|
-
|
|
16602
|
+
chunkEYMHWJTW_cjs.init_admin_layout_catalyst_template();
|
|
16605
16603
|
|
|
16606
16604
|
// src/templates/components/table.template.ts
|
|
16607
16605
|
function renderTable2(data) {
|
|
@@ -16692,8 +16690,8 @@ function renderTable2(data) {
|
|
|
16692
16690
|
</td>
|
|
16693
16691
|
` : ""}
|
|
16694
16692
|
${data.columns.map((column, colIndex) => {
|
|
16695
|
-
const
|
|
16696
|
-
const displayValue = column.render ? column.render(
|
|
16693
|
+
const value2 = row[column.key];
|
|
16694
|
+
const displayValue = column.render ? column.render(value2, row) : value2;
|
|
16697
16695
|
const stopPropagation = column.key === "actions" ? 'onclick="event.stopPropagation()"' : "";
|
|
16698
16696
|
const isFirst = colIndex === 0 && !data.selectable;
|
|
16699
16697
|
const isLast = colIndex === data.columns.length - 1;
|
|
@@ -16830,7 +16828,7 @@ function renderCollectionsListPage(data) {
|
|
|
16830
16828
|
label: "Name",
|
|
16831
16829
|
sortable: true,
|
|
16832
16830
|
sortType: "string",
|
|
16833
|
-
render: (
|
|
16831
|
+
render: (_value, collection) => `
|
|
16834
16832
|
<div class="flex items-center gap-2 ml-2">
|
|
16835
16833
|
<span class="inline-flex items-center rounded-md bg-cyan-50 dark:bg-cyan-500/10 px-2.5 py-1 text-sm font-medium text-cyan-700 dark:text-cyan-300 ring-1 ring-inset ring-cyan-700/10 dark:ring-cyan-400/20">
|
|
16836
16834
|
${collection.name}
|
|
@@ -16857,14 +16855,14 @@ function renderCollectionsListPage(data) {
|
|
|
16857
16855
|
label: "Description",
|
|
16858
16856
|
sortable: true,
|
|
16859
16857
|
sortType: "string",
|
|
16860
|
-
render: (
|
|
16858
|
+
render: (_value, collection) => collection.description || '<span class="text-zinc-500 dark:text-zinc-400">-</span>'
|
|
16861
16859
|
},
|
|
16862
16860
|
{
|
|
16863
16861
|
key: "field_count",
|
|
16864
16862
|
label: "Fields",
|
|
16865
16863
|
sortable: true,
|
|
16866
16864
|
sortType: "number",
|
|
16867
|
-
render: (
|
|
16865
|
+
render: (_value, collection) => {
|
|
16868
16866
|
const count = collection.field_count || 0;
|
|
16869
16867
|
return `
|
|
16870
16868
|
<div class="flex items-center">
|
|
@@ -16880,7 +16878,7 @@ function renderCollectionsListPage(data) {
|
|
|
16880
16878
|
label: "Source",
|
|
16881
16879
|
sortable: true,
|
|
16882
16880
|
sortType: "string",
|
|
16883
|
-
render: (
|
|
16881
|
+
render: (_value, collection) => {
|
|
16884
16882
|
if (collection.managed) {
|
|
16885
16883
|
return `
|
|
16886
16884
|
<div class="flex items-center gap-1.5">
|
|
@@ -16914,7 +16912,7 @@ function renderCollectionsListPage(data) {
|
|
|
16914
16912
|
key: "actions",
|
|
16915
16913
|
label: "Content",
|
|
16916
16914
|
sortable: false,
|
|
16917
|
-
render: (
|
|
16915
|
+
render: (_value, collection) => {
|
|
16918
16916
|
if (!collection || !collection.id) return '<span class="text-zinc-500 dark:text-zinc-400">-</span>';
|
|
16919
16917
|
return `
|
|
16920
16918
|
<div class="flex items-center space-x-2">
|
|
@@ -17075,11 +17073,11 @@ function renderCollectionsListPage(data) {
|
|
|
17075
17073
|
version: data.version,
|
|
17076
17074
|
content: pageContent
|
|
17077
17075
|
};
|
|
17078
|
-
return
|
|
17076
|
+
return chunkEYMHWJTW_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
17079
17077
|
}
|
|
17080
17078
|
|
|
17081
17079
|
// src/templates/pages/admin-collections-form.template.ts
|
|
17082
|
-
|
|
17080
|
+
chunkEYMHWJTW_cjs.init_admin_layout_catalyst_template();
|
|
17083
17081
|
function renderCollectionFormPage(data) {
|
|
17084
17082
|
const isEdit = data.isEdit || !!data.id;
|
|
17085
17083
|
const title = isEdit ? "Edit Collection" : "Create New Collection";
|
|
@@ -17308,8 +17306,56 @@ function renderCollectionFormPage(data) {
|
|
|
17308
17306
|
}
|
|
17309
17307
|
</style>
|
|
17310
17308
|
|
|
17311
|
-
${
|
|
17312
|
-
|
|
17309
|
+
${chunkEYMHWJTW_cjs.renderForm(formData)}
|
|
17310
|
+
|
|
17311
|
+
${isEdit && data.managed ? `
|
|
17312
|
+
<!-- Read-Only Fields Display for Managed Collections -->
|
|
17313
|
+
<div class="mt-8 pt-8 border-t border-zinc-950/5 dark:border-white/10">
|
|
17314
|
+
<div class="mb-6">
|
|
17315
|
+
<h3 class="text-base/7 font-semibold text-zinc-950 dark:text-white">Collection Fields</h3>
|
|
17316
|
+
<p class="text-sm/6 text-zinc-500 dark:text-zinc-400 mt-1">Fields defined in the configuration file (read-only)</p>
|
|
17317
|
+
</div>
|
|
17318
|
+
|
|
17319
|
+
<!-- Fields List (Read-Only) -->
|
|
17320
|
+
<div class="space-y-3">
|
|
17321
|
+
${(data.fields || []).map((field) => `
|
|
17322
|
+
<div class="bg-zinc-50 dark:bg-zinc-800/50 rounded-lg border border-zinc-950/5 dark:border-white/10 p-4">
|
|
17323
|
+
<div class="flex items-center justify-between">
|
|
17324
|
+
<div class="flex items-center gap-x-4">
|
|
17325
|
+
<div>
|
|
17326
|
+
<div class="flex items-center gap-x-2">
|
|
17327
|
+
<span class="text-sm/6 font-medium text-zinc-950 dark:text-white">${field.field_label}</span>
|
|
17328
|
+
<span class="inline-flex items-center rounded-md px-2 py-1 text-xs font-medium bg-cyan-500/10 dark:bg-cyan-400/10 text-cyan-700 dark:text-cyan-300 ring-1 ring-inset ring-cyan-500/20 dark:ring-cyan-400/20">
|
|
17329
|
+
${field.field_type}
|
|
17330
|
+
</span>
|
|
17331
|
+
${field.is_required ? `
|
|
17332
|
+
<span class="inline-flex items-center rounded-md px-2 py-1 text-xs font-medium bg-rose-500/10 dark:bg-rose-400/10 text-rose-700 dark:text-rose-300 ring-1 ring-inset ring-rose-500/20 dark:ring-rose-400/20">
|
|
17333
|
+
Required
|
|
17334
|
+
</span>
|
|
17335
|
+
` : ""}
|
|
17336
|
+
</div>
|
|
17337
|
+
<div class="text-xs text-zinc-500 dark:text-zinc-400 mt-1">
|
|
17338
|
+
<code class="px-1.5 py-0.5 rounded bg-zinc-100 dark:bg-zinc-800 font-mono">${field.field_name}</code>
|
|
17339
|
+
</div>
|
|
17340
|
+
</div>
|
|
17341
|
+
</div>
|
|
17342
|
+
</div>
|
|
17343
|
+
</div>
|
|
17344
|
+
`).join("")}
|
|
17345
|
+
|
|
17346
|
+
${(data.fields || []).length === 0 ? `
|
|
17347
|
+
<div class="text-center py-12 text-zinc-500 dark:text-zinc-400">
|
|
17348
|
+
<svg class="mx-auto h-12 w-12 text-zinc-400 dark:text-zinc-500" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="1.5">
|
|
17349
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"/>
|
|
17350
|
+
</svg>
|
|
17351
|
+
<p class="mt-4 text-base/7 font-semibold text-zinc-950 dark:text-white">No fields defined</p>
|
|
17352
|
+
<p class="mt-2 text-sm/6">Add fields to your collection configuration file to see them here.</p>
|
|
17353
|
+
</div>
|
|
17354
|
+
` : ""}
|
|
17355
|
+
</div>
|
|
17356
|
+
</div>
|
|
17357
|
+
` : ""}
|
|
17358
|
+
|
|
17313
17359
|
${isEdit && !data.managed ? `
|
|
17314
17360
|
<!-- Fields Management Section -->
|
|
17315
17361
|
<div class="mt-8 pt-8 border-t border-zinc-950/5 dark:border-white/10">
|
|
@@ -17852,12 +17898,12 @@ function renderCollectionFormPage(data) {
|
|
|
17852
17898
|
version: data.version,
|
|
17853
17899
|
content: pageContent
|
|
17854
17900
|
};
|
|
17855
|
-
return
|
|
17901
|
+
return chunkEYMHWJTW_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
17856
17902
|
}
|
|
17857
17903
|
|
|
17858
17904
|
// src/routes/admin-collections.ts
|
|
17859
17905
|
var adminCollectionsRoutes = new hono.Hono();
|
|
17860
|
-
adminCollectionsRoutes.use("*",
|
|
17906
|
+
adminCollectionsRoutes.use("*", chunkDYYAXDXI_cjs.requireAuth());
|
|
17861
17907
|
adminCollectionsRoutes.get("/", async (c) => {
|
|
17862
17908
|
try {
|
|
17863
17909
|
const user = c.get("user");
|
|
@@ -17868,7 +17914,7 @@ adminCollectionsRoutes.get("/", async (c) => {
|
|
|
17868
17914
|
let results;
|
|
17869
17915
|
if (search) {
|
|
17870
17916
|
stmt = db.prepare(`
|
|
17871
|
-
SELECT id, name, display_name, description, created_at, managed
|
|
17917
|
+
SELECT id, name, display_name, description, created_at, managed, schema
|
|
17872
17918
|
FROM collections
|
|
17873
17919
|
WHERE is_active = 1
|
|
17874
17920
|
AND (name LIKE ? OR display_name LIKE ? OR description LIKE ?)
|
|
@@ -17878,7 +17924,7 @@ adminCollectionsRoutes.get("/", async (c) => {
|
|
|
17878
17924
|
const queryResults = await stmt.bind(searchParam, searchParam, searchParam).all();
|
|
17879
17925
|
results = queryResults.results;
|
|
17880
17926
|
} else {
|
|
17881
|
-
stmt = db.prepare("SELECT id, name, display_name, description, created_at, managed FROM collections WHERE is_active = 1 ORDER BY created_at DESC");
|
|
17927
|
+
stmt = db.prepare("SELECT id, name, display_name, description, created_at, managed, schema FROM collections WHERE is_active = 1 ORDER BY created_at DESC");
|
|
17882
17928
|
const queryResults = await stmt.all();
|
|
17883
17929
|
results = queryResults.results;
|
|
17884
17930
|
}
|
|
@@ -17886,6 +17932,19 @@ adminCollectionsRoutes.get("/", async (c) => {
|
|
|
17886
17932
|
const { results: fieldCountResults } = await fieldCountStmt.all();
|
|
17887
17933
|
const fieldCounts = new Map((fieldCountResults || []).map((row) => [String(row.collection_id), Number(row.count)]));
|
|
17888
17934
|
const collections = (results || []).filter((row) => row && row.id).map((row) => {
|
|
17935
|
+
let fieldCount = 0;
|
|
17936
|
+
if (row.schema) {
|
|
17937
|
+
try {
|
|
17938
|
+
const schema = typeof row.schema === "string" ? JSON.parse(row.schema) : row.schema;
|
|
17939
|
+
if (schema && schema.properties) {
|
|
17940
|
+
fieldCount = Object.keys(schema.properties).length;
|
|
17941
|
+
}
|
|
17942
|
+
} catch (e) {
|
|
17943
|
+
fieldCount = fieldCounts.get(String(row.id)) || 0;
|
|
17944
|
+
}
|
|
17945
|
+
} else {
|
|
17946
|
+
fieldCount = fieldCounts.get(String(row.id)) || 0;
|
|
17947
|
+
}
|
|
17889
17948
|
return {
|
|
17890
17949
|
id: String(row.id || ""),
|
|
17891
17950
|
name: String(row.name || ""),
|
|
@@ -17893,7 +17952,7 @@ adminCollectionsRoutes.get("/", async (c) => {
|
|
|
17893
17952
|
description: row.description ? String(row.description) : void 0,
|
|
17894
17953
|
created_at: Number(row.created_at || 0),
|
|
17895
17954
|
formattedDate: row.created_at ? new Date(Number(row.created_at)).toLocaleDateString() : "Unknown",
|
|
17896
|
-
field_count:
|
|
17955
|
+
field_count: fieldCount,
|
|
17897
17956
|
managed: row.managed === 1
|
|
17898
17957
|
};
|
|
17899
17958
|
});
|
|
@@ -18067,22 +18126,45 @@ adminCollectionsRoutes.get("/:id", async (c) => {
|
|
|
18067
18126
|
};
|
|
18068
18127
|
return c.html(renderCollectionFormPage(formData2));
|
|
18069
18128
|
}
|
|
18070
|
-
|
|
18071
|
-
|
|
18072
|
-
|
|
18073
|
-
|
|
18074
|
-
|
|
18075
|
-
|
|
18076
|
-
|
|
18077
|
-
|
|
18078
|
-
|
|
18079
|
-
|
|
18080
|
-
|
|
18081
|
-
|
|
18082
|
-
|
|
18083
|
-
|
|
18084
|
-
|
|
18085
|
-
|
|
18129
|
+
let fields = [];
|
|
18130
|
+
if (collection.schema) {
|
|
18131
|
+
try {
|
|
18132
|
+
const schema = typeof collection.schema === "string" ? JSON.parse(collection.schema) : collection.schema;
|
|
18133
|
+
if (schema && schema.properties) {
|
|
18134
|
+
let fieldOrder = 0;
|
|
18135
|
+
fields = Object.entries(schema.properties).map(([fieldName, fieldConfig]) => ({
|
|
18136
|
+
id: `schema-${fieldName}`,
|
|
18137
|
+
field_name: fieldName,
|
|
18138
|
+
field_type: fieldConfig.type || "string",
|
|
18139
|
+
field_label: fieldConfig.title || fieldName,
|
|
18140
|
+
field_options: fieldConfig,
|
|
18141
|
+
field_order: fieldOrder++,
|
|
18142
|
+
is_required: fieldConfig.required === true || schema.required && schema.required.includes(fieldName),
|
|
18143
|
+
is_searchable: false
|
|
18144
|
+
}));
|
|
18145
|
+
}
|
|
18146
|
+
} catch (e) {
|
|
18147
|
+
console.error("Error parsing collection schema:", e);
|
|
18148
|
+
}
|
|
18149
|
+
}
|
|
18150
|
+
if (fields.length === 0) {
|
|
18151
|
+
const fieldsStmt = db.prepare(`
|
|
18152
|
+
SELECT * FROM content_fields
|
|
18153
|
+
WHERE collection_id = ?
|
|
18154
|
+
ORDER BY field_order ASC
|
|
18155
|
+
`);
|
|
18156
|
+
const { results: fieldsResults } = await fieldsStmt.bind(id).all();
|
|
18157
|
+
fields = (fieldsResults || []).map((row) => ({
|
|
18158
|
+
id: row.id,
|
|
18159
|
+
field_name: row.field_name,
|
|
18160
|
+
field_type: row.field_type,
|
|
18161
|
+
field_label: row.field_label,
|
|
18162
|
+
field_options: row.field_options ? JSON.parse(row.field_options) : {},
|
|
18163
|
+
field_order: row.field_order,
|
|
18164
|
+
is_required: row.is_required === 1,
|
|
18165
|
+
is_searchable: row.is_searchable === 1
|
|
18166
|
+
}));
|
|
18167
|
+
}
|
|
18086
18168
|
const formData = {
|
|
18087
18169
|
id: collection.id,
|
|
18088
18170
|
name: collection.name,
|
|
@@ -18289,7 +18371,7 @@ adminCollectionsRoutes.post("/:collectionId/fields/reorder", async (c) => {
|
|
|
18289
18371
|
});
|
|
18290
18372
|
|
|
18291
18373
|
// src/templates/pages/admin-settings.template.ts
|
|
18292
|
-
|
|
18374
|
+
chunkEYMHWJTW_cjs.init_admin_layout_catalyst_template();
|
|
18293
18375
|
function renderSettingsPage(data) {
|
|
18294
18376
|
const activeTab = data.activeTab || "general";
|
|
18295
18377
|
const pageContent = `
|
|
@@ -18720,7 +18802,7 @@ function renderSettingsPage(data) {
|
|
|
18720
18802
|
version: data.version,
|
|
18721
18803
|
content: pageContent
|
|
18722
18804
|
};
|
|
18723
|
-
return
|
|
18805
|
+
return chunkEYMHWJTW_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
18724
18806
|
}
|
|
18725
18807
|
function renderTabButton(tabId, label, iconPath, activeTab) {
|
|
18726
18808
|
const isActive = activeTab === tabId;
|
|
@@ -19737,7 +19819,7 @@ function renderDatabaseToolsSettings(settings) {
|
|
|
19737
19819
|
|
|
19738
19820
|
// src/routes/admin-settings.ts
|
|
19739
19821
|
var adminSettingsRoutes = new hono.Hono();
|
|
19740
|
-
adminSettingsRoutes.use("*",
|
|
19822
|
+
adminSettingsRoutes.use("*", chunkDYYAXDXI_cjs.requireAuth());
|
|
19741
19823
|
function getMockSettings(user) {
|
|
19742
19824
|
return {
|
|
19743
19825
|
general: {
|
|
@@ -19905,7 +19987,7 @@ adminSettingsRoutes.get("/database-tools", (c) => {
|
|
|
19905
19987
|
adminSettingsRoutes.get("/api/migrations/status", async (c) => {
|
|
19906
19988
|
try {
|
|
19907
19989
|
const db = c.env.DB;
|
|
19908
|
-
const migrationService = new
|
|
19990
|
+
const migrationService = new chunkNBDPIRQS_cjs.MigrationService(db);
|
|
19909
19991
|
const status = await migrationService.getMigrationStatus();
|
|
19910
19992
|
return c.json({
|
|
19911
19993
|
success: true,
|
|
@@ -19929,7 +20011,7 @@ adminSettingsRoutes.post("/api/migrations/run", async (c) => {
|
|
|
19929
20011
|
}, 403);
|
|
19930
20012
|
}
|
|
19931
20013
|
const db = c.env.DB;
|
|
19932
|
-
const migrationService = new
|
|
20014
|
+
const migrationService = new chunkNBDPIRQS_cjs.MigrationService(db);
|
|
19933
20015
|
const result = await migrationService.runPendingMigrations();
|
|
19934
20016
|
return c.json({
|
|
19935
20017
|
success: result.success,
|
|
@@ -19947,7 +20029,7 @@ adminSettingsRoutes.post("/api/migrations/run", async (c) => {
|
|
|
19947
20029
|
adminSettingsRoutes.get("/api/migrations/validate", async (c) => {
|
|
19948
20030
|
try {
|
|
19949
20031
|
const db = c.env.DB;
|
|
19950
|
-
const migrationService = new
|
|
20032
|
+
const migrationService = new chunkNBDPIRQS_cjs.MigrationService(db);
|
|
19951
20033
|
const validation = await migrationService.validateSchema();
|
|
19952
20034
|
return c.json({
|
|
19953
20035
|
success: true,
|
|
@@ -20191,5 +20273,5 @@ exports.api_system_default = api_system_default;
|
|
|
20191
20273
|
exports.auth_default = auth_default;
|
|
20192
20274
|
exports.router = router;
|
|
20193
20275
|
exports.userRoutes = userRoutes;
|
|
20194
|
-
//# sourceMappingURL=chunk-
|
|
20195
|
-
//# sourceMappingURL=chunk-
|
|
20276
|
+
//# sourceMappingURL=chunk-4I25AGUR.cjs.map
|
|
20277
|
+
//# sourceMappingURL=chunk-4I25AGUR.cjs.map
|