@sonicjs-cms/core 3.0.0-beta.5 → 3.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-BSM2NQYR.cjs → chunk-26X5DBNW.cjs} +2 -2
- package/dist/{chunk-BSM2NQYR.cjs.map → chunk-26X5DBNW.cjs.map} +1 -1
- package/dist/{chunk-ZWUXEIJY.js → chunk-3HYVPA3S.js} +3 -3
- package/dist/{chunk-ZWUXEIJY.js.map → chunk-3HYVPA3S.js.map} +1 -1
- package/dist/{chunk-EEYFB6SU.js → chunk-7SDH5656.js} +2 -2
- package/dist/{chunk-EEYFB6SU.js.map → chunk-7SDH5656.js.map} +1 -1
- package/dist/{chunk-GJBLR3PW.cjs → chunk-B52GZLUI.cjs} +3 -3
- package/dist/{chunk-GJBLR3PW.cjs.map → chunk-B52GZLUI.cjs.map} +1 -1
- package/dist/{chunk-JI4E5YFS.js → chunk-CVQMZZNH.js} +4 -4
- package/dist/{chunk-JI4E5YFS.js.map → chunk-CVQMZZNH.js.map} +1 -1
- package/dist/{chunk-IKEUELHZ.js → chunk-D4WJXC6V.js} +2 -2
- package/dist/{chunk-IKEUELHZ.js.map → chunk-D4WJXC6V.js.map} +1 -1
- package/dist/{chunk-TWATCPVJ.js → chunk-E3C333Y5.js} +4 -4
- package/dist/{chunk-TWATCPVJ.js.map → chunk-E3C333Y5.js.map} +1 -1
- package/dist/{chunk-BGUMJTUE.cjs → chunk-FPACD2QX.cjs} +10 -10
- package/dist/{chunk-BGUMJTUE.cjs.map → chunk-FPACD2QX.cjs.map} +1 -1
- package/dist/{chunk-EFXOZ4CD.cjs → chunk-FXIVUBMC.cjs} +11 -11
- package/dist/{chunk-EFXOZ4CD.cjs.map → chunk-FXIVUBMC.cjs.map} +1 -1
- package/dist/{chunk-GHJJVBFM.cjs → chunk-GE4626OK.cjs} +4 -4
- package/dist/{chunk-GHJJVBFM.cjs.map → chunk-GE4626OK.cjs.map} +1 -1
- package/dist/{chunk-B5ORC7QR.cjs → chunk-GP2K2K3G.cjs} +2 -2
- package/dist/{chunk-B5ORC7QR.cjs.map → chunk-GP2K2K3G.cjs.map} +1 -1
- package/dist/{chunk-VPDI7YAM.cjs → chunk-QG7OILOU.cjs} +200 -200
- package/dist/{chunk-VPDI7YAM.cjs.map → chunk-QG7OILOU.cjs.map} +1 -1
- package/dist/{chunk-I547QD6V.js → chunk-RPORS2HF.js} +3 -3
- package/dist/{chunk-I547QD6V.js.map → chunk-RPORS2HF.js.map} +1 -1
- package/dist/{chunk-7JRMNEDQ.js → chunk-W7LUKLZW.js} +9 -9
- package/dist/{chunk-7JRMNEDQ.js.map → chunk-W7LUKLZW.js.map} +1 -1
- package/dist/index.cjs +252 -252
- package/dist/index.js +13 -13
- package/dist/middleware.cjs +32 -32
- package/dist/middleware.js +3 -3
- package/dist/migrations-2VMJH7YB.cjs +13 -0
- package/dist/{migrations-PIQH3IHN.cjs.map → migrations-2VMJH7YB.cjs.map} +1 -1
- package/dist/migrations-WPLV26J5.js +4 -0
- package/dist/{migrations-JFOF3J4Z.js.map → migrations-WPLV26J5.js.map} +1 -1
- package/dist/plugins.cjs +40 -40
- package/dist/plugins.js +3 -3
- package/dist/routes.cjs +26 -26
- package/dist/routes.js +6 -6
- package/dist/services.cjs +14 -14
- package/dist/services.js +2 -2
- package/dist/utils.cjs +3 -3
- package/dist/utils.js +1 -1
- package/package.json +1 -1
- package/dist/migrations-JFOF3J4Z.js +0 -4
- package/dist/migrations-PIQH3IHN.cjs +0 -13
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
var chunkHIKBY7MS_cjs = require('./chunk-HIKBY7MS.cjs');
|
|
4
4
|
var chunkDNQCEKUK_cjs = require('./chunk-DNQCEKUK.cjs');
|
|
5
5
|
var chunkBDDABDAB_cjs = require('./chunk-BDDABDAB.cjs');
|
|
6
|
-
var
|
|
6
|
+
var chunkFXIVUBMC_cjs = require('./chunk-FXIVUBMC.cjs');
|
|
7
7
|
var chunk2CB4KY7I_cjs = require('./chunk-2CB4KY7I.cjs');
|
|
8
8
|
var chunkJEQ7FLOD_cjs = require('./chunk-JEQ7FLOD.cjs');
|
|
9
|
-
var
|
|
10
|
-
var
|
|
9
|
+
var chunk26X5DBNW_cjs = require('./chunk-26X5DBNW.cjs');
|
|
10
|
+
var chunkGP2K2K3G_cjs = require('./chunk-GP2K2K3G.cjs');
|
|
11
11
|
var chunkMVIZJOO5_cjs = require('./chunk-MVIZJOO5.cjs');
|
|
12
12
|
var chunkNAVPFIG5_cjs = require('./chunk-NAVPFIG5.cjs');
|
|
13
|
-
var
|
|
13
|
+
var chunkGE4626OK_cjs = require('./chunk-GE4626OK.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 chunkB52GZLUI_cjs = require('./chunk-B52GZLUI.cjs');
|
|
18
18
|
var chunkMNWKYY5E_cjs = require('./chunk-MNWKYY5E.cjs');
|
|
19
19
|
var hono = require('hono');
|
|
20
20
|
var zod = require('zod');
|
|
@@ -257,7 +257,7 @@ function getDocumentRequestContext(c) {
|
|
|
257
257
|
|
|
258
258
|
// src/routes/api-documents.ts
|
|
259
259
|
async function aclAllowsRead(db, tenantId, principalSet, row, preloadedType) {
|
|
260
|
-
const docType = preloadedType ?? await new
|
|
260
|
+
const docType = preloadedType ?? await new chunkFXIVUBMC_cjs.DocumentTypeRegistry(db).findById(row.type_id);
|
|
261
261
|
if (!docType) return false;
|
|
262
262
|
return new DocumentRepository(db, tenantId).isAllowed(principalSet, row.root_id, "read", docType.settings);
|
|
263
263
|
}
|
|
@@ -275,7 +275,7 @@ apiDocumentsRoutes.get("/", async (c) => {
|
|
|
275
275
|
if (!typeId) {
|
|
276
276
|
return c.json({ error: "type query parameter is required" }, 400);
|
|
277
277
|
}
|
|
278
|
-
const registry = new
|
|
278
|
+
const registry = new chunkFXIVUBMC_cjs.DocumentTypeRegistry(db);
|
|
279
279
|
const docType = await registry.findById(typeId);
|
|
280
280
|
if (!docType || !docType.isActive) {
|
|
281
281
|
return c.json({ error: "Unknown document type" }, 400);
|
|
@@ -357,7 +357,7 @@ apiDocumentsRoutes.get("/root/:rootId", async (c) => {
|
|
|
357
357
|
AND (expires_at IS NULL OR expires_at > ?) LIMIT 1`
|
|
358
358
|
).bind(rootId, now, now).first();
|
|
359
359
|
if (!row) return c.json({ error: "Not found" }, 404);
|
|
360
|
-
const docType = await new
|
|
360
|
+
const docType = await new chunkFXIVUBMC_cjs.DocumentTypeRegistry(db).findById(row.type_id);
|
|
361
361
|
const effTenant = effectiveTenantForType(tenantId, docType?.settings);
|
|
362
362
|
if (row.tenant_id !== effTenant) return c.json({ error: "Not found" }, 404);
|
|
363
363
|
if (!await aclAllowsRead(db, effTenant, principalSet, row, docType)) {
|
|
@@ -393,7 +393,7 @@ apiDocumentsRoutes.get("/:id", async (c) => {
|
|
|
393
393
|
AND (expires_at IS NULL OR expires_at > ?) LIMIT 1`
|
|
394
394
|
).bind(id, now, now).first();
|
|
395
395
|
if (!row) return c.json({ error: "Not found" }, 404);
|
|
396
|
-
const docType = await new
|
|
396
|
+
const docType = await new chunkFXIVUBMC_cjs.DocumentTypeRegistry(db).findById(row.type_id);
|
|
397
397
|
const effTenant = effectiveTenantForType(tenantId, docType?.settings);
|
|
398
398
|
if (row.tenant_id !== effTenant) return c.json({ error: "Not found" }, 404);
|
|
399
399
|
if (!await aclAllowsRead(db, effTenant, principalSet, row, docType)) {
|
|
@@ -463,17 +463,17 @@ async function resolveDocScope(c, db, by, opts = {}) {
|
|
|
463
463
|
const draft = opts.currentDraftOnly ? " AND is_current_draft = 1" : "";
|
|
464
464
|
const row = await db.prepare(`SELECT type_id, root_id, tenant_id FROM documents WHERE ${col} = ?${draft} LIMIT 1`).bind(val).first();
|
|
465
465
|
if (!row) return null;
|
|
466
|
-
const docType = await new
|
|
466
|
+
const docType = await new chunkFXIVUBMC_cjs.DocumentTypeRegistry(db).findById(row.type_id);
|
|
467
467
|
const tenantId = effectiveTenantForType(getRequestTenant(c), docType?.settings);
|
|
468
468
|
if (row.tenant_id !== tenantId) return null;
|
|
469
469
|
return { typeId: row.type_id, rootId: row.root_id, tenantId, docType };
|
|
470
470
|
}
|
|
471
471
|
var adminDocumentsRoutes = new hono.Hono();
|
|
472
|
-
adminDocumentsRoutes.use("*",
|
|
473
|
-
adminDocumentsRoutes.use("*",
|
|
472
|
+
adminDocumentsRoutes.use("*", chunkFXIVUBMC_cjs.requireAuth());
|
|
473
|
+
adminDocumentsRoutes.use("*", chunkFXIVUBMC_cjs.requireRole(["admin", "editor"]));
|
|
474
474
|
adminDocumentsRoutes.get("/types", async (c) => {
|
|
475
475
|
try {
|
|
476
|
-
const registry = new
|
|
476
|
+
const registry = new chunkFXIVUBMC_cjs.DocumentTypeRegistry(c.env.DB);
|
|
477
477
|
const types = await registry.findAll();
|
|
478
478
|
return c.json({ data: types });
|
|
479
479
|
} catch (error) {
|
|
@@ -501,7 +501,7 @@ adminDocumentsRoutes.get("/", async (c) => {
|
|
|
501
501
|
if (!typeId) {
|
|
502
502
|
return c.json({ error: "type query parameter is required" }, 400);
|
|
503
503
|
}
|
|
504
|
-
const registry = new
|
|
504
|
+
const registry = new chunkFXIVUBMC_cjs.DocumentTypeRegistry(db);
|
|
505
505
|
const docType = await registry.findById(typeId);
|
|
506
506
|
if (!docType || !docType.isActive) {
|
|
507
507
|
return c.json({ error: "Unknown document type" }, 400);
|
|
@@ -612,7 +612,7 @@ adminDocumentsRoutes.post("/", async (c) => {
|
|
|
612
612
|
const input = validation.data;
|
|
613
613
|
const db = c.env.DB;
|
|
614
614
|
const user = c.get("user");
|
|
615
|
-
const registry = new
|
|
615
|
+
const registry = new chunkFXIVUBMC_cjs.DocumentTypeRegistry(db);
|
|
616
616
|
const docType = await registry.findById(input.typeId);
|
|
617
617
|
if (!docType || !docType.isActive) {
|
|
618
618
|
return c.json({ error: "Unknown document type" }, 400);
|
|
@@ -744,7 +744,7 @@ adminDocumentsRoutes.post("/types/:typeId/reindex", async (c) => {
|
|
|
744
744
|
try {
|
|
745
745
|
const { typeId } = c.req.param();
|
|
746
746
|
const db = c.env.DB;
|
|
747
|
-
const registry = new
|
|
747
|
+
const registry = new chunkFXIVUBMC_cjs.DocumentTypeRegistry(db);
|
|
748
748
|
const docType = await registry.findById(typeId);
|
|
749
749
|
if (!docType) return c.json({ error: "Unknown document type" }, 400);
|
|
750
750
|
const reindexTenant = effectiveTenantForType(getRequestTenant(c), docType.settings);
|
|
@@ -898,13 +898,13 @@ async function resolveContentVariables(contentData, db) {
|
|
|
898
898
|
// src/routes/api-content-crud.ts
|
|
899
899
|
var apiContentCrudRoutes = new hono.Hono();
|
|
900
900
|
async function resolveDocBacking(db, collectionIdOrName) {
|
|
901
|
-
const registry =
|
|
901
|
+
const registry = chunk26X5DBNW_cjs.getCollectionRegistry();
|
|
902
902
|
const record = registry.getBySlugOrName(collectionIdOrName) ?? registry.getById(collectionIdOrName);
|
|
903
903
|
if (record) {
|
|
904
|
-
const docType2 = await new
|
|
904
|
+
const docType2 = await new chunkFXIVUBMC_cjs.DocumentTypeRegistry(db).findById(record.name);
|
|
905
905
|
return docType2 ? { coll: { id: record.id, name: record.name }, docType: docType2 } : null;
|
|
906
906
|
}
|
|
907
|
-
const docType = await new
|
|
907
|
+
const docType = await new chunkFXIVUBMC_cjs.DocumentTypeRegistry(db).findById(collectionIdOrName);
|
|
908
908
|
if (docType) {
|
|
909
909
|
return { coll: { id: collectionIdOrName, name: collectionIdOrName }, docType };
|
|
910
910
|
}
|
|
@@ -947,7 +947,7 @@ apiContentCrudRoutes.get("/check-slug", async (c) => {
|
|
|
947
947
|
}, 500);
|
|
948
948
|
}
|
|
949
949
|
});
|
|
950
|
-
apiContentCrudRoutes.get("/:id",
|
|
950
|
+
apiContentCrudRoutes.get("/:id", chunkFXIVUBMC_cjs.optionalAuth(), async (c) => {
|
|
951
951
|
try {
|
|
952
952
|
const id = c.req.param("id");
|
|
953
953
|
const db = c.env.DB;
|
|
@@ -957,7 +957,7 @@ apiContentCrudRoutes.get("/:id", chunkEFXOZ4CD_cjs.optionalAuth(), async (c) =>
|
|
|
957
957
|
).bind(id, getRequestTenant(c)).first();
|
|
958
958
|
let transformedContent;
|
|
959
959
|
if (docRow) {
|
|
960
|
-
const coll =
|
|
960
|
+
const coll = chunk26X5DBNW_cjs.getCollectionRegistry().getByName(docRow.type_id);
|
|
961
961
|
transformedContent = {
|
|
962
962
|
id: docRow.root_id,
|
|
963
963
|
title: docRow.title,
|
|
@@ -991,7 +991,7 @@ apiContentCrudRoutes.get("/:id", chunkEFXOZ4CD_cjs.optionalAuth(), async (c) =>
|
|
|
991
991
|
}, 500);
|
|
992
992
|
}
|
|
993
993
|
});
|
|
994
|
-
apiContentCrudRoutes.post("/",
|
|
994
|
+
apiContentCrudRoutes.post("/", chunkFXIVUBMC_cjs.requireAuth(), chunkFXIVUBMC_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
995
995
|
try {
|
|
996
996
|
const db = c.env.DB;
|
|
997
997
|
const user = c.get("user");
|
|
@@ -1066,7 +1066,7 @@ apiContentCrudRoutes.post("/", chunkEFXOZ4CD_cjs.requireAuth(), chunkEFXOZ4CD_cj
|
|
|
1066
1066
|
}, 500);
|
|
1067
1067
|
}
|
|
1068
1068
|
});
|
|
1069
|
-
apiContentCrudRoutes.put("/:id",
|
|
1069
|
+
apiContentCrudRoutes.put("/:id", chunkFXIVUBMC_cjs.requireAuth(), chunkFXIVUBMC_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
1070
1070
|
try {
|
|
1071
1071
|
const id = c.req.param("id");
|
|
1072
1072
|
const db = c.env.DB;
|
|
@@ -1088,7 +1088,7 @@ apiContentCrudRoutes.put("/:id", chunkEFXOZ4CD_cjs.requireAuth(), chunkEFXOZ4CD_
|
|
|
1088
1088
|
} catch (err) {
|
|
1089
1089
|
return c.json({ error: "Write cancelled by plugin", details: String(err) }, 400);
|
|
1090
1090
|
}
|
|
1091
|
-
const docType = await new
|
|
1091
|
+
const docType = await new chunkFXIVUBMC_cjs.DocumentTypeRegistry(db).findById(docRow.type_id);
|
|
1092
1092
|
const svc = new chunk2CB4KY7I_cjs.DocumentsService(db, {
|
|
1093
1093
|
queryableFields: docType?.queryableFields ?? [],
|
|
1094
1094
|
typeSchemaVersion: docType?.schemaVersion ?? 1,
|
|
@@ -1111,7 +1111,7 @@ apiContentCrudRoutes.put("/:id", chunkEFXOZ4CD_cjs.requireAuth(), chunkEFXOZ4CD_
|
|
|
1111
1111
|
const cache = chunkBDDABDAB_cjs.getCacheService(chunkBDDABDAB_cjs.CACHE_CONFIGS.api);
|
|
1112
1112
|
await cache.invalidate("content-filtered:*");
|
|
1113
1113
|
await cache.invalidate("collection-content-filtered:*");
|
|
1114
|
-
const coll =
|
|
1114
|
+
const coll = chunk26X5DBNW_cjs.getCollectionRegistry().getByName(docRow.type_id);
|
|
1115
1115
|
const saved = await db.prepare("SELECT * FROM documents WHERE id = ?").bind(newDraft.id).first();
|
|
1116
1116
|
const savedData = saved?.data ? JSON.parse(saved.data) : {};
|
|
1117
1117
|
dispatchHookEvent(c, "content:after:update", { collection: docRow.type_id, id, data: savedData, user: actor }, "fire-and-forget");
|
|
@@ -1132,7 +1132,7 @@ apiContentCrudRoutes.put("/:id", chunkEFXOZ4CD_cjs.requireAuth(), chunkEFXOZ4CD_
|
|
|
1132
1132
|
}, 500);
|
|
1133
1133
|
}
|
|
1134
1134
|
});
|
|
1135
|
-
apiContentCrudRoutes.delete("/:id",
|
|
1135
|
+
apiContentCrudRoutes.delete("/:id", chunkFXIVUBMC_cjs.requireAuth(), chunkFXIVUBMC_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
1136
1136
|
try {
|
|
1137
1137
|
const id = c.req.param("id");
|
|
1138
1138
|
const db = c.env.DB;
|
|
@@ -1258,7 +1258,7 @@ apiRoutes.use("*", async (c, next) => {
|
|
|
1258
1258
|
c.header("X-Response-Time", `${totalTime}ms`);
|
|
1259
1259
|
});
|
|
1260
1260
|
apiRoutes.use("*", async (c, next) => {
|
|
1261
|
-
const cacheEnabled = await
|
|
1261
|
+
const cacheEnabled = await chunkFXIVUBMC_cjs.isPluginActive(c.env.DB, "core-cache");
|
|
1262
1262
|
c.set("cacheEnabled", cacheEnabled);
|
|
1263
1263
|
await next();
|
|
1264
1264
|
});
|
|
@@ -1291,7 +1291,7 @@ apiRoutes.get("/", (c) => {
|
|
|
1291
1291
|
openapi: "3.0.0",
|
|
1292
1292
|
info: {
|
|
1293
1293
|
title: "SonicJS AI API",
|
|
1294
|
-
version:
|
|
1294
|
+
version: chunkB52GZLUI_cjs.getCoreVersion(),
|
|
1295
1295
|
description: "RESTful API for SonicJS headless CMS - a modern, AI-powered content management system built on Cloudflare Workers",
|
|
1296
1296
|
contact: {
|
|
1297
1297
|
name: "SonicJS Support",
|
|
@@ -1721,8 +1721,8 @@ apiRoutes.get("/collections", async (c) => {
|
|
|
1721
1721
|
}
|
|
1722
1722
|
c.header("X-Cache-Status", "MISS");
|
|
1723
1723
|
c.header("X-Cache-Source", "registry");
|
|
1724
|
-
const records =
|
|
1725
|
-
const transformedResults = records.map(
|
|
1724
|
+
const records = chunk26X5DBNW_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal);
|
|
1725
|
+
const transformedResults = records.map(chunk26X5DBNW_cjs.collectionRecordToRow);
|
|
1726
1726
|
const responseData = {
|
|
1727
1727
|
data: transformedResults,
|
|
1728
1728
|
meta: addTimingMeta(c, {
|
|
@@ -1743,7 +1743,7 @@ apiRoutes.get("/collections", async (c) => {
|
|
|
1743
1743
|
return c.json({ error: "Failed to fetch collections" }, 500);
|
|
1744
1744
|
}
|
|
1745
1745
|
});
|
|
1746
|
-
apiRoutes.get("/content",
|
|
1746
|
+
apiRoutes.get("/content", chunkFXIVUBMC_cjs.optionalAuth(), async (c) => {
|
|
1747
1747
|
const executionStart = Date.now();
|
|
1748
1748
|
try {
|
|
1749
1749
|
const db = c.env.DB;
|
|
@@ -1752,7 +1752,7 @@ apiRoutes.get("/content", chunkEFXOZ4CD_cjs.optionalAuth(), async (c) => {
|
|
|
1752
1752
|
const collIdByName = /* @__PURE__ */ new Map();
|
|
1753
1753
|
let typeId;
|
|
1754
1754
|
let typeIds;
|
|
1755
|
-
const registry =
|
|
1755
|
+
const registry = chunk26X5DBNW_cjs.getCollectionRegistry();
|
|
1756
1756
|
if (queryParams.collection) {
|
|
1757
1757
|
const collectionName = queryParams.collection;
|
|
1758
1758
|
const record = registry.getByName(collectionName);
|
|
@@ -1851,13 +1851,13 @@ apiRoutes.get("/content", chunkEFXOZ4CD_cjs.optionalAuth(), async (c) => {
|
|
|
1851
1851
|
}, 500);
|
|
1852
1852
|
}
|
|
1853
1853
|
});
|
|
1854
|
-
apiRoutes.get("/collections/:collection/content",
|
|
1854
|
+
apiRoutes.get("/collections/:collection/content", chunkFXIVUBMC_cjs.optionalAuth(), async (c) => {
|
|
1855
1855
|
const executionStart = Date.now();
|
|
1856
1856
|
try {
|
|
1857
1857
|
const collection = c.req.param("collection");
|
|
1858
1858
|
const db = c.env.DB;
|
|
1859
1859
|
const queryParams = c.req.query();
|
|
1860
|
-
const record =
|
|
1860
|
+
const record = chunk26X5DBNW_cjs.getCollectionRegistry().getBySlugOrName(collection);
|
|
1861
1861
|
if (!record || record.isActive === false) {
|
|
1862
1862
|
return c.json({ error: "Collection not found" }, 404);
|
|
1863
1863
|
}
|
|
@@ -1913,7 +1913,7 @@ apiRoutes.get("/collections/:collection/content", chunkEFXOZ4CD_cjs.optionalAuth
|
|
|
1913
1913
|
const responseData = {
|
|
1914
1914
|
data: transformedResults,
|
|
1915
1915
|
meta: addTimingMeta(c, {
|
|
1916
|
-
...includeCollection ? { collection:
|
|
1916
|
+
...includeCollection ? { collection: chunk26X5DBNW_cjs.collectionRecordToRow(record) } : {},
|
|
1917
1917
|
count: results.length,
|
|
1918
1918
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1919
1919
|
// D44: echo the caller's filter with the access policy applied (status=published forced for
|
|
@@ -1938,13 +1938,13 @@ apiRoutes.get("/collections/:collection/content", chunkEFXOZ4CD_cjs.optionalAuth
|
|
|
1938
1938
|
}
|
|
1939
1939
|
});
|
|
1940
1940
|
apiRoutes.route("/content", api_content_crud_default);
|
|
1941
|
-
apiRoutes.get("/:collection",
|
|
1941
|
+
apiRoutes.get("/:collection", chunkFXIVUBMC_cjs.optionalAuth(), async (c) => {
|
|
1942
1942
|
const executionStart = Date.now();
|
|
1943
1943
|
try {
|
|
1944
1944
|
const collection = c.req.param("collection");
|
|
1945
1945
|
const db = c.env.DB;
|
|
1946
1946
|
const queryParams = c.req.query();
|
|
1947
|
-
const record =
|
|
1947
|
+
const record = chunk26X5DBNW_cjs.getCollectionRegistry().getBySlugOrName(collection);
|
|
1948
1948
|
if (!record || record.isActive === false) {
|
|
1949
1949
|
return c.json({ error: "Collection not found" }, 404);
|
|
1950
1950
|
}
|
|
@@ -1984,7 +1984,7 @@ apiRoutes.get("/:collection", chunkEFXOZ4CD_cjs.optionalAuth(), async (c) => {
|
|
|
1984
1984
|
const responseData = {
|
|
1985
1985
|
data: transformedResults,
|
|
1986
1986
|
meta: addTimingMeta(c, {
|
|
1987
|
-
...includeCollection ? { collection:
|
|
1987
|
+
...includeCollection ? { collection: chunk26X5DBNW_cjs.collectionRecordToRow(record) } : {},
|
|
1988
1988
|
count: results.length,
|
|
1989
1989
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1990
1990
|
filter: normalizePublicContentFilter(filter, role),
|
|
@@ -2002,12 +2002,12 @@ apiRoutes.get("/:collection", chunkEFXOZ4CD_cjs.optionalAuth(), async (c) => {
|
|
|
2002
2002
|
return c.json({ error: "Failed to fetch content", details: error instanceof Error ? error.message : String(error) }, 500);
|
|
2003
2003
|
}
|
|
2004
2004
|
});
|
|
2005
|
-
apiRoutes.get("/:collection/:id",
|
|
2005
|
+
apiRoutes.get("/:collection/:id", chunkFXIVUBMC_cjs.optionalAuth(), async (c) => {
|
|
2006
2006
|
try {
|
|
2007
2007
|
const collection = c.req.param("collection");
|
|
2008
2008
|
const id = c.req.param("id");
|
|
2009
2009
|
const db = c.env.DB;
|
|
2010
|
-
const record =
|
|
2010
|
+
const record = chunk26X5DBNW_cjs.getCollectionRegistry().getBySlugOrName(collection);
|
|
2011
2011
|
if (!record || record.isActive === false) {
|
|
2012
2012
|
return c.json({ error: "Collection not found" }, 404);
|
|
2013
2013
|
}
|
|
@@ -2016,7 +2016,7 @@ apiRoutes.get("/:collection/:id", chunkEFXOZ4CD_cjs.optionalAuth(), async (c) =>
|
|
|
2016
2016
|
privileged ? "SELECT * FROM documents WHERE root_id = ? AND type_id = ? AND tenant_id = 'default' AND is_current_draft = 1 AND deleted_at IS NULL" : "SELECT * FROM documents WHERE root_id = ? AND type_id = ? AND tenant_id = 'default' AND is_published = 1 AND deleted_at IS NULL"
|
|
2017
2017
|
).bind(id, record.name).first();
|
|
2018
2018
|
if (!docRow) return c.json({ error: "Content not found" }, 404);
|
|
2019
|
-
const coll =
|
|
2019
|
+
const coll = chunk26X5DBNW_cjs.getCollectionRegistry().getByName(docRow.type_id);
|
|
2020
2020
|
const transformedContent = {
|
|
2021
2021
|
id: docRow.root_id,
|
|
2022
2022
|
title: docRow.title,
|
|
@@ -2034,7 +2034,7 @@ apiRoutes.get("/:collection/:id", chunkEFXOZ4CD_cjs.optionalAuth(), async (c) =>
|
|
|
2034
2034
|
return c.json({ error: "Failed to fetch content", details: error instanceof Error ? error.message : String(error) }, 500);
|
|
2035
2035
|
}
|
|
2036
2036
|
});
|
|
2037
|
-
apiRoutes.post("/:collection",
|
|
2037
|
+
apiRoutes.post("/:collection", chunkFXIVUBMC_cjs.requireAuth(), chunkFXIVUBMC_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
2038
2038
|
try {
|
|
2039
2039
|
const collection = c.req.param("collection");
|
|
2040
2040
|
const db = c.env.DB;
|
|
@@ -2067,14 +2067,14 @@ apiRoutes.post("/:collection", chunkEFXOZ4CD_cjs.requireAuth(), chunkEFXOZ4CD_cj
|
|
|
2067
2067
|
return c.json({ error: "Failed to create content", details: error instanceof Error ? error.message : String(error) }, 500);
|
|
2068
2068
|
}
|
|
2069
2069
|
});
|
|
2070
|
-
apiRoutes.put("/:collection/:id",
|
|
2070
|
+
apiRoutes.put("/:collection/:id", chunkFXIVUBMC_cjs.requireAuth(), chunkFXIVUBMC_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
2071
2071
|
try {
|
|
2072
2072
|
const collection = c.req.param("collection");
|
|
2073
2073
|
const id = c.req.param("id");
|
|
2074
2074
|
const db = c.env.DB;
|
|
2075
2075
|
const user = c.get("user");
|
|
2076
2076
|
const body = await c.req.json();
|
|
2077
|
-
const collRecord =
|
|
2077
|
+
const collRecord = chunk26X5DBNW_cjs.getCollectionRegistry().getBySlugOrName(collection);
|
|
2078
2078
|
const typeName = collRecord?.name ?? collection;
|
|
2079
2079
|
const docRow = await db.prepare("SELECT root_id, type_id FROM documents WHERE root_id = ? AND type_id = ? AND tenant_id = 'default' AND is_current_draft = 1 AND deleted_at IS NULL").bind(id, typeName).first();
|
|
2080
2080
|
if (!docRow) return c.json({ error: "Content not found" }, 404);
|
|
@@ -2086,7 +2086,7 @@ apiRoutes.put("/:collection/:id", chunkEFXOZ4CD_cjs.requireAuth(), chunkEFXOZ4CD
|
|
|
2086
2086
|
} catch (err) {
|
|
2087
2087
|
return c.json({ error: "Write cancelled by plugin", details: String(err) }, 400);
|
|
2088
2088
|
}
|
|
2089
|
-
const docType = await new
|
|
2089
|
+
const docType = await new chunkFXIVUBMC_cjs.DocumentTypeRegistry(db).findById(docRow.type_id);
|
|
2090
2090
|
const svc = new chunk2CB4KY7I_cjs.DocumentsService(db, { queryableFields: docType?.queryableFields ?? [], typeSchemaVersion: docType?.schemaVersion ?? 1, maxVersionsPerRoot: docType?.settings?.maxVersionsPerRoot ?? 50, tenantId: "default", versioning: docType?.settings?.versioning ?? false });
|
|
2091
2091
|
const input = {};
|
|
2092
2092
|
if (body.title !== void 0) input.title = body.title;
|
|
@@ -2103,7 +2103,7 @@ apiRoutes.put("/:collection/:id", chunkEFXOZ4CD_cjs.requireAuth(), chunkEFXOZ4CD
|
|
|
2103
2103
|
const cache = chunkBDDABDAB_cjs.getCacheService(chunkBDDABDAB_cjs.CACHE_CONFIGS.api);
|
|
2104
2104
|
await cache.invalidate("content-filtered:*");
|
|
2105
2105
|
await cache.invalidate("collection-content-filtered:*");
|
|
2106
|
-
const coll =
|
|
2106
|
+
const coll = chunk26X5DBNW_cjs.getCollectionRegistry().getByName(docRow.type_id);
|
|
2107
2107
|
const saved = await db.prepare("SELECT * FROM documents WHERE id = ?").bind(newDraft.id).first();
|
|
2108
2108
|
const savedData = saved?.data ? JSON.parse(saved.data) : {};
|
|
2109
2109
|
dispatchHookEvent(c, "content:after:update", { collection: docRow.type_id, id, data: savedData, user: actor }, "fire-and-forget");
|
|
@@ -2115,13 +2115,13 @@ apiRoutes.put("/:collection/:id", chunkEFXOZ4CD_cjs.requireAuth(), chunkEFXOZ4CD
|
|
|
2115
2115
|
return c.json({ error: "Failed to update content", details: error instanceof Error ? error.message : String(error) }, 500);
|
|
2116
2116
|
}
|
|
2117
2117
|
});
|
|
2118
|
-
apiRoutes.delete("/:collection/:id",
|
|
2118
|
+
apiRoutes.delete("/:collection/:id", chunkFXIVUBMC_cjs.requireAuth(), chunkFXIVUBMC_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
2119
2119
|
try {
|
|
2120
2120
|
const collection = c.req.param("collection");
|
|
2121
2121
|
const id = c.req.param("id");
|
|
2122
2122
|
const db = c.env.DB;
|
|
2123
2123
|
const user = c.get("user");
|
|
2124
|
-
const collRecord =
|
|
2124
|
+
const collRecord = chunk26X5DBNW_cjs.getCollectionRegistry().getBySlugOrName(collection);
|
|
2125
2125
|
const typeName = collRecord?.name ?? collection;
|
|
2126
2126
|
const docRow = await db.prepare("SELECT type_id FROM documents WHERE root_id = ? AND type_id = ? AND tenant_id = 'default' AND deleted_at IS NULL LIMIT 1").bind(id, typeName).first();
|
|
2127
2127
|
if (!docRow) return c.json({ error: "Content not found" }, 404);
|
|
@@ -2336,7 +2336,7 @@ var fileValidationSchema = zod.z.object({
|
|
|
2336
2336
|
// 50MB max
|
|
2337
2337
|
});
|
|
2338
2338
|
var apiMediaRoutes = new hono.Hono();
|
|
2339
|
-
apiMediaRoutes.use("*",
|
|
2339
|
+
apiMediaRoutes.use("*", chunkFXIVUBMC_cjs.requireAuth());
|
|
2340
2340
|
apiMediaRoutes.post("/upload", async (c) => {
|
|
2341
2341
|
try {
|
|
2342
2342
|
const user = c.get("user");
|
|
@@ -3034,7 +3034,7 @@ apiSystemRoutes.get("/info", (c) => {
|
|
|
3034
3034
|
apiSystemRoutes.get("/stats", async (c) => {
|
|
3035
3035
|
try {
|
|
3036
3036
|
const db = c.env.DB;
|
|
3037
|
-
const typeIds =
|
|
3037
|
+
const typeIds = chunk26X5DBNW_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal).map((r) => r.name);
|
|
3038
3038
|
let contentStats = null;
|
|
3039
3039
|
if (typeIds.length > 0) {
|
|
3040
3040
|
const placeholders = typeIds.map(() => "?").join(",");
|
|
@@ -3109,12 +3109,12 @@ apiSystemRoutes.get("/env", (c) => {
|
|
|
3109
3109
|
});
|
|
3110
3110
|
var api_system_default = apiSystemRoutes;
|
|
3111
3111
|
var adminApiRoutes = new hono.Hono();
|
|
3112
|
-
adminApiRoutes.use("*",
|
|
3113
|
-
adminApiRoutes.use("*",
|
|
3112
|
+
adminApiRoutes.use("*", chunkFXIVUBMC_cjs.requireAuth());
|
|
3113
|
+
adminApiRoutes.use("*", chunkFXIVUBMC_cjs.requireRole(["admin", "editor"]));
|
|
3114
3114
|
adminApiRoutes.get("/stats", async (c) => {
|
|
3115
3115
|
try {
|
|
3116
3116
|
const db = c.env.DB;
|
|
3117
|
-
const userCollections =
|
|
3117
|
+
const userCollections = chunk26X5DBNW_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal);
|
|
3118
3118
|
const collectionsCount = userCollections.length;
|
|
3119
3119
|
let contentCount = 0;
|
|
3120
3120
|
if (userCollections.length > 0) {
|
|
@@ -3205,7 +3205,7 @@ adminApiRoutes.get("/collections", async (c) => {
|
|
|
3205
3205
|
try {
|
|
3206
3206
|
const search = c.req.query("search") || "";
|
|
3207
3207
|
const includeInactive = c.req.query("includeInactive") === "true";
|
|
3208
|
-
let records =
|
|
3208
|
+
let records = chunk26X5DBNW_cjs.getCollectionRegistry().list().filter((r) => !r.internal);
|
|
3209
3209
|
if (!includeInactive) records = records.filter((r) => r.isActive !== false);
|
|
3210
3210
|
if (search) {
|
|
3211
3211
|
const needle = search.toLowerCase();
|
|
@@ -3237,7 +3237,7 @@ adminApiRoutes.get("/collections", async (c) => {
|
|
|
3237
3237
|
adminApiRoutes.get("/collections/:id", async (c) => {
|
|
3238
3238
|
try {
|
|
3239
3239
|
const id = c.req.param("id");
|
|
3240
|
-
const registry =
|
|
3240
|
+
const registry = chunk26X5DBNW_cjs.getCollectionRegistry();
|
|
3241
3241
|
const record = registry.getById(id) ?? registry.getByName(id);
|
|
3242
3242
|
if (!record) {
|
|
3243
3243
|
return c.json({ error: "Collection not found" }, 404);
|
|
@@ -3287,7 +3287,7 @@ adminApiRoutes.get("/references", async (c) => {
|
|
|
3287
3287
|
if (collectionParams.length === 0) {
|
|
3288
3288
|
return c.json({ error: "Collection is required" }, 400);
|
|
3289
3289
|
}
|
|
3290
|
-
const registry =
|
|
3290
|
+
const registry = chunk26X5DBNW_cjs.getCollectionRegistry();
|
|
3291
3291
|
const matched = collectionParams.map((param) => registry.getById(param) ?? registry.getByName(param)).filter((r) => !!r);
|
|
3292
3292
|
const seen = /* @__PURE__ */ new Set();
|
|
3293
3293
|
const collections = matched.filter((r) => {
|
|
@@ -3402,7 +3402,7 @@ adminApiRoutes.patch("/collections/:id", collectionsReadOnly);
|
|
|
3402
3402
|
adminApiRoutes.delete("/collections/:id", collectionsReadOnly);
|
|
3403
3403
|
adminApiRoutes.get("/migrations/status", async (c) => {
|
|
3404
3404
|
try {
|
|
3405
|
-
const { MigrationService: MigrationService2 } = await import('./migrations-
|
|
3405
|
+
const { MigrationService: MigrationService2 } = await import('./migrations-2VMJH7YB.cjs');
|
|
3406
3406
|
const db = c.env.DB;
|
|
3407
3407
|
const migrationService = new MigrationService2(db);
|
|
3408
3408
|
const status = await migrationService.getMigrationStatus();
|
|
@@ -3445,7 +3445,7 @@ adminApiRoutes.post("/migrations/run", async (c) => {
|
|
|
3445
3445
|
});
|
|
3446
3446
|
adminApiRoutes.get("/migrations/validate", async (c) => {
|
|
3447
3447
|
try {
|
|
3448
|
-
const { MigrationService: MigrationService2 } = await import('./migrations-
|
|
3448
|
+
const { MigrationService: MigrationService2 } = await import('./migrations-2VMJH7YB.cjs');
|
|
3449
3449
|
const db = c.env.DB;
|
|
3450
3450
|
const migrationService = new MigrationService2(db);
|
|
3451
3451
|
const validation = await migrationService.validateSchema();
|
|
@@ -3860,7 +3860,7 @@ function renderRegisterPage(data) {
|
|
|
3860
3860
|
}
|
|
3861
3861
|
|
|
3862
3862
|
// src/services/email/email-service-singleton.ts
|
|
3863
|
-
var singleton =
|
|
3863
|
+
var singleton = chunkGE4626OK_cjs.createServiceSingleton("EmailService");
|
|
3864
3864
|
function setEmailService(service2) {
|
|
3865
3865
|
singleton.set(service2);
|
|
3866
3866
|
}
|
|
@@ -4668,7 +4668,7 @@ function getLexicalInitScript(settings = {}) {
|
|
|
4668
4668
|
</script>
|
|
4669
4669
|
`;
|
|
4670
4670
|
}
|
|
4671
|
-
var lexicalEditorPlugin =
|
|
4671
|
+
var lexicalEditorPlugin = chunkGE4626OK_cjs.definePlugin({
|
|
4672
4672
|
id: "lexical-editor",
|
|
4673
4673
|
version: "1.0.0",
|
|
4674
4674
|
name: "Lexical Editor",
|
|
@@ -6887,7 +6887,7 @@ api.put("/:userId", async (c) => {
|
|
|
6887
6887
|
await saveCustomData(db, userId, sanitized);
|
|
6888
6888
|
return c.json({ success: true });
|
|
6889
6889
|
});
|
|
6890
|
-
var userProfilesPlugin =
|
|
6890
|
+
var userProfilesPlugin = chunkGE4626OK_cjs.definePlugin({
|
|
6891
6891
|
id: "user-profiles",
|
|
6892
6892
|
version: "1.0.0",
|
|
6893
6893
|
name: "User Profiles",
|
|
@@ -6925,8 +6925,8 @@ function renderPasswordResetEmail(resetLink, firstName) {
|
|
|
6925
6925
|
async function setCsrfCookie(c, maxAge) {
|
|
6926
6926
|
const secret = c.env?.JWT_SECRET || JWT_SECRET_FALLBACK;
|
|
6927
6927
|
const isDev = c.env?.ENVIRONMENT === "development" || !c.env?.ENVIRONMENT;
|
|
6928
|
-
const csrfToken = await
|
|
6929
|
-
const cookieMaxAge = await
|
|
6928
|
+
const csrfToken = await chunkFXIVUBMC_cjs.generateCsrfToken(secret);
|
|
6929
|
+
const cookieMaxAge = await chunkFXIVUBMC_cjs.getJwtExpirySecondsFromDb(c.env?.DB, c.env);
|
|
6930
6930
|
cookie.setCookie(c, "csrf_token", csrfToken, {
|
|
6931
6931
|
httpOnly: false,
|
|
6932
6932
|
secure: !isDev,
|
|
@@ -6983,7 +6983,7 @@ var loginSchema = zod.z.object({
|
|
|
6983
6983
|
});
|
|
6984
6984
|
authRoutes.post(
|
|
6985
6985
|
"/register",
|
|
6986
|
-
|
|
6986
|
+
chunkFXIVUBMC_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "register" }),
|
|
6987
6987
|
async (c) => {
|
|
6988
6988
|
try {
|
|
6989
6989
|
const db = c.env.DB;
|
|
@@ -7019,7 +7019,7 @@ authRoutes.post(
|
|
|
7019
7019
|
if (existingUser) {
|
|
7020
7020
|
return c.json({ error: "User with this email already exists" }, 400);
|
|
7021
7021
|
}
|
|
7022
|
-
const passwordHash = await
|
|
7022
|
+
const passwordHash = await chunkFXIVUBMC_cjs.AuthManager.hashPassword(password);
|
|
7023
7023
|
const userId = crypto.randomUUID();
|
|
7024
7024
|
const now = /* @__PURE__ */ new Date();
|
|
7025
7025
|
const nowSec = Math.floor(now.getTime() / 1e3);
|
|
@@ -7052,8 +7052,8 @@ authRoutes.post(
|
|
|
7052
7052
|
{ user: { id: userId, email: normalizedEmail, role: "viewer" } },
|
|
7053
7053
|
"fire-and-forget"
|
|
7054
7054
|
);
|
|
7055
|
-
const tokenTtl = await
|
|
7056
|
-
const token = await
|
|
7055
|
+
const tokenTtl = await chunkFXIVUBMC_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
|
|
7056
|
+
const token = await chunkFXIVUBMC_cjs.AuthManager.generateToken(userId, normalizedEmail, "viewer", c.env.JWT_SECRET, tokenTtl);
|
|
7057
7057
|
cookie.setCookie(c, "auth_token", token, {
|
|
7058
7058
|
httpOnly: true,
|
|
7059
7059
|
secure: true,
|
|
@@ -7085,7 +7085,7 @@ authRoutes.post(
|
|
|
7085
7085
|
);
|
|
7086
7086
|
authRoutes.post(
|
|
7087
7087
|
"/login",
|
|
7088
|
-
|
|
7088
|
+
chunkFXIVUBMC_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "login" }),
|
|
7089
7089
|
async (c) => {
|
|
7090
7090
|
try {
|
|
7091
7091
|
const body = await c.req.json();
|
|
@@ -7164,7 +7164,7 @@ authRoutes.get("/logout", async (c) => {
|
|
|
7164
7164
|
clearCsrfCookie(c);
|
|
7165
7165
|
return c.redirect("/auth/login?message=You have been logged out successfully");
|
|
7166
7166
|
});
|
|
7167
|
-
authRoutes.get("/me",
|
|
7167
|
+
authRoutes.get("/me", chunkFXIVUBMC_cjs.requireAuth(), async (c) => {
|
|
7168
7168
|
try {
|
|
7169
7169
|
const user = c.get("user");
|
|
7170
7170
|
if (!user) {
|
|
@@ -7184,7 +7184,7 @@ authRoutes.get("/me", chunkEFXOZ4CD_cjs.requireAuth(), async (c) => {
|
|
|
7184
7184
|
});
|
|
7185
7185
|
authRoutes.post(
|
|
7186
7186
|
"/refresh",
|
|
7187
|
-
|
|
7187
|
+
chunkFXIVUBMC_cjs.rateLimit({ max: 60, windowMs: 60 * 1e3, keyPrefix: "refresh" }),
|
|
7188
7188
|
async (c) => {
|
|
7189
7189
|
try {
|
|
7190
7190
|
let token = c.req.header("Authorization")?.replace("Bearer ", "");
|
|
@@ -7193,8 +7193,8 @@ authRoutes.post(
|
|
|
7193
7193
|
return c.json({ error: "Authentication required" }, 401);
|
|
7194
7194
|
}
|
|
7195
7195
|
const db = c.env.DB;
|
|
7196
|
-
const grace = await
|
|
7197
|
-
const payload = await
|
|
7196
|
+
const grace = await chunkFXIVUBMC_cjs.getJwtRefreshGraceSecondsFromDb(db, c.env);
|
|
7197
|
+
const payload = await chunkFXIVUBMC_cjs.AuthManager.verifyToken(token, c.env.JWT_SECRET, grace);
|
|
7198
7198
|
if (!payload) {
|
|
7199
7199
|
return c.json({ error: "Invalid or expired token" }, 401);
|
|
7200
7200
|
}
|
|
@@ -7202,8 +7202,8 @@ authRoutes.post(
|
|
|
7202
7202
|
if (!row || !row.is_active) {
|
|
7203
7203
|
return c.json({ error: "User is not active" }, 401);
|
|
7204
7204
|
}
|
|
7205
|
-
const tokenTtl = await
|
|
7206
|
-
const newToken = await
|
|
7205
|
+
const tokenTtl = await chunkFXIVUBMC_cjs.getJwtExpirySecondsFromDb(db, c.env);
|
|
7206
|
+
const newToken = await chunkFXIVUBMC_cjs.AuthManager.generateToken(row.id, row.email, row.role, c.env.JWT_SECRET, tokenTtl);
|
|
7207
7207
|
cookie.setCookie(c, "auth_token", newToken, {
|
|
7208
7208
|
httpOnly: true,
|
|
7209
7209
|
secure: true,
|
|
@@ -7223,7 +7223,7 @@ authRoutes.post(
|
|
|
7223
7223
|
);
|
|
7224
7224
|
authRoutes.post(
|
|
7225
7225
|
"/register/form",
|
|
7226
|
-
|
|
7226
|
+
chunkFXIVUBMC_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "register" }),
|
|
7227
7227
|
async (c) => {
|
|
7228
7228
|
try {
|
|
7229
7229
|
const db = c.env.DB;
|
|
@@ -7268,7 +7268,7 @@ authRoutes.post(
|
|
|
7268
7268
|
</div>
|
|
7269
7269
|
`);
|
|
7270
7270
|
}
|
|
7271
|
-
const passwordHash = await
|
|
7271
|
+
const passwordHash = await chunkFXIVUBMC_cjs.AuthManager.hashPassword(password);
|
|
7272
7272
|
const role = isFirstUser ? "admin" : "viewer";
|
|
7273
7273
|
const userId = crypto.randomUUID();
|
|
7274
7274
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -7310,8 +7310,8 @@ authRoutes.post(
|
|
|
7310
7310
|
{ user: { id: userId, email: normalizedEmail, role } },
|
|
7311
7311
|
"fire-and-forget"
|
|
7312
7312
|
);
|
|
7313
|
-
const tokenTtl = await
|
|
7314
|
-
const token = await
|
|
7313
|
+
const tokenTtl = await chunkFXIVUBMC_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
|
|
7314
|
+
const token = await chunkFXIVUBMC_cjs.AuthManager.generateToken(userId, normalizedEmail, role, c.env.JWT_SECRET, tokenTtl);
|
|
7315
7315
|
cookie.setCookie(c, "auth_token", token, {
|
|
7316
7316
|
httpOnly: true,
|
|
7317
7317
|
secure: false,
|
|
@@ -7343,7 +7343,7 @@ authRoutes.post(
|
|
|
7343
7343
|
);
|
|
7344
7344
|
authRoutes.post(
|
|
7345
7345
|
"/login/form",
|
|
7346
|
-
|
|
7346
|
+
chunkFXIVUBMC_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "login" }),
|
|
7347
7347
|
async (c) => {
|
|
7348
7348
|
try {
|
|
7349
7349
|
const formData = await c.req.formData();
|
|
@@ -7410,14 +7410,14 @@ authRoutes.post(
|
|
|
7410
7410
|
);
|
|
7411
7411
|
authRoutes.post(
|
|
7412
7412
|
"/seed-admin",
|
|
7413
|
-
|
|
7413
|
+
chunkFXIVUBMC_cjs.rateLimit({ max: 10, windowMs: 60 * 1e3, keyPrefix: "seed-admin" }),
|
|
7414
7414
|
async (c) => {
|
|
7415
7415
|
try {
|
|
7416
7416
|
const db = c.env.DB;
|
|
7417
7417
|
const rbac = new chunk2CB4KY7I_cjs.RbacService(db);
|
|
7418
7418
|
const results = [];
|
|
7419
7419
|
const upsertSeedUser = async (opts) => {
|
|
7420
|
-
const passwordHash = await
|
|
7420
|
+
const passwordHash = await chunkFXIVUBMC_cjs.AuthManager.hashPassword(opts.password);
|
|
7421
7421
|
const nowMs = Date.now();
|
|
7422
7422
|
const nowSec = Math.floor(nowMs / 1e3);
|
|
7423
7423
|
const existing = await db.prepare("SELECT id FROM auth_user WHERE email = ?").bind(opts.email).first();
|
|
@@ -7642,7 +7642,7 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
7642
7642
|
if (invitationAge > maxAge) {
|
|
7643
7643
|
return c.json({ error: "Invitation has expired" }, 400);
|
|
7644
7644
|
}
|
|
7645
|
-
const passwordHash = await
|
|
7645
|
+
const passwordHash = await chunkFXIVUBMC_cjs.AuthManager.hashPassword(password);
|
|
7646
7646
|
const updateStmt = db.prepare(`
|
|
7647
7647
|
UPDATE auth_user SET
|
|
7648
7648
|
password_hash = ?,
|
|
@@ -7659,8 +7659,8 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
7659
7659
|
Date.now(),
|
|
7660
7660
|
invitedUser.id
|
|
7661
7661
|
).run();
|
|
7662
|
-
const tokenTtl = await
|
|
7663
|
-
const authToken = await
|
|
7662
|
+
const tokenTtl = await chunkFXIVUBMC_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
|
|
7663
|
+
const authToken = await chunkFXIVUBMC_cjs.AuthManager.generateToken(invitedUser.id, invitedUser.email, invitedUser.role, c.env.JWT_SECRET, tokenTtl);
|
|
7664
7664
|
cookie.setCookie(c, "auth_token", authToken, {
|
|
7665
7665
|
httpOnly: true,
|
|
7666
7666
|
secure: true,
|
|
@@ -7676,7 +7676,7 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
7676
7676
|
});
|
|
7677
7677
|
authRoutes.post(
|
|
7678
7678
|
"/request-password-reset",
|
|
7679
|
-
|
|
7679
|
+
chunkFXIVUBMC_cjs.rateLimit({ max: 3, windowMs: 15 * 60 * 1e3, keyPrefix: "password-reset" }),
|
|
7680
7680
|
async (c) => {
|
|
7681
7681
|
try {
|
|
7682
7682
|
const formData = await c.req.formData();
|
|
@@ -7913,7 +7913,7 @@ authRoutes.post("/reset-password", async (c) => {
|
|
|
7913
7913
|
if (Date.now() > user.password_reset_expires) {
|
|
7914
7914
|
return c.json({ error: "Reset token has expired" }, 400);
|
|
7915
7915
|
}
|
|
7916
|
-
const newPasswordHash = await
|
|
7916
|
+
const newPasswordHash = await chunkFXIVUBMC_cjs.AuthManager.hashPassword(password);
|
|
7917
7917
|
try {
|
|
7918
7918
|
const historyStmt = db.prepare(`
|
|
7919
7919
|
INSERT INTO auth_password_history (id, user_id, password_hash, created_at)
|
|
@@ -8127,7 +8127,7 @@ app.post("/test-seed-defaults", async (c) => {
|
|
|
8127
8127
|
var test_cleanup_default = app;
|
|
8128
8128
|
|
|
8129
8129
|
// src/plugins/available/easy-mdx/index.ts
|
|
8130
|
-
|
|
8130
|
+
chunkGE4626OK_cjs.definePlugin({
|
|
8131
8131
|
id: "easy-mdx",
|
|
8132
8132
|
version: "1.0.0",
|
|
8133
8133
|
name: "EasyMDE Markdown Editor",
|
|
@@ -8327,7 +8327,7 @@ function getMDXEditorInitScript(config) {
|
|
|
8327
8327
|
}
|
|
8328
8328
|
|
|
8329
8329
|
// src/plugins/available/tinymce-plugin/index.ts
|
|
8330
|
-
|
|
8330
|
+
chunkGE4626OK_cjs.definePlugin({
|
|
8331
8331
|
id: "tinymce-plugin",
|
|
8332
8332
|
version: "1.0.0",
|
|
8333
8333
|
name: "TinyMCE",
|
|
@@ -8597,7 +8597,7 @@ function getQuillCDN(version = "2.0.2") {
|
|
|
8597
8597
|
</style>
|
|
8598
8598
|
`;
|
|
8599
8599
|
}
|
|
8600
|
-
|
|
8600
|
+
chunkGE4626OK_cjs.definePlugin({
|
|
8601
8601
|
id: "quill-editor",
|
|
8602
8602
|
version: "1.0.0",
|
|
8603
8603
|
name: "Quill Editor",
|
|
@@ -11171,7 +11171,7 @@ function extractFieldData(fields, formData, options = {}) {
|
|
|
11171
11171
|
}
|
|
11172
11172
|
return { data, errors };
|
|
11173
11173
|
}
|
|
11174
|
-
adminContentRoutes.use("*",
|
|
11174
|
+
adminContentRoutes.use("*", chunkFXIVUBMC_cjs.requireAuth());
|
|
11175
11175
|
async function getCollectionFields(db, collectionId) {
|
|
11176
11176
|
console.log(`[getCollectionFields] Loading fields for collection: ${collectionId}`);
|
|
11177
11177
|
const collectionStmt = db.prepare("SELECT schema, queryable_fields FROM document_types WHERE id = ?");
|
|
@@ -11198,7 +11198,7 @@ async function getCollectionFields(db, collectionId) {
|
|
|
11198
11198
|
};
|
|
11199
11199
|
});
|
|
11200
11200
|
}
|
|
11201
|
-
const codeCollections2 = await
|
|
11201
|
+
const codeCollections2 = await chunk26X5DBNW_cjs.loadCollectionConfigs();
|
|
11202
11202
|
const codeMatch = codeCollections2.find((c) => c.name === collectionId);
|
|
11203
11203
|
if (codeMatch && codeMatch.schema?.properties) {
|
|
11204
11204
|
console.log(`[getCollectionFields] DB doc type has no properties \u2014 using code collection schema`);
|
|
@@ -11230,7 +11230,7 @@ async function getCollectionFields(db, collectionId) {
|
|
|
11230
11230
|
}
|
|
11231
11231
|
}
|
|
11232
11232
|
console.log(`[getCollectionFields] Not in database, checking code collections`);
|
|
11233
|
-
const codeCollections = await
|
|
11233
|
+
const codeCollections = await chunk26X5DBNW_cjs.loadCollectionConfigs();
|
|
11234
11234
|
console.log(`[getCollectionFields] Found ${codeCollections.length} code collections`);
|
|
11235
11235
|
const codeCollection = codeCollections.find((c) => c.name === collectionId);
|
|
11236
11236
|
if (codeCollection && codeCollection.schema) {
|
|
@@ -11284,7 +11284,7 @@ async function getCollection(db, collectionId) {
|
|
|
11284
11284
|
};
|
|
11285
11285
|
}
|
|
11286
11286
|
console.log(`[getCollection] Not in database, checking code collections`);
|
|
11287
|
-
const codeCollections = await
|
|
11287
|
+
const codeCollections = await chunk26X5DBNW_cjs.loadCollectionConfigs();
|
|
11288
11288
|
const codeCollection = codeCollections.find((c) => c.name === collectionId);
|
|
11289
11289
|
if (codeCollection) {
|
|
11290
11290
|
console.log(`[getCollection] Found code collection: ${collectionId}`);
|
|
@@ -11303,7 +11303,7 @@ async function getCollection(db, collectionId) {
|
|
|
11303
11303
|
}
|
|
11304
11304
|
async function getDocBackingType(db, collectionName) {
|
|
11305
11305
|
if (!collectionName) return null;
|
|
11306
|
-
const dt = await new
|
|
11306
|
+
const dt = await new chunkFXIVUBMC_cjs.DocumentTypeRegistry(db).findById(collectionName);
|
|
11307
11307
|
return dt && dt.isActive ? dt : null;
|
|
11308
11308
|
}
|
|
11309
11309
|
async function getCollectionByName(db, name) {
|
|
@@ -11320,7 +11320,7 @@ async function getCollectionByName(db, name) {
|
|
|
11320
11320
|
};
|
|
11321
11321
|
}
|
|
11322
11322
|
console.log(`[getCollectionByName] Not in database, checking code collections`);
|
|
11323
|
-
const codeCollections = await
|
|
11323
|
+
const codeCollections = await chunk26X5DBNW_cjs.loadCollectionConfigs();
|
|
11324
11324
|
const codeCollection = codeCollections.find((c) => c.name === name);
|
|
11325
11325
|
if (codeCollection) {
|
|
11326
11326
|
console.log(`[getCollectionByName] Found code collection: ${name}`);
|
|
@@ -11336,7 +11336,7 @@ async function getCollectionByName(db, name) {
|
|
|
11336
11336
|
return null;
|
|
11337
11337
|
}
|
|
11338
11338
|
async function loadContentEditorFlags(db) {
|
|
11339
|
-
const flags = { workflowEnabled: await
|
|
11339
|
+
const flags = { workflowEnabled: await chunkFXIVUBMC_cjs.isPluginActive(db, "workflow") };
|
|
11340
11340
|
const editors = [
|
|
11341
11341
|
["tinymce-plugin", "tinymce"],
|
|
11342
11342
|
["quill-editor", "quill"],
|
|
@@ -11344,10 +11344,10 @@ async function loadContentEditorFlags(db) {
|
|
|
11344
11344
|
["lexical-editor", "lexical"]
|
|
11345
11345
|
];
|
|
11346
11346
|
for (const [plugin, key] of editors) {
|
|
11347
|
-
const enabled = await
|
|
11347
|
+
const enabled = await chunkFXIVUBMC_cjs.isPluginActive(db, plugin);
|
|
11348
11348
|
flags[`${key}Enabled`] = enabled;
|
|
11349
11349
|
if (enabled) {
|
|
11350
|
-
const ps = new
|
|
11350
|
+
const ps = new chunk26X5DBNW_cjs.PluginService(db);
|
|
11351
11351
|
const p = await ps.getPlugin(plugin);
|
|
11352
11352
|
flags[`${key}Settings`] = p?.settings;
|
|
11353
11353
|
}
|
|
@@ -11383,9 +11383,9 @@ adminContentRoutes.get("/", async (c) => {
|
|
|
11383
11383
|
const offset = (page - 1) * limit;
|
|
11384
11384
|
const collectionsStmt = db.prepare("SELECT id, name, display_name FROM document_types WHERE is_active = 1 ORDER BY display_name");
|
|
11385
11385
|
const { results: collectionsResults } = await collectionsStmt.all();
|
|
11386
|
-
const codeCollections = await
|
|
11386
|
+
const codeCollections = await chunk26X5DBNW_cjs.loadCollectionConfigs();
|
|
11387
11387
|
const codeCollectionMap = new Map(codeCollections.map((c2) => [c2.name, c2]));
|
|
11388
|
-
const docTypeRegistry = new
|
|
11388
|
+
const docTypeRegistry = new chunkFXIVUBMC_cjs.DocumentTypeRegistry(db);
|
|
11389
11389
|
const docTypes = (await docTypeRegistry.findAll()).filter((dt) => !dt.settings?.internal && !dt.isAuth);
|
|
11390
11390
|
const visibleTypeIds = new Set(docTypes.map((dt) => dt.id));
|
|
11391
11391
|
const allCollections = [
|
|
@@ -11397,7 +11397,7 @@ adminContentRoutes.get("/", async (c) => {
|
|
|
11397
11397
|
...allCollections.map((c2) => ({ name: c2.name, displayName: c2.displayName })),
|
|
11398
11398
|
...docTypes.filter((dt) => !collectionNames.has(dt.id)).map((dt) => ({ name: `doc:${dt.id}`, displayName: dt.displayName }))
|
|
11399
11399
|
];
|
|
11400
|
-
const newContentCollections = await
|
|
11400
|
+
const newContentCollections = await chunk26X5DBNW_cjs.getVisibleCollections(db);
|
|
11401
11401
|
const docBackedCollection = !modelName.startsWith("doc:") && modelName !== "all" ? docTypes.find((dt) => dt.id === modelName) : void 0;
|
|
11402
11402
|
const isDocModel = modelName.startsWith("doc:") || !!docBackedCollection;
|
|
11403
11403
|
if (isDocModel) {
|
|
@@ -11674,9 +11674,9 @@ adminContentRoutes.get("/new", async (c) => {
|
|
|
11674
11674
|
const collectionsStmt = db2.prepare("SELECT id, name, display_name, description FROM document_types WHERE is_active = 1 ORDER BY display_name");
|
|
11675
11675
|
const { results } = await collectionsStmt.all();
|
|
11676
11676
|
const visibleTypeIds = new Set(
|
|
11677
|
-
(await new
|
|
11677
|
+
(await new chunkFXIVUBMC_cjs.DocumentTypeRegistry(db2).findAll()).filter((dt) => !dt.settings?.internal && !dt.isAuth).map((dt) => dt.id)
|
|
11678
11678
|
);
|
|
11679
|
-
const codeCollections = await
|
|
11679
|
+
const codeCollections = await chunk26X5DBNW_cjs.loadCollectionConfigs();
|
|
11680
11680
|
const dbCollectionNames = new Set((results || []).map((r) => r.name));
|
|
11681
11681
|
const allCollections = [
|
|
11682
11682
|
...codeCollections.filter((c2) => !dbCollectionNames.has(c2.name)).map((c2) => ({
|
|
@@ -11742,32 +11742,32 @@ adminContentRoutes.get("/new", async (c) => {
|
|
|
11742
11742
|
return c.html(renderContentFormPage(formData2));
|
|
11743
11743
|
}
|
|
11744
11744
|
const fields = await getCollectionFields(db, collection.id);
|
|
11745
|
-
const workflowEnabled = await
|
|
11746
|
-
const tinymceEnabled = await
|
|
11745
|
+
const workflowEnabled = await chunkFXIVUBMC_cjs.isPluginActive(db, "workflow");
|
|
11746
|
+
const tinymceEnabled = await chunkFXIVUBMC_cjs.isPluginActive(db, "tinymce-plugin");
|
|
11747
11747
|
let tinymceSettings;
|
|
11748
11748
|
if (tinymceEnabled) {
|
|
11749
|
-
const pluginService = new
|
|
11749
|
+
const pluginService = new chunk26X5DBNW_cjs.PluginService(db);
|
|
11750
11750
|
const tinymcePlugin2 = await pluginService.getPlugin("tinymce-plugin");
|
|
11751
11751
|
tinymceSettings = tinymcePlugin2?.settings;
|
|
11752
11752
|
}
|
|
11753
|
-
const quillEnabled = await
|
|
11753
|
+
const quillEnabled = await chunkFXIVUBMC_cjs.isPluginActive(db, "quill-editor");
|
|
11754
11754
|
let quillSettings;
|
|
11755
11755
|
if (quillEnabled) {
|
|
11756
|
-
const pluginService = new
|
|
11756
|
+
const pluginService = new chunk26X5DBNW_cjs.PluginService(db);
|
|
11757
11757
|
const quillPlugin = await pluginService.getPlugin("quill-editor");
|
|
11758
11758
|
quillSettings = quillPlugin?.settings;
|
|
11759
11759
|
}
|
|
11760
|
-
const mdxeditorEnabled = await
|
|
11760
|
+
const mdxeditorEnabled = await chunkFXIVUBMC_cjs.isPluginActive(db, "easy-mdx");
|
|
11761
11761
|
let mdxeditorSettings;
|
|
11762
11762
|
if (mdxeditorEnabled) {
|
|
11763
|
-
const pluginService = new
|
|
11763
|
+
const pluginService = new chunk26X5DBNW_cjs.PluginService(db);
|
|
11764
11764
|
const mdxeditorPlugin = await pluginService.getPlugin("easy-mdx");
|
|
11765
11765
|
mdxeditorSettings = mdxeditorPlugin?.settings;
|
|
11766
11766
|
}
|
|
11767
|
-
const lexicalEnabled = await
|
|
11767
|
+
const lexicalEnabled = await chunkFXIVUBMC_cjs.isPluginActive(db, "lexical-editor");
|
|
11768
11768
|
let lexicalSettings;
|
|
11769
11769
|
if (lexicalEnabled) {
|
|
11770
|
-
const pluginService = new
|
|
11770
|
+
const pluginService = new chunk26X5DBNW_cjs.PluginService(db);
|
|
11771
11771
|
const lexicalPlugin = await pluginService.getPlugin("lexical-editor");
|
|
11772
11772
|
lexicalSettings = lexicalPlugin?.settings;
|
|
11773
11773
|
}
|
|
@@ -11895,32 +11895,32 @@ adminContentRoutes.get("/:id/edit", async (c) => {
|
|
|
11895
11895
|
};
|
|
11896
11896
|
const fields = await getCollectionFields(db, content.collection_id);
|
|
11897
11897
|
const contentData = content.data ? JSON.parse(content.data) : {};
|
|
11898
|
-
const workflowEnabled = await
|
|
11899
|
-
const tinymceEnabled = await
|
|
11898
|
+
const workflowEnabled = await chunkFXIVUBMC_cjs.isPluginActive(db, "workflow");
|
|
11899
|
+
const tinymceEnabled = await chunkFXIVUBMC_cjs.isPluginActive(db, "tinymce-plugin");
|
|
11900
11900
|
let tinymceSettings;
|
|
11901
11901
|
if (tinymceEnabled) {
|
|
11902
|
-
const pluginService = new
|
|
11902
|
+
const pluginService = new chunk26X5DBNW_cjs.PluginService(db);
|
|
11903
11903
|
const tinymcePlugin2 = await pluginService.getPlugin("tinymce-plugin");
|
|
11904
11904
|
tinymceSettings = tinymcePlugin2?.settings;
|
|
11905
11905
|
}
|
|
11906
|
-
const quillEnabled = await
|
|
11906
|
+
const quillEnabled = await chunkFXIVUBMC_cjs.isPluginActive(db, "quill-editor");
|
|
11907
11907
|
let quillSettings;
|
|
11908
11908
|
if (quillEnabled) {
|
|
11909
|
-
const pluginService = new
|
|
11909
|
+
const pluginService = new chunk26X5DBNW_cjs.PluginService(db);
|
|
11910
11910
|
const quillPlugin = await pluginService.getPlugin("quill-editor");
|
|
11911
11911
|
quillSettings = quillPlugin?.settings;
|
|
11912
11912
|
}
|
|
11913
|
-
const mdxeditorEnabled = await
|
|
11913
|
+
const mdxeditorEnabled = await chunkFXIVUBMC_cjs.isPluginActive(db, "easy-mdx");
|
|
11914
11914
|
let mdxeditorSettings;
|
|
11915
11915
|
if (mdxeditorEnabled) {
|
|
11916
|
-
const pluginService = new
|
|
11916
|
+
const pluginService = new chunk26X5DBNW_cjs.PluginService(db);
|
|
11917
11917
|
const mdxeditorPlugin = await pluginService.getPlugin("easy-mdx");
|
|
11918
11918
|
mdxeditorSettings = mdxeditorPlugin?.settings;
|
|
11919
11919
|
}
|
|
11920
|
-
const lexicalEnabled = await
|
|
11920
|
+
const lexicalEnabled = await chunkFXIVUBMC_cjs.isPluginActive(db, "lexical-editor");
|
|
11921
11921
|
let lexicalSettings;
|
|
11922
11922
|
if (lexicalEnabled) {
|
|
11923
|
-
const pluginService = new
|
|
11923
|
+
const pluginService = new chunk26X5DBNW_cjs.PluginService(db);
|
|
11924
11924
|
const lexicalPlugin = await pluginService.getPlugin("lexical-editor");
|
|
11925
11925
|
lexicalSettings = lexicalPlugin?.settings;
|
|
11926
11926
|
}
|
|
@@ -12293,7 +12293,7 @@ adminContentRoutes.put("/:id", async (c) => {
|
|
|
12293
12293
|
`);
|
|
12294
12294
|
}
|
|
12295
12295
|
});
|
|
12296
|
-
adminContentRoutes.post("/preview",
|
|
12296
|
+
adminContentRoutes.post("/preview", chunkFXIVUBMC_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
12297
12297
|
try {
|
|
12298
12298
|
const formData = await c.req.formData();
|
|
12299
12299
|
const collectionId = formData.get("collection_id");
|
|
@@ -12612,7 +12612,7 @@ adminContentRoutes.delete("/:id", async (c) => {
|
|
|
12612
12612
|
return c.json({ success: false, error: "Failed to delete content" }, 500);
|
|
12613
12613
|
}
|
|
12614
12614
|
});
|
|
12615
|
-
adminContentRoutes.get("/:id/version/:version/preview",
|
|
12615
|
+
adminContentRoutes.get("/:id/version/:version/preview", chunkFXIVUBMC_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
12616
12616
|
try {
|
|
12617
12617
|
const id = c.req.param("id");
|
|
12618
12618
|
const version = parseInt(c.req.param("version") || "0");
|
|
@@ -12708,7 +12708,7 @@ function parseDocFormData(formData, queryableFields = []) {
|
|
|
12708
12708
|
return { title, slug, data };
|
|
12709
12709
|
}
|
|
12710
12710
|
async function getDocService(db, typeId, tenantId) {
|
|
12711
|
-
const registry = new
|
|
12711
|
+
const registry = new chunkFXIVUBMC_cjs.DocumentTypeRegistry(db);
|
|
12712
12712
|
const docType = await registry.findById(typeId);
|
|
12713
12713
|
const svc = new chunk2CB4KY7I_cjs.DocumentsService(db, {
|
|
12714
12714
|
queryableFields: docType?.queryableFields ?? [],
|
|
@@ -12721,7 +12721,7 @@ async function getDocService(db, typeId, tenantId) {
|
|
|
12721
12721
|
}
|
|
12722
12722
|
adminContentRoutes.get("/documents/:typeId/new", async (c) => {
|
|
12723
12723
|
const { typeId } = c.req.param();
|
|
12724
|
-
const registry = new
|
|
12724
|
+
const registry = new chunkFXIVUBMC_cjs.DocumentTypeRegistry(c.env.DB);
|
|
12725
12725
|
const docType = await registry.findById(typeId);
|
|
12726
12726
|
if (!docType) return c.html("<p>Unknown document type.</p>", 404);
|
|
12727
12727
|
return c.html(chunkDNQCEKUK_cjs.renderDocumentFormPage({ docType, isEdit: false, user: userCtx(c) }));
|
|
@@ -12746,7 +12746,7 @@ adminContentRoutes.post("/documents/:typeId/new", async (c) => {
|
|
|
12746
12746
|
}), user?.userId);
|
|
12747
12747
|
return c.redirect(`/admin/content/documents/${typeId}/${doc.rootId}/edit?message=Created+successfully`);
|
|
12748
12748
|
} catch (err) {
|
|
12749
|
-
const registry = new
|
|
12749
|
+
const registry = new chunkFXIVUBMC_cjs.DocumentTypeRegistry(c.env.DB);
|
|
12750
12750
|
const docType = await registry.findById(typeId);
|
|
12751
12751
|
if (!docType) return c.html("<p>Unknown document type.</p>", 404);
|
|
12752
12752
|
return c.html(chunkDNQCEKUK_cjs.renderDocumentFormPage({ docType, isEdit: false, user: userCtx(c), message: err?.message ?? "Failed to create", messageType: "error" }));
|
|
@@ -12756,7 +12756,7 @@ adminContentRoutes.get("/documents/:typeId/:rootId/edit", async (c) => {
|
|
|
12756
12756
|
const { typeId, rootId } = c.req.param();
|
|
12757
12757
|
const db = c.env.DB;
|
|
12758
12758
|
const message = c.req.query("message");
|
|
12759
|
-
const registry = new
|
|
12759
|
+
const registry = new chunkFXIVUBMC_cjs.DocumentTypeRegistry(db);
|
|
12760
12760
|
const docType = await registry.findById(typeId);
|
|
12761
12761
|
if (!docType) return c.html("<p>Unknown document type.</p>", 404);
|
|
12762
12762
|
const tenantId = reqTenant(c);
|
|
@@ -12869,7 +12869,7 @@ adminContentRoutes.get("/documents/:typeId/:rootId/versions", async (c) => {
|
|
|
12869
12869
|
const { typeId, rootId } = c.req.param();
|
|
12870
12870
|
const db = c.env.DB;
|
|
12871
12871
|
const { renderVersionHistoryFragment } = await import('./admin-documents-form.template-KN7JF66Q.cjs');
|
|
12872
|
-
const registry = new
|
|
12872
|
+
const registry = new chunkFXIVUBMC_cjs.DocumentTypeRegistry(db);
|
|
12873
12873
|
const docType = await registry.findById(typeId);
|
|
12874
12874
|
if (!docType) return c.html("<div>Unknown type.</div>", 404);
|
|
12875
12875
|
const result = await db.prepare(
|
|
@@ -14801,7 +14801,7 @@ var TenantService = class {
|
|
|
14801
14801
|
SET name = ?, domain = ?, status = ?, notes = ?, updated_at = ?
|
|
14802
14802
|
WHERE slug = ?
|
|
14803
14803
|
`).bind(name, domain, status, notes, now, slug).run();
|
|
14804
|
-
|
|
14804
|
+
chunk26X5DBNW_cjs.invalidateTenantCache();
|
|
14805
14805
|
const updated = await this.getTenantBySlug(slug);
|
|
14806
14806
|
if (!updated) throw new Error("Tenant not found");
|
|
14807
14807
|
return updated;
|
|
@@ -14819,7 +14819,7 @@ var TenantService = class {
|
|
|
14819
14819
|
throw new Error(`Tenant '${slug}' still owns ${docCount} document(s). Delete or migrate its content first.`);
|
|
14820
14820
|
}
|
|
14821
14821
|
await this.db.prepare(`DELETE FROM auth_tenant WHERE slug = ?`).bind(slug).run();
|
|
14822
|
-
|
|
14822
|
+
chunk26X5DBNW_cjs.invalidateTenantCache();
|
|
14823
14823
|
}
|
|
14824
14824
|
// ─── Membership (auth_tenant_member) ───────────────────────────────────────
|
|
14825
14825
|
// Tenant resolution and the admin switcher are gated on membership: an authed user may only
|
|
@@ -15063,7 +15063,7 @@ var TenantService = class {
|
|
|
15063
15063
|
INSERT INTO auth_tenant (id, name, slug, status, domain, notes, metadata, created_at, updated_at)
|
|
15064
15064
|
VALUES (?, ?, ?, 'active', ?, ?, '{}', ?, ?)
|
|
15065
15065
|
`).bind(id, input.name, input.slug, input.domain, input.notes, now, now).run();
|
|
15066
|
-
|
|
15066
|
+
chunk26X5DBNW_cjs.invalidateTenantCache();
|
|
15067
15067
|
const created = await this.getTenantBySlug(input.slug);
|
|
15068
15068
|
if (!created) throw new Error("Failed to create tenant");
|
|
15069
15069
|
return created;
|
|
@@ -15087,14 +15087,14 @@ function mapRowToTenant(row) {
|
|
|
15087
15087
|
|
|
15088
15088
|
// src/routes/admin-users.ts
|
|
15089
15089
|
var userRoutes = new hono.Hono();
|
|
15090
|
-
userRoutes.use("*",
|
|
15091
|
-
userRoutes.use("/users/*",
|
|
15092
|
-
userRoutes.use("/users",
|
|
15093
|
-
userRoutes.use("/invite-user",
|
|
15094
|
-
userRoutes.use("/resend-invitation/*",
|
|
15095
|
-
userRoutes.use("/cancel-invitation/*",
|
|
15096
|
-
userRoutes.use("/activity-logs",
|
|
15097
|
-
userRoutes.use("/activity-logs/*",
|
|
15090
|
+
userRoutes.use("*", chunkFXIVUBMC_cjs.requireAuth());
|
|
15091
|
+
userRoutes.use("/users/*", chunkFXIVUBMC_cjs.requireRole(["admin"]));
|
|
15092
|
+
userRoutes.use("/users", chunkFXIVUBMC_cjs.requireRole(["admin"]));
|
|
15093
|
+
userRoutes.use("/invite-user", chunkFXIVUBMC_cjs.requireRole(["admin"]));
|
|
15094
|
+
userRoutes.use("/resend-invitation/*", chunkFXIVUBMC_cjs.requireRole(["admin"]));
|
|
15095
|
+
userRoutes.use("/cancel-invitation/*", chunkFXIVUBMC_cjs.requireRole(["admin"]));
|
|
15096
|
+
userRoutes.use("/activity-logs", chunkFXIVUBMC_cjs.requireRole(["admin"]));
|
|
15097
|
+
userRoutes.use("/activity-logs/*", chunkFXIVUBMC_cjs.requireRole(["admin"]));
|
|
15098
15098
|
userRoutes.get("/", (c) => {
|
|
15099
15099
|
return c.redirect("/admin/dashboard");
|
|
15100
15100
|
});
|
|
@@ -15261,7 +15261,7 @@ userRoutes.put("/profile", async (c) => {
|
|
|
15261
15261
|
}
|
|
15262
15262
|
await saveCustomData(db, user.userId, sanitized);
|
|
15263
15263
|
}
|
|
15264
|
-
await
|
|
15264
|
+
await chunkFXIVUBMC_cjs.logActivity(
|
|
15265
15265
|
db,
|
|
15266
15266
|
user.userId,
|
|
15267
15267
|
"profile.update",
|
|
@@ -15324,7 +15324,7 @@ userRoutes.post("/profile/avatar", async (c) => {
|
|
|
15324
15324
|
SELECT first_name, last_name FROM auth_user WHERE id = ?
|
|
15325
15325
|
`);
|
|
15326
15326
|
const userData = await userStmt.bind(user.userId).first();
|
|
15327
|
-
await
|
|
15327
|
+
await chunkFXIVUBMC_cjs.logActivity(
|
|
15328
15328
|
db,
|
|
15329
15329
|
user.userId,
|
|
15330
15330
|
"profile.avatar_update",
|
|
@@ -15395,7 +15395,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
15395
15395
|
dismissible: true
|
|
15396
15396
|
}));
|
|
15397
15397
|
}
|
|
15398
|
-
const validPassword = await
|
|
15398
|
+
const validPassword = await chunkFXIVUBMC_cjs.AuthManager.verifyPassword(currentPassword, userData.password_hash);
|
|
15399
15399
|
if (!validPassword) {
|
|
15400
15400
|
return c.html(chunkDNQCEKUK_cjs.renderAlert({
|
|
15401
15401
|
type: "error",
|
|
@@ -15403,7 +15403,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
15403
15403
|
dismissible: true
|
|
15404
15404
|
}));
|
|
15405
15405
|
}
|
|
15406
|
-
const newPasswordHash = await
|
|
15406
|
+
const newPasswordHash = await chunkFXIVUBMC_cjs.AuthManager.hashPassword(newPassword);
|
|
15407
15407
|
const historyStmt = db.prepare(`
|
|
15408
15408
|
INSERT INTO auth_password_history (id, user_id, password_hash, created_at)
|
|
15409
15409
|
VALUES (?, ?, ?, ?)
|
|
@@ -15419,7 +15419,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
15419
15419
|
WHERE id = ?
|
|
15420
15420
|
`);
|
|
15421
15421
|
await updateStmt.bind(newPasswordHash, Date.now(), user.userId).run();
|
|
15422
|
-
await
|
|
15422
|
+
await chunkFXIVUBMC_cjs.logActivity(
|
|
15423
15423
|
db,
|
|
15424
15424
|
user.userId,
|
|
15425
15425
|
"profile.password_change",
|
|
@@ -15486,7 +15486,7 @@ userRoutes.get("/users", async (c) => {
|
|
|
15486
15486
|
`);
|
|
15487
15487
|
const countResult = await countStmt.bind(...params).first();
|
|
15488
15488
|
const totalUsers = countResult?.total || 0;
|
|
15489
|
-
await
|
|
15489
|
+
await chunkFXIVUBMC_cjs.logActivity(
|
|
15490
15490
|
db,
|
|
15491
15491
|
user.userId,
|
|
15492
15492
|
"users.list_view",
|
|
@@ -15667,7 +15667,7 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
15667
15667
|
dismissible: true
|
|
15668
15668
|
}));
|
|
15669
15669
|
}
|
|
15670
|
-
const passwordHash = await
|
|
15670
|
+
const passwordHash = await chunkFXIVUBMC_cjs.AuthManager.hashPassword(password);
|
|
15671
15671
|
const userId = crypto.randomUUID();
|
|
15672
15672
|
const createStmt = db.prepare(`
|
|
15673
15673
|
INSERT INTO auth_user (
|
|
@@ -15692,7 +15692,7 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
15692
15692
|
if (sanitizedRegistrationCustom !== null && Object.keys(sanitizedRegistrationCustom).length > 0) {
|
|
15693
15693
|
await writeProfileData(db, userId, { custom: sanitizedRegistrationCustom }, user.userId);
|
|
15694
15694
|
}
|
|
15695
|
-
await
|
|
15695
|
+
await chunkFXIVUBMC_cjs.logActivity(
|
|
15696
15696
|
db,
|
|
15697
15697
|
user.userId,
|
|
15698
15698
|
"user!.create",
|
|
@@ -15731,7 +15731,7 @@ userRoutes.get("/users/:id", async (c) => {
|
|
|
15731
15731
|
if (!userRecord) {
|
|
15732
15732
|
return c.json({ error: "User not found" }, 404);
|
|
15733
15733
|
}
|
|
15734
|
-
await
|
|
15734
|
+
await chunkFXIVUBMC_cjs.logActivity(
|
|
15735
15735
|
db,
|
|
15736
15736
|
user.userId,
|
|
15737
15737
|
"user!.view",
|
|
@@ -15945,7 +15945,7 @@ userRoutes.put("/users/:id", async (c) => {
|
|
|
15945
15945
|
userId
|
|
15946
15946
|
).run();
|
|
15947
15947
|
if (newPassword) {
|
|
15948
|
-
const passwordHash = await
|
|
15948
|
+
const passwordHash = await chunkFXIVUBMC_cjs.AuthManager.hashPassword(newPassword);
|
|
15949
15949
|
const updatePasswordStmt = db.prepare(`
|
|
15950
15950
|
UPDATE auth_user SET password_hash = ?, updated_at = ? WHERE id = ?
|
|
15951
15951
|
`);
|
|
@@ -15958,7 +15958,7 @@ userRoutes.put("/users/:id", async (c) => {
|
|
|
15958
15958
|
...sanitizedCustom !== null ? { custom: sanitizedCustom } : {}
|
|
15959
15959
|
}, user.userId);
|
|
15960
15960
|
}
|
|
15961
|
-
await
|
|
15961
|
+
await chunkFXIVUBMC_cjs.logActivity(
|
|
15962
15962
|
db,
|
|
15963
15963
|
user.userId,
|
|
15964
15964
|
"user.update",
|
|
@@ -16004,7 +16004,7 @@ userRoutes.post("/users/:id/toggle", async (c) => {
|
|
|
16004
16004
|
UPDATE auth_user SET is_active = ?, updated_at = ? WHERE id = ?
|
|
16005
16005
|
`);
|
|
16006
16006
|
await toggleStmt.bind(active ? 1 : 0, Date.now(), userId).run();
|
|
16007
|
-
await
|
|
16007
|
+
await chunkFXIVUBMC_cjs.logActivity(
|
|
16008
16008
|
db,
|
|
16009
16009
|
user.userId,
|
|
16010
16010
|
active ? "user.activate" : "user.deactivate",
|
|
@@ -16045,7 +16045,7 @@ userRoutes.delete("/users/:id", async (c) => {
|
|
|
16045
16045
|
DELETE FROM auth_user WHERE id = ?
|
|
16046
16046
|
`);
|
|
16047
16047
|
await deleteStmt.bind(userId).run();
|
|
16048
|
-
await
|
|
16048
|
+
await chunkFXIVUBMC_cjs.logActivity(
|
|
16049
16049
|
db,
|
|
16050
16050
|
user.userId,
|
|
16051
16051
|
"user!.hard_delete",
|
|
@@ -16064,7 +16064,7 @@ userRoutes.delete("/users/:id", async (c) => {
|
|
|
16064
16064
|
UPDATE auth_user SET is_active = 0, updated_at = ? WHERE id = ?
|
|
16065
16065
|
`);
|
|
16066
16066
|
await deleteStmt.bind(Date.now(), userId).run();
|
|
16067
|
-
await
|
|
16067
|
+
await chunkFXIVUBMC_cjs.logActivity(
|
|
16068
16068
|
db,
|
|
16069
16069
|
user.userId,
|
|
16070
16070
|
"user!.soft_delete",
|
|
@@ -16130,7 +16130,7 @@ userRoutes.post("/invite-user", async (c) => {
|
|
|
16130
16130
|
Date.now(),
|
|
16131
16131
|
Date.now()
|
|
16132
16132
|
).run();
|
|
16133
|
-
await
|
|
16133
|
+
await chunkFXIVUBMC_cjs.logActivity(
|
|
16134
16134
|
db,
|
|
16135
16135
|
user.userId,
|
|
16136
16136
|
"user!.invite_sent",
|
|
@@ -16187,7 +16187,7 @@ userRoutes.post("/resend-invitation/:id", async (c) => {
|
|
|
16187
16187
|
Date.now(),
|
|
16188
16188
|
userId
|
|
16189
16189
|
).run();
|
|
16190
|
-
await
|
|
16190
|
+
await chunkFXIVUBMC_cjs.logActivity(
|
|
16191
16191
|
db,
|
|
16192
16192
|
user.userId,
|
|
16193
16193
|
"user!.invitation_resent",
|
|
@@ -16223,7 +16223,7 @@ userRoutes.delete("/cancel-invitation/:id", async (c) => {
|
|
|
16223
16223
|
}
|
|
16224
16224
|
const deleteStmt = db.prepare(`DELETE FROM auth_user WHERE id = ?`);
|
|
16225
16225
|
await deleteStmt.bind(userId).run();
|
|
16226
|
-
await
|
|
16226
|
+
await chunkFXIVUBMC_cjs.logActivity(
|
|
16227
16227
|
db,
|
|
16228
16228
|
user.userId,
|
|
16229
16229
|
"user!.invitation_cancelled",
|
|
@@ -17604,7 +17604,7 @@ var fileValidationSchema2 = zod.z.object({
|
|
|
17604
17604
|
// 50MB max
|
|
17605
17605
|
});
|
|
17606
17606
|
var adminMediaRoutes = new hono.Hono();
|
|
17607
|
-
adminMediaRoutes.use("*",
|
|
17607
|
+
adminMediaRoutes.use("*", chunkFXIVUBMC_cjs.requireAuth());
|
|
17608
17608
|
adminMediaRoutes.get("/", async (c) => {
|
|
17609
17609
|
try {
|
|
17610
17610
|
const user = c.get("user");
|
|
@@ -17646,7 +17646,7 @@ adminMediaRoutes.get("/selector", async (c) => {
|
|
|
17646
17646
|
const { searchParams } = new URL(c.req.url);
|
|
17647
17647
|
const search = searchParams.get("search") || "";
|
|
17648
17648
|
const db = c.env.DB;
|
|
17649
|
-
const pluginService = new
|
|
17649
|
+
const pluginService = new chunk26X5DBNW_cjs.PluginService(db);
|
|
17650
17650
|
const mediaPlugin = await pluginService.getPlugin("core-media");
|
|
17651
17651
|
if (!mediaPlugin || mediaPlugin.status !== "active") {
|
|
17652
17652
|
return c.html(html.html`
|
|
@@ -18020,7 +18020,7 @@ adminMediaRoutes.put("/:id", async (c) => {
|
|
|
18020
18020
|
`);
|
|
18021
18021
|
}
|
|
18022
18022
|
});
|
|
18023
|
-
adminMediaRoutes.delete("/cleanup",
|
|
18023
|
+
adminMediaRoutes.delete("/cleanup", chunkFXIVUBMC_cjs.requireRole("admin"), async (c) => {
|
|
18024
18024
|
try {
|
|
18025
18025
|
const db = c.env.DB;
|
|
18026
18026
|
const allMediaStmt = db.prepare("SELECT id, r2_key, filename FROM media WHERE deleted_at IS NULL");
|
|
@@ -20453,8 +20453,8 @@ defineUserProfile({
|
|
|
20453
20453
|
|
|
20454
20454
|
// src/routes/admin-plugins.ts
|
|
20455
20455
|
var adminPluginRoutes = new hono.Hono();
|
|
20456
|
-
adminPluginRoutes.use("*",
|
|
20457
|
-
var AVAILABLE_PLUGINS = Object.values(
|
|
20456
|
+
adminPluginRoutes.use("*", chunkFXIVUBMC_cjs.requireAuth());
|
|
20457
|
+
var AVAILABLE_PLUGINS = Object.values(chunk26X5DBNW_cjs.PLUGIN_REGISTRY).map((p) => ({
|
|
20458
20458
|
id: p.id,
|
|
20459
20459
|
name: p.codeName,
|
|
20460
20460
|
display_name: p.displayName,
|
|
@@ -20474,7 +20474,7 @@ adminPluginRoutes.get("/", async (c) => {
|
|
|
20474
20474
|
if (user?.role !== "admin") {
|
|
20475
20475
|
return c.text("Access denied", 403);
|
|
20476
20476
|
}
|
|
20477
|
-
const pluginService = new
|
|
20477
|
+
const pluginService = new chunk26X5DBNW_cjs.PluginService(db);
|
|
20478
20478
|
let installedPlugins = [];
|
|
20479
20479
|
let stats = { total: 0, active: 0, inactive: 0, errors: 0, uninstalled: 0 };
|
|
20480
20480
|
try {
|
|
@@ -20546,10 +20546,10 @@ adminPluginRoutes.get("/:id", async (c) => {
|
|
|
20546
20546
|
if (user?.role !== "admin") {
|
|
20547
20547
|
return c.redirect("/admin/plugins");
|
|
20548
20548
|
}
|
|
20549
|
-
const pluginService = new
|
|
20549
|
+
const pluginService = new chunk26X5DBNW_cjs.PluginService(db);
|
|
20550
20550
|
let plugin = await pluginService.getPlugin(pluginId);
|
|
20551
20551
|
if (!plugin) {
|
|
20552
|
-
const def =
|
|
20552
|
+
const def = chunkGE4626OK_cjs.getPluginDefinition(pluginId);
|
|
20553
20553
|
if (!def) return c.text("Plugin not found", 404);
|
|
20554
20554
|
plugin = await pluginService.ensurePlugin(pluginId, {
|
|
20555
20555
|
displayName: def.displayName ?? pluginId,
|
|
@@ -20640,14 +20640,14 @@ adminPluginRoutes.get("/:id/configure", async (c) => {
|
|
|
20640
20640
|
const user = c.get("user");
|
|
20641
20641
|
const pluginId = c.req.param("id");
|
|
20642
20642
|
if (user?.role !== "admin") return c.redirect("/admin/plugins");
|
|
20643
|
-
const def =
|
|
20643
|
+
const def = chunkGE4626OK_cjs.getPluginDefinition(pluginId);
|
|
20644
20644
|
if (!def?.configSchema) return c.text("No schema-driven settings for this plugin", 404);
|
|
20645
20645
|
const db = c.env.DB;
|
|
20646
|
-
const pluginService = new
|
|
20646
|
+
const pluginService = new chunk26X5DBNW_cjs.PluginService(db);
|
|
20647
20647
|
const plugin = await pluginService.getPlugin(pluginId);
|
|
20648
20648
|
const stored = plugin?.settings ?? {};
|
|
20649
|
-
const values =
|
|
20650
|
-
const fieldsHtml =
|
|
20649
|
+
const values = chunkGE4626OK_cjs.applySchemaDefaults(def.configSchema, stored);
|
|
20650
|
+
const fieldsHtml = chunkGE4626OK_cjs.renderSchemaFields(def.configSchema, values);
|
|
20651
20651
|
const displayName = plugin?.display_name ?? def.displayName ?? def.id;
|
|
20652
20652
|
return c.html(`<!DOCTYPE html>
|
|
20653
20653
|
<html lang="en"><head>
|
|
@@ -20674,12 +20674,12 @@ adminPluginRoutes.post("/:id/configure", async (c) => {
|
|
|
20674
20674
|
const user = c.get("user");
|
|
20675
20675
|
const pluginId = c.req.param("id");
|
|
20676
20676
|
if (user?.role !== "admin") return c.json({ error: "Access denied" }, 403);
|
|
20677
|
-
const def =
|
|
20677
|
+
const def = chunkGE4626OK_cjs.getPluginDefinition(pluginId);
|
|
20678
20678
|
if (!def?.configSchema) return c.text("No schema-driven settings for this plugin", 404);
|
|
20679
20679
|
const form = await c.req.formData();
|
|
20680
|
-
const parsed =
|
|
20680
|
+
const parsed = chunkGE4626OK_cjs.parseFormDataToSettings(def.configSchema, form);
|
|
20681
20681
|
const db = c.env.DB;
|
|
20682
|
-
const pluginService = new
|
|
20682
|
+
const pluginService = new chunk26X5DBNW_cjs.PluginService(db);
|
|
20683
20683
|
await pluginService.ensurePlugin(pluginId, {
|
|
20684
20684
|
displayName: def.displayName ?? pluginId,
|
|
20685
20685
|
version: def.version,
|
|
@@ -20701,7 +20701,7 @@ adminPluginRoutes.post("/:id/activate", async (c) => {
|
|
|
20701
20701
|
if (user?.role !== "admin") {
|
|
20702
20702
|
return c.json({ error: "Access denied" }, 403);
|
|
20703
20703
|
}
|
|
20704
|
-
const pluginService = new
|
|
20704
|
+
const pluginService = new chunk26X5DBNW_cjs.PluginService(db);
|
|
20705
20705
|
await pluginService.activatePlugin(pluginId);
|
|
20706
20706
|
return c.json({ success: true });
|
|
20707
20707
|
} catch (error) {
|
|
@@ -20718,7 +20718,7 @@ adminPluginRoutes.post("/:id/deactivate", async (c) => {
|
|
|
20718
20718
|
if (user?.role !== "admin") {
|
|
20719
20719
|
return c.json({ error: "Access denied" }, 403);
|
|
20720
20720
|
}
|
|
20721
|
-
const pluginService = new
|
|
20721
|
+
const pluginService = new chunk26X5DBNW_cjs.PluginService(db);
|
|
20722
20722
|
await pluginService.deactivatePlugin(pluginId);
|
|
20723
20723
|
return c.json({ success: true });
|
|
20724
20724
|
} catch (error) {
|
|
@@ -20735,8 +20735,8 @@ adminPluginRoutes.post("/install", async (c) => {
|
|
|
20735
20735
|
return c.json({ error: "Access denied" }, 403);
|
|
20736
20736
|
}
|
|
20737
20737
|
const body = await c.req.json();
|
|
20738
|
-
const pluginService = new
|
|
20739
|
-
const registryEntry =
|
|
20738
|
+
const pluginService = new chunk26X5DBNW_cjs.PluginService(db);
|
|
20739
|
+
const registryEntry = chunk26X5DBNW_cjs.findPluginByCodeName(body.name) || chunk26X5DBNW_cjs.PLUGIN_REGISTRY[body.name] || chunk26X5DBNW_cjs.PLUGIN_REGISTRY[body.id];
|
|
20740
20740
|
if (!registryEntry) {
|
|
20741
20741
|
return c.json({ error: "Plugin not found in registry" }, 404);
|
|
20742
20742
|
}
|
|
@@ -20769,7 +20769,7 @@ adminPluginRoutes.post("/:id/uninstall", async (c) => {
|
|
|
20769
20769
|
if (user?.role !== "admin") {
|
|
20770
20770
|
return c.json({ error: "Access denied" }, 403);
|
|
20771
20771
|
}
|
|
20772
|
-
const pluginService = new
|
|
20772
|
+
const pluginService = new chunk26X5DBNW_cjs.PluginService(db);
|
|
20773
20773
|
await pluginService.uninstallPlugin(pluginId);
|
|
20774
20774
|
return c.json({ success: true });
|
|
20775
20775
|
} catch (error) {
|
|
@@ -20787,7 +20787,7 @@ adminPluginRoutes.post("/:id/settings", async (c) => {
|
|
|
20787
20787
|
return c.json({ error: "Access denied" }, 403);
|
|
20788
20788
|
}
|
|
20789
20789
|
const settings = await c.req.json();
|
|
20790
|
-
const pluginService = new
|
|
20790
|
+
const pluginService = new chunk26X5DBNW_cjs.PluginService(db);
|
|
20791
20791
|
await pluginService.updatePluginSettings(pluginId, settings);
|
|
20792
20792
|
if (pluginId === "core-auth") {
|
|
20793
20793
|
try {
|
|
@@ -21595,7 +21595,7 @@ function renderLogConfigPage(data) {
|
|
|
21595
21595
|
|
|
21596
21596
|
// src/routes/admin-logs.ts
|
|
21597
21597
|
var adminLogsRoutes = new hono.Hono();
|
|
21598
|
-
adminLogsRoutes.use("*",
|
|
21598
|
+
adminLogsRoutes.use("*", chunkFXIVUBMC_cjs.requireAuth());
|
|
21599
21599
|
adminLogsRoutes.get("/", async (c) => {
|
|
21600
21600
|
try {
|
|
21601
21601
|
const user = c.get("user");
|
|
@@ -22587,9 +22587,9 @@ function renderStorageUsage(databaseSizeBytes, mediaSizeBytes) {
|
|
|
22587
22587
|
}
|
|
22588
22588
|
|
|
22589
22589
|
// src/routes/admin-dashboard.ts
|
|
22590
|
-
var VERSION =
|
|
22590
|
+
var VERSION = chunkB52GZLUI_cjs.getCoreVersion();
|
|
22591
22591
|
var router = new hono.Hono();
|
|
22592
|
-
router.use("*",
|
|
22592
|
+
router.use("*", chunkFXIVUBMC_cjs.requireAuth());
|
|
22593
22593
|
router.get("/", async (c) => {
|
|
22594
22594
|
const user = c.get("user");
|
|
22595
22595
|
try {
|
|
@@ -24554,7 +24554,7 @@ function renderCollectionFormPage(data) {
|
|
|
24554
24554
|
// src/routes/admin-collections.ts
|
|
24555
24555
|
chunkNAVPFIG5_cjs.init_admin_layout_catalyst_template();
|
|
24556
24556
|
var adminCollectionsRoutes = new hono.Hono();
|
|
24557
|
-
adminCollectionsRoutes.use("*",
|
|
24557
|
+
adminCollectionsRoutes.use("*", chunkFXIVUBMC_cjs.requireAuth());
|
|
24558
24558
|
adminCollectionsRoutes.get("/", async (c) => {
|
|
24559
24559
|
try {
|
|
24560
24560
|
const user = c.get("user");
|
|
@@ -24571,7 +24571,7 @@ adminCollectionsRoutes.get("/", async (c) => {
|
|
|
24571
24571
|
results = queryResults.results ?? [];
|
|
24572
24572
|
} catch (e) {
|
|
24573
24573
|
}
|
|
24574
|
-
const codeCollections =
|
|
24574
|
+
const codeCollections = chunk26X5DBNW_cjs.getCollectionRegistry().list();
|
|
24575
24575
|
const codeCollectionsMap = new Map(
|
|
24576
24576
|
codeCollections.map((cfg) => {
|
|
24577
24577
|
const fieldCount = cfg.schema?.properties ? Object.keys(cfg.schema.properties).length : 0;
|
|
@@ -24585,7 +24585,7 @@ adminCollectionsRoutes.get("/", async (c) => {
|
|
|
24585
24585
|
field_count: fieldCount,
|
|
24586
24586
|
managed: cfg.managed !== false,
|
|
24587
24587
|
source_type: "code",
|
|
24588
|
-
internal:
|
|
24588
|
+
internal: chunk26X5DBNW_cjs.isCodeCollectionInternal(cfg),
|
|
24589
24589
|
versioning: cfg.versioning === true
|
|
24590
24590
|
}];
|
|
24591
24591
|
})
|
|
@@ -24624,7 +24624,7 @@ adminCollectionsRoutes.get("/", async (c) => {
|
|
|
24624
24624
|
field_count: fieldCount,
|
|
24625
24625
|
managed: false,
|
|
24626
24626
|
source_type: row.source === "code" || row.source === "system" || row.source === "plugin" ? "code" : "user",
|
|
24627
|
-
internal:
|
|
24627
|
+
internal: chunk26X5DBNW_cjs.isDbDocTypeInternal(row.source),
|
|
24628
24628
|
versioning: dbVersioning
|
|
24629
24629
|
};
|
|
24630
24630
|
});
|
|
@@ -24785,7 +24785,7 @@ export const myPlugin = definePlugin({
|
|
|
24785
24785
|
title: "Add a Collection",
|
|
24786
24786
|
pageTitle: "Add a Collection",
|
|
24787
24787
|
currentPath: "/admin/collections",
|
|
24788
|
-
version:
|
|
24788
|
+
version: chunkB52GZLUI_cjs.getCoreVersion(),
|
|
24789
24789
|
user: u ? { name: u.email ?? "Admin", email: u.email ?? "", role: u.role ?? "admin" } : void 0,
|
|
24790
24790
|
content
|
|
24791
24791
|
})
|
|
@@ -24802,7 +24802,7 @@ adminCollectionsRoutes.get("/:id", async (c) => {
|
|
|
24802
24802
|
collection = await stmt.bind(id).first();
|
|
24803
24803
|
} catch {
|
|
24804
24804
|
}
|
|
24805
|
-
const registryRecord =
|
|
24805
|
+
const registryRecord = chunk26X5DBNW_cjs.getCollectionRegistry().getById(id) ?? chunk26X5DBNW_cjs.getCollectionRegistry().getByName(id);
|
|
24806
24806
|
if (!collection && !registryRecord) {
|
|
24807
24807
|
const formData2 = {
|
|
24808
24808
|
isEdit: true,
|
|
@@ -24849,9 +24849,9 @@ adminCollectionsRoutes.get("/:id", async (c) => {
|
|
|
24849
24849
|
isCodeDriven = true;
|
|
24850
24850
|
}
|
|
24851
24851
|
const [tinymceActive, quillActive, mdxeditorActive] = await Promise.all([
|
|
24852
|
-
|
|
24853
|
-
|
|
24854
|
-
|
|
24852
|
+
chunkFXIVUBMC_cjs.isPluginActive(db, "tinymce-plugin"),
|
|
24853
|
+
chunkFXIVUBMC_cjs.isPluginActive(db, "quill-editor"),
|
|
24854
|
+
chunkFXIVUBMC_cjs.isPluginActive(db, "easy-mdx")
|
|
24855
24855
|
]);
|
|
24856
24856
|
const displayName = collection?.display_name ?? registryRecord?.displayName ?? id;
|
|
24857
24857
|
const formData = {
|
|
@@ -24871,9 +24871,9 @@ adminCollectionsRoutes.get("/:id", async (c) => {
|
|
|
24871
24871
|
console.error("Error fetching collection:", error);
|
|
24872
24872
|
const user = c.get("user");
|
|
24873
24873
|
const [tinymceActive, quillActive, mdxeditorActive] = await Promise.all([
|
|
24874
|
-
|
|
24875
|
-
|
|
24876
|
-
|
|
24874
|
+
chunkFXIVUBMC_cjs.isPluginActive(db, "tinymce-plugin"),
|
|
24875
|
+
chunkFXIVUBMC_cjs.isPluginActive(db, "quill-editor"),
|
|
24876
|
+
chunkFXIVUBMC_cjs.isPluginActive(db, "easy-mdx")
|
|
24877
24877
|
]);
|
|
24878
24878
|
const formData = {
|
|
24879
24879
|
isEdit: true,
|
|
@@ -25822,7 +25822,7 @@ function renderDatabaseToolsSettings(settings) {
|
|
|
25822
25822
|
|
|
25823
25823
|
// src/routes/admin-settings.ts
|
|
25824
25824
|
var adminSettingsRoutes = new hono.Hono();
|
|
25825
|
-
adminSettingsRoutes.use("*",
|
|
25825
|
+
adminSettingsRoutes.use("*", chunkFXIVUBMC_cjs.requireAuth());
|
|
25826
25826
|
function getMockSettings(user) {
|
|
25827
25827
|
return {
|
|
25828
25828
|
general: {
|
|
@@ -25925,7 +25925,7 @@ adminSettingsRoutes.get("/database-tools", (c) => {
|
|
|
25925
25925
|
adminSettingsRoutes.get("/api/migrations/status", async (c) => {
|
|
25926
25926
|
try {
|
|
25927
25927
|
const db = c.env.DB;
|
|
25928
|
-
const migrationService = new
|
|
25928
|
+
const migrationService = new chunkGP2K2K3G_cjs.MigrationService(db);
|
|
25929
25929
|
const status = await migrationService.getMigrationStatus();
|
|
25930
25930
|
return c.json({
|
|
25931
25931
|
success: true,
|
|
@@ -25965,7 +25965,7 @@ adminSettingsRoutes.post("/api/migrations/run", async (c) => {
|
|
|
25965
25965
|
adminSettingsRoutes.get("/api/migrations/validate", async (c) => {
|
|
25966
25966
|
try {
|
|
25967
25967
|
const db = c.env.DB;
|
|
25968
|
-
const migrationService = new
|
|
25968
|
+
const migrationService = new chunkGP2K2K3G_cjs.MigrationService(db);
|
|
25969
25969
|
const validation = await migrationService.validateSchema();
|
|
25970
25970
|
return c.json({
|
|
25971
25971
|
success: true,
|
|
@@ -26558,16 +26558,16 @@ function renderAPIReferencePage(data) {
|
|
|
26558
26558
|
}
|
|
26559
26559
|
|
|
26560
26560
|
// src/routes/admin-api-reference.ts
|
|
26561
|
-
var VERSION2 =
|
|
26561
|
+
var VERSION2 = chunkB52GZLUI_cjs.getCoreVersion();
|
|
26562
26562
|
var router2 = new hono.Hono();
|
|
26563
|
-
router2.use("*",
|
|
26563
|
+
router2.use("*", chunkFXIVUBMC_cjs.requireAuth());
|
|
26564
26564
|
router2.get("/", async (c) => {
|
|
26565
26565
|
const user = c.get("user");
|
|
26566
26566
|
try {
|
|
26567
26567
|
const app2 = chunkBDDABDAB_cjs.getAppInstance();
|
|
26568
26568
|
const baseEndpoints = chunkBDDABDAB_cjs.buildRouteList(app2);
|
|
26569
26569
|
const collectionRoutes = [];
|
|
26570
|
-
const collections =
|
|
26570
|
+
const collections = chunk26X5DBNW_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal);
|
|
26571
26571
|
const methodOrder = { GET: 0, POST: 1, PUT: 2, PATCH: 3, DELETE: 4 };
|
|
26572
26572
|
for (const col of collections) {
|
|
26573
26573
|
const displayName = col.displayName || col.name;
|
|
@@ -26683,5 +26683,5 @@ exports.setVariablesCache = setVariablesCache;
|
|
|
26683
26683
|
exports.test_cleanup_default = test_cleanup_default;
|
|
26684
26684
|
exports.userProfilesPlugin = userProfilesPlugin;
|
|
26685
26685
|
exports.userRoutes = userRoutes;
|
|
26686
|
-
//# sourceMappingURL=chunk-
|
|
26687
|
-
//# sourceMappingURL=chunk-
|
|
26686
|
+
//# sourceMappingURL=chunk-QG7OILOU.cjs.map
|
|
26687
|
+
//# sourceMappingURL=chunk-QG7OILOU.cjs.map
|