@sonicjs-cms/core 3.0.0-beta.16 → 3.0.0-beta.18

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 (98) hide show
  1. package/dist/{chunk-RQ6N3FTV.js → chunk-2XAQTPAE.js} +3 -2
  2. package/dist/chunk-2XAQTPAE.js.map +1 -0
  3. package/dist/{chunk-4BTBSXMR.cjs → chunk-36Z3AKX3.cjs} +3 -2
  4. package/dist/chunk-36Z3AKX3.cjs.map +1 -0
  5. package/dist/{chunk-PDC7DLOV.js → chunk-3TMTYJAJ.js} +7 -3
  6. package/dist/chunk-3TMTYJAJ.js.map +1 -0
  7. package/dist/{chunk-7P2IJM4K.js → chunk-6Z7MZDDF.js} +3 -3
  8. package/dist/{chunk-7P2IJM4K.js.map → chunk-6Z7MZDDF.js.map} +1 -1
  9. package/dist/{chunk-JRMBHDGM.js → chunk-BCE6XJYG.js} +3 -3
  10. package/dist/{chunk-JRMBHDGM.js.map → chunk-BCE6XJYG.js.map} +1 -1
  11. package/dist/{chunk-LXYDJU6U.cjs → chunk-BUMHSDRW.cjs} +139 -73
  12. package/dist/chunk-BUMHSDRW.cjs.map +1 -0
  13. package/dist/{chunk-3XFA3E2F.cjs → chunk-E6LGR24C.cjs} +3 -3
  14. package/dist/{chunk-3XFA3E2F.cjs.map → chunk-E6LGR24C.cjs.map} +1 -1
  15. package/dist/{chunk-IA24HACT.cjs → chunk-ETRNDMB2.cjs} +3 -2
  16. package/dist/chunk-ETRNDMB2.cjs.map +1 -0
  17. package/dist/{chunk-KZIBF2EV.cjs → chunk-FAADMKJX.cjs} +4 -2
  18. package/dist/chunk-FAADMKJX.cjs.map +1 -0
  19. package/dist/{chunk-KMCLNO4K.cjs → chunk-GMMCCIQO.cjs} +3 -3
  20. package/dist/{chunk-KMCLNO4K.cjs.map → chunk-GMMCCIQO.cjs.map} +1 -1
  21. package/dist/{chunk-UOFRE5PY.js → chunk-GY2XWOG3.js} +27 -21
  22. package/dist/chunk-GY2XWOG3.js.map +1 -0
  23. package/dist/{chunk-IXUNNFZZ.js → chunk-KCS65CVN.js} +133 -67
  24. package/dist/chunk-KCS65CVN.js.map +1 -0
  25. package/dist/{chunk-JEQ7FLOD.cjs → chunk-KIGVVO6N.cjs} +16 -10
  26. package/dist/chunk-KIGVVO6N.cjs.map +1 -0
  27. package/dist/{chunk-W36OZTJ5.cjs → chunk-LTZ5WYOK.cjs} +10 -6
  28. package/dist/chunk-LTZ5WYOK.cjs.map +1 -0
  29. package/dist/{chunk-KMM45BTY.cjs → chunk-NOT5YX23.cjs} +19 -18
  30. package/dist/chunk-NOT5YX23.cjs.map +1 -0
  31. package/dist/{chunk-HYO2MSFI.js → chunk-PXWT5OWC.js} +3 -2
  32. package/dist/chunk-PXWT5OWC.js.map +1 -0
  33. package/dist/{chunk-KOXFYFOF.cjs → chunk-QSDN2CKI.cjs} +4 -4
  34. package/dist/{chunk-KOXFYFOF.cjs.map → chunk-QSDN2CKI.cjs.map} +1 -1
  35. package/dist/{chunk-IQZA2OY5.js → chunk-SOZUG52O.js} +3 -3
  36. package/dist/{chunk-IQZA2OY5.js.map → chunk-SOZUG52O.js.map} +1 -1
  37. package/dist/{chunk-KIB7K5LV.js → chunk-TAB4XUUP.js} +4 -2
  38. package/dist/chunk-TAB4XUUP.js.map +1 -0
  39. package/dist/{chunk-GCDZZNIN.js → chunk-UWUP2VMT.js} +16 -10
  40. package/dist/chunk-UWUP2VMT.js.map +1 -0
  41. package/dist/{chunk-SC2WZFNQ.cjs → chunk-V6EZYAWF.cjs} +283 -277
  42. package/dist/chunk-V6EZYAWF.cjs.map +1 -0
  43. package/dist/{chunk-PA2UIFB7.js → chunk-ZQLBHD3J.js} +8 -7
  44. package/dist/chunk-ZQLBHD3J.js.map +1 -0
  45. package/dist/config-6FB2BXMP.js +6 -0
  46. package/dist/{config-SM2UWSDN.js.map → config-6FB2BXMP.js.map} +1 -1
  47. package/dist/{config-YCRSU7ZP.cjs → config-OCH7S4WK.cjs} +5 -5
  48. package/dist/{config-YCRSU7ZP.cjs.map → config-OCH7S4WK.cjs.map} +1 -1
  49. package/dist/document-projection-4HG75S5S.js +4 -0
  50. package/dist/{document-projection-YYMC6I4U.js.map → document-projection-4HG75S5S.js.map} +1 -1
  51. package/dist/document-projection-JQHSTSFD.cjs +13 -0
  52. package/dist/{document-projection-TDWRJX3Z.cjs.map → document-projection-JQHSTSFD.cjs.map} +1 -1
  53. package/dist/index.cjs +327 -291
  54. package/dist/index.cjs.map +1 -1
  55. package/dist/index.js +56 -20
  56. package/dist/index.js.map +1 -1
  57. package/dist/middleware.cjs +35 -35
  58. package/dist/middleware.js +6 -6
  59. package/dist/migrations-GN6H36JS.cjs +13 -0
  60. package/dist/{migrations-KMCULV6H.cjs.map → migrations-GN6H36JS.cjs.map} +1 -1
  61. package/dist/migrations-KFRAQ4CE.js +4 -0
  62. package/dist/{migrations-F4LBAHQN.js.map → migrations-KFRAQ4CE.js.map} +1 -1
  63. package/dist/plugins.cjs +40 -40
  64. package/dist/plugins.js +3 -3
  65. package/dist/rbac-7QZ4JZ2E.cjs +14 -0
  66. package/dist/{rbac-ESTOCVT2.cjs.map → rbac-7QZ4JZ2E.cjs.map} +1 -1
  67. package/dist/rbac-Y43IEQOP.js +5 -0
  68. package/dist/{rbac-4QLDXIDF.js.map → rbac-Y43IEQOP.js.map} +1 -1
  69. package/dist/routes.cjs +29 -29
  70. package/dist/routes.js +9 -9
  71. package/dist/services.cjs +30 -30
  72. package/dist/services.js +3 -3
  73. package/dist/utils.cjs +3 -3
  74. package/dist/utils.js +1 -1
  75. package/package.json +1 -1
  76. package/dist/chunk-4BTBSXMR.cjs.map +0 -1
  77. package/dist/chunk-GCDZZNIN.js.map +0 -1
  78. package/dist/chunk-HYO2MSFI.js.map +0 -1
  79. package/dist/chunk-IA24HACT.cjs.map +0 -1
  80. package/dist/chunk-IXUNNFZZ.js.map +0 -1
  81. package/dist/chunk-JEQ7FLOD.cjs.map +0 -1
  82. package/dist/chunk-KIB7K5LV.js.map +0 -1
  83. package/dist/chunk-KMM45BTY.cjs.map +0 -1
  84. package/dist/chunk-KZIBF2EV.cjs.map +0 -1
  85. package/dist/chunk-LXYDJU6U.cjs.map +0 -1
  86. package/dist/chunk-PA2UIFB7.js.map +0 -1
  87. package/dist/chunk-PDC7DLOV.js.map +0 -1
  88. package/dist/chunk-RQ6N3FTV.js.map +0 -1
  89. package/dist/chunk-SC2WZFNQ.cjs.map +0 -1
  90. package/dist/chunk-UOFRE5PY.js.map +0 -1
  91. package/dist/chunk-W36OZTJ5.cjs.map +0 -1
  92. package/dist/config-SM2UWSDN.js +0 -6
  93. package/dist/document-projection-TDWRJX3Z.cjs +0 -13
  94. package/dist/document-projection-YYMC6I4U.js +0 -4
  95. package/dist/migrations-F4LBAHQN.js +0 -4
  96. package/dist/migrations-KMCULV6H.cjs +0 -13
  97. package/dist/rbac-4QLDXIDF.js +0 -5
  98. package/dist/rbac-ESTOCVT2.cjs +0 -14
@@ -2,19 +2,19 @@
2
2
 
3
3
  var chunkXWVDSM2L_cjs = require('./chunk-XWVDSM2L.cjs');
4
4
  var chunkN32OWET6_cjs = require('./chunk-N32OWET6.cjs');
5
- var chunk4BTBSXMR_cjs = require('./chunk-4BTBSXMR.cjs');
6
- var chunkKMM45BTY_cjs = require('./chunk-KMM45BTY.cjs');
7
- var chunkW36OZTJ5_cjs = require('./chunk-W36OZTJ5.cjs');
8
- var chunkJEQ7FLOD_cjs = require('./chunk-JEQ7FLOD.cjs');
9
- var chunkKZIBF2EV_cjs = require('./chunk-KZIBF2EV.cjs');
10
- var chunkIA24HACT_cjs = require('./chunk-IA24HACT.cjs');
5
+ var chunk36Z3AKX3_cjs = require('./chunk-36Z3AKX3.cjs');
6
+ var chunkNOT5YX23_cjs = require('./chunk-NOT5YX23.cjs');
7
+ var chunkLTZ5WYOK_cjs = require('./chunk-LTZ5WYOK.cjs');
8
+ var chunkKIGVVO6N_cjs = require('./chunk-KIGVVO6N.cjs');
9
+ var chunkFAADMKJX_cjs = require('./chunk-FAADMKJX.cjs');
10
+ var chunkETRNDMB2_cjs = require('./chunk-ETRNDMB2.cjs');
11
11
  var chunkPXNTCCPE_cjs = require('./chunk-PXNTCCPE.cjs');
12
12
  var chunkK623Q6WD_cjs = require('./chunk-K623Q6WD.cjs');
13
- var chunkKOXFYFOF_cjs = require('./chunk-KOXFYFOF.cjs');
13
+ var chunkQSDN2CKI_cjs = require('./chunk-QSDN2CKI.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 chunk3XFA3E2F_cjs = require('./chunk-3XFA3E2F.cjs');
17
+ var chunkE6LGR24C_cjs = require('./chunk-E6LGR24C.cjs');
18
18
  var chunkMNWKYY5E_cjs = require('./chunk-MNWKYY5E.cjs');
19
19
  var hono = require('hono');
20
20
  var zod = require('zod');
@@ -26,6 +26,7 @@ var DocumentPermissionsService = class {
26
26
  constructor(db) {
27
27
  this.db = db;
28
28
  }
29
+ db;
29
30
  // Deny wins. Overrides beat base grants. Empty ACL falls back to base grants.
30
31
  async isAllowed(principalSet, rootId, permission, typeSettings, tenantId) {
31
32
  const overrides = await this.getDocumentPermissions(rootId, principalSet, permission, tenantId);
@@ -73,7 +74,7 @@ var DocumentPermissionsService = class {
73
74
  async grantPermission(opts) {
74
75
  const { tenantId, rootId, principalType, principalId, permission, effect = "allow", createdBy } = opts;
75
76
  const now = Math.floor(Date.now() / 1e3);
76
- const id = chunkJEQ7FLOD_cjs.nanoid();
77
+ const id = chunkKIGVVO6N_cjs.nanoid();
77
78
  await this.db.prepare(
78
79
  `INSERT INTO document_permissions (id, tenant_id, root_id, principal_type, principal_id, permission, effect, inherited, created_at, created_by)
79
80
  VALUES (?, ?, ?, ?, ?, ?, ?, 0, ?, ?)
@@ -134,6 +135,8 @@ var DocumentRepository = class {
134
135
  this.tenantId = tenantId;
135
136
  this.permissions = new DocumentPermissionsService(db);
136
137
  }
138
+ db;
139
+ tenantId;
137
140
  permissions;
138
141
  // ─── Reads ───────────────────────────────────────────────────────────────
139
142
  async getById(id) {
@@ -256,7 +259,7 @@ function getDocumentRequestContext(c) {
256
259
 
257
260
  // src/routes/api-documents.ts
258
261
  async function aclAllowsRead(db, tenantId, principalSet, row, preloadedType) {
259
- const docType = preloadedType ?? await new chunkKMM45BTY_cjs.DocumentTypeRegistry(db).findById(row.type_id);
262
+ const docType = preloadedType ?? await new chunkNOT5YX23_cjs.DocumentTypeRegistry(db).findById(row.type_id);
260
263
  if (!docType) return false;
261
264
  return new DocumentRepository(db, tenantId).isAllowed(principalSet, row.root_id, "read", docType.settings);
262
265
  }
@@ -274,7 +277,7 @@ apiDocumentsRoutes.get("/", async (c) => {
274
277
  if (!typeId) {
275
278
  return c.json({ error: "type query parameter is required" }, 400);
276
279
  }
277
- const registry = new chunkKMM45BTY_cjs.DocumentTypeRegistry(db);
280
+ const registry = new chunkNOT5YX23_cjs.DocumentTypeRegistry(db);
278
281
  const docType = await registry.findById(typeId);
279
282
  if (!docType || !docType.isActive) {
280
283
  return c.json({ error: "Unknown document type" }, 400);
@@ -356,7 +359,7 @@ apiDocumentsRoutes.get("/root/:rootId", async (c) => {
356
359
  AND (expires_at IS NULL OR expires_at > ?) LIMIT 1`
357
360
  ).bind(rootId, now, now).first();
358
361
  if (!row) return c.json({ error: "Not found" }, 404);
359
- const docType = await new chunkKMM45BTY_cjs.DocumentTypeRegistry(db).findById(row.type_id);
362
+ const docType = await new chunkNOT5YX23_cjs.DocumentTypeRegistry(db).findById(row.type_id);
360
363
  const effTenant = effectiveTenantForType(tenantId, docType?.settings);
361
364
  if (row.tenant_id !== effTenant) return c.json({ error: "Not found" }, 404);
362
365
  if (!await aclAllowsRead(db, effTenant, principalSet, row, docType)) {
@@ -392,7 +395,7 @@ apiDocumentsRoutes.get("/:id", async (c) => {
392
395
  AND (expires_at IS NULL OR expires_at > ?) LIMIT 1`
393
396
  ).bind(id, now, now).first();
394
397
  if (!row) return c.json({ error: "Not found" }, 404);
395
- const docType = await new chunkKMM45BTY_cjs.DocumentTypeRegistry(db).findById(row.type_id);
398
+ const docType = await new chunkNOT5YX23_cjs.DocumentTypeRegistry(db).findById(row.type_id);
396
399
  const effTenant = effectiveTenantForType(tenantId, docType?.settings);
397
400
  if (row.tenant_id !== effTenant) return c.json({ error: "Not found" }, 404);
398
401
  if (!await aclAllowsRead(db, effTenant, principalSet, row, docType)) {
@@ -462,17 +465,17 @@ async function resolveDocScope(c, db, by, opts = {}) {
462
465
  const draft = opts.currentDraftOnly ? " AND is_current_draft = 1" : "";
463
466
  const row = await db.prepare(`SELECT type_id, root_id, tenant_id FROM documents WHERE ${col} = ?${draft} LIMIT 1`).bind(val).first();
464
467
  if (!row) return null;
465
- const docType = await new chunkKMM45BTY_cjs.DocumentTypeRegistry(db).findById(row.type_id);
468
+ const docType = await new chunkNOT5YX23_cjs.DocumentTypeRegistry(db).findById(row.type_id);
466
469
  const tenantId = effectiveTenantForType(getRequestTenant(c), docType?.settings);
467
470
  if (row.tenant_id !== tenantId) return null;
468
471
  return { typeId: row.type_id, rootId: row.root_id, tenantId, docType };
469
472
  }
470
473
  var adminDocumentsRoutes = new hono.Hono();
471
- adminDocumentsRoutes.use("*", chunkKMM45BTY_cjs.requireAuth());
472
- adminDocumentsRoutes.use("*", chunkKMM45BTY_cjs.requireRole(["admin", "editor"]));
474
+ adminDocumentsRoutes.use("*", chunkNOT5YX23_cjs.requireAuth());
475
+ adminDocumentsRoutes.use("*", chunkNOT5YX23_cjs.requireRole(["admin", "editor"]));
473
476
  adminDocumentsRoutes.get("/types", async (c) => {
474
477
  try {
475
- const registry = new chunkKMM45BTY_cjs.DocumentTypeRegistry(c.env.DB);
478
+ const registry = new chunkNOT5YX23_cjs.DocumentTypeRegistry(c.env.DB);
476
479
  const types = await registry.findAll();
477
480
  return c.json({ data: types });
478
481
  } catch (error) {
@@ -500,7 +503,7 @@ adminDocumentsRoutes.get("/", async (c) => {
500
503
  if (!typeId) {
501
504
  return c.json({ error: "type query parameter is required" }, 400);
502
505
  }
503
- const registry = new chunkKMM45BTY_cjs.DocumentTypeRegistry(db);
506
+ const registry = new chunkNOT5YX23_cjs.DocumentTypeRegistry(db);
504
507
  const docType = await registry.findById(typeId);
505
508
  if (!docType || !docType.isActive) {
506
509
  return c.json({ error: "Unknown document type" }, 400);
@@ -611,7 +614,7 @@ adminDocumentsRoutes.post("/", async (c) => {
611
614
  const input = validation.data;
612
615
  const db = c.env.DB;
613
616
  const user = c.get("user");
614
- const registry = new chunkKMM45BTY_cjs.DocumentTypeRegistry(db);
617
+ const registry = new chunkNOT5YX23_cjs.DocumentTypeRegistry(db);
615
618
  const docType = await registry.findById(input.typeId);
616
619
  if (!docType || !docType.isActive) {
617
620
  return c.json({ error: "Unknown document type" }, 400);
@@ -619,7 +622,7 @@ adminDocumentsRoutes.post("/", async (c) => {
619
622
  const createDenied = await denyIfNotAllowed(c, db, "", "create", docType.settings);
620
623
  if (createDenied) return createDenied;
621
624
  const tenantId = effectiveTenantForType(getRequestTenant(c), docType.settings);
622
- const svc = new chunkW36OZTJ5_cjs.DocumentsService(db, {
625
+ const svc = new chunkLTZ5WYOK_cjs.DocumentsService(db, {
623
626
  queryableFields: docType.queryableFields,
624
627
  typeSchemaVersion: docType.schemaVersion,
625
628
  maxVersionsPerRoot: docType.settings.maxVersionsPerRoot,
@@ -657,7 +660,7 @@ adminDocumentsRoutes.put("/:rootId", async (c) => {
657
660
  const docType = scope.docType;
658
661
  const updateDenied = await denyIfNotAllowed(c, db, rootId, "update", docType?.settings, scope.tenantId);
659
662
  if (updateDenied) return updateDenied;
660
- const svc = new chunkW36OZTJ5_cjs.DocumentsService(db, {
663
+ const svc = new chunkLTZ5WYOK_cjs.DocumentsService(db, {
661
664
  queryableFields: docType?.queryableFields ?? [],
662
665
  typeSchemaVersion: docType?.schemaVersion,
663
666
  maxVersionsPerRoot: docType?.settings.maxVersionsPerRoot,
@@ -682,7 +685,7 @@ adminDocumentsRoutes.post("/:id/publish", async (c) => {
682
685
  const docType = scope.docType;
683
686
  const publishDenied = await denyIfNotAllowed(c, db, scope.rootId, "publish", docType?.settings, scope.tenantId);
684
687
  if (publishDenied) return publishDenied;
685
- const svc = new chunkW36OZTJ5_cjs.DocumentsService(db, {
688
+ const svc = new chunkLTZ5WYOK_cjs.DocumentsService(db, {
686
689
  queryableFields: docType?.queryableFields ?? [],
687
690
  typeSchemaVersion: docType?.schemaVersion,
688
691
  tenantId: scope.tenantId,
@@ -705,7 +708,7 @@ adminDocumentsRoutes.post("/:id/unpublish", async (c) => {
705
708
  const docType = scope.docType;
706
709
  const unpublishDenied = await denyIfNotAllowed(c, db, scope.rootId, "publish", docType?.settings, scope.tenantId);
707
710
  if (unpublishDenied) return unpublishDenied;
708
- const svc = new chunkW36OZTJ5_cjs.DocumentsService(db, {
711
+ const svc = new chunkLTZ5WYOK_cjs.DocumentsService(db, {
709
712
  queryableFields: docType?.queryableFields ?? [],
710
713
  tenantId: scope.tenantId
711
714
  });
@@ -727,7 +730,7 @@ adminDocumentsRoutes.delete("/:id", async (c) => {
727
730
  const docType = scope.docType;
728
731
  const deleteDenied = await denyIfNotAllowed(c, db, scope.rootId, "delete", docType?.settings, scope.tenantId);
729
732
  if (deleteDenied) return deleteDenied;
730
- const svc = new chunkW36OZTJ5_cjs.DocumentsService(db, { queryableFields: docType?.queryableFields ?? [], tenantId: scope.tenantId });
733
+ const svc = new chunkLTZ5WYOK_cjs.DocumentsService(db, { queryableFields: docType?.queryableFields ?? [], tenantId: scope.tenantId });
731
734
  if (docType?.settings.pii) {
732
735
  if (scope.rootId) await svc.erase(scope.rootId, scope.tenantId);
733
736
  } else {
@@ -743,13 +746,13 @@ adminDocumentsRoutes.post("/types/:typeId/reindex", async (c) => {
743
746
  try {
744
747
  const { typeId } = c.req.param();
745
748
  const db = c.env.DB;
746
- const registry = new chunkKMM45BTY_cjs.DocumentTypeRegistry(db);
749
+ const registry = new chunkNOT5YX23_cjs.DocumentTypeRegistry(db);
747
750
  const docType = await registry.findById(typeId);
748
751
  if (!docType) return c.json({ error: "Unknown document type" }, 400);
749
752
  const reindexTenant = effectiveTenantForType(getRequestTenant(c), docType.settings);
750
753
  const reindexDenied = await denyIfNotAllowed(c, db, "", "manage", docType.settings, reindexTenant);
751
754
  if (reindexDenied) return reindexDenied;
752
- const { DocumentProjection } = await import('./document-projection-TDWRJX3Z.cjs');
755
+ const { DocumentProjection } = await import('./document-projection-JQHSTSFD.cjs');
753
756
  const projection = new DocumentProjection(db);
754
757
  const rebuilt = await projection.reindexType(typeId, reindexTenant, docType.queryableFields);
755
758
  return c.json({ rebuilt });
@@ -897,13 +900,13 @@ async function resolveContentVariables(contentData, db) {
897
900
  // src/routes/api-content-crud.ts
898
901
  var apiContentCrudRoutes = new hono.Hono();
899
902
  async function resolveDocBacking(db, collectionIdOrName) {
900
- const registry = chunkKZIBF2EV_cjs.getCollectionRegistry();
903
+ const registry = chunkFAADMKJX_cjs.getCollectionRegistry();
901
904
  const record = registry.getBySlugOrName(collectionIdOrName) ?? registry.getById(collectionIdOrName);
902
905
  if (record) {
903
- const docType2 = await new chunkKMM45BTY_cjs.DocumentTypeRegistry(db).findById(record.name);
906
+ const docType2 = await new chunkNOT5YX23_cjs.DocumentTypeRegistry(db).findById(record.name);
904
907
  return docType2 ? { coll: { id: record.id, name: record.name }, docType: docType2 } : null;
905
908
  }
906
- const docType = await new chunkKMM45BTY_cjs.DocumentTypeRegistry(db).findById(collectionIdOrName);
909
+ const docType = await new chunkNOT5YX23_cjs.DocumentTypeRegistry(db).findById(collectionIdOrName);
907
910
  if (docType) {
908
911
  return { coll: { id: collectionIdOrName, name: collectionIdOrName }, docType };
909
912
  }
@@ -946,7 +949,7 @@ apiContentCrudRoutes.get("/check-slug", async (c) => {
946
949
  }, 500);
947
950
  }
948
951
  });
949
- apiContentCrudRoutes.get("/:id", chunkKMM45BTY_cjs.optionalAuth(), async (c) => {
952
+ apiContentCrudRoutes.get("/:id", chunkNOT5YX23_cjs.optionalAuth(), async (c) => {
950
953
  try {
951
954
  const id = c.req.param("id");
952
955
  const db = c.env.DB;
@@ -956,7 +959,7 @@ apiContentCrudRoutes.get("/:id", chunkKMM45BTY_cjs.optionalAuth(), async (c) =>
956
959
  ).bind(id, getRequestTenant(c)).first();
957
960
  let transformedContent;
958
961
  if (docRow) {
959
- const coll = chunkKZIBF2EV_cjs.getCollectionRegistry().getByName(docRow.type_id);
962
+ const coll = chunkFAADMKJX_cjs.getCollectionRegistry().getByName(docRow.type_id);
960
963
  transformedContent = {
961
964
  id: docRow.root_id,
962
965
  title: docRow.title,
@@ -965,8 +968,8 @@ apiContentCrudRoutes.get("/:id", chunkKMM45BTY_cjs.optionalAuth(), async (c) =>
965
968
  collectionId: coll?.id ?? docRow.type_id,
966
969
  data: docRow.data ? JSON.parse(docRow.data) : {},
967
970
  // D29: document timestamps are SECONDS; legacy `content` API contract is MILLISECONDS.
968
- created_at: chunkW36OZTJ5_cjs.documentSecondsToMs(docRow.created_at),
969
- updated_at: chunkW36OZTJ5_cjs.documentSecondsToMs(docRow.updated_at)
971
+ created_at: chunkLTZ5WYOK_cjs.documentSecondsToMs(docRow.created_at),
972
+ updated_at: chunkLTZ5WYOK_cjs.documentSecondsToMs(docRow.updated_at)
970
973
  };
971
974
  } else {
972
975
  return c.json({ error: "Content not found" }, 404);
@@ -990,7 +993,7 @@ apiContentCrudRoutes.get("/:id", chunkKMM45BTY_cjs.optionalAuth(), async (c) =>
990
993
  }, 500);
991
994
  }
992
995
  });
993
- apiContentCrudRoutes.post("/", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45BTY_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
996
+ apiContentCrudRoutes.post("/", chunkNOT5YX23_cjs.requireAuth(), chunkNOT5YX23_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
994
997
  try {
995
998
  const db = c.env.DB;
996
999
  const user = c.get("user");
@@ -1024,7 +1027,7 @@ apiContentCrudRoutes.post("/", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45BTY_cj
1024
1027
  return c.json({ error: "Write cancelled by plugin", details: String(err) }, 400);
1025
1028
  }
1026
1029
  const tenantId = getRequestTenant(c);
1027
- const svc = new chunkW36OZTJ5_cjs.DocumentsService(db, {
1030
+ const svc = new chunkLTZ5WYOK_cjs.DocumentsService(db, {
1028
1031
  queryableFields: backing.docType.queryableFields ?? [],
1029
1032
  typeSchemaVersion: backing.docType.schemaVersion ?? 1,
1030
1033
  maxVersionsPerRoot: backing.docType.settings?.maxVersionsPerRoot ?? 50,
@@ -1043,7 +1046,7 @@ apiContentCrudRoutes.post("/", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45BTY_cj
1043
1046
  }),
1044
1047
  user?.userId
1045
1048
  );
1046
- const cache = chunk4BTBSXMR_cjs.getCacheService(chunk4BTBSXMR_cjs.CACHE_CONFIGS.api);
1049
+ const cache = chunk36Z3AKX3_cjs.getCacheService(chunk36Z3AKX3_cjs.CACHE_CONFIGS.api);
1047
1050
  await cache.invalidate("content-filtered:*");
1048
1051
  await cache.invalidate("collection-content-filtered:*");
1049
1052
  dispatchHookEvent(
@@ -1053,7 +1056,7 @@ apiContentCrudRoutes.post("/", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45BTY_cj
1053
1056
  "fire-and-forget"
1054
1057
  );
1055
1058
  return c.json({
1056
- data: { id: doc.rootId, title: doc.title, slug: doc.slug, status: doc.status, collectionId: backing.coll.id, data: doc.data, created_at: chunkW36OZTJ5_cjs.documentSecondsToMs(doc.createdAt), updated_at: chunkW36OZTJ5_cjs.documentSecondsToMs(doc.updatedAt) }
1059
+ data: { id: doc.rootId, title: doc.title, slug: doc.slug, status: doc.status, collectionId: backing.coll.id, data: doc.data, created_at: chunkLTZ5WYOK_cjs.documentSecondsToMs(doc.createdAt), updated_at: chunkLTZ5WYOK_cjs.documentSecondsToMs(doc.updatedAt) }
1057
1060
  }, 201);
1058
1061
  }
1059
1062
  return c.json({ error: "Collection is not document-backed" }, 400);
@@ -1065,7 +1068,7 @@ apiContentCrudRoutes.post("/", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45BTY_cj
1065
1068
  }, 500);
1066
1069
  }
1067
1070
  });
1068
- apiContentCrudRoutes.put("/:id", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45BTY_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
1071
+ apiContentCrudRoutes.put("/:id", chunkNOT5YX23_cjs.requireAuth(), chunkNOT5YX23_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
1069
1072
  try {
1070
1073
  const id = c.req.param("id");
1071
1074
  const db = c.env.DB;
@@ -1087,8 +1090,8 @@ apiContentCrudRoutes.put("/:id", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45BTY_
1087
1090
  } catch (err) {
1088
1091
  return c.json({ error: "Write cancelled by plugin", details: String(err) }, 400);
1089
1092
  }
1090
- const docType = await new chunkKMM45BTY_cjs.DocumentTypeRegistry(db).findById(docRow.type_id);
1091
- const svc = new chunkW36OZTJ5_cjs.DocumentsService(db, {
1093
+ const docType = await new chunkNOT5YX23_cjs.DocumentTypeRegistry(db).findById(docRow.type_id);
1094
+ const svc = new chunkLTZ5WYOK_cjs.DocumentsService(db, {
1092
1095
  queryableFields: docType?.queryableFields ?? [],
1093
1096
  typeSchemaVersion: docType?.schemaVersion ?? 1,
1094
1097
  maxVersionsPerRoot: docType?.settings?.maxVersionsPerRoot ?? 50,
@@ -1107,10 +1110,10 @@ apiContentCrudRoutes.put("/:id", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45BTY_
1107
1110
  } else if (body.status === "draft" && pub) {
1108
1111
  await svc.unpublish(pub.id);
1109
1112
  }
1110
- const cache = chunk4BTBSXMR_cjs.getCacheService(chunk4BTBSXMR_cjs.CACHE_CONFIGS.api);
1113
+ const cache = chunk36Z3AKX3_cjs.getCacheService(chunk36Z3AKX3_cjs.CACHE_CONFIGS.api);
1111
1114
  await cache.invalidate("content-filtered:*");
1112
1115
  await cache.invalidate("collection-content-filtered:*");
1113
- const coll = chunkKZIBF2EV_cjs.getCollectionRegistry().getByName(docRow.type_id);
1116
+ const coll = chunkFAADMKJX_cjs.getCollectionRegistry().getByName(docRow.type_id);
1114
1117
  const saved = await db.prepare("SELECT * FROM documents WHERE id = ?").bind(newDraft.id).first();
1115
1118
  const savedData = saved?.data ? JSON.parse(saved.data) : {};
1116
1119
  dispatchHookEvent(c, "content:after:update", { collection: docRow.type_id, id, data: savedData, user: actor }, "fire-and-forget");
@@ -1119,7 +1122,7 @@ apiContentCrudRoutes.put("/:id", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45BTY_
1119
1122
  dispatchHookEvent(c, "content:after:publish", { collection: docRow.type_id, id, data: savedData, user: actor }, "fire-and-forget");
1120
1123
  }
1121
1124
  return c.json({
1122
- data: { id: saved.root_id, title: saved.title, slug: saved.slug, status: saved.status, collectionId: coll?.id ?? docRow.type_id, data: savedData, created_at: chunkW36OZTJ5_cjs.documentSecondsToMs(saved.created_at), updated_at: chunkW36OZTJ5_cjs.documentSecondsToMs(saved.updated_at) }
1125
+ data: { id: saved.root_id, title: saved.title, slug: saved.slug, status: saved.status, collectionId: coll?.id ?? docRow.type_id, data: savedData, created_at: chunkLTZ5WYOK_cjs.documentSecondsToMs(saved.created_at), updated_at: chunkLTZ5WYOK_cjs.documentSecondsToMs(saved.updated_at) }
1123
1126
  });
1124
1127
  }
1125
1128
  return c.json({ error: "Content not found" }, 404);
@@ -1131,7 +1134,7 @@ apiContentCrudRoutes.put("/:id", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45BTY_
1131
1134
  }, 500);
1132
1135
  }
1133
1136
  });
1134
- apiContentCrudRoutes.delete("/:id", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45BTY_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
1137
+ apiContentCrudRoutes.delete("/:id", chunkNOT5YX23_cjs.requireAuth(), chunkNOT5YX23_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
1135
1138
  try {
1136
1139
  const id = c.req.param("id");
1137
1140
  const db = c.env.DB;
@@ -1147,7 +1150,7 @@ apiContentCrudRoutes.delete("/:id", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45B
1147
1150
  }
1148
1151
  const now = Math.floor(Date.now() / 1e3);
1149
1152
  await db.prepare("UPDATE documents SET deleted_at = ?, updated_at = ? WHERE root_id = ? AND tenant_id = ?").bind(now, now, id, tenantId).run();
1150
- const cache = chunk4BTBSXMR_cjs.getCacheService(chunk4BTBSXMR_cjs.CACHE_CONFIGS.api);
1153
+ const cache = chunk36Z3AKX3_cjs.getCacheService(chunk36Z3AKX3_cjs.CACHE_CONFIGS.api);
1151
1154
  await cache.invalidate("content-filtered:*");
1152
1155
  await cache.invalidate("collection-content-filtered:*");
1153
1156
  dispatchHookEvent(c, "content:after:delete", { collection: docRow.type_id, id, data: {}, user: actor }, "fire-and-forget");
@@ -1244,8 +1247,8 @@ function mapDocRowToContent(row, collectionId) {
1244
1247
  collectionId,
1245
1248
  data: row.data ? JSON.parse(row.data) : {},
1246
1249
  // D29: document timestamps are SECONDS; the legacy `content` API contract is MILLISECONDS.
1247
- created_at: chunkW36OZTJ5_cjs.documentSecondsToMs(row.created_at),
1248
- updated_at: chunkW36OZTJ5_cjs.documentSecondsToMs(row.updated_at)
1250
+ created_at: chunkLTZ5WYOK_cjs.documentSecondsToMs(row.created_at),
1251
+ updated_at: chunkLTZ5WYOK_cjs.documentSecondsToMs(row.updated_at)
1249
1252
  };
1250
1253
  }
1251
1254
  var apiRoutes = new hono.Hono();
@@ -1257,7 +1260,7 @@ apiRoutes.use("*", async (c, next) => {
1257
1260
  c.header("X-Response-Time", `${totalTime}ms`);
1258
1261
  });
1259
1262
  apiRoutes.use("*", async (c, next) => {
1260
- const cacheEnabled = await chunkKMM45BTY_cjs.isPluginActive(c.env.DB, "core-cache");
1263
+ const cacheEnabled = await chunkNOT5YX23_cjs.isPluginActive(c.env.DB, "core-cache");
1261
1264
  c.set("cacheEnabled", cacheEnabled);
1262
1265
  await next();
1263
1266
  });
@@ -1280,7 +1283,7 @@ apiRoutes.get("/", (c) => {
1280
1283
  openapi: "3.0.0",
1281
1284
  info: {
1282
1285
  title: "SonicJS AI API",
1283
- version: chunk3XFA3E2F_cjs.getCoreVersion(),
1286
+ version: chunkE6LGR24C_cjs.getCoreVersion(),
1284
1287
  description: "RESTful API for SonicJS headless CMS - a modern, AI-powered content management system built on Cloudflare Workers",
1285
1288
  contact: {
1286
1289
  name: "SonicJS Support",
@@ -1684,7 +1687,7 @@ apiRoutes.get("/collections", async (c) => {
1684
1687
  try {
1685
1688
  const db = c.env.DB;
1686
1689
  const cacheEnabled = c.get("cacheEnabled");
1687
- const cache = chunk4BTBSXMR_cjs.getCacheService(chunk4BTBSXMR_cjs.CACHE_CONFIGS.api);
1690
+ const cache = chunk36Z3AKX3_cjs.getCacheService(chunk36Z3AKX3_cjs.CACHE_CONFIGS.api);
1688
1691
  const cacheKey = cache.generateKey("collections", "all");
1689
1692
  if (cacheEnabled) {
1690
1693
  const cacheResult = await cache.getWithSource(cacheKey);
@@ -1710,8 +1713,8 @@ apiRoutes.get("/collections", async (c) => {
1710
1713
  }
1711
1714
  c.header("X-Cache-Status", "MISS");
1712
1715
  c.header("X-Cache-Source", "registry");
1713
- const records = chunkKZIBF2EV_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal);
1714
- const transformedResults = records.map(chunkKZIBF2EV_cjs.collectionRecordToRow);
1716
+ const records = chunkFAADMKJX_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal);
1717
+ const transformedResults = records.map(chunkFAADMKJX_cjs.collectionRecordToRow);
1715
1718
  const responseData = {
1716
1719
  data: transformedResults,
1717
1720
  meta: addTimingMeta(c, {
@@ -1732,7 +1735,7 @@ apiRoutes.get("/collections", async (c) => {
1732
1735
  return c.json({ error: "Failed to fetch collections" }, 500);
1733
1736
  }
1734
1737
  });
1735
- apiRoutes.get("/content", chunkKMM45BTY_cjs.optionalAuth(), async (c) => {
1738
+ apiRoutes.get("/content", chunkNOT5YX23_cjs.optionalAuth(), async (c) => {
1736
1739
  const executionStart = Date.now();
1737
1740
  try {
1738
1741
  const db = c.env.DB;
@@ -1741,7 +1744,7 @@ apiRoutes.get("/content", chunkKMM45BTY_cjs.optionalAuth(), async (c) => {
1741
1744
  const collIdByName = /* @__PURE__ */ new Map();
1742
1745
  let typeId;
1743
1746
  let typeIds;
1744
- const registry = chunkKZIBF2EV_cjs.getCollectionRegistry();
1747
+ const registry = chunkFAADMKJX_cjs.getCollectionRegistry();
1745
1748
  if (queryParams.collection) {
1746
1749
  const collectionName = queryParams.collection;
1747
1750
  const record = registry.getByName(collectionName);
@@ -1784,7 +1787,7 @@ apiRoutes.get("/content", chunkKMM45BTY_cjs.optionalAuth(), async (c) => {
1784
1787
  }, 400);
1785
1788
  }
1786
1789
  const cacheEnabled = c.get("cacheEnabled");
1787
- const cache = chunk4BTBSXMR_cjs.getCacheService(chunk4BTBSXMR_cjs.CACHE_CONFIGS.api);
1790
+ const cache = chunk36Z3AKX3_cjs.getCacheService(chunk36Z3AKX3_cjs.CACHE_CONFIGS.api);
1788
1791
  const cacheKey = cache.generateKey("content-filtered", JSON.stringify({ filter: normalizedFilter, query: queryResult.sql }));
1789
1792
  if (cacheEnabled) {
1790
1793
  const cacheResult = await cache.getWithSource(cacheKey);
@@ -1840,13 +1843,13 @@ apiRoutes.get("/content", chunkKMM45BTY_cjs.optionalAuth(), async (c) => {
1840
1843
  }, 500);
1841
1844
  }
1842
1845
  });
1843
- apiRoutes.get("/collections/:collection/content", chunkKMM45BTY_cjs.optionalAuth(), async (c) => {
1846
+ apiRoutes.get("/collections/:collection/content", chunkNOT5YX23_cjs.optionalAuth(), async (c) => {
1844
1847
  const executionStart = Date.now();
1845
1848
  try {
1846
1849
  const collection = c.req.param("collection");
1847
1850
  const db = c.env.DB;
1848
1851
  const queryParams = c.req.query();
1849
- const record = chunkKZIBF2EV_cjs.getCollectionRegistry().getBySlugOrName(collection);
1852
+ const record = chunkFAADMKJX_cjs.getCollectionRegistry().getBySlugOrName(collection);
1850
1853
  if (!record || record.isActive === false) {
1851
1854
  return c.json({ error: "Collection not found" }, 404);
1852
1855
  }
@@ -1868,7 +1871,7 @@ apiRoutes.get("/collections/:collection/content", chunkKMM45BTY_cjs.optionalAuth
1868
1871
  }, 400);
1869
1872
  }
1870
1873
  const cacheEnabled = c.get("cacheEnabled");
1871
- const cache = chunk4BTBSXMR_cjs.getCacheService(chunk4BTBSXMR_cjs.CACHE_CONFIGS.api);
1874
+ const cache = chunk36Z3AKX3_cjs.getCacheService(chunk36Z3AKX3_cjs.CACHE_CONFIGS.api);
1872
1875
  const includeCollection = queryParams.include?.split(",").map((s) => s.trim()).includes("collection");
1873
1876
  const cacheKey = cache.generateKey("collection-content-filtered", `${collection}:${JSON.stringify({ filter: normalizedFilter, query: queryResult.sql, includeCollection })}`);
1874
1877
  if (cacheEnabled) {
@@ -1902,7 +1905,7 @@ apiRoutes.get("/collections/:collection/content", chunkKMM45BTY_cjs.optionalAuth
1902
1905
  const responseData = {
1903
1906
  data: transformedResults,
1904
1907
  meta: addTimingMeta(c, {
1905
- ...includeCollection ? { collection: chunkKZIBF2EV_cjs.collectionRecordToRow(record) } : {},
1908
+ ...includeCollection ? { collection: chunkFAADMKJX_cjs.collectionRecordToRow(record) } : {},
1906
1909
  count: results.length,
1907
1910
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1908
1911
  // D44: echo the caller's filter with the access policy applied (status=published forced for
@@ -1927,13 +1930,13 @@ apiRoutes.get("/collections/:collection/content", chunkKMM45BTY_cjs.optionalAuth
1927
1930
  }
1928
1931
  });
1929
1932
  apiRoutes.route("/content", api_content_crud_default);
1930
- apiRoutes.get("/:collection", chunkKMM45BTY_cjs.optionalAuth(), async (c) => {
1933
+ apiRoutes.get("/:collection", chunkNOT5YX23_cjs.optionalAuth(), async (c) => {
1931
1934
  const executionStart = Date.now();
1932
1935
  try {
1933
1936
  const collection = c.req.param("collection");
1934
1937
  const db = c.env.DB;
1935
1938
  const queryParams = c.req.query();
1936
- const record = chunkKZIBF2EV_cjs.getCollectionRegistry().getBySlugOrName(collection);
1939
+ const record = chunkFAADMKJX_cjs.getCollectionRegistry().getBySlugOrName(collection);
1937
1940
  if (!record || record.isActive === false) {
1938
1941
  return c.json({ error: "Collection not found" }, 404);
1939
1942
  }
@@ -1952,7 +1955,7 @@ apiRoutes.get("/:collection", chunkKMM45BTY_cjs.optionalAuth(), async (c) => {
1952
1955
  const collectionCache = record.cache;
1953
1956
  const collectionCacheDisabled = collectionCache?.enabled === false;
1954
1957
  const cacheEnabled = c.get("cacheEnabled") && !collectionCacheDisabled;
1955
- const cache = chunk4BTBSXMR_cjs.getCacheService(chunk4BTBSXMR_cjs.CACHE_CONFIGS.api);
1958
+ const cache = chunk36Z3AKX3_cjs.getCacheService(chunk36Z3AKX3_cjs.CACHE_CONFIGS.api);
1956
1959
  const includeCollection = queryParams.include?.split(",").map((s) => s.trim()).includes("collection");
1957
1960
  const cacheKey = cache.generateKey("collection-content-filtered", `${collection}:${JSON.stringify({ filter: normalizedFilter, query: queryResult.sql, includeCollection })}`);
1958
1961
  if (cacheEnabled) {
@@ -1973,7 +1976,7 @@ apiRoutes.get("/:collection", chunkKMM45BTY_cjs.optionalAuth(), async (c) => {
1973
1976
  const responseData = {
1974
1977
  data: transformedResults,
1975
1978
  meta: addTimingMeta(c, {
1976
- ...includeCollection ? { collection: chunkKZIBF2EV_cjs.collectionRecordToRow(record) } : {},
1979
+ ...includeCollection ? { collection: chunkFAADMKJX_cjs.collectionRecordToRow(record) } : {},
1977
1980
  count: results.length,
1978
1981
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1979
1982
  filter: normalizePublicContentFilter(filter, role),
@@ -1991,12 +1994,12 @@ apiRoutes.get("/:collection", chunkKMM45BTY_cjs.optionalAuth(), async (c) => {
1991
1994
  return c.json({ error: "Failed to fetch content", details: error instanceof Error ? error.message : String(error) }, 500);
1992
1995
  }
1993
1996
  });
1994
- apiRoutes.get("/:collection/:id", chunkKMM45BTY_cjs.optionalAuth(), async (c) => {
1997
+ apiRoutes.get("/:collection/:id", chunkNOT5YX23_cjs.optionalAuth(), async (c) => {
1995
1998
  try {
1996
1999
  const collection = c.req.param("collection");
1997
2000
  const id = c.req.param("id");
1998
2001
  const db = c.env.DB;
1999
- const record = chunkKZIBF2EV_cjs.getCollectionRegistry().getBySlugOrName(collection);
2002
+ const record = chunkFAADMKJX_cjs.getCollectionRegistry().getBySlugOrName(collection);
2000
2003
  if (!record || record.isActive === false) {
2001
2004
  return c.json({ error: "Collection not found" }, 404);
2002
2005
  }
@@ -2005,7 +2008,7 @@ apiRoutes.get("/:collection/:id", chunkKMM45BTY_cjs.optionalAuth(), async (c) =>
2005
2008
  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"
2006
2009
  ).bind(id, record.name).first();
2007
2010
  if (!docRow) return c.json({ error: "Content not found" }, 404);
2008
- const coll = chunkKZIBF2EV_cjs.getCollectionRegistry().getByName(docRow.type_id);
2011
+ const coll = chunkFAADMKJX_cjs.getCollectionRegistry().getByName(docRow.type_id);
2009
2012
  const transformedContent = {
2010
2013
  id: docRow.root_id,
2011
2014
  title: docRow.title,
@@ -2013,8 +2016,8 @@ apiRoutes.get("/:collection/:id", chunkKMM45BTY_cjs.optionalAuth(), async (c) =>
2013
2016
  status: docRow.status,
2014
2017
  collectionId: coll?.id ?? docRow.type_id,
2015
2018
  data: docRow.data ? JSON.parse(docRow.data) : {},
2016
- created_at: chunkW36OZTJ5_cjs.documentSecondsToMs(docRow.created_at),
2017
- updated_at: chunkW36OZTJ5_cjs.documentSecondsToMs(docRow.updated_at)
2019
+ created_at: chunkLTZ5WYOK_cjs.documentSecondsToMs(docRow.created_at),
2020
+ updated_at: chunkLTZ5WYOK_cjs.documentSecondsToMs(docRow.updated_at)
2018
2021
  };
2019
2022
  dispatchHookEvent(c, "content:read", { collection: docRow.type_id, id: docRow.root_id, data: transformedContent.data }, "fire-and-forget");
2020
2023
  return c.json({ data: transformedContent });
@@ -2023,7 +2026,7 @@ apiRoutes.get("/:collection/:id", chunkKMM45BTY_cjs.optionalAuth(), async (c) =>
2023
2026
  return c.json({ error: "Failed to fetch content", details: error instanceof Error ? error.message : String(error) }, 500);
2024
2027
  }
2025
2028
  });
2026
- apiRoutes.post("/:collection", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45BTY_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
2029
+ apiRoutes.post("/:collection", chunkNOT5YX23_cjs.requireAuth(), chunkNOT5YX23_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
2027
2030
  try {
2028
2031
  const collection = c.req.param("collection");
2029
2032
  const db = c.env.DB;
@@ -2044,26 +2047,26 @@ apiRoutes.post("/:collection", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45BTY_cj
2044
2047
  } catch (err) {
2045
2048
  return c.json({ error: "Write cancelled by plugin", details: String(err) }, 400);
2046
2049
  }
2047
- const svc = new chunkW36OZTJ5_cjs.DocumentsService(db, { queryableFields: backing.docType.queryableFields ?? [], typeSchemaVersion: backing.docType.schemaVersion ?? 1, maxVersionsPerRoot: backing.docType.settings?.maxVersionsPerRoot ?? 50, tenantId: "default", versioning: backing.docType.settings?.versioning ?? false });
2050
+ const svc = new chunkLTZ5WYOK_cjs.DocumentsService(db, { queryableFields: backing.docType.queryableFields ?? [], typeSchemaVersion: backing.docType.schemaVersion ?? 1, maxVersionsPerRoot: backing.docType.settings?.maxVersionsPerRoot ?? 50, tenantId: "default", versioning: backing.docType.settings?.versioning ?? false });
2048
2051
  const doc = await svc.create(createDocumentSchema.parse({ typeId: backing.coll.name, tenantId: "default", locale: "default", title, slug: finalSlug, data: hookData, publishOnCreate: (status || "draft") === "published" }), user?.userId);
2049
- const cache = chunk4BTBSXMR_cjs.getCacheService(chunk4BTBSXMR_cjs.CACHE_CONFIGS.api);
2052
+ const cache = chunk36Z3AKX3_cjs.getCacheService(chunk36Z3AKX3_cjs.CACHE_CONFIGS.api);
2050
2053
  await cache.invalidate("content-filtered:*");
2051
2054
  await cache.invalidate("collection-content-filtered:*");
2052
2055
  dispatchHookEvent(c, "content:after:create", { collection: backing.coll.name, id: doc.rootId, data: doc.data ?? {}, user: actor }, "fire-and-forget");
2053
- return c.json({ data: { id: doc.rootId, title: doc.title, slug: doc.slug, status: doc.status, collectionId: backing.coll.id, data: doc.data, created_at: chunkW36OZTJ5_cjs.documentSecondsToMs(doc.createdAt), updated_at: chunkW36OZTJ5_cjs.documentSecondsToMs(doc.updatedAt) } }, 201);
2056
+ return c.json({ data: { id: doc.rootId, title: doc.title, slug: doc.slug, status: doc.status, collectionId: backing.coll.id, data: doc.data, created_at: chunkLTZ5WYOK_cjs.documentSecondsToMs(doc.createdAt), updated_at: chunkLTZ5WYOK_cjs.documentSecondsToMs(doc.updatedAt) } }, 201);
2054
2057
  } catch (error) {
2055
2058
  console.error("Error creating content:", error);
2056
2059
  return c.json({ error: "Failed to create content", details: error instanceof Error ? error.message : String(error) }, 500);
2057
2060
  }
2058
2061
  });
2059
- apiRoutes.put("/:collection/:id", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45BTY_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
2062
+ apiRoutes.put("/:collection/:id", chunkNOT5YX23_cjs.requireAuth(), chunkNOT5YX23_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
2060
2063
  try {
2061
2064
  const collection = c.req.param("collection");
2062
2065
  const id = c.req.param("id");
2063
2066
  const db = c.env.DB;
2064
2067
  const user = c.get("user");
2065
2068
  const body = await c.req.json();
2066
- const collRecord = chunkKZIBF2EV_cjs.getCollectionRegistry().getBySlugOrName(collection);
2069
+ const collRecord = chunkFAADMKJX_cjs.getCollectionRegistry().getBySlugOrName(collection);
2067
2070
  const typeName = collRecord?.name ?? collection;
2068
2071
  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();
2069
2072
  if (!docRow) return c.json({ error: "Content not found" }, 404);
@@ -2075,8 +2078,8 @@ apiRoutes.put("/:collection/:id", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45BTY
2075
2078
  } catch (err) {
2076
2079
  return c.json({ error: "Write cancelled by plugin", details: String(err) }, 400);
2077
2080
  }
2078
- const docType = await new chunkKMM45BTY_cjs.DocumentTypeRegistry(db).findById(docRow.type_id);
2079
- const svc = new chunkW36OZTJ5_cjs.DocumentsService(db, { queryableFields: docType?.queryableFields ?? [], typeSchemaVersion: docType?.schemaVersion ?? 1, maxVersionsPerRoot: docType?.settings?.maxVersionsPerRoot ?? 50, tenantId: "default", versioning: docType?.settings?.versioning ?? false });
2081
+ const docType = await new chunkNOT5YX23_cjs.DocumentTypeRegistry(db).findById(docRow.type_id);
2082
+ const svc = new chunkLTZ5WYOK_cjs.DocumentsService(db, { queryableFields: docType?.queryableFields ?? [], typeSchemaVersion: docType?.schemaVersion ?? 1, maxVersionsPerRoot: docType?.settings?.maxVersionsPerRoot ?? 50, tenantId: "default", versioning: docType?.settings?.versioning ?? false });
2080
2083
  const input = {};
2081
2084
  if (body.title !== void 0) input.title = body.title;
2082
2085
  if (body.slug !== void 0) input.slug = slugify(body.slug);
@@ -2089,28 +2092,28 @@ apiRoutes.put("/:collection/:id", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45BTY
2089
2092
  } else if (body.status === "draft" && pub) {
2090
2093
  await svc.unpublish(pub.id);
2091
2094
  }
2092
- const cache = chunk4BTBSXMR_cjs.getCacheService(chunk4BTBSXMR_cjs.CACHE_CONFIGS.api);
2095
+ const cache = chunk36Z3AKX3_cjs.getCacheService(chunk36Z3AKX3_cjs.CACHE_CONFIGS.api);
2093
2096
  await cache.invalidate("content-filtered:*");
2094
2097
  await cache.invalidate("collection-content-filtered:*");
2095
- const coll = chunkKZIBF2EV_cjs.getCollectionRegistry().getByName(docRow.type_id);
2098
+ const coll = chunkFAADMKJX_cjs.getCollectionRegistry().getByName(docRow.type_id);
2096
2099
  const saved = await db.prepare("SELECT * FROM documents WHERE id = ?").bind(newDraft.id).first();
2097
2100
  const savedData = saved?.data ? JSON.parse(saved.data) : {};
2098
2101
  dispatchHookEvent(c, "content:after:update", { collection: docRow.type_id, id, data: savedData, user: actor }, "fire-and-forget");
2099
2102
  const nowPublished = body.status === "published" || body.status === void 0 && wasPublished;
2100
2103
  if (nowPublished && !wasPublished) dispatchHookEvent(c, "content:after:publish", { collection: docRow.type_id, id, data: savedData, user: actor }, "fire-and-forget");
2101
- return c.json({ data: { id: saved.root_id, title: saved.title, slug: saved.slug, status: saved.status, collectionId: coll?.id ?? docRow.type_id, data: savedData, created_at: chunkW36OZTJ5_cjs.documentSecondsToMs(saved.created_at), updated_at: chunkW36OZTJ5_cjs.documentSecondsToMs(saved.updated_at) } });
2104
+ return c.json({ data: { id: saved.root_id, title: saved.title, slug: saved.slug, status: saved.status, collectionId: coll?.id ?? docRow.type_id, data: savedData, created_at: chunkLTZ5WYOK_cjs.documentSecondsToMs(saved.created_at), updated_at: chunkLTZ5WYOK_cjs.documentSecondsToMs(saved.updated_at) } });
2102
2105
  } catch (error) {
2103
2106
  console.error("Error updating content:", error);
2104
2107
  return c.json({ error: "Failed to update content", details: error instanceof Error ? error.message : String(error) }, 500);
2105
2108
  }
2106
2109
  });
2107
- apiRoutes.delete("/:collection/:id", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45BTY_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
2110
+ apiRoutes.delete("/:collection/:id", chunkNOT5YX23_cjs.requireAuth(), chunkNOT5YX23_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
2108
2111
  try {
2109
2112
  const collection = c.req.param("collection");
2110
2113
  const id = c.req.param("id");
2111
2114
  const db = c.env.DB;
2112
2115
  const user = c.get("user");
2113
- const collRecord = chunkKZIBF2EV_cjs.getCollectionRegistry().getBySlugOrName(collection);
2116
+ const collRecord = chunkFAADMKJX_cjs.getCollectionRegistry().getBySlugOrName(collection);
2114
2117
  const typeName = collRecord?.name ?? collection;
2115
2118
  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();
2116
2119
  if (!docRow) return c.json({ error: "Content not found" }, 404);
@@ -2122,7 +2125,7 @@ apiRoutes.delete("/:collection/:id", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45
2122
2125
  }
2123
2126
  const now = Math.floor(Date.now() / 1e3);
2124
2127
  await db.prepare("UPDATE documents SET deleted_at = ?, updated_at = ? WHERE root_id = ? AND tenant_id = 'default'").bind(now, now, id).run();
2125
- const cache = chunk4BTBSXMR_cjs.getCacheService(chunk4BTBSXMR_cjs.CACHE_CONFIGS.api);
2128
+ const cache = chunk36Z3AKX3_cjs.getCacheService(chunk36Z3AKX3_cjs.CACHE_CONFIGS.api);
2126
2129
  await cache.invalidate("content-filtered:*");
2127
2130
  await cache.invalidate("collection-content-filtered:*");
2128
2131
  dispatchHookEvent(c, "content:after:delete", { collection: docRow.type_id, id, data: {}, user: actor }, "fire-and-forget");
@@ -2193,9 +2196,11 @@ var MediaDocumentService = class {
2193
2196
  this.db = db;
2194
2197
  this.tenantId = tenantId;
2195
2198
  }
2199
+ db;
2200
+ tenantId;
2196
2201
  /** Create a media_asset document from R2 upload metadata. Published-on-create (immediately usable). */
2197
2202
  async createFromUpload(meta, createdBy) {
2198
- const svc = new chunkW36OZTJ5_cjs.DocumentsService(this.db, { queryableFields: MEDIA_QUERYABLE, tenantId: this.tenantId, maxVersionsPerRoot: 5 });
2203
+ const svc = new chunkLTZ5WYOK_cjs.DocumentsService(this.db, { queryableFields: MEDIA_QUERYABLE, tenantId: this.tenantId, maxVersionsPerRoot: 5 });
2199
2204
  return svc.create(
2200
2205
  createDocumentSchema.parse({
2201
2206
  typeId: "media_asset",
@@ -2268,7 +2273,7 @@ var MediaDocumentService = class {
2268
2273
  }
2269
2274
  /** Update alt/caption/tags on a media_asset document (saveDraft + publish atomically). */
2270
2275
  async updateMetadata(rootId, meta, updatedBy) {
2271
- const svc = new chunkW36OZTJ5_cjs.DocumentsService(this.db, { queryableFields: MEDIA_QUERYABLE, tenantId: this.tenantId, maxVersionsPerRoot: 5 });
2276
+ const svc = new chunkLTZ5WYOK_cjs.DocumentsService(this.db, { queryableFields: MEDIA_QUERYABLE, tenantId: this.tenantId, maxVersionsPerRoot: 5 });
2272
2277
  const newDraft = await svc.saveDraft(rootId, { data: meta }, updatedBy);
2273
2278
  return svc.publish(newDraft.id, updatedBy);
2274
2279
  }
@@ -2325,7 +2330,7 @@ var fileValidationSchema = zod.z.object({
2325
2330
  // 50MB max
2326
2331
  });
2327
2332
  var apiMediaRoutes = new hono.Hono();
2328
- apiMediaRoutes.use("*", chunkKMM45BTY_cjs.requireAuth());
2333
+ apiMediaRoutes.use("*", chunkNOT5YX23_cjs.requireAuth());
2329
2334
  apiMediaRoutes.post("/upload", async (c) => {
2330
2335
  try {
2331
2336
  const user = c.get("user");
@@ -3023,7 +3028,7 @@ apiSystemRoutes.get("/info", (c) => {
3023
3028
  apiSystemRoutes.get("/stats", async (c) => {
3024
3029
  try {
3025
3030
  const db = c.env.DB;
3026
- const typeIds = chunkKZIBF2EV_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal).map((r) => r.name);
3031
+ const typeIds = chunkFAADMKJX_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal).map((r) => r.name);
3027
3032
  let contentStats = null;
3028
3033
  if (typeIds.length > 0) {
3029
3034
  const placeholders = typeIds.map(() => "?").join(",");
@@ -3098,12 +3103,12 @@ apiSystemRoutes.get("/env", (c) => {
3098
3103
  });
3099
3104
  var api_system_default = apiSystemRoutes;
3100
3105
  var adminApiRoutes = new hono.Hono();
3101
- adminApiRoutes.use("*", chunkKMM45BTY_cjs.requireAuth());
3102
- adminApiRoutes.use("*", chunkKMM45BTY_cjs.requireRole(["admin", "editor"]));
3106
+ adminApiRoutes.use("*", chunkNOT5YX23_cjs.requireAuth());
3107
+ adminApiRoutes.use("*", chunkNOT5YX23_cjs.requireRole(["admin", "editor"]));
3103
3108
  adminApiRoutes.get("/stats", async (c) => {
3104
3109
  try {
3105
3110
  const db = c.env.DB;
3106
- const userCollections = chunkKZIBF2EV_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal);
3111
+ const userCollections = chunkFAADMKJX_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal);
3107
3112
  const collectionsCount = userCollections.length;
3108
3113
  let contentCount = 0;
3109
3114
  if (userCollections.length > 0) {
@@ -3194,7 +3199,7 @@ adminApiRoutes.get("/collections", async (c) => {
3194
3199
  try {
3195
3200
  const search = c.req.query("search") || "";
3196
3201
  const includeInactive = c.req.query("includeInactive") === "true";
3197
- let records = chunkKZIBF2EV_cjs.getCollectionRegistry().list().filter((r) => !r.internal);
3202
+ let records = chunkFAADMKJX_cjs.getCollectionRegistry().list().filter((r) => !r.internal);
3198
3203
  if (!includeInactive) records = records.filter((r) => r.isActive !== false);
3199
3204
  if (search) {
3200
3205
  const needle = search.toLowerCase();
@@ -3226,7 +3231,7 @@ adminApiRoutes.get("/collections", async (c) => {
3226
3231
  adminApiRoutes.get("/collections/:id", async (c) => {
3227
3232
  try {
3228
3233
  const id = c.req.param("id");
3229
- const registry = chunkKZIBF2EV_cjs.getCollectionRegistry();
3234
+ const registry = chunkFAADMKJX_cjs.getCollectionRegistry();
3230
3235
  const record = registry.getById(id) ?? registry.getByName(id);
3231
3236
  if (!record) {
3232
3237
  return c.json({ error: "Collection not found" }, 404);
@@ -3276,7 +3281,7 @@ adminApiRoutes.get("/references", async (c) => {
3276
3281
  if (collectionParams.length === 0) {
3277
3282
  return c.json({ error: "Collection is required" }, 400);
3278
3283
  }
3279
- const registry = chunkKZIBF2EV_cjs.getCollectionRegistry();
3284
+ const registry = chunkFAADMKJX_cjs.getCollectionRegistry();
3280
3285
  const matched = collectionParams.map((param) => registry.getById(param) ?? registry.getByName(param)).filter((r) => !!r);
3281
3286
  const seen = /* @__PURE__ */ new Set();
3282
3287
  const collections = matched.filter((r) => {
@@ -3391,7 +3396,7 @@ adminApiRoutes.patch("/collections/:id", collectionsReadOnly);
3391
3396
  adminApiRoutes.delete("/collections/:id", collectionsReadOnly);
3392
3397
  adminApiRoutes.get("/migrations/status", async (c) => {
3393
3398
  try {
3394
- const { MigrationService: MigrationService2 } = await import('./migrations-KMCULV6H.cjs');
3399
+ const { MigrationService: MigrationService2 } = await import('./migrations-GN6H36JS.cjs');
3395
3400
  const db = c.env.DB;
3396
3401
  const migrationService = new MigrationService2(db);
3397
3402
  const status = await migrationService.getMigrationStatus();
@@ -3434,7 +3439,7 @@ adminApiRoutes.post("/migrations/run", async (c) => {
3434
3439
  });
3435
3440
  adminApiRoutes.get("/migrations/validate", async (c) => {
3436
3441
  try {
3437
- const { MigrationService: MigrationService2 } = await import('./migrations-KMCULV6H.cjs');
3442
+ const { MigrationService: MigrationService2 } = await import('./migrations-GN6H36JS.cjs');
3438
3443
  const db = c.env.DB;
3439
3444
  const migrationService = new MigrationService2(db);
3440
3445
  const validation = await migrationService.validateSchema();
@@ -3849,7 +3854,7 @@ function renderRegisterPage(data) {
3849
3854
  }
3850
3855
 
3851
3856
  // src/services/email/email-service-singleton.ts
3852
- var singleton = chunkKOXFYFOF_cjs.createServiceSingleton("EmailService");
3857
+ var singleton = chunkQSDN2CKI_cjs.createServiceSingleton("EmailService");
3853
3858
  function setEmailService(service2) {
3854
3859
  singleton.set(service2);
3855
3860
  }
@@ -3893,7 +3898,7 @@ function emptyProfile() {
3893
3898
  return { custom: {} };
3894
3899
  }
3895
3900
  function service(db) {
3896
- return new chunkW36OZTJ5_cjs.DocumentsService(db, { tenantId: "default", maxVersionsPerRoot: 1, queryableFields: [] });
3901
+ return new chunkLTZ5WYOK_cjs.DocumentsService(db, { tenantId: "default", maxVersionsPerRoot: 1, queryableFields: [] });
3897
3902
  }
3898
3903
  async function readProfileData(db, userId) {
3899
3904
  const row = await db.prepare(
@@ -4657,7 +4662,7 @@ function getLexicalInitScript(settings = {}) {
4657
4662
  </script>
4658
4663
  `;
4659
4664
  }
4660
- var lexicalEditorPlugin = chunkKOXFYFOF_cjs.definePlugin({
4665
+ var lexicalEditorPlugin = chunkQSDN2CKI_cjs.definePlugin({
4661
4666
  id: "lexical-editor",
4662
4667
  version: "1.0.0",
4663
4668
  name: "Lexical Editor",
@@ -7063,7 +7068,7 @@ api.put("/:userId", async (c) => {
7063
7068
  await saveCustomData(db, userId, sanitized);
7064
7069
  return c.json({ success: true });
7065
7070
  });
7066
- var userProfilesPlugin = chunkKOXFYFOF_cjs.definePlugin({
7071
+ var userProfilesPlugin = chunkQSDN2CKI_cjs.definePlugin({
7067
7072
  id: "user-profiles",
7068
7073
  version: "1.0.0",
7069
7074
  name: "User Profiles",
@@ -7101,8 +7106,8 @@ function renderPasswordResetEmail(resetLink, firstName) {
7101
7106
  async function setCsrfCookie(c, maxAge) {
7102
7107
  const secret = c.env?.JWT_SECRET || JWT_SECRET_FALLBACK;
7103
7108
  const isDev = c.env?.ENVIRONMENT === "development" || !c.env?.ENVIRONMENT;
7104
- const csrfToken = await chunkKMM45BTY_cjs.generateCsrfToken(secret);
7105
- const cookieMaxAge = await chunkKMM45BTY_cjs.getJwtExpirySecondsFromDb(c.env?.DB, c.env);
7109
+ const csrfToken = await chunkNOT5YX23_cjs.generateCsrfToken(secret);
7110
+ const cookieMaxAge = await chunkNOT5YX23_cjs.getJwtExpirySecondsFromDb(c.env?.DB, c.env);
7106
7111
  cookie.setCookie(c, "csrf_token", csrfToken, {
7107
7112
  httpOnly: false,
7108
7113
  secure: !isDev,
@@ -7161,7 +7166,7 @@ var loginSchema = zod.z.object({
7161
7166
  });
7162
7167
  authRoutes.post(
7163
7168
  "/register",
7164
- chunkKMM45BTY_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "register" }),
7169
+ chunkNOT5YX23_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "register" }),
7165
7170
  async (c) => {
7166
7171
  try {
7167
7172
  const db = c.env.DB;
@@ -7197,7 +7202,7 @@ authRoutes.post(
7197
7202
  if (existingUser) {
7198
7203
  return c.json({ error: "User with this email already exists" }, 400);
7199
7204
  }
7200
- const passwordHash = await chunkKMM45BTY_cjs.AuthManager.hashPassword(password);
7205
+ const passwordHash = await chunkNOT5YX23_cjs.AuthManager.hashPassword(password);
7201
7206
  const userId = crypto.randomUUID();
7202
7207
  const now = /* @__PURE__ */ new Date();
7203
7208
  const nowSec = Math.floor(now.getTime() / 1e3);
@@ -7230,8 +7235,8 @@ authRoutes.post(
7230
7235
  { user: { id: userId, email: normalizedEmail, role: "viewer" } },
7231
7236
  "fire-and-forget"
7232
7237
  );
7233
- const tokenTtl = await chunkKMM45BTY_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
7234
- const token = await chunkKMM45BTY_cjs.AuthManager.generateToken(userId, normalizedEmail, "viewer", c.env.JWT_SECRET, tokenTtl);
7238
+ const tokenTtl = await chunkNOT5YX23_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
7239
+ const token = await chunkNOT5YX23_cjs.AuthManager.generateToken(userId, normalizedEmail, "viewer", c.env.JWT_SECRET, tokenTtl);
7235
7240
  cookie.setCookie(c, "auth_token", token, {
7236
7241
  httpOnly: true,
7237
7242
  secure: true,
@@ -7263,7 +7268,7 @@ authRoutes.post(
7263
7268
  );
7264
7269
  authRoutes.post(
7265
7270
  "/login",
7266
- chunkKMM45BTY_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "login" }),
7271
+ chunkNOT5YX23_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "login" }),
7267
7272
  async (c) => {
7268
7273
  try {
7269
7274
  const body = await c.req.json();
@@ -7273,7 +7278,7 @@ authRoutes.post(
7273
7278
  }
7274
7279
  const { email, password } = validation.data;
7275
7280
  const normalizedEmail = email.toLowerCase();
7276
- const { createAuth } = await import('./config-YCRSU7ZP.cjs');
7281
+ const { createAuth } = await import('./config-OCH7S4WK.cjs');
7277
7282
  const auth = createAuth(c.env);
7278
7283
  const baReq = new Request(new URL("/auth/sign-in/email", c.req.url).href, {
7279
7284
  method: "POST",
@@ -7295,8 +7300,8 @@ authRoutes.post(
7295
7300
  await setCsrfCookie(c);
7296
7301
  const baBody = await baRes.json();
7297
7302
  const user = baBody.user ?? {};
7298
- const tokenTtl = await chunkKMM45BTY_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
7299
- const token = await chunkKMM45BTY_cjs.AuthManager.generateToken(
7303
+ const tokenTtl = await chunkNOT5YX23_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
7304
+ const token = await chunkNOT5YX23_cjs.AuthManager.generateToken(
7300
7305
  user.id,
7301
7306
  user.email,
7302
7307
  user.role ?? "viewer",
@@ -7327,7 +7332,7 @@ authRoutes.post(
7327
7332
  );
7328
7333
  authRoutes.post("/logout", async (c) => {
7329
7334
  try {
7330
- const { createAuth } = await import('./config-YCRSU7ZP.cjs');
7335
+ const { createAuth } = await import('./config-OCH7S4WK.cjs');
7331
7336
  const auth = createAuth(c.env);
7332
7337
  const baReq = new Request(new URL("/auth/sign-out", c.req.url).href, {
7333
7338
  method: "POST",
@@ -7343,7 +7348,7 @@ authRoutes.post("/logout", async (c) => {
7343
7348
  });
7344
7349
  authRoutes.get("/logout", async (c) => {
7345
7350
  try {
7346
- const { createAuth } = await import('./config-YCRSU7ZP.cjs');
7351
+ const { createAuth } = await import('./config-OCH7S4WK.cjs');
7347
7352
  const auth = createAuth(c.env);
7348
7353
  const baReq = new Request(new URL("/auth/sign-out", c.req.url).href, {
7349
7354
  method: "POST",
@@ -7357,7 +7362,7 @@ authRoutes.get("/logout", async (c) => {
7357
7362
  clearCsrfCookie(c);
7358
7363
  return c.redirect("/auth/login?message=You have been logged out successfully");
7359
7364
  });
7360
- authRoutes.get("/me", chunkKMM45BTY_cjs.requireAuth(), async (c) => {
7365
+ authRoutes.get("/me", chunkNOT5YX23_cjs.requireAuth(), async (c) => {
7361
7366
  try {
7362
7367
  const user = c.get("user");
7363
7368
  if (!user) {
@@ -7377,7 +7382,7 @@ authRoutes.get("/me", chunkKMM45BTY_cjs.requireAuth(), async (c) => {
7377
7382
  });
7378
7383
  authRoutes.post(
7379
7384
  "/refresh",
7380
- chunkKMM45BTY_cjs.rateLimit({ max: 60, windowMs: 60 * 1e3, keyPrefix: "refresh" }),
7385
+ chunkNOT5YX23_cjs.rateLimit({ max: 60, windowMs: 60 * 1e3, keyPrefix: "refresh" }),
7381
7386
  async (c) => {
7382
7387
  try {
7383
7388
  let token = c.req.header("Authorization")?.replace("Bearer ", "");
@@ -7386,8 +7391,8 @@ authRoutes.post(
7386
7391
  return c.json({ error: "Authentication required" }, 401);
7387
7392
  }
7388
7393
  const db = c.env.DB;
7389
- const grace = await chunkKMM45BTY_cjs.getJwtRefreshGraceSecondsFromDb(db, c.env);
7390
- const payload = await chunkKMM45BTY_cjs.AuthManager.verifyToken(token, c.env.JWT_SECRET, grace);
7394
+ const grace = await chunkNOT5YX23_cjs.getJwtRefreshGraceSecondsFromDb(db, c.env);
7395
+ const payload = await chunkNOT5YX23_cjs.AuthManager.verifyToken(token, c.env.JWT_SECRET, grace);
7391
7396
  if (!payload) {
7392
7397
  return c.json({ error: "Invalid or expired token" }, 401);
7393
7398
  }
@@ -7395,8 +7400,8 @@ authRoutes.post(
7395
7400
  if (!row || !row.is_active) {
7396
7401
  return c.json({ error: "User is not active" }, 401);
7397
7402
  }
7398
- const tokenTtl = await chunkKMM45BTY_cjs.getJwtExpirySecondsFromDb(db, c.env);
7399
- const newToken = await chunkKMM45BTY_cjs.AuthManager.generateToken(row.id, row.email, row.role, c.env.JWT_SECRET, tokenTtl);
7403
+ const tokenTtl = await chunkNOT5YX23_cjs.getJwtExpirySecondsFromDb(db, c.env);
7404
+ const newToken = await chunkNOT5YX23_cjs.AuthManager.generateToken(row.id, row.email, row.role, c.env.JWT_SECRET, tokenTtl);
7400
7405
  cookie.setCookie(c, "auth_token", newToken, {
7401
7406
  httpOnly: true,
7402
7407
  secure: true,
@@ -7416,7 +7421,7 @@ authRoutes.post(
7416
7421
  );
7417
7422
  authRoutes.post(
7418
7423
  "/register/form",
7419
- chunkKMM45BTY_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "register" }),
7424
+ chunkNOT5YX23_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "register" }),
7420
7425
  async (c) => {
7421
7426
  try {
7422
7427
  const db = c.env.DB;
@@ -7461,7 +7466,7 @@ authRoutes.post(
7461
7466
  </div>
7462
7467
  `);
7463
7468
  }
7464
- const passwordHash = await chunkKMM45BTY_cjs.AuthManager.hashPassword(password);
7469
+ const passwordHash = await chunkNOT5YX23_cjs.AuthManager.hashPassword(password);
7465
7470
  const role = isFirstUser ? "admin" : "viewer";
7466
7471
  const userId = crypto.randomUUID();
7467
7472
  const now = /* @__PURE__ */ new Date();
@@ -7495,7 +7500,7 @@ authRoutes.post(
7495
7500
  await saveCustomData(db, userId, sanitized);
7496
7501
  }
7497
7502
  }
7498
- const rbacService = new chunkW36OZTJ5_cjs.RbacService(db);
7503
+ const rbacService = new chunkLTZ5WYOK_cjs.RbacService(db);
7499
7504
  await rbacService.addUserRoleByName(userId, role);
7500
7505
  dispatchHookEvent(
7501
7506
  c,
@@ -7503,8 +7508,8 @@ authRoutes.post(
7503
7508
  { user: { id: userId, email: normalizedEmail, role } },
7504
7509
  "fire-and-forget"
7505
7510
  );
7506
- const tokenTtl = await chunkKMM45BTY_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
7507
- const token = await chunkKMM45BTY_cjs.AuthManager.generateToken(userId, normalizedEmail, role, c.env.JWT_SECRET, tokenTtl);
7511
+ const tokenTtl = await chunkNOT5YX23_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
7512
+ const token = await chunkNOT5YX23_cjs.AuthManager.generateToken(userId, normalizedEmail, role, c.env.JWT_SECRET, tokenTtl);
7508
7513
  cookie.setCookie(c, "auth_token", token, {
7509
7514
  httpOnly: true,
7510
7515
  secure: false,
@@ -7536,7 +7541,7 @@ authRoutes.post(
7536
7541
  );
7537
7542
  authRoutes.post(
7538
7543
  "/login/form",
7539
- chunkKMM45BTY_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "login" }),
7544
+ chunkNOT5YX23_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "login" }),
7540
7545
  async (c) => {
7541
7546
  try {
7542
7547
  const formData = await c.req.formData();
@@ -7550,7 +7555,7 @@ authRoutes.post(
7550
7555
  </div>
7551
7556
  `);
7552
7557
  }
7553
- const { createAuth } = await import('./config-YCRSU7ZP.cjs');
7558
+ const { createAuth } = await import('./config-OCH7S4WK.cjs');
7554
7559
  const auth = createAuth(c.env);
7555
7560
  const baReq = new Request(new URL("/auth/sign-in/email", c.req.url).href, {
7556
7561
  method: "POST",
@@ -7605,14 +7610,14 @@ authRoutes.post(
7605
7610
  );
7606
7611
  authRoutes.post(
7607
7612
  "/seed-admin",
7608
- chunkKMM45BTY_cjs.rateLimit({ max: 10, windowMs: 60 * 1e3, keyPrefix: "seed-admin" }),
7613
+ chunkNOT5YX23_cjs.rateLimit({ max: 10, windowMs: 60 * 1e3, keyPrefix: "seed-admin" }),
7609
7614
  async (c) => {
7610
7615
  try {
7611
7616
  const db = c.env.DB;
7612
- const rbac = new chunkW36OZTJ5_cjs.RbacService(db);
7617
+ const rbac = new chunkLTZ5WYOK_cjs.RbacService(db);
7613
7618
  const results = [];
7614
7619
  const upsertSeedUser = async (opts) => {
7615
- const passwordHash = await chunkKMM45BTY_cjs.AuthManager.hashPassword(opts.password);
7620
+ const passwordHash = await chunkNOT5YX23_cjs.AuthManager.hashPassword(opts.password);
7616
7621
  const nowMs = Date.now();
7617
7622
  const nowSec = Math.floor(nowMs / 1e3);
7618
7623
  const existing = await db.prepare("SELECT id FROM auth_user WHERE email = ?").bind(opts.email).first();
@@ -7837,7 +7842,7 @@ authRoutes.post("/accept-invitation", async (c) => {
7837
7842
  if (invitationAge > maxAge) {
7838
7843
  return c.json({ error: "Invitation has expired" }, 400);
7839
7844
  }
7840
- const passwordHash = await chunkKMM45BTY_cjs.AuthManager.hashPassword(password);
7845
+ const passwordHash = await chunkNOT5YX23_cjs.AuthManager.hashPassword(password);
7841
7846
  const updateStmt = db.prepare(`
7842
7847
  UPDATE auth_user SET
7843
7848
  password_hash = ?,
@@ -7854,8 +7859,8 @@ authRoutes.post("/accept-invitation", async (c) => {
7854
7859
  Date.now(),
7855
7860
  invitedUser.id
7856
7861
  ).run();
7857
- const tokenTtl = await chunkKMM45BTY_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
7858
- const authToken = await chunkKMM45BTY_cjs.AuthManager.generateToken(invitedUser.id, invitedUser.email, invitedUser.role, c.env.JWT_SECRET, tokenTtl);
7862
+ const tokenTtl = await chunkNOT5YX23_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
7863
+ const authToken = await chunkNOT5YX23_cjs.AuthManager.generateToken(invitedUser.id, invitedUser.email, invitedUser.role, c.env.JWT_SECRET, tokenTtl);
7859
7864
  cookie.setCookie(c, "auth_token", authToken, {
7860
7865
  httpOnly: true,
7861
7866
  secure: true,
@@ -7871,7 +7876,7 @@ authRoutes.post("/accept-invitation", async (c) => {
7871
7876
  });
7872
7877
  authRoutes.post(
7873
7878
  "/request-password-reset",
7874
- chunkKMM45BTY_cjs.rateLimit({ max: 3, windowMs: 15 * 60 * 1e3, keyPrefix: "password-reset" }),
7879
+ chunkNOT5YX23_cjs.rateLimit({ max: 3, windowMs: 15 * 60 * 1e3, keyPrefix: "password-reset" }),
7875
7880
  async (c) => {
7876
7881
  try {
7877
7882
  const formData = await c.req.formData();
@@ -8108,7 +8113,7 @@ authRoutes.post("/reset-password", async (c) => {
8108
8113
  if (Date.now() > user.password_reset_expires) {
8109
8114
  return c.json({ error: "Reset token has expired" }, 400);
8110
8115
  }
8111
- const newPasswordHash = await chunkKMM45BTY_cjs.AuthManager.hashPassword(password);
8116
+ const newPasswordHash = await chunkNOT5YX23_cjs.AuthManager.hashPassword(password);
8112
8117
  try {
8113
8118
  const historyStmt = db.prepare(`
8114
8119
  INSERT INTO auth_password_history (id, user_id, password_hash, created_at)
@@ -8322,7 +8327,7 @@ app.post("/test-seed-defaults", async (c) => {
8322
8327
  var test_cleanup_default = app;
8323
8328
 
8324
8329
  // src/plugins/available/easy-mdx/index.ts
8325
- chunkKOXFYFOF_cjs.definePlugin({
8330
+ chunkQSDN2CKI_cjs.definePlugin({
8326
8331
  id: "easy-mdx",
8327
8332
  version: "1.0.0",
8328
8333
  name: "EasyMDE Markdown Editor",
@@ -8522,7 +8527,7 @@ function getMDXEditorInitScript(config) {
8522
8527
  }
8523
8528
 
8524
8529
  // src/plugins/available/tinymce-plugin/index.ts
8525
- chunkKOXFYFOF_cjs.definePlugin({
8530
+ chunkQSDN2CKI_cjs.definePlugin({
8526
8531
  id: "tinymce-plugin",
8527
8532
  version: "1.0.0",
8528
8533
  name: "TinyMCE",
@@ -8792,7 +8797,7 @@ function getQuillCDN(version = "2.0.2") {
8792
8797
  </style>
8793
8798
  `;
8794
8799
  }
8795
- chunkKOXFYFOF_cjs.definePlugin({
8800
+ chunkQSDN2CKI_cjs.definePlugin({
8796
8801
  id: "quill-editor",
8797
8802
  version: "1.0.0",
8798
8803
  name: "Quill Editor",
@@ -11366,7 +11371,7 @@ function extractFieldData(fields, formData, options = {}) {
11366
11371
  }
11367
11372
  return { data, errors };
11368
11373
  }
11369
- adminContentRoutes.use("*", chunkKMM45BTY_cjs.requireAuth());
11374
+ adminContentRoutes.use("*", chunkNOT5YX23_cjs.requireAuth());
11370
11375
  async function getCollectionFields(db, collectionId) {
11371
11376
  console.log(`[getCollectionFields] Loading fields for collection: ${collectionId}`);
11372
11377
  const collectionStmt = db.prepare("SELECT schema, queryable_fields FROM document_types WHERE id = ?");
@@ -11393,7 +11398,7 @@ async function getCollectionFields(db, collectionId) {
11393
11398
  };
11394
11399
  });
11395
11400
  }
11396
- const codeCollections2 = await chunkKZIBF2EV_cjs.loadCollectionConfigs();
11401
+ const codeCollections2 = await chunkFAADMKJX_cjs.loadCollectionConfigs();
11397
11402
  const codeMatch = codeCollections2.find((c) => c.name === collectionId);
11398
11403
  if (codeMatch && codeMatch.schema?.properties) {
11399
11404
  console.log(`[getCollectionFields] DB doc type has no properties \u2014 using code collection schema`);
@@ -11425,7 +11430,7 @@ async function getCollectionFields(db, collectionId) {
11425
11430
  }
11426
11431
  }
11427
11432
  console.log(`[getCollectionFields] Not in database, checking code collections`);
11428
- const codeCollections = await chunkKZIBF2EV_cjs.loadCollectionConfigs();
11433
+ const codeCollections = await chunkFAADMKJX_cjs.loadCollectionConfigs();
11429
11434
  console.log(`[getCollectionFields] Found ${codeCollections.length} code collections`);
11430
11435
  const codeCollection = codeCollections.find((c) => c.name === collectionId);
11431
11436
  if (codeCollection && codeCollection.schema) {
@@ -11461,7 +11466,7 @@ async function getCollectionFields(db, collectionId) {
11461
11466
  }
11462
11467
  async function getCollection(db, collectionId) {
11463
11468
  console.log(`[getCollection] Loading collection by ID: ${collectionId}`);
11464
- const cache = chunk4BTBSXMR_cjs.getCacheService(chunk4BTBSXMR_cjs.CACHE_CONFIGS.collection);
11469
+ const cache = chunk36Z3AKX3_cjs.getCacheService(chunk36Z3AKX3_cjs.CACHE_CONFIGS.collection);
11465
11470
  return cache.getOrSet(
11466
11471
  cache.generateKey("collection", collectionId),
11467
11472
  async () => {
@@ -11479,7 +11484,7 @@ async function getCollection(db, collectionId) {
11479
11484
  };
11480
11485
  }
11481
11486
  console.log(`[getCollection] Not in database, checking code collections`);
11482
- const codeCollections = await chunkKZIBF2EV_cjs.loadCollectionConfigs();
11487
+ const codeCollections = await chunkFAADMKJX_cjs.loadCollectionConfigs();
11483
11488
  const codeCollection = codeCollections.find((c) => c.name === collectionId);
11484
11489
  if (codeCollection) {
11485
11490
  console.log(`[getCollection] Found code collection: ${collectionId}`);
@@ -11498,7 +11503,7 @@ async function getCollection(db, collectionId) {
11498
11503
  }
11499
11504
  async function getDocBackingType(db, collectionName) {
11500
11505
  if (!collectionName) return null;
11501
- const dt = await new chunkKMM45BTY_cjs.DocumentTypeRegistry(db).findById(collectionName);
11506
+ const dt = await new chunkNOT5YX23_cjs.DocumentTypeRegistry(db).findById(collectionName);
11502
11507
  return dt && dt.isActive ? dt : null;
11503
11508
  }
11504
11509
  async function getCollectionByName(db, name) {
@@ -11515,7 +11520,7 @@ async function getCollectionByName(db, name) {
11515
11520
  };
11516
11521
  }
11517
11522
  console.log(`[getCollectionByName] Not in database, checking code collections`);
11518
- const codeCollections = await chunkKZIBF2EV_cjs.loadCollectionConfigs();
11523
+ const codeCollections = await chunkFAADMKJX_cjs.loadCollectionConfigs();
11519
11524
  const codeCollection = codeCollections.find((c) => c.name === name);
11520
11525
  if (codeCollection) {
11521
11526
  console.log(`[getCollectionByName] Found code collection: ${name}`);
@@ -11531,7 +11536,7 @@ async function getCollectionByName(db, name) {
11531
11536
  return null;
11532
11537
  }
11533
11538
  async function loadContentEditorFlags(db) {
11534
- const flags = { workflowEnabled: await chunkKMM45BTY_cjs.isPluginActive(db, "workflow") };
11539
+ const flags = { workflowEnabled: await chunkNOT5YX23_cjs.isPluginActive(db, "workflow") };
11535
11540
  const editors = [
11536
11541
  ["tinymce-plugin", "tinymce"],
11537
11542
  ["quill-editor", "quill"],
@@ -11539,10 +11544,10 @@ async function loadContentEditorFlags(db) {
11539
11544
  ["lexical-editor", "lexical"]
11540
11545
  ];
11541
11546
  for (const [plugin, key] of editors) {
11542
- const enabled = await chunkKMM45BTY_cjs.isPluginActive(db, plugin);
11547
+ const enabled = await chunkNOT5YX23_cjs.isPluginActive(db, plugin);
11543
11548
  flags[`${key}Enabled`] = enabled;
11544
11549
  if (enabled) {
11545
- const ps = new chunkKZIBF2EV_cjs.PluginService(db);
11550
+ const ps = new chunkFAADMKJX_cjs.PluginService(db);
11546
11551
  const p = await ps.getPlugin(plugin);
11547
11552
  flags[`${key}Settings`] = p?.settings;
11548
11553
  }
@@ -11550,7 +11555,7 @@ async function loadContentEditorFlags(db) {
11550
11555
  return flags;
11551
11556
  }
11552
11557
  function makeDocService(db, docType, tenantId) {
11553
- return new chunkW36OZTJ5_cjs.DocumentsService(db, {
11558
+ return new chunkLTZ5WYOK_cjs.DocumentsService(db, {
11554
11559
  queryableFields: docType.queryableFields ?? [],
11555
11560
  typeSchemaVersion: docType.schemaVersion ?? 1,
11556
11561
  maxVersionsPerRoot: docType.settings?.maxVersionsPerRoot ?? 50,
@@ -11578,9 +11583,9 @@ adminContentRoutes.get("/", async (c) => {
11578
11583
  const offset = (page - 1) * limit;
11579
11584
  const collectionsStmt = db.prepare("SELECT id, name, display_name FROM document_types WHERE is_active = 1 ORDER BY display_name");
11580
11585
  const { results: collectionsResults } = await collectionsStmt.all();
11581
- const codeCollections = await chunkKZIBF2EV_cjs.loadCollectionConfigs();
11586
+ const codeCollections = await chunkFAADMKJX_cjs.loadCollectionConfigs();
11582
11587
  const codeCollectionMap = new Map(codeCollections.map((c2) => [c2.name, c2]));
11583
- const docTypeRegistry = new chunkKMM45BTY_cjs.DocumentTypeRegistry(db);
11588
+ const docTypeRegistry = new chunkNOT5YX23_cjs.DocumentTypeRegistry(db);
11584
11589
  const docTypes = (await docTypeRegistry.findAll()).filter((dt) => !dt.settings?.internal && !dt.isAuth);
11585
11590
  const visibleTypeIds = new Set(docTypes.map((dt) => dt.id));
11586
11591
  const allCollections = [
@@ -11592,7 +11597,7 @@ adminContentRoutes.get("/", async (c) => {
11592
11597
  ...allCollections.map((c2) => ({ name: c2.name, displayName: c2.displayName })),
11593
11598
  ...docTypes.filter((dt) => !collectionNames.has(dt.id)).map((dt) => ({ name: `doc:${dt.id}`, displayName: dt.displayName }))
11594
11599
  ];
11595
- const newContentCollections = await chunkKZIBF2EV_cjs.getVisibleCollections(db);
11600
+ const newContentCollections = await chunkFAADMKJX_cjs.getVisibleCollections(db);
11596
11601
  const docBackedCollection = !modelName.startsWith("doc:") && modelName !== "all" ? docTypes.find((dt) => dt.id === modelName) : void 0;
11597
11602
  const isDocModel = modelName.startsWith("doc:") || !!docBackedCollection;
11598
11603
  if (isDocModel) {
@@ -11869,9 +11874,9 @@ adminContentRoutes.get("/new", async (c) => {
11869
11874
  const collectionsStmt = db2.prepare("SELECT id, name, display_name, description FROM document_types WHERE is_active = 1 ORDER BY display_name");
11870
11875
  const { results } = await collectionsStmt.all();
11871
11876
  const visibleTypeIds = new Set(
11872
- (await new chunkKMM45BTY_cjs.DocumentTypeRegistry(db2).findAll()).filter((dt) => !dt.settings?.internal && !dt.isAuth).map((dt) => dt.id)
11877
+ (await new chunkNOT5YX23_cjs.DocumentTypeRegistry(db2).findAll()).filter((dt) => !dt.settings?.internal && !dt.isAuth).map((dt) => dt.id)
11873
11878
  );
11874
- const codeCollections = await chunkKZIBF2EV_cjs.loadCollectionConfigs();
11879
+ const codeCollections = await chunkFAADMKJX_cjs.loadCollectionConfigs();
11875
11880
  const dbCollectionNames = new Set((results || []).map((r) => r.name));
11876
11881
  const allCollections = [
11877
11882
  ...codeCollections.filter((c2) => !dbCollectionNames.has(c2.name)).map((c2) => ({
@@ -11937,32 +11942,32 @@ adminContentRoutes.get("/new", async (c) => {
11937
11942
  return c.html(renderContentFormPage(formData2));
11938
11943
  }
11939
11944
  const fields = await getCollectionFields(db, collection.id);
11940
- const workflowEnabled = await chunkKMM45BTY_cjs.isPluginActive(db, "workflow");
11941
- const tinymceEnabled = await chunkKMM45BTY_cjs.isPluginActive(db, "tinymce-plugin");
11945
+ const workflowEnabled = await chunkNOT5YX23_cjs.isPluginActive(db, "workflow");
11946
+ const tinymceEnabled = await chunkNOT5YX23_cjs.isPluginActive(db, "tinymce-plugin");
11942
11947
  let tinymceSettings;
11943
11948
  if (tinymceEnabled) {
11944
- const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
11949
+ const pluginService = new chunkFAADMKJX_cjs.PluginService(db);
11945
11950
  const tinymcePlugin2 = await pluginService.getPlugin("tinymce-plugin");
11946
11951
  tinymceSettings = tinymcePlugin2?.settings;
11947
11952
  }
11948
- const quillEnabled = await chunkKMM45BTY_cjs.isPluginActive(db, "quill-editor");
11953
+ const quillEnabled = await chunkNOT5YX23_cjs.isPluginActive(db, "quill-editor");
11949
11954
  let quillSettings;
11950
11955
  if (quillEnabled) {
11951
- const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
11956
+ const pluginService = new chunkFAADMKJX_cjs.PluginService(db);
11952
11957
  const quillPlugin = await pluginService.getPlugin("quill-editor");
11953
11958
  quillSettings = quillPlugin?.settings;
11954
11959
  }
11955
- const mdxeditorEnabled = await chunkKMM45BTY_cjs.isPluginActive(db, "easy-mdx");
11960
+ const mdxeditorEnabled = await chunkNOT5YX23_cjs.isPluginActive(db, "easy-mdx");
11956
11961
  let mdxeditorSettings;
11957
11962
  if (mdxeditorEnabled) {
11958
- const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
11963
+ const pluginService = new chunkFAADMKJX_cjs.PluginService(db);
11959
11964
  const mdxeditorPlugin = await pluginService.getPlugin("easy-mdx");
11960
11965
  mdxeditorSettings = mdxeditorPlugin?.settings;
11961
11966
  }
11962
- const lexicalEnabled = await chunkKMM45BTY_cjs.isPluginActive(db, "lexical-editor");
11967
+ const lexicalEnabled = await chunkNOT5YX23_cjs.isPluginActive(db, "lexical-editor");
11963
11968
  let lexicalSettings;
11964
11969
  if (lexicalEnabled) {
11965
- const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
11970
+ const pluginService = new chunkFAADMKJX_cjs.PluginService(db);
11966
11971
  const lexicalPlugin = await pluginService.getPlugin("lexical-editor");
11967
11972
  lexicalSettings = lexicalPlugin?.settings;
11968
11973
  }
@@ -12053,7 +12058,7 @@ adminContentRoutes.get("/:id/edit", async (c) => {
12053
12058
  } : void 0
12054
12059
  };
12055
12060
  return c.html(renderContentFormPage(notFoundData));
12056
- const cache = chunk4BTBSXMR_cjs.getCacheService(chunk4BTBSXMR_cjs.CACHE_CONFIGS.content);
12061
+ const cache = chunk36Z3AKX3_cjs.getCacheService(chunk36Z3AKX3_cjs.CACHE_CONFIGS.content);
12057
12062
  const content = await cache.getOrSet(
12058
12063
  cache.generateKey("content", id),
12059
12064
  async () => {
@@ -12090,32 +12095,32 @@ adminContentRoutes.get("/:id/edit", async (c) => {
12090
12095
  };
12091
12096
  const fields = await getCollectionFields(db, content.collection_id);
12092
12097
  const contentData = content.data ? JSON.parse(content.data) : {};
12093
- const workflowEnabled = await chunkKMM45BTY_cjs.isPluginActive(db, "workflow");
12094
- const tinymceEnabled = await chunkKMM45BTY_cjs.isPluginActive(db, "tinymce-plugin");
12098
+ const workflowEnabled = await chunkNOT5YX23_cjs.isPluginActive(db, "workflow");
12099
+ const tinymceEnabled = await chunkNOT5YX23_cjs.isPluginActive(db, "tinymce-plugin");
12095
12100
  let tinymceSettings;
12096
12101
  if (tinymceEnabled) {
12097
- const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
12102
+ const pluginService = new chunkFAADMKJX_cjs.PluginService(db);
12098
12103
  const tinymcePlugin2 = await pluginService.getPlugin("tinymce-plugin");
12099
12104
  tinymceSettings = tinymcePlugin2?.settings;
12100
12105
  }
12101
- const quillEnabled = await chunkKMM45BTY_cjs.isPluginActive(db, "quill-editor");
12106
+ const quillEnabled = await chunkNOT5YX23_cjs.isPluginActive(db, "quill-editor");
12102
12107
  let quillSettings;
12103
12108
  if (quillEnabled) {
12104
- const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
12109
+ const pluginService = new chunkFAADMKJX_cjs.PluginService(db);
12105
12110
  const quillPlugin = await pluginService.getPlugin("quill-editor");
12106
12111
  quillSettings = quillPlugin?.settings;
12107
12112
  }
12108
- const mdxeditorEnabled = await chunkKMM45BTY_cjs.isPluginActive(db, "easy-mdx");
12113
+ const mdxeditorEnabled = await chunkNOT5YX23_cjs.isPluginActive(db, "easy-mdx");
12109
12114
  let mdxeditorSettings;
12110
12115
  if (mdxeditorEnabled) {
12111
- const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
12116
+ const pluginService = new chunkFAADMKJX_cjs.PluginService(db);
12112
12117
  const mdxeditorPlugin = await pluginService.getPlugin("easy-mdx");
12113
12118
  mdxeditorSettings = mdxeditorPlugin?.settings;
12114
12119
  }
12115
- const lexicalEnabled = await chunkKMM45BTY_cjs.isPluginActive(db, "lexical-editor");
12120
+ const lexicalEnabled = await chunkNOT5YX23_cjs.isPluginActive(db, "lexical-editor");
12116
12121
  let lexicalSettings;
12117
12122
  if (lexicalEnabled) {
12118
- const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
12123
+ const pluginService = new chunkFAADMKJX_cjs.PluginService(db);
12119
12124
  const lexicalPlugin = await pluginService.getPlugin("lexical-editor");
12120
12125
  lexicalSettings = lexicalPlugin?.settings;
12121
12126
  }
@@ -12236,7 +12241,7 @@ adminContentRoutes.post("/", async (c) => {
12236
12241
  data,
12237
12242
  publishOnCreate: status === "published"
12238
12243
  }), user?.userId);
12239
- const cache2 = chunk4BTBSXMR_cjs.getCacheService(chunk4BTBSXMR_cjs.CACHE_CONFIGS.content);
12244
+ const cache2 = chunk36Z3AKX3_cjs.getCacheService(chunk36Z3AKX3_cjs.CACHE_CONFIGS.content);
12240
12245
  await cache2.invalidate(`content:list:${collectionId}:*`);
12241
12246
  const redirectUrl2 = `/admin/content/${doc.rootId}/edit?success=Content created successfully!`;
12242
12247
  return c.req.header("HX-Request") === "true" ? c.text("", 200, { "HX-Redirect": redirectUrl2 }) : c.redirect(redirectUrl2);
@@ -12266,7 +12271,7 @@ adminContentRoutes.post("/", async (c) => {
12266
12271
  now,
12267
12272
  now
12268
12273
  ).run();
12269
- const cache = chunk4BTBSXMR_cjs.getCacheService(chunk4BTBSXMR_cjs.CACHE_CONFIGS.content);
12274
+ const cache = chunk36Z3AKX3_cjs.getCacheService(chunk36Z3AKX3_cjs.CACHE_CONFIGS.content);
12270
12275
  await cache.invalidate(`content:list:${collectionId}:*`);
12271
12276
  const versionStmt = db.prepare(`
12272
12277
  INSERT INTO content_versions (id, content_id, version, data, author_id, created_at)
@@ -12355,7 +12360,7 @@ adminContentRoutes.put("/:id", async (c) => {
12355
12360
  const pub = await db.prepare("SELECT id FROM documents WHERE root_id = ? AND is_published = 1 AND tenant_id = ?").bind(id, tenantId).first();
12356
12361
  if (status2 === "published") await svc.publish(newDraft.id, user?.userId);
12357
12362
  else if (pub) await svc.unpublish(pub.id);
12358
- await chunk4BTBSXMR_cjs.getCacheService(chunk4BTBSXMR_cjs.CACHE_CONFIGS.content).invalidate(`content:list:*`);
12363
+ await chunk36Z3AKX3_cjs.getCacheService(chunk36Z3AKX3_cjs.CACHE_CONFIGS.content).invalidate(`content:list:*`);
12359
12364
  const redirectUrl2 = `/admin/content/${id}/edit?success=Content updated successfully!`;
12360
12365
  return c.req.header("HX-Request") === "true" ? c.text("", 200, { "HX-Redirect": redirectUrl2 }) : c.redirect(redirectUrl2);
12361
12366
  }
@@ -12436,7 +12441,7 @@ adminContentRoutes.put("/:id", async (c) => {
12436
12441
  now,
12437
12442
  id
12438
12443
  ).run();
12439
- const cache = chunk4BTBSXMR_cjs.getCacheService(chunk4BTBSXMR_cjs.CACHE_CONFIGS.content);
12444
+ const cache = chunk36Z3AKX3_cjs.getCacheService(chunk36Z3AKX3_cjs.CACHE_CONFIGS.content);
12440
12445
  await cache.delete(cache.generateKey("content", id));
12441
12446
  await cache.invalidate(`content:list:${existingContent.collection_id}:*`);
12442
12447
  const existingData = JSON.parse(existingContent.data || "{}");
@@ -12488,7 +12493,7 @@ adminContentRoutes.put("/:id", async (c) => {
12488
12493
  `);
12489
12494
  }
12490
12495
  });
12491
- adminContentRoutes.post("/preview", chunkKMM45BTY_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
12496
+ adminContentRoutes.post("/preview", chunkNOT5YX23_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
12492
12497
  try {
12493
12498
  const formData = await c.req.formData();
12494
12499
  const collectionId = formData.get("collection_id");
@@ -12743,12 +12748,12 @@ adminContentRoutes.post("/bulk-action", async (c) => {
12743
12748
  }
12744
12749
  }
12745
12750
  }
12746
- const cache = chunk4BTBSXMR_cjs.getCacheService(chunk4BTBSXMR_cjs.CACHE_CONFIGS.content);
12751
+ const cache = chunk36Z3AKX3_cjs.getCacheService(chunk36Z3AKX3_cjs.CACHE_CONFIGS.content);
12747
12752
  for (const contentId of ids) {
12748
12753
  await cache.delete(cache.generateKey("content", contentId));
12749
12754
  }
12750
12755
  await cache.invalidate("content:list:*");
12751
- const apiCache = chunk4BTBSXMR_cjs.getCacheService(chunk4BTBSXMR_cjs.CACHE_CONFIGS.api);
12756
+ const apiCache = chunk36Z3AKX3_cjs.getCacheService(chunk36Z3AKX3_cjs.CACHE_CONFIGS.api);
12752
12757
  await apiCache.invalidate("content-filtered:*");
12753
12758
  await apiCache.invalidate("collection-content-filtered:*");
12754
12759
  return c.json({ success: true, count: ids.length });
@@ -12767,7 +12772,7 @@ adminContentRoutes.delete("/:id", async (c) => {
12767
12772
  if (docDel && await getDocBackingType(db, docDel.type_id)) {
12768
12773
  const now2 = Math.floor(Date.now() / 1e3);
12769
12774
  await db.prepare("UPDATE documents SET deleted_at = ?, updated_at = ? WHERE root_id = ? AND tenant_id = ?").bind(now2, now2, id, tenantId).run();
12770
- await chunk4BTBSXMR_cjs.getCacheService(chunk4BTBSXMR_cjs.CACHE_CONFIGS.content).invalidate("content:list:*");
12775
+ await chunk36Z3AKX3_cjs.getCacheService(chunk36Z3AKX3_cjs.CACHE_CONFIGS.content).invalidate("content:list:*");
12771
12776
  return c.html(`
12772
12777
  <div id="content-list" hx-get="/admin/content?model=${docDel.type_id}" hx-trigger="load" hx-swap="outerHTML">
12773
12778
  <div class="flex items-center justify-center p-8"><span class="text-zinc-500">Deleting\u2026</span></div>
@@ -12787,7 +12792,7 @@ adminContentRoutes.delete("/:id", async (c) => {
12787
12792
  WHERE id = ?
12788
12793
  `);
12789
12794
  await deleteStmt.bind(now, id).run();
12790
- const cache = chunk4BTBSXMR_cjs.getCacheService(chunk4BTBSXMR_cjs.CACHE_CONFIGS.content);
12795
+ const cache = chunk36Z3AKX3_cjs.getCacheService(chunk36Z3AKX3_cjs.CACHE_CONFIGS.content);
12791
12796
  await cache.delete(cache.generateKey("content", id));
12792
12797
  await cache.invalidate("content:list:*");
12793
12798
  return c.html(`
@@ -12807,7 +12812,7 @@ adminContentRoutes.delete("/:id", async (c) => {
12807
12812
  return c.json({ success: false, error: "Failed to delete content" }, 500);
12808
12813
  }
12809
12814
  });
12810
- adminContentRoutes.get("/:id/version/:version/preview", chunkKMM45BTY_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
12815
+ adminContentRoutes.get("/:id/version/:version/preview", chunkNOT5YX23_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
12811
12816
  try {
12812
12817
  const id = c.req.param("id");
12813
12818
  const version = parseInt(c.req.param("version") || "0");
@@ -12903,9 +12908,9 @@ function parseDocFormData(formData, queryableFields = []) {
12903
12908
  return { title, slug, data };
12904
12909
  }
12905
12910
  async function getDocService(db, typeId, tenantId) {
12906
- const registry = new chunkKMM45BTY_cjs.DocumentTypeRegistry(db);
12911
+ const registry = new chunkNOT5YX23_cjs.DocumentTypeRegistry(db);
12907
12912
  const docType = await registry.findById(typeId);
12908
- const svc = new chunkW36OZTJ5_cjs.DocumentsService(db, {
12913
+ const svc = new chunkLTZ5WYOK_cjs.DocumentsService(db, {
12909
12914
  queryableFields: docType?.queryableFields ?? [],
12910
12915
  typeSchemaVersion: docType?.schemaVersion ?? 1,
12911
12916
  maxVersionsPerRoot: docType?.settings?.maxVersionsPerRoot ?? 50,
@@ -12916,7 +12921,7 @@ async function getDocService(db, typeId, tenantId) {
12916
12921
  }
12917
12922
  adminContentRoutes.get("/documents/:typeId/new", async (c) => {
12918
12923
  const { typeId } = c.req.param();
12919
- const registry = new chunkKMM45BTY_cjs.DocumentTypeRegistry(c.env.DB);
12924
+ const registry = new chunkNOT5YX23_cjs.DocumentTypeRegistry(c.env.DB);
12920
12925
  const docType = await registry.findById(typeId);
12921
12926
  if (!docType) return c.html("<p>Unknown document type.</p>", 404);
12922
12927
  return c.html(chunkN32OWET6_cjs.renderDocumentFormPage({ docType, isEdit: false, user: userCtx(c) }));
@@ -12941,7 +12946,7 @@ adminContentRoutes.post("/documents/:typeId/new", async (c) => {
12941
12946
  }), user?.userId);
12942
12947
  return c.redirect(`/admin/content/documents/${typeId}/${doc.rootId}/edit?message=Created+successfully`);
12943
12948
  } catch (err) {
12944
- const registry = new chunkKMM45BTY_cjs.DocumentTypeRegistry(c.env.DB);
12949
+ const registry = new chunkNOT5YX23_cjs.DocumentTypeRegistry(c.env.DB);
12945
12950
  const docType = await registry.findById(typeId);
12946
12951
  if (!docType) return c.html("<p>Unknown document type.</p>", 404);
12947
12952
  return c.html(chunkN32OWET6_cjs.renderDocumentFormPage({ docType, isEdit: false, user: userCtx(c), message: err?.message ?? "Failed to create", messageType: "error" }));
@@ -12951,7 +12956,7 @@ adminContentRoutes.get("/documents/:typeId/:rootId/edit", async (c) => {
12951
12956
  const { typeId, rootId } = c.req.param();
12952
12957
  const db = c.env.DB;
12953
12958
  const message = c.req.query("message");
12954
- const registry = new chunkKMM45BTY_cjs.DocumentTypeRegistry(db);
12959
+ const registry = new chunkNOT5YX23_cjs.DocumentTypeRegistry(db);
12955
12960
  const docType = await registry.findById(typeId);
12956
12961
  if (!docType) return c.html("<p>Unknown document type.</p>", 404);
12957
12962
  const tenantId = reqTenant(c);
@@ -13064,7 +13069,7 @@ adminContentRoutes.get("/documents/:typeId/:rootId/versions", async (c) => {
13064
13069
  const { typeId, rootId } = c.req.param();
13065
13070
  const db = c.env.DB;
13066
13071
  const { renderVersionHistoryFragment } = await import('./admin-documents-form.template-LSZKGA5J.cjs');
13067
- const registry = new chunkKMM45BTY_cjs.DocumentTypeRegistry(db);
13072
+ const registry = new chunkNOT5YX23_cjs.DocumentTypeRegistry(db);
13068
13073
  const docType = await registry.findById(typeId);
13069
13074
  if (!docType) return c.html("<div>Unknown type.</div>", 404);
13070
13075
  const result = await db.prepare(
@@ -14936,6 +14941,7 @@ var TenantService = class {
14936
14941
  constructor(db) {
14937
14942
  this.db = db;
14938
14943
  }
14944
+ db;
14939
14945
  async listTenants() {
14940
14946
  const { results } = await this.db.prepare(`
14941
14947
  SELECT * FROM auth_tenant
@@ -14996,7 +15002,7 @@ var TenantService = class {
14996
15002
  SET name = ?, domain = ?, status = ?, notes = ?, updated_at = ?
14997
15003
  WHERE slug = ?
14998
15004
  `).bind(name, domain, status, notes, now, slug).run();
14999
- chunkKZIBF2EV_cjs.invalidateTenantCache();
15005
+ chunkFAADMKJX_cjs.invalidateTenantCache();
15000
15006
  const updated = await this.getTenantBySlug(slug);
15001
15007
  if (!updated) throw new Error("Tenant not found");
15002
15008
  return updated;
@@ -15014,7 +15020,7 @@ var TenantService = class {
15014
15020
  throw new Error(`Tenant '${slug}' still owns ${docCount} document(s). Delete or migrate its content first.`);
15015
15021
  }
15016
15022
  await this.db.prepare(`DELETE FROM auth_tenant WHERE slug = ?`).bind(slug).run();
15017
- chunkKZIBF2EV_cjs.invalidateTenantCache();
15023
+ chunkFAADMKJX_cjs.invalidateTenantCache();
15018
15024
  }
15019
15025
  // ─── Membership (auth_tenant_member) ───────────────────────────────────────
15020
15026
  // Tenant resolution and the admin switcher are gated on membership: an authed user may only
@@ -15258,7 +15264,7 @@ var TenantService = class {
15258
15264
  INSERT INTO auth_tenant (id, name, slug, status, domain, notes, metadata, created_at, updated_at)
15259
15265
  VALUES (?, ?, ?, 'active', ?, ?, '{}', ?, ?)
15260
15266
  `).bind(id, input.name, input.slug, input.domain, input.notes, now, now).run();
15261
- chunkKZIBF2EV_cjs.invalidateTenantCache();
15267
+ chunkFAADMKJX_cjs.invalidateTenantCache();
15262
15268
  const created = await this.getTenantBySlug(input.slug);
15263
15269
  if (!created) throw new Error("Failed to create tenant");
15264
15270
  return created;
@@ -15282,14 +15288,14 @@ function mapRowToTenant(row) {
15282
15288
 
15283
15289
  // src/routes/admin-users.ts
15284
15290
  var userRoutes = new hono.Hono();
15285
- userRoutes.use("*", chunkKMM45BTY_cjs.requireAuth());
15286
- userRoutes.use("/users/*", chunkKMM45BTY_cjs.requireRole(["admin"]));
15287
- userRoutes.use("/users", chunkKMM45BTY_cjs.requireRole(["admin"]));
15288
- userRoutes.use("/invite-user", chunkKMM45BTY_cjs.requireRole(["admin"]));
15289
- userRoutes.use("/resend-invitation/*", chunkKMM45BTY_cjs.requireRole(["admin"]));
15290
- userRoutes.use("/cancel-invitation/*", chunkKMM45BTY_cjs.requireRole(["admin"]));
15291
- userRoutes.use("/activity-logs", chunkKMM45BTY_cjs.requireRole(["admin"]));
15292
- userRoutes.use("/activity-logs/*", chunkKMM45BTY_cjs.requireRole(["admin"]));
15291
+ userRoutes.use("*", chunkNOT5YX23_cjs.requireAuth());
15292
+ userRoutes.use("/users/*", chunkNOT5YX23_cjs.requireRole(["admin"]));
15293
+ userRoutes.use("/users", chunkNOT5YX23_cjs.requireRole(["admin"]));
15294
+ userRoutes.use("/invite-user", chunkNOT5YX23_cjs.requireRole(["admin"]));
15295
+ userRoutes.use("/resend-invitation/*", chunkNOT5YX23_cjs.requireRole(["admin"]));
15296
+ userRoutes.use("/cancel-invitation/*", chunkNOT5YX23_cjs.requireRole(["admin"]));
15297
+ userRoutes.use("/activity-logs", chunkNOT5YX23_cjs.requireRole(["admin"]));
15298
+ userRoutes.use("/activity-logs/*", chunkNOT5YX23_cjs.requireRole(["admin"]));
15293
15299
  userRoutes.get("/", (c) => {
15294
15300
  return c.redirect("/admin/dashboard");
15295
15301
  });
@@ -15456,7 +15462,7 @@ userRoutes.put("/profile", async (c) => {
15456
15462
  }
15457
15463
  await saveCustomData(db, user.userId, sanitized);
15458
15464
  }
15459
- await chunkKMM45BTY_cjs.logActivity(
15465
+ await chunkNOT5YX23_cjs.logActivity(
15460
15466
  db,
15461
15467
  user.userId,
15462
15468
  "profile.update",
@@ -15519,7 +15525,7 @@ userRoutes.post("/profile/avatar", async (c) => {
15519
15525
  SELECT first_name, last_name FROM auth_user WHERE id = ?
15520
15526
  `);
15521
15527
  const userData = await userStmt.bind(user.userId).first();
15522
- await chunkKMM45BTY_cjs.logActivity(
15528
+ await chunkNOT5YX23_cjs.logActivity(
15523
15529
  db,
15524
15530
  user.userId,
15525
15531
  "profile.avatar_update",
@@ -15590,7 +15596,7 @@ userRoutes.post("/profile/password", async (c) => {
15590
15596
  dismissible: true
15591
15597
  }));
15592
15598
  }
15593
- const validPassword = await chunkKMM45BTY_cjs.AuthManager.verifyPassword(currentPassword, userData.password_hash);
15599
+ const validPassword = await chunkNOT5YX23_cjs.AuthManager.verifyPassword(currentPassword, userData.password_hash);
15594
15600
  if (!validPassword) {
15595
15601
  return c.html(chunkN32OWET6_cjs.renderAlert({
15596
15602
  type: "error",
@@ -15598,7 +15604,7 @@ userRoutes.post("/profile/password", async (c) => {
15598
15604
  dismissible: true
15599
15605
  }));
15600
15606
  }
15601
- const newPasswordHash = await chunkKMM45BTY_cjs.AuthManager.hashPassword(newPassword);
15607
+ const newPasswordHash = await chunkNOT5YX23_cjs.AuthManager.hashPassword(newPassword);
15602
15608
  const historyStmt = db.prepare(`
15603
15609
  INSERT INTO auth_password_history (id, user_id, password_hash, created_at)
15604
15610
  VALUES (?, ?, ?, ?)
@@ -15614,7 +15620,7 @@ userRoutes.post("/profile/password", async (c) => {
15614
15620
  WHERE id = ?
15615
15621
  `);
15616
15622
  await updateStmt.bind(newPasswordHash, Date.now(), user.userId).run();
15617
- await chunkKMM45BTY_cjs.logActivity(
15623
+ await chunkNOT5YX23_cjs.logActivity(
15618
15624
  db,
15619
15625
  user.userId,
15620
15626
  "profile.password_change",
@@ -15681,7 +15687,7 @@ userRoutes.get("/users", async (c) => {
15681
15687
  `);
15682
15688
  const countResult = await countStmt.bind(...params).first();
15683
15689
  const totalUsers = countResult?.total || 0;
15684
- await chunkKMM45BTY_cjs.logActivity(
15690
+ await chunkNOT5YX23_cjs.logActivity(
15685
15691
  db,
15686
15692
  user.userId,
15687
15693
  "users.list_view",
@@ -15862,7 +15868,7 @@ userRoutes.post("/users/new", async (c) => {
15862
15868
  dismissible: true
15863
15869
  }));
15864
15870
  }
15865
- const passwordHash = await chunkKMM45BTY_cjs.AuthManager.hashPassword(password);
15871
+ const passwordHash = await chunkNOT5YX23_cjs.AuthManager.hashPassword(password);
15866
15872
  const userId = crypto.randomUUID();
15867
15873
  const createStmt = db.prepare(`
15868
15874
  INSERT INTO auth_user (
@@ -15887,7 +15893,7 @@ userRoutes.post("/users/new", async (c) => {
15887
15893
  if (sanitizedRegistrationCustom !== null && Object.keys(sanitizedRegistrationCustom).length > 0) {
15888
15894
  await writeProfileData(db, userId, { custom: sanitizedRegistrationCustom }, user.userId);
15889
15895
  }
15890
- await chunkKMM45BTY_cjs.logActivity(
15896
+ await chunkNOT5YX23_cjs.logActivity(
15891
15897
  db,
15892
15898
  user.userId,
15893
15899
  "user!.create",
@@ -15926,7 +15932,7 @@ userRoutes.get("/users/:id", async (c) => {
15926
15932
  if (!userRecord) {
15927
15933
  return c.json({ error: "User not found" }, 404);
15928
15934
  }
15929
- await chunkKMM45BTY_cjs.logActivity(
15935
+ await chunkNOT5YX23_cjs.logActivity(
15930
15936
  db,
15931
15937
  user.userId,
15932
15938
  "user!.view",
@@ -16140,7 +16146,7 @@ userRoutes.put("/users/:id", async (c) => {
16140
16146
  userId
16141
16147
  ).run();
16142
16148
  if (newPassword) {
16143
- const passwordHash = await chunkKMM45BTY_cjs.AuthManager.hashPassword(newPassword);
16149
+ const passwordHash = await chunkNOT5YX23_cjs.AuthManager.hashPassword(newPassword);
16144
16150
  const updatePasswordStmt = db.prepare(`
16145
16151
  UPDATE auth_user SET password_hash = ?, updated_at = ? WHERE id = ?
16146
16152
  `);
@@ -16153,7 +16159,7 @@ userRoutes.put("/users/:id", async (c) => {
16153
16159
  ...sanitizedCustom !== null ? { custom: sanitizedCustom } : {}
16154
16160
  }, user.userId);
16155
16161
  }
16156
- await chunkKMM45BTY_cjs.logActivity(
16162
+ await chunkNOT5YX23_cjs.logActivity(
16157
16163
  db,
16158
16164
  user.userId,
16159
16165
  "user.update",
@@ -16199,7 +16205,7 @@ userRoutes.post("/users/:id/toggle", async (c) => {
16199
16205
  UPDATE auth_user SET is_active = ?, updated_at = ? WHERE id = ?
16200
16206
  `);
16201
16207
  await toggleStmt.bind(active ? 1 : 0, Date.now(), userId).run();
16202
- await chunkKMM45BTY_cjs.logActivity(
16208
+ await chunkNOT5YX23_cjs.logActivity(
16203
16209
  db,
16204
16210
  user.userId,
16205
16211
  active ? "user.activate" : "user.deactivate",
@@ -16240,7 +16246,7 @@ userRoutes.delete("/users/:id", async (c) => {
16240
16246
  DELETE FROM auth_user WHERE id = ?
16241
16247
  `);
16242
16248
  await deleteStmt.bind(userId).run();
16243
- await chunkKMM45BTY_cjs.logActivity(
16249
+ await chunkNOT5YX23_cjs.logActivity(
16244
16250
  db,
16245
16251
  user.userId,
16246
16252
  "user!.hard_delete",
@@ -16259,7 +16265,7 @@ userRoutes.delete("/users/:id", async (c) => {
16259
16265
  UPDATE auth_user SET is_active = 0, updated_at = ? WHERE id = ?
16260
16266
  `);
16261
16267
  await deleteStmt.bind(Date.now(), userId).run();
16262
- await chunkKMM45BTY_cjs.logActivity(
16268
+ await chunkNOT5YX23_cjs.logActivity(
16263
16269
  db,
16264
16270
  user.userId,
16265
16271
  "user!.soft_delete",
@@ -16325,7 +16331,7 @@ userRoutes.post("/invite-user", async (c) => {
16325
16331
  Date.now(),
16326
16332
  Date.now()
16327
16333
  ).run();
16328
- await chunkKMM45BTY_cjs.logActivity(
16334
+ await chunkNOT5YX23_cjs.logActivity(
16329
16335
  db,
16330
16336
  user.userId,
16331
16337
  "user!.invite_sent",
@@ -16382,7 +16388,7 @@ userRoutes.post("/resend-invitation/:id", async (c) => {
16382
16388
  Date.now(),
16383
16389
  userId
16384
16390
  ).run();
16385
- await chunkKMM45BTY_cjs.logActivity(
16391
+ await chunkNOT5YX23_cjs.logActivity(
16386
16392
  db,
16387
16393
  user.userId,
16388
16394
  "user!.invitation_resent",
@@ -16418,7 +16424,7 @@ userRoutes.delete("/cancel-invitation/:id", async (c) => {
16418
16424
  }
16419
16425
  const deleteStmt = db.prepare(`DELETE FROM auth_user WHERE id = ?`);
16420
16426
  await deleteStmt.bind(userId).run();
16421
- await chunkKMM45BTY_cjs.logActivity(
16427
+ await chunkNOT5YX23_cjs.logActivity(
16422
16428
  db,
16423
16429
  user.userId,
16424
16430
  "user!.invitation_cancelled",
@@ -17799,7 +17805,7 @@ var fileValidationSchema2 = zod.z.object({
17799
17805
  // 50MB max
17800
17806
  });
17801
17807
  var adminMediaRoutes = new hono.Hono();
17802
- adminMediaRoutes.use("*", chunkKMM45BTY_cjs.requireAuth());
17808
+ adminMediaRoutes.use("*", chunkNOT5YX23_cjs.requireAuth());
17803
17809
  adminMediaRoutes.get("/", async (c) => {
17804
17810
  try {
17805
17811
  const user = c.get("user");
@@ -17841,7 +17847,7 @@ adminMediaRoutes.get("/selector", async (c) => {
17841
17847
  const { searchParams } = new URL(c.req.url);
17842
17848
  const search = searchParams.get("search") || "";
17843
17849
  const db = c.env.DB;
17844
- const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
17850
+ const pluginService = new chunkFAADMKJX_cjs.PluginService(db);
17845
17851
  const mediaPlugin = await pluginService.getPlugin("core-media");
17846
17852
  if (!mediaPlugin || mediaPlugin.status !== "active") {
17847
17853
  return c.html(html.html`
@@ -18215,7 +18221,7 @@ adminMediaRoutes.put("/:id", async (c) => {
18215
18221
  `);
18216
18222
  }
18217
18223
  });
18218
- adminMediaRoutes.delete("/cleanup", chunkKMM45BTY_cjs.requireRole("admin"), async (c) => {
18224
+ adminMediaRoutes.delete("/cleanup", chunkNOT5YX23_cjs.requireRole("admin"), async (c) => {
18219
18225
  try {
18220
18226
  const db = c.env.DB;
18221
18227
  const allMediaStmt = db.prepare("SELECT id, r2_key, filename FROM media WHERE deleted_at IS NULL");
@@ -19335,7 +19341,7 @@ function escapeHtmlAttr(value) {
19335
19341
  function renderPluginSettingsPage(data) {
19336
19342
  const { plugin, activity = [], user } = data;
19337
19343
  const hasUserSettings = Object.keys(plugin.settings || {}).some((k) => !k.startsWith("_"));
19338
- const defaultTab = "info";
19344
+ const defaultTab = hasUserSettings ? "settings" : "info";
19339
19345
  const pageContent = `
19340
19346
  <div class="w-full px-4 sm:px-6 lg:px-8 py-6">
19341
19347
  <!-- Header with Back Button -->
@@ -19396,14 +19402,14 @@ function renderPluginSettingsPage(data) {
19396
19402
  <!-- Tabs -->
19397
19403
  <div class="mb-6">
19398
19404
  <nav class="flex space-x-8" aria-label="Tabs">
19399
- <a href="#info" onclick="showTab('info')" id="info-tab" class="tab-button border-b-2 border-transparent py-2 px-1 text-sm font-medium text-gray-400 hover:text-gray-300">
19400
- Information
19401
- </a>
19402
19405
  ${hasUserSettings ? `
19403
19406
  <a href="#settings" onclick="showTab('settings')" id="settings-tab" class="tab-button border-b-2 border-transparent py-2 px-1 text-sm font-medium text-gray-400 hover:text-gray-300">
19404
19407
  Settings
19405
19408
  </a>
19406
19409
  ` : ""}
19410
+ <a href="#info" onclick="showTab('info')" id="info-tab" class="tab-button border-b-2 border-transparent py-2 px-1 text-sm font-medium text-gray-400 hover:text-gray-300">
19411
+ Information
19412
+ </a>
19407
19413
  <a href="#activity" onclick="showTab('activity')" id="activity-tab" class="tab-button border-b-2 border-transparent py-2 px-1 text-sm font-medium text-gray-400 hover:text-gray-300">
19408
19414
  Activity Log
19409
19415
  </a>
@@ -20711,8 +20717,8 @@ defineUserProfile({
20711
20717
 
20712
20718
  // src/routes/admin-plugins.ts
20713
20719
  var adminPluginRoutes = new hono.Hono();
20714
- adminPluginRoutes.use("*", chunkKMM45BTY_cjs.requireAuth());
20715
- var AVAILABLE_PLUGINS = Object.values(chunkKZIBF2EV_cjs.PLUGIN_REGISTRY).map((p) => ({
20720
+ adminPluginRoutes.use("*", chunkNOT5YX23_cjs.requireAuth());
20721
+ var AVAILABLE_PLUGINS = Object.values(chunkFAADMKJX_cjs.PLUGIN_REGISTRY).map((p) => ({
20716
20722
  id: p.id,
20717
20723
  name: p.codeName,
20718
20724
  display_name: p.displayName,
@@ -20732,7 +20738,7 @@ adminPluginRoutes.get("/", async (c) => {
20732
20738
  if (user?.role !== "admin") {
20733
20739
  return c.text("Access denied", 403);
20734
20740
  }
20735
- const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
20741
+ const pluginService = new chunkFAADMKJX_cjs.PluginService(db);
20736
20742
  let installedPlugins = [];
20737
20743
  let stats = { total: 0, active: 0, inactive: 0, errors: 0, uninstalled: 0 };
20738
20744
  try {
@@ -20804,10 +20810,10 @@ adminPluginRoutes.get("/:id", async (c) => {
20804
20810
  if (user?.role !== "admin") {
20805
20811
  return c.redirect("/admin/plugins");
20806
20812
  }
20807
- const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
20813
+ const pluginService = new chunkFAADMKJX_cjs.PluginService(db);
20808
20814
  let plugin = await pluginService.getPlugin(pluginId);
20809
20815
  if (!plugin) {
20810
- const def = chunkKOXFYFOF_cjs.getPluginDefinition(pluginId);
20816
+ const def = chunkQSDN2CKI_cjs.getPluginDefinition(pluginId);
20811
20817
  if (!def) return c.text("Plugin not found", 404);
20812
20818
  plugin = await pluginService.ensurePlugin(pluginId, {
20813
20819
  displayName: def.displayName ?? pluginId,
@@ -20819,7 +20825,7 @@ adminPluginRoutes.get("/:id", async (c) => {
20819
20825
  const activity = await pluginService.getPluginActivity(pluginId, 20);
20820
20826
  let enrichedSettings = plugin.settings || {};
20821
20827
  if (pluginId === "otp-login") {
20822
- const settingsService = new chunk4BTBSXMR_cjs.SettingsService(db);
20828
+ const settingsService = new chunk36Z3AKX3_cjs.SettingsService(db);
20823
20829
  const generalSettings = await settingsService.getGeneralSettings();
20824
20830
  const siteName = generalSettings.siteName || "SonicJS";
20825
20831
  const emailPlugin = await db.prepare(`
@@ -20898,14 +20904,14 @@ adminPluginRoutes.get("/:id/configure", async (c) => {
20898
20904
  const user = c.get("user");
20899
20905
  const pluginId = c.req.param("id");
20900
20906
  if (user?.role !== "admin") return c.redirect("/admin/plugins");
20901
- const def = chunkKOXFYFOF_cjs.getPluginDefinition(pluginId);
20907
+ const def = chunkQSDN2CKI_cjs.getPluginDefinition(pluginId);
20902
20908
  if (!def?.configSchema) return c.text("No schema-driven settings for this plugin", 404);
20903
20909
  const db = c.env.DB;
20904
- const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
20910
+ const pluginService = new chunkFAADMKJX_cjs.PluginService(db);
20905
20911
  const plugin = await pluginService.getPlugin(pluginId);
20906
20912
  const stored = plugin?.settings ?? {};
20907
- const values = chunkKOXFYFOF_cjs.applySchemaDefaults(def.configSchema, stored);
20908
- const fieldsHtml = chunkKOXFYFOF_cjs.renderSchemaFields(def.configSchema, values);
20913
+ const values = chunkQSDN2CKI_cjs.applySchemaDefaults(def.configSchema, stored);
20914
+ const fieldsHtml = chunkQSDN2CKI_cjs.renderSchemaFields(def.configSchema, values);
20909
20915
  const displayName = plugin?.display_name ?? def.displayName ?? def.id;
20910
20916
  return c.html(`<!DOCTYPE html>
20911
20917
  <html lang="en"><head>
@@ -20932,12 +20938,12 @@ adminPluginRoutes.post("/:id/configure", async (c) => {
20932
20938
  const user = c.get("user");
20933
20939
  const pluginId = c.req.param("id");
20934
20940
  if (user?.role !== "admin") return c.json({ error: "Access denied" }, 403);
20935
- const def = chunkKOXFYFOF_cjs.getPluginDefinition(pluginId);
20941
+ const def = chunkQSDN2CKI_cjs.getPluginDefinition(pluginId);
20936
20942
  if (!def?.configSchema) return c.text("No schema-driven settings for this plugin", 404);
20937
20943
  const form = await c.req.formData();
20938
- const parsed = chunkKOXFYFOF_cjs.parseFormDataToSettings(def.configSchema, form);
20944
+ const parsed = chunkQSDN2CKI_cjs.parseFormDataToSettings(def.configSchema, form);
20939
20945
  const db = c.env.DB;
20940
- const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
20946
+ const pluginService = new chunkFAADMKJX_cjs.PluginService(db);
20941
20947
  await pluginService.ensurePlugin(pluginId, {
20942
20948
  displayName: def.displayName ?? pluginId,
20943
20949
  version: def.version,
@@ -20961,7 +20967,7 @@ adminPluginRoutes.post("/:id/activate", async (c) => {
20961
20967
  if (user?.role !== "admin") {
20962
20968
  return c.json({ error: "Access denied" }, 403);
20963
20969
  }
20964
- const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
20970
+ const pluginService = new chunkFAADMKJX_cjs.PluginService(db);
20965
20971
  await pluginService.activatePlugin(pluginId);
20966
20972
  return c.json({ success: true });
20967
20973
  } catch (error) {
@@ -20978,7 +20984,7 @@ adminPluginRoutes.post("/:id/deactivate", async (c) => {
20978
20984
  if (user?.role !== "admin") {
20979
20985
  return c.json({ error: "Access denied" }, 403);
20980
20986
  }
20981
- const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
20987
+ const pluginService = new chunkFAADMKJX_cjs.PluginService(db);
20982
20988
  await pluginService.deactivatePlugin(pluginId);
20983
20989
  return c.json({ success: true });
20984
20990
  } catch (error) {
@@ -20995,8 +21001,8 @@ adminPluginRoutes.post("/install", async (c) => {
20995
21001
  return c.json({ error: "Access denied" }, 403);
20996
21002
  }
20997
21003
  const body = await c.req.json();
20998
- const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
20999
- const registryEntry = chunkKZIBF2EV_cjs.findPluginByCodeName(body.name) || chunkKZIBF2EV_cjs.PLUGIN_REGISTRY[body.name] || chunkKZIBF2EV_cjs.PLUGIN_REGISTRY[body.id];
21004
+ const pluginService = new chunkFAADMKJX_cjs.PluginService(db);
21005
+ const registryEntry = chunkFAADMKJX_cjs.findPluginByCodeName(body.name) || chunkFAADMKJX_cjs.PLUGIN_REGISTRY[body.name] || chunkFAADMKJX_cjs.PLUGIN_REGISTRY[body.id];
21000
21006
  if (!registryEntry) {
21001
21007
  return c.json({ error: "Plugin not found in registry" }, 404);
21002
21008
  }
@@ -21029,7 +21035,7 @@ adminPluginRoutes.post("/:id/uninstall", async (c) => {
21029
21035
  if (user?.role !== "admin") {
21030
21036
  return c.json({ error: "Access denied" }, 403);
21031
21037
  }
21032
- const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
21038
+ const pluginService = new chunkFAADMKJX_cjs.PluginService(db);
21033
21039
  await pluginService.uninstallPlugin(pluginId);
21034
21040
  return c.json({ success: true });
21035
21041
  } catch (error) {
@@ -21047,7 +21053,7 @@ adminPluginRoutes.post("/:id/settings", async (c) => {
21047
21053
  return c.json({ error: "Access denied" }, 403);
21048
21054
  }
21049
21055
  const settings = await c.req.json();
21050
- const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
21056
+ const pluginService = new chunkFAADMKJX_cjs.PluginService(db);
21051
21057
  await pluginService.updatePluginSettings(pluginId, settings);
21052
21058
  if (pluginId === "core-auth") {
21053
21059
  try {
@@ -21855,11 +21861,11 @@ function renderLogConfigPage(data) {
21855
21861
 
21856
21862
  // src/routes/admin-logs.ts
21857
21863
  var adminLogsRoutes = new hono.Hono();
21858
- adminLogsRoutes.use("*", chunkKMM45BTY_cjs.requireAuth());
21864
+ adminLogsRoutes.use("*", chunkNOT5YX23_cjs.requireAuth());
21859
21865
  adminLogsRoutes.get("/", async (c) => {
21860
21866
  try {
21861
21867
  const user = c.get("user");
21862
- const logger = chunk4BTBSXMR_cjs.getLogger(c.env.DB);
21868
+ const logger = chunk36Z3AKX3_cjs.getLogger(c.env.DB);
21863
21869
  const query = c.req.query();
21864
21870
  const page = parseInt(query.page || "1");
21865
21871
  const limit = parseInt(query.limit || "50");
@@ -21939,7 +21945,7 @@ adminLogsRoutes.get("/:id", async (c) => {
21939
21945
  try {
21940
21946
  const id = c.req.param("id");
21941
21947
  const user = c.get("user");
21942
- const logger = chunk4BTBSXMR_cjs.getLogger(c.env.DB);
21948
+ const logger = chunk36Z3AKX3_cjs.getLogger(c.env.DB);
21943
21949
  const { logs } = await logger.getLogs({
21944
21950
  limit: 1,
21945
21951
  offset: 0,
@@ -21976,7 +21982,7 @@ adminLogsRoutes.get("/:id", async (c) => {
21976
21982
  adminLogsRoutes.get("/config", async (c) => {
21977
21983
  try {
21978
21984
  const user = c.get("user");
21979
- const logger = chunk4BTBSXMR_cjs.getLogger(c.env.DB);
21985
+ const logger = chunk36Z3AKX3_cjs.getLogger(c.env.DB);
21980
21986
  const configs = await logger.getAllConfigs();
21981
21987
  const pageData = {
21982
21988
  configs,
@@ -22000,7 +22006,7 @@ adminLogsRoutes.post("/config/:category", async (c) => {
22000
22006
  const level = formData.get("level");
22001
22007
  const retention = parseInt(formData.get("retention"));
22002
22008
  const maxSize = parseInt(formData.get("max_size"));
22003
- const logger = chunk4BTBSXMR_cjs.getLogger(c.env.DB);
22009
+ const logger = chunk36Z3AKX3_cjs.getLogger(c.env.DB);
22004
22010
  await logger.updateConfig(category, {
22005
22011
  enabled,
22006
22012
  level,
@@ -22029,7 +22035,7 @@ adminLogsRoutes.get("/export", async (c) => {
22029
22035
  const category = query.category;
22030
22036
  const startDate = query.start_date;
22031
22037
  const endDate = query.end_date;
22032
- const logger = chunk4BTBSXMR_cjs.getLogger(c.env.DB);
22038
+ const logger = chunk36Z3AKX3_cjs.getLogger(c.env.DB);
22033
22039
  const filter = {
22034
22040
  limit: 1e4,
22035
22041
  // Export up to 10k logs
@@ -22110,7 +22116,7 @@ adminLogsRoutes.post("/cleanup", async (c) => {
22110
22116
  error: "Unauthorized. Admin access required."
22111
22117
  }, 403);
22112
22118
  }
22113
- const logger = chunk4BTBSXMR_cjs.getLogger(c.env.DB);
22119
+ const logger = chunk36Z3AKX3_cjs.getLogger(c.env.DB);
22114
22120
  await logger.cleanupByRetention();
22115
22121
  return c.html(html.html`
22116
22122
  <div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded">
@@ -22132,7 +22138,7 @@ adminLogsRoutes.post("/search", async (c) => {
22132
22138
  const search = formData.get("search");
22133
22139
  const level = formData.get("level");
22134
22140
  const category = formData.get("category");
22135
- const logger = chunk4BTBSXMR_cjs.getLogger(c.env.DB);
22141
+ const logger = chunk36Z3AKX3_cjs.getLogger(c.env.DB);
22136
22142
  const filter = {
22137
22143
  limit: 20,
22138
22144
  offset: 0,
@@ -22847,9 +22853,9 @@ function renderStorageUsage(databaseSizeBytes, mediaSizeBytes) {
22847
22853
  }
22848
22854
 
22849
22855
  // src/routes/admin-dashboard.ts
22850
- var VERSION = chunk3XFA3E2F_cjs.getCoreVersion();
22856
+ var VERSION = chunkE6LGR24C_cjs.getCoreVersion();
22851
22857
  var router = new hono.Hono();
22852
- router.use("*", chunkKMM45BTY_cjs.requireAuth());
22858
+ router.use("*", chunkNOT5YX23_cjs.requireAuth());
22853
22859
  router.get("/", async (c) => {
22854
22860
  const user = c.get("user");
22855
22861
  try {
@@ -24814,7 +24820,7 @@ function renderCollectionFormPage(data) {
24814
24820
  // src/routes/admin-collections.ts
24815
24821
  chunkK623Q6WD_cjs.init_admin_layout_catalyst_template();
24816
24822
  var adminCollectionsRoutes = new hono.Hono();
24817
- adminCollectionsRoutes.use("*", chunkKMM45BTY_cjs.requireAuth());
24823
+ adminCollectionsRoutes.use("*", chunkNOT5YX23_cjs.requireAuth());
24818
24824
  adminCollectionsRoutes.get("/", async (c) => {
24819
24825
  try {
24820
24826
  const user = c.get("user");
@@ -24831,7 +24837,7 @@ adminCollectionsRoutes.get("/", async (c) => {
24831
24837
  results = queryResults.results ?? [];
24832
24838
  } catch (e) {
24833
24839
  }
24834
- const codeCollections = chunkKZIBF2EV_cjs.getCollectionRegistry().list();
24840
+ const codeCollections = chunkFAADMKJX_cjs.getCollectionRegistry().list();
24835
24841
  const codeCollectionsMap = new Map(
24836
24842
  codeCollections.map((cfg) => {
24837
24843
  const fieldCount = cfg.schema?.properties ? Object.keys(cfg.schema.properties).length : 0;
@@ -24845,7 +24851,7 @@ adminCollectionsRoutes.get("/", async (c) => {
24845
24851
  field_count: fieldCount,
24846
24852
  managed: cfg.managed !== false,
24847
24853
  source_type: "code",
24848
- internal: chunkKZIBF2EV_cjs.isCodeCollectionInternal(cfg),
24854
+ internal: chunkFAADMKJX_cjs.isCodeCollectionInternal(cfg),
24849
24855
  versioning: cfg.versioning === true
24850
24856
  }];
24851
24857
  })
@@ -24884,7 +24890,7 @@ adminCollectionsRoutes.get("/", async (c) => {
24884
24890
  field_count: fieldCount,
24885
24891
  managed: false,
24886
24892
  source_type: row.source === "code" || row.source === "system" || row.source === "plugin" ? "code" : "user",
24887
- internal: chunkKZIBF2EV_cjs.isDbDocTypeInternal(row.source),
24893
+ internal: chunkFAADMKJX_cjs.isDbDocTypeInternal(row.source),
24888
24894
  versioning: dbVersioning
24889
24895
  };
24890
24896
  });
@@ -25045,7 +25051,7 @@ export const myPlugin = definePlugin({
25045
25051
  title: "Add a Collection",
25046
25052
  pageTitle: "Add a Collection",
25047
25053
  currentPath: "/admin/collections",
25048
- version: chunk3XFA3E2F_cjs.getCoreVersion(),
25054
+ version: chunkE6LGR24C_cjs.getCoreVersion(),
25049
25055
  user: u ? { name: u.email ?? "Admin", email: u.email ?? "", role: u.role ?? "admin" } : void 0,
25050
25056
  content
25051
25057
  })
@@ -25062,7 +25068,7 @@ adminCollectionsRoutes.get("/:id", async (c) => {
25062
25068
  collection = await stmt.bind(id).first();
25063
25069
  } catch {
25064
25070
  }
25065
- const registryRecord = chunkKZIBF2EV_cjs.getCollectionRegistry().getById(id) ?? chunkKZIBF2EV_cjs.getCollectionRegistry().getByName(id);
25071
+ const registryRecord = chunkFAADMKJX_cjs.getCollectionRegistry().getById(id) ?? chunkFAADMKJX_cjs.getCollectionRegistry().getByName(id);
25066
25072
  if (!collection && !registryRecord) {
25067
25073
  const formData2 = {
25068
25074
  isEdit: true,
@@ -25109,9 +25115,9 @@ adminCollectionsRoutes.get("/:id", async (c) => {
25109
25115
  isCodeDriven = true;
25110
25116
  }
25111
25117
  const [tinymceActive, quillActive, mdxeditorActive] = await Promise.all([
25112
- chunkKMM45BTY_cjs.isPluginActive(db, "tinymce-plugin"),
25113
- chunkKMM45BTY_cjs.isPluginActive(db, "quill-editor"),
25114
- chunkKMM45BTY_cjs.isPluginActive(db, "easy-mdx")
25118
+ chunkNOT5YX23_cjs.isPluginActive(db, "tinymce-plugin"),
25119
+ chunkNOT5YX23_cjs.isPluginActive(db, "quill-editor"),
25120
+ chunkNOT5YX23_cjs.isPluginActive(db, "easy-mdx")
25115
25121
  ]);
25116
25122
  const displayName = collection?.display_name ?? registryRecord?.displayName ?? id;
25117
25123
  const formData = {
@@ -25131,9 +25137,9 @@ adminCollectionsRoutes.get("/:id", async (c) => {
25131
25137
  console.error("Error fetching collection:", error);
25132
25138
  const user = c.get("user");
25133
25139
  const [tinymceActive, quillActive, mdxeditorActive] = await Promise.all([
25134
- chunkKMM45BTY_cjs.isPluginActive(db, "tinymce-plugin"),
25135
- chunkKMM45BTY_cjs.isPluginActive(db, "quill-editor"),
25136
- chunkKMM45BTY_cjs.isPluginActive(db, "easy-mdx")
25140
+ chunkNOT5YX23_cjs.isPluginActive(db, "tinymce-plugin"),
25141
+ chunkNOT5YX23_cjs.isPluginActive(db, "quill-editor"),
25142
+ chunkNOT5YX23_cjs.isPluginActive(db, "easy-mdx")
25137
25143
  ]);
25138
25144
  const formData = {
25139
25145
  isEdit: true,
@@ -26082,7 +26088,7 @@ function renderDatabaseToolsSettings(settings) {
26082
26088
 
26083
26089
  // src/routes/admin-settings.ts
26084
26090
  var adminSettingsRoutes = new hono.Hono();
26085
- adminSettingsRoutes.use("*", chunkKMM45BTY_cjs.requireAuth());
26091
+ adminSettingsRoutes.use("*", chunkNOT5YX23_cjs.requireAuth());
26086
26092
  function getMockSettings(user) {
26087
26093
  return {
26088
26094
  general: {
@@ -26116,7 +26122,7 @@ adminSettingsRoutes.get("/", (c) => {
26116
26122
  adminSettingsRoutes.get("/general", async (c) => {
26117
26123
  const user = c.get("user");
26118
26124
  const db = c.env.DB;
26119
- const settingsService = new chunk4BTBSXMR_cjs.SettingsService(db);
26125
+ const settingsService = new chunk36Z3AKX3_cjs.SettingsService(db);
26120
26126
  const generalSettings = await settingsService.getGeneralSettings(user?.email);
26121
26127
  const mockSettings = getMockSettings(user);
26122
26128
  mockSettings.general = generalSettings;
@@ -26135,7 +26141,7 @@ adminSettingsRoutes.get("/general", async (c) => {
26135
26141
  adminSettingsRoutes.get("/security", async (c) => {
26136
26142
  const user = c.get("user");
26137
26143
  const db = c.env.DB;
26138
- const settingsService = new chunk4BTBSXMR_cjs.SettingsService(db);
26144
+ const settingsService = new chunk36Z3AKX3_cjs.SettingsService(db);
26139
26145
  const persisted = await settingsService.getSecuritySettings();
26140
26146
  const mockSettings = getMockSettings(user);
26141
26147
  mockSettings.security = {
@@ -26185,7 +26191,7 @@ adminSettingsRoutes.get("/database-tools", (c) => {
26185
26191
  adminSettingsRoutes.get("/api/migrations/status", async (c) => {
26186
26192
  try {
26187
26193
  const db = c.env.DB;
26188
- const migrationService = new chunkIA24HACT_cjs.MigrationService(db);
26194
+ const migrationService = new chunkETRNDMB2_cjs.MigrationService(db);
26189
26195
  const status = await migrationService.getMigrationStatus();
26190
26196
  return c.json({
26191
26197
  success: true,
@@ -26225,7 +26231,7 @@ adminSettingsRoutes.post("/api/migrations/run", async (c) => {
26225
26231
  adminSettingsRoutes.get("/api/migrations/validate", async (c) => {
26226
26232
  try {
26227
26233
  const db = c.env.DB;
26228
- const migrationService = new chunkIA24HACT_cjs.MigrationService(db);
26234
+ const migrationService = new chunkETRNDMB2_cjs.MigrationService(db);
26229
26235
  const validation = await migrationService.validateSchema();
26230
26236
  return c.json({
26231
26237
  success: true,
@@ -26394,7 +26400,7 @@ adminSettingsRoutes.post("/general", async (c) => {
26394
26400
  }
26395
26401
  const formData = await c.req.formData();
26396
26402
  const db = c.env.DB;
26397
- const settingsService = new chunk4BTBSXMR_cjs.SettingsService(db);
26403
+ const settingsService = new chunk36Z3AKX3_cjs.SettingsService(db);
26398
26404
  const settings = {
26399
26405
  siteName: formData.get("siteName"),
26400
26406
  siteDescription: formData.get("siteDescription"),
@@ -26440,7 +26446,7 @@ adminSettingsRoutes.post("/security", async (c) => {
26440
26446
  }
26441
26447
  const formData = await c.req.formData();
26442
26448
  const db = c.env.DB;
26443
- const settingsService = new chunk4BTBSXMR_cjs.SettingsService(db);
26449
+ const settingsService = new chunk36Z3AKX3_cjs.SettingsService(db);
26444
26450
  const jwtExpiresInRaw = formData.get("jwtExpiresIn")?.trim() || "";
26445
26451
  const graceRaw = formData.get("jwtRefreshGraceSeconds")?.trim() || "";
26446
26452
  if (!/^\d+(?:s|m|h|d)?$/i.test(jwtExpiresInRaw)) {
@@ -26624,7 +26630,7 @@ function renderAPIReferencePage(data) {
26624
26630
  >
26625
26631
  <option value="">All Categories</option>
26626
26632
  ${categories.map((category) => {
26627
- const info = chunk4BTBSXMR_cjs.CATEGORY_INFO[category];
26633
+ const info = chunk36Z3AKX3_cjs.CATEGORY_INFO[category];
26628
26634
  const title = info ? info.title : category;
26629
26635
  return `<option value="${category}">${title}</option>`;
26630
26636
  }).join("\n ")}
@@ -26641,7 +26647,7 @@ function renderAPIReferencePage(data) {
26641
26647
  <!-- API Categories -->
26642
26648
  <div class="space-y-6">
26643
26649
  ${Object.entries(endpointsByCategory).map(([category, endpoints]) => {
26644
- const info = chunk4BTBSXMR_cjs.CATEGORY_INFO[category] || { title: category, description: "", icon: "&#x1f4cb;" };
26650
+ const info = chunk36Z3AKX3_cjs.CATEGORY_INFO[category] || { title: category, description: "", icon: "&#x1f4cb;" };
26645
26651
  return `
26646
26652
  <div class="api-category" data-category="${category}">
26647
26653
  <div class="rounded-lg bg-white dark:bg-zinc-900 shadow-sm ring-1 ring-zinc-950/5 dark:ring-white/10 overflow-hidden">
@@ -26818,16 +26824,16 @@ function renderAPIReferencePage(data) {
26818
26824
  }
26819
26825
 
26820
26826
  // src/routes/admin-api-reference.ts
26821
- var VERSION2 = chunk3XFA3E2F_cjs.getCoreVersion();
26827
+ var VERSION2 = chunkE6LGR24C_cjs.getCoreVersion();
26822
26828
  var router2 = new hono.Hono();
26823
- router2.use("*", chunkKMM45BTY_cjs.requireAuth());
26829
+ router2.use("*", chunkNOT5YX23_cjs.requireAuth());
26824
26830
  router2.get("/", async (c) => {
26825
26831
  const user = c.get("user");
26826
26832
  try {
26827
- const app2 = chunk4BTBSXMR_cjs.getAppInstance();
26828
- const baseEndpoints = chunk4BTBSXMR_cjs.buildRouteList(app2);
26833
+ const app2 = chunk36Z3AKX3_cjs.getAppInstance();
26834
+ const baseEndpoints = chunk36Z3AKX3_cjs.buildRouteList(app2);
26829
26835
  const collectionRoutes = [];
26830
- const collections = chunkKZIBF2EV_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal);
26836
+ const collections = chunkFAADMKJX_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal);
26831
26837
  const methodOrder = { GET: 0, POST: 1, PUT: 2, PATCH: 3, DELETE: 4 };
26832
26838
  for (const col of collections) {
26833
26839
  const displayName = col.displayName || col.name;
@@ -26944,5 +26950,5 @@ exports.setVariablesCache = setVariablesCache;
26944
26950
  exports.test_cleanup_default = test_cleanup_default;
26945
26951
  exports.userProfilesPlugin = userProfilesPlugin;
26946
26952
  exports.userRoutes = userRoutes;
26947
- //# sourceMappingURL=chunk-SC2WZFNQ.cjs.map
26948
- //# sourceMappingURL=chunk-SC2WZFNQ.cjs.map
26953
+ //# sourceMappingURL=chunk-V6EZYAWF.cjs.map
26954
+ //# sourceMappingURL=chunk-V6EZYAWF.cjs.map