@sonicjs-cms/core 2.0.2 → 2.0.3

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.
@@ -3,7 +3,7 @@
3
3
  var chunk3NVJ6W27_cjs = require('./chunk-3NVJ6W27.cjs');
4
4
  var chunk4BJGEGX5_cjs = require('./chunk-4BJGEGX5.cjs');
5
5
  var chunkLEG4KNFP_cjs = require('./chunk-LEG4KNFP.cjs');
6
- var chunkALOS2CBJ_cjs = require('./chunk-ALOS2CBJ.cjs');
6
+ var chunk3SPQ3J4N_cjs = require('./chunk-3SPQ3J4N.cjs');
7
7
  var chunkUL32L2KV_cjs = require('./chunk-UL32L2KV.cjs');
8
8
  var chunkRCQ2HIQD_cjs = require('./chunk-RCQ2HIQD.cjs');
9
9
  var hono = require('hono');
@@ -1755,8 +1755,8 @@ function renderLoginPage(data, demoLoginActive = false) {
1755
1755
  <div class="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
1756
1756
  <div class="bg-zinc-900 shadow-sm ring-1 ring-white/10 rounded-xl px-6 py-8 sm:px-10">
1757
1757
  <!-- Alerts -->
1758
- ${data.error ? `<div class="mb-6">${chunkALOS2CBJ_cjs.renderAlert({ type: "error", message: data.error })}</div>` : ""}
1759
- ${data.message ? `<div class="mb-6">${chunkALOS2CBJ_cjs.renderAlert({ type: "success", message: data.message })}</div>` : ""}
1758
+ ${data.error ? `<div class="mb-6">${chunk3SPQ3J4N_cjs.renderAlert({ type: "error", message: data.error })}</div>` : ""}
1759
+ ${data.message ? `<div class="mb-6">${chunk3SPQ3J4N_cjs.renderAlert({ type: "success", message: data.message })}</div>` : ""}
1760
1760
 
1761
1761
  <!-- Form Response (HTMX target) -->
1762
1762
  <div id="form-response" class="mb-6"></div>
@@ -1920,7 +1920,7 @@ function renderRegisterPage(data) {
1920
1920
  <div class="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
1921
1921
  <div class="bg-zinc-900 shadow-sm ring-1 ring-white/10 rounded-xl px-6 py-8 sm:px-10">
1922
1922
  <!-- Alerts -->
1923
- ${data.error ? `<div class="mb-6">${chunkALOS2CBJ_cjs.renderAlert({ type: "error", message: data.error })}</div>` : ""}
1923
+ ${data.error ? `<div class="mb-6">${chunk3SPQ3J4N_cjs.renderAlert({ type: "error", message: data.error })}</div>` : ""}
1924
1924
 
1925
1925
  <!-- Form -->
1926
1926
  <form
@@ -2033,9 +2033,36 @@ function renderRegisterPage(data) {
2033
2033
  </html>
2034
2034
  `;
2035
2035
  }
2036
-
2037
- // src/services/auth-validation.ts
2038
- var authValidationService = {};
2036
+ var authValidationService = {
2037
+ /**
2038
+ * Build registration schema dynamically based on auth settings
2039
+ * For now, returns a static schema with standard fields
2040
+ */
2041
+ async buildRegistrationSchema(_db) {
2042
+ return zod.z.object({
2043
+ email: zod.z.string().email("Valid email is required"),
2044
+ password: zod.z.string().min(8, "Password must be at least 8 characters"),
2045
+ username: zod.z.string().min(3, "Username must be at least 3 characters").optional(),
2046
+ firstName: zod.z.string().min(1, "First name is required").optional(),
2047
+ lastName: zod.z.string().min(1, "Last name is required").optional()
2048
+ });
2049
+ },
2050
+ /**
2051
+ * Generate default values for optional fields
2052
+ */
2053
+ generateDefaultValue(field, data) {
2054
+ switch (field) {
2055
+ case "username":
2056
+ return data.email ? data.email.split("@")[0] : `user${Date.now()}`;
2057
+ case "firstName":
2058
+ return "User";
2059
+ case "lastName":
2060
+ return data.email ? data.email.split("@")[0] : "Account";
2061
+ default:
2062
+ return "";
2063
+ }
2064
+ }
2065
+ };
2039
2066
 
2040
2067
  // src/routes/auth.ts
2041
2068
  var authRoutes = new hono.Hono();
@@ -2939,7 +2966,7 @@ authRoutes.post("/reset-password", async (c) => {
2939
2966
  var auth_default = authRoutes;
2940
2967
 
2941
2968
  // src/templates/pages/admin-content-form.template.ts
2942
- chunkALOS2CBJ_cjs.init_admin_layout_catalyst_template();
2969
+ chunk3SPQ3J4N_cjs.init_admin_layout_catalyst_template();
2943
2970
 
2944
2971
  // src/templates/components/dynamic-field.template.ts
2945
2972
  function renderDynamicField(field, options = {}) {
@@ -3343,8 +3370,8 @@ function renderContentFormPage(data) {
3343
3370
  <!-- Form Content -->
3344
3371
  <div class="px-6 py-6">
3345
3372
  <div id="form-messages">
3346
- ${data.error ? chunkALOS2CBJ_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
3347
- ${data.success ? chunkALOS2CBJ_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
3373
+ ${data.error ? chunk3SPQ3J4N_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
3374
+ ${data.success ? chunk3SPQ3J4N_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
3348
3375
  </div>
3349
3376
 
3350
3377
  <div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
@@ -3579,7 +3606,7 @@ function renderContentFormPage(data) {
3579
3606
  </div>
3580
3607
 
3581
3608
  <!-- Confirmation Dialogs -->
3582
- ${chunkALOS2CBJ_cjs.renderConfirmationDialog({
3609
+ ${chunk3SPQ3J4N_cjs.renderConfirmationDialog({
3583
3610
  id: "duplicate-content-confirm",
3584
3611
  title: "Duplicate Content",
3585
3612
  message: "Create a copy of this content?",
@@ -3590,7 +3617,7 @@ function renderContentFormPage(data) {
3590
3617
  onConfirm: "performDuplicateContent()"
3591
3618
  })}
3592
3619
 
3593
- ${chunkALOS2CBJ_cjs.renderConfirmationDialog({
3620
+ ${chunk3SPQ3J4N_cjs.renderConfirmationDialog({
3594
3621
  id: "delete-content-confirm",
3595
3622
  title: "Delete Content",
3596
3623
  message: "Are you sure you want to delete this content? This action cannot be undone.",
@@ -3601,7 +3628,7 @@ function renderContentFormPage(data) {
3601
3628
  onConfirm: `performDeleteContent('${data.id}')`
3602
3629
  })}
3603
3630
 
3604
- ${chunkALOS2CBJ_cjs.getConfirmationDialogScript()}
3631
+ ${chunk3SPQ3J4N_cjs.getConfirmationDialogScript()}
3605
3632
 
3606
3633
  <!-- TinyMCE CDN -->
3607
3634
  <script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script>
@@ -3889,11 +3916,11 @@ function renderContentFormPage(data) {
3889
3916
  content: pageContent,
3890
3917
  version: data.version
3891
3918
  };
3892
- return chunkALOS2CBJ_cjs.renderAdminLayoutCatalyst(layoutData);
3919
+ return chunk3SPQ3J4N_cjs.renderAdminLayoutCatalyst(layoutData);
3893
3920
  }
3894
3921
 
3895
3922
  // src/templates/pages/admin-content-list.template.ts
3896
- chunkALOS2CBJ_cjs.init_admin_layout_catalyst_template();
3923
+ chunk3SPQ3J4N_cjs.init_admin_layout_catalyst_template();
3897
3924
  function renderContentListPage(data) {
3898
3925
  const urlParams = new URLSearchParams();
3899
3926
  if (data.modelName && data.modelName !== "all") urlParams.set("model", data.modelName);
@@ -4289,8 +4316,8 @@ function renderContentListPage(data) {
4289
4316
 
4290
4317
  <!-- Content List -->
4291
4318
  <div id="content-list">
4292
- ${chunkALOS2CBJ_cjs.renderTable(tableData)}
4293
- ${chunkALOS2CBJ_cjs.renderPagination(paginationData)}
4319
+ ${chunk3SPQ3J4N_cjs.renderTable(tableData)}
4320
+ ${chunk3SPQ3J4N_cjs.renderPagination(paginationData)}
4294
4321
  </div>
4295
4322
 
4296
4323
  </div>
@@ -4499,7 +4526,7 @@ function renderContentListPage(data) {
4499
4526
  </script>
4500
4527
 
4501
4528
  <!-- Confirmation Dialog for Bulk Actions -->
4502
- ${chunkALOS2CBJ_cjs.renderConfirmationDialog({
4529
+ ${chunk3SPQ3J4N_cjs.renderConfirmationDialog({
4503
4530
  id: "bulk-action-confirm",
4504
4531
  title: "Confirm Bulk Action",
4505
4532
  message: "Are you sure you want to perform this action? This operation will affect multiple items.",
@@ -4511,7 +4538,7 @@ function renderContentListPage(data) {
4511
4538
  })}
4512
4539
 
4513
4540
  <!-- Confirmation Dialog Script -->
4514
- ${chunkALOS2CBJ_cjs.getConfirmationDialogScript()}
4541
+ ${chunk3SPQ3J4N_cjs.getConfirmationDialogScript()}
4515
4542
  `;
4516
4543
  const layoutData = {
4517
4544
  title: "Content Management",
@@ -4521,7 +4548,7 @@ function renderContentListPage(data) {
4521
4548
  version: data.version,
4522
4549
  content: pageContent
4523
4550
  };
4524
- return chunkALOS2CBJ_cjs.renderAdminLayoutCatalyst(layoutData);
4551
+ return chunk3SPQ3J4N_cjs.renderAdminLayoutCatalyst(layoutData);
4525
4552
  }
4526
4553
 
4527
4554
  // src/templates/components/version-history.template.ts
@@ -5840,7 +5867,7 @@ ${JSON.stringify(data, null, 2)}
5840
5867
  var admin_content_default = adminContentRoutes;
5841
5868
 
5842
5869
  // src/templates/pages/admin-profile.template.ts
5843
- chunkALOS2CBJ_cjs.init_admin_layout_catalyst_template();
5870
+ chunk3SPQ3J4N_cjs.init_admin_layout_catalyst_template();
5844
5871
  function renderProfilePage(data) {
5845
5872
  const pageContent = `
5846
5873
  <div class="space-y-8">
@@ -5855,8 +5882,8 @@ function renderProfilePage(data) {
5855
5882
  </div>
5856
5883
 
5857
5884
  <!-- Alert Messages -->
5858
- ${data.error ? chunkALOS2CBJ_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
5859
- ${data.success ? chunkALOS2CBJ_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
5885
+ ${data.error ? chunk3SPQ3J4N_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
5886
+ ${data.success ? chunk3SPQ3J4N_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
5860
5887
 
5861
5888
  <!-- Profile Form -->
5862
5889
  <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
@@ -6245,7 +6272,7 @@ function renderProfilePage(data) {
6245
6272
  version: data.version,
6246
6273
  content: pageContent
6247
6274
  };
6248
- return chunkALOS2CBJ_cjs.renderAdminLayoutCatalyst(layoutData);
6275
+ return chunk3SPQ3J4N_cjs.renderAdminLayoutCatalyst(layoutData);
6249
6276
  }
6250
6277
 
6251
6278
  // src/templates/components/alert.template.ts
@@ -6528,7 +6555,7 @@ function renderActivityLogsPage(data) {
6528
6555
  user: data.user,
6529
6556
  content: pageContent
6530
6557
  };
6531
- return chunkALOS2CBJ_cjs.renderAdminLayout(layoutData);
6558
+ return chunk3SPQ3J4N_cjs.renderAdminLayout(layoutData);
6532
6559
  }
6533
6560
  function getActionBadgeClass(action) {
6534
6561
  if (action.includes("login") || action.includes("logout")) {
@@ -6548,7 +6575,7 @@ function formatAction(action) {
6548
6575
  }
6549
6576
 
6550
6577
  // src/templates/pages/admin-user-edit.template.ts
6551
- chunkALOS2CBJ_cjs.init_admin_layout_catalyst_template();
6578
+ chunk3SPQ3J4N_cjs.init_admin_layout_catalyst_template();
6552
6579
 
6553
6580
  // src/templates/components/confirmation-dialog.template.ts
6554
6581
  function renderConfirmationDialog2(options) {
@@ -6669,8 +6696,8 @@ function renderUserEditPage(data) {
6669
6696
 
6670
6697
  <!-- Alert Messages -->
6671
6698
  <div id="form-messages">
6672
- ${data.error ? chunkALOS2CBJ_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
6673
- ${data.success ? chunkALOS2CBJ_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
6699
+ ${data.error ? chunk3SPQ3J4N_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
6700
+ ${data.success ? chunk3SPQ3J4N_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
6674
6701
  </div>
6675
6702
 
6676
6703
  <!-- User Edit Form -->
@@ -6963,11 +6990,11 @@ function renderUserEditPage(data) {
6963
6990
  user: data.user,
6964
6991
  content: pageContent
6965
6992
  };
6966
- return chunkALOS2CBJ_cjs.renderAdminLayoutCatalyst(layoutData);
6993
+ return chunk3SPQ3J4N_cjs.renderAdminLayoutCatalyst(layoutData);
6967
6994
  }
6968
6995
 
6969
6996
  // src/templates/pages/admin-user-new.template.ts
6970
- chunkALOS2CBJ_cjs.init_admin_layout_catalyst_template();
6997
+ chunk3SPQ3J4N_cjs.init_admin_layout_catalyst_template();
6971
6998
  function renderUserNewPage(data) {
6972
6999
  const pageContent = `
6973
7000
  <div>
@@ -7006,8 +7033,8 @@ function renderUserNewPage(data) {
7006
7033
 
7007
7034
  <!-- Alert Messages -->
7008
7035
  <div id="form-messages">
7009
- ${data.error ? chunkALOS2CBJ_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
7010
- ${data.success ? chunkALOS2CBJ_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
7036
+ ${data.error ? chunk3SPQ3J4N_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
7037
+ ${data.success ? chunk3SPQ3J4N_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
7011
7038
  </div>
7012
7039
 
7013
7040
  <!-- User New Form -->
@@ -7251,11 +7278,11 @@ function renderUserNewPage(data) {
7251
7278
  user: data.user,
7252
7279
  content: pageContent
7253
7280
  };
7254
- return chunkALOS2CBJ_cjs.renderAdminLayoutCatalyst(layoutData);
7281
+ return chunk3SPQ3J4N_cjs.renderAdminLayoutCatalyst(layoutData);
7255
7282
  }
7256
7283
 
7257
7284
  // src/templates/pages/admin-users-list.template.ts
7258
- chunkALOS2CBJ_cjs.init_admin_layout_catalyst_template();
7285
+ chunk3SPQ3J4N_cjs.init_admin_layout_catalyst_template();
7259
7286
  function renderUsersListPage(data) {
7260
7287
  const columns = [
7261
7288
  {
@@ -7406,8 +7433,8 @@ function renderUsersListPage(data) {
7406
7433
  </div>
7407
7434
 
7408
7435
  <!-- Alert Messages -->
7409
- ${data.error ? chunkALOS2CBJ_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
7410
- ${data.success ? chunkALOS2CBJ_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
7436
+ ${data.error ? chunk3SPQ3J4N_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
7437
+ ${data.success ? chunk3SPQ3J4N_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
7411
7438
 
7412
7439
  <!-- Stats -->
7413
7440
  <div class="mb-6">
@@ -7584,10 +7611,10 @@ function renderUsersListPage(data) {
7584
7611
  </div>
7585
7612
 
7586
7613
  <!-- Users Table -->
7587
- ${chunkALOS2CBJ_cjs.renderTable(tableData)}
7614
+ ${chunk3SPQ3J4N_cjs.renderTable(tableData)}
7588
7615
 
7589
7616
  <!-- Pagination -->
7590
- ${data.pagination ? chunkALOS2CBJ_cjs.renderPagination(data.pagination) : ""}
7617
+ ${data.pagination ? chunk3SPQ3J4N_cjs.renderPagination(data.pagination) : ""}
7591
7618
  </div>
7592
7619
 
7593
7620
  <script>
@@ -7658,7 +7685,7 @@ function renderUsersListPage(data) {
7658
7685
  version: data.version,
7659
7686
  content: pageContent
7660
7687
  };
7661
- return chunkALOS2CBJ_cjs.renderAdminLayoutCatalyst(layoutData);
7688
+ return chunk3SPQ3J4N_cjs.renderAdminLayoutCatalyst(layoutData);
7662
7689
  }
7663
7690
 
7664
7691
  // src/routes/admin-users.ts
@@ -7989,7 +8016,7 @@ userRoutes.post("/profile/password", async (c) => {
7989
8016
  }));
7990
8017
  }
7991
8018
  });
7992
- userRoutes.get("/users", chunk4BJGEGX5_cjs.requirePermission("users.read"), async (c) => {
8019
+ userRoutes.get("/users", async (c) => {
7993
8020
  const db = c.env.DB;
7994
8021
  const user = c.get("user");
7995
8022
  try {
@@ -8108,7 +8135,7 @@ userRoutes.get("/users", chunk4BJGEGX5_cjs.requirePermission("users.read"), asyn
8108
8135
  }), 500);
8109
8136
  }
8110
8137
  });
8111
- userRoutes.get("/users/new", chunk4BJGEGX5_cjs.requirePermission("users.create"), async (c) => {
8138
+ userRoutes.get("/users/new", async (c) => {
8112
8139
  const user = c.get("user");
8113
8140
  try {
8114
8141
  const pageData = {
@@ -8129,7 +8156,7 @@ userRoutes.get("/users/new", chunk4BJGEGX5_cjs.requirePermission("users.create")
8129
8156
  }), 500);
8130
8157
  }
8131
8158
  });
8132
- userRoutes.post("/users/new", chunk4BJGEGX5_cjs.requirePermission("users.create"), async (c) => {
8159
+ userRoutes.post("/users/new", async (c) => {
8133
8160
  const db = c.env.DB;
8134
8161
  const user = c.get("user");
8135
8162
  try {
@@ -8229,7 +8256,7 @@ userRoutes.post("/users/new", chunk4BJGEGX5_cjs.requirePermission("users.create"
8229
8256
  }));
8230
8257
  }
8231
8258
  });
8232
- userRoutes.get("/users/:id", chunk4BJGEGX5_cjs.requirePermission("users.read"), async (c) => {
8259
+ userRoutes.get("/users/:id", async (c) => {
8233
8260
  if (c.req.path.endsWith("/edit")) {
8234
8261
  return c.notFound();
8235
8262
  }
@@ -8280,7 +8307,7 @@ userRoutes.get("/users/:id", chunk4BJGEGX5_cjs.requirePermission("users.read"),
8280
8307
  return c.json({ error: "Failed to fetch user" }, 500);
8281
8308
  }
8282
8309
  });
8283
- userRoutes.get("/users/:id/edit", chunk4BJGEGX5_cjs.requirePermission("users.update"), async (c) => {
8310
+ userRoutes.get("/users/:id/edit", async (c) => {
8284
8311
  const db = c.env.DB;
8285
8312
  const user = c.get("user");
8286
8313
  const userId = c.req.param("id");
@@ -8334,7 +8361,7 @@ userRoutes.get("/users/:id/edit", chunk4BJGEGX5_cjs.requirePermission("users.upd
8334
8361
  }), 500);
8335
8362
  }
8336
8363
  });
8337
- userRoutes.put("/users/:id", chunk4BJGEGX5_cjs.requirePermission("users.update"), async (c) => {
8364
+ userRoutes.put("/users/:id", async (c) => {
8338
8365
  const db = c.env.DB;
8339
8366
  const user = c.get("user");
8340
8367
  const userId = c.req.param("id");
@@ -8420,7 +8447,7 @@ userRoutes.put("/users/:id", chunk4BJGEGX5_cjs.requirePermission("users.update")
8420
8447
  }));
8421
8448
  }
8422
8449
  });
8423
- userRoutes.delete("/users/:id", chunk4BJGEGX5_cjs.requirePermission("users.delete"), async (c) => {
8450
+ userRoutes.delete("/users/:id", async (c) => {
8424
8451
  const db = c.env.DB;
8425
8452
  const user = c.get("user");
8426
8453
  const userId = c.req.param("id");
@@ -8481,7 +8508,7 @@ userRoutes.delete("/users/:id", chunk4BJGEGX5_cjs.requirePermission("users.delet
8481
8508
  return c.json({ error: "Failed to delete user" }, 500);
8482
8509
  }
8483
8510
  });
8484
- userRoutes.post("/invite-user", chunk4BJGEGX5_cjs.requirePermission("users.create"), async (c) => {
8511
+ userRoutes.post("/invite-user", async (c) => {
8485
8512
  const db = c.env.DB;
8486
8513
  const user = c.get("user");
8487
8514
  try {
@@ -8557,7 +8584,7 @@ userRoutes.post("/invite-user", chunk4BJGEGX5_cjs.requirePermission("users.creat
8557
8584
  return c.json({ error: "Failed to send user invitation" }, 500);
8558
8585
  }
8559
8586
  });
8560
- userRoutes.post("/resend-invitation/:id", chunk4BJGEGX5_cjs.requirePermission("users.create"), async (c) => {
8587
+ userRoutes.post("/resend-invitation/:id", async (c) => {
8561
8588
  const db = c.env.DB;
8562
8589
  const user = c.get("user");
8563
8590
  const userId = c.req.param("id");
@@ -8606,7 +8633,7 @@ userRoutes.post("/resend-invitation/:id", chunk4BJGEGX5_cjs.requirePermission("u
8606
8633
  return c.json({ error: "Failed to resend invitation" }, 500);
8607
8634
  }
8608
8635
  });
8609
- userRoutes.delete("/cancel-invitation/:id", chunk4BJGEGX5_cjs.requirePermission("users.delete"), async (c) => {
8636
+ userRoutes.delete("/cancel-invitation/:id", async (c) => {
8610
8637
  const db = c.env.DB;
8611
8638
  const user = c.get("user");
8612
8639
  const userId = c.req.param("id");
@@ -8640,7 +8667,7 @@ userRoutes.delete("/cancel-invitation/:id", chunk4BJGEGX5_cjs.requirePermission(
8640
8667
  return c.json({ error: "Failed to cancel invitation" }, 500);
8641
8668
  }
8642
8669
  });
8643
- userRoutes.get("/activity-logs", chunk4BJGEGX5_cjs.requirePermission("activity.read"), async (c) => {
8670
+ userRoutes.get("/activity-logs", async (c) => {
8644
8671
  const db = c.env.DB;
8645
8672
  const user = c.get("user");
8646
8673
  try {
@@ -8746,7 +8773,7 @@ userRoutes.get("/activity-logs", chunk4BJGEGX5_cjs.requirePermission("activity.r
8746
8773
  return c.html(renderActivityLogsPage(pageData));
8747
8774
  }
8748
8775
  });
8749
- userRoutes.get("/activity-logs/export", chunk4BJGEGX5_cjs.requirePermission("activity.read"), async (c) => {
8776
+ userRoutes.get("/activity-logs/export", async (c) => {
8750
8777
  const db = c.env.DB;
8751
8778
  const user = c.get("user");
8752
8779
  try {
@@ -9029,7 +9056,7 @@ function getFileIcon(mimeType) {
9029
9056
  }
9030
9057
 
9031
9058
  // src/templates/pages/admin-media-library.template.ts
9032
- chunkALOS2CBJ_cjs.init_admin_layout_catalyst_template();
9059
+ chunk3SPQ3J4N_cjs.init_admin_layout_catalyst_template();
9033
9060
  function renderMediaLibraryPage(data) {
9034
9061
  const pageContent = `
9035
9062
  <div>
@@ -9961,7 +9988,7 @@ function renderMediaLibraryPage(data) {
9961
9988
  version: data.version,
9962
9989
  content: pageContent
9963
9990
  };
9964
- return chunkALOS2CBJ_cjs.renderAdminLayoutCatalyst(layoutData);
9991
+ return chunk3SPQ3J4N_cjs.renderAdminLayoutCatalyst(layoutData);
9965
9992
  }
9966
9993
 
9967
9994
  // src/templates/components/media-file-details.template.ts
@@ -10880,7 +10907,7 @@ function formatFileSize(bytes) {
10880
10907
  }
10881
10908
 
10882
10909
  // src/templates/pages/admin-plugins-list.template.ts
10883
- chunkALOS2CBJ_cjs.init_admin_layout_catalyst_template();
10910
+ chunk3SPQ3J4N_cjs.init_admin_layout_catalyst_template();
10884
10911
  function renderPluginsListPage(data) {
10885
10912
  const pageContent = `
10886
10913
  <div>
@@ -11254,7 +11281,7 @@ function renderPluginsListPage(data) {
11254
11281
  version: data.version,
11255
11282
  content: pageContent
11256
11283
  };
11257
- return chunkALOS2CBJ_cjs.renderAdminLayoutCatalyst(layoutData);
11284
+ return chunk3SPQ3J4N_cjs.renderAdminLayoutCatalyst(layoutData);
11258
11285
  }
11259
11286
  function renderPluginCard(plugin) {
11260
11287
  const statusColors = {
@@ -11904,7 +11931,7 @@ function renderPluginSettingsPage(data) {
11904
11931
  user,
11905
11932
  content: pageContent
11906
11933
  };
11907
- return chunkALOS2CBJ_cjs.renderAdminLayout(layoutData);
11934
+ return chunk3SPQ3J4N_cjs.renderAdminLayout(layoutData);
11908
11935
  }
11909
11936
  function renderStatusBadge(status) {
11910
11937
  const statusColors = {
@@ -12502,7 +12529,7 @@ function formatLastUpdated(timestamp) {
12502
12529
  }
12503
12530
 
12504
12531
  // src/templates/pages/admin-logs-list.template.ts
12505
- chunkALOS2CBJ_cjs.init_admin_layout_catalyst_template();
12532
+ chunk3SPQ3J4N_cjs.init_admin_layout_catalyst_template();
12506
12533
  function renderLogsListPage(data) {
12507
12534
  const { logs, pagination, filters, user } = data;
12508
12535
  const content = `
@@ -12813,7 +12840,7 @@ function renderLogsListPage(data) {
12813
12840
  user,
12814
12841
  content
12815
12842
  };
12816
- return chunkALOS2CBJ_cjs.renderAdminLayoutCatalyst(layoutData);
12843
+ return chunk3SPQ3J4N_cjs.renderAdminLayoutCatalyst(layoutData);
12817
12844
  }
12818
12845
  function renderLogDetailsPage(data) {
12819
12846
  const { log, user } = data;
@@ -13025,7 +13052,7 @@ function renderLogDetailsPage(data) {
13025
13052
  </div>
13026
13053
  </div>
13027
13054
  `;
13028
- return chunkALOS2CBJ_cjs.adminLayoutV2({
13055
+ return chunk3SPQ3J4N_cjs.adminLayoutV2({
13029
13056
  title: `Log Details - ${log.id}`,
13030
13057
  user,
13031
13058
  content
@@ -13268,7 +13295,7 @@ function renderLogConfigPage(data) {
13268
13295
 
13269
13296
  <script src="https://unpkg.com/htmx.org@1.9.6"></script>
13270
13297
  `;
13271
- return chunkALOS2CBJ_cjs.adminLayoutV2({
13298
+ return chunk3SPQ3J4N_cjs.adminLayoutV2({
13272
13299
  title: "Log Configuration",
13273
13300
  user,
13274
13301
  content
@@ -13649,7 +13676,7 @@ adminDesignRoutes.get("/", (c) => {
13649
13676
  role: user.role
13650
13677
  } : void 0
13651
13678
  };
13652
- return c.html(chunkALOS2CBJ_cjs.renderDesignPage(pageData));
13679
+ return c.html(chunk3SPQ3J4N_cjs.renderDesignPage(pageData));
13653
13680
  });
13654
13681
  var adminCheckboxRoutes = new hono.Hono();
13655
13682
  adminCheckboxRoutes.get("/", (c) => {
@@ -13661,7 +13688,7 @@ adminCheckboxRoutes.get("/", (c) => {
13661
13688
  role: user.role
13662
13689
  } : void 0
13663
13690
  };
13664
- return c.html(chunkALOS2CBJ_cjs.renderCheckboxPage(pageData));
13691
+ return c.html(chunk3SPQ3J4N_cjs.renderCheckboxPage(pageData));
13665
13692
  });
13666
13693
 
13667
13694
  // src/templates/pages/admin-faq-form.template.ts
@@ -13689,7 +13716,7 @@ function renderFAQForm(data) {
13689
13716
  </div>
13690
13717
  </div>
13691
13718
 
13692
- ${message ? chunkALOS2CBJ_cjs.renderAlert({ type: messageType || "info", message, dismissible: true }) : ""}
13719
+ ${message ? chunk3SPQ3J4N_cjs.renderAlert({ type: messageType || "info", message, dismissible: true }) : ""}
13693
13720
 
13694
13721
  <!-- Form -->
13695
13722
  <div class="backdrop-blur-xl bg-white/10 rounded-xl border border-white/20 shadow-2xl">
@@ -13902,7 +13929,7 @@ function renderFAQForm(data) {
13902
13929
  user: data.user,
13903
13930
  content: pageContent
13904
13931
  };
13905
- return chunkALOS2CBJ_cjs.renderAdminLayout(layoutData);
13932
+ return chunk3SPQ3J4N_cjs.renderAdminLayout(layoutData);
13906
13933
  }
13907
13934
  function escapeHtml4(unsafe) {
13908
13935
  return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
@@ -13927,7 +13954,7 @@ adminFAQRoutes.get("/", async (c) => {
13927
13954
  const offset = (currentPage - 1) * limit;
13928
13955
  const db = c.env?.DB;
13929
13956
  if (!db) {
13930
- return c.html(chunkALOS2CBJ_cjs.renderFAQList({
13957
+ return c.html(chunk3SPQ3J4N_cjs.renderFAQList({
13931
13958
  faqs: [],
13932
13959
  totalCount: 0,
13933
13960
  currentPage: 1,
@@ -13967,7 +13994,7 @@ adminFAQRoutes.get("/", async (c) => {
13967
13994
  `;
13968
13995
  const { results: faqs } = await db.prepare(dataQuery).bind(...params, limit, offset).all();
13969
13996
  const totalPages = Math.ceil(totalCount / limit);
13970
- return c.html(chunkALOS2CBJ_cjs.renderFAQList({
13997
+ return c.html(chunk3SPQ3J4N_cjs.renderFAQList({
13971
13998
  faqs: faqs || [],
13972
13999
  totalCount,
13973
14000
  currentPage,
@@ -13981,7 +14008,7 @@ adminFAQRoutes.get("/", async (c) => {
13981
14008
  } catch (error) {
13982
14009
  console.error("Error fetching FAQs:", error);
13983
14010
  const user = c.get("user");
13984
- return c.html(chunkALOS2CBJ_cjs.renderFAQList({
14011
+ return c.html(chunk3SPQ3J4N_cjs.renderFAQList({
13985
14012
  faqs: [],
13986
14013
  totalCount: 0,
13987
14014
  currentPage: 1,
@@ -14294,7 +14321,7 @@ function renderTestimonialsForm(data) {
14294
14321
  </div>
14295
14322
  </div>
14296
14323
 
14297
- ${message ? chunkALOS2CBJ_cjs.renderAlert({ type: messageType || "info", message, dismissible: true }) : ""}
14324
+ ${message ? chunk3SPQ3J4N_cjs.renderAlert({ type: messageType || "info", message, dismissible: true }) : ""}
14298
14325
 
14299
14326
  <!-- Form -->
14300
14327
  <div class="backdrop-blur-xl bg-white/10 rounded-xl border border-white/20 shadow-2xl">
@@ -14523,7 +14550,7 @@ function renderTestimonialsForm(data) {
14523
14550
  user: data.user,
14524
14551
  content: pageContent
14525
14552
  };
14526
- return chunkALOS2CBJ_cjs.renderAdminLayout(layoutData);
14553
+ return chunk3SPQ3J4N_cjs.renderAdminLayout(layoutData);
14527
14554
  }
14528
14555
  function escapeHtml5(unsafe) {
14529
14556
  return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
@@ -14549,7 +14576,7 @@ adminTestimonialsRoutes.get("/", async (c) => {
14549
14576
  const offset = (currentPage - 1) * limit;
14550
14577
  const db = c.env?.DB;
14551
14578
  if (!db) {
14552
- return c.html(chunkALOS2CBJ_cjs.renderTestimonialsList({
14579
+ return c.html(chunk3SPQ3J4N_cjs.renderTestimonialsList({
14553
14580
  testimonials: [],
14554
14581
  totalCount: 0,
14555
14582
  currentPage: 1,
@@ -14589,7 +14616,7 @@ adminTestimonialsRoutes.get("/", async (c) => {
14589
14616
  `;
14590
14617
  const { results: testimonials } = await db.prepare(dataQuery).bind(...params, limit, offset).all();
14591
14618
  const totalPages = Math.ceil(totalCount / limit);
14592
- return c.html(chunkALOS2CBJ_cjs.renderTestimonialsList({
14619
+ return c.html(chunk3SPQ3J4N_cjs.renderTestimonialsList({
14593
14620
  testimonials: testimonials || [],
14594
14621
  totalCount,
14595
14622
  currentPage,
@@ -14603,7 +14630,7 @@ adminTestimonialsRoutes.get("/", async (c) => {
14603
14630
  } catch (error) {
14604
14631
  console.error("Error fetching testimonials:", error);
14605
14632
  const user = c.get("user");
14606
- return c.html(chunkALOS2CBJ_cjs.renderTestimonialsList({
14633
+ return c.html(chunk3SPQ3J4N_cjs.renderTestimonialsList({
14607
14634
  testimonials: [],
14608
14635
  totalCount: 0,
14609
14636
  currentPage: 1,
@@ -14922,7 +14949,7 @@ function renderCodeExamplesForm(data) {
14922
14949
  </div>
14923
14950
  </div>
14924
14951
 
14925
- ${message ? chunkALOS2CBJ_cjs.renderAlert({ type: messageType || "info", message, dismissible: true }) : ""}
14952
+ ${message ? chunk3SPQ3J4N_cjs.renderAlert({ type: messageType || "info", message, dismissible: true }) : ""}
14926
14953
 
14927
14954
  <!-- Form -->
14928
14955
  <div class="backdrop-blur-xl bg-white/10 rounded-xl border border-white/20 shadow-2xl">
@@ -15192,7 +15219,7 @@ function renderCodeExamplesForm(data) {
15192
15219
  user: data.user,
15193
15220
  content: pageContent
15194
15221
  };
15195
- return chunkALOS2CBJ_cjs.renderAdminLayout(layoutData);
15222
+ return chunk3SPQ3J4N_cjs.renderAdminLayout(layoutData);
15196
15223
  }
15197
15224
  function escapeHtml6(unsafe) {
15198
15225
  return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
@@ -15219,7 +15246,7 @@ adminCodeExamplesRoutes.get("/", async (c) => {
15219
15246
  const offset = (currentPage - 1) * limit;
15220
15247
  const db = c.env?.DB;
15221
15248
  if (!db) {
15222
- return c.html(chunkALOS2CBJ_cjs.renderCodeExamplesList({
15249
+ return c.html(chunk3SPQ3J4N_cjs.renderCodeExamplesList({
15223
15250
  codeExamples: [],
15224
15251
  totalCount: 0,
15225
15252
  currentPage: 1,
@@ -15259,7 +15286,7 @@ adminCodeExamplesRoutes.get("/", async (c) => {
15259
15286
  `;
15260
15287
  const { results: codeExamples } = await db.prepare(dataQuery).bind(...params, limit, offset).all();
15261
15288
  const totalPages = Math.ceil(totalCount / limit);
15262
- return c.html(chunkALOS2CBJ_cjs.renderCodeExamplesList({
15289
+ return c.html(chunk3SPQ3J4N_cjs.renderCodeExamplesList({
15263
15290
  codeExamples: codeExamples || [],
15264
15291
  totalCount,
15265
15292
  currentPage,
@@ -15273,7 +15300,7 @@ adminCodeExamplesRoutes.get("/", async (c) => {
15273
15300
  } catch (error) {
15274
15301
  console.error("Error fetching code examples:", error);
15275
15302
  const user = c.get("user");
15276
- return c.html(chunkALOS2CBJ_cjs.renderCodeExamplesList({
15303
+ return c.html(chunk3SPQ3J4N_cjs.renderCodeExamplesList({
15277
15304
  codeExamples: [],
15278
15305
  totalCount: 0,
15279
15306
  currentPage: 1,
@@ -15662,7 +15689,7 @@ function renderDashboardPage(data) {
15662
15689
  version: data.version,
15663
15690
  content: pageContent
15664
15691
  };
15665
- return chunkALOS2CBJ_cjs.renderAdminLayout(layoutData);
15692
+ return chunk3SPQ3J4N_cjs.renderAdminLayout(layoutData);
15666
15693
  }
15667
15694
  function renderStatsCards(stats) {
15668
15695
  const cards = [
@@ -16437,7 +16464,7 @@ router.get("/system-status", async (c) => {
16437
16464
  });
16438
16465
 
16439
16466
  // src/templates/pages/admin-collections-list.template.ts
16440
- chunkALOS2CBJ_cjs.init_admin_layout_catalyst_template();
16467
+ chunk3SPQ3J4N_cjs.init_admin_layout_catalyst_template();
16441
16468
 
16442
16469
  // src/templates/components/table.template.ts
16443
16470
  function renderTable2(data) {
@@ -16911,11 +16938,11 @@ function renderCollectionsListPage(data) {
16911
16938
  version: data.version,
16912
16939
  content: pageContent
16913
16940
  };
16914
- return chunkALOS2CBJ_cjs.renderAdminLayoutCatalyst(layoutData);
16941
+ return chunk3SPQ3J4N_cjs.renderAdminLayoutCatalyst(layoutData);
16915
16942
  }
16916
16943
 
16917
16944
  // src/templates/pages/admin-collections-form.template.ts
16918
- chunkALOS2CBJ_cjs.init_admin_layout_catalyst_template();
16945
+ chunk3SPQ3J4N_cjs.init_admin_layout_catalyst_template();
16919
16946
  function renderCollectionFormPage(data) {
16920
16947
  const isEdit = data.isEdit || !!data.id;
16921
16948
  const title = isEdit ? "Edit Collection" : "Create New Collection";
@@ -17144,7 +17171,7 @@ function renderCollectionFormPage(data) {
17144
17171
  }
17145
17172
  </style>
17146
17173
 
17147
- ${chunkALOS2CBJ_cjs.renderForm(formData)}
17174
+ ${chunk3SPQ3J4N_cjs.renderForm(formData)}
17148
17175
 
17149
17176
  ${isEdit && !data.managed ? `
17150
17177
  <!-- Fields Management Section -->
@@ -17688,7 +17715,7 @@ function renderCollectionFormPage(data) {
17688
17715
  version: data.version,
17689
17716
  content: pageContent
17690
17717
  };
17691
- return chunkALOS2CBJ_cjs.renderAdminLayoutCatalyst(layoutData);
17718
+ return chunk3SPQ3J4N_cjs.renderAdminLayoutCatalyst(layoutData);
17692
17719
  }
17693
17720
 
17694
17721
  // src/routes/admin-collections.ts
@@ -18123,7 +18150,7 @@ adminCollectionsRoutes.post("/:collectionId/fields/reorder", async (c) => {
18123
18150
  });
18124
18151
 
18125
18152
  // src/templates/pages/admin-settings.template.ts
18126
- chunkALOS2CBJ_cjs.init_admin_layout_catalyst_template();
18153
+ chunk3SPQ3J4N_cjs.init_admin_layout_catalyst_template();
18127
18154
  function renderSettingsPage(data) {
18128
18155
  const activeTab = data.activeTab || "general";
18129
18156
  const pageContent = `
@@ -18224,7 +18251,7 @@ function renderSettingsPage(data) {
18224
18251
  // Migration functions
18225
18252
  window.refreshMigrationStatus = async function() {
18226
18253
  try {
18227
- const response = await fetch('/admin/api/migrations/status');
18254
+ const response = await fetch('/admin/settings/api/migrations/status');
18228
18255
  const result = await response.json();
18229
18256
 
18230
18257
  if (result.success) {
@@ -18252,7 +18279,7 @@ function renderSettingsPage(data) {
18252
18279
  btn.innerHTML = 'Running...';
18253
18280
 
18254
18281
  try {
18255
- const response = await fetch('/admin/api/migrations/run', {
18282
+ const response = await fetch('/admin/settings/api/migrations/run', {
18256
18283
  method: 'POST'
18257
18284
  });
18258
18285
  const result = await response.json();
@@ -18273,7 +18300,7 @@ function renderSettingsPage(data) {
18273
18300
 
18274
18301
  window.validateSchema = async function() {
18275
18302
  try {
18276
- const response = await fetch('/admin/api/migrations/validate');
18303
+ const response = await fetch('/admin/settings/api/migrations/validate');
18277
18304
  const result = await response.json();
18278
18305
 
18279
18306
  if (result.success) {
@@ -18351,7 +18378,7 @@ function renderSettingsPage(data) {
18351
18378
  // Database Tools functions
18352
18379
  window.refreshDatabaseStats = async function() {
18353
18380
  try {
18354
- const response = await fetch('/admin/database-tools/api/stats');
18381
+ const response = await fetch('/admin/settings/api/database-tools/stats');
18355
18382
  const result = await response.json();
18356
18383
 
18357
18384
  if (result.success) {
@@ -18372,7 +18399,7 @@ function renderSettingsPage(data) {
18372
18399
  btn.innerHTML = 'Creating Backup...';
18373
18400
 
18374
18401
  try {
18375
- const response = await fetch('/admin/database-tools/api/backup', {
18402
+ const response = await fetch('/admin/settings/api/database-tools/backup', {
18376
18403
  method: 'POST'
18377
18404
  });
18378
18405
  const result = await response.json();
@@ -18411,7 +18438,7 @@ function renderSettingsPage(data) {
18411
18438
  btn.innerHTML = 'Truncating...';
18412
18439
 
18413
18440
  try {
18414
- const response = await fetch('/admin/database-tools/api/truncate', {
18441
+ const response = await fetch('/admin/settings/api/database-tools/truncate', {
18415
18442
  method: 'POST',
18416
18443
  headers: {
18417
18444
  'Content-Type': 'application/json'
@@ -18442,7 +18469,7 @@ function renderSettingsPage(data) {
18442
18469
 
18443
18470
  window.validateDatabase = async function() {
18444
18471
  try {
18445
- const response = await fetch('/admin/database-tools/api/validate');
18472
+ const response = await fetch('/admin/settings/api/database-tools/validate');
18446
18473
  const result = await response.json();
18447
18474
 
18448
18475
  if (result.success) {
@@ -18533,7 +18560,7 @@ function renderSettingsPage(data) {
18533
18560
  version: data.version,
18534
18561
  content: pageContent
18535
18562
  };
18536
- return chunkALOS2CBJ_cjs.renderAdminLayoutCatalyst(layoutData);
18563
+ return chunk3SPQ3J4N_cjs.renderAdminLayoutCatalyst(layoutData);
18537
18564
  }
18538
18565
  function renderTabButton(tabId, label, iconPath, activeTab) {
18539
18566
  const isActive = activeTab === tabId;
@@ -19296,7 +19323,7 @@ function renderMigrationSettings(settings) {
19296
19323
  if (typeof refreshMigrationStatus === 'undefined') {
19297
19324
  window.refreshMigrationStatus = async function() {
19298
19325
  try {
19299
- const response = await fetch('/admin/api/migrations/status');
19326
+ const response = await fetch('/admin/settings/api/migrations/status');
19300
19327
  const result = await response.json();
19301
19328
 
19302
19329
  if (result.success) {
@@ -19769,6 +19796,138 @@ adminSettingsRoutes.get("/api/migrations/validate", async (c) => {
19769
19796
  }, 500);
19770
19797
  }
19771
19798
  });
19799
+ adminSettingsRoutes.get("/api/database-tools/stats", async (c) => {
19800
+ try {
19801
+ const db = c.env.DB;
19802
+ const tablesQuery = await db.prepare(`
19803
+ SELECT name FROM sqlite_master
19804
+ WHERE type='table'
19805
+ AND name NOT LIKE 'sqlite_%'
19806
+ AND name NOT LIKE '_cf_%'
19807
+ ORDER BY name
19808
+ `).all();
19809
+ const tables = tablesQuery.results || [];
19810
+ let totalRows = 0;
19811
+ const tableStats = await Promise.all(
19812
+ tables.map(async (table) => {
19813
+ try {
19814
+ const countResult = await db.prepare(`SELECT COUNT(*) as count FROM ${table.name}`).first();
19815
+ const rowCount = countResult?.count || 0;
19816
+ totalRows += rowCount;
19817
+ return {
19818
+ name: table.name,
19819
+ rowCount
19820
+ };
19821
+ } catch (error) {
19822
+ console.error(`Error counting rows in ${table.name}:`, error);
19823
+ return {
19824
+ name: table.name,
19825
+ rowCount: 0
19826
+ };
19827
+ }
19828
+ })
19829
+ );
19830
+ const estimatedSizeBytes = totalRows * 1024;
19831
+ const databaseSizeMB = (estimatedSizeBytes / (1024 * 1024)).toFixed(2);
19832
+ return c.json({
19833
+ success: true,
19834
+ data: {
19835
+ totalTables: tables.length,
19836
+ totalRows,
19837
+ databaseSize: `${databaseSizeMB} MB (estimated)`,
19838
+ tables: tableStats
19839
+ }
19840
+ });
19841
+ } catch (error) {
19842
+ console.error("Error fetching database stats:", error);
19843
+ return c.json({
19844
+ success: false,
19845
+ error: "Failed to fetch database statistics"
19846
+ }, 500);
19847
+ }
19848
+ });
19849
+ adminSettingsRoutes.get("/api/database-tools/validate", async (c) => {
19850
+ try {
19851
+ const db = c.env.DB;
19852
+ const integrityResult = await db.prepare("PRAGMA integrity_check").first();
19853
+ const isValid = integrityResult?.integrity_check === "ok";
19854
+ return c.json({
19855
+ success: true,
19856
+ data: {
19857
+ valid: isValid,
19858
+ message: isValid ? "Database integrity check passed" : "Database integrity check failed"
19859
+ }
19860
+ });
19861
+ } catch (error) {
19862
+ console.error("Error validating database:", error);
19863
+ return c.json({
19864
+ success: false,
19865
+ error: "Failed to validate database"
19866
+ }, 500);
19867
+ }
19868
+ });
19869
+ adminSettingsRoutes.post("/api/database-tools/backup", async (c) => {
19870
+ try {
19871
+ const user = c.get("user");
19872
+ if (!user || user.role !== "admin") {
19873
+ return c.json({
19874
+ success: false,
19875
+ error: "Unauthorized. Admin access required."
19876
+ }, 403);
19877
+ }
19878
+ return c.json({
19879
+ success: true,
19880
+ message: "Database backup feature coming soon. Use Cloudflare Dashboard for backups."
19881
+ });
19882
+ } catch (error) {
19883
+ console.error("Error creating backup:", error);
19884
+ return c.json({
19885
+ success: false,
19886
+ error: "Failed to create backup"
19887
+ }, 500);
19888
+ }
19889
+ });
19890
+ adminSettingsRoutes.post("/api/database-tools/truncate", async (c) => {
19891
+ try {
19892
+ const user = c.get("user");
19893
+ if (!user || user.role !== "admin") {
19894
+ return c.json({
19895
+ success: false,
19896
+ error: "Unauthorized. Admin access required."
19897
+ }, 403);
19898
+ }
19899
+ const body = await c.req.json();
19900
+ const tablesToTruncate = body.tables || [];
19901
+ if (!Array.isArray(tablesToTruncate) || tablesToTruncate.length === 0) {
19902
+ return c.json({
19903
+ success: false,
19904
+ error: "No tables specified for truncation"
19905
+ }, 400);
19906
+ }
19907
+ const db = c.env.DB;
19908
+ const results = [];
19909
+ for (const tableName of tablesToTruncate) {
19910
+ try {
19911
+ await db.prepare(`DELETE FROM ${tableName}`).run();
19912
+ results.push({ table: tableName, success: true });
19913
+ } catch (error) {
19914
+ console.error(`Error truncating ${tableName}:`, error);
19915
+ results.push({ table: tableName, success: false, error: String(error) });
19916
+ }
19917
+ }
19918
+ return c.json({
19919
+ success: true,
19920
+ message: `Truncated ${results.filter((r) => r.success).length} of ${tablesToTruncate.length} tables`,
19921
+ results
19922
+ });
19923
+ } catch (error) {
19924
+ console.error("Error truncating tables:", error);
19925
+ return c.json({
19926
+ success: false,
19927
+ error: "Failed to truncate tables"
19928
+ }, 500);
19929
+ }
19930
+ });
19772
19931
  adminSettingsRoutes.post("/", async (c) => {
19773
19932
  try {
19774
19933
  const formData = await c.req.formData();
@@ -19840,5 +19999,5 @@ exports.api_system_default = api_system_default;
19840
19999
  exports.auth_default = auth_default;
19841
20000
  exports.router = router;
19842
20001
  exports.userRoutes = userRoutes;
19843
- //# sourceMappingURL=chunk-7G6XT62S.cjs.map
19844
- //# sourceMappingURL=chunk-7G6XT62S.cjs.map
20002
+ //# sourceMappingURL=chunk-5B3VMVEX.cjs.map
20003
+ //# sourceMappingURL=chunk-5B3VMVEX.cjs.map