@sonicjs-cms/core 3.0.0-beta.11 → 3.0.0-beta.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/{chunk-SXLVXD2X.js → chunk-3FBZFYSQ.js} +25 -21
  2. package/dist/chunk-3FBZFYSQ.js.map +1 -0
  3. package/dist/{chunk-KV3CM5RK.cjs → chunk-6CKXZFED.cjs} +3 -3
  4. package/dist/{chunk-KV3CM5RK.cjs.map → chunk-6CKXZFED.cjs.map} +1 -1
  5. package/dist/{chunk-PDYRDYXI.js → chunk-6KFX4LAT.js} +4 -4
  6. package/dist/{chunk-PDYRDYXI.js.map → chunk-6KFX4LAT.js.map} +1 -1
  7. package/dist/{chunk-3PU4WVU6.js → chunk-BK3NB35S.js} +4 -4
  8. package/dist/{chunk-3PU4WVU6.js.map → chunk-BK3NB35S.js.map} +1 -1
  9. package/dist/{chunk-HPAJKZAQ.js → chunk-EKMN6W5B.js} +3 -3
  10. package/dist/{chunk-HPAJKZAQ.js.map → chunk-EKMN6W5B.js.map} +1 -1
  11. package/dist/{chunk-MKKGA3C4.cjs → chunk-IM3UG4QW.cjs} +10 -10
  12. package/dist/{chunk-MKKGA3C4.cjs.map → chunk-IM3UG4QW.cjs.map} +1 -1
  13. package/dist/{chunk-6H66MSSL.js → chunk-IV3NA6WZ.js} +2 -2
  14. package/dist/{chunk-6H66MSSL.js.map → chunk-IV3NA6WZ.js.map} +1 -1
  15. package/dist/{chunk-QLFTG3QJ.js → chunk-KG6GQE6B.js} +2 -2
  16. package/dist/{chunk-QLFTG3QJ.js.map → chunk-KG6GQE6B.js.map} +1 -1
  17. package/dist/{chunk-QJNKSFDJ.cjs → chunk-KPQ57HAH.cjs} +2 -2
  18. package/dist/{chunk-QJNKSFDJ.cjs.map → chunk-KPQ57HAH.cjs.map} +1 -1
  19. package/dist/{chunk-ZUEIQFE5.js → chunk-PPFQDMZE.js} +3 -3
  20. package/dist/{chunk-ZUEIQFE5.js.map → chunk-PPFQDMZE.js.map} +1 -1
  21. package/dist/{chunk-UHRHZXVR.cjs → chunk-PZGGIJI6.cjs} +4 -4
  22. package/dist/{chunk-UHRHZXVR.cjs.map → chunk-PZGGIJI6.cjs.map} +1 -1
  23. package/dist/{chunk-YJEBDJDV.cjs → chunk-VMBQ6NQB.cjs} +13 -13
  24. package/dist/{chunk-YJEBDJDV.cjs.map → chunk-VMBQ6NQB.cjs.map} +1 -1
  25. package/dist/{chunk-K342JMA3.cjs → chunk-VT77YUTP.cjs} +216 -212
  26. package/dist/chunk-VT77YUTP.cjs.map +1 -0
  27. package/dist/{chunk-ORF4CT74.cjs → chunk-YNYEQP3K.cjs} +2 -2
  28. package/dist/{chunk-ORF4CT74.cjs.map → chunk-YNYEQP3K.cjs.map} +1 -1
  29. package/dist/index.cjs +283 -252
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.js +44 -13
  32. package/dist/index.js.map +1 -1
  33. package/dist/middleware.cjs +32 -32
  34. package/dist/middleware.js +3 -3
  35. package/dist/migrations-KKLQ2CEF.js +4 -0
  36. package/dist/{migrations-XQLBY7E5.js.map → migrations-KKLQ2CEF.js.map} +1 -1
  37. package/dist/migrations-XOXYLHHU.cjs +13 -0
  38. package/dist/{migrations-ZXJEUTFA.cjs.map → migrations-XOXYLHHU.cjs.map} +1 -1
  39. package/dist/plugins.cjs +40 -40
  40. package/dist/plugins.js +3 -3
  41. package/dist/routes.cjs +26 -26
  42. package/dist/routes.js +6 -6
  43. package/dist/services.cjs +18 -18
  44. package/dist/services.js +2 -2
  45. package/dist/utils.cjs +3 -3
  46. package/dist/utils.js +1 -1
  47. package/package.json +1 -1
  48. package/dist/chunk-K342JMA3.cjs.map +0 -1
  49. package/dist/chunk-SXLVXD2X.js.map +0 -1
  50. package/dist/migrations-XQLBY7E5.js +0 -4
  51. package/dist/migrations-ZXJEUTFA.cjs +0 -13
@@ -3,22 +3,21 @@
3
3
  var chunkHIKBY7MS_cjs = require('./chunk-HIKBY7MS.cjs');
4
4
  var chunkN32OWET6_cjs = require('./chunk-N32OWET6.cjs');
5
5
  var chunk4BTBSXMR_cjs = require('./chunk-4BTBSXMR.cjs');
6
- var chunkYJEBDJDV_cjs = require('./chunk-YJEBDJDV.cjs');
6
+ var chunkVMBQ6NQB_cjs = require('./chunk-VMBQ6NQB.cjs');
7
7
  var chunk2CB4KY7I_cjs = require('./chunk-2CB4KY7I.cjs');
8
8
  var chunkJEQ7FLOD_cjs = require('./chunk-JEQ7FLOD.cjs');
9
- var chunkQJNKSFDJ_cjs = require('./chunk-QJNKSFDJ.cjs');
10
- var chunkORF4CT74_cjs = require('./chunk-ORF4CT74.cjs');
9
+ var chunkKPQ57HAH_cjs = require('./chunk-KPQ57HAH.cjs');
10
+ var chunkYNYEQP3K_cjs = require('./chunk-YNYEQP3K.cjs');
11
11
  var chunkPXNTCCPE_cjs = require('./chunk-PXNTCCPE.cjs');
12
12
  var chunkK623Q6WD_cjs = require('./chunk-K623Q6WD.cjs');
13
- var chunkUHRHZXVR_cjs = require('./chunk-UHRHZXVR.cjs');
13
+ var chunkPZGGIJI6_cjs = require('./chunk-PZGGIJI6.cjs');
14
14
  var chunkJ6JTWD2A_cjs = require('./chunk-J6JTWD2A.cjs');
15
15
  var chunkIXUHXTHW_cjs = require('./chunk-IXUHXTHW.cjs');
16
16
  var chunkRCQ2HIQD_cjs = require('./chunk-RCQ2HIQD.cjs');
17
- var chunkKV3CM5RK_cjs = require('./chunk-KV3CM5RK.cjs');
17
+ var chunk6CKXZFED_cjs = require('./chunk-6CKXZFED.cjs');
18
18
  var chunkMNWKYY5E_cjs = require('./chunk-MNWKYY5E.cjs');
19
19
  var hono = require('hono');
20
20
  var zod = require('zod');
21
- var cors = require('hono/cors');
22
21
  var cookie = require('hono/cookie');
23
22
  var html = require('hono/html');
24
23
 
@@ -257,7 +256,7 @@ function getDocumentRequestContext(c) {
257
256
 
258
257
  // src/routes/api-documents.ts
259
258
  async function aclAllowsRead(db, tenantId, principalSet, row, preloadedType) {
260
- const docType = preloadedType ?? await new chunkYJEBDJDV_cjs.DocumentTypeRegistry(db).findById(row.type_id);
259
+ const docType = preloadedType ?? await new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db).findById(row.type_id);
261
260
  if (!docType) return false;
262
261
  return new DocumentRepository(db, tenantId).isAllowed(principalSet, row.root_id, "read", docType.settings);
263
262
  }
@@ -275,7 +274,7 @@ apiDocumentsRoutes.get("/", async (c) => {
275
274
  if (!typeId) {
276
275
  return c.json({ error: "type query parameter is required" }, 400);
277
276
  }
278
- const registry = new chunkYJEBDJDV_cjs.DocumentTypeRegistry(db);
277
+ const registry = new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db);
279
278
  const docType = await registry.findById(typeId);
280
279
  if (!docType || !docType.isActive) {
281
280
  return c.json({ error: "Unknown document type" }, 400);
@@ -357,7 +356,7 @@ apiDocumentsRoutes.get("/root/:rootId", async (c) => {
357
356
  AND (expires_at IS NULL OR expires_at > ?) LIMIT 1`
358
357
  ).bind(rootId, now, now).first();
359
358
  if (!row) return c.json({ error: "Not found" }, 404);
360
- const docType = await new chunkYJEBDJDV_cjs.DocumentTypeRegistry(db).findById(row.type_id);
359
+ const docType = await new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db).findById(row.type_id);
361
360
  const effTenant = effectiveTenantForType(tenantId, docType?.settings);
362
361
  if (row.tenant_id !== effTenant) return c.json({ error: "Not found" }, 404);
363
362
  if (!await aclAllowsRead(db, effTenant, principalSet, row, docType)) {
@@ -393,7 +392,7 @@ apiDocumentsRoutes.get("/:id", async (c) => {
393
392
  AND (expires_at IS NULL OR expires_at > ?) LIMIT 1`
394
393
  ).bind(id, now, now).first();
395
394
  if (!row) return c.json({ error: "Not found" }, 404);
396
- const docType = await new chunkYJEBDJDV_cjs.DocumentTypeRegistry(db).findById(row.type_id);
395
+ const docType = await new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db).findById(row.type_id);
397
396
  const effTenant = effectiveTenantForType(tenantId, docType?.settings);
398
397
  if (row.tenant_id !== effTenant) return c.json({ error: "Not found" }, 404);
399
398
  if (!await aclAllowsRead(db, effTenant, principalSet, row, docType)) {
@@ -463,17 +462,17 @@ async function resolveDocScope(c, db, by, opts = {}) {
463
462
  const draft = opts.currentDraftOnly ? " AND is_current_draft = 1" : "";
464
463
  const row = await db.prepare(`SELECT type_id, root_id, tenant_id FROM documents WHERE ${col} = ?${draft} LIMIT 1`).bind(val).first();
465
464
  if (!row) return null;
466
- const docType = await new chunkYJEBDJDV_cjs.DocumentTypeRegistry(db).findById(row.type_id);
465
+ const docType = await new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db).findById(row.type_id);
467
466
  const tenantId = effectiveTenantForType(getRequestTenant(c), docType?.settings);
468
467
  if (row.tenant_id !== tenantId) return null;
469
468
  return { typeId: row.type_id, rootId: row.root_id, tenantId, docType };
470
469
  }
471
470
  var adminDocumentsRoutes = new hono.Hono();
472
- adminDocumentsRoutes.use("*", chunkYJEBDJDV_cjs.requireAuth());
473
- adminDocumentsRoutes.use("*", chunkYJEBDJDV_cjs.requireRole(["admin", "editor"]));
471
+ adminDocumentsRoutes.use("*", chunkVMBQ6NQB_cjs.requireAuth());
472
+ adminDocumentsRoutes.use("*", chunkVMBQ6NQB_cjs.requireRole(["admin", "editor"]));
474
473
  adminDocumentsRoutes.get("/types", async (c) => {
475
474
  try {
476
- const registry = new chunkYJEBDJDV_cjs.DocumentTypeRegistry(c.env.DB);
475
+ const registry = new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(c.env.DB);
477
476
  const types = await registry.findAll();
478
477
  return c.json({ data: types });
479
478
  } catch (error) {
@@ -501,7 +500,7 @@ adminDocumentsRoutes.get("/", async (c) => {
501
500
  if (!typeId) {
502
501
  return c.json({ error: "type query parameter is required" }, 400);
503
502
  }
504
- const registry = new chunkYJEBDJDV_cjs.DocumentTypeRegistry(db);
503
+ const registry = new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db);
505
504
  const docType = await registry.findById(typeId);
506
505
  if (!docType || !docType.isActive) {
507
506
  return c.json({ error: "Unknown document type" }, 400);
@@ -612,7 +611,7 @@ adminDocumentsRoutes.post("/", async (c) => {
612
611
  const input = validation.data;
613
612
  const db = c.env.DB;
614
613
  const user = c.get("user");
615
- const registry = new chunkYJEBDJDV_cjs.DocumentTypeRegistry(db);
614
+ const registry = new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db);
616
615
  const docType = await registry.findById(input.typeId);
617
616
  if (!docType || !docType.isActive) {
618
617
  return c.json({ error: "Unknown document type" }, 400);
@@ -744,7 +743,7 @@ adminDocumentsRoutes.post("/types/:typeId/reindex", async (c) => {
744
743
  try {
745
744
  const { typeId } = c.req.param();
746
745
  const db = c.env.DB;
747
- const registry = new chunkYJEBDJDV_cjs.DocumentTypeRegistry(db);
746
+ const registry = new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db);
748
747
  const docType = await registry.findById(typeId);
749
748
  if (!docType) return c.json({ error: "Unknown document type" }, 400);
750
749
  const reindexTenant = effectiveTenantForType(getRequestTenant(c), docType.settings);
@@ -898,13 +897,13 @@ async function resolveContentVariables(contentData, db) {
898
897
  // src/routes/api-content-crud.ts
899
898
  var apiContentCrudRoutes = new hono.Hono();
900
899
  async function resolveDocBacking(db, collectionIdOrName) {
901
- const registry = chunkQJNKSFDJ_cjs.getCollectionRegistry();
900
+ const registry = chunkKPQ57HAH_cjs.getCollectionRegistry();
902
901
  const record = registry.getBySlugOrName(collectionIdOrName) ?? registry.getById(collectionIdOrName);
903
902
  if (record) {
904
- const docType2 = await new chunkYJEBDJDV_cjs.DocumentTypeRegistry(db).findById(record.name);
903
+ const docType2 = await new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db).findById(record.name);
905
904
  return docType2 ? { coll: { id: record.id, name: record.name }, docType: docType2 } : null;
906
905
  }
907
- const docType = await new chunkYJEBDJDV_cjs.DocumentTypeRegistry(db).findById(collectionIdOrName);
906
+ const docType = await new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db).findById(collectionIdOrName);
908
907
  if (docType) {
909
908
  return { coll: { id: collectionIdOrName, name: collectionIdOrName }, docType };
910
909
  }
@@ -947,7 +946,7 @@ apiContentCrudRoutes.get("/check-slug", async (c) => {
947
946
  }, 500);
948
947
  }
949
948
  });
950
- apiContentCrudRoutes.get("/:id", chunkYJEBDJDV_cjs.optionalAuth(), async (c) => {
949
+ apiContentCrudRoutes.get("/:id", chunkVMBQ6NQB_cjs.optionalAuth(), async (c) => {
951
950
  try {
952
951
  const id = c.req.param("id");
953
952
  const db = c.env.DB;
@@ -957,7 +956,7 @@ apiContentCrudRoutes.get("/:id", chunkYJEBDJDV_cjs.optionalAuth(), async (c) =>
957
956
  ).bind(id, getRequestTenant(c)).first();
958
957
  let transformedContent;
959
958
  if (docRow) {
960
- const coll = chunkQJNKSFDJ_cjs.getCollectionRegistry().getByName(docRow.type_id);
959
+ const coll = chunkKPQ57HAH_cjs.getCollectionRegistry().getByName(docRow.type_id);
961
960
  transformedContent = {
962
961
  id: docRow.root_id,
963
962
  title: docRow.title,
@@ -991,7 +990,7 @@ apiContentCrudRoutes.get("/:id", chunkYJEBDJDV_cjs.optionalAuth(), async (c) =>
991
990
  }, 500);
992
991
  }
993
992
  });
994
- apiContentCrudRoutes.post("/", chunkYJEBDJDV_cjs.requireAuth(), chunkYJEBDJDV_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
993
+ apiContentCrudRoutes.post("/", chunkVMBQ6NQB_cjs.requireAuth(), chunkVMBQ6NQB_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
995
994
  try {
996
995
  const db = c.env.DB;
997
996
  const user = c.get("user");
@@ -1066,7 +1065,7 @@ apiContentCrudRoutes.post("/", chunkYJEBDJDV_cjs.requireAuth(), chunkYJEBDJDV_cj
1066
1065
  }, 500);
1067
1066
  }
1068
1067
  });
1069
- apiContentCrudRoutes.put("/:id", chunkYJEBDJDV_cjs.requireAuth(), chunkYJEBDJDV_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
1068
+ apiContentCrudRoutes.put("/:id", chunkVMBQ6NQB_cjs.requireAuth(), chunkVMBQ6NQB_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
1070
1069
  try {
1071
1070
  const id = c.req.param("id");
1072
1071
  const db = c.env.DB;
@@ -1088,7 +1087,7 @@ apiContentCrudRoutes.put("/:id", chunkYJEBDJDV_cjs.requireAuth(), chunkYJEBDJDV_
1088
1087
  } catch (err) {
1089
1088
  return c.json({ error: "Write cancelled by plugin", details: String(err) }, 400);
1090
1089
  }
1091
- const docType = await new chunkYJEBDJDV_cjs.DocumentTypeRegistry(db).findById(docRow.type_id);
1090
+ const docType = await new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db).findById(docRow.type_id);
1092
1091
  const svc = new chunk2CB4KY7I_cjs.DocumentsService(db, {
1093
1092
  queryableFields: docType?.queryableFields ?? [],
1094
1093
  typeSchemaVersion: docType?.schemaVersion ?? 1,
@@ -1111,7 +1110,7 @@ apiContentCrudRoutes.put("/:id", chunkYJEBDJDV_cjs.requireAuth(), chunkYJEBDJDV_
1111
1110
  const cache = chunk4BTBSXMR_cjs.getCacheService(chunk4BTBSXMR_cjs.CACHE_CONFIGS.api);
1112
1111
  await cache.invalidate("content-filtered:*");
1113
1112
  await cache.invalidate("collection-content-filtered:*");
1114
- const coll = chunkQJNKSFDJ_cjs.getCollectionRegistry().getByName(docRow.type_id);
1113
+ const coll = chunkKPQ57HAH_cjs.getCollectionRegistry().getByName(docRow.type_id);
1115
1114
  const saved = await db.prepare("SELECT * FROM documents WHERE id = ?").bind(newDraft.id).first();
1116
1115
  const savedData = saved?.data ? JSON.parse(saved.data) : {};
1117
1116
  dispatchHookEvent(c, "content:after:update", { collection: docRow.type_id, id, data: savedData, user: actor }, "fire-and-forget");
@@ -1132,7 +1131,7 @@ apiContentCrudRoutes.put("/:id", chunkYJEBDJDV_cjs.requireAuth(), chunkYJEBDJDV_
1132
1131
  }, 500);
1133
1132
  }
1134
1133
  });
1135
- apiContentCrudRoutes.delete("/:id", chunkYJEBDJDV_cjs.requireAuth(), chunkYJEBDJDV_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
1134
+ apiContentCrudRoutes.delete("/:id", chunkVMBQ6NQB_cjs.requireAuth(), chunkVMBQ6NQB_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
1136
1135
  try {
1137
1136
  const id = c.req.param("id");
1138
1137
  const db = c.env.DB;
@@ -1258,20 +1257,10 @@ apiRoutes.use("*", async (c, next) => {
1258
1257
  c.header("X-Response-Time", `${totalTime}ms`);
1259
1258
  });
1260
1259
  apiRoutes.use("*", async (c, next) => {
1261
- const cacheEnabled = await chunkYJEBDJDV_cjs.isPluginActive(c.env.DB, "core-cache");
1260
+ const cacheEnabled = await chunkVMBQ6NQB_cjs.isPluginActive(c.env.DB, "core-cache");
1262
1261
  c.set("cacheEnabled", cacheEnabled);
1263
1262
  await next();
1264
1263
  });
1265
- apiRoutes.use("*", cors.cors({
1266
- origin: (origin, c) => {
1267
- const allowed = c.env?.CORS_ORIGINS;
1268
- if (!allowed) return null;
1269
- const list = allowed.split(",").map((s) => s.trim());
1270
- return list.includes(origin) ? origin : null;
1271
- },
1272
- allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
1273
- allowHeaders: ["Content-Type", "Authorization", "X-API-Key"]
1274
- }));
1275
1264
  function addTimingMeta(c, meta = {}, executionStartTime) {
1276
1265
  const totalTime = Date.now() - c.get("startTime");
1277
1266
  const executionTime = executionStartTime ? Date.now() - executionStartTime : void 0;
@@ -1291,7 +1280,7 @@ apiRoutes.get("/", (c) => {
1291
1280
  openapi: "3.0.0",
1292
1281
  info: {
1293
1282
  title: "SonicJS AI API",
1294
- version: chunkKV3CM5RK_cjs.getCoreVersion(),
1283
+ version: chunk6CKXZFED_cjs.getCoreVersion(),
1295
1284
  description: "RESTful API for SonicJS headless CMS - a modern, AI-powered content management system built on Cloudflare Workers",
1296
1285
  contact: {
1297
1286
  name: "SonicJS Support",
@@ -1721,8 +1710,8 @@ apiRoutes.get("/collections", async (c) => {
1721
1710
  }
1722
1711
  c.header("X-Cache-Status", "MISS");
1723
1712
  c.header("X-Cache-Source", "registry");
1724
- const records = chunkQJNKSFDJ_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal);
1725
- const transformedResults = records.map(chunkQJNKSFDJ_cjs.collectionRecordToRow);
1713
+ const records = chunkKPQ57HAH_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal);
1714
+ const transformedResults = records.map(chunkKPQ57HAH_cjs.collectionRecordToRow);
1726
1715
  const responseData = {
1727
1716
  data: transformedResults,
1728
1717
  meta: addTimingMeta(c, {
@@ -1743,7 +1732,7 @@ apiRoutes.get("/collections", async (c) => {
1743
1732
  return c.json({ error: "Failed to fetch collections" }, 500);
1744
1733
  }
1745
1734
  });
1746
- apiRoutes.get("/content", chunkYJEBDJDV_cjs.optionalAuth(), async (c) => {
1735
+ apiRoutes.get("/content", chunkVMBQ6NQB_cjs.optionalAuth(), async (c) => {
1747
1736
  const executionStart = Date.now();
1748
1737
  try {
1749
1738
  const db = c.env.DB;
@@ -1752,7 +1741,7 @@ apiRoutes.get("/content", chunkYJEBDJDV_cjs.optionalAuth(), async (c) => {
1752
1741
  const collIdByName = /* @__PURE__ */ new Map();
1753
1742
  let typeId;
1754
1743
  let typeIds;
1755
- const registry = chunkQJNKSFDJ_cjs.getCollectionRegistry();
1744
+ const registry = chunkKPQ57HAH_cjs.getCollectionRegistry();
1756
1745
  if (queryParams.collection) {
1757
1746
  const collectionName = queryParams.collection;
1758
1747
  const record = registry.getByName(collectionName);
@@ -1851,13 +1840,13 @@ apiRoutes.get("/content", chunkYJEBDJDV_cjs.optionalAuth(), async (c) => {
1851
1840
  }, 500);
1852
1841
  }
1853
1842
  });
1854
- apiRoutes.get("/collections/:collection/content", chunkYJEBDJDV_cjs.optionalAuth(), async (c) => {
1843
+ apiRoutes.get("/collections/:collection/content", chunkVMBQ6NQB_cjs.optionalAuth(), async (c) => {
1855
1844
  const executionStart = Date.now();
1856
1845
  try {
1857
1846
  const collection = c.req.param("collection");
1858
1847
  const db = c.env.DB;
1859
1848
  const queryParams = c.req.query();
1860
- const record = chunkQJNKSFDJ_cjs.getCollectionRegistry().getBySlugOrName(collection);
1849
+ const record = chunkKPQ57HAH_cjs.getCollectionRegistry().getBySlugOrName(collection);
1861
1850
  if (!record || record.isActive === false) {
1862
1851
  return c.json({ error: "Collection not found" }, 404);
1863
1852
  }
@@ -1913,7 +1902,7 @@ apiRoutes.get("/collections/:collection/content", chunkYJEBDJDV_cjs.optionalAuth
1913
1902
  const responseData = {
1914
1903
  data: transformedResults,
1915
1904
  meta: addTimingMeta(c, {
1916
- ...includeCollection ? { collection: chunkQJNKSFDJ_cjs.collectionRecordToRow(record) } : {},
1905
+ ...includeCollection ? { collection: chunkKPQ57HAH_cjs.collectionRecordToRow(record) } : {},
1917
1906
  count: results.length,
1918
1907
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1919
1908
  // D44: echo the caller's filter with the access policy applied (status=published forced for
@@ -1938,13 +1927,13 @@ apiRoutes.get("/collections/:collection/content", chunkYJEBDJDV_cjs.optionalAuth
1938
1927
  }
1939
1928
  });
1940
1929
  apiRoutes.route("/content", api_content_crud_default);
1941
- apiRoutes.get("/:collection", chunkYJEBDJDV_cjs.optionalAuth(), async (c) => {
1930
+ apiRoutes.get("/:collection", chunkVMBQ6NQB_cjs.optionalAuth(), async (c) => {
1942
1931
  const executionStart = Date.now();
1943
1932
  try {
1944
1933
  const collection = c.req.param("collection");
1945
1934
  const db = c.env.DB;
1946
1935
  const queryParams = c.req.query();
1947
- const record = chunkQJNKSFDJ_cjs.getCollectionRegistry().getBySlugOrName(collection);
1936
+ const record = chunkKPQ57HAH_cjs.getCollectionRegistry().getBySlugOrName(collection);
1948
1937
  if (!record || record.isActive === false) {
1949
1938
  return c.json({ error: "Collection not found" }, 404);
1950
1939
  }
@@ -1984,7 +1973,7 @@ apiRoutes.get("/:collection", chunkYJEBDJDV_cjs.optionalAuth(), async (c) => {
1984
1973
  const responseData = {
1985
1974
  data: transformedResults,
1986
1975
  meta: addTimingMeta(c, {
1987
- ...includeCollection ? { collection: chunkQJNKSFDJ_cjs.collectionRecordToRow(record) } : {},
1976
+ ...includeCollection ? { collection: chunkKPQ57HAH_cjs.collectionRecordToRow(record) } : {},
1988
1977
  count: results.length,
1989
1978
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1990
1979
  filter: normalizePublicContentFilter(filter, role),
@@ -2002,12 +1991,12 @@ apiRoutes.get("/:collection", chunkYJEBDJDV_cjs.optionalAuth(), async (c) => {
2002
1991
  return c.json({ error: "Failed to fetch content", details: error instanceof Error ? error.message : String(error) }, 500);
2003
1992
  }
2004
1993
  });
2005
- apiRoutes.get("/:collection/:id", chunkYJEBDJDV_cjs.optionalAuth(), async (c) => {
1994
+ apiRoutes.get("/:collection/:id", chunkVMBQ6NQB_cjs.optionalAuth(), async (c) => {
2006
1995
  try {
2007
1996
  const collection = c.req.param("collection");
2008
1997
  const id = c.req.param("id");
2009
1998
  const db = c.env.DB;
2010
- const record = chunkQJNKSFDJ_cjs.getCollectionRegistry().getBySlugOrName(collection);
1999
+ const record = chunkKPQ57HAH_cjs.getCollectionRegistry().getBySlugOrName(collection);
2011
2000
  if (!record || record.isActive === false) {
2012
2001
  return c.json({ error: "Collection not found" }, 404);
2013
2002
  }
@@ -2016,7 +2005,7 @@ apiRoutes.get("/:collection/:id", chunkYJEBDJDV_cjs.optionalAuth(), async (c) =>
2016
2005
  privileged ? "SELECT * FROM documents WHERE root_id = ? AND type_id = ? AND tenant_id = 'default' AND is_current_draft = 1 AND deleted_at IS NULL" : "SELECT * FROM documents WHERE root_id = ? AND type_id = ? AND tenant_id = 'default' AND is_published = 1 AND deleted_at IS NULL"
2017
2006
  ).bind(id, record.name).first();
2018
2007
  if (!docRow) return c.json({ error: "Content not found" }, 404);
2019
- const coll = chunkQJNKSFDJ_cjs.getCollectionRegistry().getByName(docRow.type_id);
2008
+ const coll = chunkKPQ57HAH_cjs.getCollectionRegistry().getByName(docRow.type_id);
2020
2009
  const transformedContent = {
2021
2010
  id: docRow.root_id,
2022
2011
  title: docRow.title,
@@ -2034,7 +2023,7 @@ apiRoutes.get("/:collection/:id", chunkYJEBDJDV_cjs.optionalAuth(), async (c) =>
2034
2023
  return c.json({ error: "Failed to fetch content", details: error instanceof Error ? error.message : String(error) }, 500);
2035
2024
  }
2036
2025
  });
2037
- apiRoutes.post("/:collection", chunkYJEBDJDV_cjs.requireAuth(), chunkYJEBDJDV_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
2026
+ apiRoutes.post("/:collection", chunkVMBQ6NQB_cjs.requireAuth(), chunkVMBQ6NQB_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
2038
2027
  try {
2039
2028
  const collection = c.req.param("collection");
2040
2029
  const db = c.env.DB;
@@ -2067,14 +2056,14 @@ apiRoutes.post("/:collection", chunkYJEBDJDV_cjs.requireAuth(), chunkYJEBDJDV_cj
2067
2056
  return c.json({ error: "Failed to create content", details: error instanceof Error ? error.message : String(error) }, 500);
2068
2057
  }
2069
2058
  });
2070
- apiRoutes.put("/:collection/:id", chunkYJEBDJDV_cjs.requireAuth(), chunkYJEBDJDV_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
2059
+ apiRoutes.put("/:collection/:id", chunkVMBQ6NQB_cjs.requireAuth(), chunkVMBQ6NQB_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
2071
2060
  try {
2072
2061
  const collection = c.req.param("collection");
2073
2062
  const id = c.req.param("id");
2074
2063
  const db = c.env.DB;
2075
2064
  const user = c.get("user");
2076
2065
  const body = await c.req.json();
2077
- const collRecord = chunkQJNKSFDJ_cjs.getCollectionRegistry().getBySlugOrName(collection);
2066
+ const collRecord = chunkKPQ57HAH_cjs.getCollectionRegistry().getBySlugOrName(collection);
2078
2067
  const typeName = collRecord?.name ?? collection;
2079
2068
  const docRow = await db.prepare("SELECT root_id, type_id FROM documents WHERE root_id = ? AND type_id = ? AND tenant_id = 'default' AND is_current_draft = 1 AND deleted_at IS NULL").bind(id, typeName).first();
2080
2069
  if (!docRow) return c.json({ error: "Content not found" }, 404);
@@ -2086,7 +2075,7 @@ apiRoutes.put("/:collection/:id", chunkYJEBDJDV_cjs.requireAuth(), chunkYJEBDJDV
2086
2075
  } catch (err) {
2087
2076
  return c.json({ error: "Write cancelled by plugin", details: String(err) }, 400);
2088
2077
  }
2089
- const docType = await new chunkYJEBDJDV_cjs.DocumentTypeRegistry(db).findById(docRow.type_id);
2078
+ const docType = await new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db).findById(docRow.type_id);
2090
2079
  const svc = new chunk2CB4KY7I_cjs.DocumentsService(db, { queryableFields: docType?.queryableFields ?? [], typeSchemaVersion: docType?.schemaVersion ?? 1, maxVersionsPerRoot: docType?.settings?.maxVersionsPerRoot ?? 50, tenantId: "default", versioning: docType?.settings?.versioning ?? false });
2091
2080
  const input = {};
2092
2081
  if (body.title !== void 0) input.title = body.title;
@@ -2103,7 +2092,7 @@ apiRoutes.put("/:collection/:id", chunkYJEBDJDV_cjs.requireAuth(), chunkYJEBDJDV
2103
2092
  const cache = chunk4BTBSXMR_cjs.getCacheService(chunk4BTBSXMR_cjs.CACHE_CONFIGS.api);
2104
2093
  await cache.invalidate("content-filtered:*");
2105
2094
  await cache.invalidate("collection-content-filtered:*");
2106
- const coll = chunkQJNKSFDJ_cjs.getCollectionRegistry().getByName(docRow.type_id);
2095
+ const coll = chunkKPQ57HAH_cjs.getCollectionRegistry().getByName(docRow.type_id);
2107
2096
  const saved = await db.prepare("SELECT * FROM documents WHERE id = ?").bind(newDraft.id).first();
2108
2097
  const savedData = saved?.data ? JSON.parse(saved.data) : {};
2109
2098
  dispatchHookEvent(c, "content:after:update", { collection: docRow.type_id, id, data: savedData, user: actor }, "fire-and-forget");
@@ -2115,13 +2104,13 @@ apiRoutes.put("/:collection/:id", chunkYJEBDJDV_cjs.requireAuth(), chunkYJEBDJDV
2115
2104
  return c.json({ error: "Failed to update content", details: error instanceof Error ? error.message : String(error) }, 500);
2116
2105
  }
2117
2106
  });
2118
- apiRoutes.delete("/:collection/:id", chunkYJEBDJDV_cjs.requireAuth(), chunkYJEBDJDV_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
2107
+ apiRoutes.delete("/:collection/:id", chunkVMBQ6NQB_cjs.requireAuth(), chunkVMBQ6NQB_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
2119
2108
  try {
2120
2109
  const collection = c.req.param("collection");
2121
2110
  const id = c.req.param("id");
2122
2111
  const db = c.env.DB;
2123
2112
  const user = c.get("user");
2124
- const collRecord = chunkQJNKSFDJ_cjs.getCollectionRegistry().getBySlugOrName(collection);
2113
+ const collRecord = chunkKPQ57HAH_cjs.getCollectionRegistry().getBySlugOrName(collection);
2125
2114
  const typeName = collRecord?.name ?? collection;
2126
2115
  const docRow = await db.prepare("SELECT type_id FROM documents WHERE root_id = ? AND type_id = ? AND tenant_id = 'default' AND deleted_at IS NULL LIMIT 1").bind(id, typeName).first();
2127
2116
  if (!docRow) return c.json({ error: "Content not found" }, 404);
@@ -2336,7 +2325,7 @@ var fileValidationSchema = zod.z.object({
2336
2325
  // 50MB max
2337
2326
  });
2338
2327
  var apiMediaRoutes = new hono.Hono();
2339
- apiMediaRoutes.use("*", chunkYJEBDJDV_cjs.requireAuth());
2328
+ apiMediaRoutes.use("*", chunkVMBQ6NQB_cjs.requireAuth());
2340
2329
  apiMediaRoutes.post("/upload", async (c) => {
2341
2330
  try {
2342
2331
  const user = c.get("user");
@@ -3034,7 +3023,7 @@ apiSystemRoutes.get("/info", (c) => {
3034
3023
  apiSystemRoutes.get("/stats", async (c) => {
3035
3024
  try {
3036
3025
  const db = c.env.DB;
3037
- const typeIds = chunkQJNKSFDJ_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal).map((r) => r.name);
3026
+ const typeIds = chunkKPQ57HAH_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal).map((r) => r.name);
3038
3027
  let contentStats = null;
3039
3028
  if (typeIds.length > 0) {
3040
3029
  const placeholders = typeIds.map(() => "?").join(",");
@@ -3109,12 +3098,12 @@ apiSystemRoutes.get("/env", (c) => {
3109
3098
  });
3110
3099
  var api_system_default = apiSystemRoutes;
3111
3100
  var adminApiRoutes = new hono.Hono();
3112
- adminApiRoutes.use("*", chunkYJEBDJDV_cjs.requireAuth());
3113
- adminApiRoutes.use("*", chunkYJEBDJDV_cjs.requireRole(["admin", "editor"]));
3101
+ adminApiRoutes.use("*", chunkVMBQ6NQB_cjs.requireAuth());
3102
+ adminApiRoutes.use("*", chunkVMBQ6NQB_cjs.requireRole(["admin", "editor"]));
3114
3103
  adminApiRoutes.get("/stats", async (c) => {
3115
3104
  try {
3116
3105
  const db = c.env.DB;
3117
- const userCollections = chunkQJNKSFDJ_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal);
3106
+ const userCollections = chunkKPQ57HAH_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal);
3118
3107
  const collectionsCount = userCollections.length;
3119
3108
  let contentCount = 0;
3120
3109
  if (userCollections.length > 0) {
@@ -3205,7 +3194,7 @@ adminApiRoutes.get("/collections", async (c) => {
3205
3194
  try {
3206
3195
  const search = c.req.query("search") || "";
3207
3196
  const includeInactive = c.req.query("includeInactive") === "true";
3208
- let records = chunkQJNKSFDJ_cjs.getCollectionRegistry().list().filter((r) => !r.internal);
3197
+ let records = chunkKPQ57HAH_cjs.getCollectionRegistry().list().filter((r) => !r.internal);
3209
3198
  if (!includeInactive) records = records.filter((r) => r.isActive !== false);
3210
3199
  if (search) {
3211
3200
  const needle = search.toLowerCase();
@@ -3237,7 +3226,7 @@ adminApiRoutes.get("/collections", async (c) => {
3237
3226
  adminApiRoutes.get("/collections/:id", async (c) => {
3238
3227
  try {
3239
3228
  const id = c.req.param("id");
3240
- const registry = chunkQJNKSFDJ_cjs.getCollectionRegistry();
3229
+ const registry = chunkKPQ57HAH_cjs.getCollectionRegistry();
3241
3230
  const record = registry.getById(id) ?? registry.getByName(id);
3242
3231
  if (!record) {
3243
3232
  return c.json({ error: "Collection not found" }, 404);
@@ -3287,7 +3276,7 @@ adminApiRoutes.get("/references", async (c) => {
3287
3276
  if (collectionParams.length === 0) {
3288
3277
  return c.json({ error: "Collection is required" }, 400);
3289
3278
  }
3290
- const registry = chunkQJNKSFDJ_cjs.getCollectionRegistry();
3279
+ const registry = chunkKPQ57HAH_cjs.getCollectionRegistry();
3291
3280
  const matched = collectionParams.map((param) => registry.getById(param) ?? registry.getByName(param)).filter((r) => !!r);
3292
3281
  const seen = /* @__PURE__ */ new Set();
3293
3282
  const collections = matched.filter((r) => {
@@ -3402,7 +3391,7 @@ adminApiRoutes.patch("/collections/:id", collectionsReadOnly);
3402
3391
  adminApiRoutes.delete("/collections/:id", collectionsReadOnly);
3403
3392
  adminApiRoutes.get("/migrations/status", async (c) => {
3404
3393
  try {
3405
- const { MigrationService: MigrationService2 } = await import('./migrations-ZXJEUTFA.cjs');
3394
+ const { MigrationService: MigrationService2 } = await import('./migrations-XOXYLHHU.cjs');
3406
3395
  const db = c.env.DB;
3407
3396
  const migrationService = new MigrationService2(db);
3408
3397
  const status = await migrationService.getMigrationStatus();
@@ -3445,7 +3434,7 @@ adminApiRoutes.post("/migrations/run", async (c) => {
3445
3434
  });
3446
3435
  adminApiRoutes.get("/migrations/validate", async (c) => {
3447
3436
  try {
3448
- const { MigrationService: MigrationService2 } = await import('./migrations-ZXJEUTFA.cjs');
3437
+ const { MigrationService: MigrationService2 } = await import('./migrations-XOXYLHHU.cjs');
3449
3438
  const db = c.env.DB;
3450
3439
  const migrationService = new MigrationService2(db);
3451
3440
  const validation = await migrationService.validateSchema();
@@ -3860,7 +3849,7 @@ function renderRegisterPage(data) {
3860
3849
  }
3861
3850
 
3862
3851
  // src/services/email/email-service-singleton.ts
3863
- var singleton = chunkUHRHZXVR_cjs.createServiceSingleton("EmailService");
3852
+ var singleton = chunkPZGGIJI6_cjs.createServiceSingleton("EmailService");
3864
3853
  function setEmailService(service2) {
3865
3854
  singleton.set(service2);
3866
3855
  }
@@ -4668,7 +4657,7 @@ function getLexicalInitScript(settings = {}) {
4668
4657
  </script>
4669
4658
  `;
4670
4659
  }
4671
- var lexicalEditorPlugin = chunkUHRHZXVR_cjs.definePlugin({
4660
+ var lexicalEditorPlugin = chunkPZGGIJI6_cjs.definePlugin({
4672
4661
  id: "lexical-editor",
4673
4662
  version: "1.0.0",
4674
4663
  name: "Lexical Editor",
@@ -6887,7 +6876,7 @@ api.put("/:userId", async (c) => {
6887
6876
  await saveCustomData(db, userId, sanitized);
6888
6877
  return c.json({ success: true });
6889
6878
  });
6890
- var userProfilesPlugin = chunkUHRHZXVR_cjs.definePlugin({
6879
+ var userProfilesPlugin = chunkPZGGIJI6_cjs.definePlugin({
6891
6880
  id: "user-profiles",
6892
6881
  version: "1.0.0",
6893
6882
  name: "User Profiles",
@@ -6925,8 +6914,8 @@ function renderPasswordResetEmail(resetLink, firstName) {
6925
6914
  async function setCsrfCookie(c, maxAge) {
6926
6915
  const secret = c.env?.JWT_SECRET || JWT_SECRET_FALLBACK;
6927
6916
  const isDev = c.env?.ENVIRONMENT === "development" || !c.env?.ENVIRONMENT;
6928
- const csrfToken = await chunkYJEBDJDV_cjs.generateCsrfToken(secret);
6929
- const cookieMaxAge = await chunkYJEBDJDV_cjs.getJwtExpirySecondsFromDb(c.env?.DB, c.env);
6917
+ const csrfToken = await chunkVMBQ6NQB_cjs.generateCsrfToken(secret);
6918
+ const cookieMaxAge = await chunkVMBQ6NQB_cjs.getJwtExpirySecondsFromDb(c.env?.DB, c.env);
6930
6919
  cookie.setCookie(c, "csrf_token", csrfToken, {
6931
6920
  httpOnly: false,
6932
6921
  secure: !isDev,
@@ -6983,7 +6972,7 @@ var loginSchema = zod.z.object({
6983
6972
  });
6984
6973
  authRoutes.post(
6985
6974
  "/register",
6986
- chunkYJEBDJDV_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "register" }),
6975
+ chunkVMBQ6NQB_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "register" }),
6987
6976
  async (c) => {
6988
6977
  try {
6989
6978
  const db = c.env.DB;
@@ -7019,7 +7008,7 @@ authRoutes.post(
7019
7008
  if (existingUser) {
7020
7009
  return c.json({ error: "User with this email already exists" }, 400);
7021
7010
  }
7022
- const passwordHash = await chunkYJEBDJDV_cjs.AuthManager.hashPassword(password);
7011
+ const passwordHash = await chunkVMBQ6NQB_cjs.AuthManager.hashPassword(password);
7023
7012
  const userId = crypto.randomUUID();
7024
7013
  const now = /* @__PURE__ */ new Date();
7025
7014
  const nowSec = Math.floor(now.getTime() / 1e3);
@@ -7052,8 +7041,8 @@ authRoutes.post(
7052
7041
  { user: { id: userId, email: normalizedEmail, role: "viewer" } },
7053
7042
  "fire-and-forget"
7054
7043
  );
7055
- const tokenTtl = await chunkYJEBDJDV_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
7056
- const token = await chunkYJEBDJDV_cjs.AuthManager.generateToken(userId, normalizedEmail, "viewer", c.env.JWT_SECRET, tokenTtl);
7044
+ const tokenTtl = await chunkVMBQ6NQB_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
7045
+ const token = await chunkVMBQ6NQB_cjs.AuthManager.generateToken(userId, normalizedEmail, "viewer", c.env.JWT_SECRET, tokenTtl);
7057
7046
  cookie.setCookie(c, "auth_token", token, {
7058
7047
  httpOnly: true,
7059
7048
  secure: true,
@@ -7085,7 +7074,7 @@ authRoutes.post(
7085
7074
  );
7086
7075
  authRoutes.post(
7087
7076
  "/login",
7088
- chunkYJEBDJDV_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "login" }),
7077
+ chunkVMBQ6NQB_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "login" }),
7089
7078
  async (c) => {
7090
7079
  try {
7091
7080
  const body = await c.req.json();
@@ -7117,6 +7106,20 @@ authRoutes.post(
7117
7106
  await setCsrfCookie(c);
7118
7107
  const baBody = await baRes.json();
7119
7108
  const user = baBody.user ?? {};
7109
+ const tokenTtl = await chunkVMBQ6NQB_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
7110
+ const token = await chunkVMBQ6NQB_cjs.AuthManager.generateToken(
7111
+ user.id,
7112
+ user.email,
7113
+ user.role ?? "viewer",
7114
+ c.env.JWT_SECRET,
7115
+ tokenTtl
7116
+ );
7117
+ cookie.setCookie(c, "auth_token", token, {
7118
+ httpOnly: true,
7119
+ secure: true,
7120
+ sameSite: "Strict",
7121
+ maxAge: tokenTtl
7122
+ });
7120
7123
  return c.json({
7121
7124
  user: {
7122
7125
  id: user.id,
@@ -7124,7 +7127,8 @@ authRoutes.post(
7124
7127
  firstName: user.name?.split(" ")[0] ?? "",
7125
7128
  lastName: user.name?.split(" ").slice(1).join(" ") ?? "",
7126
7129
  role: user.role ?? "viewer"
7127
- }
7130
+ },
7131
+ token
7128
7132
  });
7129
7133
  } catch (error) {
7130
7134
  console.error("Login error:", error);
@@ -7164,7 +7168,7 @@ authRoutes.get("/logout", async (c) => {
7164
7168
  clearCsrfCookie(c);
7165
7169
  return c.redirect("/auth/login?message=You have been logged out successfully");
7166
7170
  });
7167
- authRoutes.get("/me", chunkYJEBDJDV_cjs.requireAuth(), async (c) => {
7171
+ authRoutes.get("/me", chunkVMBQ6NQB_cjs.requireAuth(), async (c) => {
7168
7172
  try {
7169
7173
  const user = c.get("user");
7170
7174
  if (!user) {
@@ -7184,7 +7188,7 @@ authRoutes.get("/me", chunkYJEBDJDV_cjs.requireAuth(), async (c) => {
7184
7188
  });
7185
7189
  authRoutes.post(
7186
7190
  "/refresh",
7187
- chunkYJEBDJDV_cjs.rateLimit({ max: 60, windowMs: 60 * 1e3, keyPrefix: "refresh" }),
7191
+ chunkVMBQ6NQB_cjs.rateLimit({ max: 60, windowMs: 60 * 1e3, keyPrefix: "refresh" }),
7188
7192
  async (c) => {
7189
7193
  try {
7190
7194
  let token = c.req.header("Authorization")?.replace("Bearer ", "");
@@ -7193,8 +7197,8 @@ authRoutes.post(
7193
7197
  return c.json({ error: "Authentication required" }, 401);
7194
7198
  }
7195
7199
  const db = c.env.DB;
7196
- const grace = await chunkYJEBDJDV_cjs.getJwtRefreshGraceSecondsFromDb(db, c.env);
7197
- const payload = await chunkYJEBDJDV_cjs.AuthManager.verifyToken(token, c.env.JWT_SECRET, grace);
7200
+ const grace = await chunkVMBQ6NQB_cjs.getJwtRefreshGraceSecondsFromDb(db, c.env);
7201
+ const payload = await chunkVMBQ6NQB_cjs.AuthManager.verifyToken(token, c.env.JWT_SECRET, grace);
7198
7202
  if (!payload) {
7199
7203
  return c.json({ error: "Invalid or expired token" }, 401);
7200
7204
  }
@@ -7202,8 +7206,8 @@ authRoutes.post(
7202
7206
  if (!row || !row.is_active) {
7203
7207
  return c.json({ error: "User is not active" }, 401);
7204
7208
  }
7205
- const tokenTtl = await chunkYJEBDJDV_cjs.getJwtExpirySecondsFromDb(db, c.env);
7206
- const newToken = await chunkYJEBDJDV_cjs.AuthManager.generateToken(row.id, row.email, row.role, c.env.JWT_SECRET, tokenTtl);
7209
+ const tokenTtl = await chunkVMBQ6NQB_cjs.getJwtExpirySecondsFromDb(db, c.env);
7210
+ const newToken = await chunkVMBQ6NQB_cjs.AuthManager.generateToken(row.id, row.email, row.role, c.env.JWT_SECRET, tokenTtl);
7207
7211
  cookie.setCookie(c, "auth_token", newToken, {
7208
7212
  httpOnly: true,
7209
7213
  secure: true,
@@ -7223,7 +7227,7 @@ authRoutes.post(
7223
7227
  );
7224
7228
  authRoutes.post(
7225
7229
  "/register/form",
7226
- chunkYJEBDJDV_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "register" }),
7230
+ chunkVMBQ6NQB_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "register" }),
7227
7231
  async (c) => {
7228
7232
  try {
7229
7233
  const db = c.env.DB;
@@ -7268,7 +7272,7 @@ authRoutes.post(
7268
7272
  </div>
7269
7273
  `);
7270
7274
  }
7271
- const passwordHash = await chunkYJEBDJDV_cjs.AuthManager.hashPassword(password);
7275
+ const passwordHash = await chunkVMBQ6NQB_cjs.AuthManager.hashPassword(password);
7272
7276
  const role = isFirstUser ? "admin" : "viewer";
7273
7277
  const userId = crypto.randomUUID();
7274
7278
  const now = /* @__PURE__ */ new Date();
@@ -7310,8 +7314,8 @@ authRoutes.post(
7310
7314
  { user: { id: userId, email: normalizedEmail, role } },
7311
7315
  "fire-and-forget"
7312
7316
  );
7313
- const tokenTtl = await chunkYJEBDJDV_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
7314
- const token = await chunkYJEBDJDV_cjs.AuthManager.generateToken(userId, normalizedEmail, role, c.env.JWT_SECRET, tokenTtl);
7317
+ const tokenTtl = await chunkVMBQ6NQB_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
7318
+ const token = await chunkVMBQ6NQB_cjs.AuthManager.generateToken(userId, normalizedEmail, role, c.env.JWT_SECRET, tokenTtl);
7315
7319
  cookie.setCookie(c, "auth_token", token, {
7316
7320
  httpOnly: true,
7317
7321
  secure: false,
@@ -7343,7 +7347,7 @@ authRoutes.post(
7343
7347
  );
7344
7348
  authRoutes.post(
7345
7349
  "/login/form",
7346
- chunkYJEBDJDV_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "login" }),
7350
+ chunkVMBQ6NQB_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "login" }),
7347
7351
  async (c) => {
7348
7352
  try {
7349
7353
  const formData = await c.req.formData();
@@ -7410,14 +7414,14 @@ authRoutes.post(
7410
7414
  );
7411
7415
  authRoutes.post(
7412
7416
  "/seed-admin",
7413
- chunkYJEBDJDV_cjs.rateLimit({ max: 10, windowMs: 60 * 1e3, keyPrefix: "seed-admin" }),
7417
+ chunkVMBQ6NQB_cjs.rateLimit({ max: 10, windowMs: 60 * 1e3, keyPrefix: "seed-admin" }),
7414
7418
  async (c) => {
7415
7419
  try {
7416
7420
  const db = c.env.DB;
7417
7421
  const rbac = new chunk2CB4KY7I_cjs.RbacService(db);
7418
7422
  const results = [];
7419
7423
  const upsertSeedUser = async (opts) => {
7420
- const passwordHash = await chunkYJEBDJDV_cjs.AuthManager.hashPassword(opts.password);
7424
+ const passwordHash = await chunkVMBQ6NQB_cjs.AuthManager.hashPassword(opts.password);
7421
7425
  const nowMs = Date.now();
7422
7426
  const nowSec = Math.floor(nowMs / 1e3);
7423
7427
  const existing = await db.prepare("SELECT id FROM auth_user WHERE email = ?").bind(opts.email).first();
@@ -7642,7 +7646,7 @@ authRoutes.post("/accept-invitation", async (c) => {
7642
7646
  if (invitationAge > maxAge) {
7643
7647
  return c.json({ error: "Invitation has expired" }, 400);
7644
7648
  }
7645
- const passwordHash = await chunkYJEBDJDV_cjs.AuthManager.hashPassword(password);
7649
+ const passwordHash = await chunkVMBQ6NQB_cjs.AuthManager.hashPassword(password);
7646
7650
  const updateStmt = db.prepare(`
7647
7651
  UPDATE auth_user SET
7648
7652
  password_hash = ?,
@@ -7659,8 +7663,8 @@ authRoutes.post("/accept-invitation", async (c) => {
7659
7663
  Date.now(),
7660
7664
  invitedUser.id
7661
7665
  ).run();
7662
- const tokenTtl = await chunkYJEBDJDV_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
7663
- const authToken = await chunkYJEBDJDV_cjs.AuthManager.generateToken(invitedUser.id, invitedUser.email, invitedUser.role, c.env.JWT_SECRET, tokenTtl);
7666
+ const tokenTtl = await chunkVMBQ6NQB_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
7667
+ const authToken = await chunkVMBQ6NQB_cjs.AuthManager.generateToken(invitedUser.id, invitedUser.email, invitedUser.role, c.env.JWT_SECRET, tokenTtl);
7664
7668
  cookie.setCookie(c, "auth_token", authToken, {
7665
7669
  httpOnly: true,
7666
7670
  secure: true,
@@ -7676,7 +7680,7 @@ authRoutes.post("/accept-invitation", async (c) => {
7676
7680
  });
7677
7681
  authRoutes.post(
7678
7682
  "/request-password-reset",
7679
- chunkYJEBDJDV_cjs.rateLimit({ max: 3, windowMs: 15 * 60 * 1e3, keyPrefix: "password-reset" }),
7683
+ chunkVMBQ6NQB_cjs.rateLimit({ max: 3, windowMs: 15 * 60 * 1e3, keyPrefix: "password-reset" }),
7680
7684
  async (c) => {
7681
7685
  try {
7682
7686
  const formData = await c.req.formData();
@@ -7913,7 +7917,7 @@ authRoutes.post("/reset-password", async (c) => {
7913
7917
  if (Date.now() > user.password_reset_expires) {
7914
7918
  return c.json({ error: "Reset token has expired" }, 400);
7915
7919
  }
7916
- const newPasswordHash = await chunkYJEBDJDV_cjs.AuthManager.hashPassword(password);
7920
+ const newPasswordHash = await chunkVMBQ6NQB_cjs.AuthManager.hashPassword(password);
7917
7921
  try {
7918
7922
  const historyStmt = db.prepare(`
7919
7923
  INSERT INTO auth_password_history (id, user_id, password_hash, created_at)
@@ -8127,7 +8131,7 @@ app.post("/test-seed-defaults", async (c) => {
8127
8131
  var test_cleanup_default = app;
8128
8132
 
8129
8133
  // src/plugins/available/easy-mdx/index.ts
8130
- chunkUHRHZXVR_cjs.definePlugin({
8134
+ chunkPZGGIJI6_cjs.definePlugin({
8131
8135
  id: "easy-mdx",
8132
8136
  version: "1.0.0",
8133
8137
  name: "EasyMDE Markdown Editor",
@@ -8327,7 +8331,7 @@ function getMDXEditorInitScript(config) {
8327
8331
  }
8328
8332
 
8329
8333
  // src/plugins/available/tinymce-plugin/index.ts
8330
- chunkUHRHZXVR_cjs.definePlugin({
8334
+ chunkPZGGIJI6_cjs.definePlugin({
8331
8335
  id: "tinymce-plugin",
8332
8336
  version: "1.0.0",
8333
8337
  name: "TinyMCE",
@@ -8597,7 +8601,7 @@ function getQuillCDN(version = "2.0.2") {
8597
8601
  </style>
8598
8602
  `;
8599
8603
  }
8600
- chunkUHRHZXVR_cjs.definePlugin({
8604
+ chunkPZGGIJI6_cjs.definePlugin({
8601
8605
  id: "quill-editor",
8602
8606
  version: "1.0.0",
8603
8607
  name: "Quill Editor",
@@ -11171,7 +11175,7 @@ function extractFieldData(fields, formData, options = {}) {
11171
11175
  }
11172
11176
  return { data, errors };
11173
11177
  }
11174
- adminContentRoutes.use("*", chunkYJEBDJDV_cjs.requireAuth());
11178
+ adminContentRoutes.use("*", chunkVMBQ6NQB_cjs.requireAuth());
11175
11179
  async function getCollectionFields(db, collectionId) {
11176
11180
  console.log(`[getCollectionFields] Loading fields for collection: ${collectionId}`);
11177
11181
  const collectionStmt = db.prepare("SELECT schema, queryable_fields FROM document_types WHERE id = ?");
@@ -11198,7 +11202,7 @@ async function getCollectionFields(db, collectionId) {
11198
11202
  };
11199
11203
  });
11200
11204
  }
11201
- const codeCollections2 = await chunkQJNKSFDJ_cjs.loadCollectionConfigs();
11205
+ const codeCollections2 = await chunkKPQ57HAH_cjs.loadCollectionConfigs();
11202
11206
  const codeMatch = codeCollections2.find((c) => c.name === collectionId);
11203
11207
  if (codeMatch && codeMatch.schema?.properties) {
11204
11208
  console.log(`[getCollectionFields] DB doc type has no properties \u2014 using code collection schema`);
@@ -11230,7 +11234,7 @@ async function getCollectionFields(db, collectionId) {
11230
11234
  }
11231
11235
  }
11232
11236
  console.log(`[getCollectionFields] Not in database, checking code collections`);
11233
- const codeCollections = await chunkQJNKSFDJ_cjs.loadCollectionConfigs();
11237
+ const codeCollections = await chunkKPQ57HAH_cjs.loadCollectionConfigs();
11234
11238
  console.log(`[getCollectionFields] Found ${codeCollections.length} code collections`);
11235
11239
  const codeCollection = codeCollections.find((c) => c.name === collectionId);
11236
11240
  if (codeCollection && codeCollection.schema) {
@@ -11284,7 +11288,7 @@ async function getCollection(db, collectionId) {
11284
11288
  };
11285
11289
  }
11286
11290
  console.log(`[getCollection] Not in database, checking code collections`);
11287
- const codeCollections = await chunkQJNKSFDJ_cjs.loadCollectionConfigs();
11291
+ const codeCollections = await chunkKPQ57HAH_cjs.loadCollectionConfigs();
11288
11292
  const codeCollection = codeCollections.find((c) => c.name === collectionId);
11289
11293
  if (codeCollection) {
11290
11294
  console.log(`[getCollection] Found code collection: ${collectionId}`);
@@ -11303,7 +11307,7 @@ async function getCollection(db, collectionId) {
11303
11307
  }
11304
11308
  async function getDocBackingType(db, collectionName) {
11305
11309
  if (!collectionName) return null;
11306
- const dt = await new chunkYJEBDJDV_cjs.DocumentTypeRegistry(db).findById(collectionName);
11310
+ const dt = await new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db).findById(collectionName);
11307
11311
  return dt && dt.isActive ? dt : null;
11308
11312
  }
11309
11313
  async function getCollectionByName(db, name) {
@@ -11320,7 +11324,7 @@ async function getCollectionByName(db, name) {
11320
11324
  };
11321
11325
  }
11322
11326
  console.log(`[getCollectionByName] Not in database, checking code collections`);
11323
- const codeCollections = await chunkQJNKSFDJ_cjs.loadCollectionConfigs();
11327
+ const codeCollections = await chunkKPQ57HAH_cjs.loadCollectionConfigs();
11324
11328
  const codeCollection = codeCollections.find((c) => c.name === name);
11325
11329
  if (codeCollection) {
11326
11330
  console.log(`[getCollectionByName] Found code collection: ${name}`);
@@ -11336,7 +11340,7 @@ async function getCollectionByName(db, name) {
11336
11340
  return null;
11337
11341
  }
11338
11342
  async function loadContentEditorFlags(db) {
11339
- const flags = { workflowEnabled: await chunkYJEBDJDV_cjs.isPluginActive(db, "workflow") };
11343
+ const flags = { workflowEnabled: await chunkVMBQ6NQB_cjs.isPluginActive(db, "workflow") };
11340
11344
  const editors = [
11341
11345
  ["tinymce-plugin", "tinymce"],
11342
11346
  ["quill-editor", "quill"],
@@ -11344,10 +11348,10 @@ async function loadContentEditorFlags(db) {
11344
11348
  ["lexical-editor", "lexical"]
11345
11349
  ];
11346
11350
  for (const [plugin, key] of editors) {
11347
- const enabled = await chunkYJEBDJDV_cjs.isPluginActive(db, plugin);
11351
+ const enabled = await chunkVMBQ6NQB_cjs.isPluginActive(db, plugin);
11348
11352
  flags[`${key}Enabled`] = enabled;
11349
11353
  if (enabled) {
11350
- const ps = new chunkQJNKSFDJ_cjs.PluginService(db);
11354
+ const ps = new chunkKPQ57HAH_cjs.PluginService(db);
11351
11355
  const p = await ps.getPlugin(plugin);
11352
11356
  flags[`${key}Settings`] = p?.settings;
11353
11357
  }
@@ -11383,9 +11387,9 @@ adminContentRoutes.get("/", async (c) => {
11383
11387
  const offset = (page - 1) * limit;
11384
11388
  const collectionsStmt = db.prepare("SELECT id, name, display_name FROM document_types WHERE is_active = 1 ORDER BY display_name");
11385
11389
  const { results: collectionsResults } = await collectionsStmt.all();
11386
- const codeCollections = await chunkQJNKSFDJ_cjs.loadCollectionConfigs();
11390
+ const codeCollections = await chunkKPQ57HAH_cjs.loadCollectionConfigs();
11387
11391
  const codeCollectionMap = new Map(codeCollections.map((c2) => [c2.name, c2]));
11388
- const docTypeRegistry = new chunkYJEBDJDV_cjs.DocumentTypeRegistry(db);
11392
+ const docTypeRegistry = new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db);
11389
11393
  const docTypes = (await docTypeRegistry.findAll()).filter((dt) => !dt.settings?.internal && !dt.isAuth);
11390
11394
  const visibleTypeIds = new Set(docTypes.map((dt) => dt.id));
11391
11395
  const allCollections = [
@@ -11397,7 +11401,7 @@ adminContentRoutes.get("/", async (c) => {
11397
11401
  ...allCollections.map((c2) => ({ name: c2.name, displayName: c2.displayName })),
11398
11402
  ...docTypes.filter((dt) => !collectionNames.has(dt.id)).map((dt) => ({ name: `doc:${dt.id}`, displayName: dt.displayName }))
11399
11403
  ];
11400
- const newContentCollections = await chunkQJNKSFDJ_cjs.getVisibleCollections(db);
11404
+ const newContentCollections = await chunkKPQ57HAH_cjs.getVisibleCollections(db);
11401
11405
  const docBackedCollection = !modelName.startsWith("doc:") && modelName !== "all" ? docTypes.find((dt) => dt.id === modelName) : void 0;
11402
11406
  const isDocModel = modelName.startsWith("doc:") || !!docBackedCollection;
11403
11407
  if (isDocModel) {
@@ -11674,9 +11678,9 @@ adminContentRoutes.get("/new", async (c) => {
11674
11678
  const collectionsStmt = db2.prepare("SELECT id, name, display_name, description FROM document_types WHERE is_active = 1 ORDER BY display_name");
11675
11679
  const { results } = await collectionsStmt.all();
11676
11680
  const visibleTypeIds = new Set(
11677
- (await new chunkYJEBDJDV_cjs.DocumentTypeRegistry(db2).findAll()).filter((dt) => !dt.settings?.internal && !dt.isAuth).map((dt) => dt.id)
11681
+ (await new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db2).findAll()).filter((dt) => !dt.settings?.internal && !dt.isAuth).map((dt) => dt.id)
11678
11682
  );
11679
- const codeCollections = await chunkQJNKSFDJ_cjs.loadCollectionConfigs();
11683
+ const codeCollections = await chunkKPQ57HAH_cjs.loadCollectionConfigs();
11680
11684
  const dbCollectionNames = new Set((results || []).map((r) => r.name));
11681
11685
  const allCollections = [
11682
11686
  ...codeCollections.filter((c2) => !dbCollectionNames.has(c2.name)).map((c2) => ({
@@ -11742,32 +11746,32 @@ adminContentRoutes.get("/new", async (c) => {
11742
11746
  return c.html(renderContentFormPage(formData2));
11743
11747
  }
11744
11748
  const fields = await getCollectionFields(db, collection.id);
11745
- const workflowEnabled = await chunkYJEBDJDV_cjs.isPluginActive(db, "workflow");
11746
- const tinymceEnabled = await chunkYJEBDJDV_cjs.isPluginActive(db, "tinymce-plugin");
11749
+ const workflowEnabled = await chunkVMBQ6NQB_cjs.isPluginActive(db, "workflow");
11750
+ const tinymceEnabled = await chunkVMBQ6NQB_cjs.isPluginActive(db, "tinymce-plugin");
11747
11751
  let tinymceSettings;
11748
11752
  if (tinymceEnabled) {
11749
- const pluginService = new chunkQJNKSFDJ_cjs.PluginService(db);
11753
+ const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
11750
11754
  const tinymcePlugin2 = await pluginService.getPlugin("tinymce-plugin");
11751
11755
  tinymceSettings = tinymcePlugin2?.settings;
11752
11756
  }
11753
- const quillEnabled = await chunkYJEBDJDV_cjs.isPluginActive(db, "quill-editor");
11757
+ const quillEnabled = await chunkVMBQ6NQB_cjs.isPluginActive(db, "quill-editor");
11754
11758
  let quillSettings;
11755
11759
  if (quillEnabled) {
11756
- const pluginService = new chunkQJNKSFDJ_cjs.PluginService(db);
11760
+ const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
11757
11761
  const quillPlugin = await pluginService.getPlugin("quill-editor");
11758
11762
  quillSettings = quillPlugin?.settings;
11759
11763
  }
11760
- const mdxeditorEnabled = await chunkYJEBDJDV_cjs.isPluginActive(db, "easy-mdx");
11764
+ const mdxeditorEnabled = await chunkVMBQ6NQB_cjs.isPluginActive(db, "easy-mdx");
11761
11765
  let mdxeditorSettings;
11762
11766
  if (mdxeditorEnabled) {
11763
- const pluginService = new chunkQJNKSFDJ_cjs.PluginService(db);
11767
+ const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
11764
11768
  const mdxeditorPlugin = await pluginService.getPlugin("easy-mdx");
11765
11769
  mdxeditorSettings = mdxeditorPlugin?.settings;
11766
11770
  }
11767
- const lexicalEnabled = await chunkYJEBDJDV_cjs.isPluginActive(db, "lexical-editor");
11771
+ const lexicalEnabled = await chunkVMBQ6NQB_cjs.isPluginActive(db, "lexical-editor");
11768
11772
  let lexicalSettings;
11769
11773
  if (lexicalEnabled) {
11770
- const pluginService = new chunkQJNKSFDJ_cjs.PluginService(db);
11774
+ const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
11771
11775
  const lexicalPlugin = await pluginService.getPlugin("lexical-editor");
11772
11776
  lexicalSettings = lexicalPlugin?.settings;
11773
11777
  }
@@ -11895,32 +11899,32 @@ adminContentRoutes.get("/:id/edit", async (c) => {
11895
11899
  };
11896
11900
  const fields = await getCollectionFields(db, content.collection_id);
11897
11901
  const contentData = content.data ? JSON.parse(content.data) : {};
11898
- const workflowEnabled = await chunkYJEBDJDV_cjs.isPluginActive(db, "workflow");
11899
- const tinymceEnabled = await chunkYJEBDJDV_cjs.isPluginActive(db, "tinymce-plugin");
11902
+ const workflowEnabled = await chunkVMBQ6NQB_cjs.isPluginActive(db, "workflow");
11903
+ const tinymceEnabled = await chunkVMBQ6NQB_cjs.isPluginActive(db, "tinymce-plugin");
11900
11904
  let tinymceSettings;
11901
11905
  if (tinymceEnabled) {
11902
- const pluginService = new chunkQJNKSFDJ_cjs.PluginService(db);
11906
+ const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
11903
11907
  const tinymcePlugin2 = await pluginService.getPlugin("tinymce-plugin");
11904
11908
  tinymceSettings = tinymcePlugin2?.settings;
11905
11909
  }
11906
- const quillEnabled = await chunkYJEBDJDV_cjs.isPluginActive(db, "quill-editor");
11910
+ const quillEnabled = await chunkVMBQ6NQB_cjs.isPluginActive(db, "quill-editor");
11907
11911
  let quillSettings;
11908
11912
  if (quillEnabled) {
11909
- const pluginService = new chunkQJNKSFDJ_cjs.PluginService(db);
11913
+ const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
11910
11914
  const quillPlugin = await pluginService.getPlugin("quill-editor");
11911
11915
  quillSettings = quillPlugin?.settings;
11912
11916
  }
11913
- const mdxeditorEnabled = await chunkYJEBDJDV_cjs.isPluginActive(db, "easy-mdx");
11917
+ const mdxeditorEnabled = await chunkVMBQ6NQB_cjs.isPluginActive(db, "easy-mdx");
11914
11918
  let mdxeditorSettings;
11915
11919
  if (mdxeditorEnabled) {
11916
- const pluginService = new chunkQJNKSFDJ_cjs.PluginService(db);
11920
+ const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
11917
11921
  const mdxeditorPlugin = await pluginService.getPlugin("easy-mdx");
11918
11922
  mdxeditorSettings = mdxeditorPlugin?.settings;
11919
11923
  }
11920
- const lexicalEnabled = await chunkYJEBDJDV_cjs.isPluginActive(db, "lexical-editor");
11924
+ const lexicalEnabled = await chunkVMBQ6NQB_cjs.isPluginActive(db, "lexical-editor");
11921
11925
  let lexicalSettings;
11922
11926
  if (lexicalEnabled) {
11923
- const pluginService = new chunkQJNKSFDJ_cjs.PluginService(db);
11927
+ const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
11924
11928
  const lexicalPlugin = await pluginService.getPlugin("lexical-editor");
11925
11929
  lexicalSettings = lexicalPlugin?.settings;
11926
11930
  }
@@ -12293,7 +12297,7 @@ adminContentRoutes.put("/:id", async (c) => {
12293
12297
  `);
12294
12298
  }
12295
12299
  });
12296
- adminContentRoutes.post("/preview", chunkYJEBDJDV_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
12300
+ adminContentRoutes.post("/preview", chunkVMBQ6NQB_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
12297
12301
  try {
12298
12302
  const formData = await c.req.formData();
12299
12303
  const collectionId = formData.get("collection_id");
@@ -12612,7 +12616,7 @@ adminContentRoutes.delete("/:id", async (c) => {
12612
12616
  return c.json({ success: false, error: "Failed to delete content" }, 500);
12613
12617
  }
12614
12618
  });
12615
- adminContentRoutes.get("/:id/version/:version/preview", chunkYJEBDJDV_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
12619
+ adminContentRoutes.get("/:id/version/:version/preview", chunkVMBQ6NQB_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
12616
12620
  try {
12617
12621
  const id = c.req.param("id");
12618
12622
  const version = parseInt(c.req.param("version") || "0");
@@ -12708,7 +12712,7 @@ function parseDocFormData(formData, queryableFields = []) {
12708
12712
  return { title, slug, data };
12709
12713
  }
12710
12714
  async function getDocService(db, typeId, tenantId) {
12711
- const registry = new chunkYJEBDJDV_cjs.DocumentTypeRegistry(db);
12715
+ const registry = new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db);
12712
12716
  const docType = await registry.findById(typeId);
12713
12717
  const svc = new chunk2CB4KY7I_cjs.DocumentsService(db, {
12714
12718
  queryableFields: docType?.queryableFields ?? [],
@@ -12721,7 +12725,7 @@ async function getDocService(db, typeId, tenantId) {
12721
12725
  }
12722
12726
  adminContentRoutes.get("/documents/:typeId/new", async (c) => {
12723
12727
  const { typeId } = c.req.param();
12724
- const registry = new chunkYJEBDJDV_cjs.DocumentTypeRegistry(c.env.DB);
12728
+ const registry = new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(c.env.DB);
12725
12729
  const docType = await registry.findById(typeId);
12726
12730
  if (!docType) return c.html("<p>Unknown document type.</p>", 404);
12727
12731
  return c.html(chunkN32OWET6_cjs.renderDocumentFormPage({ docType, isEdit: false, user: userCtx(c) }));
@@ -12746,7 +12750,7 @@ adminContentRoutes.post("/documents/:typeId/new", async (c) => {
12746
12750
  }), user?.userId);
12747
12751
  return c.redirect(`/admin/content/documents/${typeId}/${doc.rootId}/edit?message=Created+successfully`);
12748
12752
  } catch (err) {
12749
- const registry = new chunkYJEBDJDV_cjs.DocumentTypeRegistry(c.env.DB);
12753
+ const registry = new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(c.env.DB);
12750
12754
  const docType = await registry.findById(typeId);
12751
12755
  if (!docType) return c.html("<p>Unknown document type.</p>", 404);
12752
12756
  return c.html(chunkN32OWET6_cjs.renderDocumentFormPage({ docType, isEdit: false, user: userCtx(c), message: err?.message ?? "Failed to create", messageType: "error" }));
@@ -12756,7 +12760,7 @@ adminContentRoutes.get("/documents/:typeId/:rootId/edit", async (c) => {
12756
12760
  const { typeId, rootId } = c.req.param();
12757
12761
  const db = c.env.DB;
12758
12762
  const message = c.req.query("message");
12759
- const registry = new chunkYJEBDJDV_cjs.DocumentTypeRegistry(db);
12763
+ const registry = new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db);
12760
12764
  const docType = await registry.findById(typeId);
12761
12765
  if (!docType) return c.html("<p>Unknown document type.</p>", 404);
12762
12766
  const tenantId = reqTenant(c);
@@ -12869,7 +12873,7 @@ adminContentRoutes.get("/documents/:typeId/:rootId/versions", async (c) => {
12869
12873
  const { typeId, rootId } = c.req.param();
12870
12874
  const db = c.env.DB;
12871
12875
  const { renderVersionHistoryFragment } = await import('./admin-documents-form.template-LSZKGA5J.cjs');
12872
- const registry = new chunkYJEBDJDV_cjs.DocumentTypeRegistry(db);
12876
+ const registry = new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db);
12873
12877
  const docType = await registry.findById(typeId);
12874
12878
  if (!docType) return c.html("<div>Unknown type.</div>", 404);
12875
12879
  const result = await db.prepare(
@@ -14801,7 +14805,7 @@ var TenantService = class {
14801
14805
  SET name = ?, domain = ?, status = ?, notes = ?, updated_at = ?
14802
14806
  WHERE slug = ?
14803
14807
  `).bind(name, domain, status, notes, now, slug).run();
14804
- chunkQJNKSFDJ_cjs.invalidateTenantCache();
14808
+ chunkKPQ57HAH_cjs.invalidateTenantCache();
14805
14809
  const updated = await this.getTenantBySlug(slug);
14806
14810
  if (!updated) throw new Error("Tenant not found");
14807
14811
  return updated;
@@ -14819,7 +14823,7 @@ var TenantService = class {
14819
14823
  throw new Error(`Tenant '${slug}' still owns ${docCount} document(s). Delete or migrate its content first.`);
14820
14824
  }
14821
14825
  await this.db.prepare(`DELETE FROM auth_tenant WHERE slug = ?`).bind(slug).run();
14822
- chunkQJNKSFDJ_cjs.invalidateTenantCache();
14826
+ chunkKPQ57HAH_cjs.invalidateTenantCache();
14823
14827
  }
14824
14828
  // ─── Membership (auth_tenant_member) ───────────────────────────────────────
14825
14829
  // Tenant resolution and the admin switcher are gated on membership: an authed user may only
@@ -15063,7 +15067,7 @@ var TenantService = class {
15063
15067
  INSERT INTO auth_tenant (id, name, slug, status, domain, notes, metadata, created_at, updated_at)
15064
15068
  VALUES (?, ?, ?, 'active', ?, ?, '{}', ?, ?)
15065
15069
  `).bind(id, input.name, input.slug, input.domain, input.notes, now, now).run();
15066
- chunkQJNKSFDJ_cjs.invalidateTenantCache();
15070
+ chunkKPQ57HAH_cjs.invalidateTenantCache();
15067
15071
  const created = await this.getTenantBySlug(input.slug);
15068
15072
  if (!created) throw new Error("Failed to create tenant");
15069
15073
  return created;
@@ -15087,14 +15091,14 @@ function mapRowToTenant(row) {
15087
15091
 
15088
15092
  // src/routes/admin-users.ts
15089
15093
  var userRoutes = new hono.Hono();
15090
- userRoutes.use("*", chunkYJEBDJDV_cjs.requireAuth());
15091
- userRoutes.use("/users/*", chunkYJEBDJDV_cjs.requireRole(["admin"]));
15092
- userRoutes.use("/users", chunkYJEBDJDV_cjs.requireRole(["admin"]));
15093
- userRoutes.use("/invite-user", chunkYJEBDJDV_cjs.requireRole(["admin"]));
15094
- userRoutes.use("/resend-invitation/*", chunkYJEBDJDV_cjs.requireRole(["admin"]));
15095
- userRoutes.use("/cancel-invitation/*", chunkYJEBDJDV_cjs.requireRole(["admin"]));
15096
- userRoutes.use("/activity-logs", chunkYJEBDJDV_cjs.requireRole(["admin"]));
15097
- userRoutes.use("/activity-logs/*", chunkYJEBDJDV_cjs.requireRole(["admin"]));
15094
+ userRoutes.use("*", chunkVMBQ6NQB_cjs.requireAuth());
15095
+ userRoutes.use("/users/*", chunkVMBQ6NQB_cjs.requireRole(["admin"]));
15096
+ userRoutes.use("/users", chunkVMBQ6NQB_cjs.requireRole(["admin"]));
15097
+ userRoutes.use("/invite-user", chunkVMBQ6NQB_cjs.requireRole(["admin"]));
15098
+ userRoutes.use("/resend-invitation/*", chunkVMBQ6NQB_cjs.requireRole(["admin"]));
15099
+ userRoutes.use("/cancel-invitation/*", chunkVMBQ6NQB_cjs.requireRole(["admin"]));
15100
+ userRoutes.use("/activity-logs", chunkVMBQ6NQB_cjs.requireRole(["admin"]));
15101
+ userRoutes.use("/activity-logs/*", chunkVMBQ6NQB_cjs.requireRole(["admin"]));
15098
15102
  userRoutes.get("/", (c) => {
15099
15103
  return c.redirect("/admin/dashboard");
15100
15104
  });
@@ -15261,7 +15265,7 @@ userRoutes.put("/profile", async (c) => {
15261
15265
  }
15262
15266
  await saveCustomData(db, user.userId, sanitized);
15263
15267
  }
15264
- await chunkYJEBDJDV_cjs.logActivity(
15268
+ await chunkVMBQ6NQB_cjs.logActivity(
15265
15269
  db,
15266
15270
  user.userId,
15267
15271
  "profile.update",
@@ -15324,7 +15328,7 @@ userRoutes.post("/profile/avatar", async (c) => {
15324
15328
  SELECT first_name, last_name FROM auth_user WHERE id = ?
15325
15329
  `);
15326
15330
  const userData = await userStmt.bind(user.userId).first();
15327
- await chunkYJEBDJDV_cjs.logActivity(
15331
+ await chunkVMBQ6NQB_cjs.logActivity(
15328
15332
  db,
15329
15333
  user.userId,
15330
15334
  "profile.avatar_update",
@@ -15395,7 +15399,7 @@ userRoutes.post("/profile/password", async (c) => {
15395
15399
  dismissible: true
15396
15400
  }));
15397
15401
  }
15398
- const validPassword = await chunkYJEBDJDV_cjs.AuthManager.verifyPassword(currentPassword, userData.password_hash);
15402
+ const validPassword = await chunkVMBQ6NQB_cjs.AuthManager.verifyPassword(currentPassword, userData.password_hash);
15399
15403
  if (!validPassword) {
15400
15404
  return c.html(chunkN32OWET6_cjs.renderAlert({
15401
15405
  type: "error",
@@ -15403,7 +15407,7 @@ userRoutes.post("/profile/password", async (c) => {
15403
15407
  dismissible: true
15404
15408
  }));
15405
15409
  }
15406
- const newPasswordHash = await chunkYJEBDJDV_cjs.AuthManager.hashPassword(newPassword);
15410
+ const newPasswordHash = await chunkVMBQ6NQB_cjs.AuthManager.hashPassword(newPassword);
15407
15411
  const historyStmt = db.prepare(`
15408
15412
  INSERT INTO auth_password_history (id, user_id, password_hash, created_at)
15409
15413
  VALUES (?, ?, ?, ?)
@@ -15419,7 +15423,7 @@ userRoutes.post("/profile/password", async (c) => {
15419
15423
  WHERE id = ?
15420
15424
  `);
15421
15425
  await updateStmt.bind(newPasswordHash, Date.now(), user.userId).run();
15422
- await chunkYJEBDJDV_cjs.logActivity(
15426
+ await chunkVMBQ6NQB_cjs.logActivity(
15423
15427
  db,
15424
15428
  user.userId,
15425
15429
  "profile.password_change",
@@ -15486,7 +15490,7 @@ userRoutes.get("/users", async (c) => {
15486
15490
  `);
15487
15491
  const countResult = await countStmt.bind(...params).first();
15488
15492
  const totalUsers = countResult?.total || 0;
15489
- await chunkYJEBDJDV_cjs.logActivity(
15493
+ await chunkVMBQ6NQB_cjs.logActivity(
15490
15494
  db,
15491
15495
  user.userId,
15492
15496
  "users.list_view",
@@ -15667,7 +15671,7 @@ userRoutes.post("/users/new", async (c) => {
15667
15671
  dismissible: true
15668
15672
  }));
15669
15673
  }
15670
- const passwordHash = await chunkYJEBDJDV_cjs.AuthManager.hashPassword(password);
15674
+ const passwordHash = await chunkVMBQ6NQB_cjs.AuthManager.hashPassword(password);
15671
15675
  const userId = crypto.randomUUID();
15672
15676
  const createStmt = db.prepare(`
15673
15677
  INSERT INTO auth_user (
@@ -15692,7 +15696,7 @@ userRoutes.post("/users/new", async (c) => {
15692
15696
  if (sanitizedRegistrationCustom !== null && Object.keys(sanitizedRegistrationCustom).length > 0) {
15693
15697
  await writeProfileData(db, userId, { custom: sanitizedRegistrationCustom }, user.userId);
15694
15698
  }
15695
- await chunkYJEBDJDV_cjs.logActivity(
15699
+ await chunkVMBQ6NQB_cjs.logActivity(
15696
15700
  db,
15697
15701
  user.userId,
15698
15702
  "user!.create",
@@ -15731,7 +15735,7 @@ userRoutes.get("/users/:id", async (c) => {
15731
15735
  if (!userRecord) {
15732
15736
  return c.json({ error: "User not found" }, 404);
15733
15737
  }
15734
- await chunkYJEBDJDV_cjs.logActivity(
15738
+ await chunkVMBQ6NQB_cjs.logActivity(
15735
15739
  db,
15736
15740
  user.userId,
15737
15741
  "user!.view",
@@ -15945,7 +15949,7 @@ userRoutes.put("/users/:id", async (c) => {
15945
15949
  userId
15946
15950
  ).run();
15947
15951
  if (newPassword) {
15948
- const passwordHash = await chunkYJEBDJDV_cjs.AuthManager.hashPassword(newPassword);
15952
+ const passwordHash = await chunkVMBQ6NQB_cjs.AuthManager.hashPassword(newPassword);
15949
15953
  const updatePasswordStmt = db.prepare(`
15950
15954
  UPDATE auth_user SET password_hash = ?, updated_at = ? WHERE id = ?
15951
15955
  `);
@@ -15958,7 +15962,7 @@ userRoutes.put("/users/:id", async (c) => {
15958
15962
  ...sanitizedCustom !== null ? { custom: sanitizedCustom } : {}
15959
15963
  }, user.userId);
15960
15964
  }
15961
- await chunkYJEBDJDV_cjs.logActivity(
15965
+ await chunkVMBQ6NQB_cjs.logActivity(
15962
15966
  db,
15963
15967
  user.userId,
15964
15968
  "user.update",
@@ -16004,7 +16008,7 @@ userRoutes.post("/users/:id/toggle", async (c) => {
16004
16008
  UPDATE auth_user SET is_active = ?, updated_at = ? WHERE id = ?
16005
16009
  `);
16006
16010
  await toggleStmt.bind(active ? 1 : 0, Date.now(), userId).run();
16007
- await chunkYJEBDJDV_cjs.logActivity(
16011
+ await chunkVMBQ6NQB_cjs.logActivity(
16008
16012
  db,
16009
16013
  user.userId,
16010
16014
  active ? "user.activate" : "user.deactivate",
@@ -16045,7 +16049,7 @@ userRoutes.delete("/users/:id", async (c) => {
16045
16049
  DELETE FROM auth_user WHERE id = ?
16046
16050
  `);
16047
16051
  await deleteStmt.bind(userId).run();
16048
- await chunkYJEBDJDV_cjs.logActivity(
16052
+ await chunkVMBQ6NQB_cjs.logActivity(
16049
16053
  db,
16050
16054
  user.userId,
16051
16055
  "user!.hard_delete",
@@ -16064,7 +16068,7 @@ userRoutes.delete("/users/:id", async (c) => {
16064
16068
  UPDATE auth_user SET is_active = 0, updated_at = ? WHERE id = ?
16065
16069
  `);
16066
16070
  await deleteStmt.bind(Date.now(), userId).run();
16067
- await chunkYJEBDJDV_cjs.logActivity(
16071
+ await chunkVMBQ6NQB_cjs.logActivity(
16068
16072
  db,
16069
16073
  user.userId,
16070
16074
  "user!.soft_delete",
@@ -16130,7 +16134,7 @@ userRoutes.post("/invite-user", async (c) => {
16130
16134
  Date.now(),
16131
16135
  Date.now()
16132
16136
  ).run();
16133
- await chunkYJEBDJDV_cjs.logActivity(
16137
+ await chunkVMBQ6NQB_cjs.logActivity(
16134
16138
  db,
16135
16139
  user.userId,
16136
16140
  "user!.invite_sent",
@@ -16187,7 +16191,7 @@ userRoutes.post("/resend-invitation/:id", async (c) => {
16187
16191
  Date.now(),
16188
16192
  userId
16189
16193
  ).run();
16190
- await chunkYJEBDJDV_cjs.logActivity(
16194
+ await chunkVMBQ6NQB_cjs.logActivity(
16191
16195
  db,
16192
16196
  user.userId,
16193
16197
  "user!.invitation_resent",
@@ -16223,7 +16227,7 @@ userRoutes.delete("/cancel-invitation/:id", async (c) => {
16223
16227
  }
16224
16228
  const deleteStmt = db.prepare(`DELETE FROM auth_user WHERE id = ?`);
16225
16229
  await deleteStmt.bind(userId).run();
16226
- await chunkYJEBDJDV_cjs.logActivity(
16230
+ await chunkVMBQ6NQB_cjs.logActivity(
16227
16231
  db,
16228
16232
  user.userId,
16229
16233
  "user!.invitation_cancelled",
@@ -17604,7 +17608,7 @@ var fileValidationSchema2 = zod.z.object({
17604
17608
  // 50MB max
17605
17609
  });
17606
17610
  var adminMediaRoutes = new hono.Hono();
17607
- adminMediaRoutes.use("*", chunkYJEBDJDV_cjs.requireAuth());
17611
+ adminMediaRoutes.use("*", chunkVMBQ6NQB_cjs.requireAuth());
17608
17612
  adminMediaRoutes.get("/", async (c) => {
17609
17613
  try {
17610
17614
  const user = c.get("user");
@@ -17646,7 +17650,7 @@ adminMediaRoutes.get("/selector", async (c) => {
17646
17650
  const { searchParams } = new URL(c.req.url);
17647
17651
  const search = searchParams.get("search") || "";
17648
17652
  const db = c.env.DB;
17649
- const pluginService = new chunkQJNKSFDJ_cjs.PluginService(db);
17653
+ const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
17650
17654
  const mediaPlugin = await pluginService.getPlugin("core-media");
17651
17655
  if (!mediaPlugin || mediaPlugin.status !== "active") {
17652
17656
  return c.html(html.html`
@@ -18020,7 +18024,7 @@ adminMediaRoutes.put("/:id", async (c) => {
18020
18024
  `);
18021
18025
  }
18022
18026
  });
18023
- adminMediaRoutes.delete("/cleanup", chunkYJEBDJDV_cjs.requireRole("admin"), async (c) => {
18027
+ adminMediaRoutes.delete("/cleanup", chunkVMBQ6NQB_cjs.requireRole("admin"), async (c) => {
18024
18028
  try {
18025
18029
  const db = c.env.DB;
18026
18030
  const allMediaStmt = db.prepare("SELECT id, r2_key, filename FROM media WHERE deleted_at IS NULL");
@@ -20453,8 +20457,8 @@ defineUserProfile({
20453
20457
 
20454
20458
  // src/routes/admin-plugins.ts
20455
20459
  var adminPluginRoutes = new hono.Hono();
20456
- adminPluginRoutes.use("*", chunkYJEBDJDV_cjs.requireAuth());
20457
- var AVAILABLE_PLUGINS = Object.values(chunkQJNKSFDJ_cjs.PLUGIN_REGISTRY).map((p) => ({
20460
+ adminPluginRoutes.use("*", chunkVMBQ6NQB_cjs.requireAuth());
20461
+ var AVAILABLE_PLUGINS = Object.values(chunkKPQ57HAH_cjs.PLUGIN_REGISTRY).map((p) => ({
20458
20462
  id: p.id,
20459
20463
  name: p.codeName,
20460
20464
  display_name: p.displayName,
@@ -20474,7 +20478,7 @@ adminPluginRoutes.get("/", async (c) => {
20474
20478
  if (user?.role !== "admin") {
20475
20479
  return c.text("Access denied", 403);
20476
20480
  }
20477
- const pluginService = new chunkQJNKSFDJ_cjs.PluginService(db);
20481
+ const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
20478
20482
  let installedPlugins = [];
20479
20483
  let stats = { total: 0, active: 0, inactive: 0, errors: 0, uninstalled: 0 };
20480
20484
  try {
@@ -20546,10 +20550,10 @@ adminPluginRoutes.get("/:id", async (c) => {
20546
20550
  if (user?.role !== "admin") {
20547
20551
  return c.redirect("/admin/plugins");
20548
20552
  }
20549
- const pluginService = new chunkQJNKSFDJ_cjs.PluginService(db);
20553
+ const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
20550
20554
  let plugin = await pluginService.getPlugin(pluginId);
20551
20555
  if (!plugin) {
20552
- const def = chunkUHRHZXVR_cjs.getPluginDefinition(pluginId);
20556
+ const def = chunkPZGGIJI6_cjs.getPluginDefinition(pluginId);
20553
20557
  if (!def) return c.text("Plugin not found", 404);
20554
20558
  plugin = await pluginService.ensurePlugin(pluginId, {
20555
20559
  displayName: def.displayName ?? pluginId,
@@ -20640,14 +20644,14 @@ adminPluginRoutes.get("/:id/configure", async (c) => {
20640
20644
  const user = c.get("user");
20641
20645
  const pluginId = c.req.param("id");
20642
20646
  if (user?.role !== "admin") return c.redirect("/admin/plugins");
20643
- const def = chunkUHRHZXVR_cjs.getPluginDefinition(pluginId);
20647
+ const def = chunkPZGGIJI6_cjs.getPluginDefinition(pluginId);
20644
20648
  if (!def?.configSchema) return c.text("No schema-driven settings for this plugin", 404);
20645
20649
  const db = c.env.DB;
20646
- const pluginService = new chunkQJNKSFDJ_cjs.PluginService(db);
20650
+ const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
20647
20651
  const plugin = await pluginService.getPlugin(pluginId);
20648
20652
  const stored = plugin?.settings ?? {};
20649
- const values = chunkUHRHZXVR_cjs.applySchemaDefaults(def.configSchema, stored);
20650
- const fieldsHtml = chunkUHRHZXVR_cjs.renderSchemaFields(def.configSchema, values);
20653
+ const values = chunkPZGGIJI6_cjs.applySchemaDefaults(def.configSchema, stored);
20654
+ const fieldsHtml = chunkPZGGIJI6_cjs.renderSchemaFields(def.configSchema, values);
20651
20655
  const displayName = plugin?.display_name ?? def.displayName ?? def.id;
20652
20656
  return c.html(`<!DOCTYPE html>
20653
20657
  <html lang="en"><head>
@@ -20674,12 +20678,12 @@ adminPluginRoutes.post("/:id/configure", async (c) => {
20674
20678
  const user = c.get("user");
20675
20679
  const pluginId = c.req.param("id");
20676
20680
  if (user?.role !== "admin") return c.json({ error: "Access denied" }, 403);
20677
- const def = chunkUHRHZXVR_cjs.getPluginDefinition(pluginId);
20681
+ const def = chunkPZGGIJI6_cjs.getPluginDefinition(pluginId);
20678
20682
  if (!def?.configSchema) return c.text("No schema-driven settings for this plugin", 404);
20679
20683
  const form = await c.req.formData();
20680
- const parsed = chunkUHRHZXVR_cjs.parseFormDataToSettings(def.configSchema, form);
20684
+ const parsed = chunkPZGGIJI6_cjs.parseFormDataToSettings(def.configSchema, form);
20681
20685
  const db = c.env.DB;
20682
- const pluginService = new chunkQJNKSFDJ_cjs.PluginService(db);
20686
+ const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
20683
20687
  await pluginService.ensurePlugin(pluginId, {
20684
20688
  displayName: def.displayName ?? pluginId,
20685
20689
  version: def.version,
@@ -20701,7 +20705,7 @@ adminPluginRoutes.post("/:id/activate", async (c) => {
20701
20705
  if (user?.role !== "admin") {
20702
20706
  return c.json({ error: "Access denied" }, 403);
20703
20707
  }
20704
- const pluginService = new chunkQJNKSFDJ_cjs.PluginService(db);
20708
+ const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
20705
20709
  await pluginService.activatePlugin(pluginId);
20706
20710
  return c.json({ success: true });
20707
20711
  } catch (error) {
@@ -20718,7 +20722,7 @@ adminPluginRoutes.post("/:id/deactivate", async (c) => {
20718
20722
  if (user?.role !== "admin") {
20719
20723
  return c.json({ error: "Access denied" }, 403);
20720
20724
  }
20721
- const pluginService = new chunkQJNKSFDJ_cjs.PluginService(db);
20725
+ const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
20722
20726
  await pluginService.deactivatePlugin(pluginId);
20723
20727
  return c.json({ success: true });
20724
20728
  } catch (error) {
@@ -20735,8 +20739,8 @@ adminPluginRoutes.post("/install", async (c) => {
20735
20739
  return c.json({ error: "Access denied" }, 403);
20736
20740
  }
20737
20741
  const body = await c.req.json();
20738
- const pluginService = new chunkQJNKSFDJ_cjs.PluginService(db);
20739
- const registryEntry = chunkQJNKSFDJ_cjs.findPluginByCodeName(body.name) || chunkQJNKSFDJ_cjs.PLUGIN_REGISTRY[body.name] || chunkQJNKSFDJ_cjs.PLUGIN_REGISTRY[body.id];
20742
+ const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
20743
+ const registryEntry = chunkKPQ57HAH_cjs.findPluginByCodeName(body.name) || chunkKPQ57HAH_cjs.PLUGIN_REGISTRY[body.name] || chunkKPQ57HAH_cjs.PLUGIN_REGISTRY[body.id];
20740
20744
  if (!registryEntry) {
20741
20745
  return c.json({ error: "Plugin not found in registry" }, 404);
20742
20746
  }
@@ -20769,7 +20773,7 @@ adminPluginRoutes.post("/:id/uninstall", async (c) => {
20769
20773
  if (user?.role !== "admin") {
20770
20774
  return c.json({ error: "Access denied" }, 403);
20771
20775
  }
20772
- const pluginService = new chunkQJNKSFDJ_cjs.PluginService(db);
20776
+ const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
20773
20777
  await pluginService.uninstallPlugin(pluginId);
20774
20778
  return c.json({ success: true });
20775
20779
  } catch (error) {
@@ -20787,7 +20791,7 @@ adminPluginRoutes.post("/:id/settings", async (c) => {
20787
20791
  return c.json({ error: "Access denied" }, 403);
20788
20792
  }
20789
20793
  const settings = await c.req.json();
20790
- const pluginService = new chunkQJNKSFDJ_cjs.PluginService(db);
20794
+ const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
20791
20795
  await pluginService.updatePluginSettings(pluginId, settings);
20792
20796
  if (pluginId === "core-auth") {
20793
20797
  try {
@@ -21595,7 +21599,7 @@ function renderLogConfigPage(data) {
21595
21599
 
21596
21600
  // src/routes/admin-logs.ts
21597
21601
  var adminLogsRoutes = new hono.Hono();
21598
- adminLogsRoutes.use("*", chunkYJEBDJDV_cjs.requireAuth());
21602
+ adminLogsRoutes.use("*", chunkVMBQ6NQB_cjs.requireAuth());
21599
21603
  adminLogsRoutes.get("/", async (c) => {
21600
21604
  try {
21601
21605
  const user = c.get("user");
@@ -22587,9 +22591,9 @@ function renderStorageUsage(databaseSizeBytes, mediaSizeBytes) {
22587
22591
  }
22588
22592
 
22589
22593
  // src/routes/admin-dashboard.ts
22590
- var VERSION = chunkKV3CM5RK_cjs.getCoreVersion();
22594
+ var VERSION = chunk6CKXZFED_cjs.getCoreVersion();
22591
22595
  var router = new hono.Hono();
22592
- router.use("*", chunkYJEBDJDV_cjs.requireAuth());
22596
+ router.use("*", chunkVMBQ6NQB_cjs.requireAuth());
22593
22597
  router.get("/", async (c) => {
22594
22598
  const user = c.get("user");
22595
22599
  try {
@@ -24554,7 +24558,7 @@ function renderCollectionFormPage(data) {
24554
24558
  // src/routes/admin-collections.ts
24555
24559
  chunkK623Q6WD_cjs.init_admin_layout_catalyst_template();
24556
24560
  var adminCollectionsRoutes = new hono.Hono();
24557
- adminCollectionsRoutes.use("*", chunkYJEBDJDV_cjs.requireAuth());
24561
+ adminCollectionsRoutes.use("*", chunkVMBQ6NQB_cjs.requireAuth());
24558
24562
  adminCollectionsRoutes.get("/", async (c) => {
24559
24563
  try {
24560
24564
  const user = c.get("user");
@@ -24571,7 +24575,7 @@ adminCollectionsRoutes.get("/", async (c) => {
24571
24575
  results = queryResults.results ?? [];
24572
24576
  } catch (e) {
24573
24577
  }
24574
- const codeCollections = chunkQJNKSFDJ_cjs.getCollectionRegistry().list();
24578
+ const codeCollections = chunkKPQ57HAH_cjs.getCollectionRegistry().list();
24575
24579
  const codeCollectionsMap = new Map(
24576
24580
  codeCollections.map((cfg) => {
24577
24581
  const fieldCount = cfg.schema?.properties ? Object.keys(cfg.schema.properties).length : 0;
@@ -24585,7 +24589,7 @@ adminCollectionsRoutes.get("/", async (c) => {
24585
24589
  field_count: fieldCount,
24586
24590
  managed: cfg.managed !== false,
24587
24591
  source_type: "code",
24588
- internal: chunkQJNKSFDJ_cjs.isCodeCollectionInternal(cfg),
24592
+ internal: chunkKPQ57HAH_cjs.isCodeCollectionInternal(cfg),
24589
24593
  versioning: cfg.versioning === true
24590
24594
  }];
24591
24595
  })
@@ -24624,7 +24628,7 @@ adminCollectionsRoutes.get("/", async (c) => {
24624
24628
  field_count: fieldCount,
24625
24629
  managed: false,
24626
24630
  source_type: row.source === "code" || row.source === "system" || row.source === "plugin" ? "code" : "user",
24627
- internal: chunkQJNKSFDJ_cjs.isDbDocTypeInternal(row.source),
24631
+ internal: chunkKPQ57HAH_cjs.isDbDocTypeInternal(row.source),
24628
24632
  versioning: dbVersioning
24629
24633
  };
24630
24634
  });
@@ -24785,7 +24789,7 @@ export const myPlugin = definePlugin({
24785
24789
  title: "Add a Collection",
24786
24790
  pageTitle: "Add a Collection",
24787
24791
  currentPath: "/admin/collections",
24788
- version: chunkKV3CM5RK_cjs.getCoreVersion(),
24792
+ version: chunk6CKXZFED_cjs.getCoreVersion(),
24789
24793
  user: u ? { name: u.email ?? "Admin", email: u.email ?? "", role: u.role ?? "admin" } : void 0,
24790
24794
  content
24791
24795
  })
@@ -24802,7 +24806,7 @@ adminCollectionsRoutes.get("/:id", async (c) => {
24802
24806
  collection = await stmt.bind(id).first();
24803
24807
  } catch {
24804
24808
  }
24805
- const registryRecord = chunkQJNKSFDJ_cjs.getCollectionRegistry().getById(id) ?? chunkQJNKSFDJ_cjs.getCollectionRegistry().getByName(id);
24809
+ const registryRecord = chunkKPQ57HAH_cjs.getCollectionRegistry().getById(id) ?? chunkKPQ57HAH_cjs.getCollectionRegistry().getByName(id);
24806
24810
  if (!collection && !registryRecord) {
24807
24811
  const formData2 = {
24808
24812
  isEdit: true,
@@ -24849,9 +24853,9 @@ adminCollectionsRoutes.get("/:id", async (c) => {
24849
24853
  isCodeDriven = true;
24850
24854
  }
24851
24855
  const [tinymceActive, quillActive, mdxeditorActive] = await Promise.all([
24852
- chunkYJEBDJDV_cjs.isPluginActive(db, "tinymce-plugin"),
24853
- chunkYJEBDJDV_cjs.isPluginActive(db, "quill-editor"),
24854
- chunkYJEBDJDV_cjs.isPluginActive(db, "easy-mdx")
24856
+ chunkVMBQ6NQB_cjs.isPluginActive(db, "tinymce-plugin"),
24857
+ chunkVMBQ6NQB_cjs.isPluginActive(db, "quill-editor"),
24858
+ chunkVMBQ6NQB_cjs.isPluginActive(db, "easy-mdx")
24855
24859
  ]);
24856
24860
  const displayName = collection?.display_name ?? registryRecord?.displayName ?? id;
24857
24861
  const formData = {
@@ -24871,9 +24875,9 @@ adminCollectionsRoutes.get("/:id", async (c) => {
24871
24875
  console.error("Error fetching collection:", error);
24872
24876
  const user = c.get("user");
24873
24877
  const [tinymceActive, quillActive, mdxeditorActive] = await Promise.all([
24874
- chunkYJEBDJDV_cjs.isPluginActive(db, "tinymce-plugin"),
24875
- chunkYJEBDJDV_cjs.isPluginActive(db, "quill-editor"),
24876
- chunkYJEBDJDV_cjs.isPluginActive(db, "easy-mdx")
24878
+ chunkVMBQ6NQB_cjs.isPluginActive(db, "tinymce-plugin"),
24879
+ chunkVMBQ6NQB_cjs.isPluginActive(db, "quill-editor"),
24880
+ chunkVMBQ6NQB_cjs.isPluginActive(db, "easy-mdx")
24877
24881
  ]);
24878
24882
  const formData = {
24879
24883
  isEdit: true,
@@ -25822,7 +25826,7 @@ function renderDatabaseToolsSettings(settings) {
25822
25826
 
25823
25827
  // src/routes/admin-settings.ts
25824
25828
  var adminSettingsRoutes = new hono.Hono();
25825
- adminSettingsRoutes.use("*", chunkYJEBDJDV_cjs.requireAuth());
25829
+ adminSettingsRoutes.use("*", chunkVMBQ6NQB_cjs.requireAuth());
25826
25830
  function getMockSettings(user) {
25827
25831
  return {
25828
25832
  general: {
@@ -25925,7 +25929,7 @@ adminSettingsRoutes.get("/database-tools", (c) => {
25925
25929
  adminSettingsRoutes.get("/api/migrations/status", async (c) => {
25926
25930
  try {
25927
25931
  const db = c.env.DB;
25928
- const migrationService = new chunkORF4CT74_cjs.MigrationService(db);
25932
+ const migrationService = new chunkYNYEQP3K_cjs.MigrationService(db);
25929
25933
  const status = await migrationService.getMigrationStatus();
25930
25934
  return c.json({
25931
25935
  success: true,
@@ -25965,7 +25969,7 @@ adminSettingsRoutes.post("/api/migrations/run", async (c) => {
25965
25969
  adminSettingsRoutes.get("/api/migrations/validate", async (c) => {
25966
25970
  try {
25967
25971
  const db = c.env.DB;
25968
- const migrationService = new chunkORF4CT74_cjs.MigrationService(db);
25972
+ const migrationService = new chunkYNYEQP3K_cjs.MigrationService(db);
25969
25973
  const validation = await migrationService.validateSchema();
25970
25974
  return c.json({
25971
25975
  success: true,
@@ -26558,16 +26562,16 @@ function renderAPIReferencePage(data) {
26558
26562
  }
26559
26563
 
26560
26564
  // src/routes/admin-api-reference.ts
26561
- var VERSION2 = chunkKV3CM5RK_cjs.getCoreVersion();
26565
+ var VERSION2 = chunk6CKXZFED_cjs.getCoreVersion();
26562
26566
  var router2 = new hono.Hono();
26563
- router2.use("*", chunkYJEBDJDV_cjs.requireAuth());
26567
+ router2.use("*", chunkVMBQ6NQB_cjs.requireAuth());
26564
26568
  router2.get("/", async (c) => {
26565
26569
  const user = c.get("user");
26566
26570
  try {
26567
26571
  const app2 = chunk4BTBSXMR_cjs.getAppInstance();
26568
26572
  const baseEndpoints = chunk4BTBSXMR_cjs.buildRouteList(app2);
26569
26573
  const collectionRoutes = [];
26570
- const collections = chunkQJNKSFDJ_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal);
26574
+ const collections = chunkKPQ57HAH_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal);
26571
26575
  const methodOrder = { GET: 0, POST: 1, PUT: 2, PATCH: 3, DELETE: 4 };
26572
26576
  for (const col of collections) {
26573
26577
  const displayName = col.displayName || col.name;
@@ -26683,5 +26687,5 @@ exports.setVariablesCache = setVariablesCache;
26683
26687
  exports.test_cleanup_default = test_cleanup_default;
26684
26688
  exports.userProfilesPlugin = userProfilesPlugin;
26685
26689
  exports.userRoutes = userRoutes;
26686
- //# sourceMappingURL=chunk-K342JMA3.cjs.map
26687
- //# sourceMappingURL=chunk-K342JMA3.cjs.map
26690
+ //# sourceMappingURL=chunk-VT77YUTP.cjs.map
26691
+ //# sourceMappingURL=chunk-VT77YUTP.cjs.map