@sonicjs-cms/core 2.3.9 → 2.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-AUU4H5MP.js → chunk-2NTBZ2Y7.js} +4 -4
- package/dist/{chunk-AUU4H5MP.js.map → chunk-2NTBZ2Y7.js.map} +1 -1
- package/dist/{chunk-Q52ZQFMB.js → chunk-3YNNVSMC.js} +21 -34
- package/dist/chunk-3YNNVSMC.js.map +1 -0
- package/dist/{chunk-YLFQXTTX.cjs → chunk-5NCBFP37.cjs} +7 -7
- package/dist/{chunk-YLFQXTTX.cjs.map → chunk-5NCBFP37.cjs.map} +1 -1
- package/dist/{chunk-ES3BRZQJ.cjs → chunk-7FOAMNTI.cjs} +29 -42
- package/dist/chunk-7FOAMNTI.cjs.map +1 -0
- package/dist/{chunk-T7HDJE2H.cjs → chunk-ARLXQU2S.cjs} +292 -208
- package/dist/chunk-ARLXQU2S.cjs.map +1 -0
- package/dist/{chunk-5RKQB2JG.js → chunk-DN45O5XV.js} +8 -6
- package/dist/chunk-DN45O5XV.js.map +1 -0
- package/dist/{chunk-QNWYQZ55.js → chunk-F56JKQTA.js} +3 -3
- package/dist/{chunk-QNWYQZ55.js.map → chunk-F56JKQTA.js.map} +1 -1
- package/dist/{chunk-HNHKS2XF.js → chunk-FHCN7KR2.js} +11 -7
- package/dist/chunk-FHCN7KR2.js.map +1 -0
- package/dist/{chunk-NAYD76QF.cjs → chunk-ILZ3DP4I.cjs} +15 -6
- package/dist/chunk-ILZ3DP4I.cjs.map +1 -0
- package/dist/{chunk-YU6QFFI4.cjs → chunk-MF7DWI5P.cjs} +8 -6
- package/dist/chunk-MF7DWI5P.cjs.map +1 -0
- package/dist/{chunk-7KCDFDRI.cjs → chunk-P3XDZL6Q.cjs} +3 -4
- package/dist/chunk-P3XDZL6Q.cjs.map +1 -0
- package/dist/{chunk-I3M6I2FY.js → chunk-RP66TPEJ.js} +110 -26
- package/dist/chunk-RP66TPEJ.js.map +1 -0
- package/dist/{chunk-7CXL5K7N.js → chunk-SGAG6FD3.js} +15 -6
- package/dist/chunk-SGAG6FD3.js.map +1 -0
- package/dist/{chunk-624OTQ55.js → chunk-VMEBHBYY.js} +34 -2
- package/dist/chunk-VMEBHBYY.js.map +1 -0
- package/dist/{chunk-N3EHA3AX.cjs → chunk-W2IAEG4W.cjs} +11 -7
- package/dist/chunk-W2IAEG4W.cjs.map +1 -0
- package/dist/{chunk-O446Q45G.cjs → chunk-W4CE7XME.cjs} +34 -2
- package/dist/chunk-W4CE7XME.cjs.map +1 -0
- package/dist/{chunk-RRKXFGIO.js → chunk-X7ZAEI5S.js} +3 -4
- package/dist/chunk-X7ZAEI5S.js.map +1 -0
- package/dist/{chunk-ZMSYKV62.cjs → chunk-XR6XACXJ.cjs} +5 -5
- package/dist/{chunk-ZMSYKV62.cjs.map → chunk-XR6XACXJ.cjs.map} +1 -1
- package/dist/index.cjs +145 -145
- package/dist/index.js +14 -14
- package/dist/middleware.cjs +24 -24
- package/dist/middleware.js +3 -3
- package/dist/migrations-43GTELB5.js +4 -0
- package/dist/{migrations-ALSBVBV5.js.map → migrations-43GTELB5.js.map} +1 -1
- package/dist/migrations-ZAYXZXON.cjs +13 -0
- package/dist/{migrations-RMI7TLPG.cjs.map → migrations-ZAYXZXON.cjs.map} +1 -1
- package/dist/routes.cjs +28 -28
- package/dist/routes.js +8 -8
- package/dist/services.cjs +29 -29
- package/dist/services.d.cts +3 -4
- package/dist/services.d.ts +3 -4
- package/dist/services.js +4 -4
- package/dist/{telemetry-BFBIjBxK.d.cts → telemetry-UiD1i9GS.d.cts} +0 -1
- package/dist/{telemetry-BFBIjBxK.d.ts → telemetry-UiD1i9GS.d.ts} +0 -1
- package/dist/templates.cjs +17 -17
- package/dist/templates.js +2 -2
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils.cjs +20 -20
- package/dist/utils.d.cts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +2 -2
- package/migrations/025_add_easymde_plugin.sql +25 -0
- package/package.json +9 -5
- package/dist/chunk-5RKQB2JG.js.map +0 -1
- package/dist/chunk-624OTQ55.js.map +0 -1
- package/dist/chunk-7CXL5K7N.js.map +0 -1
- package/dist/chunk-7KCDFDRI.cjs.map +0 -1
- package/dist/chunk-ES3BRZQJ.cjs.map +0 -1
- package/dist/chunk-HNHKS2XF.js.map +0 -1
- package/dist/chunk-I3M6I2FY.js.map +0 -1
- package/dist/chunk-N3EHA3AX.cjs.map +0 -1
- package/dist/chunk-NAYD76QF.cjs.map +0 -1
- package/dist/chunk-O446Q45G.cjs.map +0 -1
- package/dist/chunk-Q52ZQFMB.js.map +0 -1
- package/dist/chunk-RRKXFGIO.js.map +0 -1
- package/dist/chunk-T7HDJE2H.cjs.map +0 -1
- package/dist/chunk-YU6QFFI4.cjs.map +0 -1
- package/dist/migrations-ALSBVBV5.js +0 -4
- package/dist/migrations-RMI7TLPG.cjs +0 -13
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
3
|
+
var chunk7FOAMNTI_cjs = require('./chunk-7FOAMNTI.cjs');
|
|
4
|
+
var chunk5NCBFP37_cjs = require('./chunk-5NCBFP37.cjs');
|
|
5
|
+
var chunkILZ3DP4I_cjs = require('./chunk-ILZ3DP4I.cjs');
|
|
6
|
+
var chunkW4CE7XME_cjs = require('./chunk-W4CE7XME.cjs');
|
|
7
|
+
var chunkMF7DWI5P_cjs = require('./chunk-MF7DWI5P.cjs');
|
|
8
|
+
var chunkW2IAEG4W_cjs = require('./chunk-W2IAEG4W.cjs');
|
|
9
9
|
var chunkRCQ2HIQD_cjs = require('./chunk-RCQ2HIQD.cjs');
|
|
10
10
|
var hono = require('hono');
|
|
11
11
|
var cors = require('hono/cors');
|
|
@@ -44,7 +44,7 @@ apiContentCrudRoutes.get("/:id", async (c) => {
|
|
|
44
44
|
}, 500);
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
|
-
apiContentCrudRoutes.post("/",
|
|
47
|
+
apiContentCrudRoutes.post("/", chunk5NCBFP37_cjs.requireAuth(), async (c) => {
|
|
48
48
|
try {
|
|
49
49
|
const db = c.env.DB;
|
|
50
50
|
const user = c.get("user");
|
|
@@ -85,7 +85,7 @@ apiContentCrudRoutes.post("/", chunkYLFQXTTX_cjs.requireAuth(), async (c) => {
|
|
|
85
85
|
now,
|
|
86
86
|
now
|
|
87
87
|
).run();
|
|
88
|
-
const cache =
|
|
88
|
+
const cache = chunk7FOAMNTI_cjs.getCacheService(chunk7FOAMNTI_cjs.CACHE_CONFIGS.api);
|
|
89
89
|
await cache.invalidate(`content:list:${collectionId}:*`);
|
|
90
90
|
await cache.invalidate("content-filtered:*");
|
|
91
91
|
const getStmt = db.prepare("SELECT * FROM content WHERE id = ?");
|
|
@@ -110,7 +110,7 @@ apiContentCrudRoutes.post("/", chunkYLFQXTTX_cjs.requireAuth(), async (c) => {
|
|
|
110
110
|
}, 500);
|
|
111
111
|
}
|
|
112
112
|
});
|
|
113
|
-
apiContentCrudRoutes.put("/:id",
|
|
113
|
+
apiContentCrudRoutes.put("/:id", chunk5NCBFP37_cjs.requireAuth(), async (c) => {
|
|
114
114
|
try {
|
|
115
115
|
const id = c.req.param("id");
|
|
116
116
|
const db = c.env.DB;
|
|
@@ -148,7 +148,7 @@ apiContentCrudRoutes.put("/:id", chunkYLFQXTTX_cjs.requireAuth(), async (c) => {
|
|
|
148
148
|
WHERE id = ?
|
|
149
149
|
`);
|
|
150
150
|
await updateStmt.bind(...params).run();
|
|
151
|
-
const cache =
|
|
151
|
+
const cache = chunk7FOAMNTI_cjs.getCacheService(chunk7FOAMNTI_cjs.CACHE_CONFIGS.api);
|
|
152
152
|
await cache.delete(cache.generateKey("content", id));
|
|
153
153
|
await cache.invalidate(`content:list:${existing.collection_id}:*`);
|
|
154
154
|
await cache.invalidate("content-filtered:*");
|
|
@@ -174,7 +174,7 @@ apiContentCrudRoutes.put("/:id", chunkYLFQXTTX_cjs.requireAuth(), async (c) => {
|
|
|
174
174
|
}, 500);
|
|
175
175
|
}
|
|
176
176
|
});
|
|
177
|
-
apiContentCrudRoutes.delete("/:id",
|
|
177
|
+
apiContentCrudRoutes.delete("/:id", chunk5NCBFP37_cjs.requireAuth(), async (c) => {
|
|
178
178
|
try {
|
|
179
179
|
const id = c.req.param("id");
|
|
180
180
|
const db = c.env.DB;
|
|
@@ -185,7 +185,7 @@ apiContentCrudRoutes.delete("/:id", chunkYLFQXTTX_cjs.requireAuth(), async (c) =
|
|
|
185
185
|
}
|
|
186
186
|
const deleteStmt = db.prepare("DELETE FROM content WHERE id = ?");
|
|
187
187
|
await deleteStmt.bind(id).run();
|
|
188
|
-
const cache =
|
|
188
|
+
const cache = chunk7FOAMNTI_cjs.getCacheService(chunk7FOAMNTI_cjs.CACHE_CONFIGS.api);
|
|
189
189
|
await cache.delete(cache.generateKey("content", id));
|
|
190
190
|
await cache.invalidate(`content:list:${existing.collection_id}:*`);
|
|
191
191
|
await cache.invalidate("content-filtered:*");
|
|
@@ -210,7 +210,7 @@ apiRoutes.use("*", async (c, next) => {
|
|
|
210
210
|
c.header("X-Response-Time", `${totalTime}ms`);
|
|
211
211
|
});
|
|
212
212
|
apiRoutes.use("*", async (c, next) => {
|
|
213
|
-
const cacheEnabled = await
|
|
213
|
+
const cacheEnabled = await chunk5NCBFP37_cjs.isPluginActive(c.env.DB, "core-cache");
|
|
214
214
|
c.set("cacheEnabled", cacheEnabled);
|
|
215
215
|
await next();
|
|
216
216
|
});
|
|
@@ -258,7 +258,7 @@ apiRoutes.get("/collections", async (c) => {
|
|
|
258
258
|
try {
|
|
259
259
|
const db = c.env.DB;
|
|
260
260
|
const cacheEnabled = c.get("cacheEnabled");
|
|
261
|
-
const cache =
|
|
261
|
+
const cache = chunk7FOAMNTI_cjs.getCacheService(chunk7FOAMNTI_cjs.CACHE_CONFIGS.api);
|
|
262
262
|
const cacheKey = cache.generateKey("collections", "all");
|
|
263
263
|
if (cacheEnabled) {
|
|
264
264
|
const cacheResult = await cache.getWithSource(cacheKey);
|
|
@@ -335,12 +335,12 @@ apiRoutes.get("/content", async (c) => {
|
|
|
335
335
|
});
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
|
-
const filter =
|
|
338
|
+
const filter = chunkW2IAEG4W_cjs.QueryFilterBuilder.parseFromQuery(queryParams);
|
|
339
339
|
if (!filter.limit) {
|
|
340
340
|
filter.limit = 50;
|
|
341
341
|
}
|
|
342
342
|
filter.limit = Math.min(filter.limit, 1e3);
|
|
343
|
-
const builder3 = new
|
|
343
|
+
const builder3 = new chunkW2IAEG4W_cjs.QueryFilterBuilder();
|
|
344
344
|
const queryResult = builder3.build("content", filter);
|
|
345
345
|
if (queryResult.errors.length > 0) {
|
|
346
346
|
return c.json({
|
|
@@ -349,7 +349,7 @@ apiRoutes.get("/content", async (c) => {
|
|
|
349
349
|
}, 400);
|
|
350
350
|
}
|
|
351
351
|
const cacheEnabled = c.get("cacheEnabled");
|
|
352
|
-
const cache =
|
|
352
|
+
const cache = chunk7FOAMNTI_cjs.getCacheService(chunk7FOAMNTI_cjs.CACHE_CONFIGS.api);
|
|
353
353
|
const cacheKey = cache.generateKey("content-filtered", JSON.stringify({ filter, query: queryResult.sql }));
|
|
354
354
|
if (cacheEnabled) {
|
|
355
355
|
const cacheResult = await cache.getWithSource(cacheKey);
|
|
@@ -427,7 +427,7 @@ apiRoutes.get("/collections/:collection/content", async (c) => {
|
|
|
427
427
|
if (!collectionResult) {
|
|
428
428
|
return c.json({ error: "Collection not found" }, 404);
|
|
429
429
|
}
|
|
430
|
-
const filter =
|
|
430
|
+
const filter = chunkW2IAEG4W_cjs.QueryFilterBuilder.parseFromQuery(queryParams);
|
|
431
431
|
if (!filter.where) {
|
|
432
432
|
filter.where = { and: [] };
|
|
433
433
|
}
|
|
@@ -443,7 +443,7 @@ apiRoutes.get("/collections/:collection/content", async (c) => {
|
|
|
443
443
|
filter.limit = 50;
|
|
444
444
|
}
|
|
445
445
|
filter.limit = Math.min(filter.limit, 1e3);
|
|
446
|
-
const builder3 = new
|
|
446
|
+
const builder3 = new chunkW2IAEG4W_cjs.QueryFilterBuilder();
|
|
447
447
|
const queryResult = builder3.build("content", filter);
|
|
448
448
|
if (queryResult.errors.length > 0) {
|
|
449
449
|
return c.json({
|
|
@@ -452,7 +452,7 @@ apiRoutes.get("/collections/:collection/content", async (c) => {
|
|
|
452
452
|
}, 400);
|
|
453
453
|
}
|
|
454
454
|
const cacheEnabled = c.get("cacheEnabled");
|
|
455
|
-
const cache =
|
|
455
|
+
const cache = chunk7FOAMNTI_cjs.getCacheService(chunk7FOAMNTI_cjs.CACHE_CONFIGS.api);
|
|
456
456
|
const cacheKey = cache.generateKey("collection-content-filtered", `${collection}:${JSON.stringify({ filter, query: queryResult.sql })}`);
|
|
457
457
|
if (cacheEnabled) {
|
|
458
458
|
const cacheResult = await cache.getWithSource(cacheKey);
|
|
@@ -568,7 +568,7 @@ var fileValidationSchema = zod.z.object({
|
|
|
568
568
|
// 50MB max
|
|
569
569
|
});
|
|
570
570
|
var apiMediaRoutes = new hono.Hono();
|
|
571
|
-
apiMediaRoutes.use("*",
|
|
571
|
+
apiMediaRoutes.use("*", chunk5NCBFP37_cjs.requireAuth());
|
|
572
572
|
apiMediaRoutes.post("/upload", async (c) => {
|
|
573
573
|
try {
|
|
574
574
|
const user = c.get("user");
|
|
@@ -1312,8 +1312,8 @@ apiSystemRoutes.get("/env", (c) => {
|
|
|
1312
1312
|
});
|
|
1313
1313
|
var api_system_default = apiSystemRoutes;
|
|
1314
1314
|
var adminApiRoutes = new hono.Hono();
|
|
1315
|
-
adminApiRoutes.use("*",
|
|
1316
|
-
adminApiRoutes.use("*",
|
|
1315
|
+
adminApiRoutes.use("*", chunk5NCBFP37_cjs.requireAuth());
|
|
1316
|
+
adminApiRoutes.use("*", chunk5NCBFP37_cjs.requireRole(["admin", "editor"]));
|
|
1317
1317
|
adminApiRoutes.get("/stats", async (c) => {
|
|
1318
1318
|
try {
|
|
1319
1319
|
const db = c.env.DB;
|
|
@@ -1571,7 +1571,7 @@ adminApiRoutes.post("/collections", async (c) => {
|
|
|
1571
1571
|
}
|
|
1572
1572
|
const validatedData = validation.data;
|
|
1573
1573
|
const db = c.env.DB;
|
|
1574
|
-
const
|
|
1574
|
+
const _user = c.get("user");
|
|
1575
1575
|
const displayName = validatedData.displayName || validatedData.display_name || "";
|
|
1576
1576
|
const existingStmt = db.prepare("SELECT id FROM collections WHERE name = ?");
|
|
1577
1577
|
const existing = await existingStmt.bind(validatedData.name).first();
|
|
@@ -1722,7 +1722,7 @@ adminApiRoutes.delete("/collections/:id", async (c) => {
|
|
|
1722
1722
|
});
|
|
1723
1723
|
adminApiRoutes.get("/migrations/status", async (c) => {
|
|
1724
1724
|
try {
|
|
1725
|
-
const { MigrationService: MigrationService2 } = await import('./migrations-
|
|
1725
|
+
const { MigrationService: MigrationService2 } = await import('./migrations-ZAYXZXON.cjs');
|
|
1726
1726
|
const db = c.env.DB;
|
|
1727
1727
|
const migrationService = new MigrationService2(db);
|
|
1728
1728
|
const status = await migrationService.getMigrationStatus();
|
|
@@ -1747,7 +1747,7 @@ adminApiRoutes.post("/migrations/run", async (c) => {
|
|
|
1747
1747
|
error: "Unauthorized. Admin access required."
|
|
1748
1748
|
}, 403);
|
|
1749
1749
|
}
|
|
1750
|
-
const { MigrationService: MigrationService2 } = await import('./migrations-
|
|
1750
|
+
const { MigrationService: MigrationService2 } = await import('./migrations-ZAYXZXON.cjs');
|
|
1751
1751
|
const db = c.env.DB;
|
|
1752
1752
|
const migrationService = new MigrationService2(db);
|
|
1753
1753
|
const result = await migrationService.runPendingMigrations();
|
|
@@ -1766,7 +1766,7 @@ adminApiRoutes.post("/migrations/run", async (c) => {
|
|
|
1766
1766
|
});
|
|
1767
1767
|
adminApiRoutes.get("/migrations/validate", async (c) => {
|
|
1768
1768
|
try {
|
|
1769
|
-
const { MigrationService: MigrationService2 } = await import('./migrations-
|
|
1769
|
+
const { MigrationService: MigrationService2 } = await import('./migrations-ZAYXZXON.cjs');
|
|
1770
1770
|
const db = c.env.DB;
|
|
1771
1771
|
const migrationService = new MigrationService2(db);
|
|
1772
1772
|
const validation = await migrationService.validateSchema();
|
|
@@ -1841,8 +1841,8 @@ function renderLoginPage(data, demoLoginActive = false) {
|
|
|
1841
1841
|
<div class="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
|
|
1842
1842
|
<div class="bg-zinc-900 shadow-sm ring-1 ring-white/10 rounded-xl px-6 py-8 sm:px-10">
|
|
1843
1843
|
<!-- Alerts -->
|
|
1844
|
-
${data.error ? `<div class="mb-6">${
|
|
1845
|
-
${data.message ? `<div class="mb-6">${
|
|
1844
|
+
${data.error ? `<div class="mb-6">${chunkMF7DWI5P_cjs.renderAlert({ type: "error", message: data.error })}</div>` : ""}
|
|
1845
|
+
${data.message ? `<div class="mb-6">${chunkMF7DWI5P_cjs.renderAlert({ type: "success", message: data.message })}</div>` : ""}
|
|
1846
1846
|
|
|
1847
1847
|
<!-- Form Response (HTMX target) -->
|
|
1848
1848
|
<div id="form-response" class="mb-6"></div>
|
|
@@ -2006,7 +2006,7 @@ function renderRegisterPage(data) {
|
|
|
2006
2006
|
<div class="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
|
|
2007
2007
|
<div class="bg-zinc-900 shadow-sm ring-1 ring-white/10 rounded-xl px-6 py-8 sm:px-10">
|
|
2008
2008
|
<!-- Alerts -->
|
|
2009
|
-
${data.error ? `<div class="mb-6">${
|
|
2009
|
+
${data.error ? `<div class="mb-6">${chunkMF7DWI5P_cjs.renderAlert({ type: "error", message: data.error })}</div>` : ""}
|
|
2010
2010
|
|
|
2011
2011
|
<!-- Form -->
|
|
2012
2012
|
<form
|
|
@@ -2212,7 +2212,7 @@ authRoutes.post(
|
|
|
2212
2212
|
if (existingUser) {
|
|
2213
2213
|
return c.json({ error: "User with this email or username already exists" }, 400);
|
|
2214
2214
|
}
|
|
2215
|
-
const passwordHash = await
|
|
2215
|
+
const passwordHash = await chunk5NCBFP37_cjs.AuthManager.hashPassword(password);
|
|
2216
2216
|
const userId = crypto.randomUUID();
|
|
2217
2217
|
const now = /* @__PURE__ */ new Date();
|
|
2218
2218
|
await db.prepare(`
|
|
@@ -2232,7 +2232,7 @@ authRoutes.post(
|
|
|
2232
2232
|
now.getTime(),
|
|
2233
2233
|
now.getTime()
|
|
2234
2234
|
).run();
|
|
2235
|
-
const token = await
|
|
2235
|
+
const token = await chunk5NCBFP37_cjs.AuthManager.generateToken(userId, normalizedEmail, "viewer");
|
|
2236
2236
|
cookie.setCookie(c, "auth_token", token, {
|
|
2237
2237
|
httpOnly: true,
|
|
2238
2238
|
secure: true,
|
|
@@ -2273,7 +2273,7 @@ authRoutes.post("/login", async (c) => {
|
|
|
2273
2273
|
const { email, password } = validation.data;
|
|
2274
2274
|
const db = c.env.DB;
|
|
2275
2275
|
const normalizedEmail = email.toLowerCase();
|
|
2276
|
-
const cache =
|
|
2276
|
+
const cache = chunk7FOAMNTI_cjs.getCacheService(chunk7FOAMNTI_cjs.CACHE_CONFIGS.user);
|
|
2277
2277
|
let user = await cache.get(cache.generateKey("user", `email:${normalizedEmail}`));
|
|
2278
2278
|
if (!user) {
|
|
2279
2279
|
user = await db.prepare("SELECT * FROM users WHERE email = ? AND is_active = 1").bind(normalizedEmail).first();
|
|
@@ -2285,11 +2285,11 @@ authRoutes.post("/login", async (c) => {
|
|
|
2285
2285
|
if (!user) {
|
|
2286
2286
|
return c.json({ error: "Invalid email or password" }, 401);
|
|
2287
2287
|
}
|
|
2288
|
-
const isValidPassword = await
|
|
2288
|
+
const isValidPassword = await chunk5NCBFP37_cjs.AuthManager.verifyPassword(password, user.password_hash);
|
|
2289
2289
|
if (!isValidPassword) {
|
|
2290
2290
|
return c.json({ error: "Invalid email or password" }, 401);
|
|
2291
2291
|
}
|
|
2292
|
-
const token = await
|
|
2292
|
+
const token = await chunk5NCBFP37_cjs.AuthManager.generateToken(user.id, user.email, user.role);
|
|
2293
2293
|
cookie.setCookie(c, "auth_token", token, {
|
|
2294
2294
|
httpOnly: true,
|
|
2295
2295
|
secure: true,
|
|
@@ -2338,7 +2338,7 @@ authRoutes.get("/logout", (c) => {
|
|
|
2338
2338
|
});
|
|
2339
2339
|
return c.redirect("/auth/login?message=You have been logged out successfully");
|
|
2340
2340
|
});
|
|
2341
|
-
authRoutes.get("/me",
|
|
2341
|
+
authRoutes.get("/me", chunk5NCBFP37_cjs.requireAuth(), async (c) => {
|
|
2342
2342
|
try {
|
|
2343
2343
|
const user = c.get("user");
|
|
2344
2344
|
if (!user) {
|
|
@@ -2355,13 +2355,13 @@ authRoutes.get("/me", chunkYLFQXTTX_cjs.requireAuth(), async (c) => {
|
|
|
2355
2355
|
return c.json({ error: "Failed to get user" }, 500);
|
|
2356
2356
|
}
|
|
2357
2357
|
});
|
|
2358
|
-
authRoutes.post("/refresh",
|
|
2358
|
+
authRoutes.post("/refresh", chunk5NCBFP37_cjs.requireAuth(), async (c) => {
|
|
2359
2359
|
try {
|
|
2360
2360
|
const user = c.get("user");
|
|
2361
2361
|
if (!user) {
|
|
2362
2362
|
return c.json({ error: "Not authenticated" }, 401);
|
|
2363
2363
|
}
|
|
2364
|
-
const token = await
|
|
2364
|
+
const token = await chunk5NCBFP37_cjs.AuthManager.generateToken(user.userId, user.email, user.role);
|
|
2365
2365
|
cookie.setCookie(c, "auth_token", token, {
|
|
2366
2366
|
httpOnly: true,
|
|
2367
2367
|
secure: true,
|
|
@@ -2410,7 +2410,7 @@ authRoutes.post("/register/form", async (c) => {
|
|
|
2410
2410
|
</div>
|
|
2411
2411
|
`);
|
|
2412
2412
|
}
|
|
2413
|
-
const passwordHash = await
|
|
2413
|
+
const passwordHash = await chunk5NCBFP37_cjs.AuthManager.hashPassword(password);
|
|
2414
2414
|
const userId = crypto.randomUUID();
|
|
2415
2415
|
const now = /* @__PURE__ */ new Date();
|
|
2416
2416
|
await db.prepare(`
|
|
@@ -2430,7 +2430,7 @@ authRoutes.post("/register/form", async (c) => {
|
|
|
2430
2430
|
now.getTime(),
|
|
2431
2431
|
now.getTime()
|
|
2432
2432
|
).run();
|
|
2433
|
-
const token = await
|
|
2433
|
+
const token = await chunk5NCBFP37_cjs.AuthManager.generateToken(userId, normalizedEmail, "admin");
|
|
2434
2434
|
cookie.setCookie(c, "auth_token", token, {
|
|
2435
2435
|
httpOnly: true,
|
|
2436
2436
|
secure: false,
|
|
@@ -2481,7 +2481,7 @@ authRoutes.post("/login/form", async (c) => {
|
|
|
2481
2481
|
</div>
|
|
2482
2482
|
`);
|
|
2483
2483
|
}
|
|
2484
|
-
const isValidPassword = await
|
|
2484
|
+
const isValidPassword = await chunk5NCBFP37_cjs.AuthManager.verifyPassword(password, user.password_hash);
|
|
2485
2485
|
if (!isValidPassword) {
|
|
2486
2486
|
return c.html(html.html`
|
|
2487
2487
|
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded">
|
|
@@ -2489,7 +2489,7 @@ authRoutes.post("/login/form", async (c) => {
|
|
|
2489
2489
|
</div>
|
|
2490
2490
|
`);
|
|
2491
2491
|
}
|
|
2492
|
-
const token = await
|
|
2492
|
+
const token = await chunk5NCBFP37_cjs.AuthManager.generateToken(user.id, user.email, user.role);
|
|
2493
2493
|
cookie.setCookie(c, "auth_token", token, {
|
|
2494
2494
|
httpOnly: true,
|
|
2495
2495
|
secure: false,
|
|
@@ -2548,7 +2548,7 @@ authRoutes.post("/seed-admin", async (c) => {
|
|
|
2548
2548
|
`).run();
|
|
2549
2549
|
const existingAdmin = await db.prepare("SELECT id FROM users WHERE email = ? OR username = ?").bind("admin@sonicjs.com", "admin").first();
|
|
2550
2550
|
if (existingAdmin) {
|
|
2551
|
-
const passwordHash2 = await
|
|
2551
|
+
const passwordHash2 = await chunk5NCBFP37_cjs.AuthManager.hashPassword("sonicjs!");
|
|
2552
2552
|
await db.prepare("UPDATE users SET password_hash = ?, updated_at = ? WHERE id = ?").bind(passwordHash2, Date.now(), existingAdmin.id).run();
|
|
2553
2553
|
return c.json({
|
|
2554
2554
|
message: "Admin user already exists (password updated)",
|
|
@@ -2560,7 +2560,7 @@ authRoutes.post("/seed-admin", async (c) => {
|
|
|
2560
2560
|
}
|
|
2561
2561
|
});
|
|
2562
2562
|
}
|
|
2563
|
-
const passwordHash = await
|
|
2563
|
+
const passwordHash = await chunk5NCBFP37_cjs.AuthManager.hashPassword("sonicjs!");
|
|
2564
2564
|
const userId = "admin-user-id";
|
|
2565
2565
|
const now = Date.now();
|
|
2566
2566
|
const adminEmail = "admin@sonicjs.com".toLowerCase();
|
|
@@ -2780,7 +2780,7 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
2780
2780
|
if (existingUsername) {
|
|
2781
2781
|
return c.json({ error: "Username is already taken" }, 400);
|
|
2782
2782
|
}
|
|
2783
|
-
const passwordHash = await
|
|
2783
|
+
const passwordHash = await chunk5NCBFP37_cjs.AuthManager.hashPassword(password);
|
|
2784
2784
|
const updateStmt = db.prepare(`
|
|
2785
2785
|
UPDATE users SET
|
|
2786
2786
|
username = ?,
|
|
@@ -2799,7 +2799,7 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
2799
2799
|
Date.now(),
|
|
2800
2800
|
invitedUser.id
|
|
2801
2801
|
).run();
|
|
2802
|
-
const authToken = await
|
|
2802
|
+
const authToken = await chunk5NCBFP37_cjs.AuthManager.generateToken(invitedUser.id, invitedUser.email, invitedUser.role);
|
|
2803
2803
|
cookie.setCookie(c, "auth_token", authToken, {
|
|
2804
2804
|
httpOnly: true,
|
|
2805
2805
|
secure: true,
|
|
@@ -3029,7 +3029,7 @@ authRoutes.post("/reset-password", async (c) => {
|
|
|
3029
3029
|
if (Date.now() > user.password_reset_expires) {
|
|
3030
3030
|
return c.json({ error: "Reset token has expired" }, 400);
|
|
3031
3031
|
}
|
|
3032
|
-
const newPasswordHash = await
|
|
3032
|
+
const newPasswordHash = await chunk5NCBFP37_cjs.AuthManager.hashPassword(password);
|
|
3033
3033
|
try {
|
|
3034
3034
|
const historyStmt = db.prepare(`
|
|
3035
3035
|
INSERT INTO password_history (id, user_id, password_hash, created_at)
|
|
@@ -3287,7 +3287,7 @@ app.post("/test-cleanup/content", async (c) => {
|
|
|
3287
3287
|
var test_cleanup_default = app;
|
|
3288
3288
|
|
|
3289
3289
|
// src/templates/pages/admin-content-form.template.ts
|
|
3290
|
-
|
|
3290
|
+
chunkMF7DWI5P_cjs.init_admin_layout_catalyst_template();
|
|
3291
3291
|
|
|
3292
3292
|
// src/templates/components/dynamic-field.template.ts
|
|
3293
3293
|
function renderDynamicField(field, options = {}) {
|
|
@@ -4526,8 +4526,8 @@ function renderContentFormPage(data) {
|
|
|
4526
4526
|
<!-- Form Content -->
|
|
4527
4527
|
<div class="px-6 py-6">
|
|
4528
4528
|
<div id="form-messages">
|
|
4529
|
-
${data.error ?
|
|
4530
|
-
${data.success ?
|
|
4529
|
+
${data.error ? chunkMF7DWI5P_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
|
|
4530
|
+
${data.success ? chunkMF7DWI5P_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
|
|
4531
4531
|
</div>
|
|
4532
4532
|
|
|
4533
4533
|
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
|
@@ -4762,7 +4762,7 @@ function renderContentFormPage(data) {
|
|
|
4762
4762
|
</div>
|
|
4763
4763
|
|
|
4764
4764
|
<!-- Confirmation Dialogs -->
|
|
4765
|
-
${
|
|
4765
|
+
${chunkMF7DWI5P_cjs.renderConfirmationDialog({
|
|
4766
4766
|
id: "duplicate-content-confirm",
|
|
4767
4767
|
title: "Duplicate Content",
|
|
4768
4768
|
message: "Create a copy of this content?",
|
|
@@ -4773,7 +4773,7 @@ function renderContentFormPage(data) {
|
|
|
4773
4773
|
onConfirm: "performDuplicateContent()"
|
|
4774
4774
|
})}
|
|
4775
4775
|
|
|
4776
|
-
${
|
|
4776
|
+
${chunkMF7DWI5P_cjs.renderConfirmationDialog({
|
|
4777
4777
|
id: "delete-content-confirm",
|
|
4778
4778
|
title: "Delete Content",
|
|
4779
4779
|
message: "Are you sure you want to delete this content? This action cannot be undone.",
|
|
@@ -4784,7 +4784,7 @@ function renderContentFormPage(data) {
|
|
|
4784
4784
|
onConfirm: `performDeleteContent('${data.id}')`
|
|
4785
4785
|
})}
|
|
4786
4786
|
|
|
4787
|
-
${
|
|
4787
|
+
${chunkMF7DWI5P_cjs.getConfirmationDialogScript()}
|
|
4788
4788
|
|
|
4789
4789
|
${data.tinymceEnabled ? getTinyMCEScript(data.tinymceSettings?.apiKey) : "<!-- TinyMCE plugin not active -->"}
|
|
4790
4790
|
|
|
@@ -5089,11 +5089,11 @@ function renderContentFormPage(data) {
|
|
|
5089
5089
|
content: pageContent,
|
|
5090
5090
|
version: data.version
|
|
5091
5091
|
};
|
|
5092
|
-
return
|
|
5092
|
+
return chunkMF7DWI5P_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
5093
5093
|
}
|
|
5094
5094
|
|
|
5095
5095
|
// src/templates/pages/admin-content-list.template.ts
|
|
5096
|
-
|
|
5096
|
+
chunkMF7DWI5P_cjs.init_admin_layout_catalyst_template();
|
|
5097
5097
|
function renderContentListPage(data) {
|
|
5098
5098
|
const urlParams = new URLSearchParams();
|
|
5099
5099
|
if (data.modelName && data.modelName !== "all") urlParams.set("model", data.modelName);
|
|
@@ -5498,8 +5498,8 @@ function renderContentListPage(data) {
|
|
|
5498
5498
|
|
|
5499
5499
|
<!-- Content List -->
|
|
5500
5500
|
<div id="content-list">
|
|
5501
|
-
${
|
|
5502
|
-
${
|
|
5501
|
+
${chunkMF7DWI5P_cjs.renderTable(tableData)}
|
|
5502
|
+
${chunkMF7DWI5P_cjs.renderPagination(paginationData)}
|
|
5503
5503
|
</div>
|
|
5504
5504
|
|
|
5505
5505
|
</div>
|
|
@@ -5708,7 +5708,7 @@ function renderContentListPage(data) {
|
|
|
5708
5708
|
</script>
|
|
5709
5709
|
|
|
5710
5710
|
<!-- Confirmation Dialog for Bulk Actions -->
|
|
5711
|
-
${
|
|
5711
|
+
${chunkMF7DWI5P_cjs.renderConfirmationDialog({
|
|
5712
5712
|
id: "bulk-action-confirm",
|
|
5713
5713
|
title: "Confirm Bulk Action",
|
|
5714
5714
|
message: "Are you sure you want to perform this action? This operation will affect multiple items.",
|
|
@@ -5720,7 +5720,7 @@ function renderContentListPage(data) {
|
|
|
5720
5720
|
})}
|
|
5721
5721
|
|
|
5722
5722
|
<!-- Confirmation Dialog Script -->
|
|
5723
|
-
${
|
|
5723
|
+
${chunkMF7DWI5P_cjs.getConfirmationDialogScript()}
|
|
5724
5724
|
`;
|
|
5725
5725
|
const layoutData = {
|
|
5726
5726
|
title: "Content Management",
|
|
@@ -5730,7 +5730,7 @@ function renderContentListPage(data) {
|
|
|
5730
5730
|
version: data.version,
|
|
5731
5731
|
content: pageContent
|
|
5732
5732
|
};
|
|
5733
|
-
return
|
|
5733
|
+
return chunkMF7DWI5P_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
5734
5734
|
}
|
|
5735
5735
|
|
|
5736
5736
|
// src/templates/components/version-history.template.ts
|
|
@@ -5924,9 +5924,9 @@ async function isPluginActive2(db, pluginId) {
|
|
|
5924
5924
|
|
|
5925
5925
|
// src/routes/admin-content.ts
|
|
5926
5926
|
var adminContentRoutes = new hono.Hono();
|
|
5927
|
-
adminContentRoutes.use("*",
|
|
5927
|
+
adminContentRoutes.use("*", chunk5NCBFP37_cjs.requireAuth());
|
|
5928
5928
|
async function getCollectionFields(db, collectionId) {
|
|
5929
|
-
const cache =
|
|
5929
|
+
const cache = chunk7FOAMNTI_cjs.getCacheService(chunk7FOAMNTI_cjs.CACHE_CONFIGS.collection);
|
|
5930
5930
|
return cache.getOrSet(
|
|
5931
5931
|
cache.generateKey("fields", collectionId),
|
|
5932
5932
|
async () => {
|
|
@@ -5981,7 +5981,7 @@ async function getCollectionFields(db, collectionId) {
|
|
|
5981
5981
|
);
|
|
5982
5982
|
}
|
|
5983
5983
|
async function getCollection(db, collectionId) {
|
|
5984
|
-
const cache =
|
|
5984
|
+
const cache = chunk7FOAMNTI_cjs.getCacheService(chunk7FOAMNTI_cjs.CACHE_CONFIGS.collection);
|
|
5985
5985
|
return cache.getOrSet(
|
|
5986
5986
|
cache.generateKey("collection", collectionId),
|
|
5987
5987
|
async () => {
|
|
@@ -6021,8 +6021,8 @@ adminContentRoutes.get("/", async (c) => {
|
|
|
6021
6021
|
conditions.push("c.status != 'deleted'");
|
|
6022
6022
|
}
|
|
6023
6023
|
if (search) {
|
|
6024
|
-
conditions.push("(c.title LIKE ? OR c.slug LIKE ?)");
|
|
6025
|
-
params.push(`%${search}%`, `%${search}%`);
|
|
6024
|
+
conditions.push("(c.title LIKE ? OR c.slug LIKE ? OR c.data LIKE ?)");
|
|
6025
|
+
params.push(`%${search}%`, `%${search}%`, `%${search}%`);
|
|
6026
6026
|
}
|
|
6027
6027
|
if (modelName !== "all") {
|
|
6028
6028
|
conditions.push("col.name = ?");
|
|
@@ -6206,21 +6206,21 @@ adminContentRoutes.get("/new", async (c) => {
|
|
|
6206
6206
|
const tinymceEnabled = await isPluginActive2(db, "tinymce-plugin");
|
|
6207
6207
|
let tinymceSettings;
|
|
6208
6208
|
if (tinymceEnabled) {
|
|
6209
|
-
const pluginService = new
|
|
6209
|
+
const pluginService = new chunkILZ3DP4I_cjs.PluginService(db);
|
|
6210
6210
|
const tinymcePlugin2 = await pluginService.getPlugin("tinymce-plugin");
|
|
6211
6211
|
tinymceSettings = tinymcePlugin2?.settings;
|
|
6212
6212
|
}
|
|
6213
6213
|
const quillEnabled = await isPluginActive2(db, "quill-editor");
|
|
6214
6214
|
let quillSettings;
|
|
6215
6215
|
if (quillEnabled) {
|
|
6216
|
-
const pluginService = new
|
|
6216
|
+
const pluginService = new chunkILZ3DP4I_cjs.PluginService(db);
|
|
6217
6217
|
const quillPlugin = await pluginService.getPlugin("quill-editor");
|
|
6218
6218
|
quillSettings = quillPlugin?.settings;
|
|
6219
6219
|
}
|
|
6220
6220
|
const mdxeditorEnabled = await isPluginActive2(db, "easy-mdx");
|
|
6221
6221
|
let mdxeditorSettings;
|
|
6222
6222
|
if (mdxeditorEnabled) {
|
|
6223
|
-
const pluginService = new
|
|
6223
|
+
const pluginService = new chunkILZ3DP4I_cjs.PluginService(db);
|
|
6224
6224
|
const mdxeditorPlugin = await pluginService.getPlugin("easy-mdx");
|
|
6225
6225
|
mdxeditorSettings = mdxeditorPlugin?.settings;
|
|
6226
6226
|
}
|
|
@@ -6270,7 +6270,7 @@ adminContentRoutes.get("/:id/edit", async (c) => {
|
|
|
6270
6270
|
const db = c.env.DB;
|
|
6271
6271
|
const url = new URL(c.req.url);
|
|
6272
6272
|
const referrerParams = url.searchParams.get("ref") || "";
|
|
6273
|
-
const cache =
|
|
6273
|
+
const cache = chunk7FOAMNTI_cjs.getCacheService(chunk7FOAMNTI_cjs.CACHE_CONFIGS.content);
|
|
6274
6274
|
const content = await cache.getOrSet(
|
|
6275
6275
|
cache.generateKey("content", id),
|
|
6276
6276
|
async () => {
|
|
@@ -6311,21 +6311,21 @@ adminContentRoutes.get("/:id/edit", async (c) => {
|
|
|
6311
6311
|
const tinymceEnabled = await isPluginActive2(db, "tinymce-plugin");
|
|
6312
6312
|
let tinymceSettings;
|
|
6313
6313
|
if (tinymceEnabled) {
|
|
6314
|
-
const pluginService = new
|
|
6314
|
+
const pluginService = new chunkILZ3DP4I_cjs.PluginService(db);
|
|
6315
6315
|
const tinymcePlugin2 = await pluginService.getPlugin("tinymce-plugin");
|
|
6316
6316
|
tinymceSettings = tinymcePlugin2?.settings;
|
|
6317
6317
|
}
|
|
6318
6318
|
const quillEnabled = await isPluginActive2(db, "quill-editor");
|
|
6319
6319
|
let quillSettings;
|
|
6320
6320
|
if (quillEnabled) {
|
|
6321
|
-
const pluginService = new
|
|
6321
|
+
const pluginService = new chunkILZ3DP4I_cjs.PluginService(db);
|
|
6322
6322
|
const quillPlugin = await pluginService.getPlugin("quill-editor");
|
|
6323
6323
|
quillSettings = quillPlugin?.settings;
|
|
6324
6324
|
}
|
|
6325
6325
|
const mdxeditorEnabled = await isPluginActive2(db, "easy-mdx");
|
|
6326
6326
|
let mdxeditorSettings;
|
|
6327
6327
|
if (mdxeditorEnabled) {
|
|
6328
|
-
const pluginService = new
|
|
6328
|
+
const pluginService = new chunkILZ3DP4I_cjs.PluginService(db);
|
|
6329
6329
|
const mdxeditorPlugin = await pluginService.getPlugin("easy-mdx");
|
|
6330
6330
|
mdxeditorSettings = mdxeditorPlugin?.settings;
|
|
6331
6331
|
}
|
|
@@ -6457,10 +6457,9 @@ adminContentRoutes.post("/", async (c) => {
|
|
|
6457
6457
|
const insertStmt = db.prepare(`
|
|
6458
6458
|
INSERT INTO content (
|
|
6459
6459
|
id, collection_id, slug, title, data, status,
|
|
6460
|
-
|
|
6461
|
-
meta_title, meta_description, author_id, created_by, created_at, updated_at
|
|
6460
|
+
author_id, created_at, updated_at
|
|
6462
6461
|
)
|
|
6463
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?,
|
|
6462
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
6464
6463
|
`);
|
|
6465
6464
|
await insertStmt.bind(
|
|
6466
6465
|
contentId,
|
|
@@ -6469,16 +6468,11 @@ adminContentRoutes.post("/", async (c) => {
|
|
|
6469
6468
|
data.title || "Untitled",
|
|
6470
6469
|
JSON.stringify(data),
|
|
6471
6470
|
status,
|
|
6472
|
-
scheduledPublishAt ? new Date(scheduledPublishAt).getTime() : null,
|
|
6473
|
-
scheduledUnpublishAt ? new Date(scheduledUnpublishAt).getTime() : null,
|
|
6474
|
-
data.meta_title || null,
|
|
6475
|
-
data.meta_description || null,
|
|
6476
|
-
user?.userId || "unknown",
|
|
6477
6471
|
user?.userId || "unknown",
|
|
6478
6472
|
now,
|
|
6479
6473
|
now
|
|
6480
6474
|
).run();
|
|
6481
|
-
const cache =
|
|
6475
|
+
const cache = chunk7FOAMNTI_cjs.getCacheService(chunk7FOAMNTI_cjs.CACHE_CONFIGS.content);
|
|
6482
6476
|
await cache.invalidate(`content:list:${collectionId}:*`);
|
|
6483
6477
|
const versionStmt = db.prepare(`
|
|
6484
6478
|
INSERT INTO content_versions (id, content_id, version, data, author_id, created_at)
|
|
@@ -6626,7 +6620,7 @@ adminContentRoutes.put("/:id", async (c) => {
|
|
|
6626
6620
|
now,
|
|
6627
6621
|
id
|
|
6628
6622
|
).run();
|
|
6629
|
-
const cache =
|
|
6623
|
+
const cache = chunk7FOAMNTI_cjs.getCacheService(chunk7FOAMNTI_cjs.CACHE_CONFIGS.content);
|
|
6630
6624
|
await cache.delete(cache.generateKey("content", id));
|
|
6631
6625
|
await cache.invalidate(`content:list:${existingContent.collection_id}:*`);
|
|
6632
6626
|
const existingData = JSON.parse(existingContent.data || "{}");
|
|
@@ -6919,7 +6913,7 @@ adminContentRoutes.post("/bulk-action", async (c) => {
|
|
|
6919
6913
|
} else {
|
|
6920
6914
|
return c.json({ success: false, error: "Invalid action" });
|
|
6921
6915
|
}
|
|
6922
|
-
const cache =
|
|
6916
|
+
const cache = chunk7FOAMNTI_cjs.getCacheService(chunk7FOAMNTI_cjs.CACHE_CONFIGS.content);
|
|
6923
6917
|
for (const contentId of ids) {
|
|
6924
6918
|
await cache.delete(cache.generateKey("content", contentId));
|
|
6925
6919
|
}
|
|
@@ -6947,7 +6941,7 @@ adminContentRoutes.delete("/:id", async (c) => {
|
|
|
6947
6941
|
WHERE id = ?
|
|
6948
6942
|
`);
|
|
6949
6943
|
await deleteStmt.bind(now, id).run();
|
|
6950
|
-
const cache =
|
|
6944
|
+
const cache = chunk7FOAMNTI_cjs.getCacheService(chunk7FOAMNTI_cjs.CACHE_CONFIGS.content);
|
|
6951
6945
|
await cache.delete(cache.generateKey("content", id));
|
|
6952
6946
|
await cache.invalidate("content:list:*");
|
|
6953
6947
|
return c.html(`
|
|
@@ -7139,7 +7133,7 @@ ${JSON.stringify(data, null, 2)}
|
|
|
7139
7133
|
var admin_content_default = adminContentRoutes;
|
|
7140
7134
|
|
|
7141
7135
|
// src/templates/pages/admin-profile.template.ts
|
|
7142
|
-
|
|
7136
|
+
chunkMF7DWI5P_cjs.init_admin_layout_catalyst_template();
|
|
7143
7137
|
function renderAvatarImage(avatarUrl, firstName, lastName) {
|
|
7144
7138
|
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">
|
|
7145
7139
|
${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>`}
|
|
@@ -7159,8 +7153,8 @@ function renderProfilePage(data) {
|
|
|
7159
7153
|
</div>
|
|
7160
7154
|
|
|
7161
7155
|
<!-- Alert Messages -->
|
|
7162
|
-
${data.error ?
|
|
7163
|
-
${data.success ?
|
|
7156
|
+
${data.error ? chunkMF7DWI5P_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
|
|
7157
|
+
${data.success ? chunkMF7DWI5P_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
|
|
7164
7158
|
|
|
7165
7159
|
<!-- Profile Form -->
|
|
7166
7160
|
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
|
|
@@ -7547,7 +7541,7 @@ function renderProfilePage(data) {
|
|
|
7547
7541
|
version: data.version,
|
|
7548
7542
|
content: pageContent
|
|
7549
7543
|
};
|
|
7550
|
-
return
|
|
7544
|
+
return chunkMF7DWI5P_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
7551
7545
|
}
|
|
7552
7546
|
|
|
7553
7547
|
// src/templates/components/alert.template.ts
|
|
@@ -7830,7 +7824,7 @@ function renderActivityLogsPage(data) {
|
|
|
7830
7824
|
user: data.user,
|
|
7831
7825
|
content: pageContent
|
|
7832
7826
|
};
|
|
7833
|
-
return
|
|
7827
|
+
return chunkMF7DWI5P_cjs.renderAdminLayout(layoutData);
|
|
7834
7828
|
}
|
|
7835
7829
|
function getActionBadgeClass(action) {
|
|
7836
7830
|
if (action.includes("login") || action.includes("logout")) {
|
|
@@ -7850,7 +7844,7 @@ function formatAction(action) {
|
|
|
7850
7844
|
}
|
|
7851
7845
|
|
|
7852
7846
|
// src/templates/pages/admin-user-edit.template.ts
|
|
7853
|
-
|
|
7847
|
+
chunkMF7DWI5P_cjs.init_admin_layout_catalyst_template();
|
|
7854
7848
|
|
|
7855
7849
|
// src/templates/components/confirmation-dialog.template.ts
|
|
7856
7850
|
function renderConfirmationDialog2(options) {
|
|
@@ -7971,8 +7965,8 @@ function renderUserEditPage(data) {
|
|
|
7971
7965
|
|
|
7972
7966
|
<!-- Alert Messages -->
|
|
7973
7967
|
<div id="form-messages">
|
|
7974
|
-
${data.error ?
|
|
7975
|
-
${data.success ?
|
|
7968
|
+
${data.error ? chunkMF7DWI5P_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
|
|
7969
|
+
${data.success ? chunkMF7DWI5P_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
|
|
7976
7970
|
</div>
|
|
7977
7971
|
|
|
7978
7972
|
<!-- User Edit Form -->
|
|
@@ -7991,7 +7985,7 @@ function renderUserEditPage(data) {
|
|
|
7991
7985
|
<input
|
|
7992
7986
|
type="text"
|
|
7993
7987
|
name="first_name"
|
|
7994
|
-
value="${
|
|
7988
|
+
value="${chunkW2IAEG4W_cjs.escapeHtml(data.userToEdit.firstName || "")}"
|
|
7995
7989
|
required
|
|
7996
7990
|
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"
|
|
7997
7991
|
/>
|
|
@@ -8002,7 +7996,7 @@ function renderUserEditPage(data) {
|
|
|
8002
7996
|
<input
|
|
8003
7997
|
type="text"
|
|
8004
7998
|
name="last_name"
|
|
8005
|
-
value="${
|
|
7999
|
+
value="${chunkW2IAEG4W_cjs.escapeHtml(data.userToEdit.lastName || "")}"
|
|
8006
8000
|
required
|
|
8007
8001
|
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"
|
|
8008
8002
|
/>
|
|
@@ -8013,7 +8007,7 @@ function renderUserEditPage(data) {
|
|
|
8013
8007
|
<input
|
|
8014
8008
|
type="text"
|
|
8015
8009
|
name="username"
|
|
8016
|
-
value="${
|
|
8010
|
+
value="${chunkW2IAEG4W_cjs.escapeHtml(data.userToEdit.username || "")}"
|
|
8017
8011
|
required
|
|
8018
8012
|
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"
|
|
8019
8013
|
/>
|
|
@@ -8024,7 +8018,7 @@ function renderUserEditPage(data) {
|
|
|
8024
8018
|
<input
|
|
8025
8019
|
type="email"
|
|
8026
8020
|
name="email"
|
|
8027
|
-
value="${
|
|
8021
|
+
value="${chunkW2IAEG4W_cjs.escapeHtml(data.userToEdit.email || "")}"
|
|
8028
8022
|
required
|
|
8029
8023
|
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"
|
|
8030
8024
|
/>
|
|
@@ -8035,7 +8029,7 @@ function renderUserEditPage(data) {
|
|
|
8035
8029
|
<input
|
|
8036
8030
|
type="tel"
|
|
8037
8031
|
name="phone"
|
|
8038
|
-
value="${
|
|
8032
|
+
value="${chunkW2IAEG4W_cjs.escapeHtml(data.userToEdit.phone || "")}"
|
|
8039
8033
|
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"
|
|
8040
8034
|
/>
|
|
8041
8035
|
</div>
|
|
@@ -8049,7 +8043,7 @@ function renderUserEditPage(data) {
|
|
|
8049
8043
|
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"
|
|
8050
8044
|
>
|
|
8051
8045
|
${data.roles.map((role) => `
|
|
8052
|
-
<option value="${
|
|
8046
|
+
<option value="${chunkW2IAEG4W_cjs.escapeHtml(role.value)}" ${data.userToEdit.role === role.value ? "selected" : ""}>${chunkW2IAEG4W_cjs.escapeHtml(role.label)}</option>
|
|
8053
8047
|
`).join("")}
|
|
8054
8048
|
</select>
|
|
8055
8049
|
<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">
|
|
@@ -8065,7 +8059,7 @@ function renderUserEditPage(data) {
|
|
|
8065
8059
|
name="bio"
|
|
8066
8060
|
rows="3"
|
|
8067
8061
|
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"
|
|
8068
|
-
>${
|
|
8062
|
+
>${chunkW2IAEG4W_cjs.escapeHtml(data.userToEdit.bio || "")}</textarea>
|
|
8069
8063
|
</div>
|
|
8070
8064
|
</div>
|
|
8071
8065
|
|
|
@@ -8265,11 +8259,11 @@ function renderUserEditPage(data) {
|
|
|
8265
8259
|
user: data.user,
|
|
8266
8260
|
content: pageContent
|
|
8267
8261
|
};
|
|
8268
|
-
return
|
|
8262
|
+
return chunkMF7DWI5P_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
8269
8263
|
}
|
|
8270
8264
|
|
|
8271
8265
|
// src/templates/pages/admin-user-new.template.ts
|
|
8272
|
-
|
|
8266
|
+
chunkMF7DWI5P_cjs.init_admin_layout_catalyst_template();
|
|
8273
8267
|
function renderUserNewPage(data) {
|
|
8274
8268
|
const pageContent = `
|
|
8275
8269
|
<div>
|
|
@@ -8308,8 +8302,8 @@ function renderUserNewPage(data) {
|
|
|
8308
8302
|
|
|
8309
8303
|
<!-- Alert Messages -->
|
|
8310
8304
|
<div id="form-messages">
|
|
8311
|
-
${data.error ?
|
|
8312
|
-
${data.success ?
|
|
8305
|
+
${data.error ? chunkMF7DWI5P_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
|
|
8306
|
+
${data.success ? chunkMF7DWI5P_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
|
|
8313
8307
|
</div>
|
|
8314
8308
|
|
|
8315
8309
|
<!-- User New Form -->
|
|
@@ -8553,11 +8547,11 @@ function renderUserNewPage(data) {
|
|
|
8553
8547
|
user: data.user,
|
|
8554
8548
|
content: pageContent
|
|
8555
8549
|
};
|
|
8556
|
-
return
|
|
8550
|
+
return chunkMF7DWI5P_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
8557
8551
|
}
|
|
8558
8552
|
|
|
8559
8553
|
// src/templates/pages/admin-users-list.template.ts
|
|
8560
|
-
|
|
8554
|
+
chunkMF7DWI5P_cjs.init_admin_layout_catalyst_template();
|
|
8561
8555
|
function renderUsersListPage(data) {
|
|
8562
8556
|
const columns = [
|
|
8563
8557
|
{
|
|
@@ -8708,8 +8702,8 @@ function renderUsersListPage(data) {
|
|
|
8708
8702
|
</div>
|
|
8709
8703
|
|
|
8710
8704
|
<!-- Alert Messages -->
|
|
8711
|
-
${data.error ?
|
|
8712
|
-
${data.success ?
|
|
8705
|
+
${data.error ? chunkMF7DWI5P_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
|
|
8706
|
+
${data.success ? chunkMF7DWI5P_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
|
|
8713
8707
|
|
|
8714
8708
|
<!-- Stats -->
|
|
8715
8709
|
<div class="mb-6">
|
|
@@ -8886,10 +8880,10 @@ function renderUsersListPage(data) {
|
|
|
8886
8880
|
</div>
|
|
8887
8881
|
|
|
8888
8882
|
<!-- Users Table -->
|
|
8889
|
-
${
|
|
8883
|
+
${chunkMF7DWI5P_cjs.renderTable(tableData)}
|
|
8890
8884
|
|
|
8891
8885
|
<!-- Pagination -->
|
|
8892
|
-
${data.pagination ?
|
|
8886
|
+
${data.pagination ? chunkMF7DWI5P_cjs.renderPagination(data.pagination) : ""}
|
|
8893
8887
|
</div>
|
|
8894
8888
|
|
|
8895
8889
|
<script>
|
|
@@ -8960,12 +8954,12 @@ function renderUsersListPage(data) {
|
|
|
8960
8954
|
version: data.version,
|
|
8961
8955
|
content: pageContent
|
|
8962
8956
|
};
|
|
8963
|
-
return
|
|
8957
|
+
return chunkMF7DWI5P_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
8964
8958
|
}
|
|
8965
8959
|
|
|
8966
8960
|
// src/routes/admin-users.ts
|
|
8967
8961
|
var userRoutes = new hono.Hono();
|
|
8968
|
-
userRoutes.use("*",
|
|
8962
|
+
userRoutes.use("*", chunk5NCBFP37_cjs.requireAuth());
|
|
8969
8963
|
userRoutes.get("/", (c) => {
|
|
8970
8964
|
return c.redirect("/admin/dashboard");
|
|
8971
8965
|
});
|
|
@@ -9064,12 +9058,12 @@ userRoutes.put("/profile", async (c) => {
|
|
|
9064
9058
|
const db = c.env.DB;
|
|
9065
9059
|
try {
|
|
9066
9060
|
const formData = await c.req.formData();
|
|
9067
|
-
const firstName =
|
|
9068
|
-
const lastName =
|
|
9069
|
-
const username =
|
|
9061
|
+
const firstName = chunkW2IAEG4W_cjs.sanitizeInput(formData.get("first_name")?.toString());
|
|
9062
|
+
const lastName = chunkW2IAEG4W_cjs.sanitizeInput(formData.get("last_name")?.toString());
|
|
9063
|
+
const username = chunkW2IAEG4W_cjs.sanitizeInput(formData.get("username")?.toString());
|
|
9070
9064
|
const email = formData.get("email")?.toString()?.trim().toLowerCase() || "";
|
|
9071
|
-
const phone =
|
|
9072
|
-
const bio =
|
|
9065
|
+
const phone = chunkW2IAEG4W_cjs.sanitizeInput(formData.get("phone")?.toString()) || null;
|
|
9066
|
+
const bio = chunkW2IAEG4W_cjs.sanitizeInput(formData.get("bio")?.toString()) || null;
|
|
9073
9067
|
const timezone = formData.get("timezone")?.toString() || "UTC";
|
|
9074
9068
|
const language = formData.get("language")?.toString() || "en";
|
|
9075
9069
|
const emailNotifications = formData.get("email_notifications") === "1";
|
|
@@ -9120,7 +9114,7 @@ userRoutes.put("/profile", async (c) => {
|
|
|
9120
9114
|
Date.now(),
|
|
9121
9115
|
user.userId
|
|
9122
9116
|
).run();
|
|
9123
|
-
await
|
|
9117
|
+
await chunk5NCBFP37_cjs.logActivity(
|
|
9124
9118
|
db,
|
|
9125
9119
|
user.userId,
|
|
9126
9120
|
"profile.update",
|
|
@@ -9183,7 +9177,7 @@ userRoutes.post("/profile/avatar", async (c) => {
|
|
|
9183
9177
|
SELECT first_name, last_name FROM users WHERE id = ?
|
|
9184
9178
|
`);
|
|
9185
9179
|
const userData = await userStmt.bind(user.userId).first();
|
|
9186
|
-
await
|
|
9180
|
+
await chunk5NCBFP37_cjs.logActivity(
|
|
9187
9181
|
db,
|
|
9188
9182
|
user.userId,
|
|
9189
9183
|
"profile.avatar_update",
|
|
@@ -9254,7 +9248,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
9254
9248
|
dismissible: true
|
|
9255
9249
|
}));
|
|
9256
9250
|
}
|
|
9257
|
-
const validPassword = await
|
|
9251
|
+
const validPassword = await chunk5NCBFP37_cjs.AuthManager.verifyPassword(currentPassword, userData.password_hash);
|
|
9258
9252
|
if (!validPassword) {
|
|
9259
9253
|
return c.html(renderAlert2({
|
|
9260
9254
|
type: "error",
|
|
@@ -9262,7 +9256,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
9262
9256
|
dismissible: true
|
|
9263
9257
|
}));
|
|
9264
9258
|
}
|
|
9265
|
-
const newPasswordHash = await
|
|
9259
|
+
const newPasswordHash = await chunk5NCBFP37_cjs.AuthManager.hashPassword(newPassword);
|
|
9266
9260
|
const historyStmt = db.prepare(`
|
|
9267
9261
|
INSERT INTO password_history (id, user_id, password_hash, created_at)
|
|
9268
9262
|
VALUES (?, ?, ?, ?)
|
|
@@ -9278,7 +9272,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
9278
9272
|
WHERE id = ?
|
|
9279
9273
|
`);
|
|
9280
9274
|
await updateStmt.bind(newPasswordHash, Date.now(), user.userId).run();
|
|
9281
|
-
await
|
|
9275
|
+
await chunk5NCBFP37_cjs.logActivity(
|
|
9282
9276
|
db,
|
|
9283
9277
|
user.userId,
|
|
9284
9278
|
"profile.password_change",
|
|
@@ -9345,7 +9339,7 @@ userRoutes.get("/users", async (c) => {
|
|
|
9345
9339
|
`);
|
|
9346
9340
|
const countResult = await countStmt.bind(...params).first();
|
|
9347
9341
|
const totalUsers = countResult?.total || 0;
|
|
9348
|
-
await
|
|
9342
|
+
await chunk5NCBFP37_cjs.logActivity(
|
|
9349
9343
|
db,
|
|
9350
9344
|
user.userId,
|
|
9351
9345
|
"users.list_view",
|
|
@@ -9447,12 +9441,12 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
9447
9441
|
const user = c.get("user");
|
|
9448
9442
|
try {
|
|
9449
9443
|
const formData = await c.req.formData();
|
|
9450
|
-
const firstName =
|
|
9451
|
-
const lastName =
|
|
9452
|
-
const username =
|
|
9444
|
+
const firstName = chunkW2IAEG4W_cjs.sanitizeInput(formData.get("first_name")?.toString());
|
|
9445
|
+
const lastName = chunkW2IAEG4W_cjs.sanitizeInput(formData.get("last_name")?.toString());
|
|
9446
|
+
const username = chunkW2IAEG4W_cjs.sanitizeInput(formData.get("username")?.toString());
|
|
9453
9447
|
const email = formData.get("email")?.toString()?.trim().toLowerCase() || "";
|
|
9454
|
-
const phone =
|
|
9455
|
-
const bio =
|
|
9448
|
+
const phone = chunkW2IAEG4W_cjs.sanitizeInput(formData.get("phone")?.toString()) || null;
|
|
9449
|
+
const bio = chunkW2IAEG4W_cjs.sanitizeInput(formData.get("bio")?.toString()) || null;
|
|
9456
9450
|
const role = formData.get("role")?.toString() || "viewer";
|
|
9457
9451
|
const password = formData.get("password")?.toString() || "";
|
|
9458
9452
|
const confirmPassword = formData.get("confirm_password")?.toString() || "";
|
|
@@ -9499,7 +9493,7 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
9499
9493
|
dismissible: true
|
|
9500
9494
|
}));
|
|
9501
9495
|
}
|
|
9502
|
-
const passwordHash = await
|
|
9496
|
+
const passwordHash = await chunk5NCBFP37_cjs.AuthManager.hashPassword(password);
|
|
9503
9497
|
const userId = crypto.randomUUID();
|
|
9504
9498
|
const createStmt = db.prepare(`
|
|
9505
9499
|
INSERT INTO users (
|
|
@@ -9522,7 +9516,7 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
9522
9516
|
Date.now(),
|
|
9523
9517
|
Date.now()
|
|
9524
9518
|
).run();
|
|
9525
|
-
await
|
|
9519
|
+
await chunk5NCBFP37_cjs.logActivity(
|
|
9526
9520
|
db,
|
|
9527
9521
|
user.userId,
|
|
9528
9522
|
"user!.create",
|
|
@@ -9560,7 +9554,7 @@ userRoutes.get("/users/:id", async (c) => {
|
|
|
9560
9554
|
if (!userRecord) {
|
|
9561
9555
|
return c.json({ error: "User not found" }, 404);
|
|
9562
9556
|
}
|
|
9563
|
-
await
|
|
9557
|
+
await chunk5NCBFP37_cjs.logActivity(
|
|
9564
9558
|
db,
|
|
9565
9559
|
user.userId,
|
|
9566
9560
|
"user!.view",
|
|
@@ -9653,12 +9647,12 @@ userRoutes.put("/users/:id", async (c) => {
|
|
|
9653
9647
|
const userId = c.req.param("id");
|
|
9654
9648
|
try {
|
|
9655
9649
|
const formData = await c.req.formData();
|
|
9656
|
-
const firstName =
|
|
9657
|
-
const lastName =
|
|
9658
|
-
const username =
|
|
9650
|
+
const firstName = chunkW2IAEG4W_cjs.sanitizeInput(formData.get("first_name")?.toString());
|
|
9651
|
+
const lastName = chunkW2IAEG4W_cjs.sanitizeInput(formData.get("last_name")?.toString());
|
|
9652
|
+
const username = chunkW2IAEG4W_cjs.sanitizeInput(formData.get("username")?.toString());
|
|
9659
9653
|
const email = formData.get("email")?.toString()?.trim().toLowerCase() || "";
|
|
9660
|
-
const phone =
|
|
9661
|
-
const bio =
|
|
9654
|
+
const phone = chunkW2IAEG4W_cjs.sanitizeInput(formData.get("phone")?.toString()) || null;
|
|
9655
|
+
const bio = chunkW2IAEG4W_cjs.sanitizeInput(formData.get("bio")?.toString()) || null;
|
|
9662
9656
|
const role = formData.get("role")?.toString() || "viewer";
|
|
9663
9657
|
const isActive = formData.get("is_active") === "1";
|
|
9664
9658
|
const emailVerified = formData.get("email_verified") === "1";
|
|
@@ -9709,7 +9703,7 @@ userRoutes.put("/users/:id", async (c) => {
|
|
|
9709
9703
|
Date.now(),
|
|
9710
9704
|
userId
|
|
9711
9705
|
).run();
|
|
9712
|
-
await
|
|
9706
|
+
await chunk5NCBFP37_cjs.logActivity(
|
|
9713
9707
|
db,
|
|
9714
9708
|
user.userId,
|
|
9715
9709
|
"user!.update",
|
|
@@ -9754,7 +9748,7 @@ userRoutes.post("/users/:id/toggle", async (c) => {
|
|
|
9754
9748
|
UPDATE users SET is_active = ?, updated_at = ? WHERE id = ?
|
|
9755
9749
|
`);
|
|
9756
9750
|
await toggleStmt.bind(active ? 1 : 0, Date.now(), userId).run();
|
|
9757
|
-
await
|
|
9751
|
+
await chunk5NCBFP37_cjs.logActivity(
|
|
9758
9752
|
db,
|
|
9759
9753
|
user.userId,
|
|
9760
9754
|
active ? "user.activate" : "user.deactivate",
|
|
@@ -9795,7 +9789,7 @@ userRoutes.delete("/users/:id", async (c) => {
|
|
|
9795
9789
|
DELETE FROM users WHERE id = ?
|
|
9796
9790
|
`);
|
|
9797
9791
|
await deleteStmt.bind(userId).run();
|
|
9798
|
-
await
|
|
9792
|
+
await chunk5NCBFP37_cjs.logActivity(
|
|
9799
9793
|
db,
|
|
9800
9794
|
user.userId,
|
|
9801
9795
|
"user!.hard_delete",
|
|
@@ -9814,7 +9808,7 @@ userRoutes.delete("/users/:id", async (c) => {
|
|
|
9814
9808
|
UPDATE users SET is_active = 0, updated_at = ? WHERE id = ?
|
|
9815
9809
|
`);
|
|
9816
9810
|
await deleteStmt.bind(Date.now(), userId).run();
|
|
9817
|
-
await
|
|
9811
|
+
await chunk5NCBFP37_cjs.logActivity(
|
|
9818
9812
|
db,
|
|
9819
9813
|
user.userId,
|
|
9820
9814
|
"user!.soft_delete",
|
|
@@ -9841,8 +9835,8 @@ userRoutes.post("/invite-user", async (c) => {
|
|
|
9841
9835
|
const formData = await c.req.formData();
|
|
9842
9836
|
const email = formData.get("email")?.toString()?.trim().toLowerCase() || "";
|
|
9843
9837
|
const role = formData.get("role")?.toString()?.trim() || "viewer";
|
|
9844
|
-
const firstName =
|
|
9845
|
-
const lastName =
|
|
9838
|
+
const firstName = chunkW2IAEG4W_cjs.sanitizeInput(formData.get("first_name")?.toString());
|
|
9839
|
+
const lastName = chunkW2IAEG4W_cjs.sanitizeInput(formData.get("last_name")?.toString());
|
|
9846
9840
|
if (!email || !firstName || !lastName) {
|
|
9847
9841
|
return c.json({ error: "Email, first name, and last name are required" }, 400);
|
|
9848
9842
|
}
|
|
@@ -9880,7 +9874,7 @@ userRoutes.post("/invite-user", async (c) => {
|
|
|
9880
9874
|
Date.now(),
|
|
9881
9875
|
Date.now()
|
|
9882
9876
|
).run();
|
|
9883
|
-
await
|
|
9877
|
+
await chunk5NCBFP37_cjs.logActivity(
|
|
9884
9878
|
db,
|
|
9885
9879
|
user.userId,
|
|
9886
9880
|
"user!.invite_sent",
|
|
@@ -9937,7 +9931,7 @@ userRoutes.post("/resend-invitation/:id", async (c) => {
|
|
|
9937
9931
|
Date.now(),
|
|
9938
9932
|
userId
|
|
9939
9933
|
).run();
|
|
9940
|
-
await
|
|
9934
|
+
await chunk5NCBFP37_cjs.logActivity(
|
|
9941
9935
|
db,
|
|
9942
9936
|
user.userId,
|
|
9943
9937
|
"user!.invitation_resent",
|
|
@@ -9973,7 +9967,7 @@ userRoutes.delete("/cancel-invitation/:id", async (c) => {
|
|
|
9973
9967
|
}
|
|
9974
9968
|
const deleteStmt = db.prepare(`DELETE FROM users WHERE id = ?`);
|
|
9975
9969
|
await deleteStmt.bind(userId).run();
|
|
9976
|
-
await
|
|
9970
|
+
await chunk5NCBFP37_cjs.logActivity(
|
|
9977
9971
|
db,
|
|
9978
9972
|
user.userId,
|
|
9979
9973
|
"user!.invitation_cancelled",
|
|
@@ -10056,7 +10050,7 @@ userRoutes.get("/activity-logs", async (c) => {
|
|
|
10056
10050
|
...log,
|
|
10057
10051
|
details: log.details ? JSON.parse(log.details) : null
|
|
10058
10052
|
}));
|
|
10059
|
-
await
|
|
10053
|
+
await chunk5NCBFP37_cjs.logActivity(
|
|
10060
10054
|
db,
|
|
10061
10055
|
user.userId,
|
|
10062
10056
|
"activity.logs_viewed",
|
|
@@ -10163,7 +10157,7 @@ userRoutes.get("/activity-logs/export", async (c) => {
|
|
|
10163
10157
|
csvRows.push(row.join(","));
|
|
10164
10158
|
}
|
|
10165
10159
|
const csvContent = csvRows.join("\n");
|
|
10166
|
-
await
|
|
10160
|
+
await chunk5NCBFP37_cjs.logActivity(
|
|
10167
10161
|
db,
|
|
10168
10162
|
user.userId,
|
|
10169
10163
|
"activity.logs_exported",
|
|
@@ -10381,7 +10375,7 @@ function getFileIcon(mimeType) {
|
|
|
10381
10375
|
}
|
|
10382
10376
|
|
|
10383
10377
|
// src/templates/pages/admin-media-library.template.ts
|
|
10384
|
-
|
|
10378
|
+
chunkMF7DWI5P_cjs.init_admin_layout_catalyst_template();
|
|
10385
10379
|
function renderMediaLibraryPage(data) {
|
|
10386
10380
|
const pageContent = `
|
|
10387
10381
|
<div>
|
|
@@ -11316,7 +11310,7 @@ function renderMediaLibraryPage(data) {
|
|
|
11316
11310
|
version: data.version,
|
|
11317
11311
|
content: pageContent
|
|
11318
11312
|
};
|
|
11319
|
-
return
|
|
11313
|
+
return chunkMF7DWI5P_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
11320
11314
|
}
|
|
11321
11315
|
|
|
11322
11316
|
// src/templates/components/media-file-details.template.ts
|
|
@@ -11502,7 +11496,7 @@ var fileValidationSchema2 = zod.z.object({
|
|
|
11502
11496
|
// 50MB max
|
|
11503
11497
|
});
|
|
11504
11498
|
var adminMediaRoutes = new hono.Hono();
|
|
11505
|
-
adminMediaRoutes.use("*",
|
|
11499
|
+
adminMediaRoutes.use("*", chunk5NCBFP37_cjs.requireAuth());
|
|
11506
11500
|
adminMediaRoutes.get("/", async (c) => {
|
|
11507
11501
|
try {
|
|
11508
11502
|
const user = c.get("user");
|
|
@@ -11511,7 +11505,7 @@ adminMediaRoutes.get("/", async (c) => {
|
|
|
11511
11505
|
const type = searchParams.get("type") || "all";
|
|
11512
11506
|
const view = searchParams.get("view") || "grid";
|
|
11513
11507
|
const page = parseInt(searchParams.get("page") || "1");
|
|
11514
|
-
const
|
|
11508
|
+
const _cacheBust = searchParams.get("t");
|
|
11515
11509
|
const limit = 24;
|
|
11516
11510
|
const offset = (page - 1) * limit;
|
|
11517
11511
|
const db = c.env.DB;
|
|
@@ -12088,7 +12082,7 @@ adminMediaRoutes.put("/:id", async (c) => {
|
|
|
12088
12082
|
`);
|
|
12089
12083
|
}
|
|
12090
12084
|
});
|
|
12091
|
-
adminMediaRoutes.delete("/cleanup",
|
|
12085
|
+
adminMediaRoutes.delete("/cleanup", chunk5NCBFP37_cjs.requireRole("admin"), async (c) => {
|
|
12092
12086
|
try {
|
|
12093
12087
|
const db = c.env.DB;
|
|
12094
12088
|
const allMediaStmt = db.prepare("SELECT id, r2_key, filename FROM media WHERE deleted_at IS NULL");
|
|
@@ -12338,7 +12332,7 @@ function formatFileSize(bytes) {
|
|
|
12338
12332
|
}
|
|
12339
12333
|
|
|
12340
12334
|
// src/templates/pages/admin-plugins-list.template.ts
|
|
12341
|
-
|
|
12335
|
+
chunkMF7DWI5P_cjs.init_admin_layout_catalyst_template();
|
|
12342
12336
|
function renderPluginsListPage(data) {
|
|
12343
12337
|
const pageContent = `
|
|
12344
12338
|
<div>
|
|
@@ -12773,7 +12767,7 @@ function renderPluginsListPage(data) {
|
|
|
12773
12767
|
version: data.version,
|
|
12774
12768
|
content: pageContent
|
|
12775
12769
|
};
|
|
12776
|
-
return
|
|
12770
|
+
return chunkMF7DWI5P_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
12777
12771
|
}
|
|
12778
12772
|
function renderPluginCard(plugin) {
|
|
12779
12773
|
const statusColors = {
|
|
@@ -13430,7 +13424,7 @@ function renderPluginSettingsPage(data) {
|
|
|
13430
13424
|
user,
|
|
13431
13425
|
content: pageContent
|
|
13432
13426
|
};
|
|
13433
|
-
return
|
|
13427
|
+
return chunkMF7DWI5P_cjs.renderAdminLayout(layoutData);
|
|
13434
13428
|
}
|
|
13435
13429
|
function renderStatusBadge(status) {
|
|
13436
13430
|
const statusColors = {
|
|
@@ -13693,7 +13687,7 @@ function formatTimestamp(timestamp) {
|
|
|
13693
13687
|
|
|
13694
13688
|
// src/routes/admin-plugins.ts
|
|
13695
13689
|
var adminPluginRoutes = new hono.Hono();
|
|
13696
|
-
adminPluginRoutes.use("*",
|
|
13690
|
+
adminPluginRoutes.use("*", chunk5NCBFP37_cjs.requireAuth());
|
|
13697
13691
|
var AVAILABLE_PLUGINS = [
|
|
13698
13692
|
{
|
|
13699
13693
|
id: "third-party-faq",
|
|
@@ -13794,7 +13788,7 @@ adminPluginRoutes.get("/", async (c) => {
|
|
|
13794
13788
|
if (user?.role !== "admin") {
|
|
13795
13789
|
return c.text("Access denied", 403);
|
|
13796
13790
|
}
|
|
13797
|
-
const pluginService = new
|
|
13791
|
+
const pluginService = new chunkILZ3DP4I_cjs.PluginService(db);
|
|
13798
13792
|
let installedPlugins = [];
|
|
13799
13793
|
let stats = { total: 0, active: 0, inactive: 0, errors: 0, uninstalled: 0 };
|
|
13800
13794
|
try {
|
|
@@ -13866,7 +13860,7 @@ adminPluginRoutes.get("/:id", async (c) => {
|
|
|
13866
13860
|
if (user?.role !== "admin") {
|
|
13867
13861
|
return c.redirect("/admin/plugins");
|
|
13868
13862
|
}
|
|
13869
|
-
const pluginService = new
|
|
13863
|
+
const pluginService = new chunkILZ3DP4I_cjs.PluginService(db);
|
|
13870
13864
|
const plugin = await pluginService.getPlugin(pluginId);
|
|
13871
13865
|
if (!plugin) {
|
|
13872
13866
|
return c.text("Plugin not found", 404);
|
|
@@ -13920,7 +13914,7 @@ adminPluginRoutes.post("/:id/activate", async (c) => {
|
|
|
13920
13914
|
if (user?.role !== "admin") {
|
|
13921
13915
|
return c.json({ error: "Access denied" }, 403);
|
|
13922
13916
|
}
|
|
13923
|
-
const pluginService = new
|
|
13917
|
+
const pluginService = new chunkILZ3DP4I_cjs.PluginService(db);
|
|
13924
13918
|
await pluginService.activatePlugin(pluginId);
|
|
13925
13919
|
return c.json({ success: true });
|
|
13926
13920
|
} catch (error) {
|
|
@@ -13937,7 +13931,7 @@ adminPluginRoutes.post("/:id/deactivate", async (c) => {
|
|
|
13937
13931
|
if (user?.role !== "admin") {
|
|
13938
13932
|
return c.json({ error: "Access denied" }, 403);
|
|
13939
13933
|
}
|
|
13940
|
-
const pluginService = new
|
|
13934
|
+
const pluginService = new chunkILZ3DP4I_cjs.PluginService(db);
|
|
13941
13935
|
await pluginService.deactivatePlugin(pluginId);
|
|
13942
13936
|
return c.json({ success: true });
|
|
13943
13937
|
} catch (error) {
|
|
@@ -13954,7 +13948,7 @@ adminPluginRoutes.post("/install", async (c) => {
|
|
|
13954
13948
|
return c.json({ error: "Access denied" }, 403);
|
|
13955
13949
|
}
|
|
13956
13950
|
const body = await c.req.json();
|
|
13957
|
-
const pluginService = new
|
|
13951
|
+
const pluginService = new chunkILZ3DP4I_cjs.PluginService(db);
|
|
13958
13952
|
if (body.name === "faq-plugin") {
|
|
13959
13953
|
const faqPlugin = await pluginService.installPlugin({
|
|
13960
13954
|
id: "third-party-faq",
|
|
@@ -14170,7 +14164,7 @@ adminPluginRoutes.post("/:id/uninstall", async (c) => {
|
|
|
14170
14164
|
if (user?.role !== "admin") {
|
|
14171
14165
|
return c.json({ error: "Access denied" }, 403);
|
|
14172
14166
|
}
|
|
14173
|
-
const pluginService = new
|
|
14167
|
+
const pluginService = new chunkILZ3DP4I_cjs.PluginService(db);
|
|
14174
14168
|
await pluginService.uninstallPlugin(pluginId);
|
|
14175
14169
|
return c.json({ success: true });
|
|
14176
14170
|
} catch (error) {
|
|
@@ -14188,7 +14182,7 @@ adminPluginRoutes.post("/:id/settings", async (c) => {
|
|
|
14188
14182
|
return c.json({ error: "Access denied" }, 403);
|
|
14189
14183
|
}
|
|
14190
14184
|
const settings = await c.req.json();
|
|
14191
|
-
const pluginService = new
|
|
14185
|
+
const pluginService = new chunkILZ3DP4I_cjs.PluginService(db);
|
|
14192
14186
|
await pluginService.updatePluginSettings(pluginId, settings);
|
|
14193
14187
|
return c.json({ success: true });
|
|
14194
14188
|
} catch (error) {
|
|
@@ -14209,7 +14203,7 @@ function formatLastUpdated(timestamp) {
|
|
|
14209
14203
|
}
|
|
14210
14204
|
|
|
14211
14205
|
// src/templates/pages/admin-logs-list.template.ts
|
|
14212
|
-
|
|
14206
|
+
chunkMF7DWI5P_cjs.init_admin_layout_catalyst_template();
|
|
14213
14207
|
function renderLogsListPage(data) {
|
|
14214
14208
|
const { logs, pagination, filters, user } = data;
|
|
14215
14209
|
const content = `
|
|
@@ -14520,7 +14514,7 @@ function renderLogsListPage(data) {
|
|
|
14520
14514
|
user,
|
|
14521
14515
|
content
|
|
14522
14516
|
};
|
|
14523
|
-
return
|
|
14517
|
+
return chunkMF7DWI5P_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
14524
14518
|
}
|
|
14525
14519
|
function renderLogDetailsPage(data) {
|
|
14526
14520
|
const { log, user } = data;
|
|
@@ -14732,7 +14726,7 @@ function renderLogDetailsPage(data) {
|
|
|
14732
14726
|
</div>
|
|
14733
14727
|
</div>
|
|
14734
14728
|
`;
|
|
14735
|
-
return
|
|
14729
|
+
return chunkMF7DWI5P_cjs.adminLayoutV2({
|
|
14736
14730
|
title: `Log Details - ${log.id}`,
|
|
14737
14731
|
user,
|
|
14738
14732
|
content
|
|
@@ -14975,7 +14969,7 @@ function renderLogConfigPage(data) {
|
|
|
14975
14969
|
|
|
14976
14970
|
<script src="https://unpkg.com/htmx.org@1.9.6"></script>
|
|
14977
14971
|
`;
|
|
14978
|
-
return
|
|
14972
|
+
return chunkMF7DWI5P_cjs.adminLayoutV2({
|
|
14979
14973
|
title: "Log Configuration",
|
|
14980
14974
|
user,
|
|
14981
14975
|
content
|
|
@@ -14984,11 +14978,11 @@ function renderLogConfigPage(data) {
|
|
|
14984
14978
|
|
|
14985
14979
|
// src/routes/admin-logs.ts
|
|
14986
14980
|
var adminLogsRoutes = new hono.Hono();
|
|
14987
|
-
adminLogsRoutes.use("*",
|
|
14981
|
+
adminLogsRoutes.use("*", chunk5NCBFP37_cjs.requireAuth());
|
|
14988
14982
|
adminLogsRoutes.get("/", async (c) => {
|
|
14989
14983
|
try {
|
|
14990
14984
|
const user = c.get("user");
|
|
14991
|
-
const logger =
|
|
14985
|
+
const logger = chunk7FOAMNTI_cjs.getLogger(c.env.DB);
|
|
14992
14986
|
const query = c.req.query();
|
|
14993
14987
|
const page = parseInt(query.page || "1");
|
|
14994
14988
|
const limit = parseInt(query.limit || "50");
|
|
@@ -15068,7 +15062,7 @@ adminLogsRoutes.get("/:id", async (c) => {
|
|
|
15068
15062
|
try {
|
|
15069
15063
|
const id = c.req.param("id");
|
|
15070
15064
|
const user = c.get("user");
|
|
15071
|
-
const logger =
|
|
15065
|
+
const logger = chunk7FOAMNTI_cjs.getLogger(c.env.DB);
|
|
15072
15066
|
const { logs } = await logger.getLogs({
|
|
15073
15067
|
limit: 1,
|
|
15074
15068
|
offset: 0,
|
|
@@ -15105,7 +15099,7 @@ adminLogsRoutes.get("/:id", async (c) => {
|
|
|
15105
15099
|
adminLogsRoutes.get("/config", async (c) => {
|
|
15106
15100
|
try {
|
|
15107
15101
|
const user = c.get("user");
|
|
15108
|
-
const logger =
|
|
15102
|
+
const logger = chunk7FOAMNTI_cjs.getLogger(c.env.DB);
|
|
15109
15103
|
const configs = await logger.getAllConfigs();
|
|
15110
15104
|
const pageData = {
|
|
15111
15105
|
configs,
|
|
@@ -15129,7 +15123,7 @@ adminLogsRoutes.post("/config/:category", async (c) => {
|
|
|
15129
15123
|
const level = formData.get("level");
|
|
15130
15124
|
const retention = parseInt(formData.get("retention"));
|
|
15131
15125
|
const maxSize = parseInt(formData.get("max_size"));
|
|
15132
|
-
const logger =
|
|
15126
|
+
const logger = chunk7FOAMNTI_cjs.getLogger(c.env.DB);
|
|
15133
15127
|
await logger.updateConfig(category, {
|
|
15134
15128
|
enabled,
|
|
15135
15129
|
level,
|
|
@@ -15158,7 +15152,7 @@ adminLogsRoutes.get("/export", async (c) => {
|
|
|
15158
15152
|
const category = query.category;
|
|
15159
15153
|
const startDate = query.start_date;
|
|
15160
15154
|
const endDate = query.end_date;
|
|
15161
|
-
const logger =
|
|
15155
|
+
const logger = chunk7FOAMNTI_cjs.getLogger(c.env.DB);
|
|
15162
15156
|
const filter = {
|
|
15163
15157
|
limit: 1e4,
|
|
15164
15158
|
// Export up to 10k logs
|
|
@@ -15239,7 +15233,7 @@ adminLogsRoutes.post("/cleanup", async (c) => {
|
|
|
15239
15233
|
error: "Unauthorized. Admin access required."
|
|
15240
15234
|
}, 403);
|
|
15241
15235
|
}
|
|
15242
|
-
const logger =
|
|
15236
|
+
const logger = chunk7FOAMNTI_cjs.getLogger(c.env.DB);
|
|
15243
15237
|
await logger.cleanupByRetention();
|
|
15244
15238
|
return c.html(html.html`
|
|
15245
15239
|
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded">
|
|
@@ -15261,7 +15255,7 @@ adminLogsRoutes.post("/search", async (c) => {
|
|
|
15261
15255
|
const search = formData.get("search");
|
|
15262
15256
|
const level = formData.get("level");
|
|
15263
15257
|
const category = formData.get("category");
|
|
15264
|
-
const logger =
|
|
15258
|
+
const logger = chunk7FOAMNTI_cjs.getLogger(c.env.DB);
|
|
15265
15259
|
const filter = {
|
|
15266
15260
|
limit: 20,
|
|
15267
15261
|
offset: 0,
|
|
@@ -15356,7 +15350,7 @@ adminDesignRoutes.get("/", (c) => {
|
|
|
15356
15350
|
role: user.role
|
|
15357
15351
|
} : void 0
|
|
15358
15352
|
};
|
|
15359
|
-
return c.html(
|
|
15353
|
+
return c.html(chunkMF7DWI5P_cjs.renderDesignPage(pageData));
|
|
15360
15354
|
});
|
|
15361
15355
|
var adminCheckboxRoutes = new hono.Hono();
|
|
15362
15356
|
adminCheckboxRoutes.get("/", (c) => {
|
|
@@ -15368,7 +15362,7 @@ adminCheckboxRoutes.get("/", (c) => {
|
|
|
15368
15362
|
role: user.role
|
|
15369
15363
|
} : void 0
|
|
15370
15364
|
};
|
|
15371
|
-
return c.html(
|
|
15365
|
+
return c.html(chunkMF7DWI5P_cjs.renderCheckboxPage(pageData));
|
|
15372
15366
|
});
|
|
15373
15367
|
|
|
15374
15368
|
// src/templates/pages/admin-testimonials-form.template.ts
|
|
@@ -15396,7 +15390,7 @@ function renderTestimonialsForm(data) {
|
|
|
15396
15390
|
</div>
|
|
15397
15391
|
</div>
|
|
15398
15392
|
|
|
15399
|
-
${message ?
|
|
15393
|
+
${message ? chunkMF7DWI5P_cjs.renderAlert({ type: messageType || "info", message, dismissible: true }) : ""}
|
|
15400
15394
|
|
|
15401
15395
|
<!-- Form -->
|
|
15402
15396
|
<div class="backdrop-blur-xl bg-white/10 rounded-xl border border-white/20 shadow-2xl">
|
|
@@ -15625,7 +15619,7 @@ function renderTestimonialsForm(data) {
|
|
|
15625
15619
|
user: data.user,
|
|
15626
15620
|
content: pageContent
|
|
15627
15621
|
};
|
|
15628
|
-
return
|
|
15622
|
+
return chunkMF7DWI5P_cjs.renderAdminLayout(layoutData);
|
|
15629
15623
|
}
|
|
15630
15624
|
function escapeHtml4(unsafe) {
|
|
15631
15625
|
return unsafe.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
@@ -15651,7 +15645,7 @@ adminTestimonialsRoutes.get("/", async (c) => {
|
|
|
15651
15645
|
const offset = (currentPage - 1) * limit;
|
|
15652
15646
|
const db = c.env?.DB;
|
|
15653
15647
|
if (!db) {
|
|
15654
|
-
return c.html(
|
|
15648
|
+
return c.html(chunkMF7DWI5P_cjs.renderTestimonialsList({
|
|
15655
15649
|
testimonials: [],
|
|
15656
15650
|
totalCount: 0,
|
|
15657
15651
|
currentPage: 1,
|
|
@@ -15691,7 +15685,7 @@ adminTestimonialsRoutes.get("/", async (c) => {
|
|
|
15691
15685
|
`;
|
|
15692
15686
|
const { results: testimonials } = await db.prepare(dataQuery).bind(...params, limit, offset).all();
|
|
15693
15687
|
const totalPages = Math.ceil(totalCount / limit);
|
|
15694
|
-
return c.html(
|
|
15688
|
+
return c.html(chunkMF7DWI5P_cjs.renderTestimonialsList({
|
|
15695
15689
|
testimonials: testimonials || [],
|
|
15696
15690
|
totalCount,
|
|
15697
15691
|
currentPage,
|
|
@@ -15705,7 +15699,7 @@ adminTestimonialsRoutes.get("/", async (c) => {
|
|
|
15705
15699
|
} catch (error) {
|
|
15706
15700
|
console.error("Error fetching testimonials:", error);
|
|
15707
15701
|
const user = c.get("user");
|
|
15708
|
-
return c.html(
|
|
15702
|
+
return c.html(chunkMF7DWI5P_cjs.renderTestimonialsList({
|
|
15709
15703
|
testimonials: [],
|
|
15710
15704
|
totalCount: 0,
|
|
15711
15705
|
currentPage: 1,
|
|
@@ -16024,7 +16018,7 @@ function renderCodeExamplesForm(data) {
|
|
|
16024
16018
|
</div>
|
|
16025
16019
|
</div>
|
|
16026
16020
|
|
|
16027
|
-
${message ?
|
|
16021
|
+
${message ? chunkMF7DWI5P_cjs.renderAlert({ type: messageType || "info", message, dismissible: true }) : ""}
|
|
16028
16022
|
|
|
16029
16023
|
<!-- Form -->
|
|
16030
16024
|
<div class="backdrop-blur-xl bg-white/10 rounded-xl border border-white/20 shadow-2xl">
|
|
@@ -16294,7 +16288,7 @@ function renderCodeExamplesForm(data) {
|
|
|
16294
16288
|
user: data.user,
|
|
16295
16289
|
content: pageContent
|
|
16296
16290
|
};
|
|
16297
|
-
return
|
|
16291
|
+
return chunkMF7DWI5P_cjs.renderAdminLayout(layoutData);
|
|
16298
16292
|
}
|
|
16299
16293
|
function escapeHtml5(unsafe) {
|
|
16300
16294
|
return unsafe.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
@@ -16321,7 +16315,7 @@ adminCodeExamplesRoutes.get("/", async (c) => {
|
|
|
16321
16315
|
const offset = (currentPage - 1) * limit;
|
|
16322
16316
|
const db = c.env?.DB;
|
|
16323
16317
|
if (!db) {
|
|
16324
|
-
return c.html(
|
|
16318
|
+
return c.html(chunkMF7DWI5P_cjs.renderCodeExamplesList({
|
|
16325
16319
|
codeExamples: [],
|
|
16326
16320
|
totalCount: 0,
|
|
16327
16321
|
currentPage: 1,
|
|
@@ -16361,7 +16355,7 @@ adminCodeExamplesRoutes.get("/", async (c) => {
|
|
|
16361
16355
|
`;
|
|
16362
16356
|
const { results: codeExamples } = await db.prepare(dataQuery).bind(...params, limit, offset).all();
|
|
16363
16357
|
const totalPages = Math.ceil(totalCount / limit);
|
|
16364
|
-
return c.html(
|
|
16358
|
+
return c.html(chunkMF7DWI5P_cjs.renderCodeExamplesList({
|
|
16365
16359
|
codeExamples: codeExamples || [],
|
|
16366
16360
|
totalCount,
|
|
16367
16361
|
currentPage,
|
|
@@ -16375,7 +16369,7 @@ adminCodeExamplesRoutes.get("/", async (c) => {
|
|
|
16375
16369
|
} catch (error) {
|
|
16376
16370
|
console.error("Error fetching code examples:", error);
|
|
16377
16371
|
const user = c.get("user");
|
|
16378
|
-
return c.html(
|
|
16372
|
+
return c.html(chunkMF7DWI5P_cjs.renderCodeExamplesList({
|
|
16379
16373
|
codeExamples: [],
|
|
16380
16374
|
totalCount: 0,
|
|
16381
16375
|
currentPage: 1,
|
|
@@ -16764,7 +16758,7 @@ function renderDashboardPage(data) {
|
|
|
16764
16758
|
version: data.version,
|
|
16765
16759
|
content: pageContent
|
|
16766
16760
|
};
|
|
16767
|
-
return
|
|
16761
|
+
return chunkMF7DWI5P_cjs.renderAdminLayout(layoutData);
|
|
16768
16762
|
}
|
|
16769
16763
|
function renderStatsCards(stats) {
|
|
16770
16764
|
const cards = [
|
|
@@ -17312,9 +17306,9 @@ function renderStorageUsage(databaseSizeBytes, mediaSizeBytes) {
|
|
|
17312
17306
|
}
|
|
17313
17307
|
|
|
17314
17308
|
// src/routes/admin-dashboard.ts
|
|
17315
|
-
var VERSION =
|
|
17309
|
+
var VERSION = chunkW2IAEG4W_cjs.getCoreVersion();
|
|
17316
17310
|
var router = new hono.Hono();
|
|
17317
|
-
router.use("*",
|
|
17311
|
+
router.use("*", chunk5NCBFP37_cjs.requireAuth());
|
|
17318
17312
|
router.get("/", async (c) => {
|
|
17319
17313
|
const user = c.get("user");
|
|
17320
17314
|
try {
|
|
@@ -17539,7 +17533,7 @@ router.get("/system-status", async (c) => {
|
|
|
17539
17533
|
});
|
|
17540
17534
|
|
|
17541
17535
|
// src/templates/pages/admin-collections-list.template.ts
|
|
17542
|
-
|
|
17536
|
+
chunkMF7DWI5P_cjs.init_admin_layout_catalyst_template();
|
|
17543
17537
|
|
|
17544
17538
|
// src/templates/components/table.template.ts
|
|
17545
17539
|
function renderTable2(data) {
|
|
@@ -18013,11 +18007,11 @@ function renderCollectionsListPage(data) {
|
|
|
18013
18007
|
version: data.version,
|
|
18014
18008
|
content: pageContent
|
|
18015
18009
|
};
|
|
18016
|
-
return
|
|
18010
|
+
return chunkMF7DWI5P_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
18017
18011
|
}
|
|
18018
18012
|
|
|
18019
18013
|
// src/templates/pages/admin-collections-form.template.ts
|
|
18020
|
-
|
|
18014
|
+
chunkMF7DWI5P_cjs.init_admin_layout_catalyst_template();
|
|
18021
18015
|
function getFieldTypeBadge(fieldType) {
|
|
18022
18016
|
const typeLabels = {
|
|
18023
18017
|
"text": "Text",
|
|
@@ -18278,7 +18272,7 @@ function renderCollectionFormPage(data) {
|
|
|
18278
18272
|
}
|
|
18279
18273
|
</style>
|
|
18280
18274
|
|
|
18281
|
-
${
|
|
18275
|
+
${chunkMF7DWI5P_cjs.renderForm(formData)}
|
|
18282
18276
|
|
|
18283
18277
|
${isEdit && data.managed ? `
|
|
18284
18278
|
<!-- Read-Only Fields Display for Managed Collections -->
|
|
@@ -18350,7 +18344,7 @@ function renderCollectionFormPage(data) {
|
|
|
18350
18344
|
Add Field
|
|
18351
18345
|
</button>
|
|
18352
18346
|
</div>
|
|
18353
|
-
|
|
18347
|
+
|
|
18354
18348
|
<!-- Fields List -->
|
|
18355
18349
|
<div id="fields-list" class="space-y-3">
|
|
18356
18350
|
${fieldsWithData.map((field) => `
|
|
@@ -18421,7 +18415,9 @@ function renderCollectionFormPage(data) {
|
|
|
18421
18415
|
` : ""}
|
|
18422
18416
|
</div>
|
|
18423
18417
|
</div>
|
|
18424
|
-
` :
|
|
18418
|
+
` : ""}
|
|
18419
|
+
|
|
18420
|
+
${!isEdit ? `
|
|
18425
18421
|
<div class="mt-6 rounded-lg bg-cyan-50 dark:bg-cyan-900/20 border border-cyan-100 dark:border-cyan-900/30 p-4">
|
|
18426
18422
|
<div class="flex items-start gap-x-3">
|
|
18427
18423
|
<svg class="h-5 w-5 text-cyan-600 dark:text-cyan-400 mt-0.5" fill="currentColor" viewBox="0 0 20 20">
|
|
@@ -18437,7 +18433,7 @@ function renderCollectionFormPage(data) {
|
|
|
18437
18433
|
</div>
|
|
18438
18434
|
</div>
|
|
18439
18435
|
</div>
|
|
18440
|
-
`}
|
|
18436
|
+
` : ""}
|
|
18441
18437
|
|
|
18442
18438
|
<!-- Action Buttons -->
|
|
18443
18439
|
<div class="mt-6 pt-6 border-t border-zinc-950/5 dark:border-white/10 flex items-center justify-between">
|
|
@@ -18957,6 +18953,8 @@ function renderCollectionFormPage(data) {
|
|
|
18957
18953
|
})
|
|
18958
18954
|
.then(data => {
|
|
18959
18955
|
if (data.success) {
|
|
18956
|
+
// Close modal before reloading
|
|
18957
|
+
closeFieldModal();
|
|
18960
18958
|
location.reload();
|
|
18961
18959
|
} else {
|
|
18962
18960
|
alert('Error saving field: ' + (data.error || 'Unknown error'));
|
|
@@ -19063,12 +19061,12 @@ function renderCollectionFormPage(data) {
|
|
|
19063
19061
|
version: data.version,
|
|
19064
19062
|
content: pageContent
|
|
19065
19063
|
};
|
|
19066
|
-
return
|
|
19064
|
+
return chunkMF7DWI5P_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
19067
19065
|
}
|
|
19068
19066
|
|
|
19069
19067
|
// src/routes/admin-collections.ts
|
|
19070
19068
|
var adminCollectionsRoutes = new hono.Hono();
|
|
19071
|
-
adminCollectionsRoutes.use("*",
|
|
19069
|
+
adminCollectionsRoutes.use("*", chunk5NCBFP37_cjs.requireAuth());
|
|
19072
19070
|
adminCollectionsRoutes.get("/", async (c) => {
|
|
19073
19071
|
try {
|
|
19074
19072
|
const user = c.get("user");
|
|
@@ -19507,11 +19505,65 @@ adminCollectionsRoutes.post("/:id/fields", async (c) => {
|
|
|
19507
19505
|
return c.json({ success: false, error: "Field name must contain only lowercase letters, numbers, and underscores." });
|
|
19508
19506
|
}
|
|
19509
19507
|
const db = c.env.DB;
|
|
19508
|
+
const getCollectionStmt = db.prepare("SELECT * FROM collections WHERE id = ?");
|
|
19509
|
+
const collection = await getCollectionStmt.bind(collectionId).first();
|
|
19510
|
+
if (!collection) {
|
|
19511
|
+
return c.json({ success: false, error: "Collection not found." });
|
|
19512
|
+
}
|
|
19513
|
+
let schema = collection.schema ? typeof collection.schema === "string" ? JSON.parse(collection.schema) : collection.schema : null;
|
|
19514
|
+
if (schema && schema.properties && schema.properties[fieldName]) {
|
|
19515
|
+
return c.json({ success: false, error: "A field with this name already exists." });
|
|
19516
|
+
}
|
|
19510
19517
|
const existingStmt = db.prepare("SELECT id FROM content_fields WHERE collection_id = ? AND field_name = ?");
|
|
19511
19518
|
const existing = await existingStmt.bind(collectionId, fieldName).first();
|
|
19512
19519
|
if (existing) {
|
|
19513
19520
|
return c.json({ success: false, error: "A field with this name already exists." });
|
|
19514
19521
|
}
|
|
19522
|
+
let parsedOptions = {};
|
|
19523
|
+
try {
|
|
19524
|
+
parsedOptions = fieldOptions ? JSON.parse(fieldOptions) : {};
|
|
19525
|
+
} catch (e) {
|
|
19526
|
+
console.error("Error parsing field options:", e);
|
|
19527
|
+
}
|
|
19528
|
+
if (schema) {
|
|
19529
|
+
if (!schema.properties) {
|
|
19530
|
+
schema.properties = {};
|
|
19531
|
+
}
|
|
19532
|
+
if (!schema.required) {
|
|
19533
|
+
schema.required = [];
|
|
19534
|
+
}
|
|
19535
|
+
const fieldConfig = {
|
|
19536
|
+
type: fieldType === "number" ? "number" : fieldType === "boolean" ? "boolean" : "string",
|
|
19537
|
+
title: fieldLabel,
|
|
19538
|
+
searchable: isSearchable,
|
|
19539
|
+
...parsedOptions
|
|
19540
|
+
};
|
|
19541
|
+
if (fieldType === "richtext") {
|
|
19542
|
+
fieldConfig.format = "richtext";
|
|
19543
|
+
} else if (fieldType === "date") {
|
|
19544
|
+
fieldConfig.format = "date-time";
|
|
19545
|
+
} else if (fieldType === "select") {
|
|
19546
|
+
fieldConfig.enum = parsedOptions.options || [];
|
|
19547
|
+
} else if (fieldType === "media") {
|
|
19548
|
+
fieldConfig.format = "media";
|
|
19549
|
+
} else if (fieldType === "quill") {
|
|
19550
|
+
fieldConfig.type = "quill";
|
|
19551
|
+
} else if (fieldType === "mdxeditor") {
|
|
19552
|
+
fieldConfig.type = "mdxeditor";
|
|
19553
|
+
}
|
|
19554
|
+
schema.properties[fieldName] = fieldConfig;
|
|
19555
|
+
if (isRequired && !schema.required.includes(fieldName)) {
|
|
19556
|
+
schema.required.push(fieldName);
|
|
19557
|
+
}
|
|
19558
|
+
const updateSchemaStmt = db.prepare(`
|
|
19559
|
+
UPDATE collections
|
|
19560
|
+
SET schema = ?, updated_at = ?
|
|
19561
|
+
WHERE id = ?
|
|
19562
|
+
`);
|
|
19563
|
+
await updateSchemaStmt.bind(JSON.stringify(schema), Date.now(), collectionId).run();
|
|
19564
|
+
console.log("[Add Field] Added field to schema:", fieldName, fieldConfig);
|
|
19565
|
+
return c.json({ success: true, fieldId: `schema-${fieldName}` });
|
|
19566
|
+
}
|
|
19515
19567
|
const orderStmt = db.prepare("SELECT MAX(field_order) as max_order FROM content_fields WHERE collection_id = ?");
|
|
19516
19568
|
const orderResult = await orderStmt.bind(collectionId).first();
|
|
19517
19569
|
const nextOrder = (orderResult?.max_order || 0) + 1;
|
|
@@ -19652,7 +19704,39 @@ adminCollectionsRoutes.put("/:collectionId/fields/:fieldId", async (c) => {
|
|
|
19652
19704
|
adminCollectionsRoutes.delete("/:collectionId/fields/:fieldId", async (c) => {
|
|
19653
19705
|
try {
|
|
19654
19706
|
const fieldId = c.req.param("fieldId");
|
|
19707
|
+
const collectionId = c.req.param("collectionId");
|
|
19655
19708
|
const db = c.env.DB;
|
|
19709
|
+
if (fieldId.startsWith("schema-")) {
|
|
19710
|
+
const fieldName = fieldId.replace("schema-", "");
|
|
19711
|
+
const getCollectionStmt = db.prepare("SELECT * FROM collections WHERE id = ?");
|
|
19712
|
+
const collection = await getCollectionStmt.bind(collectionId).first();
|
|
19713
|
+
if (!collection) {
|
|
19714
|
+
return c.json({ success: false, error: "Collection not found." });
|
|
19715
|
+
}
|
|
19716
|
+
let schema = typeof collection.schema === "string" ? JSON.parse(collection.schema) : collection.schema;
|
|
19717
|
+
if (!schema || !schema.properties) {
|
|
19718
|
+
return c.json({ success: false, error: "Field not found in schema." });
|
|
19719
|
+
}
|
|
19720
|
+
if (schema.properties[fieldName]) {
|
|
19721
|
+
delete schema.properties[fieldName];
|
|
19722
|
+
if (schema.required && Array.isArray(schema.required)) {
|
|
19723
|
+
const requiredIndex = schema.required.indexOf(fieldName);
|
|
19724
|
+
if (requiredIndex !== -1) {
|
|
19725
|
+
schema.required.splice(requiredIndex, 1);
|
|
19726
|
+
}
|
|
19727
|
+
}
|
|
19728
|
+
const updateCollectionStmt = db.prepare(`
|
|
19729
|
+
UPDATE collections
|
|
19730
|
+
SET schema = ?, updated_at = ?
|
|
19731
|
+
WHERE id = ?
|
|
19732
|
+
`);
|
|
19733
|
+
await updateCollectionStmt.bind(JSON.stringify(schema), Date.now(), collectionId).run();
|
|
19734
|
+
console.log("[Delete Field] Removed field from schema:", fieldName);
|
|
19735
|
+
return c.json({ success: true });
|
|
19736
|
+
} else {
|
|
19737
|
+
return c.json({ success: false, error: "Field not found in schema." });
|
|
19738
|
+
}
|
|
19739
|
+
}
|
|
19656
19740
|
const deleteStmt = db.prepare("DELETE FROM content_fields WHERE id = ?");
|
|
19657
19741
|
await deleteStmt.bind(fieldId).run();
|
|
19658
19742
|
return c.json({ success: true });
|
|
@@ -19681,7 +19765,7 @@ adminCollectionsRoutes.post("/:collectionId/fields/reorder", async (c) => {
|
|
|
19681
19765
|
});
|
|
19682
19766
|
|
|
19683
19767
|
// src/templates/pages/admin-settings.template.ts
|
|
19684
|
-
|
|
19768
|
+
chunkMF7DWI5P_cjs.init_admin_layout_catalyst_template();
|
|
19685
19769
|
function renderSettingsPage(data) {
|
|
19686
19770
|
const activeTab = data.activeTab || "general";
|
|
19687
19771
|
const pageContent = `
|
|
@@ -20063,7 +20147,7 @@ function renderSettingsPage(data) {
|
|
|
20063
20147
|
version: data.version,
|
|
20064
20148
|
content: pageContent
|
|
20065
20149
|
};
|
|
20066
|
-
return
|
|
20150
|
+
return chunkMF7DWI5P_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
20067
20151
|
}
|
|
20068
20152
|
function renderTabButton(tabId, label, iconPath, activeTab) {
|
|
20069
20153
|
const isActive = activeTab === tabId;
|
|
@@ -21145,7 +21229,7 @@ function renderDatabaseToolsSettings(settings) {
|
|
|
21145
21229
|
|
|
21146
21230
|
// src/routes/admin-settings.ts
|
|
21147
21231
|
var adminSettingsRoutes = new hono.Hono();
|
|
21148
|
-
adminSettingsRoutes.use("*",
|
|
21232
|
+
adminSettingsRoutes.use("*", chunk5NCBFP37_cjs.requireAuth());
|
|
21149
21233
|
function getMockSettings(user) {
|
|
21150
21234
|
return {
|
|
21151
21235
|
general: {
|
|
@@ -21210,7 +21294,7 @@ adminSettingsRoutes.get("/", (c) => {
|
|
|
21210
21294
|
adminSettingsRoutes.get("/general", async (c) => {
|
|
21211
21295
|
const user = c.get("user");
|
|
21212
21296
|
const db = c.env.DB;
|
|
21213
|
-
const settingsService = new
|
|
21297
|
+
const settingsService = new chunk7FOAMNTI_cjs.SettingsService(db);
|
|
21214
21298
|
const generalSettings = await settingsService.getGeneralSettings(user?.email);
|
|
21215
21299
|
const mockSettings = getMockSettings(user);
|
|
21216
21300
|
mockSettings.general = generalSettings;
|
|
@@ -21313,7 +21397,7 @@ adminSettingsRoutes.get("/database-tools", (c) => {
|
|
|
21313
21397
|
adminSettingsRoutes.get("/api/migrations/status", async (c) => {
|
|
21314
21398
|
try {
|
|
21315
21399
|
const db = c.env.DB;
|
|
21316
|
-
const migrationService = new
|
|
21400
|
+
const migrationService = new chunkW4CE7XME_cjs.MigrationService(db);
|
|
21317
21401
|
const status = await migrationService.getMigrationStatus();
|
|
21318
21402
|
return c.json({
|
|
21319
21403
|
success: true,
|
|
@@ -21337,7 +21421,7 @@ adminSettingsRoutes.post("/api/migrations/run", async (c) => {
|
|
|
21337
21421
|
}, 403);
|
|
21338
21422
|
}
|
|
21339
21423
|
const db = c.env.DB;
|
|
21340
|
-
const migrationService = new
|
|
21424
|
+
const migrationService = new chunkW4CE7XME_cjs.MigrationService(db);
|
|
21341
21425
|
const result = await migrationService.runPendingMigrations();
|
|
21342
21426
|
return c.json({
|
|
21343
21427
|
success: result.success,
|
|
@@ -21355,7 +21439,7 @@ adminSettingsRoutes.post("/api/migrations/run", async (c) => {
|
|
|
21355
21439
|
adminSettingsRoutes.get("/api/migrations/validate", async (c) => {
|
|
21356
21440
|
try {
|
|
21357
21441
|
const db = c.env.DB;
|
|
21358
|
-
const migrationService = new
|
|
21442
|
+
const migrationService = new chunkW4CE7XME_cjs.MigrationService(db);
|
|
21359
21443
|
const validation = await migrationService.validateSchema();
|
|
21360
21444
|
return c.json({
|
|
21361
21445
|
success: true,
|
|
@@ -21512,7 +21596,7 @@ adminSettingsRoutes.post("/general", async (c) => {
|
|
|
21512
21596
|
}
|
|
21513
21597
|
const formData = await c.req.formData();
|
|
21514
21598
|
const db = c.env.DB;
|
|
21515
|
-
const settingsService = new
|
|
21599
|
+
const settingsService = new chunk7FOAMNTI_cjs.SettingsService(db);
|
|
21516
21600
|
const settings = {
|
|
21517
21601
|
siteName: formData.get("siteName"),
|
|
21518
21602
|
siteDescription: formData.get("siteDescription"),
|
|
@@ -21600,5 +21684,5 @@ exports.auth_default = auth_default;
|
|
|
21600
21684
|
exports.router = router;
|
|
21601
21685
|
exports.test_cleanup_default = test_cleanup_default;
|
|
21602
21686
|
exports.userRoutes = userRoutes;
|
|
21603
|
-
//# sourceMappingURL=chunk-
|
|
21604
|
-
//# sourceMappingURL=chunk-
|
|
21687
|
+
//# sourceMappingURL=chunk-ARLXQU2S.cjs.map
|
|
21688
|
+
//# sourceMappingURL=chunk-ARLXQU2S.cjs.map
|