@sonicjs-cms/core 3.0.0-beta.23 → 3.0.0-beta.24

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.
Files changed (57) hide show
  1. package/dist/{chunk-IS54FPB7.cjs → chunk-37V3RET3.cjs} +18 -34
  2. package/dist/chunk-37V3RET3.cjs.map +1 -0
  3. package/dist/{chunk-VGHEKIJL.cjs → chunk-A2SN3RVL.cjs} +2 -2
  4. package/dist/{chunk-VGHEKIJL.cjs.map → chunk-A2SN3RVL.cjs.map} +1 -1
  5. package/dist/{chunk-4WMZGHIC.cjs → chunk-BP52BFIV.cjs} +4 -4
  6. package/dist/{chunk-4WMZGHIC.cjs.map → chunk-BP52BFIV.cjs.map} +1 -1
  7. package/dist/{chunk-DIBCKCUE.js → chunk-FHPEM77Y.js} +8 -24
  8. package/dist/chunk-FHPEM77Y.js.map +1 -0
  9. package/dist/{chunk-CTYLCWMO.cjs → chunk-I767LVN7.cjs} +252 -217
  10. package/dist/chunk-I767LVN7.cjs.map +1 -0
  11. package/dist/{chunk-C3ZQP5NW.cjs → chunk-KKNEYIZJ.cjs} +3 -3
  12. package/dist/{chunk-C3ZQP5NW.cjs.map → chunk-KKNEYIZJ.cjs.map} +1 -1
  13. package/dist/{chunk-DPLJYTHE.js → chunk-LNI3FYSI.js} +3 -3
  14. package/dist/{chunk-DPLJYTHE.js.map → chunk-LNI3FYSI.js.map} +1 -1
  15. package/dist/{chunk-AT4ZQGEZ.cjs → chunk-QCJHCSOK.cjs} +21 -2
  16. package/dist/chunk-QCJHCSOK.cjs.map +1 -0
  17. package/dist/{chunk-RFBW5RRH.cjs → chunk-QJUJNTIU.cjs} +11 -11
  18. package/dist/{chunk-RFBW5RRH.cjs.map → chunk-QJUJNTIU.cjs.map} +1 -1
  19. package/dist/{chunk-KS24NPPL.js → chunk-RJ2O5IIE.js} +21 -2
  20. package/dist/chunk-RJ2O5IIE.js.map +1 -0
  21. package/dist/{chunk-A46IRC5A.js → chunk-UIHIXTIS.js} +2 -2
  22. package/dist/{chunk-A46IRC5A.js.map → chunk-UIHIXTIS.js.map} +1 -1
  23. package/dist/{chunk-SK5CHFJP.js → chunk-VC5XVPLM.js} +52 -20
  24. package/dist/chunk-VC5XVPLM.js.map +1 -0
  25. package/dist/{chunk-2MIYYAO4.js → chunk-VGEZNFWH.js} +3 -3
  26. package/dist/{chunk-2MIYYAO4.js.map → chunk-VGEZNFWH.js.map} +1 -1
  27. package/dist/{chunk-XXRR54AB.js → chunk-VYQVDL2M.js} +4 -4
  28. package/dist/{chunk-XXRR54AB.js.map → chunk-VYQVDL2M.js.map} +1 -1
  29. package/dist/index.cjs +1093 -264
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +28 -1
  32. package/dist/index.d.ts +28 -1
  33. package/dist/index.js +841 -14
  34. package/dist/index.js.map +1 -1
  35. package/dist/middleware.cjs +33 -33
  36. package/dist/middleware.js +4 -4
  37. package/dist/migrations-FGXZPKDC.cjs +13 -0
  38. package/dist/{migrations-ZD7Y5NUC.cjs.map → migrations-FGXZPKDC.cjs.map} +1 -1
  39. package/dist/migrations-Z6D27NAW.js +4 -0
  40. package/dist/{migrations-XQ6EX6HX.js.map → migrations-Z6D27NAW.js.map} +1 -1
  41. package/dist/plugins.cjs +40 -40
  42. package/dist/plugins.js +3 -3
  43. package/dist/routes.cjs +26 -26
  44. package/dist/routes.js +6 -6
  45. package/dist/services.cjs +18 -18
  46. package/dist/services.js +2 -2
  47. package/dist/utils.cjs +3 -3
  48. package/dist/utils.js +1 -1
  49. package/package.json +1 -1
  50. package/dist/chunk-AT4ZQGEZ.cjs.map +0 -1
  51. package/dist/chunk-CTYLCWMO.cjs.map +0 -1
  52. package/dist/chunk-DIBCKCUE.js.map +0 -1
  53. package/dist/chunk-IS54FPB7.cjs.map +0 -1
  54. package/dist/chunk-KS24NPPL.js.map +0 -1
  55. package/dist/chunk-SK5CHFJP.js.map +0 -1
  56. package/dist/migrations-XQ6EX6HX.js +0 -4
  57. package/dist/migrations-ZD7Y5NUC.cjs +0 -13
package/dist/index.cjs CHANGED
@@ -1,27 +1,27 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkGMMCCIQO_cjs = require('./chunk-GMMCCIQO.cjs');
4
- var chunkCTYLCWMO_cjs = require('./chunk-CTYLCWMO.cjs');
4
+ var chunkI767LVN7_cjs = require('./chunk-I767LVN7.cjs');
5
5
  require('./chunk-XWVDSM2L.cjs');
6
6
  require('./chunk-JMJM7DMM.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 chunkIS54FPB7_cjs = require('./chunk-IS54FPB7.cjs');
10
+ var chunk37V3RET3_cjs = require('./chunk-37V3RET3.cjs');
11
11
  var chunkLTZ5WYOK_cjs = require('./chunk-LTZ5WYOK.cjs');
12
12
  var chunkKIGVVO6N_cjs = require('./chunk-KIGVVO6N.cjs');
13
- var chunkAT4ZQGEZ_cjs = require('./chunk-AT4ZQGEZ.cjs');
14
- var chunkVGHEKIJL_cjs = require('./chunk-VGHEKIJL.cjs');
13
+ var chunkQCJHCSOK_cjs = require('./chunk-QCJHCSOK.cjs');
14
+ var chunkA2SN3RVL_cjs = require('./chunk-A2SN3RVL.cjs');
15
15
  var chunkBBEKHLTW_cjs = require('./chunk-BBEKHLTW.cjs');
16
16
  var chunkE66UVONV_cjs = require('./chunk-E66UVONV.cjs');
17
17
  var chunkUYJQDDEE_cjs = require('./chunk-UYJQDDEE.cjs');
18
- var chunkRFBW5RRH_cjs = require('./chunk-RFBW5RRH.cjs');
19
- var chunk4WMZGHIC_cjs = require('./chunk-4WMZGHIC.cjs');
18
+ var chunkQJUJNTIU_cjs = require('./chunk-QJUJNTIU.cjs');
19
+ var chunkBP52BFIV_cjs = require('./chunk-BP52BFIV.cjs');
20
20
  var chunkJ6JTWD2A_cjs = require('./chunk-J6JTWD2A.cjs');
21
21
  var chunkIXUHXTHW_cjs = require('./chunk-IXUHXTHW.cjs');
22
22
  var chunkRCQ2HIQD_cjs = require('./chunk-RCQ2HIQD.cjs');
23
23
  require('./chunk-P3XDZL6Q.cjs');
24
- var chunkC3ZQP5NW_cjs = require('./chunk-C3ZQP5NW.cjs');
24
+ var chunkKKNEYIZJ_cjs = require('./chunk-KKNEYIZJ.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');
@@ -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("*", chunkIS54FPB7_cjs.requireAuth());
704
+ router3.use("*", chunk37V3RET3_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("*", chunkIS54FPB7_cjs.requireAuth());
1113
+ adminRoutes.use("*", chunk37V3RET3_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 chunkCTYLCWMO_cjs.getEmailService().send({
1151
+ const result = await chunkI767LVN7_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 chunkCTYLCWMO_cjs.getEmailService().send({
1233
+ const result = await chunkI767LVN7_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 chunkCTYLCWMO_cjs.getEmailService().send({
1307
+ const result = await chunkI767LVN7_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 chunkCTYLCWMO_cjs.getEmailService().send({
1375
+ const result = await chunkI767LVN7_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 = chunk4WMZGHIC_cjs.definePlugin({
2116
+ var emailPluginV3 = chunkBP52BFIV_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 chunkIS54FPB7_cjs.DocumentTypeRegistry(db);
2130
+ const typeRegistry = new chunk37V3RET3_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 (!chunkCTYLCWMO_cjs.hasEmailService()) {
2145
+ if (!chunkI767LVN7_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
- chunkCTYLCWMO_cjs.setEmailService(new EmailService({ ...serviceOpts, provider }));
2163
+ chunkI767LVN7_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 = chunk4WMZGHIC_cjs.definePlugin({
2174
+ var emailReconciliationPlugin = chunkBP52BFIV_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 (!chunkCTYLCWMO_cjs.hasEmailService()) {
2195
+ if (!chunkI767LVN7_cjs.hasEmailService()) {
2196
2196
  console.warn("[email-reconciliation] EmailService not initialized \u2014 skipping.");
2197
2197
  return;
2198
2198
  }
2199
- const emailService = chunkCTYLCWMO_cjs.getEmailService();
2199
+ const emailService = chunkI767LVN7_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 (chunkCTYLCWMO_cjs.hasEmailService()) {
2687
- const sent = await chunkCTYLCWMO_cjs.getEmailService().send({
2686
+ if (chunkI767LVN7_cjs.hasEmailService()) {
2687
+ const sent = await chunkI767LVN7_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 chunkIS54FPB7_cjs.getJwtExpirySecondsFromDb(db, c.env);
2790
- const token = await chunkIS54FPB7_cjs.AuthManager.generateToken(user.id, user.email, user.role, c.env.JWT_SECRET, tokenTtl);
2789
+ const tokenTtl = await chunk37V3RET3_cjs.getJwtExpirySecondsFromDb(db, c.env);
2790
+ const token = await chunk37V3RET3_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
- chunkCTYLCWMO_cjs.dispatchHookEvent(
2797
+ chunkI767LVN7_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 chunkCTYLCWMO_cjs.getCustomData(db, user.id);
2803
+ const customData = await chunkI767LVN7_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 = chunk4WMZGHIC_cjs.definePlugin({
2848
+ var otpLoginPlugin = chunkBP52BFIV_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 chunkIS54FPB7_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
3247
- const jwt2 = await chunkIS54FPB7_cjs.AuthManager.generateToken(
3246
+ const tokenTtl2 = await chunk37V3RET3_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
3247
+ const jwt2 = await chunk37V3RET3_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
- chunkIS54FPB7_cjs.AuthManager.setAuthCookie(c, jwt2, { sameSite: "Lax", maxAge: tokenTtl2 });
3254
+ chunk37V3RET3_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 chunkIS54FPB7_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
3272
- const jwt2 = await chunkIS54FPB7_cjs.AuthManager.generateToken(
3271
+ const tokenTtl2 = await chunk37V3RET3_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
3272
+ const jwt2 = await chunk37V3RET3_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
- chunkIS54FPB7_cjs.AuthManager.setAuthCookie(c, jwt2, { sameSite: "Lax", maxAge: tokenTtl2 });
3279
+ chunk37V3RET3_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 chunkIS54FPB7_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
3293
- const jwt = await chunkIS54FPB7_cjs.AuthManager.generateToken(
3292
+ const tokenTtl = await chunk37V3RET3_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
3293
+ const jwt = await chunk37V3RET3_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
- chunkIS54FPB7_cjs.AuthManager.setAuthCookie(c, jwt, { sameSite: "Lax", maxAge: tokenTtl });
3300
+ chunk37V3RET3_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 = chunk4WMZGHIC_cjs.definePlugin({
3395
+ var oauthProvidersPlugin = chunkBP52BFIV_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 = chunkAT4ZQGEZ_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal).map((r) => ({
3979
+ const allCollections = chunkQCJHCSOK_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 = chunkAT4ZQGEZ_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal).sort((a, b) => a.displayName.localeCompare(b.displayName)).map((r) => ({
4031
+ const allCollections = chunkQCJHCSOK_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 = chunkAT4ZQGEZ_cjs.getCollectionRegistry();
4370
+ const registry = chunkQCJHCSOK_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`);
@@ -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("*", chunkIS54FPB7_cjs.requireAuth());
4997
+ adminRoutes2.use("*", chunk37V3RET3_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 = chunk4WMZGHIC_cjs.definePlugin({
5238
+ var aiSearchPlugin = chunkBP52BFIV_cjs.definePlugin({
5239
5239
  id: manifest_default.id,
5240
5240
  version: manifest_default.version,
5241
5241
  name: manifest_default.name,
@@ -6108,7 +6108,7 @@ function renderSecuritySettingsPage(data) {
6108
6108
 
6109
6109
  // src/plugins/core-plugins/security-audit-plugin/routes/admin.ts
6110
6110
  var adminRoutes3 = new hono.Hono();
6111
- adminRoutes3.use("*", chunkIS54FPB7_cjs.requireAuth());
6111
+ adminRoutes3.use("*", chunk37V3RET3_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 chunkAT4ZQGEZ_cjs.PluginService(db);
6121
+ const pluginService = new chunkQCJHCSOK_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 chunkAT4ZQGEZ_cjs.PluginService(db);
6226
+ const pluginService = new chunkQCJHCSOK_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("*", chunkIS54FPB7_cjs.requireAuth());
6388
+ apiRoutes2.use("*", chunk37V3RET3_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 chunkAT4ZQGEZ_cjs.PluginService(db);
6398
+ const pluginService = new chunkQCJHCSOK_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 chunkAT4ZQGEZ_cjs.PluginService(db);
6546
+ const pluginService = new chunkQCJHCSOK_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 = chunk4WMZGHIC_cjs.definePlugin({
6777
+ var securityAuditPlugin = chunkBP52BFIV_cjs.definePlugin({
6778
6778
  id: "security-audit",
6779
6779
  version: "1.0.0",
6780
6780
  name: "Security Audit",
@@ -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
- chunkCTYLCWMO_cjs.createDocumentSchema.parse({
6853
+ chunkI767LVN7_cjs.createDocumentSchema.parse({
6854
6854
  typeId: "api_key",
6855
6855
  tenantId: this.tenantId,
6856
6856
  title: name,
@@ -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 chunkAT4ZQGEZ_cjs.PluginService(db).getPlugin("api-keys");
7166
+ const plugin2 = await new chunkQCJHCSOK_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("*", chunkIS54FPB7_cjs.requireAuth());
7175
+ adminRoutes4.use("*", chunk37V3RET3_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 = chunk4WMZGHIC_cjs.definePlugin({
7260
+ var apiKeysPlugin = chunkBP52BFIV_cjs.definePlugin({
7261
7261
  id: "api-keys",
7262
7262
  version: "1.0.0-beta.1",
7263
7263
  name: "API Keys",
@@ -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("*", chunkIS54FPB7_cjs.requireAuth());
8031
+ adminRoutes5.use("*", chunk37V3RET3_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 chunkAT4ZQGEZ_cjs.PluginService(db);
8041
+ const pluginService = new chunkQCJHCSOK_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;
@@ -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 chunkAT4ZQGEZ_cjs.PluginService(db);
8364
+ const pluginService = new chunkQCJHCSOK_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", chunkIS54FPB7_cjs.requireAuth(), async (c) => {
8515
+ apiRoutes3.post("/create-checkout-session", chunk37V3RET3_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", chunkIS54FPB7_cjs.requireAuth(), async (c) => {
8555
+ apiRoutes3.get("/subscription", chunk37V3RET3_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", chunkIS54FPB7_cjs.requireAuth(), async (c) => {
8567
+ apiRoutes3.get("/subscriptions", chunk37V3RET3_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", chunkIS54FPB7_cjs.requireAuth(), async (c) => {
8583
+ apiRoutes3.get("/stats", chunk37V3RET3_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", chunkIS54FPB7_cjs.requireAuth(), async (c) => {
8592
+ apiRoutes3.post("/sync-subscriptions", chunk37V3RET3_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", chunkIS54FPB7_cjs.requireAuth(), async (c) => {
8640
+ apiRoutes3.get("/events", chunk37V3RET3_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 = chunk4WMZGHIC_cjs.definePlugin({
8663
+ var stripePlugin = chunkBP52BFIV_cjs.definePlugin({
8664
8664
  id: "stripe",
8665
8665
  version: "1.0.0",
8666
8666
  name: "Stripe",
@@ -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
- ${chunkCTYLCWMO_cjs.renderTable(tableData)}
8936
+ ${chunkI767LVN7_cjs.renderTable(tableData)}
8937
8937
  </div>
8938
8938
  </div>
8939
8939
  `;
@@ -10363,7 +10363,7 @@ function renderFormCreatePage(data) {
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("*", chunkIS54FPB7_cjs.requireAuth());
10366
+ adminFormsRoutes.use("*", chunk37V3RET3_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 chunkRFBW5RRH_cjs.TurnstileService(db);
10539
+ const turnstileService = new chunkQJUJNTIU_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 chunkRFBW5RRH_cjs.TurnstileService(db);
10708
+ const turnstileService = new chunkQJUJNTIU_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 chunkRFBW5RRH_cjs.TurnstileService(db);
11138
+ const turnstileService = new chunkQJUJNTIU_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 = chunk4WMZGHIC_cjs.definePlugin({
11200
+ var formsPlugin = chunkBP52BFIV_cjs.definePlugin({
11201
11201
  id: "forms",
11202
11202
  version: "1.0.0",
11203
11203
  name: "Forms",
@@ -11217,7 +11217,7 @@ var formsPlugin = chunk4WMZGHIC_cjs.definePlugin({
11217
11217
  });
11218
11218
  chunkUYJQDDEE_cjs.init_admin_layout_catalyst_template();
11219
11219
  var adminRbacRoutes = new hono.Hono();
11220
- adminRbacRoutes.use("*", chunkIS54FPB7_cjs.requireRbac("rbac", "manage"));
11220
+ adminRbacRoutes.use("*", chunk37V3RET3_cjs.requireRbac("rbac", "manage"));
11221
11221
  var esc = (s) => String(s).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
11222
11222
  var TABS2 = `
11223
11223
  <div class="border-b border-zinc-950/10 dark:border-white/10 mb-6">
@@ -11525,7 +11525,7 @@ adminRbacRoutes.get("/", async (c) => {
11525
11525
  title: "Roles & Permissions",
11526
11526
  pageTitle: "Roles & Permissions",
11527
11527
  currentPath: "/admin/users",
11528
- version: chunkC3ZQP5NW_cjs.getCoreVersion(),
11528
+ version: chunkKKNEYIZJ_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
  })
@@ -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(chunkAT4ZQGEZ_cjs.PLUGIN_REGISTRY).filter((p) => p.adminMenu !== null).map((p) => ({
11665
+ var REGISTRY_MENU_PLUGINS = Object.values(chunkQCJHCSOK_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,
@@ -11741,7 +11741,7 @@ function pluginMenuMiddleware() {
11741
11741
  } catch {
11742
11742
  }
11743
11743
  const user = c.get("user");
11744
- const singletonItems = chunk4WMZGHIC_cjs.resolvePluginMenuItems(user ? { role: user.role } : void 0);
11744
+ const singletonItems = chunkBP52BFIV_cjs.resolvePluginMenuItems(user ? { role: user.role } : void 0);
11745
11745
  const existingPaths = new Set(activeMenuItems.map((i) => i.path));
11746
11746
  for (const item of singletonItems) {
11747
11747
  if (!existingPaths.has(item.path)) {
@@ -12913,8 +12913,8 @@ function sanitizeUrl(url) {
12913
12913
  return trimmed;
12914
12914
  }
12915
12915
  var adminMenuRoutes = new hono.Hono();
12916
- adminMenuRoutes.use("*", chunkIS54FPB7_cjs.requireAuth());
12917
- adminMenuRoutes.use("*", chunkIS54FPB7_cjs.requireRole(["admin"]));
12916
+ adminMenuRoutes.use("*", chunk37V3RET3_cjs.requireAuth());
12917
+ adminMenuRoutes.use("*", chunk37V3RET3_cjs.requireRole(["admin"]));
12918
12918
  adminMenuRoutes.get("/", async (c) => {
12919
12919
  const db = c.env.DB;
12920
12920
  const user = c.get("user");
@@ -13128,7 +13128,7 @@ adminMenuRoutes.post("/:id/move-down", async (c) => {
13128
13128
  }
13129
13129
  return c.redirect("/admin/menu");
13130
13130
  });
13131
- var menuPlugin = chunk4WMZGHIC_cjs.definePlugin({
13131
+ var menuPlugin = chunkBP52BFIV_cjs.definePlugin({
13132
13132
  id: "menu",
13133
13133
  version: "1.0.0",
13134
13134
  name: "Menu Manager",
@@ -13143,7 +13143,7 @@ var menuPlugin = chunk4WMZGHIC_cjs.definePlugin({
13143
13143
  const db = env.DB;
13144
13144
  if (!db) return;
13145
13145
  try {
13146
- const typeRegistry = new chunkIS54FPB7_cjs.DocumentTypeRegistry(db);
13146
+ const typeRegistry = new chunk37V3RET3_cjs.DocumentTypeRegistry(db);
13147
13147
  await typeRegistry.register({
13148
13148
  id: "menu_item",
13149
13149
  name: "menu_item",
@@ -13178,7 +13178,7 @@ var menuPlugin = chunk4WMZGHIC_cjs.definePlugin({
13178
13178
  lockedFields: [...item.lockedFields]
13179
13179
  }, item.sortOrder);
13180
13180
  }
13181
- await chunkCTYLCWMO_cjs.reconcileMenuFromPlugins(db);
13181
+ await chunkI767LVN7_cjs.reconcileMenuFromPlugins(db);
13182
13182
  } catch {
13183
13183
  }
13184
13184
  },
@@ -13198,7 +13198,7 @@ var menuPlugin = chunk4WMZGHIC_cjs.definePlugin({
13198
13198
  });
13199
13199
  chunkUYJQDDEE_cjs.init_admin_layout_catalyst_template();
13200
13200
  var adminRoutes6 = new hono.Hono();
13201
- adminRoutes6.use("*", chunkIS54FPB7_cjs.requireAuth());
13201
+ adminRoutes6.use("*", chunk37V3RET3_cjs.requireAuth());
13202
13202
  adminRoutes6.use("*", async (c, next) => {
13203
13203
  const user = c.get("user");
13204
13204
  if (user?.role !== "admin") {
@@ -13554,7 +13554,7 @@ apiRoutes4.get("/stats", async (c) => {
13554
13554
  });
13555
13555
 
13556
13556
  // src/plugins/core-plugins/analytics/index.ts
13557
- var analyticsPlugin = chunk4WMZGHIC_cjs.definePlugin({
13557
+ var analyticsPlugin = chunkBP52BFIV_cjs.definePlugin({
13558
13558
  id: "core-analytics",
13559
13559
  version: "1.0.0",
13560
13560
  name: "Analytics",
@@ -13701,7 +13701,7 @@ function esc2(s) {
13701
13701
  return (s || "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
13702
13702
  }
13703
13703
  async function getVariablesMap(db) {
13704
- let variables = chunkCTYLCWMO_cjs.getVariablesCached();
13704
+ let variables = chunkI767LVN7_cjs.getVariablesCached();
13705
13705
  if (variables) return variables;
13706
13706
  try {
13707
13707
  const { results } = await db.prepare(
@@ -13711,7 +13711,7 @@ async function getVariablesMap(db) {
13711
13711
  for (const row of results || []) {
13712
13712
  variables.set(row.key, row.value);
13713
13713
  }
13714
- chunkCTYLCWMO_cjs.setVariablesCache(variables);
13714
+ chunkI767LVN7_cjs.setVariablesCache(variables);
13715
13715
  return variables;
13716
13716
  } catch {
13717
13717
  return /* @__PURE__ */ new Map();
@@ -13780,7 +13780,7 @@ apiRoutes5.post("/", async (c) => {
13780
13780
  await db.prepare(
13781
13781
  "INSERT INTO global_variables (key, value, description, category, is_active) VALUES (?, ?, ?, ?, ?)"
13782
13782
  ).bind(key, value || "", description || "", category || "general", isActive !== false ? 1 : 0).run();
13783
- chunkCTYLCWMO_cjs.invalidateVariablesCache();
13783
+ chunkI767LVN7_cjs.invalidateVariablesCache();
13784
13784
  const created = await db.prepare("SELECT * FROM global_variables WHERE key = ?").bind(key).first();
13785
13785
  return c.json({ success: true, data: formatVariable(created) }, 201);
13786
13786
  } catch {
@@ -13825,7 +13825,7 @@ apiRoutes5.put("/:id", async (c) => {
13825
13825
  updates.push("updated_at = strftime('%s', 'now')");
13826
13826
  params.push(id);
13827
13827
  await db.prepare(`UPDATE global_variables SET ${updates.join(", ")} WHERE id = ?`).bind(...params).run();
13828
- chunkCTYLCWMO_cjs.invalidateVariablesCache();
13828
+ chunkI767LVN7_cjs.invalidateVariablesCache();
13829
13829
  const updated = await db.prepare("SELECT * FROM global_variables WHERE id = ?").bind(id).first();
13830
13830
  return c.json({ success: true, data: formatVariable(updated) });
13831
13831
  } catch {
@@ -13839,7 +13839,7 @@ apiRoutes5.delete("/:id", async (c) => {
13839
13839
  const existing = await db.prepare("SELECT id FROM global_variables WHERE id = ?").bind(id).first();
13840
13840
  if (!existing) return c.json({ error: "Variable not found" }, 404);
13841
13841
  await db.prepare("DELETE FROM global_variables WHERE id = ?").bind(id).run();
13842
- chunkCTYLCWMO_cjs.invalidateVariablesCache();
13842
+ chunkI767LVN7_cjs.invalidateVariablesCache();
13843
13843
  return c.json({ success: true });
13844
13844
  } catch {
13845
13845
  return c.json({ success: false, error: "Failed to delete variable" }, 500);
@@ -13899,7 +13899,7 @@ adminRoutes7.put("/:id", async (c) => {
13899
13899
  const value = body.value;
13900
13900
  if (value !== void 0) {
13901
13901
  await db.prepare("UPDATE global_variables SET value = ?, updated_at = strftime('%s', 'now') WHERE id = ?").bind(value, id).run();
13902
- chunkCTYLCWMO_cjs.invalidateVariablesCache();
13902
+ chunkI767LVN7_cjs.invalidateVariablesCache();
13903
13903
  }
13904
13904
  return c.html('<span class="text-green-400 text-xs">Saved</span>');
13905
13905
  });
@@ -13907,7 +13907,7 @@ adminRoutes7.post("/:id/toggle", async (c) => {
13907
13907
  const db = c.env.DB;
13908
13908
  const id = c.req.param("id");
13909
13909
  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
- chunkCTYLCWMO_cjs.invalidateVariablesCache();
13910
+ chunkI767LVN7_cjs.invalidateVariablesCache();
13911
13911
  c.header("HX-Redirect", "/admin/global-variables");
13912
13912
  return c.body(null, 204);
13913
13913
  });
@@ -13928,7 +13928,7 @@ adminRoutes7.post("/", async (c) => {
13928
13928
  await db.prepare(
13929
13929
  "INSERT INTO global_variables (key, value, description, category) VALUES (?, ?, ?, ?)"
13930
13930
  ).bind(key, value, description, category).run();
13931
- chunkCTYLCWMO_cjs.invalidateVariablesCache();
13931
+ chunkI767LVN7_cjs.invalidateVariablesCache();
13932
13932
  c.header("HX-Redirect", "/admin/global-variables");
13933
13933
  return c.body(null, 204);
13934
13934
  });
@@ -13947,7 +13947,7 @@ adminRoutes7.post("/settings/editor-integration", async (c) => {
13947
13947
  adminRoutes7.delete("/:id", async (c) => {
13948
13948
  const db = c.env.DB;
13949
13949
  await db.prepare("DELETE FROM global_variables WHERE id = ?").bind(c.req.param("id")).run();
13950
- chunkCTYLCWMO_cjs.invalidateVariablesCache();
13950
+ chunkI767LVN7_cjs.invalidateVariablesCache();
13951
13951
  return c.html("");
13952
13952
  });
13953
13953
  function renderAdminPage(variables, editorStatus = { editorActive: false, activeEditorName: "", enableEditorIntegration: true }) {
@@ -14265,7 +14265,7 @@ function renderAdminPage(variables, editorStatus = { editorActive: false, active
14265
14265
  </div>
14266
14266
  ` });
14267
14267
  }
14268
- var globalVariablesPlugin = chunk4WMZGHIC_cjs.definePlugin({
14268
+ var globalVariablesPlugin = chunkBP52BFIV_cjs.definePlugin({
14269
14269
  id: "global-variables",
14270
14270
  version: "1.1.0",
14271
14271
  name: "Global Variables",
@@ -14288,7 +14288,7 @@ var globalVariablesPlugin = chunk4WMZGHIC_cjs.definePlugin({
14288
14288
  if (!db || !data) return data;
14289
14289
  const variables = await getVariablesMap(db);
14290
14290
  if (variables.size === 0) return data;
14291
- return chunkCTYLCWMO_cjs.resolveVariablesInObject(data, variables);
14291
+ return chunkI767LVN7_cjs.resolveVariablesInObject(data, variables);
14292
14292
  } catch {
14293
14293
  return data;
14294
14294
  }
@@ -14306,7 +14306,7 @@ var globalVariablesPlugin = chunk4WMZGHIC_cjs.definePlugin({
14306
14306
  },
14307
14307
  activate: async () => console.info("[GlobalVariables] Plugin activated"),
14308
14308
  deactivate: async () => {
14309
- chunkCTYLCWMO_cjs.invalidateVariablesCache();
14309
+ chunkI767LVN7_cjs.invalidateVariablesCache();
14310
14310
  console.info("[GlobalVariables] Plugin deactivated, cache cleared");
14311
14311
  },
14312
14312
  uninstall: async (ctx) => {
@@ -14872,7 +14872,7 @@ function renderAdminPage2(shortcodes, editorStatus = { editorActive: false, acti
14872
14872
  </div>
14873
14873
  ` });
14874
14874
  }
14875
- var shortcodesPlugin = chunk4WMZGHIC_cjs.definePlugin({
14875
+ var shortcodesPlugin = chunkBP52BFIV_cjs.definePlugin({
14876
14876
  id: "shortcodes",
14877
14877
  version: "1.0.0",
14878
14878
  name: "Shortcodes",
@@ -14956,7 +14956,7 @@ helloWorldRoutes.get("/", async (c) => {
14956
14956
  </html>
14957
14957
  `);
14958
14958
  });
14959
- var helloWorldPlugin = chunk4WMZGHIC_cjs.definePlugin({
14959
+ var helloWorldPlugin = chunkBP52BFIV_cjs.definePlugin({
14960
14960
  id: "hello-world",
14961
14961
  version: "1.0.0",
14962
14962
  name: "Hello World",
@@ -15187,7 +15187,7 @@ function renderTenantForm(data) {
15187
15187
  // src/plugins/core-plugins/multi-tenant-plugin/templates/tenant-members.template.ts
15188
15188
  chunkUYJQDDEE_cjs.init_admin_layout_catalyst_template();
15189
15189
  function roleOptions(selected) {
15190
- return chunkCTYLCWMO_cjs.VALID_MEMBER_ROLES.map(
15190
+ return chunkI767LVN7_cjs.VALID_MEMBER_ROLES.map(
15191
15191
  (r) => `<option value="${r}" ${r === selected ? "selected" : ""}>${r}</option>`
15192
15192
  ).join("");
15193
15193
  }
@@ -15249,7 +15249,7 @@ function renderInvitations(slug, invitations) {
15249
15249
  <div>
15250
15250
  <label for="invite-role" class="mb-1 block text-xs font-medium text-zinc-500 dark:text-zinc-400">Role</label>
15251
15251
  <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
- ${chunkCTYLCWMO_cjs.VALID_MEMBER_ROLES.map((r) => `<option value="${r}" ${r === "viewer" ? "selected" : ""}>${r}</option>`).join("")}
15252
+ ${chunkI767LVN7_cjs.VALID_MEMBER_ROLES.map((r) => `<option value="${r}" ${r === "viewer" ? "selected" : ""}>${r}</option>`).join("")}
15253
15253
  </select>
15254
15254
  </div>
15255
15255
  <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>
@@ -15345,7 +15345,7 @@ function renderTenantMembers(data) {
15345
15345
  // src/plugins/core-plugins/multi-tenant-plugin/templates/user-memberships.template.ts
15346
15346
  chunkUYJQDDEE_cjs.init_admin_layout_catalyst_template();
15347
15347
  function roleOptions2(selected) {
15348
- return chunkCTYLCWMO_cjs.VALID_MEMBER_ROLES.map(
15348
+ return chunkI767LVN7_cjs.VALID_MEMBER_ROLES.map(
15349
15349
  (r) => `<option value="${r}" ${r === selected ? "selected" : ""}>${r}</option>`
15350
15350
  ).join("");
15351
15351
  }
@@ -15507,7 +15507,7 @@ function zodToFieldErrors(error) {
15507
15507
  }
15508
15508
  async function isMultiTenantActive(db) {
15509
15509
  try {
15510
- const plugin2 = await new chunkAT4ZQGEZ_cjs.PluginService(db).getPlugin(chunkAT4ZQGEZ_cjs.MULTI_TENANT_PLUGIN_ID);
15510
+ const plugin2 = await new chunkQCJHCSOK_cjs.PluginService(db).getPlugin(chunkQCJHCSOK_cjs.MULTI_TENANT_PLUGIN_ID);
15511
15511
  return plugin2?.status === "active";
15512
15512
  } catch {
15513
15513
  return false;
@@ -15515,7 +15515,7 @@ async function isMultiTenantActive(db) {
15515
15515
  }
15516
15516
  function createTenantAdminRoutes() {
15517
15517
  const routes2 = new hono.Hono();
15518
- routes2.use("*", chunkIS54FPB7_cjs.requireAuth());
15518
+ routes2.use("*", chunk37V3RET3_cjs.requireAuth());
15519
15519
  routes2.use("*", async (c, next) => {
15520
15520
  const user = c.get("user");
15521
15521
  if (user?.role !== "admin") {
@@ -15529,7 +15529,7 @@ function createTenantAdminRoutes() {
15529
15529
  const form = await c.req.formData();
15530
15530
  const slug = String(form.get("tenant") ?? "").trim().toLowerCase();
15531
15531
  const redirect = String(form.get("redirect") ?? "");
15532
- const svc = new chunkCTYLCWMO_cjs.TenantService(db);
15532
+ const svc = new chunkI767LVN7_cjs.TenantService(db);
15533
15533
  const tenant = await svc.getTenantBySlug(slug);
15534
15534
  if (!tenant || tenant.status !== "active") {
15535
15535
  return c.json({ error: "Unknown or inactive tenant" }, 400);
@@ -15539,7 +15539,7 @@ function createTenantAdminRoutes() {
15539
15539
  if (!user.isSuperAdmin && !await svc.isMember(user.userId, slug)) {
15540
15540
  return c.json({ error: "You are not a member of this tenant" }, 403);
15541
15541
  }
15542
- cookie.setCookie(c, chunkAT4ZQGEZ_cjs.TENANT_COOKIE, slug, {
15542
+ cookie.setCookie(c, chunkQCJHCSOK_cjs.TENANT_COOKIE, slug, {
15543
15543
  path: "/",
15544
15544
  httpOnly: true,
15545
15545
  sameSite: "Lax",
@@ -15556,7 +15556,7 @@ function createTenantAdminRoutes() {
15556
15556
  if (!user) return c.redirect("/auth/login");
15557
15557
  const token = c.req.query("token") ?? "";
15558
15558
  try {
15559
- const { slug } = await new chunkCTYLCWMO_cjs.TenantService(db).acceptInvitation(token, user.userId, user.email);
15559
+ const { slug } = await new chunkI767LVN7_cjs.TenantService(db).acceptInvitation(token, user.userId, user.email);
15560
15560
  return c.redirect(`/admin/tenants/${slug}/members?message=Invitation accepted`);
15561
15561
  } catch (error) {
15562
15562
  const message = error instanceof Error ? error.message : "Failed to accept invitation";
@@ -15584,7 +15584,7 @@ function createTenantAdminRoutes() {
15584
15584
  const userId = c.req.param("userId");
15585
15585
  const target = await db.prepare("SELECT id, email FROM auth_user WHERE id = ?").bind(userId).first();
15586
15586
  if (!target?.id) return c.redirect("/admin/users?message=User not found&type=error");
15587
- const svc = new chunkCTYLCWMO_cjs.TenantService(db);
15587
+ const svc = new chunkI767LVN7_cjs.TenantService(db);
15588
15588
  const [memberships, allTenants] = await Promise.all([svc.listUserMemberships(userId), svc.listTenants()]);
15589
15589
  const memberSlugs = new Set(memberships.map((m) => m.slug));
15590
15590
  const availableTenants = allTenants.filter((t) => t.status === "active" && !memberSlugs.has(t.slug)).map((t) => ({ slug: t.slug, name: t.name }));
@@ -15609,10 +15609,10 @@ function createTenantAdminRoutes() {
15609
15609
  const slug = String(form.get("slug") ?? "").trim().toLowerCase();
15610
15610
  const role = String(form.get("role") ?? "viewer");
15611
15611
  const redirectTo = String(form.get("_redirect") ?? "") || `/admin/tenants/users/${userId}`;
15612
- if (!chunkCTYLCWMO_cjs.isValidMemberRole(role)) throw new Error(`Invalid role '${role}'`);
15612
+ if (!chunkI767LVN7_cjs.isValidMemberRole(role)) throw new Error(`Invalid role '${role}'`);
15613
15613
  const target = await db.prepare("SELECT email FROM auth_user WHERE id = ?").bind(userId).first();
15614
15614
  if (!target) throw new Error("User not found");
15615
- const svc = new chunkCTYLCWMO_cjs.TenantService(db);
15615
+ const svc = new chunkI767LVN7_cjs.TenantService(db);
15616
15616
  if (!await svc.getTenantBySlug(slug)) throw new Error("Tenant not found");
15617
15617
  if (await svc.isMember(userId, slug)) throw new Error(`Already a member of '${slug}'`);
15618
15618
  await svc.addMember(slug, userId, role, target.email ?? null);
@@ -15631,7 +15631,7 @@ function createTenantAdminRoutes() {
15631
15631
  const form = await c.req.formData();
15632
15632
  const role = String(form.get("role") ?? "");
15633
15633
  const redirectTo = String(form.get("_redirect") ?? "") || `/admin/tenants/users/${userId}`;
15634
- await new chunkCTYLCWMO_cjs.TenantService(db).setMemberRole(slug, userId, role);
15634
+ await new chunkI767LVN7_cjs.TenantService(db).setMemberRole(slug, userId, role);
15635
15635
  return c.redirect(`${redirectTo}?message=Role updated`);
15636
15636
  } catch (error) {
15637
15637
  const message = error instanceof Error ? error.message : "Failed to update role";
@@ -15646,7 +15646,7 @@ function createTenantAdminRoutes() {
15646
15646
  try {
15647
15647
  const form = await c.req.formData();
15648
15648
  const redirectTo = String(form.get("_redirect") ?? "") || `/admin/tenants/users/${userId}`;
15649
- await new chunkCTYLCWMO_cjs.TenantService(db).removeMember(slug, userId);
15649
+ await new chunkI767LVN7_cjs.TenantService(db).removeMember(slug, userId);
15650
15650
  return c.redirect(`${redirectTo}?message=Removed from ${encodeURIComponent(slug)}`);
15651
15651
  } catch (error) {
15652
15652
  const message = error instanceof Error ? error.message : "Failed to remove membership";
@@ -15661,7 +15661,7 @@ function createTenantAdminRoutes() {
15661
15661
  return c.html(renderTenantsInactive({ user: userShape(cur), version }));
15662
15662
  }
15663
15663
  const roleName = c.req.param("roleName");
15664
- const assignments = await new chunkCTYLCWMO_cjs.TenantService(db).listAssignmentsByRole(roleName);
15664
+ const assignments = await new chunkI767LVN7_cjs.TenantService(db).listAssignmentsByRole(roleName);
15665
15665
  return c.html(renderRoleUsage({ roleName, assignments, user: userShape(cur), version }));
15666
15666
  });
15667
15667
  routes2.get("/", async (c) => {
@@ -15671,7 +15671,7 @@ function createTenantAdminRoutes() {
15671
15671
  if (!await isMultiTenantActive(db)) {
15672
15672
  return c.html(renderTenantsInactive({ user: userShape(user), version }));
15673
15673
  }
15674
- const svc = new chunkCTYLCWMO_cjs.TenantService(db);
15674
+ const svc = new chunkI767LVN7_cjs.TenantService(db);
15675
15675
  await svc.ensureDefaultTenant();
15676
15676
  const tenants = await svc.listTenants();
15677
15677
  const [docRes, memberRes] = await db.batch([
@@ -15710,7 +15710,7 @@ function createTenantAdminRoutes() {
15710
15710
  formEntries = Object.fromEntries(form.entries());
15711
15711
  const validated = tenantFormSchema.parse(formEntries);
15712
15712
  if (!validated.slug) throw new zod.z.ZodError([{ code: "custom", message: "Slug is required", path: ["slug"] }]);
15713
- const svc = new chunkCTYLCWMO_cjs.TenantService(db);
15713
+ const svc = new chunkI767LVN7_cjs.TenantService(db);
15714
15714
  await svc.createTenant({
15715
15715
  name: validated.name,
15716
15716
  slug: validated.slug,
@@ -15735,7 +15735,7 @@ function createTenantAdminRoutes() {
15735
15735
  if (!await isMultiTenantActive(db)) {
15736
15736
  return c.html(renderTenantsInactive({ user: userShape(user), version }));
15737
15737
  }
15738
- const tenant = await new chunkCTYLCWMO_cjs.TenantService(db).getTenantBySlug(c.req.param("slug"));
15738
+ const tenant = await new chunkI767LVN7_cjs.TenantService(db).getTenantBySlug(c.req.param("slug"));
15739
15739
  if (!tenant) return c.redirect("/admin/tenants?message=Tenant not found&type=error");
15740
15740
  return c.html(renderTenantForm({ tenant, isEdit: true, user: userShape(user), version }));
15741
15741
  });
@@ -15745,7 +15745,7 @@ function createTenantAdminRoutes() {
15745
15745
  const version = c.get("appVersion");
15746
15746
  const slug = c.req.param("slug");
15747
15747
  if (!await isMultiTenantActive(db)) return c.json({ error: "Multi-tenant plugin is not active" }, 403);
15748
- const svc = new chunkCTYLCWMO_cjs.TenantService(db);
15748
+ const svc = new chunkI767LVN7_cjs.TenantService(db);
15749
15749
  try {
15750
15750
  const form = await c.req.formData();
15751
15751
  const validated = tenantFormSchema.parse(Object.fromEntries(form.entries()));
@@ -15770,7 +15770,7 @@ function createTenantAdminRoutes() {
15770
15770
  const slug = c.req.param("slug");
15771
15771
  if (!await isMultiTenantActive(db)) return c.json({ error: "Multi-tenant plugin is not active" }, 403);
15772
15772
  try {
15773
- await new chunkCTYLCWMO_cjs.TenantService(db).deleteTenant(slug);
15773
+ await new chunkI767LVN7_cjs.TenantService(db).deleteTenant(slug);
15774
15774
  return c.redirect("/admin/tenants?message=Tenant deleted successfully");
15775
15775
  } catch (error) {
15776
15776
  const message = error instanceof Error ? error.message : "Failed to delete tenant";
@@ -15785,7 +15785,7 @@ function createTenantAdminRoutes() {
15785
15785
  return c.html(renderTenantsInactive({ user: userShape(user), version }));
15786
15786
  }
15787
15787
  const slug = c.req.param("slug");
15788
- const svc = new chunkCTYLCWMO_cjs.TenantService(db);
15788
+ const svc = new chunkI767LVN7_cjs.TenantService(db);
15789
15789
  const tenant = await svc.getTenantBySlug(slug);
15790
15790
  if (!tenant) return c.redirect("/admin/tenants?message=Tenant not found&type=error");
15791
15791
  const [members, invitations] = await Promise.all([svc.listMembers(slug), svc.listInvitations(slug)]);
@@ -15811,7 +15811,7 @@ function createTenantAdminRoutes() {
15811
15811
  const form = await c.req.formData();
15812
15812
  const email = String(form.get("email") ?? "");
15813
15813
  const role = String(form.get("role") ?? "viewer");
15814
- await new chunkCTYLCWMO_cjs.TenantService(db).addMemberByEmail(slug, email, role);
15814
+ await new chunkI767LVN7_cjs.TenantService(db).addMemberByEmail(slug, email, role);
15815
15815
  return c.redirect(`/admin/tenants/${slug}/members?message=Member added`);
15816
15816
  } catch (error) {
15817
15817
  const message = error instanceof Error ? error.message : "Failed to add member";
@@ -15826,7 +15826,7 @@ function createTenantAdminRoutes() {
15826
15826
  try {
15827
15827
  const form = await c.req.formData();
15828
15828
  const role = String(form.get("role") ?? "");
15829
- await new chunkCTYLCWMO_cjs.TenantService(db).setMemberRole(slug, userId, role);
15829
+ await new chunkI767LVN7_cjs.TenantService(db).setMemberRole(slug, userId, role);
15830
15830
  return c.redirect(`/admin/tenants/${slug}/members?message=Role updated`);
15831
15831
  } catch (error) {
15832
15832
  const message = error instanceof Error ? error.message : "Failed to update role";
@@ -15839,7 +15839,7 @@ function createTenantAdminRoutes() {
15839
15839
  const userId = c.req.param("userId");
15840
15840
  if (!await isMultiTenantActive(db)) return c.json({ error: "Multi-tenant plugin is not active" }, 403);
15841
15841
  try {
15842
- await new chunkCTYLCWMO_cjs.TenantService(db).removeMember(slug, userId);
15842
+ await new chunkI767LVN7_cjs.TenantService(db).removeMember(slug, userId);
15843
15843
  return c.redirect(`/admin/tenants/${slug}/members?message=Member removed`);
15844
15844
  } catch (error) {
15845
15845
  const message = error instanceof Error ? error.message : "Failed to remove member";
@@ -15855,12 +15855,12 @@ function createTenantAdminRoutes() {
15855
15855
  const form = await c.req.formData();
15856
15856
  const email = String(form.get("email") ?? "");
15857
15857
  const role = String(form.get("role") ?? "viewer");
15858
- const token = await new chunkCTYLCWMO_cjs.TenantService(db).createInvitation(slug, email, role, user?.userId ?? null);
15858
+ const token = await new chunkI767LVN7_cjs.TenantService(db).createInvitation(slug, email, role, user?.userId ?? null);
15859
15859
  const origin = c.req.header("origin") || new URL(c.req.url).origin;
15860
15860
  const acceptUrl = `${origin}/join/invite?token=${encodeURIComponent(token)}`;
15861
15861
  let note;
15862
15862
  let noteType = "";
15863
- const svc2 = chunkCTYLCWMO_cjs.hasEmailService() ? chunkCTYLCWMO_cjs.getEmailService() : null;
15863
+ const svc2 = chunkI767LVN7_cjs.hasEmailService() ? chunkI767LVN7_cjs.getEmailService() : null;
15864
15864
  const hasRealProvider = !!svc2 && svc2.getProviderName() !== "console";
15865
15865
  if (hasRealProvider) {
15866
15866
  const result = await svc2.send({
@@ -15901,7 +15901,7 @@ function createTenantAdminRoutes() {
15901
15901
  WHERE i.id = ? AND t.slug = ? AND i.status = 'pending'`
15902
15902
  ).bind(id, slug).first();
15903
15903
  if (!inv) throw new Error("Invitation not found or already used");
15904
- const svc2 = chunkCTYLCWMO_cjs.hasEmailService() ? chunkCTYLCWMO_cjs.getEmailService() : null;
15904
+ const svc2 = chunkI767LVN7_cjs.hasEmailService() ? chunkI767LVN7_cjs.getEmailService() : null;
15905
15905
  const hasRealProvider = !!svc2 && svc2.getProviderName() !== "console";
15906
15906
  if (!hasRealProvider) throw new Error("No email plugin active");
15907
15907
  const origin = c.req.header("origin") || new URL(c.req.url).origin;
@@ -15926,7 +15926,7 @@ function createTenantAdminRoutes() {
15926
15926
  const id = c.req.param("id");
15927
15927
  if (!await isMultiTenantActive(db)) return c.json({ error: "Multi-tenant plugin is not active" }, 403);
15928
15928
  try {
15929
- await new chunkCTYLCWMO_cjs.TenantService(db).revokeInvitation(slug, id);
15929
+ await new chunkI767LVN7_cjs.TenantService(db).revokeInvitation(slug, id);
15930
15930
  return c.redirect(`/admin/tenants/${slug}/members?message=Invitation revoked`);
15931
15931
  } catch (error) {
15932
15932
  const message = error instanceof Error ? error.message : "Failed to revoke invitation";
@@ -16156,7 +16156,7 @@ function createJoinRoutes() {
16156
16156
  if (existing) return rerender("An account with this email already exists. Please sign in instead.");
16157
16157
  try {
16158
16158
  const userId = crypto.randomUUID();
16159
- const passwordHash = await chunkIS54FPB7_cjs.AuthManager.hashPassword(password);
16159
+ const passwordHash = await chunk37V3RET3_cjs.AuthManager.hashPassword(password);
16160
16160
  const now = Date.now();
16161
16161
  const nowSec = Math.floor(now / 1e3);
16162
16162
  await db.batch([
@@ -16169,7 +16169,7 @@ function createJoinRoutes() {
16169
16169
  VALUES (?, ?, ?, 'credential', ?, ?, ?)`
16170
16170
  ).bind(`cred-${userId}`, userId, userId, passwordHash, nowSec, nowSec)
16171
16171
  ]);
16172
- await new chunkCTYLCWMO_cjs.TenantService(db).acceptInvitation(token, userId, inv.email);
16172
+ await new chunkI767LVN7_cjs.TenantService(db).acceptInvitation(token, userId, inv.email);
16173
16173
  const auth = chunkGMMCCIQO_cjs.createAuth(c.env);
16174
16174
  const origin = new URL(c.req.url).origin;
16175
16175
  const baReq = new Request(`${origin}/auth/sign-in/email`, {
@@ -16237,7 +16237,7 @@ function createJoinRoutes() {
16237
16237
  const baBody = await baRes.json();
16238
16238
  const userId = baBody?.user?.id;
16239
16239
  if (!userId) return rerender("Sign-in succeeded but could not read user ID.");
16240
- await new chunkCTYLCWMO_cjs.TenantService(db).acceptInvitation(token, userId, inv.email);
16240
+ await new chunkI767LVN7_cjs.TenantService(db).acceptInvitation(token, userId, inv.email);
16241
16241
  const headers = new Headers({ Location: "/admin?message=Welcome! You have joined " + encodeURIComponent(inv.tenantName) });
16242
16242
  copyBaCookies(baRes, headers);
16243
16243
  return new Response(null, { status: 302, headers });
@@ -16251,7 +16251,7 @@ function createJoinRoutes() {
16251
16251
 
16252
16252
  // src/plugins/core-plugins/multi-tenant-plugin/index.ts
16253
16253
  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 = chunk4WMZGHIC_cjs.definePlugin({
16254
+ var multiTenantPlugin = chunkBP52BFIV_cjs.definePlugin({
16255
16255
  id: manifest_default2.id,
16256
16256
  version: "1.0.0",
16257
16257
  name: manifest_default2.name,
@@ -16266,30 +16266,30 @@ var multiTenantPlugin = chunk4WMZGHIC_cjs.definePlugin({
16266
16266
  { label: "Tenants", path: "/admin/tenants", icon: TENANT_ICON, order: 80 }
16267
16267
  ],
16268
16268
  activate: async () => {
16269
- chunkAT4ZQGEZ_cjs.invalidateTenantCache();
16269
+ chunkQCJHCSOK_cjs.invalidateTenantCache();
16270
16270
  console.info("\u2705 Multi-Tenant plugin activated");
16271
16271
  },
16272
16272
  deactivate: async () => {
16273
- chunkAT4ZQGEZ_cjs.invalidateTenantCache();
16273
+ chunkQCJHCSOK_cjs.invalidateTenantCache();
16274
16274
  console.info("\u274C Multi-Tenant plugin deactivated");
16275
16275
  }
16276
16276
  });
16277
16277
  var routes = new hono.Hono();
16278
- routes.use("*", chunkIS54FPB7_cjs.requireAuth());
16279
- routes.use("*", chunkIS54FPB7_cjs.requireRole(["admin", "editor"]));
16278
+ routes.use("*", chunk37V3RET3_cjs.requireAuth());
16279
+ routes.use("*", chunk37V3RET3_cjs.requireRole(["admin", "editor"]));
16280
16280
  routes.get("/:rootId", async (c) => {
16281
16281
  const { rootId } = c.req.param();
16282
16282
  const db = c.env.DB;
16283
- const scope = await chunkCTYLCWMO_cjs.resolveDocScope(c, db, { rootId });
16283
+ const scope = await chunkI767LVN7_cjs.resolveDocScope(c, db, { rootId });
16284
16284
  if (!scope) {
16285
16285
  return c.html('<p class="text-zinc-500 dark:text-zinc-400 p-4">Document not found.</p>', 404);
16286
16286
  }
16287
16287
  if (!scope.docType?.settings?.versioning) {
16288
16288
  return c.html('<p class="text-zinc-500 dark:text-zinc-400 p-4">Versioning not enabled for this type.</p>', 404);
16289
16289
  }
16290
- const denied = await chunkCTYLCWMO_cjs.denyIfNotAllowed(c, db, rootId, "read", scope.docType?.settings, scope.tenantId);
16290
+ const denied = await chunkI767LVN7_cjs.denyIfNotAllowed(c, db, rootId, "read", scope.docType?.settings, scope.tenantId);
16291
16291
  if (denied) return denied;
16292
- const repo = new chunkCTYLCWMO_cjs.DocumentRepository(db, scope.tenantId);
16292
+ const repo = new chunkI767LVN7_cjs.DocumentRepository(db, scope.tenantId);
16293
16293
  const versions = await repo.getVersionHistory(rootId);
16294
16294
  const safeRootIdAttr = chunkMNWKYY5E_cjs.escapeHtml(rootId);
16295
16295
  const rows = versions.map((v) => {
@@ -16382,14 +16382,14 @@ routes.post("/:rootId/restore/:versionNumber", async (c) => {
16382
16382
  const { rootId, versionNumber } = c.req.param();
16383
16383
  const db = c.env.DB;
16384
16384
  const user = c.get("user");
16385
- const scope = await chunkCTYLCWMO_cjs.resolveDocScope(c, db, { rootId });
16385
+ const scope = await chunkI767LVN7_cjs.resolveDocScope(c, db, { rootId });
16386
16386
  if (!scope) {
16387
16387
  return c.json({ error: "Document not found" }, 404);
16388
16388
  }
16389
16389
  if (!scope.docType?.settings?.versioning) {
16390
16390
  return c.json({ error: "Versioning not enabled for this type" }, 404);
16391
16391
  }
16392
- const denied = await chunkCTYLCWMO_cjs.denyIfNotAllowed(c, db, rootId, "update", scope.docType?.settings, scope.tenantId);
16392
+ const denied = await chunkI767LVN7_cjs.denyIfNotAllowed(c, db, rootId, "update", scope.docType?.settings, scope.tenantId);
16393
16393
  if (denied) return denied;
16394
16394
  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
16395
  if (!row) {
@@ -16412,7 +16412,7 @@ routes.post("/:rootId/restore/:versionNumber", async (c) => {
16412
16412
  var routes_default = routes;
16413
16413
 
16414
16414
  // src/plugins/core-plugins/versioning-plugin/index.ts
16415
- var versioningPlugin = chunk4WMZGHIC_cjs.definePlugin({
16415
+ var versioningPlugin = chunkBP52BFIV_cjs.definePlugin({
16416
16416
  id: "versioning",
16417
16417
  version: "1.0.0",
16418
16418
  name: "Versioning",
@@ -16489,8 +16489,8 @@ function createMagicLinkAuthPlugin() {
16489
16489
  const baseUrl = new URL(c.req.url).origin;
16490
16490
  const magicLink = `${baseUrl}/auth/magic-link/verify?token=${token}`;
16491
16491
  try {
16492
- if (chunkCTYLCWMO_cjs.hasEmailService()) {
16493
- await chunkCTYLCWMO_cjs.getEmailService().send({
16492
+ if (chunkI767LVN7_cjs.hasEmailService()) {
16493
+ await chunkI767LVN7_cjs.getEmailService().send({
16494
16494
  to: normalizedEmail,
16495
16495
  subject: "Your Magic Link to Sign In",
16496
16496
  flow: "magic-link",
@@ -16567,19 +16567,19 @@ function createMagicLinkAuthPlugin() {
16567
16567
  SET used = 1, used_at = ?
16568
16568
  WHERE id = ?
16569
16569
  `).bind(Date.now(), magicLink.id).run();
16570
- const tokenTtl = await chunkIS54FPB7_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
16571
- const jwtToken = await chunkIS54FPB7_cjs.AuthManager.generateToken(
16570
+ const tokenTtl = await chunk37V3RET3_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
16571
+ const jwtToken = await chunk37V3RET3_cjs.AuthManager.generateToken(
16572
16572
  user.id,
16573
16573
  user.email,
16574
16574
  user.role,
16575
16575
  c.env.JWT_SECRET,
16576
16576
  tokenTtl
16577
16577
  );
16578
- chunkIS54FPB7_cjs.AuthManager.setAuthCookie(c, jwtToken, { maxAge: tokenTtl });
16578
+ chunk37V3RET3_cjs.AuthManager.setAuthCookie(c, jwtToken, { maxAge: tokenTtl });
16579
16579
  await db.prepare(`
16580
16580
  UPDATE auth_user SET last_login_at = ? WHERE id = ?
16581
16581
  `).bind(Date.now(), user.id).run();
16582
- chunkCTYLCWMO_cjs.dispatchHookEvent(
16582
+ chunkI767LVN7_cjs.dispatchHookEvent(
16583
16583
  c,
16584
16584
  "auth:magic-link:consumed",
16585
16585
  { user: { id: user.id, email: user.email, role: user.role } },
@@ -17064,7 +17064,7 @@ async function warmCollections(db) {
17064
17064
  const collectionCache = chunkYA3TJ65D_cjs.getCacheService(config);
17065
17065
  let count = 0;
17066
17066
  try {
17067
- const results = chunkAT4ZQGEZ_cjs.getCollectionRegistry().listActive().map(chunkAT4ZQGEZ_cjs.collectionRecordToRow);
17067
+ const results = chunkQCJHCSOK_cjs.getCollectionRegistry().listActive().map(chunkQCJHCSOK_cjs.collectionRecordToRow);
17068
17068
  for (const collection of results) {
17069
17069
  const key = collectionCache.generateKey("item", collection.id);
17070
17070
  await collectionCache.set(key, collection);
@@ -17335,7 +17335,7 @@ function renderCacheDashboard(data) {
17335
17335
  </script>
17336
17336
 
17337
17337
  <!-- Confirmation Dialogs -->
17338
- ${chunkCTYLCWMO_cjs.renderConfirmationDialog({
17338
+ ${chunkI767LVN7_cjs.renderConfirmationDialog({
17339
17339
  id: "clear-all-cache-confirm",
17340
17340
  title: "Clear All Cache",
17341
17341
  message: "Are you sure you want to clear all cache entries? This cannot be undone.",
@@ -17346,7 +17346,7 @@ function renderCacheDashboard(data) {
17346
17346
  onConfirm: "performClearAllCaches()"
17347
17347
  })}
17348
17348
 
17349
- ${chunkCTYLCWMO_cjs.renderConfirmationDialog({
17349
+ ${chunkI767LVN7_cjs.renderConfirmationDialog({
17350
17350
  id: "clear-namespace-cache-confirm",
17351
17351
  title: "Clear Namespace Cache",
17352
17352
  message: "Clear cache for this namespace?",
@@ -17357,7 +17357,7 @@ function renderCacheDashboard(data) {
17357
17357
  onConfirm: "performClearNamespaceCache()"
17358
17358
  })}
17359
17359
 
17360
- ${chunkCTYLCWMO_cjs.getConfirmationDialogScript()}
17360
+ ${chunkI767LVN7_cjs.getConfirmationDialogScript()}
17361
17361
  `;
17362
17362
  const layoutData = {
17363
17363
  title: "Cache System",
@@ -17623,7 +17623,7 @@ app.get("/", async (c) => {
17623
17623
  const totalRequests = totalHits + totalMisses;
17624
17624
  const overallHitRate = totalRequests > 0 ? totalHits / totalRequests * 100 : 0;
17625
17625
  const DEFAULT_TTL = chunkYA3TJ65D_cjs.CACHE_CONFIGS.api?.ttl ?? 300;
17626
- const collections = chunkAT4ZQGEZ_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal).map((r) => {
17626
+ const collections = chunkQCJHCSOK_cjs.getCollectionRegistry().listActive().filter((r) => !r.internal).map((r) => {
17627
17627
  const cacheOverride = r.cache;
17628
17628
  const cacheEnabled = cacheOverride?.enabled !== false;
17629
17629
  const hasCustomTtl = typeof cacheOverride?.ttl === "number";
@@ -18160,9 +18160,9 @@ var faviconSvg = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
18160
18160
  // src/app.ts
18161
18161
  function createSonicJSApp(config = {}) {
18162
18162
  const app2 = new hono.Hono();
18163
- const appVersion = config.version || chunkC3ZQP5NW_cjs.getCoreVersion();
18163
+ const appVersion = config.version || chunkKKNEYIZJ_cjs.getCoreVersion();
18164
18164
  const appName = config.name || "SonicJS AI";
18165
- const hookSystem = new chunkRFBW5RRH_cjs.HookSystemImpl();
18165
+ const hookSystem = new chunkQJUJNTIU_cjs.HookSystemImpl();
18166
18166
  chunkJ6JTWD2A_cjs.setHookSystem(hookSystem);
18167
18167
  const magicLinkPlugin = createMagicLinkAuthPlugin();
18168
18168
  const corePluginsBeforeCatchAll = [
@@ -18170,7 +18170,7 @@ function createSonicJSApp(config = {}) {
18170
18170
  apiKeysPlugin,
18171
18171
  aiSearchPlugin,
18172
18172
  oauthProvidersPlugin,
18173
- chunkCTYLCWMO_cjs.userProfilesPlugin,
18173
+ chunkI767LVN7_cjs.userProfilesPlugin,
18174
18174
  otpLoginPlugin,
18175
18175
  analyticsPlugin,
18176
18176
  stripePlugin,
@@ -18180,24 +18180,24 @@ function createSonicJSApp(config = {}) {
18180
18180
  shortcodesPlugin,
18181
18181
  helloWorldPlugin,
18182
18182
  multiTenantPlugin,
18183
- chunkCTYLCWMO_cjs.lexicalEditorPlugin,
18183
+ chunkI767LVN7_cjs.lexicalEditorPlugin,
18184
18184
  versioningPlugin,
18185
18185
  menuPlugin
18186
18186
  ];
18187
18187
  const corePluginsAfterCatchAll = [emailPluginV3, magicLinkPlugin, emailReconciliationPlugin];
18188
- const wirePlugins = chunkRFBW5RRH_cjs.createPluginWirer(
18188
+ const wirePlugins = chunkQJUJNTIU_cjs.createPluginWirer(
18189
18189
  () => [...corePluginsBeforeCatchAll, ...corePluginsAfterCatchAll, ...config.plugins?.register ?? []],
18190
18190
  // The capability-gated `ctx.cap.email` resolves to the app EmailService, which
18191
18191
  // is initialized (below) just before wiring on the first request.
18192
18192
  () => ({
18193
18193
  hooks: hookSystem,
18194
18194
  env: firstRequestEnv,
18195
- providers: { email: () => chunkCTYLCWMO_cjs.getEmailService() }
18195
+ providers: { email: () => chunkI767LVN7_cjs.getEmailService() }
18196
18196
  })
18197
18197
  );
18198
18198
  let firstRequestEnv;
18199
18199
  const initEmailService = async (env = {}) => {
18200
- if (chunkCTYLCWMO_cjs.hasEmailService()) return;
18200
+ if (chunkI767LVN7_cjs.hasEmailService()) return;
18201
18201
  let provider;
18202
18202
  let defaultFrom = config.email?.from;
18203
18203
  let defaultReplyTo;
@@ -18232,14 +18232,14 @@ function createSonicJSApp(config = {}) {
18232
18232
  }
18233
18233
  }
18234
18234
  defaultFrom = defaultFrom || env.DEFAULT_FROM_EMAIL || "noreply@sonicjs.local";
18235
- chunkCTYLCWMO_cjs.setEmailService(new EmailService({ provider, defaultFrom, defaultReplyTo, db: env.DB }));
18235
+ chunkI767LVN7_cjs.setEmailService(new EmailService({ provider, defaultFrom, defaultReplyTo, db: env.DB }));
18236
18236
  };
18237
18237
  app2.use("*", async (c, next) => {
18238
18238
  c.set("appVersion", appVersion);
18239
18239
  await next();
18240
18240
  });
18241
- app2.use("*", chunkIS54FPB7_cjs.metricsMiddleware());
18242
- app2.use("*", chunkIS54FPB7_cjs.bootstrapMiddleware(config));
18241
+ app2.use("*", chunk37V3RET3_cjs.metricsMiddleware());
18242
+ app2.use("*", chunk37V3RET3_cjs.bootstrapMiddleware(config));
18243
18243
  const boot = async (env) => {
18244
18244
  if (config.plugins?.disableAll) return;
18245
18245
  firstRequestEnv = env;
@@ -18277,8 +18277,8 @@ function createSonicJSApp(config = {}) {
18277
18277
  allowHeaders: ["Content-Type", "Authorization", "X-API-Key"],
18278
18278
  credentials: true
18279
18279
  }));
18280
- app2.use("*", chunkIS54FPB7_cjs.securityHeadersMiddleware());
18281
- app2.use("*", chunkIS54FPB7_cjs.csrfProtection());
18280
+ app2.use("*", chunk37V3RET3_cjs.securityHeadersMiddleware());
18281
+ app2.use("*", chunk37V3RET3_cjs.csrfProtection());
18282
18282
  app2.use("*", async (c, next) => {
18283
18283
  try {
18284
18284
  const reqUrl = new URL(c.req.url);
@@ -18316,9 +18316,9 @@ function createSonicJSApp(config = {}) {
18316
18316
  app2.use("*", middleware);
18317
18317
  }
18318
18318
  }
18319
- app2.use("*", chunkAT4ZQGEZ_cjs.tenantMiddleware());
18320
- app2.use("/admin/*", chunkIS54FPB7_cjs.requireAuth());
18321
- app2.use("/admin/*", chunkIS54FPB7_cjs.requireRbac("portal", "access"));
18319
+ app2.use("*", chunkQCJHCSOK_cjs.tenantMiddleware());
18320
+ app2.use("/admin/*", chunk37V3RET3_cjs.requireAuth());
18321
+ app2.use("/admin/*", chunk37V3RET3_cjs.requireRbac("portal", "access"));
18322
18322
  app2.use("/admin/*", pluginMenuMiddleware());
18323
18323
  app2.use("/admin/*", menuMiddleware());
18324
18324
  const NAV_LANDING = [
@@ -18365,43 +18365,43 @@ function createSonicJSApp(config = {}) {
18365
18365
  });
18366
18366
  app2.route("/api/security-audit", apiRoutes2);
18367
18367
  app2.route("/admin/plugins/security-audit", adminRoutes3);
18368
- app2.route("/api/media", chunkCTYLCWMO_cjs.api_media_default);
18369
- app2.route("/api/system", chunkCTYLCWMO_cjs.api_system_default);
18370
- app2.route("/api/documents", chunkCTYLCWMO_cjs.apiDocumentsRoutes);
18371
- app2.route("/api", chunkCTYLCWMO_cjs.api_default);
18372
- app2.route("/admin/documents", chunkCTYLCWMO_cjs.adminDocumentsRoutes);
18373
- chunkRFBW5RRH_cjs.registerPluginRoutes(app2, [formsPlugin], { source: "core" });
18374
- app2.route("/admin/api", chunkCTYLCWMO_cjs.admin_api_default);
18375
- app2.route("/admin/collections", chunkCTYLCWMO_cjs.adminCollectionsRoutes);
18376
- app2.route("/admin/settings", chunkCTYLCWMO_cjs.adminSettingsRoutes);
18377
- app2.route("/admin/api-reference", chunkCTYLCWMO_cjs.router2);
18368
+ app2.route("/api/media", chunkI767LVN7_cjs.api_media_default);
18369
+ app2.route("/api/system", chunkI767LVN7_cjs.api_system_default);
18370
+ app2.route("/api/documents", chunkI767LVN7_cjs.apiDocumentsRoutes);
18371
+ app2.route("/api", chunkI767LVN7_cjs.api_default);
18372
+ app2.route("/admin/documents", chunkI767LVN7_cjs.adminDocumentsRoutes);
18373
+ chunkQJUJNTIU_cjs.registerPluginRoutes(app2, [formsPlugin], { source: "core" });
18374
+ app2.route("/admin/api", chunkI767LVN7_cjs.admin_api_default);
18375
+ app2.route("/admin/collections", chunkI767LVN7_cjs.adminCollectionsRoutes);
18376
+ app2.route("/admin/settings", chunkI767LVN7_cjs.adminSettingsRoutes);
18377
+ app2.route("/admin/api-reference", chunkI767LVN7_cjs.router2);
18378
18378
  app2.route("/admin/database-tools", createDatabaseToolsAdminRoutes());
18379
- app2.route("/admin/content", chunkCTYLCWMO_cjs.admin_content_default);
18380
- app2.route("/admin/media", chunkCTYLCWMO_cjs.adminMediaRoutes);
18379
+ app2.route("/admin/content", chunkI767LVN7_cjs.admin_content_default);
18380
+ app2.route("/admin/media", chunkI767LVN7_cjs.adminMediaRoutes);
18381
18381
  app2.use("/auth/*", securityAuditMiddleware());
18382
18382
  if (!config.plugins?.disableAll) {
18383
- chunkRFBW5RRH_cjs.registerPluginRoutes(app2, corePluginsBeforeCatchAll, { source: "core" });
18383
+ chunkQJUJNTIU_cjs.registerPluginRoutes(app2, corePluginsBeforeCatchAll, { source: "core" });
18384
18384
  app2.route("/admin/cache", cache_default.getRoutes());
18385
18385
  if (config.plugins?.register && config.plugins.register.length > 0) {
18386
- chunkRFBW5RRH_cjs.registerPluginRoutes(app2, config.plugins.register, { source: "user" });
18386
+ chunkQJUJNTIU_cjs.registerPluginRoutes(app2, config.plugins.register, { source: "user" });
18387
18387
  }
18388
18388
  }
18389
18389
  app2.route("/api/events", apiRoutes4);
18390
- app2.route("/admin/dashboard", chunkCTYLCWMO_cjs.router);
18391
- app2.route("/admin/plugins", chunkCTYLCWMO_cjs.adminPluginRoutes);
18392
- app2.route("/admin/logs", chunkCTYLCWMO_cjs.adminLogsRoutes);
18390
+ app2.route("/admin/dashboard", chunkI767LVN7_cjs.router);
18391
+ app2.route("/admin/plugins", chunkI767LVN7_cjs.adminPluginRoutes);
18392
+ app2.route("/admin/logs", chunkI767LVN7_cjs.adminLogsRoutes);
18393
18393
  app2.route("/admin/rbac", adminRbacRoutes);
18394
- app2.route("/admin", chunkCTYLCWMO_cjs.userRoutes);
18395
- app2.route("/auth", chunkCTYLCWMO_cjs.auth_default);
18394
+ app2.route("/admin", chunkI767LVN7_cjs.userRoutes);
18395
+ app2.route("/auth", chunkI767LVN7_cjs.auth_default);
18396
18396
  app2.on(["GET", "POST"], "/auth/*", (c) => {
18397
18397
  const reqUrl = new URL(c.req.url);
18398
18398
  const requestBaseURL = `${reqUrl.protocol}//${reqUrl.host}`;
18399
18399
  const auth = chunkGMMCCIQO_cjs.createAuth(c.env, config.auth?.extendBetterAuth, requestBaseURL);
18400
18400
  return auth.handler(c.req.raw);
18401
18401
  });
18402
- app2.route("/", chunkCTYLCWMO_cjs.test_cleanup_default);
18402
+ app2.route("/", chunkI767LVN7_cjs.test_cleanup_default);
18403
18403
  if (!config.plugins?.disableAll) {
18404
- chunkRFBW5RRH_cjs.registerPluginRoutes(app2, corePluginsAfterCatchAll, { source: "core" });
18404
+ chunkQJUJNTIU_cjs.registerPluginRoutes(app2, corePluginsAfterCatchAll, { source: "core" });
18405
18405
  }
18406
18406
  if (!config.plugins?.disableAll) {
18407
18407
  const allMountedPlugins = [
@@ -18411,10 +18411,10 @@ function createSonicJSApp(config = {}) {
18411
18411
  ...config.plugins?.register ?? []
18412
18412
  ];
18413
18413
  const userPlugins = (config.plugins?.register ?? []).filter(
18414
- (p) => !chunkAT4ZQGEZ_cjs.PLUGIN_REGISTRY[p.id]
18414
+ (p) => !chunkQCJHCSOK_cjs.PLUGIN_REGISTRY[p.id]
18415
18415
  );
18416
- chunk4WMZGHIC_cjs.setPluginMenu(userPlugins.flatMap((p) => p.menu ?? []));
18417
- chunk4WMZGHIC_cjs.setPluginDefinitions(allMountedPlugins);
18416
+ chunkBP52BFIV_cjs.setPluginMenu(userPlugins.flatMap((p) => p.menu ?? []));
18417
+ chunkBP52BFIV_cjs.setPluginDefinitions(allMountedPlugins);
18418
18418
  }
18419
18419
  app2.get("/favicon.svg", (c) => {
18420
18420
  return new Response(faviconSvg, {
@@ -21908,7 +21908,7 @@ function createRedirectApiRoutes() {
21908
21908
  });
21909
21909
  return api;
21910
21910
  }
21911
- var redirectPlugin = chunk4WMZGHIC_cjs.definePlugin({
21911
+ var redirectPlugin = chunkBP52BFIV_cjs.definePlugin({
21912
21912
  id: manifest_default3.id,
21913
21913
  version: manifest_default3.version,
21914
21914
  name: manifest_default3.name,
@@ -21926,7 +21926,7 @@ var redirectPlugin = chunk4WMZGHIC_cjs.definePlugin({
21926
21926
  async onBoot(ctx) {
21927
21927
  const db = ctx.env?.DB;
21928
21928
  if (!db) return;
21929
- const registry = new chunkIS54FPB7_cjs.DocumentTypeRegistry(db);
21929
+ const registry = new chunk37V3RET3_cjs.DocumentTypeRegistry(db);
21930
21930
  await registry.register({
21931
21931
  id: "redirect",
21932
21932
  name: "redirect",
@@ -22040,93 +22040,920 @@ var site_settings_collection_default = {
22040
22040
  function createDb(d1$1) {
22041
22041
  return d1.drizzle(d1$1, { schema: chunkYP7GW2G5_cjs.schema_exports });
22042
22042
  }
22043
+ var mcpTypeConfigSchema = zod.z.object({
22044
+ read: zod.z.boolean().default(true),
22045
+ write: zod.z.boolean().default(true)
22046
+ });
22047
+ var mcpConfigSchema = zod.z.object({
22048
+ /** Collections exposed over MCP. Omitted → every active collection. */
22049
+ expose: zod.z.array(zod.z.string()).optional(),
22050
+ /** Per-collection read/write overrides, keyed by collection name. */
22051
+ types: zod.z.record(zod.z.string(), mcpTypeConfigSchema).default({}),
22052
+ /** Field names stripped from every tool response + write schema. */
22053
+ redactFields: zod.z.array(zod.z.string()).default([]),
22054
+ /** Max documents returned by list_* tools and document resources. */
22055
+ listLimit: zod.z.number().int().positive().max(200).default(50)
22056
+ });
22057
+ function resolveMcpConfig(raw, collections) {
22058
+ const cfg = mcpConfigSchema.parse(raw ?? {});
22059
+ const exposeSet = cfg.expose ? new Set(cfg.expose) : null;
22060
+ const types = collections.filter((c) => exposeSet ? exposeSet.has(c.name) : true).map((c) => {
22061
+ const override = cfg.types[c.name];
22062
+ return {
22063
+ typeId: c.name,
22064
+ displayName: c.displayName ?? c.name,
22065
+ read: override?.read ?? true,
22066
+ write: override?.write ?? true
22067
+ };
22068
+ });
22069
+ return { types, redactFields: cfg.redactFields, listLimit: cfg.listLimit };
22070
+ }
22071
+
22072
+ // src/plugins/core-plugins/mcp-plugin/schema/field-to-jsonschema.ts
22073
+ var SYSTEM_FIELDS = /* @__PURE__ */ new Set([
22074
+ "id",
22075
+ "root_id",
22076
+ "rootId",
22077
+ "created_at",
22078
+ "createdAt",
22079
+ "updated_at",
22080
+ "updatedAt",
22081
+ "version_number",
22082
+ "versionNumber"
22083
+ ]);
22084
+ function fieldToJsonSchema(field) {
22085
+ const base = {};
22086
+ if (field.title) base.title = field.title;
22087
+ if (field.description) base.description = field.description;
22088
+ switch (field.type) {
22089
+ case "number":
22090
+ return {
22091
+ ...base,
22092
+ type: "number",
22093
+ ...field.min != null ? { minimum: field.min } : {},
22094
+ ...field.max != null ? { maximum: field.max } : {}
22095
+ };
22096
+ case "boolean":
22097
+ case "checkbox":
22098
+ return { ...base, type: "boolean" };
22099
+ case "date":
22100
+ case "datetime":
22101
+ return { ...base, type: "string", format: "date-time" };
22102
+ case "select":
22103
+ case "radio":
22104
+ return { ...base, type: "string", ...field.enum ? { enum: field.enum } : {} };
22105
+ case "multiselect":
22106
+ return {
22107
+ ...base,
22108
+ type: "array",
22109
+ items: { type: "string", ...field.enum ? { enum: field.enum } : {} }
22110
+ };
22111
+ case "array":
22112
+ return {
22113
+ ...base,
22114
+ type: "array",
22115
+ items: field.items ? fieldToJsonSchema(field.items) : {}
22116
+ };
22117
+ case "object":
22118
+ return {
22119
+ ...base,
22120
+ type: "object",
22121
+ ...field.properties ? { properties: mapProperties(field.properties) } : {}
22122
+ };
22123
+ case "json":
22124
+ return { ...base };
22125
+ // string-like: string, slug, email, url, richtext, markdown, textarea, editors,
22126
+ // reference, media, color, file, user
22127
+ default: {
22128
+ const node = { ...base, type: "string" };
22129
+ if (field.minLength != null) node.minLength = field.minLength;
22130
+ if (field.maxLength != null) node.maxLength = field.maxLength;
22131
+ if (field.pattern) node.pattern = field.pattern;
22132
+ if (field.format) node.format = field.format;
22133
+ return node;
22134
+ }
22135
+ }
22136
+ }
22137
+ function mapProperties(props) {
22138
+ const out = {};
22139
+ for (const [name, field] of Object.entries(props)) {
22140
+ out[name] = fieldToJsonSchema(field);
22141
+ }
22142
+ return out;
22143
+ }
22144
+ function collectionToJsonSchema(schema, opts = {}) {
22145
+ const properties = {};
22146
+ const required = [];
22147
+ const redact2 = new Set(opts.redactFields ?? []);
22148
+ const schemaRequired = new Set(schema.required ?? []);
22149
+ for (const [name, field] of Object.entries(schema.properties ?? {})) {
22150
+ if (redact2.has(name)) continue;
22151
+ if (opts.forWrite && SYSTEM_FIELDS.has(name)) continue;
22152
+ properties[name] = fieldToJsonSchema(field);
22153
+ if (field.required || schemaRequired.has(name)) required.push(name);
22154
+ }
22155
+ return { type: "object", properties, ...required.length ? { required } : {} };
22156
+ }
22157
+
22158
+ // src/plugins/core-plugins/mcp-plugin/tools/registry.ts
22159
+ var PHASE_FLAGS = { includeWrite: true, includeSearch: false };
22160
+ var EMPTY_OBJECT_SCHEMA = { type: "object", properties: {} };
22161
+ function buildToolRegistry(cfg, collections, opts = {}) {
22162
+ const tools = [];
22163
+ tools.push({
22164
+ name: "list_collections",
22165
+ description: "List every content collection exposed over MCP, with its read/write access.",
22166
+ inputSchema: EMPTY_OBJECT_SCHEMA,
22167
+ op: "list_collections"
22168
+ });
22169
+ if (opts.includeSearch) {
22170
+ tools.push({
22171
+ name: "search_content",
22172
+ description: "Search content across exposed collections by title or slug.",
22173
+ inputSchema: {
22174
+ type: "object",
22175
+ properties: { query: { type: "string", description: "Text matched against document title and slug." } },
22176
+ required: ["query"]
22177
+ },
22178
+ op: "search_content"
22179
+ });
22180
+ }
22181
+ for (const t of cfg.types) {
22182
+ const col = collections.get(t.typeId);
22183
+ const writeSchema = col ? collectionToJsonSchema(col.schema, { forWrite: true, redactFields: cfg.redactFields }) : EMPTY_OBJECT_SCHEMA;
22184
+ if (t.read) {
22185
+ tools.push({
22186
+ name: `list_${t.typeId}`,
22187
+ description: `List ${t.displayName} documents.`,
22188
+ inputSchema: {
22189
+ type: "object",
22190
+ properties: {
22191
+ status: {
22192
+ type: "string",
22193
+ enum: ["published", "draft"],
22194
+ description: "Lifecycle to list. Defaults to published."
22195
+ },
22196
+ limit: { type: "number", description: `Max documents to return (capped at ${cfg.listLimit}).` }
22197
+ }
22198
+ },
22199
+ op: "list",
22200
+ typeId: t.typeId
22201
+ });
22202
+ tools.push({
22203
+ name: `get_${t.typeId}`,
22204
+ description: `Get one ${t.displayName} document by id or slug.`,
22205
+ inputSchema: {
22206
+ type: "object",
22207
+ properties: {
22208
+ id: { type: "string", description: "Document id or root id." },
22209
+ slug: { type: "string", description: "Document slug (alternative to id)." }
22210
+ }
22211
+ },
22212
+ op: "get",
22213
+ typeId: t.typeId
22214
+ });
22215
+ }
22216
+ if (opts.includeWrite && t.write) {
22217
+ tools.push({
22218
+ name: `create_${t.typeId}`,
22219
+ description: `Create a ${t.displayName} document.`,
22220
+ inputSchema: {
22221
+ type: "object",
22222
+ properties: {
22223
+ title: { type: "string" },
22224
+ slug: { type: "string" },
22225
+ data: writeSchema,
22226
+ publish: { type: "boolean", description: "Publish immediately. Defaults to false (draft)." }
22227
+ }
22228
+ },
22229
+ op: "create",
22230
+ typeId: t.typeId
22231
+ });
22232
+ tools.push({
22233
+ name: `update_${t.typeId}`,
22234
+ description: `Update a ${t.displayName} document (saves a new draft).`,
22235
+ inputSchema: {
22236
+ type: "object",
22237
+ properties: {
22238
+ id: { type: "string", description: "Root id of the document to update." },
22239
+ title: { type: "string" },
22240
+ slug: { type: "string" },
22241
+ data: writeSchema
22242
+ },
22243
+ required: ["id"]
22244
+ },
22245
+ op: "update",
22246
+ typeId: t.typeId
22247
+ });
22248
+ tools.push({
22249
+ name: `publish_${t.typeId}`,
22250
+ description: `Publish a ${t.displayName} document.`,
22251
+ inputSchema: {
22252
+ type: "object",
22253
+ properties: { id: { type: "string", description: "Root id of the document to publish." } },
22254
+ required: ["id"]
22255
+ },
22256
+ op: "publish",
22257
+ typeId: t.typeId
22258
+ });
22259
+ tools.push({
22260
+ name: `delete_${t.typeId}`,
22261
+ description: `Delete a ${t.displayName} document.`,
22262
+ inputSchema: {
22263
+ type: "object",
22264
+ properties: { id: { type: "string", description: "Root id of the document to delete." } },
22265
+ required: ["id"]
22266
+ },
22267
+ op: "delete",
22268
+ typeId: t.typeId
22269
+ });
22270
+ }
22271
+ }
22272
+ return tools;
22273
+ }
22274
+
22275
+ // src/plugins/core-plugins/mcp-plugin/jsonrpc.ts
22276
+ var JSON_RPC = {
22277
+ PARSE_ERROR: -32700,
22278
+ INVALID_REQUEST: -32600,
22279
+ METHOD_NOT_FOUND: -32601,
22280
+ INVALID_PARAMS: -32602,
22281
+ INTERNAL_ERROR: -32603,
22282
+ /** Custom: no valid API key on the request. */
22283
+ UNAUTHORIZED: -32001
22284
+ };
22285
+ var McpToolError = class extends Error {
22286
+ constructor(message) {
22287
+ super(message);
22288
+ this.name = "McpToolError";
22289
+ }
22290
+ };
22291
+ function rpcResult(id, result) {
22292
+ return { jsonrpc: "2.0", id: id ?? null, result };
22293
+ }
22294
+ function rpcError(id, code, message, data) {
22295
+ return { jsonrpc: "2.0", id: id ?? null, error: { code, message, ...{} } };
22296
+ }
22297
+ function parseJsonRpc(body) {
22298
+ if (!body || typeof body !== "object" || Array.isArray(body)) {
22299
+ return { error: { code: JSON_RPC.INVALID_REQUEST, message: "Request must be a JSON object" } };
22300
+ }
22301
+ const b = body;
22302
+ if (b.jsonrpc !== "2.0") {
22303
+ return { error: { code: JSON_RPC.INVALID_REQUEST, message: 'jsonrpc must be "2.0"' } };
22304
+ }
22305
+ if (typeof b.method !== "string" || b.method.length === 0) {
22306
+ return { error: { code: JSON_RPC.INVALID_REQUEST, message: "method must be a non-empty string" } };
22307
+ }
22308
+ const id = b.id === void 0 ? null : b.id;
22309
+ const params = b.params && typeof b.params === "object" && !Array.isArray(b.params) ? b.params : {};
22310
+ return { jsonrpc: "2.0", id, method: b.method, params };
22311
+ }
22312
+
22313
+ // src/plugins/core-plugins/mcp-plugin/tools/documents.ts
22314
+ function redact(data, fields) {
22315
+ if (!fields.length) return data;
22316
+ const out = { ...data };
22317
+ for (const f of fields) delete out[f];
22318
+ return out;
22319
+ }
22320
+ function shapeDocument(doc, redactFields) {
22321
+ return {
22322
+ id: doc.id,
22323
+ rootId: doc.rootId,
22324
+ typeId: doc.typeId,
22325
+ title: doc.title,
22326
+ slug: doc.slug,
22327
+ status: doc.status,
22328
+ isPublished: doc.isPublished,
22329
+ publishedAt: doc.publishedAt,
22330
+ updatedAt: doc.updatedAt,
22331
+ data: redact(doc.data, redactFields)
22332
+ };
22333
+ }
22334
+ async function resolveType(ctx, typeId) {
22335
+ const docType = await new chunk37V3RET3_cjs.DocumentTypeRegistry(ctx.db).findById(typeId);
22336
+ if (!docType || !docType.isActive) throw new McpToolError(`Unknown document type: ${typeId}`);
22337
+ const effTenant = chunkI767LVN7_cjs.effectiveTenantForType(ctx.tenantId, docType.settings);
22338
+ const repo = new chunkI767LVN7_cjs.DocumentRepository(ctx.db, effTenant);
22339
+ return { docType, repo };
22340
+ }
22341
+ async function execList(ctx, typeId, args) {
22342
+ const { docType, repo } = await resolveType(ctx, typeId);
22343
+ const status = args.status === "draft" ? "draft" : "published";
22344
+ const limit = Math.min(Math.max(1, args.limit ?? ctx.listLimit), ctx.listLimit);
22345
+ const now = Math.floor(Date.now() / 1e3);
22346
+ const docs = await repo.list({
22347
+ typeId,
22348
+ status,
22349
+ timeWindow: status === "published",
22350
+ now,
22351
+ limit
22352
+ });
22353
+ const allowed = await Promise.all(
22354
+ docs.map((d) => repo.isAllowed(ctx.principalSet, d.rootId, "read", docType.settings))
22355
+ );
22356
+ return docs.filter((_, i) => allowed[i]).map((d) => shapeDocument(d, ctx.redactFields));
22357
+ }
22358
+ async function execGet(ctx, typeId, args) {
22359
+ const { docType, repo } = await resolveType(ctx, typeId);
22360
+ let doc = null;
22361
+ if (args.id) {
22362
+ doc = await repo.getById(args.id) ?? await repo.getPublished(args.id) ?? await repo.getCurrentDraft(args.id);
22363
+ } else if (args.slug) {
22364
+ doc = await repo.getBySlug(typeId, args.slug);
22365
+ } else {
22366
+ throw new McpToolError('get requires an "id" or "slug" argument');
22367
+ }
22368
+ if (!doc || doc.typeId !== typeId) throw new McpToolError("Document not found");
22369
+ const ok = await repo.isAllowed(ctx.principalSet, doc.rootId, "read", docType.settings);
22370
+ if (!ok) throw new McpToolError("Document not found");
22371
+ return shapeDocument(doc, ctx.redactFields);
22372
+ }
22373
+
22374
+ // src/plugins/core-plugins/mcp-plugin/tools/mutations.ts
22375
+ async function resolveWriteScope(ctx, typeId) {
22376
+ const docType = await new chunk37V3RET3_cjs.DocumentTypeRegistry(ctx.db).findById(typeId);
22377
+ if (!docType || !docType.isActive) throw new McpToolError(`Unknown document type: ${typeId}`);
22378
+ const effTenant = chunkI767LVN7_cjs.effectiveTenantForType(ctx.tenantId, docType.settings);
22379
+ const repo = new chunkI767LVN7_cjs.DocumentRepository(ctx.db, effTenant);
22380
+ const svc = new chunkLTZ5WYOK_cjs.DocumentsService(ctx.db, {
22381
+ queryableFields: docType.queryableFields ?? [],
22382
+ typeSchemaVersion: docType.schemaVersion,
22383
+ maxVersionsPerRoot: docType.settings?.maxVersionsPerRoot,
22384
+ tenantId: effTenant,
22385
+ versioning: docType.settings?.versioning ?? false
22386
+ });
22387
+ return { docType, effTenant, repo, svc };
22388
+ }
22389
+ async function assertAllowed(scope, ctx, rootId, permission) {
22390
+ const ok = await scope.repo.isAllowed(ctx.principalSet, rootId, permission, scope.docType.settings ?? {});
22391
+ if (!ok) throw new McpToolError(`Permission denied: cannot ${permission} ${scope.docType.id}`);
22392
+ }
22393
+ function applyUserFieldDefaults(data, typeId, userId) {
22394
+ const col = chunkQCJHCSOK_cjs.getCollectionRegistry().getByName(typeId);
22395
+ if (!col?.schema?.properties) return data;
22396
+ const props = col.schema.properties;
22397
+ const patched = { ...data };
22398
+ for (const [name, field] of Object.entries(props)) {
22399
+ if (field.type === "user" && !patched[name]) patched[name] = userId;
22400
+ }
22401
+ return patched;
22402
+ }
22403
+ async function execCreate(ctx, typeId, args) {
22404
+ const scope = await resolveWriteScope(ctx, typeId);
22405
+ await assertAllowed(scope, ctx, "", "create");
22406
+ const data = redact(applyUserFieldDefaults(args.data ?? {}, typeId, ctx.userId), ctx.redactFields);
22407
+ const input = chunkI767LVN7_cjs.createDocumentSchema.parse({
22408
+ typeId,
22409
+ tenantId: scope.effTenant,
22410
+ title: args.title ?? null,
22411
+ slug: args.slug ?? null,
22412
+ data,
22413
+ ownerId: ctx.userId,
22414
+ publishOnCreate: Boolean(args.publish)
22415
+ });
22416
+ const doc = await scope.svc.create(input, ctx.userId);
22417
+ return shapeDocument(doc, ctx.redactFields);
22418
+ }
22419
+ async function execUpdate(ctx, typeId, args) {
22420
+ if (!args.id) throw new McpToolError('update requires an "id" (root id)');
22421
+ const scope = await resolveWriteScope(ctx, typeId);
22422
+ const current = await scope.repo.getCurrentDraft(args.id);
22423
+ if (!current || current.typeId !== typeId) throw new McpToolError("Document not found");
22424
+ await assertAllowed(scope, ctx, args.id, "update");
22425
+ const patch = chunkI767LVN7_cjs.updateDocumentSchema.parse({
22426
+ ...args.title !== void 0 ? { title: args.title } : {},
22427
+ ...args.slug !== void 0 ? { slug: args.slug } : {},
22428
+ ...args.data !== void 0 ? { data: redact(args.data, ctx.redactFields) } : {}
22429
+ });
22430
+ const doc = await scope.svc.saveDraft(args.id, patch, ctx.userId);
22431
+ return shapeDocument(doc, ctx.redactFields);
22432
+ }
22433
+ async function execPublish(ctx, typeId, args) {
22434
+ if (!args.id) throw new McpToolError('publish requires an "id" (root id)');
22435
+ const scope = await resolveWriteScope(ctx, typeId);
22436
+ const current = await scope.repo.getCurrentDraft(args.id);
22437
+ if (!current || current.typeId !== typeId) throw new McpToolError("Document not found");
22438
+ await assertAllowed(scope, ctx, args.id, "publish");
22439
+ const doc = await scope.svc.publish(current.id, ctx.userId);
22440
+ return shapeDocument(doc, ctx.redactFields);
22441
+ }
22442
+ async function execDelete(ctx, typeId, args) {
22443
+ if (!args.id) throw new McpToolError('delete requires an "id" (root id)');
22444
+ const scope = await resolveWriteScope(ctx, typeId);
22445
+ const current = await scope.repo.getCurrentDraft(args.id) ?? await scope.repo.getPublished(args.id);
22446
+ if (!current || current.typeId !== typeId) throw new McpToolError("Document not found");
22447
+ await assertAllowed(scope, ctx, args.id, "delete");
22448
+ if (scope.docType.settings?.pii) {
22449
+ await scope.svc.erase(args.id, scope.effTenant);
22450
+ return { rootId: args.id, deleted: true, erased: true };
22451
+ }
22452
+ const ids = /* @__PURE__ */ new Set();
22453
+ ids.add(current.id);
22454
+ if (current.isCurrentDraft) {
22455
+ const published = await scope.repo.getPublished(args.id);
22456
+ if (published) ids.add(published.id);
22457
+ } else {
22458
+ const draft = await scope.repo.getCurrentDraft(args.id);
22459
+ if (draft) ids.add(draft.id);
22460
+ }
22461
+ for (const id of ids) await scope.svc.softDelete(id);
22462
+ return { rootId: args.id, deleted: true, erased: false };
22463
+ }
22464
+
22465
+ // src/plugins/core-plugins/mcp-plugin/tools/static.ts
22466
+ function execListCollections(types) {
22467
+ return types.map((t) => ({ typeId: t.typeId, displayName: t.displayName, read: t.read, write: t.write }));
22468
+ }
22469
+
22470
+ // src/plugins/core-plugins/mcp-plugin/resources/schemas.ts
22471
+ function buildResourceList(cfg) {
22472
+ const out = [
22473
+ { uri: "sonicjs://collections", name: "All collections", mimeType: "application/json" }
22474
+ ];
22475
+ for (const t of cfg.types) {
22476
+ out.push({
22477
+ uri: `sonicjs://collections/${t.typeId}/schema`,
22478
+ name: `${t.displayName} schema`,
22479
+ mimeType: "application/json"
22480
+ });
22481
+ }
22482
+ return out;
22483
+ }
22484
+ var SCHEMA_URI = /^sonicjs:\/\/collections\/([^/]+)\/schema$/;
22485
+ function readResource(uri, cfg, collections) {
22486
+ if (uri === "sonicjs://collections") {
22487
+ const list = cfg.types.map((t) => ({
22488
+ typeId: t.typeId,
22489
+ displayName: t.displayName,
22490
+ read: t.read,
22491
+ write: t.write
22492
+ }));
22493
+ return { uri, mimeType: "application/json", text: JSON.stringify(list, null, 2) };
22494
+ }
22495
+ const m = uri.match(SCHEMA_URI);
22496
+ if (m) {
22497
+ const typeId = m[1];
22498
+ const exposed = cfg.types.find((t) => t.typeId === typeId);
22499
+ const col = collections.get(typeId);
22500
+ if (!exposed || !col) throw new McpToolError(`Unknown collection: ${typeId}`);
22501
+ const schema = collectionToJsonSchema(col.schema, { redactFields: cfg.redactFields });
22502
+ return { uri, mimeType: "application/json", text: JSON.stringify(schema, null, 2) };
22503
+ }
22504
+ throw new McpToolError(`Unknown resource URI: ${uri}`);
22505
+ }
22506
+
22507
+ // src/plugins/core-plugins/mcp-plugin/routes/mcp.ts
22508
+ var SERVER_INFO = { name: "sonicjs-mcp", version: "1.0.0" };
22509
+ var PROTOCOL_VERSION = "2024-11-05";
22510
+ function createMcpRoutes(options = {}) {
22511
+ const app2 = new hono.Hono();
22512
+ app2.post("/", async (c) => {
22513
+ let body;
22514
+ try {
22515
+ body = await c.req.json();
22516
+ } catch {
22517
+ return c.json(rpcError(null, JSON_RPC.PARSE_ERROR, "Invalid JSON"));
22518
+ }
22519
+ const parsed = parseJsonRpc(body);
22520
+ if ("error" in parsed) {
22521
+ const id2 = body && typeof body === "object" ? body.id ?? null : null;
22522
+ return c.json(rpcError(id2, parsed.error.code, parsed.error.message));
22523
+ }
22524
+ const { id, method, params } = parsed;
22525
+ const user = c.get("user");
22526
+ if (!user) {
22527
+ return c.json(
22528
+ rpcError(id, JSON_RPC.UNAUTHORIZED, "Unauthorized: provide a valid API key via Authorization: Bearer sk_...")
22529
+ );
22530
+ }
22531
+ const { tenantId, principalSet, userId } = chunkI767LVN7_cjs.getDocumentRequestContext(c);
22532
+ const registry = chunkQCJHCSOK_cjs.getCollectionRegistry();
22533
+ const active = registry.listActive();
22534
+ const collections = new Map(active.map((col) => [col.name, col]));
22535
+ const cfg = resolveMcpConfig(options, active);
22536
+ const tools = buildToolRegistry(cfg, collections, PHASE_FLAGS);
22537
+ try {
22538
+ switch (method) {
22539
+ case "initialize":
22540
+ return c.json(
22541
+ rpcResult(id, {
22542
+ protocolVersion: PROTOCOL_VERSION,
22543
+ serverInfo: SERVER_INFO,
22544
+ capabilities: { tools: {}, resources: {} }
22545
+ })
22546
+ );
22547
+ case "tools/list":
22548
+ return c.json(
22549
+ rpcResult(id, {
22550
+ tools: tools.map((t) => ({ name: t.name, description: t.description, inputSchema: t.inputSchema }))
22551
+ })
22552
+ );
22553
+ case "tools/call": {
22554
+ const name = typeof params.name === "string" ? params.name : "";
22555
+ const args = params.arguments && typeof params.arguments === "object" ? params.arguments : {};
22556
+ const tool = tools.find((t) => t.name === name);
22557
+ if (!tool) return c.json(rpcError(id, JSON_RPC.METHOD_NOT_FOUND, `Unknown tool: ${name}`));
22558
+ const readCtx = {
22559
+ db: c.env.DB,
22560
+ tenantId,
22561
+ principalSet,
22562
+ listLimit: cfg.listLimit,
22563
+ redactFields: cfg.redactFields
22564
+ };
22565
+ const writeCtx = {
22566
+ db: c.env.DB,
22567
+ tenantId,
22568
+ principalSet,
22569
+ userId: userId ?? "",
22570
+ redactFields: cfg.redactFields
22571
+ };
22572
+ try {
22573
+ let result;
22574
+ switch (tool.op) {
22575
+ case "list_collections":
22576
+ result = execListCollections(cfg.types);
22577
+ break;
22578
+ case "list":
22579
+ result = await execList(readCtx, tool.typeId, args);
22580
+ break;
22581
+ case "get":
22582
+ result = await execGet(readCtx, tool.typeId, args);
22583
+ break;
22584
+ case "create":
22585
+ result = await execCreate(writeCtx, tool.typeId, args);
22586
+ break;
22587
+ case "update":
22588
+ result = await execUpdate(writeCtx, tool.typeId, args);
22589
+ break;
22590
+ case "publish":
22591
+ result = await execPublish(writeCtx, tool.typeId, args);
22592
+ break;
22593
+ case "delete":
22594
+ result = await execDelete(writeCtx, tool.typeId, args);
22595
+ break;
22596
+ default:
22597
+ return c.json(rpcError(id, JSON_RPC.METHOD_NOT_FOUND, `Tool not available: ${name}`));
22598
+ }
22599
+ return c.json(rpcResult(id, { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }));
22600
+ } catch (e) {
22601
+ if (e instanceof McpToolError) {
22602
+ return c.json(rpcResult(id, { content: [{ type: "text", text: e.message }], isError: true }));
22603
+ }
22604
+ throw e;
22605
+ }
22606
+ }
22607
+ case "resources/list":
22608
+ return c.json(rpcResult(id, { resources: buildResourceList(cfg) }));
22609
+ case "resources/read": {
22610
+ const uri = typeof params.uri === "string" ? params.uri : "";
22611
+ if (!uri) return c.json(rpcError(id, JSON_RPC.INVALID_PARAMS, 'resources/read requires a "uri" param'));
22612
+ try {
22613
+ const contents = readResource(uri, cfg, collections);
22614
+ return c.json(rpcResult(id, { contents: [contents] }));
22615
+ } catch (e) {
22616
+ if (e instanceof McpToolError) return c.json(rpcError(id, JSON_RPC.INVALID_PARAMS, e.message));
22617
+ throw e;
22618
+ }
22619
+ }
22620
+ default:
22621
+ return c.json(rpcError(id, JSON_RPC.METHOD_NOT_FOUND, `Method not found: ${method}`));
22622
+ }
22623
+ } catch (e) {
22624
+ console.error("[mcp] handler error:", e);
22625
+ return c.json(rpcError(id, JSON_RPC.INTERNAL_ERROR, "Internal error"));
22626
+ }
22627
+ });
22628
+ return app2;
22629
+ }
22630
+
22631
+ // src/plugins/core-plugins/mcp-plugin/admin/templates.ts
22632
+ chunkUYJQDDEE_cjs.init_admin_layout_catalyst_template();
22633
+ function accessBadge(ok) {
22634
+ 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>`;
22635
+ }
22636
+ function toolNamesForType(typeId, tools) {
22637
+ 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>`);
22638
+ return names.length ? names.join('<span class="text-zinc-300 dark:text-zinc-600 mx-1">,</span>') : "\u2014";
22639
+ }
22640
+ function buildClaudeJson(endpointUrl) {
22641
+ return JSON.stringify(
22642
+ {
22643
+ mcpServers: {
22644
+ sonicjs: {
22645
+ type: "http",
22646
+ url: endpointUrl,
22647
+ headers: { Authorization: "Bearer sk_YOUR_API_KEY" }
22648
+ }
22649
+ }
22650
+ },
22651
+ null,
22652
+ 2
22653
+ );
22654
+ }
22655
+ function buildCursorJson(endpointUrl) {
22656
+ return JSON.stringify(
22657
+ {
22658
+ mcpServers: {
22659
+ sonicjs: {
22660
+ url: endpointUrl,
22661
+ headers: { Authorization: "Bearer sk_YOUR_API_KEY" }
22662
+ }
22663
+ }
22664
+ },
22665
+ null,
22666
+ 2
22667
+ );
22668
+ }
22669
+ function renderMcpDashboardPage(data) {
22670
+ const { endpointUrl, types, tools, user, version, dynamicMenuItems } = data;
22671
+ const safeEndpoint = chunkMNWKYY5E_cjs.escapeHtml(endpointUrl);
22672
+ const typeCount = types.length;
22673
+ const toolCount = tools.length;
22674
+ const typeRows = types.length ? types.map(
22675
+ (t) => `
22676
+ <tr class="border-t border-zinc-950/5 dark:border-white/10">
22677
+ <td class="py-3 pr-4 text-sm font-mono text-zinc-950 dark:text-white">${chunkMNWKYY5E_cjs.escapeHtml(t.typeId)}</td>
22678
+ <td class="py-3 pr-4 text-sm text-zinc-500 dark:text-zinc-400">${chunkMNWKYY5E_cjs.escapeHtml(t.displayName)}</td>
22679
+ <td class="py-3 pr-4">${accessBadge(t.read)}</td>
22680
+ <td class="py-3 pr-4">${accessBadge(t.write)}</td>
22681
+ <td class="py-3 text-sm">${toolNamesForType(t.typeId, tools)}</td>
22682
+ </tr>`
22683
+ ).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>`;
22684
+ const claudeJson = chunkMNWKYY5E_cjs.escapeHtml(buildClaudeJson(endpointUrl));
22685
+ const cursorJson = chunkMNWKYY5E_cjs.escapeHtml(buildCursorJson(endpointUrl));
22686
+ const content2 = `
22687
+ <div class="space-y-8">
22688
+
22689
+ <!-- Header -->
22690
+ <div class="sm:flex sm:items-center sm:justify-between">
22691
+ <div class="sm:flex-auto">
22692
+ <h1 class="text-2xl/8 font-semibold text-zinc-950 dark:text-white sm:text-xl/8">MCP Server</h1>
22693
+ <p class="mt-2 text-sm/6 text-zinc-500 dark:text-zinc-400">
22694
+ Model Context Protocol endpoint for AI agents (Claude Code, Cursor, VS Code). Requests are authenticated with API keys.
22695
+ </p>
22696
+ </div>
22697
+ <div class="mt-4 sm:mt-0 sm:ml-16">
22698
+ <a href="/admin/plugins/api-keys"
22699
+ 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">
22700
+ Mint API Key
22701
+ </a>
22702
+ </div>
22703
+ </div>
22704
+
22705
+ <!-- Status -->
22706
+ <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">
22707
+ <h2 class="text-sm font-semibold text-zinc-950 dark:text-white mb-4">Endpoint</h2>
22708
+ <div class="flex items-center gap-3">
22709
+ <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>
22710
+ <button type="button" onclick="copyEndpoint()"
22711
+ 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">
22712
+ Copy
22713
+ </button>
22714
+ </div>
22715
+ <div class="mt-4 flex flex-wrap gap-4 text-sm text-zinc-500 dark:text-zinc-400">
22716
+ <span>
22717
+ <span class="font-semibold text-zinc-950 dark:text-white">${typeCount}</span>
22718
+ collection${typeCount === 1 ? "" : "s"} exposed
22719
+ </span>
22720
+ <span class="text-zinc-300 dark:text-zinc-600">&middot;</span>
22721
+ <span>
22722
+ <span class="font-semibold text-zinc-950 dark:text-white">${toolCount}</span>
22723
+ tool${toolCount === 1 ? "" : "s"} available
22724
+ </span>
22725
+ <span class="text-zinc-300 dark:text-zinc-600">&middot;</span>
22726
+ <span>Auth via <a href="/admin/plugins/api-keys" class="text-cyan-600 dark:text-cyan-400 hover:underline">API Keys</a></span>
22727
+ </div>
22728
+ </div>
22729
+
22730
+ <!-- Exposed collections table -->
22731
+ <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">
22732
+ <h2 class="text-sm font-semibold text-zinc-950 dark:text-white mb-4">Exposed collections</h2>
22733
+ <table class="w-full text-left">
22734
+ <thead>
22735
+ <tr class="text-xs font-semibold uppercase tracking-wide text-zinc-500 dark:text-zinc-400">
22736
+ <th class="pb-2 pr-4">ID</th>
22737
+ <th class="pb-2 pr-4">Display name</th>
22738
+ <th class="pb-2 pr-4">Read</th>
22739
+ <th class="pb-2 pr-4">Write</th>
22740
+ <th class="pb-2">Tools</th>
22741
+ </tr>
22742
+ </thead>
22743
+ <tbody>${typeRows}</tbody>
22744
+ </table>
22745
+ </div>
22746
+
22747
+ <!-- Integration guide -->
22748
+ <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">
22749
+ <div>
22750
+ <h2 class="text-sm font-semibold text-zinc-950 dark:text-white mb-1">Integration guide</h2>
22751
+ <p class="text-sm text-zinc-500 dark:text-zinc-400">
22752
+ <a href="/admin/plugins/api-keys" class="text-cyan-600 dark:text-cyan-400 hover:underline">Mint an API key</a>,
22753
+ then paste one of the configs below into your MCP client.
22754
+ Replace <code class="font-mono text-xs">sk_YOUR_API_KEY</code> with the key.
22755
+ </p>
22756
+ </div>
22757
+
22758
+ <!-- Claude Code -->
22759
+ <div>
22760
+ <div class="flex items-center justify-between mb-2">
22761
+ <h3 class="text-sm font-medium text-zinc-700 dark:text-zinc-300">
22762
+ Claude Code &mdash; <code class="font-mono text-xs">~/.claude/mcp.json</code>
22763
+ </h3>
22764
+ <button type="button" onclick="copyConfig('claude-config')"
22765
+ class="text-xs text-zinc-500 dark:text-zinc-400 hover:text-zinc-700 dark:hover:text-zinc-200 transition-colors">
22766
+ Copy
22767
+ </button>
22768
+ </div>
22769
+ <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>
22770
+ </div>
22771
+
22772
+ <!-- Cursor -->
22773
+ <div>
22774
+ <div class="flex items-center justify-between mb-2">
22775
+ <h3 class="text-sm font-medium text-zinc-700 dark:text-zinc-300">
22776
+ Cursor &mdash; <code class="font-mono text-xs">~/.cursor/mcp.json</code>
22777
+ </h3>
22778
+ <button type="button" onclick="copyConfig('cursor-config')"
22779
+ class="text-xs text-zinc-500 dark:text-zinc-400 hover:text-zinc-700 dark:hover:text-zinc-200 transition-colors">
22780
+ Copy
22781
+ </button>
22782
+ </div>
22783
+ <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>
22784
+ </div>
22785
+
22786
+ <p class="text-xs text-zinc-400 dark:text-zinc-500">
22787
+ MCP v1 = HTTP POST only (no SSE stream). Clients that require stdio transport can use
22788
+ <code class="font-mono">npx mcp-remote ${safeEndpoint}</code> as a local bridge.
22789
+ </p>
22790
+ </div>
22791
+
22792
+ </div>
22793
+
22794
+ <script>
22795
+ function copyEndpoint() {
22796
+ navigator.clipboard.writeText(document.getElementById('endpoint-url').textContent.trim()).then(() => {
22797
+ window.showNotification && window.showNotification('Endpoint URL copied', 'success')
22798
+ })
22799
+ }
22800
+ function copyConfig(id) {
22801
+ navigator.clipboard.writeText(document.getElementById(id).textContent).then(() => {
22802
+ window.showNotification && window.showNotification('Config copied', 'success')
22803
+ })
22804
+ }
22805
+ </script>`;
22806
+ const layoutData = {
22807
+ title: "MCP Server",
22808
+ pageTitle: "MCP Server",
22809
+ currentPath: "/admin/mcp",
22810
+ user,
22811
+ content: content2,
22812
+ version,
22813
+ dynamicMenuItems
22814
+ };
22815
+ return chunkUYJQDDEE_cjs.renderAdminLayoutCatalyst(layoutData);
22816
+ }
22817
+
22818
+ // src/plugins/core-plugins/mcp-plugin/admin/routes.ts
22819
+ function createMcpAdminRoutes(options = {}) {
22820
+ const routes2 = new hono.Hono();
22821
+ routes2.use("*", chunk37V3RET3_cjs.requireAuth());
22822
+ routes2.use("*", async (c, next) => {
22823
+ const user = c.get("user");
22824
+ if (user?.role !== "admin") return c.json({ error: "Access denied" }, 403);
22825
+ return next();
22826
+ });
22827
+ routes2.get("/", async (c) => {
22828
+ const url = new URL(c.req.url);
22829
+ const endpointUrl = `${url.protocol}//${url.host}/mcp`;
22830
+ const registry = chunkQCJHCSOK_cjs.getCollectionRegistry();
22831
+ const active = registry.listActive();
22832
+ const collections = new Map(active.map((col) => [col.name, col]));
22833
+ const cfg = resolveMcpConfig(options, active);
22834
+ const tools = buildToolRegistry(cfg, collections, PHASE_FLAGS);
22835
+ const user = c.get("user");
22836
+ return c.html(
22837
+ renderMcpDashboardPage({
22838
+ endpointUrl,
22839
+ types: cfg.types,
22840
+ tools,
22841
+ user: { name: user.email, email: user.email, role: user.role },
22842
+ version: c.get("appVersion"),
22843
+ dynamicMenuItems: c.get("pluginMenuItems")
22844
+ })
22845
+ );
22846
+ });
22847
+ return routes2;
22848
+ }
22849
+
22850
+ // src/plugins/core-plugins/mcp-plugin/index.ts
22851
+ 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>`;
22852
+ function mcpPlugin(options = {}) {
22853
+ return chunkBP52BFIV_cjs.definePlugin({
22854
+ id: "mcp",
22855
+ version: "1.0.0",
22856
+ name: "MCP Server",
22857
+ description: "Exposes SonicJS content as Model Context Protocol tools for AI agents (Claude Code, Cursor, \u2026).",
22858
+ sonicjsVersionRange: "^3.0.0",
22859
+ author: { name: "SonicJS Team" },
22860
+ register(app2) {
22861
+ app2.route("/mcp", createMcpRoutes(options));
22862
+ app2.route("/admin/mcp", createMcpAdminRoutes(options));
22863
+ },
22864
+ menu: [{ label: "MCP Server", path: "/admin/mcp", icon: MCP_ICON, order: 87 }]
22865
+ });
22866
+ }
22867
+ function createMcpPlugin(options) {
22868
+ return mcpPlugin(options);
22869
+ }
22043
22870
 
22044
22871
  // src/index.ts
22045
- var VERSION = chunkC3ZQP5NW_cjs.package_default.version;
22872
+ var VERSION = chunkKKNEYIZJ_cjs.package_default.version;
22046
22873
 
22047
22874
  Object.defineProperty(exports, "DocumentRepository", {
22048
22875
  enumerable: true,
22049
- get: function () { return chunkCTYLCWMO_cjs.DocumentRepository; }
22876
+ get: function () { return chunkI767LVN7_cjs.DocumentRepository; }
22050
22877
  });
22051
22878
  Object.defineProperty(exports, "ROUTES_INFO", {
22052
22879
  enumerable: true,
22053
- get: function () { return chunkCTYLCWMO_cjs.ROUTES_INFO; }
22880
+ get: function () { return chunkI767LVN7_cjs.ROUTES_INFO; }
22054
22881
  });
22055
22882
  Object.defineProperty(exports, "adminApiRoutes", {
22056
22883
  enumerable: true,
22057
- get: function () { return chunkCTYLCWMO_cjs.admin_api_default; }
22884
+ get: function () { return chunkI767LVN7_cjs.admin_api_default; }
22058
22885
  });
22059
22886
  Object.defineProperty(exports, "adminCheckboxRoutes", {
22060
22887
  enumerable: true,
22061
- get: function () { return chunkCTYLCWMO_cjs.adminCheckboxRoutes; }
22888
+ get: function () { return chunkI767LVN7_cjs.adminCheckboxRoutes; }
22062
22889
  });
22063
22890
  Object.defineProperty(exports, "adminCollectionsRoutes", {
22064
22891
  enumerable: true,
22065
- get: function () { return chunkCTYLCWMO_cjs.adminCollectionsRoutes; }
22892
+ get: function () { return chunkI767LVN7_cjs.adminCollectionsRoutes; }
22066
22893
  });
22067
22894
  Object.defineProperty(exports, "adminContentRoutes", {
22068
22895
  enumerable: true,
22069
- get: function () { return chunkCTYLCWMO_cjs.admin_content_default; }
22896
+ get: function () { return chunkI767LVN7_cjs.admin_content_default; }
22070
22897
  });
22071
22898
  Object.defineProperty(exports, "adminDashboardRoutes", {
22072
22899
  enumerable: true,
22073
- get: function () { return chunkCTYLCWMO_cjs.router; }
22900
+ get: function () { return chunkI767LVN7_cjs.router; }
22074
22901
  });
22075
22902
  Object.defineProperty(exports, "adminLogsRoutes", {
22076
22903
  enumerable: true,
22077
- get: function () { return chunkCTYLCWMO_cjs.adminLogsRoutes; }
22904
+ get: function () { return chunkI767LVN7_cjs.adminLogsRoutes; }
22078
22905
  });
22079
22906
  Object.defineProperty(exports, "adminMediaRoutes", {
22080
22907
  enumerable: true,
22081
- get: function () { return chunkCTYLCWMO_cjs.adminMediaRoutes; }
22908
+ get: function () { return chunkI767LVN7_cjs.adminMediaRoutes; }
22082
22909
  });
22083
22910
  Object.defineProperty(exports, "adminPluginRoutes", {
22084
22911
  enumerable: true,
22085
- get: function () { return chunkCTYLCWMO_cjs.adminPluginRoutes; }
22912
+ get: function () { return chunkI767LVN7_cjs.adminPluginRoutes; }
22086
22913
  });
22087
22914
  Object.defineProperty(exports, "adminSettingsRoutes", {
22088
22915
  enumerable: true,
22089
- get: function () { return chunkCTYLCWMO_cjs.adminSettingsRoutes; }
22916
+ get: function () { return chunkI767LVN7_cjs.adminSettingsRoutes; }
22090
22917
  });
22091
22918
  Object.defineProperty(exports, "adminUsersRoutes", {
22092
22919
  enumerable: true,
22093
- get: function () { return chunkCTYLCWMO_cjs.userRoutes; }
22920
+ get: function () { return chunkI767LVN7_cjs.userRoutes; }
22094
22921
  });
22095
22922
  Object.defineProperty(exports, "apiContentCrudRoutes", {
22096
22923
  enumerable: true,
22097
- get: function () { return chunkCTYLCWMO_cjs.api_content_crud_default; }
22924
+ get: function () { return chunkI767LVN7_cjs.api_content_crud_default; }
22098
22925
  });
22099
22926
  Object.defineProperty(exports, "apiMediaRoutes", {
22100
22927
  enumerable: true,
22101
- get: function () { return chunkCTYLCWMO_cjs.api_media_default; }
22928
+ get: function () { return chunkI767LVN7_cjs.api_media_default; }
22102
22929
  });
22103
22930
  Object.defineProperty(exports, "apiRoutes", {
22104
22931
  enumerable: true,
22105
- get: function () { return chunkCTYLCWMO_cjs.api_default; }
22932
+ get: function () { return chunkI767LVN7_cjs.api_default; }
22106
22933
  });
22107
22934
  Object.defineProperty(exports, "apiSystemRoutes", {
22108
22935
  enumerable: true,
22109
- get: function () { return chunkCTYLCWMO_cjs.api_system_default; }
22936
+ get: function () { return chunkI767LVN7_cjs.api_system_default; }
22110
22937
  });
22111
22938
  Object.defineProperty(exports, "authRoutes", {
22112
22939
  enumerable: true,
22113
- get: function () { return chunkCTYLCWMO_cjs.auth_default; }
22940
+ get: function () { return chunkI767LVN7_cjs.auth_default; }
22114
22941
  });
22115
22942
  Object.defineProperty(exports, "createUserProfilesPlugin", {
22116
22943
  enumerable: true,
22117
- get: function () { return chunkCTYLCWMO_cjs.createUserProfilesPlugin; }
22944
+ get: function () { return chunkI767LVN7_cjs.createUserProfilesPlugin; }
22118
22945
  });
22119
22946
  Object.defineProperty(exports, "defineUserProfile", {
22120
22947
  enumerable: true,
22121
- get: function () { return chunkCTYLCWMO_cjs.defineUserProfile; }
22948
+ get: function () { return chunkI767LVN7_cjs.defineUserProfile; }
22122
22949
  });
22123
22950
  Object.defineProperty(exports, "getUserProfileConfig", {
22124
22951
  enumerable: true,
22125
- get: function () { return chunkCTYLCWMO_cjs.getUserProfileConfig; }
22952
+ get: function () { return chunkI767LVN7_cjs.getUserProfileConfig; }
22126
22953
  });
22127
22954
  Object.defineProperty(exports, "userProfilesPlugin", {
22128
22955
  enumerable: true,
22129
- get: function () { return chunkCTYLCWMO_cjs.userProfilesPlugin; }
22956
+ get: function () { return chunkI767LVN7_cjs.userProfilesPlugin; }
22130
22957
  });
22131
22958
  Object.defineProperty(exports, "Logger", {
22132
22959
  enumerable: true,
@@ -22282,87 +23109,87 @@ Object.defineProperty(exports, "workflowHistory", {
22282
23109
  });
22283
23110
  Object.defineProperty(exports, "AuthManager", {
22284
23111
  enumerable: true,
22285
- get: function () { return chunkIS54FPB7_cjs.AuthManager; }
23112
+ get: function () { return chunk37V3RET3_cjs.AuthManager; }
22286
23113
  });
22287
23114
  Object.defineProperty(exports, "PermissionManager", {
22288
23115
  enumerable: true,
22289
- get: function () { return chunkIS54FPB7_cjs.PermissionManager; }
23116
+ get: function () { return chunk37V3RET3_cjs.PermissionManager; }
22290
23117
  });
22291
23118
  Object.defineProperty(exports, "bootstrapDocumentTypes", {
22292
23119
  enumerable: true,
22293
- get: function () { return chunkIS54FPB7_cjs.bootstrapDocumentTypes; }
23120
+ get: function () { return chunk37V3RET3_cjs.bootstrapDocumentTypes; }
22294
23121
  });
22295
23122
  Object.defineProperty(exports, "bootstrapMiddleware", {
22296
23123
  enumerable: true,
22297
- get: function () { return chunkIS54FPB7_cjs.bootstrapMiddleware; }
23124
+ get: function () { return chunk37V3RET3_cjs.bootstrapMiddleware; }
22298
23125
  });
22299
23126
  Object.defineProperty(exports, "cacheHeaders", {
22300
23127
  enumerable: true,
22301
- get: function () { return chunkIS54FPB7_cjs.cacheHeaders; }
23128
+ get: function () { return chunk37V3RET3_cjs.cacheHeaders; }
22302
23129
  });
22303
23130
  Object.defineProperty(exports, "compressionMiddleware", {
22304
23131
  enumerable: true,
22305
- get: function () { return chunkIS54FPB7_cjs.compressionMiddleware; }
23132
+ get: function () { return chunk37V3RET3_cjs.compressionMiddleware; }
22306
23133
  });
22307
23134
  Object.defineProperty(exports, "detailedLoggingMiddleware", {
22308
23135
  enumerable: true,
22309
- get: function () { return chunkIS54FPB7_cjs.detailedLoggingMiddleware; }
23136
+ get: function () { return chunk37V3RET3_cjs.detailedLoggingMiddleware; }
22310
23137
  });
22311
23138
  Object.defineProperty(exports, "getActivePlugins", {
22312
23139
  enumerable: true,
22313
- get: function () { return chunkIS54FPB7_cjs.getActivePlugins; }
23140
+ get: function () { return chunk37V3RET3_cjs.getActivePlugins; }
22314
23141
  });
22315
23142
  Object.defineProperty(exports, "isPluginActive", {
22316
23143
  enumerable: true,
22317
- get: function () { return chunkIS54FPB7_cjs.isPluginActive; }
23144
+ get: function () { return chunk37V3RET3_cjs.isPluginActive; }
22318
23145
  });
22319
23146
  Object.defineProperty(exports, "logActivity", {
22320
23147
  enumerable: true,
22321
- get: function () { return chunkIS54FPB7_cjs.logActivity; }
23148
+ get: function () { return chunk37V3RET3_cjs.logActivity; }
22322
23149
  });
22323
23150
  Object.defineProperty(exports, "loggingMiddleware", {
22324
23151
  enumerable: true,
22325
- get: function () { return chunkIS54FPB7_cjs.loggingMiddleware; }
23152
+ get: function () { return chunk37V3RET3_cjs.loggingMiddleware; }
22326
23153
  });
22327
23154
  Object.defineProperty(exports, "optionalAuth", {
22328
23155
  enumerable: true,
22329
- get: function () { return chunkIS54FPB7_cjs.optionalAuth; }
23156
+ get: function () { return chunk37V3RET3_cjs.optionalAuth; }
22330
23157
  });
22331
23158
  Object.defineProperty(exports, "performanceLoggingMiddleware", {
22332
23159
  enumerable: true,
22333
- get: function () { return chunkIS54FPB7_cjs.performanceLoggingMiddleware; }
23160
+ get: function () { return chunk37V3RET3_cjs.performanceLoggingMiddleware; }
22334
23161
  });
22335
23162
  Object.defineProperty(exports, "requireActivePlugin", {
22336
23163
  enumerable: true,
22337
- get: function () { return chunkIS54FPB7_cjs.requireActivePlugin; }
23164
+ get: function () { return chunk37V3RET3_cjs.requireActivePlugin; }
22338
23165
  });
22339
23166
  Object.defineProperty(exports, "requireActivePlugins", {
22340
23167
  enumerable: true,
22341
- get: function () { return chunkIS54FPB7_cjs.requireActivePlugins; }
23168
+ get: function () { return chunk37V3RET3_cjs.requireActivePlugins; }
22342
23169
  });
22343
23170
  Object.defineProperty(exports, "requireAnyPermission", {
22344
23171
  enumerable: true,
22345
- get: function () { return chunkIS54FPB7_cjs.requireAnyPermission; }
23172
+ get: function () { return chunk37V3RET3_cjs.requireAnyPermission; }
22346
23173
  });
22347
23174
  Object.defineProperty(exports, "requireAuth", {
22348
23175
  enumerable: true,
22349
- get: function () { return chunkIS54FPB7_cjs.requireAuth; }
23176
+ get: function () { return chunk37V3RET3_cjs.requireAuth; }
22350
23177
  });
22351
23178
  Object.defineProperty(exports, "requirePermission", {
22352
23179
  enumerable: true,
22353
- get: function () { return chunkIS54FPB7_cjs.requirePermission; }
23180
+ get: function () { return chunk37V3RET3_cjs.requirePermission; }
22354
23181
  });
22355
23182
  Object.defineProperty(exports, "requireRole", {
22356
23183
  enumerable: true,
22357
- get: function () { return chunkIS54FPB7_cjs.requireRole; }
23184
+ get: function () { return chunk37V3RET3_cjs.requireRole; }
22358
23185
  });
22359
23186
  Object.defineProperty(exports, "securityHeaders", {
22360
23187
  enumerable: true,
22361
- get: function () { return chunkIS54FPB7_cjs.securityHeadersMiddleware; }
23188
+ get: function () { return chunk37V3RET3_cjs.securityHeadersMiddleware; }
22362
23189
  });
22363
23190
  Object.defineProperty(exports, "securityLoggingMiddleware", {
22364
23191
  enumerable: true,
22365
- get: function () { return chunkIS54FPB7_cjs.securityLoggingMiddleware; }
23192
+ get: function () { return chunk37V3RET3_cjs.securityLoggingMiddleware; }
22366
23193
  });
22367
23194
  Object.defineProperty(exports, "DocumentsService", {
22368
23195
  enumerable: true,
@@ -22374,35 +23201,35 @@ Object.defineProperty(exports, "RbacService", {
22374
23201
  });
22375
23202
  Object.defineProperty(exports, "PluginBootstrapService", {
22376
23203
  enumerable: true,
22377
- get: function () { return chunkAT4ZQGEZ_cjs.PluginBootstrapService; }
23204
+ get: function () { return chunkQCJHCSOK_cjs.PluginBootstrapService; }
22378
23205
  });
22379
23206
  Object.defineProperty(exports, "PluginServiceClass", {
22380
23207
  enumerable: true,
22381
- get: function () { return chunkAT4ZQGEZ_cjs.PluginService; }
23208
+ get: function () { return chunkQCJHCSOK_cjs.PluginService; }
22382
23209
  });
22383
23210
  Object.defineProperty(exports, "getAvailableCollectionNames", {
22384
23211
  enumerable: true,
22385
- get: function () { return chunkAT4ZQGEZ_cjs.getAvailableCollectionNames; }
23212
+ get: function () { return chunkQCJHCSOK_cjs.getAvailableCollectionNames; }
22386
23213
  });
22387
23214
  Object.defineProperty(exports, "loadCollectionConfig", {
22388
23215
  enumerable: true,
22389
- get: function () { return chunkAT4ZQGEZ_cjs.loadCollectionConfig; }
23216
+ get: function () { return chunkQCJHCSOK_cjs.loadCollectionConfig; }
22390
23217
  });
22391
23218
  Object.defineProperty(exports, "loadCollectionConfigs", {
22392
23219
  enumerable: true,
22393
- get: function () { return chunkAT4ZQGEZ_cjs.loadCollectionConfigs; }
23220
+ get: function () { return chunkQCJHCSOK_cjs.loadCollectionConfigs; }
22394
23221
  });
22395
23222
  Object.defineProperty(exports, "registerCollections", {
22396
23223
  enumerable: true,
22397
- get: function () { return chunkAT4ZQGEZ_cjs.registerCollections; }
23224
+ get: function () { return chunkQCJHCSOK_cjs.registerCollections; }
22398
23225
  });
22399
23226
  Object.defineProperty(exports, "validateCollectionConfig", {
22400
23227
  enumerable: true,
22401
- get: function () { return chunkAT4ZQGEZ_cjs.validateCollectionConfig; }
23228
+ get: function () { return chunkQCJHCSOK_cjs.validateCollectionConfig; }
22402
23229
  });
22403
23230
  Object.defineProperty(exports, "MigrationService", {
22404
23231
  enumerable: true,
22405
- get: function () { return chunkVGHEKIJL_cjs.MigrationService; }
23232
+ get: function () { return chunkA2SN3RVL_cjs.MigrationService; }
22406
23233
  });
22407
23234
  Object.defineProperty(exports, "renderFilterBar", {
22408
23235
  enumerable: true,
@@ -22442,99 +23269,99 @@ Object.defineProperty(exports, "renderAdminLayoutCatalyst", {
22442
23269
  });
22443
23270
  Object.defineProperty(exports, "HookSystemImpl", {
22444
23271
  enumerable: true,
22445
- get: function () { return chunkRFBW5RRH_cjs.HookSystemImpl; }
23272
+ get: function () { return chunkQJUJNTIU_cjs.HookSystemImpl; }
22446
23273
  });
22447
23274
  Object.defineProperty(exports, "HookUtils", {
22448
23275
  enumerable: true,
22449
- get: function () { return chunkRFBW5RRH_cjs.HookUtils; }
23276
+ get: function () { return chunkQJUJNTIU_cjs.HookUtils; }
22450
23277
  });
22451
23278
  Object.defineProperty(exports, "PluginDependencyCycleError", {
22452
23279
  enumerable: true,
22453
- get: function () { return chunkRFBW5RRH_cjs.PluginDependencyCycleError; }
23280
+ get: function () { return chunkQJUJNTIU_cjs.PluginDependencyCycleError; }
22454
23281
  });
22455
23282
  Object.defineProperty(exports, "PluginManagerClass", {
22456
23283
  enumerable: true,
22457
- get: function () { return chunkRFBW5RRH_cjs.PluginManager; }
23284
+ get: function () { return chunkQJUJNTIU_cjs.PluginManager; }
22458
23285
  });
22459
23286
  Object.defineProperty(exports, "PluginRegistryImpl", {
22460
23287
  enumerable: true,
22461
- get: function () { return chunkRFBW5RRH_cjs.PluginRegistryImpl; }
23288
+ get: function () { return chunkQJUJNTIU_cjs.PluginRegistryImpl; }
22462
23289
  });
22463
23290
  Object.defineProperty(exports, "PluginValidatorClass", {
22464
23291
  enumerable: true,
22465
- get: function () { return chunkRFBW5RRH_cjs.PluginValidator; }
23292
+ get: function () { return chunkQJUJNTIU_cjs.PluginValidator; }
22466
23293
  });
22467
23294
  Object.defineProperty(exports, "RegisterPluginsError", {
22468
23295
  enumerable: true,
22469
- get: function () { return chunkRFBW5RRH_cjs.RegisterPluginsError; }
23296
+ get: function () { return chunkQJUJNTIU_cjs.RegisterPluginsError; }
22470
23297
  });
22471
23298
  Object.defineProperty(exports, "ScopedHookSystemClass", {
22472
23299
  enumerable: true,
22473
- get: function () { return chunkRFBW5RRH_cjs.ScopedHookSystem; }
23300
+ get: function () { return chunkQJUJNTIU_cjs.ScopedHookSystem; }
22474
23301
  });
22475
23302
  Object.defineProperty(exports, "collectCronSchedules", {
22476
23303
  enumerable: true,
22477
- get: function () { return chunkRFBW5RRH_cjs.collectCronSchedules; }
23304
+ get: function () { return chunkQJUJNTIU_cjs.collectCronSchedules; }
22478
23305
  });
22479
23306
  Object.defineProperty(exports, "collectCrons", {
22480
23307
  enumerable: true,
22481
- get: function () { return chunkRFBW5RRH_cjs.collectCrons; }
23308
+ get: function () { return chunkQJUJNTIU_cjs.collectCrons; }
22482
23309
  });
22483
23310
  Object.defineProperty(exports, "createScheduledHandler", {
22484
23311
  enumerable: true,
22485
- get: function () { return chunkRFBW5RRH_cjs.createScheduledHandler; }
23312
+ get: function () { return chunkQJUJNTIU_cjs.createScheduledHandler; }
22486
23313
  });
22487
23314
  Object.defineProperty(exports, "dispatchCronTick", {
22488
23315
  enumerable: true,
22489
- get: function () { return chunkRFBW5RRH_cjs.dispatchCronTick; }
23316
+ get: function () { return chunkQJUJNTIU_cjs.dispatchCronTick; }
22490
23317
  });
22491
23318
  Object.defineProperty(exports, "registerPlugins", {
22492
23319
  enumerable: true,
22493
- get: function () { return chunkRFBW5RRH_cjs.registerPlugins; }
23320
+ get: function () { return chunkQJUJNTIU_cjs.registerPlugins; }
22494
23321
  });
22495
23322
  Object.defineProperty(exports, "topoSort", {
22496
23323
  enumerable: true,
22497
- get: function () { return chunkRFBW5RRH_cjs.topoSort; }
23324
+ get: function () { return chunkQJUJNTIU_cjs.topoSort; }
22498
23325
  });
22499
23326
  Object.defineProperty(exports, "applySchemaDefaults", {
22500
23327
  enumerable: true,
22501
- get: function () { return chunk4WMZGHIC_cjs.applySchemaDefaults; }
23328
+ get: function () { return chunkBP52BFIV_cjs.applySchemaDefaults; }
22502
23329
  });
22503
23330
  Object.defineProperty(exports, "definePlugin", {
22504
23331
  enumerable: true,
22505
- get: function () { return chunk4WMZGHIC_cjs.definePlugin; }
23332
+ get: function () { return chunkBP52BFIV_cjs.definePlugin; }
22506
23333
  });
22507
23334
  Object.defineProperty(exports, "getPluginMenu", {
22508
23335
  enumerable: true,
22509
- get: function () { return chunk4WMZGHIC_cjs.getPluginMenu; }
23336
+ get: function () { return chunkBP52BFIV_cjs.getPluginMenu; }
22510
23337
  });
22511
23338
  Object.defineProperty(exports, "isDefinedPlugin", {
22512
23339
  enumerable: true,
22513
- get: function () { return chunk4WMZGHIC_cjs.isDefinedPlugin; }
23340
+ get: function () { return chunkBP52BFIV_cjs.isDefinedPlugin; }
22514
23341
  });
22515
23342
  Object.defineProperty(exports, "parseConfigSchema", {
22516
23343
  enumerable: true,
22517
- get: function () { return chunk4WMZGHIC_cjs.parseConfigSchema; }
23344
+ get: function () { return chunkBP52BFIV_cjs.parseConfigSchema; }
22518
23345
  });
22519
23346
  Object.defineProperty(exports, "parseFormDataToSettings", {
22520
23347
  enumerable: true,
22521
- get: function () { return chunk4WMZGHIC_cjs.parseFormDataToSettings; }
23348
+ get: function () { return chunkBP52BFIV_cjs.parseFormDataToSettings; }
22522
23349
  });
22523
23350
  Object.defineProperty(exports, "renderSchemaFields", {
22524
23351
  enumerable: true,
22525
- get: function () { return chunk4WMZGHIC_cjs.renderSchemaFields; }
23352
+ get: function () { return chunkBP52BFIV_cjs.renderSchemaFields; }
22526
23353
  });
22527
23354
  Object.defineProperty(exports, "resetPluginMenu", {
22528
23355
  enumerable: true,
22529
- get: function () { return chunk4WMZGHIC_cjs.resetPluginMenu; }
23356
+ get: function () { return chunkBP52BFIV_cjs.resetPluginMenu; }
22530
23357
  });
22531
23358
  Object.defineProperty(exports, "resolvePluginMenuItems", {
22532
23359
  enumerable: true,
22533
- get: function () { return chunk4WMZGHIC_cjs.resolvePluginMenuItems; }
23360
+ get: function () { return chunkBP52BFIV_cjs.resolvePluginMenuItems; }
22534
23361
  });
22535
23362
  Object.defineProperty(exports, "setPluginMenu", {
22536
23363
  enumerable: true,
22537
- get: function () { return chunk4WMZGHIC_cjs.setPluginMenu; }
23364
+ get: function () { return chunkBP52BFIV_cjs.setPluginMenu; }
22538
23365
  });
22539
23366
  Object.defineProperty(exports, "getHookSystem", {
22540
23367
  enumerable: true,
@@ -22582,11 +23409,11 @@ Object.defineProperty(exports, "metricsTracker", {
22582
23409
  });
22583
23410
  Object.defineProperty(exports, "SONICJS_VERSION", {
22584
23411
  enumerable: true,
22585
- get: function () { return chunkC3ZQP5NW_cjs.SONICJS_VERSION; }
23412
+ get: function () { return chunkKKNEYIZJ_cjs.SONICJS_VERSION; }
22586
23413
  });
22587
23414
  Object.defineProperty(exports, "getCoreVersion", {
22588
23415
  enumerable: true,
22589
- get: function () { return chunkC3ZQP5NW_cjs.getCoreVersion; }
23416
+ get: function () { return chunkKKNEYIZJ_cjs.getCoreVersion; }
22590
23417
  });
22591
23418
  Object.defineProperty(exports, "escapeHtml", {
22592
23419
  enumerable: true,
@@ -22610,12 +23437,14 @@ exports.OAuthService = OAuthService;
22610
23437
  exports.VERSION = VERSION;
22611
23438
  exports.createDb = createDb;
22612
23439
  exports.createHelloWorldPlugin = createHelloWorldPlugin;
23440
+ exports.createMcpPlugin = createMcpPlugin;
22613
23441
  exports.createOAuthProvidersPlugin = createOAuthProvidersPlugin;
22614
23442
  exports.createRedirectPlugin = createRedirectPlugin;
22615
23443
  exports.createSonicJSApp = createSonicJSApp;
22616
23444
  exports.emailReconciliationPlugin = emailReconciliationPlugin;
22617
23445
  exports.generateTriggersComment = generateTriggersComment;
22618
23446
  exports.helloWorldPlugin = helloWorldPlugin;
23447
+ exports.mcpPlugin = mcpPlugin;
22619
23448
  exports.oauthProvidersPlugin = oauthProvidersPlugin;
22620
23449
  exports.parseCronTriggers = parseCronTriggers;
22621
23450
  exports.redirectPlugin = redirectPlugin;