@sonicjs-cms/core 3.0.0-beta.23 → 3.0.0-beta.25
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/bin/db-reset.js +39 -22
- package/dist/admin-documents-form.template-JWV5GITD.js +6 -0
- package/dist/{admin-documents-form.template-55V2ZGWT.js.map → admin-documents-form.template-JWV5GITD.js.map} +1 -1
- package/dist/admin-documents-form.template-UWKGVAMW.cjs +19 -0
- package/dist/{admin-layout-catalyst.template-6UQGLCKI.js.map → admin-documents-form.template-UWKGVAMW.cjs.map} +1 -1
- package/dist/admin-layout-catalyst.template-MOQ3BBXA.cjs +21 -0
- package/dist/{admin-layout-catalyst.template-3XZXDGF7.cjs.map → admin-layout-catalyst.template-MOQ3BBXA.cjs.map} +1 -1
- package/dist/admin-layout-catalyst.template-WCYMQVTZ.js +7 -0
- package/dist/{admin-documents-form.template-YNAVMJCV.cjs.map → admin-layout-catalyst.template-WCYMQVTZ.js.map} +1 -1
- package/dist/{chunk-KS24NPPL.js → chunk-2D3A4X52.js} +21 -2
- package/dist/chunk-2D3A4X52.js.map +1 -0
- package/dist/{chunk-DIBCKCUE.js → chunk-2OXFMMA3.js} +14 -29
- package/dist/chunk-2OXFMMA3.js.map +1 -0
- package/dist/{chunk-SOZUG52O.js → chunk-3KGY4IBW.js} +3 -3
- package/dist/{chunk-SOZUG52O.js.map → chunk-3KGY4IBW.js.map} +1 -1
- package/dist/{chunk-CTYLCWMO.cjs → chunk-6OA77UM7.cjs} +802 -481
- package/dist/chunk-6OA77UM7.cjs.map +1 -0
- package/dist/{chunk-URIBTX27.js → chunk-73RTFFMX.js} +3 -3
- package/dist/{chunk-URIBTX27.js.map → chunk-73RTFFMX.js.map} +1 -1
- package/dist/{chunk-SK5CHFJP.js → chunk-7P5OCUPS.js} +467 -149
- package/dist/chunk-7P5OCUPS.js.map +1 -0
- package/dist/{chunk-3TMTYJAJ.js → chunk-BDQ55MWV.js} +18 -2
- package/dist/chunk-BDQ55MWV.js.map +1 -0
- package/dist/{chunk-C3ZQP5NW.cjs → chunk-BJ6NJL2E.cjs} +7 -12
- package/dist/chunk-BJ6NJL2E.cjs.map +1 -0
- package/dist/{chunk-2MIYYAO4.js → chunk-C54MH5UI.js} +5 -4
- package/dist/chunk-C54MH5UI.js.map +1 -0
- package/dist/{chunk-BBEKHLTW.cjs → chunk-CN3T3TDI.cjs} +9 -9
- package/dist/{chunk-BBEKHLTW.cjs.map → chunk-CN3T3TDI.cjs.map} +1 -1
- package/dist/{chunk-DPLJYTHE.js → chunk-CWIGQYRR.js} +7 -12
- package/dist/chunk-CWIGQYRR.js.map +1 -0
- package/dist/{chunk-4WMZGHIC.cjs → chunk-D6FWEYQE.cjs} +6 -5
- package/dist/chunk-D6FWEYQE.cjs.map +1 -0
- package/dist/{chunk-A46IRC5A.js → chunk-D7RLBBHE.js} +2 -2
- package/dist/{chunk-A46IRC5A.js.map → chunk-D7RLBBHE.js.map} +1 -1
- package/dist/{chunk-IXUHXTHW.cjs → chunk-DLTT7QZU.cjs} +17 -6
- package/dist/chunk-DLTT7QZU.cjs.map +1 -0
- package/dist/{chunk-BHND5PEV.js → chunk-E3TQG7AA.js} +3 -3
- package/dist/{chunk-BHND5PEV.js.map → chunk-E3TQG7AA.js.map} +1 -1
- package/dist/{chunk-IS54FPB7.cjs → chunk-E7E3NL3Y.cjs} +27 -42
- package/dist/chunk-E7E3NL3Y.cjs.map +1 -0
- package/dist/{chunk-XXRR54AB.js → chunk-F26HP3B6.js} +36 -5
- package/dist/chunk-F26HP3B6.js.map +1 -0
- package/dist/{chunk-QZGABF2M.js → chunk-FVAK4C6L.js} +17 -6
- package/dist/chunk-FVAK4C6L.js.map +1 -0
- package/dist/{chunk-BJROXF4N.js → chunk-HSDJDWLV.js} +19 -4
- package/dist/chunk-HSDJDWLV.js.map +1 -0
- package/dist/{chunk-RFBW5RRH.cjs → chunk-I7MIRRFJ.cjs} +43 -12
- package/dist/chunk-I7MIRRFJ.cjs.map +1 -0
- package/dist/{chunk-LTZ5WYOK.cjs → chunk-JCBDXEY2.cjs} +18 -2
- package/dist/chunk-JCBDXEY2.cjs.map +1 -0
- package/dist/{chunk-UYJQDDEE.cjs → chunk-MI2YXCK4.cjs} +14 -8
- package/dist/chunk-MI2YXCK4.cjs.map +1 -0
- package/dist/{chunk-VGHEKIJL.cjs → chunk-MOGK3U4A.cjs} +2 -2
- package/dist/{chunk-VGHEKIJL.cjs.map → chunk-MOGK3U4A.cjs.map} +1 -1
- package/dist/{chunk-E66UVONV.cjs → chunk-OUBUS74I.cjs} +24 -9
- package/dist/chunk-OUBUS74I.cjs.map +1 -0
- package/dist/{chunk-GMMCCIQO.cjs → chunk-RSBZITK3.cjs} +3 -3
- package/dist/{chunk-GMMCCIQO.cjs.map → chunk-RSBZITK3.cjs.map} +1 -1
- package/dist/{chunk-THFZSDIU.js → chunk-SXC4HPK6.js} +14 -8
- package/dist/chunk-SXC4HPK6.js.map +1 -0
- package/dist/{chunk-JMJM7DMM.cjs → chunk-TT3TQSCZ.cjs} +5 -5
- package/dist/{chunk-JMJM7DMM.cjs.map → chunk-TT3TQSCZ.cjs.map} +1 -1
- package/dist/{chunk-AT4ZQGEZ.cjs → chunk-YAURVGUK.cjs} +21 -2
- package/dist/chunk-YAURVGUK.cjs.map +1 -0
- package/dist/config-4TIHSNW6.js +6 -0
- package/dist/{config-6FB2BXMP.js.map → config-4TIHSNW6.js.map} +1 -1
- package/dist/{config-OCH7S4WK.cjs → config-XN2ETAJ3.cjs} +5 -5
- package/dist/{config-OCH7S4WK.cjs.map → config-XN2ETAJ3.cjs.map} +1 -1
- package/dist/{define-plugin-D_6D9vVZ.d.ts → define-plugin-DDe8a_bh.d.ts} +3 -0
- package/dist/{define-plugin-DMcvEy_C.d.cts → define-plugin-rjXmGOgu.d.cts} +3 -0
- package/dist/index.cjs +1220 -353
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +38 -3
- package/dist/index.d.ts +38 -3
- package/dist/index.js +895 -30
- package/dist/index.js.map +1 -1
- package/dist/middleware.cjs +35 -35
- package/dist/middleware.d.cts +4 -1
- package/dist/middleware.d.ts +4 -1
- package/dist/middleware.js +6 -6
- package/dist/migrations-JAHMI5MK.js +4 -0
- package/dist/{migrations-XQ6EX6HX.js.map → migrations-JAHMI5MK.js.map} +1 -1
- package/dist/migrations-KU4V6T73.cjs +13 -0
- package/dist/{migrations-ZD7Y5NUC.cjs.map → migrations-KU4V6T73.cjs.map} +1 -1
- package/dist/plugins.cjs +40 -40
- package/dist/plugins.d.cts +1 -1
- package/dist/plugins.d.ts +1 -1
- package/dist/plugins.js +3 -3
- package/dist/rbac-AORZ6O3N.cjs +14 -0
- package/dist/{rbac-7QZ4JZ2E.cjs.map → rbac-AORZ6O3N.cjs.map} +1 -1
- package/dist/rbac-P44772FP.js +5 -0
- package/dist/{rbac-Y43IEQOP.js.map → rbac-P44772FP.js.map} +1 -1
- package/dist/routes.cjs +31 -31
- package/dist/routes.js +11 -11
- package/dist/services.cjs +18 -18
- package/dist/services.d.cts +1 -1
- package/dist/services.d.ts +1 -1
- package/dist/services.js +2 -2
- package/dist/{telemetry-Cku1ax74.d.cts → telemetry-QFlTv9f8.d.cts} +1 -1
- package/dist/{telemetry-Cku1ax74.d.ts → telemetry-QFlTv9f8.d.ts} +1 -1
- package/dist/templates.cjs +17 -17
- package/dist/templates.js +3 -3
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils.cjs +12 -12
- package/dist/utils.d.cts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +2 -2
- package/package.json +5 -10
- package/dist/admin-documents-form.template-55V2ZGWT.js +0 -6
- package/dist/admin-documents-form.template-YNAVMJCV.cjs +0 -19
- package/dist/admin-layout-catalyst.template-3XZXDGF7.cjs +0 -21
- package/dist/admin-layout-catalyst.template-6UQGLCKI.js +0 -7
- package/dist/chunk-2MIYYAO4.js.map +0 -1
- package/dist/chunk-3TMTYJAJ.js.map +0 -1
- package/dist/chunk-4WMZGHIC.cjs.map +0 -1
- package/dist/chunk-AT4ZQGEZ.cjs.map +0 -1
- package/dist/chunk-BJROXF4N.js.map +0 -1
- package/dist/chunk-C3ZQP5NW.cjs.map +0 -1
- package/dist/chunk-CTYLCWMO.cjs.map +0 -1
- package/dist/chunk-DIBCKCUE.js.map +0 -1
- package/dist/chunk-DPLJYTHE.js.map +0 -1
- package/dist/chunk-E66UVONV.cjs.map +0 -1
- package/dist/chunk-IS54FPB7.cjs.map +0 -1
- package/dist/chunk-IXUHXTHW.cjs.map +0 -1
- package/dist/chunk-KS24NPPL.js.map +0 -1
- package/dist/chunk-LTZ5WYOK.cjs.map +0 -1
- package/dist/chunk-QZGABF2M.js.map +0 -1
- package/dist/chunk-RFBW5RRH.cjs.map +0 -1
- package/dist/chunk-SK5CHFJP.js.map +0 -1
- package/dist/chunk-THFZSDIU.js.map +0 -1
- package/dist/chunk-UYJQDDEE.cjs.map +0 -1
- package/dist/chunk-XXRR54AB.js.map +0 -1
- package/dist/config-6FB2BXMP.js +0 -6
- package/dist/migrations-XQ6EX6HX.js +0 -4
- package/dist/migrations-ZD7Y5NUC.cjs +0 -13
- package/dist/rbac-7QZ4JZ2E.cjs +0 -14
- package/dist/rbac-Y43IEQOP.js +0 -5
package/dist/index.cjs
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkRSBZITK3_cjs = require('./chunk-RSBZITK3.cjs');
|
|
4
|
+
var chunk6OA77UM7_cjs = require('./chunk-6OA77UM7.cjs');
|
|
5
5
|
require('./chunk-XWVDSM2L.cjs');
|
|
6
|
-
require('./chunk-
|
|
6
|
+
require('./chunk-TT3TQSCZ.cjs');
|
|
7
7
|
var chunk36Z3AKX3_cjs = require('./chunk-36Z3AKX3.cjs');
|
|
8
8
|
var chunkYA3TJ65D_cjs = require('./chunk-YA3TJ65D.cjs');
|
|
9
9
|
var chunkYP7GW2G5_cjs = require('./chunk-YP7GW2G5.cjs');
|
|
10
|
-
var
|
|
11
|
-
var
|
|
10
|
+
var chunkE7E3NL3Y_cjs = require('./chunk-E7E3NL3Y.cjs');
|
|
11
|
+
var chunkJCBDXEY2_cjs = require('./chunk-JCBDXEY2.cjs');
|
|
12
12
|
var chunkKIGVVO6N_cjs = require('./chunk-KIGVVO6N.cjs');
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
13
|
+
var chunkYAURVGUK_cjs = require('./chunk-YAURVGUK.cjs');
|
|
14
|
+
var chunkMOGK3U4A_cjs = require('./chunk-MOGK3U4A.cjs');
|
|
15
|
+
var chunkCN3T3TDI_cjs = require('./chunk-CN3T3TDI.cjs');
|
|
16
|
+
var chunkOUBUS74I_cjs = require('./chunk-OUBUS74I.cjs');
|
|
17
|
+
var chunkMI2YXCK4_cjs = require('./chunk-MI2YXCK4.cjs');
|
|
18
|
+
var chunkI7MIRRFJ_cjs = require('./chunk-I7MIRRFJ.cjs');
|
|
19
|
+
var chunkD6FWEYQE_cjs = require('./chunk-D6FWEYQE.cjs');
|
|
20
20
|
var chunkJ6JTWD2A_cjs = require('./chunk-J6JTWD2A.cjs');
|
|
21
|
-
var
|
|
21
|
+
var chunkDLTT7QZU_cjs = require('./chunk-DLTT7QZU.cjs');
|
|
22
22
|
var chunkRCQ2HIQD_cjs = require('./chunk-RCQ2HIQD.cjs');
|
|
23
23
|
require('./chunk-P3XDZL6Q.cjs');
|
|
24
|
-
var
|
|
24
|
+
var chunkBJ6NJL2E_cjs = require('./chunk-BJ6NJL2E.cjs');
|
|
25
25
|
var chunkMNWKYY5E_cjs = require('./chunk-MNWKYY5E.cjs');
|
|
26
26
|
var chunkQTFKZBLC_cjs = require('./chunk-QTFKZBLC.cjs');
|
|
27
27
|
require('./chunk-IGJUBJBW.cjs');
|
|
@@ -263,7 +263,7 @@ var DatabaseToolsService = class {
|
|
|
263
263
|
};
|
|
264
264
|
|
|
265
265
|
// src/templates/pages/admin-database-table.template.ts
|
|
266
|
-
|
|
266
|
+
chunkMI2YXCK4_cjs.init_admin_layout_catalyst_template();
|
|
267
267
|
function renderDatabaseTablePage(data) {
|
|
268
268
|
const totalPages = Math.ceil(data.totalRows / data.pageSize);
|
|
269
269
|
const startRow = (data.currentPage - 1) * data.pageSize + 1;
|
|
@@ -613,7 +613,7 @@ function renderDatabaseTablePage(data) {
|
|
|
613
613
|
user: data.user,
|
|
614
614
|
content: pageContent
|
|
615
615
|
};
|
|
616
|
-
return
|
|
616
|
+
return chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
617
617
|
}
|
|
618
618
|
function generatePageNumbers(currentPage, totalPages) {
|
|
619
619
|
const pages = [];
|
|
@@ -701,7 +701,7 @@ function formatCellValue(value, colName) {
|
|
|
701
701
|
// src/plugins/core-plugins/database-tools-plugin/admin-routes.ts
|
|
702
702
|
function createDatabaseToolsAdminRoutes() {
|
|
703
703
|
const router3 = new hono.Hono();
|
|
704
|
-
router3.use("*",
|
|
704
|
+
router3.use("*", chunkE7E3NL3Y_cjs.requireAuth());
|
|
705
705
|
router3.get("/api/stats", async (c) => {
|
|
706
706
|
try {
|
|
707
707
|
const user = c.get("user");
|
|
@@ -1110,7 +1110,7 @@ var SiteConfigService = class {
|
|
|
1110
1110
|
|
|
1111
1111
|
// src/plugins/core-plugins/email-plugin/routes/admin.ts
|
|
1112
1112
|
var adminRoutes = new hono.Hono();
|
|
1113
|
-
adminRoutes.use("*",
|
|
1113
|
+
adminRoutes.use("*", chunkE7E3NL3Y_cjs.requireAuth());
|
|
1114
1114
|
adminRoutes.post("/settings", async (c) => {
|
|
1115
1115
|
if (c.get("user")?.role !== "admin") {
|
|
1116
1116
|
return c.json({ error: "admin role required" }, 403);
|
|
@@ -1148,7 +1148,7 @@ adminRoutes.post("/test", async (c) => {
|
|
|
1148
1148
|
const { subject, html: html4, text } = renderTestEmail({ siteName });
|
|
1149
1149
|
try {
|
|
1150
1150
|
const settingsLoaded = await settings.load();
|
|
1151
|
-
const result = await
|
|
1151
|
+
const result = await chunk6OA77UM7_cjs.getEmailService().send({
|
|
1152
1152
|
to,
|
|
1153
1153
|
subject,
|
|
1154
1154
|
html: html4,
|
|
@@ -1230,7 +1230,7 @@ function makeOnRegistrationCompleted(env) {
|
|
|
1230
1230
|
siteName,
|
|
1231
1231
|
loginUrl: siteConfig.buildLoginUrl(siteUrl)
|
|
1232
1232
|
});
|
|
1233
|
-
const result = await
|
|
1233
|
+
const result = await chunk6OA77UM7_cjs.getEmailService().send({
|
|
1234
1234
|
to: user.email,
|
|
1235
1235
|
subject,
|
|
1236
1236
|
html: html4,
|
|
@@ -1304,7 +1304,7 @@ function makeOnPasswordResetRequested(env) {
|
|
|
1304
1304
|
expiresAt: Date.now() + DEFAULT_EXPIRY_MS,
|
|
1305
1305
|
siteName
|
|
1306
1306
|
});
|
|
1307
|
-
const result = await
|
|
1307
|
+
const result = await chunk6OA77UM7_cjs.getEmailService().send({
|
|
1308
1308
|
to: user.email,
|
|
1309
1309
|
subject,
|
|
1310
1310
|
html: html4,
|
|
@@ -1372,7 +1372,7 @@ function makeOnPasswordResetCompleted(env) {
|
|
|
1372
1372
|
supportEmail,
|
|
1373
1373
|
when: Date.now()
|
|
1374
1374
|
});
|
|
1375
|
-
const result = await
|
|
1375
|
+
const result = await chunk6OA77UM7_cjs.getEmailService().send({
|
|
1376
1376
|
to: user.email,
|
|
1377
1377
|
subject,
|
|
1378
1378
|
html: html4,
|
|
@@ -2113,7 +2113,7 @@ var CloudflareEmailProvider = class {
|
|
|
2113
2113
|
}
|
|
2114
2114
|
}
|
|
2115
2115
|
};
|
|
2116
|
-
var emailPluginV3 =
|
|
2116
|
+
var emailPluginV3 = chunkD6FWEYQE_cjs.definePlugin({
|
|
2117
2117
|
id: "email",
|
|
2118
2118
|
version: "1.0.0",
|
|
2119
2119
|
name: "Email",
|
|
@@ -2127,7 +2127,7 @@ var emailPluginV3 = chunk4WMZGHIC_cjs.definePlugin({
|
|
|
2127
2127
|
const db = env.DB;
|
|
2128
2128
|
if (db) {
|
|
2129
2129
|
try {
|
|
2130
|
-
const typeRegistry = new
|
|
2130
|
+
const typeRegistry = new chunkE7E3NL3Y_cjs.DocumentTypeRegistry(db);
|
|
2131
2131
|
await typeRegistry.register({
|
|
2132
2132
|
id: "email_log",
|
|
2133
2133
|
name: "email_log",
|
|
@@ -2142,7 +2142,7 @@ var emailPluginV3 = chunk4WMZGHIC_cjs.definePlugin({
|
|
|
2142
2142
|
} catch {
|
|
2143
2143
|
}
|
|
2144
2144
|
}
|
|
2145
|
-
if (!
|
|
2145
|
+
if (!chunk6OA77UM7_cjs.hasEmailService()) {
|
|
2146
2146
|
const settings = db ? await new EmailSettingsService(db).load() : {};
|
|
2147
2147
|
const envResendKey = typeof env.RESEND_API_KEY === "string" && env.RESEND_API_KEY ? env.RESEND_API_KEY : void 0;
|
|
2148
2148
|
const cfEmailBinding = env.EMAIL;
|
|
@@ -2160,7 +2160,7 @@ var emailPluginV3 = chunk4WMZGHIC_cjs.definePlugin({
|
|
|
2160
2160
|
} else {
|
|
2161
2161
|
provider = resolveEmailProvider({ env });
|
|
2162
2162
|
}
|
|
2163
|
-
|
|
2163
|
+
chunk6OA77UM7_cjs.setEmailService(new EmailService({ ...serviceOpts, provider }));
|
|
2164
2164
|
}
|
|
2165
2165
|
ctx.hooks.on("auth:registration:completed", makeOnRegistrationCompleted(env));
|
|
2166
2166
|
ctx.hooks.on("auth:password-reset:requested", makeOnPasswordResetRequested(env));
|
|
@@ -2171,7 +2171,7 @@ var emailPluginV3 = chunk4WMZGHIC_cjs.definePlugin({
|
|
|
2171
2171
|
var BATCH_SIZE = 100;
|
|
2172
2172
|
({
|
|
2173
2173
|
schema: zod.z.record(zod.z.string(), zod.z.unknown())});
|
|
2174
|
-
var emailReconciliationPlugin =
|
|
2174
|
+
var emailReconciliationPlugin = chunkD6FWEYQE_cjs.definePlugin({
|
|
2175
2175
|
id: "email-reconciliation",
|
|
2176
2176
|
version: "1.0.0",
|
|
2177
2177
|
description: "Hourly cron that backfills email delivery state from provider status APIs. Only active for providers that implement EmailProvider.reconcile().",
|
|
@@ -2192,11 +2192,11 @@ var emailReconciliationPlugin = chunk4WMZGHIC_cjs.definePlugin({
|
|
|
2192
2192
|
console.warn("[email-reconciliation] No DB binding in cron env \u2014 skipping.");
|
|
2193
2193
|
return;
|
|
2194
2194
|
}
|
|
2195
|
-
if (!
|
|
2195
|
+
if (!chunk6OA77UM7_cjs.hasEmailService()) {
|
|
2196
2196
|
console.warn("[email-reconciliation] EmailService not initialized \u2014 skipping.");
|
|
2197
2197
|
return;
|
|
2198
2198
|
}
|
|
2199
|
-
const emailService =
|
|
2199
|
+
const emailService = chunk6OA77UM7_cjs.getEmailService();
|
|
2200
2200
|
let rows = [];
|
|
2201
2201
|
try {
|
|
2202
2202
|
const result = await db.prepare(
|
|
@@ -2683,8 +2683,8 @@ function buildOtpApi() {
|
|
|
2683
2683
|
loginUrl: settings.loginUrl || "",
|
|
2684
2684
|
loginButtonText: settings.loginButtonText || ""
|
|
2685
2685
|
});
|
|
2686
|
-
if (
|
|
2687
|
-
const sent = await
|
|
2686
|
+
if (chunk6OA77UM7_cjs.hasEmailService()) {
|
|
2687
|
+
const sent = await chunk6OA77UM7_cjs.getEmailService().send({
|
|
2688
2688
|
to: normalizedEmail,
|
|
2689
2689
|
subject: `Your login code for ${siteName}`,
|
|
2690
2690
|
flow: "otp",
|
|
@@ -2786,21 +2786,21 @@ function buildOtpApi() {
|
|
|
2786
2786
|
error: "Account is deactivated"
|
|
2787
2787
|
}, 403);
|
|
2788
2788
|
}
|
|
2789
|
-
const tokenTtl = await
|
|
2790
|
-
const token = await
|
|
2789
|
+
const tokenTtl = await chunkE7E3NL3Y_cjs.getJwtExpirySecondsFromDb(db, c.env);
|
|
2790
|
+
const token = await chunkE7E3NL3Y_cjs.AuthManager.generateToken(user.id, user.email, user.role, c.env.JWT_SECRET, tokenTtl);
|
|
2791
2791
|
cookie.setCookie(c, "auth_token", token, {
|
|
2792
2792
|
httpOnly: true,
|
|
2793
2793
|
secure: true,
|
|
2794
2794
|
sameSite: "Strict",
|
|
2795
2795
|
maxAge: tokenTtl
|
|
2796
2796
|
});
|
|
2797
|
-
|
|
2797
|
+
chunk6OA77UM7_cjs.dispatchHookEvent(
|
|
2798
2798
|
c,
|
|
2799
2799
|
"auth:otp:verified",
|
|
2800
2800
|
{ user: { id: user.id, email: user.email, role: user.role } },
|
|
2801
2801
|
"fire-and-forget"
|
|
2802
2802
|
);
|
|
2803
|
-
const customData = await
|
|
2803
|
+
const customData = await chunk6OA77UM7_cjs.getCustomData(db, user.id);
|
|
2804
2804
|
const { is_active: _isActive, ...publicUser } = user;
|
|
2805
2805
|
return c.json({
|
|
2806
2806
|
success: true,
|
|
@@ -2845,7 +2845,7 @@ function buildOtpApi() {
|
|
|
2845
2845
|
});
|
|
2846
2846
|
return otpAPI;
|
|
2847
2847
|
}
|
|
2848
|
-
var otpLoginPlugin =
|
|
2848
|
+
var otpLoginPlugin = chunkD6FWEYQE_cjs.definePlugin({
|
|
2849
2849
|
id: "otp-login",
|
|
2850
2850
|
version: "1.0.0",
|
|
2851
2851
|
name: "OTP Login",
|
|
@@ -3243,15 +3243,15 @@ function buildOauthApi() {
|
|
|
3243
3243
|
if (!user || !user.is_active) {
|
|
3244
3244
|
return c.redirect("/auth/login?error=Account is deactivated");
|
|
3245
3245
|
}
|
|
3246
|
-
const tokenTtl2 = await
|
|
3247
|
-
const jwt2 = await
|
|
3246
|
+
const tokenTtl2 = await chunkE7E3NL3Y_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
|
|
3247
|
+
const jwt2 = await chunkE7E3NL3Y_cjs.AuthManager.generateToken(
|
|
3248
3248
|
user.id,
|
|
3249
3249
|
user.email,
|
|
3250
3250
|
user.role,
|
|
3251
3251
|
c.env.JWT_SECRET,
|
|
3252
3252
|
tokenTtl2
|
|
3253
3253
|
);
|
|
3254
|
-
|
|
3254
|
+
chunkE7E3NL3Y_cjs.AuthManager.setAuthCookie(c, jwt2, { sameSite: "Lax", maxAge: tokenTtl2 });
|
|
3255
3255
|
return c.redirect("/admin");
|
|
3256
3256
|
}
|
|
3257
3257
|
const existingUser = await oauthService.findUserByEmail(profile.email);
|
|
@@ -3268,15 +3268,15 @@ function buildOauthApi() {
|
|
|
3268
3268
|
tokenExpiresAt: tokenExpiresAt ?? void 0,
|
|
3269
3269
|
profileData: JSON.stringify(profile)
|
|
3270
3270
|
});
|
|
3271
|
-
const tokenTtl2 = await
|
|
3272
|
-
const jwt2 = await
|
|
3271
|
+
const tokenTtl2 = await chunkE7E3NL3Y_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
|
|
3272
|
+
const jwt2 = await chunkE7E3NL3Y_cjs.AuthManager.generateToken(
|
|
3273
3273
|
existingUser.id,
|
|
3274
3274
|
existingUser.email,
|
|
3275
3275
|
existingUser.role,
|
|
3276
3276
|
c.env.JWT_SECRET,
|
|
3277
3277
|
tokenTtl2
|
|
3278
3278
|
);
|
|
3279
|
-
|
|
3279
|
+
chunkE7E3NL3Y_cjs.AuthManager.setAuthCookie(c, jwt2, { sameSite: "Lax", maxAge: tokenTtl2 });
|
|
3280
3280
|
return c.redirect("/admin");
|
|
3281
3281
|
}
|
|
3282
3282
|
const newUserId = await oauthService.createUserFromOAuth(profile);
|
|
@@ -3289,15 +3289,15 @@ function buildOauthApi() {
|
|
|
3289
3289
|
tokenExpiresAt: tokenExpiresAt ?? void 0,
|
|
3290
3290
|
profileData: JSON.stringify(profile)
|
|
3291
3291
|
});
|
|
3292
|
-
const tokenTtl = await
|
|
3293
|
-
const jwt = await
|
|
3292
|
+
const tokenTtl = await chunkE7E3NL3Y_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
|
|
3293
|
+
const jwt = await chunkE7E3NL3Y_cjs.AuthManager.generateToken(
|
|
3294
3294
|
newUserId,
|
|
3295
3295
|
profile.email.toLowerCase(),
|
|
3296
3296
|
"viewer",
|
|
3297
3297
|
c.env.JWT_SECRET,
|
|
3298
3298
|
tokenTtl
|
|
3299
3299
|
);
|
|
3300
|
-
|
|
3300
|
+
chunkE7E3NL3Y_cjs.AuthManager.setAuthCookie(c, jwt, { sameSite: "Lax", maxAge: tokenTtl });
|
|
3301
3301
|
return c.redirect("/admin");
|
|
3302
3302
|
} catch (error) {
|
|
3303
3303
|
console.error("OAuth callback error:", error);
|
|
@@ -3392,7 +3392,7 @@ function buildOauthApi() {
|
|
|
3392
3392
|
});
|
|
3393
3393
|
return oauthAPI;
|
|
3394
3394
|
}
|
|
3395
|
-
var oauthProvidersPlugin =
|
|
3395
|
+
var oauthProvidersPlugin = chunkD6FWEYQE_cjs.definePlugin({
|
|
3396
3396
|
id: "oauth-providers",
|
|
3397
3397
|
version: "1.0.0",
|
|
3398
3398
|
name: "OAuth Providers",
|
|
@@ -3976,7 +3976,7 @@ var AISearchService = class {
|
|
|
3976
3976
|
*/
|
|
3977
3977
|
async detectNewCollections() {
|
|
3978
3978
|
try {
|
|
3979
|
-
const allCollections =
|
|
3979
|
+
const allCollections = chunkYAURVGUK_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal).map((r) => ({
|
|
3980
3980
|
id: r.id,
|
|
3981
3981
|
name: r.name,
|
|
3982
3982
|
display_name: r.displayName,
|
|
@@ -4028,7 +4028,7 @@ var AISearchService = class {
|
|
|
4028
4028
|
*/
|
|
4029
4029
|
async getAllCollections() {
|
|
4030
4030
|
try {
|
|
4031
|
-
const allCollections =
|
|
4031
|
+
const allCollections = chunkYAURVGUK_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal).sort((a, b) => a.displayName.localeCompare(b.displayName)).map((r) => ({
|
|
4032
4032
|
id: r.id,
|
|
4033
4033
|
name: r.name,
|
|
4034
4034
|
display_name: r.displayName,
|
|
@@ -4367,7 +4367,7 @@ var IndexManager = class {
|
|
|
4367
4367
|
*/
|
|
4368
4368
|
async indexCollection(collectionId) {
|
|
4369
4369
|
try {
|
|
4370
|
-
const registry =
|
|
4370
|
+
const registry = chunkYAURVGUK_cjs.getCollectionRegistry();
|
|
4371
4371
|
const record = registry.getById(collectionId) ?? registry.getByName(collectionId);
|
|
4372
4372
|
if (!record) {
|
|
4373
4373
|
throw new Error(`Collection ${collectionId} not found`);
|
|
@@ -4983,7 +4983,7 @@ function renderSettingsPage(data) {
|
|
|
4983
4983
|
}, 30000);
|
|
4984
4984
|
</script>
|
|
4985
4985
|
`;
|
|
4986
|
-
return
|
|
4986
|
+
return chunkOUBUS74I_cjs.renderAdminLayout({
|
|
4987
4987
|
title: "AI Search Settings",
|
|
4988
4988
|
pageTitle: "AI Search Settings",
|
|
4989
4989
|
currentPath: "/admin/plugins/ai-search/settings",
|
|
@@ -4994,7 +4994,7 @@ function renderSettingsPage(data) {
|
|
|
4994
4994
|
|
|
4995
4995
|
// src/plugins/core-plugins/ai-search-plugin/routes/admin.ts
|
|
4996
4996
|
var adminRoutes2 = new hono.Hono();
|
|
4997
|
-
adminRoutes2.use("*",
|
|
4997
|
+
adminRoutes2.use("*", chunkE7E3NL3Y_cjs.requireAuth());
|
|
4998
4998
|
adminRoutes2.get("/", async (c) => {
|
|
4999
4999
|
try {
|
|
5000
5000
|
const user = c.get("user");
|
|
@@ -5235,7 +5235,7 @@ var manifest_default = {
|
|
|
5235
5235
|
author: "SonicJS"};
|
|
5236
5236
|
|
|
5237
5237
|
// src/plugins/core-plugins/ai-search-plugin/index.ts
|
|
5238
|
-
var aiSearchPlugin =
|
|
5238
|
+
var aiSearchPlugin = chunkD6FWEYQE_cjs.definePlugin({
|
|
5239
5239
|
id: manifest_default.id,
|
|
5240
5240
|
version: manifest_default.version,
|
|
5241
5241
|
name: manifest_default.name,
|
|
@@ -5288,7 +5288,7 @@ var SecurityAuditService = class {
|
|
|
5288
5288
|
constructor(db, settings = DEFAULT_SETTINGS2) {
|
|
5289
5289
|
this.db = db;
|
|
5290
5290
|
this.settings = settings;
|
|
5291
|
-
this.docsService = new
|
|
5291
|
+
this.docsService = new chunkJCBDXEY2_cjs.DocumentsService(db, {
|
|
5292
5292
|
queryableFields: QUERYABLE_FIELDS,
|
|
5293
5293
|
maxVersionsPerRoot: 1,
|
|
5294
5294
|
tenantId: TENANT
|
|
@@ -5536,7 +5536,7 @@ function rowToEvent(row) {
|
|
|
5536
5536
|
}
|
|
5537
5537
|
|
|
5538
5538
|
// src/plugins/core-plugins/security-audit-plugin/components/dashboard-page.ts
|
|
5539
|
-
|
|
5539
|
+
chunkMI2YXCK4_cjs.init_admin_layout_catalyst_template();
|
|
5540
5540
|
function formatTimestamp(ts) {
|
|
5541
5541
|
const date = new Date(ts);
|
|
5542
5542
|
const now = Date.now();
|
|
@@ -5735,11 +5735,11 @@ function renderSecurityDashboard(data) {
|
|
|
5735
5735
|
version,
|
|
5736
5736
|
dynamicMenuItems
|
|
5737
5737
|
};
|
|
5738
|
-
return
|
|
5738
|
+
return chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
5739
5739
|
}
|
|
5740
5740
|
|
|
5741
5741
|
// src/plugins/core-plugins/security-audit-plugin/components/event-log-page.ts
|
|
5742
|
-
|
|
5742
|
+
chunkMI2YXCK4_cjs.init_admin_layout_catalyst_template();
|
|
5743
5743
|
function formatTimestamp2(ts) {
|
|
5744
5744
|
const date = new Date(ts);
|
|
5745
5745
|
return date.toLocaleDateString("en-US", {
|
|
@@ -5946,11 +5946,11 @@ function renderEventLogPage(data) {
|
|
|
5946
5946
|
version,
|
|
5947
5947
|
dynamicMenuItems
|
|
5948
5948
|
};
|
|
5949
|
-
return
|
|
5949
|
+
return chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
5950
5950
|
}
|
|
5951
5951
|
|
|
5952
5952
|
// src/plugins/core-plugins/security-audit-plugin/components/settings-page.ts
|
|
5953
|
-
|
|
5953
|
+
chunkMI2YXCK4_cjs.init_admin_layout_catalyst_template();
|
|
5954
5954
|
function renderSecuritySettingsPage(data) {
|
|
5955
5955
|
const { settings, user, version, message, dynamicMenuItems } = data;
|
|
5956
5956
|
const content2 = `
|
|
@@ -6103,12 +6103,12 @@ function renderSecuritySettingsPage(data) {
|
|
|
6103
6103
|
version,
|
|
6104
6104
|
dynamicMenuItems
|
|
6105
6105
|
};
|
|
6106
|
-
return
|
|
6106
|
+
return chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
6107
6107
|
}
|
|
6108
6108
|
|
|
6109
6109
|
// src/plugins/core-plugins/security-audit-plugin/routes/admin.ts
|
|
6110
6110
|
var adminRoutes3 = new hono.Hono();
|
|
6111
|
-
adminRoutes3.use("*",
|
|
6111
|
+
adminRoutes3.use("*", chunkE7E3NL3Y_cjs.requireAuth());
|
|
6112
6112
|
adminRoutes3.use("*", async (c, next) => {
|
|
6113
6113
|
const user = c.get("user");
|
|
6114
6114
|
if (user?.role !== "admin") {
|
|
@@ -6118,7 +6118,7 @@ adminRoutes3.use("*", async (c, next) => {
|
|
|
6118
6118
|
});
|
|
6119
6119
|
async function getSettings(db) {
|
|
6120
6120
|
try {
|
|
6121
|
-
const pluginService = new
|
|
6121
|
+
const pluginService = new chunkYAURVGUK_cjs.PluginService(db);
|
|
6122
6122
|
const plugin2 = await pluginService.getPlugin("security-audit");
|
|
6123
6123
|
if (plugin2?.settings) {
|
|
6124
6124
|
const settings = typeof plugin2.settings === "string" ? JSON.parse(plugin2.settings) : plugin2.settings;
|
|
@@ -6223,7 +6223,7 @@ adminRoutes3.post("/settings", async (c) => {
|
|
|
6223
6223
|
autoPurge: body["retention.autoPurge"] === "true"
|
|
6224
6224
|
}
|
|
6225
6225
|
};
|
|
6226
|
-
const pluginService = new
|
|
6226
|
+
const pluginService = new chunkYAURVGUK_cjs.PluginService(db);
|
|
6227
6227
|
await pluginService.updatePluginSettings("security-audit", settings);
|
|
6228
6228
|
if (c.req.header("HX-Request")) {
|
|
6229
6229
|
return c.json({ success: true });
|
|
@@ -6385,7 +6385,7 @@ var BruteForceDetector = class {
|
|
|
6385
6385
|
|
|
6386
6386
|
// src/plugins/core-plugins/security-audit-plugin/routes/api.ts
|
|
6387
6387
|
var apiRoutes2 = new hono.Hono();
|
|
6388
|
-
apiRoutes2.use("*",
|
|
6388
|
+
apiRoutes2.use("*", chunkE7E3NL3Y_cjs.requireAuth());
|
|
6389
6389
|
apiRoutes2.use("*", async (c, next) => {
|
|
6390
6390
|
const user = c.get("user");
|
|
6391
6391
|
if (user?.role !== "admin") {
|
|
@@ -6395,7 +6395,7 @@ apiRoutes2.use("*", async (c, next) => {
|
|
|
6395
6395
|
});
|
|
6396
6396
|
async function getSettings2(db) {
|
|
6397
6397
|
try {
|
|
6398
|
-
const pluginService = new
|
|
6398
|
+
const pluginService = new chunkYAURVGUK_cjs.PluginService(db);
|
|
6399
6399
|
const plugin2 = await pluginService.getPlugin("security-audit");
|
|
6400
6400
|
if (plugin2?.settings) {
|
|
6401
6401
|
const settings = typeof plugin2.settings === "string" ? JSON.parse(plugin2.settings) : plugin2.settings;
|
|
@@ -6543,7 +6543,7 @@ function generateFingerprint(ip, userAgent) {
|
|
|
6543
6543
|
}
|
|
6544
6544
|
async function getPluginSettings(db) {
|
|
6545
6545
|
try {
|
|
6546
|
-
const pluginService = new
|
|
6546
|
+
const pluginService = new chunkYAURVGUK_cjs.PluginService(db);
|
|
6547
6547
|
const plugin2 = await pluginService.getPlugin("security-audit");
|
|
6548
6548
|
if (plugin2?.settings) {
|
|
6549
6549
|
const settings = typeof plugin2.settings === "string" ? JSON.parse(plugin2.settings) : plugin2.settings;
|
|
@@ -6774,7 +6774,7 @@ async function logAuthEvent(c, db, settings, ip, userAgent, countryCode, fingerp
|
|
|
6774
6774
|
|
|
6775
6775
|
// src/plugins/core-plugins/security-audit-plugin/index.ts
|
|
6776
6776
|
var SECURITY_ICON = `<svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"/></svg>`;
|
|
6777
|
-
var securityAuditPlugin =
|
|
6777
|
+
var securityAuditPlugin = chunkD6FWEYQE_cjs.definePlugin({
|
|
6778
6778
|
id: "security-audit",
|
|
6779
6779
|
version: "1.0.0",
|
|
6780
6780
|
name: "Security Audit",
|
|
@@ -6824,7 +6824,7 @@ var ApiKeyService = class {
|
|
|
6824
6824
|
db;
|
|
6825
6825
|
tenantId;
|
|
6826
6826
|
docService() {
|
|
6827
|
-
return new
|
|
6827
|
+
return new chunkJCBDXEY2_cjs.DocumentsService(this.db, {
|
|
6828
6828
|
queryableFields: API_KEY_QUERYABLE,
|
|
6829
6829
|
tenantId: this.tenantId,
|
|
6830
6830
|
maxVersionsPerRoot: 1
|
|
@@ -6850,7 +6850,7 @@ var ApiKeyService = class {
|
|
|
6850
6850
|
const prefix = secret.slice(0, DISPLAY_PREFIX_LEN);
|
|
6851
6851
|
const expiresAt = input.expiresAt ?? null;
|
|
6852
6852
|
const doc = await this.docService().create(
|
|
6853
|
-
|
|
6853
|
+
chunk6OA77UM7_cjs.createDocumentSchema.parse({
|
|
6854
6854
|
typeId: "api_key",
|
|
6855
6855
|
tenantId: this.tenantId,
|
|
6856
6856
|
title: name,
|
|
@@ -6943,7 +6943,7 @@ var ApiKeyService = class {
|
|
|
6943
6943
|
};
|
|
6944
6944
|
|
|
6945
6945
|
// src/plugins/core-plugins/api-keys-plugin/components/keys-page.ts
|
|
6946
|
-
|
|
6946
|
+
chunkMI2YXCK4_cjs.init_admin_layout_catalyst_template();
|
|
6947
6947
|
function fmtDate(ms) {
|
|
6948
6948
|
if (!ms) return "\u2014";
|
|
6949
6949
|
try {
|
|
@@ -7144,7 +7144,7 @@ function renderApiKeysPage(data) {
|
|
|
7144
7144
|
version,
|
|
7145
7145
|
dynamicMenuItems
|
|
7146
7146
|
};
|
|
7147
|
-
return
|
|
7147
|
+
return chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
7148
7148
|
}
|
|
7149
7149
|
|
|
7150
7150
|
// src/plugins/core-plugins/api-keys-plugin/types.ts
|
|
@@ -7163,7 +7163,7 @@ var createSchema = zod.z.object({
|
|
|
7163
7163
|
});
|
|
7164
7164
|
async function getSettings3(db) {
|
|
7165
7165
|
try {
|
|
7166
|
-
const plugin2 = await new
|
|
7166
|
+
const plugin2 = await new chunkYAURVGUK_cjs.PluginService(db).getPlugin("api-keys");
|
|
7167
7167
|
if (plugin2?.settings) {
|
|
7168
7168
|
const s = typeof plugin2.settings === "string" ? JSON.parse(plugin2.settings) : plugin2.settings;
|
|
7169
7169
|
return { ...DEFAULT_SETTINGS3, ...s };
|
|
@@ -7172,7 +7172,7 @@ async function getSettings3(db) {
|
|
|
7172
7172
|
}
|
|
7173
7173
|
return DEFAULT_SETTINGS3;
|
|
7174
7174
|
}
|
|
7175
|
-
adminRoutes4.use("*",
|
|
7175
|
+
adminRoutes4.use("*", chunkE7E3NL3Y_cjs.requireAuth());
|
|
7176
7176
|
adminRoutes4.use("*", async (c, next) => {
|
|
7177
7177
|
const user = c.get("user");
|
|
7178
7178
|
if (user?.role !== "admin") {
|
|
@@ -7257,7 +7257,7 @@ function apiKeyAuthMiddleware() {
|
|
|
7257
7257
|
|
|
7258
7258
|
// src/plugins/core-plugins/api-keys-plugin/index.ts
|
|
7259
7259
|
var KEY_ICON = `<svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z"/></svg>`;
|
|
7260
|
-
var apiKeysPlugin =
|
|
7260
|
+
var apiKeysPlugin = chunkD6FWEYQE_cjs.definePlugin({
|
|
7261
7261
|
id: "api-keys",
|
|
7262
7262
|
version: "1.0.0-beta.1",
|
|
7263
7263
|
name: "API Keys",
|
|
@@ -7643,7 +7643,7 @@ var StripeEventService = class {
|
|
|
7643
7643
|
};
|
|
7644
7644
|
|
|
7645
7645
|
// src/plugins/core-plugins/stripe-plugin/components/subscriptions-page.ts
|
|
7646
|
-
|
|
7646
|
+
chunkMI2YXCK4_cjs.init_admin_layout_catalyst_template();
|
|
7647
7647
|
|
|
7648
7648
|
// src/plugins/core-plugins/stripe-plugin/components/tab-bar.ts
|
|
7649
7649
|
var TABS = [
|
|
@@ -7776,7 +7776,7 @@ function renderSubscriptionsPage(data) {
|
|
|
7776
7776
|
version,
|
|
7777
7777
|
dynamicMenuItems
|
|
7778
7778
|
};
|
|
7779
|
-
return
|
|
7779
|
+
return chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
7780
7780
|
}
|
|
7781
7781
|
function statsCard(label, value, colorClass) {
|
|
7782
7782
|
return `
|
|
@@ -7856,7 +7856,7 @@ function renderPagination2(page, totalPages, status) {
|
|
|
7856
7856
|
}
|
|
7857
7857
|
|
|
7858
7858
|
// src/plugins/core-plugins/stripe-plugin/components/events-page.ts
|
|
7859
|
-
|
|
7859
|
+
chunkMI2YXCK4_cjs.init_admin_layout_catalyst_template();
|
|
7860
7860
|
function renderEventsPage(data) {
|
|
7861
7861
|
const { events, stats, types, filters, user, version, dynamicMenuItems } = data;
|
|
7862
7862
|
const content2 = `
|
|
@@ -7929,7 +7929,7 @@ function renderEventsPage(data) {
|
|
|
7929
7929
|
version,
|
|
7930
7930
|
dynamicMenuItems
|
|
7931
7931
|
};
|
|
7932
|
-
return
|
|
7932
|
+
return chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
7933
7933
|
}
|
|
7934
7934
|
function eventStatsCard(label, value, colorClass) {
|
|
7935
7935
|
return `
|
|
@@ -8028,7 +8028,7 @@ var DEFAULT_SETTINGS4 = {
|
|
|
8028
8028
|
|
|
8029
8029
|
// src/plugins/core-plugins/stripe-plugin/routes/admin.ts
|
|
8030
8030
|
var adminRoutes5 = new hono.Hono();
|
|
8031
|
-
adminRoutes5.use("*",
|
|
8031
|
+
adminRoutes5.use("*", chunkE7E3NL3Y_cjs.requireAuth());
|
|
8032
8032
|
adminRoutes5.use("*", async (c, next) => {
|
|
8033
8033
|
const user = c.get("user");
|
|
8034
8034
|
if (user?.role !== "admin") {
|
|
@@ -8038,7 +8038,7 @@ adminRoutes5.use("*", async (c, next) => {
|
|
|
8038
8038
|
});
|
|
8039
8039
|
async function getSettings4(db) {
|
|
8040
8040
|
try {
|
|
8041
|
-
const pluginService = new
|
|
8041
|
+
const pluginService = new chunkYAURVGUK_cjs.PluginService(db);
|
|
8042
8042
|
const plugin2 = await pluginService.getPlugin("stripe");
|
|
8043
8043
|
if (plugin2?.settings) {
|
|
8044
8044
|
const settings = typeof plugin2.settings === "string" ? JSON.parse(plugin2.settings) : plugin2.settings;
|
|
@@ -8101,7 +8101,7 @@ adminRoutes5.get("/settings", async (c) => {
|
|
|
8101
8101
|
const db = c.env.DB;
|
|
8102
8102
|
const user = c.get("user");
|
|
8103
8103
|
const settings = await getSettings4(db);
|
|
8104
|
-
const { renderAdminLayoutCatalyst: renderAdminLayoutCatalyst2 } = await import('./admin-layout-catalyst.template-
|
|
8104
|
+
const { renderAdminLayoutCatalyst: renderAdminLayoutCatalyst2 } = await import('./admin-layout-catalyst.template-MOQ3BBXA.cjs');
|
|
8105
8105
|
const content2 = `
|
|
8106
8106
|
<div>
|
|
8107
8107
|
<div class="mb-6">
|
|
@@ -8361,7 +8361,7 @@ function timingSafeEqual(a, b) {
|
|
|
8361
8361
|
var apiRoutes3 = new hono.Hono();
|
|
8362
8362
|
async function getSettings5(db) {
|
|
8363
8363
|
try {
|
|
8364
|
-
const pluginService = new
|
|
8364
|
+
const pluginService = new chunkYAURVGUK_cjs.PluginService(db);
|
|
8365
8365
|
const plugin2 = await pluginService.getPlugin("stripe");
|
|
8366
8366
|
if (plugin2?.settings) {
|
|
8367
8367
|
const settings = typeof plugin2.settings === "string" ? JSON.parse(plugin2.settings) : plugin2.settings;
|
|
@@ -8512,7 +8512,7 @@ apiRoutes3.post("/webhook", async (c) => {
|
|
|
8512
8512
|
}
|
|
8513
8513
|
return c.json({ received: true });
|
|
8514
8514
|
});
|
|
8515
|
-
apiRoutes3.post("/create-checkout-session",
|
|
8515
|
+
apiRoutes3.post("/create-checkout-session", chunkE7E3NL3Y_cjs.requireAuth(), async (c) => {
|
|
8516
8516
|
const db = c.env.DB;
|
|
8517
8517
|
const user = c.get("user");
|
|
8518
8518
|
if (!user) return c.json({ error: "Unauthorized" }, 401);
|
|
@@ -8552,7 +8552,7 @@ apiRoutes3.post("/create-checkout-session", chunkIS54FPB7_cjs.requireAuth(), asy
|
|
|
8552
8552
|
});
|
|
8553
8553
|
return c.json({ sessionId: session.id, url: session.url });
|
|
8554
8554
|
});
|
|
8555
|
-
apiRoutes3.get("/subscription",
|
|
8555
|
+
apiRoutes3.get("/subscription", chunkE7E3NL3Y_cjs.requireAuth(), async (c) => {
|
|
8556
8556
|
const user = c.get("user");
|
|
8557
8557
|
if (!user) return c.json({ error: "Unauthorized" }, 401);
|
|
8558
8558
|
const db = c.env.DB;
|
|
@@ -8564,7 +8564,7 @@ apiRoutes3.get("/subscription", chunkIS54FPB7_cjs.requireAuth(), async (c) => {
|
|
|
8564
8564
|
}
|
|
8565
8565
|
return c.json({ subscription });
|
|
8566
8566
|
});
|
|
8567
|
-
apiRoutes3.get("/subscriptions",
|
|
8567
|
+
apiRoutes3.get("/subscriptions", chunkE7E3NL3Y_cjs.requireAuth(), async (c) => {
|
|
8568
8568
|
const user = c.get("user");
|
|
8569
8569
|
if (user?.role !== "admin") return c.json({ error: "Access denied" }, 403);
|
|
8570
8570
|
const db = c.env.DB;
|
|
@@ -8580,7 +8580,7 @@ apiRoutes3.get("/subscriptions", chunkIS54FPB7_cjs.requireAuth(), async (c) => {
|
|
|
8580
8580
|
const result = await subscriptionService.list(filters);
|
|
8581
8581
|
return c.json(result);
|
|
8582
8582
|
});
|
|
8583
|
-
apiRoutes3.get("/stats",
|
|
8583
|
+
apiRoutes3.get("/stats", chunkE7E3NL3Y_cjs.requireAuth(), async (c) => {
|
|
8584
8584
|
const user = c.get("user");
|
|
8585
8585
|
if (user?.role !== "admin") return c.json({ error: "Access denied" }, 403);
|
|
8586
8586
|
const db = c.env.DB;
|
|
@@ -8589,7 +8589,7 @@ apiRoutes3.get("/stats", chunkIS54FPB7_cjs.requireAuth(), async (c) => {
|
|
|
8589
8589
|
const stats = await subscriptionService.getStats();
|
|
8590
8590
|
return c.json(stats);
|
|
8591
8591
|
});
|
|
8592
|
-
apiRoutes3.post("/sync-subscriptions",
|
|
8592
|
+
apiRoutes3.post("/sync-subscriptions", chunkE7E3NL3Y_cjs.requireAuth(), async (c) => {
|
|
8593
8593
|
const user = c.get("user");
|
|
8594
8594
|
if (user?.role !== "admin") return c.json({ error: "Access denied" }, 403);
|
|
8595
8595
|
const db = c.env.DB;
|
|
@@ -8637,7 +8637,7 @@ apiRoutes3.post("/sync-subscriptions", chunkIS54FPB7_cjs.requireAuth(), async (c
|
|
|
8637
8637
|
}, 500);
|
|
8638
8638
|
}
|
|
8639
8639
|
});
|
|
8640
|
-
apiRoutes3.get("/events",
|
|
8640
|
+
apiRoutes3.get("/events", chunkE7E3NL3Y_cjs.requireAuth(), async (c) => {
|
|
8641
8641
|
const user = c.get("user");
|
|
8642
8642
|
if (user?.role !== "admin") return c.json({ error: "Access denied" }, 403);
|
|
8643
8643
|
const db = c.env.DB;
|
|
@@ -8660,7 +8660,7 @@ apiRoutes3.get("/events", chunkIS54FPB7_cjs.requireAuth(), async (c) => {
|
|
|
8660
8660
|
|
|
8661
8661
|
// src/plugins/core-plugins/stripe-plugin/index.ts
|
|
8662
8662
|
var STRIPE_ICON = `<svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z"/></svg>`;
|
|
8663
|
-
var stripePlugin =
|
|
8663
|
+
var stripePlugin = chunkD6FWEYQE_cjs.definePlugin({
|
|
8664
8664
|
id: "stripe",
|
|
8665
8665
|
version: "1.0.0",
|
|
8666
8666
|
name: "Stripe",
|
|
@@ -8681,7 +8681,7 @@ var stripePlugin = chunk4WMZGHIC_cjs.definePlugin({
|
|
|
8681
8681
|
});
|
|
8682
8682
|
|
|
8683
8683
|
// src/templates/pages/admin-forms-list.template.ts
|
|
8684
|
-
|
|
8684
|
+
chunkMI2YXCK4_cjs.init_admin_layout_catalyst_template();
|
|
8685
8685
|
function renderFormsListPage(data) {
|
|
8686
8686
|
const tableData = {
|
|
8687
8687
|
tableId: "forms-table",
|
|
@@ -8933,7 +8933,7 @@ function renderFormsListPage(data) {
|
|
|
8933
8933
|
|
|
8934
8934
|
<!-- Forms Table -->
|
|
8935
8935
|
<div class="bg-white dark:bg-zinc-900 rounded-lg border border-zinc-950/5 dark:border-white/10 overflow-hidden">
|
|
8936
|
-
${
|
|
8936
|
+
${chunk6OA77UM7_cjs.renderTable(tableData)}
|
|
8937
8937
|
</div>
|
|
8938
8938
|
</div>
|
|
8939
8939
|
`;
|
|
@@ -8943,11 +8943,11 @@ function renderFormsListPage(data) {
|
|
|
8943
8943
|
user: data.user,
|
|
8944
8944
|
version: data.version
|
|
8945
8945
|
};
|
|
8946
|
-
return
|
|
8946
|
+
return chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
8947
8947
|
}
|
|
8948
8948
|
|
|
8949
8949
|
// src/templates/pages/admin-forms-builder.template.ts
|
|
8950
|
-
|
|
8950
|
+
chunkMI2YXCK4_cjs.init_admin_layout_catalyst_template();
|
|
8951
8951
|
function getTurnstileComponentScript() {
|
|
8952
8952
|
return `
|
|
8953
8953
|
(function() {
|
|
@@ -10160,11 +10160,11 @@ ${getTurnstileComponentScript()}
|
|
|
10160
10160
|
user: data.user,
|
|
10161
10161
|
version: data.version
|
|
10162
10162
|
};
|
|
10163
|
-
return
|
|
10163
|
+
return chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
10164
10164
|
}
|
|
10165
10165
|
|
|
10166
10166
|
// src/templates/pages/admin-forms-create.template.ts
|
|
10167
|
-
|
|
10167
|
+
chunkMI2YXCK4_cjs.init_admin_layout_catalyst_template();
|
|
10168
10168
|
function renderFormCreatePage(data) {
|
|
10169
10169
|
const pageContent = `
|
|
10170
10170
|
<div class="max-w-3xl mx-auto">
|
|
@@ -10357,13 +10357,13 @@ function renderFormCreatePage(data) {
|
|
|
10357
10357
|
user: data.user,
|
|
10358
10358
|
version: data.version
|
|
10359
10359
|
};
|
|
10360
|
-
return
|
|
10360
|
+
return chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
10361
10361
|
}
|
|
10362
10362
|
|
|
10363
10363
|
// src/routes/admin-forms.ts
|
|
10364
10364
|
var isTableMissing = (err) => String(err?.message ?? err?.cause?.message ?? "").includes("no such table: forms");
|
|
10365
10365
|
var adminFormsRoutes = new hono.Hono();
|
|
10366
|
-
adminFormsRoutes.use("*",
|
|
10366
|
+
adminFormsRoutes.use("*", chunkE7E3NL3Y_cjs.requireAuth());
|
|
10367
10367
|
adminFormsRoutes.get("/", async (c) => {
|
|
10368
10368
|
try {
|
|
10369
10369
|
const user = c.get("user");
|
|
@@ -10536,7 +10536,7 @@ adminFormsRoutes.get("/:id/builder", async (c) => {
|
|
|
10536
10536
|
if (!form) {
|
|
10537
10537
|
return c.html("<p>Form not found</p>", 404);
|
|
10538
10538
|
}
|
|
10539
|
-
const turnstileService = new
|
|
10539
|
+
const turnstileService = new chunkI7MIRRFJ_cjs.TurnstileService(db);
|
|
10540
10540
|
const turnstileSettings = await turnstileService.getSettings();
|
|
10541
10541
|
const pageData = {
|
|
10542
10542
|
id: form.id,
|
|
@@ -10705,7 +10705,7 @@ publicFormsRoutes.get("/:identifier/turnstile-config", async (c) => {
|
|
|
10705
10705
|
if (!form) {
|
|
10706
10706
|
return c.json({ error: "Form not found" }, 404);
|
|
10707
10707
|
}
|
|
10708
|
-
const turnstileService = new
|
|
10708
|
+
const turnstileService = new chunkI7MIRRFJ_cjs.TurnstileService(db);
|
|
10709
10709
|
const globalSettings = await turnstileService.getSettings();
|
|
10710
10710
|
const formSettings = form.turnstile_settings ? JSON.parse(form.turnstile_settings) : { inherit: true };
|
|
10711
10711
|
const enabled = form.turnstile_enabled === 1 || formSettings.inherit && globalSettings?.enabled;
|
|
@@ -11135,7 +11135,7 @@ publicFormsRoutes.post("/:identifier/submit", async (c) => {
|
|
|
11135
11135
|
const turnstileEnabled = form.turnstile_enabled === 1;
|
|
11136
11136
|
const turnstileSettings = form.turnstile_settings ? JSON.parse(form.turnstile_settings) : { inherit: true };
|
|
11137
11137
|
if (turnstileEnabled || turnstileSettings.inherit) {
|
|
11138
|
-
const turnstileService = new
|
|
11138
|
+
const turnstileService = new chunkI7MIRRFJ_cjs.TurnstileService(db);
|
|
11139
11139
|
const globalEnabled = await turnstileService.isEnabled();
|
|
11140
11140
|
if (globalEnabled || turnstileEnabled) {
|
|
11141
11141
|
const turnstileToken = body.data?.turnstile || body.turnstile;
|
|
@@ -11197,7 +11197,7 @@ publicFormsRoutes.post("/:identifier/submit", async (c) => {
|
|
|
11197
11197
|
});
|
|
11198
11198
|
|
|
11199
11199
|
// src/plugins/core-plugins/forms-plugin/index.ts
|
|
11200
|
-
var formsPlugin =
|
|
11200
|
+
var formsPlugin = chunkD6FWEYQE_cjs.definePlugin({
|
|
11201
11201
|
id: "forms",
|
|
11202
11202
|
version: "1.0.0",
|
|
11203
11203
|
name: "Forms",
|
|
@@ -11215,9 +11215,9 @@ var formsPlugin = chunk4WMZGHIC_cjs.definePlugin({
|
|
|
11215
11215
|
activate: async () => console.info("\u2705 Forms plugin activated"),
|
|
11216
11216
|
deactivate: async () => console.info("\u274C Forms plugin deactivated")
|
|
11217
11217
|
});
|
|
11218
|
-
|
|
11218
|
+
chunkMI2YXCK4_cjs.init_admin_layout_catalyst_template();
|
|
11219
11219
|
var adminRbacRoutes = new hono.Hono();
|
|
11220
|
-
adminRbacRoutes.use("*",
|
|
11220
|
+
adminRbacRoutes.use("*", chunkE7E3NL3Y_cjs.requireRbac("rbac", "manage"));
|
|
11221
11221
|
var esc = (s) => String(s).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
11222
11222
|
var TABS2 = `
|
|
11223
11223
|
<div class="border-b border-zinc-950/10 dark:border-white/10 mb-6">
|
|
@@ -11227,7 +11227,7 @@ var TABS2 = `
|
|
|
11227
11227
|
</nav>
|
|
11228
11228
|
</div>`;
|
|
11229
11229
|
adminRbacRoutes.get("/", async (c) => {
|
|
11230
|
-
const rbac = new
|
|
11230
|
+
const rbac = new chunkJCBDXEY2_cjs.RbacService(c.env.DB);
|
|
11231
11231
|
const [roles, verbs, resources, grants] = await Promise.all([
|
|
11232
11232
|
rbac.getRoles(),
|
|
11233
11233
|
rbac.getVerbs(),
|
|
@@ -11521,11 +11521,11 @@ adminRbacRoutes.get("/", async (c) => {
|
|
|
11521
11521
|
</script>`;
|
|
11522
11522
|
const u = c.get("user");
|
|
11523
11523
|
return c.html(
|
|
11524
|
-
|
|
11524
|
+
chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst({
|
|
11525
11525
|
title: "Roles & Permissions",
|
|
11526
11526
|
pageTitle: "Roles & Permissions",
|
|
11527
11527
|
currentPath: "/admin/users",
|
|
11528
|
-
version:
|
|
11528
|
+
version: chunkBJ6NJL2E_cjs.getCoreVersion(),
|
|
11529
11529
|
user: u ? { name: u.email || "Admin", email: u.email || "", role: u.role || "admin" } : void 0,
|
|
11530
11530
|
content: content2
|
|
11531
11531
|
})
|
|
@@ -11549,7 +11549,7 @@ adminRbacRoutes.post("/grants", async (c) => {
|
|
|
11549
11549
|
pairsByRole.get(roleId).push({ resource, verb, scope });
|
|
11550
11550
|
}
|
|
11551
11551
|
}
|
|
11552
|
-
const rbac = new
|
|
11552
|
+
const rbac = new chunkJCBDXEY2_cjs.RbacService(c.env.DB);
|
|
11553
11553
|
for (const id of saveRoleIds) {
|
|
11554
11554
|
await rbac.setRoleGrants(id, pairsByRole.get(id) || []);
|
|
11555
11555
|
}
|
|
@@ -11570,7 +11570,7 @@ adminRbacRoutes.post("/grants", async (c) => {
|
|
|
11570
11570
|
adminRbacRoutes.post("/roles/bulk", async (c) => {
|
|
11571
11571
|
const form = await c.req.formData();
|
|
11572
11572
|
const roleIds = String(form.get("role_ids") || "").split(",").filter(Boolean);
|
|
11573
|
-
const rbac = new
|
|
11573
|
+
const rbac = new chunkJCBDXEY2_cjs.RbacService(c.env.DB);
|
|
11574
11574
|
for (const roleId of roleIds) {
|
|
11575
11575
|
const displayName = String(form.get(`display_name_${roleId}`) || "").trim();
|
|
11576
11576
|
const nameVal = form.get(`name_${roleId}`) ? String(form.get(`name_${roleId}`)).trim() : void 0;
|
|
@@ -11595,7 +11595,7 @@ adminRbacRoutes.post("/roles", async (c) => {
|
|
|
11595
11595
|
const displayName = String(form.get("display_name") || "").trim();
|
|
11596
11596
|
if (name && displayName) {
|
|
11597
11597
|
try {
|
|
11598
|
-
await new
|
|
11598
|
+
await new chunkJCBDXEY2_cjs.RbacService(c.env.DB).createRole(name, displayName);
|
|
11599
11599
|
} catch {
|
|
11600
11600
|
}
|
|
11601
11601
|
}
|
|
@@ -11610,7 +11610,7 @@ adminRbacRoutes.post("/roles/:id", async (c) => {
|
|
|
11610
11610
|
const portalAccess = form.get("portal_access") === "1";
|
|
11611
11611
|
if (displayName) {
|
|
11612
11612
|
try {
|
|
11613
|
-
const rbac = new
|
|
11613
|
+
const rbac = new chunkJCBDXEY2_cjs.RbacService(c.env.DB);
|
|
11614
11614
|
if (roleId !== "role-admin") {
|
|
11615
11615
|
await rbac.updateRoleAndPortalAccess(roleId, displayName, name, portalAccess, description);
|
|
11616
11616
|
} else {
|
|
@@ -11622,7 +11622,7 @@ adminRbacRoutes.post("/roles/:id", async (c) => {
|
|
|
11622
11622
|
return c.redirect(`/admin/rbac#roles-verbs`);
|
|
11623
11623
|
});
|
|
11624
11624
|
adminRbacRoutes.post("/roles/:id/delete", async (c) => {
|
|
11625
|
-
await new
|
|
11625
|
+
await new chunkJCBDXEY2_cjs.RbacService(c.env.DB).deleteRole(c.req.param("id"));
|
|
11626
11626
|
return c.redirect("/admin/rbac#roles-verbs");
|
|
11627
11627
|
});
|
|
11628
11628
|
adminRbacRoutes.post("/verbs", async (c) => {
|
|
@@ -11630,18 +11630,18 @@ adminRbacRoutes.post("/verbs", async (c) => {
|
|
|
11630
11630
|
const name = String(form.get("name") || "").trim();
|
|
11631
11631
|
if (name) {
|
|
11632
11632
|
try {
|
|
11633
|
-
await new
|
|
11633
|
+
await new chunkJCBDXEY2_cjs.RbacService(c.env.DB).createVerb(name);
|
|
11634
11634
|
} catch {
|
|
11635
11635
|
}
|
|
11636
11636
|
}
|
|
11637
11637
|
return c.redirect("/admin/rbac#roles-verbs");
|
|
11638
11638
|
});
|
|
11639
11639
|
adminRbacRoutes.post("/verbs/:id/delete", async (c) => {
|
|
11640
|
-
await new
|
|
11640
|
+
await new chunkJCBDXEY2_cjs.RbacService(c.env.DB).deleteVerb(c.req.param("id"));
|
|
11641
11641
|
return c.redirect("/admin/rbac#roles-verbs");
|
|
11642
11642
|
});
|
|
11643
11643
|
adminRbacRoutes.get("/check", async (c) => {
|
|
11644
|
-
const rbac = new
|
|
11644
|
+
const rbac = new chunkJCBDXEY2_cjs.RbacService(c.env.DB);
|
|
11645
11645
|
const resource = c.req.query("resource") || "";
|
|
11646
11646
|
const verb = c.req.query("verb") || "";
|
|
11647
11647
|
const roleId = c.req.query("role");
|
|
@@ -11662,7 +11662,7 @@ adminRbacRoutes.get("/check", async (c) => {
|
|
|
11662
11662
|
});
|
|
11663
11663
|
|
|
11664
11664
|
// src/middleware/plugin-menu.ts
|
|
11665
|
-
var REGISTRY_MENU_PLUGINS = Object.values(
|
|
11665
|
+
var REGISTRY_MENU_PLUGINS = Object.values(chunkYAURVGUK_cjs.PLUGIN_REGISTRY).filter((p) => p.adminMenu !== null).map((p) => ({
|
|
11666
11666
|
id: p.id,
|
|
11667
11667
|
label: p.adminMenu.label,
|
|
11668
11668
|
path: p.adminMenu.path,
|
|
@@ -11716,9 +11716,9 @@ function pluginMenuMiddleware() {
|
|
|
11716
11716
|
if (!path.startsWith("/admin")) {
|
|
11717
11717
|
return next();
|
|
11718
11718
|
}
|
|
11719
|
+
const db = c.env.DB;
|
|
11719
11720
|
let activeMenuItems = [];
|
|
11720
11721
|
try {
|
|
11721
|
-
const db = c.env.DB;
|
|
11722
11722
|
const pluginIds = REGISTRY_MENU_PLUGINS.map((p) => p.id);
|
|
11723
11723
|
if (pluginIds.length > 0) {
|
|
11724
11724
|
const placeholders = pluginIds.map(() => "?").join(",");
|
|
@@ -11741,10 +11741,25 @@ function pluginMenuMiddleware() {
|
|
|
11741
11741
|
} catch {
|
|
11742
11742
|
}
|
|
11743
11743
|
const user = c.get("user");
|
|
11744
|
-
const singletonItems =
|
|
11744
|
+
const singletonItems = chunkD6FWEYQE_cjs.resolvePluginMenuItems(user ? { role: user.role } : void 0);
|
|
11745
|
+
const singletonPluginIds = [...new Set(
|
|
11746
|
+
singletonItems.map((i) => i.pluginId).filter((id) => !!id)
|
|
11747
|
+
)];
|
|
11748
|
+
let activeSingletonIds = /* @__PURE__ */ new Set();
|
|
11749
|
+
try {
|
|
11750
|
+
if (singletonPluginIds.length > 0) {
|
|
11751
|
+
const ph = singletonPluginIds.map(() => "?").join(",");
|
|
11752
|
+
const result = await db.prepare(
|
|
11753
|
+
`SELECT slug FROM documents WHERE type_id = 'plugin' AND tenant_id = 'default' AND slug IN (${ph}) AND q_plugin_status = 'active' AND is_current_draft = 1 AND deleted_at IS NULL`
|
|
11754
|
+
).bind(...singletonPluginIds).all();
|
|
11755
|
+
activeSingletonIds = new Set((result.results || []).map((r) => r.slug));
|
|
11756
|
+
}
|
|
11757
|
+
} catch {
|
|
11758
|
+
}
|
|
11745
11759
|
const existingPaths = new Set(activeMenuItems.map((i) => i.path));
|
|
11746
11760
|
for (const item of singletonItems) {
|
|
11747
|
-
|
|
11761
|
+
const isActive = !item.pluginId || activeSingletonIds.has(item.pluginId);
|
|
11762
|
+
if (isActive && !existingPaths.has(item.path)) {
|
|
11748
11763
|
activeMenuItems.push({ label: item.label, path: item.path, icon: item.icon, order: item.order });
|
|
11749
11764
|
}
|
|
11750
11765
|
}
|
|
@@ -12310,7 +12325,7 @@ var SYSTEM_MENU_ITEMS = [
|
|
|
12310
12325
|
];
|
|
12311
12326
|
|
|
12312
12327
|
// src/plugins/core-plugins/menu-plugin/templates/admin-menu-list.template.ts
|
|
12313
|
-
|
|
12328
|
+
chunkMI2YXCK4_cjs.init_admin_layout_catalyst_template();
|
|
12314
12329
|
function pluginStatusBadge(status) {
|
|
12315
12330
|
if (status === "inactive") {
|
|
12316
12331
|
return `<span class="inline-flex items-center rounded-md px-2 py-0.5 text-xs font-medium bg-red-50 dark:bg-red-500/10 text-red-700 dark:text-red-400 ring-1 ring-inset ring-red-600/20 dark:ring-red-500/20 ml-1">disabled</span>`;
|
|
@@ -12462,7 +12477,7 @@ function renderMenuListPage(data) {
|
|
|
12462
12477
|
dynamicMenuItems: data.dynamicMenuItems,
|
|
12463
12478
|
content: pageContent
|
|
12464
12479
|
};
|
|
12465
|
-
return
|
|
12480
|
+
return chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
12466
12481
|
}
|
|
12467
12482
|
function renderMenuSettingsContent(items, pluginStatuses = {}, message) {
|
|
12468
12483
|
const messageBanner = "";
|
|
@@ -12567,7 +12582,7 @@ function renderMenuSettingsContent(items, pluginStatuses = {}, message) {
|
|
|
12567
12582
|
}
|
|
12568
12583
|
|
|
12569
12584
|
// src/plugins/core-plugins/menu-plugin/templates/admin-menu-form.template.ts
|
|
12570
|
-
|
|
12585
|
+
chunkMI2YXCK4_cjs.init_admin_layout_catalyst_template();
|
|
12571
12586
|
|
|
12572
12587
|
// src/plugins/core-plugins/menu-plugin/templates/icon-picker.template.ts
|
|
12573
12588
|
var ICONS = [
|
|
@@ -12903,7 +12918,7 @@ function renderMenuFormPage(data) {
|
|
|
12903
12918
|
dynamicMenuItems: data.dynamicMenuItems,
|
|
12904
12919
|
content: pageContent
|
|
12905
12920
|
};
|
|
12906
|
-
return
|
|
12921
|
+
return chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
12907
12922
|
}
|
|
12908
12923
|
|
|
12909
12924
|
// src/plugins/core-plugins/menu-plugin/routes/admin-menu.ts
|
|
@@ -12913,8 +12928,8 @@ function sanitizeUrl(url) {
|
|
|
12913
12928
|
return trimmed;
|
|
12914
12929
|
}
|
|
12915
12930
|
var adminMenuRoutes = new hono.Hono();
|
|
12916
|
-
adminMenuRoutes.use("*",
|
|
12917
|
-
adminMenuRoutes.use("*",
|
|
12931
|
+
adminMenuRoutes.use("*", chunkE7E3NL3Y_cjs.requireAuth());
|
|
12932
|
+
adminMenuRoutes.use("*", chunkE7E3NL3Y_cjs.requireRole(["admin"]));
|
|
12918
12933
|
adminMenuRoutes.get("/", async (c) => {
|
|
12919
12934
|
const db = c.env.DB;
|
|
12920
12935
|
const user = c.get("user");
|
|
@@ -13128,7 +13143,7 @@ adminMenuRoutes.post("/:id/move-down", async (c) => {
|
|
|
13128
13143
|
}
|
|
13129
13144
|
return c.redirect("/admin/menu");
|
|
13130
13145
|
});
|
|
13131
|
-
var menuPlugin =
|
|
13146
|
+
var menuPlugin = chunkD6FWEYQE_cjs.definePlugin({
|
|
13132
13147
|
id: "menu",
|
|
13133
13148
|
version: "1.0.0",
|
|
13134
13149
|
name: "Menu Manager",
|
|
@@ -13143,7 +13158,7 @@ var menuPlugin = chunk4WMZGHIC_cjs.definePlugin({
|
|
|
13143
13158
|
const db = env.DB;
|
|
13144
13159
|
if (!db) return;
|
|
13145
13160
|
try {
|
|
13146
|
-
const typeRegistry = new
|
|
13161
|
+
const typeRegistry = new chunkE7E3NL3Y_cjs.DocumentTypeRegistry(db);
|
|
13147
13162
|
await typeRegistry.register({
|
|
13148
13163
|
id: "menu_item",
|
|
13149
13164
|
name: "menu_item",
|
|
@@ -13178,7 +13193,7 @@ var menuPlugin = chunk4WMZGHIC_cjs.definePlugin({
|
|
|
13178
13193
|
lockedFields: [...item.lockedFields]
|
|
13179
13194
|
}, item.sortOrder);
|
|
13180
13195
|
}
|
|
13181
|
-
await
|
|
13196
|
+
await chunk6OA77UM7_cjs.reconcileMenuFromPlugins(db);
|
|
13182
13197
|
} catch {
|
|
13183
13198
|
}
|
|
13184
13199
|
},
|
|
@@ -13196,9 +13211,9 @@ var menuPlugin = chunk4WMZGHIC_cjs.definePlugin({
|
|
|
13196
13211
|
}
|
|
13197
13212
|
}
|
|
13198
13213
|
});
|
|
13199
|
-
|
|
13214
|
+
chunkMI2YXCK4_cjs.init_admin_layout_catalyst_template();
|
|
13200
13215
|
var adminRoutes6 = new hono.Hono();
|
|
13201
|
-
adminRoutes6.use("*",
|
|
13216
|
+
adminRoutes6.use("*", chunkE7E3NL3Y_cjs.requireAuth());
|
|
13202
13217
|
adminRoutes6.use("*", async (c, next) => {
|
|
13203
13218
|
const user = c.get("user");
|
|
13204
13219
|
if (user?.role !== "admin") {
|
|
@@ -13314,7 +13329,7 @@ adminRoutes6.get("/", async (c) => {
|
|
|
13314
13329
|
</div>
|
|
13315
13330
|
</div>
|
|
13316
13331
|
`;
|
|
13317
|
-
return c.html(
|
|
13332
|
+
return c.html(chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst({
|
|
13318
13333
|
title: "Analytics",
|
|
13319
13334
|
pageTitle: "Analytics Dashboard",
|
|
13320
13335
|
currentPath: "/admin/analytics",
|
|
@@ -13345,7 +13360,7 @@ var QUERYABLE_FIELDS2 = [
|
|
|
13345
13360
|
var EventTrackingService = class {
|
|
13346
13361
|
constructor(db) {
|
|
13347
13362
|
this.db = db;
|
|
13348
|
-
this.docsService = new
|
|
13363
|
+
this.docsService = new chunkJCBDXEY2_cjs.DocumentsService(db, {
|
|
13349
13364
|
queryableFields: QUERYABLE_FIELDS2,
|
|
13350
13365
|
maxVersionsPerRoot: 1,
|
|
13351
13366
|
tenantId: TENANT2
|
|
@@ -13554,7 +13569,7 @@ apiRoutes4.get("/stats", async (c) => {
|
|
|
13554
13569
|
});
|
|
13555
13570
|
|
|
13556
13571
|
// src/plugins/core-plugins/analytics/index.ts
|
|
13557
|
-
var analyticsPlugin =
|
|
13572
|
+
var analyticsPlugin = chunkD6FWEYQE_cjs.definePlugin({
|
|
13558
13573
|
id: "core-analytics",
|
|
13559
13574
|
version: "1.0.0",
|
|
13560
13575
|
name: "Analytics",
|
|
@@ -13701,7 +13716,7 @@ function esc2(s) {
|
|
|
13701
13716
|
return (s || "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
13702
13717
|
}
|
|
13703
13718
|
async function getVariablesMap(db) {
|
|
13704
|
-
let variables =
|
|
13719
|
+
let variables = chunk6OA77UM7_cjs.getVariablesCached();
|
|
13705
13720
|
if (variables) return variables;
|
|
13706
13721
|
try {
|
|
13707
13722
|
const { results } = await db.prepare(
|
|
@@ -13711,7 +13726,7 @@ async function getVariablesMap(db) {
|
|
|
13711
13726
|
for (const row of results || []) {
|
|
13712
13727
|
variables.set(row.key, row.value);
|
|
13713
13728
|
}
|
|
13714
|
-
|
|
13729
|
+
chunk6OA77UM7_cjs.setVariablesCache(variables);
|
|
13715
13730
|
return variables;
|
|
13716
13731
|
} catch {
|
|
13717
13732
|
return /* @__PURE__ */ new Map();
|
|
@@ -13780,7 +13795,7 @@ apiRoutes5.post("/", async (c) => {
|
|
|
13780
13795
|
await db.prepare(
|
|
13781
13796
|
"INSERT INTO global_variables (key, value, description, category, is_active) VALUES (?, ?, ?, ?, ?)"
|
|
13782
13797
|
).bind(key, value || "", description || "", category || "general", isActive !== false ? 1 : 0).run();
|
|
13783
|
-
|
|
13798
|
+
chunk6OA77UM7_cjs.invalidateVariablesCache();
|
|
13784
13799
|
const created = await db.prepare("SELECT * FROM global_variables WHERE key = ?").bind(key).first();
|
|
13785
13800
|
return c.json({ success: true, data: formatVariable(created) }, 201);
|
|
13786
13801
|
} catch {
|
|
@@ -13825,7 +13840,7 @@ apiRoutes5.put("/:id", async (c) => {
|
|
|
13825
13840
|
updates.push("updated_at = strftime('%s', 'now')");
|
|
13826
13841
|
params.push(id);
|
|
13827
13842
|
await db.prepare(`UPDATE global_variables SET ${updates.join(", ")} WHERE id = ?`).bind(...params).run();
|
|
13828
|
-
|
|
13843
|
+
chunk6OA77UM7_cjs.invalidateVariablesCache();
|
|
13829
13844
|
const updated = await db.prepare("SELECT * FROM global_variables WHERE id = ?").bind(id).first();
|
|
13830
13845
|
return c.json({ success: true, data: formatVariable(updated) });
|
|
13831
13846
|
} catch {
|
|
@@ -13839,7 +13854,7 @@ apiRoutes5.delete("/:id", async (c) => {
|
|
|
13839
13854
|
const existing = await db.prepare("SELECT id FROM global_variables WHERE id = ?").bind(id).first();
|
|
13840
13855
|
if (!existing) return c.json({ error: "Variable not found" }, 404);
|
|
13841
13856
|
await db.prepare("DELETE FROM global_variables WHERE id = ?").bind(id).run();
|
|
13842
|
-
|
|
13857
|
+
chunk6OA77UM7_cjs.invalidateVariablesCache();
|
|
13843
13858
|
return c.json({ success: true });
|
|
13844
13859
|
} catch {
|
|
13845
13860
|
return c.json({ success: false, error: "Failed to delete variable" }, 500);
|
|
@@ -13899,7 +13914,7 @@ adminRoutes7.put("/:id", async (c) => {
|
|
|
13899
13914
|
const value = body.value;
|
|
13900
13915
|
if (value !== void 0) {
|
|
13901
13916
|
await db.prepare("UPDATE global_variables SET value = ?, updated_at = strftime('%s', 'now') WHERE id = ?").bind(value, id).run();
|
|
13902
|
-
|
|
13917
|
+
chunk6OA77UM7_cjs.invalidateVariablesCache();
|
|
13903
13918
|
}
|
|
13904
13919
|
return c.html('<span class="text-green-400 text-xs">Saved</span>');
|
|
13905
13920
|
});
|
|
@@ -13907,7 +13922,7 @@ adminRoutes7.post("/:id/toggle", async (c) => {
|
|
|
13907
13922
|
const db = c.env.DB;
|
|
13908
13923
|
const id = c.req.param("id");
|
|
13909
13924
|
await db.prepare("UPDATE global_variables SET is_active = CASE WHEN is_active = 1 THEN 0 ELSE 1 END, updated_at = strftime('%s', 'now') WHERE id = ?").bind(id).run();
|
|
13910
|
-
|
|
13925
|
+
chunk6OA77UM7_cjs.invalidateVariablesCache();
|
|
13911
13926
|
c.header("HX-Redirect", "/admin/global-variables");
|
|
13912
13927
|
return c.body(null, 204);
|
|
13913
13928
|
});
|
|
@@ -13928,7 +13943,7 @@ adminRoutes7.post("/", async (c) => {
|
|
|
13928
13943
|
await db.prepare(
|
|
13929
13944
|
"INSERT INTO global_variables (key, value, description, category) VALUES (?, ?, ?, ?)"
|
|
13930
13945
|
).bind(key, value, description, category).run();
|
|
13931
|
-
|
|
13946
|
+
chunk6OA77UM7_cjs.invalidateVariablesCache();
|
|
13932
13947
|
c.header("HX-Redirect", "/admin/global-variables");
|
|
13933
13948
|
return c.body(null, 204);
|
|
13934
13949
|
});
|
|
@@ -13947,7 +13962,7 @@ adminRoutes7.post("/settings/editor-integration", async (c) => {
|
|
|
13947
13962
|
adminRoutes7.delete("/:id", async (c) => {
|
|
13948
13963
|
const db = c.env.DB;
|
|
13949
13964
|
await db.prepare("DELETE FROM global_variables WHERE id = ?").bind(c.req.param("id")).run();
|
|
13950
|
-
|
|
13965
|
+
chunk6OA77UM7_cjs.invalidateVariablesCache();
|
|
13951
13966
|
return c.html("");
|
|
13952
13967
|
});
|
|
13953
13968
|
function renderAdminPage(variables, editorStatus = { editorActive: false, activeEditorName: "", enableEditorIntegration: true }) {
|
|
@@ -14265,7 +14280,7 @@ function renderAdminPage(variables, editorStatus = { editorActive: false, active
|
|
|
14265
14280
|
</div>
|
|
14266
14281
|
` });
|
|
14267
14282
|
}
|
|
14268
|
-
var globalVariablesPlugin =
|
|
14283
|
+
var globalVariablesPlugin = chunkD6FWEYQE_cjs.definePlugin({
|
|
14269
14284
|
id: "global-variables",
|
|
14270
14285
|
version: "1.1.0",
|
|
14271
14286
|
name: "Global Variables",
|
|
@@ -14288,7 +14303,7 @@ var globalVariablesPlugin = chunk4WMZGHIC_cjs.definePlugin({
|
|
|
14288
14303
|
if (!db || !data) return data;
|
|
14289
14304
|
const variables = await getVariablesMap(db);
|
|
14290
14305
|
if (variables.size === 0) return data;
|
|
14291
|
-
return
|
|
14306
|
+
return chunk6OA77UM7_cjs.resolveVariablesInObject(data, variables);
|
|
14292
14307
|
} catch {
|
|
14293
14308
|
return data;
|
|
14294
14309
|
}
|
|
@@ -14306,7 +14321,7 @@ var globalVariablesPlugin = chunk4WMZGHIC_cjs.definePlugin({
|
|
|
14306
14321
|
},
|
|
14307
14322
|
activate: async () => console.info("[GlobalVariables] Plugin activated"),
|
|
14308
14323
|
deactivate: async () => {
|
|
14309
|
-
|
|
14324
|
+
chunk6OA77UM7_cjs.invalidateVariablesCache();
|
|
14310
14325
|
console.info("[GlobalVariables] Plugin deactivated, cache cleared");
|
|
14311
14326
|
},
|
|
14312
14327
|
uninstall: async (ctx) => {
|
|
@@ -14872,7 +14887,7 @@ function renderAdminPage2(shortcodes, editorStatus = { editorActive: false, acti
|
|
|
14872
14887
|
</div>
|
|
14873
14888
|
` });
|
|
14874
14889
|
}
|
|
14875
|
-
var shortcodesPlugin =
|
|
14890
|
+
var shortcodesPlugin = chunkD6FWEYQE_cjs.definePlugin({
|
|
14876
14891
|
id: "shortcodes",
|
|
14877
14892
|
version: "1.0.0",
|
|
14878
14893
|
name: "Shortcodes",
|
|
@@ -14956,7 +14971,7 @@ helloWorldRoutes.get("/", async (c) => {
|
|
|
14956
14971
|
</html>
|
|
14957
14972
|
`);
|
|
14958
14973
|
});
|
|
14959
|
-
var helloWorldPlugin =
|
|
14974
|
+
var helloWorldPlugin = chunkD6FWEYQE_cjs.definePlugin({
|
|
14960
14975
|
id: "hello-world",
|
|
14961
14976
|
version: "1.0.0",
|
|
14962
14977
|
name: "Hello World",
|
|
@@ -15003,7 +15018,7 @@ var manifest_default2 = {
|
|
|
15003
15018
|
author: "SonicJS Team"};
|
|
15004
15019
|
|
|
15005
15020
|
// src/plugins/core-plugins/multi-tenant-plugin/templates/tenants-list.template.ts
|
|
15006
|
-
|
|
15021
|
+
chunkMI2YXCK4_cjs.init_admin_layout_catalyst_template();
|
|
15007
15022
|
function statusBadge2(status) {
|
|
15008
15023
|
return status === "active" ? '<span class="inline-flex items-center rounded-md bg-emerald-500/10 px-2 py-1 text-xs font-medium text-emerald-600 dark:text-emerald-400">Active</span>' : '<span class="inline-flex items-center rounded-md bg-zinc-500/10 px-2 py-1 text-xs font-medium text-zinc-600 dark:text-zinc-400">Inactive</span>';
|
|
15009
15024
|
}
|
|
@@ -15076,7 +15091,7 @@ function renderTenantsList(data) {
|
|
|
15076
15091
|
</table>
|
|
15077
15092
|
</div>
|
|
15078
15093
|
</div>`;
|
|
15079
|
-
return
|
|
15094
|
+
return chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst({
|
|
15080
15095
|
title: "Tenants - SonicJS",
|
|
15081
15096
|
pageTitle: "Tenants",
|
|
15082
15097
|
currentPath: "/admin/tenants",
|
|
@@ -15095,7 +15110,7 @@ function renderTenantsInactive(data) {
|
|
|
15095
15110
|
<a href="/admin/plugins" class="mt-6 inline-flex items-center rounded-lg bg-zinc-950 px-3.5 py-2 text-sm font-semibold text-white hover:bg-zinc-800 dark:bg-white dark:text-zinc-950 dark:hover:bg-zinc-200">Go to Plugins</a>
|
|
15096
15111
|
</div>
|
|
15097
15112
|
</div>`;
|
|
15098
|
-
return
|
|
15113
|
+
return chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst({
|
|
15099
15114
|
title: "Tenants - SonicJS",
|
|
15100
15115
|
pageTitle: "Tenants",
|
|
15101
15116
|
currentPath: "/admin/tenants",
|
|
@@ -15106,7 +15121,7 @@ function renderTenantsInactive(data) {
|
|
|
15106
15121
|
}
|
|
15107
15122
|
|
|
15108
15123
|
// src/plugins/core-plugins/multi-tenant-plugin/templates/tenant-form.template.ts
|
|
15109
|
-
|
|
15124
|
+
chunkMI2YXCK4_cjs.init_admin_layout_catalyst_template();
|
|
15110
15125
|
function fieldErrors(errors, field) {
|
|
15111
15126
|
const list = errors?.[field];
|
|
15112
15127
|
if (!list || list.length === 0) return "";
|
|
@@ -15174,7 +15189,7 @@ function renderTenantForm(data) {
|
|
|
15174
15189
|
</form>
|
|
15175
15190
|
</div>
|
|
15176
15191
|
</div>`;
|
|
15177
|
-
return
|
|
15192
|
+
return chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst({
|
|
15178
15193
|
title: `${data.isEdit ? "Edit Tenant" : "New Tenant"} - SonicJS`,
|
|
15179
15194
|
pageTitle: data.isEdit ? "Edit Tenant" : "New Tenant",
|
|
15180
15195
|
currentPath: "/admin/tenants",
|
|
@@ -15185,9 +15200,9 @@ function renderTenantForm(data) {
|
|
|
15185
15200
|
}
|
|
15186
15201
|
|
|
15187
15202
|
// src/plugins/core-plugins/multi-tenant-plugin/templates/tenant-members.template.ts
|
|
15188
|
-
|
|
15203
|
+
chunkMI2YXCK4_cjs.init_admin_layout_catalyst_template();
|
|
15189
15204
|
function roleOptions(selected) {
|
|
15190
|
-
return
|
|
15205
|
+
return chunk6OA77UM7_cjs.VALID_MEMBER_ROLES.map(
|
|
15191
15206
|
(r) => `<option value="${r}" ${r === selected ? "selected" : ""}>${r}</option>`
|
|
15192
15207
|
).join("");
|
|
15193
15208
|
}
|
|
@@ -15249,7 +15264,7 @@ function renderInvitations(slug, invitations) {
|
|
|
15249
15264
|
<div>
|
|
15250
15265
|
<label for="invite-role" class="mb-1 block text-xs font-medium text-zinc-500 dark:text-zinc-400">Role</label>
|
|
15251
15266
|
<select id="invite-role" name="role" class="rounded-lg border border-zinc-950/10 bg-white px-2 py-2 text-sm text-zinc-950 dark:border-white/10 dark:bg-zinc-800 dark:text-white">
|
|
15252
|
-
${
|
|
15267
|
+
${chunk6OA77UM7_cjs.VALID_MEMBER_ROLES.map((r) => `<option value="${r}" ${r === "viewer" ? "selected" : ""}>${r}</option>`).join("")}
|
|
15253
15268
|
</select>
|
|
15254
15269
|
</div>
|
|
15255
15270
|
<button type="submit" data-send-invite class="rounded-lg bg-zinc-950 px-3.5 py-2 text-sm font-semibold text-white hover:bg-zinc-800 dark:bg-white dark:text-zinc-950 dark:hover:bg-zinc-200">Invite</button>
|
|
@@ -15332,7 +15347,7 @@ function renderTenantMembers(data) {
|
|
|
15332
15347
|
|
|
15333
15348
|
${renderInvitations(data.slug, data.invitations)}
|
|
15334
15349
|
</div>`;
|
|
15335
|
-
return
|
|
15350
|
+
return chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst({
|
|
15336
15351
|
title: `Members - ${data.tenantName} - SonicJS`,
|
|
15337
15352
|
pageTitle: "Tenant Members",
|
|
15338
15353
|
currentPath: "/admin/tenants",
|
|
@@ -15343,9 +15358,9 @@ function renderTenantMembers(data) {
|
|
|
15343
15358
|
}
|
|
15344
15359
|
|
|
15345
15360
|
// src/plugins/core-plugins/multi-tenant-plugin/templates/user-memberships.template.ts
|
|
15346
|
-
|
|
15361
|
+
chunkMI2YXCK4_cjs.init_admin_layout_catalyst_template();
|
|
15347
15362
|
function roleOptions2(selected) {
|
|
15348
|
-
return
|
|
15363
|
+
return chunk6OA77UM7_cjs.VALID_MEMBER_ROLES.map(
|
|
15349
15364
|
(r) => `<option value="${r}" ${r === selected ? "selected" : ""}>${r}</option>`
|
|
15350
15365
|
).join("");
|
|
15351
15366
|
}
|
|
@@ -15418,7 +15433,7 @@ function renderUserMemberships(data) {
|
|
|
15418
15433
|
</table>
|
|
15419
15434
|
</div>
|
|
15420
15435
|
</div>`;
|
|
15421
|
-
return
|
|
15436
|
+
return chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst({
|
|
15422
15437
|
title: `Tenant memberships - ${data.userEmail} - SonicJS`,
|
|
15423
15438
|
pageTitle: "Tenant memberships",
|
|
15424
15439
|
currentPath: "/admin/users",
|
|
@@ -15429,7 +15444,7 @@ function renderUserMemberships(data) {
|
|
|
15429
15444
|
}
|
|
15430
15445
|
|
|
15431
15446
|
// src/plugins/core-plugins/multi-tenant-plugin/templates/role-usage.template.ts
|
|
15432
|
-
|
|
15447
|
+
chunkMI2YXCK4_cjs.init_admin_layout_catalyst_template();
|
|
15433
15448
|
function renderRoleUsage(data) {
|
|
15434
15449
|
const role = chunkMNWKYY5E_cjs.escapeHtml(data.roleName);
|
|
15435
15450
|
const rows = data.assignments.length ? data.assignments.map((a) => `
|
|
@@ -15464,7 +15479,7 @@ function renderRoleUsage(data) {
|
|
|
15464
15479
|
</table>
|
|
15465
15480
|
</div>
|
|
15466
15481
|
</div>`;
|
|
15467
|
-
return
|
|
15482
|
+
return chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst({
|
|
15468
15483
|
title: `Role usage - ${data.roleName} - SonicJS`,
|
|
15469
15484
|
pageTitle: "Role usage",
|
|
15470
15485
|
currentPath: "/admin/tenants",
|
|
@@ -15507,7 +15522,7 @@ function zodToFieldErrors(error) {
|
|
|
15507
15522
|
}
|
|
15508
15523
|
async function isMultiTenantActive(db) {
|
|
15509
15524
|
try {
|
|
15510
|
-
const plugin2 = await new
|
|
15525
|
+
const plugin2 = await new chunkYAURVGUK_cjs.PluginService(db).getPlugin(chunkYAURVGUK_cjs.MULTI_TENANT_PLUGIN_ID);
|
|
15511
15526
|
return plugin2?.status === "active";
|
|
15512
15527
|
} catch {
|
|
15513
15528
|
return false;
|
|
@@ -15515,7 +15530,7 @@ async function isMultiTenantActive(db) {
|
|
|
15515
15530
|
}
|
|
15516
15531
|
function createTenantAdminRoutes() {
|
|
15517
15532
|
const routes2 = new hono.Hono();
|
|
15518
|
-
routes2.use("*",
|
|
15533
|
+
routes2.use("*", chunkE7E3NL3Y_cjs.requireAuth());
|
|
15519
15534
|
routes2.use("*", async (c, next) => {
|
|
15520
15535
|
const user = c.get("user");
|
|
15521
15536
|
if (user?.role !== "admin") {
|
|
@@ -15529,7 +15544,7 @@ function createTenantAdminRoutes() {
|
|
|
15529
15544
|
const form = await c.req.formData();
|
|
15530
15545
|
const slug = String(form.get("tenant") ?? "").trim().toLowerCase();
|
|
15531
15546
|
const redirect = String(form.get("redirect") ?? "");
|
|
15532
|
-
const svc = new
|
|
15547
|
+
const svc = new chunk6OA77UM7_cjs.TenantService(db);
|
|
15533
15548
|
const tenant = await svc.getTenantBySlug(slug);
|
|
15534
15549
|
if (!tenant || tenant.status !== "active") {
|
|
15535
15550
|
return c.json({ error: "Unknown or inactive tenant" }, 400);
|
|
@@ -15539,7 +15554,7 @@ function createTenantAdminRoutes() {
|
|
|
15539
15554
|
if (!user.isSuperAdmin && !await svc.isMember(user.userId, slug)) {
|
|
15540
15555
|
return c.json({ error: "You are not a member of this tenant" }, 403);
|
|
15541
15556
|
}
|
|
15542
|
-
cookie.setCookie(c,
|
|
15557
|
+
cookie.setCookie(c, chunkYAURVGUK_cjs.TENANT_COOKIE, slug, {
|
|
15543
15558
|
path: "/",
|
|
15544
15559
|
httpOnly: true,
|
|
15545
15560
|
sameSite: "Lax",
|
|
@@ -15556,7 +15571,7 @@ function createTenantAdminRoutes() {
|
|
|
15556
15571
|
if (!user) return c.redirect("/auth/login");
|
|
15557
15572
|
const token = c.req.query("token") ?? "";
|
|
15558
15573
|
try {
|
|
15559
|
-
const { slug } = await new
|
|
15574
|
+
const { slug } = await new chunk6OA77UM7_cjs.TenantService(db).acceptInvitation(token, user.userId, user.email);
|
|
15560
15575
|
return c.redirect(`/admin/tenants/${slug}/members?message=Invitation accepted`);
|
|
15561
15576
|
} catch (error) {
|
|
15562
15577
|
const message = error instanceof Error ? error.message : "Failed to accept invitation";
|
|
@@ -15584,7 +15599,7 @@ function createTenantAdminRoutes() {
|
|
|
15584
15599
|
const userId = c.req.param("userId");
|
|
15585
15600
|
const target = await db.prepare("SELECT id, email FROM auth_user WHERE id = ?").bind(userId).first();
|
|
15586
15601
|
if (!target?.id) return c.redirect("/admin/users?message=User not found&type=error");
|
|
15587
|
-
const svc = new
|
|
15602
|
+
const svc = new chunk6OA77UM7_cjs.TenantService(db);
|
|
15588
15603
|
const [memberships, allTenants] = await Promise.all([svc.listUserMemberships(userId), svc.listTenants()]);
|
|
15589
15604
|
const memberSlugs = new Set(memberships.map((m) => m.slug));
|
|
15590
15605
|
const availableTenants = allTenants.filter((t) => t.status === "active" && !memberSlugs.has(t.slug)).map((t) => ({ slug: t.slug, name: t.name }));
|
|
@@ -15609,10 +15624,10 @@ function createTenantAdminRoutes() {
|
|
|
15609
15624
|
const slug = String(form.get("slug") ?? "").trim().toLowerCase();
|
|
15610
15625
|
const role = String(form.get("role") ?? "viewer");
|
|
15611
15626
|
const redirectTo = String(form.get("_redirect") ?? "") || `/admin/tenants/users/${userId}`;
|
|
15612
|
-
if (!
|
|
15627
|
+
if (!chunk6OA77UM7_cjs.isValidMemberRole(role)) throw new Error(`Invalid role '${role}'`);
|
|
15613
15628
|
const target = await db.prepare("SELECT email FROM auth_user WHERE id = ?").bind(userId).first();
|
|
15614
15629
|
if (!target) throw new Error("User not found");
|
|
15615
|
-
const svc = new
|
|
15630
|
+
const svc = new chunk6OA77UM7_cjs.TenantService(db);
|
|
15616
15631
|
if (!await svc.getTenantBySlug(slug)) throw new Error("Tenant not found");
|
|
15617
15632
|
if (await svc.isMember(userId, slug)) throw new Error(`Already a member of '${slug}'`);
|
|
15618
15633
|
await svc.addMember(slug, userId, role, target.email ?? null);
|
|
@@ -15631,7 +15646,7 @@ function createTenantAdminRoutes() {
|
|
|
15631
15646
|
const form = await c.req.formData();
|
|
15632
15647
|
const role = String(form.get("role") ?? "");
|
|
15633
15648
|
const redirectTo = String(form.get("_redirect") ?? "") || `/admin/tenants/users/${userId}`;
|
|
15634
|
-
await new
|
|
15649
|
+
await new chunk6OA77UM7_cjs.TenantService(db).setMemberRole(slug, userId, role);
|
|
15635
15650
|
return c.redirect(`${redirectTo}?message=Role updated`);
|
|
15636
15651
|
} catch (error) {
|
|
15637
15652
|
const message = error instanceof Error ? error.message : "Failed to update role";
|
|
@@ -15646,7 +15661,7 @@ function createTenantAdminRoutes() {
|
|
|
15646
15661
|
try {
|
|
15647
15662
|
const form = await c.req.formData();
|
|
15648
15663
|
const redirectTo = String(form.get("_redirect") ?? "") || `/admin/tenants/users/${userId}`;
|
|
15649
|
-
await new
|
|
15664
|
+
await new chunk6OA77UM7_cjs.TenantService(db).removeMember(slug, userId);
|
|
15650
15665
|
return c.redirect(`${redirectTo}?message=Removed from ${encodeURIComponent(slug)}`);
|
|
15651
15666
|
} catch (error) {
|
|
15652
15667
|
const message = error instanceof Error ? error.message : "Failed to remove membership";
|
|
@@ -15661,7 +15676,7 @@ function createTenantAdminRoutes() {
|
|
|
15661
15676
|
return c.html(renderTenantsInactive({ user: userShape(cur), version }));
|
|
15662
15677
|
}
|
|
15663
15678
|
const roleName = c.req.param("roleName");
|
|
15664
|
-
const assignments = await new
|
|
15679
|
+
const assignments = await new chunk6OA77UM7_cjs.TenantService(db).listAssignmentsByRole(roleName);
|
|
15665
15680
|
return c.html(renderRoleUsage({ roleName, assignments, user: userShape(cur), version }));
|
|
15666
15681
|
});
|
|
15667
15682
|
routes2.get("/", async (c) => {
|
|
@@ -15671,7 +15686,7 @@ function createTenantAdminRoutes() {
|
|
|
15671
15686
|
if (!await isMultiTenantActive(db)) {
|
|
15672
15687
|
return c.html(renderTenantsInactive({ user: userShape(user), version }));
|
|
15673
15688
|
}
|
|
15674
|
-
const svc = new
|
|
15689
|
+
const svc = new chunk6OA77UM7_cjs.TenantService(db);
|
|
15675
15690
|
await svc.ensureDefaultTenant();
|
|
15676
15691
|
const tenants = await svc.listTenants();
|
|
15677
15692
|
const [docRes, memberRes] = await db.batch([
|
|
@@ -15710,7 +15725,7 @@ function createTenantAdminRoutes() {
|
|
|
15710
15725
|
formEntries = Object.fromEntries(form.entries());
|
|
15711
15726
|
const validated = tenantFormSchema.parse(formEntries);
|
|
15712
15727
|
if (!validated.slug) throw new zod.z.ZodError([{ code: "custom", message: "Slug is required", path: ["slug"] }]);
|
|
15713
|
-
const svc = new
|
|
15728
|
+
const svc = new chunk6OA77UM7_cjs.TenantService(db);
|
|
15714
15729
|
await svc.createTenant({
|
|
15715
15730
|
name: validated.name,
|
|
15716
15731
|
slug: validated.slug,
|
|
@@ -15735,7 +15750,7 @@ function createTenantAdminRoutes() {
|
|
|
15735
15750
|
if (!await isMultiTenantActive(db)) {
|
|
15736
15751
|
return c.html(renderTenantsInactive({ user: userShape(user), version }));
|
|
15737
15752
|
}
|
|
15738
|
-
const tenant = await new
|
|
15753
|
+
const tenant = await new chunk6OA77UM7_cjs.TenantService(db).getTenantBySlug(c.req.param("slug"));
|
|
15739
15754
|
if (!tenant) return c.redirect("/admin/tenants?message=Tenant not found&type=error");
|
|
15740
15755
|
return c.html(renderTenantForm({ tenant, isEdit: true, user: userShape(user), version }));
|
|
15741
15756
|
});
|
|
@@ -15745,7 +15760,7 @@ function createTenantAdminRoutes() {
|
|
|
15745
15760
|
const version = c.get("appVersion");
|
|
15746
15761
|
const slug = c.req.param("slug");
|
|
15747
15762
|
if (!await isMultiTenantActive(db)) return c.json({ error: "Multi-tenant plugin is not active" }, 403);
|
|
15748
|
-
const svc = new
|
|
15763
|
+
const svc = new chunk6OA77UM7_cjs.TenantService(db);
|
|
15749
15764
|
try {
|
|
15750
15765
|
const form = await c.req.formData();
|
|
15751
15766
|
const validated = tenantFormSchema.parse(Object.fromEntries(form.entries()));
|
|
@@ -15770,7 +15785,7 @@ function createTenantAdminRoutes() {
|
|
|
15770
15785
|
const slug = c.req.param("slug");
|
|
15771
15786
|
if (!await isMultiTenantActive(db)) return c.json({ error: "Multi-tenant plugin is not active" }, 403);
|
|
15772
15787
|
try {
|
|
15773
|
-
await new
|
|
15788
|
+
await new chunk6OA77UM7_cjs.TenantService(db).deleteTenant(slug);
|
|
15774
15789
|
return c.redirect("/admin/tenants?message=Tenant deleted successfully");
|
|
15775
15790
|
} catch (error) {
|
|
15776
15791
|
const message = error instanceof Error ? error.message : "Failed to delete tenant";
|
|
@@ -15785,7 +15800,7 @@ function createTenantAdminRoutes() {
|
|
|
15785
15800
|
return c.html(renderTenantsInactive({ user: userShape(user), version }));
|
|
15786
15801
|
}
|
|
15787
15802
|
const slug = c.req.param("slug");
|
|
15788
|
-
const svc = new
|
|
15803
|
+
const svc = new chunk6OA77UM7_cjs.TenantService(db);
|
|
15789
15804
|
const tenant = await svc.getTenantBySlug(slug);
|
|
15790
15805
|
if (!tenant) return c.redirect("/admin/tenants?message=Tenant not found&type=error");
|
|
15791
15806
|
const [members, invitations] = await Promise.all([svc.listMembers(slug), svc.listInvitations(slug)]);
|
|
@@ -15811,7 +15826,7 @@ function createTenantAdminRoutes() {
|
|
|
15811
15826
|
const form = await c.req.formData();
|
|
15812
15827
|
const email = String(form.get("email") ?? "");
|
|
15813
15828
|
const role = String(form.get("role") ?? "viewer");
|
|
15814
|
-
await new
|
|
15829
|
+
await new chunk6OA77UM7_cjs.TenantService(db).addMemberByEmail(slug, email, role);
|
|
15815
15830
|
return c.redirect(`/admin/tenants/${slug}/members?message=Member added`);
|
|
15816
15831
|
} catch (error) {
|
|
15817
15832
|
const message = error instanceof Error ? error.message : "Failed to add member";
|
|
@@ -15826,7 +15841,7 @@ function createTenantAdminRoutes() {
|
|
|
15826
15841
|
try {
|
|
15827
15842
|
const form = await c.req.formData();
|
|
15828
15843
|
const role = String(form.get("role") ?? "");
|
|
15829
|
-
await new
|
|
15844
|
+
await new chunk6OA77UM7_cjs.TenantService(db).setMemberRole(slug, userId, role);
|
|
15830
15845
|
return c.redirect(`/admin/tenants/${slug}/members?message=Role updated`);
|
|
15831
15846
|
} catch (error) {
|
|
15832
15847
|
const message = error instanceof Error ? error.message : "Failed to update role";
|
|
@@ -15839,7 +15854,7 @@ function createTenantAdminRoutes() {
|
|
|
15839
15854
|
const userId = c.req.param("userId");
|
|
15840
15855
|
if (!await isMultiTenantActive(db)) return c.json({ error: "Multi-tenant plugin is not active" }, 403);
|
|
15841
15856
|
try {
|
|
15842
|
-
await new
|
|
15857
|
+
await new chunk6OA77UM7_cjs.TenantService(db).removeMember(slug, userId);
|
|
15843
15858
|
return c.redirect(`/admin/tenants/${slug}/members?message=Member removed`);
|
|
15844
15859
|
} catch (error) {
|
|
15845
15860
|
const message = error instanceof Error ? error.message : "Failed to remove member";
|
|
@@ -15855,12 +15870,12 @@ function createTenantAdminRoutes() {
|
|
|
15855
15870
|
const form = await c.req.formData();
|
|
15856
15871
|
const email = String(form.get("email") ?? "");
|
|
15857
15872
|
const role = String(form.get("role") ?? "viewer");
|
|
15858
|
-
const token = await new
|
|
15873
|
+
const token = await new chunk6OA77UM7_cjs.TenantService(db).createInvitation(slug, email, role, user?.userId ?? null);
|
|
15859
15874
|
const origin = c.req.header("origin") || new URL(c.req.url).origin;
|
|
15860
15875
|
const acceptUrl = `${origin}/join/invite?token=${encodeURIComponent(token)}`;
|
|
15861
15876
|
let note;
|
|
15862
15877
|
let noteType = "";
|
|
15863
|
-
const svc2 =
|
|
15878
|
+
const svc2 = chunk6OA77UM7_cjs.hasEmailService() ? chunk6OA77UM7_cjs.getEmailService() : null;
|
|
15864
15879
|
const hasRealProvider = !!svc2 && svc2.getProviderName() !== "console";
|
|
15865
15880
|
if (hasRealProvider) {
|
|
15866
15881
|
const result = await svc2.send({
|
|
@@ -15901,7 +15916,7 @@ function createTenantAdminRoutes() {
|
|
|
15901
15916
|
WHERE i.id = ? AND t.slug = ? AND i.status = 'pending'`
|
|
15902
15917
|
).bind(id, slug).first();
|
|
15903
15918
|
if (!inv) throw new Error("Invitation not found or already used");
|
|
15904
|
-
const svc2 =
|
|
15919
|
+
const svc2 = chunk6OA77UM7_cjs.hasEmailService() ? chunk6OA77UM7_cjs.getEmailService() : null;
|
|
15905
15920
|
const hasRealProvider = !!svc2 && svc2.getProviderName() !== "console";
|
|
15906
15921
|
if (!hasRealProvider) throw new Error("No email plugin active");
|
|
15907
15922
|
const origin = c.req.header("origin") || new URL(c.req.url).origin;
|
|
@@ -15926,7 +15941,7 @@ function createTenantAdminRoutes() {
|
|
|
15926
15941
|
const id = c.req.param("id");
|
|
15927
15942
|
if (!await isMultiTenantActive(db)) return c.json({ error: "Multi-tenant plugin is not active" }, 403);
|
|
15928
15943
|
try {
|
|
15929
|
-
await new
|
|
15944
|
+
await new chunk6OA77UM7_cjs.TenantService(db).revokeInvitation(slug, id);
|
|
15930
15945
|
return c.redirect(`/admin/tenants/${slug}/members?message=Invitation revoked`);
|
|
15931
15946
|
} catch (error) {
|
|
15932
15947
|
const message = error instanceof Error ? error.message : "Failed to revoke invitation";
|
|
@@ -16156,7 +16171,7 @@ function createJoinRoutes() {
|
|
|
16156
16171
|
if (existing) return rerender("An account with this email already exists. Please sign in instead.");
|
|
16157
16172
|
try {
|
|
16158
16173
|
const userId = crypto.randomUUID();
|
|
16159
|
-
const passwordHash = await
|
|
16174
|
+
const passwordHash = await chunkE7E3NL3Y_cjs.AuthManager.hashPassword(password);
|
|
16160
16175
|
const now = Date.now();
|
|
16161
16176
|
const nowSec = Math.floor(now / 1e3);
|
|
16162
16177
|
await db.batch([
|
|
@@ -16169,8 +16184,8 @@ function createJoinRoutes() {
|
|
|
16169
16184
|
VALUES (?, ?, ?, 'credential', ?, ?, ?)`
|
|
16170
16185
|
).bind(`cred-${userId}`, userId, userId, passwordHash, nowSec, nowSec)
|
|
16171
16186
|
]);
|
|
16172
|
-
await new
|
|
16173
|
-
const auth =
|
|
16187
|
+
await new chunk6OA77UM7_cjs.TenantService(db).acceptInvitation(token, userId, inv.email);
|
|
16188
|
+
const auth = chunkRSBZITK3_cjs.createAuth(c.env);
|
|
16174
16189
|
const origin = new URL(c.req.url).origin;
|
|
16175
16190
|
const baReq = new Request(`${origin}/auth/sign-in/email`, {
|
|
16176
16191
|
method: "POST",
|
|
@@ -16225,7 +16240,7 @@ function createJoinRoutes() {
|
|
|
16225
16240
|
version
|
|
16226
16241
|
}), 400);
|
|
16227
16242
|
try {
|
|
16228
|
-
const auth =
|
|
16243
|
+
const auth = chunkRSBZITK3_cjs.createAuth(c.env);
|
|
16229
16244
|
const origin = new URL(c.req.url).origin;
|
|
16230
16245
|
const baReq = new Request(`${origin}/auth/sign-in/email`, {
|
|
16231
16246
|
method: "POST",
|
|
@@ -16237,7 +16252,7 @@ function createJoinRoutes() {
|
|
|
16237
16252
|
const baBody = await baRes.json();
|
|
16238
16253
|
const userId = baBody?.user?.id;
|
|
16239
16254
|
if (!userId) return rerender("Sign-in succeeded but could not read user ID.");
|
|
16240
|
-
await new
|
|
16255
|
+
await new chunk6OA77UM7_cjs.TenantService(db).acceptInvitation(token, userId, inv.email);
|
|
16241
16256
|
const headers = new Headers({ Location: "/admin?message=Welcome! You have joined " + encodeURIComponent(inv.tenantName) });
|
|
16242
16257
|
copyBaCookies(baRes, headers);
|
|
16243
16258
|
return new Response(null, { status: 302, headers });
|
|
@@ -16251,7 +16266,7 @@ function createJoinRoutes() {
|
|
|
16251
16266
|
|
|
16252
16267
|
// src/plugins/core-plugins/multi-tenant-plugin/index.ts
|
|
16253
16268
|
var TENANT_ICON = `<svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3.75 21h16.5M4.5 3h15M5.25 3v18m13.5-18v18M9 6.75h1.5m-1.5 3h1.5m-1.5 3h1.5m3-6H15m-1.5 3H15m-1.5 3H15M9 21v-3.375c0-.621.504-1.125 1.125-1.125h3.75c.621 0 1.125.504 1.125 1.125V21"/></svg>`;
|
|
16254
|
-
var multiTenantPlugin =
|
|
16269
|
+
var multiTenantPlugin = chunkD6FWEYQE_cjs.definePlugin({
|
|
16255
16270
|
id: manifest_default2.id,
|
|
16256
16271
|
version: "1.0.0",
|
|
16257
16272
|
name: manifest_default2.name,
|
|
@@ -16266,30 +16281,30 @@ var multiTenantPlugin = chunk4WMZGHIC_cjs.definePlugin({
|
|
|
16266
16281
|
{ label: "Tenants", path: "/admin/tenants", icon: TENANT_ICON, order: 80 }
|
|
16267
16282
|
],
|
|
16268
16283
|
activate: async () => {
|
|
16269
|
-
|
|
16284
|
+
chunkYAURVGUK_cjs.invalidateTenantCache();
|
|
16270
16285
|
console.info("\u2705 Multi-Tenant plugin activated");
|
|
16271
16286
|
},
|
|
16272
16287
|
deactivate: async () => {
|
|
16273
|
-
|
|
16288
|
+
chunkYAURVGUK_cjs.invalidateTenantCache();
|
|
16274
16289
|
console.info("\u274C Multi-Tenant plugin deactivated");
|
|
16275
16290
|
}
|
|
16276
16291
|
});
|
|
16277
16292
|
var routes = new hono.Hono();
|
|
16278
|
-
routes.use("*",
|
|
16279
|
-
routes.use("*",
|
|
16293
|
+
routes.use("*", chunkE7E3NL3Y_cjs.requireAuth());
|
|
16294
|
+
routes.use("*", chunkE7E3NL3Y_cjs.requireRole(["admin", "editor"]));
|
|
16280
16295
|
routes.get("/:rootId", async (c) => {
|
|
16281
16296
|
const { rootId } = c.req.param();
|
|
16282
16297
|
const db = c.env.DB;
|
|
16283
|
-
const scope = await
|
|
16298
|
+
const scope = await chunk6OA77UM7_cjs.resolveDocScope(c, db, { rootId });
|
|
16284
16299
|
if (!scope) {
|
|
16285
16300
|
return c.html('<p class="text-zinc-500 dark:text-zinc-400 p-4">Document not found.</p>', 404);
|
|
16286
16301
|
}
|
|
16287
16302
|
if (!scope.docType?.settings?.versioning) {
|
|
16288
16303
|
return c.html('<p class="text-zinc-500 dark:text-zinc-400 p-4">Versioning not enabled for this type.</p>', 404);
|
|
16289
16304
|
}
|
|
16290
|
-
const denied = await
|
|
16305
|
+
const denied = await chunk6OA77UM7_cjs.denyIfNotAllowed(c, db, rootId, "read", scope.docType?.settings, scope.tenantId);
|
|
16291
16306
|
if (denied) return denied;
|
|
16292
|
-
const repo = new
|
|
16307
|
+
const repo = new chunk6OA77UM7_cjs.DocumentRepository(db, scope.tenantId);
|
|
16293
16308
|
const versions = await repo.getVersionHistory(rootId);
|
|
16294
16309
|
const safeRootIdAttr = chunkMNWKYY5E_cjs.escapeHtml(rootId);
|
|
16295
16310
|
const rows = versions.map((v) => {
|
|
@@ -16382,14 +16397,14 @@ routes.post("/:rootId/restore/:versionNumber", async (c) => {
|
|
|
16382
16397
|
const { rootId, versionNumber } = c.req.param();
|
|
16383
16398
|
const db = c.env.DB;
|
|
16384
16399
|
const user = c.get("user");
|
|
16385
|
-
const scope = await
|
|
16400
|
+
const scope = await chunk6OA77UM7_cjs.resolveDocScope(c, db, { rootId });
|
|
16386
16401
|
if (!scope) {
|
|
16387
16402
|
return c.json({ error: "Document not found" }, 404);
|
|
16388
16403
|
}
|
|
16389
16404
|
if (!scope.docType?.settings?.versioning) {
|
|
16390
16405
|
return c.json({ error: "Versioning not enabled for this type" }, 404);
|
|
16391
16406
|
}
|
|
16392
|
-
const denied = await
|
|
16407
|
+
const denied = await chunk6OA77UM7_cjs.denyIfNotAllowed(c, db, rootId, "update", scope.docType?.settings, scope.tenantId);
|
|
16393
16408
|
if (denied) return denied;
|
|
16394
16409
|
const row = await db.prepare("SELECT * FROM documents WHERE root_id = ? AND tenant_id = ? AND version_number = ? LIMIT 1").bind(rootId, scope.tenantId, Number(versionNumber)).first();
|
|
16395
16410
|
if (!row) {
|
|
@@ -16399,7 +16414,7 @@ routes.post("/:rootId/restore/:versionNumber", async (c) => {
|
|
|
16399
16414
|
const title = row.title ?? null;
|
|
16400
16415
|
const slug = row.slug ?? null;
|
|
16401
16416
|
const docType = scope.docType;
|
|
16402
|
-
const svc = new
|
|
16417
|
+
const svc = new chunkJCBDXEY2_cjs.DocumentsService(db, {
|
|
16403
16418
|
queryableFields: docType?.queryableFields ?? [],
|
|
16404
16419
|
typeSchemaVersion: docType?.schemaVersion ?? 1,
|
|
16405
16420
|
maxVersionsPerRoot: docType?.settings?.maxVersionsPerRoot ?? 50,
|
|
@@ -16412,7 +16427,7 @@ routes.post("/:rootId/restore/:versionNumber", async (c) => {
|
|
|
16412
16427
|
var routes_default = routes;
|
|
16413
16428
|
|
|
16414
16429
|
// src/plugins/core-plugins/versioning-plugin/index.ts
|
|
16415
|
-
var versioningPlugin =
|
|
16430
|
+
var versioningPlugin = chunkD6FWEYQE_cjs.definePlugin({
|
|
16416
16431
|
id: "versioning",
|
|
16417
16432
|
version: "1.0.0",
|
|
16418
16433
|
name: "Versioning",
|
|
@@ -16489,8 +16504,8 @@ function createMagicLinkAuthPlugin() {
|
|
|
16489
16504
|
const baseUrl = new URL(c.req.url).origin;
|
|
16490
16505
|
const magicLink = `${baseUrl}/auth/magic-link/verify?token=${token}`;
|
|
16491
16506
|
try {
|
|
16492
|
-
if (
|
|
16493
|
-
await
|
|
16507
|
+
if (chunk6OA77UM7_cjs.hasEmailService()) {
|
|
16508
|
+
await chunk6OA77UM7_cjs.getEmailService().send({
|
|
16494
16509
|
to: normalizedEmail,
|
|
16495
16510
|
subject: "Your Magic Link to Sign In",
|
|
16496
16511
|
flow: "magic-link",
|
|
@@ -16567,19 +16582,19 @@ function createMagicLinkAuthPlugin() {
|
|
|
16567
16582
|
SET used = 1, used_at = ?
|
|
16568
16583
|
WHERE id = ?
|
|
16569
16584
|
`).bind(Date.now(), magicLink.id).run();
|
|
16570
|
-
const tokenTtl = await
|
|
16571
|
-
const jwtToken = await
|
|
16585
|
+
const tokenTtl = await chunkE7E3NL3Y_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
|
|
16586
|
+
const jwtToken = await chunkE7E3NL3Y_cjs.AuthManager.generateToken(
|
|
16572
16587
|
user.id,
|
|
16573
16588
|
user.email,
|
|
16574
16589
|
user.role,
|
|
16575
16590
|
c.env.JWT_SECRET,
|
|
16576
16591
|
tokenTtl
|
|
16577
16592
|
);
|
|
16578
|
-
|
|
16593
|
+
chunkE7E3NL3Y_cjs.AuthManager.setAuthCookie(c, jwtToken, { maxAge: tokenTtl });
|
|
16579
16594
|
await db.prepare(`
|
|
16580
16595
|
UPDATE auth_user SET last_login_at = ? WHERE id = ?
|
|
16581
16596
|
`).bind(Date.now(), user.id).run();
|
|
16582
|
-
|
|
16597
|
+
chunk6OA77UM7_cjs.dispatchHookEvent(
|
|
16583
16598
|
c,
|
|
16584
16599
|
"auth:magic-link:consumed",
|
|
16585
16600
|
{ user: { id: user.id, email: user.email, role: user.role } },
|
|
@@ -17064,7 +17079,7 @@ async function warmCollections(db) {
|
|
|
17064
17079
|
const collectionCache = chunkYA3TJ65D_cjs.getCacheService(config);
|
|
17065
17080
|
let count = 0;
|
|
17066
17081
|
try {
|
|
17067
|
-
const results =
|
|
17082
|
+
const results = chunkYAURVGUK_cjs.getCollectionRegistry().listActive().map(chunkYAURVGUK_cjs.collectionRecordToRow);
|
|
17068
17083
|
for (const collection of results) {
|
|
17069
17084
|
const key = collectionCache.generateKey("item", collection.id);
|
|
17070
17085
|
await collectionCache.set(key, collection);
|
|
@@ -17131,7 +17146,7 @@ async function warmNamespace(namespace, entries) {
|
|
|
17131
17146
|
}
|
|
17132
17147
|
|
|
17133
17148
|
// src/templates/pages/admin-cache.template.ts
|
|
17134
|
-
|
|
17149
|
+
chunkMI2YXCK4_cjs.init_admin_layout_catalyst_template();
|
|
17135
17150
|
function renderCacheDashboard(data) {
|
|
17136
17151
|
const pageContent = `
|
|
17137
17152
|
<div class="space-y-6">
|
|
@@ -17335,7 +17350,7 @@ function renderCacheDashboard(data) {
|
|
|
17335
17350
|
</script>
|
|
17336
17351
|
|
|
17337
17352
|
<!-- Confirmation Dialogs -->
|
|
17338
|
-
${
|
|
17353
|
+
${chunk6OA77UM7_cjs.renderConfirmationDialog({
|
|
17339
17354
|
id: "clear-all-cache-confirm",
|
|
17340
17355
|
title: "Clear All Cache",
|
|
17341
17356
|
message: "Are you sure you want to clear all cache entries? This cannot be undone.",
|
|
@@ -17346,7 +17361,7 @@ function renderCacheDashboard(data) {
|
|
|
17346
17361
|
onConfirm: "performClearAllCaches()"
|
|
17347
17362
|
})}
|
|
17348
17363
|
|
|
17349
|
-
${
|
|
17364
|
+
${chunk6OA77UM7_cjs.renderConfirmationDialog({
|
|
17350
17365
|
id: "clear-namespace-cache-confirm",
|
|
17351
17366
|
title: "Clear Namespace Cache",
|
|
17352
17367
|
message: "Clear cache for this namespace?",
|
|
@@ -17357,7 +17372,7 @@ function renderCacheDashboard(data) {
|
|
|
17357
17372
|
onConfirm: "performClearNamespaceCache()"
|
|
17358
17373
|
})}
|
|
17359
17374
|
|
|
17360
|
-
${
|
|
17375
|
+
${chunk6OA77UM7_cjs.getConfirmationDialogScript()}
|
|
17361
17376
|
`;
|
|
17362
17377
|
const layoutData = {
|
|
17363
17378
|
title: "Cache System",
|
|
@@ -17367,7 +17382,7 @@ function renderCacheDashboard(data) {
|
|
|
17367
17382
|
version: data.version,
|
|
17368
17383
|
content: pageContent
|
|
17369
17384
|
};
|
|
17370
|
-
return
|
|
17385
|
+
return chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
17371
17386
|
}
|
|
17372
17387
|
function renderCollectionSettingsTab(collections) {
|
|
17373
17388
|
if (collections.length === 0) {
|
|
@@ -17623,7 +17638,7 @@ app.get("/", async (c) => {
|
|
|
17623
17638
|
const totalRequests = totalHits + totalMisses;
|
|
17624
17639
|
const overallHitRate = totalRequests > 0 ? totalHits / totalRequests * 100 : 0;
|
|
17625
17640
|
const DEFAULT_TTL = chunkYA3TJ65D_cjs.CACHE_CONFIGS.api?.ttl ?? 300;
|
|
17626
|
-
const collections =
|
|
17641
|
+
const collections = chunkYAURVGUK_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal).map((r) => {
|
|
17627
17642
|
const cacheOverride = r.cache;
|
|
17628
17643
|
const cacheEnabled = cacheOverride?.enabled !== false;
|
|
17629
17644
|
const hasCustomTtl = typeof cacheOverride?.ttl === "number";
|
|
@@ -18160,9 +18175,9 @@ var faviconSvg = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
|
18160
18175
|
// src/app.ts
|
|
18161
18176
|
function createSonicJSApp(config = {}) {
|
|
18162
18177
|
const app2 = new hono.Hono();
|
|
18163
|
-
const appVersion = config.version ||
|
|
18178
|
+
const appVersion = config.version || chunkBJ6NJL2E_cjs.getCoreVersion();
|
|
18164
18179
|
const appName = config.name || "SonicJS AI";
|
|
18165
|
-
const hookSystem = new
|
|
18180
|
+
const hookSystem = new chunkI7MIRRFJ_cjs.HookSystemImpl();
|
|
18166
18181
|
chunkJ6JTWD2A_cjs.setHookSystem(hookSystem);
|
|
18167
18182
|
const magicLinkPlugin = createMagicLinkAuthPlugin();
|
|
18168
18183
|
const corePluginsBeforeCatchAll = [
|
|
@@ -18170,7 +18185,7 @@ function createSonicJSApp(config = {}) {
|
|
|
18170
18185
|
apiKeysPlugin,
|
|
18171
18186
|
aiSearchPlugin,
|
|
18172
18187
|
oauthProvidersPlugin,
|
|
18173
|
-
|
|
18188
|
+
chunk6OA77UM7_cjs.userProfilesPlugin,
|
|
18174
18189
|
otpLoginPlugin,
|
|
18175
18190
|
analyticsPlugin,
|
|
18176
18191
|
stripePlugin,
|
|
@@ -18180,24 +18195,24 @@ function createSonicJSApp(config = {}) {
|
|
|
18180
18195
|
shortcodesPlugin,
|
|
18181
18196
|
helloWorldPlugin,
|
|
18182
18197
|
multiTenantPlugin,
|
|
18183
|
-
|
|
18198
|
+
chunk6OA77UM7_cjs.lexicalEditorPlugin,
|
|
18184
18199
|
versioningPlugin,
|
|
18185
18200
|
menuPlugin
|
|
18186
18201
|
];
|
|
18187
18202
|
const corePluginsAfterCatchAll = [emailPluginV3, magicLinkPlugin, emailReconciliationPlugin];
|
|
18188
|
-
const wirePlugins =
|
|
18203
|
+
const wirePlugins = chunkI7MIRRFJ_cjs.createPluginWirer(
|
|
18189
18204
|
() => [...corePluginsBeforeCatchAll, ...corePluginsAfterCatchAll, ...config.plugins?.register ?? []],
|
|
18190
18205
|
// The capability-gated `ctx.cap.email` resolves to the app EmailService, which
|
|
18191
18206
|
// is initialized (below) just before wiring on the first request.
|
|
18192
18207
|
() => ({
|
|
18193
18208
|
hooks: hookSystem,
|
|
18194
18209
|
env: firstRequestEnv,
|
|
18195
|
-
providers: { email: () =>
|
|
18210
|
+
providers: { email: () => chunk6OA77UM7_cjs.getEmailService() }
|
|
18196
18211
|
})
|
|
18197
18212
|
);
|
|
18198
18213
|
let firstRequestEnv;
|
|
18199
18214
|
const initEmailService = async (env = {}) => {
|
|
18200
|
-
if (
|
|
18215
|
+
if (chunk6OA77UM7_cjs.hasEmailService()) return;
|
|
18201
18216
|
let provider;
|
|
18202
18217
|
let defaultFrom = config.email?.from;
|
|
18203
18218
|
let defaultReplyTo;
|
|
@@ -18232,14 +18247,14 @@ function createSonicJSApp(config = {}) {
|
|
|
18232
18247
|
}
|
|
18233
18248
|
}
|
|
18234
18249
|
defaultFrom = defaultFrom || env.DEFAULT_FROM_EMAIL || "noreply@sonicjs.local";
|
|
18235
|
-
|
|
18250
|
+
chunk6OA77UM7_cjs.setEmailService(new EmailService({ provider, defaultFrom, defaultReplyTo, db: env.DB }));
|
|
18236
18251
|
};
|
|
18237
18252
|
app2.use("*", async (c, next) => {
|
|
18238
18253
|
c.set("appVersion", appVersion);
|
|
18239
18254
|
await next();
|
|
18240
18255
|
});
|
|
18241
|
-
app2.use("*",
|
|
18242
|
-
app2.use("*",
|
|
18256
|
+
app2.use("*", chunkE7E3NL3Y_cjs.metricsMiddleware());
|
|
18257
|
+
app2.use("*", chunkE7E3NL3Y_cjs.bootstrapMiddleware(config, [...corePluginsBeforeCatchAll, ...corePluginsAfterCatchAll, ...config.plugins?.register ?? []]));
|
|
18243
18258
|
const boot = async (env) => {
|
|
18244
18259
|
if (config.plugins?.disableAll) return;
|
|
18245
18260
|
firstRequestEnv = env;
|
|
@@ -18277,13 +18292,13 @@ function createSonicJSApp(config = {}) {
|
|
|
18277
18292
|
allowHeaders: ["Content-Type", "Authorization", "X-API-Key"],
|
|
18278
18293
|
credentials: true
|
|
18279
18294
|
}));
|
|
18280
|
-
app2.use("*",
|
|
18281
|
-
app2.use("*",
|
|
18295
|
+
app2.use("*", chunkE7E3NL3Y_cjs.securityHeadersMiddleware());
|
|
18296
|
+
app2.use("*", chunkE7E3NL3Y_cjs.csrfProtection());
|
|
18282
18297
|
app2.use("*", async (c, next) => {
|
|
18283
18298
|
try {
|
|
18284
18299
|
const reqUrl = new URL(c.req.url);
|
|
18285
18300
|
const requestBaseURL = `${reqUrl.protocol}//${reqUrl.host}`;
|
|
18286
|
-
const auth =
|
|
18301
|
+
const auth = chunkRSBZITK3_cjs.createAuth(c.env, config.auth?.extendBetterAuth, requestBaseURL);
|
|
18287
18302
|
const session = await auth.api.getSession({ headers: c.req.raw.headers });
|
|
18288
18303
|
if (session?.user) {
|
|
18289
18304
|
const u = session.user;
|
|
@@ -18311,14 +18326,37 @@ function createSonicJSApp(config = {}) {
|
|
|
18311
18326
|
await next();
|
|
18312
18327
|
});
|
|
18313
18328
|
app2.use("*", apiKeyAuthMiddleware());
|
|
18329
|
+
app2.use("*", async (c, next) => {
|
|
18330
|
+
if (!c.get("user")) {
|
|
18331
|
+
const authHeader = c.req.header("Authorization");
|
|
18332
|
+
if (authHeader?.startsWith("Bearer ") && !authHeader.startsWith("Bearer sk_")) {
|
|
18333
|
+
const token = authHeader.slice(7);
|
|
18334
|
+
try {
|
|
18335
|
+
const secret = c.env?.JWT_SECRET;
|
|
18336
|
+
const payload = await chunkE7E3NL3Y_cjs.AuthManager.verifyToken(token, secret);
|
|
18337
|
+
if (payload) {
|
|
18338
|
+
c.set("user", {
|
|
18339
|
+
userId: payload.userId,
|
|
18340
|
+
email: payload.email,
|
|
18341
|
+
role: payload.role,
|
|
18342
|
+
exp: payload.exp,
|
|
18343
|
+
iat: payload.iat
|
|
18344
|
+
});
|
|
18345
|
+
}
|
|
18346
|
+
} catch {
|
|
18347
|
+
}
|
|
18348
|
+
}
|
|
18349
|
+
}
|
|
18350
|
+
await next();
|
|
18351
|
+
});
|
|
18314
18352
|
if (config.middleware?.afterAuth) {
|
|
18315
18353
|
for (const middleware of config.middleware.afterAuth) {
|
|
18316
18354
|
app2.use("*", middleware);
|
|
18317
18355
|
}
|
|
18318
18356
|
}
|
|
18319
|
-
app2.use("*",
|
|
18320
|
-
app2.use("/admin/*",
|
|
18321
|
-
app2.use("/admin/*",
|
|
18357
|
+
app2.use("*", chunkYAURVGUK_cjs.tenantMiddleware());
|
|
18358
|
+
app2.use("/admin/*", chunkE7E3NL3Y_cjs.requireAuth());
|
|
18359
|
+
app2.use("/admin/*", chunkE7E3NL3Y_cjs.requireRbac("portal", "access"));
|
|
18322
18360
|
app2.use("/admin/*", pluginMenuMiddleware());
|
|
18323
18361
|
app2.use("/admin/*", menuMiddleware());
|
|
18324
18362
|
const NAV_LANDING = [
|
|
@@ -18336,7 +18374,7 @@ function createSonicJSApp(config = {}) {
|
|
|
18336
18374
|
if (!user?.userId) return next();
|
|
18337
18375
|
let perms = [];
|
|
18338
18376
|
try {
|
|
18339
|
-
const { RbacService: RbacService2 } = await import('./rbac-
|
|
18377
|
+
const { RbacService: RbacService2 } = await import('./rbac-AORZ6O3N.cjs');
|
|
18340
18378
|
perms = await new RbacService2(c.env.DB, c.env.CACHE_KV).permissionsForUser(user.userId);
|
|
18341
18379
|
} catch {
|
|
18342
18380
|
return next();
|
|
@@ -18365,43 +18403,43 @@ function createSonicJSApp(config = {}) {
|
|
|
18365
18403
|
});
|
|
18366
18404
|
app2.route("/api/security-audit", apiRoutes2);
|
|
18367
18405
|
app2.route("/admin/plugins/security-audit", adminRoutes3);
|
|
18368
|
-
app2.route("/api/media",
|
|
18369
|
-
app2.route("/api/system",
|
|
18370
|
-
app2.route("/api/documents",
|
|
18371
|
-
app2.route("/api",
|
|
18372
|
-
app2.route("/admin/documents",
|
|
18373
|
-
|
|
18374
|
-
app2.route("/admin/api",
|
|
18375
|
-
app2.route("/admin/collections",
|
|
18376
|
-
app2.route("/admin/settings",
|
|
18377
|
-
app2.route("/admin/api-reference",
|
|
18406
|
+
app2.route("/api/media", chunk6OA77UM7_cjs.api_media_default);
|
|
18407
|
+
app2.route("/api/system", chunk6OA77UM7_cjs.api_system_default);
|
|
18408
|
+
app2.route("/api/documents", chunk6OA77UM7_cjs.apiDocumentsRoutes);
|
|
18409
|
+
app2.route("/api", chunk6OA77UM7_cjs.api_default);
|
|
18410
|
+
app2.route("/admin/documents", chunk6OA77UM7_cjs.adminDocumentsRoutes);
|
|
18411
|
+
chunkI7MIRRFJ_cjs.registerPluginRoutes(app2, [formsPlugin], { source: "core" });
|
|
18412
|
+
app2.route("/admin/api", chunk6OA77UM7_cjs.admin_api_default);
|
|
18413
|
+
app2.route("/admin/collections", chunk6OA77UM7_cjs.adminCollectionsRoutes);
|
|
18414
|
+
app2.route("/admin/settings", chunk6OA77UM7_cjs.adminSettingsRoutes);
|
|
18415
|
+
app2.route("/admin/api-reference", chunk6OA77UM7_cjs.router2);
|
|
18378
18416
|
app2.route("/admin/database-tools", createDatabaseToolsAdminRoutes());
|
|
18379
|
-
app2.route("/admin/content",
|
|
18380
|
-
app2.route("/admin/media",
|
|
18417
|
+
app2.route("/admin/content", chunk6OA77UM7_cjs.admin_content_default);
|
|
18418
|
+
app2.route("/admin/media", chunk6OA77UM7_cjs.adminMediaRoutes);
|
|
18381
18419
|
app2.use("/auth/*", securityAuditMiddleware());
|
|
18382
18420
|
if (!config.plugins?.disableAll) {
|
|
18383
|
-
|
|
18421
|
+
chunkI7MIRRFJ_cjs.registerPluginRoutes(app2, corePluginsBeforeCatchAll, { source: "core" });
|
|
18384
18422
|
app2.route("/admin/cache", cache_default.getRoutes());
|
|
18385
18423
|
if (config.plugins?.register && config.plugins.register.length > 0) {
|
|
18386
|
-
|
|
18424
|
+
chunkI7MIRRFJ_cjs.registerPluginRoutes(app2, config.plugins.register, { source: "user" });
|
|
18387
18425
|
}
|
|
18388
18426
|
}
|
|
18389
18427
|
app2.route("/api/events", apiRoutes4);
|
|
18390
|
-
app2.route("/admin/dashboard",
|
|
18391
|
-
app2.route("/admin/plugins",
|
|
18392
|
-
app2.route("/admin/logs",
|
|
18428
|
+
app2.route("/admin/dashboard", chunk6OA77UM7_cjs.router);
|
|
18429
|
+
app2.route("/admin/plugins", chunk6OA77UM7_cjs.adminPluginRoutes);
|
|
18430
|
+
app2.route("/admin/logs", chunk6OA77UM7_cjs.adminLogsRoutes);
|
|
18393
18431
|
app2.route("/admin/rbac", adminRbacRoutes);
|
|
18394
|
-
app2.route("/admin",
|
|
18395
|
-
app2.route("/auth",
|
|
18432
|
+
app2.route("/admin", chunk6OA77UM7_cjs.userRoutes);
|
|
18433
|
+
app2.route("/auth", chunk6OA77UM7_cjs.auth_default);
|
|
18396
18434
|
app2.on(["GET", "POST"], "/auth/*", (c) => {
|
|
18397
18435
|
const reqUrl = new URL(c.req.url);
|
|
18398
18436
|
const requestBaseURL = `${reqUrl.protocol}//${reqUrl.host}`;
|
|
18399
|
-
const auth =
|
|
18437
|
+
const auth = chunkRSBZITK3_cjs.createAuth(c.env, config.auth?.extendBetterAuth, requestBaseURL);
|
|
18400
18438
|
return auth.handler(c.req.raw);
|
|
18401
18439
|
});
|
|
18402
|
-
app2.route("/",
|
|
18440
|
+
app2.route("/", chunk6OA77UM7_cjs.test_cleanup_default);
|
|
18403
18441
|
if (!config.plugins?.disableAll) {
|
|
18404
|
-
|
|
18442
|
+
chunkI7MIRRFJ_cjs.registerPluginRoutes(app2, corePluginsAfterCatchAll, { source: "core" });
|
|
18405
18443
|
}
|
|
18406
18444
|
if (!config.plugins?.disableAll) {
|
|
18407
18445
|
const allMountedPlugins = [
|
|
@@ -18411,10 +18449,10 @@ function createSonicJSApp(config = {}) {
|
|
|
18411
18449
|
...config.plugins?.register ?? []
|
|
18412
18450
|
];
|
|
18413
18451
|
const userPlugins = (config.plugins?.register ?? []).filter(
|
|
18414
|
-
(p) => !
|
|
18452
|
+
(p) => !chunkYAURVGUK_cjs.PLUGIN_REGISTRY[p.id]
|
|
18415
18453
|
);
|
|
18416
|
-
|
|
18417
|
-
|
|
18454
|
+
chunkD6FWEYQE_cjs.setPluginMenu(userPlugins.flatMap((p) => (p.menu ?? []).map((m) => ({ ...m, pluginId: p.id }))));
|
|
18455
|
+
chunkD6FWEYQE_cjs.setPluginDefinitions(allMountedPlugins);
|
|
18418
18456
|
}
|
|
18419
18457
|
app2.get("/favicon.svg", (c) => {
|
|
18420
18458
|
return new Response(faviconSvg, {
|
|
@@ -19282,7 +19320,7 @@ var RedirectService = class {
|
|
|
19282
19320
|
env;
|
|
19283
19321
|
cloudflareService = null;
|
|
19284
19322
|
getDocService() {
|
|
19285
|
-
return new
|
|
19323
|
+
return new chunkJCBDXEY2_cjs.DocumentsService(this.db, {
|
|
19286
19324
|
queryableFields: REDIRECT_QUERYABLE_FIELDS,
|
|
19287
19325
|
maxVersionsPerRoot: 1,
|
|
19288
19326
|
tenantId: TENANT3
|
|
@@ -20585,7 +20623,7 @@ function renderLayout(title, content2) {
|
|
|
20585
20623
|
}
|
|
20586
20624
|
</style>
|
|
20587
20625
|
`;
|
|
20588
|
-
return
|
|
20626
|
+
return chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst({
|
|
20589
20627
|
title,
|
|
20590
20628
|
currentPath: "/admin/redirects",
|
|
20591
20629
|
content: customStyles + content2.toString()
|
|
@@ -20950,7 +20988,7 @@ function getFormScripts() {
|
|
|
20950
20988
|
`;
|
|
20951
20989
|
}
|
|
20952
20990
|
function renderLayout2(title, content2) {
|
|
20953
|
-
return
|
|
20991
|
+
return chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst({
|
|
20954
20992
|
title,
|
|
20955
20993
|
currentPath: "/admin/redirects",
|
|
20956
20994
|
content: content2.toString()
|
|
@@ -21908,7 +21946,7 @@ function createRedirectApiRoutes() {
|
|
|
21908
21946
|
});
|
|
21909
21947
|
return api;
|
|
21910
21948
|
}
|
|
21911
|
-
var redirectPlugin =
|
|
21949
|
+
var redirectPlugin = chunkD6FWEYQE_cjs.definePlugin({
|
|
21912
21950
|
id: manifest_default3.id,
|
|
21913
21951
|
version: manifest_default3.version,
|
|
21914
21952
|
name: manifest_default3.name,
|
|
@@ -21926,7 +21964,7 @@ var redirectPlugin = chunk4WMZGHIC_cjs.definePlugin({
|
|
|
21926
21964
|
async onBoot(ctx) {
|
|
21927
21965
|
const db = ctx.env?.DB;
|
|
21928
21966
|
if (!db) return;
|
|
21929
|
-
const registry = new
|
|
21967
|
+
const registry = new chunkE7E3NL3Y_cjs.DocumentTypeRegistry(db);
|
|
21930
21968
|
await registry.register({
|
|
21931
21969
|
id: "redirect",
|
|
21932
21970
|
name: "redirect",
|
|
@@ -22040,93 +22078,920 @@ var site_settings_collection_default = {
|
|
|
22040
22078
|
function createDb(d1$1) {
|
|
22041
22079
|
return d1.drizzle(d1$1, { schema: chunkYP7GW2G5_cjs.schema_exports });
|
|
22042
22080
|
}
|
|
22081
|
+
var mcpTypeConfigSchema = zod.z.object({
|
|
22082
|
+
read: zod.z.boolean().default(true),
|
|
22083
|
+
write: zod.z.boolean().default(true)
|
|
22084
|
+
});
|
|
22085
|
+
var mcpConfigSchema = zod.z.object({
|
|
22086
|
+
/** Collections exposed over MCP. Omitted → every active collection. */
|
|
22087
|
+
expose: zod.z.array(zod.z.string()).optional(),
|
|
22088
|
+
/** Per-collection read/write overrides, keyed by collection name. */
|
|
22089
|
+
types: zod.z.record(zod.z.string(), mcpTypeConfigSchema).default({}),
|
|
22090
|
+
/** Field names stripped from every tool response + write schema. */
|
|
22091
|
+
redactFields: zod.z.array(zod.z.string()).default([]),
|
|
22092
|
+
/** Max documents returned by list_* tools and document resources. */
|
|
22093
|
+
listLimit: zod.z.number().int().positive().max(200).default(50)
|
|
22094
|
+
});
|
|
22095
|
+
function resolveMcpConfig(raw, collections) {
|
|
22096
|
+
const cfg = mcpConfigSchema.parse(raw ?? {});
|
|
22097
|
+
const exposeSet = cfg.expose ? new Set(cfg.expose) : null;
|
|
22098
|
+
const types = collections.filter((c) => exposeSet ? exposeSet.has(c.name) : true).map((c) => {
|
|
22099
|
+
const override = cfg.types[c.name];
|
|
22100
|
+
return {
|
|
22101
|
+
typeId: c.name,
|
|
22102
|
+
displayName: c.displayName ?? c.name,
|
|
22103
|
+
read: override?.read ?? true,
|
|
22104
|
+
write: override?.write ?? true
|
|
22105
|
+
};
|
|
22106
|
+
});
|
|
22107
|
+
return { types, redactFields: cfg.redactFields, listLimit: cfg.listLimit };
|
|
22108
|
+
}
|
|
22109
|
+
|
|
22110
|
+
// src/plugins/core-plugins/mcp-plugin/schema/field-to-jsonschema.ts
|
|
22111
|
+
var SYSTEM_FIELDS = /* @__PURE__ */ new Set([
|
|
22112
|
+
"id",
|
|
22113
|
+
"root_id",
|
|
22114
|
+
"rootId",
|
|
22115
|
+
"created_at",
|
|
22116
|
+
"createdAt",
|
|
22117
|
+
"updated_at",
|
|
22118
|
+
"updatedAt",
|
|
22119
|
+
"version_number",
|
|
22120
|
+
"versionNumber"
|
|
22121
|
+
]);
|
|
22122
|
+
function fieldToJsonSchema(field) {
|
|
22123
|
+
const base = {};
|
|
22124
|
+
if (field.title) base.title = field.title;
|
|
22125
|
+
if (field.description) base.description = field.description;
|
|
22126
|
+
switch (field.type) {
|
|
22127
|
+
case "number":
|
|
22128
|
+
return {
|
|
22129
|
+
...base,
|
|
22130
|
+
type: "number",
|
|
22131
|
+
...field.min != null ? { minimum: field.min } : {},
|
|
22132
|
+
...field.max != null ? { maximum: field.max } : {}
|
|
22133
|
+
};
|
|
22134
|
+
case "boolean":
|
|
22135
|
+
case "checkbox":
|
|
22136
|
+
return { ...base, type: "boolean" };
|
|
22137
|
+
case "date":
|
|
22138
|
+
case "datetime":
|
|
22139
|
+
return { ...base, type: "string", format: "date-time" };
|
|
22140
|
+
case "select":
|
|
22141
|
+
case "radio":
|
|
22142
|
+
return { ...base, type: "string", ...field.enum ? { enum: field.enum } : {} };
|
|
22143
|
+
case "multiselect":
|
|
22144
|
+
return {
|
|
22145
|
+
...base,
|
|
22146
|
+
type: "array",
|
|
22147
|
+
items: { type: "string", ...field.enum ? { enum: field.enum } : {} }
|
|
22148
|
+
};
|
|
22149
|
+
case "array":
|
|
22150
|
+
return {
|
|
22151
|
+
...base,
|
|
22152
|
+
type: "array",
|
|
22153
|
+
items: field.items ? fieldToJsonSchema(field.items) : {}
|
|
22154
|
+
};
|
|
22155
|
+
case "object":
|
|
22156
|
+
return {
|
|
22157
|
+
...base,
|
|
22158
|
+
type: "object",
|
|
22159
|
+
...field.properties ? { properties: mapProperties(field.properties) } : {}
|
|
22160
|
+
};
|
|
22161
|
+
case "json":
|
|
22162
|
+
return { ...base };
|
|
22163
|
+
// string-like: string, slug, email, url, richtext, markdown, textarea, editors,
|
|
22164
|
+
// reference, media, color, file, user
|
|
22165
|
+
default: {
|
|
22166
|
+
const node = { ...base, type: "string" };
|
|
22167
|
+
if (field.minLength != null) node.minLength = field.minLength;
|
|
22168
|
+
if (field.maxLength != null) node.maxLength = field.maxLength;
|
|
22169
|
+
if (field.pattern) node.pattern = field.pattern;
|
|
22170
|
+
if (field.format) node.format = field.format;
|
|
22171
|
+
return node;
|
|
22172
|
+
}
|
|
22173
|
+
}
|
|
22174
|
+
}
|
|
22175
|
+
function mapProperties(props) {
|
|
22176
|
+
const out = {};
|
|
22177
|
+
for (const [name, field] of Object.entries(props)) {
|
|
22178
|
+
out[name] = fieldToJsonSchema(field);
|
|
22179
|
+
}
|
|
22180
|
+
return out;
|
|
22181
|
+
}
|
|
22182
|
+
function collectionToJsonSchema(schema, opts = {}) {
|
|
22183
|
+
const properties = {};
|
|
22184
|
+
const required = [];
|
|
22185
|
+
const redact2 = new Set(opts.redactFields ?? []);
|
|
22186
|
+
const schemaRequired = new Set(schema.required ?? []);
|
|
22187
|
+
for (const [name, field] of Object.entries(schema.properties ?? {})) {
|
|
22188
|
+
if (redact2.has(name)) continue;
|
|
22189
|
+
if (opts.forWrite && SYSTEM_FIELDS.has(name)) continue;
|
|
22190
|
+
properties[name] = fieldToJsonSchema(field);
|
|
22191
|
+
if (field.required || schemaRequired.has(name)) required.push(name);
|
|
22192
|
+
}
|
|
22193
|
+
return { type: "object", properties, ...required.length ? { required } : {} };
|
|
22194
|
+
}
|
|
22195
|
+
|
|
22196
|
+
// src/plugins/core-plugins/mcp-plugin/tools/registry.ts
|
|
22197
|
+
var PHASE_FLAGS = { includeWrite: true, includeSearch: false };
|
|
22198
|
+
var EMPTY_OBJECT_SCHEMA = { type: "object", properties: {} };
|
|
22199
|
+
function buildToolRegistry(cfg, collections, opts = {}) {
|
|
22200
|
+
const tools = [];
|
|
22201
|
+
tools.push({
|
|
22202
|
+
name: "list_collections",
|
|
22203
|
+
description: "List every content collection exposed over MCP, with its read/write access.",
|
|
22204
|
+
inputSchema: EMPTY_OBJECT_SCHEMA,
|
|
22205
|
+
op: "list_collections"
|
|
22206
|
+
});
|
|
22207
|
+
if (opts.includeSearch) {
|
|
22208
|
+
tools.push({
|
|
22209
|
+
name: "search_content",
|
|
22210
|
+
description: "Search content across exposed collections by title or slug.",
|
|
22211
|
+
inputSchema: {
|
|
22212
|
+
type: "object",
|
|
22213
|
+
properties: { query: { type: "string", description: "Text matched against document title and slug." } },
|
|
22214
|
+
required: ["query"]
|
|
22215
|
+
},
|
|
22216
|
+
op: "search_content"
|
|
22217
|
+
});
|
|
22218
|
+
}
|
|
22219
|
+
for (const t of cfg.types) {
|
|
22220
|
+
const col = collections.get(t.typeId);
|
|
22221
|
+
const writeSchema = col ? collectionToJsonSchema(col.schema, { forWrite: true, redactFields: cfg.redactFields }) : EMPTY_OBJECT_SCHEMA;
|
|
22222
|
+
if (t.read) {
|
|
22223
|
+
tools.push({
|
|
22224
|
+
name: `list_${t.typeId}`,
|
|
22225
|
+
description: `List ${t.displayName} documents.`,
|
|
22226
|
+
inputSchema: {
|
|
22227
|
+
type: "object",
|
|
22228
|
+
properties: {
|
|
22229
|
+
status: {
|
|
22230
|
+
type: "string",
|
|
22231
|
+
enum: ["published", "draft"],
|
|
22232
|
+
description: "Lifecycle to list. Defaults to published."
|
|
22233
|
+
},
|
|
22234
|
+
limit: { type: "number", description: `Max documents to return (capped at ${cfg.listLimit}).` }
|
|
22235
|
+
}
|
|
22236
|
+
},
|
|
22237
|
+
op: "list",
|
|
22238
|
+
typeId: t.typeId
|
|
22239
|
+
});
|
|
22240
|
+
tools.push({
|
|
22241
|
+
name: `get_${t.typeId}`,
|
|
22242
|
+
description: `Get one ${t.displayName} document by id or slug.`,
|
|
22243
|
+
inputSchema: {
|
|
22244
|
+
type: "object",
|
|
22245
|
+
properties: {
|
|
22246
|
+
id: { type: "string", description: "Document id or root id." },
|
|
22247
|
+
slug: { type: "string", description: "Document slug (alternative to id)." }
|
|
22248
|
+
}
|
|
22249
|
+
},
|
|
22250
|
+
op: "get",
|
|
22251
|
+
typeId: t.typeId
|
|
22252
|
+
});
|
|
22253
|
+
}
|
|
22254
|
+
if (opts.includeWrite && t.write) {
|
|
22255
|
+
tools.push({
|
|
22256
|
+
name: `create_${t.typeId}`,
|
|
22257
|
+
description: `Create a ${t.displayName} document.`,
|
|
22258
|
+
inputSchema: {
|
|
22259
|
+
type: "object",
|
|
22260
|
+
properties: {
|
|
22261
|
+
title: { type: "string" },
|
|
22262
|
+
slug: { type: "string" },
|
|
22263
|
+
data: writeSchema,
|
|
22264
|
+
publish: { type: "boolean", description: "Publish immediately. Defaults to false (draft)." }
|
|
22265
|
+
}
|
|
22266
|
+
},
|
|
22267
|
+
op: "create",
|
|
22268
|
+
typeId: t.typeId
|
|
22269
|
+
});
|
|
22270
|
+
tools.push({
|
|
22271
|
+
name: `update_${t.typeId}`,
|
|
22272
|
+
description: `Update a ${t.displayName} document (saves a new draft).`,
|
|
22273
|
+
inputSchema: {
|
|
22274
|
+
type: "object",
|
|
22275
|
+
properties: {
|
|
22276
|
+
id: { type: "string", description: "Root id of the document to update." },
|
|
22277
|
+
title: { type: "string" },
|
|
22278
|
+
slug: { type: "string" },
|
|
22279
|
+
data: writeSchema
|
|
22280
|
+
},
|
|
22281
|
+
required: ["id"]
|
|
22282
|
+
},
|
|
22283
|
+
op: "update",
|
|
22284
|
+
typeId: t.typeId
|
|
22285
|
+
});
|
|
22286
|
+
tools.push({
|
|
22287
|
+
name: `publish_${t.typeId}`,
|
|
22288
|
+
description: `Publish a ${t.displayName} document.`,
|
|
22289
|
+
inputSchema: {
|
|
22290
|
+
type: "object",
|
|
22291
|
+
properties: { id: { type: "string", description: "Root id of the document to publish." } },
|
|
22292
|
+
required: ["id"]
|
|
22293
|
+
},
|
|
22294
|
+
op: "publish",
|
|
22295
|
+
typeId: t.typeId
|
|
22296
|
+
});
|
|
22297
|
+
tools.push({
|
|
22298
|
+
name: `delete_${t.typeId}`,
|
|
22299
|
+
description: `Delete a ${t.displayName} document.`,
|
|
22300
|
+
inputSchema: {
|
|
22301
|
+
type: "object",
|
|
22302
|
+
properties: { id: { type: "string", description: "Root id of the document to delete." } },
|
|
22303
|
+
required: ["id"]
|
|
22304
|
+
},
|
|
22305
|
+
op: "delete",
|
|
22306
|
+
typeId: t.typeId
|
|
22307
|
+
});
|
|
22308
|
+
}
|
|
22309
|
+
}
|
|
22310
|
+
return tools;
|
|
22311
|
+
}
|
|
22312
|
+
|
|
22313
|
+
// src/plugins/core-plugins/mcp-plugin/jsonrpc.ts
|
|
22314
|
+
var JSON_RPC = {
|
|
22315
|
+
PARSE_ERROR: -32700,
|
|
22316
|
+
INVALID_REQUEST: -32600,
|
|
22317
|
+
METHOD_NOT_FOUND: -32601,
|
|
22318
|
+
INVALID_PARAMS: -32602,
|
|
22319
|
+
INTERNAL_ERROR: -32603,
|
|
22320
|
+
/** Custom: no valid API key on the request. */
|
|
22321
|
+
UNAUTHORIZED: -32001
|
|
22322
|
+
};
|
|
22323
|
+
var McpToolError = class extends Error {
|
|
22324
|
+
constructor(message) {
|
|
22325
|
+
super(message);
|
|
22326
|
+
this.name = "McpToolError";
|
|
22327
|
+
}
|
|
22328
|
+
};
|
|
22329
|
+
function rpcResult(id, result) {
|
|
22330
|
+
return { jsonrpc: "2.0", id: id ?? null, result };
|
|
22331
|
+
}
|
|
22332
|
+
function rpcError(id, code, message, data) {
|
|
22333
|
+
return { jsonrpc: "2.0", id: id ?? null, error: { code, message, ...{} } };
|
|
22334
|
+
}
|
|
22335
|
+
function parseJsonRpc(body) {
|
|
22336
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) {
|
|
22337
|
+
return { error: { code: JSON_RPC.INVALID_REQUEST, message: "Request must be a JSON object" } };
|
|
22338
|
+
}
|
|
22339
|
+
const b = body;
|
|
22340
|
+
if (b.jsonrpc !== "2.0") {
|
|
22341
|
+
return { error: { code: JSON_RPC.INVALID_REQUEST, message: 'jsonrpc must be "2.0"' } };
|
|
22342
|
+
}
|
|
22343
|
+
if (typeof b.method !== "string" || b.method.length === 0) {
|
|
22344
|
+
return { error: { code: JSON_RPC.INVALID_REQUEST, message: "method must be a non-empty string" } };
|
|
22345
|
+
}
|
|
22346
|
+
const id = b.id === void 0 ? null : b.id;
|
|
22347
|
+
const params = b.params && typeof b.params === "object" && !Array.isArray(b.params) ? b.params : {};
|
|
22348
|
+
return { jsonrpc: "2.0", id, method: b.method, params };
|
|
22349
|
+
}
|
|
22350
|
+
|
|
22351
|
+
// src/plugins/core-plugins/mcp-plugin/tools/documents.ts
|
|
22352
|
+
function redact(data, fields) {
|
|
22353
|
+
if (!fields.length) return data;
|
|
22354
|
+
const out = { ...data };
|
|
22355
|
+
for (const f of fields) delete out[f];
|
|
22356
|
+
return out;
|
|
22357
|
+
}
|
|
22358
|
+
function shapeDocument(doc, redactFields) {
|
|
22359
|
+
return {
|
|
22360
|
+
id: doc.id,
|
|
22361
|
+
rootId: doc.rootId,
|
|
22362
|
+
typeId: doc.typeId,
|
|
22363
|
+
title: doc.title,
|
|
22364
|
+
slug: doc.slug,
|
|
22365
|
+
status: doc.status,
|
|
22366
|
+
isPublished: doc.isPublished,
|
|
22367
|
+
publishedAt: doc.publishedAt,
|
|
22368
|
+
updatedAt: doc.updatedAt,
|
|
22369
|
+
data: redact(doc.data, redactFields)
|
|
22370
|
+
};
|
|
22371
|
+
}
|
|
22372
|
+
async function resolveType(ctx, typeId) {
|
|
22373
|
+
const docType = await new chunkE7E3NL3Y_cjs.DocumentTypeRegistry(ctx.db).findById(typeId);
|
|
22374
|
+
if (!docType || !docType.isActive) throw new McpToolError(`Unknown document type: ${typeId}`);
|
|
22375
|
+
const effTenant = chunk6OA77UM7_cjs.effectiveTenantForType(ctx.tenantId, docType.settings);
|
|
22376
|
+
const repo = new chunk6OA77UM7_cjs.DocumentRepository(ctx.db, effTenant);
|
|
22377
|
+
return { docType, repo };
|
|
22378
|
+
}
|
|
22379
|
+
async function execList(ctx, typeId, args) {
|
|
22380
|
+
const { docType, repo } = await resolveType(ctx, typeId);
|
|
22381
|
+
const status = args.status === "draft" ? "draft" : "published";
|
|
22382
|
+
const limit = Math.min(Math.max(1, args.limit ?? ctx.listLimit), ctx.listLimit);
|
|
22383
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
22384
|
+
const docs = await repo.list({
|
|
22385
|
+
typeId,
|
|
22386
|
+
status,
|
|
22387
|
+
timeWindow: status === "published",
|
|
22388
|
+
now,
|
|
22389
|
+
limit
|
|
22390
|
+
});
|
|
22391
|
+
const allowed = await Promise.all(
|
|
22392
|
+
docs.map((d) => repo.isAllowed(ctx.principalSet, d.rootId, "read", docType.settings))
|
|
22393
|
+
);
|
|
22394
|
+
return docs.filter((_, i) => allowed[i]).map((d) => shapeDocument(d, ctx.redactFields));
|
|
22395
|
+
}
|
|
22396
|
+
async function execGet(ctx, typeId, args) {
|
|
22397
|
+
const { docType, repo } = await resolveType(ctx, typeId);
|
|
22398
|
+
let doc = null;
|
|
22399
|
+
if (args.id) {
|
|
22400
|
+
doc = await repo.getById(args.id) ?? await repo.getPublished(args.id) ?? await repo.getCurrentDraft(args.id);
|
|
22401
|
+
} else if (args.slug) {
|
|
22402
|
+
doc = await repo.getBySlug(typeId, args.slug);
|
|
22403
|
+
} else {
|
|
22404
|
+
throw new McpToolError('get requires an "id" or "slug" argument');
|
|
22405
|
+
}
|
|
22406
|
+
if (!doc || doc.typeId !== typeId) throw new McpToolError("Document not found");
|
|
22407
|
+
const ok = await repo.isAllowed(ctx.principalSet, doc.rootId, "read", docType.settings);
|
|
22408
|
+
if (!ok) throw new McpToolError("Document not found");
|
|
22409
|
+
return shapeDocument(doc, ctx.redactFields);
|
|
22410
|
+
}
|
|
22411
|
+
|
|
22412
|
+
// src/plugins/core-plugins/mcp-plugin/tools/mutations.ts
|
|
22413
|
+
async function resolveWriteScope(ctx, typeId) {
|
|
22414
|
+
const docType = await new chunkE7E3NL3Y_cjs.DocumentTypeRegistry(ctx.db).findById(typeId);
|
|
22415
|
+
if (!docType || !docType.isActive) throw new McpToolError(`Unknown document type: ${typeId}`);
|
|
22416
|
+
const effTenant = chunk6OA77UM7_cjs.effectiveTenantForType(ctx.tenantId, docType.settings);
|
|
22417
|
+
const repo = new chunk6OA77UM7_cjs.DocumentRepository(ctx.db, effTenant);
|
|
22418
|
+
const svc = new chunkJCBDXEY2_cjs.DocumentsService(ctx.db, {
|
|
22419
|
+
queryableFields: docType.queryableFields ?? [],
|
|
22420
|
+
typeSchemaVersion: docType.schemaVersion,
|
|
22421
|
+
maxVersionsPerRoot: docType.settings?.maxVersionsPerRoot,
|
|
22422
|
+
tenantId: effTenant,
|
|
22423
|
+
versioning: docType.settings?.versioning ?? false
|
|
22424
|
+
});
|
|
22425
|
+
return { docType, effTenant, repo, svc };
|
|
22426
|
+
}
|
|
22427
|
+
async function assertAllowed(scope, ctx, rootId, permission) {
|
|
22428
|
+
const ok = await scope.repo.isAllowed(ctx.principalSet, rootId, permission, scope.docType.settings ?? {});
|
|
22429
|
+
if (!ok) throw new McpToolError(`Permission denied: cannot ${permission} ${scope.docType.id}`);
|
|
22430
|
+
}
|
|
22431
|
+
function applyUserFieldDefaults(data, typeId, userId) {
|
|
22432
|
+
const col = chunkYAURVGUK_cjs.getCollectionRegistry().getByName(typeId);
|
|
22433
|
+
if (!col?.schema?.properties) return data;
|
|
22434
|
+
const props = col.schema.properties;
|
|
22435
|
+
const patched = { ...data };
|
|
22436
|
+
for (const [name, field] of Object.entries(props)) {
|
|
22437
|
+
if (field.type === "user" && !patched[name]) patched[name] = userId;
|
|
22438
|
+
}
|
|
22439
|
+
return patched;
|
|
22440
|
+
}
|
|
22441
|
+
async function execCreate(ctx, typeId, args) {
|
|
22442
|
+
const scope = await resolveWriteScope(ctx, typeId);
|
|
22443
|
+
await assertAllowed(scope, ctx, "", "create");
|
|
22444
|
+
const data = redact(applyUserFieldDefaults(args.data ?? {}, typeId, ctx.userId), ctx.redactFields);
|
|
22445
|
+
const input = chunk6OA77UM7_cjs.createDocumentSchema.parse({
|
|
22446
|
+
typeId,
|
|
22447
|
+
tenantId: scope.effTenant,
|
|
22448
|
+
title: args.title ?? null,
|
|
22449
|
+
slug: args.slug ?? null,
|
|
22450
|
+
data,
|
|
22451
|
+
ownerId: ctx.userId,
|
|
22452
|
+
publishOnCreate: Boolean(args.publish)
|
|
22453
|
+
});
|
|
22454
|
+
const doc = await scope.svc.create(input, ctx.userId);
|
|
22455
|
+
return shapeDocument(doc, ctx.redactFields);
|
|
22456
|
+
}
|
|
22457
|
+
async function execUpdate(ctx, typeId, args) {
|
|
22458
|
+
if (!args.id) throw new McpToolError('update requires an "id" (root id)');
|
|
22459
|
+
const scope = await resolveWriteScope(ctx, typeId);
|
|
22460
|
+
const current = await scope.repo.getCurrentDraft(args.id);
|
|
22461
|
+
if (!current || current.typeId !== typeId) throw new McpToolError("Document not found");
|
|
22462
|
+
await assertAllowed(scope, ctx, args.id, "update");
|
|
22463
|
+
const patch = chunk6OA77UM7_cjs.updateDocumentSchema.parse({
|
|
22464
|
+
...args.title !== void 0 ? { title: args.title } : {},
|
|
22465
|
+
...args.slug !== void 0 ? { slug: args.slug } : {},
|
|
22466
|
+
...args.data !== void 0 ? { data: redact(args.data, ctx.redactFields) } : {}
|
|
22467
|
+
});
|
|
22468
|
+
const doc = await scope.svc.saveDraft(args.id, patch, ctx.userId);
|
|
22469
|
+
return shapeDocument(doc, ctx.redactFields);
|
|
22470
|
+
}
|
|
22471
|
+
async function execPublish(ctx, typeId, args) {
|
|
22472
|
+
if (!args.id) throw new McpToolError('publish requires an "id" (root id)');
|
|
22473
|
+
const scope = await resolveWriteScope(ctx, typeId);
|
|
22474
|
+
const current = await scope.repo.getCurrentDraft(args.id);
|
|
22475
|
+
if (!current || current.typeId !== typeId) throw new McpToolError("Document not found");
|
|
22476
|
+
await assertAllowed(scope, ctx, args.id, "publish");
|
|
22477
|
+
const doc = await scope.svc.publish(current.id, ctx.userId);
|
|
22478
|
+
return shapeDocument(doc, ctx.redactFields);
|
|
22479
|
+
}
|
|
22480
|
+
async function execDelete(ctx, typeId, args) {
|
|
22481
|
+
if (!args.id) throw new McpToolError('delete requires an "id" (root id)');
|
|
22482
|
+
const scope = await resolveWriteScope(ctx, typeId);
|
|
22483
|
+
const current = await scope.repo.getCurrentDraft(args.id) ?? await scope.repo.getPublished(args.id);
|
|
22484
|
+
if (!current || current.typeId !== typeId) throw new McpToolError("Document not found");
|
|
22485
|
+
await assertAllowed(scope, ctx, args.id, "delete");
|
|
22486
|
+
if (scope.docType.settings?.pii) {
|
|
22487
|
+
await scope.svc.erase(args.id, scope.effTenant);
|
|
22488
|
+
return { rootId: args.id, deleted: true, erased: true };
|
|
22489
|
+
}
|
|
22490
|
+
const ids = /* @__PURE__ */ new Set();
|
|
22491
|
+
ids.add(current.id);
|
|
22492
|
+
if (current.isCurrentDraft) {
|
|
22493
|
+
const published = await scope.repo.getPublished(args.id);
|
|
22494
|
+
if (published) ids.add(published.id);
|
|
22495
|
+
} else {
|
|
22496
|
+
const draft = await scope.repo.getCurrentDraft(args.id);
|
|
22497
|
+
if (draft) ids.add(draft.id);
|
|
22498
|
+
}
|
|
22499
|
+
for (const id of ids) await scope.svc.softDelete(id);
|
|
22500
|
+
return { rootId: args.id, deleted: true, erased: false };
|
|
22501
|
+
}
|
|
22502
|
+
|
|
22503
|
+
// src/plugins/core-plugins/mcp-plugin/tools/static.ts
|
|
22504
|
+
function execListCollections(types) {
|
|
22505
|
+
return types.map((t) => ({ typeId: t.typeId, displayName: t.displayName, read: t.read, write: t.write }));
|
|
22506
|
+
}
|
|
22507
|
+
|
|
22508
|
+
// src/plugins/core-plugins/mcp-plugin/resources/schemas.ts
|
|
22509
|
+
function buildResourceList(cfg) {
|
|
22510
|
+
const out = [
|
|
22511
|
+
{ uri: "sonicjs://collections", name: "All collections", mimeType: "application/json" }
|
|
22512
|
+
];
|
|
22513
|
+
for (const t of cfg.types) {
|
|
22514
|
+
out.push({
|
|
22515
|
+
uri: `sonicjs://collections/${t.typeId}/schema`,
|
|
22516
|
+
name: `${t.displayName} schema`,
|
|
22517
|
+
mimeType: "application/json"
|
|
22518
|
+
});
|
|
22519
|
+
}
|
|
22520
|
+
return out;
|
|
22521
|
+
}
|
|
22522
|
+
var SCHEMA_URI = /^sonicjs:\/\/collections\/([^/]+)\/schema$/;
|
|
22523
|
+
function readResource(uri, cfg, collections) {
|
|
22524
|
+
if (uri === "sonicjs://collections") {
|
|
22525
|
+
const list = cfg.types.map((t) => ({
|
|
22526
|
+
typeId: t.typeId,
|
|
22527
|
+
displayName: t.displayName,
|
|
22528
|
+
read: t.read,
|
|
22529
|
+
write: t.write
|
|
22530
|
+
}));
|
|
22531
|
+
return { uri, mimeType: "application/json", text: JSON.stringify(list, null, 2) };
|
|
22532
|
+
}
|
|
22533
|
+
const m = uri.match(SCHEMA_URI);
|
|
22534
|
+
if (m) {
|
|
22535
|
+
const typeId = m[1];
|
|
22536
|
+
const exposed = cfg.types.find((t) => t.typeId === typeId);
|
|
22537
|
+
const col = collections.get(typeId);
|
|
22538
|
+
if (!exposed || !col) throw new McpToolError(`Unknown collection: ${typeId}`);
|
|
22539
|
+
const schema = collectionToJsonSchema(col.schema, { redactFields: cfg.redactFields });
|
|
22540
|
+
return { uri, mimeType: "application/json", text: JSON.stringify(schema, null, 2) };
|
|
22541
|
+
}
|
|
22542
|
+
throw new McpToolError(`Unknown resource URI: ${uri}`);
|
|
22543
|
+
}
|
|
22544
|
+
|
|
22545
|
+
// src/plugins/core-plugins/mcp-plugin/routes/mcp.ts
|
|
22546
|
+
var SERVER_INFO = { name: "sonicjs-mcp", version: "1.0.0" };
|
|
22547
|
+
var PROTOCOL_VERSION = "2024-11-05";
|
|
22548
|
+
function createMcpRoutes(options = {}) {
|
|
22549
|
+
const app2 = new hono.Hono();
|
|
22550
|
+
app2.post("/", async (c) => {
|
|
22551
|
+
let body;
|
|
22552
|
+
try {
|
|
22553
|
+
body = await c.req.json();
|
|
22554
|
+
} catch {
|
|
22555
|
+
return c.json(rpcError(null, JSON_RPC.PARSE_ERROR, "Invalid JSON"));
|
|
22556
|
+
}
|
|
22557
|
+
const parsed = parseJsonRpc(body);
|
|
22558
|
+
if ("error" in parsed) {
|
|
22559
|
+
const id2 = body && typeof body === "object" ? body.id ?? null : null;
|
|
22560
|
+
return c.json(rpcError(id2, parsed.error.code, parsed.error.message));
|
|
22561
|
+
}
|
|
22562
|
+
const { id, method, params } = parsed;
|
|
22563
|
+
const user = c.get("user");
|
|
22564
|
+
if (!user) {
|
|
22565
|
+
return c.json(
|
|
22566
|
+
rpcError(id, JSON_RPC.UNAUTHORIZED, "Unauthorized: provide a valid API key via Authorization: Bearer sk_...")
|
|
22567
|
+
);
|
|
22568
|
+
}
|
|
22569
|
+
const { tenantId, principalSet, userId } = chunk6OA77UM7_cjs.getDocumentRequestContext(c);
|
|
22570
|
+
const registry = chunkYAURVGUK_cjs.getCollectionRegistry();
|
|
22571
|
+
const active = registry.listActive();
|
|
22572
|
+
const collections = new Map(active.map((col) => [col.name, col]));
|
|
22573
|
+
const cfg = resolveMcpConfig(options, active);
|
|
22574
|
+
const tools = buildToolRegistry(cfg, collections, PHASE_FLAGS);
|
|
22575
|
+
try {
|
|
22576
|
+
switch (method) {
|
|
22577
|
+
case "initialize":
|
|
22578
|
+
return c.json(
|
|
22579
|
+
rpcResult(id, {
|
|
22580
|
+
protocolVersion: PROTOCOL_VERSION,
|
|
22581
|
+
serverInfo: SERVER_INFO,
|
|
22582
|
+
capabilities: { tools: {}, resources: {} }
|
|
22583
|
+
})
|
|
22584
|
+
);
|
|
22585
|
+
case "tools/list":
|
|
22586
|
+
return c.json(
|
|
22587
|
+
rpcResult(id, {
|
|
22588
|
+
tools: tools.map((t) => ({ name: t.name, description: t.description, inputSchema: t.inputSchema }))
|
|
22589
|
+
})
|
|
22590
|
+
);
|
|
22591
|
+
case "tools/call": {
|
|
22592
|
+
const name = typeof params.name === "string" ? params.name : "";
|
|
22593
|
+
const args = params.arguments && typeof params.arguments === "object" ? params.arguments : {};
|
|
22594
|
+
const tool = tools.find((t) => t.name === name);
|
|
22595
|
+
if (!tool) return c.json(rpcError(id, JSON_RPC.METHOD_NOT_FOUND, `Unknown tool: ${name}`));
|
|
22596
|
+
const readCtx = {
|
|
22597
|
+
db: c.env.DB,
|
|
22598
|
+
tenantId,
|
|
22599
|
+
principalSet,
|
|
22600
|
+
listLimit: cfg.listLimit,
|
|
22601
|
+
redactFields: cfg.redactFields
|
|
22602
|
+
};
|
|
22603
|
+
const writeCtx = {
|
|
22604
|
+
db: c.env.DB,
|
|
22605
|
+
tenantId,
|
|
22606
|
+
principalSet,
|
|
22607
|
+
userId: userId ?? "",
|
|
22608
|
+
redactFields: cfg.redactFields
|
|
22609
|
+
};
|
|
22610
|
+
try {
|
|
22611
|
+
let result;
|
|
22612
|
+
switch (tool.op) {
|
|
22613
|
+
case "list_collections":
|
|
22614
|
+
result = execListCollections(cfg.types);
|
|
22615
|
+
break;
|
|
22616
|
+
case "list":
|
|
22617
|
+
result = await execList(readCtx, tool.typeId, args);
|
|
22618
|
+
break;
|
|
22619
|
+
case "get":
|
|
22620
|
+
result = await execGet(readCtx, tool.typeId, args);
|
|
22621
|
+
break;
|
|
22622
|
+
case "create":
|
|
22623
|
+
result = await execCreate(writeCtx, tool.typeId, args);
|
|
22624
|
+
break;
|
|
22625
|
+
case "update":
|
|
22626
|
+
result = await execUpdate(writeCtx, tool.typeId, args);
|
|
22627
|
+
break;
|
|
22628
|
+
case "publish":
|
|
22629
|
+
result = await execPublish(writeCtx, tool.typeId, args);
|
|
22630
|
+
break;
|
|
22631
|
+
case "delete":
|
|
22632
|
+
result = await execDelete(writeCtx, tool.typeId, args);
|
|
22633
|
+
break;
|
|
22634
|
+
default:
|
|
22635
|
+
return c.json(rpcError(id, JSON_RPC.METHOD_NOT_FOUND, `Tool not available: ${name}`));
|
|
22636
|
+
}
|
|
22637
|
+
return c.json(rpcResult(id, { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }));
|
|
22638
|
+
} catch (e) {
|
|
22639
|
+
if (e instanceof McpToolError) {
|
|
22640
|
+
return c.json(rpcResult(id, { content: [{ type: "text", text: e.message }], isError: true }));
|
|
22641
|
+
}
|
|
22642
|
+
throw e;
|
|
22643
|
+
}
|
|
22644
|
+
}
|
|
22645
|
+
case "resources/list":
|
|
22646
|
+
return c.json(rpcResult(id, { resources: buildResourceList(cfg) }));
|
|
22647
|
+
case "resources/read": {
|
|
22648
|
+
const uri = typeof params.uri === "string" ? params.uri : "";
|
|
22649
|
+
if (!uri) return c.json(rpcError(id, JSON_RPC.INVALID_PARAMS, 'resources/read requires a "uri" param'));
|
|
22650
|
+
try {
|
|
22651
|
+
const contents = readResource(uri, cfg, collections);
|
|
22652
|
+
return c.json(rpcResult(id, { contents: [contents] }));
|
|
22653
|
+
} catch (e) {
|
|
22654
|
+
if (e instanceof McpToolError) return c.json(rpcError(id, JSON_RPC.INVALID_PARAMS, e.message));
|
|
22655
|
+
throw e;
|
|
22656
|
+
}
|
|
22657
|
+
}
|
|
22658
|
+
default:
|
|
22659
|
+
return c.json(rpcError(id, JSON_RPC.METHOD_NOT_FOUND, `Method not found: ${method}`));
|
|
22660
|
+
}
|
|
22661
|
+
} catch (e) {
|
|
22662
|
+
console.error("[mcp] handler error:", e);
|
|
22663
|
+
return c.json(rpcError(id, JSON_RPC.INTERNAL_ERROR, "Internal error"));
|
|
22664
|
+
}
|
|
22665
|
+
});
|
|
22666
|
+
return app2;
|
|
22667
|
+
}
|
|
22668
|
+
|
|
22669
|
+
// src/plugins/core-plugins/mcp-plugin/admin/templates.ts
|
|
22670
|
+
chunkMI2YXCK4_cjs.init_admin_layout_catalyst_template();
|
|
22671
|
+
function accessBadge(ok) {
|
|
22672
|
+
return ok ? `<span class="inline-flex items-center rounded-full bg-emerald-50 dark:bg-emerald-900/20 px-2 py-0.5 text-xs font-medium text-emerald-700 dark:text-emerald-400 ring-1 ring-emerald-600/20 dark:ring-emerald-400/20">Yes</span>` : `<span class="inline-flex items-center rounded-full bg-zinc-100 dark:bg-zinc-800 px-2 py-0.5 text-xs font-medium text-zinc-500 dark:text-zinc-400 ring-1 ring-zinc-200 dark:ring-zinc-700">No</span>`;
|
|
22673
|
+
}
|
|
22674
|
+
function toolNamesForType(typeId, tools) {
|
|
22675
|
+
const names = tools.filter((t) => t.typeId === typeId).map((t) => `<code class="text-xs font-mono text-zinc-500 dark:text-zinc-400">${chunkMNWKYY5E_cjs.escapeHtml(t.name)}</code>`);
|
|
22676
|
+
return names.length ? names.join('<span class="text-zinc-300 dark:text-zinc-600 mx-1">,</span>') : "\u2014";
|
|
22677
|
+
}
|
|
22678
|
+
function buildClaudeJson(endpointUrl) {
|
|
22679
|
+
return JSON.stringify(
|
|
22680
|
+
{
|
|
22681
|
+
mcpServers: {
|
|
22682
|
+
sonicjs: {
|
|
22683
|
+
type: "http",
|
|
22684
|
+
url: endpointUrl,
|
|
22685
|
+
headers: { Authorization: "Bearer sk_YOUR_API_KEY" }
|
|
22686
|
+
}
|
|
22687
|
+
}
|
|
22688
|
+
},
|
|
22689
|
+
null,
|
|
22690
|
+
2
|
|
22691
|
+
);
|
|
22692
|
+
}
|
|
22693
|
+
function buildCursorJson(endpointUrl) {
|
|
22694
|
+
return JSON.stringify(
|
|
22695
|
+
{
|
|
22696
|
+
mcpServers: {
|
|
22697
|
+
sonicjs: {
|
|
22698
|
+
url: endpointUrl,
|
|
22699
|
+
headers: { Authorization: "Bearer sk_YOUR_API_KEY" }
|
|
22700
|
+
}
|
|
22701
|
+
}
|
|
22702
|
+
},
|
|
22703
|
+
null,
|
|
22704
|
+
2
|
|
22705
|
+
);
|
|
22706
|
+
}
|
|
22707
|
+
function renderMcpDashboardPage(data) {
|
|
22708
|
+
const { endpointUrl, types, tools, user, version, dynamicMenuItems } = data;
|
|
22709
|
+
const safeEndpoint = chunkMNWKYY5E_cjs.escapeHtml(endpointUrl);
|
|
22710
|
+
const typeCount = types.length;
|
|
22711
|
+
const toolCount = tools.length;
|
|
22712
|
+
const typeRows = types.length ? types.map(
|
|
22713
|
+
(t) => `
|
|
22714
|
+
<tr class="border-t border-zinc-950/5 dark:border-white/10">
|
|
22715
|
+
<td class="py-3 pr-4 text-sm font-mono text-zinc-950 dark:text-white">${chunkMNWKYY5E_cjs.escapeHtml(t.typeId)}</td>
|
|
22716
|
+
<td class="py-3 pr-4 text-sm text-zinc-500 dark:text-zinc-400">${chunkMNWKYY5E_cjs.escapeHtml(t.displayName)}</td>
|
|
22717
|
+
<td class="py-3 pr-4">${accessBadge(t.read)}</td>
|
|
22718
|
+
<td class="py-3 pr-4">${accessBadge(t.write)}</td>
|
|
22719
|
+
<td class="py-3 text-sm">${toolNamesForType(t.typeId, tools)}</td>
|
|
22720
|
+
</tr>`
|
|
22721
|
+
).join("") : `<tr><td colspan="5" class="py-8 text-center text-sm text-zinc-500 dark:text-zinc-400">No collections exposed. Register collections via <code class="font-mono">registerCollections()</code> in your app entry point.</td></tr>`;
|
|
22722
|
+
const claudeJson = chunkMNWKYY5E_cjs.escapeHtml(buildClaudeJson(endpointUrl));
|
|
22723
|
+
const cursorJson = chunkMNWKYY5E_cjs.escapeHtml(buildCursorJson(endpointUrl));
|
|
22724
|
+
const content2 = `
|
|
22725
|
+
<div class="space-y-8">
|
|
22726
|
+
|
|
22727
|
+
<!-- Header -->
|
|
22728
|
+
<div class="sm:flex sm:items-center sm:justify-between">
|
|
22729
|
+
<div class="sm:flex-auto">
|
|
22730
|
+
<h1 class="text-2xl/8 font-semibold text-zinc-950 dark:text-white sm:text-xl/8">MCP Server</h1>
|
|
22731
|
+
<p class="mt-2 text-sm/6 text-zinc-500 dark:text-zinc-400">
|
|
22732
|
+
Model Context Protocol endpoint for AI agents (Claude Code, Cursor, VS Code). Requests are authenticated with API keys.
|
|
22733
|
+
</p>
|
|
22734
|
+
</div>
|
|
22735
|
+
<div class="mt-4 sm:mt-0 sm:ml-16">
|
|
22736
|
+
<a href="/admin/plugins/api-keys"
|
|
22737
|
+
class="inline-flex items-center justify-center rounded-lg bg-cyan-600 px-4 py-2.5 text-sm font-semibold text-white hover:bg-cyan-500 transition-colors shadow-sm">
|
|
22738
|
+
Mint API Key
|
|
22739
|
+
</a>
|
|
22740
|
+
</div>
|
|
22741
|
+
</div>
|
|
22742
|
+
|
|
22743
|
+
<!-- Status -->
|
|
22744
|
+
<div class="rounded-xl bg-white/80 dark:bg-zinc-900/80 backdrop-blur-xl p-6 ring-1 ring-zinc-950/5 dark:ring-white/10 shadow-sm">
|
|
22745
|
+
<h2 class="text-sm font-semibold text-zinc-950 dark:text-white mb-4">Endpoint</h2>
|
|
22746
|
+
<div class="flex items-center gap-3">
|
|
22747
|
+
<code id="endpoint-url" class="flex-1 rounded-lg bg-zinc-50 dark:bg-zinc-800 px-3 py-2 text-sm font-mono text-zinc-950 dark:text-white ring-1 ring-zinc-950/5 dark:ring-white/5 break-all">${safeEndpoint}</code>
|
|
22748
|
+
<button type="button" onclick="copyEndpoint()"
|
|
22749
|
+
class="shrink-0 rounded-lg bg-zinc-100 dark:bg-zinc-800 px-3 py-2 text-sm font-medium text-zinc-700 dark:text-zinc-300 hover:bg-zinc-200 dark:hover:bg-zinc-700 ring-1 ring-zinc-950/5 dark:ring-white/10 transition-colors">
|
|
22750
|
+
Copy
|
|
22751
|
+
</button>
|
|
22752
|
+
</div>
|
|
22753
|
+
<div class="mt-4 flex flex-wrap gap-4 text-sm text-zinc-500 dark:text-zinc-400">
|
|
22754
|
+
<span>
|
|
22755
|
+
<span class="font-semibold text-zinc-950 dark:text-white">${typeCount}</span>
|
|
22756
|
+
collection${typeCount === 1 ? "" : "s"} exposed
|
|
22757
|
+
</span>
|
|
22758
|
+
<span class="text-zinc-300 dark:text-zinc-600">·</span>
|
|
22759
|
+
<span>
|
|
22760
|
+
<span class="font-semibold text-zinc-950 dark:text-white">${toolCount}</span>
|
|
22761
|
+
tool${toolCount === 1 ? "" : "s"} available
|
|
22762
|
+
</span>
|
|
22763
|
+
<span class="text-zinc-300 dark:text-zinc-600">·</span>
|
|
22764
|
+
<span>Auth via <a href="/admin/plugins/api-keys" class="text-cyan-600 dark:text-cyan-400 hover:underline">API Keys</a></span>
|
|
22765
|
+
</div>
|
|
22766
|
+
</div>
|
|
22767
|
+
|
|
22768
|
+
<!-- Exposed collections table -->
|
|
22769
|
+
<div class="rounded-xl bg-white/80 dark:bg-zinc-900/80 backdrop-blur-xl p-6 ring-1 ring-zinc-950/5 dark:ring-white/10 shadow-sm overflow-x-auto">
|
|
22770
|
+
<h2 class="text-sm font-semibold text-zinc-950 dark:text-white mb-4">Exposed collections</h2>
|
|
22771
|
+
<table class="w-full text-left">
|
|
22772
|
+
<thead>
|
|
22773
|
+
<tr class="text-xs font-semibold uppercase tracking-wide text-zinc-500 dark:text-zinc-400">
|
|
22774
|
+
<th class="pb-2 pr-4">ID</th>
|
|
22775
|
+
<th class="pb-2 pr-4">Display name</th>
|
|
22776
|
+
<th class="pb-2 pr-4">Read</th>
|
|
22777
|
+
<th class="pb-2 pr-4">Write</th>
|
|
22778
|
+
<th class="pb-2">Tools</th>
|
|
22779
|
+
</tr>
|
|
22780
|
+
</thead>
|
|
22781
|
+
<tbody>${typeRows}</tbody>
|
|
22782
|
+
</table>
|
|
22783
|
+
</div>
|
|
22784
|
+
|
|
22785
|
+
<!-- Integration guide -->
|
|
22786
|
+
<div class="rounded-xl bg-white/80 dark:bg-zinc-900/80 backdrop-blur-xl p-6 ring-1 ring-zinc-950/5 dark:ring-white/10 shadow-sm space-y-6">
|
|
22787
|
+
<div>
|
|
22788
|
+
<h2 class="text-sm font-semibold text-zinc-950 dark:text-white mb-1">Integration guide</h2>
|
|
22789
|
+
<p class="text-sm text-zinc-500 dark:text-zinc-400">
|
|
22790
|
+
<a href="/admin/plugins/api-keys" class="text-cyan-600 dark:text-cyan-400 hover:underline">Mint an API key</a>,
|
|
22791
|
+
then paste one of the configs below into your MCP client.
|
|
22792
|
+
Replace <code class="font-mono text-xs">sk_YOUR_API_KEY</code> with the key.
|
|
22793
|
+
</p>
|
|
22794
|
+
</div>
|
|
22795
|
+
|
|
22796
|
+
<!-- Claude Code -->
|
|
22797
|
+
<div>
|
|
22798
|
+
<div class="flex items-center justify-between mb-2">
|
|
22799
|
+
<h3 class="text-sm font-medium text-zinc-700 dark:text-zinc-300">
|
|
22800
|
+
Claude Code — <code class="font-mono text-xs">~/.claude/mcp.json</code>
|
|
22801
|
+
</h3>
|
|
22802
|
+
<button type="button" onclick="copyConfig('claude-config')"
|
|
22803
|
+
class="text-xs text-zinc-500 dark:text-zinc-400 hover:text-zinc-700 dark:hover:text-zinc-200 transition-colors">
|
|
22804
|
+
Copy
|
|
22805
|
+
</button>
|
|
22806
|
+
</div>
|
|
22807
|
+
<pre id="claude-config" class="rounded-lg bg-zinc-950 dark:bg-zinc-800 px-4 py-3 text-sm font-mono text-zinc-100 overflow-x-auto ring-1 ring-zinc-700 dark:ring-zinc-600 whitespace-pre">${claudeJson}</pre>
|
|
22808
|
+
</div>
|
|
22809
|
+
|
|
22810
|
+
<!-- Cursor -->
|
|
22811
|
+
<div>
|
|
22812
|
+
<div class="flex items-center justify-between mb-2">
|
|
22813
|
+
<h3 class="text-sm font-medium text-zinc-700 dark:text-zinc-300">
|
|
22814
|
+
Cursor — <code class="font-mono text-xs">~/.cursor/mcp.json</code>
|
|
22815
|
+
</h3>
|
|
22816
|
+
<button type="button" onclick="copyConfig('cursor-config')"
|
|
22817
|
+
class="text-xs text-zinc-500 dark:text-zinc-400 hover:text-zinc-700 dark:hover:text-zinc-200 transition-colors">
|
|
22818
|
+
Copy
|
|
22819
|
+
</button>
|
|
22820
|
+
</div>
|
|
22821
|
+
<pre id="cursor-config" class="rounded-lg bg-zinc-950 dark:bg-zinc-800 px-4 py-3 text-sm font-mono text-zinc-100 overflow-x-auto ring-1 ring-zinc-700 dark:ring-zinc-600 whitespace-pre">${cursorJson}</pre>
|
|
22822
|
+
</div>
|
|
22823
|
+
|
|
22824
|
+
<p class="text-xs text-zinc-400 dark:text-zinc-500">
|
|
22825
|
+
MCP v1 = HTTP POST only (no SSE stream). Clients that require stdio transport can use
|
|
22826
|
+
<code class="font-mono">npx mcp-remote ${safeEndpoint}</code> as a local bridge.
|
|
22827
|
+
</p>
|
|
22828
|
+
</div>
|
|
22829
|
+
|
|
22830
|
+
</div>
|
|
22831
|
+
|
|
22832
|
+
<script>
|
|
22833
|
+
function copyEndpoint() {
|
|
22834
|
+
navigator.clipboard.writeText(document.getElementById('endpoint-url').textContent.trim()).then(() => {
|
|
22835
|
+
window.showNotification && window.showNotification('Endpoint URL copied', 'success')
|
|
22836
|
+
})
|
|
22837
|
+
}
|
|
22838
|
+
function copyConfig(id) {
|
|
22839
|
+
navigator.clipboard.writeText(document.getElementById(id).textContent).then(() => {
|
|
22840
|
+
window.showNotification && window.showNotification('Config copied', 'success')
|
|
22841
|
+
})
|
|
22842
|
+
}
|
|
22843
|
+
</script>`;
|
|
22844
|
+
const layoutData = {
|
|
22845
|
+
title: "MCP Server",
|
|
22846
|
+
pageTitle: "MCP Server",
|
|
22847
|
+
currentPath: "/admin/mcp",
|
|
22848
|
+
user,
|
|
22849
|
+
content: content2,
|
|
22850
|
+
version,
|
|
22851
|
+
dynamicMenuItems
|
|
22852
|
+
};
|
|
22853
|
+
return chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst(layoutData);
|
|
22854
|
+
}
|
|
22855
|
+
|
|
22856
|
+
// src/plugins/core-plugins/mcp-plugin/admin/routes.ts
|
|
22857
|
+
function createMcpAdminRoutes(options = {}) {
|
|
22858
|
+
const routes2 = new hono.Hono();
|
|
22859
|
+
routes2.use("*", chunkE7E3NL3Y_cjs.requireAuth());
|
|
22860
|
+
routes2.use("*", async (c, next) => {
|
|
22861
|
+
const user = c.get("user");
|
|
22862
|
+
if (user?.role !== "admin") return c.json({ error: "Access denied" }, 403);
|
|
22863
|
+
return next();
|
|
22864
|
+
});
|
|
22865
|
+
routes2.get("/", async (c) => {
|
|
22866
|
+
const url = new URL(c.req.url);
|
|
22867
|
+
const endpointUrl = `${url.protocol}//${url.host}/mcp`;
|
|
22868
|
+
const registry = chunkYAURVGUK_cjs.getCollectionRegistry();
|
|
22869
|
+
const active = registry.listActive();
|
|
22870
|
+
const collections = new Map(active.map((col) => [col.name, col]));
|
|
22871
|
+
const cfg = resolveMcpConfig(options, active);
|
|
22872
|
+
const tools = buildToolRegistry(cfg, collections, PHASE_FLAGS);
|
|
22873
|
+
const user = c.get("user");
|
|
22874
|
+
return c.html(
|
|
22875
|
+
renderMcpDashboardPage({
|
|
22876
|
+
endpointUrl,
|
|
22877
|
+
types: cfg.types,
|
|
22878
|
+
tools,
|
|
22879
|
+
user: { name: user.email, email: user.email, role: user.role },
|
|
22880
|
+
version: c.get("appVersion"),
|
|
22881
|
+
dynamicMenuItems: c.get("pluginMenuItems")
|
|
22882
|
+
})
|
|
22883
|
+
);
|
|
22884
|
+
});
|
|
22885
|
+
return routes2;
|
|
22886
|
+
}
|
|
22887
|
+
|
|
22888
|
+
// src/plugins/core-plugins/mcp-plugin/index.ts
|
|
22889
|
+
var MCP_ICON = `<svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/></svg>`;
|
|
22890
|
+
function mcpPlugin(options = {}) {
|
|
22891
|
+
return chunkD6FWEYQE_cjs.definePlugin({
|
|
22892
|
+
id: "mcp",
|
|
22893
|
+
version: "1.0.0",
|
|
22894
|
+
name: "MCP Server",
|
|
22895
|
+
description: "Exposes SonicJS content as Model Context Protocol tools for AI agents (Claude Code, Cursor, \u2026).",
|
|
22896
|
+
sonicjsVersionRange: "^3.0.0",
|
|
22897
|
+
author: { name: "SonicJS Team" },
|
|
22898
|
+
register(app2) {
|
|
22899
|
+
app2.route("/mcp", createMcpRoutes(options));
|
|
22900
|
+
app2.route("/admin/mcp", createMcpAdminRoutes(options));
|
|
22901
|
+
},
|
|
22902
|
+
menu: [{ label: "MCP Server", path: "/admin/mcp", icon: MCP_ICON, order: 87 }]
|
|
22903
|
+
});
|
|
22904
|
+
}
|
|
22905
|
+
function createMcpPlugin(options) {
|
|
22906
|
+
return mcpPlugin(options);
|
|
22907
|
+
}
|
|
22043
22908
|
|
|
22044
22909
|
// src/index.ts
|
|
22045
|
-
var VERSION =
|
|
22910
|
+
var VERSION = chunkBJ6NJL2E_cjs.package_default.version;
|
|
22046
22911
|
|
|
22047
22912
|
Object.defineProperty(exports, "DocumentRepository", {
|
|
22048
22913
|
enumerable: true,
|
|
22049
|
-
get: function () { return
|
|
22914
|
+
get: function () { return chunk6OA77UM7_cjs.DocumentRepository; }
|
|
22050
22915
|
});
|
|
22051
22916
|
Object.defineProperty(exports, "ROUTES_INFO", {
|
|
22052
22917
|
enumerable: true,
|
|
22053
|
-
get: function () { return
|
|
22918
|
+
get: function () { return chunk6OA77UM7_cjs.ROUTES_INFO; }
|
|
22054
22919
|
});
|
|
22055
22920
|
Object.defineProperty(exports, "adminApiRoutes", {
|
|
22056
22921
|
enumerable: true,
|
|
22057
|
-
get: function () { return
|
|
22922
|
+
get: function () { return chunk6OA77UM7_cjs.admin_api_default; }
|
|
22058
22923
|
});
|
|
22059
22924
|
Object.defineProperty(exports, "adminCheckboxRoutes", {
|
|
22060
22925
|
enumerable: true,
|
|
22061
|
-
get: function () { return
|
|
22926
|
+
get: function () { return chunk6OA77UM7_cjs.adminCheckboxRoutes; }
|
|
22062
22927
|
});
|
|
22063
22928
|
Object.defineProperty(exports, "adminCollectionsRoutes", {
|
|
22064
22929
|
enumerable: true,
|
|
22065
|
-
get: function () { return
|
|
22930
|
+
get: function () { return chunk6OA77UM7_cjs.adminCollectionsRoutes; }
|
|
22066
22931
|
});
|
|
22067
22932
|
Object.defineProperty(exports, "adminContentRoutes", {
|
|
22068
22933
|
enumerable: true,
|
|
22069
|
-
get: function () { return
|
|
22934
|
+
get: function () { return chunk6OA77UM7_cjs.admin_content_default; }
|
|
22070
22935
|
});
|
|
22071
22936
|
Object.defineProperty(exports, "adminDashboardRoutes", {
|
|
22072
22937
|
enumerable: true,
|
|
22073
|
-
get: function () { return
|
|
22938
|
+
get: function () { return chunk6OA77UM7_cjs.router; }
|
|
22074
22939
|
});
|
|
22075
22940
|
Object.defineProperty(exports, "adminLogsRoutes", {
|
|
22076
22941
|
enumerable: true,
|
|
22077
|
-
get: function () { return
|
|
22942
|
+
get: function () { return chunk6OA77UM7_cjs.adminLogsRoutes; }
|
|
22078
22943
|
});
|
|
22079
22944
|
Object.defineProperty(exports, "adminMediaRoutes", {
|
|
22080
22945
|
enumerable: true,
|
|
22081
|
-
get: function () { return
|
|
22946
|
+
get: function () { return chunk6OA77UM7_cjs.adminMediaRoutes; }
|
|
22082
22947
|
});
|
|
22083
22948
|
Object.defineProperty(exports, "adminPluginRoutes", {
|
|
22084
22949
|
enumerable: true,
|
|
22085
|
-
get: function () { return
|
|
22950
|
+
get: function () { return chunk6OA77UM7_cjs.adminPluginRoutes; }
|
|
22086
22951
|
});
|
|
22087
22952
|
Object.defineProperty(exports, "adminSettingsRoutes", {
|
|
22088
22953
|
enumerable: true,
|
|
22089
|
-
get: function () { return
|
|
22954
|
+
get: function () { return chunk6OA77UM7_cjs.adminSettingsRoutes; }
|
|
22090
22955
|
});
|
|
22091
22956
|
Object.defineProperty(exports, "adminUsersRoutes", {
|
|
22092
22957
|
enumerable: true,
|
|
22093
|
-
get: function () { return
|
|
22958
|
+
get: function () { return chunk6OA77UM7_cjs.userRoutes; }
|
|
22094
22959
|
});
|
|
22095
22960
|
Object.defineProperty(exports, "apiContentCrudRoutes", {
|
|
22096
22961
|
enumerable: true,
|
|
22097
|
-
get: function () { return
|
|
22962
|
+
get: function () { return chunk6OA77UM7_cjs.api_content_crud_default; }
|
|
22098
22963
|
});
|
|
22099
22964
|
Object.defineProperty(exports, "apiMediaRoutes", {
|
|
22100
22965
|
enumerable: true,
|
|
22101
|
-
get: function () { return
|
|
22966
|
+
get: function () { return chunk6OA77UM7_cjs.api_media_default; }
|
|
22102
22967
|
});
|
|
22103
22968
|
Object.defineProperty(exports, "apiRoutes", {
|
|
22104
22969
|
enumerable: true,
|
|
22105
|
-
get: function () { return
|
|
22970
|
+
get: function () { return chunk6OA77UM7_cjs.api_default; }
|
|
22106
22971
|
});
|
|
22107
22972
|
Object.defineProperty(exports, "apiSystemRoutes", {
|
|
22108
22973
|
enumerable: true,
|
|
22109
|
-
get: function () { return
|
|
22974
|
+
get: function () { return chunk6OA77UM7_cjs.api_system_default; }
|
|
22110
22975
|
});
|
|
22111
22976
|
Object.defineProperty(exports, "authRoutes", {
|
|
22112
22977
|
enumerable: true,
|
|
22113
|
-
get: function () { return
|
|
22978
|
+
get: function () { return chunk6OA77UM7_cjs.auth_default; }
|
|
22114
22979
|
});
|
|
22115
22980
|
Object.defineProperty(exports, "createUserProfilesPlugin", {
|
|
22116
22981
|
enumerable: true,
|
|
22117
|
-
get: function () { return
|
|
22982
|
+
get: function () { return chunk6OA77UM7_cjs.createUserProfilesPlugin; }
|
|
22118
22983
|
});
|
|
22119
22984
|
Object.defineProperty(exports, "defineUserProfile", {
|
|
22120
22985
|
enumerable: true,
|
|
22121
|
-
get: function () { return
|
|
22986
|
+
get: function () { return chunk6OA77UM7_cjs.defineUserProfile; }
|
|
22122
22987
|
});
|
|
22123
22988
|
Object.defineProperty(exports, "getUserProfileConfig", {
|
|
22124
22989
|
enumerable: true,
|
|
22125
|
-
get: function () { return
|
|
22990
|
+
get: function () { return chunk6OA77UM7_cjs.getUserProfileConfig; }
|
|
22126
22991
|
});
|
|
22127
22992
|
Object.defineProperty(exports, "userProfilesPlugin", {
|
|
22128
22993
|
enumerable: true,
|
|
22129
|
-
get: function () { return
|
|
22994
|
+
get: function () { return chunk6OA77UM7_cjs.userProfilesPlugin; }
|
|
22130
22995
|
});
|
|
22131
22996
|
Object.defineProperty(exports, "Logger", {
|
|
22132
22997
|
enumerable: true,
|
|
@@ -22282,259 +23147,259 @@ Object.defineProperty(exports, "workflowHistory", {
|
|
|
22282
23147
|
});
|
|
22283
23148
|
Object.defineProperty(exports, "AuthManager", {
|
|
22284
23149
|
enumerable: true,
|
|
22285
|
-
get: function () { return
|
|
23150
|
+
get: function () { return chunkE7E3NL3Y_cjs.AuthManager; }
|
|
22286
23151
|
});
|
|
22287
23152
|
Object.defineProperty(exports, "PermissionManager", {
|
|
22288
23153
|
enumerable: true,
|
|
22289
|
-
get: function () { return
|
|
23154
|
+
get: function () { return chunkE7E3NL3Y_cjs.PermissionManager; }
|
|
22290
23155
|
});
|
|
22291
23156
|
Object.defineProperty(exports, "bootstrapDocumentTypes", {
|
|
22292
23157
|
enumerable: true,
|
|
22293
|
-
get: function () { return
|
|
23158
|
+
get: function () { return chunkE7E3NL3Y_cjs.bootstrapDocumentTypes; }
|
|
22294
23159
|
});
|
|
22295
23160
|
Object.defineProperty(exports, "bootstrapMiddleware", {
|
|
22296
23161
|
enumerable: true,
|
|
22297
|
-
get: function () { return
|
|
23162
|
+
get: function () { return chunkE7E3NL3Y_cjs.bootstrapMiddleware; }
|
|
22298
23163
|
});
|
|
22299
23164
|
Object.defineProperty(exports, "cacheHeaders", {
|
|
22300
23165
|
enumerable: true,
|
|
22301
|
-
get: function () { return
|
|
23166
|
+
get: function () { return chunkE7E3NL3Y_cjs.cacheHeaders; }
|
|
22302
23167
|
});
|
|
22303
23168
|
Object.defineProperty(exports, "compressionMiddleware", {
|
|
22304
23169
|
enumerable: true,
|
|
22305
|
-
get: function () { return
|
|
23170
|
+
get: function () { return chunkE7E3NL3Y_cjs.compressionMiddleware; }
|
|
22306
23171
|
});
|
|
22307
23172
|
Object.defineProperty(exports, "detailedLoggingMiddleware", {
|
|
22308
23173
|
enumerable: true,
|
|
22309
|
-
get: function () { return
|
|
23174
|
+
get: function () { return chunkE7E3NL3Y_cjs.detailedLoggingMiddleware; }
|
|
22310
23175
|
});
|
|
22311
23176
|
Object.defineProperty(exports, "getActivePlugins", {
|
|
22312
23177
|
enumerable: true,
|
|
22313
|
-
get: function () { return
|
|
23178
|
+
get: function () { return chunkE7E3NL3Y_cjs.getActivePlugins; }
|
|
22314
23179
|
});
|
|
22315
23180
|
Object.defineProperty(exports, "isPluginActive", {
|
|
22316
23181
|
enumerable: true,
|
|
22317
|
-
get: function () { return
|
|
23182
|
+
get: function () { return chunkE7E3NL3Y_cjs.isPluginActive; }
|
|
22318
23183
|
});
|
|
22319
23184
|
Object.defineProperty(exports, "logActivity", {
|
|
22320
23185
|
enumerable: true,
|
|
22321
|
-
get: function () { return
|
|
23186
|
+
get: function () { return chunkE7E3NL3Y_cjs.logActivity; }
|
|
22322
23187
|
});
|
|
22323
23188
|
Object.defineProperty(exports, "loggingMiddleware", {
|
|
22324
23189
|
enumerable: true,
|
|
22325
|
-
get: function () { return
|
|
23190
|
+
get: function () { return chunkE7E3NL3Y_cjs.loggingMiddleware; }
|
|
22326
23191
|
});
|
|
22327
23192
|
Object.defineProperty(exports, "optionalAuth", {
|
|
22328
23193
|
enumerable: true,
|
|
22329
|
-
get: function () { return
|
|
23194
|
+
get: function () { return chunkE7E3NL3Y_cjs.optionalAuth; }
|
|
22330
23195
|
});
|
|
22331
23196
|
Object.defineProperty(exports, "performanceLoggingMiddleware", {
|
|
22332
23197
|
enumerable: true,
|
|
22333
|
-
get: function () { return
|
|
23198
|
+
get: function () { return chunkE7E3NL3Y_cjs.performanceLoggingMiddleware; }
|
|
22334
23199
|
});
|
|
22335
23200
|
Object.defineProperty(exports, "requireActivePlugin", {
|
|
22336
23201
|
enumerable: true,
|
|
22337
|
-
get: function () { return
|
|
23202
|
+
get: function () { return chunkE7E3NL3Y_cjs.requireActivePlugin; }
|
|
22338
23203
|
});
|
|
22339
23204
|
Object.defineProperty(exports, "requireActivePlugins", {
|
|
22340
23205
|
enumerable: true,
|
|
22341
|
-
get: function () { return
|
|
23206
|
+
get: function () { return chunkE7E3NL3Y_cjs.requireActivePlugins; }
|
|
22342
23207
|
});
|
|
22343
23208
|
Object.defineProperty(exports, "requireAnyPermission", {
|
|
22344
23209
|
enumerable: true,
|
|
22345
|
-
get: function () { return
|
|
23210
|
+
get: function () { return chunkE7E3NL3Y_cjs.requireAnyPermission; }
|
|
22346
23211
|
});
|
|
22347
23212
|
Object.defineProperty(exports, "requireAuth", {
|
|
22348
23213
|
enumerable: true,
|
|
22349
|
-
get: function () { return
|
|
23214
|
+
get: function () { return chunkE7E3NL3Y_cjs.requireAuth; }
|
|
22350
23215
|
});
|
|
22351
23216
|
Object.defineProperty(exports, "requirePermission", {
|
|
22352
23217
|
enumerable: true,
|
|
22353
|
-
get: function () { return
|
|
23218
|
+
get: function () { return chunkE7E3NL3Y_cjs.requirePermission; }
|
|
22354
23219
|
});
|
|
22355
23220
|
Object.defineProperty(exports, "requireRole", {
|
|
22356
23221
|
enumerable: true,
|
|
22357
|
-
get: function () { return
|
|
23222
|
+
get: function () { return chunkE7E3NL3Y_cjs.requireRole; }
|
|
22358
23223
|
});
|
|
22359
23224
|
Object.defineProperty(exports, "securityHeaders", {
|
|
22360
23225
|
enumerable: true,
|
|
22361
|
-
get: function () { return
|
|
23226
|
+
get: function () { return chunkE7E3NL3Y_cjs.securityHeadersMiddleware; }
|
|
22362
23227
|
});
|
|
22363
23228
|
Object.defineProperty(exports, "securityLoggingMiddleware", {
|
|
22364
23229
|
enumerable: true,
|
|
22365
|
-
get: function () { return
|
|
23230
|
+
get: function () { return chunkE7E3NL3Y_cjs.securityLoggingMiddleware; }
|
|
22366
23231
|
});
|
|
22367
23232
|
Object.defineProperty(exports, "DocumentsService", {
|
|
22368
23233
|
enumerable: true,
|
|
22369
|
-
get: function () { return
|
|
23234
|
+
get: function () { return chunkJCBDXEY2_cjs.DocumentsService; }
|
|
22370
23235
|
});
|
|
22371
23236
|
Object.defineProperty(exports, "RbacService", {
|
|
22372
23237
|
enumerable: true,
|
|
22373
|
-
get: function () { return
|
|
23238
|
+
get: function () { return chunkJCBDXEY2_cjs.RbacService; }
|
|
22374
23239
|
});
|
|
22375
23240
|
Object.defineProperty(exports, "PluginBootstrapService", {
|
|
22376
23241
|
enumerable: true,
|
|
22377
|
-
get: function () { return
|
|
23242
|
+
get: function () { return chunkYAURVGUK_cjs.PluginBootstrapService; }
|
|
22378
23243
|
});
|
|
22379
23244
|
Object.defineProperty(exports, "PluginServiceClass", {
|
|
22380
23245
|
enumerable: true,
|
|
22381
|
-
get: function () { return
|
|
23246
|
+
get: function () { return chunkYAURVGUK_cjs.PluginService; }
|
|
22382
23247
|
});
|
|
22383
23248
|
Object.defineProperty(exports, "getAvailableCollectionNames", {
|
|
22384
23249
|
enumerable: true,
|
|
22385
|
-
get: function () { return
|
|
23250
|
+
get: function () { return chunkYAURVGUK_cjs.getAvailableCollectionNames; }
|
|
22386
23251
|
});
|
|
22387
23252
|
Object.defineProperty(exports, "loadCollectionConfig", {
|
|
22388
23253
|
enumerable: true,
|
|
22389
|
-
get: function () { return
|
|
23254
|
+
get: function () { return chunkYAURVGUK_cjs.loadCollectionConfig; }
|
|
22390
23255
|
});
|
|
22391
23256
|
Object.defineProperty(exports, "loadCollectionConfigs", {
|
|
22392
23257
|
enumerable: true,
|
|
22393
|
-
get: function () { return
|
|
23258
|
+
get: function () { return chunkYAURVGUK_cjs.loadCollectionConfigs; }
|
|
22394
23259
|
});
|
|
22395
23260
|
Object.defineProperty(exports, "registerCollections", {
|
|
22396
23261
|
enumerable: true,
|
|
22397
|
-
get: function () { return
|
|
23262
|
+
get: function () { return chunkYAURVGUK_cjs.registerCollections; }
|
|
22398
23263
|
});
|
|
22399
23264
|
Object.defineProperty(exports, "validateCollectionConfig", {
|
|
22400
23265
|
enumerable: true,
|
|
22401
|
-
get: function () { return
|
|
23266
|
+
get: function () { return chunkYAURVGUK_cjs.validateCollectionConfig; }
|
|
22402
23267
|
});
|
|
22403
23268
|
Object.defineProperty(exports, "MigrationService", {
|
|
22404
23269
|
enumerable: true,
|
|
22405
|
-
get: function () { return
|
|
23270
|
+
get: function () { return chunkMOGK3U4A_cjs.MigrationService; }
|
|
22406
23271
|
});
|
|
22407
23272
|
Object.defineProperty(exports, "renderFilterBar", {
|
|
22408
23273
|
enumerable: true,
|
|
22409
|
-
get: function () { return
|
|
23274
|
+
get: function () { return chunkCN3T3TDI_cjs.renderFilterBar; }
|
|
22410
23275
|
});
|
|
22411
23276
|
Object.defineProperty(exports, "getConfirmationDialogScript", {
|
|
22412
23277
|
enumerable: true,
|
|
22413
|
-
get: function () { return
|
|
23278
|
+
get: function () { return chunkOUBUS74I_cjs.getConfirmationDialogScript; }
|
|
22414
23279
|
});
|
|
22415
23280
|
Object.defineProperty(exports, "renderAlert", {
|
|
22416
23281
|
enumerable: true,
|
|
22417
|
-
get: function () { return
|
|
23282
|
+
get: function () { return chunkOUBUS74I_cjs.renderAlert; }
|
|
22418
23283
|
});
|
|
22419
23284
|
Object.defineProperty(exports, "renderConfirmationDialog", {
|
|
22420
23285
|
enumerable: true,
|
|
22421
|
-
get: function () { return
|
|
23286
|
+
get: function () { return chunkOUBUS74I_cjs.renderConfirmationDialog; }
|
|
22422
23287
|
});
|
|
22423
23288
|
Object.defineProperty(exports, "renderForm", {
|
|
22424
23289
|
enumerable: true,
|
|
22425
|
-
get: function () { return
|
|
23290
|
+
get: function () { return chunkOUBUS74I_cjs.renderForm; }
|
|
22426
23291
|
});
|
|
22427
23292
|
Object.defineProperty(exports, "renderFormField", {
|
|
22428
23293
|
enumerable: true,
|
|
22429
|
-
get: function () { return
|
|
23294
|
+
get: function () { return chunkOUBUS74I_cjs.renderFormField; }
|
|
22430
23295
|
});
|
|
22431
23296
|
Object.defineProperty(exports, "renderPagination", {
|
|
22432
23297
|
enumerable: true,
|
|
22433
|
-
get: function () { return
|
|
23298
|
+
get: function () { return chunkOUBUS74I_cjs.renderPagination; }
|
|
22434
23299
|
});
|
|
22435
23300
|
Object.defineProperty(exports, "renderTable", {
|
|
22436
23301
|
enumerable: true,
|
|
22437
|
-
get: function () { return
|
|
23302
|
+
get: function () { return chunkOUBUS74I_cjs.renderTable; }
|
|
22438
23303
|
});
|
|
22439
23304
|
Object.defineProperty(exports, "renderAdminLayoutCatalyst", {
|
|
22440
23305
|
enumerable: true,
|
|
22441
|
-
get: function () { return
|
|
23306
|
+
get: function () { return chunkMI2YXCK4_cjs.renderAdminLayoutCatalyst; }
|
|
22442
23307
|
});
|
|
22443
23308
|
Object.defineProperty(exports, "HookSystemImpl", {
|
|
22444
23309
|
enumerable: true,
|
|
22445
|
-
get: function () { return
|
|
23310
|
+
get: function () { return chunkI7MIRRFJ_cjs.HookSystemImpl; }
|
|
22446
23311
|
});
|
|
22447
23312
|
Object.defineProperty(exports, "HookUtils", {
|
|
22448
23313
|
enumerable: true,
|
|
22449
|
-
get: function () { return
|
|
23314
|
+
get: function () { return chunkI7MIRRFJ_cjs.HookUtils; }
|
|
22450
23315
|
});
|
|
22451
23316
|
Object.defineProperty(exports, "PluginDependencyCycleError", {
|
|
22452
23317
|
enumerable: true,
|
|
22453
|
-
get: function () { return
|
|
23318
|
+
get: function () { return chunkI7MIRRFJ_cjs.PluginDependencyCycleError; }
|
|
22454
23319
|
});
|
|
22455
23320
|
Object.defineProperty(exports, "PluginManagerClass", {
|
|
22456
23321
|
enumerable: true,
|
|
22457
|
-
get: function () { return
|
|
23322
|
+
get: function () { return chunkI7MIRRFJ_cjs.PluginManager; }
|
|
22458
23323
|
});
|
|
22459
23324
|
Object.defineProperty(exports, "PluginRegistryImpl", {
|
|
22460
23325
|
enumerable: true,
|
|
22461
|
-
get: function () { return
|
|
23326
|
+
get: function () { return chunkI7MIRRFJ_cjs.PluginRegistryImpl; }
|
|
22462
23327
|
});
|
|
22463
23328
|
Object.defineProperty(exports, "PluginValidatorClass", {
|
|
22464
23329
|
enumerable: true,
|
|
22465
|
-
get: function () { return
|
|
23330
|
+
get: function () { return chunkI7MIRRFJ_cjs.PluginValidator; }
|
|
22466
23331
|
});
|
|
22467
23332
|
Object.defineProperty(exports, "RegisterPluginsError", {
|
|
22468
23333
|
enumerable: true,
|
|
22469
|
-
get: function () { return
|
|
23334
|
+
get: function () { return chunkI7MIRRFJ_cjs.RegisterPluginsError; }
|
|
22470
23335
|
});
|
|
22471
23336
|
Object.defineProperty(exports, "ScopedHookSystemClass", {
|
|
22472
23337
|
enumerable: true,
|
|
22473
|
-
get: function () { return
|
|
23338
|
+
get: function () { return chunkI7MIRRFJ_cjs.ScopedHookSystem; }
|
|
22474
23339
|
});
|
|
22475
23340
|
Object.defineProperty(exports, "collectCronSchedules", {
|
|
22476
23341
|
enumerable: true,
|
|
22477
|
-
get: function () { return
|
|
23342
|
+
get: function () { return chunkI7MIRRFJ_cjs.collectCronSchedules; }
|
|
22478
23343
|
});
|
|
22479
23344
|
Object.defineProperty(exports, "collectCrons", {
|
|
22480
23345
|
enumerable: true,
|
|
22481
|
-
get: function () { return
|
|
23346
|
+
get: function () { return chunkI7MIRRFJ_cjs.collectCrons; }
|
|
22482
23347
|
});
|
|
22483
23348
|
Object.defineProperty(exports, "createScheduledHandler", {
|
|
22484
23349
|
enumerable: true,
|
|
22485
|
-
get: function () { return
|
|
23350
|
+
get: function () { return chunkI7MIRRFJ_cjs.createScheduledHandler; }
|
|
22486
23351
|
});
|
|
22487
23352
|
Object.defineProperty(exports, "dispatchCronTick", {
|
|
22488
23353
|
enumerable: true,
|
|
22489
|
-
get: function () { return
|
|
23354
|
+
get: function () { return chunkI7MIRRFJ_cjs.dispatchCronTick; }
|
|
22490
23355
|
});
|
|
22491
23356
|
Object.defineProperty(exports, "registerPlugins", {
|
|
22492
23357
|
enumerable: true,
|
|
22493
|
-
get: function () { return
|
|
23358
|
+
get: function () { return chunkI7MIRRFJ_cjs.registerPlugins; }
|
|
22494
23359
|
});
|
|
22495
23360
|
Object.defineProperty(exports, "topoSort", {
|
|
22496
23361
|
enumerable: true,
|
|
22497
|
-
get: function () { return
|
|
23362
|
+
get: function () { return chunkI7MIRRFJ_cjs.topoSort; }
|
|
22498
23363
|
});
|
|
22499
23364
|
Object.defineProperty(exports, "applySchemaDefaults", {
|
|
22500
23365
|
enumerable: true,
|
|
22501
|
-
get: function () { return
|
|
23366
|
+
get: function () { return chunkD6FWEYQE_cjs.applySchemaDefaults; }
|
|
22502
23367
|
});
|
|
22503
23368
|
Object.defineProperty(exports, "definePlugin", {
|
|
22504
23369
|
enumerable: true,
|
|
22505
|
-
get: function () { return
|
|
23370
|
+
get: function () { return chunkD6FWEYQE_cjs.definePlugin; }
|
|
22506
23371
|
});
|
|
22507
23372
|
Object.defineProperty(exports, "getPluginMenu", {
|
|
22508
23373
|
enumerable: true,
|
|
22509
|
-
get: function () { return
|
|
23374
|
+
get: function () { return chunkD6FWEYQE_cjs.getPluginMenu; }
|
|
22510
23375
|
});
|
|
22511
23376
|
Object.defineProperty(exports, "isDefinedPlugin", {
|
|
22512
23377
|
enumerable: true,
|
|
22513
|
-
get: function () { return
|
|
23378
|
+
get: function () { return chunkD6FWEYQE_cjs.isDefinedPlugin; }
|
|
22514
23379
|
});
|
|
22515
23380
|
Object.defineProperty(exports, "parseConfigSchema", {
|
|
22516
23381
|
enumerable: true,
|
|
22517
|
-
get: function () { return
|
|
23382
|
+
get: function () { return chunkD6FWEYQE_cjs.parseConfigSchema; }
|
|
22518
23383
|
});
|
|
22519
23384
|
Object.defineProperty(exports, "parseFormDataToSettings", {
|
|
22520
23385
|
enumerable: true,
|
|
22521
|
-
get: function () { return
|
|
23386
|
+
get: function () { return chunkD6FWEYQE_cjs.parseFormDataToSettings; }
|
|
22522
23387
|
});
|
|
22523
23388
|
Object.defineProperty(exports, "renderSchemaFields", {
|
|
22524
23389
|
enumerable: true,
|
|
22525
|
-
get: function () { return
|
|
23390
|
+
get: function () { return chunkD6FWEYQE_cjs.renderSchemaFields; }
|
|
22526
23391
|
});
|
|
22527
23392
|
Object.defineProperty(exports, "resetPluginMenu", {
|
|
22528
23393
|
enumerable: true,
|
|
22529
|
-
get: function () { return
|
|
23394
|
+
get: function () { return chunkD6FWEYQE_cjs.resetPluginMenu; }
|
|
22530
23395
|
});
|
|
22531
23396
|
Object.defineProperty(exports, "resolvePluginMenuItems", {
|
|
22532
23397
|
enumerable: true,
|
|
22533
|
-
get: function () { return
|
|
23398
|
+
get: function () { return chunkD6FWEYQE_cjs.resolvePluginMenuItems; }
|
|
22534
23399
|
});
|
|
22535
23400
|
Object.defineProperty(exports, "setPluginMenu", {
|
|
22536
23401
|
enumerable: true,
|
|
22537
|
-
get: function () { return
|
|
23402
|
+
get: function () { return chunkD6FWEYQE_cjs.setPluginMenu; }
|
|
22538
23403
|
});
|
|
22539
23404
|
Object.defineProperty(exports, "getHookSystem", {
|
|
22540
23405
|
enumerable: true,
|
|
@@ -22558,23 +23423,23 @@ Object.defineProperty(exports, "setHookSystem", {
|
|
|
22558
23423
|
});
|
|
22559
23424
|
Object.defineProperty(exports, "QueryFilterBuilder", {
|
|
22560
23425
|
enumerable: true,
|
|
22561
|
-
get: function () { return
|
|
23426
|
+
get: function () { return chunkDLTT7QZU_cjs.QueryFilterBuilder; }
|
|
22562
23427
|
});
|
|
22563
23428
|
Object.defineProperty(exports, "TemplateRenderer", {
|
|
22564
23429
|
enumerable: true,
|
|
22565
|
-
get: function () { return
|
|
23430
|
+
get: function () { return chunkDLTT7QZU_cjs.TemplateRenderer; }
|
|
22566
23431
|
});
|
|
22567
23432
|
Object.defineProperty(exports, "buildQuery", {
|
|
22568
23433
|
enumerable: true,
|
|
22569
|
-
get: function () { return
|
|
23434
|
+
get: function () { return chunkDLTT7QZU_cjs.buildQuery; }
|
|
22570
23435
|
});
|
|
22571
23436
|
Object.defineProperty(exports, "renderTemplate", {
|
|
22572
23437
|
enumerable: true,
|
|
22573
|
-
get: function () { return
|
|
23438
|
+
get: function () { return chunkDLTT7QZU_cjs.renderTemplate; }
|
|
22574
23439
|
});
|
|
22575
23440
|
Object.defineProperty(exports, "templateRenderer", {
|
|
22576
23441
|
enumerable: true,
|
|
22577
|
-
get: function () { return
|
|
23442
|
+
get: function () { return chunkDLTT7QZU_cjs.templateRenderer; }
|
|
22578
23443
|
});
|
|
22579
23444
|
Object.defineProperty(exports, "metricsTracker", {
|
|
22580
23445
|
enumerable: true,
|
|
@@ -22582,11 +23447,11 @@ Object.defineProperty(exports, "metricsTracker", {
|
|
|
22582
23447
|
});
|
|
22583
23448
|
Object.defineProperty(exports, "SONICJS_VERSION", {
|
|
22584
23449
|
enumerable: true,
|
|
22585
|
-
get: function () { return
|
|
23450
|
+
get: function () { return chunkBJ6NJL2E_cjs.SONICJS_VERSION; }
|
|
22586
23451
|
});
|
|
22587
23452
|
Object.defineProperty(exports, "getCoreVersion", {
|
|
22588
23453
|
enumerable: true,
|
|
22589
|
-
get: function () { return
|
|
23454
|
+
get: function () { return chunkBJ6NJL2E_cjs.getCoreVersion; }
|
|
22590
23455
|
});
|
|
22591
23456
|
Object.defineProperty(exports, "escapeHtml", {
|
|
22592
23457
|
enumerable: true,
|
|
@@ -22610,12 +23475,14 @@ exports.OAuthService = OAuthService;
|
|
|
22610
23475
|
exports.VERSION = VERSION;
|
|
22611
23476
|
exports.createDb = createDb;
|
|
22612
23477
|
exports.createHelloWorldPlugin = createHelloWorldPlugin;
|
|
23478
|
+
exports.createMcpPlugin = createMcpPlugin;
|
|
22613
23479
|
exports.createOAuthProvidersPlugin = createOAuthProvidersPlugin;
|
|
22614
23480
|
exports.createRedirectPlugin = createRedirectPlugin;
|
|
22615
23481
|
exports.createSonicJSApp = createSonicJSApp;
|
|
22616
23482
|
exports.emailReconciliationPlugin = emailReconciliationPlugin;
|
|
22617
23483
|
exports.generateTriggersComment = generateTriggersComment;
|
|
22618
23484
|
exports.helloWorldPlugin = helloWorldPlugin;
|
|
23485
|
+
exports.mcpPlugin = mcpPlugin;
|
|
22619
23486
|
exports.oauthProvidersPlugin = oauthProvidersPlugin;
|
|
22620
23487
|
exports.parseCronTriggers = parseCronTriggers;
|
|
22621
23488
|
exports.redirectPlugin = redirectPlugin;
|