@sonicjs-cms/core 3.0.0-beta.19 → 3.0.0-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-JJ6HE4J4.cjs → chunk-3E7IROND.cjs} +202 -202
- package/dist/{chunk-JJ6HE4J4.cjs.map → chunk-3E7IROND.cjs.map} +1 -1
- package/dist/{chunk-SYAUCKSD.cjs → chunk-4SHNHNRP.cjs} +15 -15
- package/dist/{chunk-SYAUCKSD.cjs.map → chunk-4SHNHNRP.cjs.map} +1 -1
- package/dist/{chunk-2DSRS3VA.cjs → chunk-5ARIHAGN.cjs} +2 -2
- package/dist/{chunk-2DSRS3VA.cjs.map → chunk-5ARIHAGN.cjs.map} +1 -1
- package/dist/{chunk-EHTBXFTA.cjs → chunk-5RSB5SEK.cjs} +4 -4
- package/dist/{chunk-EHTBXFTA.cjs.map → chunk-5RSB5SEK.cjs.map} +1 -1
- package/dist/{chunk-LGZHS6WW.js → chunk-5UCMLBRQ.js} +9 -9
- package/dist/{chunk-LGZHS6WW.js.map → chunk-5UCMLBRQ.js.map} +1 -1
- package/dist/{chunk-NZF3THNY.cjs → chunk-AQJEMVAY.cjs} +3 -3
- package/dist/{chunk-NZF3THNY.cjs.map → chunk-AQJEMVAY.cjs.map} +1 -1
- package/dist/{chunk-52DAVKDM.js → chunk-DSXEVMOM.js} +2 -2
- package/dist/{chunk-52DAVKDM.js.map → chunk-DSXEVMOM.js.map} +1 -1
- package/dist/{chunk-YS5S47VV.cjs → chunk-DTGCXWWM.cjs} +10 -10
- package/dist/{chunk-YS5S47VV.cjs.map → chunk-DTGCXWWM.cjs.map} +1 -1
- package/dist/{chunk-PMEV7CWP.js → chunk-GMZ5TGYP.js} +3 -3
- package/dist/{chunk-PMEV7CWP.js.map → chunk-GMZ5TGYP.js.map} +1 -1
- package/dist/{chunk-64MTTVX2.js → chunk-MYQ7KZUQ.js} +4 -4
- package/dist/{chunk-64MTTVX2.js.map → chunk-MYQ7KZUQ.js.map} +1 -1
- package/dist/{chunk-L6IPQIWU.js → chunk-RDH6PUOP.js} +2 -2
- package/dist/{chunk-L6IPQIWU.js.map → chunk-RDH6PUOP.js.map} +1 -1
- package/dist/{chunk-IDMHRCZS.cjs → chunk-TQG5FNNR.cjs} +2 -2
- package/dist/{chunk-IDMHRCZS.cjs.map → chunk-TQG5FNNR.cjs.map} +1 -1
- package/dist/{chunk-OJHJ4I34.js → chunk-W53J3BJ2.js} +3 -3
- package/dist/{chunk-OJHJ4I34.js.map → chunk-W53J3BJ2.js.map} +1 -1
- package/dist/{chunk-HUDG4GS6.js → chunk-WCA4VENG.js} +5 -5
- package/dist/{chunk-HUDG4GS6.js.map → chunk-WCA4VENG.js.map} +1 -1
- package/dist/index.cjs +259 -259
- package/dist/index.js +13 -13
- package/dist/middleware.cjs +33 -33
- package/dist/middleware.js +4 -4
- package/dist/migrations-HZJ6U6SX.js +4 -0
- package/dist/{migrations-HUR2YY4Q.js.map → migrations-HZJ6U6SX.js.map} +1 -1
- package/dist/migrations-VQAFXMU7.cjs +13 -0
- package/dist/{migrations-RYH2MGG4.cjs.map → migrations-VQAFXMU7.cjs.map} +1 -1
- package/dist/plugins.cjs +40 -40
- package/dist/plugins.js +3 -3
- package/dist/routes.cjs +26 -26
- package/dist/routes.js +6 -6
- package/dist/services.cjs +18 -18
- package/dist/services.js +2 -2
- package/dist/utils.cjs +3 -3
- package/dist/utils.js +1 -1
- package/package.json +1 -1
- package/dist/migrations-HUR2YY4Q.js +0 -4
- package/dist/migrations-RYH2MGG4.cjs +0 -13
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
var chunkXWVDSM2L_cjs = require('./chunk-XWVDSM2L.cjs');
|
|
4
4
|
var chunkN32OWET6_cjs = require('./chunk-N32OWET6.cjs');
|
|
5
5
|
var chunk36Z3AKX3_cjs = require('./chunk-36Z3AKX3.cjs');
|
|
6
|
-
var
|
|
6
|
+
var chunk4SHNHNRP_cjs = require('./chunk-4SHNHNRP.cjs');
|
|
7
7
|
var chunkLTZ5WYOK_cjs = require('./chunk-LTZ5WYOK.cjs');
|
|
8
8
|
var chunkKIGVVO6N_cjs = require('./chunk-KIGVVO6N.cjs');
|
|
9
|
-
var
|
|
10
|
-
var
|
|
9
|
+
var chunk5ARIHAGN_cjs = require('./chunk-5ARIHAGN.cjs');
|
|
10
|
+
var chunkTQG5FNNR_cjs = require('./chunk-TQG5FNNR.cjs');
|
|
11
11
|
var chunkPXNTCCPE_cjs = require('./chunk-PXNTCCPE.cjs');
|
|
12
12
|
var chunkK623Q6WD_cjs = require('./chunk-K623Q6WD.cjs');
|
|
13
|
-
var
|
|
13
|
+
var chunk5RSB5SEK_cjs = require('./chunk-5RSB5SEK.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
|
|
17
|
+
var chunkAQJEMVAY_cjs = require('./chunk-AQJEMVAY.cjs');
|
|
18
18
|
var chunkMNWKYY5E_cjs = require('./chunk-MNWKYY5E.cjs');
|
|
19
19
|
var hono = require('hono');
|
|
20
20
|
var zod = require('zod');
|
|
@@ -259,7 +259,7 @@ function getDocumentRequestContext(c) {
|
|
|
259
259
|
|
|
260
260
|
// src/routes/api-documents.ts
|
|
261
261
|
async function aclAllowsRead(db, tenantId, principalSet, row, preloadedType) {
|
|
262
|
-
const docType = preloadedType ?? await new
|
|
262
|
+
const docType = preloadedType ?? await new chunk4SHNHNRP_cjs.DocumentTypeRegistry(db).findById(row.type_id);
|
|
263
263
|
if (!docType) return false;
|
|
264
264
|
return new DocumentRepository(db, tenantId).isAllowed(principalSet, row.root_id, "read", docType.settings);
|
|
265
265
|
}
|
|
@@ -277,7 +277,7 @@ apiDocumentsRoutes.get("/", async (c) => {
|
|
|
277
277
|
if (!typeId) {
|
|
278
278
|
return c.json({ error: "type query parameter is required" }, 400);
|
|
279
279
|
}
|
|
280
|
-
const registry = new
|
|
280
|
+
const registry = new chunk4SHNHNRP_cjs.DocumentTypeRegistry(db);
|
|
281
281
|
const docType = await registry.findById(typeId);
|
|
282
282
|
if (!docType || !docType.isActive) {
|
|
283
283
|
return c.json({ error: "Unknown document type" }, 400);
|
|
@@ -359,7 +359,7 @@ apiDocumentsRoutes.get("/root/:rootId", async (c) => {
|
|
|
359
359
|
AND (expires_at IS NULL OR expires_at > ?) LIMIT 1`
|
|
360
360
|
).bind(rootId, now, now).first();
|
|
361
361
|
if (!row) return c.json({ error: "Not found" }, 404);
|
|
362
|
-
const docType = await new
|
|
362
|
+
const docType = await new chunk4SHNHNRP_cjs.DocumentTypeRegistry(db).findById(row.type_id);
|
|
363
363
|
const effTenant = effectiveTenantForType(tenantId, docType?.settings);
|
|
364
364
|
if (row.tenant_id !== effTenant) return c.json({ error: "Not found" }, 404);
|
|
365
365
|
if (!await aclAllowsRead(db, effTenant, principalSet, row, docType)) {
|
|
@@ -395,7 +395,7 @@ apiDocumentsRoutes.get("/:id", async (c) => {
|
|
|
395
395
|
AND (expires_at IS NULL OR expires_at > ?) LIMIT 1`
|
|
396
396
|
).bind(id, now, now).first();
|
|
397
397
|
if (!row) return c.json({ error: "Not found" }, 404);
|
|
398
|
-
const docType = await new
|
|
398
|
+
const docType = await new chunk4SHNHNRP_cjs.DocumentTypeRegistry(db).findById(row.type_id);
|
|
399
399
|
const effTenant = effectiveTenantForType(tenantId, docType?.settings);
|
|
400
400
|
if (row.tenant_id !== effTenant) return c.json({ error: "Not found" }, 404);
|
|
401
401
|
if (!await aclAllowsRead(db, effTenant, principalSet, row, docType)) {
|
|
@@ -465,17 +465,17 @@ async function resolveDocScope(c, db, by, opts = {}) {
|
|
|
465
465
|
const draft = opts.currentDraftOnly ? " AND is_current_draft = 1" : "";
|
|
466
466
|
const row = await db.prepare(`SELECT type_id, root_id, tenant_id FROM documents WHERE ${col} = ?${draft} LIMIT 1`).bind(val).first();
|
|
467
467
|
if (!row) return null;
|
|
468
|
-
const docType = await new
|
|
468
|
+
const docType = await new chunk4SHNHNRP_cjs.DocumentTypeRegistry(db).findById(row.type_id);
|
|
469
469
|
const tenantId = effectiveTenantForType(getRequestTenant(c), docType?.settings);
|
|
470
470
|
if (row.tenant_id !== tenantId) return null;
|
|
471
471
|
return { typeId: row.type_id, rootId: row.root_id, tenantId, docType };
|
|
472
472
|
}
|
|
473
473
|
var adminDocumentsRoutes = new hono.Hono();
|
|
474
|
-
adminDocumentsRoutes.use("*",
|
|
475
|
-
adminDocumentsRoutes.use("*",
|
|
474
|
+
adminDocumentsRoutes.use("*", chunk4SHNHNRP_cjs.requireAuth());
|
|
475
|
+
adminDocumentsRoutes.use("*", chunk4SHNHNRP_cjs.requireRole(["admin", "editor"]));
|
|
476
476
|
adminDocumentsRoutes.get("/types", async (c) => {
|
|
477
477
|
try {
|
|
478
|
-
const registry = new
|
|
478
|
+
const registry = new chunk4SHNHNRP_cjs.DocumentTypeRegistry(c.env.DB);
|
|
479
479
|
const types = await registry.findAll();
|
|
480
480
|
return c.json({ data: types });
|
|
481
481
|
} catch (error) {
|
|
@@ -503,7 +503,7 @@ adminDocumentsRoutes.get("/", async (c) => {
|
|
|
503
503
|
if (!typeId) {
|
|
504
504
|
return c.json({ error: "type query parameter is required" }, 400);
|
|
505
505
|
}
|
|
506
|
-
const registry = new
|
|
506
|
+
const registry = new chunk4SHNHNRP_cjs.DocumentTypeRegistry(db);
|
|
507
507
|
const docType = await registry.findById(typeId);
|
|
508
508
|
if (!docType || !docType.isActive) {
|
|
509
509
|
return c.json({ error: "Unknown document type" }, 400);
|
|
@@ -614,7 +614,7 @@ adminDocumentsRoutes.post("/", async (c) => {
|
|
|
614
614
|
const input = validation.data;
|
|
615
615
|
const db = c.env.DB;
|
|
616
616
|
const user = c.get("user");
|
|
617
|
-
const registry = new
|
|
617
|
+
const registry = new chunk4SHNHNRP_cjs.DocumentTypeRegistry(db);
|
|
618
618
|
const docType = await registry.findById(input.typeId);
|
|
619
619
|
if (!docType || !docType.isActive) {
|
|
620
620
|
return c.json({ error: "Unknown document type" }, 400);
|
|
@@ -746,7 +746,7 @@ adminDocumentsRoutes.post("/types/:typeId/reindex", async (c) => {
|
|
|
746
746
|
try {
|
|
747
747
|
const { typeId } = c.req.param();
|
|
748
748
|
const db = c.env.DB;
|
|
749
|
-
const registry = new
|
|
749
|
+
const registry = new chunk4SHNHNRP_cjs.DocumentTypeRegistry(db);
|
|
750
750
|
const docType = await registry.findById(typeId);
|
|
751
751
|
if (!docType) return c.json({ error: "Unknown document type" }, 400);
|
|
752
752
|
const reindexTenant = effectiveTenantForType(getRequestTenant(c), docType.settings);
|
|
@@ -900,13 +900,13 @@ async function resolveContentVariables(contentData, db) {
|
|
|
900
900
|
// src/routes/api-content-crud.ts
|
|
901
901
|
var apiContentCrudRoutes = new hono.Hono();
|
|
902
902
|
async function resolveDocBacking(db, collectionIdOrName) {
|
|
903
|
-
const registry =
|
|
903
|
+
const registry = chunk5ARIHAGN_cjs.getCollectionRegistry();
|
|
904
904
|
const record = registry.getBySlugOrName(collectionIdOrName) ?? registry.getById(collectionIdOrName);
|
|
905
905
|
if (record) {
|
|
906
|
-
const docType2 = await new
|
|
906
|
+
const docType2 = await new chunk4SHNHNRP_cjs.DocumentTypeRegistry(db).findById(record.name);
|
|
907
907
|
return docType2 ? { coll: { id: record.id, name: record.name }, docType: docType2 } : null;
|
|
908
908
|
}
|
|
909
|
-
const docType = await new
|
|
909
|
+
const docType = await new chunk4SHNHNRP_cjs.DocumentTypeRegistry(db).findById(collectionIdOrName);
|
|
910
910
|
if (docType) {
|
|
911
911
|
return { coll: { id: collectionIdOrName, name: collectionIdOrName }, docType };
|
|
912
912
|
}
|
|
@@ -949,7 +949,7 @@ apiContentCrudRoutes.get("/check-slug", async (c) => {
|
|
|
949
949
|
}, 500);
|
|
950
950
|
}
|
|
951
951
|
});
|
|
952
|
-
apiContentCrudRoutes.get("/:id",
|
|
952
|
+
apiContentCrudRoutes.get("/:id", chunk4SHNHNRP_cjs.optionalAuth(), async (c) => {
|
|
953
953
|
try {
|
|
954
954
|
const id = c.req.param("id");
|
|
955
955
|
const db = c.env.DB;
|
|
@@ -959,7 +959,7 @@ apiContentCrudRoutes.get("/:id", chunkSYAUCKSD_cjs.optionalAuth(), async (c) =>
|
|
|
959
959
|
).bind(id, getRequestTenant(c)).first();
|
|
960
960
|
let transformedContent;
|
|
961
961
|
if (docRow) {
|
|
962
|
-
const coll =
|
|
962
|
+
const coll = chunk5ARIHAGN_cjs.getCollectionRegistry().getByName(docRow.type_id);
|
|
963
963
|
transformedContent = {
|
|
964
964
|
id: docRow.root_id,
|
|
965
965
|
title: docRow.title,
|
|
@@ -993,7 +993,7 @@ apiContentCrudRoutes.get("/:id", chunkSYAUCKSD_cjs.optionalAuth(), async (c) =>
|
|
|
993
993
|
}, 500);
|
|
994
994
|
}
|
|
995
995
|
});
|
|
996
|
-
apiContentCrudRoutes.post("/",
|
|
996
|
+
apiContentCrudRoutes.post("/", chunk4SHNHNRP_cjs.requireAuth(), chunk4SHNHNRP_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
997
997
|
try {
|
|
998
998
|
const db = c.env.DB;
|
|
999
999
|
const user = c.get("user");
|
|
@@ -1068,7 +1068,7 @@ apiContentCrudRoutes.post("/", chunkSYAUCKSD_cjs.requireAuth(), chunkSYAUCKSD_cj
|
|
|
1068
1068
|
}, 500);
|
|
1069
1069
|
}
|
|
1070
1070
|
});
|
|
1071
|
-
apiContentCrudRoutes.put("/:id",
|
|
1071
|
+
apiContentCrudRoutes.put("/:id", chunk4SHNHNRP_cjs.requireAuth(), chunk4SHNHNRP_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
1072
1072
|
try {
|
|
1073
1073
|
const id = c.req.param("id");
|
|
1074
1074
|
const db = c.env.DB;
|
|
@@ -1090,7 +1090,7 @@ apiContentCrudRoutes.put("/:id", chunkSYAUCKSD_cjs.requireAuth(), chunkSYAUCKSD_
|
|
|
1090
1090
|
} catch (err) {
|
|
1091
1091
|
return c.json({ error: "Write cancelled by plugin", details: String(err) }, 400);
|
|
1092
1092
|
}
|
|
1093
|
-
const docType = await new
|
|
1093
|
+
const docType = await new chunk4SHNHNRP_cjs.DocumentTypeRegistry(db).findById(docRow.type_id);
|
|
1094
1094
|
const svc = new chunkLTZ5WYOK_cjs.DocumentsService(db, {
|
|
1095
1095
|
queryableFields: docType?.queryableFields ?? [],
|
|
1096
1096
|
typeSchemaVersion: docType?.schemaVersion ?? 1,
|
|
@@ -1113,7 +1113,7 @@ apiContentCrudRoutes.put("/:id", chunkSYAUCKSD_cjs.requireAuth(), chunkSYAUCKSD_
|
|
|
1113
1113
|
const cache = chunk36Z3AKX3_cjs.getCacheService(chunk36Z3AKX3_cjs.CACHE_CONFIGS.api);
|
|
1114
1114
|
await cache.invalidate("content-filtered:*");
|
|
1115
1115
|
await cache.invalidate("collection-content-filtered:*");
|
|
1116
|
-
const coll =
|
|
1116
|
+
const coll = chunk5ARIHAGN_cjs.getCollectionRegistry().getByName(docRow.type_id);
|
|
1117
1117
|
const saved = await db.prepare("SELECT * FROM documents WHERE id = ?").bind(newDraft.id).first();
|
|
1118
1118
|
const savedData = saved?.data ? JSON.parse(saved.data) : {};
|
|
1119
1119
|
dispatchHookEvent(c, "content:after:update", { collection: docRow.type_id, id, data: savedData, user: actor }, "fire-and-forget");
|
|
@@ -1134,7 +1134,7 @@ apiContentCrudRoutes.put("/:id", chunkSYAUCKSD_cjs.requireAuth(), chunkSYAUCKSD_
|
|
|
1134
1134
|
}, 500);
|
|
1135
1135
|
}
|
|
1136
1136
|
});
|
|
1137
|
-
apiContentCrudRoutes.delete("/:id",
|
|
1137
|
+
apiContentCrudRoutes.delete("/:id", chunk4SHNHNRP_cjs.requireAuth(), chunk4SHNHNRP_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
1138
1138
|
try {
|
|
1139
1139
|
const id = c.req.param("id");
|
|
1140
1140
|
const db = c.env.DB;
|
|
@@ -1260,7 +1260,7 @@ apiRoutes.use("*", async (c, next) => {
|
|
|
1260
1260
|
c.header("X-Response-Time", `${totalTime}ms`);
|
|
1261
1261
|
});
|
|
1262
1262
|
apiRoutes.use("*", async (c, next) => {
|
|
1263
|
-
const cacheEnabled = await
|
|
1263
|
+
const cacheEnabled = await chunk4SHNHNRP_cjs.isPluginActive(c.env.DB, "core-cache");
|
|
1264
1264
|
c.set("cacheEnabled", cacheEnabled);
|
|
1265
1265
|
await next();
|
|
1266
1266
|
});
|
|
@@ -1283,7 +1283,7 @@ apiRoutes.get("/", (c) => {
|
|
|
1283
1283
|
openapi: "3.0.0",
|
|
1284
1284
|
info: {
|
|
1285
1285
|
title: "SonicJS AI API",
|
|
1286
|
-
version:
|
|
1286
|
+
version: chunkAQJEMVAY_cjs.getCoreVersion(),
|
|
1287
1287
|
description: "RESTful API for SonicJS headless CMS - a modern, AI-powered content management system built on Cloudflare Workers",
|
|
1288
1288
|
contact: {
|
|
1289
1289
|
name: "SonicJS Support",
|
|
@@ -1713,8 +1713,8 @@ apiRoutes.get("/collections", async (c) => {
|
|
|
1713
1713
|
}
|
|
1714
1714
|
c.header("X-Cache-Status", "MISS");
|
|
1715
1715
|
c.header("X-Cache-Source", "registry");
|
|
1716
|
-
const records =
|
|
1717
|
-
const transformedResults = records.map(
|
|
1716
|
+
const records = chunk5ARIHAGN_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal);
|
|
1717
|
+
const transformedResults = records.map(chunk5ARIHAGN_cjs.collectionRecordToRow);
|
|
1718
1718
|
const responseData = {
|
|
1719
1719
|
data: transformedResults,
|
|
1720
1720
|
meta: addTimingMeta(c, {
|
|
@@ -1735,7 +1735,7 @@ apiRoutes.get("/collections", async (c) => {
|
|
|
1735
1735
|
return c.json({ error: "Failed to fetch collections" }, 500);
|
|
1736
1736
|
}
|
|
1737
1737
|
});
|
|
1738
|
-
apiRoutes.get("/content",
|
|
1738
|
+
apiRoutes.get("/content", chunk4SHNHNRP_cjs.optionalAuth(), async (c) => {
|
|
1739
1739
|
const executionStart = Date.now();
|
|
1740
1740
|
try {
|
|
1741
1741
|
const db = c.env.DB;
|
|
@@ -1744,7 +1744,7 @@ apiRoutes.get("/content", chunkSYAUCKSD_cjs.optionalAuth(), async (c) => {
|
|
|
1744
1744
|
const collIdByName = /* @__PURE__ */ new Map();
|
|
1745
1745
|
let typeId;
|
|
1746
1746
|
let typeIds;
|
|
1747
|
-
const registry =
|
|
1747
|
+
const registry = chunk5ARIHAGN_cjs.getCollectionRegistry();
|
|
1748
1748
|
if (queryParams.collection) {
|
|
1749
1749
|
const collectionName = queryParams.collection;
|
|
1750
1750
|
const record = registry.getByName(collectionName);
|
|
@@ -1843,13 +1843,13 @@ apiRoutes.get("/content", chunkSYAUCKSD_cjs.optionalAuth(), async (c) => {
|
|
|
1843
1843
|
}, 500);
|
|
1844
1844
|
}
|
|
1845
1845
|
});
|
|
1846
|
-
apiRoutes.get("/collections/:collection/content",
|
|
1846
|
+
apiRoutes.get("/collections/:collection/content", chunk4SHNHNRP_cjs.optionalAuth(), async (c) => {
|
|
1847
1847
|
const executionStart = Date.now();
|
|
1848
1848
|
try {
|
|
1849
1849
|
const collection = c.req.param("collection");
|
|
1850
1850
|
const db = c.env.DB;
|
|
1851
1851
|
const queryParams = c.req.query();
|
|
1852
|
-
const record =
|
|
1852
|
+
const record = chunk5ARIHAGN_cjs.getCollectionRegistry().getBySlugOrName(collection);
|
|
1853
1853
|
if (!record || record.isActive === false) {
|
|
1854
1854
|
return c.json({ error: "Collection not found" }, 404);
|
|
1855
1855
|
}
|
|
@@ -1905,7 +1905,7 @@ apiRoutes.get("/collections/:collection/content", chunkSYAUCKSD_cjs.optionalAuth
|
|
|
1905
1905
|
const responseData = {
|
|
1906
1906
|
data: transformedResults,
|
|
1907
1907
|
meta: addTimingMeta(c, {
|
|
1908
|
-
...includeCollection ? { collection:
|
|
1908
|
+
...includeCollection ? { collection: chunk5ARIHAGN_cjs.collectionRecordToRow(record) } : {},
|
|
1909
1909
|
count: results.length,
|
|
1910
1910
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1911
1911
|
// D44: echo the caller's filter with the access policy applied (status=published forced for
|
|
@@ -1930,13 +1930,13 @@ apiRoutes.get("/collections/:collection/content", chunkSYAUCKSD_cjs.optionalAuth
|
|
|
1930
1930
|
}
|
|
1931
1931
|
});
|
|
1932
1932
|
apiRoutes.route("/content", api_content_crud_default);
|
|
1933
|
-
apiRoutes.get("/:collection",
|
|
1933
|
+
apiRoutes.get("/:collection", chunk4SHNHNRP_cjs.optionalAuth(), async (c) => {
|
|
1934
1934
|
const executionStart = Date.now();
|
|
1935
1935
|
try {
|
|
1936
1936
|
const collection = c.req.param("collection");
|
|
1937
1937
|
const db = c.env.DB;
|
|
1938
1938
|
const queryParams = c.req.query();
|
|
1939
|
-
const record =
|
|
1939
|
+
const record = chunk5ARIHAGN_cjs.getCollectionRegistry().getBySlugOrName(collection);
|
|
1940
1940
|
if (!record || record.isActive === false) {
|
|
1941
1941
|
return c.json({ error: "Collection not found" }, 404);
|
|
1942
1942
|
}
|
|
@@ -1976,7 +1976,7 @@ apiRoutes.get("/:collection", chunkSYAUCKSD_cjs.optionalAuth(), async (c) => {
|
|
|
1976
1976
|
const responseData = {
|
|
1977
1977
|
data: transformedResults,
|
|
1978
1978
|
meta: addTimingMeta(c, {
|
|
1979
|
-
...includeCollection ? { collection:
|
|
1979
|
+
...includeCollection ? { collection: chunk5ARIHAGN_cjs.collectionRecordToRow(record) } : {},
|
|
1980
1980
|
count: results.length,
|
|
1981
1981
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1982
1982
|
filter: normalizePublicContentFilter(filter, role),
|
|
@@ -1994,12 +1994,12 @@ apiRoutes.get("/:collection", chunkSYAUCKSD_cjs.optionalAuth(), async (c) => {
|
|
|
1994
1994
|
return c.json({ error: "Failed to fetch content", details: error instanceof Error ? error.message : String(error) }, 500);
|
|
1995
1995
|
}
|
|
1996
1996
|
});
|
|
1997
|
-
apiRoutes.get("/:collection/:id",
|
|
1997
|
+
apiRoutes.get("/:collection/:id", chunk4SHNHNRP_cjs.optionalAuth(), async (c) => {
|
|
1998
1998
|
try {
|
|
1999
1999
|
const collection = c.req.param("collection");
|
|
2000
2000
|
const id = c.req.param("id");
|
|
2001
2001
|
const db = c.env.DB;
|
|
2002
|
-
const record =
|
|
2002
|
+
const record = chunk5ARIHAGN_cjs.getCollectionRegistry().getBySlugOrName(collection);
|
|
2003
2003
|
if (!record || record.isActive === false) {
|
|
2004
2004
|
return c.json({ error: "Collection not found" }, 404);
|
|
2005
2005
|
}
|
|
@@ -2008,7 +2008,7 @@ apiRoutes.get("/:collection/:id", chunkSYAUCKSD_cjs.optionalAuth(), async (c) =>
|
|
|
2008
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"
|
|
2009
2009
|
).bind(id, record.name).first();
|
|
2010
2010
|
if (!docRow) return c.json({ error: "Content not found" }, 404);
|
|
2011
|
-
const coll =
|
|
2011
|
+
const coll = chunk5ARIHAGN_cjs.getCollectionRegistry().getByName(docRow.type_id);
|
|
2012
2012
|
const transformedContent = {
|
|
2013
2013
|
id: docRow.root_id,
|
|
2014
2014
|
title: docRow.title,
|
|
@@ -2026,7 +2026,7 @@ apiRoutes.get("/:collection/:id", chunkSYAUCKSD_cjs.optionalAuth(), async (c) =>
|
|
|
2026
2026
|
return c.json({ error: "Failed to fetch content", details: error instanceof Error ? error.message : String(error) }, 500);
|
|
2027
2027
|
}
|
|
2028
2028
|
});
|
|
2029
|
-
apiRoutes.post("/:collection",
|
|
2029
|
+
apiRoutes.post("/:collection", chunk4SHNHNRP_cjs.requireAuth(), chunk4SHNHNRP_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
2030
2030
|
try {
|
|
2031
2031
|
const collection = c.req.param("collection");
|
|
2032
2032
|
const db = c.env.DB;
|
|
@@ -2059,14 +2059,14 @@ apiRoutes.post("/:collection", chunkSYAUCKSD_cjs.requireAuth(), chunkSYAUCKSD_cj
|
|
|
2059
2059
|
return c.json({ error: "Failed to create content", details: error instanceof Error ? error.message : String(error) }, 500);
|
|
2060
2060
|
}
|
|
2061
2061
|
});
|
|
2062
|
-
apiRoutes.put("/:collection/:id",
|
|
2062
|
+
apiRoutes.put("/:collection/:id", chunk4SHNHNRP_cjs.requireAuth(), chunk4SHNHNRP_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
2063
2063
|
try {
|
|
2064
2064
|
const collection = c.req.param("collection");
|
|
2065
2065
|
const id = c.req.param("id");
|
|
2066
2066
|
const db = c.env.DB;
|
|
2067
2067
|
const user = c.get("user");
|
|
2068
2068
|
const body = await c.req.json();
|
|
2069
|
-
const collRecord =
|
|
2069
|
+
const collRecord = chunk5ARIHAGN_cjs.getCollectionRegistry().getBySlugOrName(collection);
|
|
2070
2070
|
const typeName = collRecord?.name ?? collection;
|
|
2071
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();
|
|
2072
2072
|
if (!docRow) return c.json({ error: "Content not found" }, 404);
|
|
@@ -2078,7 +2078,7 @@ apiRoutes.put("/:collection/:id", chunkSYAUCKSD_cjs.requireAuth(), chunkSYAUCKSD
|
|
|
2078
2078
|
} catch (err) {
|
|
2079
2079
|
return c.json({ error: "Write cancelled by plugin", details: String(err) }, 400);
|
|
2080
2080
|
}
|
|
2081
|
-
const docType = await new
|
|
2081
|
+
const docType = await new chunk4SHNHNRP_cjs.DocumentTypeRegistry(db).findById(docRow.type_id);
|
|
2082
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 });
|
|
2083
2083
|
const input = {};
|
|
2084
2084
|
if (body.title !== void 0) input.title = body.title;
|
|
@@ -2095,7 +2095,7 @@ apiRoutes.put("/:collection/:id", chunkSYAUCKSD_cjs.requireAuth(), chunkSYAUCKSD
|
|
|
2095
2095
|
const cache = chunk36Z3AKX3_cjs.getCacheService(chunk36Z3AKX3_cjs.CACHE_CONFIGS.api);
|
|
2096
2096
|
await cache.invalidate("content-filtered:*");
|
|
2097
2097
|
await cache.invalidate("collection-content-filtered:*");
|
|
2098
|
-
const coll =
|
|
2098
|
+
const coll = chunk5ARIHAGN_cjs.getCollectionRegistry().getByName(docRow.type_id);
|
|
2099
2099
|
const saved = await db.prepare("SELECT * FROM documents WHERE id = ?").bind(newDraft.id).first();
|
|
2100
2100
|
const savedData = saved?.data ? JSON.parse(saved.data) : {};
|
|
2101
2101
|
dispatchHookEvent(c, "content:after:update", { collection: docRow.type_id, id, data: savedData, user: actor }, "fire-and-forget");
|
|
@@ -2107,13 +2107,13 @@ apiRoutes.put("/:collection/:id", chunkSYAUCKSD_cjs.requireAuth(), chunkSYAUCKSD
|
|
|
2107
2107
|
return c.json({ error: "Failed to update content", details: error instanceof Error ? error.message : String(error) }, 500);
|
|
2108
2108
|
}
|
|
2109
2109
|
});
|
|
2110
|
-
apiRoutes.delete("/:collection/:id",
|
|
2110
|
+
apiRoutes.delete("/:collection/:id", chunk4SHNHNRP_cjs.requireAuth(), chunk4SHNHNRP_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
2111
2111
|
try {
|
|
2112
2112
|
const collection = c.req.param("collection");
|
|
2113
2113
|
const id = c.req.param("id");
|
|
2114
2114
|
const db = c.env.DB;
|
|
2115
2115
|
const user = c.get("user");
|
|
2116
|
-
const collRecord =
|
|
2116
|
+
const collRecord = chunk5ARIHAGN_cjs.getCollectionRegistry().getBySlugOrName(collection);
|
|
2117
2117
|
const typeName = collRecord?.name ?? collection;
|
|
2118
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();
|
|
2119
2119
|
if (!docRow) return c.json({ error: "Content not found" }, 404);
|
|
@@ -2330,7 +2330,7 @@ var fileValidationSchema = zod.z.object({
|
|
|
2330
2330
|
// 50MB max
|
|
2331
2331
|
});
|
|
2332
2332
|
var apiMediaRoutes = new hono.Hono();
|
|
2333
|
-
apiMediaRoutes.use("*",
|
|
2333
|
+
apiMediaRoutes.use("*", chunk4SHNHNRP_cjs.requireAuth());
|
|
2334
2334
|
apiMediaRoutes.post("/upload", async (c) => {
|
|
2335
2335
|
try {
|
|
2336
2336
|
const user = c.get("user");
|
|
@@ -3028,7 +3028,7 @@ apiSystemRoutes.get("/info", (c) => {
|
|
|
3028
3028
|
apiSystemRoutes.get("/stats", async (c) => {
|
|
3029
3029
|
try {
|
|
3030
3030
|
const db = c.env.DB;
|
|
3031
|
-
const typeIds =
|
|
3031
|
+
const typeIds = chunk5ARIHAGN_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal).map((r) => r.name);
|
|
3032
3032
|
let contentStats = null;
|
|
3033
3033
|
if (typeIds.length > 0) {
|
|
3034
3034
|
const placeholders = typeIds.map(() => "?").join(",");
|
|
@@ -3103,12 +3103,12 @@ apiSystemRoutes.get("/env", (c) => {
|
|
|
3103
3103
|
});
|
|
3104
3104
|
var api_system_default = apiSystemRoutes;
|
|
3105
3105
|
var adminApiRoutes = new hono.Hono();
|
|
3106
|
-
adminApiRoutes.use("*",
|
|
3107
|
-
adminApiRoutes.use("*",
|
|
3106
|
+
adminApiRoutes.use("*", chunk4SHNHNRP_cjs.requireAuth());
|
|
3107
|
+
adminApiRoutes.use("*", chunk4SHNHNRP_cjs.requireRole(["admin", "editor"]));
|
|
3108
3108
|
adminApiRoutes.get("/stats", async (c) => {
|
|
3109
3109
|
try {
|
|
3110
3110
|
const db = c.env.DB;
|
|
3111
|
-
const userCollections =
|
|
3111
|
+
const userCollections = chunk5ARIHAGN_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal);
|
|
3112
3112
|
const collectionsCount = userCollections.length;
|
|
3113
3113
|
let contentCount = 0;
|
|
3114
3114
|
if (userCollections.length > 0) {
|
|
@@ -3199,7 +3199,7 @@ adminApiRoutes.get("/collections", async (c) => {
|
|
|
3199
3199
|
try {
|
|
3200
3200
|
const search = c.req.query("search") || "";
|
|
3201
3201
|
const includeInactive = c.req.query("includeInactive") === "true";
|
|
3202
|
-
let records =
|
|
3202
|
+
let records = chunk5ARIHAGN_cjs.getCollectionRegistry().list().filter((r) => !r.internal);
|
|
3203
3203
|
if (!includeInactive) records = records.filter((r) => r.isActive !== false);
|
|
3204
3204
|
if (search) {
|
|
3205
3205
|
const needle = search.toLowerCase();
|
|
@@ -3231,7 +3231,7 @@ adminApiRoutes.get("/collections", async (c) => {
|
|
|
3231
3231
|
adminApiRoutes.get("/collections/:id", async (c) => {
|
|
3232
3232
|
try {
|
|
3233
3233
|
const id = c.req.param("id");
|
|
3234
|
-
const registry =
|
|
3234
|
+
const registry = chunk5ARIHAGN_cjs.getCollectionRegistry();
|
|
3235
3235
|
const record = registry.getById(id) ?? registry.getByName(id);
|
|
3236
3236
|
if (!record) {
|
|
3237
3237
|
return c.json({ error: "Collection not found" }, 404);
|
|
@@ -3281,7 +3281,7 @@ adminApiRoutes.get("/references", async (c) => {
|
|
|
3281
3281
|
if (collectionParams.length === 0) {
|
|
3282
3282
|
return c.json({ error: "Collection is required" }, 400);
|
|
3283
3283
|
}
|
|
3284
|
-
const registry =
|
|
3284
|
+
const registry = chunk5ARIHAGN_cjs.getCollectionRegistry();
|
|
3285
3285
|
const matched = collectionParams.map((param) => registry.getById(param) ?? registry.getByName(param)).filter((r) => !!r);
|
|
3286
3286
|
const seen = /* @__PURE__ */ new Set();
|
|
3287
3287
|
const collections = matched.filter((r) => {
|
|
@@ -3396,7 +3396,7 @@ adminApiRoutes.patch("/collections/:id", collectionsReadOnly);
|
|
|
3396
3396
|
adminApiRoutes.delete("/collections/:id", collectionsReadOnly);
|
|
3397
3397
|
adminApiRoutes.get("/migrations/status", async (c) => {
|
|
3398
3398
|
try {
|
|
3399
|
-
const { MigrationService: MigrationService2 } = await import('./migrations-
|
|
3399
|
+
const { MigrationService: MigrationService2 } = await import('./migrations-VQAFXMU7.cjs');
|
|
3400
3400
|
const db = c.env.DB;
|
|
3401
3401
|
const migrationService = new MigrationService2(db);
|
|
3402
3402
|
const status = await migrationService.getMigrationStatus();
|
|
@@ -3439,7 +3439,7 @@ adminApiRoutes.post("/migrations/run", async (c) => {
|
|
|
3439
3439
|
});
|
|
3440
3440
|
adminApiRoutes.get("/migrations/validate", async (c) => {
|
|
3441
3441
|
try {
|
|
3442
|
-
const { MigrationService: MigrationService2 } = await import('./migrations-
|
|
3442
|
+
const { MigrationService: MigrationService2 } = await import('./migrations-VQAFXMU7.cjs');
|
|
3443
3443
|
const db = c.env.DB;
|
|
3444
3444
|
const migrationService = new MigrationService2(db);
|
|
3445
3445
|
const validation = await migrationService.validateSchema();
|
|
@@ -3854,7 +3854,7 @@ function renderRegisterPage(data) {
|
|
|
3854
3854
|
}
|
|
3855
3855
|
|
|
3856
3856
|
// src/services/email/email-service-singleton.ts
|
|
3857
|
-
var singleton =
|
|
3857
|
+
var singleton = chunk5RSB5SEK_cjs.createServiceSingleton("EmailService");
|
|
3858
3858
|
function setEmailService(service2) {
|
|
3859
3859
|
singleton.set(service2);
|
|
3860
3860
|
}
|
|
@@ -4662,7 +4662,7 @@ function getLexicalInitScript(settings = {}) {
|
|
|
4662
4662
|
</script>
|
|
4663
4663
|
`;
|
|
4664
4664
|
}
|
|
4665
|
-
var lexicalEditorPlugin =
|
|
4665
|
+
var lexicalEditorPlugin = chunk5RSB5SEK_cjs.definePlugin({
|
|
4666
4666
|
id: "lexical-editor",
|
|
4667
4667
|
version: "1.0.0",
|
|
4668
4668
|
name: "Lexical Editor",
|
|
@@ -7068,7 +7068,7 @@ api.put("/:userId", async (c) => {
|
|
|
7068
7068
|
await saveCustomData(db, userId, sanitized);
|
|
7069
7069
|
return c.json({ success: true });
|
|
7070
7070
|
});
|
|
7071
|
-
var userProfilesPlugin =
|
|
7071
|
+
var userProfilesPlugin = chunk5RSB5SEK_cjs.definePlugin({
|
|
7072
7072
|
id: "user-profiles",
|
|
7073
7073
|
version: "1.0.0",
|
|
7074
7074
|
name: "User Profiles",
|
|
@@ -7106,8 +7106,8 @@ function renderPasswordResetEmail(resetLink, firstName) {
|
|
|
7106
7106
|
async function setCsrfCookie(c, maxAge) {
|
|
7107
7107
|
const secret = c.env?.JWT_SECRET || JWT_SECRET_FALLBACK;
|
|
7108
7108
|
const isDev = c.env?.ENVIRONMENT === "development" || !c.env?.ENVIRONMENT;
|
|
7109
|
-
const csrfToken = await
|
|
7110
|
-
const cookieMaxAge = await
|
|
7109
|
+
const csrfToken = await chunk4SHNHNRP_cjs.generateCsrfToken(secret);
|
|
7110
|
+
const cookieMaxAge = await chunk4SHNHNRP_cjs.getJwtExpirySecondsFromDb(c.env?.DB, c.env);
|
|
7111
7111
|
cookie.setCookie(c, "csrf_token", csrfToken, {
|
|
7112
7112
|
httpOnly: false,
|
|
7113
7113
|
secure: !isDev,
|
|
@@ -7166,7 +7166,7 @@ var loginSchema = zod.z.object({
|
|
|
7166
7166
|
});
|
|
7167
7167
|
authRoutes.post(
|
|
7168
7168
|
"/register",
|
|
7169
|
-
|
|
7169
|
+
chunk4SHNHNRP_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "register" }),
|
|
7170
7170
|
async (c) => {
|
|
7171
7171
|
try {
|
|
7172
7172
|
const db = c.env.DB;
|
|
@@ -7202,7 +7202,7 @@ authRoutes.post(
|
|
|
7202
7202
|
if (existingUser) {
|
|
7203
7203
|
return c.json({ error: "User with this email already exists" }, 400);
|
|
7204
7204
|
}
|
|
7205
|
-
const passwordHash = await
|
|
7205
|
+
const passwordHash = await chunk4SHNHNRP_cjs.AuthManager.hashPassword(password);
|
|
7206
7206
|
const userId = crypto.randomUUID();
|
|
7207
7207
|
const now = /* @__PURE__ */ new Date();
|
|
7208
7208
|
const nowSec = Math.floor(now.getTime() / 1e3);
|
|
@@ -7235,8 +7235,8 @@ authRoutes.post(
|
|
|
7235
7235
|
{ user: { id: userId, email: normalizedEmail, role: "viewer" } },
|
|
7236
7236
|
"fire-and-forget"
|
|
7237
7237
|
);
|
|
7238
|
-
const tokenTtl = await
|
|
7239
|
-
const token = await
|
|
7238
|
+
const tokenTtl = await chunk4SHNHNRP_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
|
|
7239
|
+
const token = await chunk4SHNHNRP_cjs.AuthManager.generateToken(userId, normalizedEmail, "viewer", c.env.JWT_SECRET, tokenTtl);
|
|
7240
7240
|
cookie.setCookie(c, "auth_token", token, {
|
|
7241
7241
|
httpOnly: true,
|
|
7242
7242
|
secure: true,
|
|
@@ -7268,7 +7268,7 @@ authRoutes.post(
|
|
|
7268
7268
|
);
|
|
7269
7269
|
authRoutes.post(
|
|
7270
7270
|
"/login",
|
|
7271
|
-
|
|
7271
|
+
chunk4SHNHNRP_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "login" }),
|
|
7272
7272
|
async (c) => {
|
|
7273
7273
|
try {
|
|
7274
7274
|
const body = await c.req.json();
|
|
@@ -7300,8 +7300,8 @@ authRoutes.post(
|
|
|
7300
7300
|
await setCsrfCookie(c);
|
|
7301
7301
|
const baBody = await baRes.json();
|
|
7302
7302
|
const user = baBody.user ?? {};
|
|
7303
|
-
const tokenTtl = await
|
|
7304
|
-
const token = await
|
|
7303
|
+
const tokenTtl = await chunk4SHNHNRP_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
|
|
7304
|
+
const token = await chunk4SHNHNRP_cjs.AuthManager.generateToken(
|
|
7305
7305
|
user.id,
|
|
7306
7306
|
user.email,
|
|
7307
7307
|
user.role ?? "viewer",
|
|
@@ -7362,7 +7362,7 @@ authRoutes.get("/logout", async (c) => {
|
|
|
7362
7362
|
clearCsrfCookie(c);
|
|
7363
7363
|
return c.redirect("/auth/login?message=You have been logged out successfully");
|
|
7364
7364
|
});
|
|
7365
|
-
authRoutes.get("/me",
|
|
7365
|
+
authRoutes.get("/me", chunk4SHNHNRP_cjs.requireAuth(), async (c) => {
|
|
7366
7366
|
try {
|
|
7367
7367
|
const user = c.get("user");
|
|
7368
7368
|
if (!user) {
|
|
@@ -7382,7 +7382,7 @@ authRoutes.get("/me", chunkSYAUCKSD_cjs.requireAuth(), async (c) => {
|
|
|
7382
7382
|
});
|
|
7383
7383
|
authRoutes.post(
|
|
7384
7384
|
"/refresh",
|
|
7385
|
-
|
|
7385
|
+
chunk4SHNHNRP_cjs.rateLimit({ max: 60, windowMs: 60 * 1e3, keyPrefix: "refresh" }),
|
|
7386
7386
|
async (c) => {
|
|
7387
7387
|
try {
|
|
7388
7388
|
let token = c.req.header("Authorization")?.replace("Bearer ", "");
|
|
@@ -7391,8 +7391,8 @@ authRoutes.post(
|
|
|
7391
7391
|
return c.json({ error: "Authentication required" }, 401);
|
|
7392
7392
|
}
|
|
7393
7393
|
const db = c.env.DB;
|
|
7394
|
-
const grace = await
|
|
7395
|
-
const payload = await
|
|
7394
|
+
const grace = await chunk4SHNHNRP_cjs.getJwtRefreshGraceSecondsFromDb(db, c.env);
|
|
7395
|
+
const payload = await chunk4SHNHNRP_cjs.AuthManager.verifyToken(token, c.env.JWT_SECRET, grace);
|
|
7396
7396
|
if (!payload) {
|
|
7397
7397
|
return c.json({ error: "Invalid or expired token" }, 401);
|
|
7398
7398
|
}
|
|
@@ -7400,8 +7400,8 @@ authRoutes.post(
|
|
|
7400
7400
|
if (!row || !row.is_active) {
|
|
7401
7401
|
return c.json({ error: "User is not active" }, 401);
|
|
7402
7402
|
}
|
|
7403
|
-
const tokenTtl = await
|
|
7404
|
-
const newToken = await
|
|
7403
|
+
const tokenTtl = await chunk4SHNHNRP_cjs.getJwtExpirySecondsFromDb(db, c.env);
|
|
7404
|
+
const newToken = await chunk4SHNHNRP_cjs.AuthManager.generateToken(row.id, row.email, row.role, c.env.JWT_SECRET, tokenTtl);
|
|
7405
7405
|
cookie.setCookie(c, "auth_token", newToken, {
|
|
7406
7406
|
httpOnly: true,
|
|
7407
7407
|
secure: true,
|
|
@@ -7421,7 +7421,7 @@ authRoutes.post(
|
|
|
7421
7421
|
);
|
|
7422
7422
|
authRoutes.post(
|
|
7423
7423
|
"/register/form",
|
|
7424
|
-
|
|
7424
|
+
chunk4SHNHNRP_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "register" }),
|
|
7425
7425
|
async (c) => {
|
|
7426
7426
|
try {
|
|
7427
7427
|
const db = c.env.DB;
|
|
@@ -7466,7 +7466,7 @@ authRoutes.post(
|
|
|
7466
7466
|
</div>
|
|
7467
7467
|
`);
|
|
7468
7468
|
}
|
|
7469
|
-
const passwordHash = await
|
|
7469
|
+
const passwordHash = await chunk4SHNHNRP_cjs.AuthManager.hashPassword(password);
|
|
7470
7470
|
const role = isFirstUser ? "admin" : "viewer";
|
|
7471
7471
|
const userId = crypto.randomUUID();
|
|
7472
7472
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -7508,8 +7508,8 @@ authRoutes.post(
|
|
|
7508
7508
|
{ user: { id: userId, email: normalizedEmail, role } },
|
|
7509
7509
|
"fire-and-forget"
|
|
7510
7510
|
);
|
|
7511
|
-
const tokenTtl = await
|
|
7512
|
-
const token = await
|
|
7511
|
+
const tokenTtl = await chunk4SHNHNRP_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
|
|
7512
|
+
const token = await chunk4SHNHNRP_cjs.AuthManager.generateToken(userId, normalizedEmail, role, c.env.JWT_SECRET, tokenTtl);
|
|
7513
7513
|
cookie.setCookie(c, "auth_token", token, {
|
|
7514
7514
|
httpOnly: true,
|
|
7515
7515
|
secure: false,
|
|
@@ -7541,7 +7541,7 @@ authRoutes.post(
|
|
|
7541
7541
|
);
|
|
7542
7542
|
authRoutes.post(
|
|
7543
7543
|
"/login/form",
|
|
7544
|
-
|
|
7544
|
+
chunk4SHNHNRP_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "login" }),
|
|
7545
7545
|
async (c) => {
|
|
7546
7546
|
try {
|
|
7547
7547
|
const formData = await c.req.formData();
|
|
@@ -7610,14 +7610,14 @@ authRoutes.post(
|
|
|
7610
7610
|
);
|
|
7611
7611
|
authRoutes.post(
|
|
7612
7612
|
"/seed-admin",
|
|
7613
|
-
|
|
7613
|
+
chunk4SHNHNRP_cjs.rateLimit({ max: 10, windowMs: 60 * 1e3, keyPrefix: "seed-admin" }),
|
|
7614
7614
|
async (c) => {
|
|
7615
7615
|
try {
|
|
7616
7616
|
const db = c.env.DB;
|
|
7617
7617
|
const rbac = new chunkLTZ5WYOK_cjs.RbacService(db);
|
|
7618
7618
|
const results = [];
|
|
7619
7619
|
const upsertSeedUser = async (opts) => {
|
|
7620
|
-
const passwordHash = await
|
|
7620
|
+
const passwordHash = await chunk4SHNHNRP_cjs.AuthManager.hashPassword(opts.password);
|
|
7621
7621
|
const nowMs = Date.now();
|
|
7622
7622
|
const nowSec = Math.floor(nowMs / 1e3);
|
|
7623
7623
|
const existing = await db.prepare("SELECT id FROM auth_user WHERE email = ?").bind(opts.email).first();
|
|
@@ -7842,7 +7842,7 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
7842
7842
|
if (invitationAge > maxAge) {
|
|
7843
7843
|
return c.json({ error: "Invitation has expired" }, 400);
|
|
7844
7844
|
}
|
|
7845
|
-
const passwordHash = await
|
|
7845
|
+
const passwordHash = await chunk4SHNHNRP_cjs.AuthManager.hashPassword(password);
|
|
7846
7846
|
const updateStmt = db.prepare(`
|
|
7847
7847
|
UPDATE auth_user SET
|
|
7848
7848
|
password_hash = ?,
|
|
@@ -7859,8 +7859,8 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
7859
7859
|
Date.now(),
|
|
7860
7860
|
invitedUser.id
|
|
7861
7861
|
).run();
|
|
7862
|
-
const tokenTtl = await
|
|
7863
|
-
const authToken = await
|
|
7862
|
+
const tokenTtl = await chunk4SHNHNRP_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
|
|
7863
|
+
const authToken = await chunk4SHNHNRP_cjs.AuthManager.generateToken(invitedUser.id, invitedUser.email, invitedUser.role, c.env.JWT_SECRET, tokenTtl);
|
|
7864
7864
|
cookie.setCookie(c, "auth_token", authToken, {
|
|
7865
7865
|
httpOnly: true,
|
|
7866
7866
|
secure: true,
|
|
@@ -7876,7 +7876,7 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
7876
7876
|
});
|
|
7877
7877
|
authRoutes.post(
|
|
7878
7878
|
"/request-password-reset",
|
|
7879
|
-
|
|
7879
|
+
chunk4SHNHNRP_cjs.rateLimit({ max: 3, windowMs: 15 * 60 * 1e3, keyPrefix: "password-reset" }),
|
|
7880
7880
|
async (c) => {
|
|
7881
7881
|
try {
|
|
7882
7882
|
const formData = await c.req.formData();
|
|
@@ -8113,7 +8113,7 @@ authRoutes.post("/reset-password", async (c) => {
|
|
|
8113
8113
|
if (Date.now() > user.password_reset_expires) {
|
|
8114
8114
|
return c.json({ error: "Reset token has expired" }, 400);
|
|
8115
8115
|
}
|
|
8116
|
-
const newPasswordHash = await
|
|
8116
|
+
const newPasswordHash = await chunk4SHNHNRP_cjs.AuthManager.hashPassword(password);
|
|
8117
8117
|
try {
|
|
8118
8118
|
const historyStmt = db.prepare(`
|
|
8119
8119
|
INSERT INTO auth_password_history (id, user_id, password_hash, created_at)
|
|
@@ -8327,7 +8327,7 @@ app.post("/test-seed-defaults", async (c) => {
|
|
|
8327
8327
|
var test_cleanup_default = app;
|
|
8328
8328
|
|
|
8329
8329
|
// src/plugins/available/easy-mdx/index.ts
|
|
8330
|
-
|
|
8330
|
+
chunk5RSB5SEK_cjs.definePlugin({
|
|
8331
8331
|
id: "easy-mdx",
|
|
8332
8332
|
version: "1.0.0",
|
|
8333
8333
|
name: "EasyMDE Markdown Editor",
|
|
@@ -8527,7 +8527,7 @@ function getMDXEditorInitScript(config) {
|
|
|
8527
8527
|
}
|
|
8528
8528
|
|
|
8529
8529
|
// src/plugins/available/tinymce-plugin/index.ts
|
|
8530
|
-
|
|
8530
|
+
chunk5RSB5SEK_cjs.definePlugin({
|
|
8531
8531
|
id: "tinymce-plugin",
|
|
8532
8532
|
version: "1.0.0",
|
|
8533
8533
|
name: "TinyMCE",
|
|
@@ -8797,7 +8797,7 @@ function getQuillCDN(version = "2.0.2") {
|
|
|
8797
8797
|
</style>
|
|
8798
8798
|
`;
|
|
8799
8799
|
}
|
|
8800
|
-
|
|
8800
|
+
chunk5RSB5SEK_cjs.definePlugin({
|
|
8801
8801
|
id: "quill-editor",
|
|
8802
8802
|
version: "1.0.0",
|
|
8803
8803
|
name: "Quill Editor",
|
|
@@ -11371,7 +11371,7 @@ function extractFieldData(fields, formData, options = {}) {
|
|
|
11371
11371
|
}
|
|
11372
11372
|
return { data, errors };
|
|
11373
11373
|
}
|
|
11374
|
-
adminContentRoutes.use("*",
|
|
11374
|
+
adminContentRoutes.use("*", chunk4SHNHNRP_cjs.requireAuth());
|
|
11375
11375
|
async function getCollectionFields(db, collectionId) {
|
|
11376
11376
|
console.log(`[getCollectionFields] Loading fields for collection: ${collectionId}`);
|
|
11377
11377
|
const collectionStmt = db.prepare("SELECT schema, queryable_fields FROM document_types WHERE id = ?");
|
|
@@ -11398,7 +11398,7 @@ async function getCollectionFields(db, collectionId) {
|
|
|
11398
11398
|
};
|
|
11399
11399
|
});
|
|
11400
11400
|
}
|
|
11401
|
-
const codeCollections2 = await
|
|
11401
|
+
const codeCollections2 = await chunk5ARIHAGN_cjs.loadCollectionConfigs();
|
|
11402
11402
|
const codeMatch = codeCollections2.find((c) => c.name === collectionId);
|
|
11403
11403
|
if (codeMatch && codeMatch.schema?.properties) {
|
|
11404
11404
|
console.log(`[getCollectionFields] DB doc type has no properties \u2014 using code collection schema`);
|
|
@@ -11430,7 +11430,7 @@ async function getCollectionFields(db, collectionId) {
|
|
|
11430
11430
|
}
|
|
11431
11431
|
}
|
|
11432
11432
|
console.log(`[getCollectionFields] Not in database, checking code collections`);
|
|
11433
|
-
const codeCollections = await
|
|
11433
|
+
const codeCollections = await chunk5ARIHAGN_cjs.loadCollectionConfigs();
|
|
11434
11434
|
console.log(`[getCollectionFields] Found ${codeCollections.length} code collections`);
|
|
11435
11435
|
const codeCollection = codeCollections.find((c) => c.name === collectionId);
|
|
11436
11436
|
if (codeCollection && codeCollection.schema) {
|
|
@@ -11484,7 +11484,7 @@ async function getCollection(db, collectionId) {
|
|
|
11484
11484
|
};
|
|
11485
11485
|
}
|
|
11486
11486
|
console.log(`[getCollection] Not in database, checking code collections`);
|
|
11487
|
-
const codeCollections = await
|
|
11487
|
+
const codeCollections = await chunk5ARIHAGN_cjs.loadCollectionConfigs();
|
|
11488
11488
|
const codeCollection = codeCollections.find((c) => c.name === collectionId);
|
|
11489
11489
|
if (codeCollection) {
|
|
11490
11490
|
console.log(`[getCollection] Found code collection: ${collectionId}`);
|
|
@@ -11503,7 +11503,7 @@ async function getCollection(db, collectionId) {
|
|
|
11503
11503
|
}
|
|
11504
11504
|
async function getDocBackingType(db, collectionName) {
|
|
11505
11505
|
if (!collectionName) return null;
|
|
11506
|
-
const dt = await new
|
|
11506
|
+
const dt = await new chunk4SHNHNRP_cjs.DocumentTypeRegistry(db).findById(collectionName);
|
|
11507
11507
|
return dt && dt.isActive ? dt : null;
|
|
11508
11508
|
}
|
|
11509
11509
|
async function getCollectionByName(db, name) {
|
|
@@ -11520,7 +11520,7 @@ async function getCollectionByName(db, name) {
|
|
|
11520
11520
|
};
|
|
11521
11521
|
}
|
|
11522
11522
|
console.log(`[getCollectionByName] Not in database, checking code collections`);
|
|
11523
|
-
const codeCollections = await
|
|
11523
|
+
const codeCollections = await chunk5ARIHAGN_cjs.loadCollectionConfigs();
|
|
11524
11524
|
const codeCollection = codeCollections.find((c) => c.name === name);
|
|
11525
11525
|
if (codeCollection) {
|
|
11526
11526
|
console.log(`[getCollectionByName] Found code collection: ${name}`);
|
|
@@ -11536,7 +11536,7 @@ async function getCollectionByName(db, name) {
|
|
|
11536
11536
|
return null;
|
|
11537
11537
|
}
|
|
11538
11538
|
async function loadContentEditorFlags(db) {
|
|
11539
|
-
const flags = { workflowEnabled: await
|
|
11539
|
+
const flags = { workflowEnabled: await chunk4SHNHNRP_cjs.isPluginActive(db, "workflow") };
|
|
11540
11540
|
const editors = [
|
|
11541
11541
|
["tinymce-plugin", "tinymce"],
|
|
11542
11542
|
["quill-editor", "quill"],
|
|
@@ -11544,10 +11544,10 @@ async function loadContentEditorFlags(db) {
|
|
|
11544
11544
|
["lexical-editor", "lexical"]
|
|
11545
11545
|
];
|
|
11546
11546
|
for (const [plugin, key] of editors) {
|
|
11547
|
-
const enabled = await
|
|
11547
|
+
const enabled = await chunk4SHNHNRP_cjs.isPluginActive(db, plugin);
|
|
11548
11548
|
flags[`${key}Enabled`] = enabled;
|
|
11549
11549
|
if (enabled) {
|
|
11550
|
-
const ps = new
|
|
11550
|
+
const ps = new chunk5ARIHAGN_cjs.PluginService(db);
|
|
11551
11551
|
const p = await ps.getPlugin(plugin);
|
|
11552
11552
|
flags[`${key}Settings`] = p?.settings;
|
|
11553
11553
|
}
|
|
@@ -11583,9 +11583,9 @@ adminContentRoutes.get("/", async (c) => {
|
|
|
11583
11583
|
const offset = (page - 1) * limit;
|
|
11584
11584
|
const collectionsStmt = db.prepare("SELECT id, name, display_name FROM document_types WHERE is_active = 1 ORDER BY display_name");
|
|
11585
11585
|
const { results: collectionsResults } = await collectionsStmt.all();
|
|
11586
|
-
const codeCollections = await
|
|
11586
|
+
const codeCollections = await chunk5ARIHAGN_cjs.loadCollectionConfigs();
|
|
11587
11587
|
const codeCollectionMap = new Map(codeCollections.map((c2) => [c2.name, c2]));
|
|
11588
|
-
const docTypeRegistry = new
|
|
11588
|
+
const docTypeRegistry = new chunk4SHNHNRP_cjs.DocumentTypeRegistry(db);
|
|
11589
11589
|
const docTypes = (await docTypeRegistry.findAll()).filter((dt) => !dt.settings?.internal && !dt.isAuth);
|
|
11590
11590
|
const visibleTypeIds = new Set(docTypes.map((dt) => dt.id));
|
|
11591
11591
|
const allCollections = [
|
|
@@ -11597,7 +11597,7 @@ adminContentRoutes.get("/", async (c) => {
|
|
|
11597
11597
|
...allCollections.map((c2) => ({ name: c2.name, displayName: c2.displayName })),
|
|
11598
11598
|
...docTypes.filter((dt) => !collectionNames.has(dt.id)).map((dt) => ({ name: `doc:${dt.id}`, displayName: dt.displayName }))
|
|
11599
11599
|
];
|
|
11600
|
-
const newContentCollections = await
|
|
11600
|
+
const newContentCollections = await chunk5ARIHAGN_cjs.getVisibleCollections(db);
|
|
11601
11601
|
const docBackedCollection = !modelName.startsWith("doc:") && modelName !== "all" ? docTypes.find((dt) => dt.id === modelName) : void 0;
|
|
11602
11602
|
const isDocModel = modelName.startsWith("doc:") || !!docBackedCollection;
|
|
11603
11603
|
if (isDocModel) {
|
|
@@ -11874,9 +11874,9 @@ adminContentRoutes.get("/new", async (c) => {
|
|
|
11874
11874
|
const collectionsStmt = db2.prepare("SELECT id, name, display_name, description FROM document_types WHERE is_active = 1 ORDER BY display_name");
|
|
11875
11875
|
const { results } = await collectionsStmt.all();
|
|
11876
11876
|
const visibleTypeIds = new Set(
|
|
11877
|
-
(await new
|
|
11877
|
+
(await new chunk4SHNHNRP_cjs.DocumentTypeRegistry(db2).findAll()).filter((dt) => !dt.settings?.internal && !dt.isAuth).map((dt) => dt.id)
|
|
11878
11878
|
);
|
|
11879
|
-
const codeCollections = await
|
|
11879
|
+
const codeCollections = await chunk5ARIHAGN_cjs.loadCollectionConfigs();
|
|
11880
11880
|
const dbCollectionNames = new Set((results || []).map((r) => r.name));
|
|
11881
11881
|
const allCollections = [
|
|
11882
11882
|
...codeCollections.filter((c2) => !dbCollectionNames.has(c2.name)).map((c2) => ({
|
|
@@ -11942,32 +11942,32 @@ adminContentRoutes.get("/new", async (c) => {
|
|
|
11942
11942
|
return c.html(renderContentFormPage(formData2));
|
|
11943
11943
|
}
|
|
11944
11944
|
const fields = await getCollectionFields(db, collection.id);
|
|
11945
|
-
const workflowEnabled = await
|
|
11946
|
-
const tinymceEnabled = await
|
|
11945
|
+
const workflowEnabled = await chunk4SHNHNRP_cjs.isPluginActive(db, "workflow");
|
|
11946
|
+
const tinymceEnabled = await chunk4SHNHNRP_cjs.isPluginActive(db, "tinymce-plugin");
|
|
11947
11947
|
let tinymceSettings;
|
|
11948
11948
|
if (tinymceEnabled) {
|
|
11949
|
-
const pluginService = new
|
|
11949
|
+
const pluginService = new chunk5ARIHAGN_cjs.PluginService(db);
|
|
11950
11950
|
const tinymcePlugin2 = await pluginService.getPlugin("tinymce-plugin");
|
|
11951
11951
|
tinymceSettings = tinymcePlugin2?.settings;
|
|
11952
11952
|
}
|
|
11953
|
-
const quillEnabled = await
|
|
11953
|
+
const quillEnabled = await chunk4SHNHNRP_cjs.isPluginActive(db, "quill-editor");
|
|
11954
11954
|
let quillSettings;
|
|
11955
11955
|
if (quillEnabled) {
|
|
11956
|
-
const pluginService = new
|
|
11956
|
+
const pluginService = new chunk5ARIHAGN_cjs.PluginService(db);
|
|
11957
11957
|
const quillPlugin = await pluginService.getPlugin("quill-editor");
|
|
11958
11958
|
quillSettings = quillPlugin?.settings;
|
|
11959
11959
|
}
|
|
11960
|
-
const mdxeditorEnabled = await
|
|
11960
|
+
const mdxeditorEnabled = await chunk4SHNHNRP_cjs.isPluginActive(db, "easy-mdx");
|
|
11961
11961
|
let mdxeditorSettings;
|
|
11962
11962
|
if (mdxeditorEnabled) {
|
|
11963
|
-
const pluginService = new
|
|
11963
|
+
const pluginService = new chunk5ARIHAGN_cjs.PluginService(db);
|
|
11964
11964
|
const mdxeditorPlugin = await pluginService.getPlugin("easy-mdx");
|
|
11965
11965
|
mdxeditorSettings = mdxeditorPlugin?.settings;
|
|
11966
11966
|
}
|
|
11967
|
-
const lexicalEnabled = await
|
|
11967
|
+
const lexicalEnabled = await chunk4SHNHNRP_cjs.isPluginActive(db, "lexical-editor");
|
|
11968
11968
|
let lexicalSettings;
|
|
11969
11969
|
if (lexicalEnabled) {
|
|
11970
|
-
const pluginService = new
|
|
11970
|
+
const pluginService = new chunk5ARIHAGN_cjs.PluginService(db);
|
|
11971
11971
|
const lexicalPlugin = await pluginService.getPlugin("lexical-editor");
|
|
11972
11972
|
lexicalSettings = lexicalPlugin?.settings;
|
|
11973
11973
|
}
|
|
@@ -12095,32 +12095,32 @@ adminContentRoutes.get("/:id/edit", async (c) => {
|
|
|
12095
12095
|
};
|
|
12096
12096
|
const fields = await getCollectionFields(db, content.collection_id);
|
|
12097
12097
|
const contentData = content.data ? JSON.parse(content.data) : {};
|
|
12098
|
-
const workflowEnabled = await
|
|
12099
|
-
const tinymceEnabled = await
|
|
12098
|
+
const workflowEnabled = await chunk4SHNHNRP_cjs.isPluginActive(db, "workflow");
|
|
12099
|
+
const tinymceEnabled = await chunk4SHNHNRP_cjs.isPluginActive(db, "tinymce-plugin");
|
|
12100
12100
|
let tinymceSettings;
|
|
12101
12101
|
if (tinymceEnabled) {
|
|
12102
|
-
const pluginService = new
|
|
12102
|
+
const pluginService = new chunk5ARIHAGN_cjs.PluginService(db);
|
|
12103
12103
|
const tinymcePlugin2 = await pluginService.getPlugin("tinymce-plugin");
|
|
12104
12104
|
tinymceSettings = tinymcePlugin2?.settings;
|
|
12105
12105
|
}
|
|
12106
|
-
const quillEnabled = await
|
|
12106
|
+
const quillEnabled = await chunk4SHNHNRP_cjs.isPluginActive(db, "quill-editor");
|
|
12107
12107
|
let quillSettings;
|
|
12108
12108
|
if (quillEnabled) {
|
|
12109
|
-
const pluginService = new
|
|
12109
|
+
const pluginService = new chunk5ARIHAGN_cjs.PluginService(db);
|
|
12110
12110
|
const quillPlugin = await pluginService.getPlugin("quill-editor");
|
|
12111
12111
|
quillSettings = quillPlugin?.settings;
|
|
12112
12112
|
}
|
|
12113
|
-
const mdxeditorEnabled = await
|
|
12113
|
+
const mdxeditorEnabled = await chunk4SHNHNRP_cjs.isPluginActive(db, "easy-mdx");
|
|
12114
12114
|
let mdxeditorSettings;
|
|
12115
12115
|
if (mdxeditorEnabled) {
|
|
12116
|
-
const pluginService = new
|
|
12116
|
+
const pluginService = new chunk5ARIHAGN_cjs.PluginService(db);
|
|
12117
12117
|
const mdxeditorPlugin = await pluginService.getPlugin("easy-mdx");
|
|
12118
12118
|
mdxeditorSettings = mdxeditorPlugin?.settings;
|
|
12119
12119
|
}
|
|
12120
|
-
const lexicalEnabled = await
|
|
12120
|
+
const lexicalEnabled = await chunk4SHNHNRP_cjs.isPluginActive(db, "lexical-editor");
|
|
12121
12121
|
let lexicalSettings;
|
|
12122
12122
|
if (lexicalEnabled) {
|
|
12123
|
-
const pluginService = new
|
|
12123
|
+
const pluginService = new chunk5ARIHAGN_cjs.PluginService(db);
|
|
12124
12124
|
const lexicalPlugin = await pluginService.getPlugin("lexical-editor");
|
|
12125
12125
|
lexicalSettings = lexicalPlugin?.settings;
|
|
12126
12126
|
}
|
|
@@ -12493,7 +12493,7 @@ adminContentRoutes.put("/:id", async (c) => {
|
|
|
12493
12493
|
`);
|
|
12494
12494
|
}
|
|
12495
12495
|
});
|
|
12496
|
-
adminContentRoutes.post("/preview",
|
|
12496
|
+
adminContentRoutes.post("/preview", chunk4SHNHNRP_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
12497
12497
|
try {
|
|
12498
12498
|
const formData = await c.req.formData();
|
|
12499
12499
|
const collectionId = formData.get("collection_id");
|
|
@@ -12812,7 +12812,7 @@ adminContentRoutes.delete("/:id", async (c) => {
|
|
|
12812
12812
|
return c.json({ success: false, error: "Failed to delete content" }, 500);
|
|
12813
12813
|
}
|
|
12814
12814
|
});
|
|
12815
|
-
adminContentRoutes.get("/:id/version/:version/preview",
|
|
12815
|
+
adminContentRoutes.get("/:id/version/:version/preview", chunk4SHNHNRP_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
12816
12816
|
try {
|
|
12817
12817
|
const id = c.req.param("id");
|
|
12818
12818
|
const version = parseInt(c.req.param("version") || "0");
|
|
@@ -12908,7 +12908,7 @@ function parseDocFormData(formData, queryableFields = []) {
|
|
|
12908
12908
|
return { title, slug, data };
|
|
12909
12909
|
}
|
|
12910
12910
|
async function getDocService(db, typeId, tenantId) {
|
|
12911
|
-
const registry = new
|
|
12911
|
+
const registry = new chunk4SHNHNRP_cjs.DocumentTypeRegistry(db);
|
|
12912
12912
|
const docType = await registry.findById(typeId);
|
|
12913
12913
|
const svc = new chunkLTZ5WYOK_cjs.DocumentsService(db, {
|
|
12914
12914
|
queryableFields: docType?.queryableFields ?? [],
|
|
@@ -12921,7 +12921,7 @@ async function getDocService(db, typeId, tenantId) {
|
|
|
12921
12921
|
}
|
|
12922
12922
|
adminContentRoutes.get("/documents/:typeId/new", async (c) => {
|
|
12923
12923
|
const { typeId } = c.req.param();
|
|
12924
|
-
const registry = new
|
|
12924
|
+
const registry = new chunk4SHNHNRP_cjs.DocumentTypeRegistry(c.env.DB);
|
|
12925
12925
|
const docType = await registry.findById(typeId);
|
|
12926
12926
|
if (!docType) return c.html("<p>Unknown document type.</p>", 404);
|
|
12927
12927
|
return c.html(chunkN32OWET6_cjs.renderDocumentFormPage({ docType, isEdit: false, user: userCtx(c) }));
|
|
@@ -12946,7 +12946,7 @@ adminContentRoutes.post("/documents/:typeId/new", async (c) => {
|
|
|
12946
12946
|
}), user?.userId);
|
|
12947
12947
|
return c.redirect(`/admin/content/documents/${typeId}/${doc.rootId}/edit?message=Created+successfully`);
|
|
12948
12948
|
} catch (err) {
|
|
12949
|
-
const registry = new
|
|
12949
|
+
const registry = new chunk4SHNHNRP_cjs.DocumentTypeRegistry(c.env.DB);
|
|
12950
12950
|
const docType = await registry.findById(typeId);
|
|
12951
12951
|
if (!docType) return c.html("<p>Unknown document type.</p>", 404);
|
|
12952
12952
|
return c.html(chunkN32OWET6_cjs.renderDocumentFormPage({ docType, isEdit: false, user: userCtx(c), message: err?.message ?? "Failed to create", messageType: "error" }));
|
|
@@ -12956,7 +12956,7 @@ adminContentRoutes.get("/documents/:typeId/:rootId/edit", async (c) => {
|
|
|
12956
12956
|
const { typeId, rootId } = c.req.param();
|
|
12957
12957
|
const db = c.env.DB;
|
|
12958
12958
|
const message = c.req.query("message");
|
|
12959
|
-
const registry = new
|
|
12959
|
+
const registry = new chunk4SHNHNRP_cjs.DocumentTypeRegistry(db);
|
|
12960
12960
|
const docType = await registry.findById(typeId);
|
|
12961
12961
|
if (!docType) return c.html("<p>Unknown document type.</p>", 404);
|
|
12962
12962
|
const tenantId = reqTenant(c);
|
|
@@ -13069,7 +13069,7 @@ adminContentRoutes.get("/documents/:typeId/:rootId/versions", async (c) => {
|
|
|
13069
13069
|
const { typeId, rootId } = c.req.param();
|
|
13070
13070
|
const db = c.env.DB;
|
|
13071
13071
|
const { renderVersionHistoryFragment } = await import('./admin-documents-form.template-LSZKGA5J.cjs');
|
|
13072
|
-
const registry = new
|
|
13072
|
+
const registry = new chunk4SHNHNRP_cjs.DocumentTypeRegistry(db);
|
|
13073
13073
|
const docType = await registry.findById(typeId);
|
|
13074
13074
|
if (!docType) return c.html("<div>Unknown type.</div>", 404);
|
|
13075
13075
|
const result = await db.prepare(
|
|
@@ -15002,7 +15002,7 @@ var TenantService = class {
|
|
|
15002
15002
|
SET name = ?, domain = ?, status = ?, notes = ?, updated_at = ?
|
|
15003
15003
|
WHERE slug = ?
|
|
15004
15004
|
`).bind(name, domain, status, notes, now, slug).run();
|
|
15005
|
-
|
|
15005
|
+
chunk5ARIHAGN_cjs.invalidateTenantCache();
|
|
15006
15006
|
const updated = await this.getTenantBySlug(slug);
|
|
15007
15007
|
if (!updated) throw new Error("Tenant not found");
|
|
15008
15008
|
return updated;
|
|
@@ -15020,7 +15020,7 @@ var TenantService = class {
|
|
|
15020
15020
|
throw new Error(`Tenant '${slug}' still owns ${docCount} document(s). Delete or migrate its content first.`);
|
|
15021
15021
|
}
|
|
15022
15022
|
await this.db.prepare(`DELETE FROM auth_tenant WHERE slug = ?`).bind(slug).run();
|
|
15023
|
-
|
|
15023
|
+
chunk5ARIHAGN_cjs.invalidateTenantCache();
|
|
15024
15024
|
}
|
|
15025
15025
|
// ─── Membership (auth_tenant_member) ───────────────────────────────────────
|
|
15026
15026
|
// Tenant resolution and the admin switcher are gated on membership: an authed user may only
|
|
@@ -15264,7 +15264,7 @@ var TenantService = class {
|
|
|
15264
15264
|
INSERT INTO auth_tenant (id, name, slug, status, domain, notes, metadata, created_at, updated_at)
|
|
15265
15265
|
VALUES (?, ?, ?, 'active', ?, ?, '{}', ?, ?)
|
|
15266
15266
|
`).bind(id, input.name, input.slug, input.domain, input.notes, now, now).run();
|
|
15267
|
-
|
|
15267
|
+
chunk5ARIHAGN_cjs.invalidateTenantCache();
|
|
15268
15268
|
const created = await this.getTenantBySlug(input.slug);
|
|
15269
15269
|
if (!created) throw new Error("Failed to create tenant");
|
|
15270
15270
|
return created;
|
|
@@ -15288,14 +15288,14 @@ function mapRowToTenant(row) {
|
|
|
15288
15288
|
|
|
15289
15289
|
// src/routes/admin-users.ts
|
|
15290
15290
|
var userRoutes = new hono.Hono();
|
|
15291
|
-
userRoutes.use("*",
|
|
15292
|
-
userRoutes.use("/users/*",
|
|
15293
|
-
userRoutes.use("/users",
|
|
15294
|
-
userRoutes.use("/invite-user",
|
|
15295
|
-
userRoutes.use("/resend-invitation/*",
|
|
15296
|
-
userRoutes.use("/cancel-invitation/*",
|
|
15297
|
-
userRoutes.use("/activity-logs",
|
|
15298
|
-
userRoutes.use("/activity-logs/*",
|
|
15291
|
+
userRoutes.use("*", chunk4SHNHNRP_cjs.requireAuth());
|
|
15292
|
+
userRoutes.use("/users/*", chunk4SHNHNRP_cjs.requireRole(["admin"]));
|
|
15293
|
+
userRoutes.use("/users", chunk4SHNHNRP_cjs.requireRole(["admin"]));
|
|
15294
|
+
userRoutes.use("/invite-user", chunk4SHNHNRP_cjs.requireRole(["admin"]));
|
|
15295
|
+
userRoutes.use("/resend-invitation/*", chunk4SHNHNRP_cjs.requireRole(["admin"]));
|
|
15296
|
+
userRoutes.use("/cancel-invitation/*", chunk4SHNHNRP_cjs.requireRole(["admin"]));
|
|
15297
|
+
userRoutes.use("/activity-logs", chunk4SHNHNRP_cjs.requireRole(["admin"]));
|
|
15298
|
+
userRoutes.use("/activity-logs/*", chunk4SHNHNRP_cjs.requireRole(["admin"]));
|
|
15299
15299
|
userRoutes.get("/", (c) => {
|
|
15300
15300
|
return c.redirect("/admin/dashboard");
|
|
15301
15301
|
});
|
|
@@ -15462,7 +15462,7 @@ userRoutes.put("/profile", async (c) => {
|
|
|
15462
15462
|
}
|
|
15463
15463
|
await saveCustomData(db, user.userId, sanitized);
|
|
15464
15464
|
}
|
|
15465
|
-
await
|
|
15465
|
+
await chunk4SHNHNRP_cjs.logActivity(
|
|
15466
15466
|
db,
|
|
15467
15467
|
user.userId,
|
|
15468
15468
|
"profile.update",
|
|
@@ -15525,7 +15525,7 @@ userRoutes.post("/profile/avatar", async (c) => {
|
|
|
15525
15525
|
SELECT first_name, last_name FROM auth_user WHERE id = ?
|
|
15526
15526
|
`);
|
|
15527
15527
|
const userData = await userStmt.bind(user.userId).first();
|
|
15528
|
-
await
|
|
15528
|
+
await chunk4SHNHNRP_cjs.logActivity(
|
|
15529
15529
|
db,
|
|
15530
15530
|
user.userId,
|
|
15531
15531
|
"profile.avatar_update",
|
|
@@ -15596,7 +15596,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
15596
15596
|
dismissible: true
|
|
15597
15597
|
}));
|
|
15598
15598
|
}
|
|
15599
|
-
const validPassword = await
|
|
15599
|
+
const validPassword = await chunk4SHNHNRP_cjs.AuthManager.verifyPassword(currentPassword, userData.password_hash);
|
|
15600
15600
|
if (!validPassword) {
|
|
15601
15601
|
return c.html(chunkN32OWET6_cjs.renderAlert({
|
|
15602
15602
|
type: "error",
|
|
@@ -15604,7 +15604,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
15604
15604
|
dismissible: true
|
|
15605
15605
|
}));
|
|
15606
15606
|
}
|
|
15607
|
-
const newPasswordHash = await
|
|
15607
|
+
const newPasswordHash = await chunk4SHNHNRP_cjs.AuthManager.hashPassword(newPassword);
|
|
15608
15608
|
const historyStmt = db.prepare(`
|
|
15609
15609
|
INSERT INTO auth_password_history (id, user_id, password_hash, created_at)
|
|
15610
15610
|
VALUES (?, ?, ?, ?)
|
|
@@ -15620,7 +15620,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
15620
15620
|
WHERE id = ?
|
|
15621
15621
|
`);
|
|
15622
15622
|
await updateStmt.bind(newPasswordHash, Date.now(), user.userId).run();
|
|
15623
|
-
await
|
|
15623
|
+
await chunk4SHNHNRP_cjs.logActivity(
|
|
15624
15624
|
db,
|
|
15625
15625
|
user.userId,
|
|
15626
15626
|
"profile.password_change",
|
|
@@ -15687,7 +15687,7 @@ userRoutes.get("/users", async (c) => {
|
|
|
15687
15687
|
`);
|
|
15688
15688
|
const countResult = await countStmt.bind(...params).first();
|
|
15689
15689
|
const totalUsers = countResult?.total || 0;
|
|
15690
|
-
await
|
|
15690
|
+
await chunk4SHNHNRP_cjs.logActivity(
|
|
15691
15691
|
db,
|
|
15692
15692
|
user.userId,
|
|
15693
15693
|
"users.list_view",
|
|
@@ -15868,7 +15868,7 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
15868
15868
|
dismissible: true
|
|
15869
15869
|
}));
|
|
15870
15870
|
}
|
|
15871
|
-
const passwordHash = await
|
|
15871
|
+
const passwordHash = await chunk4SHNHNRP_cjs.AuthManager.hashPassword(password);
|
|
15872
15872
|
const userId = crypto.randomUUID();
|
|
15873
15873
|
const createStmt = db.prepare(`
|
|
15874
15874
|
INSERT INTO auth_user (
|
|
@@ -15893,7 +15893,7 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
15893
15893
|
if (sanitizedRegistrationCustom !== null && Object.keys(sanitizedRegistrationCustom).length > 0) {
|
|
15894
15894
|
await writeProfileData(db, userId, { custom: sanitizedRegistrationCustom }, user.userId);
|
|
15895
15895
|
}
|
|
15896
|
-
await
|
|
15896
|
+
await chunk4SHNHNRP_cjs.logActivity(
|
|
15897
15897
|
db,
|
|
15898
15898
|
user.userId,
|
|
15899
15899
|
"user!.create",
|
|
@@ -15932,7 +15932,7 @@ userRoutes.get("/users/:id", async (c) => {
|
|
|
15932
15932
|
if (!userRecord) {
|
|
15933
15933
|
return c.json({ error: "User not found" }, 404);
|
|
15934
15934
|
}
|
|
15935
|
-
await
|
|
15935
|
+
await chunk4SHNHNRP_cjs.logActivity(
|
|
15936
15936
|
db,
|
|
15937
15937
|
user.userId,
|
|
15938
15938
|
"user!.view",
|
|
@@ -16146,7 +16146,7 @@ userRoutes.put("/users/:id", async (c) => {
|
|
|
16146
16146
|
userId
|
|
16147
16147
|
).run();
|
|
16148
16148
|
if (newPassword) {
|
|
16149
|
-
const passwordHash = await
|
|
16149
|
+
const passwordHash = await chunk4SHNHNRP_cjs.AuthManager.hashPassword(newPassword);
|
|
16150
16150
|
const updatePasswordStmt = db.prepare(`
|
|
16151
16151
|
UPDATE auth_user SET password_hash = ?, updated_at = ? WHERE id = ?
|
|
16152
16152
|
`);
|
|
@@ -16159,7 +16159,7 @@ userRoutes.put("/users/:id", async (c) => {
|
|
|
16159
16159
|
...sanitizedCustom !== null ? { custom: sanitizedCustom } : {}
|
|
16160
16160
|
}, user.userId);
|
|
16161
16161
|
}
|
|
16162
|
-
await
|
|
16162
|
+
await chunk4SHNHNRP_cjs.logActivity(
|
|
16163
16163
|
db,
|
|
16164
16164
|
user.userId,
|
|
16165
16165
|
"user.update",
|
|
@@ -16205,7 +16205,7 @@ userRoutes.post("/users/:id/toggle", async (c) => {
|
|
|
16205
16205
|
UPDATE auth_user SET is_active = ?, updated_at = ? WHERE id = ?
|
|
16206
16206
|
`);
|
|
16207
16207
|
await toggleStmt.bind(active ? 1 : 0, Date.now(), userId).run();
|
|
16208
|
-
await
|
|
16208
|
+
await chunk4SHNHNRP_cjs.logActivity(
|
|
16209
16209
|
db,
|
|
16210
16210
|
user.userId,
|
|
16211
16211
|
active ? "user.activate" : "user.deactivate",
|
|
@@ -16246,7 +16246,7 @@ userRoutes.delete("/users/:id", async (c) => {
|
|
|
16246
16246
|
DELETE FROM auth_user WHERE id = ?
|
|
16247
16247
|
`);
|
|
16248
16248
|
await deleteStmt.bind(userId).run();
|
|
16249
|
-
await
|
|
16249
|
+
await chunk4SHNHNRP_cjs.logActivity(
|
|
16250
16250
|
db,
|
|
16251
16251
|
user.userId,
|
|
16252
16252
|
"user!.hard_delete",
|
|
@@ -16265,7 +16265,7 @@ userRoutes.delete("/users/:id", async (c) => {
|
|
|
16265
16265
|
UPDATE auth_user SET is_active = 0, updated_at = ? WHERE id = ?
|
|
16266
16266
|
`);
|
|
16267
16267
|
await deleteStmt.bind(Date.now(), userId).run();
|
|
16268
|
-
await
|
|
16268
|
+
await chunk4SHNHNRP_cjs.logActivity(
|
|
16269
16269
|
db,
|
|
16270
16270
|
user.userId,
|
|
16271
16271
|
"user!.soft_delete",
|
|
@@ -16331,7 +16331,7 @@ userRoutes.post("/invite-user", async (c) => {
|
|
|
16331
16331
|
Date.now(),
|
|
16332
16332
|
Date.now()
|
|
16333
16333
|
).run();
|
|
16334
|
-
await
|
|
16334
|
+
await chunk4SHNHNRP_cjs.logActivity(
|
|
16335
16335
|
db,
|
|
16336
16336
|
user.userId,
|
|
16337
16337
|
"user!.invite_sent",
|
|
@@ -16388,7 +16388,7 @@ userRoutes.post("/resend-invitation/:id", async (c) => {
|
|
|
16388
16388
|
Date.now(),
|
|
16389
16389
|
userId
|
|
16390
16390
|
).run();
|
|
16391
|
-
await
|
|
16391
|
+
await chunk4SHNHNRP_cjs.logActivity(
|
|
16392
16392
|
db,
|
|
16393
16393
|
user.userId,
|
|
16394
16394
|
"user!.invitation_resent",
|
|
@@ -16424,7 +16424,7 @@ userRoutes.delete("/cancel-invitation/:id", async (c) => {
|
|
|
16424
16424
|
}
|
|
16425
16425
|
const deleteStmt = db.prepare(`DELETE FROM auth_user WHERE id = ?`);
|
|
16426
16426
|
await deleteStmt.bind(userId).run();
|
|
16427
|
-
await
|
|
16427
|
+
await chunk4SHNHNRP_cjs.logActivity(
|
|
16428
16428
|
db,
|
|
16429
16429
|
user.userId,
|
|
16430
16430
|
"user!.invitation_cancelled",
|
|
@@ -17805,7 +17805,7 @@ var fileValidationSchema2 = zod.z.object({
|
|
|
17805
17805
|
// 50MB max
|
|
17806
17806
|
});
|
|
17807
17807
|
var adminMediaRoutes = new hono.Hono();
|
|
17808
|
-
adminMediaRoutes.use("*",
|
|
17808
|
+
adminMediaRoutes.use("*", chunk4SHNHNRP_cjs.requireAuth());
|
|
17809
17809
|
adminMediaRoutes.get("/", async (c) => {
|
|
17810
17810
|
try {
|
|
17811
17811
|
const user = c.get("user");
|
|
@@ -17847,7 +17847,7 @@ adminMediaRoutes.get("/selector", async (c) => {
|
|
|
17847
17847
|
const { searchParams } = new URL(c.req.url);
|
|
17848
17848
|
const search = searchParams.get("search") || "";
|
|
17849
17849
|
const db = c.env.DB;
|
|
17850
|
-
const pluginService = new
|
|
17850
|
+
const pluginService = new chunk5ARIHAGN_cjs.PluginService(db);
|
|
17851
17851
|
const mediaPlugin = await pluginService.getPlugin("core-media");
|
|
17852
17852
|
if (!mediaPlugin || mediaPlugin.status !== "active") {
|
|
17853
17853
|
return c.html(html.html`
|
|
@@ -18221,7 +18221,7 @@ adminMediaRoutes.put("/:id", async (c) => {
|
|
|
18221
18221
|
`);
|
|
18222
18222
|
}
|
|
18223
18223
|
});
|
|
18224
|
-
adminMediaRoutes.delete("/cleanup",
|
|
18224
|
+
adminMediaRoutes.delete("/cleanup", chunk4SHNHNRP_cjs.requireRole("admin"), async (c) => {
|
|
18225
18225
|
try {
|
|
18226
18226
|
const db = c.env.DB;
|
|
18227
18227
|
const allMediaStmt = db.prepare("SELECT id, r2_key, filename FROM media WHERE deleted_at IS NULL");
|
|
@@ -20717,8 +20717,8 @@ defineUserProfile({
|
|
|
20717
20717
|
|
|
20718
20718
|
// src/routes/admin-plugins.ts
|
|
20719
20719
|
var adminPluginRoutes = new hono.Hono();
|
|
20720
|
-
adminPluginRoutes.use("*",
|
|
20721
|
-
var AVAILABLE_PLUGINS = Object.values(
|
|
20720
|
+
adminPluginRoutes.use("*", chunk4SHNHNRP_cjs.requireAuth());
|
|
20721
|
+
var AVAILABLE_PLUGINS = Object.values(chunk5ARIHAGN_cjs.PLUGIN_REGISTRY).map((p) => ({
|
|
20722
20722
|
id: p.id,
|
|
20723
20723
|
name: p.codeName,
|
|
20724
20724
|
display_name: p.displayName,
|
|
@@ -20738,7 +20738,7 @@ adminPluginRoutes.get("/", async (c) => {
|
|
|
20738
20738
|
if (user?.role !== "admin") {
|
|
20739
20739
|
return c.text("Access denied", 403);
|
|
20740
20740
|
}
|
|
20741
|
-
const pluginService = new
|
|
20741
|
+
const pluginService = new chunk5ARIHAGN_cjs.PluginService(db);
|
|
20742
20742
|
let installedPlugins = [];
|
|
20743
20743
|
let stats = { total: 0, active: 0, inactive: 0, errors: 0, uninstalled: 0 };
|
|
20744
20744
|
try {
|
|
@@ -20810,10 +20810,10 @@ adminPluginRoutes.get("/:id", async (c) => {
|
|
|
20810
20810
|
if (user?.role !== "admin") {
|
|
20811
20811
|
return c.redirect("/admin/plugins");
|
|
20812
20812
|
}
|
|
20813
|
-
const pluginService = new
|
|
20813
|
+
const pluginService = new chunk5ARIHAGN_cjs.PluginService(db);
|
|
20814
20814
|
let plugin = await pluginService.getPlugin(pluginId);
|
|
20815
20815
|
if (!plugin) {
|
|
20816
|
-
const def =
|
|
20816
|
+
const def = chunk5RSB5SEK_cjs.getPluginDefinition(pluginId);
|
|
20817
20817
|
if (!def) return c.text("Plugin not found", 404);
|
|
20818
20818
|
plugin = await pluginService.ensurePlugin(pluginId, {
|
|
20819
20819
|
displayName: def.displayName ?? pluginId,
|
|
@@ -20904,14 +20904,14 @@ adminPluginRoutes.get("/:id/configure", async (c) => {
|
|
|
20904
20904
|
const user = c.get("user");
|
|
20905
20905
|
const pluginId = c.req.param("id");
|
|
20906
20906
|
if (user?.role !== "admin") return c.redirect("/admin/plugins");
|
|
20907
|
-
const def =
|
|
20907
|
+
const def = chunk5RSB5SEK_cjs.getPluginDefinition(pluginId);
|
|
20908
20908
|
if (!def?.configSchema) return c.text("No schema-driven settings for this plugin", 404);
|
|
20909
20909
|
const db = c.env.DB;
|
|
20910
|
-
const pluginService = new
|
|
20910
|
+
const pluginService = new chunk5ARIHAGN_cjs.PluginService(db);
|
|
20911
20911
|
const plugin = await pluginService.getPlugin(pluginId);
|
|
20912
20912
|
const stored = plugin?.settings ?? {};
|
|
20913
|
-
const values =
|
|
20914
|
-
const fieldsHtml =
|
|
20913
|
+
const values = chunk5RSB5SEK_cjs.applySchemaDefaults(def.configSchema, stored);
|
|
20914
|
+
const fieldsHtml = chunk5RSB5SEK_cjs.renderSchemaFields(def.configSchema, values);
|
|
20915
20915
|
const displayName = plugin?.display_name ?? def.displayName ?? def.id;
|
|
20916
20916
|
return c.html(`<!DOCTYPE html>
|
|
20917
20917
|
<html lang="en"><head>
|
|
@@ -20938,12 +20938,12 @@ adminPluginRoutes.post("/:id/configure", async (c) => {
|
|
|
20938
20938
|
const user = c.get("user");
|
|
20939
20939
|
const pluginId = c.req.param("id");
|
|
20940
20940
|
if (user?.role !== "admin") return c.json({ error: "Access denied" }, 403);
|
|
20941
|
-
const def =
|
|
20941
|
+
const def = chunk5RSB5SEK_cjs.getPluginDefinition(pluginId);
|
|
20942
20942
|
if (!def?.configSchema) return c.text("No schema-driven settings for this plugin", 404);
|
|
20943
20943
|
const form = await c.req.formData();
|
|
20944
|
-
const parsed =
|
|
20944
|
+
const parsed = chunk5RSB5SEK_cjs.parseFormDataToSettings(def.configSchema, form);
|
|
20945
20945
|
const db = c.env.DB;
|
|
20946
|
-
const pluginService = new
|
|
20946
|
+
const pluginService = new chunk5ARIHAGN_cjs.PluginService(db);
|
|
20947
20947
|
await pluginService.ensurePlugin(pluginId, {
|
|
20948
20948
|
displayName: def.displayName ?? pluginId,
|
|
20949
20949
|
version: def.version,
|
|
@@ -20967,7 +20967,7 @@ adminPluginRoutes.post("/:id/activate", async (c) => {
|
|
|
20967
20967
|
if (user?.role !== "admin") {
|
|
20968
20968
|
return c.json({ error: "Access denied" }, 403);
|
|
20969
20969
|
}
|
|
20970
|
-
const pluginService = new
|
|
20970
|
+
const pluginService = new chunk5ARIHAGN_cjs.PluginService(db);
|
|
20971
20971
|
await pluginService.activatePlugin(pluginId);
|
|
20972
20972
|
return c.json({ success: true });
|
|
20973
20973
|
} catch (error) {
|
|
@@ -20984,7 +20984,7 @@ adminPluginRoutes.post("/:id/deactivate", async (c) => {
|
|
|
20984
20984
|
if (user?.role !== "admin") {
|
|
20985
20985
|
return c.json({ error: "Access denied" }, 403);
|
|
20986
20986
|
}
|
|
20987
|
-
const pluginService = new
|
|
20987
|
+
const pluginService = new chunk5ARIHAGN_cjs.PluginService(db);
|
|
20988
20988
|
await pluginService.deactivatePlugin(pluginId);
|
|
20989
20989
|
return c.json({ success: true });
|
|
20990
20990
|
} catch (error) {
|
|
@@ -21001,8 +21001,8 @@ adminPluginRoutes.post("/install", async (c) => {
|
|
|
21001
21001
|
return c.json({ error: "Access denied" }, 403);
|
|
21002
21002
|
}
|
|
21003
21003
|
const body = await c.req.json();
|
|
21004
|
-
const pluginService = new
|
|
21005
|
-
const registryEntry =
|
|
21004
|
+
const pluginService = new chunk5ARIHAGN_cjs.PluginService(db);
|
|
21005
|
+
const registryEntry = chunk5ARIHAGN_cjs.findPluginByCodeName(body.name) || chunk5ARIHAGN_cjs.PLUGIN_REGISTRY[body.name] || chunk5ARIHAGN_cjs.PLUGIN_REGISTRY[body.id];
|
|
21006
21006
|
if (!registryEntry) {
|
|
21007
21007
|
return c.json({ error: "Plugin not found in registry" }, 404);
|
|
21008
21008
|
}
|
|
@@ -21035,7 +21035,7 @@ adminPluginRoutes.post("/:id/uninstall", async (c) => {
|
|
|
21035
21035
|
if (user?.role !== "admin") {
|
|
21036
21036
|
return c.json({ error: "Access denied" }, 403);
|
|
21037
21037
|
}
|
|
21038
|
-
const pluginService = new
|
|
21038
|
+
const pluginService = new chunk5ARIHAGN_cjs.PluginService(db);
|
|
21039
21039
|
await pluginService.uninstallPlugin(pluginId);
|
|
21040
21040
|
return c.json({ success: true });
|
|
21041
21041
|
} catch (error) {
|
|
@@ -21053,7 +21053,7 @@ adminPluginRoutes.post("/:id/settings", async (c) => {
|
|
|
21053
21053
|
return c.json({ error: "Access denied" }, 403);
|
|
21054
21054
|
}
|
|
21055
21055
|
const settings = await c.req.json();
|
|
21056
|
-
const pluginService = new
|
|
21056
|
+
const pluginService = new chunk5ARIHAGN_cjs.PluginService(db);
|
|
21057
21057
|
await pluginService.updatePluginSettings(pluginId, settings);
|
|
21058
21058
|
if (pluginId === "core-auth") {
|
|
21059
21059
|
try {
|
|
@@ -21861,7 +21861,7 @@ function renderLogConfigPage(data) {
|
|
|
21861
21861
|
|
|
21862
21862
|
// src/routes/admin-logs.ts
|
|
21863
21863
|
var adminLogsRoutes = new hono.Hono();
|
|
21864
|
-
adminLogsRoutes.use("*",
|
|
21864
|
+
adminLogsRoutes.use("*", chunk4SHNHNRP_cjs.requireAuth());
|
|
21865
21865
|
adminLogsRoutes.get("/", async (c) => {
|
|
21866
21866
|
try {
|
|
21867
21867
|
const user = c.get("user");
|
|
@@ -22853,9 +22853,9 @@ function renderStorageUsage(databaseSizeBytes, mediaSizeBytes) {
|
|
|
22853
22853
|
}
|
|
22854
22854
|
|
|
22855
22855
|
// src/routes/admin-dashboard.ts
|
|
22856
|
-
var VERSION =
|
|
22856
|
+
var VERSION = chunkAQJEMVAY_cjs.getCoreVersion();
|
|
22857
22857
|
var router = new hono.Hono();
|
|
22858
|
-
router.use("*",
|
|
22858
|
+
router.use("*", chunk4SHNHNRP_cjs.requireAuth());
|
|
22859
22859
|
router.get("/", async (c) => {
|
|
22860
22860
|
const user = c.get("user");
|
|
22861
22861
|
try {
|
|
@@ -24820,7 +24820,7 @@ function renderCollectionFormPage(data) {
|
|
|
24820
24820
|
// src/routes/admin-collections.ts
|
|
24821
24821
|
chunkK623Q6WD_cjs.init_admin_layout_catalyst_template();
|
|
24822
24822
|
var adminCollectionsRoutes = new hono.Hono();
|
|
24823
|
-
adminCollectionsRoutes.use("*",
|
|
24823
|
+
adminCollectionsRoutes.use("*", chunk4SHNHNRP_cjs.requireAuth());
|
|
24824
24824
|
adminCollectionsRoutes.get("/", async (c) => {
|
|
24825
24825
|
try {
|
|
24826
24826
|
const user = c.get("user");
|
|
@@ -24837,7 +24837,7 @@ adminCollectionsRoutes.get("/", async (c) => {
|
|
|
24837
24837
|
results = queryResults.results ?? [];
|
|
24838
24838
|
} catch (e) {
|
|
24839
24839
|
}
|
|
24840
|
-
const codeCollections =
|
|
24840
|
+
const codeCollections = chunk5ARIHAGN_cjs.getCollectionRegistry().list();
|
|
24841
24841
|
const codeCollectionsMap = new Map(
|
|
24842
24842
|
codeCollections.map((cfg) => {
|
|
24843
24843
|
const fieldCount = cfg.schema?.properties ? Object.keys(cfg.schema.properties).length : 0;
|
|
@@ -24851,7 +24851,7 @@ adminCollectionsRoutes.get("/", async (c) => {
|
|
|
24851
24851
|
field_count: fieldCount,
|
|
24852
24852
|
managed: cfg.managed !== false,
|
|
24853
24853
|
source_type: "code",
|
|
24854
|
-
internal:
|
|
24854
|
+
internal: chunk5ARIHAGN_cjs.isCodeCollectionInternal(cfg),
|
|
24855
24855
|
versioning: cfg.versioning === true
|
|
24856
24856
|
}];
|
|
24857
24857
|
})
|
|
@@ -24890,7 +24890,7 @@ adminCollectionsRoutes.get("/", async (c) => {
|
|
|
24890
24890
|
field_count: fieldCount,
|
|
24891
24891
|
managed: false,
|
|
24892
24892
|
source_type: row.source === "code" || row.source === "system" || row.source === "plugin" ? "code" : "user",
|
|
24893
|
-
internal:
|
|
24893
|
+
internal: chunk5ARIHAGN_cjs.isDbDocTypeInternal(row.source),
|
|
24894
24894
|
versioning: dbVersioning
|
|
24895
24895
|
};
|
|
24896
24896
|
});
|
|
@@ -25051,7 +25051,7 @@ export const myPlugin = definePlugin({
|
|
|
25051
25051
|
title: "Add a Collection",
|
|
25052
25052
|
pageTitle: "Add a Collection",
|
|
25053
25053
|
currentPath: "/admin/collections",
|
|
25054
|
-
version:
|
|
25054
|
+
version: chunkAQJEMVAY_cjs.getCoreVersion(),
|
|
25055
25055
|
user: u ? { name: u.email ?? "Admin", email: u.email ?? "", role: u.role ?? "admin" } : void 0,
|
|
25056
25056
|
content
|
|
25057
25057
|
})
|
|
@@ -25068,7 +25068,7 @@ adminCollectionsRoutes.get("/:id", async (c) => {
|
|
|
25068
25068
|
collection = await stmt.bind(id).first();
|
|
25069
25069
|
} catch {
|
|
25070
25070
|
}
|
|
25071
|
-
const registryRecord =
|
|
25071
|
+
const registryRecord = chunk5ARIHAGN_cjs.getCollectionRegistry().getById(id) ?? chunk5ARIHAGN_cjs.getCollectionRegistry().getByName(id);
|
|
25072
25072
|
if (!collection && !registryRecord) {
|
|
25073
25073
|
const formData2 = {
|
|
25074
25074
|
isEdit: true,
|
|
@@ -25115,9 +25115,9 @@ adminCollectionsRoutes.get("/:id", async (c) => {
|
|
|
25115
25115
|
isCodeDriven = true;
|
|
25116
25116
|
}
|
|
25117
25117
|
const [tinymceActive, quillActive, mdxeditorActive] = await Promise.all([
|
|
25118
|
-
|
|
25119
|
-
|
|
25120
|
-
|
|
25118
|
+
chunk4SHNHNRP_cjs.isPluginActive(db, "tinymce-plugin"),
|
|
25119
|
+
chunk4SHNHNRP_cjs.isPluginActive(db, "quill-editor"),
|
|
25120
|
+
chunk4SHNHNRP_cjs.isPluginActive(db, "easy-mdx")
|
|
25121
25121
|
]);
|
|
25122
25122
|
const displayName = collection?.display_name ?? registryRecord?.displayName ?? id;
|
|
25123
25123
|
const formData = {
|
|
@@ -25137,9 +25137,9 @@ adminCollectionsRoutes.get("/:id", async (c) => {
|
|
|
25137
25137
|
console.error("Error fetching collection:", error);
|
|
25138
25138
|
const user = c.get("user");
|
|
25139
25139
|
const [tinymceActive, quillActive, mdxeditorActive] = await Promise.all([
|
|
25140
|
-
|
|
25141
|
-
|
|
25142
|
-
|
|
25140
|
+
chunk4SHNHNRP_cjs.isPluginActive(db, "tinymce-plugin"),
|
|
25141
|
+
chunk4SHNHNRP_cjs.isPluginActive(db, "quill-editor"),
|
|
25142
|
+
chunk4SHNHNRP_cjs.isPluginActive(db, "easy-mdx")
|
|
25143
25143
|
]);
|
|
25144
25144
|
const formData = {
|
|
25145
25145
|
isEdit: true,
|
|
@@ -26088,7 +26088,7 @@ function renderDatabaseToolsSettings(settings) {
|
|
|
26088
26088
|
|
|
26089
26089
|
// src/routes/admin-settings.ts
|
|
26090
26090
|
var adminSettingsRoutes = new hono.Hono();
|
|
26091
|
-
adminSettingsRoutes.use("*",
|
|
26091
|
+
adminSettingsRoutes.use("*", chunk4SHNHNRP_cjs.requireAuth());
|
|
26092
26092
|
function getMockSettings(user) {
|
|
26093
26093
|
return {
|
|
26094
26094
|
general: {
|
|
@@ -26191,7 +26191,7 @@ adminSettingsRoutes.get("/database-tools", (c) => {
|
|
|
26191
26191
|
adminSettingsRoutes.get("/api/migrations/status", async (c) => {
|
|
26192
26192
|
try {
|
|
26193
26193
|
const db = c.env.DB;
|
|
26194
|
-
const migrationService = new
|
|
26194
|
+
const migrationService = new chunkTQG5FNNR_cjs.MigrationService(db);
|
|
26195
26195
|
const status = await migrationService.getMigrationStatus();
|
|
26196
26196
|
return c.json({
|
|
26197
26197
|
success: true,
|
|
@@ -26231,7 +26231,7 @@ adminSettingsRoutes.post("/api/migrations/run", async (c) => {
|
|
|
26231
26231
|
adminSettingsRoutes.get("/api/migrations/validate", async (c) => {
|
|
26232
26232
|
try {
|
|
26233
26233
|
const db = c.env.DB;
|
|
26234
|
-
const migrationService = new
|
|
26234
|
+
const migrationService = new chunkTQG5FNNR_cjs.MigrationService(db);
|
|
26235
26235
|
const validation = await migrationService.validateSchema();
|
|
26236
26236
|
return c.json({
|
|
26237
26237
|
success: true,
|
|
@@ -26824,16 +26824,16 @@ function renderAPIReferencePage(data) {
|
|
|
26824
26824
|
}
|
|
26825
26825
|
|
|
26826
26826
|
// src/routes/admin-api-reference.ts
|
|
26827
|
-
var VERSION2 =
|
|
26827
|
+
var VERSION2 = chunkAQJEMVAY_cjs.getCoreVersion();
|
|
26828
26828
|
var router2 = new hono.Hono();
|
|
26829
|
-
router2.use("*",
|
|
26829
|
+
router2.use("*", chunk4SHNHNRP_cjs.requireAuth());
|
|
26830
26830
|
router2.get("/", async (c) => {
|
|
26831
26831
|
const user = c.get("user");
|
|
26832
26832
|
try {
|
|
26833
26833
|
const app2 = chunk36Z3AKX3_cjs.getAppInstance();
|
|
26834
26834
|
const baseEndpoints = chunk36Z3AKX3_cjs.buildRouteList(app2);
|
|
26835
26835
|
const collectionRoutes = [];
|
|
26836
|
-
const collections =
|
|
26836
|
+
const collections = chunk5ARIHAGN_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal);
|
|
26837
26837
|
const methodOrder = { GET: 0, POST: 1, PUT: 2, PATCH: 3, DELETE: 4 };
|
|
26838
26838
|
for (const col of collections) {
|
|
26839
26839
|
const displayName = col.displayName || col.name;
|
|
@@ -26950,5 +26950,5 @@ exports.setVariablesCache = setVariablesCache;
|
|
|
26950
26950
|
exports.test_cleanup_default = test_cleanup_default;
|
|
26951
26951
|
exports.userProfilesPlugin = userProfilesPlugin;
|
|
26952
26952
|
exports.userRoutes = userRoutes;
|
|
26953
|
-
//# sourceMappingURL=chunk-
|
|
26954
|
-
//# sourceMappingURL=chunk-
|
|
26953
|
+
//# sourceMappingURL=chunk-3E7IROND.cjs.map
|
|
26954
|
+
//# sourceMappingURL=chunk-3E7IROND.cjs.map
|