@sonicjs-cms/core 2.10.0 → 2.10.1

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 (60) hide show
  1. package/dist/{chunk-IT2TC4ZD.cjs → chunk-5GO3AMON.cjs} +13 -7
  2. package/dist/chunk-5GO3AMON.cjs.map +1 -0
  3. package/dist/{chunk-27AOVQTR.js → chunk-BUPNX3ZM.js} +367 -3
  4. package/dist/chunk-BUPNX3ZM.js.map +1 -0
  5. package/dist/{chunk-EKPLKUZT.cjs → chunk-E2GKK5HX.cjs} +3 -3
  6. package/dist/{chunk-EKPLKUZT.cjs.map → chunk-E2GKK5HX.cjs.map} +1 -1
  7. package/dist/{chunk-ZMVWMJ3S.cjs → chunk-EAJJHE5F.cjs} +9 -2
  8. package/dist/chunk-EAJJHE5F.cjs.map +1 -0
  9. package/dist/{chunk-6O3RJV3C.js → chunk-FW5CGNM2.js} +9 -2
  10. package/dist/chunk-FW5CGNM2.js.map +1 -0
  11. package/dist/{chunk-RCA6R6VE.cjs → chunk-HGKBMUYY.cjs} +174 -148
  12. package/dist/chunk-HGKBMUYY.cjs.map +1 -0
  13. package/dist/{chunk-4TTMQQC7.js → chunk-JFMBYQTC.js} +10 -4
  14. package/dist/chunk-JFMBYQTC.js.map +1 -0
  15. package/dist/{chunk-64APW3DW.cjs → chunk-LFAQUR7P.cjs} +9 -2
  16. package/dist/chunk-LFAQUR7P.cjs.map +1 -0
  17. package/dist/{chunk-JTNUM7JE.js → chunk-SDAGUFOF.js} +46 -20
  18. package/dist/chunk-SDAGUFOF.js.map +1 -0
  19. package/dist/{chunk-IIBRG5S5.cjs → chunk-TWCQVJ6M.cjs} +373 -2
  20. package/dist/chunk-TWCQVJ6M.cjs.map +1 -0
  21. package/dist/{chunk-7JMMLHPQ.js → chunk-VJCLJH3X.js} +9 -2
  22. package/dist/chunk-VJCLJH3X.js.map +1 -0
  23. package/dist/{chunk-IZWNIUJI.js → chunk-YXTFJPMN.js} +3 -3
  24. package/dist/{chunk-IZWNIUJI.js.map → chunk-YXTFJPMN.js.map} +1 -1
  25. package/dist/index.cjs +170 -142
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +2 -2
  28. package/dist/index.d.ts +2 -2
  29. package/dist/index.js +10 -10
  30. package/dist/index.js.map +1 -1
  31. package/dist/middleware.cjs +29 -29
  32. package/dist/middleware.js +3 -3
  33. package/dist/migrations-ADK6YNM2.js +4 -0
  34. package/dist/{migrations-N2C2VPJU.js.map → migrations-ADK6YNM2.js.map} +1 -1
  35. package/dist/migrations-EM2D6EG2.cjs +13 -0
  36. package/dist/{migrations-ONIAY6GK.cjs.map → migrations-EM2D6EG2.cjs.map} +1 -1
  37. package/dist/{plugin-bootstrap-fpG98Otb.d.cts → plugin-bootstrap-B8PXeGj_.d.cts} +229 -1
  38. package/dist/{plugin-bootstrap-WmpvYM5w.d.ts → plugin-bootstrap-CD63DZ-p.d.ts} +229 -1
  39. package/dist/routes.cjs +29 -29
  40. package/dist/routes.js +6 -6
  41. package/dist/services.cjs +60 -32
  42. package/dist/services.d.cts +1 -1
  43. package/dist/services.d.ts +1 -1
  44. package/dist/services.js +3 -3
  45. package/dist/utils.cjs +11 -11
  46. package/dist/utils.js +1 -1
  47. package/migrations/033_form_content_integration.sql +19 -0
  48. package/package.json +1 -1
  49. package/dist/chunk-27AOVQTR.js.map +0 -1
  50. package/dist/chunk-4TTMQQC7.js.map +0 -1
  51. package/dist/chunk-64APW3DW.cjs.map +0 -1
  52. package/dist/chunk-6O3RJV3C.js.map +0 -1
  53. package/dist/chunk-7JMMLHPQ.js.map +0 -1
  54. package/dist/chunk-IIBRG5S5.cjs.map +0 -1
  55. package/dist/chunk-IT2TC4ZD.cjs.map +0 -1
  56. package/dist/chunk-JTNUM7JE.js.map +0 -1
  57. package/dist/chunk-RCA6R6VE.cjs.map +0 -1
  58. package/dist/chunk-ZMVWMJ3S.cjs.map +0 -1
  59. package/dist/migrations-N2C2VPJU.js +0 -4
  60. package/dist/migrations-ONIAY6GK.cjs +0 -13
@@ -1,10 +1,10 @@
1
- import { getCacheService, CACHE_CONFIGS, getLogger, SettingsService, getAppInstance, buildRouteList, CATEGORY_INFO } from './chunk-7JMMLHPQ.js';
2
- import { requireAuth, requireRole, isPluginActive, optionalAuth, rateLimit, AuthManager, logActivity, generateCsrfToken } from './chunk-4TTMQQC7.js';
3
- import { PluginService } from './chunk-27AOVQTR.js';
4
- import { MigrationService } from './chunk-6O3RJV3C.js';
1
+ import { getCacheService, CACHE_CONFIGS, getLogger, SettingsService, getAppInstance, buildRouteList, CATEGORY_INFO } from './chunk-VJCLJH3X.js';
2
+ import { requireAuth, requireRole, isPluginActive, optionalAuth, rateLimit, AuthManager, logActivity, generateCsrfToken } from './chunk-JFMBYQTC.js';
3
+ import { PluginService, createContentFromSubmission } from './chunk-BUPNX3ZM.js';
4
+ import { MigrationService } from './chunk-FW5CGNM2.js';
5
5
  import { init_admin_layout_catalyst_template, renderDesignPage, renderCheckboxPage, renderTestimonialsList, renderCodeExamplesList, renderAlert, renderTable, renderPagination, renderConfirmationDialog, getConfirmationDialogScript, renderAdminLayoutCatalyst, renderAdminLayout, adminLayoutV2, renderForm } from './chunk-JJS7JZCH.js';
6
6
  import { PluginBuilder, TurnstileService } from './chunk-J5WGMRSU.js';
7
- import { QueryFilterBuilder, getCoreVersion, getBlocksFieldConfig, parseBlocksValue } from './chunk-IZWNIUJI.js';
7
+ import { QueryFilterBuilder, getCoreVersion, getBlocksFieldConfig, parseBlocksValue } from './chunk-YXTFJPMN.js';
8
8
  import { metricsTracker } from './chunk-FICTAGD4.js';
9
9
  import { escapeHtml, sanitizeRichText, sanitizeInput } from './chunk-TQABQWOP.js';
10
10
  import { Hono } from 'hono';
@@ -748,7 +748,7 @@ apiRoutes.get("/collections", async (c) => {
748
748
  }
749
749
  c.header("X-Cache-Status", "MISS");
750
750
  c.header("X-Cache-Source", "database");
751
- const stmt = db.prepare("SELECT * FROM collections WHERE is_active = 1");
751
+ const stmt = db.prepare("SELECT * FROM collections WHERE is_active = 1 AND (source_type IS NULL OR source_type = 'user')");
752
752
  const { results } = await stmt.all();
753
753
  const transformedResults = results.map((row) => ({
754
754
  ...row,
@@ -1777,7 +1777,7 @@ adminApiRoutes.get("/stats", async (c) => {
1777
1777
  const db = c.env.DB;
1778
1778
  let collectionsCount = 0;
1779
1779
  try {
1780
- const collectionsStmt = db.prepare("SELECT COUNT(*) as count FROM collections WHERE is_active = 1");
1780
+ const collectionsStmt = db.prepare("SELECT COUNT(*) as count FROM collections WHERE is_active = 1 AND (source_type IS NULL OR source_type = 'user')");
1781
1781
  const collectionsResult = await collectionsStmt.first();
1782
1782
  collectionsCount = collectionsResult?.count || 0;
1783
1783
  } catch (error) {
@@ -1785,7 +1785,7 @@ adminApiRoutes.get("/stats", async (c) => {
1785
1785
  }
1786
1786
  let contentCount = 0;
1787
1787
  try {
1788
- const contentStmt = db.prepare("SELECT COUNT(*) as count FROM content WHERE deleted_at IS NULL");
1788
+ const contentStmt = db.prepare("SELECT COUNT(*) as count FROM content c JOIN collections col ON c.collection_id = col.id WHERE c.deleted_at IS NULL AND (col.source_type IS NULL OR col.source_type = 'user')");
1789
1789
  const contentResult = await contentStmt.first();
1790
1790
  contentCount = contentResult?.count || 0;
1791
1791
  } catch (error) {
@@ -1927,6 +1927,7 @@ adminApiRoutes.get("/collections", async (c) => {
1927
1927
  SELECT id, name, display_name, description, created_at, updated_at, is_active, managed
1928
1928
  FROM collections
1929
1929
  WHERE ${includeInactive ? "1=1" : "is_active = 1"}
1930
+ AND (source_type IS NULL OR source_type = 'user')
1930
1931
  AND (name LIKE ? OR display_name LIKE ? OR description LIKE ?)
1931
1932
  ORDER BY created_at DESC
1932
1933
  `);
@@ -1937,7 +1938,8 @@ adminApiRoutes.get("/collections", async (c) => {
1937
1938
  stmt = db.prepare(`
1938
1939
  SELECT id, name, display_name, description, created_at, updated_at, is_active, managed
1939
1940
  FROM collections
1940
- ${includeInactive ? "" : "WHERE is_active = 1"}
1941
+ WHERE (source_type IS NULL OR source_type = 'user')
1942
+ ${includeInactive ? "" : "AND is_active = 1"}
1941
1943
  ORDER BY created_at DESC
1942
1944
  `);
1943
1945
  const queryResults = await stmt.all();
@@ -2281,7 +2283,7 @@ adminApiRoutes.delete("/collections/:id", async (c) => {
2281
2283
  });
2282
2284
  adminApiRoutes.get("/migrations/status", async (c) => {
2283
2285
  try {
2284
- const { MigrationService: MigrationService2 } = await import('./migrations-N2C2VPJU.js');
2286
+ const { MigrationService: MigrationService2 } = await import('./migrations-ADK6YNM2.js');
2285
2287
  const db = c.env.DB;
2286
2288
  const migrationService = new MigrationService2(db);
2287
2289
  const status = await migrationService.getMigrationStatus();
@@ -2306,7 +2308,7 @@ adminApiRoutes.post("/migrations/run", async (c) => {
2306
2308
  error: "Unauthorized. Admin access required."
2307
2309
  }, 403);
2308
2310
  }
2309
- const { MigrationService: MigrationService2 } = await import('./migrations-N2C2VPJU.js');
2311
+ const { MigrationService: MigrationService2 } = await import('./migrations-ADK6YNM2.js');
2310
2312
  const db = c.env.DB;
2311
2313
  const migrationService = new MigrationService2(db);
2312
2314
  const result = await migrationService.runPendingMigrations();
@@ -2325,7 +2327,7 @@ adminApiRoutes.post("/migrations/run", async (c) => {
2325
2327
  });
2326
2328
  adminApiRoutes.get("/migrations/validate", async (c) => {
2327
2329
  try {
2328
- const { MigrationService: MigrationService2 } = await import('./migrations-N2C2VPJU.js');
2330
+ const { MigrationService: MigrationService2 } = await import('./migrations-ADK6YNM2.js');
2329
2331
  const db = c.env.DB;
2330
2332
  const migrationService = new MigrationService2(db);
2331
2333
  const validation = await migrationService.validateSchema();
@@ -9357,7 +9359,7 @@ adminContentRoutes.get("/", async (c) => {
9357
9359
  const status = url.searchParams.get("status") || "all";
9358
9360
  const search = url.searchParams.get("search") || "";
9359
9361
  const offset = (page - 1) * limit;
9360
- const collectionsStmt = db.prepare("SELECT id, name, display_name FROM collections WHERE is_active = 1 ORDER BY display_name");
9362
+ const collectionsStmt = db.prepare("SELECT id, name, display_name FROM collections WHERE is_active = 1 AND (source_type IS NULL OR source_type = 'user') ORDER BY display_name");
9361
9363
  const { results: collectionsResults } = await collectionsStmt.all();
9362
9364
  const models = (collectionsResults || []).map((row) => ({
9363
9365
  name: row.name,
@@ -9365,6 +9367,7 @@ adminContentRoutes.get("/", async (c) => {
9365
9367
  }));
9366
9368
  const conditions = [];
9367
9369
  const params = [];
9370
+ conditions.push("(col.source_type IS NULL OR col.source_type = 'user')");
9368
9371
  if (status !== "deleted") {
9369
9372
  conditions.push("c.status != 'deleted'");
9370
9373
  }
@@ -9493,7 +9496,7 @@ adminContentRoutes.get("/new", async (c) => {
9493
9496
  const collectionId = url.searchParams.get("collection");
9494
9497
  if (!collectionId) {
9495
9498
  const db2 = c.env.DB;
9496
- const collectionsStmt = db2.prepare("SELECT id, name, display_name, description FROM collections WHERE is_active = 1 ORDER BY display_name");
9499
+ const collectionsStmt = db2.prepare("SELECT id, name, display_name, description FROM collections WHERE is_active = 1 AND (source_type IS NULL OR source_type = 'user') ORDER BY display_name");
9497
9500
  const { results } = await collectionsStmt.all();
9498
9501
  const collections = (results || []).map((row) => ({
9499
9502
  id: row.id,
@@ -21524,7 +21527,7 @@ router.get("/stats", async (c) => {
21524
21527
  const db = c.env.DB;
21525
21528
  let collectionsCount = 0;
21526
21529
  try {
21527
- const collectionsStmt = db.prepare("SELECT COUNT(*) as count FROM collections WHERE is_active = 1");
21530
+ const collectionsStmt = db.prepare("SELECT COUNT(*) as count FROM collections WHERE is_active = 1 AND (source_type IS NULL OR source_type = 'user')");
21528
21531
  const collectionsResult = await collectionsStmt.first();
21529
21532
  collectionsCount = collectionsResult?.count || 0;
21530
21533
  } catch (error) {
@@ -21532,7 +21535,7 @@ router.get("/stats", async (c) => {
21532
21535
  }
21533
21536
  let contentCount = 0;
21534
21537
  try {
21535
- const contentStmt = db.prepare("SELECT COUNT(*) as count FROM content");
21538
+ const contentStmt = db.prepare("SELECT COUNT(*) as count FROM content c JOIN collections col ON c.collection_id = col.id WHERE (col.source_type IS NULL OR col.source_type = 'user')");
21536
21539
  const contentResult = await contentStmt.first();
21537
21540
  contentCount = contentResult?.count || 0;
21538
21541
  } catch (error) {
@@ -23329,6 +23332,7 @@ adminCollectionsRoutes.get("/", async (c) => {
23329
23332
  SELECT id, name, display_name, description, created_at, managed, schema
23330
23333
  FROM collections
23331
23334
  WHERE is_active = 1
23335
+ AND (source_type IS NULL OR source_type = 'user')
23332
23336
  AND (name LIKE ? OR display_name LIKE ? OR description LIKE ?)
23333
23337
  ORDER BY created_at DESC
23334
23338
  `);
@@ -23336,7 +23340,7 @@ adminCollectionsRoutes.get("/", async (c) => {
23336
23340
  const queryResults = await stmt.bind(searchParam, searchParam, searchParam).all();
23337
23341
  results = queryResults.results;
23338
23342
  } else {
23339
- stmt = db.prepare("SELECT id, name, display_name, description, created_at, managed, schema FROM collections WHERE is_active = 1 ORDER BY created_at DESC");
23343
+ stmt = db.prepare("SELECT id, name, display_name, description, created_at, managed, schema FROM collections WHERE is_active = 1 AND (source_type IS NULL OR source_type = 'user') ORDER BY created_at DESC");
23340
23344
  const queryResults = await stmt.all();
23341
23345
  results = queryResults.results;
23342
23346
  }
@@ -28408,14 +28412,36 @@ publicFormsRoutes.post("/:identifier/submit", async (c) => {
28408
28412
  now
28409
28413
  ).run();
28410
28414
  await db.prepare(`
28411
- UPDATE forms
28415
+ UPDATE forms
28412
28416
  SET submission_count = submission_count + 1,
28413
28417
  updated_at = ?
28414
28418
  WHERE id = ?
28415
28419
  `).bind(now, form.id).run();
28420
+ let contentId = null;
28421
+ try {
28422
+ contentId = await createContentFromSubmission(
28423
+ db,
28424
+ sanitizedData,
28425
+ { id: form.id, name: form.name, display_name: form.display_name },
28426
+ submissionId,
28427
+ {
28428
+ ipAddress: c.req.header("cf-connecting-ip") || null,
28429
+ userAgent: c.req.header("user-agent") || null,
28430
+ userEmail: sanitizedData?.email || null,
28431
+ userId: null
28432
+ // anonymous submission
28433
+ }
28434
+ );
28435
+ if (!contentId) {
28436
+ console.warn("[FormSubmit] Content creation returned null for submission:", submissionId);
28437
+ }
28438
+ } catch (contentError) {
28439
+ console.error("[FormSubmit] Error creating content from submission:", contentError);
28440
+ }
28416
28441
  return c.json({
28417
28442
  success: true,
28418
28443
  submissionId,
28444
+ contentId,
28419
28445
  message: "Form submitted successfully"
28420
28446
  });
28421
28447
  } catch (error) {
@@ -28826,5 +28852,5 @@ var ROUTES_INFO = {
28826
28852
  };
28827
28853
 
28828
28854
  export { ROUTES_INFO, adminCheckboxRoutes, adminCollectionsRoutes, adminDesignRoutes, adminFormsRoutes, adminLogsRoutes, adminMediaRoutes, adminPluginRoutes, adminSettingsRoutes, admin_api_default, admin_code_examples_default, admin_content_default, admin_testimonials_default, api_content_crud_default, api_default, api_media_default, api_system_default, auth_default, getConfirmationDialogScript2 as getConfirmationDialogScript, public_forms_default, renderConfirmationDialog2 as renderConfirmationDialog, router, router2, test_cleanup_default, userRoutes };
28829
- //# sourceMappingURL=chunk-JTNUM7JE.js.map
28830
- //# sourceMappingURL=chunk-JTNUM7JE.js.map
28855
+ //# sourceMappingURL=chunk-SDAGUFOF.js.map
28856
+ //# sourceMappingURL=chunk-SDAGUFOF.js.map