@sonicjs-cms/core 3.0.0-beta.14 → 3.0.0-beta.16
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/{app-Bo0X1OWX.d.ts → app-01M0dIwt.d.ts} +1 -1
- package/dist/{app-Do66yCcV.d.cts → app-aj39TGHB.d.cts} +1 -1
- package/dist/{chunk-SIPBHWMG.cjs → chunk-3XFA3E2F.cjs} +4 -4
- package/dist/{chunk-SIPBHWMG.cjs.map → chunk-3XFA3E2F.cjs.map} +1 -1
- package/dist/{chunk-QNPT6BQP.js → chunk-7P2IJM4K.js} +3 -3
- package/dist/{chunk-QNPT6BQP.js.map → chunk-7P2IJM4K.js.map} +1 -1
- package/dist/{chunk-32SDMKZ7.js → chunk-HYO2MSFI.js} +2 -2
- package/dist/{chunk-32SDMKZ7.js.map → chunk-HYO2MSFI.js.map} +1 -1
- package/dist/{chunk-H5FB6GKR.cjs → chunk-IA24HACT.cjs} +2 -2
- package/dist/{chunk-H5FB6GKR.cjs.map → chunk-IA24HACT.cjs.map} +1 -1
- package/dist/{chunk-75JKPNUZ.js → chunk-IQZA2OY5.js} +3 -3
- package/dist/{chunk-75JKPNUZ.js.map → chunk-IQZA2OY5.js.map} +1 -1
- package/dist/{chunk-5L6EMI7A.js → chunk-IXUNNFZZ.js} +6 -5
- package/dist/chunk-IXUNNFZZ.js.map +1 -0
- package/dist/{chunk-U7T5EOHJ.js → chunk-JRMBHDGM.js} +4 -4
- package/dist/{chunk-U7T5EOHJ.js.map → chunk-JRMBHDGM.js.map} +1 -1
- package/dist/{chunk-INE5E3SL.js → chunk-KIB7K5LV.js} +27 -2
- package/dist/chunk-KIB7K5LV.js.map +1 -0
- package/dist/{chunk-ZTEJHSYS.cjs → chunk-KMCLNO4K.cjs} +5 -5
- package/dist/{chunk-ZTEJHSYS.cjs.map → chunk-KMCLNO4K.cjs.map} +1 -1
- package/dist/{chunk-L3KHLEHL.cjs → chunk-KMM45BTY.cjs} +53 -15
- package/dist/chunk-KMM45BTY.cjs.map +1 -0
- package/dist/{chunk-4YRYGDCQ.cjs → chunk-KOXFYFOF.cjs} +4 -4
- package/dist/{chunk-4YRYGDCQ.cjs.map → chunk-KOXFYFOF.cjs.map} +1 -1
- package/dist/{chunk-WIV3R2MJ.cjs → chunk-KZIBF2EV.cjs} +27 -2
- package/dist/chunk-KZIBF2EV.cjs.map +1 -0
- package/dist/{chunk-G5LC7MYH.cjs → chunk-LXYDJU6U.cjs} +12 -11
- package/dist/chunk-LXYDJU6U.cjs.map +1 -0
- package/dist/{chunk-O32IZ6JS.js → chunk-PA2UIFB7.js} +43 -5
- package/dist/chunk-PA2UIFB7.js.map +1 -0
- package/dist/{chunk-SSOP7G4R.cjs → chunk-SC2WZFNQ.cjs} +309 -243
- package/dist/chunk-SC2WZFNQ.cjs.map +1 -0
- package/dist/{chunk-HNUGMALL.js → chunk-UOFRE5PY.js} +104 -39
- package/dist/chunk-UOFRE5PY.js.map +1 -0
- package/dist/{chunk-IESEVHXL.js → chunk-VVYVFCML.js} +12 -3
- package/dist/chunk-VVYVFCML.js.map +1 -0
- package/dist/{chunk-HIKBY7MS.cjs → chunk-XWVDSM2L.cjs} +12 -3
- package/dist/chunk-XWVDSM2L.cjs.map +1 -0
- package/dist/config-SM2UWSDN.js +6 -0
- package/dist/{config-PLJTDINX.js.map → config-SM2UWSDN.js.map} +1 -1
- package/dist/config-YCRSU7ZP.cjs +19 -0
- package/dist/{config-FLOUCYHH.cjs.map → config-YCRSU7ZP.cjs.map} +1 -1
- package/dist/{define-plugin-BzNHc1ZI.d.ts → define-plugin-BYIey6sp.d.ts} +1 -1
- package/dist/{define-plugin-IWDKYaVm.d.cts → define-plugin-DsKiGu1q.d.cts} +1 -1
- package/dist/index.cjs +775 -297
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +194 -7
- package/dist/index.d.ts +194 -7
- package/dist/index.js +527 -59
- package/dist/index.js.map +1 -1
- package/dist/middleware.cjs +33 -33
- package/dist/middleware.d.cts +2 -2
- package/dist/middleware.d.ts +2 -2
- package/dist/middleware.js +4 -4
- package/dist/migrations-F4LBAHQN.js +4 -0
- package/dist/{migrations-DOPZXFK3.js.map → migrations-F4LBAHQN.js.map} +1 -1
- package/dist/migrations-KMCULV6H.cjs +13 -0
- package/dist/{migrations-TYYC66P4.cjs.map → migrations-KMCULV6H.cjs.map} +1 -1
- package/dist/plugins.cjs +40 -40
- package/dist/plugins.d.cts +2 -2
- package/dist/plugins.d.ts +2 -2
- package/dist/plugins.js +3 -3
- package/dist/routes.cjs +27 -27
- package/dist/routes.d.cts +2 -2
- package/dist/routes.d.ts +2 -2
- package/dist/routes.js +7 -7
- package/dist/services.cjs +18 -18
- package/dist/services.js +2 -2
- package/dist/{types-Dea1eNxU.d.cts → types-DT7XN5TX.d.cts} +1 -1
- package/dist/{types-Dea1eNxU.d.ts → types-DT7XN5TX.d.ts} +1 -1
- package/dist/utils.cjs +3 -3
- package/dist/utils.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-5L6EMI7A.js.map +0 -1
- package/dist/chunk-G5LC7MYH.cjs.map +0 -1
- package/dist/chunk-HIKBY7MS.cjs.map +0 -1
- package/dist/chunk-HNUGMALL.js.map +0 -1
- package/dist/chunk-IESEVHXL.js.map +0 -1
- package/dist/chunk-INE5E3SL.js.map +0 -1
- package/dist/chunk-L3KHLEHL.cjs.map +0 -1
- package/dist/chunk-O32IZ6JS.js.map +0 -1
- package/dist/chunk-SSOP7G4R.cjs.map +0 -1
- package/dist/chunk-WIV3R2MJ.cjs.map +0 -1
- package/dist/config-FLOUCYHH.cjs +0 -19
- package/dist/config-PLJTDINX.js +0 -6
- package/dist/migrations-DOPZXFK3.js +0 -4
- package/dist/migrations-TYYC66P4.cjs +0 -13
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkXWVDSM2L_cjs = require('./chunk-XWVDSM2L.cjs');
|
|
4
4
|
var chunkN32OWET6_cjs = require('./chunk-N32OWET6.cjs');
|
|
5
5
|
var chunk4BTBSXMR_cjs = require('./chunk-4BTBSXMR.cjs');
|
|
6
|
-
var
|
|
6
|
+
var chunkKMM45BTY_cjs = require('./chunk-KMM45BTY.cjs');
|
|
7
7
|
var chunkW36OZTJ5_cjs = require('./chunk-W36OZTJ5.cjs');
|
|
8
8
|
var chunkJEQ7FLOD_cjs = require('./chunk-JEQ7FLOD.cjs');
|
|
9
|
-
var
|
|
10
|
-
var
|
|
9
|
+
var chunkKZIBF2EV_cjs = require('./chunk-KZIBF2EV.cjs');
|
|
10
|
+
var chunkIA24HACT_cjs = require('./chunk-IA24HACT.cjs');
|
|
11
11
|
var chunkPXNTCCPE_cjs = require('./chunk-PXNTCCPE.cjs');
|
|
12
12
|
var chunkK623Q6WD_cjs = require('./chunk-K623Q6WD.cjs');
|
|
13
|
-
var
|
|
13
|
+
var chunkKOXFYFOF_cjs = require('./chunk-KOXFYFOF.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 chunk3XFA3E2F_cjs = require('./chunk-3XFA3E2F.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 chunkKMM45BTY_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 chunkKMM45BTY_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 chunkKMM45BTY_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 chunkKMM45BTY_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 chunkKMM45BTY_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("*", chunkKMM45BTY_cjs.requireAuth());
|
|
472
|
+
adminDocumentsRoutes.use("*", chunkKMM45BTY_cjs.requireRole(["admin", "editor"]));
|
|
473
473
|
adminDocumentsRoutes.get("/types", async (c) => {
|
|
474
474
|
try {
|
|
475
|
-
const registry = new
|
|
475
|
+
const registry = new chunkKMM45BTY_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 chunkKMM45BTY_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 chunkKMM45BTY_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 chunkKMM45BTY_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 = chunkKZIBF2EV_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 chunkKMM45BTY_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 chunkKMM45BTY_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", chunkKMM45BTY_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", chunkL3KHLEHL_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 = chunkKZIBF2EV_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", chunkL3KHLEHL_cjs.optionalAuth(), async (c) =>
|
|
|
990
990
|
}, 500);
|
|
991
991
|
}
|
|
992
992
|
});
|
|
993
|
-
apiContentCrudRoutes.post("/",
|
|
993
|
+
apiContentCrudRoutes.post("/", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45BTY_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("/", chunkL3KHLEHL_cjs.requireAuth(), chunkL3KHLEHL_cj
|
|
|
1065
1065
|
}, 500);
|
|
1066
1066
|
}
|
|
1067
1067
|
});
|
|
1068
|
-
apiContentCrudRoutes.put("/:id",
|
|
1068
|
+
apiContentCrudRoutes.put("/:id", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45BTY_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", chunkL3KHLEHL_cjs.requireAuth(), chunkL3KHLEHL_
|
|
|
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 chunkKMM45BTY_cjs.DocumentTypeRegistry(db).findById(docRow.type_id);
|
|
1091
1091
|
const svc = new chunkW36OZTJ5_cjs.DocumentsService(db, {
|
|
1092
1092
|
queryableFields: docType?.queryableFields ?? [],
|
|
1093
1093
|
typeSchemaVersion: docType?.schemaVersion ?? 1,
|
|
@@ -1110,7 +1110,7 @@ apiContentCrudRoutes.put("/:id", chunkL3KHLEHL_cjs.requireAuth(), chunkL3KHLEHL_
|
|
|
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 = chunkKZIBF2EV_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", chunkL3KHLEHL_cjs.requireAuth(), chunkL3KHLEHL_
|
|
|
1131
1131
|
}, 500);
|
|
1132
1132
|
}
|
|
1133
1133
|
});
|
|
1134
|
-
apiContentCrudRoutes.delete("/:id",
|
|
1134
|
+
apiContentCrudRoutes.delete("/:id", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45BTY_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 chunkKMM45BTY_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: chunk3XFA3E2F_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 = chunkKZIBF2EV_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal);
|
|
1714
|
+
const transformedResults = records.map(chunkKZIBF2EV_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", chunkKMM45BTY_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", chunkL3KHLEHL_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 = chunkKZIBF2EV_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", chunkL3KHLEHL_cjs.optionalAuth(), async (c) => {
|
|
|
1840
1840
|
}, 500);
|
|
1841
1841
|
}
|
|
1842
1842
|
});
|
|
1843
|
-
apiRoutes.get("/collections/:collection/content",
|
|
1843
|
+
apiRoutes.get("/collections/:collection/content", chunkKMM45BTY_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 = chunkKZIBF2EV_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", chunkL3KHLEHL_cjs.optionalAuth
|
|
|
1902
1902
|
const responseData = {
|
|
1903
1903
|
data: transformedResults,
|
|
1904
1904
|
meta: addTimingMeta(c, {
|
|
1905
|
-
...includeCollection ? { collection:
|
|
1905
|
+
...includeCollection ? { collection: chunkKZIBF2EV_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", chunkL3KHLEHL_cjs.optionalAuth
|
|
|
1927
1927
|
}
|
|
1928
1928
|
});
|
|
1929
1929
|
apiRoutes.route("/content", api_content_crud_default);
|
|
1930
|
-
apiRoutes.get("/:collection",
|
|
1930
|
+
apiRoutes.get("/:collection", chunkKMM45BTY_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 = chunkKZIBF2EV_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", chunkL3KHLEHL_cjs.optionalAuth(), async (c) => {
|
|
|
1973
1973
|
const responseData = {
|
|
1974
1974
|
data: transformedResults,
|
|
1975
1975
|
meta: addTimingMeta(c, {
|
|
1976
|
-
...includeCollection ? { collection:
|
|
1976
|
+
...includeCollection ? { collection: chunkKZIBF2EV_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", chunkL3KHLEHL_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", chunkKMM45BTY_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 = chunkKZIBF2EV_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", chunkL3KHLEHL_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 = chunkKZIBF2EV_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", chunkL3KHLEHL_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", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45BTY_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", chunkL3KHLEHL_cjs.requireAuth(), chunkL3KHLEHL_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", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45BTY_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 = chunkKZIBF2EV_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", chunkL3KHLEHL_cjs.requireAuth(), chunkL3KHLEHL
|
|
|
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 chunkKMM45BTY_cjs.DocumentTypeRegistry(db).findById(docRow.type_id);
|
|
2079
2079
|
const svc = new chunkW36OZTJ5_cjs.DocumentsService(db, { queryableFields: docType?.queryableFields ?? [], typeSchemaVersion: docType?.schemaVersion ?? 1, maxVersionsPerRoot: docType?.settings?.maxVersionsPerRoot ?? 50, tenantId: "default", versioning: docType?.settings?.versioning ?? false });
|
|
2080
2080
|
const input = {};
|
|
2081
2081
|
if (body.title !== void 0) input.title = body.title;
|
|
@@ -2092,7 +2092,7 @@ apiRoutes.put("/:collection/:id", chunkL3KHLEHL_cjs.requireAuth(), chunkL3KHLEHL
|
|
|
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 = chunkKZIBF2EV_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", chunkL3KHLEHL_cjs.requireAuth(), chunkL3KHLEHL
|
|
|
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", chunkKMM45BTY_cjs.requireAuth(), chunkKMM45BTY_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 = chunkKZIBF2EV_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("*", chunkKMM45BTY_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 = chunkKZIBF2EV_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("*", chunkKMM45BTY_cjs.requireAuth());
|
|
3102
|
+
adminApiRoutes.use("*", chunkKMM45BTY_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 = chunkKZIBF2EV_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 = chunkKZIBF2EV_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 = chunkKZIBF2EV_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 = chunkKZIBF2EV_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-KMCULV6H.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-KMCULV6H.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 = chunkKOXFYFOF_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 = chunkKOXFYFOF_cjs.definePlugin({
|
|
4661
4661
|
id: "lexical-editor",
|
|
4662
4662
|
version: "1.0.0",
|
|
4663
4663
|
name: "Lexical Editor",
|
|
@@ -7063,7 +7063,7 @@ api.put("/:userId", async (c) => {
|
|
|
7063
7063
|
await saveCustomData(db, userId, sanitized);
|
|
7064
7064
|
return c.json({ success: true });
|
|
7065
7065
|
});
|
|
7066
|
-
var userProfilesPlugin =
|
|
7066
|
+
var userProfilesPlugin = chunkKOXFYFOF_cjs.definePlugin({
|
|
7067
7067
|
id: "user-profiles",
|
|
7068
7068
|
version: "1.0.0",
|
|
7069
7069
|
name: "User Profiles",
|
|
@@ -7101,8 +7101,8 @@ function renderPasswordResetEmail(resetLink, firstName) {
|
|
|
7101
7101
|
async function setCsrfCookie(c, maxAge) {
|
|
7102
7102
|
const secret = c.env?.JWT_SECRET || JWT_SECRET_FALLBACK;
|
|
7103
7103
|
const isDev = c.env?.ENVIRONMENT === "development" || !c.env?.ENVIRONMENT;
|
|
7104
|
-
const csrfToken = await
|
|
7105
|
-
const cookieMaxAge = await
|
|
7104
|
+
const csrfToken = await chunkKMM45BTY_cjs.generateCsrfToken(secret);
|
|
7105
|
+
const cookieMaxAge = await chunkKMM45BTY_cjs.getJwtExpirySecondsFromDb(c.env?.DB, c.env);
|
|
7106
7106
|
cookie.setCookie(c, "csrf_token", csrfToken, {
|
|
7107
7107
|
httpOnly: false,
|
|
7108
7108
|
secure: !isDev,
|
|
@@ -7142,9 +7142,9 @@ authRoutes.get("/login", async (c) => {
|
|
|
7142
7142
|
});
|
|
7143
7143
|
authRoutes.get("/register", async (c) => {
|
|
7144
7144
|
const db = c.env.DB;
|
|
7145
|
-
const isFirstUser = await
|
|
7145
|
+
const isFirstUser = await chunkXWVDSM2L_cjs.isFirstUserRegistration(db);
|
|
7146
7146
|
if (!isFirstUser) {
|
|
7147
|
-
const registrationEnabled = await
|
|
7147
|
+
const registrationEnabled = await chunkXWVDSM2L_cjs.isRegistrationEnabled(db);
|
|
7148
7148
|
if (!registrationEnabled) {
|
|
7149
7149
|
return c.redirect("/auth/login?error=Registration is currently disabled");
|
|
7150
7150
|
}
|
|
@@ -7161,13 +7161,13 @@ var loginSchema = zod.z.object({
|
|
|
7161
7161
|
});
|
|
7162
7162
|
authRoutes.post(
|
|
7163
7163
|
"/register",
|
|
7164
|
-
|
|
7164
|
+
chunkKMM45BTY_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "register" }),
|
|
7165
7165
|
async (c) => {
|
|
7166
7166
|
try {
|
|
7167
7167
|
const db = c.env.DB;
|
|
7168
|
-
const isFirstUser = await
|
|
7168
|
+
const isFirstUser = await chunkXWVDSM2L_cjs.isFirstUserRegistration(db);
|
|
7169
7169
|
if (!isFirstUser) {
|
|
7170
|
-
const registrationEnabled = await
|
|
7170
|
+
const registrationEnabled = await chunkXWVDSM2L_cjs.isRegistrationEnabled(db);
|
|
7171
7171
|
if (!registrationEnabled) {
|
|
7172
7172
|
return c.json({ error: "Registration is currently disabled" }, 403);
|
|
7173
7173
|
}
|
|
@@ -7178,7 +7178,7 @@ authRoutes.post(
|
|
|
7178
7178
|
} catch (parseError) {
|
|
7179
7179
|
return c.json({ error: "Invalid JSON in request body" }, 400);
|
|
7180
7180
|
}
|
|
7181
|
-
const validationSchema = await
|
|
7181
|
+
const validationSchema = await chunkXWVDSM2L_cjs.authValidationService.buildRegistrationSchema(db);
|
|
7182
7182
|
let validatedData;
|
|
7183
7183
|
try {
|
|
7184
7184
|
validatedData = await validationSchema.parseAsync(requestData);
|
|
@@ -7190,14 +7190,14 @@ authRoutes.post(
|
|
|
7190
7190
|
}
|
|
7191
7191
|
const email = validatedData.email;
|
|
7192
7192
|
const password = validatedData.password;
|
|
7193
|
-
const firstName = validatedData.firstName ||
|
|
7194
|
-
const lastName = validatedData.lastName ||
|
|
7193
|
+
const firstName = validatedData.firstName || chunkXWVDSM2L_cjs.authValidationService.generateDefaultValue("firstName", validatedData);
|
|
7194
|
+
const lastName = validatedData.lastName || chunkXWVDSM2L_cjs.authValidationService.generateDefaultValue("lastName", validatedData);
|
|
7195
7195
|
const normalizedEmail = email.toLowerCase();
|
|
7196
7196
|
const existingUser = await db.prepare("SELECT id FROM auth_user WHERE email = ?").bind(normalizedEmail).first();
|
|
7197
7197
|
if (existingUser) {
|
|
7198
7198
|
return c.json({ error: "User with this email already exists" }, 400);
|
|
7199
7199
|
}
|
|
7200
|
-
const passwordHash = await
|
|
7200
|
+
const passwordHash = await chunkKMM45BTY_cjs.AuthManager.hashPassword(password);
|
|
7201
7201
|
const userId = crypto.randomUUID();
|
|
7202
7202
|
const now = /* @__PURE__ */ new Date();
|
|
7203
7203
|
const nowSec = Math.floor(now.getTime() / 1e3);
|
|
@@ -7230,8 +7230,8 @@ authRoutes.post(
|
|
|
7230
7230
|
{ user: { id: userId, email: normalizedEmail, role: "viewer" } },
|
|
7231
7231
|
"fire-and-forget"
|
|
7232
7232
|
);
|
|
7233
|
-
const tokenTtl = await
|
|
7234
|
-
const token = await
|
|
7233
|
+
const tokenTtl = await chunkKMM45BTY_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
|
|
7234
|
+
const token = await chunkKMM45BTY_cjs.AuthManager.generateToken(userId, normalizedEmail, "viewer", c.env.JWT_SECRET, tokenTtl);
|
|
7235
7235
|
cookie.setCookie(c, "auth_token", token, {
|
|
7236
7236
|
httpOnly: true,
|
|
7237
7237
|
secure: true,
|
|
@@ -7263,7 +7263,7 @@ authRoutes.post(
|
|
|
7263
7263
|
);
|
|
7264
7264
|
authRoutes.post(
|
|
7265
7265
|
"/login",
|
|
7266
|
-
|
|
7266
|
+
chunkKMM45BTY_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "login" }),
|
|
7267
7267
|
async (c) => {
|
|
7268
7268
|
try {
|
|
7269
7269
|
const body = await c.req.json();
|
|
@@ -7273,7 +7273,7 @@ authRoutes.post(
|
|
|
7273
7273
|
}
|
|
7274
7274
|
const { email, password } = validation.data;
|
|
7275
7275
|
const normalizedEmail = email.toLowerCase();
|
|
7276
|
-
const { createAuth } = await import('./config-
|
|
7276
|
+
const { createAuth } = await import('./config-YCRSU7ZP.cjs');
|
|
7277
7277
|
const auth = createAuth(c.env);
|
|
7278
7278
|
const baReq = new Request(new URL("/auth/sign-in/email", c.req.url).href, {
|
|
7279
7279
|
method: "POST",
|
|
@@ -7295,8 +7295,8 @@ authRoutes.post(
|
|
|
7295
7295
|
await setCsrfCookie(c);
|
|
7296
7296
|
const baBody = await baRes.json();
|
|
7297
7297
|
const user = baBody.user ?? {};
|
|
7298
|
-
const tokenTtl = await
|
|
7299
|
-
const token = await
|
|
7298
|
+
const tokenTtl = await chunkKMM45BTY_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
|
|
7299
|
+
const token = await chunkKMM45BTY_cjs.AuthManager.generateToken(
|
|
7300
7300
|
user.id,
|
|
7301
7301
|
user.email,
|
|
7302
7302
|
user.role ?? "viewer",
|
|
@@ -7327,7 +7327,7 @@ authRoutes.post(
|
|
|
7327
7327
|
);
|
|
7328
7328
|
authRoutes.post("/logout", async (c) => {
|
|
7329
7329
|
try {
|
|
7330
|
-
const { createAuth } = await import('./config-
|
|
7330
|
+
const { createAuth } = await import('./config-YCRSU7ZP.cjs');
|
|
7331
7331
|
const auth = createAuth(c.env);
|
|
7332
7332
|
const baReq = new Request(new URL("/auth/sign-out", c.req.url).href, {
|
|
7333
7333
|
method: "POST",
|
|
@@ -7343,7 +7343,7 @@ authRoutes.post("/logout", async (c) => {
|
|
|
7343
7343
|
});
|
|
7344
7344
|
authRoutes.get("/logout", async (c) => {
|
|
7345
7345
|
try {
|
|
7346
|
-
const { createAuth } = await import('./config-
|
|
7346
|
+
const { createAuth } = await import('./config-YCRSU7ZP.cjs');
|
|
7347
7347
|
const auth = createAuth(c.env);
|
|
7348
7348
|
const baReq = new Request(new URL("/auth/sign-out", c.req.url).href, {
|
|
7349
7349
|
method: "POST",
|
|
@@ -7357,7 +7357,7 @@ authRoutes.get("/logout", async (c) => {
|
|
|
7357
7357
|
clearCsrfCookie(c);
|
|
7358
7358
|
return c.redirect("/auth/login?message=You have been logged out successfully");
|
|
7359
7359
|
});
|
|
7360
|
-
authRoutes.get("/me",
|
|
7360
|
+
authRoutes.get("/me", chunkKMM45BTY_cjs.requireAuth(), async (c) => {
|
|
7361
7361
|
try {
|
|
7362
7362
|
const user = c.get("user");
|
|
7363
7363
|
if (!user) {
|
|
@@ -7377,7 +7377,7 @@ authRoutes.get("/me", chunkL3KHLEHL_cjs.requireAuth(), async (c) => {
|
|
|
7377
7377
|
});
|
|
7378
7378
|
authRoutes.post(
|
|
7379
7379
|
"/refresh",
|
|
7380
|
-
|
|
7380
|
+
chunkKMM45BTY_cjs.rateLimit({ max: 60, windowMs: 60 * 1e3, keyPrefix: "refresh" }),
|
|
7381
7381
|
async (c) => {
|
|
7382
7382
|
try {
|
|
7383
7383
|
let token = c.req.header("Authorization")?.replace("Bearer ", "");
|
|
@@ -7386,8 +7386,8 @@ authRoutes.post(
|
|
|
7386
7386
|
return c.json({ error: "Authentication required" }, 401);
|
|
7387
7387
|
}
|
|
7388
7388
|
const db = c.env.DB;
|
|
7389
|
-
const grace = await
|
|
7390
|
-
const payload = await
|
|
7389
|
+
const grace = await chunkKMM45BTY_cjs.getJwtRefreshGraceSecondsFromDb(db, c.env);
|
|
7390
|
+
const payload = await chunkKMM45BTY_cjs.AuthManager.verifyToken(token, c.env.JWT_SECRET, grace);
|
|
7391
7391
|
if (!payload) {
|
|
7392
7392
|
return c.json({ error: "Invalid or expired token" }, 401);
|
|
7393
7393
|
}
|
|
@@ -7395,8 +7395,8 @@ authRoutes.post(
|
|
|
7395
7395
|
if (!row || !row.is_active) {
|
|
7396
7396
|
return c.json({ error: "User is not active" }, 401);
|
|
7397
7397
|
}
|
|
7398
|
-
const tokenTtl = await
|
|
7399
|
-
const newToken = await
|
|
7398
|
+
const tokenTtl = await chunkKMM45BTY_cjs.getJwtExpirySecondsFromDb(db, c.env);
|
|
7399
|
+
const newToken = await chunkKMM45BTY_cjs.AuthManager.generateToken(row.id, row.email, row.role, c.env.JWT_SECRET, tokenTtl);
|
|
7400
7400
|
cookie.setCookie(c, "auth_token", newToken, {
|
|
7401
7401
|
httpOnly: true,
|
|
7402
7402
|
secure: true,
|
|
@@ -7416,13 +7416,13 @@ authRoutes.post(
|
|
|
7416
7416
|
);
|
|
7417
7417
|
authRoutes.post(
|
|
7418
7418
|
"/register/form",
|
|
7419
|
-
|
|
7419
|
+
chunkKMM45BTY_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "register" }),
|
|
7420
7420
|
async (c) => {
|
|
7421
7421
|
try {
|
|
7422
7422
|
const db = c.env.DB;
|
|
7423
|
-
const isFirstUser = await
|
|
7423
|
+
const isFirstUser = await chunkXWVDSM2L_cjs.isFirstUserRegistration(db);
|
|
7424
7424
|
if (!isFirstUser) {
|
|
7425
|
-
const registrationEnabled = await
|
|
7425
|
+
const registrationEnabled = await chunkXWVDSM2L_cjs.isRegistrationEnabled(db);
|
|
7426
7426
|
if (!registrationEnabled) {
|
|
7427
7427
|
return c.html(html.html`
|
|
7428
7428
|
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded">
|
|
@@ -7440,7 +7440,7 @@ authRoutes.post(
|
|
|
7440
7440
|
};
|
|
7441
7441
|
const normalizedEmail = requestData.email?.toLowerCase();
|
|
7442
7442
|
requestData.email = normalizedEmail;
|
|
7443
|
-
const validationSchema = await
|
|
7443
|
+
const validationSchema = await chunkXWVDSM2L_cjs.authValidationService.buildRegistrationSchema(db);
|
|
7444
7444
|
const validation = await validationSchema.safeParseAsync(requestData);
|
|
7445
7445
|
if (!validation.success) {
|
|
7446
7446
|
return c.html(html.html`
|
|
@@ -7451,8 +7451,8 @@ authRoutes.post(
|
|
|
7451
7451
|
}
|
|
7452
7452
|
const validatedData = validation.data;
|
|
7453
7453
|
const password = validatedData.password;
|
|
7454
|
-
const firstName = validatedData.firstName ||
|
|
7455
|
-
const lastName = validatedData.lastName ||
|
|
7454
|
+
const firstName = validatedData.firstName || chunkXWVDSM2L_cjs.authValidationService.generateDefaultValue("firstName", validatedData);
|
|
7455
|
+
const lastName = validatedData.lastName || chunkXWVDSM2L_cjs.authValidationService.generateDefaultValue("lastName", validatedData);
|
|
7456
7456
|
const existingUser = await db.prepare("SELECT id FROM auth_user WHERE email = ?").bind(normalizedEmail).first();
|
|
7457
7457
|
if (existingUser) {
|
|
7458
7458
|
return c.html(html.html`
|
|
@@ -7461,7 +7461,7 @@ authRoutes.post(
|
|
|
7461
7461
|
</div>
|
|
7462
7462
|
`);
|
|
7463
7463
|
}
|
|
7464
|
-
const passwordHash = await
|
|
7464
|
+
const passwordHash = await chunkKMM45BTY_cjs.AuthManager.hashPassword(password);
|
|
7465
7465
|
const role = isFirstUser ? "admin" : "viewer";
|
|
7466
7466
|
const userId = crypto.randomUUID();
|
|
7467
7467
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -7503,8 +7503,8 @@ authRoutes.post(
|
|
|
7503
7503
|
{ user: { id: userId, email: normalizedEmail, role } },
|
|
7504
7504
|
"fire-and-forget"
|
|
7505
7505
|
);
|
|
7506
|
-
const tokenTtl = await
|
|
7507
|
-
const token = await
|
|
7506
|
+
const tokenTtl = await chunkKMM45BTY_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
|
|
7507
|
+
const token = await chunkKMM45BTY_cjs.AuthManager.generateToken(userId, normalizedEmail, role, c.env.JWT_SECRET, tokenTtl);
|
|
7508
7508
|
cookie.setCookie(c, "auth_token", token, {
|
|
7509
7509
|
httpOnly: true,
|
|
7510
7510
|
secure: false,
|
|
@@ -7536,7 +7536,7 @@ authRoutes.post(
|
|
|
7536
7536
|
);
|
|
7537
7537
|
authRoutes.post(
|
|
7538
7538
|
"/login/form",
|
|
7539
|
-
|
|
7539
|
+
chunkKMM45BTY_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "login" }),
|
|
7540
7540
|
async (c) => {
|
|
7541
7541
|
try {
|
|
7542
7542
|
const formData = await c.req.formData();
|
|
@@ -7550,7 +7550,7 @@ authRoutes.post(
|
|
|
7550
7550
|
</div>
|
|
7551
7551
|
`);
|
|
7552
7552
|
}
|
|
7553
|
-
const { createAuth } = await import('./config-
|
|
7553
|
+
const { createAuth } = await import('./config-YCRSU7ZP.cjs');
|
|
7554
7554
|
const auth = createAuth(c.env);
|
|
7555
7555
|
const baReq = new Request(new URL("/auth/sign-in/email", c.req.url).href, {
|
|
7556
7556
|
method: "POST",
|
|
@@ -7605,14 +7605,14 @@ authRoutes.post(
|
|
|
7605
7605
|
);
|
|
7606
7606
|
authRoutes.post(
|
|
7607
7607
|
"/seed-admin",
|
|
7608
|
-
|
|
7608
|
+
chunkKMM45BTY_cjs.rateLimit({ max: 10, windowMs: 60 * 1e3, keyPrefix: "seed-admin" }),
|
|
7609
7609
|
async (c) => {
|
|
7610
7610
|
try {
|
|
7611
7611
|
const db = c.env.DB;
|
|
7612
7612
|
const rbac = new chunkW36OZTJ5_cjs.RbacService(db);
|
|
7613
7613
|
const results = [];
|
|
7614
7614
|
const upsertSeedUser = async (opts) => {
|
|
7615
|
-
const passwordHash = await
|
|
7615
|
+
const passwordHash = await chunkKMM45BTY_cjs.AuthManager.hashPassword(opts.password);
|
|
7616
7616
|
const nowMs = Date.now();
|
|
7617
7617
|
const nowSec = Math.floor(nowMs / 1e3);
|
|
7618
7618
|
const existing = await db.prepare("SELECT id FROM auth_user WHERE email = ?").bind(opts.email).first();
|
|
@@ -7837,7 +7837,7 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
7837
7837
|
if (invitationAge > maxAge) {
|
|
7838
7838
|
return c.json({ error: "Invitation has expired" }, 400);
|
|
7839
7839
|
}
|
|
7840
|
-
const passwordHash = await
|
|
7840
|
+
const passwordHash = await chunkKMM45BTY_cjs.AuthManager.hashPassword(password);
|
|
7841
7841
|
const updateStmt = db.prepare(`
|
|
7842
7842
|
UPDATE auth_user SET
|
|
7843
7843
|
password_hash = ?,
|
|
@@ -7854,8 +7854,8 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
7854
7854
|
Date.now(),
|
|
7855
7855
|
invitedUser.id
|
|
7856
7856
|
).run();
|
|
7857
|
-
const tokenTtl = await
|
|
7858
|
-
const authToken = await
|
|
7857
|
+
const tokenTtl = await chunkKMM45BTY_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
|
|
7858
|
+
const authToken = await chunkKMM45BTY_cjs.AuthManager.generateToken(invitedUser.id, invitedUser.email, invitedUser.role, c.env.JWT_SECRET, tokenTtl);
|
|
7859
7859
|
cookie.setCookie(c, "auth_token", authToken, {
|
|
7860
7860
|
httpOnly: true,
|
|
7861
7861
|
secure: true,
|
|
@@ -7871,7 +7871,7 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
7871
7871
|
});
|
|
7872
7872
|
authRoutes.post(
|
|
7873
7873
|
"/request-password-reset",
|
|
7874
|
-
|
|
7874
|
+
chunkKMM45BTY_cjs.rateLimit({ max: 3, windowMs: 15 * 60 * 1e3, keyPrefix: "password-reset" }),
|
|
7875
7875
|
async (c) => {
|
|
7876
7876
|
try {
|
|
7877
7877
|
const formData = await c.req.formData();
|
|
@@ -8108,7 +8108,7 @@ authRoutes.post("/reset-password", async (c) => {
|
|
|
8108
8108
|
if (Date.now() > user.password_reset_expires) {
|
|
8109
8109
|
return c.json({ error: "Reset token has expired" }, 400);
|
|
8110
8110
|
}
|
|
8111
|
-
const newPasswordHash = await
|
|
8111
|
+
const newPasswordHash = await chunkKMM45BTY_cjs.AuthManager.hashPassword(password);
|
|
8112
8112
|
try {
|
|
8113
8113
|
const historyStmt = db.prepare(`
|
|
8114
8114
|
INSERT INTO auth_password_history (id, user_id, password_hash, created_at)
|
|
@@ -8322,7 +8322,7 @@ app.post("/test-seed-defaults", async (c) => {
|
|
|
8322
8322
|
var test_cleanup_default = app;
|
|
8323
8323
|
|
|
8324
8324
|
// src/plugins/available/easy-mdx/index.ts
|
|
8325
|
-
|
|
8325
|
+
chunkKOXFYFOF_cjs.definePlugin({
|
|
8326
8326
|
id: "easy-mdx",
|
|
8327
8327
|
version: "1.0.0",
|
|
8328
8328
|
name: "EasyMDE Markdown Editor",
|
|
@@ -8522,7 +8522,7 @@ function getMDXEditorInitScript(config) {
|
|
|
8522
8522
|
}
|
|
8523
8523
|
|
|
8524
8524
|
// src/plugins/available/tinymce-plugin/index.ts
|
|
8525
|
-
|
|
8525
|
+
chunkKOXFYFOF_cjs.definePlugin({
|
|
8526
8526
|
id: "tinymce-plugin",
|
|
8527
8527
|
version: "1.0.0",
|
|
8528
8528
|
name: "TinyMCE",
|
|
@@ -8792,7 +8792,7 @@ function getQuillCDN(version = "2.0.2") {
|
|
|
8792
8792
|
</style>
|
|
8793
8793
|
`;
|
|
8794
8794
|
}
|
|
8795
|
-
|
|
8795
|
+
chunkKOXFYFOF_cjs.definePlugin({
|
|
8796
8796
|
id: "quill-editor",
|
|
8797
8797
|
version: "1.0.0",
|
|
8798
8798
|
name: "Quill Editor",
|
|
@@ -11366,7 +11366,7 @@ function extractFieldData(fields, formData, options = {}) {
|
|
|
11366
11366
|
}
|
|
11367
11367
|
return { data, errors };
|
|
11368
11368
|
}
|
|
11369
|
-
adminContentRoutes.use("*",
|
|
11369
|
+
adminContentRoutes.use("*", chunkKMM45BTY_cjs.requireAuth());
|
|
11370
11370
|
async function getCollectionFields(db, collectionId) {
|
|
11371
11371
|
console.log(`[getCollectionFields] Loading fields for collection: ${collectionId}`);
|
|
11372
11372
|
const collectionStmt = db.prepare("SELECT schema, queryable_fields FROM document_types WHERE id = ?");
|
|
@@ -11393,7 +11393,7 @@ async function getCollectionFields(db, collectionId) {
|
|
|
11393
11393
|
};
|
|
11394
11394
|
});
|
|
11395
11395
|
}
|
|
11396
|
-
const codeCollections2 = await
|
|
11396
|
+
const codeCollections2 = await chunkKZIBF2EV_cjs.loadCollectionConfigs();
|
|
11397
11397
|
const codeMatch = codeCollections2.find((c) => c.name === collectionId);
|
|
11398
11398
|
if (codeMatch && codeMatch.schema?.properties) {
|
|
11399
11399
|
console.log(`[getCollectionFields] DB doc type has no properties \u2014 using code collection schema`);
|
|
@@ -11425,7 +11425,7 @@ async function getCollectionFields(db, collectionId) {
|
|
|
11425
11425
|
}
|
|
11426
11426
|
}
|
|
11427
11427
|
console.log(`[getCollectionFields] Not in database, checking code collections`);
|
|
11428
|
-
const codeCollections = await
|
|
11428
|
+
const codeCollections = await chunkKZIBF2EV_cjs.loadCollectionConfigs();
|
|
11429
11429
|
console.log(`[getCollectionFields] Found ${codeCollections.length} code collections`);
|
|
11430
11430
|
const codeCollection = codeCollections.find((c) => c.name === collectionId);
|
|
11431
11431
|
if (codeCollection && codeCollection.schema) {
|
|
@@ -11479,7 +11479,7 @@ async function getCollection(db, collectionId) {
|
|
|
11479
11479
|
};
|
|
11480
11480
|
}
|
|
11481
11481
|
console.log(`[getCollection] Not in database, checking code collections`);
|
|
11482
|
-
const codeCollections = await
|
|
11482
|
+
const codeCollections = await chunkKZIBF2EV_cjs.loadCollectionConfigs();
|
|
11483
11483
|
const codeCollection = codeCollections.find((c) => c.name === collectionId);
|
|
11484
11484
|
if (codeCollection) {
|
|
11485
11485
|
console.log(`[getCollection] Found code collection: ${collectionId}`);
|
|
@@ -11498,7 +11498,7 @@ async function getCollection(db, collectionId) {
|
|
|
11498
11498
|
}
|
|
11499
11499
|
async function getDocBackingType(db, collectionName) {
|
|
11500
11500
|
if (!collectionName) return null;
|
|
11501
|
-
const dt = await new
|
|
11501
|
+
const dt = await new chunkKMM45BTY_cjs.DocumentTypeRegistry(db).findById(collectionName);
|
|
11502
11502
|
return dt && dt.isActive ? dt : null;
|
|
11503
11503
|
}
|
|
11504
11504
|
async function getCollectionByName(db, name) {
|
|
@@ -11515,7 +11515,7 @@ async function getCollectionByName(db, name) {
|
|
|
11515
11515
|
};
|
|
11516
11516
|
}
|
|
11517
11517
|
console.log(`[getCollectionByName] Not in database, checking code collections`);
|
|
11518
|
-
const codeCollections = await
|
|
11518
|
+
const codeCollections = await chunkKZIBF2EV_cjs.loadCollectionConfigs();
|
|
11519
11519
|
const codeCollection = codeCollections.find((c) => c.name === name);
|
|
11520
11520
|
if (codeCollection) {
|
|
11521
11521
|
console.log(`[getCollectionByName] Found code collection: ${name}`);
|
|
@@ -11531,7 +11531,7 @@ async function getCollectionByName(db, name) {
|
|
|
11531
11531
|
return null;
|
|
11532
11532
|
}
|
|
11533
11533
|
async function loadContentEditorFlags(db) {
|
|
11534
|
-
const flags = { workflowEnabled: await
|
|
11534
|
+
const flags = { workflowEnabled: await chunkKMM45BTY_cjs.isPluginActive(db, "workflow") };
|
|
11535
11535
|
const editors = [
|
|
11536
11536
|
["tinymce-plugin", "tinymce"],
|
|
11537
11537
|
["quill-editor", "quill"],
|
|
@@ -11539,10 +11539,10 @@ async function loadContentEditorFlags(db) {
|
|
|
11539
11539
|
["lexical-editor", "lexical"]
|
|
11540
11540
|
];
|
|
11541
11541
|
for (const [plugin, key] of editors) {
|
|
11542
|
-
const enabled = await
|
|
11542
|
+
const enabled = await chunkKMM45BTY_cjs.isPluginActive(db, plugin);
|
|
11543
11543
|
flags[`${key}Enabled`] = enabled;
|
|
11544
11544
|
if (enabled) {
|
|
11545
|
-
const ps = new
|
|
11545
|
+
const ps = new chunkKZIBF2EV_cjs.PluginService(db);
|
|
11546
11546
|
const p = await ps.getPlugin(plugin);
|
|
11547
11547
|
flags[`${key}Settings`] = p?.settings;
|
|
11548
11548
|
}
|
|
@@ -11578,9 +11578,9 @@ adminContentRoutes.get("/", async (c) => {
|
|
|
11578
11578
|
const offset = (page - 1) * limit;
|
|
11579
11579
|
const collectionsStmt = db.prepare("SELECT id, name, display_name FROM document_types WHERE is_active = 1 ORDER BY display_name");
|
|
11580
11580
|
const { results: collectionsResults } = await collectionsStmt.all();
|
|
11581
|
-
const codeCollections = await
|
|
11581
|
+
const codeCollections = await chunkKZIBF2EV_cjs.loadCollectionConfigs();
|
|
11582
11582
|
const codeCollectionMap = new Map(codeCollections.map((c2) => [c2.name, c2]));
|
|
11583
|
-
const docTypeRegistry = new
|
|
11583
|
+
const docTypeRegistry = new chunkKMM45BTY_cjs.DocumentTypeRegistry(db);
|
|
11584
11584
|
const docTypes = (await docTypeRegistry.findAll()).filter((dt) => !dt.settings?.internal && !dt.isAuth);
|
|
11585
11585
|
const visibleTypeIds = new Set(docTypes.map((dt) => dt.id));
|
|
11586
11586
|
const allCollections = [
|
|
@@ -11592,7 +11592,7 @@ adminContentRoutes.get("/", async (c) => {
|
|
|
11592
11592
|
...allCollections.map((c2) => ({ name: c2.name, displayName: c2.displayName })),
|
|
11593
11593
|
...docTypes.filter((dt) => !collectionNames.has(dt.id)).map((dt) => ({ name: `doc:${dt.id}`, displayName: dt.displayName }))
|
|
11594
11594
|
];
|
|
11595
|
-
const newContentCollections = await
|
|
11595
|
+
const newContentCollections = await chunkKZIBF2EV_cjs.getVisibleCollections(db);
|
|
11596
11596
|
const docBackedCollection = !modelName.startsWith("doc:") && modelName !== "all" ? docTypes.find((dt) => dt.id === modelName) : void 0;
|
|
11597
11597
|
const isDocModel = modelName.startsWith("doc:") || !!docBackedCollection;
|
|
11598
11598
|
if (isDocModel) {
|
|
@@ -11869,9 +11869,9 @@ adminContentRoutes.get("/new", async (c) => {
|
|
|
11869
11869
|
const collectionsStmt = db2.prepare("SELECT id, name, display_name, description FROM document_types WHERE is_active = 1 ORDER BY display_name");
|
|
11870
11870
|
const { results } = await collectionsStmt.all();
|
|
11871
11871
|
const visibleTypeIds = new Set(
|
|
11872
|
-
(await new
|
|
11872
|
+
(await new chunkKMM45BTY_cjs.DocumentTypeRegistry(db2).findAll()).filter((dt) => !dt.settings?.internal && !dt.isAuth).map((dt) => dt.id)
|
|
11873
11873
|
);
|
|
11874
|
-
const codeCollections = await
|
|
11874
|
+
const codeCollections = await chunkKZIBF2EV_cjs.loadCollectionConfigs();
|
|
11875
11875
|
const dbCollectionNames = new Set((results || []).map((r) => r.name));
|
|
11876
11876
|
const allCollections = [
|
|
11877
11877
|
...codeCollections.filter((c2) => !dbCollectionNames.has(c2.name)).map((c2) => ({
|
|
@@ -11937,32 +11937,32 @@ adminContentRoutes.get("/new", async (c) => {
|
|
|
11937
11937
|
return c.html(renderContentFormPage(formData2));
|
|
11938
11938
|
}
|
|
11939
11939
|
const fields = await getCollectionFields(db, collection.id);
|
|
11940
|
-
const workflowEnabled = await
|
|
11941
|
-
const tinymceEnabled = await
|
|
11940
|
+
const workflowEnabled = await chunkKMM45BTY_cjs.isPluginActive(db, "workflow");
|
|
11941
|
+
const tinymceEnabled = await chunkKMM45BTY_cjs.isPluginActive(db, "tinymce-plugin");
|
|
11942
11942
|
let tinymceSettings;
|
|
11943
11943
|
if (tinymceEnabled) {
|
|
11944
|
-
const pluginService = new
|
|
11944
|
+
const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
|
|
11945
11945
|
const tinymcePlugin2 = await pluginService.getPlugin("tinymce-plugin");
|
|
11946
11946
|
tinymceSettings = tinymcePlugin2?.settings;
|
|
11947
11947
|
}
|
|
11948
|
-
const quillEnabled = await
|
|
11948
|
+
const quillEnabled = await chunkKMM45BTY_cjs.isPluginActive(db, "quill-editor");
|
|
11949
11949
|
let quillSettings;
|
|
11950
11950
|
if (quillEnabled) {
|
|
11951
|
-
const pluginService = new
|
|
11951
|
+
const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
|
|
11952
11952
|
const quillPlugin = await pluginService.getPlugin("quill-editor");
|
|
11953
11953
|
quillSettings = quillPlugin?.settings;
|
|
11954
11954
|
}
|
|
11955
|
-
const mdxeditorEnabled = await
|
|
11955
|
+
const mdxeditorEnabled = await chunkKMM45BTY_cjs.isPluginActive(db, "easy-mdx");
|
|
11956
11956
|
let mdxeditorSettings;
|
|
11957
11957
|
if (mdxeditorEnabled) {
|
|
11958
|
-
const pluginService = new
|
|
11958
|
+
const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
|
|
11959
11959
|
const mdxeditorPlugin = await pluginService.getPlugin("easy-mdx");
|
|
11960
11960
|
mdxeditorSettings = mdxeditorPlugin?.settings;
|
|
11961
11961
|
}
|
|
11962
|
-
const lexicalEnabled = await
|
|
11962
|
+
const lexicalEnabled = await chunkKMM45BTY_cjs.isPluginActive(db, "lexical-editor");
|
|
11963
11963
|
let lexicalSettings;
|
|
11964
11964
|
if (lexicalEnabled) {
|
|
11965
|
-
const pluginService = new
|
|
11965
|
+
const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
|
|
11966
11966
|
const lexicalPlugin = await pluginService.getPlugin("lexical-editor");
|
|
11967
11967
|
lexicalSettings = lexicalPlugin?.settings;
|
|
11968
11968
|
}
|
|
@@ -12090,32 +12090,32 @@ adminContentRoutes.get("/:id/edit", async (c) => {
|
|
|
12090
12090
|
};
|
|
12091
12091
|
const fields = await getCollectionFields(db, content.collection_id);
|
|
12092
12092
|
const contentData = content.data ? JSON.parse(content.data) : {};
|
|
12093
|
-
const workflowEnabled = await
|
|
12094
|
-
const tinymceEnabled = await
|
|
12093
|
+
const workflowEnabled = await chunkKMM45BTY_cjs.isPluginActive(db, "workflow");
|
|
12094
|
+
const tinymceEnabled = await chunkKMM45BTY_cjs.isPluginActive(db, "tinymce-plugin");
|
|
12095
12095
|
let tinymceSettings;
|
|
12096
12096
|
if (tinymceEnabled) {
|
|
12097
|
-
const pluginService = new
|
|
12097
|
+
const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
|
|
12098
12098
|
const tinymcePlugin2 = await pluginService.getPlugin("tinymce-plugin");
|
|
12099
12099
|
tinymceSettings = tinymcePlugin2?.settings;
|
|
12100
12100
|
}
|
|
12101
|
-
const quillEnabled = await
|
|
12101
|
+
const quillEnabled = await chunkKMM45BTY_cjs.isPluginActive(db, "quill-editor");
|
|
12102
12102
|
let quillSettings;
|
|
12103
12103
|
if (quillEnabled) {
|
|
12104
|
-
const pluginService = new
|
|
12104
|
+
const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
|
|
12105
12105
|
const quillPlugin = await pluginService.getPlugin("quill-editor");
|
|
12106
12106
|
quillSettings = quillPlugin?.settings;
|
|
12107
12107
|
}
|
|
12108
|
-
const mdxeditorEnabled = await
|
|
12108
|
+
const mdxeditorEnabled = await chunkKMM45BTY_cjs.isPluginActive(db, "easy-mdx");
|
|
12109
12109
|
let mdxeditorSettings;
|
|
12110
12110
|
if (mdxeditorEnabled) {
|
|
12111
|
-
const pluginService = new
|
|
12111
|
+
const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
|
|
12112
12112
|
const mdxeditorPlugin = await pluginService.getPlugin("easy-mdx");
|
|
12113
12113
|
mdxeditorSettings = mdxeditorPlugin?.settings;
|
|
12114
12114
|
}
|
|
12115
|
-
const lexicalEnabled = await
|
|
12115
|
+
const lexicalEnabled = await chunkKMM45BTY_cjs.isPluginActive(db, "lexical-editor");
|
|
12116
12116
|
let lexicalSettings;
|
|
12117
12117
|
if (lexicalEnabled) {
|
|
12118
|
-
const pluginService = new
|
|
12118
|
+
const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
|
|
12119
12119
|
const lexicalPlugin = await pluginService.getPlugin("lexical-editor");
|
|
12120
12120
|
lexicalSettings = lexicalPlugin?.settings;
|
|
12121
12121
|
}
|
|
@@ -12488,7 +12488,7 @@ adminContentRoutes.put("/:id", async (c) => {
|
|
|
12488
12488
|
`);
|
|
12489
12489
|
}
|
|
12490
12490
|
});
|
|
12491
|
-
adminContentRoutes.post("/preview",
|
|
12491
|
+
adminContentRoutes.post("/preview", chunkKMM45BTY_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
12492
12492
|
try {
|
|
12493
12493
|
const formData = await c.req.formData();
|
|
12494
12494
|
const collectionId = formData.get("collection_id");
|
|
@@ -12807,7 +12807,7 @@ adminContentRoutes.delete("/:id", async (c) => {
|
|
|
12807
12807
|
return c.json({ success: false, error: "Failed to delete content" }, 500);
|
|
12808
12808
|
}
|
|
12809
12809
|
});
|
|
12810
|
-
adminContentRoutes.get("/:id/version/:version/preview",
|
|
12810
|
+
adminContentRoutes.get("/:id/version/:version/preview", chunkKMM45BTY_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
12811
12811
|
try {
|
|
12812
12812
|
const id = c.req.param("id");
|
|
12813
12813
|
const version = parseInt(c.req.param("version") || "0");
|
|
@@ -12903,7 +12903,7 @@ function parseDocFormData(formData, queryableFields = []) {
|
|
|
12903
12903
|
return { title, slug, data };
|
|
12904
12904
|
}
|
|
12905
12905
|
async function getDocService(db, typeId, tenantId) {
|
|
12906
|
-
const registry = new
|
|
12906
|
+
const registry = new chunkKMM45BTY_cjs.DocumentTypeRegistry(db);
|
|
12907
12907
|
const docType = await registry.findById(typeId);
|
|
12908
12908
|
const svc = new chunkW36OZTJ5_cjs.DocumentsService(db, {
|
|
12909
12909
|
queryableFields: docType?.queryableFields ?? [],
|
|
@@ -12916,7 +12916,7 @@ async function getDocService(db, typeId, tenantId) {
|
|
|
12916
12916
|
}
|
|
12917
12917
|
adminContentRoutes.get("/documents/:typeId/new", async (c) => {
|
|
12918
12918
|
const { typeId } = c.req.param();
|
|
12919
|
-
const registry = new
|
|
12919
|
+
const registry = new chunkKMM45BTY_cjs.DocumentTypeRegistry(c.env.DB);
|
|
12920
12920
|
const docType = await registry.findById(typeId);
|
|
12921
12921
|
if (!docType) return c.html("<p>Unknown document type.</p>", 404);
|
|
12922
12922
|
return c.html(chunkN32OWET6_cjs.renderDocumentFormPage({ docType, isEdit: false, user: userCtx(c) }));
|
|
@@ -12941,7 +12941,7 @@ adminContentRoutes.post("/documents/:typeId/new", async (c) => {
|
|
|
12941
12941
|
}), user?.userId);
|
|
12942
12942
|
return c.redirect(`/admin/content/documents/${typeId}/${doc.rootId}/edit?message=Created+successfully`);
|
|
12943
12943
|
} catch (err) {
|
|
12944
|
-
const registry = new
|
|
12944
|
+
const registry = new chunkKMM45BTY_cjs.DocumentTypeRegistry(c.env.DB);
|
|
12945
12945
|
const docType = await registry.findById(typeId);
|
|
12946
12946
|
if (!docType) return c.html("<p>Unknown document type.</p>", 404);
|
|
12947
12947
|
return c.html(chunkN32OWET6_cjs.renderDocumentFormPage({ docType, isEdit: false, user: userCtx(c), message: err?.message ?? "Failed to create", messageType: "error" }));
|
|
@@ -12951,7 +12951,7 @@ adminContentRoutes.get("/documents/:typeId/:rootId/edit", async (c) => {
|
|
|
12951
12951
|
const { typeId, rootId } = c.req.param();
|
|
12952
12952
|
const db = c.env.DB;
|
|
12953
12953
|
const message = c.req.query("message");
|
|
12954
|
-
const registry = new
|
|
12954
|
+
const registry = new chunkKMM45BTY_cjs.DocumentTypeRegistry(db);
|
|
12955
12955
|
const docType = await registry.findById(typeId);
|
|
12956
12956
|
if (!docType) return c.html("<p>Unknown document type.</p>", 404);
|
|
12957
12957
|
const tenantId = reqTenant(c);
|
|
@@ -13064,7 +13064,7 @@ adminContentRoutes.get("/documents/:typeId/:rootId/versions", async (c) => {
|
|
|
13064
13064
|
const { typeId, rootId } = c.req.param();
|
|
13065
13065
|
const db = c.env.DB;
|
|
13066
13066
|
const { renderVersionHistoryFragment } = await import('./admin-documents-form.template-LSZKGA5J.cjs');
|
|
13067
|
-
const registry = new
|
|
13067
|
+
const registry = new chunkKMM45BTY_cjs.DocumentTypeRegistry(db);
|
|
13068
13068
|
const docType = await registry.findById(typeId);
|
|
13069
13069
|
if (!docType) return c.html("<div>Unknown type.</div>", 404);
|
|
13070
13070
|
const result = await db.prepare(
|
|
@@ -14996,7 +14996,7 @@ var TenantService = class {
|
|
|
14996
14996
|
SET name = ?, domain = ?, status = ?, notes = ?, updated_at = ?
|
|
14997
14997
|
WHERE slug = ?
|
|
14998
14998
|
`).bind(name, domain, status, notes, now, slug).run();
|
|
14999
|
-
|
|
14999
|
+
chunkKZIBF2EV_cjs.invalidateTenantCache();
|
|
15000
15000
|
const updated = await this.getTenantBySlug(slug);
|
|
15001
15001
|
if (!updated) throw new Error("Tenant not found");
|
|
15002
15002
|
return updated;
|
|
@@ -15014,7 +15014,7 @@ var TenantService = class {
|
|
|
15014
15014
|
throw new Error(`Tenant '${slug}' still owns ${docCount} document(s). Delete or migrate its content first.`);
|
|
15015
15015
|
}
|
|
15016
15016
|
await this.db.prepare(`DELETE FROM auth_tenant WHERE slug = ?`).bind(slug).run();
|
|
15017
|
-
|
|
15017
|
+
chunkKZIBF2EV_cjs.invalidateTenantCache();
|
|
15018
15018
|
}
|
|
15019
15019
|
// ─── Membership (auth_tenant_member) ───────────────────────────────────────
|
|
15020
15020
|
// Tenant resolution and the admin switcher are gated on membership: an authed user may only
|
|
@@ -15258,7 +15258,7 @@ var TenantService = class {
|
|
|
15258
15258
|
INSERT INTO auth_tenant (id, name, slug, status, domain, notes, metadata, created_at, updated_at)
|
|
15259
15259
|
VALUES (?, ?, ?, 'active', ?, ?, '{}', ?, ?)
|
|
15260
15260
|
`).bind(id, input.name, input.slug, input.domain, input.notes, now, now).run();
|
|
15261
|
-
|
|
15261
|
+
chunkKZIBF2EV_cjs.invalidateTenantCache();
|
|
15262
15262
|
const created = await this.getTenantBySlug(input.slug);
|
|
15263
15263
|
if (!created) throw new Error("Failed to create tenant");
|
|
15264
15264
|
return created;
|
|
@@ -15282,14 +15282,14 @@ function mapRowToTenant(row) {
|
|
|
15282
15282
|
|
|
15283
15283
|
// src/routes/admin-users.ts
|
|
15284
15284
|
var userRoutes = new hono.Hono();
|
|
15285
|
-
userRoutes.use("*",
|
|
15286
|
-
userRoutes.use("/users/*",
|
|
15287
|
-
userRoutes.use("/users",
|
|
15288
|
-
userRoutes.use("/invite-user",
|
|
15289
|
-
userRoutes.use("/resend-invitation/*",
|
|
15290
|
-
userRoutes.use("/cancel-invitation/*",
|
|
15291
|
-
userRoutes.use("/activity-logs",
|
|
15292
|
-
userRoutes.use("/activity-logs/*",
|
|
15285
|
+
userRoutes.use("*", chunkKMM45BTY_cjs.requireAuth());
|
|
15286
|
+
userRoutes.use("/users/*", chunkKMM45BTY_cjs.requireRole(["admin"]));
|
|
15287
|
+
userRoutes.use("/users", chunkKMM45BTY_cjs.requireRole(["admin"]));
|
|
15288
|
+
userRoutes.use("/invite-user", chunkKMM45BTY_cjs.requireRole(["admin"]));
|
|
15289
|
+
userRoutes.use("/resend-invitation/*", chunkKMM45BTY_cjs.requireRole(["admin"]));
|
|
15290
|
+
userRoutes.use("/cancel-invitation/*", chunkKMM45BTY_cjs.requireRole(["admin"]));
|
|
15291
|
+
userRoutes.use("/activity-logs", chunkKMM45BTY_cjs.requireRole(["admin"]));
|
|
15292
|
+
userRoutes.use("/activity-logs/*", chunkKMM45BTY_cjs.requireRole(["admin"]));
|
|
15293
15293
|
userRoutes.get("/", (c) => {
|
|
15294
15294
|
return c.redirect("/admin/dashboard");
|
|
15295
15295
|
});
|
|
@@ -15456,7 +15456,7 @@ userRoutes.put("/profile", async (c) => {
|
|
|
15456
15456
|
}
|
|
15457
15457
|
await saveCustomData(db, user.userId, sanitized);
|
|
15458
15458
|
}
|
|
15459
|
-
await
|
|
15459
|
+
await chunkKMM45BTY_cjs.logActivity(
|
|
15460
15460
|
db,
|
|
15461
15461
|
user.userId,
|
|
15462
15462
|
"profile.update",
|
|
@@ -15519,7 +15519,7 @@ userRoutes.post("/profile/avatar", async (c) => {
|
|
|
15519
15519
|
SELECT first_name, last_name FROM auth_user WHERE id = ?
|
|
15520
15520
|
`);
|
|
15521
15521
|
const userData = await userStmt.bind(user.userId).first();
|
|
15522
|
-
await
|
|
15522
|
+
await chunkKMM45BTY_cjs.logActivity(
|
|
15523
15523
|
db,
|
|
15524
15524
|
user.userId,
|
|
15525
15525
|
"profile.avatar_update",
|
|
@@ -15590,7 +15590,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
15590
15590
|
dismissible: true
|
|
15591
15591
|
}));
|
|
15592
15592
|
}
|
|
15593
|
-
const validPassword = await
|
|
15593
|
+
const validPassword = await chunkKMM45BTY_cjs.AuthManager.verifyPassword(currentPassword, userData.password_hash);
|
|
15594
15594
|
if (!validPassword) {
|
|
15595
15595
|
return c.html(chunkN32OWET6_cjs.renderAlert({
|
|
15596
15596
|
type: "error",
|
|
@@ -15598,7 +15598,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
15598
15598
|
dismissible: true
|
|
15599
15599
|
}));
|
|
15600
15600
|
}
|
|
15601
|
-
const newPasswordHash = await
|
|
15601
|
+
const newPasswordHash = await chunkKMM45BTY_cjs.AuthManager.hashPassword(newPassword);
|
|
15602
15602
|
const historyStmt = db.prepare(`
|
|
15603
15603
|
INSERT INTO auth_password_history (id, user_id, password_hash, created_at)
|
|
15604
15604
|
VALUES (?, ?, ?, ?)
|
|
@@ -15614,7 +15614,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
15614
15614
|
WHERE id = ?
|
|
15615
15615
|
`);
|
|
15616
15616
|
await updateStmt.bind(newPasswordHash, Date.now(), user.userId).run();
|
|
15617
|
-
await
|
|
15617
|
+
await chunkKMM45BTY_cjs.logActivity(
|
|
15618
15618
|
db,
|
|
15619
15619
|
user.userId,
|
|
15620
15620
|
"profile.password_change",
|
|
@@ -15681,7 +15681,7 @@ userRoutes.get("/users", async (c) => {
|
|
|
15681
15681
|
`);
|
|
15682
15682
|
const countResult = await countStmt.bind(...params).first();
|
|
15683
15683
|
const totalUsers = countResult?.total || 0;
|
|
15684
|
-
await
|
|
15684
|
+
await chunkKMM45BTY_cjs.logActivity(
|
|
15685
15685
|
db,
|
|
15686
15686
|
user.userId,
|
|
15687
15687
|
"users.list_view",
|
|
@@ -15862,7 +15862,7 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
15862
15862
|
dismissible: true
|
|
15863
15863
|
}));
|
|
15864
15864
|
}
|
|
15865
|
-
const passwordHash = await
|
|
15865
|
+
const passwordHash = await chunkKMM45BTY_cjs.AuthManager.hashPassword(password);
|
|
15866
15866
|
const userId = crypto.randomUUID();
|
|
15867
15867
|
const createStmt = db.prepare(`
|
|
15868
15868
|
INSERT INTO auth_user (
|
|
@@ -15887,7 +15887,7 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
15887
15887
|
if (sanitizedRegistrationCustom !== null && Object.keys(sanitizedRegistrationCustom).length > 0) {
|
|
15888
15888
|
await writeProfileData(db, userId, { custom: sanitizedRegistrationCustom }, user.userId);
|
|
15889
15889
|
}
|
|
15890
|
-
await
|
|
15890
|
+
await chunkKMM45BTY_cjs.logActivity(
|
|
15891
15891
|
db,
|
|
15892
15892
|
user.userId,
|
|
15893
15893
|
"user!.create",
|
|
@@ -15926,7 +15926,7 @@ userRoutes.get("/users/:id", async (c) => {
|
|
|
15926
15926
|
if (!userRecord) {
|
|
15927
15927
|
return c.json({ error: "User not found" }, 404);
|
|
15928
15928
|
}
|
|
15929
|
-
await
|
|
15929
|
+
await chunkKMM45BTY_cjs.logActivity(
|
|
15930
15930
|
db,
|
|
15931
15931
|
user.userId,
|
|
15932
15932
|
"user!.view",
|
|
@@ -16140,7 +16140,7 @@ userRoutes.put("/users/:id", async (c) => {
|
|
|
16140
16140
|
userId
|
|
16141
16141
|
).run();
|
|
16142
16142
|
if (newPassword) {
|
|
16143
|
-
const passwordHash = await
|
|
16143
|
+
const passwordHash = await chunkKMM45BTY_cjs.AuthManager.hashPassword(newPassword);
|
|
16144
16144
|
const updatePasswordStmt = db.prepare(`
|
|
16145
16145
|
UPDATE auth_user SET password_hash = ?, updated_at = ? WHERE id = ?
|
|
16146
16146
|
`);
|
|
@@ -16153,7 +16153,7 @@ userRoutes.put("/users/:id", async (c) => {
|
|
|
16153
16153
|
...sanitizedCustom !== null ? { custom: sanitizedCustom } : {}
|
|
16154
16154
|
}, user.userId);
|
|
16155
16155
|
}
|
|
16156
|
-
await
|
|
16156
|
+
await chunkKMM45BTY_cjs.logActivity(
|
|
16157
16157
|
db,
|
|
16158
16158
|
user.userId,
|
|
16159
16159
|
"user.update",
|
|
@@ -16199,7 +16199,7 @@ userRoutes.post("/users/:id/toggle", async (c) => {
|
|
|
16199
16199
|
UPDATE auth_user SET is_active = ?, updated_at = ? WHERE id = ?
|
|
16200
16200
|
`);
|
|
16201
16201
|
await toggleStmt.bind(active ? 1 : 0, Date.now(), userId).run();
|
|
16202
|
-
await
|
|
16202
|
+
await chunkKMM45BTY_cjs.logActivity(
|
|
16203
16203
|
db,
|
|
16204
16204
|
user.userId,
|
|
16205
16205
|
active ? "user.activate" : "user.deactivate",
|
|
@@ -16240,7 +16240,7 @@ userRoutes.delete("/users/:id", async (c) => {
|
|
|
16240
16240
|
DELETE FROM auth_user WHERE id = ?
|
|
16241
16241
|
`);
|
|
16242
16242
|
await deleteStmt.bind(userId).run();
|
|
16243
|
-
await
|
|
16243
|
+
await chunkKMM45BTY_cjs.logActivity(
|
|
16244
16244
|
db,
|
|
16245
16245
|
user.userId,
|
|
16246
16246
|
"user!.hard_delete",
|
|
@@ -16259,7 +16259,7 @@ userRoutes.delete("/users/:id", async (c) => {
|
|
|
16259
16259
|
UPDATE auth_user SET is_active = 0, updated_at = ? WHERE id = ?
|
|
16260
16260
|
`);
|
|
16261
16261
|
await deleteStmt.bind(Date.now(), userId).run();
|
|
16262
|
-
await
|
|
16262
|
+
await chunkKMM45BTY_cjs.logActivity(
|
|
16263
16263
|
db,
|
|
16264
16264
|
user.userId,
|
|
16265
16265
|
"user!.soft_delete",
|
|
@@ -16325,7 +16325,7 @@ userRoutes.post("/invite-user", async (c) => {
|
|
|
16325
16325
|
Date.now(),
|
|
16326
16326
|
Date.now()
|
|
16327
16327
|
).run();
|
|
16328
|
-
await
|
|
16328
|
+
await chunkKMM45BTY_cjs.logActivity(
|
|
16329
16329
|
db,
|
|
16330
16330
|
user.userId,
|
|
16331
16331
|
"user!.invite_sent",
|
|
@@ -16382,7 +16382,7 @@ userRoutes.post("/resend-invitation/:id", async (c) => {
|
|
|
16382
16382
|
Date.now(),
|
|
16383
16383
|
userId
|
|
16384
16384
|
).run();
|
|
16385
|
-
await
|
|
16385
|
+
await chunkKMM45BTY_cjs.logActivity(
|
|
16386
16386
|
db,
|
|
16387
16387
|
user.userId,
|
|
16388
16388
|
"user!.invitation_resent",
|
|
@@ -16418,7 +16418,7 @@ userRoutes.delete("/cancel-invitation/:id", async (c) => {
|
|
|
16418
16418
|
}
|
|
16419
16419
|
const deleteStmt = db.prepare(`DELETE FROM auth_user WHERE id = ?`);
|
|
16420
16420
|
await deleteStmt.bind(userId).run();
|
|
16421
|
-
await
|
|
16421
|
+
await chunkKMM45BTY_cjs.logActivity(
|
|
16422
16422
|
db,
|
|
16423
16423
|
user.userId,
|
|
16424
16424
|
"user!.invitation_cancelled",
|
|
@@ -17799,7 +17799,7 @@ var fileValidationSchema2 = zod.z.object({
|
|
|
17799
17799
|
// 50MB max
|
|
17800
17800
|
});
|
|
17801
17801
|
var adminMediaRoutes = new hono.Hono();
|
|
17802
|
-
adminMediaRoutes.use("*",
|
|
17802
|
+
adminMediaRoutes.use("*", chunkKMM45BTY_cjs.requireAuth());
|
|
17803
17803
|
adminMediaRoutes.get("/", async (c) => {
|
|
17804
17804
|
try {
|
|
17805
17805
|
const user = c.get("user");
|
|
@@ -17841,7 +17841,7 @@ adminMediaRoutes.get("/selector", async (c) => {
|
|
|
17841
17841
|
const { searchParams } = new URL(c.req.url);
|
|
17842
17842
|
const search = searchParams.get("search") || "";
|
|
17843
17843
|
const db = c.env.DB;
|
|
17844
|
-
const pluginService = new
|
|
17844
|
+
const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
|
|
17845
17845
|
const mediaPlugin = await pluginService.getPlugin("core-media");
|
|
17846
17846
|
if (!mediaPlugin || mediaPlugin.status !== "active") {
|
|
17847
17847
|
return c.html(html.html`
|
|
@@ -18215,7 +18215,7 @@ adminMediaRoutes.put("/:id", async (c) => {
|
|
|
18215
18215
|
`);
|
|
18216
18216
|
}
|
|
18217
18217
|
});
|
|
18218
|
-
adminMediaRoutes.delete("/cleanup",
|
|
18218
|
+
adminMediaRoutes.delete("/cleanup", chunkKMM45BTY_cjs.requireRole("admin"), async (c) => {
|
|
18219
18219
|
try {
|
|
18220
18220
|
const db = c.env.DB;
|
|
18221
18221
|
const allMediaStmt = db.prepare("SELECT id, r2_key, filename FROM media WHERE deleted_at IS NULL");
|
|
@@ -19334,6 +19334,8 @@ function escapeHtmlAttr(value) {
|
|
|
19334
19334
|
}
|
|
19335
19335
|
function renderPluginSettingsPage(data) {
|
|
19336
19336
|
const { plugin, activity = [], user } = data;
|
|
19337
|
+
const hasUserSettings = Object.keys(plugin.settings || {}).some((k) => !k.startsWith("_"));
|
|
19338
|
+
const defaultTab = "info";
|
|
19337
19339
|
const pageContent = `
|
|
19338
19340
|
<div class="w-full px-4 sm:px-6 lg:px-8 py-6">
|
|
19339
19341
|
<!-- Header with Back Button -->
|
|
@@ -19344,13 +19346,24 @@ function renderPluginSettingsPage(data) {
|
|
|
19344
19346
|
${plugin.description}
|
|
19345
19347
|
</p>
|
|
19346
19348
|
</div>
|
|
19347
|
-
<div class="mt-4 sm:mt-0 sm:ml-16
|
|
19349
|
+
<div class="mt-4 sm:mt-0 sm:ml-16 flex items-center gap-3">
|
|
19348
19350
|
<a href="/admin/plugins" class="inline-flex items-center justify-center rounded-lg bg-white dark:bg-zinc-800 px-3.5 py-2.5 text-sm font-semibold text-zinc-950 dark:text-white ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 hover:bg-zinc-50 dark:hover:bg-zinc-700 transition-colors shadow-sm">
|
|
19349
19351
|
<svg class="-ml-0.5 mr-1.5 h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
19350
19352
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"/>
|
|
19351
19353
|
</svg>
|
|
19352
19354
|
Back to Plugins
|
|
19353
19355
|
</a>
|
|
19356
|
+
${plugin.settings?._adminPath ? `
|
|
19357
|
+
<a
|
|
19358
|
+
href="${plugin.settings._adminPath}"
|
|
19359
|
+
class="inline-flex items-center justify-center gap-1.5 rounded-lg bg-gradient-to-r from-cyan-500 to-purple-600 hover:from-cyan-400 hover:to-purple-500 px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm transition-all duration-200"
|
|
19360
|
+
>
|
|
19361
|
+
<svg class="-ml-0.5 h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
19362
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"/>
|
|
19363
|
+
</svg>
|
|
19364
|
+
View Page
|
|
19365
|
+
</a>
|
|
19366
|
+
` : ""}
|
|
19354
19367
|
</div>
|
|
19355
19368
|
</div>
|
|
19356
19369
|
|
|
@@ -19383,23 +19396,25 @@ function renderPluginSettingsPage(data) {
|
|
|
19383
19396
|
<!-- Tabs -->
|
|
19384
19397
|
<div class="mb-6">
|
|
19385
19398
|
<nav class="flex space-x-8" aria-label="Tabs">
|
|
19386
|
-
<
|
|
19399
|
+
<a href="#info" onclick="showTab('info')" id="info-tab" class="tab-button border-b-2 border-transparent py-2 px-1 text-sm font-medium text-gray-400 hover:text-gray-300">
|
|
19400
|
+
Information
|
|
19401
|
+
</a>
|
|
19402
|
+
${hasUserSettings ? `
|
|
19403
|
+
<a href="#settings" onclick="showTab('settings')" id="settings-tab" class="tab-button border-b-2 border-transparent py-2 px-1 text-sm font-medium text-gray-400 hover:text-gray-300">
|
|
19387
19404
|
Settings
|
|
19388
|
-
</
|
|
19389
|
-
|
|
19405
|
+
</a>
|
|
19406
|
+
` : ""}
|
|
19407
|
+
<a href="#activity" onclick="showTab('activity')" id="activity-tab" class="tab-button border-b-2 border-transparent py-2 px-1 text-sm font-medium text-gray-400 hover:text-gray-300">
|
|
19390
19408
|
Activity Log
|
|
19391
|
-
</
|
|
19392
|
-
<button onclick="showTab('info')" id="info-tab" class="tab-button border-b-2 border-transparent py-2 px-1 text-sm font-medium text-gray-400 hover:text-gray-300">
|
|
19393
|
-
Information
|
|
19394
|
-
</button>
|
|
19409
|
+
</a>
|
|
19395
19410
|
</nav>
|
|
19396
19411
|
</div>
|
|
19397
19412
|
|
|
19398
19413
|
<!-- Tab Content -->
|
|
19399
19414
|
<div id="tab-content">
|
|
19400
19415
|
<!-- Settings Tab -->
|
|
19401
|
-
<div id="settings-content" class="tab-content">
|
|
19402
|
-
${renderSettingsTab(plugin)}
|
|
19416
|
+
<div id="settings-content" class="tab-content hidden">
|
|
19417
|
+
${hasUserSettings ? renderSettingsTab(plugin) : ""}
|
|
19403
19418
|
</div>
|
|
19404
19419
|
|
|
19405
19420
|
<!-- Activity Tab -->
|
|
@@ -19415,27 +19430,42 @@ function renderPluginSettingsPage(data) {
|
|
|
19415
19430
|
</div>
|
|
19416
19431
|
|
|
19417
19432
|
<script>
|
|
19433
|
+
const VALID_TABS = [${hasUserSettings ? "'settings', " : ""}'activity', 'info'];
|
|
19434
|
+
|
|
19418
19435
|
function showTab(tabName) {
|
|
19419
|
-
|
|
19436
|
+
if (!VALID_TABS.includes(tabName)) tabName = '${defaultTab}';
|
|
19437
|
+
|
|
19420
19438
|
document.querySelectorAll('.tab-content').forEach(content => {
|
|
19421
19439
|
content.classList.add('hidden');
|
|
19422
19440
|
});
|
|
19423
|
-
|
|
19424
|
-
// Remove active class from all tabs
|
|
19441
|
+
|
|
19425
19442
|
document.querySelectorAll('.tab-button').forEach(tab => {
|
|
19426
19443
|
tab.classList.remove('active', 'border-blue-400', 'text-blue-400');
|
|
19427
19444
|
tab.classList.add('border-transparent', 'text-gray-400');
|
|
19428
19445
|
});
|
|
19429
|
-
|
|
19430
|
-
|
|
19431
|
-
|
|
19432
|
-
|
|
19433
|
-
// Add active class to selected tab
|
|
19446
|
+
|
|
19447
|
+
const contentEl = document.getElementById(tabName + '-content');
|
|
19448
|
+
if (contentEl) contentEl.classList.remove('hidden');
|
|
19449
|
+
|
|
19434
19450
|
const activeTab = document.getElementById(tabName + '-tab');
|
|
19435
|
-
activeTab
|
|
19436
|
-
|
|
19451
|
+
if (activeTab) {
|
|
19452
|
+
activeTab.classList.add('active', 'border-blue-400', 'text-blue-400');
|
|
19453
|
+
activeTab.classList.remove('border-transparent', 'text-gray-400');
|
|
19454
|
+
}
|
|
19455
|
+
|
|
19456
|
+
if (window.location.hash !== '#' + tabName) {
|
|
19457
|
+
history.replaceState(null, '', '#' + tabName);
|
|
19458
|
+
}
|
|
19459
|
+
}
|
|
19460
|
+
|
|
19461
|
+
function initTabFromHash() {
|
|
19462
|
+
const hash = window.location.hash.replace('#', '');
|
|
19463
|
+
showTab(VALID_TABS.includes(hash) ? hash : '${defaultTab}');
|
|
19437
19464
|
}
|
|
19438
19465
|
|
|
19466
|
+
window.addEventListener('hashchange', initTabFromHash);
|
|
19467
|
+
initTabFromHash();
|
|
19468
|
+
|
|
19439
19469
|
async function togglePlugin(pluginId, action) {
|
|
19440
19470
|
const button = event.target;
|
|
19441
19471
|
const originalText = button.textContent;
|
|
@@ -19608,6 +19638,7 @@ function renderToggleButton(plugin) {
|
|
|
19608
19638
|
function renderSettingsTab(plugin) {
|
|
19609
19639
|
const settings = plugin.settings || {};
|
|
19610
19640
|
const pluginId = plugin.id || plugin.name;
|
|
19641
|
+
const hasUserKeys = Object.keys(settings).some((k) => !k.startsWith("_"));
|
|
19611
19642
|
const customRenderer = pluginSettingsComponents[pluginId];
|
|
19612
19643
|
if (customRenderer) {
|
|
19613
19644
|
return `
|
|
@@ -19643,9 +19674,9 @@ function renderSettingsTab(plugin) {
|
|
|
19643
19674
|
`}
|
|
19644
19675
|
|
|
19645
19676
|
<form id="settings-form" class="space-y-6">
|
|
19646
|
-
${isAuthPlugin &&
|
|
19677
|
+
${isAuthPlugin && hasUserKeys ? renderAuthSettingsForm(settings) : isTurnstilePlugin && hasUserKeys ? renderTurnstileSettingsForm(settings) : hasUserKeys ? renderSettingsFields(settings) : renderNoSettings(plugin)}
|
|
19647
19678
|
|
|
19648
|
-
${
|
|
19679
|
+
${hasUserKeys ? `
|
|
19649
19680
|
<div class="flex items-center justify-end pt-6 border-t border-white/10">
|
|
19650
19681
|
<button
|
|
19651
19682
|
type="button"
|
|
@@ -19662,7 +19693,7 @@ function renderSettingsTab(plugin) {
|
|
|
19662
19693
|
`;
|
|
19663
19694
|
}
|
|
19664
19695
|
function renderSettingsFields(settings) {
|
|
19665
|
-
return Object.entries(settings).map(([key, value]) => {
|
|
19696
|
+
return Object.entries(settings).filter(([key]) => !key.startsWith("_")).map(([key, value]) => {
|
|
19666
19697
|
const fieldId = `setting_${key}`;
|
|
19667
19698
|
const displayName = key.replace(/([A-Z])/g, " $1").replace(/^./, (str) => str.toUpperCase());
|
|
19668
19699
|
if (typeof value === "boolean") {
|
|
@@ -19851,6 +19882,38 @@ function renderActivityTab(activity) {
|
|
|
19851
19882
|
}
|
|
19852
19883
|
function renderInformationTab(plugin) {
|
|
19853
19884
|
return `
|
|
19885
|
+
${plugin.description ? `
|
|
19886
|
+
<!-- About -->
|
|
19887
|
+
<div class="backdrop-blur-md bg-black/20 rounded-xl border border-white/10 shadow-xl p-6 mb-6">
|
|
19888
|
+
<h2 class="text-xl font-semibold text-white mb-3">About</h2>
|
|
19889
|
+
<p class="text-gray-300 leading-relaxed">${plugin.description}</p>
|
|
19890
|
+
</div>
|
|
19891
|
+
` : ""}
|
|
19892
|
+
|
|
19893
|
+
${(plugin.settings?._routes?.length ?? 0) > 0 ? `
|
|
19894
|
+
<!-- Routes -->
|
|
19895
|
+
<div class="backdrop-blur-md bg-black/20 rounded-xl border border-white/10 shadow-xl p-6 mb-6">
|
|
19896
|
+
<h2 class="text-xl font-semibold text-white mb-4">Routes</h2>
|
|
19897
|
+
<div class="space-y-2">
|
|
19898
|
+
${plugin.settings._routes.map((r) => {
|
|
19899
|
+
const badge = r.method === "GET" ? "bg-emerald-500/20 text-emerald-300 border border-emerald-500/30" : r.method === "POST" ? "bg-blue-500/20 text-blue-300 border border-blue-500/30" : r.method === "DELETE" ? "bg-red-500/20 text-red-300 border border-red-500/30" : "bg-white/10 text-gray-300 border border-white/20";
|
|
19900
|
+
const pathHtml = r.method === "GET" ? `<a href="${r.path}" class="font-mono text-sm text-blue-400 hover:text-blue-300 hover:underline">${r.path}</a>` : `<span class="font-mono text-sm text-gray-200">${r.path}</span>`;
|
|
19901
|
+
const authBadge = r.requiresAuth ? `<span class="ml-2 text-xs text-amber-400/80">\u{1F512} auth</span>` : "";
|
|
19902
|
+
return `
|
|
19903
|
+
<div class="flex items-start gap-3 py-2 border-b border-white/5 last:border-0">
|
|
19904
|
+
<span class="shrink-0 inline-block px-2 py-0.5 rounded text-xs font-bold ${badge}">${r.method}</span>
|
|
19905
|
+
<div class="min-w-0">
|
|
19906
|
+
<div class="flex items-center gap-1 flex-wrap">
|
|
19907
|
+
${pathHtml}${authBadge}
|
|
19908
|
+
</div>
|
|
19909
|
+
${r.description ? `<p class="text-xs text-gray-400 mt-0.5">${r.description}</p>` : ""}
|
|
19910
|
+
</div>
|
|
19911
|
+
</div>`;
|
|
19912
|
+
}).join("")}
|
|
19913
|
+
</div>
|
|
19914
|
+
</div>
|
|
19915
|
+
` : ""}
|
|
19916
|
+
|
|
19854
19917
|
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
|
19855
19918
|
<!-- Plugin Details -->
|
|
19856
19919
|
<div class="backdrop-blur-md bg-black/20 rounded-xl border border-white/10 shadow-xl p-6">
|
|
@@ -20648,8 +20711,8 @@ defineUserProfile({
|
|
|
20648
20711
|
|
|
20649
20712
|
// src/routes/admin-plugins.ts
|
|
20650
20713
|
var adminPluginRoutes = new hono.Hono();
|
|
20651
|
-
adminPluginRoutes.use("*",
|
|
20652
|
-
var AVAILABLE_PLUGINS = Object.values(
|
|
20714
|
+
adminPluginRoutes.use("*", chunkKMM45BTY_cjs.requireAuth());
|
|
20715
|
+
var AVAILABLE_PLUGINS = Object.values(chunkKZIBF2EV_cjs.PLUGIN_REGISTRY).map((p) => ({
|
|
20653
20716
|
id: p.id,
|
|
20654
20717
|
name: p.codeName,
|
|
20655
20718
|
display_name: p.displayName,
|
|
@@ -20669,7 +20732,7 @@ adminPluginRoutes.get("/", async (c) => {
|
|
|
20669
20732
|
if (user?.role !== "admin") {
|
|
20670
20733
|
return c.text("Access denied", 403);
|
|
20671
20734
|
}
|
|
20672
|
-
const pluginService = new
|
|
20735
|
+
const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
|
|
20673
20736
|
let installedPlugins = [];
|
|
20674
20737
|
let stats = { total: 0, active: 0, inactive: 0, errors: 0, uninstalled: 0 };
|
|
20675
20738
|
try {
|
|
@@ -20741,10 +20804,10 @@ adminPluginRoutes.get("/:id", async (c) => {
|
|
|
20741
20804
|
if (user?.role !== "admin") {
|
|
20742
20805
|
return c.redirect("/admin/plugins");
|
|
20743
20806
|
}
|
|
20744
|
-
const pluginService = new
|
|
20807
|
+
const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
|
|
20745
20808
|
let plugin = await pluginService.getPlugin(pluginId);
|
|
20746
20809
|
if (!plugin) {
|
|
20747
|
-
const def =
|
|
20810
|
+
const def = chunkKOXFYFOF_cjs.getPluginDefinition(pluginId);
|
|
20748
20811
|
if (!def) return c.text("Plugin not found", 404);
|
|
20749
20812
|
plugin = await pluginService.ensurePlugin(pluginId, {
|
|
20750
20813
|
displayName: def.displayName ?? pluginId,
|
|
@@ -20835,14 +20898,14 @@ adminPluginRoutes.get("/:id/configure", async (c) => {
|
|
|
20835
20898
|
const user = c.get("user");
|
|
20836
20899
|
const pluginId = c.req.param("id");
|
|
20837
20900
|
if (user?.role !== "admin") return c.redirect("/admin/plugins");
|
|
20838
|
-
const def =
|
|
20901
|
+
const def = chunkKOXFYFOF_cjs.getPluginDefinition(pluginId);
|
|
20839
20902
|
if (!def?.configSchema) return c.text("No schema-driven settings for this plugin", 404);
|
|
20840
20903
|
const db = c.env.DB;
|
|
20841
|
-
const pluginService = new
|
|
20904
|
+
const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
|
|
20842
20905
|
const plugin = await pluginService.getPlugin(pluginId);
|
|
20843
20906
|
const stored = plugin?.settings ?? {};
|
|
20844
|
-
const values =
|
|
20845
|
-
const fieldsHtml =
|
|
20907
|
+
const values = chunkKOXFYFOF_cjs.applySchemaDefaults(def.configSchema, stored);
|
|
20908
|
+
const fieldsHtml = chunkKOXFYFOF_cjs.renderSchemaFields(def.configSchema, values);
|
|
20846
20909
|
const displayName = plugin?.display_name ?? def.displayName ?? def.id;
|
|
20847
20910
|
return c.html(`<!DOCTYPE html>
|
|
20848
20911
|
<html lang="en"><head>
|
|
@@ -20869,19 +20932,21 @@ adminPluginRoutes.post("/:id/configure", async (c) => {
|
|
|
20869
20932
|
const user = c.get("user");
|
|
20870
20933
|
const pluginId = c.req.param("id");
|
|
20871
20934
|
if (user?.role !== "admin") return c.json({ error: "Access denied" }, 403);
|
|
20872
|
-
const def =
|
|
20935
|
+
const def = chunkKOXFYFOF_cjs.getPluginDefinition(pluginId);
|
|
20873
20936
|
if (!def?.configSchema) return c.text("No schema-driven settings for this plugin", 404);
|
|
20874
20937
|
const form = await c.req.formData();
|
|
20875
|
-
const parsed =
|
|
20938
|
+
const parsed = chunkKOXFYFOF_cjs.parseFormDataToSettings(def.configSchema, form);
|
|
20876
20939
|
const db = c.env.DB;
|
|
20877
|
-
const pluginService = new
|
|
20940
|
+
const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
|
|
20878
20941
|
await pluginService.ensurePlugin(pluginId, {
|
|
20879
20942
|
displayName: def.displayName ?? pluginId,
|
|
20880
20943
|
version: def.version,
|
|
20881
20944
|
description: def.description,
|
|
20882
20945
|
author: typeof def.author === "object" ? def.author?.name : def.author
|
|
20883
20946
|
});
|
|
20884
|
-
await pluginService.
|
|
20947
|
+
const existingPlugin = await pluginService.getPlugin(pluginId);
|
|
20948
|
+
const existingSettings = existingPlugin?.settings ?? {};
|
|
20949
|
+
await pluginService.updatePluginSettings(pluginId, { ...existingSettings, ...parsed });
|
|
20885
20950
|
return c.redirect(`/admin/plugins/${encodeURIComponent(pluginId)}/configure`);
|
|
20886
20951
|
} catch (error) {
|
|
20887
20952
|
console.error("Error saving schema settings:", error);
|
|
@@ -20896,7 +20961,7 @@ adminPluginRoutes.post("/:id/activate", async (c) => {
|
|
|
20896
20961
|
if (user?.role !== "admin") {
|
|
20897
20962
|
return c.json({ error: "Access denied" }, 403);
|
|
20898
20963
|
}
|
|
20899
|
-
const pluginService = new
|
|
20964
|
+
const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
|
|
20900
20965
|
await pluginService.activatePlugin(pluginId);
|
|
20901
20966
|
return c.json({ success: true });
|
|
20902
20967
|
} catch (error) {
|
|
@@ -20913,7 +20978,7 @@ adminPluginRoutes.post("/:id/deactivate", async (c) => {
|
|
|
20913
20978
|
if (user?.role !== "admin") {
|
|
20914
20979
|
return c.json({ error: "Access denied" }, 403);
|
|
20915
20980
|
}
|
|
20916
|
-
const pluginService = new
|
|
20981
|
+
const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
|
|
20917
20982
|
await pluginService.deactivatePlugin(pluginId);
|
|
20918
20983
|
return c.json({ success: true });
|
|
20919
20984
|
} catch (error) {
|
|
@@ -20930,8 +20995,8 @@ adminPluginRoutes.post("/install", async (c) => {
|
|
|
20930
20995
|
return c.json({ error: "Access denied" }, 403);
|
|
20931
20996
|
}
|
|
20932
20997
|
const body = await c.req.json();
|
|
20933
|
-
const pluginService = new
|
|
20934
|
-
const registryEntry =
|
|
20998
|
+
const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
|
|
20999
|
+
const registryEntry = chunkKZIBF2EV_cjs.findPluginByCodeName(body.name) || chunkKZIBF2EV_cjs.PLUGIN_REGISTRY[body.name] || chunkKZIBF2EV_cjs.PLUGIN_REGISTRY[body.id];
|
|
20935
21000
|
if (!registryEntry) {
|
|
20936
21001
|
return c.json({ error: "Plugin not found in registry" }, 404);
|
|
20937
21002
|
}
|
|
@@ -20964,7 +21029,7 @@ adminPluginRoutes.post("/:id/uninstall", async (c) => {
|
|
|
20964
21029
|
if (user?.role !== "admin") {
|
|
20965
21030
|
return c.json({ error: "Access denied" }, 403);
|
|
20966
21031
|
}
|
|
20967
|
-
const pluginService = new
|
|
21032
|
+
const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
|
|
20968
21033
|
await pluginService.uninstallPlugin(pluginId);
|
|
20969
21034
|
return c.json({ success: true });
|
|
20970
21035
|
} catch (error) {
|
|
@@ -20982,7 +21047,7 @@ adminPluginRoutes.post("/:id/settings", async (c) => {
|
|
|
20982
21047
|
return c.json({ error: "Access denied" }, 403);
|
|
20983
21048
|
}
|
|
20984
21049
|
const settings = await c.req.json();
|
|
20985
|
-
const pluginService = new
|
|
21050
|
+
const pluginService = new chunkKZIBF2EV_cjs.PluginService(db);
|
|
20986
21051
|
await pluginService.updatePluginSettings(pluginId, settings);
|
|
20987
21052
|
if (pluginId === "core-auth") {
|
|
20988
21053
|
try {
|
|
@@ -21790,7 +21855,7 @@ function renderLogConfigPage(data) {
|
|
|
21790
21855
|
|
|
21791
21856
|
// src/routes/admin-logs.ts
|
|
21792
21857
|
var adminLogsRoutes = new hono.Hono();
|
|
21793
|
-
adminLogsRoutes.use("*",
|
|
21858
|
+
adminLogsRoutes.use("*", chunkKMM45BTY_cjs.requireAuth());
|
|
21794
21859
|
adminLogsRoutes.get("/", async (c) => {
|
|
21795
21860
|
try {
|
|
21796
21861
|
const user = c.get("user");
|
|
@@ -22782,9 +22847,9 @@ function renderStorageUsage(databaseSizeBytes, mediaSizeBytes) {
|
|
|
22782
22847
|
}
|
|
22783
22848
|
|
|
22784
22849
|
// src/routes/admin-dashboard.ts
|
|
22785
|
-
var VERSION =
|
|
22850
|
+
var VERSION = chunk3XFA3E2F_cjs.getCoreVersion();
|
|
22786
22851
|
var router = new hono.Hono();
|
|
22787
|
-
router.use("*",
|
|
22852
|
+
router.use("*", chunkKMM45BTY_cjs.requireAuth());
|
|
22788
22853
|
router.get("/", async (c) => {
|
|
22789
22854
|
const user = c.get("user");
|
|
22790
22855
|
try {
|
|
@@ -24749,7 +24814,7 @@ function renderCollectionFormPage(data) {
|
|
|
24749
24814
|
// src/routes/admin-collections.ts
|
|
24750
24815
|
chunkK623Q6WD_cjs.init_admin_layout_catalyst_template();
|
|
24751
24816
|
var adminCollectionsRoutes = new hono.Hono();
|
|
24752
|
-
adminCollectionsRoutes.use("*",
|
|
24817
|
+
adminCollectionsRoutes.use("*", chunkKMM45BTY_cjs.requireAuth());
|
|
24753
24818
|
adminCollectionsRoutes.get("/", async (c) => {
|
|
24754
24819
|
try {
|
|
24755
24820
|
const user = c.get("user");
|
|
@@ -24766,7 +24831,7 @@ adminCollectionsRoutes.get("/", async (c) => {
|
|
|
24766
24831
|
results = queryResults.results ?? [];
|
|
24767
24832
|
} catch (e) {
|
|
24768
24833
|
}
|
|
24769
|
-
const codeCollections =
|
|
24834
|
+
const codeCollections = chunkKZIBF2EV_cjs.getCollectionRegistry().list();
|
|
24770
24835
|
const codeCollectionsMap = new Map(
|
|
24771
24836
|
codeCollections.map((cfg) => {
|
|
24772
24837
|
const fieldCount = cfg.schema?.properties ? Object.keys(cfg.schema.properties).length : 0;
|
|
@@ -24780,7 +24845,7 @@ adminCollectionsRoutes.get("/", async (c) => {
|
|
|
24780
24845
|
field_count: fieldCount,
|
|
24781
24846
|
managed: cfg.managed !== false,
|
|
24782
24847
|
source_type: "code",
|
|
24783
|
-
internal:
|
|
24848
|
+
internal: chunkKZIBF2EV_cjs.isCodeCollectionInternal(cfg),
|
|
24784
24849
|
versioning: cfg.versioning === true
|
|
24785
24850
|
}];
|
|
24786
24851
|
})
|
|
@@ -24819,7 +24884,7 @@ adminCollectionsRoutes.get("/", async (c) => {
|
|
|
24819
24884
|
field_count: fieldCount,
|
|
24820
24885
|
managed: false,
|
|
24821
24886
|
source_type: row.source === "code" || row.source === "system" || row.source === "plugin" ? "code" : "user",
|
|
24822
|
-
internal:
|
|
24887
|
+
internal: chunkKZIBF2EV_cjs.isDbDocTypeInternal(row.source),
|
|
24823
24888
|
versioning: dbVersioning
|
|
24824
24889
|
};
|
|
24825
24890
|
});
|
|
@@ -24980,7 +25045,7 @@ export const myPlugin = definePlugin({
|
|
|
24980
25045
|
title: "Add a Collection",
|
|
24981
25046
|
pageTitle: "Add a Collection",
|
|
24982
25047
|
currentPath: "/admin/collections",
|
|
24983
|
-
version:
|
|
25048
|
+
version: chunk3XFA3E2F_cjs.getCoreVersion(),
|
|
24984
25049
|
user: u ? { name: u.email ?? "Admin", email: u.email ?? "", role: u.role ?? "admin" } : void 0,
|
|
24985
25050
|
content
|
|
24986
25051
|
})
|
|
@@ -24997,7 +25062,7 @@ adminCollectionsRoutes.get("/:id", async (c) => {
|
|
|
24997
25062
|
collection = await stmt.bind(id).first();
|
|
24998
25063
|
} catch {
|
|
24999
25064
|
}
|
|
25000
|
-
const registryRecord =
|
|
25065
|
+
const registryRecord = chunkKZIBF2EV_cjs.getCollectionRegistry().getById(id) ?? chunkKZIBF2EV_cjs.getCollectionRegistry().getByName(id);
|
|
25001
25066
|
if (!collection && !registryRecord) {
|
|
25002
25067
|
const formData2 = {
|
|
25003
25068
|
isEdit: true,
|
|
@@ -25044,9 +25109,9 @@ adminCollectionsRoutes.get("/:id", async (c) => {
|
|
|
25044
25109
|
isCodeDriven = true;
|
|
25045
25110
|
}
|
|
25046
25111
|
const [tinymceActive, quillActive, mdxeditorActive] = await Promise.all([
|
|
25047
|
-
|
|
25048
|
-
|
|
25049
|
-
|
|
25112
|
+
chunkKMM45BTY_cjs.isPluginActive(db, "tinymce-plugin"),
|
|
25113
|
+
chunkKMM45BTY_cjs.isPluginActive(db, "quill-editor"),
|
|
25114
|
+
chunkKMM45BTY_cjs.isPluginActive(db, "easy-mdx")
|
|
25050
25115
|
]);
|
|
25051
25116
|
const displayName = collection?.display_name ?? registryRecord?.displayName ?? id;
|
|
25052
25117
|
const formData = {
|
|
@@ -25066,9 +25131,9 @@ adminCollectionsRoutes.get("/:id", async (c) => {
|
|
|
25066
25131
|
console.error("Error fetching collection:", error);
|
|
25067
25132
|
const user = c.get("user");
|
|
25068
25133
|
const [tinymceActive, quillActive, mdxeditorActive] = await Promise.all([
|
|
25069
|
-
|
|
25070
|
-
|
|
25071
|
-
|
|
25134
|
+
chunkKMM45BTY_cjs.isPluginActive(db, "tinymce-plugin"),
|
|
25135
|
+
chunkKMM45BTY_cjs.isPluginActive(db, "quill-editor"),
|
|
25136
|
+
chunkKMM45BTY_cjs.isPluginActive(db, "easy-mdx")
|
|
25072
25137
|
]);
|
|
25073
25138
|
const formData = {
|
|
25074
25139
|
isEdit: true,
|
|
@@ -26017,7 +26082,7 @@ function renderDatabaseToolsSettings(settings) {
|
|
|
26017
26082
|
|
|
26018
26083
|
// src/routes/admin-settings.ts
|
|
26019
26084
|
var adminSettingsRoutes = new hono.Hono();
|
|
26020
|
-
adminSettingsRoutes.use("*",
|
|
26085
|
+
adminSettingsRoutes.use("*", chunkKMM45BTY_cjs.requireAuth());
|
|
26021
26086
|
function getMockSettings(user) {
|
|
26022
26087
|
return {
|
|
26023
26088
|
general: {
|
|
@@ -26120,7 +26185,7 @@ adminSettingsRoutes.get("/database-tools", (c) => {
|
|
|
26120
26185
|
adminSettingsRoutes.get("/api/migrations/status", async (c) => {
|
|
26121
26186
|
try {
|
|
26122
26187
|
const db = c.env.DB;
|
|
26123
|
-
const migrationService = new
|
|
26188
|
+
const migrationService = new chunkIA24HACT_cjs.MigrationService(db);
|
|
26124
26189
|
const status = await migrationService.getMigrationStatus();
|
|
26125
26190
|
return c.json({
|
|
26126
26191
|
success: true,
|
|
@@ -26160,7 +26225,7 @@ adminSettingsRoutes.post("/api/migrations/run", async (c) => {
|
|
|
26160
26225
|
adminSettingsRoutes.get("/api/migrations/validate", async (c) => {
|
|
26161
26226
|
try {
|
|
26162
26227
|
const db = c.env.DB;
|
|
26163
|
-
const migrationService = new
|
|
26228
|
+
const migrationService = new chunkIA24HACT_cjs.MigrationService(db);
|
|
26164
26229
|
const validation = await migrationService.validateSchema();
|
|
26165
26230
|
return c.json({
|
|
26166
26231
|
success: true,
|
|
@@ -26753,16 +26818,16 @@ function renderAPIReferencePage(data) {
|
|
|
26753
26818
|
}
|
|
26754
26819
|
|
|
26755
26820
|
// src/routes/admin-api-reference.ts
|
|
26756
|
-
var VERSION2 =
|
|
26821
|
+
var VERSION2 = chunk3XFA3E2F_cjs.getCoreVersion();
|
|
26757
26822
|
var router2 = new hono.Hono();
|
|
26758
|
-
router2.use("*",
|
|
26823
|
+
router2.use("*", chunkKMM45BTY_cjs.requireAuth());
|
|
26759
26824
|
router2.get("/", async (c) => {
|
|
26760
26825
|
const user = c.get("user");
|
|
26761
26826
|
try {
|
|
26762
26827
|
const app2 = chunk4BTBSXMR_cjs.getAppInstance();
|
|
26763
26828
|
const baseEndpoints = chunk4BTBSXMR_cjs.buildRouteList(app2);
|
|
26764
26829
|
const collectionRoutes = [];
|
|
26765
|
-
const collections =
|
|
26830
|
+
const collections = chunkKZIBF2EV_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal);
|
|
26766
26831
|
const methodOrder = { GET: 0, POST: 1, PUT: 2, PATCH: 3, DELETE: 4 };
|
|
26767
26832
|
for (const col of collections) {
|
|
26768
26833
|
const displayName = col.displayName || col.name;
|
|
@@ -26854,6 +26919,7 @@ exports.api_default = api_default;
|
|
|
26854
26919
|
exports.api_media_default = api_media_default;
|
|
26855
26920
|
exports.api_system_default = api_system_default;
|
|
26856
26921
|
exports.auth_default = auth_default;
|
|
26922
|
+
exports.createDocumentSchema = createDocumentSchema;
|
|
26857
26923
|
exports.createUserProfilesPlugin = createUserProfilesPlugin;
|
|
26858
26924
|
exports.defineUserProfile = defineUserProfile;
|
|
26859
26925
|
exports.denyIfNotAllowed = denyIfNotAllowed;
|
|
@@ -26878,5 +26944,5 @@ exports.setVariablesCache = setVariablesCache;
|
|
|
26878
26944
|
exports.test_cleanup_default = test_cleanup_default;
|
|
26879
26945
|
exports.userProfilesPlugin = userProfilesPlugin;
|
|
26880
26946
|
exports.userRoutes = userRoutes;
|
|
26881
|
-
//# sourceMappingURL=chunk-
|
|
26882
|
-
//# sourceMappingURL=chunk-
|
|
26947
|
+
//# sourceMappingURL=chunk-SC2WZFNQ.cjs.map
|
|
26948
|
+
//# sourceMappingURL=chunk-SC2WZFNQ.cjs.map
|