@sonicjs-cms/core 2.17.0 → 2.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/{chunk-J5MYHM6Z.cjs → chunk-2VY2G7OR.cjs} +125 -127
  2. package/dist/chunk-2VY2G7OR.cjs.map +1 -0
  3. package/dist/{chunk-4HCUJ3MG.cjs → chunk-FXWF5D5V.cjs} +2 -2
  4. package/dist/{chunk-4HCUJ3MG.cjs.map → chunk-FXWF5D5V.cjs.map} +1 -1
  5. package/dist/{chunk-6F57Z6SD.js → chunk-I2Z72YTD.js} +54 -3
  6. package/dist/chunk-I2Z72YTD.js.map +1 -0
  7. package/dist/{chunk-NMJT6BJR.js → chunk-ITGOUYVN.js} +2 -2
  8. package/dist/{chunk-NMJT6BJR.js.map → chunk-ITGOUYVN.js.map} +1 -1
  9. package/dist/{chunk-S7K4FRJ2.js → chunk-K6QVIOTA.js} +4 -4
  10. package/dist/{chunk-S7K4FRJ2.js.map → chunk-K6QVIOTA.js.map} +1 -1
  11. package/dist/{chunk-LZJLWW7E.js → chunk-KJSZMIBF.js} +11 -13
  12. package/dist/chunk-KJSZMIBF.js.map +1 -0
  13. package/dist/{chunk-FSWP4FBW.cjs → chunk-LVGB5UU5.cjs} +2 -2
  14. package/dist/{chunk-FSWP4FBW.cjs.map → chunk-LVGB5UU5.cjs.map} +1 -1
  15. package/dist/{chunk-FDXNIZ6N.js → chunk-NAYUXSNR.js} +2 -2
  16. package/dist/{chunk-FDXNIZ6N.js.map → chunk-NAYUXSNR.js.map} +1 -1
  17. package/dist/{chunk-RE3NVA23.cjs → chunk-P4RAIX7B.cjs} +8 -8
  18. package/dist/{chunk-RE3NVA23.cjs.map → chunk-P4RAIX7B.cjs.map} +1 -1
  19. package/dist/{chunk-QBLBIAVZ.cjs → chunk-Q3W6LCEN.cjs} +54 -3
  20. package/dist/chunk-Q3W6LCEN.cjs.map +1 -0
  21. package/dist/index.cjs +140 -140
  22. package/dist/index.d.cts +1 -1
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.js +9 -9
  25. package/dist/middleware.cjs +32 -32
  26. package/dist/middleware.js +3 -3
  27. package/dist/migrations-IFZLGVV3.js +4 -0
  28. package/dist/{migrations-HQI62CAO.js.map → migrations-IFZLGVV3.js.map} +1 -1
  29. package/dist/migrations-Q7C6F2RM.cjs +13 -0
  30. package/dist/{migrations-ZYPYVSXI.cjs.map → migrations-Q7C6F2RM.cjs.map} +1 -1
  31. package/dist/routes.cjs +28 -28
  32. package/dist/routes.js +5 -5
  33. package/dist/services.cjs +23 -23
  34. package/dist/services.js +2 -2
  35. package/dist/utils.cjs +11 -11
  36. package/dist/utils.d.cts +1 -1
  37. package/dist/utils.d.ts +1 -1
  38. package/dist/utils.js +1 -1
  39. package/dist/{version-ChpccWQ1.d.cts → version-DFTyGfIH.d.cts} +9 -1
  40. package/dist/{version-ChpccWQ1.d.ts → version-DFTyGfIH.d.ts} +9 -1
  41. package/package.json +1 -1
  42. package/dist/chunk-6F57Z6SD.js.map +0 -1
  43. package/dist/chunk-J5MYHM6Z.cjs.map +0 -1
  44. package/dist/chunk-LZJLWW7E.js.map +0 -1
  45. package/dist/chunk-QBLBIAVZ.cjs.map +0 -1
  46. package/dist/migrations-HQI62CAO.js +0 -4
  47. package/dist/migrations-ZYPYVSXI.cjs +0 -13
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkWAEQXGCX_cjs = require('./chunk-WAEQXGCX.cjs');
4
- var chunkRE3NVA23_cjs = require('./chunk-RE3NVA23.cjs');
5
- var chunk4HCUJ3MG_cjs = require('./chunk-4HCUJ3MG.cjs');
6
- var chunkFSWP4FBW_cjs = require('./chunk-FSWP4FBW.cjs');
4
+ var chunkP4RAIX7B_cjs = require('./chunk-P4RAIX7B.cjs');
5
+ var chunkFXWF5D5V_cjs = require('./chunk-FXWF5D5V.cjs');
6
+ var chunkLVGB5UU5_cjs = require('./chunk-LVGB5UU5.cjs');
7
7
  var chunkOHYBNCVL_cjs = require('./chunk-OHYBNCVL.cjs');
8
8
  var chunkUYJ6TJHX_cjs = require('./chunk-UYJ6TJHX.cjs');
9
9
  var chunk635JAMSE_cjs = require('./chunk-635JAMSE.cjs');
10
- var chunkQBLBIAVZ_cjs = require('./chunk-QBLBIAVZ.cjs');
10
+ var chunkQ3W6LCEN_cjs = require('./chunk-Q3W6LCEN.cjs');
11
11
  var chunkRCQ2HIQD_cjs = require('./chunk-RCQ2HIQD.cjs');
12
12
  var chunkMNWKYY5E_cjs = require('./chunk-MNWKYY5E.cjs');
13
13
  var hono = require('hono');
@@ -189,7 +189,7 @@ apiContentCrudRoutes.get("/:id", async (c) => {
189
189
  }, 500);
190
190
  }
191
191
  });
192
- apiContentCrudRoutes.post("/", chunkRE3NVA23_cjs.requireAuth(), chunkRE3NVA23_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
192
+ apiContentCrudRoutes.post("/", chunkP4RAIX7B_cjs.requireAuth(), chunkP4RAIX7B_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
193
193
  try {
194
194
  const db = c.env.DB;
195
195
  const user = c.get("user");
@@ -255,7 +255,7 @@ apiContentCrudRoutes.post("/", chunkRE3NVA23_cjs.requireAuth(), chunkRE3NVA23_cj
255
255
  }, 500);
256
256
  }
257
257
  });
258
- apiContentCrudRoutes.put("/:id", chunkRE3NVA23_cjs.requireAuth(), chunkRE3NVA23_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
258
+ apiContentCrudRoutes.put("/:id", chunkP4RAIX7B_cjs.requireAuth(), chunkP4RAIX7B_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
259
259
  try {
260
260
  const id = c.req.param("id");
261
261
  const db = c.env.DB;
@@ -319,7 +319,7 @@ apiContentCrudRoutes.put("/:id", chunkRE3NVA23_cjs.requireAuth(), chunkRE3NVA23_
319
319
  }, 500);
320
320
  }
321
321
  });
322
- apiContentCrudRoutes.delete("/:id", chunkRE3NVA23_cjs.requireAuth(), chunkRE3NVA23_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
322
+ apiContentCrudRoutes.delete("/:id", chunkP4RAIX7B_cjs.requireAuth(), chunkP4RAIX7B_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
323
323
  try {
324
324
  const id = c.req.param("id");
325
325
  const db = c.env.DB;
@@ -355,7 +355,7 @@ apiRoutes.use("*", async (c, next) => {
355
355
  c.header("X-Response-Time", `${totalTime}ms`);
356
356
  });
357
357
  apiRoutes.use("*", async (c, next) => {
358
- const cacheEnabled = await chunkRE3NVA23_cjs.isPluginActive(c.env.DB, "core-cache");
358
+ const cacheEnabled = await chunkP4RAIX7B_cjs.isPluginActive(c.env.DB, "core-cache");
359
359
  c.set("cacheEnabled", cacheEnabled);
360
360
  await next();
361
361
  });
@@ -846,7 +846,7 @@ apiRoutes.get("/collections", async (c) => {
846
846
  return c.json({ error: "Failed to fetch collections" }, 500);
847
847
  }
848
848
  });
849
- apiRoutes.get("/content", chunkRE3NVA23_cjs.optionalAuth(), async (c) => {
849
+ apiRoutes.get("/content", chunkP4RAIX7B_cjs.optionalAuth(), async (c) => {
850
850
  const executionStart = Date.now();
851
851
  try {
852
852
  const db = c.env.DB;
@@ -869,13 +869,13 @@ apiRoutes.get("/content", chunkRE3NVA23_cjs.optionalAuth(), async (c) => {
869
869
  });
870
870
  }
871
871
  }
872
- const filter = chunkQBLBIAVZ_cjs.QueryFilterBuilder.parseFromQuery(queryParams);
872
+ const filter = chunkQ3W6LCEN_cjs.QueryFilterBuilder.parseFromQuery(queryParams);
873
873
  const normalizedFilter = normalizePublicContentFilter(filter, c.get("user")?.role);
874
874
  if (!normalizedFilter.limit) {
875
875
  normalizedFilter.limit = 50;
876
876
  }
877
877
  normalizedFilter.limit = Math.min(normalizedFilter.limit, 1e3);
878
- const builder3 = new chunkQBLBIAVZ_cjs.QueryFilterBuilder();
878
+ const builder3 = new chunkQ3W6LCEN_cjs.QueryFilterBuilder();
879
879
  const queryResult = builder3.build("content", normalizedFilter);
880
880
  if (queryResult.errors.length > 0) {
881
881
  return c.json({
@@ -947,7 +947,7 @@ apiRoutes.get("/content", chunkRE3NVA23_cjs.optionalAuth(), async (c) => {
947
947
  }, 500);
948
948
  }
949
949
  });
950
- apiRoutes.get("/collections/:collection/content", chunkRE3NVA23_cjs.optionalAuth(), async (c) => {
950
+ apiRoutes.get("/collections/:collection/content", chunkP4RAIX7B_cjs.optionalAuth(), async (c) => {
951
951
  const executionStart = Date.now();
952
952
  try {
953
953
  const collection = c.req.param("collection");
@@ -958,7 +958,7 @@ apiRoutes.get("/collections/:collection/content", chunkRE3NVA23_cjs.optionalAuth
958
958
  if (!collectionResult) {
959
959
  return c.json({ error: "Collection not found" }, 404);
960
960
  }
961
- const filter = chunkQBLBIAVZ_cjs.QueryFilterBuilder.parseFromQuery(queryParams);
961
+ const filter = chunkQ3W6LCEN_cjs.QueryFilterBuilder.parseFromQuery(queryParams);
962
962
  const normalizedFilter = normalizePublicContentFilter(filter, c.get("user")?.role);
963
963
  if (!normalizedFilter.where) {
964
964
  normalizedFilter.where = { and: [] };
@@ -975,7 +975,7 @@ apiRoutes.get("/collections/:collection/content", chunkRE3NVA23_cjs.optionalAuth
975
975
  normalizedFilter.limit = 50;
976
976
  }
977
977
  normalizedFilter.limit = Math.min(normalizedFilter.limit, 1e3);
978
- const builder3 = new chunkQBLBIAVZ_cjs.QueryFilterBuilder();
978
+ const builder3 = new chunkQ3W6LCEN_cjs.QueryFilterBuilder();
979
979
  const queryResult = builder3.build("content", normalizedFilter);
980
980
  if (queryResult.errors.length > 0) {
981
981
  return c.json({
@@ -1096,7 +1096,7 @@ var fileValidationSchema = zod.z.object({
1096
1096
  // 50MB max
1097
1097
  });
1098
1098
  var apiMediaRoutes = new hono.Hono();
1099
- apiMediaRoutes.use("*", chunkRE3NVA23_cjs.requireAuth());
1099
+ apiMediaRoutes.use("*", chunkP4RAIX7B_cjs.requireAuth());
1100
1100
  apiMediaRoutes.post("/upload", async (c) => {
1101
1101
  try {
1102
1102
  const user = c.get("user");
@@ -1840,8 +1840,8 @@ apiSystemRoutes.get("/env", (c) => {
1840
1840
  });
1841
1841
  var api_system_default = apiSystemRoutes;
1842
1842
  var adminApiRoutes = new hono.Hono();
1843
- adminApiRoutes.use("*", chunkRE3NVA23_cjs.requireAuth());
1844
- adminApiRoutes.use("*", chunkRE3NVA23_cjs.requireRole(["admin", "editor"]));
1843
+ adminApiRoutes.use("*", chunkP4RAIX7B_cjs.requireAuth());
1844
+ adminApiRoutes.use("*", chunkP4RAIX7B_cjs.requireRole(["admin", "editor"]));
1845
1845
  adminApiRoutes.get("/stats", async (c) => {
1846
1846
  try {
1847
1847
  const db = c.env.DB;
@@ -2353,7 +2353,7 @@ adminApiRoutes.delete("/collections/:id", async (c) => {
2353
2353
  });
2354
2354
  adminApiRoutes.get("/migrations/status", async (c) => {
2355
2355
  try {
2356
- const { MigrationService: MigrationService2 } = await import('./migrations-ZYPYVSXI.cjs');
2356
+ const { MigrationService: MigrationService2 } = await import('./migrations-Q7C6F2RM.cjs');
2357
2357
  const db = c.env.DB;
2358
2358
  const migrationService = new MigrationService2(db);
2359
2359
  const status = await migrationService.getMigrationStatus();
@@ -2378,7 +2378,7 @@ adminApiRoutes.post("/migrations/run", async (c) => {
2378
2378
  error: "Unauthorized. Admin access required."
2379
2379
  }, 403);
2380
2380
  }
2381
- const { MigrationService: MigrationService2 } = await import('./migrations-ZYPYVSXI.cjs');
2381
+ const { MigrationService: MigrationService2 } = await import('./migrations-Q7C6F2RM.cjs');
2382
2382
  const db = c.env.DB;
2383
2383
  const migrationService = new MigrationService2(db);
2384
2384
  const result = await migrationService.runPendingMigrations();
@@ -2400,7 +2400,7 @@ adminApiRoutes.post("/migrations/run", async (c) => {
2400
2400
  });
2401
2401
  adminApiRoutes.get("/migrations/validate", async (c) => {
2402
2402
  try {
2403
- const { MigrationService: MigrationService2 } = await import('./migrations-ZYPYVSXI.cjs');
2403
+ const { MigrationService: MigrationService2 } = await import('./migrations-Q7C6F2RM.cjs');
2404
2404
  const db = c.env.DB;
2405
2405
  const migrationService = new MigrationService2(db);
2406
2406
  const validation = await migrationService.validateSchema();
@@ -5153,8 +5153,8 @@ var JWT_SECRET_FALLBACK = "your-super-secret-jwt-key-change-in-production";
5153
5153
  async function setCsrfCookie(c, maxAge) {
5154
5154
  const secret = c.env?.JWT_SECRET || JWT_SECRET_FALLBACK;
5155
5155
  const isDev = c.env?.ENVIRONMENT === "development" || !c.env?.ENVIRONMENT;
5156
- const csrfToken = await chunkRE3NVA23_cjs.generateCsrfToken(secret);
5157
- const cookieMaxAge = await chunkRE3NVA23_cjs.getJwtExpirySecondsFromDb(c.env?.DB, c.env);
5156
+ const csrfToken = await chunkP4RAIX7B_cjs.generateCsrfToken(secret);
5157
+ const cookieMaxAge = await chunkP4RAIX7B_cjs.getJwtExpirySecondsFromDb(c.env?.DB, c.env);
5158
5158
  cookie.setCookie(c, "csrf_token", csrfToken, {
5159
5159
  httpOnly: false,
5160
5160
  secure: !isDev,
@@ -5211,7 +5211,7 @@ var loginSchema = zod.z.object({
5211
5211
  });
5212
5212
  authRoutes.post(
5213
5213
  "/register",
5214
- chunkRE3NVA23_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "register" }),
5214
+ chunkP4RAIX7B_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "register" }),
5215
5215
  async (c) => {
5216
5216
  try {
5217
5217
  const db = c.env.DB;
@@ -5248,7 +5248,7 @@ authRoutes.post(
5248
5248
  if (existingUser) {
5249
5249
  return c.json({ error: "User with this email or username already exists" }, 400);
5250
5250
  }
5251
- const passwordHash = await chunkRE3NVA23_cjs.AuthManager.hashPassword(password);
5251
+ const passwordHash = await chunkP4RAIX7B_cjs.AuthManager.hashPassword(password);
5252
5252
  const userId = crypto.randomUUID();
5253
5253
  const now = /* @__PURE__ */ new Date();
5254
5254
  await db.prepare(`
@@ -5282,8 +5282,8 @@ authRoutes.post(
5282
5282
  await saveCustomData(db, userId, sanitized);
5283
5283
  }
5284
5284
  }
5285
- const tokenTtl = await chunkRE3NVA23_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
5286
- const token = await chunkRE3NVA23_cjs.AuthManager.generateToken(userId, normalizedEmail, "viewer", c.env.JWT_SECRET, tokenTtl);
5285
+ const tokenTtl = await chunkP4RAIX7B_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
5286
+ const token = await chunkP4RAIX7B_cjs.AuthManager.generateToken(userId, normalizedEmail, "viewer", c.env.JWT_SECRET, tokenTtl);
5287
5287
  cookie.setCookie(c, "auth_token", token, {
5288
5288
  httpOnly: true,
5289
5289
  secure: true,
@@ -5316,7 +5316,7 @@ authRoutes.post(
5316
5316
  );
5317
5317
  authRoutes.post(
5318
5318
  "/login",
5319
- chunkRE3NVA23_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "login" }),
5319
+ chunkP4RAIX7B_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "login" }),
5320
5320
  async (c) => {
5321
5321
  try {
5322
5322
  const body = await c.req.json();
@@ -5339,20 +5339,20 @@ authRoutes.post(
5339
5339
  if (!user) {
5340
5340
  return c.json({ error: "Invalid email or password" }, 401);
5341
5341
  }
5342
- const isValidPassword = await chunkRE3NVA23_cjs.AuthManager.verifyPassword(password, user.password_hash);
5342
+ const isValidPassword = await chunkP4RAIX7B_cjs.AuthManager.verifyPassword(password, user.password_hash);
5343
5343
  if (!isValidPassword) {
5344
5344
  return c.json({ error: "Invalid email or password" }, 401);
5345
5345
  }
5346
- if (chunkRE3NVA23_cjs.AuthManager.isLegacyHash(user.password_hash)) {
5346
+ if (chunkP4RAIX7B_cjs.AuthManager.isLegacyHash(user.password_hash)) {
5347
5347
  try {
5348
- const newHash = await chunkRE3NVA23_cjs.AuthManager.hashPassword(password);
5348
+ const newHash = await chunkP4RAIX7B_cjs.AuthManager.hashPassword(password);
5349
5349
  await db.prepare("UPDATE users SET password_hash = ?, updated_at = ? WHERE id = ?").bind(newHash, Date.now(), user.id).run();
5350
5350
  } catch (rehashError) {
5351
5351
  console.error("Password rehash failed (non-fatal):", rehashError);
5352
5352
  }
5353
5353
  }
5354
- const tokenTtl = await chunkRE3NVA23_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
5355
- const token = await chunkRE3NVA23_cjs.AuthManager.generateToken(user.id, user.email, user.role, c.env.JWT_SECRET, tokenTtl);
5354
+ const tokenTtl = await chunkP4RAIX7B_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
5355
+ const token = await chunkP4RAIX7B_cjs.AuthManager.generateToken(user.id, user.email, user.role, c.env.JWT_SECRET, tokenTtl);
5356
5356
  cookie.setCookie(c, "auth_token", token, {
5357
5357
  httpOnly: true,
5358
5358
  secure: true,
@@ -5404,7 +5404,7 @@ authRoutes.get("/logout", (c) => {
5404
5404
  clearCsrfCookie(c);
5405
5405
  return c.redirect("/auth/login?message=You have been logged out successfully");
5406
5406
  });
5407
- authRoutes.get("/me", chunkRE3NVA23_cjs.requireAuth(), async (c) => {
5407
+ authRoutes.get("/me", chunkP4RAIX7B_cjs.requireAuth(), async (c) => {
5408
5408
  try {
5409
5409
  const user = c.get("user");
5410
5410
  if (!user) {
@@ -5423,7 +5423,7 @@ authRoutes.get("/me", chunkRE3NVA23_cjs.requireAuth(), async (c) => {
5423
5423
  });
5424
5424
  authRoutes.post(
5425
5425
  "/refresh",
5426
- chunkRE3NVA23_cjs.rateLimit({ max: 60, windowMs: 60 * 1e3, keyPrefix: "refresh" }),
5426
+ chunkP4RAIX7B_cjs.rateLimit({ max: 60, windowMs: 60 * 1e3, keyPrefix: "refresh" }),
5427
5427
  async (c) => {
5428
5428
  try {
5429
5429
  let token = c.req.header("Authorization")?.replace("Bearer ", "");
@@ -5432,8 +5432,8 @@ authRoutes.post(
5432
5432
  return c.json({ error: "Authentication required" }, 401);
5433
5433
  }
5434
5434
  const db = c.env.DB;
5435
- const grace = await chunkRE3NVA23_cjs.getJwtRefreshGraceSecondsFromDb(db, c.env);
5436
- const payload = await chunkRE3NVA23_cjs.AuthManager.verifyToken(token, c.env.JWT_SECRET, grace);
5435
+ const grace = await chunkP4RAIX7B_cjs.getJwtRefreshGraceSecondsFromDb(db, c.env);
5436
+ const payload = await chunkP4RAIX7B_cjs.AuthManager.verifyToken(token, c.env.JWT_SECRET, grace);
5437
5437
  if (!payload) {
5438
5438
  return c.json({ error: "Invalid or expired token" }, 401);
5439
5439
  }
@@ -5441,8 +5441,8 @@ authRoutes.post(
5441
5441
  if (!row || !row.is_active) {
5442
5442
  return c.json({ error: "User is not active" }, 401);
5443
5443
  }
5444
- const tokenTtl = await chunkRE3NVA23_cjs.getJwtExpirySecondsFromDb(db, c.env);
5445
- const newToken = await chunkRE3NVA23_cjs.AuthManager.generateToken(row.id, row.email, row.role, c.env.JWT_SECRET, tokenTtl);
5444
+ const tokenTtl = await chunkP4RAIX7B_cjs.getJwtExpirySecondsFromDb(db, c.env);
5445
+ const newToken = await chunkP4RAIX7B_cjs.AuthManager.generateToken(row.id, row.email, row.role, c.env.JWT_SECRET, tokenTtl);
5446
5446
  cookie.setCookie(c, "auth_token", newToken, {
5447
5447
  httpOnly: true,
5448
5448
  secure: true,
@@ -5462,7 +5462,7 @@ authRoutes.post(
5462
5462
  );
5463
5463
  authRoutes.post(
5464
5464
  "/register/form",
5465
- chunkRE3NVA23_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "register" }),
5465
+ chunkP4RAIX7B_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "register" }),
5466
5466
  async (c) => {
5467
5467
  try {
5468
5468
  const db = c.env.DB;
@@ -5509,7 +5509,7 @@ authRoutes.post(
5509
5509
  </div>
5510
5510
  `);
5511
5511
  }
5512
- const passwordHash = await chunkRE3NVA23_cjs.AuthManager.hashPassword(password);
5512
+ const passwordHash = await chunkP4RAIX7B_cjs.AuthManager.hashPassword(password);
5513
5513
  const role = isFirstUser ? "admin" : "viewer";
5514
5514
  const userId = crypto.randomUUID();
5515
5515
  const now = /* @__PURE__ */ new Date();
@@ -5544,8 +5544,8 @@ authRoutes.post(
5544
5544
  await saveCustomData(db, userId, sanitized);
5545
5545
  }
5546
5546
  }
5547
- const tokenTtl = await chunkRE3NVA23_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
5548
- const token = await chunkRE3NVA23_cjs.AuthManager.generateToken(userId, normalizedEmail, role, c.env.JWT_SECRET, tokenTtl);
5547
+ const tokenTtl = await chunkP4RAIX7B_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
5548
+ const token = await chunkP4RAIX7B_cjs.AuthManager.generateToken(userId, normalizedEmail, role, c.env.JWT_SECRET, tokenTtl);
5549
5549
  cookie.setCookie(c, "auth_token", token, {
5550
5550
  httpOnly: true,
5551
5551
  secure: false,
@@ -5577,7 +5577,7 @@ authRoutes.post(
5577
5577
  );
5578
5578
  authRoutes.post(
5579
5579
  "/login/form",
5580
- chunkRE3NVA23_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "login" }),
5580
+ chunkP4RAIX7B_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "login" }),
5581
5581
  async (c) => {
5582
5582
  try {
5583
5583
  const formData = await c.req.formData();
@@ -5601,7 +5601,7 @@ authRoutes.post(
5601
5601
  </div>
5602
5602
  `);
5603
5603
  }
5604
- const isValidPassword = await chunkRE3NVA23_cjs.AuthManager.verifyPassword(password, user.password_hash);
5604
+ const isValidPassword = await chunkP4RAIX7B_cjs.AuthManager.verifyPassword(password, user.password_hash);
5605
5605
  if (!isValidPassword) {
5606
5606
  return c.html(html.html`
5607
5607
  <div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded">
@@ -5609,16 +5609,16 @@ authRoutes.post(
5609
5609
  </div>
5610
5610
  `);
5611
5611
  }
5612
- if (chunkRE3NVA23_cjs.AuthManager.isLegacyHash(user.password_hash)) {
5612
+ if (chunkP4RAIX7B_cjs.AuthManager.isLegacyHash(user.password_hash)) {
5613
5613
  try {
5614
- const newHash = await chunkRE3NVA23_cjs.AuthManager.hashPassword(password);
5614
+ const newHash = await chunkP4RAIX7B_cjs.AuthManager.hashPassword(password);
5615
5615
  await db.prepare("UPDATE users SET password_hash = ?, updated_at = ? WHERE id = ?").bind(newHash, Date.now(), user.id).run();
5616
5616
  } catch (rehashError) {
5617
5617
  console.error("Password rehash failed (non-fatal):", rehashError);
5618
5618
  }
5619
5619
  }
5620
- const tokenTtl = await chunkRE3NVA23_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
5621
- const token = await chunkRE3NVA23_cjs.AuthManager.generateToken(user.id, user.email, user.role, c.env.JWT_SECRET, tokenTtl);
5620
+ const tokenTtl = await chunkP4RAIX7B_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
5621
+ const token = await chunkP4RAIX7B_cjs.AuthManager.generateToken(user.id, user.email, user.role, c.env.JWT_SECRET, tokenTtl);
5622
5622
  cookie.setCookie(c, "auth_token", token, {
5623
5623
  httpOnly: true,
5624
5624
  secure: false,
@@ -5659,7 +5659,7 @@ authRoutes.post(
5659
5659
  );
5660
5660
  authRoutes.post(
5661
5661
  "/seed-admin",
5662
- chunkRE3NVA23_cjs.rateLimit({ max: 10, windowMs: 60 * 1e3, keyPrefix: "seed-admin" }),
5662
+ chunkP4RAIX7B_cjs.rateLimit({ max: 10, windowMs: 60 * 1e3, keyPrefix: "seed-admin" }),
5663
5663
  async (c) => {
5664
5664
  try {
5665
5665
  const db = c.env.DB;
@@ -5681,7 +5681,7 @@ authRoutes.post(
5681
5681
  `).run();
5682
5682
  const existingAdmin = await db.prepare("SELECT id FROM users WHERE email = ? OR username = ?").bind("admin@sonicjs.com", "admin").first();
5683
5683
  if (existingAdmin) {
5684
- const passwordHash2 = await chunkRE3NVA23_cjs.AuthManager.hashPassword("sonicjs!");
5684
+ const passwordHash2 = await chunkP4RAIX7B_cjs.AuthManager.hashPassword("sonicjs!");
5685
5685
  await db.prepare("UPDATE users SET password_hash = ?, updated_at = ? WHERE id = ?").bind(passwordHash2, Date.now(), existingAdmin.id).run();
5686
5686
  return c.json({
5687
5687
  message: "Admin user already exists (password updated)",
@@ -5693,7 +5693,7 @@ authRoutes.post(
5693
5693
  }
5694
5694
  });
5695
5695
  }
5696
- const passwordHash = await chunkRE3NVA23_cjs.AuthManager.hashPassword("sonicjs!");
5696
+ const passwordHash = await chunkP4RAIX7B_cjs.AuthManager.hashPassword("sonicjs!");
5697
5697
  const userId = "admin-user-id";
5698
5698
  const now = Date.now();
5699
5699
  const adminEmail = "admin@sonicjs.com".toLowerCase();
@@ -5914,7 +5914,7 @@ authRoutes.post("/accept-invitation", async (c) => {
5914
5914
  if (existingUsername) {
5915
5915
  return c.json({ error: "Username is already taken" }, 400);
5916
5916
  }
5917
- const passwordHash = await chunkRE3NVA23_cjs.AuthManager.hashPassword(password);
5917
+ const passwordHash = await chunkP4RAIX7B_cjs.AuthManager.hashPassword(password);
5918
5918
  const updateStmt = db.prepare(`
5919
5919
  UPDATE users SET
5920
5920
  username = ?,
@@ -5933,8 +5933,8 @@ authRoutes.post("/accept-invitation", async (c) => {
5933
5933
  Date.now(),
5934
5934
  invitedUser.id
5935
5935
  ).run();
5936
- const tokenTtl = await chunkRE3NVA23_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
5937
- const authToken = await chunkRE3NVA23_cjs.AuthManager.generateToken(invitedUser.id, invitedUser.email, invitedUser.role, c.env.JWT_SECRET, tokenTtl);
5936
+ const tokenTtl = await chunkP4RAIX7B_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
5937
+ const authToken = await chunkP4RAIX7B_cjs.AuthManager.generateToken(invitedUser.id, invitedUser.email, invitedUser.role, c.env.JWT_SECRET, tokenTtl);
5938
5938
  cookie.setCookie(c, "auth_token", authToken, {
5939
5939
  httpOnly: true,
5940
5940
  secure: true,
@@ -5950,7 +5950,7 @@ authRoutes.post("/accept-invitation", async (c) => {
5950
5950
  });
5951
5951
  authRoutes.post(
5952
5952
  "/request-password-reset",
5953
- chunkRE3NVA23_cjs.rateLimit({ max: 3, windowMs: 15 * 60 * 1e3, keyPrefix: "password-reset" }),
5953
+ chunkP4RAIX7B_cjs.rateLimit({ max: 3, windowMs: 15 * 60 * 1e3, keyPrefix: "password-reset" }),
5954
5954
  async (c) => {
5955
5955
  try {
5956
5956
  const formData = await c.req.formData();
@@ -6168,7 +6168,7 @@ authRoutes.post("/reset-password", async (c) => {
6168
6168
  if (Date.now() > user.password_reset_expires) {
6169
6169
  return c.json({ error: "Reset token has expired" }, 400);
6170
6170
  }
6171
- const newPasswordHash = await chunkRE3NVA23_cjs.AuthManager.hashPassword(password);
6171
+ const newPasswordHash = await chunkP4RAIX7B_cjs.AuthManager.hashPassword(password);
6172
6172
  try {
6173
6173
  const historyStmt = db.prepare(`
6174
6174
  INSERT INTO password_history (id, user_id, password_hash, created_at)
@@ -9544,9 +9544,9 @@ function parseFieldValue(field, formData, options = {}) {
9544
9544
  const { skipValidation = false } = options;
9545
9545
  const value = formData.get(field.field_name);
9546
9546
  const errors = [];
9547
- const blocksConfig = chunkQBLBIAVZ_cjs.getBlocksFieldConfig(field.field_options);
9547
+ const blocksConfig = chunkQ3W6LCEN_cjs.getBlocksFieldConfig(field.field_options);
9548
9548
  if (blocksConfig) {
9549
- const parsed = chunkQBLBIAVZ_cjs.parseBlocksValue(value, blocksConfig);
9549
+ const parsed = chunkQ3W6LCEN_cjs.parseBlocksValue(value, blocksConfig);
9550
9550
  if (!skipValidation && field.is_required && parsed.value.length === 0) {
9551
9551
  parsed.errors.push(`${field.field_label} is required`);
9552
9552
  }
@@ -9656,7 +9656,7 @@ function extractFieldData(fields, formData, options = {}) {
9656
9656
  }
9657
9657
  return { data, errors };
9658
9658
  }
9659
- adminContentRoutes.use("*", chunkRE3NVA23_cjs.requireAuth());
9659
+ adminContentRoutes.use("*", chunkP4RAIX7B_cjs.requireAuth());
9660
9660
  async function getCollectionFields(db, collectionId) {
9661
9661
  const cache = chunkWAEQXGCX_cjs.getCacheService(chunkWAEQXGCX_cjs.CACHE_CONFIGS.collection);
9662
9662
  return cache.getOrSet(
@@ -9933,21 +9933,21 @@ adminContentRoutes.get("/new", async (c) => {
9933
9933
  const tinymceEnabled = await isPluginActive2(db, "tinymce-plugin");
9934
9934
  let tinymceSettings;
9935
9935
  if (tinymceEnabled) {
9936
- const pluginService = new chunk4HCUJ3MG_cjs.PluginService(db);
9936
+ const pluginService = new chunkFXWF5D5V_cjs.PluginService(db);
9937
9937
  const tinymcePlugin2 = await pluginService.getPlugin("tinymce-plugin");
9938
9938
  tinymceSettings = tinymcePlugin2?.settings;
9939
9939
  }
9940
9940
  const quillEnabled = await isPluginActive2(db, "quill-editor");
9941
9941
  let quillSettings;
9942
9942
  if (quillEnabled) {
9943
- const pluginService = new chunk4HCUJ3MG_cjs.PluginService(db);
9943
+ const pluginService = new chunkFXWF5D5V_cjs.PluginService(db);
9944
9944
  const quillPlugin = await pluginService.getPlugin("quill-editor");
9945
9945
  quillSettings = quillPlugin?.settings;
9946
9946
  }
9947
9947
  const mdxeditorEnabled = await isPluginActive2(db, "easy-mdx");
9948
9948
  let mdxeditorSettings;
9949
9949
  if (mdxeditorEnabled) {
9950
- const pluginService = new chunk4HCUJ3MG_cjs.PluginService(db);
9950
+ const pluginService = new chunkFXWF5D5V_cjs.PluginService(db);
9951
9951
  const mdxeditorPlugin = await pluginService.getPlugin("easy-mdx");
9952
9952
  mdxeditorSettings = mdxeditorPlugin?.settings;
9953
9953
  }
@@ -10038,21 +10038,21 @@ adminContentRoutes.get("/:id/edit", async (c) => {
10038
10038
  const tinymceEnabled = await isPluginActive2(db, "tinymce-plugin");
10039
10039
  let tinymceSettings;
10040
10040
  if (tinymceEnabled) {
10041
- const pluginService = new chunk4HCUJ3MG_cjs.PluginService(db);
10041
+ const pluginService = new chunkFXWF5D5V_cjs.PluginService(db);
10042
10042
  const tinymcePlugin2 = await pluginService.getPlugin("tinymce-plugin");
10043
10043
  tinymceSettings = tinymcePlugin2?.settings;
10044
10044
  }
10045
10045
  const quillEnabled = await isPluginActive2(db, "quill-editor");
10046
10046
  let quillSettings;
10047
10047
  if (quillEnabled) {
10048
- const pluginService = new chunk4HCUJ3MG_cjs.PluginService(db);
10048
+ const pluginService = new chunkFXWF5D5V_cjs.PluginService(db);
10049
10049
  const quillPlugin = await pluginService.getPlugin("quill-editor");
10050
10050
  quillSettings = quillPlugin?.settings;
10051
10051
  }
10052
10052
  const mdxeditorEnabled = await isPluginActive2(db, "easy-mdx");
10053
10053
  let mdxeditorSettings;
10054
10054
  if (mdxeditorEnabled) {
10055
- const pluginService = new chunk4HCUJ3MG_cjs.PluginService(db);
10055
+ const pluginService = new chunkFXWF5D5V_cjs.PluginService(db);
10056
10056
  const mdxeditorPlugin = await pluginService.getPlugin("easy-mdx");
10057
10057
  mdxeditorSettings = mdxeditorPlugin?.settings;
10058
10058
  }
@@ -10347,7 +10347,7 @@ adminContentRoutes.put("/:id", async (c) => {
10347
10347
  `);
10348
10348
  }
10349
10349
  });
10350
- adminContentRoutes.post("/preview", chunkRE3NVA23_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
10350
+ adminContentRoutes.post("/preview", chunkP4RAIX7B_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
10351
10351
  try {
10352
10352
  const formData = await c.req.formData();
10353
10353
  const collectionId = formData.get("collection_id");
@@ -10725,7 +10725,7 @@ adminContentRoutes.post("/:id/restore/:version", async (c) => {
10725
10725
  return c.json({ success: false, error: "Failed to restore version" });
10726
10726
  }
10727
10727
  });
10728
- adminContentRoutes.get("/:id/version/:version/preview", chunkRE3NVA23_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
10728
+ adminContentRoutes.get("/:id/version/:version/preview", chunkP4RAIX7B_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
10729
10729
  try {
10730
10730
  const id = c.req.param("id");
10731
10731
  const version = parseInt(c.req.param("version") || "0");
@@ -11648,7 +11648,6 @@ function renderUserEditPage(data) {
11648
11648
  type="text"
11649
11649
  name="first_name"
11650
11650
  value="${chunkMNWKYY5E_cjs.escapeHtml(data.userToEdit.firstName || "")}"
11651
- required
11652
11651
  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"
11653
11652
  />
11654
11653
  </div>
@@ -11659,7 +11658,6 @@ function renderUserEditPage(data) {
11659
11658
  type="text"
11660
11659
  name="last_name"
11661
11660
  value="${chunkMNWKYY5E_cjs.escapeHtml(data.userToEdit.lastName || "")}"
11662
- required
11663
11661
  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"
11664
11662
  />
11665
11663
  </div>
@@ -12726,14 +12724,14 @@ function renderUsersListPage(data) {
12726
12724
 
12727
12725
  // src/routes/admin-users.ts
12728
12726
  var userRoutes = new hono.Hono();
12729
- userRoutes.use("*", chunkRE3NVA23_cjs.requireAuth());
12730
- userRoutes.use("/users/*", chunkRE3NVA23_cjs.requireRole(["admin"]));
12731
- userRoutes.use("/users", chunkRE3NVA23_cjs.requireRole(["admin"]));
12732
- userRoutes.use("/invite-user", chunkRE3NVA23_cjs.requireRole(["admin"]));
12733
- userRoutes.use("/resend-invitation/*", chunkRE3NVA23_cjs.requireRole(["admin"]));
12734
- userRoutes.use("/cancel-invitation/*", chunkRE3NVA23_cjs.requireRole(["admin"]));
12735
- userRoutes.use("/activity-logs", chunkRE3NVA23_cjs.requireRole(["admin"]));
12736
- userRoutes.use("/activity-logs/*", chunkRE3NVA23_cjs.requireRole(["admin"]));
12727
+ userRoutes.use("*", chunkP4RAIX7B_cjs.requireAuth());
12728
+ userRoutes.use("/users/*", chunkP4RAIX7B_cjs.requireRole(["admin"]));
12729
+ userRoutes.use("/users", chunkP4RAIX7B_cjs.requireRole(["admin"]));
12730
+ userRoutes.use("/invite-user", chunkP4RAIX7B_cjs.requireRole(["admin"]));
12731
+ userRoutes.use("/resend-invitation/*", chunkP4RAIX7B_cjs.requireRole(["admin"]));
12732
+ userRoutes.use("/cancel-invitation/*", chunkP4RAIX7B_cjs.requireRole(["admin"]));
12733
+ userRoutes.use("/activity-logs", chunkP4RAIX7B_cjs.requireRole(["admin"]));
12734
+ userRoutes.use("/activity-logs/*", chunkP4RAIX7B_cjs.requireRole(["admin"]));
12737
12735
  userRoutes.get("/", (c) => {
12738
12736
  return c.redirect("/admin/dashboard");
12739
12737
  });
@@ -12903,7 +12901,7 @@ userRoutes.put("/profile", async (c) => {
12903
12901
  }
12904
12902
  await saveCustomData(db, user.userId, sanitized);
12905
12903
  }
12906
- await chunkRE3NVA23_cjs.logActivity(
12904
+ await chunkP4RAIX7B_cjs.logActivity(
12907
12905
  db,
12908
12906
  user.userId,
12909
12907
  "profile.update",
@@ -12966,7 +12964,7 @@ userRoutes.post("/profile/avatar", async (c) => {
12966
12964
  SELECT first_name, last_name FROM users WHERE id = ?
12967
12965
  `);
12968
12966
  const userData = await userStmt.bind(user.userId).first();
12969
- await chunkRE3NVA23_cjs.logActivity(
12967
+ await chunkP4RAIX7B_cjs.logActivity(
12970
12968
  db,
12971
12969
  user.userId,
12972
12970
  "profile.avatar_update",
@@ -13037,7 +13035,7 @@ userRoutes.post("/profile/password", async (c) => {
13037
13035
  dismissible: true
13038
13036
  }));
13039
13037
  }
13040
- const validPassword = await chunkRE3NVA23_cjs.AuthManager.verifyPassword(currentPassword, userData.password_hash);
13038
+ const validPassword = await chunkP4RAIX7B_cjs.AuthManager.verifyPassword(currentPassword, userData.password_hash);
13041
13039
  if (!validPassword) {
13042
13040
  return c.html(renderAlert2({
13043
13041
  type: "error",
@@ -13045,7 +13043,7 @@ userRoutes.post("/profile/password", async (c) => {
13045
13043
  dismissible: true
13046
13044
  }));
13047
13045
  }
13048
- const newPasswordHash = await chunkRE3NVA23_cjs.AuthManager.hashPassword(newPassword);
13046
+ const newPasswordHash = await chunkP4RAIX7B_cjs.AuthManager.hashPassword(newPassword);
13049
13047
  const historyStmt = db.prepare(`
13050
13048
  INSERT INTO password_history (id, user_id, password_hash, created_at)
13051
13049
  VALUES (?, ?, ?, ?)
@@ -13061,7 +13059,7 @@ userRoutes.post("/profile/password", async (c) => {
13061
13059
  WHERE id = ?
13062
13060
  `);
13063
13061
  await updateStmt.bind(newPasswordHash, Date.now(), user.userId).run();
13064
- await chunkRE3NVA23_cjs.logActivity(
13062
+ await chunkP4RAIX7B_cjs.logActivity(
13065
13063
  db,
13066
13064
  user.userId,
13067
13065
  "profile.password_change",
@@ -13128,7 +13126,7 @@ userRoutes.get("/users", async (c) => {
13128
13126
  `);
13129
13127
  const countResult = await countStmt.bind(...params).first();
13130
13128
  const totalUsers = countResult?.total || 0;
13131
- await chunkRE3NVA23_cjs.logActivity(
13129
+ await chunkP4RAIX7B_cjs.logActivity(
13132
13130
  db,
13133
13131
  user.userId,
13134
13132
  "users.list_view",
@@ -13286,7 +13284,7 @@ userRoutes.post("/users/new", async (c) => {
13286
13284
  dismissible: true
13287
13285
  }));
13288
13286
  }
13289
- const passwordHash = await chunkRE3NVA23_cjs.AuthManager.hashPassword(password);
13287
+ const passwordHash = await chunkP4RAIX7B_cjs.AuthManager.hashPassword(password);
13290
13288
  const userId = crypto.randomUUID();
13291
13289
  const createStmt = db.prepare(`
13292
13290
  INSERT INTO users (
@@ -13309,7 +13307,7 @@ userRoutes.post("/users/new", async (c) => {
13309
13307
  Date.now(),
13310
13308
  Date.now()
13311
13309
  ).run();
13312
- await chunkRE3NVA23_cjs.logActivity(
13310
+ await chunkP4RAIX7B_cjs.logActivity(
13313
13311
  db,
13314
13312
  user.userId,
13315
13313
  "user!.create",
@@ -13348,7 +13346,7 @@ userRoutes.get("/users/:id", async (c) => {
13348
13346
  if (!userRecord) {
13349
13347
  return c.json({ error: "User not found" }, 404);
13350
13348
  }
13351
- await chunkRE3NVA23_cjs.logActivity(
13349
+ await chunkP4RAIX7B_cjs.logActivity(
13352
13350
  db,
13353
13351
  user.userId,
13354
13352
  "user!.view",
@@ -13500,10 +13498,10 @@ userRoutes.put("/users/:id", async (c) => {
13500
13498
  const merged = { ...existingCustom, ...sanitized };
13501
13499
  customDataJson = JSON.stringify(merged);
13502
13500
  }
13503
- if (!firstName || !lastName || !username || !email) {
13501
+ if (!username || !email) {
13504
13502
  return c.html(renderAlert2({
13505
13503
  type: "error",
13506
- message: "First name, last name, username, and email are required.",
13504
+ message: "Username and email are required.",
13507
13505
  dismissible: true
13508
13506
  }));
13509
13507
  }
@@ -13574,7 +13572,7 @@ userRoutes.put("/users/:id", async (c) => {
13574
13572
  userId
13575
13573
  ).run();
13576
13574
  if (newPassword) {
13577
- const passwordHash = await chunkRE3NVA23_cjs.AuthManager.hashPassword(newPassword);
13575
+ const passwordHash = await chunkP4RAIX7B_cjs.AuthManager.hashPassword(newPassword);
13578
13576
  const updatePasswordStmt = db.prepare(`
13579
13577
  UPDATE users SET password_hash = ?, updated_at = ? WHERE id = ?
13580
13578
  `);
@@ -13628,7 +13626,7 @@ userRoutes.put("/users/:id", async (c) => {
13628
13626
  ).run();
13629
13627
  }
13630
13628
  }
13631
- await chunkRE3NVA23_cjs.logActivity(
13629
+ await chunkP4RAIX7B_cjs.logActivity(
13632
13630
  db,
13633
13631
  user.userId,
13634
13632
  "user.update",
@@ -13673,7 +13671,7 @@ userRoutes.post("/users/:id/toggle", async (c) => {
13673
13671
  UPDATE users SET is_active = ?, updated_at = ? WHERE id = ?
13674
13672
  `);
13675
13673
  await toggleStmt.bind(active ? 1 : 0, Date.now(), userId).run();
13676
- await chunkRE3NVA23_cjs.logActivity(
13674
+ await chunkP4RAIX7B_cjs.logActivity(
13677
13675
  db,
13678
13676
  user.userId,
13679
13677
  active ? "user.activate" : "user.deactivate",
@@ -13714,7 +13712,7 @@ userRoutes.delete("/users/:id", async (c) => {
13714
13712
  DELETE FROM users WHERE id = ?
13715
13713
  `);
13716
13714
  await deleteStmt.bind(userId).run();
13717
- await chunkRE3NVA23_cjs.logActivity(
13715
+ await chunkP4RAIX7B_cjs.logActivity(
13718
13716
  db,
13719
13717
  user.userId,
13720
13718
  "user!.hard_delete",
@@ -13733,7 +13731,7 @@ userRoutes.delete("/users/:id", async (c) => {
13733
13731
  UPDATE users SET is_active = 0, updated_at = ? WHERE id = ?
13734
13732
  `);
13735
13733
  await deleteStmt.bind(Date.now(), userId).run();
13736
- await chunkRE3NVA23_cjs.logActivity(
13734
+ await chunkP4RAIX7B_cjs.logActivity(
13737
13735
  db,
13738
13736
  user.userId,
13739
13737
  "user!.soft_delete",
@@ -13799,7 +13797,7 @@ userRoutes.post("/invite-user", async (c) => {
13799
13797
  Date.now(),
13800
13798
  Date.now()
13801
13799
  ).run();
13802
- await chunkRE3NVA23_cjs.logActivity(
13800
+ await chunkP4RAIX7B_cjs.logActivity(
13803
13801
  db,
13804
13802
  user.userId,
13805
13803
  "user!.invite_sent",
@@ -13856,7 +13854,7 @@ userRoutes.post("/resend-invitation/:id", async (c) => {
13856
13854
  Date.now(),
13857
13855
  userId
13858
13856
  ).run();
13859
- await chunkRE3NVA23_cjs.logActivity(
13857
+ await chunkP4RAIX7B_cjs.logActivity(
13860
13858
  db,
13861
13859
  user.userId,
13862
13860
  "user!.invitation_resent",
@@ -13892,7 +13890,7 @@ userRoutes.delete("/cancel-invitation/:id", async (c) => {
13892
13890
  }
13893
13891
  const deleteStmt = db.prepare(`DELETE FROM users WHERE id = ?`);
13894
13892
  await deleteStmt.bind(userId).run();
13895
- await chunkRE3NVA23_cjs.logActivity(
13893
+ await chunkP4RAIX7B_cjs.logActivity(
13896
13894
  db,
13897
13895
  user.userId,
13898
13896
  "user!.invitation_cancelled",
@@ -13975,7 +13973,7 @@ userRoutes.get("/activity-logs", async (c) => {
13975
13973
  ...log,
13976
13974
  details: log.details ? JSON.parse(log.details) : null
13977
13975
  }));
13978
- await chunkRE3NVA23_cjs.logActivity(
13976
+ await chunkP4RAIX7B_cjs.logActivity(
13979
13977
  db,
13980
13978
  user.userId,
13981
13979
  "activity.logs_viewed",
@@ -14082,7 +14080,7 @@ userRoutes.get("/activity-logs/export", async (c) => {
14082
14080
  csvRows.push(row.join(","));
14083
14081
  }
14084
14082
  const csvContent = csvRows.join("\n");
14085
- await chunkRE3NVA23_cjs.logActivity(
14083
+ await chunkP4RAIX7B_cjs.logActivity(
14086
14084
  db,
14087
14085
  user.userId,
14088
14086
  "activity.logs_exported",
@@ -15421,7 +15419,7 @@ var fileValidationSchema2 = zod.z.object({
15421
15419
  // 50MB max
15422
15420
  });
15423
15421
  var adminMediaRoutes = new hono.Hono();
15424
- adminMediaRoutes.use("*", chunkRE3NVA23_cjs.requireAuth());
15422
+ adminMediaRoutes.use("*", chunkP4RAIX7B_cjs.requireAuth());
15425
15423
  adminMediaRoutes.get("/", async (c) => {
15426
15424
  try {
15427
15425
  const user = c.get("user");
@@ -16007,7 +16005,7 @@ adminMediaRoutes.put("/:id", async (c) => {
16007
16005
  `);
16008
16006
  }
16009
16007
  });
16010
- adminMediaRoutes.delete("/cleanup", chunkRE3NVA23_cjs.requireRole("admin"), async (c) => {
16008
+ adminMediaRoutes.delete("/cleanup", chunkP4RAIX7B_cjs.requireRole("admin"), async (c) => {
16011
16009
  try {
16012
16010
  const db = c.env.DB;
16013
16011
  const allMediaStmt = db.prepare("SELECT id, r2_key, filename FROM media WHERE deleted_at IS NULL");
@@ -18232,8 +18230,8 @@ function renderEmailSettingsContent(plugin, settings) {
18232
18230
 
18233
18231
  // src/routes/admin-plugins.ts
18234
18232
  var adminPluginRoutes = new hono.Hono();
18235
- adminPluginRoutes.use("*", chunkRE3NVA23_cjs.requireAuth());
18236
- var AVAILABLE_PLUGINS = Object.values(chunk4HCUJ3MG_cjs.PLUGIN_REGISTRY).map((p) => ({
18233
+ adminPluginRoutes.use("*", chunkP4RAIX7B_cjs.requireAuth());
18234
+ var AVAILABLE_PLUGINS = Object.values(chunkFXWF5D5V_cjs.PLUGIN_REGISTRY).map((p) => ({
18237
18235
  id: p.id,
18238
18236
  name: p.codeName,
18239
18237
  display_name: p.displayName,
@@ -18253,7 +18251,7 @@ adminPluginRoutes.get("/", async (c) => {
18253
18251
  if (user?.role !== "admin") {
18254
18252
  return c.text("Access denied", 403);
18255
18253
  }
18256
- const pluginService = new chunk4HCUJ3MG_cjs.PluginService(db);
18254
+ const pluginService = new chunkFXWF5D5V_cjs.PluginService(db);
18257
18255
  let installedPlugins = [];
18258
18256
  let stats = { total: 0, active: 0, inactive: 0, errors: 0, uninstalled: 0 };
18259
18257
  try {
@@ -18325,7 +18323,7 @@ adminPluginRoutes.get("/:id", async (c) => {
18325
18323
  if (user?.role !== "admin") {
18326
18324
  return c.redirect("/admin/plugins");
18327
18325
  }
18328
- const pluginService = new chunk4HCUJ3MG_cjs.PluginService(db);
18326
+ const pluginService = new chunkFXWF5D5V_cjs.PluginService(db);
18329
18327
  const plugin = await pluginService.getPlugin(pluginId);
18330
18328
  if (!plugin) {
18331
18329
  return c.text("Plugin not found", 404);
@@ -18401,7 +18399,7 @@ adminPluginRoutes.post("/:id/activate", async (c) => {
18401
18399
  if (user?.role !== "admin") {
18402
18400
  return c.json({ error: "Access denied" }, 403);
18403
18401
  }
18404
- const pluginService = new chunk4HCUJ3MG_cjs.PluginService(db);
18402
+ const pluginService = new chunkFXWF5D5V_cjs.PluginService(db);
18405
18403
  await pluginService.activatePlugin(pluginId);
18406
18404
  return c.json({ success: true });
18407
18405
  } catch (error) {
@@ -18418,7 +18416,7 @@ adminPluginRoutes.post("/:id/deactivate", async (c) => {
18418
18416
  if (user?.role !== "admin") {
18419
18417
  return c.json({ error: "Access denied" }, 403);
18420
18418
  }
18421
- const pluginService = new chunk4HCUJ3MG_cjs.PluginService(db);
18419
+ const pluginService = new chunkFXWF5D5V_cjs.PluginService(db);
18422
18420
  await pluginService.deactivatePlugin(pluginId);
18423
18421
  return c.json({ success: true });
18424
18422
  } catch (error) {
@@ -18435,8 +18433,8 @@ adminPluginRoutes.post("/install", async (c) => {
18435
18433
  return c.json({ error: "Access denied" }, 403);
18436
18434
  }
18437
18435
  const body = await c.req.json();
18438
- const pluginService = new chunk4HCUJ3MG_cjs.PluginService(db);
18439
- const registryEntry = chunk4HCUJ3MG_cjs.findPluginByCodeName(body.name) || chunk4HCUJ3MG_cjs.PLUGIN_REGISTRY[body.name] || chunk4HCUJ3MG_cjs.PLUGIN_REGISTRY[body.id];
18436
+ const pluginService = new chunkFXWF5D5V_cjs.PluginService(db);
18437
+ const registryEntry = chunkFXWF5D5V_cjs.findPluginByCodeName(body.name) || chunkFXWF5D5V_cjs.PLUGIN_REGISTRY[body.name] || chunkFXWF5D5V_cjs.PLUGIN_REGISTRY[body.id];
18440
18438
  if (!registryEntry) {
18441
18439
  return c.json({ error: "Plugin not found in registry" }, 404);
18442
18440
  }
@@ -18469,7 +18467,7 @@ adminPluginRoutes.post("/:id/uninstall", async (c) => {
18469
18467
  if (user?.role !== "admin") {
18470
18468
  return c.json({ error: "Access denied" }, 403);
18471
18469
  }
18472
- const pluginService = new chunk4HCUJ3MG_cjs.PluginService(db);
18470
+ const pluginService = new chunkFXWF5D5V_cjs.PluginService(db);
18473
18471
  await pluginService.uninstallPlugin(pluginId);
18474
18472
  return c.json({ success: true });
18475
18473
  } catch (error) {
@@ -18487,7 +18485,7 @@ adminPluginRoutes.post("/:id/settings", async (c) => {
18487
18485
  return c.json({ error: "Access denied" }, 403);
18488
18486
  }
18489
18487
  const settings = await c.req.json();
18490
- const pluginService = new chunk4HCUJ3MG_cjs.PluginService(db);
18488
+ const pluginService = new chunkFXWF5D5V_cjs.PluginService(db);
18491
18489
  await pluginService.updatePluginSettings(pluginId, settings);
18492
18490
  if (pluginId === "core-auth") {
18493
18491
  try {
@@ -19295,7 +19293,7 @@ function renderLogConfigPage(data) {
19295
19293
 
19296
19294
  // src/routes/admin-logs.ts
19297
19295
  var adminLogsRoutes = new hono.Hono();
19298
- adminLogsRoutes.use("*", chunkRE3NVA23_cjs.requireAuth());
19296
+ adminLogsRoutes.use("*", chunkP4RAIX7B_cjs.requireAuth());
19299
19297
  adminLogsRoutes.get("/", async (c) => {
19300
19298
  try {
19301
19299
  const user = c.get("user");
@@ -21623,9 +21621,9 @@ function renderStorageUsage(databaseSizeBytes, mediaSizeBytes) {
21623
21621
  }
21624
21622
 
21625
21623
  // src/routes/admin-dashboard.ts
21626
- var VERSION = chunkQBLBIAVZ_cjs.getCoreVersion();
21624
+ var VERSION = chunkQ3W6LCEN_cjs.getCoreVersion();
21627
21625
  var router = new hono.Hono();
21628
- router.use("*", chunkRE3NVA23_cjs.requireAuth());
21626
+ router.use("*", chunkP4RAIX7B_cjs.requireAuth());
21629
21627
  router.get("/", async (c) => {
21630
21628
  const user = c.get("user");
21631
21629
  try {
@@ -23444,10 +23442,10 @@ function renderCollectionFormPage(data) {
23444
23442
 
23445
23443
  // src/routes/admin-collections.ts
23446
23444
  var adminCollectionsRoutes = new hono.Hono();
23447
- adminCollectionsRoutes.use("*", chunkRE3NVA23_cjs.requireAuth());
23448
- adminCollectionsRoutes.post("*", chunkRE3NVA23_cjs.requireRole(["admin"]));
23449
- adminCollectionsRoutes.put("*", chunkRE3NVA23_cjs.requireRole(["admin"]));
23450
- adminCollectionsRoutes.delete("*", chunkRE3NVA23_cjs.requireRole(["admin"]));
23445
+ adminCollectionsRoutes.use("*", chunkP4RAIX7B_cjs.requireAuth());
23446
+ adminCollectionsRoutes.post("*", chunkP4RAIX7B_cjs.requireRole(["admin"]));
23447
+ adminCollectionsRoutes.put("*", chunkP4RAIX7B_cjs.requireRole(["admin"]));
23448
+ adminCollectionsRoutes.delete("*", chunkP4RAIX7B_cjs.requireRole(["admin"]));
23451
23449
  adminCollectionsRoutes.get("/", async (c) => {
23452
23450
  try {
23453
23451
  const user = c.get("user");
@@ -25742,7 +25740,7 @@ function renderDatabaseToolsSettings(settings) {
25742
25740
 
25743
25741
  // src/routes/admin-settings.ts
25744
25742
  var adminSettingsRoutes = new hono.Hono();
25745
- adminSettingsRoutes.use("*", chunkRE3NVA23_cjs.requireAuth());
25743
+ adminSettingsRoutes.use("*", chunkP4RAIX7B_cjs.requireAuth());
25746
25744
  function getMockSettings(user) {
25747
25745
  return {
25748
25746
  general: {
@@ -25919,7 +25917,7 @@ adminSettingsRoutes.get("/database-tools", (c) => {
25919
25917
  adminSettingsRoutes.get("/api/migrations/status", async (c) => {
25920
25918
  try {
25921
25919
  const db = c.env.DB;
25922
- const migrationService = new chunkFSWP4FBW_cjs.MigrationService(db);
25920
+ const migrationService = new chunkLVGB5UU5_cjs.MigrationService(db);
25923
25921
  const status = await migrationService.getMigrationStatus();
25924
25922
  return c.json({
25925
25923
  success: true,
@@ -25943,7 +25941,7 @@ adminSettingsRoutes.post("/api/migrations/run", async (c) => {
25943
25941
  }, 403);
25944
25942
  }
25945
25943
  const db = c.env.DB;
25946
- const migrationService = new chunkFSWP4FBW_cjs.MigrationService(db);
25944
+ const migrationService = new chunkLVGB5UU5_cjs.MigrationService(db);
25947
25945
  const result = await migrationService.runPendingMigrations();
25948
25946
  return c.json({
25949
25947
  success: result.success,
@@ -25961,7 +25959,7 @@ adminSettingsRoutes.post("/api/migrations/run", async (c) => {
25961
25959
  adminSettingsRoutes.get("/api/migrations/validate", async (c) => {
25962
25960
  try {
25963
25961
  const db = c.env.DB;
25964
- const migrationService = new chunkFSWP4FBW_cjs.MigrationService(db);
25962
+ const migrationService = new chunkLVGB5UU5_cjs.MigrationService(db);
25965
25963
  const validation = await migrationService.validateSchema();
25966
25964
  return c.json({
25967
25965
  success: true,
@@ -27900,7 +27898,7 @@ function renderFormCreatePage(data) {
27900
27898
 
27901
27899
  // src/routes/admin-forms.ts
27902
27900
  var adminFormsRoutes = new hono.Hono();
27903
- adminFormsRoutes.use("*", chunkRE3NVA23_cjs.requireAuth());
27901
+ adminFormsRoutes.use("*", chunkP4RAIX7B_cjs.requireAuth());
27904
27902
  adminFormsRoutes.get("/", async (c) => {
27905
27903
  try {
27906
27904
  const user = c.get("user");
@@ -28705,7 +28703,7 @@ publicFormsRoutes.post("/:identifier/submit", async (c) => {
28705
28703
  `).bind(now, form.id).run();
28706
28704
  let contentId = null;
28707
28705
  try {
28708
- contentId = await chunk4HCUJ3MG_cjs.createContentFromSubmission(
28706
+ contentId = await chunkFXWF5D5V_cjs.createContentFromSubmission(
28709
28707
  db,
28710
28708
  sanitizedData,
28711
28709
  { id: form.id, name: form.name, display_name: form.display_name },
@@ -29073,9 +29071,9 @@ function renderAPIReferencePage(data) {
29073
29071
  }
29074
29072
 
29075
29073
  // src/routes/admin-api-reference.ts
29076
- var VERSION2 = chunkQBLBIAVZ_cjs.getCoreVersion();
29074
+ var VERSION2 = chunkQ3W6LCEN_cjs.getCoreVersion();
29077
29075
  var router2 = new hono.Hono();
29078
- router2.use("*", chunkRE3NVA23_cjs.requireAuth());
29076
+ router2.use("*", chunkP4RAIX7B_cjs.requireAuth());
29079
29077
  router2.get("/", async (c) => {
29080
29078
  const user = c.get("user");
29081
29079
  try {
@@ -29166,5 +29164,5 @@ exports.router2 = router2;
29166
29164
  exports.test_cleanup_default = test_cleanup_default;
29167
29165
  exports.userProfilesPlugin = userProfilesPlugin;
29168
29166
  exports.userRoutes = userRoutes;
29169
- //# sourceMappingURL=chunk-J5MYHM6Z.cjs.map
29170
- //# sourceMappingURL=chunk-J5MYHM6Z.cjs.map
29167
+ //# sourceMappingURL=chunk-2VY2G7OR.cjs.map
29168
+ //# sourceMappingURL=chunk-2VY2G7OR.cjs.map