@sonicjs-cms/core 2.1.0 → 2.2.0
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-LPM3NPAX.cjs → chunk-2DIWLDCA.cjs} +121 -121
- package/dist/{chunk-LPM3NPAX.cjs.map → chunk-2DIWLDCA.cjs.map} +1 -1
- package/dist/{chunk-YP52USGX.cjs → chunk-AINTFRTC.cjs} +2 -249
- package/dist/chunk-AINTFRTC.cjs.map +1 -0
- package/dist/{chunk-22EFGHAX.cjs → chunk-HV2I6API.cjs} +250 -2
- package/dist/chunk-HV2I6API.cjs.map +1 -0
- package/dist/{chunk-LWMMMW43.js → chunk-K4Z3IHOK.js} +247 -3
- package/dist/chunk-K4Z3IHOK.js.map +1 -0
- package/dist/{chunk-F4K5QAN6.js → chunk-L232U757.js} +3 -246
- package/dist/chunk-L232U757.js.map +1 -0
- package/dist/{chunk-UJ4K4B23.js → chunk-OORGXYDA.js} +31 -4
- package/dist/chunk-OORGXYDA.js.map +1 -0
- package/dist/{chunk-KZ5XDGE6.js → chunk-R57VFNP3.js} +6 -6
- package/dist/{chunk-KZ5XDGE6.js.map → chunk-R57VFNP3.js.map} +1 -1
- package/dist/{chunk-7EGKU7OO.cjs → chunk-UEYMFNBN.cjs} +34 -5
- package/dist/chunk-UEYMFNBN.cjs.map +1 -0
- package/dist/{chunk-2MBNRFS5.cjs → chunk-YTMFJLJZ.cjs} +3 -3
- package/dist/{chunk-2MBNRFS5.cjs.map → chunk-YTMFJLJZ.cjs.map} +1 -1
- package/dist/{chunk-K5JZ4JI3.js → chunk-ZUK55KZB.js} +3 -3
- package/dist/{chunk-K5JZ4JI3.js.map → chunk-ZUK55KZB.js.map} +1 -1
- package/dist/index.cjs +154 -130
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/middleware.cjs +32 -23
- package/dist/middleware.js +3 -2
- package/dist/routes.cjs +26 -26
- package/dist/routes.js +6 -6
- package/dist/services.cjs +38 -38
- package/dist/services.js +2 -2
- package/dist/utils.cjs +16 -16
- package/dist/utils.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-22EFGHAX.cjs.map +0 -1
- package/dist/chunk-7EGKU7OO.cjs.map +0 -1
- package/dist/chunk-F4K5QAN6.js.map +0 -1
- package/dist/chunk-LWMMMW43.js.map +0 -1
- package/dist/chunk-UJ4K4B23.js.map +0 -1
- package/dist/chunk-YP52USGX.cjs.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkAINTFRTC_cjs = require('./chunk-AINTFRTC.cjs');
|
|
4
|
+
var chunkUEYMFNBN_cjs = require('./chunk-UEYMFNBN.cjs');
|
|
5
|
+
var chunkHV2I6API_cjs = require('./chunk-HV2I6API.cjs');
|
|
6
6
|
var chunkT7IYBGGO_cjs = require('./chunk-T7IYBGGO.cjs');
|
|
7
7
|
var chunkYU6QFFI4_cjs = require('./chunk-YU6QFFI4.cjs');
|
|
8
|
-
var
|
|
8
|
+
var chunkYTMFJLJZ_cjs = require('./chunk-YTMFJLJZ.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("/", chunkUEYMFNBN_cjs.requireAuth(), async (c) => {
|
|
48
48
|
try {
|
|
49
49
|
const db2 = c.env.DB;
|
|
50
50
|
const user = c.get("user");
|
|
@@ -85,7 +85,7 @@ apiContentCrudRoutes.post("/", chunk7EGKU7OO_cjs.requireAuth(), async (c) => {
|
|
|
85
85
|
now,
|
|
86
86
|
now
|
|
87
87
|
).run();
|
|
88
|
-
const cache =
|
|
88
|
+
const cache = chunkAINTFRTC_cjs.getCacheService(chunkAINTFRTC_cjs.CACHE_CONFIGS.api);
|
|
89
89
|
await cache.invalidate(`content:list:${collectionId}:*`);
|
|
90
90
|
await cache.invalidate("content-filtered:*");
|
|
91
91
|
const getStmt = db2.prepare("SELECT * FROM content WHERE id = ?");
|
|
@@ -110,7 +110,7 @@ apiContentCrudRoutes.post("/", chunk7EGKU7OO_cjs.requireAuth(), async (c) => {
|
|
|
110
110
|
}, 500);
|
|
111
111
|
}
|
|
112
112
|
});
|
|
113
|
-
apiContentCrudRoutes.put("/:id",
|
|
113
|
+
apiContentCrudRoutes.put("/:id", chunkUEYMFNBN_cjs.requireAuth(), async (c) => {
|
|
114
114
|
try {
|
|
115
115
|
const id = c.req.param("id");
|
|
116
116
|
const db2 = c.env.DB;
|
|
@@ -148,7 +148,7 @@ apiContentCrudRoutes.put("/:id", chunk7EGKU7OO_cjs.requireAuth(), async (c) => {
|
|
|
148
148
|
WHERE id = ?
|
|
149
149
|
`);
|
|
150
150
|
await updateStmt.bind(...params).run();
|
|
151
|
-
const cache =
|
|
151
|
+
const cache = chunkAINTFRTC_cjs.getCacheService(chunkAINTFRTC_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", chunk7EGKU7OO_cjs.requireAuth(), async (c) => {
|
|
|
174
174
|
}, 500);
|
|
175
175
|
}
|
|
176
176
|
});
|
|
177
|
-
apiContentCrudRoutes.delete("/:id",
|
|
177
|
+
apiContentCrudRoutes.delete("/:id", chunkUEYMFNBN_cjs.requireAuth(), async (c) => {
|
|
178
178
|
try {
|
|
179
179
|
const id = c.req.param("id");
|
|
180
180
|
const db2 = c.env.DB;
|
|
@@ -185,7 +185,7 @@ apiContentCrudRoutes.delete("/:id", chunk7EGKU7OO_cjs.requireAuth(), async (c) =
|
|
|
185
185
|
}
|
|
186
186
|
const deleteStmt = db2.prepare("DELETE FROM content WHERE id = ?");
|
|
187
187
|
await deleteStmt.bind(id).run();
|
|
188
|
-
const cache =
|
|
188
|
+
const cache = chunkAINTFRTC_cjs.getCacheService(chunkAINTFRTC_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 chunkUEYMFNBN_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 db2 = c.env.DB;
|
|
260
260
|
const cacheEnabled = c.get("cacheEnabled");
|
|
261
|
-
const cache =
|
|
261
|
+
const cache = chunkAINTFRTC_cjs.getCacheService(chunkAINTFRTC_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 = chunkYTMFJLJZ_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 chunkYTMFJLJZ_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 = chunkAINTFRTC_cjs.getCacheService(chunkAINTFRTC_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 = chunkYTMFJLJZ_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 chunkYTMFJLJZ_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 = chunkAINTFRTC_cjs.getCacheService(chunkAINTFRTC_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("*", chunkUEYMFNBN_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("*", chunkUEYMFNBN_cjs.requireAuth());
|
|
1316
|
+
adminApiRoutes.use("*", chunkUEYMFNBN_cjs.requireRole(["admin", "editor"]));
|
|
1317
1317
|
adminApiRoutes.get("/stats", async (c) => {
|
|
1318
1318
|
try {
|
|
1319
1319
|
const db2 = c.env.DB;
|
|
@@ -2211,7 +2211,7 @@ authRoutes.post(
|
|
|
2211
2211
|
if (existingUser) {
|
|
2212
2212
|
return c.json({ error: "User with this email or username already exists" }, 400);
|
|
2213
2213
|
}
|
|
2214
|
-
const passwordHash = await
|
|
2214
|
+
const passwordHash = await chunkUEYMFNBN_cjs.AuthManager.hashPassword(password);
|
|
2215
2215
|
const userId = crypto.randomUUID();
|
|
2216
2216
|
const now = /* @__PURE__ */ new Date();
|
|
2217
2217
|
await db2.prepare(`
|
|
@@ -2231,7 +2231,7 @@ authRoutes.post(
|
|
|
2231
2231
|
now.getTime(),
|
|
2232
2232
|
now.getTime()
|
|
2233
2233
|
).run();
|
|
2234
|
-
const token = await
|
|
2234
|
+
const token = await chunkUEYMFNBN_cjs.AuthManager.generateToken(userId, normalizedEmail, "viewer");
|
|
2235
2235
|
cookie.setCookie(c, "auth_token", token, {
|
|
2236
2236
|
httpOnly: true,
|
|
2237
2237
|
secure: true,
|
|
@@ -2272,7 +2272,7 @@ authRoutes.post("/login", async (c) => {
|
|
|
2272
2272
|
const { email, password } = validation.data;
|
|
2273
2273
|
const db2 = c.env.DB;
|
|
2274
2274
|
const normalizedEmail = email.toLowerCase();
|
|
2275
|
-
const cache =
|
|
2275
|
+
const cache = chunkAINTFRTC_cjs.getCacheService(chunkAINTFRTC_cjs.CACHE_CONFIGS.user);
|
|
2276
2276
|
let user = await cache.get(cache.generateKey("user", `email:${normalizedEmail}`));
|
|
2277
2277
|
if (!user) {
|
|
2278
2278
|
user = await db2.prepare("SELECT * FROM users WHERE email = ? AND is_active = 1").bind(normalizedEmail).first();
|
|
@@ -2284,11 +2284,11 @@ authRoutes.post("/login", async (c) => {
|
|
|
2284
2284
|
if (!user) {
|
|
2285
2285
|
return c.json({ error: "Invalid email or password" }, 401);
|
|
2286
2286
|
}
|
|
2287
|
-
const isValidPassword = await
|
|
2287
|
+
const isValidPassword = await chunkUEYMFNBN_cjs.AuthManager.verifyPassword(password, user.password_hash);
|
|
2288
2288
|
if (!isValidPassword) {
|
|
2289
2289
|
return c.json({ error: "Invalid email or password" }, 401);
|
|
2290
2290
|
}
|
|
2291
|
-
const token = await
|
|
2291
|
+
const token = await chunkUEYMFNBN_cjs.AuthManager.generateToken(user.id, user.email, user.role);
|
|
2292
2292
|
cookie.setCookie(c, "auth_token", token, {
|
|
2293
2293
|
httpOnly: true,
|
|
2294
2294
|
secure: true,
|
|
@@ -2337,7 +2337,7 @@ authRoutes.get("/logout", (c) => {
|
|
|
2337
2337
|
});
|
|
2338
2338
|
return c.redirect("/auth/login?message=You have been logged out successfully");
|
|
2339
2339
|
});
|
|
2340
|
-
authRoutes.get("/me",
|
|
2340
|
+
authRoutes.get("/me", chunkUEYMFNBN_cjs.requireAuth(), async (c) => {
|
|
2341
2341
|
try {
|
|
2342
2342
|
const user = c.get("user");
|
|
2343
2343
|
if (!user) {
|
|
@@ -2354,13 +2354,13 @@ authRoutes.get("/me", chunk7EGKU7OO_cjs.requireAuth(), async (c) => {
|
|
|
2354
2354
|
return c.json({ error: "Failed to get user" }, 500);
|
|
2355
2355
|
}
|
|
2356
2356
|
});
|
|
2357
|
-
authRoutes.post("/refresh",
|
|
2357
|
+
authRoutes.post("/refresh", chunkUEYMFNBN_cjs.requireAuth(), async (c) => {
|
|
2358
2358
|
try {
|
|
2359
2359
|
const user = c.get("user");
|
|
2360
2360
|
if (!user) {
|
|
2361
2361
|
return c.json({ error: "Not authenticated" }, 401);
|
|
2362
2362
|
}
|
|
2363
|
-
const token = await
|
|
2363
|
+
const token = await chunkUEYMFNBN_cjs.AuthManager.generateToken(user.userId, user.email, user.role);
|
|
2364
2364
|
cookie.setCookie(c, "auth_token", token, {
|
|
2365
2365
|
httpOnly: true,
|
|
2366
2366
|
secure: true,
|
|
@@ -2409,7 +2409,7 @@ authRoutes.post("/register/form", async (c) => {
|
|
|
2409
2409
|
</div>
|
|
2410
2410
|
`);
|
|
2411
2411
|
}
|
|
2412
|
-
const passwordHash = await
|
|
2412
|
+
const passwordHash = await chunkUEYMFNBN_cjs.AuthManager.hashPassword(password);
|
|
2413
2413
|
const userId = crypto.randomUUID();
|
|
2414
2414
|
const now = /* @__PURE__ */ new Date();
|
|
2415
2415
|
await db2.prepare(`
|
|
@@ -2429,7 +2429,7 @@ authRoutes.post("/register/form", async (c) => {
|
|
|
2429
2429
|
now.getTime(),
|
|
2430
2430
|
now.getTime()
|
|
2431
2431
|
).run();
|
|
2432
|
-
const token = await
|
|
2432
|
+
const token = await chunkUEYMFNBN_cjs.AuthManager.generateToken(userId, normalizedEmail, "admin");
|
|
2433
2433
|
cookie.setCookie(c, "auth_token", token, {
|
|
2434
2434
|
httpOnly: true,
|
|
2435
2435
|
secure: false,
|
|
@@ -2480,7 +2480,7 @@ authRoutes.post("/login/form", async (c) => {
|
|
|
2480
2480
|
</div>
|
|
2481
2481
|
`);
|
|
2482
2482
|
}
|
|
2483
|
-
const isValidPassword = await
|
|
2483
|
+
const isValidPassword = await chunkUEYMFNBN_cjs.AuthManager.verifyPassword(password, user.password_hash);
|
|
2484
2484
|
if (!isValidPassword) {
|
|
2485
2485
|
return c.html(html.html`
|
|
2486
2486
|
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded">
|
|
@@ -2488,7 +2488,7 @@ authRoutes.post("/login/form", async (c) => {
|
|
|
2488
2488
|
</div>
|
|
2489
2489
|
`);
|
|
2490
2490
|
}
|
|
2491
|
-
const token = await
|
|
2491
|
+
const token = await chunkUEYMFNBN_cjs.AuthManager.generateToken(user.id, user.email, user.role);
|
|
2492
2492
|
cookie.setCookie(c, "auth_token", token, {
|
|
2493
2493
|
httpOnly: true,
|
|
2494
2494
|
secure: false,
|
|
@@ -2547,7 +2547,7 @@ authRoutes.post("/seed-admin", async (c) => {
|
|
|
2547
2547
|
`).run();
|
|
2548
2548
|
const existingAdmin = await db2.prepare("SELECT id FROM users WHERE email = ? OR username = ?").bind("admin@sonicjs.com", "admin").first();
|
|
2549
2549
|
if (existingAdmin) {
|
|
2550
|
-
const passwordHash2 = await
|
|
2550
|
+
const passwordHash2 = await chunkUEYMFNBN_cjs.AuthManager.hashPassword("sonicjs!");
|
|
2551
2551
|
await db2.prepare("UPDATE users SET password_hash = ?, updated_at = ? WHERE id = ?").bind(passwordHash2, Date.now(), existingAdmin.id).run();
|
|
2552
2552
|
return c.json({
|
|
2553
2553
|
message: "Admin user already exists (password updated)",
|
|
@@ -2559,7 +2559,7 @@ authRoutes.post("/seed-admin", async (c) => {
|
|
|
2559
2559
|
}
|
|
2560
2560
|
});
|
|
2561
2561
|
}
|
|
2562
|
-
const passwordHash = await
|
|
2562
|
+
const passwordHash = await chunkUEYMFNBN_cjs.AuthManager.hashPassword("sonicjs!");
|
|
2563
2563
|
const userId = "admin-user-id";
|
|
2564
2564
|
const now = Date.now();
|
|
2565
2565
|
const adminEmail = "admin@sonicjs.com".toLowerCase();
|
|
@@ -2779,7 +2779,7 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
2779
2779
|
if (existingUsername) {
|
|
2780
2780
|
return c.json({ error: "Username is already taken" }, 400);
|
|
2781
2781
|
}
|
|
2782
|
-
const passwordHash = await
|
|
2782
|
+
const passwordHash = await chunkUEYMFNBN_cjs.AuthManager.hashPassword(password);
|
|
2783
2783
|
const updateStmt = db2.prepare(`
|
|
2784
2784
|
UPDATE users SET
|
|
2785
2785
|
username = ?,
|
|
@@ -2798,7 +2798,7 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
2798
2798
|
Date.now(),
|
|
2799
2799
|
invitedUser.id
|
|
2800
2800
|
).run();
|
|
2801
|
-
const authToken = await
|
|
2801
|
+
const authToken = await chunkUEYMFNBN_cjs.AuthManager.generateToken(invitedUser.id, invitedUser.email, invitedUser.role);
|
|
2802
2802
|
cookie.setCookie(c, "auth_token", authToken, {
|
|
2803
2803
|
httpOnly: true,
|
|
2804
2804
|
secure: true,
|
|
@@ -3028,7 +3028,7 @@ authRoutes.post("/reset-password", async (c) => {
|
|
|
3028
3028
|
if (Date.now() > user.password_reset_expires) {
|
|
3029
3029
|
return c.json({ error: "Reset token has expired" }, 400);
|
|
3030
3030
|
}
|
|
3031
|
-
const newPasswordHash = await
|
|
3031
|
+
const newPasswordHash = await chunkUEYMFNBN_cjs.AuthManager.hashPassword(password);
|
|
3032
3032
|
try {
|
|
3033
3033
|
const historyStmt = db2.prepare(`
|
|
3034
3034
|
INSERT INTO password_history (id, user_id, password_hash, created_at)
|
|
@@ -5925,9 +5925,9 @@ async function isPluginActive2(db2, pluginId) {
|
|
|
5925
5925
|
|
|
5926
5926
|
// src/routes/admin-content.ts
|
|
5927
5927
|
var adminContentRoutes = new hono.Hono();
|
|
5928
|
-
adminContentRoutes.use("*",
|
|
5928
|
+
adminContentRoutes.use("*", chunkUEYMFNBN_cjs.requireAuth());
|
|
5929
5929
|
async function getCollectionFields(db2, collectionId) {
|
|
5930
|
-
const cache =
|
|
5930
|
+
const cache = chunkAINTFRTC_cjs.getCacheService(chunkAINTFRTC_cjs.CACHE_CONFIGS.collection);
|
|
5931
5931
|
return cache.getOrSet(
|
|
5932
5932
|
cache.generateKey("fields", collectionId),
|
|
5933
5933
|
async () => {
|
|
@@ -5982,7 +5982,7 @@ async function getCollectionFields(db2, collectionId) {
|
|
|
5982
5982
|
);
|
|
5983
5983
|
}
|
|
5984
5984
|
async function getCollection(db2, collectionId) {
|
|
5985
|
-
const cache =
|
|
5985
|
+
const cache = chunkAINTFRTC_cjs.getCacheService(chunkAINTFRTC_cjs.CACHE_CONFIGS.collection);
|
|
5986
5986
|
return cache.getOrSet(
|
|
5987
5987
|
cache.generateKey("collection", collectionId),
|
|
5988
5988
|
async () => {
|
|
@@ -6207,21 +6207,21 @@ adminContentRoutes.get("/new", async (c) => {
|
|
|
6207
6207
|
const tinymceEnabled = await isPluginActive2(db2, "tinymce-plugin");
|
|
6208
6208
|
let tinymceSettings;
|
|
6209
6209
|
if (tinymceEnabled) {
|
|
6210
|
-
const pluginService = new
|
|
6210
|
+
const pluginService = new chunkHV2I6API_cjs.PluginService(db2);
|
|
6211
6211
|
const tinymcePlugin2 = await pluginService.getPlugin("tinymce-plugin");
|
|
6212
6212
|
tinymceSettings = tinymcePlugin2?.settings;
|
|
6213
6213
|
}
|
|
6214
6214
|
const quillEnabled = await isPluginActive2(db2, "quill-editor");
|
|
6215
6215
|
let quillSettings;
|
|
6216
6216
|
if (quillEnabled) {
|
|
6217
|
-
const pluginService = new
|
|
6217
|
+
const pluginService = new chunkHV2I6API_cjs.PluginService(db2);
|
|
6218
6218
|
const quillPlugin = await pluginService.getPlugin("quill-editor");
|
|
6219
6219
|
quillSettings = quillPlugin?.settings;
|
|
6220
6220
|
}
|
|
6221
6221
|
const mdxeditorEnabled = await isPluginActive2(db2, "easy-mdx");
|
|
6222
6222
|
let mdxeditorSettings;
|
|
6223
6223
|
if (mdxeditorEnabled) {
|
|
6224
|
-
const pluginService = new
|
|
6224
|
+
const pluginService = new chunkHV2I6API_cjs.PluginService(db2);
|
|
6225
6225
|
const mdxeditorPlugin = await pluginService.getPlugin("easy-mdx");
|
|
6226
6226
|
mdxeditorSettings = mdxeditorPlugin?.settings;
|
|
6227
6227
|
}
|
|
@@ -6271,7 +6271,7 @@ adminContentRoutes.get("/:id/edit", async (c) => {
|
|
|
6271
6271
|
const db2 = c.env.DB;
|
|
6272
6272
|
const url = new URL(c.req.url);
|
|
6273
6273
|
const referrerParams = url.searchParams.get("ref") || "";
|
|
6274
|
-
const cache =
|
|
6274
|
+
const cache = chunkAINTFRTC_cjs.getCacheService(chunkAINTFRTC_cjs.CACHE_CONFIGS.content);
|
|
6275
6275
|
const content = await cache.getOrSet(
|
|
6276
6276
|
cache.generateKey("content", id),
|
|
6277
6277
|
async () => {
|
|
@@ -6312,21 +6312,21 @@ adminContentRoutes.get("/:id/edit", async (c) => {
|
|
|
6312
6312
|
const tinymceEnabled = await isPluginActive2(db2, "tinymce-plugin");
|
|
6313
6313
|
let tinymceSettings;
|
|
6314
6314
|
if (tinymceEnabled) {
|
|
6315
|
-
const pluginService = new
|
|
6315
|
+
const pluginService = new chunkHV2I6API_cjs.PluginService(db2);
|
|
6316
6316
|
const tinymcePlugin2 = await pluginService.getPlugin("tinymce-plugin");
|
|
6317
6317
|
tinymceSettings = tinymcePlugin2?.settings;
|
|
6318
6318
|
}
|
|
6319
6319
|
const quillEnabled = await isPluginActive2(db2, "quill-editor");
|
|
6320
6320
|
let quillSettings;
|
|
6321
6321
|
if (quillEnabled) {
|
|
6322
|
-
const pluginService = new
|
|
6322
|
+
const pluginService = new chunkHV2I6API_cjs.PluginService(db2);
|
|
6323
6323
|
const quillPlugin = await pluginService.getPlugin("quill-editor");
|
|
6324
6324
|
quillSettings = quillPlugin?.settings;
|
|
6325
6325
|
}
|
|
6326
6326
|
const mdxeditorEnabled = await isPluginActive2(db2, "easy-mdx");
|
|
6327
6327
|
let mdxeditorSettings;
|
|
6328
6328
|
if (mdxeditorEnabled) {
|
|
6329
|
-
const pluginService = new
|
|
6329
|
+
const pluginService = new chunkHV2I6API_cjs.PluginService(db2);
|
|
6330
6330
|
const mdxeditorPlugin = await pluginService.getPlugin("easy-mdx");
|
|
6331
6331
|
mdxeditorSettings = mdxeditorPlugin?.settings;
|
|
6332
6332
|
}
|
|
@@ -6479,7 +6479,7 @@ adminContentRoutes.post("/", async (c) => {
|
|
|
6479
6479
|
now,
|
|
6480
6480
|
now
|
|
6481
6481
|
).run();
|
|
6482
|
-
const cache =
|
|
6482
|
+
const cache = chunkAINTFRTC_cjs.getCacheService(chunkAINTFRTC_cjs.CACHE_CONFIGS.content);
|
|
6483
6483
|
await cache.invalidate(`content:list:${collectionId}:*`);
|
|
6484
6484
|
const versionStmt = db2.prepare(`
|
|
6485
6485
|
INSERT INTO content_versions (id, content_id, version, data, author_id, created_at)
|
|
@@ -6627,7 +6627,7 @@ adminContentRoutes.put("/:id", async (c) => {
|
|
|
6627
6627
|
now,
|
|
6628
6628
|
id
|
|
6629
6629
|
).run();
|
|
6630
|
-
const cache =
|
|
6630
|
+
const cache = chunkAINTFRTC_cjs.getCacheService(chunkAINTFRTC_cjs.CACHE_CONFIGS.content);
|
|
6631
6631
|
await cache.delete(cache.generateKey("content", id));
|
|
6632
6632
|
await cache.invalidate(`content:list:${existingContent.collection_id}:*`);
|
|
6633
6633
|
const existingData = JSON.parse(existingContent.data || "{}");
|
|
@@ -6920,7 +6920,7 @@ adminContentRoutes.post("/bulk-action", async (c) => {
|
|
|
6920
6920
|
} else {
|
|
6921
6921
|
return c.json({ success: false, error: "Invalid action" });
|
|
6922
6922
|
}
|
|
6923
|
-
const cache =
|
|
6923
|
+
const cache = chunkAINTFRTC_cjs.getCacheService(chunkAINTFRTC_cjs.CACHE_CONFIGS.content);
|
|
6924
6924
|
for (const contentId of ids) {
|
|
6925
6925
|
await cache.delete(cache.generateKey("content", contentId));
|
|
6926
6926
|
}
|
|
@@ -6948,7 +6948,7 @@ adminContentRoutes.delete("/:id", async (c) => {
|
|
|
6948
6948
|
WHERE id = ?
|
|
6949
6949
|
`);
|
|
6950
6950
|
await deleteStmt.bind(now, id).run();
|
|
6951
|
-
const cache =
|
|
6951
|
+
const cache = chunkAINTFRTC_cjs.getCacheService(chunkAINTFRTC_cjs.CACHE_CONFIGS.content);
|
|
6952
6952
|
await cache.delete(cache.generateKey("content", id));
|
|
6953
6953
|
await cache.invalidate("content:list:*");
|
|
6954
6954
|
return c.html(`
|
|
@@ -7992,7 +7992,7 @@ function renderUserEditPage(data) {
|
|
|
7992
7992
|
<input
|
|
7993
7993
|
type="text"
|
|
7994
7994
|
name="first_name"
|
|
7995
|
-
value="${
|
|
7995
|
+
value="${chunkYTMFJLJZ_cjs.escapeHtml(data.userToEdit.firstName || "")}"
|
|
7996
7996
|
required
|
|
7997
7997
|
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"
|
|
7998
7998
|
/>
|
|
@@ -8003,7 +8003,7 @@ function renderUserEditPage(data) {
|
|
|
8003
8003
|
<input
|
|
8004
8004
|
type="text"
|
|
8005
8005
|
name="last_name"
|
|
8006
|
-
value="${
|
|
8006
|
+
value="${chunkYTMFJLJZ_cjs.escapeHtml(data.userToEdit.lastName || "")}"
|
|
8007
8007
|
required
|
|
8008
8008
|
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"
|
|
8009
8009
|
/>
|
|
@@ -8014,7 +8014,7 @@ function renderUserEditPage(data) {
|
|
|
8014
8014
|
<input
|
|
8015
8015
|
type="text"
|
|
8016
8016
|
name="username"
|
|
8017
|
-
value="${
|
|
8017
|
+
value="${chunkYTMFJLJZ_cjs.escapeHtml(data.userToEdit.username || "")}"
|
|
8018
8018
|
required
|
|
8019
8019
|
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"
|
|
8020
8020
|
/>
|
|
@@ -8025,7 +8025,7 @@ function renderUserEditPage(data) {
|
|
|
8025
8025
|
<input
|
|
8026
8026
|
type="email"
|
|
8027
8027
|
name="email"
|
|
8028
|
-
value="${
|
|
8028
|
+
value="${chunkYTMFJLJZ_cjs.escapeHtml(data.userToEdit.email || "")}"
|
|
8029
8029
|
required
|
|
8030
8030
|
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"
|
|
8031
8031
|
/>
|
|
@@ -8036,7 +8036,7 @@ function renderUserEditPage(data) {
|
|
|
8036
8036
|
<input
|
|
8037
8037
|
type="tel"
|
|
8038
8038
|
name="phone"
|
|
8039
|
-
value="${
|
|
8039
|
+
value="${chunkYTMFJLJZ_cjs.escapeHtml(data.userToEdit.phone || "")}"
|
|
8040
8040
|
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"
|
|
8041
8041
|
/>
|
|
8042
8042
|
</div>
|
|
@@ -8050,7 +8050,7 @@ function renderUserEditPage(data) {
|
|
|
8050
8050
|
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"
|
|
8051
8051
|
>
|
|
8052
8052
|
${data.roles.map((role) => `
|
|
8053
|
-
<option value="${
|
|
8053
|
+
<option value="${chunkYTMFJLJZ_cjs.escapeHtml(role.value)}" ${data.userToEdit.role === role.value ? "selected" : ""}>${chunkYTMFJLJZ_cjs.escapeHtml(role.label)}</option>
|
|
8054
8054
|
`).join("")}
|
|
8055
8055
|
</select>
|
|
8056
8056
|
<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">
|
|
@@ -8066,7 +8066,7 @@ function renderUserEditPage(data) {
|
|
|
8066
8066
|
name="bio"
|
|
8067
8067
|
rows="3"
|
|
8068
8068
|
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"
|
|
8069
|
-
>${
|
|
8069
|
+
>${chunkYTMFJLJZ_cjs.escapeHtml(data.userToEdit.bio || "")}</textarea>
|
|
8070
8070
|
</div>
|
|
8071
8071
|
</div>
|
|
8072
8072
|
|
|
@@ -8966,7 +8966,7 @@ function renderUsersListPage(data) {
|
|
|
8966
8966
|
|
|
8967
8967
|
// src/routes/admin-users.ts
|
|
8968
8968
|
var userRoutes = new hono.Hono();
|
|
8969
|
-
userRoutes.use("*",
|
|
8969
|
+
userRoutes.use("*", chunkUEYMFNBN_cjs.requireAuth());
|
|
8970
8970
|
userRoutes.get("/", (c) => {
|
|
8971
8971
|
return c.redirect("/admin/dashboard");
|
|
8972
8972
|
});
|
|
@@ -9065,12 +9065,12 @@ userRoutes.put("/profile", async (c) => {
|
|
|
9065
9065
|
const db2 = c.env.DB;
|
|
9066
9066
|
try {
|
|
9067
9067
|
const formData = await c.req.formData();
|
|
9068
|
-
const firstName =
|
|
9069
|
-
const lastName =
|
|
9070
|
-
const username =
|
|
9068
|
+
const firstName = chunkYTMFJLJZ_cjs.sanitizeInput(formData.get("first_name")?.toString());
|
|
9069
|
+
const lastName = chunkYTMFJLJZ_cjs.sanitizeInput(formData.get("last_name")?.toString());
|
|
9070
|
+
const username = chunkYTMFJLJZ_cjs.sanitizeInput(formData.get("username")?.toString());
|
|
9071
9071
|
const email = formData.get("email")?.toString()?.trim().toLowerCase() || "";
|
|
9072
|
-
const phone =
|
|
9073
|
-
const bio =
|
|
9072
|
+
const phone = chunkYTMFJLJZ_cjs.sanitizeInput(formData.get("phone")?.toString()) || null;
|
|
9073
|
+
const bio = chunkYTMFJLJZ_cjs.sanitizeInput(formData.get("bio")?.toString()) || null;
|
|
9074
9074
|
const timezone = formData.get("timezone")?.toString() || "UTC";
|
|
9075
9075
|
const language = formData.get("language")?.toString() || "en";
|
|
9076
9076
|
const emailNotifications = formData.get("email_notifications") === "1";
|
|
@@ -9121,7 +9121,7 @@ userRoutes.put("/profile", async (c) => {
|
|
|
9121
9121
|
Date.now(),
|
|
9122
9122
|
user.userId
|
|
9123
9123
|
).run();
|
|
9124
|
-
await
|
|
9124
|
+
await chunkUEYMFNBN_cjs.logActivity(
|
|
9125
9125
|
db2,
|
|
9126
9126
|
user.userId,
|
|
9127
9127
|
"profile.update",
|
|
@@ -9184,7 +9184,7 @@ userRoutes.post("/profile/avatar", async (c) => {
|
|
|
9184
9184
|
SELECT first_name, last_name FROM users WHERE id = ?
|
|
9185
9185
|
`);
|
|
9186
9186
|
const userData = await userStmt.bind(user.userId).first();
|
|
9187
|
-
await
|
|
9187
|
+
await chunkUEYMFNBN_cjs.logActivity(
|
|
9188
9188
|
db2,
|
|
9189
9189
|
user.userId,
|
|
9190
9190
|
"profile.avatar_update",
|
|
@@ -9255,7 +9255,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
9255
9255
|
dismissible: true
|
|
9256
9256
|
}));
|
|
9257
9257
|
}
|
|
9258
|
-
const validPassword = await
|
|
9258
|
+
const validPassword = await chunkUEYMFNBN_cjs.AuthManager.verifyPassword(currentPassword, userData.password_hash);
|
|
9259
9259
|
if (!validPassword) {
|
|
9260
9260
|
return c.html(renderAlert2({
|
|
9261
9261
|
type: "error",
|
|
@@ -9263,7 +9263,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
9263
9263
|
dismissible: true
|
|
9264
9264
|
}));
|
|
9265
9265
|
}
|
|
9266
|
-
const newPasswordHash = await
|
|
9266
|
+
const newPasswordHash = await chunkUEYMFNBN_cjs.AuthManager.hashPassword(newPassword);
|
|
9267
9267
|
const historyStmt = db2.prepare(`
|
|
9268
9268
|
INSERT INTO password_history (id, user_id, password_hash, created_at)
|
|
9269
9269
|
VALUES (?, ?, ?, ?)
|
|
@@ -9279,7 +9279,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
9279
9279
|
WHERE id = ?
|
|
9280
9280
|
`);
|
|
9281
9281
|
await updateStmt.bind(newPasswordHash, Date.now(), user.userId).run();
|
|
9282
|
-
await
|
|
9282
|
+
await chunkUEYMFNBN_cjs.logActivity(
|
|
9283
9283
|
db2,
|
|
9284
9284
|
user.userId,
|
|
9285
9285
|
"profile.password_change",
|
|
@@ -9346,7 +9346,7 @@ userRoutes.get("/users", async (c) => {
|
|
|
9346
9346
|
`);
|
|
9347
9347
|
const countResult = await countStmt.bind(...params).first();
|
|
9348
9348
|
const totalUsers = countResult?.total || 0;
|
|
9349
|
-
await
|
|
9349
|
+
await chunkUEYMFNBN_cjs.logActivity(
|
|
9350
9350
|
db2,
|
|
9351
9351
|
user.userId,
|
|
9352
9352
|
"users.list_view",
|
|
@@ -9448,12 +9448,12 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
9448
9448
|
const user = c.get("user");
|
|
9449
9449
|
try {
|
|
9450
9450
|
const formData = await c.req.formData();
|
|
9451
|
-
const firstName =
|
|
9452
|
-
const lastName =
|
|
9453
|
-
const username =
|
|
9451
|
+
const firstName = chunkYTMFJLJZ_cjs.sanitizeInput(formData.get("first_name")?.toString());
|
|
9452
|
+
const lastName = chunkYTMFJLJZ_cjs.sanitizeInput(formData.get("last_name")?.toString());
|
|
9453
|
+
const username = chunkYTMFJLJZ_cjs.sanitizeInput(formData.get("username")?.toString());
|
|
9454
9454
|
const email = formData.get("email")?.toString()?.trim().toLowerCase() || "";
|
|
9455
|
-
const phone =
|
|
9456
|
-
const bio =
|
|
9455
|
+
const phone = chunkYTMFJLJZ_cjs.sanitizeInput(formData.get("phone")?.toString()) || null;
|
|
9456
|
+
const bio = chunkYTMFJLJZ_cjs.sanitizeInput(formData.get("bio")?.toString()) || null;
|
|
9457
9457
|
const role = formData.get("role")?.toString() || "viewer";
|
|
9458
9458
|
const password = formData.get("password")?.toString() || "";
|
|
9459
9459
|
const confirmPassword = formData.get("confirm_password")?.toString() || "";
|
|
@@ -9500,7 +9500,7 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
9500
9500
|
dismissible: true
|
|
9501
9501
|
}));
|
|
9502
9502
|
}
|
|
9503
|
-
const passwordHash = await
|
|
9503
|
+
const passwordHash = await chunkUEYMFNBN_cjs.AuthManager.hashPassword(password);
|
|
9504
9504
|
const userId = crypto.randomUUID();
|
|
9505
9505
|
const createStmt = db2.prepare(`
|
|
9506
9506
|
INSERT INTO users (
|
|
@@ -9523,7 +9523,7 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
9523
9523
|
Date.now(),
|
|
9524
9524
|
Date.now()
|
|
9525
9525
|
).run();
|
|
9526
|
-
await
|
|
9526
|
+
await chunkUEYMFNBN_cjs.logActivity(
|
|
9527
9527
|
db2,
|
|
9528
9528
|
user.userId,
|
|
9529
9529
|
"user!.create",
|
|
@@ -9561,7 +9561,7 @@ userRoutes.get("/users/:id", async (c) => {
|
|
|
9561
9561
|
if (!userRecord) {
|
|
9562
9562
|
return c.json({ error: "User not found" }, 404);
|
|
9563
9563
|
}
|
|
9564
|
-
await
|
|
9564
|
+
await chunkUEYMFNBN_cjs.logActivity(
|
|
9565
9565
|
db2,
|
|
9566
9566
|
user.userId,
|
|
9567
9567
|
"user!.view",
|
|
@@ -9654,12 +9654,12 @@ userRoutes.put("/users/:id", async (c) => {
|
|
|
9654
9654
|
const userId = c.req.param("id");
|
|
9655
9655
|
try {
|
|
9656
9656
|
const formData = await c.req.formData();
|
|
9657
|
-
const firstName =
|
|
9658
|
-
const lastName =
|
|
9659
|
-
const username =
|
|
9657
|
+
const firstName = chunkYTMFJLJZ_cjs.sanitizeInput(formData.get("first_name")?.toString());
|
|
9658
|
+
const lastName = chunkYTMFJLJZ_cjs.sanitizeInput(formData.get("last_name")?.toString());
|
|
9659
|
+
const username = chunkYTMFJLJZ_cjs.sanitizeInput(formData.get("username")?.toString());
|
|
9660
9660
|
const email = formData.get("email")?.toString()?.trim().toLowerCase() || "";
|
|
9661
|
-
const phone =
|
|
9662
|
-
const bio =
|
|
9661
|
+
const phone = chunkYTMFJLJZ_cjs.sanitizeInput(formData.get("phone")?.toString()) || null;
|
|
9662
|
+
const bio = chunkYTMFJLJZ_cjs.sanitizeInput(formData.get("bio")?.toString()) || null;
|
|
9663
9663
|
const role = formData.get("role")?.toString() || "viewer";
|
|
9664
9664
|
const isActive = formData.get("is_active") === "1";
|
|
9665
9665
|
const emailVerified = formData.get("email_verified") === "1";
|
|
@@ -9710,7 +9710,7 @@ userRoutes.put("/users/:id", async (c) => {
|
|
|
9710
9710
|
Date.now(),
|
|
9711
9711
|
userId
|
|
9712
9712
|
).run();
|
|
9713
|
-
await
|
|
9713
|
+
await chunkUEYMFNBN_cjs.logActivity(
|
|
9714
9714
|
db2,
|
|
9715
9715
|
user.userId,
|
|
9716
9716
|
"user!.update",
|
|
@@ -9755,7 +9755,7 @@ userRoutes.post("/users/:id/toggle", async (c) => {
|
|
|
9755
9755
|
UPDATE users SET is_active = ?, updated_at = ? WHERE id = ?
|
|
9756
9756
|
`);
|
|
9757
9757
|
await toggleStmt.bind(active ? 1 : 0, Date.now(), userId).run();
|
|
9758
|
-
await
|
|
9758
|
+
await chunkUEYMFNBN_cjs.logActivity(
|
|
9759
9759
|
db2,
|
|
9760
9760
|
user.userId,
|
|
9761
9761
|
active ? "user.activate" : "user.deactivate",
|
|
@@ -9796,7 +9796,7 @@ userRoutes.delete("/users/:id", async (c) => {
|
|
|
9796
9796
|
DELETE FROM users WHERE id = ?
|
|
9797
9797
|
`);
|
|
9798
9798
|
await deleteStmt.bind(userId).run();
|
|
9799
|
-
await
|
|
9799
|
+
await chunkUEYMFNBN_cjs.logActivity(
|
|
9800
9800
|
db2,
|
|
9801
9801
|
user.userId,
|
|
9802
9802
|
"user!.hard_delete",
|
|
@@ -9815,7 +9815,7 @@ userRoutes.delete("/users/:id", async (c) => {
|
|
|
9815
9815
|
UPDATE users SET is_active = 0, updated_at = ? WHERE id = ?
|
|
9816
9816
|
`);
|
|
9817
9817
|
await deleteStmt.bind(Date.now(), userId).run();
|
|
9818
|
-
await
|
|
9818
|
+
await chunkUEYMFNBN_cjs.logActivity(
|
|
9819
9819
|
db2,
|
|
9820
9820
|
user.userId,
|
|
9821
9821
|
"user!.soft_delete",
|
|
@@ -9842,8 +9842,8 @@ userRoutes.post("/invite-user", async (c) => {
|
|
|
9842
9842
|
const formData = await c.req.formData();
|
|
9843
9843
|
const email = formData.get("email")?.toString()?.trim().toLowerCase() || "";
|
|
9844
9844
|
const role = formData.get("role")?.toString()?.trim() || "viewer";
|
|
9845
|
-
const firstName =
|
|
9846
|
-
const lastName =
|
|
9845
|
+
const firstName = chunkYTMFJLJZ_cjs.sanitizeInput(formData.get("first_name")?.toString());
|
|
9846
|
+
const lastName = chunkYTMFJLJZ_cjs.sanitizeInput(formData.get("last_name")?.toString());
|
|
9847
9847
|
if (!email || !firstName || !lastName) {
|
|
9848
9848
|
return c.json({ error: "Email, first name, and last name are required" }, 400);
|
|
9849
9849
|
}
|
|
@@ -9881,7 +9881,7 @@ userRoutes.post("/invite-user", async (c) => {
|
|
|
9881
9881
|
Date.now(),
|
|
9882
9882
|
Date.now()
|
|
9883
9883
|
).run();
|
|
9884
|
-
await
|
|
9884
|
+
await chunkUEYMFNBN_cjs.logActivity(
|
|
9885
9885
|
db2,
|
|
9886
9886
|
user.userId,
|
|
9887
9887
|
"user!.invite_sent",
|
|
@@ -9938,7 +9938,7 @@ userRoutes.post("/resend-invitation/:id", async (c) => {
|
|
|
9938
9938
|
Date.now(),
|
|
9939
9939
|
userId
|
|
9940
9940
|
).run();
|
|
9941
|
-
await
|
|
9941
|
+
await chunkUEYMFNBN_cjs.logActivity(
|
|
9942
9942
|
db2,
|
|
9943
9943
|
user.userId,
|
|
9944
9944
|
"user!.invitation_resent",
|
|
@@ -9974,7 +9974,7 @@ userRoutes.delete("/cancel-invitation/:id", async (c) => {
|
|
|
9974
9974
|
}
|
|
9975
9975
|
const deleteStmt = db2.prepare(`DELETE FROM users WHERE id = ?`);
|
|
9976
9976
|
await deleteStmt.bind(userId).run();
|
|
9977
|
-
await
|
|
9977
|
+
await chunkUEYMFNBN_cjs.logActivity(
|
|
9978
9978
|
db2,
|
|
9979
9979
|
user.userId,
|
|
9980
9980
|
"user!.invitation_cancelled",
|
|
@@ -10057,7 +10057,7 @@ userRoutes.get("/activity-logs", async (c) => {
|
|
|
10057
10057
|
...log,
|
|
10058
10058
|
details: log.details ? JSON.parse(log.details) : null
|
|
10059
10059
|
}));
|
|
10060
|
-
await
|
|
10060
|
+
await chunkUEYMFNBN_cjs.logActivity(
|
|
10061
10061
|
db2,
|
|
10062
10062
|
user.userId,
|
|
10063
10063
|
"activity.logs_viewed",
|
|
@@ -10164,7 +10164,7 @@ userRoutes.get("/activity-logs/export", async (c) => {
|
|
|
10164
10164
|
csvRows.push(row.join(","));
|
|
10165
10165
|
}
|
|
10166
10166
|
const csvContent = csvRows.join("\n");
|
|
10167
|
-
await
|
|
10167
|
+
await chunkUEYMFNBN_cjs.logActivity(
|
|
10168
10168
|
db2,
|
|
10169
10169
|
user.userId,
|
|
10170
10170
|
"activity.logs_exported",
|
|
@@ -11503,7 +11503,7 @@ var fileValidationSchema2 = zod.z.object({
|
|
|
11503
11503
|
// 50MB max
|
|
11504
11504
|
});
|
|
11505
11505
|
var adminMediaRoutes = new hono.Hono();
|
|
11506
|
-
adminMediaRoutes.use("*",
|
|
11506
|
+
adminMediaRoutes.use("*", chunkUEYMFNBN_cjs.requireAuth());
|
|
11507
11507
|
adminMediaRoutes.get("/", async (c) => {
|
|
11508
11508
|
try {
|
|
11509
11509
|
const user = c.get("user");
|
|
@@ -12082,7 +12082,7 @@ adminMediaRoutes.put("/:id", async (c) => {
|
|
|
12082
12082
|
`);
|
|
12083
12083
|
}
|
|
12084
12084
|
});
|
|
12085
|
-
adminMediaRoutes.delete("/cleanup",
|
|
12085
|
+
adminMediaRoutes.delete("/cleanup", chunkUEYMFNBN_cjs.requireRole("admin"), async (c) => {
|
|
12086
12086
|
try {
|
|
12087
12087
|
const db2 = c.env.DB;
|
|
12088
12088
|
const allMediaStmt = db2.prepare("SELECT id, r2_key, filename FROM media WHERE deleted_at IS NULL");
|
|
@@ -13686,7 +13686,7 @@ function formatTimestamp(timestamp) {
|
|
|
13686
13686
|
|
|
13687
13687
|
// src/routes/admin-plugins.ts
|
|
13688
13688
|
var adminPluginRoutes = new hono.Hono();
|
|
13689
|
-
adminPluginRoutes.use("*",
|
|
13689
|
+
adminPluginRoutes.use("*", chunkUEYMFNBN_cjs.requireAuth());
|
|
13690
13690
|
var AVAILABLE_PLUGINS = [
|
|
13691
13691
|
{
|
|
13692
13692
|
id: "third-party-faq",
|
|
@@ -13787,7 +13787,7 @@ adminPluginRoutes.get("/", async (c) => {
|
|
|
13787
13787
|
if (user?.role !== "admin") {
|
|
13788
13788
|
return c.text("Access denied", 403);
|
|
13789
13789
|
}
|
|
13790
|
-
const pluginService = new
|
|
13790
|
+
const pluginService = new chunkHV2I6API_cjs.PluginService(db2);
|
|
13791
13791
|
let installedPlugins = [];
|
|
13792
13792
|
let stats = { total: 0, active: 0, inactive: 0, errors: 0, uninstalled: 0 };
|
|
13793
13793
|
try {
|
|
@@ -13859,7 +13859,7 @@ adminPluginRoutes.get("/:id", async (c) => {
|
|
|
13859
13859
|
if (user?.role !== "admin") {
|
|
13860
13860
|
return c.redirect("/admin/plugins");
|
|
13861
13861
|
}
|
|
13862
|
-
const pluginService = new
|
|
13862
|
+
const pluginService = new chunkHV2I6API_cjs.PluginService(db2);
|
|
13863
13863
|
const plugin = await pluginService.getPlugin(pluginId);
|
|
13864
13864
|
if (!plugin) {
|
|
13865
13865
|
return c.text("Plugin not found", 404);
|
|
@@ -13913,7 +13913,7 @@ adminPluginRoutes.post("/:id/activate", async (c) => {
|
|
|
13913
13913
|
if (user?.role !== "admin") {
|
|
13914
13914
|
return c.json({ error: "Access denied" }, 403);
|
|
13915
13915
|
}
|
|
13916
|
-
const pluginService = new
|
|
13916
|
+
const pluginService = new chunkHV2I6API_cjs.PluginService(db2);
|
|
13917
13917
|
await pluginService.activatePlugin(pluginId);
|
|
13918
13918
|
return c.json({ success: true });
|
|
13919
13919
|
} catch (error) {
|
|
@@ -13930,7 +13930,7 @@ adminPluginRoutes.post("/:id/deactivate", async (c) => {
|
|
|
13930
13930
|
if (user?.role !== "admin") {
|
|
13931
13931
|
return c.json({ error: "Access denied" }, 403);
|
|
13932
13932
|
}
|
|
13933
|
-
const pluginService = new
|
|
13933
|
+
const pluginService = new chunkHV2I6API_cjs.PluginService(db2);
|
|
13934
13934
|
await pluginService.deactivatePlugin(pluginId);
|
|
13935
13935
|
return c.json({ success: true });
|
|
13936
13936
|
} catch (error) {
|
|
@@ -13947,7 +13947,7 @@ adminPluginRoutes.post("/install", async (c) => {
|
|
|
13947
13947
|
return c.json({ error: "Access denied" }, 403);
|
|
13948
13948
|
}
|
|
13949
13949
|
const body = await c.req.json();
|
|
13950
|
-
const pluginService = new
|
|
13950
|
+
const pluginService = new chunkHV2I6API_cjs.PluginService(db2);
|
|
13951
13951
|
if (body.name === "faq-plugin") {
|
|
13952
13952
|
const faqPlugin = await pluginService.installPlugin({
|
|
13953
13953
|
id: "third-party-faq",
|
|
@@ -14163,7 +14163,7 @@ adminPluginRoutes.post("/:id/uninstall", async (c) => {
|
|
|
14163
14163
|
if (user?.role !== "admin") {
|
|
14164
14164
|
return c.json({ error: "Access denied" }, 403);
|
|
14165
14165
|
}
|
|
14166
|
-
const pluginService = new
|
|
14166
|
+
const pluginService = new chunkHV2I6API_cjs.PluginService(db2);
|
|
14167
14167
|
await pluginService.uninstallPlugin(pluginId);
|
|
14168
14168
|
return c.json({ success: true });
|
|
14169
14169
|
} catch (error) {
|
|
@@ -14181,7 +14181,7 @@ adminPluginRoutes.post("/:id/settings", async (c) => {
|
|
|
14181
14181
|
return c.json({ error: "Access denied" }, 403);
|
|
14182
14182
|
}
|
|
14183
14183
|
const settings = await c.req.json();
|
|
14184
|
-
const pluginService = new
|
|
14184
|
+
const pluginService = new chunkHV2I6API_cjs.PluginService(db2);
|
|
14185
14185
|
await pluginService.updatePluginSettings(pluginId, settings);
|
|
14186
14186
|
return c.json({ success: true });
|
|
14187
14187
|
} catch (error) {
|
|
@@ -14977,11 +14977,11 @@ function renderLogConfigPage(data) {
|
|
|
14977
14977
|
|
|
14978
14978
|
// src/routes/admin-logs.ts
|
|
14979
14979
|
var adminLogsRoutes = new hono.Hono();
|
|
14980
|
-
adminLogsRoutes.use("*",
|
|
14980
|
+
adminLogsRoutes.use("*", chunkUEYMFNBN_cjs.requireAuth());
|
|
14981
14981
|
adminLogsRoutes.get("/", async (c) => {
|
|
14982
14982
|
try {
|
|
14983
14983
|
const user = c.get("user");
|
|
14984
|
-
const logger =
|
|
14984
|
+
const logger = chunkAINTFRTC_cjs.getLogger(c.env.DB);
|
|
14985
14985
|
const query = c.req.query();
|
|
14986
14986
|
const page = parseInt(query.page || "1");
|
|
14987
14987
|
const limit = parseInt(query.limit || "50");
|
|
@@ -15061,7 +15061,7 @@ adminLogsRoutes.get("/:id", async (c) => {
|
|
|
15061
15061
|
try {
|
|
15062
15062
|
const id = c.req.param("id");
|
|
15063
15063
|
const user = c.get("user");
|
|
15064
|
-
const logger =
|
|
15064
|
+
const logger = chunkAINTFRTC_cjs.getLogger(c.env.DB);
|
|
15065
15065
|
const { logs } = await logger.getLogs({
|
|
15066
15066
|
limit: 1,
|
|
15067
15067
|
offset: 0,
|
|
@@ -15098,7 +15098,7 @@ adminLogsRoutes.get("/:id", async (c) => {
|
|
|
15098
15098
|
adminLogsRoutes.get("/config", async (c) => {
|
|
15099
15099
|
try {
|
|
15100
15100
|
const user = c.get("user");
|
|
15101
|
-
const logger =
|
|
15101
|
+
const logger = chunkAINTFRTC_cjs.getLogger(c.env.DB);
|
|
15102
15102
|
const configs = await logger.getAllConfigs();
|
|
15103
15103
|
const pageData = {
|
|
15104
15104
|
configs,
|
|
@@ -15122,7 +15122,7 @@ adminLogsRoutes.post("/config/:category", async (c) => {
|
|
|
15122
15122
|
const level = formData.get("level");
|
|
15123
15123
|
const retention = parseInt(formData.get("retention"));
|
|
15124
15124
|
const maxSize = parseInt(formData.get("max_size"));
|
|
15125
|
-
const logger =
|
|
15125
|
+
const logger = chunkAINTFRTC_cjs.getLogger(c.env.DB);
|
|
15126
15126
|
await logger.updateConfig(category, {
|
|
15127
15127
|
enabled,
|
|
15128
15128
|
level,
|
|
@@ -15151,7 +15151,7 @@ adminLogsRoutes.get("/export", async (c) => {
|
|
|
15151
15151
|
const category = query.category;
|
|
15152
15152
|
const startDate = query.start_date;
|
|
15153
15153
|
const endDate = query.end_date;
|
|
15154
|
-
const logger =
|
|
15154
|
+
const logger = chunkAINTFRTC_cjs.getLogger(c.env.DB);
|
|
15155
15155
|
const filter = {
|
|
15156
15156
|
limit: 1e4,
|
|
15157
15157
|
// Export up to 10k logs
|
|
@@ -15232,7 +15232,7 @@ adminLogsRoutes.post("/cleanup", async (c) => {
|
|
|
15232
15232
|
error: "Unauthorized. Admin access required."
|
|
15233
15233
|
}, 403);
|
|
15234
15234
|
}
|
|
15235
|
-
const logger =
|
|
15235
|
+
const logger = chunkAINTFRTC_cjs.getLogger(c.env.DB);
|
|
15236
15236
|
await logger.cleanupByRetention();
|
|
15237
15237
|
return c.html(html.html`
|
|
15238
15238
|
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded">
|
|
@@ -15254,7 +15254,7 @@ adminLogsRoutes.post("/search", async (c) => {
|
|
|
15254
15254
|
const search = formData.get("search");
|
|
15255
15255
|
const level = formData.get("level");
|
|
15256
15256
|
const category = formData.get("category");
|
|
15257
|
-
const logger =
|
|
15257
|
+
const logger = chunkAINTFRTC_cjs.getLogger(c.env.DB);
|
|
15258
15258
|
const filter = {
|
|
15259
15259
|
limit: 20,
|
|
15260
15260
|
offset: 0,
|
|
@@ -17305,9 +17305,9 @@ function renderStorageUsage(databaseSizeBytes, mediaSizeBytes) {
|
|
|
17305
17305
|
}
|
|
17306
17306
|
|
|
17307
17307
|
// src/routes/admin-dashboard.ts
|
|
17308
|
-
var VERSION =
|
|
17308
|
+
var VERSION = chunkYTMFJLJZ_cjs.getCoreVersion();
|
|
17309
17309
|
var router = new hono.Hono();
|
|
17310
|
-
router.use("*",
|
|
17310
|
+
router.use("*", chunkUEYMFNBN_cjs.requireAuth());
|
|
17311
17311
|
router.get("/", async (c) => {
|
|
17312
17312
|
const user = c.get("user");
|
|
17313
17313
|
try {
|
|
@@ -19061,7 +19061,7 @@ function renderCollectionFormPage(data) {
|
|
|
19061
19061
|
|
|
19062
19062
|
// src/routes/admin-collections.ts
|
|
19063
19063
|
var adminCollectionsRoutes = new hono.Hono();
|
|
19064
|
-
adminCollectionsRoutes.use("*",
|
|
19064
|
+
adminCollectionsRoutes.use("*", chunkUEYMFNBN_cjs.requireAuth());
|
|
19065
19065
|
adminCollectionsRoutes.get("/", async (c) => {
|
|
19066
19066
|
try {
|
|
19067
19067
|
const user = c.get("user");
|
|
@@ -21121,7 +21121,7 @@ function renderDatabaseToolsSettings(settings) {
|
|
|
21121
21121
|
|
|
21122
21122
|
// src/routes/admin-settings.ts
|
|
21123
21123
|
var adminSettingsRoutes = new hono.Hono();
|
|
21124
|
-
adminSettingsRoutes.use("*",
|
|
21124
|
+
adminSettingsRoutes.use("*", chunkUEYMFNBN_cjs.requireAuth());
|
|
21125
21125
|
function getMockSettings(user) {
|
|
21126
21126
|
return {
|
|
21127
21127
|
general: {
|
|
@@ -21186,7 +21186,7 @@ adminSettingsRoutes.get("/", (c) => {
|
|
|
21186
21186
|
adminSettingsRoutes.get("/general", async (c) => {
|
|
21187
21187
|
const user = c.get("user");
|
|
21188
21188
|
const db2 = c.env.DB;
|
|
21189
|
-
const settingsService = new
|
|
21189
|
+
const settingsService = new chunkAINTFRTC_cjs.SettingsService(db2);
|
|
21190
21190
|
const generalSettings = await settingsService.getGeneralSettings(user?.email);
|
|
21191
21191
|
const mockSettings = getMockSettings(user);
|
|
21192
21192
|
mockSettings.general = generalSettings;
|
|
@@ -21488,7 +21488,7 @@ adminSettingsRoutes.post("/general", async (c) => {
|
|
|
21488
21488
|
}
|
|
21489
21489
|
const formData = await c.req.formData();
|
|
21490
21490
|
const db2 = c.env.DB;
|
|
21491
|
-
const settingsService = new
|
|
21491
|
+
const settingsService = new chunkAINTFRTC_cjs.SettingsService(db2);
|
|
21492
21492
|
const settings = {
|
|
21493
21493
|
siteName: formData.get("siteName"),
|
|
21494
21494
|
siteDescription: formData.get("siteDescription"),
|
|
@@ -21576,5 +21576,5 @@ exports.auth_default = auth_default;
|
|
|
21576
21576
|
exports.router = router;
|
|
21577
21577
|
exports.test_cleanup_default = test_cleanup_default;
|
|
21578
21578
|
exports.userRoutes = userRoutes;
|
|
21579
|
-
//# sourceMappingURL=chunk-
|
|
21580
|
-
//# sourceMappingURL=chunk-
|
|
21579
|
+
//# sourceMappingURL=chunk-2DIWLDCA.cjs.map
|
|
21580
|
+
//# sourceMappingURL=chunk-2DIWLDCA.cjs.map
|