@sonicjs-cms/core 3.0.0-beta.12 → 3.0.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-R2O6TTQS.js → chunk-3FBZFYSQ.js} +25 -10
- package/dist/chunk-3FBZFYSQ.js.map +1 -0
- package/dist/{chunk-XGH2FVVR.cjs → chunk-6CKXZFED.cjs} +3 -3
- package/dist/{chunk-XGH2FVVR.cjs.map → chunk-6CKXZFED.cjs.map} +1 -1
- package/dist/{chunk-Q3P7Y5VO.js → chunk-6KFX4LAT.js} +4 -4
- package/dist/{chunk-Q3P7Y5VO.js.map → chunk-6KFX4LAT.js.map} +1 -1
- package/dist/{chunk-DMXDQ5YI.js → chunk-BK3NB35S.js} +4 -4
- package/dist/{chunk-DMXDQ5YI.js.map → chunk-BK3NB35S.js.map} +1 -1
- package/dist/{chunk-XHBEFQJ3.js → chunk-EKMN6W5B.js} +3 -3
- package/dist/{chunk-XHBEFQJ3.js.map → chunk-EKMN6W5B.js.map} +1 -1
- package/dist/{chunk-SY7CBACS.cjs → chunk-IM3UG4QW.cjs} +10 -10
- package/dist/{chunk-SY7CBACS.cjs.map → chunk-IM3UG4QW.cjs.map} +1 -1
- package/dist/{chunk-INKP2WNU.js → chunk-IV3NA6WZ.js} +2 -2
- package/dist/{chunk-INKP2WNU.js.map → chunk-IV3NA6WZ.js.map} +1 -1
- package/dist/{chunk-SUHGXAII.js → chunk-KG6GQE6B.js} +2 -2
- package/dist/{chunk-SUHGXAII.js.map → chunk-KG6GQE6B.js.map} +1 -1
- package/dist/{chunk-LLWLHFTD.cjs → chunk-KPQ57HAH.cjs} +2 -2
- package/dist/{chunk-LLWLHFTD.cjs.map → chunk-KPQ57HAH.cjs.map} +1 -1
- package/dist/{chunk-ALNODOY4.js → chunk-PPFQDMZE.js} +3 -3
- package/dist/{chunk-ALNODOY4.js.map → chunk-PPFQDMZE.js.map} +1 -1
- package/dist/{chunk-NYLWNR6T.cjs → chunk-PZGGIJI6.cjs} +4 -4
- package/dist/{chunk-NYLWNR6T.cjs.map → chunk-PZGGIJI6.cjs.map} +1 -1
- package/dist/{chunk-BYLQOBO6.cjs → chunk-VMBQ6NQB.cjs} +13 -13
- package/dist/{chunk-BYLQOBO6.cjs.map → chunk-VMBQ6NQB.cjs.map} +1 -1
- package/dist/{chunk-TV7LRFXH.cjs → chunk-VT77YUTP.cjs} +216 -201
- package/dist/chunk-VT77YUTP.cjs.map +1 -0
- package/dist/{chunk-KI5KMJH2.cjs → chunk-YNYEQP3K.cjs} +2 -2
- package/dist/{chunk-KI5KMJH2.cjs.map → chunk-YNYEQP3K.cjs.map} +1 -1
- package/dist/index.cjs +252 -252
- package/dist/index.js +13 -13
- package/dist/middleware.cjs +32 -32
- package/dist/middleware.js +3 -3
- package/dist/migrations-KKLQ2CEF.js +4 -0
- package/dist/{migrations-MLBACCPF.js.map → migrations-KKLQ2CEF.js.map} +1 -1
- package/dist/migrations-XOXYLHHU.cjs +13 -0
- package/dist/{migrations-AFSCRO56.cjs.map → migrations-XOXYLHHU.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/chunk-R2O6TTQS.js.map +0 -1
- package/dist/chunk-TV7LRFXH.cjs.map +0 -1
- package/dist/migrations-AFSCRO56.cjs +0 -13
- package/dist/migrations-MLBACCPF.js +0 -4
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
var chunkHIKBY7MS_cjs = require('./chunk-HIKBY7MS.cjs');
|
|
4
4
|
var chunkN32OWET6_cjs = require('./chunk-N32OWET6.cjs');
|
|
5
5
|
var chunk4BTBSXMR_cjs = require('./chunk-4BTBSXMR.cjs');
|
|
6
|
-
var
|
|
6
|
+
var chunkVMBQ6NQB_cjs = require('./chunk-VMBQ6NQB.cjs');
|
|
7
7
|
var chunk2CB4KY7I_cjs = require('./chunk-2CB4KY7I.cjs');
|
|
8
8
|
var chunkJEQ7FLOD_cjs = require('./chunk-JEQ7FLOD.cjs');
|
|
9
|
-
var
|
|
10
|
-
var
|
|
9
|
+
var chunkKPQ57HAH_cjs = require('./chunk-KPQ57HAH.cjs');
|
|
10
|
+
var chunkYNYEQP3K_cjs = require('./chunk-YNYEQP3K.cjs');
|
|
11
11
|
var chunkPXNTCCPE_cjs = require('./chunk-PXNTCCPE.cjs');
|
|
12
12
|
var chunkK623Q6WD_cjs = require('./chunk-K623Q6WD.cjs');
|
|
13
|
-
var
|
|
13
|
+
var chunkPZGGIJI6_cjs = require('./chunk-PZGGIJI6.cjs');
|
|
14
14
|
var chunkJ6JTWD2A_cjs = require('./chunk-J6JTWD2A.cjs');
|
|
15
15
|
var chunkIXUHXTHW_cjs = require('./chunk-IXUHXTHW.cjs');
|
|
16
16
|
var chunkRCQ2HIQD_cjs = require('./chunk-RCQ2HIQD.cjs');
|
|
17
|
-
var
|
|
17
|
+
var chunk6CKXZFED_cjs = require('./chunk-6CKXZFED.cjs');
|
|
18
18
|
var chunkMNWKYY5E_cjs = require('./chunk-MNWKYY5E.cjs');
|
|
19
19
|
var hono = require('hono');
|
|
20
20
|
var zod = require('zod');
|
|
@@ -256,7 +256,7 @@ function getDocumentRequestContext(c) {
|
|
|
256
256
|
|
|
257
257
|
// src/routes/api-documents.ts
|
|
258
258
|
async function aclAllowsRead(db, tenantId, principalSet, row, preloadedType) {
|
|
259
|
-
const docType = preloadedType ?? await new
|
|
259
|
+
const docType = preloadedType ?? await new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db).findById(row.type_id);
|
|
260
260
|
if (!docType) return false;
|
|
261
261
|
return new DocumentRepository(db, tenantId).isAllowed(principalSet, row.root_id, "read", docType.settings);
|
|
262
262
|
}
|
|
@@ -274,7 +274,7 @@ apiDocumentsRoutes.get("/", async (c) => {
|
|
|
274
274
|
if (!typeId) {
|
|
275
275
|
return c.json({ error: "type query parameter is required" }, 400);
|
|
276
276
|
}
|
|
277
|
-
const registry = new
|
|
277
|
+
const registry = new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db);
|
|
278
278
|
const docType = await registry.findById(typeId);
|
|
279
279
|
if (!docType || !docType.isActive) {
|
|
280
280
|
return c.json({ error: "Unknown document type" }, 400);
|
|
@@ -356,7 +356,7 @@ apiDocumentsRoutes.get("/root/:rootId", async (c) => {
|
|
|
356
356
|
AND (expires_at IS NULL OR expires_at > ?) LIMIT 1`
|
|
357
357
|
).bind(rootId, now, now).first();
|
|
358
358
|
if (!row) return c.json({ error: "Not found" }, 404);
|
|
359
|
-
const docType = await new
|
|
359
|
+
const docType = await new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db).findById(row.type_id);
|
|
360
360
|
const effTenant = effectiveTenantForType(tenantId, docType?.settings);
|
|
361
361
|
if (row.tenant_id !== effTenant) return c.json({ error: "Not found" }, 404);
|
|
362
362
|
if (!await aclAllowsRead(db, effTenant, principalSet, row, docType)) {
|
|
@@ -392,7 +392,7 @@ apiDocumentsRoutes.get("/:id", async (c) => {
|
|
|
392
392
|
AND (expires_at IS NULL OR expires_at > ?) LIMIT 1`
|
|
393
393
|
).bind(id, now, now).first();
|
|
394
394
|
if (!row) return c.json({ error: "Not found" }, 404);
|
|
395
|
-
const docType = await new
|
|
395
|
+
const docType = await new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db).findById(row.type_id);
|
|
396
396
|
const effTenant = effectiveTenantForType(tenantId, docType?.settings);
|
|
397
397
|
if (row.tenant_id !== effTenant) return c.json({ error: "Not found" }, 404);
|
|
398
398
|
if (!await aclAllowsRead(db, effTenant, principalSet, row, docType)) {
|
|
@@ -462,17 +462,17 @@ async function resolveDocScope(c, db, by, opts = {}) {
|
|
|
462
462
|
const draft = opts.currentDraftOnly ? " AND is_current_draft = 1" : "";
|
|
463
463
|
const row = await db.prepare(`SELECT type_id, root_id, tenant_id FROM documents WHERE ${col} = ?${draft} LIMIT 1`).bind(val).first();
|
|
464
464
|
if (!row) return null;
|
|
465
|
-
const docType = await new
|
|
465
|
+
const docType = await new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db).findById(row.type_id);
|
|
466
466
|
const tenantId = effectiveTenantForType(getRequestTenant(c), docType?.settings);
|
|
467
467
|
if (row.tenant_id !== tenantId) return null;
|
|
468
468
|
return { typeId: row.type_id, rootId: row.root_id, tenantId, docType };
|
|
469
469
|
}
|
|
470
470
|
var adminDocumentsRoutes = new hono.Hono();
|
|
471
|
-
adminDocumentsRoutes.use("*",
|
|
472
|
-
adminDocumentsRoutes.use("*",
|
|
471
|
+
adminDocumentsRoutes.use("*", chunkVMBQ6NQB_cjs.requireAuth());
|
|
472
|
+
adminDocumentsRoutes.use("*", chunkVMBQ6NQB_cjs.requireRole(["admin", "editor"]));
|
|
473
473
|
adminDocumentsRoutes.get("/types", async (c) => {
|
|
474
474
|
try {
|
|
475
|
-
const registry = new
|
|
475
|
+
const registry = new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(c.env.DB);
|
|
476
476
|
const types = await registry.findAll();
|
|
477
477
|
return c.json({ data: types });
|
|
478
478
|
} catch (error) {
|
|
@@ -500,7 +500,7 @@ adminDocumentsRoutes.get("/", async (c) => {
|
|
|
500
500
|
if (!typeId) {
|
|
501
501
|
return c.json({ error: "type query parameter is required" }, 400);
|
|
502
502
|
}
|
|
503
|
-
const registry = new
|
|
503
|
+
const registry = new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db);
|
|
504
504
|
const docType = await registry.findById(typeId);
|
|
505
505
|
if (!docType || !docType.isActive) {
|
|
506
506
|
return c.json({ error: "Unknown document type" }, 400);
|
|
@@ -611,7 +611,7 @@ adminDocumentsRoutes.post("/", async (c) => {
|
|
|
611
611
|
const input = validation.data;
|
|
612
612
|
const db = c.env.DB;
|
|
613
613
|
const user = c.get("user");
|
|
614
|
-
const registry = new
|
|
614
|
+
const registry = new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db);
|
|
615
615
|
const docType = await registry.findById(input.typeId);
|
|
616
616
|
if (!docType || !docType.isActive) {
|
|
617
617
|
return c.json({ error: "Unknown document type" }, 400);
|
|
@@ -743,7 +743,7 @@ adminDocumentsRoutes.post("/types/:typeId/reindex", async (c) => {
|
|
|
743
743
|
try {
|
|
744
744
|
const { typeId } = c.req.param();
|
|
745
745
|
const db = c.env.DB;
|
|
746
|
-
const registry = new
|
|
746
|
+
const registry = new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db);
|
|
747
747
|
const docType = await registry.findById(typeId);
|
|
748
748
|
if (!docType) return c.json({ error: "Unknown document type" }, 400);
|
|
749
749
|
const reindexTenant = effectiveTenantForType(getRequestTenant(c), docType.settings);
|
|
@@ -897,13 +897,13 @@ async function resolveContentVariables(contentData, db) {
|
|
|
897
897
|
// src/routes/api-content-crud.ts
|
|
898
898
|
var apiContentCrudRoutes = new hono.Hono();
|
|
899
899
|
async function resolveDocBacking(db, collectionIdOrName) {
|
|
900
|
-
const registry =
|
|
900
|
+
const registry = chunkKPQ57HAH_cjs.getCollectionRegistry();
|
|
901
901
|
const record = registry.getBySlugOrName(collectionIdOrName) ?? registry.getById(collectionIdOrName);
|
|
902
902
|
if (record) {
|
|
903
|
-
const docType2 = await new
|
|
903
|
+
const docType2 = await new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db).findById(record.name);
|
|
904
904
|
return docType2 ? { coll: { id: record.id, name: record.name }, docType: docType2 } : null;
|
|
905
905
|
}
|
|
906
|
-
const docType = await new
|
|
906
|
+
const docType = await new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db).findById(collectionIdOrName);
|
|
907
907
|
if (docType) {
|
|
908
908
|
return { coll: { id: collectionIdOrName, name: collectionIdOrName }, docType };
|
|
909
909
|
}
|
|
@@ -946,7 +946,7 @@ apiContentCrudRoutes.get("/check-slug", async (c) => {
|
|
|
946
946
|
}, 500);
|
|
947
947
|
}
|
|
948
948
|
});
|
|
949
|
-
apiContentCrudRoutes.get("/:id",
|
|
949
|
+
apiContentCrudRoutes.get("/:id", chunkVMBQ6NQB_cjs.optionalAuth(), async (c) => {
|
|
950
950
|
try {
|
|
951
951
|
const id = c.req.param("id");
|
|
952
952
|
const db = c.env.DB;
|
|
@@ -956,7 +956,7 @@ apiContentCrudRoutes.get("/:id", chunkBYLQOBO6_cjs.optionalAuth(), async (c) =>
|
|
|
956
956
|
).bind(id, getRequestTenant(c)).first();
|
|
957
957
|
let transformedContent;
|
|
958
958
|
if (docRow) {
|
|
959
|
-
const coll =
|
|
959
|
+
const coll = chunkKPQ57HAH_cjs.getCollectionRegistry().getByName(docRow.type_id);
|
|
960
960
|
transformedContent = {
|
|
961
961
|
id: docRow.root_id,
|
|
962
962
|
title: docRow.title,
|
|
@@ -990,7 +990,7 @@ apiContentCrudRoutes.get("/:id", chunkBYLQOBO6_cjs.optionalAuth(), async (c) =>
|
|
|
990
990
|
}, 500);
|
|
991
991
|
}
|
|
992
992
|
});
|
|
993
|
-
apiContentCrudRoutes.post("/",
|
|
993
|
+
apiContentCrudRoutes.post("/", chunkVMBQ6NQB_cjs.requireAuth(), chunkVMBQ6NQB_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
994
994
|
try {
|
|
995
995
|
const db = c.env.DB;
|
|
996
996
|
const user = c.get("user");
|
|
@@ -1065,7 +1065,7 @@ apiContentCrudRoutes.post("/", chunkBYLQOBO6_cjs.requireAuth(), chunkBYLQOBO6_cj
|
|
|
1065
1065
|
}, 500);
|
|
1066
1066
|
}
|
|
1067
1067
|
});
|
|
1068
|
-
apiContentCrudRoutes.put("/:id",
|
|
1068
|
+
apiContentCrudRoutes.put("/:id", chunkVMBQ6NQB_cjs.requireAuth(), chunkVMBQ6NQB_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
1069
1069
|
try {
|
|
1070
1070
|
const id = c.req.param("id");
|
|
1071
1071
|
const db = c.env.DB;
|
|
@@ -1087,7 +1087,7 @@ apiContentCrudRoutes.put("/:id", chunkBYLQOBO6_cjs.requireAuth(), chunkBYLQOBO6_
|
|
|
1087
1087
|
} catch (err) {
|
|
1088
1088
|
return c.json({ error: "Write cancelled by plugin", details: String(err) }, 400);
|
|
1089
1089
|
}
|
|
1090
|
-
const docType = await new
|
|
1090
|
+
const docType = await new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db).findById(docRow.type_id);
|
|
1091
1091
|
const svc = new chunk2CB4KY7I_cjs.DocumentsService(db, {
|
|
1092
1092
|
queryableFields: docType?.queryableFields ?? [],
|
|
1093
1093
|
typeSchemaVersion: docType?.schemaVersion ?? 1,
|
|
@@ -1110,7 +1110,7 @@ apiContentCrudRoutes.put("/:id", chunkBYLQOBO6_cjs.requireAuth(), chunkBYLQOBO6_
|
|
|
1110
1110
|
const cache = chunk4BTBSXMR_cjs.getCacheService(chunk4BTBSXMR_cjs.CACHE_CONFIGS.api);
|
|
1111
1111
|
await cache.invalidate("content-filtered:*");
|
|
1112
1112
|
await cache.invalidate("collection-content-filtered:*");
|
|
1113
|
-
const coll =
|
|
1113
|
+
const coll = chunkKPQ57HAH_cjs.getCollectionRegistry().getByName(docRow.type_id);
|
|
1114
1114
|
const saved = await db.prepare("SELECT * FROM documents WHERE id = ?").bind(newDraft.id).first();
|
|
1115
1115
|
const savedData = saved?.data ? JSON.parse(saved.data) : {};
|
|
1116
1116
|
dispatchHookEvent(c, "content:after:update", { collection: docRow.type_id, id, data: savedData, user: actor }, "fire-and-forget");
|
|
@@ -1131,7 +1131,7 @@ apiContentCrudRoutes.put("/:id", chunkBYLQOBO6_cjs.requireAuth(), chunkBYLQOBO6_
|
|
|
1131
1131
|
}, 500);
|
|
1132
1132
|
}
|
|
1133
1133
|
});
|
|
1134
|
-
apiContentCrudRoutes.delete("/:id",
|
|
1134
|
+
apiContentCrudRoutes.delete("/:id", chunkVMBQ6NQB_cjs.requireAuth(), chunkVMBQ6NQB_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
1135
1135
|
try {
|
|
1136
1136
|
const id = c.req.param("id");
|
|
1137
1137
|
const db = c.env.DB;
|
|
@@ -1257,7 +1257,7 @@ apiRoutes.use("*", async (c, next) => {
|
|
|
1257
1257
|
c.header("X-Response-Time", `${totalTime}ms`);
|
|
1258
1258
|
});
|
|
1259
1259
|
apiRoutes.use("*", async (c, next) => {
|
|
1260
|
-
const cacheEnabled = await
|
|
1260
|
+
const cacheEnabled = await chunkVMBQ6NQB_cjs.isPluginActive(c.env.DB, "core-cache");
|
|
1261
1261
|
c.set("cacheEnabled", cacheEnabled);
|
|
1262
1262
|
await next();
|
|
1263
1263
|
});
|
|
@@ -1280,7 +1280,7 @@ apiRoutes.get("/", (c) => {
|
|
|
1280
1280
|
openapi: "3.0.0",
|
|
1281
1281
|
info: {
|
|
1282
1282
|
title: "SonicJS AI API",
|
|
1283
|
-
version:
|
|
1283
|
+
version: chunk6CKXZFED_cjs.getCoreVersion(),
|
|
1284
1284
|
description: "RESTful API for SonicJS headless CMS - a modern, AI-powered content management system built on Cloudflare Workers",
|
|
1285
1285
|
contact: {
|
|
1286
1286
|
name: "SonicJS Support",
|
|
@@ -1710,8 +1710,8 @@ apiRoutes.get("/collections", async (c) => {
|
|
|
1710
1710
|
}
|
|
1711
1711
|
c.header("X-Cache-Status", "MISS");
|
|
1712
1712
|
c.header("X-Cache-Source", "registry");
|
|
1713
|
-
const records =
|
|
1714
|
-
const transformedResults = records.map(
|
|
1713
|
+
const records = chunkKPQ57HAH_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal);
|
|
1714
|
+
const transformedResults = records.map(chunkKPQ57HAH_cjs.collectionRecordToRow);
|
|
1715
1715
|
const responseData = {
|
|
1716
1716
|
data: transformedResults,
|
|
1717
1717
|
meta: addTimingMeta(c, {
|
|
@@ -1732,7 +1732,7 @@ apiRoutes.get("/collections", async (c) => {
|
|
|
1732
1732
|
return c.json({ error: "Failed to fetch collections" }, 500);
|
|
1733
1733
|
}
|
|
1734
1734
|
});
|
|
1735
|
-
apiRoutes.get("/content",
|
|
1735
|
+
apiRoutes.get("/content", chunkVMBQ6NQB_cjs.optionalAuth(), async (c) => {
|
|
1736
1736
|
const executionStart = Date.now();
|
|
1737
1737
|
try {
|
|
1738
1738
|
const db = c.env.DB;
|
|
@@ -1741,7 +1741,7 @@ apiRoutes.get("/content", chunkBYLQOBO6_cjs.optionalAuth(), async (c) => {
|
|
|
1741
1741
|
const collIdByName = /* @__PURE__ */ new Map();
|
|
1742
1742
|
let typeId;
|
|
1743
1743
|
let typeIds;
|
|
1744
|
-
const registry =
|
|
1744
|
+
const registry = chunkKPQ57HAH_cjs.getCollectionRegistry();
|
|
1745
1745
|
if (queryParams.collection) {
|
|
1746
1746
|
const collectionName = queryParams.collection;
|
|
1747
1747
|
const record = registry.getByName(collectionName);
|
|
@@ -1840,13 +1840,13 @@ apiRoutes.get("/content", chunkBYLQOBO6_cjs.optionalAuth(), async (c) => {
|
|
|
1840
1840
|
}, 500);
|
|
1841
1841
|
}
|
|
1842
1842
|
});
|
|
1843
|
-
apiRoutes.get("/collections/:collection/content",
|
|
1843
|
+
apiRoutes.get("/collections/:collection/content", chunkVMBQ6NQB_cjs.optionalAuth(), async (c) => {
|
|
1844
1844
|
const executionStart = Date.now();
|
|
1845
1845
|
try {
|
|
1846
1846
|
const collection = c.req.param("collection");
|
|
1847
1847
|
const db = c.env.DB;
|
|
1848
1848
|
const queryParams = c.req.query();
|
|
1849
|
-
const record =
|
|
1849
|
+
const record = chunkKPQ57HAH_cjs.getCollectionRegistry().getBySlugOrName(collection);
|
|
1850
1850
|
if (!record || record.isActive === false) {
|
|
1851
1851
|
return c.json({ error: "Collection not found" }, 404);
|
|
1852
1852
|
}
|
|
@@ -1902,7 +1902,7 @@ apiRoutes.get("/collections/:collection/content", chunkBYLQOBO6_cjs.optionalAuth
|
|
|
1902
1902
|
const responseData = {
|
|
1903
1903
|
data: transformedResults,
|
|
1904
1904
|
meta: addTimingMeta(c, {
|
|
1905
|
-
...includeCollection ? { collection:
|
|
1905
|
+
...includeCollection ? { collection: chunkKPQ57HAH_cjs.collectionRecordToRow(record) } : {},
|
|
1906
1906
|
count: results.length,
|
|
1907
1907
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1908
1908
|
// D44: echo the caller's filter with the access policy applied (status=published forced for
|
|
@@ -1927,13 +1927,13 @@ apiRoutes.get("/collections/:collection/content", chunkBYLQOBO6_cjs.optionalAuth
|
|
|
1927
1927
|
}
|
|
1928
1928
|
});
|
|
1929
1929
|
apiRoutes.route("/content", api_content_crud_default);
|
|
1930
|
-
apiRoutes.get("/:collection",
|
|
1930
|
+
apiRoutes.get("/:collection", chunkVMBQ6NQB_cjs.optionalAuth(), async (c) => {
|
|
1931
1931
|
const executionStart = Date.now();
|
|
1932
1932
|
try {
|
|
1933
1933
|
const collection = c.req.param("collection");
|
|
1934
1934
|
const db = c.env.DB;
|
|
1935
1935
|
const queryParams = c.req.query();
|
|
1936
|
-
const record =
|
|
1936
|
+
const record = chunkKPQ57HAH_cjs.getCollectionRegistry().getBySlugOrName(collection);
|
|
1937
1937
|
if (!record || record.isActive === false) {
|
|
1938
1938
|
return c.json({ error: "Collection not found" }, 404);
|
|
1939
1939
|
}
|
|
@@ -1973,7 +1973,7 @@ apiRoutes.get("/:collection", chunkBYLQOBO6_cjs.optionalAuth(), async (c) => {
|
|
|
1973
1973
|
const responseData = {
|
|
1974
1974
|
data: transformedResults,
|
|
1975
1975
|
meta: addTimingMeta(c, {
|
|
1976
|
-
...includeCollection ? { collection:
|
|
1976
|
+
...includeCollection ? { collection: chunkKPQ57HAH_cjs.collectionRecordToRow(record) } : {},
|
|
1977
1977
|
count: results.length,
|
|
1978
1978
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1979
1979
|
filter: normalizePublicContentFilter(filter, role),
|
|
@@ -1991,12 +1991,12 @@ apiRoutes.get("/:collection", chunkBYLQOBO6_cjs.optionalAuth(), async (c) => {
|
|
|
1991
1991
|
return c.json({ error: "Failed to fetch content", details: error instanceof Error ? error.message : String(error) }, 500);
|
|
1992
1992
|
}
|
|
1993
1993
|
});
|
|
1994
|
-
apiRoutes.get("/:collection/:id",
|
|
1994
|
+
apiRoutes.get("/:collection/:id", chunkVMBQ6NQB_cjs.optionalAuth(), async (c) => {
|
|
1995
1995
|
try {
|
|
1996
1996
|
const collection = c.req.param("collection");
|
|
1997
1997
|
const id = c.req.param("id");
|
|
1998
1998
|
const db = c.env.DB;
|
|
1999
|
-
const record =
|
|
1999
|
+
const record = chunkKPQ57HAH_cjs.getCollectionRegistry().getBySlugOrName(collection);
|
|
2000
2000
|
if (!record || record.isActive === false) {
|
|
2001
2001
|
return c.json({ error: "Collection not found" }, 404);
|
|
2002
2002
|
}
|
|
@@ -2005,7 +2005,7 @@ apiRoutes.get("/:collection/:id", chunkBYLQOBO6_cjs.optionalAuth(), async (c) =>
|
|
|
2005
2005
|
privileged ? "SELECT * FROM documents WHERE root_id = ? AND type_id = ? AND tenant_id = 'default' AND is_current_draft = 1 AND deleted_at IS NULL" : "SELECT * FROM documents WHERE root_id = ? AND type_id = ? AND tenant_id = 'default' AND is_published = 1 AND deleted_at IS NULL"
|
|
2006
2006
|
).bind(id, record.name).first();
|
|
2007
2007
|
if (!docRow) return c.json({ error: "Content not found" }, 404);
|
|
2008
|
-
const coll =
|
|
2008
|
+
const coll = chunkKPQ57HAH_cjs.getCollectionRegistry().getByName(docRow.type_id);
|
|
2009
2009
|
const transformedContent = {
|
|
2010
2010
|
id: docRow.root_id,
|
|
2011
2011
|
title: docRow.title,
|
|
@@ -2023,7 +2023,7 @@ apiRoutes.get("/:collection/:id", chunkBYLQOBO6_cjs.optionalAuth(), async (c) =>
|
|
|
2023
2023
|
return c.json({ error: "Failed to fetch content", details: error instanceof Error ? error.message : String(error) }, 500);
|
|
2024
2024
|
}
|
|
2025
2025
|
});
|
|
2026
|
-
apiRoutes.post("/:collection",
|
|
2026
|
+
apiRoutes.post("/:collection", chunkVMBQ6NQB_cjs.requireAuth(), chunkVMBQ6NQB_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
2027
2027
|
try {
|
|
2028
2028
|
const collection = c.req.param("collection");
|
|
2029
2029
|
const db = c.env.DB;
|
|
@@ -2056,14 +2056,14 @@ apiRoutes.post("/:collection", chunkBYLQOBO6_cjs.requireAuth(), chunkBYLQOBO6_cj
|
|
|
2056
2056
|
return c.json({ error: "Failed to create content", details: error instanceof Error ? error.message : String(error) }, 500);
|
|
2057
2057
|
}
|
|
2058
2058
|
});
|
|
2059
|
-
apiRoutes.put("/:collection/:id",
|
|
2059
|
+
apiRoutes.put("/:collection/:id", chunkVMBQ6NQB_cjs.requireAuth(), chunkVMBQ6NQB_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
2060
2060
|
try {
|
|
2061
2061
|
const collection = c.req.param("collection");
|
|
2062
2062
|
const id = c.req.param("id");
|
|
2063
2063
|
const db = c.env.DB;
|
|
2064
2064
|
const user = c.get("user");
|
|
2065
2065
|
const body = await c.req.json();
|
|
2066
|
-
const collRecord =
|
|
2066
|
+
const collRecord = chunkKPQ57HAH_cjs.getCollectionRegistry().getBySlugOrName(collection);
|
|
2067
2067
|
const typeName = collRecord?.name ?? collection;
|
|
2068
2068
|
const docRow = await db.prepare("SELECT root_id, type_id FROM documents WHERE root_id = ? AND type_id = ? AND tenant_id = 'default' AND is_current_draft = 1 AND deleted_at IS NULL").bind(id, typeName).first();
|
|
2069
2069
|
if (!docRow) return c.json({ error: "Content not found" }, 404);
|
|
@@ -2075,7 +2075,7 @@ apiRoutes.put("/:collection/:id", chunkBYLQOBO6_cjs.requireAuth(), chunkBYLQOBO6
|
|
|
2075
2075
|
} catch (err) {
|
|
2076
2076
|
return c.json({ error: "Write cancelled by plugin", details: String(err) }, 400);
|
|
2077
2077
|
}
|
|
2078
|
-
const docType = await new
|
|
2078
|
+
const docType = await new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db).findById(docRow.type_id);
|
|
2079
2079
|
const svc = new chunk2CB4KY7I_cjs.DocumentsService(db, { queryableFields: docType?.queryableFields ?? [], typeSchemaVersion: docType?.schemaVersion ?? 1, maxVersionsPerRoot: docType?.settings?.maxVersionsPerRoot ?? 50, tenantId: "default", versioning: docType?.settings?.versioning ?? false });
|
|
2080
2080
|
const input = {};
|
|
2081
2081
|
if (body.title !== void 0) input.title = body.title;
|
|
@@ -2092,7 +2092,7 @@ apiRoutes.put("/:collection/:id", chunkBYLQOBO6_cjs.requireAuth(), chunkBYLQOBO6
|
|
|
2092
2092
|
const cache = chunk4BTBSXMR_cjs.getCacheService(chunk4BTBSXMR_cjs.CACHE_CONFIGS.api);
|
|
2093
2093
|
await cache.invalidate("content-filtered:*");
|
|
2094
2094
|
await cache.invalidate("collection-content-filtered:*");
|
|
2095
|
-
const coll =
|
|
2095
|
+
const coll = chunkKPQ57HAH_cjs.getCollectionRegistry().getByName(docRow.type_id);
|
|
2096
2096
|
const saved = await db.prepare("SELECT * FROM documents WHERE id = ?").bind(newDraft.id).first();
|
|
2097
2097
|
const savedData = saved?.data ? JSON.parse(saved.data) : {};
|
|
2098
2098
|
dispatchHookEvent(c, "content:after:update", { collection: docRow.type_id, id, data: savedData, user: actor }, "fire-and-forget");
|
|
@@ -2104,13 +2104,13 @@ apiRoutes.put("/:collection/:id", chunkBYLQOBO6_cjs.requireAuth(), chunkBYLQOBO6
|
|
|
2104
2104
|
return c.json({ error: "Failed to update content", details: error instanceof Error ? error.message : String(error) }, 500);
|
|
2105
2105
|
}
|
|
2106
2106
|
});
|
|
2107
|
-
apiRoutes.delete("/:collection/:id",
|
|
2107
|
+
apiRoutes.delete("/:collection/:id", chunkVMBQ6NQB_cjs.requireAuth(), chunkVMBQ6NQB_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
2108
2108
|
try {
|
|
2109
2109
|
const collection = c.req.param("collection");
|
|
2110
2110
|
const id = c.req.param("id");
|
|
2111
2111
|
const db = c.env.DB;
|
|
2112
2112
|
const user = c.get("user");
|
|
2113
|
-
const collRecord =
|
|
2113
|
+
const collRecord = chunkKPQ57HAH_cjs.getCollectionRegistry().getBySlugOrName(collection);
|
|
2114
2114
|
const typeName = collRecord?.name ?? collection;
|
|
2115
2115
|
const docRow = await db.prepare("SELECT type_id FROM documents WHERE root_id = ? AND type_id = ? AND tenant_id = 'default' AND deleted_at IS NULL LIMIT 1").bind(id, typeName).first();
|
|
2116
2116
|
if (!docRow) return c.json({ error: "Content not found" }, 404);
|
|
@@ -2325,7 +2325,7 @@ var fileValidationSchema = zod.z.object({
|
|
|
2325
2325
|
// 50MB max
|
|
2326
2326
|
});
|
|
2327
2327
|
var apiMediaRoutes = new hono.Hono();
|
|
2328
|
-
apiMediaRoutes.use("*",
|
|
2328
|
+
apiMediaRoutes.use("*", chunkVMBQ6NQB_cjs.requireAuth());
|
|
2329
2329
|
apiMediaRoutes.post("/upload", async (c) => {
|
|
2330
2330
|
try {
|
|
2331
2331
|
const user = c.get("user");
|
|
@@ -3023,7 +3023,7 @@ apiSystemRoutes.get("/info", (c) => {
|
|
|
3023
3023
|
apiSystemRoutes.get("/stats", async (c) => {
|
|
3024
3024
|
try {
|
|
3025
3025
|
const db = c.env.DB;
|
|
3026
|
-
const typeIds =
|
|
3026
|
+
const typeIds = chunkKPQ57HAH_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal).map((r) => r.name);
|
|
3027
3027
|
let contentStats = null;
|
|
3028
3028
|
if (typeIds.length > 0) {
|
|
3029
3029
|
const placeholders = typeIds.map(() => "?").join(",");
|
|
@@ -3098,12 +3098,12 @@ apiSystemRoutes.get("/env", (c) => {
|
|
|
3098
3098
|
});
|
|
3099
3099
|
var api_system_default = apiSystemRoutes;
|
|
3100
3100
|
var adminApiRoutes = new hono.Hono();
|
|
3101
|
-
adminApiRoutes.use("*",
|
|
3102
|
-
adminApiRoutes.use("*",
|
|
3101
|
+
adminApiRoutes.use("*", chunkVMBQ6NQB_cjs.requireAuth());
|
|
3102
|
+
adminApiRoutes.use("*", chunkVMBQ6NQB_cjs.requireRole(["admin", "editor"]));
|
|
3103
3103
|
adminApiRoutes.get("/stats", async (c) => {
|
|
3104
3104
|
try {
|
|
3105
3105
|
const db = c.env.DB;
|
|
3106
|
-
const userCollections =
|
|
3106
|
+
const userCollections = chunkKPQ57HAH_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal);
|
|
3107
3107
|
const collectionsCount = userCollections.length;
|
|
3108
3108
|
let contentCount = 0;
|
|
3109
3109
|
if (userCollections.length > 0) {
|
|
@@ -3194,7 +3194,7 @@ adminApiRoutes.get("/collections", async (c) => {
|
|
|
3194
3194
|
try {
|
|
3195
3195
|
const search = c.req.query("search") || "";
|
|
3196
3196
|
const includeInactive = c.req.query("includeInactive") === "true";
|
|
3197
|
-
let records =
|
|
3197
|
+
let records = chunkKPQ57HAH_cjs.getCollectionRegistry().list().filter((r) => !r.internal);
|
|
3198
3198
|
if (!includeInactive) records = records.filter((r) => r.isActive !== false);
|
|
3199
3199
|
if (search) {
|
|
3200
3200
|
const needle = search.toLowerCase();
|
|
@@ -3226,7 +3226,7 @@ adminApiRoutes.get("/collections", async (c) => {
|
|
|
3226
3226
|
adminApiRoutes.get("/collections/:id", async (c) => {
|
|
3227
3227
|
try {
|
|
3228
3228
|
const id = c.req.param("id");
|
|
3229
|
-
const registry =
|
|
3229
|
+
const registry = chunkKPQ57HAH_cjs.getCollectionRegistry();
|
|
3230
3230
|
const record = registry.getById(id) ?? registry.getByName(id);
|
|
3231
3231
|
if (!record) {
|
|
3232
3232
|
return c.json({ error: "Collection not found" }, 404);
|
|
@@ -3276,7 +3276,7 @@ adminApiRoutes.get("/references", async (c) => {
|
|
|
3276
3276
|
if (collectionParams.length === 0) {
|
|
3277
3277
|
return c.json({ error: "Collection is required" }, 400);
|
|
3278
3278
|
}
|
|
3279
|
-
const registry =
|
|
3279
|
+
const registry = chunkKPQ57HAH_cjs.getCollectionRegistry();
|
|
3280
3280
|
const matched = collectionParams.map((param) => registry.getById(param) ?? registry.getByName(param)).filter((r) => !!r);
|
|
3281
3281
|
const seen = /* @__PURE__ */ new Set();
|
|
3282
3282
|
const collections = matched.filter((r) => {
|
|
@@ -3391,7 +3391,7 @@ adminApiRoutes.patch("/collections/:id", collectionsReadOnly);
|
|
|
3391
3391
|
adminApiRoutes.delete("/collections/:id", collectionsReadOnly);
|
|
3392
3392
|
adminApiRoutes.get("/migrations/status", async (c) => {
|
|
3393
3393
|
try {
|
|
3394
|
-
const { MigrationService: MigrationService2 } = await import('./migrations-
|
|
3394
|
+
const { MigrationService: MigrationService2 } = await import('./migrations-XOXYLHHU.cjs');
|
|
3395
3395
|
const db = c.env.DB;
|
|
3396
3396
|
const migrationService = new MigrationService2(db);
|
|
3397
3397
|
const status = await migrationService.getMigrationStatus();
|
|
@@ -3434,7 +3434,7 @@ adminApiRoutes.post("/migrations/run", async (c) => {
|
|
|
3434
3434
|
});
|
|
3435
3435
|
adminApiRoutes.get("/migrations/validate", async (c) => {
|
|
3436
3436
|
try {
|
|
3437
|
-
const { MigrationService: MigrationService2 } = await import('./migrations-
|
|
3437
|
+
const { MigrationService: MigrationService2 } = await import('./migrations-XOXYLHHU.cjs');
|
|
3438
3438
|
const db = c.env.DB;
|
|
3439
3439
|
const migrationService = new MigrationService2(db);
|
|
3440
3440
|
const validation = await migrationService.validateSchema();
|
|
@@ -3849,7 +3849,7 @@ function renderRegisterPage(data) {
|
|
|
3849
3849
|
}
|
|
3850
3850
|
|
|
3851
3851
|
// src/services/email/email-service-singleton.ts
|
|
3852
|
-
var singleton =
|
|
3852
|
+
var singleton = chunkPZGGIJI6_cjs.createServiceSingleton("EmailService");
|
|
3853
3853
|
function setEmailService(service2) {
|
|
3854
3854
|
singleton.set(service2);
|
|
3855
3855
|
}
|
|
@@ -4657,7 +4657,7 @@ function getLexicalInitScript(settings = {}) {
|
|
|
4657
4657
|
</script>
|
|
4658
4658
|
`;
|
|
4659
4659
|
}
|
|
4660
|
-
var lexicalEditorPlugin =
|
|
4660
|
+
var lexicalEditorPlugin = chunkPZGGIJI6_cjs.definePlugin({
|
|
4661
4661
|
id: "lexical-editor",
|
|
4662
4662
|
version: "1.0.0",
|
|
4663
4663
|
name: "Lexical Editor",
|
|
@@ -6876,7 +6876,7 @@ api.put("/:userId", async (c) => {
|
|
|
6876
6876
|
await saveCustomData(db, userId, sanitized);
|
|
6877
6877
|
return c.json({ success: true });
|
|
6878
6878
|
});
|
|
6879
|
-
var userProfilesPlugin =
|
|
6879
|
+
var userProfilesPlugin = chunkPZGGIJI6_cjs.definePlugin({
|
|
6880
6880
|
id: "user-profiles",
|
|
6881
6881
|
version: "1.0.0",
|
|
6882
6882
|
name: "User Profiles",
|
|
@@ -6914,8 +6914,8 @@ function renderPasswordResetEmail(resetLink, firstName) {
|
|
|
6914
6914
|
async function setCsrfCookie(c, maxAge) {
|
|
6915
6915
|
const secret = c.env?.JWT_SECRET || JWT_SECRET_FALLBACK;
|
|
6916
6916
|
const isDev = c.env?.ENVIRONMENT === "development" || !c.env?.ENVIRONMENT;
|
|
6917
|
-
const csrfToken = await
|
|
6918
|
-
const cookieMaxAge = await
|
|
6917
|
+
const csrfToken = await chunkVMBQ6NQB_cjs.generateCsrfToken(secret);
|
|
6918
|
+
const cookieMaxAge = await chunkVMBQ6NQB_cjs.getJwtExpirySecondsFromDb(c.env?.DB, c.env);
|
|
6919
6919
|
cookie.setCookie(c, "csrf_token", csrfToken, {
|
|
6920
6920
|
httpOnly: false,
|
|
6921
6921
|
secure: !isDev,
|
|
@@ -6972,7 +6972,7 @@ var loginSchema = zod.z.object({
|
|
|
6972
6972
|
});
|
|
6973
6973
|
authRoutes.post(
|
|
6974
6974
|
"/register",
|
|
6975
|
-
|
|
6975
|
+
chunkVMBQ6NQB_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "register" }),
|
|
6976
6976
|
async (c) => {
|
|
6977
6977
|
try {
|
|
6978
6978
|
const db = c.env.DB;
|
|
@@ -7008,7 +7008,7 @@ authRoutes.post(
|
|
|
7008
7008
|
if (existingUser) {
|
|
7009
7009
|
return c.json({ error: "User with this email already exists" }, 400);
|
|
7010
7010
|
}
|
|
7011
|
-
const passwordHash = await
|
|
7011
|
+
const passwordHash = await chunkVMBQ6NQB_cjs.AuthManager.hashPassword(password);
|
|
7012
7012
|
const userId = crypto.randomUUID();
|
|
7013
7013
|
const now = /* @__PURE__ */ new Date();
|
|
7014
7014
|
const nowSec = Math.floor(now.getTime() / 1e3);
|
|
@@ -7041,8 +7041,8 @@ authRoutes.post(
|
|
|
7041
7041
|
{ user: { id: userId, email: normalizedEmail, role: "viewer" } },
|
|
7042
7042
|
"fire-and-forget"
|
|
7043
7043
|
);
|
|
7044
|
-
const tokenTtl = await
|
|
7045
|
-
const token = await
|
|
7044
|
+
const tokenTtl = await chunkVMBQ6NQB_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
|
|
7045
|
+
const token = await chunkVMBQ6NQB_cjs.AuthManager.generateToken(userId, normalizedEmail, "viewer", c.env.JWT_SECRET, tokenTtl);
|
|
7046
7046
|
cookie.setCookie(c, "auth_token", token, {
|
|
7047
7047
|
httpOnly: true,
|
|
7048
7048
|
secure: true,
|
|
@@ -7074,7 +7074,7 @@ authRoutes.post(
|
|
|
7074
7074
|
);
|
|
7075
7075
|
authRoutes.post(
|
|
7076
7076
|
"/login",
|
|
7077
|
-
|
|
7077
|
+
chunkVMBQ6NQB_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "login" }),
|
|
7078
7078
|
async (c) => {
|
|
7079
7079
|
try {
|
|
7080
7080
|
const body = await c.req.json();
|
|
@@ -7106,6 +7106,20 @@ authRoutes.post(
|
|
|
7106
7106
|
await setCsrfCookie(c);
|
|
7107
7107
|
const baBody = await baRes.json();
|
|
7108
7108
|
const user = baBody.user ?? {};
|
|
7109
|
+
const tokenTtl = await chunkVMBQ6NQB_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
|
|
7110
|
+
const token = await chunkVMBQ6NQB_cjs.AuthManager.generateToken(
|
|
7111
|
+
user.id,
|
|
7112
|
+
user.email,
|
|
7113
|
+
user.role ?? "viewer",
|
|
7114
|
+
c.env.JWT_SECRET,
|
|
7115
|
+
tokenTtl
|
|
7116
|
+
);
|
|
7117
|
+
cookie.setCookie(c, "auth_token", token, {
|
|
7118
|
+
httpOnly: true,
|
|
7119
|
+
secure: true,
|
|
7120
|
+
sameSite: "Strict",
|
|
7121
|
+
maxAge: tokenTtl
|
|
7122
|
+
});
|
|
7109
7123
|
return c.json({
|
|
7110
7124
|
user: {
|
|
7111
7125
|
id: user.id,
|
|
@@ -7113,7 +7127,8 @@ authRoutes.post(
|
|
|
7113
7127
|
firstName: user.name?.split(" ")[0] ?? "",
|
|
7114
7128
|
lastName: user.name?.split(" ").slice(1).join(" ") ?? "",
|
|
7115
7129
|
role: user.role ?? "viewer"
|
|
7116
|
-
}
|
|
7130
|
+
},
|
|
7131
|
+
token
|
|
7117
7132
|
});
|
|
7118
7133
|
} catch (error) {
|
|
7119
7134
|
console.error("Login error:", error);
|
|
@@ -7153,7 +7168,7 @@ authRoutes.get("/logout", async (c) => {
|
|
|
7153
7168
|
clearCsrfCookie(c);
|
|
7154
7169
|
return c.redirect("/auth/login?message=You have been logged out successfully");
|
|
7155
7170
|
});
|
|
7156
|
-
authRoutes.get("/me",
|
|
7171
|
+
authRoutes.get("/me", chunkVMBQ6NQB_cjs.requireAuth(), async (c) => {
|
|
7157
7172
|
try {
|
|
7158
7173
|
const user = c.get("user");
|
|
7159
7174
|
if (!user) {
|
|
@@ -7173,7 +7188,7 @@ authRoutes.get("/me", chunkBYLQOBO6_cjs.requireAuth(), async (c) => {
|
|
|
7173
7188
|
});
|
|
7174
7189
|
authRoutes.post(
|
|
7175
7190
|
"/refresh",
|
|
7176
|
-
|
|
7191
|
+
chunkVMBQ6NQB_cjs.rateLimit({ max: 60, windowMs: 60 * 1e3, keyPrefix: "refresh" }),
|
|
7177
7192
|
async (c) => {
|
|
7178
7193
|
try {
|
|
7179
7194
|
let token = c.req.header("Authorization")?.replace("Bearer ", "");
|
|
@@ -7182,8 +7197,8 @@ authRoutes.post(
|
|
|
7182
7197
|
return c.json({ error: "Authentication required" }, 401);
|
|
7183
7198
|
}
|
|
7184
7199
|
const db = c.env.DB;
|
|
7185
|
-
const grace = await
|
|
7186
|
-
const payload = await
|
|
7200
|
+
const grace = await chunkVMBQ6NQB_cjs.getJwtRefreshGraceSecondsFromDb(db, c.env);
|
|
7201
|
+
const payload = await chunkVMBQ6NQB_cjs.AuthManager.verifyToken(token, c.env.JWT_SECRET, grace);
|
|
7187
7202
|
if (!payload) {
|
|
7188
7203
|
return c.json({ error: "Invalid or expired token" }, 401);
|
|
7189
7204
|
}
|
|
@@ -7191,8 +7206,8 @@ authRoutes.post(
|
|
|
7191
7206
|
if (!row || !row.is_active) {
|
|
7192
7207
|
return c.json({ error: "User is not active" }, 401);
|
|
7193
7208
|
}
|
|
7194
|
-
const tokenTtl = await
|
|
7195
|
-
const newToken = await
|
|
7209
|
+
const tokenTtl = await chunkVMBQ6NQB_cjs.getJwtExpirySecondsFromDb(db, c.env);
|
|
7210
|
+
const newToken = await chunkVMBQ6NQB_cjs.AuthManager.generateToken(row.id, row.email, row.role, c.env.JWT_SECRET, tokenTtl);
|
|
7196
7211
|
cookie.setCookie(c, "auth_token", newToken, {
|
|
7197
7212
|
httpOnly: true,
|
|
7198
7213
|
secure: true,
|
|
@@ -7212,7 +7227,7 @@ authRoutes.post(
|
|
|
7212
7227
|
);
|
|
7213
7228
|
authRoutes.post(
|
|
7214
7229
|
"/register/form",
|
|
7215
|
-
|
|
7230
|
+
chunkVMBQ6NQB_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "register" }),
|
|
7216
7231
|
async (c) => {
|
|
7217
7232
|
try {
|
|
7218
7233
|
const db = c.env.DB;
|
|
@@ -7257,7 +7272,7 @@ authRoutes.post(
|
|
|
7257
7272
|
</div>
|
|
7258
7273
|
`);
|
|
7259
7274
|
}
|
|
7260
|
-
const passwordHash = await
|
|
7275
|
+
const passwordHash = await chunkVMBQ6NQB_cjs.AuthManager.hashPassword(password);
|
|
7261
7276
|
const role = isFirstUser ? "admin" : "viewer";
|
|
7262
7277
|
const userId = crypto.randomUUID();
|
|
7263
7278
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -7299,8 +7314,8 @@ authRoutes.post(
|
|
|
7299
7314
|
{ user: { id: userId, email: normalizedEmail, role } },
|
|
7300
7315
|
"fire-and-forget"
|
|
7301
7316
|
);
|
|
7302
|
-
const tokenTtl = await
|
|
7303
|
-
const token = await
|
|
7317
|
+
const tokenTtl = await chunkVMBQ6NQB_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
|
|
7318
|
+
const token = await chunkVMBQ6NQB_cjs.AuthManager.generateToken(userId, normalizedEmail, role, c.env.JWT_SECRET, tokenTtl);
|
|
7304
7319
|
cookie.setCookie(c, "auth_token", token, {
|
|
7305
7320
|
httpOnly: true,
|
|
7306
7321
|
secure: false,
|
|
@@ -7332,7 +7347,7 @@ authRoutes.post(
|
|
|
7332
7347
|
);
|
|
7333
7348
|
authRoutes.post(
|
|
7334
7349
|
"/login/form",
|
|
7335
|
-
|
|
7350
|
+
chunkVMBQ6NQB_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "login" }),
|
|
7336
7351
|
async (c) => {
|
|
7337
7352
|
try {
|
|
7338
7353
|
const formData = await c.req.formData();
|
|
@@ -7399,14 +7414,14 @@ authRoutes.post(
|
|
|
7399
7414
|
);
|
|
7400
7415
|
authRoutes.post(
|
|
7401
7416
|
"/seed-admin",
|
|
7402
|
-
|
|
7417
|
+
chunkVMBQ6NQB_cjs.rateLimit({ max: 10, windowMs: 60 * 1e3, keyPrefix: "seed-admin" }),
|
|
7403
7418
|
async (c) => {
|
|
7404
7419
|
try {
|
|
7405
7420
|
const db = c.env.DB;
|
|
7406
7421
|
const rbac = new chunk2CB4KY7I_cjs.RbacService(db);
|
|
7407
7422
|
const results = [];
|
|
7408
7423
|
const upsertSeedUser = async (opts) => {
|
|
7409
|
-
const passwordHash = await
|
|
7424
|
+
const passwordHash = await chunkVMBQ6NQB_cjs.AuthManager.hashPassword(opts.password);
|
|
7410
7425
|
const nowMs = Date.now();
|
|
7411
7426
|
const nowSec = Math.floor(nowMs / 1e3);
|
|
7412
7427
|
const existing = await db.prepare("SELECT id FROM auth_user WHERE email = ?").bind(opts.email).first();
|
|
@@ -7631,7 +7646,7 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
7631
7646
|
if (invitationAge > maxAge) {
|
|
7632
7647
|
return c.json({ error: "Invitation has expired" }, 400);
|
|
7633
7648
|
}
|
|
7634
|
-
const passwordHash = await
|
|
7649
|
+
const passwordHash = await chunkVMBQ6NQB_cjs.AuthManager.hashPassword(password);
|
|
7635
7650
|
const updateStmt = db.prepare(`
|
|
7636
7651
|
UPDATE auth_user SET
|
|
7637
7652
|
password_hash = ?,
|
|
@@ -7648,8 +7663,8 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
7648
7663
|
Date.now(),
|
|
7649
7664
|
invitedUser.id
|
|
7650
7665
|
).run();
|
|
7651
|
-
const tokenTtl = await
|
|
7652
|
-
const authToken = await
|
|
7666
|
+
const tokenTtl = await chunkVMBQ6NQB_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
|
|
7667
|
+
const authToken = await chunkVMBQ6NQB_cjs.AuthManager.generateToken(invitedUser.id, invitedUser.email, invitedUser.role, c.env.JWT_SECRET, tokenTtl);
|
|
7653
7668
|
cookie.setCookie(c, "auth_token", authToken, {
|
|
7654
7669
|
httpOnly: true,
|
|
7655
7670
|
secure: true,
|
|
@@ -7665,7 +7680,7 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
7665
7680
|
});
|
|
7666
7681
|
authRoutes.post(
|
|
7667
7682
|
"/request-password-reset",
|
|
7668
|
-
|
|
7683
|
+
chunkVMBQ6NQB_cjs.rateLimit({ max: 3, windowMs: 15 * 60 * 1e3, keyPrefix: "password-reset" }),
|
|
7669
7684
|
async (c) => {
|
|
7670
7685
|
try {
|
|
7671
7686
|
const formData = await c.req.formData();
|
|
@@ -7902,7 +7917,7 @@ authRoutes.post("/reset-password", async (c) => {
|
|
|
7902
7917
|
if (Date.now() > user.password_reset_expires) {
|
|
7903
7918
|
return c.json({ error: "Reset token has expired" }, 400);
|
|
7904
7919
|
}
|
|
7905
|
-
const newPasswordHash = await
|
|
7920
|
+
const newPasswordHash = await chunkVMBQ6NQB_cjs.AuthManager.hashPassword(password);
|
|
7906
7921
|
try {
|
|
7907
7922
|
const historyStmt = db.prepare(`
|
|
7908
7923
|
INSERT INTO auth_password_history (id, user_id, password_hash, created_at)
|
|
@@ -8116,7 +8131,7 @@ app.post("/test-seed-defaults", async (c) => {
|
|
|
8116
8131
|
var test_cleanup_default = app;
|
|
8117
8132
|
|
|
8118
8133
|
// src/plugins/available/easy-mdx/index.ts
|
|
8119
|
-
|
|
8134
|
+
chunkPZGGIJI6_cjs.definePlugin({
|
|
8120
8135
|
id: "easy-mdx",
|
|
8121
8136
|
version: "1.0.0",
|
|
8122
8137
|
name: "EasyMDE Markdown Editor",
|
|
@@ -8316,7 +8331,7 @@ function getMDXEditorInitScript(config) {
|
|
|
8316
8331
|
}
|
|
8317
8332
|
|
|
8318
8333
|
// src/plugins/available/tinymce-plugin/index.ts
|
|
8319
|
-
|
|
8334
|
+
chunkPZGGIJI6_cjs.definePlugin({
|
|
8320
8335
|
id: "tinymce-plugin",
|
|
8321
8336
|
version: "1.0.0",
|
|
8322
8337
|
name: "TinyMCE",
|
|
@@ -8586,7 +8601,7 @@ function getQuillCDN(version = "2.0.2") {
|
|
|
8586
8601
|
</style>
|
|
8587
8602
|
`;
|
|
8588
8603
|
}
|
|
8589
|
-
|
|
8604
|
+
chunkPZGGIJI6_cjs.definePlugin({
|
|
8590
8605
|
id: "quill-editor",
|
|
8591
8606
|
version: "1.0.0",
|
|
8592
8607
|
name: "Quill Editor",
|
|
@@ -11160,7 +11175,7 @@ function extractFieldData(fields, formData, options = {}) {
|
|
|
11160
11175
|
}
|
|
11161
11176
|
return { data, errors };
|
|
11162
11177
|
}
|
|
11163
|
-
adminContentRoutes.use("*",
|
|
11178
|
+
adminContentRoutes.use("*", chunkVMBQ6NQB_cjs.requireAuth());
|
|
11164
11179
|
async function getCollectionFields(db, collectionId) {
|
|
11165
11180
|
console.log(`[getCollectionFields] Loading fields for collection: ${collectionId}`);
|
|
11166
11181
|
const collectionStmt = db.prepare("SELECT schema, queryable_fields FROM document_types WHERE id = ?");
|
|
@@ -11187,7 +11202,7 @@ async function getCollectionFields(db, collectionId) {
|
|
|
11187
11202
|
};
|
|
11188
11203
|
});
|
|
11189
11204
|
}
|
|
11190
|
-
const codeCollections2 = await
|
|
11205
|
+
const codeCollections2 = await chunkKPQ57HAH_cjs.loadCollectionConfigs();
|
|
11191
11206
|
const codeMatch = codeCollections2.find((c) => c.name === collectionId);
|
|
11192
11207
|
if (codeMatch && codeMatch.schema?.properties) {
|
|
11193
11208
|
console.log(`[getCollectionFields] DB doc type has no properties \u2014 using code collection schema`);
|
|
@@ -11219,7 +11234,7 @@ async function getCollectionFields(db, collectionId) {
|
|
|
11219
11234
|
}
|
|
11220
11235
|
}
|
|
11221
11236
|
console.log(`[getCollectionFields] Not in database, checking code collections`);
|
|
11222
|
-
const codeCollections = await
|
|
11237
|
+
const codeCollections = await chunkKPQ57HAH_cjs.loadCollectionConfigs();
|
|
11223
11238
|
console.log(`[getCollectionFields] Found ${codeCollections.length} code collections`);
|
|
11224
11239
|
const codeCollection = codeCollections.find((c) => c.name === collectionId);
|
|
11225
11240
|
if (codeCollection && codeCollection.schema) {
|
|
@@ -11273,7 +11288,7 @@ async function getCollection(db, collectionId) {
|
|
|
11273
11288
|
};
|
|
11274
11289
|
}
|
|
11275
11290
|
console.log(`[getCollection] Not in database, checking code collections`);
|
|
11276
|
-
const codeCollections = await
|
|
11291
|
+
const codeCollections = await chunkKPQ57HAH_cjs.loadCollectionConfigs();
|
|
11277
11292
|
const codeCollection = codeCollections.find((c) => c.name === collectionId);
|
|
11278
11293
|
if (codeCollection) {
|
|
11279
11294
|
console.log(`[getCollection] Found code collection: ${collectionId}`);
|
|
@@ -11292,7 +11307,7 @@ async function getCollection(db, collectionId) {
|
|
|
11292
11307
|
}
|
|
11293
11308
|
async function getDocBackingType(db, collectionName) {
|
|
11294
11309
|
if (!collectionName) return null;
|
|
11295
|
-
const dt = await new
|
|
11310
|
+
const dt = await new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db).findById(collectionName);
|
|
11296
11311
|
return dt && dt.isActive ? dt : null;
|
|
11297
11312
|
}
|
|
11298
11313
|
async function getCollectionByName(db, name) {
|
|
@@ -11309,7 +11324,7 @@ async function getCollectionByName(db, name) {
|
|
|
11309
11324
|
};
|
|
11310
11325
|
}
|
|
11311
11326
|
console.log(`[getCollectionByName] Not in database, checking code collections`);
|
|
11312
|
-
const codeCollections = await
|
|
11327
|
+
const codeCollections = await chunkKPQ57HAH_cjs.loadCollectionConfigs();
|
|
11313
11328
|
const codeCollection = codeCollections.find((c) => c.name === name);
|
|
11314
11329
|
if (codeCollection) {
|
|
11315
11330
|
console.log(`[getCollectionByName] Found code collection: ${name}`);
|
|
@@ -11325,7 +11340,7 @@ async function getCollectionByName(db, name) {
|
|
|
11325
11340
|
return null;
|
|
11326
11341
|
}
|
|
11327
11342
|
async function loadContentEditorFlags(db) {
|
|
11328
|
-
const flags = { workflowEnabled: await
|
|
11343
|
+
const flags = { workflowEnabled: await chunkVMBQ6NQB_cjs.isPluginActive(db, "workflow") };
|
|
11329
11344
|
const editors = [
|
|
11330
11345
|
["tinymce-plugin", "tinymce"],
|
|
11331
11346
|
["quill-editor", "quill"],
|
|
@@ -11333,10 +11348,10 @@ async function loadContentEditorFlags(db) {
|
|
|
11333
11348
|
["lexical-editor", "lexical"]
|
|
11334
11349
|
];
|
|
11335
11350
|
for (const [plugin, key] of editors) {
|
|
11336
|
-
const enabled = await
|
|
11351
|
+
const enabled = await chunkVMBQ6NQB_cjs.isPluginActive(db, plugin);
|
|
11337
11352
|
flags[`${key}Enabled`] = enabled;
|
|
11338
11353
|
if (enabled) {
|
|
11339
|
-
const ps = new
|
|
11354
|
+
const ps = new chunkKPQ57HAH_cjs.PluginService(db);
|
|
11340
11355
|
const p = await ps.getPlugin(plugin);
|
|
11341
11356
|
flags[`${key}Settings`] = p?.settings;
|
|
11342
11357
|
}
|
|
@@ -11372,9 +11387,9 @@ adminContentRoutes.get("/", async (c) => {
|
|
|
11372
11387
|
const offset = (page - 1) * limit;
|
|
11373
11388
|
const collectionsStmt = db.prepare("SELECT id, name, display_name FROM document_types WHERE is_active = 1 ORDER BY display_name");
|
|
11374
11389
|
const { results: collectionsResults } = await collectionsStmt.all();
|
|
11375
|
-
const codeCollections = await
|
|
11390
|
+
const codeCollections = await chunkKPQ57HAH_cjs.loadCollectionConfigs();
|
|
11376
11391
|
const codeCollectionMap = new Map(codeCollections.map((c2) => [c2.name, c2]));
|
|
11377
|
-
const docTypeRegistry = new
|
|
11392
|
+
const docTypeRegistry = new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db);
|
|
11378
11393
|
const docTypes = (await docTypeRegistry.findAll()).filter((dt) => !dt.settings?.internal && !dt.isAuth);
|
|
11379
11394
|
const visibleTypeIds = new Set(docTypes.map((dt) => dt.id));
|
|
11380
11395
|
const allCollections = [
|
|
@@ -11386,7 +11401,7 @@ adminContentRoutes.get("/", async (c) => {
|
|
|
11386
11401
|
...allCollections.map((c2) => ({ name: c2.name, displayName: c2.displayName })),
|
|
11387
11402
|
...docTypes.filter((dt) => !collectionNames.has(dt.id)).map((dt) => ({ name: `doc:${dt.id}`, displayName: dt.displayName }))
|
|
11388
11403
|
];
|
|
11389
|
-
const newContentCollections = await
|
|
11404
|
+
const newContentCollections = await chunkKPQ57HAH_cjs.getVisibleCollections(db);
|
|
11390
11405
|
const docBackedCollection = !modelName.startsWith("doc:") && modelName !== "all" ? docTypes.find((dt) => dt.id === modelName) : void 0;
|
|
11391
11406
|
const isDocModel = modelName.startsWith("doc:") || !!docBackedCollection;
|
|
11392
11407
|
if (isDocModel) {
|
|
@@ -11663,9 +11678,9 @@ adminContentRoutes.get("/new", async (c) => {
|
|
|
11663
11678
|
const collectionsStmt = db2.prepare("SELECT id, name, display_name, description FROM document_types WHERE is_active = 1 ORDER BY display_name");
|
|
11664
11679
|
const { results } = await collectionsStmt.all();
|
|
11665
11680
|
const visibleTypeIds = new Set(
|
|
11666
|
-
(await new
|
|
11681
|
+
(await new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db2).findAll()).filter((dt) => !dt.settings?.internal && !dt.isAuth).map((dt) => dt.id)
|
|
11667
11682
|
);
|
|
11668
|
-
const codeCollections = await
|
|
11683
|
+
const codeCollections = await chunkKPQ57HAH_cjs.loadCollectionConfigs();
|
|
11669
11684
|
const dbCollectionNames = new Set((results || []).map((r) => r.name));
|
|
11670
11685
|
const allCollections = [
|
|
11671
11686
|
...codeCollections.filter((c2) => !dbCollectionNames.has(c2.name)).map((c2) => ({
|
|
@@ -11731,32 +11746,32 @@ adminContentRoutes.get("/new", async (c) => {
|
|
|
11731
11746
|
return c.html(renderContentFormPage(formData2));
|
|
11732
11747
|
}
|
|
11733
11748
|
const fields = await getCollectionFields(db, collection.id);
|
|
11734
|
-
const workflowEnabled = await
|
|
11735
|
-
const tinymceEnabled = await
|
|
11749
|
+
const workflowEnabled = await chunkVMBQ6NQB_cjs.isPluginActive(db, "workflow");
|
|
11750
|
+
const tinymceEnabled = await chunkVMBQ6NQB_cjs.isPluginActive(db, "tinymce-plugin");
|
|
11736
11751
|
let tinymceSettings;
|
|
11737
11752
|
if (tinymceEnabled) {
|
|
11738
|
-
const pluginService = new
|
|
11753
|
+
const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
|
|
11739
11754
|
const tinymcePlugin2 = await pluginService.getPlugin("tinymce-plugin");
|
|
11740
11755
|
tinymceSettings = tinymcePlugin2?.settings;
|
|
11741
11756
|
}
|
|
11742
|
-
const quillEnabled = await
|
|
11757
|
+
const quillEnabled = await chunkVMBQ6NQB_cjs.isPluginActive(db, "quill-editor");
|
|
11743
11758
|
let quillSettings;
|
|
11744
11759
|
if (quillEnabled) {
|
|
11745
|
-
const pluginService = new
|
|
11760
|
+
const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
|
|
11746
11761
|
const quillPlugin = await pluginService.getPlugin("quill-editor");
|
|
11747
11762
|
quillSettings = quillPlugin?.settings;
|
|
11748
11763
|
}
|
|
11749
|
-
const mdxeditorEnabled = await
|
|
11764
|
+
const mdxeditorEnabled = await chunkVMBQ6NQB_cjs.isPluginActive(db, "easy-mdx");
|
|
11750
11765
|
let mdxeditorSettings;
|
|
11751
11766
|
if (mdxeditorEnabled) {
|
|
11752
|
-
const pluginService = new
|
|
11767
|
+
const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
|
|
11753
11768
|
const mdxeditorPlugin = await pluginService.getPlugin("easy-mdx");
|
|
11754
11769
|
mdxeditorSettings = mdxeditorPlugin?.settings;
|
|
11755
11770
|
}
|
|
11756
|
-
const lexicalEnabled = await
|
|
11771
|
+
const lexicalEnabled = await chunkVMBQ6NQB_cjs.isPluginActive(db, "lexical-editor");
|
|
11757
11772
|
let lexicalSettings;
|
|
11758
11773
|
if (lexicalEnabled) {
|
|
11759
|
-
const pluginService = new
|
|
11774
|
+
const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
|
|
11760
11775
|
const lexicalPlugin = await pluginService.getPlugin("lexical-editor");
|
|
11761
11776
|
lexicalSettings = lexicalPlugin?.settings;
|
|
11762
11777
|
}
|
|
@@ -11884,32 +11899,32 @@ adminContentRoutes.get("/:id/edit", async (c) => {
|
|
|
11884
11899
|
};
|
|
11885
11900
|
const fields = await getCollectionFields(db, content.collection_id);
|
|
11886
11901
|
const contentData = content.data ? JSON.parse(content.data) : {};
|
|
11887
|
-
const workflowEnabled = await
|
|
11888
|
-
const tinymceEnabled = await
|
|
11902
|
+
const workflowEnabled = await chunkVMBQ6NQB_cjs.isPluginActive(db, "workflow");
|
|
11903
|
+
const tinymceEnabled = await chunkVMBQ6NQB_cjs.isPluginActive(db, "tinymce-plugin");
|
|
11889
11904
|
let tinymceSettings;
|
|
11890
11905
|
if (tinymceEnabled) {
|
|
11891
|
-
const pluginService = new
|
|
11906
|
+
const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
|
|
11892
11907
|
const tinymcePlugin2 = await pluginService.getPlugin("tinymce-plugin");
|
|
11893
11908
|
tinymceSettings = tinymcePlugin2?.settings;
|
|
11894
11909
|
}
|
|
11895
|
-
const quillEnabled = await
|
|
11910
|
+
const quillEnabled = await chunkVMBQ6NQB_cjs.isPluginActive(db, "quill-editor");
|
|
11896
11911
|
let quillSettings;
|
|
11897
11912
|
if (quillEnabled) {
|
|
11898
|
-
const pluginService = new
|
|
11913
|
+
const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
|
|
11899
11914
|
const quillPlugin = await pluginService.getPlugin("quill-editor");
|
|
11900
11915
|
quillSettings = quillPlugin?.settings;
|
|
11901
11916
|
}
|
|
11902
|
-
const mdxeditorEnabled = await
|
|
11917
|
+
const mdxeditorEnabled = await chunkVMBQ6NQB_cjs.isPluginActive(db, "easy-mdx");
|
|
11903
11918
|
let mdxeditorSettings;
|
|
11904
11919
|
if (mdxeditorEnabled) {
|
|
11905
|
-
const pluginService = new
|
|
11920
|
+
const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
|
|
11906
11921
|
const mdxeditorPlugin = await pluginService.getPlugin("easy-mdx");
|
|
11907
11922
|
mdxeditorSettings = mdxeditorPlugin?.settings;
|
|
11908
11923
|
}
|
|
11909
|
-
const lexicalEnabled = await
|
|
11924
|
+
const lexicalEnabled = await chunkVMBQ6NQB_cjs.isPluginActive(db, "lexical-editor");
|
|
11910
11925
|
let lexicalSettings;
|
|
11911
11926
|
if (lexicalEnabled) {
|
|
11912
|
-
const pluginService = new
|
|
11927
|
+
const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
|
|
11913
11928
|
const lexicalPlugin = await pluginService.getPlugin("lexical-editor");
|
|
11914
11929
|
lexicalSettings = lexicalPlugin?.settings;
|
|
11915
11930
|
}
|
|
@@ -12282,7 +12297,7 @@ adminContentRoutes.put("/:id", async (c) => {
|
|
|
12282
12297
|
`);
|
|
12283
12298
|
}
|
|
12284
12299
|
});
|
|
12285
|
-
adminContentRoutes.post("/preview",
|
|
12300
|
+
adminContentRoutes.post("/preview", chunkVMBQ6NQB_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
12286
12301
|
try {
|
|
12287
12302
|
const formData = await c.req.formData();
|
|
12288
12303
|
const collectionId = formData.get("collection_id");
|
|
@@ -12601,7 +12616,7 @@ adminContentRoutes.delete("/:id", async (c) => {
|
|
|
12601
12616
|
return c.json({ success: false, error: "Failed to delete content" }, 500);
|
|
12602
12617
|
}
|
|
12603
12618
|
});
|
|
12604
|
-
adminContentRoutes.get("/:id/version/:version/preview",
|
|
12619
|
+
adminContentRoutes.get("/:id/version/:version/preview", chunkVMBQ6NQB_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
12605
12620
|
try {
|
|
12606
12621
|
const id = c.req.param("id");
|
|
12607
12622
|
const version = parseInt(c.req.param("version") || "0");
|
|
@@ -12697,7 +12712,7 @@ function parseDocFormData(formData, queryableFields = []) {
|
|
|
12697
12712
|
return { title, slug, data };
|
|
12698
12713
|
}
|
|
12699
12714
|
async function getDocService(db, typeId, tenantId) {
|
|
12700
|
-
const registry = new
|
|
12715
|
+
const registry = new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db);
|
|
12701
12716
|
const docType = await registry.findById(typeId);
|
|
12702
12717
|
const svc = new chunk2CB4KY7I_cjs.DocumentsService(db, {
|
|
12703
12718
|
queryableFields: docType?.queryableFields ?? [],
|
|
@@ -12710,7 +12725,7 @@ async function getDocService(db, typeId, tenantId) {
|
|
|
12710
12725
|
}
|
|
12711
12726
|
adminContentRoutes.get("/documents/:typeId/new", async (c) => {
|
|
12712
12727
|
const { typeId } = c.req.param();
|
|
12713
|
-
const registry = new
|
|
12728
|
+
const registry = new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(c.env.DB);
|
|
12714
12729
|
const docType = await registry.findById(typeId);
|
|
12715
12730
|
if (!docType) return c.html("<p>Unknown document type.</p>", 404);
|
|
12716
12731
|
return c.html(chunkN32OWET6_cjs.renderDocumentFormPage({ docType, isEdit: false, user: userCtx(c) }));
|
|
@@ -12735,7 +12750,7 @@ adminContentRoutes.post("/documents/:typeId/new", async (c) => {
|
|
|
12735
12750
|
}), user?.userId);
|
|
12736
12751
|
return c.redirect(`/admin/content/documents/${typeId}/${doc.rootId}/edit?message=Created+successfully`);
|
|
12737
12752
|
} catch (err) {
|
|
12738
|
-
const registry = new
|
|
12753
|
+
const registry = new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(c.env.DB);
|
|
12739
12754
|
const docType = await registry.findById(typeId);
|
|
12740
12755
|
if (!docType) return c.html("<p>Unknown document type.</p>", 404);
|
|
12741
12756
|
return c.html(chunkN32OWET6_cjs.renderDocumentFormPage({ docType, isEdit: false, user: userCtx(c), message: err?.message ?? "Failed to create", messageType: "error" }));
|
|
@@ -12745,7 +12760,7 @@ adminContentRoutes.get("/documents/:typeId/:rootId/edit", async (c) => {
|
|
|
12745
12760
|
const { typeId, rootId } = c.req.param();
|
|
12746
12761
|
const db = c.env.DB;
|
|
12747
12762
|
const message = c.req.query("message");
|
|
12748
|
-
const registry = new
|
|
12763
|
+
const registry = new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db);
|
|
12749
12764
|
const docType = await registry.findById(typeId);
|
|
12750
12765
|
if (!docType) return c.html("<p>Unknown document type.</p>", 404);
|
|
12751
12766
|
const tenantId = reqTenant(c);
|
|
@@ -12858,7 +12873,7 @@ adminContentRoutes.get("/documents/:typeId/:rootId/versions", async (c) => {
|
|
|
12858
12873
|
const { typeId, rootId } = c.req.param();
|
|
12859
12874
|
const db = c.env.DB;
|
|
12860
12875
|
const { renderVersionHistoryFragment } = await import('./admin-documents-form.template-LSZKGA5J.cjs');
|
|
12861
|
-
const registry = new
|
|
12876
|
+
const registry = new chunkVMBQ6NQB_cjs.DocumentTypeRegistry(db);
|
|
12862
12877
|
const docType = await registry.findById(typeId);
|
|
12863
12878
|
if (!docType) return c.html("<div>Unknown type.</div>", 404);
|
|
12864
12879
|
const result = await db.prepare(
|
|
@@ -14790,7 +14805,7 @@ var TenantService = class {
|
|
|
14790
14805
|
SET name = ?, domain = ?, status = ?, notes = ?, updated_at = ?
|
|
14791
14806
|
WHERE slug = ?
|
|
14792
14807
|
`).bind(name, domain, status, notes, now, slug).run();
|
|
14793
|
-
|
|
14808
|
+
chunkKPQ57HAH_cjs.invalidateTenantCache();
|
|
14794
14809
|
const updated = await this.getTenantBySlug(slug);
|
|
14795
14810
|
if (!updated) throw new Error("Tenant not found");
|
|
14796
14811
|
return updated;
|
|
@@ -14808,7 +14823,7 @@ var TenantService = class {
|
|
|
14808
14823
|
throw new Error(`Tenant '${slug}' still owns ${docCount} document(s). Delete or migrate its content first.`);
|
|
14809
14824
|
}
|
|
14810
14825
|
await this.db.prepare(`DELETE FROM auth_tenant WHERE slug = ?`).bind(slug).run();
|
|
14811
|
-
|
|
14826
|
+
chunkKPQ57HAH_cjs.invalidateTenantCache();
|
|
14812
14827
|
}
|
|
14813
14828
|
// ─── Membership (auth_tenant_member) ───────────────────────────────────────
|
|
14814
14829
|
// Tenant resolution and the admin switcher are gated on membership: an authed user may only
|
|
@@ -15052,7 +15067,7 @@ var TenantService = class {
|
|
|
15052
15067
|
INSERT INTO auth_tenant (id, name, slug, status, domain, notes, metadata, created_at, updated_at)
|
|
15053
15068
|
VALUES (?, ?, ?, 'active', ?, ?, '{}', ?, ?)
|
|
15054
15069
|
`).bind(id, input.name, input.slug, input.domain, input.notes, now, now).run();
|
|
15055
|
-
|
|
15070
|
+
chunkKPQ57HAH_cjs.invalidateTenantCache();
|
|
15056
15071
|
const created = await this.getTenantBySlug(input.slug);
|
|
15057
15072
|
if (!created) throw new Error("Failed to create tenant");
|
|
15058
15073
|
return created;
|
|
@@ -15076,14 +15091,14 @@ function mapRowToTenant(row) {
|
|
|
15076
15091
|
|
|
15077
15092
|
// src/routes/admin-users.ts
|
|
15078
15093
|
var userRoutes = new hono.Hono();
|
|
15079
|
-
userRoutes.use("*",
|
|
15080
|
-
userRoutes.use("/users/*",
|
|
15081
|
-
userRoutes.use("/users",
|
|
15082
|
-
userRoutes.use("/invite-user",
|
|
15083
|
-
userRoutes.use("/resend-invitation/*",
|
|
15084
|
-
userRoutes.use("/cancel-invitation/*",
|
|
15085
|
-
userRoutes.use("/activity-logs",
|
|
15086
|
-
userRoutes.use("/activity-logs/*",
|
|
15094
|
+
userRoutes.use("*", chunkVMBQ6NQB_cjs.requireAuth());
|
|
15095
|
+
userRoutes.use("/users/*", chunkVMBQ6NQB_cjs.requireRole(["admin"]));
|
|
15096
|
+
userRoutes.use("/users", chunkVMBQ6NQB_cjs.requireRole(["admin"]));
|
|
15097
|
+
userRoutes.use("/invite-user", chunkVMBQ6NQB_cjs.requireRole(["admin"]));
|
|
15098
|
+
userRoutes.use("/resend-invitation/*", chunkVMBQ6NQB_cjs.requireRole(["admin"]));
|
|
15099
|
+
userRoutes.use("/cancel-invitation/*", chunkVMBQ6NQB_cjs.requireRole(["admin"]));
|
|
15100
|
+
userRoutes.use("/activity-logs", chunkVMBQ6NQB_cjs.requireRole(["admin"]));
|
|
15101
|
+
userRoutes.use("/activity-logs/*", chunkVMBQ6NQB_cjs.requireRole(["admin"]));
|
|
15087
15102
|
userRoutes.get("/", (c) => {
|
|
15088
15103
|
return c.redirect("/admin/dashboard");
|
|
15089
15104
|
});
|
|
@@ -15250,7 +15265,7 @@ userRoutes.put("/profile", async (c) => {
|
|
|
15250
15265
|
}
|
|
15251
15266
|
await saveCustomData(db, user.userId, sanitized);
|
|
15252
15267
|
}
|
|
15253
|
-
await
|
|
15268
|
+
await chunkVMBQ6NQB_cjs.logActivity(
|
|
15254
15269
|
db,
|
|
15255
15270
|
user.userId,
|
|
15256
15271
|
"profile.update",
|
|
@@ -15313,7 +15328,7 @@ userRoutes.post("/profile/avatar", async (c) => {
|
|
|
15313
15328
|
SELECT first_name, last_name FROM auth_user WHERE id = ?
|
|
15314
15329
|
`);
|
|
15315
15330
|
const userData = await userStmt.bind(user.userId).first();
|
|
15316
|
-
await
|
|
15331
|
+
await chunkVMBQ6NQB_cjs.logActivity(
|
|
15317
15332
|
db,
|
|
15318
15333
|
user.userId,
|
|
15319
15334
|
"profile.avatar_update",
|
|
@@ -15384,7 +15399,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
15384
15399
|
dismissible: true
|
|
15385
15400
|
}));
|
|
15386
15401
|
}
|
|
15387
|
-
const validPassword = await
|
|
15402
|
+
const validPassword = await chunkVMBQ6NQB_cjs.AuthManager.verifyPassword(currentPassword, userData.password_hash);
|
|
15388
15403
|
if (!validPassword) {
|
|
15389
15404
|
return c.html(chunkN32OWET6_cjs.renderAlert({
|
|
15390
15405
|
type: "error",
|
|
@@ -15392,7 +15407,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
15392
15407
|
dismissible: true
|
|
15393
15408
|
}));
|
|
15394
15409
|
}
|
|
15395
|
-
const newPasswordHash = await
|
|
15410
|
+
const newPasswordHash = await chunkVMBQ6NQB_cjs.AuthManager.hashPassword(newPassword);
|
|
15396
15411
|
const historyStmt = db.prepare(`
|
|
15397
15412
|
INSERT INTO auth_password_history (id, user_id, password_hash, created_at)
|
|
15398
15413
|
VALUES (?, ?, ?, ?)
|
|
@@ -15408,7 +15423,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
15408
15423
|
WHERE id = ?
|
|
15409
15424
|
`);
|
|
15410
15425
|
await updateStmt.bind(newPasswordHash, Date.now(), user.userId).run();
|
|
15411
|
-
await
|
|
15426
|
+
await chunkVMBQ6NQB_cjs.logActivity(
|
|
15412
15427
|
db,
|
|
15413
15428
|
user.userId,
|
|
15414
15429
|
"profile.password_change",
|
|
@@ -15475,7 +15490,7 @@ userRoutes.get("/users", async (c) => {
|
|
|
15475
15490
|
`);
|
|
15476
15491
|
const countResult = await countStmt.bind(...params).first();
|
|
15477
15492
|
const totalUsers = countResult?.total || 0;
|
|
15478
|
-
await
|
|
15493
|
+
await chunkVMBQ6NQB_cjs.logActivity(
|
|
15479
15494
|
db,
|
|
15480
15495
|
user.userId,
|
|
15481
15496
|
"users.list_view",
|
|
@@ -15656,7 +15671,7 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
15656
15671
|
dismissible: true
|
|
15657
15672
|
}));
|
|
15658
15673
|
}
|
|
15659
|
-
const passwordHash = await
|
|
15674
|
+
const passwordHash = await chunkVMBQ6NQB_cjs.AuthManager.hashPassword(password);
|
|
15660
15675
|
const userId = crypto.randomUUID();
|
|
15661
15676
|
const createStmt = db.prepare(`
|
|
15662
15677
|
INSERT INTO auth_user (
|
|
@@ -15681,7 +15696,7 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
15681
15696
|
if (sanitizedRegistrationCustom !== null && Object.keys(sanitizedRegistrationCustom).length > 0) {
|
|
15682
15697
|
await writeProfileData(db, userId, { custom: sanitizedRegistrationCustom }, user.userId);
|
|
15683
15698
|
}
|
|
15684
|
-
await
|
|
15699
|
+
await chunkVMBQ6NQB_cjs.logActivity(
|
|
15685
15700
|
db,
|
|
15686
15701
|
user.userId,
|
|
15687
15702
|
"user!.create",
|
|
@@ -15720,7 +15735,7 @@ userRoutes.get("/users/:id", async (c) => {
|
|
|
15720
15735
|
if (!userRecord) {
|
|
15721
15736
|
return c.json({ error: "User not found" }, 404);
|
|
15722
15737
|
}
|
|
15723
|
-
await
|
|
15738
|
+
await chunkVMBQ6NQB_cjs.logActivity(
|
|
15724
15739
|
db,
|
|
15725
15740
|
user.userId,
|
|
15726
15741
|
"user!.view",
|
|
@@ -15934,7 +15949,7 @@ userRoutes.put("/users/:id", async (c) => {
|
|
|
15934
15949
|
userId
|
|
15935
15950
|
).run();
|
|
15936
15951
|
if (newPassword) {
|
|
15937
|
-
const passwordHash = await
|
|
15952
|
+
const passwordHash = await chunkVMBQ6NQB_cjs.AuthManager.hashPassword(newPassword);
|
|
15938
15953
|
const updatePasswordStmt = db.prepare(`
|
|
15939
15954
|
UPDATE auth_user SET password_hash = ?, updated_at = ? WHERE id = ?
|
|
15940
15955
|
`);
|
|
@@ -15947,7 +15962,7 @@ userRoutes.put("/users/:id", async (c) => {
|
|
|
15947
15962
|
...sanitizedCustom !== null ? { custom: sanitizedCustom } : {}
|
|
15948
15963
|
}, user.userId);
|
|
15949
15964
|
}
|
|
15950
|
-
await
|
|
15965
|
+
await chunkVMBQ6NQB_cjs.logActivity(
|
|
15951
15966
|
db,
|
|
15952
15967
|
user.userId,
|
|
15953
15968
|
"user.update",
|
|
@@ -15993,7 +16008,7 @@ userRoutes.post("/users/:id/toggle", async (c) => {
|
|
|
15993
16008
|
UPDATE auth_user SET is_active = ?, updated_at = ? WHERE id = ?
|
|
15994
16009
|
`);
|
|
15995
16010
|
await toggleStmt.bind(active ? 1 : 0, Date.now(), userId).run();
|
|
15996
|
-
await
|
|
16011
|
+
await chunkVMBQ6NQB_cjs.logActivity(
|
|
15997
16012
|
db,
|
|
15998
16013
|
user.userId,
|
|
15999
16014
|
active ? "user.activate" : "user.deactivate",
|
|
@@ -16034,7 +16049,7 @@ userRoutes.delete("/users/:id", async (c) => {
|
|
|
16034
16049
|
DELETE FROM auth_user WHERE id = ?
|
|
16035
16050
|
`);
|
|
16036
16051
|
await deleteStmt.bind(userId).run();
|
|
16037
|
-
await
|
|
16052
|
+
await chunkVMBQ6NQB_cjs.logActivity(
|
|
16038
16053
|
db,
|
|
16039
16054
|
user.userId,
|
|
16040
16055
|
"user!.hard_delete",
|
|
@@ -16053,7 +16068,7 @@ userRoutes.delete("/users/:id", async (c) => {
|
|
|
16053
16068
|
UPDATE auth_user SET is_active = 0, updated_at = ? WHERE id = ?
|
|
16054
16069
|
`);
|
|
16055
16070
|
await deleteStmt.bind(Date.now(), userId).run();
|
|
16056
|
-
await
|
|
16071
|
+
await chunkVMBQ6NQB_cjs.logActivity(
|
|
16057
16072
|
db,
|
|
16058
16073
|
user.userId,
|
|
16059
16074
|
"user!.soft_delete",
|
|
@@ -16119,7 +16134,7 @@ userRoutes.post("/invite-user", async (c) => {
|
|
|
16119
16134
|
Date.now(),
|
|
16120
16135
|
Date.now()
|
|
16121
16136
|
).run();
|
|
16122
|
-
await
|
|
16137
|
+
await chunkVMBQ6NQB_cjs.logActivity(
|
|
16123
16138
|
db,
|
|
16124
16139
|
user.userId,
|
|
16125
16140
|
"user!.invite_sent",
|
|
@@ -16176,7 +16191,7 @@ userRoutes.post("/resend-invitation/:id", async (c) => {
|
|
|
16176
16191
|
Date.now(),
|
|
16177
16192
|
userId
|
|
16178
16193
|
).run();
|
|
16179
|
-
await
|
|
16194
|
+
await chunkVMBQ6NQB_cjs.logActivity(
|
|
16180
16195
|
db,
|
|
16181
16196
|
user.userId,
|
|
16182
16197
|
"user!.invitation_resent",
|
|
@@ -16212,7 +16227,7 @@ userRoutes.delete("/cancel-invitation/:id", async (c) => {
|
|
|
16212
16227
|
}
|
|
16213
16228
|
const deleteStmt = db.prepare(`DELETE FROM auth_user WHERE id = ?`);
|
|
16214
16229
|
await deleteStmt.bind(userId).run();
|
|
16215
|
-
await
|
|
16230
|
+
await chunkVMBQ6NQB_cjs.logActivity(
|
|
16216
16231
|
db,
|
|
16217
16232
|
user.userId,
|
|
16218
16233
|
"user!.invitation_cancelled",
|
|
@@ -17593,7 +17608,7 @@ var fileValidationSchema2 = zod.z.object({
|
|
|
17593
17608
|
// 50MB max
|
|
17594
17609
|
});
|
|
17595
17610
|
var adminMediaRoutes = new hono.Hono();
|
|
17596
|
-
adminMediaRoutes.use("*",
|
|
17611
|
+
adminMediaRoutes.use("*", chunkVMBQ6NQB_cjs.requireAuth());
|
|
17597
17612
|
adminMediaRoutes.get("/", async (c) => {
|
|
17598
17613
|
try {
|
|
17599
17614
|
const user = c.get("user");
|
|
@@ -17635,7 +17650,7 @@ adminMediaRoutes.get("/selector", async (c) => {
|
|
|
17635
17650
|
const { searchParams } = new URL(c.req.url);
|
|
17636
17651
|
const search = searchParams.get("search") || "";
|
|
17637
17652
|
const db = c.env.DB;
|
|
17638
|
-
const pluginService = new
|
|
17653
|
+
const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
|
|
17639
17654
|
const mediaPlugin = await pluginService.getPlugin("core-media");
|
|
17640
17655
|
if (!mediaPlugin || mediaPlugin.status !== "active") {
|
|
17641
17656
|
return c.html(html.html`
|
|
@@ -18009,7 +18024,7 @@ adminMediaRoutes.put("/:id", async (c) => {
|
|
|
18009
18024
|
`);
|
|
18010
18025
|
}
|
|
18011
18026
|
});
|
|
18012
|
-
adminMediaRoutes.delete("/cleanup",
|
|
18027
|
+
adminMediaRoutes.delete("/cleanup", chunkVMBQ6NQB_cjs.requireRole("admin"), async (c) => {
|
|
18013
18028
|
try {
|
|
18014
18029
|
const db = c.env.DB;
|
|
18015
18030
|
const allMediaStmt = db.prepare("SELECT id, r2_key, filename FROM media WHERE deleted_at IS NULL");
|
|
@@ -20442,8 +20457,8 @@ defineUserProfile({
|
|
|
20442
20457
|
|
|
20443
20458
|
// src/routes/admin-plugins.ts
|
|
20444
20459
|
var adminPluginRoutes = new hono.Hono();
|
|
20445
|
-
adminPluginRoutes.use("*",
|
|
20446
|
-
var AVAILABLE_PLUGINS = Object.values(
|
|
20460
|
+
adminPluginRoutes.use("*", chunkVMBQ6NQB_cjs.requireAuth());
|
|
20461
|
+
var AVAILABLE_PLUGINS = Object.values(chunkKPQ57HAH_cjs.PLUGIN_REGISTRY).map((p) => ({
|
|
20447
20462
|
id: p.id,
|
|
20448
20463
|
name: p.codeName,
|
|
20449
20464
|
display_name: p.displayName,
|
|
@@ -20463,7 +20478,7 @@ adminPluginRoutes.get("/", async (c) => {
|
|
|
20463
20478
|
if (user?.role !== "admin") {
|
|
20464
20479
|
return c.text("Access denied", 403);
|
|
20465
20480
|
}
|
|
20466
|
-
const pluginService = new
|
|
20481
|
+
const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
|
|
20467
20482
|
let installedPlugins = [];
|
|
20468
20483
|
let stats = { total: 0, active: 0, inactive: 0, errors: 0, uninstalled: 0 };
|
|
20469
20484
|
try {
|
|
@@ -20535,10 +20550,10 @@ adminPluginRoutes.get("/:id", async (c) => {
|
|
|
20535
20550
|
if (user?.role !== "admin") {
|
|
20536
20551
|
return c.redirect("/admin/plugins");
|
|
20537
20552
|
}
|
|
20538
|
-
const pluginService = new
|
|
20553
|
+
const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
|
|
20539
20554
|
let plugin = await pluginService.getPlugin(pluginId);
|
|
20540
20555
|
if (!plugin) {
|
|
20541
|
-
const def =
|
|
20556
|
+
const def = chunkPZGGIJI6_cjs.getPluginDefinition(pluginId);
|
|
20542
20557
|
if (!def) return c.text("Plugin not found", 404);
|
|
20543
20558
|
plugin = await pluginService.ensurePlugin(pluginId, {
|
|
20544
20559
|
displayName: def.displayName ?? pluginId,
|
|
@@ -20629,14 +20644,14 @@ adminPluginRoutes.get("/:id/configure", async (c) => {
|
|
|
20629
20644
|
const user = c.get("user");
|
|
20630
20645
|
const pluginId = c.req.param("id");
|
|
20631
20646
|
if (user?.role !== "admin") return c.redirect("/admin/plugins");
|
|
20632
|
-
const def =
|
|
20647
|
+
const def = chunkPZGGIJI6_cjs.getPluginDefinition(pluginId);
|
|
20633
20648
|
if (!def?.configSchema) return c.text("No schema-driven settings for this plugin", 404);
|
|
20634
20649
|
const db = c.env.DB;
|
|
20635
|
-
const pluginService = new
|
|
20650
|
+
const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
|
|
20636
20651
|
const plugin = await pluginService.getPlugin(pluginId);
|
|
20637
20652
|
const stored = plugin?.settings ?? {};
|
|
20638
|
-
const values =
|
|
20639
|
-
const fieldsHtml =
|
|
20653
|
+
const values = chunkPZGGIJI6_cjs.applySchemaDefaults(def.configSchema, stored);
|
|
20654
|
+
const fieldsHtml = chunkPZGGIJI6_cjs.renderSchemaFields(def.configSchema, values);
|
|
20640
20655
|
const displayName = plugin?.display_name ?? def.displayName ?? def.id;
|
|
20641
20656
|
return c.html(`<!DOCTYPE html>
|
|
20642
20657
|
<html lang="en"><head>
|
|
@@ -20663,12 +20678,12 @@ adminPluginRoutes.post("/:id/configure", async (c) => {
|
|
|
20663
20678
|
const user = c.get("user");
|
|
20664
20679
|
const pluginId = c.req.param("id");
|
|
20665
20680
|
if (user?.role !== "admin") return c.json({ error: "Access denied" }, 403);
|
|
20666
|
-
const def =
|
|
20681
|
+
const def = chunkPZGGIJI6_cjs.getPluginDefinition(pluginId);
|
|
20667
20682
|
if (!def?.configSchema) return c.text("No schema-driven settings for this plugin", 404);
|
|
20668
20683
|
const form = await c.req.formData();
|
|
20669
|
-
const parsed =
|
|
20684
|
+
const parsed = chunkPZGGIJI6_cjs.parseFormDataToSettings(def.configSchema, form);
|
|
20670
20685
|
const db = c.env.DB;
|
|
20671
|
-
const pluginService = new
|
|
20686
|
+
const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
|
|
20672
20687
|
await pluginService.ensurePlugin(pluginId, {
|
|
20673
20688
|
displayName: def.displayName ?? pluginId,
|
|
20674
20689
|
version: def.version,
|
|
@@ -20690,7 +20705,7 @@ adminPluginRoutes.post("/:id/activate", async (c) => {
|
|
|
20690
20705
|
if (user?.role !== "admin") {
|
|
20691
20706
|
return c.json({ error: "Access denied" }, 403);
|
|
20692
20707
|
}
|
|
20693
|
-
const pluginService = new
|
|
20708
|
+
const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
|
|
20694
20709
|
await pluginService.activatePlugin(pluginId);
|
|
20695
20710
|
return c.json({ success: true });
|
|
20696
20711
|
} catch (error) {
|
|
@@ -20707,7 +20722,7 @@ adminPluginRoutes.post("/:id/deactivate", async (c) => {
|
|
|
20707
20722
|
if (user?.role !== "admin") {
|
|
20708
20723
|
return c.json({ error: "Access denied" }, 403);
|
|
20709
20724
|
}
|
|
20710
|
-
const pluginService = new
|
|
20725
|
+
const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
|
|
20711
20726
|
await pluginService.deactivatePlugin(pluginId);
|
|
20712
20727
|
return c.json({ success: true });
|
|
20713
20728
|
} catch (error) {
|
|
@@ -20724,8 +20739,8 @@ adminPluginRoutes.post("/install", async (c) => {
|
|
|
20724
20739
|
return c.json({ error: "Access denied" }, 403);
|
|
20725
20740
|
}
|
|
20726
20741
|
const body = await c.req.json();
|
|
20727
|
-
const pluginService = new
|
|
20728
|
-
const registryEntry =
|
|
20742
|
+
const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
|
|
20743
|
+
const registryEntry = chunkKPQ57HAH_cjs.findPluginByCodeName(body.name) || chunkKPQ57HAH_cjs.PLUGIN_REGISTRY[body.name] || chunkKPQ57HAH_cjs.PLUGIN_REGISTRY[body.id];
|
|
20729
20744
|
if (!registryEntry) {
|
|
20730
20745
|
return c.json({ error: "Plugin not found in registry" }, 404);
|
|
20731
20746
|
}
|
|
@@ -20758,7 +20773,7 @@ adminPluginRoutes.post("/:id/uninstall", async (c) => {
|
|
|
20758
20773
|
if (user?.role !== "admin") {
|
|
20759
20774
|
return c.json({ error: "Access denied" }, 403);
|
|
20760
20775
|
}
|
|
20761
|
-
const pluginService = new
|
|
20776
|
+
const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
|
|
20762
20777
|
await pluginService.uninstallPlugin(pluginId);
|
|
20763
20778
|
return c.json({ success: true });
|
|
20764
20779
|
} catch (error) {
|
|
@@ -20776,7 +20791,7 @@ adminPluginRoutes.post("/:id/settings", async (c) => {
|
|
|
20776
20791
|
return c.json({ error: "Access denied" }, 403);
|
|
20777
20792
|
}
|
|
20778
20793
|
const settings = await c.req.json();
|
|
20779
|
-
const pluginService = new
|
|
20794
|
+
const pluginService = new chunkKPQ57HAH_cjs.PluginService(db);
|
|
20780
20795
|
await pluginService.updatePluginSettings(pluginId, settings);
|
|
20781
20796
|
if (pluginId === "core-auth") {
|
|
20782
20797
|
try {
|
|
@@ -21584,7 +21599,7 @@ function renderLogConfigPage(data) {
|
|
|
21584
21599
|
|
|
21585
21600
|
// src/routes/admin-logs.ts
|
|
21586
21601
|
var adminLogsRoutes = new hono.Hono();
|
|
21587
|
-
adminLogsRoutes.use("*",
|
|
21602
|
+
adminLogsRoutes.use("*", chunkVMBQ6NQB_cjs.requireAuth());
|
|
21588
21603
|
adminLogsRoutes.get("/", async (c) => {
|
|
21589
21604
|
try {
|
|
21590
21605
|
const user = c.get("user");
|
|
@@ -22576,9 +22591,9 @@ function renderStorageUsage(databaseSizeBytes, mediaSizeBytes) {
|
|
|
22576
22591
|
}
|
|
22577
22592
|
|
|
22578
22593
|
// src/routes/admin-dashboard.ts
|
|
22579
|
-
var VERSION =
|
|
22594
|
+
var VERSION = chunk6CKXZFED_cjs.getCoreVersion();
|
|
22580
22595
|
var router = new hono.Hono();
|
|
22581
|
-
router.use("*",
|
|
22596
|
+
router.use("*", chunkVMBQ6NQB_cjs.requireAuth());
|
|
22582
22597
|
router.get("/", async (c) => {
|
|
22583
22598
|
const user = c.get("user");
|
|
22584
22599
|
try {
|
|
@@ -24543,7 +24558,7 @@ function renderCollectionFormPage(data) {
|
|
|
24543
24558
|
// src/routes/admin-collections.ts
|
|
24544
24559
|
chunkK623Q6WD_cjs.init_admin_layout_catalyst_template();
|
|
24545
24560
|
var adminCollectionsRoutes = new hono.Hono();
|
|
24546
|
-
adminCollectionsRoutes.use("*",
|
|
24561
|
+
adminCollectionsRoutes.use("*", chunkVMBQ6NQB_cjs.requireAuth());
|
|
24547
24562
|
adminCollectionsRoutes.get("/", async (c) => {
|
|
24548
24563
|
try {
|
|
24549
24564
|
const user = c.get("user");
|
|
@@ -24560,7 +24575,7 @@ adminCollectionsRoutes.get("/", async (c) => {
|
|
|
24560
24575
|
results = queryResults.results ?? [];
|
|
24561
24576
|
} catch (e) {
|
|
24562
24577
|
}
|
|
24563
|
-
const codeCollections =
|
|
24578
|
+
const codeCollections = chunkKPQ57HAH_cjs.getCollectionRegistry().list();
|
|
24564
24579
|
const codeCollectionsMap = new Map(
|
|
24565
24580
|
codeCollections.map((cfg) => {
|
|
24566
24581
|
const fieldCount = cfg.schema?.properties ? Object.keys(cfg.schema.properties).length : 0;
|
|
@@ -24574,7 +24589,7 @@ adminCollectionsRoutes.get("/", async (c) => {
|
|
|
24574
24589
|
field_count: fieldCount,
|
|
24575
24590
|
managed: cfg.managed !== false,
|
|
24576
24591
|
source_type: "code",
|
|
24577
|
-
internal:
|
|
24592
|
+
internal: chunkKPQ57HAH_cjs.isCodeCollectionInternal(cfg),
|
|
24578
24593
|
versioning: cfg.versioning === true
|
|
24579
24594
|
}];
|
|
24580
24595
|
})
|
|
@@ -24613,7 +24628,7 @@ adminCollectionsRoutes.get("/", async (c) => {
|
|
|
24613
24628
|
field_count: fieldCount,
|
|
24614
24629
|
managed: false,
|
|
24615
24630
|
source_type: row.source === "code" || row.source === "system" || row.source === "plugin" ? "code" : "user",
|
|
24616
|
-
internal:
|
|
24631
|
+
internal: chunkKPQ57HAH_cjs.isDbDocTypeInternal(row.source),
|
|
24617
24632
|
versioning: dbVersioning
|
|
24618
24633
|
};
|
|
24619
24634
|
});
|
|
@@ -24774,7 +24789,7 @@ export const myPlugin = definePlugin({
|
|
|
24774
24789
|
title: "Add a Collection",
|
|
24775
24790
|
pageTitle: "Add a Collection",
|
|
24776
24791
|
currentPath: "/admin/collections",
|
|
24777
|
-
version:
|
|
24792
|
+
version: chunk6CKXZFED_cjs.getCoreVersion(),
|
|
24778
24793
|
user: u ? { name: u.email ?? "Admin", email: u.email ?? "", role: u.role ?? "admin" } : void 0,
|
|
24779
24794
|
content
|
|
24780
24795
|
})
|
|
@@ -24791,7 +24806,7 @@ adminCollectionsRoutes.get("/:id", async (c) => {
|
|
|
24791
24806
|
collection = await stmt.bind(id).first();
|
|
24792
24807
|
} catch {
|
|
24793
24808
|
}
|
|
24794
|
-
const registryRecord =
|
|
24809
|
+
const registryRecord = chunkKPQ57HAH_cjs.getCollectionRegistry().getById(id) ?? chunkKPQ57HAH_cjs.getCollectionRegistry().getByName(id);
|
|
24795
24810
|
if (!collection && !registryRecord) {
|
|
24796
24811
|
const formData2 = {
|
|
24797
24812
|
isEdit: true,
|
|
@@ -24838,9 +24853,9 @@ adminCollectionsRoutes.get("/:id", async (c) => {
|
|
|
24838
24853
|
isCodeDriven = true;
|
|
24839
24854
|
}
|
|
24840
24855
|
const [tinymceActive, quillActive, mdxeditorActive] = await Promise.all([
|
|
24841
|
-
|
|
24842
|
-
|
|
24843
|
-
|
|
24856
|
+
chunkVMBQ6NQB_cjs.isPluginActive(db, "tinymce-plugin"),
|
|
24857
|
+
chunkVMBQ6NQB_cjs.isPluginActive(db, "quill-editor"),
|
|
24858
|
+
chunkVMBQ6NQB_cjs.isPluginActive(db, "easy-mdx")
|
|
24844
24859
|
]);
|
|
24845
24860
|
const displayName = collection?.display_name ?? registryRecord?.displayName ?? id;
|
|
24846
24861
|
const formData = {
|
|
@@ -24860,9 +24875,9 @@ adminCollectionsRoutes.get("/:id", async (c) => {
|
|
|
24860
24875
|
console.error("Error fetching collection:", error);
|
|
24861
24876
|
const user = c.get("user");
|
|
24862
24877
|
const [tinymceActive, quillActive, mdxeditorActive] = await Promise.all([
|
|
24863
|
-
|
|
24864
|
-
|
|
24865
|
-
|
|
24878
|
+
chunkVMBQ6NQB_cjs.isPluginActive(db, "tinymce-plugin"),
|
|
24879
|
+
chunkVMBQ6NQB_cjs.isPluginActive(db, "quill-editor"),
|
|
24880
|
+
chunkVMBQ6NQB_cjs.isPluginActive(db, "easy-mdx")
|
|
24866
24881
|
]);
|
|
24867
24882
|
const formData = {
|
|
24868
24883
|
isEdit: true,
|
|
@@ -25811,7 +25826,7 @@ function renderDatabaseToolsSettings(settings) {
|
|
|
25811
25826
|
|
|
25812
25827
|
// src/routes/admin-settings.ts
|
|
25813
25828
|
var adminSettingsRoutes = new hono.Hono();
|
|
25814
|
-
adminSettingsRoutes.use("*",
|
|
25829
|
+
adminSettingsRoutes.use("*", chunkVMBQ6NQB_cjs.requireAuth());
|
|
25815
25830
|
function getMockSettings(user) {
|
|
25816
25831
|
return {
|
|
25817
25832
|
general: {
|
|
@@ -25914,7 +25929,7 @@ adminSettingsRoutes.get("/database-tools", (c) => {
|
|
|
25914
25929
|
adminSettingsRoutes.get("/api/migrations/status", async (c) => {
|
|
25915
25930
|
try {
|
|
25916
25931
|
const db = c.env.DB;
|
|
25917
|
-
const migrationService = new
|
|
25932
|
+
const migrationService = new chunkYNYEQP3K_cjs.MigrationService(db);
|
|
25918
25933
|
const status = await migrationService.getMigrationStatus();
|
|
25919
25934
|
return c.json({
|
|
25920
25935
|
success: true,
|
|
@@ -25954,7 +25969,7 @@ adminSettingsRoutes.post("/api/migrations/run", async (c) => {
|
|
|
25954
25969
|
adminSettingsRoutes.get("/api/migrations/validate", async (c) => {
|
|
25955
25970
|
try {
|
|
25956
25971
|
const db = c.env.DB;
|
|
25957
|
-
const migrationService = new
|
|
25972
|
+
const migrationService = new chunkYNYEQP3K_cjs.MigrationService(db);
|
|
25958
25973
|
const validation = await migrationService.validateSchema();
|
|
25959
25974
|
return c.json({
|
|
25960
25975
|
success: true,
|
|
@@ -26547,16 +26562,16 @@ function renderAPIReferencePage(data) {
|
|
|
26547
26562
|
}
|
|
26548
26563
|
|
|
26549
26564
|
// src/routes/admin-api-reference.ts
|
|
26550
|
-
var VERSION2 =
|
|
26565
|
+
var VERSION2 = chunk6CKXZFED_cjs.getCoreVersion();
|
|
26551
26566
|
var router2 = new hono.Hono();
|
|
26552
|
-
router2.use("*",
|
|
26567
|
+
router2.use("*", chunkVMBQ6NQB_cjs.requireAuth());
|
|
26553
26568
|
router2.get("/", async (c) => {
|
|
26554
26569
|
const user = c.get("user");
|
|
26555
26570
|
try {
|
|
26556
26571
|
const app2 = chunk4BTBSXMR_cjs.getAppInstance();
|
|
26557
26572
|
const baseEndpoints = chunk4BTBSXMR_cjs.buildRouteList(app2);
|
|
26558
26573
|
const collectionRoutes = [];
|
|
26559
|
-
const collections =
|
|
26574
|
+
const collections = chunkKPQ57HAH_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal);
|
|
26560
26575
|
const methodOrder = { GET: 0, POST: 1, PUT: 2, PATCH: 3, DELETE: 4 };
|
|
26561
26576
|
for (const col of collections) {
|
|
26562
26577
|
const displayName = col.displayName || col.name;
|
|
@@ -26672,5 +26687,5 @@ exports.setVariablesCache = setVariablesCache;
|
|
|
26672
26687
|
exports.test_cleanup_default = test_cleanup_default;
|
|
26673
26688
|
exports.userProfilesPlugin = userProfilesPlugin;
|
|
26674
26689
|
exports.userRoutes = userRoutes;
|
|
26675
|
-
//# sourceMappingURL=chunk-
|
|
26676
|
-
//# sourceMappingURL=chunk-
|
|
26690
|
+
//# sourceMappingURL=chunk-VT77YUTP.cjs.map
|
|
26691
|
+
//# sourceMappingURL=chunk-VT77YUTP.cjs.map
|