@sonicjs-cms/core 2.0.2 → 2.0.4

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 (33) hide show
  1. package/dist/{chunk-O46XKBFM.js → chunk-3LZ6TLPC.js} +14 -24
  2. package/dist/chunk-3LZ6TLPC.js.map +1 -0
  3. package/dist/{chunk-ALOS2CBJ.cjs → chunk-3SPQ3J4N.cjs} +14 -24
  4. package/dist/chunk-3SPQ3J4N.cjs.map +1 -0
  5. package/dist/{chunk-EGFHFM4N.cjs → chunk-5APKEYFK.cjs} +5 -5
  6. package/dist/{chunk-EGFHFM4N.cjs.map → chunk-5APKEYFK.cjs.map} +1 -1
  7. package/dist/{chunk-UL32L2KV.cjs → chunk-BRPONFW6.cjs} +123 -3
  8. package/dist/chunk-BRPONFW6.cjs.map +1 -0
  9. package/dist/{chunk-SGGHTIWV.js → chunk-CQ2VMJQO.js} +228 -45
  10. package/dist/chunk-CQ2VMJQO.js.map +1 -0
  11. package/dist/{chunk-P2PTTBO5.js → chunk-RYQCT2IV.js} +3 -3
  12. package/dist/{chunk-P2PTTBO5.js.map → chunk-RYQCT2IV.js.map} +1 -1
  13. package/dist/{chunk-7G6XT62S.cjs → chunk-RZW752PE.cjs} +325 -142
  14. package/dist/chunk-RZW752PE.cjs.map +1 -0
  15. package/dist/{chunk-XJETEIRU.js → chunk-WKGONLHK.js} +123 -4
  16. package/dist/chunk-WKGONLHK.js.map +1 -0
  17. package/dist/index.cjs +58 -62
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.js +7 -11
  20. package/dist/index.js.map +1 -1
  21. package/dist/routes.cjs +23 -23
  22. package/dist/routes.js +3 -3
  23. package/dist/templates.cjs +18 -18
  24. package/dist/templates.js +2 -2
  25. package/dist/utils.cjs +11 -11
  26. package/dist/utils.js +1 -1
  27. package/package.json +1 -1
  28. package/dist/chunk-7G6XT62S.cjs.map +0 -1
  29. package/dist/chunk-ALOS2CBJ.cjs.map +0 -1
  30. package/dist/chunk-O46XKBFM.js.map +0 -1
  31. package/dist/chunk-SGGHTIWV.js.map +0 -1
  32. package/dist/chunk-UL32L2KV.cjs.map +0 -1
  33. package/dist/chunk-XJETEIRU.js.map +0 -1
@@ -3,8 +3,8 @@
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');
7
- var chunkUL32L2KV_cjs = require('./chunk-UL32L2KV.cjs');
6
+ var chunk3SPQ3J4N_cjs = require('./chunk-3SPQ3J4N.cjs');
7
+ var chunkBRPONFW6_cjs = require('./chunk-BRPONFW6.cjs');
8
8
  var chunkRCQ2HIQD_cjs = require('./chunk-RCQ2HIQD.cjs');
9
9
  var hono = require('hono');
10
10
  var cors = require('hono/cors');
@@ -334,12 +334,12 @@ apiRoutes.get("/content", async (c) => {
334
334
  });
335
335
  }
336
336
  }
337
- const filter = chunkUL32L2KV_cjs.QueryFilterBuilder.parseFromQuery(queryParams);
337
+ const filter = chunkBRPONFW6_cjs.QueryFilterBuilder.parseFromQuery(queryParams);
338
338
  if (!filter.limit) {
339
339
  filter.limit = 50;
340
340
  }
341
341
  filter.limit = Math.min(filter.limit, 1e3);
342
- const builder = new chunkUL32L2KV_cjs.QueryFilterBuilder();
342
+ const builder = new chunkBRPONFW6_cjs.QueryFilterBuilder();
343
343
  const queryResult = builder.build("content", filter);
344
344
  if (queryResult.errors.length > 0) {
345
345
  return c.json({
@@ -426,7 +426,7 @@ apiRoutes.get("/collections/:collection/content", async (c) => {
426
426
  if (!collectionResult) {
427
427
  return c.json({ error: "Collection not found" }, 404);
428
428
  }
429
- const filter = chunkUL32L2KV_cjs.QueryFilterBuilder.parseFromQuery(queryParams);
429
+ const filter = chunkBRPONFW6_cjs.QueryFilterBuilder.parseFromQuery(queryParams);
430
430
  if (!filter.where) {
431
431
  filter.where = { and: [] };
432
432
  }
@@ -442,7 +442,7 @@ apiRoutes.get("/collections/:collection/content", async (c) => {
442
442
  filter.limit = 50;
443
443
  }
444
444
  filter.limit = Math.min(filter.limit, 1e3);
445
- const builder = new chunkUL32L2KV_cjs.QueryFilterBuilder();
445
+ const builder = new chunkBRPONFW6_cjs.QueryFilterBuilder();
446
446
  const queryResult = builder.build("content", filter);
447
447
  if (queryResult.errors.length > 0) {
448
448
  return c.json({
@@ -918,10 +918,17 @@ apiMediaRoutes.post("/create-folder", async (c) => {
918
918
  }
919
919
  const checkStmt = c.env.DB.prepare("SELECT COUNT(*) as count FROM media WHERE folder = ? AND deleted_at IS NULL");
920
920
  const existingFolder = await checkStmt.bind(folderName).first();
921
+ if (existingFolder && existingFolder.count > 0) {
922
+ return c.json({
923
+ success: false,
924
+ error: `Folder "${folderName}" already exists`
925
+ }, 400);
926
+ }
921
927
  return c.json({
922
928
  success: true,
923
- message: `Folder "${folderName}" created successfully`,
924
- folder: folderName
929
+ message: `Folder "${folderName}" is ready. Upload files to this folder to make it appear in the media library.`,
930
+ folder: folderName,
931
+ note: "Folders appear automatically when you upload files to them"
925
932
  });
926
933
  } catch (error) {
927
934
  console.error("Create folder error:", error);
@@ -1755,8 +1762,8 @@ function renderLoginPage(data, demoLoginActive = false) {
1755
1762
  <div class="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
1756
1763
  <div class="bg-zinc-900 shadow-sm ring-1 ring-white/10 rounded-xl px-6 py-8 sm:px-10">
1757
1764
  <!-- 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>` : ""}
1765
+ ${data.error ? `<div class="mb-6">${chunk3SPQ3J4N_cjs.renderAlert({ type: "error", message: data.error })}</div>` : ""}
1766
+ ${data.message ? `<div class="mb-6">${chunk3SPQ3J4N_cjs.renderAlert({ type: "success", message: data.message })}</div>` : ""}
1760
1767
 
1761
1768
  <!-- Form Response (HTMX target) -->
1762
1769
  <div id="form-response" class="mb-6"></div>
@@ -1920,7 +1927,7 @@ function renderRegisterPage(data) {
1920
1927
  <div class="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
1921
1928
  <div class="bg-zinc-900 shadow-sm ring-1 ring-white/10 rounded-xl px-6 py-8 sm:px-10">
1922
1929
  <!-- Alerts -->
1923
- ${data.error ? `<div class="mb-6">${chunkALOS2CBJ_cjs.renderAlert({ type: "error", message: data.error })}</div>` : ""}
1930
+ ${data.error ? `<div class="mb-6">${chunk3SPQ3J4N_cjs.renderAlert({ type: "error", message: data.error })}</div>` : ""}
1924
1931
 
1925
1932
  <!-- Form -->
1926
1933
  <form
@@ -2033,9 +2040,36 @@ function renderRegisterPage(data) {
2033
2040
  </html>
2034
2041
  `;
2035
2042
  }
2036
-
2037
- // src/services/auth-validation.ts
2038
- var authValidationService = {};
2043
+ var authValidationService = {
2044
+ /**
2045
+ * Build registration schema dynamically based on auth settings
2046
+ * For now, returns a static schema with standard fields
2047
+ */
2048
+ async buildRegistrationSchema(_db) {
2049
+ return zod.z.object({
2050
+ email: zod.z.string().email("Valid email is required"),
2051
+ password: zod.z.string().min(8, "Password must be at least 8 characters"),
2052
+ username: zod.z.string().min(3, "Username must be at least 3 characters").optional(),
2053
+ firstName: zod.z.string().min(1, "First name is required").optional(),
2054
+ lastName: zod.z.string().min(1, "Last name is required").optional()
2055
+ });
2056
+ },
2057
+ /**
2058
+ * Generate default values for optional fields
2059
+ */
2060
+ generateDefaultValue(field, data) {
2061
+ switch (field) {
2062
+ case "username":
2063
+ return data.email ? data.email.split("@")[0] : `user${Date.now()}`;
2064
+ case "firstName":
2065
+ return "User";
2066
+ case "lastName":
2067
+ return data.email ? data.email.split("@")[0] : "Account";
2068
+ default:
2069
+ return "";
2070
+ }
2071
+ }
2072
+ };
2039
2073
 
2040
2074
  // src/routes/auth.ts
2041
2075
  var authRoutes = new hono.Hono();
@@ -2319,7 +2353,7 @@ authRoutes.post("/register/form", async (c) => {
2319
2353
  Account created successfully! Redirecting to admin dashboard...
2320
2354
  <script>
2321
2355
  setTimeout(() => {
2322
- window.location.href = '/admin/content';
2356
+ window.location.href = '/admin/dashboard';
2323
2357
  }, 2000);
2324
2358
  </script>
2325
2359
  </div>
@@ -2387,7 +2421,7 @@ authRoutes.post("/login/form", async (c) => {
2387
2421
  </div>
2388
2422
  <script>
2389
2423
  setTimeout(() => {
2390
- window.location.href = '/admin/content';
2424
+ window.location.href = '/admin/dashboard';
2391
2425
  }, 2000);
2392
2426
  </script>
2393
2427
  </div>
@@ -2680,7 +2714,7 @@ authRoutes.post("/accept-invitation", async (c) => {
2680
2714
  maxAge: 60 * 60 * 24
2681
2715
  // 24 hours
2682
2716
  });
2683
- return c.redirect("/admin/content?welcome=true");
2717
+ return c.redirect("/admin/dashboard?welcome=true");
2684
2718
  } catch (error) {
2685
2719
  console.error("Accept invitation error:", error);
2686
2720
  return c.json({ error: "Failed to accept invitation" }, 500);
@@ -2939,7 +2973,7 @@ authRoutes.post("/reset-password", async (c) => {
2939
2973
  var auth_default = authRoutes;
2940
2974
 
2941
2975
  // src/templates/pages/admin-content-form.template.ts
2942
- chunkALOS2CBJ_cjs.init_admin_layout_catalyst_template();
2976
+ chunk3SPQ3J4N_cjs.init_admin_layout_catalyst_template();
2943
2977
 
2944
2978
  // src/templates/components/dynamic-field.template.ts
2945
2979
  function renderDynamicField(field, options = {}) {
@@ -3343,8 +3377,8 @@ function renderContentFormPage(data) {
3343
3377
  <!-- Form Content -->
3344
3378
  <div class="px-6 py-6">
3345
3379
  <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 }) : ""}
3380
+ ${data.error ? chunk3SPQ3J4N_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
3381
+ ${data.success ? chunk3SPQ3J4N_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
3348
3382
  </div>
3349
3383
 
3350
3384
  <div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
@@ -3579,7 +3613,7 @@ function renderContentFormPage(data) {
3579
3613
  </div>
3580
3614
 
3581
3615
  <!-- Confirmation Dialogs -->
3582
- ${chunkALOS2CBJ_cjs.renderConfirmationDialog({
3616
+ ${chunk3SPQ3J4N_cjs.renderConfirmationDialog({
3583
3617
  id: "duplicate-content-confirm",
3584
3618
  title: "Duplicate Content",
3585
3619
  message: "Create a copy of this content?",
@@ -3590,7 +3624,7 @@ function renderContentFormPage(data) {
3590
3624
  onConfirm: "performDuplicateContent()"
3591
3625
  })}
3592
3626
 
3593
- ${chunkALOS2CBJ_cjs.renderConfirmationDialog({
3627
+ ${chunk3SPQ3J4N_cjs.renderConfirmationDialog({
3594
3628
  id: "delete-content-confirm",
3595
3629
  title: "Delete Content",
3596
3630
  message: "Are you sure you want to delete this content? This action cannot be undone.",
@@ -3601,7 +3635,7 @@ function renderContentFormPage(data) {
3601
3635
  onConfirm: `performDeleteContent('${data.id}')`
3602
3636
  })}
3603
3637
 
3604
- ${chunkALOS2CBJ_cjs.getConfirmationDialogScript()}
3638
+ ${chunk3SPQ3J4N_cjs.getConfirmationDialogScript()}
3605
3639
 
3606
3640
  <!-- TinyMCE CDN -->
3607
3641
  <script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script>
@@ -3889,11 +3923,11 @@ function renderContentFormPage(data) {
3889
3923
  content: pageContent,
3890
3924
  version: data.version
3891
3925
  };
3892
- return chunkALOS2CBJ_cjs.renderAdminLayoutCatalyst(layoutData);
3926
+ return chunk3SPQ3J4N_cjs.renderAdminLayoutCatalyst(layoutData);
3893
3927
  }
3894
3928
 
3895
3929
  // src/templates/pages/admin-content-list.template.ts
3896
- chunkALOS2CBJ_cjs.init_admin_layout_catalyst_template();
3930
+ chunk3SPQ3J4N_cjs.init_admin_layout_catalyst_template();
3897
3931
  function renderContentListPage(data) {
3898
3932
  const urlParams = new URLSearchParams();
3899
3933
  if (data.modelName && data.modelName !== "all") urlParams.set("model", data.modelName);
@@ -4289,8 +4323,8 @@ function renderContentListPage(data) {
4289
4323
 
4290
4324
  <!-- Content List -->
4291
4325
  <div id="content-list">
4292
- ${chunkALOS2CBJ_cjs.renderTable(tableData)}
4293
- ${chunkALOS2CBJ_cjs.renderPagination(paginationData)}
4326
+ ${chunk3SPQ3J4N_cjs.renderTable(tableData)}
4327
+ ${chunk3SPQ3J4N_cjs.renderPagination(paginationData)}
4294
4328
  </div>
4295
4329
 
4296
4330
  </div>
@@ -4499,7 +4533,7 @@ function renderContentListPage(data) {
4499
4533
  </script>
4500
4534
 
4501
4535
  <!-- Confirmation Dialog for Bulk Actions -->
4502
- ${chunkALOS2CBJ_cjs.renderConfirmationDialog({
4536
+ ${chunk3SPQ3J4N_cjs.renderConfirmationDialog({
4503
4537
  id: "bulk-action-confirm",
4504
4538
  title: "Confirm Bulk Action",
4505
4539
  message: "Are you sure you want to perform this action? This operation will affect multiple items.",
@@ -4511,7 +4545,7 @@ function renderContentListPage(data) {
4511
4545
  })}
4512
4546
 
4513
4547
  <!-- Confirmation Dialog Script -->
4514
- ${chunkALOS2CBJ_cjs.getConfirmationDialogScript()}
4548
+ ${chunk3SPQ3J4N_cjs.getConfirmationDialogScript()}
4515
4549
  `;
4516
4550
  const layoutData = {
4517
4551
  title: "Content Management",
@@ -4521,7 +4555,7 @@ function renderContentListPage(data) {
4521
4555
  version: data.version,
4522
4556
  content: pageContent
4523
4557
  };
4524
- return chunkALOS2CBJ_cjs.renderAdminLayoutCatalyst(layoutData);
4558
+ return chunk3SPQ3J4N_cjs.renderAdminLayoutCatalyst(layoutData);
4525
4559
  }
4526
4560
 
4527
4561
  // src/templates/components/version-history.template.ts
@@ -5840,7 +5874,7 @@ ${JSON.stringify(data, null, 2)}
5840
5874
  var admin_content_default = adminContentRoutes;
5841
5875
 
5842
5876
  // src/templates/pages/admin-profile.template.ts
5843
- chunkALOS2CBJ_cjs.init_admin_layout_catalyst_template();
5877
+ chunk3SPQ3J4N_cjs.init_admin_layout_catalyst_template();
5844
5878
  function renderProfilePage(data) {
5845
5879
  const pageContent = `
5846
5880
  <div class="space-y-8">
@@ -5855,8 +5889,8 @@ function renderProfilePage(data) {
5855
5889
  </div>
5856
5890
 
5857
5891
  <!-- 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 }) : ""}
5892
+ ${data.error ? chunk3SPQ3J4N_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
5893
+ ${data.success ? chunk3SPQ3J4N_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
5860
5894
 
5861
5895
  <!-- Profile Form -->
5862
5896
  <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
@@ -6245,7 +6279,7 @@ function renderProfilePage(data) {
6245
6279
  version: data.version,
6246
6280
  content: pageContent
6247
6281
  };
6248
- return chunkALOS2CBJ_cjs.renderAdminLayoutCatalyst(layoutData);
6282
+ return chunk3SPQ3J4N_cjs.renderAdminLayoutCatalyst(layoutData);
6249
6283
  }
6250
6284
 
6251
6285
  // src/templates/components/alert.template.ts
@@ -6528,7 +6562,7 @@ function renderActivityLogsPage(data) {
6528
6562
  user: data.user,
6529
6563
  content: pageContent
6530
6564
  };
6531
- return chunkALOS2CBJ_cjs.renderAdminLayout(layoutData);
6565
+ return chunk3SPQ3J4N_cjs.renderAdminLayout(layoutData);
6532
6566
  }
6533
6567
  function getActionBadgeClass(action) {
6534
6568
  if (action.includes("login") || action.includes("logout")) {
@@ -6548,7 +6582,7 @@ function formatAction(action) {
6548
6582
  }
6549
6583
 
6550
6584
  // src/templates/pages/admin-user-edit.template.ts
6551
- chunkALOS2CBJ_cjs.init_admin_layout_catalyst_template();
6585
+ chunk3SPQ3J4N_cjs.init_admin_layout_catalyst_template();
6552
6586
 
6553
6587
  // src/templates/components/confirmation-dialog.template.ts
6554
6588
  function renderConfirmationDialog2(options) {
@@ -6669,8 +6703,8 @@ function renderUserEditPage(data) {
6669
6703
 
6670
6704
  <!-- Alert Messages -->
6671
6705
  <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 }) : ""}
6706
+ ${data.error ? chunk3SPQ3J4N_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
6707
+ ${data.success ? chunk3SPQ3J4N_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
6674
6708
  </div>
6675
6709
 
6676
6710
  <!-- User Edit Form -->
@@ -6689,7 +6723,7 @@ function renderUserEditPage(data) {
6689
6723
  <input
6690
6724
  type="text"
6691
6725
  name="first_name"
6692
- value="${chunkUL32L2KV_cjs.escapeHtml(data.userToEdit.firstName || "")}"
6726
+ value="${chunkBRPONFW6_cjs.escapeHtml(data.userToEdit.firstName || "")}"
6693
6727
  required
6694
6728
  class="w-full rounded-lg bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-950 dark:text-white shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow"
6695
6729
  />
@@ -6700,7 +6734,7 @@ function renderUserEditPage(data) {
6700
6734
  <input
6701
6735
  type="text"
6702
6736
  name="last_name"
6703
- value="${chunkUL32L2KV_cjs.escapeHtml(data.userToEdit.lastName || "")}"
6737
+ value="${chunkBRPONFW6_cjs.escapeHtml(data.userToEdit.lastName || "")}"
6704
6738
  required
6705
6739
  class="w-full rounded-lg bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-950 dark:text-white shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow"
6706
6740
  />
@@ -6711,7 +6745,7 @@ function renderUserEditPage(data) {
6711
6745
  <input
6712
6746
  type="text"
6713
6747
  name="username"
6714
- value="${chunkUL32L2KV_cjs.escapeHtml(data.userToEdit.username || "")}"
6748
+ value="${chunkBRPONFW6_cjs.escapeHtml(data.userToEdit.username || "")}"
6715
6749
  required
6716
6750
  class="w-full rounded-lg bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-950 dark:text-white shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow"
6717
6751
  />
@@ -6722,7 +6756,7 @@ function renderUserEditPage(data) {
6722
6756
  <input
6723
6757
  type="email"
6724
6758
  name="email"
6725
- value="${chunkUL32L2KV_cjs.escapeHtml(data.userToEdit.email || "")}"
6759
+ value="${chunkBRPONFW6_cjs.escapeHtml(data.userToEdit.email || "")}"
6726
6760
  required
6727
6761
  class="w-full rounded-lg bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-950 dark:text-white shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow"
6728
6762
  />
@@ -6733,7 +6767,7 @@ function renderUserEditPage(data) {
6733
6767
  <input
6734
6768
  type="tel"
6735
6769
  name="phone"
6736
- value="${chunkUL32L2KV_cjs.escapeHtml(data.userToEdit.phone || "")}"
6770
+ value="${chunkBRPONFW6_cjs.escapeHtml(data.userToEdit.phone || "")}"
6737
6771
  class="w-full rounded-lg bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-950 dark:text-white shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow"
6738
6772
  />
6739
6773
  </div>
@@ -6747,7 +6781,7 @@ function renderUserEditPage(data) {
6747
6781
  class="col-start-1 row-start-1 w-full appearance-none rounded-md bg-white/5 dark:bg-white/5 py-1.5 pl-3 pr-8 text-base text-zinc-950 dark:text-white outline outline-1 -outline-offset-1 outline-zinc-500/30 dark:outline-zinc-400/30 *:bg-white dark:*:bg-zinc-800 focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-zinc-500 dark:focus-visible:outline-zinc-400 sm:text-sm/6"
6748
6782
  >
6749
6783
  ${data.roles.map((role) => `
6750
- <option value="${chunkUL32L2KV_cjs.escapeHtml(role.value)}" ${data.userToEdit.role === role.value ? "selected" : ""}>${chunkUL32L2KV_cjs.escapeHtml(role.label)}</option>
6784
+ <option value="${chunkBRPONFW6_cjs.escapeHtml(role.value)}" ${data.userToEdit.role === role.value ? "selected" : ""}>${chunkBRPONFW6_cjs.escapeHtml(role.label)}</option>
6751
6785
  `).join("")}
6752
6786
  </select>
6753
6787
  <svg viewBox="0 0 16 16" fill="currentColor" data-slot="icon" aria-hidden="true" class="pointer-events-none col-start-1 row-start-1 mr-2 size-5 self-center justify-self-end text-zinc-600 dark:text-zinc-400 sm:size-4">
@@ -6763,7 +6797,7 @@ function renderUserEditPage(data) {
6763
6797
  name="bio"
6764
6798
  rows="3"
6765
6799
  class="w-full rounded-lg bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-950 dark:text-white shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow"
6766
- >${chunkUL32L2KV_cjs.escapeHtml(data.userToEdit.bio || "")}</textarea>
6800
+ >${chunkBRPONFW6_cjs.escapeHtml(data.userToEdit.bio || "")}</textarea>
6767
6801
  </div>
6768
6802
  </div>
6769
6803
 
@@ -6963,11 +6997,11 @@ function renderUserEditPage(data) {
6963
6997
  user: data.user,
6964
6998
  content: pageContent
6965
6999
  };
6966
- return chunkALOS2CBJ_cjs.renderAdminLayoutCatalyst(layoutData);
7000
+ return chunk3SPQ3J4N_cjs.renderAdminLayoutCatalyst(layoutData);
6967
7001
  }
6968
7002
 
6969
7003
  // src/templates/pages/admin-user-new.template.ts
6970
- chunkALOS2CBJ_cjs.init_admin_layout_catalyst_template();
7004
+ chunk3SPQ3J4N_cjs.init_admin_layout_catalyst_template();
6971
7005
  function renderUserNewPage(data) {
6972
7006
  const pageContent = `
6973
7007
  <div>
@@ -7006,8 +7040,8 @@ function renderUserNewPage(data) {
7006
7040
 
7007
7041
  <!-- Alert Messages -->
7008
7042
  <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 }) : ""}
7043
+ ${data.error ? chunk3SPQ3J4N_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
7044
+ ${data.success ? chunk3SPQ3J4N_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
7011
7045
  </div>
7012
7046
 
7013
7047
  <!-- User New Form -->
@@ -7251,11 +7285,11 @@ function renderUserNewPage(data) {
7251
7285
  user: data.user,
7252
7286
  content: pageContent
7253
7287
  };
7254
- return chunkALOS2CBJ_cjs.renderAdminLayoutCatalyst(layoutData);
7288
+ return chunk3SPQ3J4N_cjs.renderAdminLayoutCatalyst(layoutData);
7255
7289
  }
7256
7290
 
7257
7291
  // src/templates/pages/admin-users-list.template.ts
7258
- chunkALOS2CBJ_cjs.init_admin_layout_catalyst_template();
7292
+ chunk3SPQ3J4N_cjs.init_admin_layout_catalyst_template();
7259
7293
  function renderUsersListPage(data) {
7260
7294
  const columns = [
7261
7295
  {
@@ -7406,8 +7440,8 @@ function renderUsersListPage(data) {
7406
7440
  </div>
7407
7441
 
7408
7442
  <!-- 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 }) : ""}
7443
+ ${data.error ? chunk3SPQ3J4N_cjs.renderAlert({ type: "error", message: data.error, dismissible: true }) : ""}
7444
+ ${data.success ? chunk3SPQ3J4N_cjs.renderAlert({ type: "success", message: data.success, dismissible: true }) : ""}
7411
7445
 
7412
7446
  <!-- Stats -->
7413
7447
  <div class="mb-6">
@@ -7584,10 +7618,10 @@ function renderUsersListPage(data) {
7584
7618
  </div>
7585
7619
 
7586
7620
  <!-- Users Table -->
7587
- ${chunkALOS2CBJ_cjs.renderTable(tableData)}
7621
+ ${chunk3SPQ3J4N_cjs.renderTable(tableData)}
7588
7622
 
7589
7623
  <!-- Pagination -->
7590
- ${data.pagination ? chunkALOS2CBJ_cjs.renderPagination(data.pagination) : ""}
7624
+ ${data.pagination ? chunk3SPQ3J4N_cjs.renderPagination(data.pagination) : ""}
7591
7625
  </div>
7592
7626
 
7593
7627
  <script>
@@ -7658,7 +7692,7 @@ function renderUsersListPage(data) {
7658
7692
  version: data.version,
7659
7693
  content: pageContent
7660
7694
  };
7661
- return chunkALOS2CBJ_cjs.renderAdminLayoutCatalyst(layoutData);
7695
+ return chunk3SPQ3J4N_cjs.renderAdminLayoutCatalyst(layoutData);
7662
7696
  }
7663
7697
 
7664
7698
  // src/routes/admin-users.ts
@@ -7762,12 +7796,12 @@ userRoutes.put("/profile", async (c) => {
7762
7796
  const db = c.env.DB;
7763
7797
  try {
7764
7798
  const formData = await c.req.formData();
7765
- const firstName = chunkUL32L2KV_cjs.sanitizeInput(formData.get("first_name")?.toString());
7766
- const lastName = chunkUL32L2KV_cjs.sanitizeInput(formData.get("last_name")?.toString());
7767
- const username = chunkUL32L2KV_cjs.sanitizeInput(formData.get("username")?.toString());
7799
+ const firstName = chunkBRPONFW6_cjs.sanitizeInput(formData.get("first_name")?.toString());
7800
+ const lastName = chunkBRPONFW6_cjs.sanitizeInput(formData.get("last_name")?.toString());
7801
+ const username = chunkBRPONFW6_cjs.sanitizeInput(formData.get("username")?.toString());
7768
7802
  const email = formData.get("email")?.toString()?.trim().toLowerCase() || "";
7769
- const phone = chunkUL32L2KV_cjs.sanitizeInput(formData.get("phone")?.toString()) || null;
7770
- const bio = chunkUL32L2KV_cjs.sanitizeInput(formData.get("bio")?.toString()) || null;
7803
+ const phone = chunkBRPONFW6_cjs.sanitizeInput(formData.get("phone")?.toString()) || null;
7804
+ const bio = chunkBRPONFW6_cjs.sanitizeInput(formData.get("bio")?.toString()) || null;
7771
7805
  const timezone = formData.get("timezone")?.toString() || "UTC";
7772
7806
  const language = formData.get("language")?.toString() || "en";
7773
7807
  const emailNotifications = formData.get("email_notifications") === "1";
@@ -7989,7 +8023,7 @@ userRoutes.post("/profile/password", async (c) => {
7989
8023
  }));
7990
8024
  }
7991
8025
  });
7992
- userRoutes.get("/users", chunk4BJGEGX5_cjs.requirePermission("users.read"), async (c) => {
8026
+ userRoutes.get("/users", async (c) => {
7993
8027
  const db = c.env.DB;
7994
8028
  const user = c.get("user");
7995
8029
  try {
@@ -8108,7 +8142,7 @@ userRoutes.get("/users", chunk4BJGEGX5_cjs.requirePermission("users.read"), asyn
8108
8142
  }), 500);
8109
8143
  }
8110
8144
  });
8111
- userRoutes.get("/users/new", chunk4BJGEGX5_cjs.requirePermission("users.create"), async (c) => {
8145
+ userRoutes.get("/users/new", async (c) => {
8112
8146
  const user = c.get("user");
8113
8147
  try {
8114
8148
  const pageData = {
@@ -8129,17 +8163,17 @@ userRoutes.get("/users/new", chunk4BJGEGX5_cjs.requirePermission("users.create")
8129
8163
  }), 500);
8130
8164
  }
8131
8165
  });
8132
- userRoutes.post("/users/new", chunk4BJGEGX5_cjs.requirePermission("users.create"), async (c) => {
8166
+ userRoutes.post("/users/new", async (c) => {
8133
8167
  const db = c.env.DB;
8134
8168
  const user = c.get("user");
8135
8169
  try {
8136
8170
  const formData = await c.req.formData();
8137
- const firstName = chunkUL32L2KV_cjs.sanitizeInput(formData.get("first_name")?.toString());
8138
- const lastName = chunkUL32L2KV_cjs.sanitizeInput(formData.get("last_name")?.toString());
8139
- const username = chunkUL32L2KV_cjs.sanitizeInput(formData.get("username")?.toString());
8171
+ const firstName = chunkBRPONFW6_cjs.sanitizeInput(formData.get("first_name")?.toString());
8172
+ const lastName = chunkBRPONFW6_cjs.sanitizeInput(formData.get("last_name")?.toString());
8173
+ const username = chunkBRPONFW6_cjs.sanitizeInput(formData.get("username")?.toString());
8140
8174
  const email = formData.get("email")?.toString()?.trim().toLowerCase() || "";
8141
- const phone = chunkUL32L2KV_cjs.sanitizeInput(formData.get("phone")?.toString()) || null;
8142
- const bio = chunkUL32L2KV_cjs.sanitizeInput(formData.get("bio")?.toString()) || null;
8175
+ const phone = chunkBRPONFW6_cjs.sanitizeInput(formData.get("phone")?.toString()) || null;
8176
+ const bio = chunkBRPONFW6_cjs.sanitizeInput(formData.get("bio")?.toString()) || null;
8143
8177
  const role = formData.get("role")?.toString() || "viewer";
8144
8178
  const password = formData.get("password")?.toString() || "";
8145
8179
  const confirmPassword = formData.get("confirm_password")?.toString() || "";
@@ -8229,7 +8263,7 @@ userRoutes.post("/users/new", chunk4BJGEGX5_cjs.requirePermission("users.create"
8229
8263
  }));
8230
8264
  }
8231
8265
  });
8232
- userRoutes.get("/users/:id", chunk4BJGEGX5_cjs.requirePermission("users.read"), async (c) => {
8266
+ userRoutes.get("/users/:id", async (c) => {
8233
8267
  if (c.req.path.endsWith("/edit")) {
8234
8268
  return c.notFound();
8235
8269
  }
@@ -8280,7 +8314,7 @@ userRoutes.get("/users/:id", chunk4BJGEGX5_cjs.requirePermission("users.read"),
8280
8314
  return c.json({ error: "Failed to fetch user" }, 500);
8281
8315
  }
8282
8316
  });
8283
- userRoutes.get("/users/:id/edit", chunk4BJGEGX5_cjs.requirePermission("users.update"), async (c) => {
8317
+ userRoutes.get("/users/:id/edit", async (c) => {
8284
8318
  const db = c.env.DB;
8285
8319
  const user = c.get("user");
8286
8320
  const userId = c.req.param("id");
@@ -8334,18 +8368,18 @@ userRoutes.get("/users/:id/edit", chunk4BJGEGX5_cjs.requirePermission("users.upd
8334
8368
  }), 500);
8335
8369
  }
8336
8370
  });
8337
- userRoutes.put("/users/:id", chunk4BJGEGX5_cjs.requirePermission("users.update"), async (c) => {
8371
+ userRoutes.put("/users/:id", async (c) => {
8338
8372
  const db = c.env.DB;
8339
8373
  const user = c.get("user");
8340
8374
  const userId = c.req.param("id");
8341
8375
  try {
8342
8376
  const formData = await c.req.formData();
8343
- const firstName = chunkUL32L2KV_cjs.sanitizeInput(formData.get("first_name")?.toString());
8344
- const lastName = chunkUL32L2KV_cjs.sanitizeInput(formData.get("last_name")?.toString());
8345
- const username = chunkUL32L2KV_cjs.sanitizeInput(formData.get("username")?.toString());
8377
+ const firstName = chunkBRPONFW6_cjs.sanitizeInput(formData.get("first_name")?.toString());
8378
+ const lastName = chunkBRPONFW6_cjs.sanitizeInput(formData.get("last_name")?.toString());
8379
+ const username = chunkBRPONFW6_cjs.sanitizeInput(formData.get("username")?.toString());
8346
8380
  const email = formData.get("email")?.toString()?.trim().toLowerCase() || "";
8347
- const phone = chunkUL32L2KV_cjs.sanitizeInput(formData.get("phone")?.toString()) || null;
8348
- const bio = chunkUL32L2KV_cjs.sanitizeInput(formData.get("bio")?.toString()) || null;
8381
+ const phone = chunkBRPONFW6_cjs.sanitizeInput(formData.get("phone")?.toString()) || null;
8382
+ const bio = chunkBRPONFW6_cjs.sanitizeInput(formData.get("bio")?.toString()) || null;
8349
8383
  const role = formData.get("role")?.toString() || "viewer";
8350
8384
  const isActive = formData.get("is_active") === "1";
8351
8385
  const emailVerified = formData.get("email_verified") === "1";
@@ -8420,7 +8454,7 @@ userRoutes.put("/users/:id", chunk4BJGEGX5_cjs.requirePermission("users.update")
8420
8454
  }));
8421
8455
  }
8422
8456
  });
8423
- userRoutes.delete("/users/:id", chunk4BJGEGX5_cjs.requirePermission("users.delete"), async (c) => {
8457
+ userRoutes.delete("/users/:id", async (c) => {
8424
8458
  const db = c.env.DB;
8425
8459
  const user = c.get("user");
8426
8460
  const userId = c.req.param("id");
@@ -8481,15 +8515,15 @@ userRoutes.delete("/users/:id", chunk4BJGEGX5_cjs.requirePermission("users.delet
8481
8515
  return c.json({ error: "Failed to delete user" }, 500);
8482
8516
  }
8483
8517
  });
8484
- userRoutes.post("/invite-user", chunk4BJGEGX5_cjs.requirePermission("users.create"), async (c) => {
8518
+ userRoutes.post("/invite-user", async (c) => {
8485
8519
  const db = c.env.DB;
8486
8520
  const user = c.get("user");
8487
8521
  try {
8488
8522
  const formData = await c.req.formData();
8489
8523
  const email = formData.get("email")?.toString()?.trim().toLowerCase() || "";
8490
8524
  const role = formData.get("role")?.toString()?.trim() || "viewer";
8491
- const firstName = chunkUL32L2KV_cjs.sanitizeInput(formData.get("first_name")?.toString());
8492
- const lastName = chunkUL32L2KV_cjs.sanitizeInput(formData.get("last_name")?.toString());
8525
+ const firstName = chunkBRPONFW6_cjs.sanitizeInput(formData.get("first_name")?.toString());
8526
+ const lastName = chunkBRPONFW6_cjs.sanitizeInput(formData.get("last_name")?.toString());
8493
8527
  if (!email || !firstName || !lastName) {
8494
8528
  return c.json({ error: "Email, first name, and last name are required" }, 400);
8495
8529
  }
@@ -8557,7 +8591,7 @@ userRoutes.post("/invite-user", chunk4BJGEGX5_cjs.requirePermission("users.creat
8557
8591
  return c.json({ error: "Failed to send user invitation" }, 500);
8558
8592
  }
8559
8593
  });
8560
- userRoutes.post("/resend-invitation/:id", chunk4BJGEGX5_cjs.requirePermission("users.create"), async (c) => {
8594
+ userRoutes.post("/resend-invitation/:id", async (c) => {
8561
8595
  const db = c.env.DB;
8562
8596
  const user = c.get("user");
8563
8597
  const userId = c.req.param("id");
@@ -8606,7 +8640,7 @@ userRoutes.post("/resend-invitation/:id", chunk4BJGEGX5_cjs.requirePermission("u
8606
8640
  return c.json({ error: "Failed to resend invitation" }, 500);
8607
8641
  }
8608
8642
  });
8609
- userRoutes.delete("/cancel-invitation/:id", chunk4BJGEGX5_cjs.requirePermission("users.delete"), async (c) => {
8643
+ userRoutes.delete("/cancel-invitation/:id", async (c) => {
8610
8644
  const db = c.env.DB;
8611
8645
  const user = c.get("user");
8612
8646
  const userId = c.req.param("id");
@@ -8640,7 +8674,7 @@ userRoutes.delete("/cancel-invitation/:id", chunk4BJGEGX5_cjs.requirePermission(
8640
8674
  return c.json({ error: "Failed to cancel invitation" }, 500);
8641
8675
  }
8642
8676
  });
8643
- userRoutes.get("/activity-logs", chunk4BJGEGX5_cjs.requirePermission("activity.read"), async (c) => {
8677
+ userRoutes.get("/activity-logs", async (c) => {
8644
8678
  const db = c.env.DB;
8645
8679
  const user = c.get("user");
8646
8680
  try {
@@ -8746,7 +8780,7 @@ userRoutes.get("/activity-logs", chunk4BJGEGX5_cjs.requirePermission("activity.r
8746
8780
  return c.html(renderActivityLogsPage(pageData));
8747
8781
  }
8748
8782
  });
8749
- userRoutes.get("/activity-logs/export", chunk4BJGEGX5_cjs.requirePermission("activity.read"), async (c) => {
8783
+ userRoutes.get("/activity-logs/export", async (c) => {
8750
8784
  const db = c.env.DB;
8751
8785
  const user = c.get("user");
8752
8786
  try {
@@ -9029,7 +9063,7 @@ function getFileIcon(mimeType) {
9029
9063
  }
9030
9064
 
9031
9065
  // src/templates/pages/admin-media-library.template.ts
9032
- chunkALOS2CBJ_cjs.init_admin_layout_catalyst_template();
9066
+ chunk3SPQ3J4N_cjs.init_admin_layout_catalyst_template();
9033
9067
  function renderMediaLibraryPage(data) {
9034
9068
  const pageContent = `
9035
9069
  <div>
@@ -9304,11 +9338,12 @@ function renderMediaLibraryPage(data) {
9304
9338
  </div>
9305
9339
 
9306
9340
  <!-- Upload Form -->
9307
- <form
9341
+ <form
9308
9342
  id="upload-form"
9309
9343
  hx-post="/admin/media/upload"
9310
9344
  hx-encoding="multipart/form-data"
9311
9345
  hx-target="#upload-results"
9346
+ hx-on::after-request="if(event.detail.successful) { setTimeout(() => { window.location.href = '/admin/media?t=' + Date.now(); }, 1500); }"
9312
9347
  class="space-y-4"
9313
9348
  >
9314
9349
  <!-- Drag and Drop Zone -->
@@ -9961,7 +9996,7 @@ function renderMediaLibraryPage(data) {
9961
9996
  version: data.version,
9962
9997
  content: pageContent
9963
9998
  };
9964
- return chunkALOS2CBJ_cjs.renderAdminLayoutCatalyst(layoutData);
9999
+ return chunk3SPQ3J4N_cjs.renderAdminLayoutCatalyst(layoutData);
9965
10000
  }
9966
10001
 
9967
10002
  // src/templates/components/media-file-details.template.ts
@@ -10191,21 +10226,23 @@ adminMediaRoutes.get("/", async (c) => {
10191
10226
  const { results } = await stmt.bind(...params).all();
10192
10227
  const foldersStmt = db.prepare(`
10193
10228
  SELECT folder, COUNT(*) as count, SUM(size) as totalSize
10194
- FROM media
10195
- GROUP BY folder
10229
+ FROM media
10230
+ WHERE deleted_at IS NULL
10231
+ GROUP BY folder
10196
10232
  ORDER BY folder
10197
10233
  `);
10198
10234
  const { results: folders } = await foldersStmt.all();
10199
10235
  const typesStmt = db.prepare(`
10200
- SELECT
10201
- CASE
10236
+ SELECT
10237
+ CASE
10202
10238
  WHEN mime_type LIKE 'image/%' THEN 'images'
10203
10239
  WHEN mime_type LIKE 'video/%' THEN 'videos'
10204
10240
  WHEN mime_type IN ('application/pdf', 'text/plain') THEN 'documents'
10205
10241
  ELSE 'other'
10206
10242
  END as type,
10207
10243
  COUNT(*) as count
10208
- FROM media
10244
+ FROM media
10245
+ WHERE deleted_at IS NULL
10209
10246
  GROUP BY type
10210
10247
  `);
10211
10248
  const { results: types } = await typesStmt.all();
@@ -10481,6 +10518,18 @@ adminMediaRoutes.post("/upload", async (c) => {
10481
10518
  }
10482
10519
  const uploadResults = [];
10483
10520
  const errors = [];
10521
+ console.log("[MEDIA UPLOAD] c.env keys:", Object.keys(c.env));
10522
+ console.log("[MEDIA UPLOAD] MEDIA_BUCKET defined?", !!c.env.MEDIA_BUCKET);
10523
+ console.log("[MEDIA UPLOAD] MEDIA_BUCKET type:", typeof c.env.MEDIA_BUCKET);
10524
+ if (!c.env.MEDIA_BUCKET) {
10525
+ console.error("[MEDIA UPLOAD] MEDIA_BUCKET is not available! Available env keys:", Object.keys(c.env));
10526
+ return c.html(html.html`
10527
+ <div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded">
10528
+ Media storage (R2) is not configured. Please check your wrangler.toml configuration.
10529
+ <br><small>Debug: Available bindings: ${Object.keys(c.env).join(", ")}</small>
10530
+ </div>
10531
+ `);
10532
+ }
10484
10533
  for (const file of files) {
10485
10534
  try {
10486
10535
  const validation = fileValidationSchema2.safeParse({
@@ -10880,7 +10929,7 @@ function formatFileSize(bytes) {
10880
10929
  }
10881
10930
 
10882
10931
  // src/templates/pages/admin-plugins-list.template.ts
10883
- chunkALOS2CBJ_cjs.init_admin_layout_catalyst_template();
10932
+ chunk3SPQ3J4N_cjs.init_admin_layout_catalyst_template();
10884
10933
  function renderPluginsListPage(data) {
10885
10934
  const pageContent = `
10886
10935
  <div>
@@ -11254,7 +11303,7 @@ function renderPluginsListPage(data) {
11254
11303
  version: data.version,
11255
11304
  content: pageContent
11256
11305
  };
11257
- return chunkALOS2CBJ_cjs.renderAdminLayoutCatalyst(layoutData);
11306
+ return chunk3SPQ3J4N_cjs.renderAdminLayoutCatalyst(layoutData);
11258
11307
  }
11259
11308
  function renderPluginCard(plugin) {
11260
11309
  const statusColors = {
@@ -11904,7 +11953,7 @@ function renderPluginSettingsPage(data) {
11904
11953
  user,
11905
11954
  content: pageContent
11906
11955
  };
11907
- return chunkALOS2CBJ_cjs.renderAdminLayout(layoutData);
11956
+ return chunk3SPQ3J4N_cjs.renderAdminLayout(layoutData);
11908
11957
  }
11909
11958
  function renderStatusBadge(status) {
11910
11959
  const statusColors = {
@@ -12502,7 +12551,7 @@ function formatLastUpdated(timestamp) {
12502
12551
  }
12503
12552
 
12504
12553
  // src/templates/pages/admin-logs-list.template.ts
12505
- chunkALOS2CBJ_cjs.init_admin_layout_catalyst_template();
12554
+ chunk3SPQ3J4N_cjs.init_admin_layout_catalyst_template();
12506
12555
  function renderLogsListPage(data) {
12507
12556
  const { logs, pagination, filters, user } = data;
12508
12557
  const content = `
@@ -12813,7 +12862,7 @@ function renderLogsListPage(data) {
12813
12862
  user,
12814
12863
  content
12815
12864
  };
12816
- return chunkALOS2CBJ_cjs.renderAdminLayoutCatalyst(layoutData);
12865
+ return chunk3SPQ3J4N_cjs.renderAdminLayoutCatalyst(layoutData);
12817
12866
  }
12818
12867
  function renderLogDetailsPage(data) {
12819
12868
  const { log, user } = data;
@@ -13025,7 +13074,7 @@ function renderLogDetailsPage(data) {
13025
13074
  </div>
13026
13075
  </div>
13027
13076
  `;
13028
- return chunkALOS2CBJ_cjs.adminLayoutV2({
13077
+ return chunk3SPQ3J4N_cjs.adminLayoutV2({
13029
13078
  title: `Log Details - ${log.id}`,
13030
13079
  user,
13031
13080
  content
@@ -13268,7 +13317,7 @@ function renderLogConfigPage(data) {
13268
13317
 
13269
13318
  <script src="https://unpkg.com/htmx.org@1.9.6"></script>
13270
13319
  `;
13271
- return chunkALOS2CBJ_cjs.adminLayoutV2({
13320
+ return chunk3SPQ3J4N_cjs.adminLayoutV2({
13272
13321
  title: "Log Configuration",
13273
13322
  user,
13274
13323
  content
@@ -13649,7 +13698,7 @@ adminDesignRoutes.get("/", (c) => {
13649
13698
  role: user.role
13650
13699
  } : void 0
13651
13700
  };
13652
- return c.html(chunkALOS2CBJ_cjs.renderDesignPage(pageData));
13701
+ return c.html(chunk3SPQ3J4N_cjs.renderDesignPage(pageData));
13653
13702
  });
13654
13703
  var adminCheckboxRoutes = new hono.Hono();
13655
13704
  adminCheckboxRoutes.get("/", (c) => {
@@ -13661,7 +13710,7 @@ adminCheckboxRoutes.get("/", (c) => {
13661
13710
  role: user.role
13662
13711
  } : void 0
13663
13712
  };
13664
- return c.html(chunkALOS2CBJ_cjs.renderCheckboxPage(pageData));
13713
+ return c.html(chunk3SPQ3J4N_cjs.renderCheckboxPage(pageData));
13665
13714
  });
13666
13715
 
13667
13716
  // src/templates/pages/admin-faq-form.template.ts
@@ -13689,7 +13738,7 @@ function renderFAQForm(data) {
13689
13738
  </div>
13690
13739
  </div>
13691
13740
 
13692
- ${message ? chunkALOS2CBJ_cjs.renderAlert({ type: messageType || "info", message, dismissible: true }) : ""}
13741
+ ${message ? chunk3SPQ3J4N_cjs.renderAlert({ type: messageType || "info", message, dismissible: true }) : ""}
13693
13742
 
13694
13743
  <!-- Form -->
13695
13744
  <div class="backdrop-blur-xl bg-white/10 rounded-xl border border-white/20 shadow-2xl">
@@ -13902,7 +13951,7 @@ function renderFAQForm(data) {
13902
13951
  user: data.user,
13903
13952
  content: pageContent
13904
13953
  };
13905
- return chunkALOS2CBJ_cjs.renderAdminLayout(layoutData);
13954
+ return chunk3SPQ3J4N_cjs.renderAdminLayout(layoutData);
13906
13955
  }
13907
13956
  function escapeHtml4(unsafe) {
13908
13957
  return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
@@ -13927,7 +13976,7 @@ adminFAQRoutes.get("/", async (c) => {
13927
13976
  const offset = (currentPage - 1) * limit;
13928
13977
  const db = c.env?.DB;
13929
13978
  if (!db) {
13930
- return c.html(chunkALOS2CBJ_cjs.renderFAQList({
13979
+ return c.html(chunk3SPQ3J4N_cjs.renderFAQList({
13931
13980
  faqs: [],
13932
13981
  totalCount: 0,
13933
13982
  currentPage: 1,
@@ -13967,7 +14016,7 @@ adminFAQRoutes.get("/", async (c) => {
13967
14016
  `;
13968
14017
  const { results: faqs } = await db.prepare(dataQuery).bind(...params, limit, offset).all();
13969
14018
  const totalPages = Math.ceil(totalCount / limit);
13970
- return c.html(chunkALOS2CBJ_cjs.renderFAQList({
14019
+ return c.html(chunk3SPQ3J4N_cjs.renderFAQList({
13971
14020
  faqs: faqs || [],
13972
14021
  totalCount,
13973
14022
  currentPage,
@@ -13981,7 +14030,7 @@ adminFAQRoutes.get("/", async (c) => {
13981
14030
  } catch (error) {
13982
14031
  console.error("Error fetching FAQs:", error);
13983
14032
  const user = c.get("user");
13984
- return c.html(chunkALOS2CBJ_cjs.renderFAQList({
14033
+ return c.html(chunk3SPQ3J4N_cjs.renderFAQList({
13985
14034
  faqs: [],
13986
14035
  totalCount: 0,
13987
14036
  currentPage: 1,
@@ -14294,7 +14343,7 @@ function renderTestimonialsForm(data) {
14294
14343
  </div>
14295
14344
  </div>
14296
14345
 
14297
- ${message ? chunkALOS2CBJ_cjs.renderAlert({ type: messageType || "info", message, dismissible: true }) : ""}
14346
+ ${message ? chunk3SPQ3J4N_cjs.renderAlert({ type: messageType || "info", message, dismissible: true }) : ""}
14298
14347
 
14299
14348
  <!-- Form -->
14300
14349
  <div class="backdrop-blur-xl bg-white/10 rounded-xl border border-white/20 shadow-2xl">
@@ -14523,7 +14572,7 @@ function renderTestimonialsForm(data) {
14523
14572
  user: data.user,
14524
14573
  content: pageContent
14525
14574
  };
14526
- return chunkALOS2CBJ_cjs.renderAdminLayout(layoutData);
14575
+ return chunk3SPQ3J4N_cjs.renderAdminLayout(layoutData);
14527
14576
  }
14528
14577
  function escapeHtml5(unsafe) {
14529
14578
  return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
@@ -14549,7 +14598,7 @@ adminTestimonialsRoutes.get("/", async (c) => {
14549
14598
  const offset = (currentPage - 1) * limit;
14550
14599
  const db = c.env?.DB;
14551
14600
  if (!db) {
14552
- return c.html(chunkALOS2CBJ_cjs.renderTestimonialsList({
14601
+ return c.html(chunk3SPQ3J4N_cjs.renderTestimonialsList({
14553
14602
  testimonials: [],
14554
14603
  totalCount: 0,
14555
14604
  currentPage: 1,
@@ -14589,7 +14638,7 @@ adminTestimonialsRoutes.get("/", async (c) => {
14589
14638
  `;
14590
14639
  const { results: testimonials } = await db.prepare(dataQuery).bind(...params, limit, offset).all();
14591
14640
  const totalPages = Math.ceil(totalCount / limit);
14592
- return c.html(chunkALOS2CBJ_cjs.renderTestimonialsList({
14641
+ return c.html(chunk3SPQ3J4N_cjs.renderTestimonialsList({
14593
14642
  testimonials: testimonials || [],
14594
14643
  totalCount,
14595
14644
  currentPage,
@@ -14603,7 +14652,7 @@ adminTestimonialsRoutes.get("/", async (c) => {
14603
14652
  } catch (error) {
14604
14653
  console.error("Error fetching testimonials:", error);
14605
14654
  const user = c.get("user");
14606
- return c.html(chunkALOS2CBJ_cjs.renderTestimonialsList({
14655
+ return c.html(chunk3SPQ3J4N_cjs.renderTestimonialsList({
14607
14656
  testimonials: [],
14608
14657
  totalCount: 0,
14609
14658
  currentPage: 1,
@@ -14922,7 +14971,7 @@ function renderCodeExamplesForm(data) {
14922
14971
  </div>
14923
14972
  </div>
14924
14973
 
14925
- ${message ? chunkALOS2CBJ_cjs.renderAlert({ type: messageType || "info", message, dismissible: true }) : ""}
14974
+ ${message ? chunk3SPQ3J4N_cjs.renderAlert({ type: messageType || "info", message, dismissible: true }) : ""}
14926
14975
 
14927
14976
  <!-- Form -->
14928
14977
  <div class="backdrop-blur-xl bg-white/10 rounded-xl border border-white/20 shadow-2xl">
@@ -15192,7 +15241,7 @@ function renderCodeExamplesForm(data) {
15192
15241
  user: data.user,
15193
15242
  content: pageContent
15194
15243
  };
15195
- return chunkALOS2CBJ_cjs.renderAdminLayout(layoutData);
15244
+ return chunk3SPQ3J4N_cjs.renderAdminLayout(layoutData);
15196
15245
  }
15197
15246
  function escapeHtml6(unsafe) {
15198
15247
  return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
@@ -15219,7 +15268,7 @@ adminCodeExamplesRoutes.get("/", async (c) => {
15219
15268
  const offset = (currentPage - 1) * limit;
15220
15269
  const db = c.env?.DB;
15221
15270
  if (!db) {
15222
- return c.html(chunkALOS2CBJ_cjs.renderCodeExamplesList({
15271
+ return c.html(chunk3SPQ3J4N_cjs.renderCodeExamplesList({
15223
15272
  codeExamples: [],
15224
15273
  totalCount: 0,
15225
15274
  currentPage: 1,
@@ -15259,7 +15308,7 @@ adminCodeExamplesRoutes.get("/", async (c) => {
15259
15308
  `;
15260
15309
  const { results: codeExamples } = await db.prepare(dataQuery).bind(...params, limit, offset).all();
15261
15310
  const totalPages = Math.ceil(totalCount / limit);
15262
- return c.html(chunkALOS2CBJ_cjs.renderCodeExamplesList({
15311
+ return c.html(chunk3SPQ3J4N_cjs.renderCodeExamplesList({
15263
15312
  codeExamples: codeExamples || [],
15264
15313
  totalCount,
15265
15314
  currentPage,
@@ -15273,7 +15322,7 @@ adminCodeExamplesRoutes.get("/", async (c) => {
15273
15322
  } catch (error) {
15274
15323
  console.error("Error fetching code examples:", error);
15275
15324
  const user = c.get("user");
15276
- return c.html(chunkALOS2CBJ_cjs.renderCodeExamplesList({
15325
+ return c.html(chunk3SPQ3J4N_cjs.renderCodeExamplesList({
15277
15326
  codeExamples: [],
15278
15327
  totalCount: 0,
15279
15328
  currentPage: 1,
@@ -15662,7 +15711,7 @@ function renderDashboardPage(data) {
15662
15711
  version: data.version,
15663
15712
  content: pageContent
15664
15713
  };
15665
- return chunkALOS2CBJ_cjs.renderAdminLayout(layoutData);
15714
+ return chunk3SPQ3J4N_cjs.renderAdminLayout(layoutData);
15666
15715
  }
15667
15716
  function renderStatsCards(stats) {
15668
15717
  const cards = [
@@ -16210,7 +16259,7 @@ function renderStorageUsage(databaseSizeBytes, mediaSizeBytes) {
16210
16259
  }
16211
16260
 
16212
16261
  // src/routes/admin-dashboard.ts
16213
- var VERSION = chunkUL32L2KV_cjs.getCoreVersion();
16262
+ var VERSION = chunkBRPONFW6_cjs.getCoreVersion();
16214
16263
  var router = new hono.Hono();
16215
16264
  router.use("*", chunk4BJGEGX5_cjs.requireAuth());
16216
16265
  router.get("/", async (c) => {
@@ -16251,7 +16300,7 @@ router.get("/stats", async (c) => {
16251
16300
  }
16252
16301
  let contentCount = 0;
16253
16302
  try {
16254
- const contentStmt = db.prepare("SELECT COUNT(*) as count FROM content WHERE deleted_at IS NULL");
16303
+ const contentStmt = db.prepare("SELECT COUNT(*) as count FROM content");
16255
16304
  const contentResult = await contentStmt.first();
16256
16305
  contentCount = contentResult?.count || 0;
16257
16306
  } catch (error) {
@@ -16437,7 +16486,7 @@ router.get("/system-status", async (c) => {
16437
16486
  });
16438
16487
 
16439
16488
  // src/templates/pages/admin-collections-list.template.ts
16440
- chunkALOS2CBJ_cjs.init_admin_layout_catalyst_template();
16489
+ chunk3SPQ3J4N_cjs.init_admin_layout_catalyst_template();
16441
16490
 
16442
16491
  // src/templates/components/table.template.ts
16443
16492
  function renderTable2(data) {
@@ -16911,11 +16960,11 @@ function renderCollectionsListPage(data) {
16911
16960
  version: data.version,
16912
16961
  content: pageContent
16913
16962
  };
16914
- return chunkALOS2CBJ_cjs.renderAdminLayoutCatalyst(layoutData);
16963
+ return chunk3SPQ3J4N_cjs.renderAdminLayoutCatalyst(layoutData);
16915
16964
  }
16916
16965
 
16917
16966
  // src/templates/pages/admin-collections-form.template.ts
16918
- chunkALOS2CBJ_cjs.init_admin_layout_catalyst_template();
16967
+ chunk3SPQ3J4N_cjs.init_admin_layout_catalyst_template();
16919
16968
  function renderCollectionFormPage(data) {
16920
16969
  const isEdit = data.isEdit || !!data.id;
16921
16970
  const title = isEdit ? "Edit Collection" : "Create New Collection";
@@ -17144,7 +17193,7 @@ function renderCollectionFormPage(data) {
17144
17193
  }
17145
17194
  </style>
17146
17195
 
17147
- ${chunkALOS2CBJ_cjs.renderForm(formData)}
17196
+ ${chunk3SPQ3J4N_cjs.renderForm(formData)}
17148
17197
 
17149
17198
  ${isEdit && !data.managed ? `
17150
17199
  <!-- Fields Management Section -->
@@ -17688,7 +17737,7 @@ function renderCollectionFormPage(data) {
17688
17737
  version: data.version,
17689
17738
  content: pageContent
17690
17739
  };
17691
- return chunkALOS2CBJ_cjs.renderAdminLayoutCatalyst(layoutData);
17740
+ return chunk3SPQ3J4N_cjs.renderAdminLayoutCatalyst(layoutData);
17692
17741
  }
17693
17742
 
17694
17743
  // src/routes/admin-collections.ts
@@ -17847,11 +17896,13 @@ adminCollectionsRoutes.post("/", async (c) => {
17847
17896
  now,
17848
17897
  now
17849
17898
  ).run();
17850
- try {
17851
- await c.env.CACHE_KV.delete("cache:collections:all");
17852
- await c.env.CACHE_KV.delete(`cache:collection:${name}`);
17853
- } catch (e) {
17854
- console.error("Error clearing cache:", e);
17899
+ if (c.env.CACHE_KV) {
17900
+ try {
17901
+ await c.env.CACHE_KV.delete("cache:collections:all");
17902
+ await c.env.CACHE_KV.delete(`cache:collection:${name}`);
17903
+ } catch (e) {
17904
+ console.error("Error clearing cache:", e);
17905
+ }
17855
17906
  }
17856
17907
  if (isHtmx) {
17857
17908
  return c.html(html.html`
@@ -18123,7 +18174,7 @@ adminCollectionsRoutes.post("/:collectionId/fields/reorder", async (c) => {
18123
18174
  });
18124
18175
 
18125
18176
  // src/templates/pages/admin-settings.template.ts
18126
- chunkALOS2CBJ_cjs.init_admin_layout_catalyst_template();
18177
+ chunk3SPQ3J4N_cjs.init_admin_layout_catalyst_template();
18127
18178
  function renderSettingsPage(data) {
18128
18179
  const activeTab = data.activeTab || "general";
18129
18180
  const pageContent = `
@@ -18224,7 +18275,7 @@ function renderSettingsPage(data) {
18224
18275
  // Migration functions
18225
18276
  window.refreshMigrationStatus = async function() {
18226
18277
  try {
18227
- const response = await fetch('/admin/api/migrations/status');
18278
+ const response = await fetch('/admin/settings/api/migrations/status');
18228
18279
  const result = await response.json();
18229
18280
 
18230
18281
  if (result.success) {
@@ -18252,7 +18303,7 @@ function renderSettingsPage(data) {
18252
18303
  btn.innerHTML = 'Running...';
18253
18304
 
18254
18305
  try {
18255
- const response = await fetch('/admin/api/migrations/run', {
18306
+ const response = await fetch('/admin/settings/api/migrations/run', {
18256
18307
  method: 'POST'
18257
18308
  });
18258
18309
  const result = await response.json();
@@ -18273,7 +18324,7 @@ function renderSettingsPage(data) {
18273
18324
 
18274
18325
  window.validateSchema = async function() {
18275
18326
  try {
18276
- const response = await fetch('/admin/api/migrations/validate');
18327
+ const response = await fetch('/admin/settings/api/migrations/validate');
18277
18328
  const result = await response.json();
18278
18329
 
18279
18330
  if (result.success) {
@@ -18351,7 +18402,7 @@ function renderSettingsPage(data) {
18351
18402
  // Database Tools functions
18352
18403
  window.refreshDatabaseStats = async function() {
18353
18404
  try {
18354
- const response = await fetch('/admin/database-tools/api/stats');
18405
+ const response = await fetch('/admin/settings/api/database-tools/stats');
18355
18406
  const result = await response.json();
18356
18407
 
18357
18408
  if (result.success) {
@@ -18372,7 +18423,7 @@ function renderSettingsPage(data) {
18372
18423
  btn.innerHTML = 'Creating Backup...';
18373
18424
 
18374
18425
  try {
18375
- const response = await fetch('/admin/database-tools/api/backup', {
18426
+ const response = await fetch('/admin/settings/api/database-tools/backup', {
18376
18427
  method: 'POST'
18377
18428
  });
18378
18429
  const result = await response.json();
@@ -18411,7 +18462,7 @@ function renderSettingsPage(data) {
18411
18462
  btn.innerHTML = 'Truncating...';
18412
18463
 
18413
18464
  try {
18414
- const response = await fetch('/admin/database-tools/api/truncate', {
18465
+ const response = await fetch('/admin/settings/api/database-tools/truncate', {
18415
18466
  method: 'POST',
18416
18467
  headers: {
18417
18468
  'Content-Type': 'application/json'
@@ -18442,7 +18493,7 @@ function renderSettingsPage(data) {
18442
18493
 
18443
18494
  window.validateDatabase = async function() {
18444
18495
  try {
18445
- const response = await fetch('/admin/database-tools/api/validate');
18496
+ const response = await fetch('/admin/settings/api/database-tools/validate');
18446
18497
  const result = await response.json();
18447
18498
 
18448
18499
  if (result.success) {
@@ -18533,7 +18584,7 @@ function renderSettingsPage(data) {
18533
18584
  version: data.version,
18534
18585
  content: pageContent
18535
18586
  };
18536
- return chunkALOS2CBJ_cjs.renderAdminLayoutCatalyst(layoutData);
18587
+ return chunk3SPQ3J4N_cjs.renderAdminLayoutCatalyst(layoutData);
18537
18588
  }
18538
18589
  function renderTabButton(tabId, label, iconPath, activeTab) {
18539
18590
  const isActive = activeTab === tabId;
@@ -19296,7 +19347,7 @@ function renderMigrationSettings(settings) {
19296
19347
  if (typeof refreshMigrationStatus === 'undefined') {
19297
19348
  window.refreshMigrationStatus = async function() {
19298
19349
  try {
19299
- const response = await fetch('/admin/api/migrations/status');
19350
+ const response = await fetch('/admin/settings/api/migrations/status');
19300
19351
  const result = await response.json();
19301
19352
 
19302
19353
  if (result.success) {
@@ -19769,6 +19820,138 @@ adminSettingsRoutes.get("/api/migrations/validate", async (c) => {
19769
19820
  }, 500);
19770
19821
  }
19771
19822
  });
19823
+ adminSettingsRoutes.get("/api/database-tools/stats", async (c) => {
19824
+ try {
19825
+ const db = c.env.DB;
19826
+ const tablesQuery = await db.prepare(`
19827
+ SELECT name FROM sqlite_master
19828
+ WHERE type='table'
19829
+ AND name NOT LIKE 'sqlite_%'
19830
+ AND name NOT LIKE '_cf_%'
19831
+ ORDER BY name
19832
+ `).all();
19833
+ const tables = tablesQuery.results || [];
19834
+ let totalRows = 0;
19835
+ const tableStats = await Promise.all(
19836
+ tables.map(async (table) => {
19837
+ try {
19838
+ const countResult = await db.prepare(`SELECT COUNT(*) as count FROM ${table.name}`).first();
19839
+ const rowCount = countResult?.count || 0;
19840
+ totalRows += rowCount;
19841
+ return {
19842
+ name: table.name,
19843
+ rowCount
19844
+ };
19845
+ } catch (error) {
19846
+ console.error(`Error counting rows in ${table.name}:`, error);
19847
+ return {
19848
+ name: table.name,
19849
+ rowCount: 0
19850
+ };
19851
+ }
19852
+ })
19853
+ );
19854
+ const estimatedSizeBytes = totalRows * 1024;
19855
+ const databaseSizeMB = (estimatedSizeBytes / (1024 * 1024)).toFixed(2);
19856
+ return c.json({
19857
+ success: true,
19858
+ data: {
19859
+ totalTables: tables.length,
19860
+ totalRows,
19861
+ databaseSize: `${databaseSizeMB} MB (estimated)`,
19862
+ tables: tableStats
19863
+ }
19864
+ });
19865
+ } catch (error) {
19866
+ console.error("Error fetching database stats:", error);
19867
+ return c.json({
19868
+ success: false,
19869
+ error: "Failed to fetch database statistics"
19870
+ }, 500);
19871
+ }
19872
+ });
19873
+ adminSettingsRoutes.get("/api/database-tools/validate", async (c) => {
19874
+ try {
19875
+ const db = c.env.DB;
19876
+ const integrityResult = await db.prepare("PRAGMA integrity_check").first();
19877
+ const isValid = integrityResult?.integrity_check === "ok";
19878
+ return c.json({
19879
+ success: true,
19880
+ data: {
19881
+ valid: isValid,
19882
+ message: isValid ? "Database integrity check passed" : "Database integrity check failed"
19883
+ }
19884
+ });
19885
+ } catch (error) {
19886
+ console.error("Error validating database:", error);
19887
+ return c.json({
19888
+ success: false,
19889
+ error: "Failed to validate database"
19890
+ }, 500);
19891
+ }
19892
+ });
19893
+ adminSettingsRoutes.post("/api/database-tools/backup", async (c) => {
19894
+ try {
19895
+ const user = c.get("user");
19896
+ if (!user || user.role !== "admin") {
19897
+ return c.json({
19898
+ success: false,
19899
+ error: "Unauthorized. Admin access required."
19900
+ }, 403);
19901
+ }
19902
+ return c.json({
19903
+ success: true,
19904
+ message: "Database backup feature coming soon. Use Cloudflare Dashboard for backups."
19905
+ });
19906
+ } catch (error) {
19907
+ console.error("Error creating backup:", error);
19908
+ return c.json({
19909
+ success: false,
19910
+ error: "Failed to create backup"
19911
+ }, 500);
19912
+ }
19913
+ });
19914
+ adminSettingsRoutes.post("/api/database-tools/truncate", async (c) => {
19915
+ try {
19916
+ const user = c.get("user");
19917
+ if (!user || user.role !== "admin") {
19918
+ return c.json({
19919
+ success: false,
19920
+ error: "Unauthorized. Admin access required."
19921
+ }, 403);
19922
+ }
19923
+ const body = await c.req.json();
19924
+ const tablesToTruncate = body.tables || [];
19925
+ if (!Array.isArray(tablesToTruncate) || tablesToTruncate.length === 0) {
19926
+ return c.json({
19927
+ success: false,
19928
+ error: "No tables specified for truncation"
19929
+ }, 400);
19930
+ }
19931
+ const db = c.env.DB;
19932
+ const results = [];
19933
+ for (const tableName of tablesToTruncate) {
19934
+ try {
19935
+ await db.prepare(`DELETE FROM ${tableName}`).run();
19936
+ results.push({ table: tableName, success: true });
19937
+ } catch (error) {
19938
+ console.error(`Error truncating ${tableName}:`, error);
19939
+ results.push({ table: tableName, success: false, error: String(error) });
19940
+ }
19941
+ }
19942
+ return c.json({
19943
+ success: true,
19944
+ message: `Truncated ${results.filter((r) => r.success).length} of ${tablesToTruncate.length} tables`,
19945
+ results
19946
+ });
19947
+ } catch (error) {
19948
+ console.error("Error truncating tables:", error);
19949
+ return c.json({
19950
+ success: false,
19951
+ error: "Failed to truncate tables"
19952
+ }, 500);
19953
+ }
19954
+ });
19772
19955
  adminSettingsRoutes.post("/", async (c) => {
19773
19956
  try {
19774
19957
  const formData = await c.req.formData();
@@ -19840,5 +20023,5 @@ exports.api_system_default = api_system_default;
19840
20023
  exports.auth_default = auth_default;
19841
20024
  exports.router = router;
19842
20025
  exports.userRoutes = userRoutes;
19843
- //# sourceMappingURL=chunk-7G6XT62S.cjs.map
19844
- //# sourceMappingURL=chunk-7G6XT62S.cjs.map
20026
+ //# sourceMappingURL=chunk-RZW752PE.cjs.map
20027
+ //# sourceMappingURL=chunk-RZW752PE.cjs.map