@sonicjs-cms/core 2.3.12 → 2.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-EIE35JCC.js → chunk-2NTBZ2Y7.js} +3 -3
- package/dist/{chunk-EIE35JCC.js.map → chunk-2NTBZ2Y7.js.map} +1 -1
- package/dist/{chunk-OJ5WUCSH.cjs → chunk-5NCBFP37.cjs} +4 -4
- package/dist/{chunk-OJ5WUCSH.cjs.map → chunk-5NCBFP37.cjs.map} +1 -1
- package/dist/{chunk-HTJLBF6F.cjs → chunk-ARLXQU2S.cjs} +247 -165
- package/dist/chunk-ARLXQU2S.cjs.map +1 -0
- package/dist/{chunk-KQCYQKSV.js → chunk-DN45O5XV.js} +2 -2
- package/dist/chunk-DN45O5XV.js.map +1 -0
- package/dist/{chunk-REY542YK.js → chunk-F56JKQTA.js} +3 -3
- package/dist/{chunk-REY542YK.js.map → chunk-F56JKQTA.js.map} +1 -1
- package/dist/{chunk-74RYBO6J.js → chunk-FHCN7KR2.js} +10 -5
- package/dist/chunk-FHCN7KR2.js.map +1 -0
- package/dist/{chunk-RIOIKM3Y.cjs → chunk-MF7DWI5P.cjs} +2 -2
- package/dist/chunk-MF7DWI5P.cjs.map +1 -0
- package/dist/{chunk-HDSRB23N.js → chunk-RP66TPEJ.js} +101 -19
- package/dist/chunk-RP66TPEJ.js.map +1 -0
- package/dist/{chunk-NTXPL746.js → chunk-VMEBHBYY.js} +34 -2
- package/dist/chunk-VMEBHBYY.js.map +1 -0
- package/dist/{chunk-IB6UBZVD.cjs → chunk-W2IAEG4W.cjs} +10 -5
- package/dist/chunk-W2IAEG4W.cjs.map +1 -0
- package/dist/{chunk-P6NMVNJJ.cjs → chunk-W4CE7XME.cjs} +34 -2
- package/dist/chunk-W4CE7XME.cjs.map +1 -0
- package/dist/{chunk-K6BFUYJH.cjs → chunk-XR6XACXJ.cjs} +5 -5
- package/dist/{chunk-K6BFUYJH.cjs.map → chunk-XR6XACXJ.cjs.map} +1 -1
- package/dist/index.cjs +87 -87
- package/dist/index.js +10 -10
- package/dist/middleware.cjs +23 -23
- package/dist/middleware.js +2 -2
- package/dist/migrations-43GTELB5.js +4 -0
- package/dist/{migrations-YAFC5JVO.js.map → migrations-43GTELB5.js.map} +1 -1
- package/dist/migrations-ZAYXZXON.cjs +13 -0
- package/dist/{migrations-DQ74P6V4.cjs.map → migrations-ZAYXZXON.cjs.map} +1 -1
- package/dist/routes.cjs +25 -25
- package/dist/routes.js +5 -5
- package/dist/services.cjs +2 -2
- package/dist/services.js +1 -1
- package/dist/templates.cjs +17 -17
- package/dist/templates.js +2 -2
- package/dist/utils.cjs +11 -11
- package/dist/utils.js +1 -1
- package/migrations/025_add_easymde_plugin.sql +25 -0
- package/package.json +8 -3
- package/dist/chunk-74RYBO6J.js.map +0 -1
- package/dist/chunk-HDSRB23N.js.map +0 -1
- package/dist/chunk-HTJLBF6F.cjs.map +0 -1
- package/dist/chunk-IB6UBZVD.cjs.map +0 -1
- package/dist/chunk-KQCYQKSV.js.map +0 -1
- package/dist/chunk-NTXPL746.js.map +0 -1
- package/dist/chunk-P6NMVNJJ.cjs.map +0 -1
- package/dist/chunk-RIOIKM3Y.cjs.map +0 -1
- package/dist/migrations-DQ74P6V4.cjs +0 -13
- package/dist/migrations-YAFC5JVO.js +0 -4
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { getCacheService, CACHE_CONFIGS, getLogger, SettingsService } from './chunk-3YNNVSMC.js';
|
|
2
|
-
import { requireAuth, isPluginActive, requireRole, AuthManager, logActivity } from './chunk-
|
|
2
|
+
import { requireAuth, isPluginActive, requireRole, AuthManager, logActivity } from './chunk-2NTBZ2Y7.js';
|
|
3
3
|
import { PluginService } from './chunk-SGAG6FD3.js';
|
|
4
|
-
import { MigrationService } from './chunk-
|
|
5
|
-
import { init_admin_layout_catalyst_template, renderDesignPage, renderCheckboxPage, renderTestimonialsList, renderCodeExamplesList, renderAlert, renderTable, renderPagination, renderConfirmationDialog, getConfirmationDialogScript, renderAdminLayoutCatalyst, renderAdminLayout, adminLayoutV2, renderForm } from './chunk-
|
|
6
|
-
import { QueryFilterBuilder, sanitizeInput, getCoreVersion, escapeHtml } from './chunk-
|
|
4
|
+
import { MigrationService } from './chunk-VMEBHBYY.js';
|
|
5
|
+
import { init_admin_layout_catalyst_template, renderDesignPage, renderCheckboxPage, renderTestimonialsList, renderCodeExamplesList, renderAlert, renderTable, renderPagination, renderConfirmationDialog, getConfirmationDialogScript, renderAdminLayoutCatalyst, renderAdminLayout, adminLayoutV2, renderForm } from './chunk-DN45O5XV.js';
|
|
6
|
+
import { QueryFilterBuilder, sanitizeInput, getCoreVersion, escapeHtml } from './chunk-FHCN7KR2.js';
|
|
7
7
|
import { metricsTracker } from './chunk-FICTAGD4.js';
|
|
8
8
|
import { Hono } from 'hono';
|
|
9
9
|
import { cors } from 'hono/cors';
|
|
@@ -1569,7 +1569,7 @@ adminApiRoutes.post("/collections", async (c) => {
|
|
|
1569
1569
|
}
|
|
1570
1570
|
const validatedData = validation.data;
|
|
1571
1571
|
const db = c.env.DB;
|
|
1572
|
-
const
|
|
1572
|
+
const _user = c.get("user");
|
|
1573
1573
|
const displayName = validatedData.displayName || validatedData.display_name || "";
|
|
1574
1574
|
const existingStmt = db.prepare("SELECT id FROM collections WHERE name = ?");
|
|
1575
1575
|
const existing = await existingStmt.bind(validatedData.name).first();
|
|
@@ -1720,7 +1720,7 @@ adminApiRoutes.delete("/collections/:id", async (c) => {
|
|
|
1720
1720
|
});
|
|
1721
1721
|
adminApiRoutes.get("/migrations/status", async (c) => {
|
|
1722
1722
|
try {
|
|
1723
|
-
const { MigrationService: MigrationService2 } = await import('./migrations-
|
|
1723
|
+
const { MigrationService: MigrationService2 } = await import('./migrations-43GTELB5.js');
|
|
1724
1724
|
const db = c.env.DB;
|
|
1725
1725
|
const migrationService = new MigrationService2(db);
|
|
1726
1726
|
const status = await migrationService.getMigrationStatus();
|
|
@@ -1745,7 +1745,7 @@ adminApiRoutes.post("/migrations/run", async (c) => {
|
|
|
1745
1745
|
error: "Unauthorized. Admin access required."
|
|
1746
1746
|
}, 403);
|
|
1747
1747
|
}
|
|
1748
|
-
const { MigrationService: MigrationService2 } = await import('./migrations-
|
|
1748
|
+
const { MigrationService: MigrationService2 } = await import('./migrations-43GTELB5.js');
|
|
1749
1749
|
const db = c.env.DB;
|
|
1750
1750
|
const migrationService = new MigrationService2(db);
|
|
1751
1751
|
const result = await migrationService.runPendingMigrations();
|
|
@@ -1764,7 +1764,7 @@ adminApiRoutes.post("/migrations/run", async (c) => {
|
|
|
1764
1764
|
});
|
|
1765
1765
|
adminApiRoutes.get("/migrations/validate", async (c) => {
|
|
1766
1766
|
try {
|
|
1767
|
-
const { MigrationService: MigrationService2 } = await import('./migrations-
|
|
1767
|
+
const { MigrationService: MigrationService2 } = await import('./migrations-43GTELB5.js');
|
|
1768
1768
|
const db = c.env.DB;
|
|
1769
1769
|
const migrationService = new MigrationService2(db);
|
|
1770
1770
|
const validation = await migrationService.validateSchema();
|
|
@@ -6455,10 +6455,9 @@ adminContentRoutes.post("/", async (c) => {
|
|
|
6455
6455
|
const insertStmt = db.prepare(`
|
|
6456
6456
|
INSERT INTO content (
|
|
6457
6457
|
id, collection_id, slug, title, data, status,
|
|
6458
|
-
|
|
6459
|
-
meta_title, meta_description, author_id, created_by, created_at, updated_at
|
|
6458
|
+
author_id, created_at, updated_at
|
|
6460
6459
|
)
|
|
6461
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?,
|
|
6460
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
6462
6461
|
`);
|
|
6463
6462
|
await insertStmt.bind(
|
|
6464
6463
|
contentId,
|
|
@@ -6467,11 +6466,6 @@ adminContentRoutes.post("/", async (c) => {
|
|
|
6467
6466
|
data.title || "Untitled",
|
|
6468
6467
|
JSON.stringify(data),
|
|
6469
6468
|
status,
|
|
6470
|
-
scheduledPublishAt ? new Date(scheduledPublishAt).getTime() : null,
|
|
6471
|
-
scheduledUnpublishAt ? new Date(scheduledUnpublishAt).getTime() : null,
|
|
6472
|
-
data.meta_title || null,
|
|
6473
|
-
data.meta_description || null,
|
|
6474
|
-
user?.userId || "unknown",
|
|
6475
6469
|
user?.userId || "unknown",
|
|
6476
6470
|
now,
|
|
6477
6471
|
now
|
|
@@ -11509,7 +11503,7 @@ adminMediaRoutes.get("/", async (c) => {
|
|
|
11509
11503
|
const type = searchParams.get("type") || "all";
|
|
11510
11504
|
const view = searchParams.get("view") || "grid";
|
|
11511
11505
|
const page = parseInt(searchParams.get("page") || "1");
|
|
11512
|
-
const
|
|
11506
|
+
const _cacheBust = searchParams.get("t");
|
|
11513
11507
|
const limit = 24;
|
|
11514
11508
|
const offset = (page - 1) * limit;
|
|
11515
11509
|
const db = c.env.DB;
|
|
@@ -18957,6 +18951,8 @@ function renderCollectionFormPage(data) {
|
|
|
18957
18951
|
})
|
|
18958
18952
|
.then(data => {
|
|
18959
18953
|
if (data.success) {
|
|
18954
|
+
// Close modal before reloading
|
|
18955
|
+
closeFieldModal();
|
|
18960
18956
|
location.reload();
|
|
18961
18957
|
} else {
|
|
18962
18958
|
alert('Error saving field: ' + (data.error || 'Unknown error'));
|
|
@@ -19507,11 +19503,65 @@ adminCollectionsRoutes.post("/:id/fields", async (c) => {
|
|
|
19507
19503
|
return c.json({ success: false, error: "Field name must contain only lowercase letters, numbers, and underscores." });
|
|
19508
19504
|
}
|
|
19509
19505
|
const db = c.env.DB;
|
|
19506
|
+
const getCollectionStmt = db.prepare("SELECT * FROM collections WHERE id = ?");
|
|
19507
|
+
const collection = await getCollectionStmt.bind(collectionId).first();
|
|
19508
|
+
if (!collection) {
|
|
19509
|
+
return c.json({ success: false, error: "Collection not found." });
|
|
19510
|
+
}
|
|
19511
|
+
let schema = collection.schema ? typeof collection.schema === "string" ? JSON.parse(collection.schema) : collection.schema : null;
|
|
19512
|
+
if (schema && schema.properties && schema.properties[fieldName]) {
|
|
19513
|
+
return c.json({ success: false, error: "A field with this name already exists." });
|
|
19514
|
+
}
|
|
19510
19515
|
const existingStmt = db.prepare("SELECT id FROM content_fields WHERE collection_id = ? AND field_name = ?");
|
|
19511
19516
|
const existing = await existingStmt.bind(collectionId, fieldName).first();
|
|
19512
19517
|
if (existing) {
|
|
19513
19518
|
return c.json({ success: false, error: "A field with this name already exists." });
|
|
19514
19519
|
}
|
|
19520
|
+
let parsedOptions = {};
|
|
19521
|
+
try {
|
|
19522
|
+
parsedOptions = fieldOptions ? JSON.parse(fieldOptions) : {};
|
|
19523
|
+
} catch (e) {
|
|
19524
|
+
console.error("Error parsing field options:", e);
|
|
19525
|
+
}
|
|
19526
|
+
if (schema) {
|
|
19527
|
+
if (!schema.properties) {
|
|
19528
|
+
schema.properties = {};
|
|
19529
|
+
}
|
|
19530
|
+
if (!schema.required) {
|
|
19531
|
+
schema.required = [];
|
|
19532
|
+
}
|
|
19533
|
+
const fieldConfig = {
|
|
19534
|
+
type: fieldType === "number" ? "number" : fieldType === "boolean" ? "boolean" : "string",
|
|
19535
|
+
title: fieldLabel,
|
|
19536
|
+
searchable: isSearchable,
|
|
19537
|
+
...parsedOptions
|
|
19538
|
+
};
|
|
19539
|
+
if (fieldType === "richtext") {
|
|
19540
|
+
fieldConfig.format = "richtext";
|
|
19541
|
+
} else if (fieldType === "date") {
|
|
19542
|
+
fieldConfig.format = "date-time";
|
|
19543
|
+
} else if (fieldType === "select") {
|
|
19544
|
+
fieldConfig.enum = parsedOptions.options || [];
|
|
19545
|
+
} else if (fieldType === "media") {
|
|
19546
|
+
fieldConfig.format = "media";
|
|
19547
|
+
} else if (fieldType === "quill") {
|
|
19548
|
+
fieldConfig.type = "quill";
|
|
19549
|
+
} else if (fieldType === "mdxeditor") {
|
|
19550
|
+
fieldConfig.type = "mdxeditor";
|
|
19551
|
+
}
|
|
19552
|
+
schema.properties[fieldName] = fieldConfig;
|
|
19553
|
+
if (isRequired && !schema.required.includes(fieldName)) {
|
|
19554
|
+
schema.required.push(fieldName);
|
|
19555
|
+
}
|
|
19556
|
+
const updateSchemaStmt = db.prepare(`
|
|
19557
|
+
UPDATE collections
|
|
19558
|
+
SET schema = ?, updated_at = ?
|
|
19559
|
+
WHERE id = ?
|
|
19560
|
+
`);
|
|
19561
|
+
await updateSchemaStmt.bind(JSON.stringify(schema), Date.now(), collectionId).run();
|
|
19562
|
+
console.log("[Add Field] Added field to schema:", fieldName, fieldConfig);
|
|
19563
|
+
return c.json({ success: true, fieldId: `schema-${fieldName}` });
|
|
19564
|
+
}
|
|
19515
19565
|
const orderStmt = db.prepare("SELECT MAX(field_order) as max_order FROM content_fields WHERE collection_id = ?");
|
|
19516
19566
|
const orderResult = await orderStmt.bind(collectionId).first();
|
|
19517
19567
|
const nextOrder = (orderResult?.max_order || 0) + 1;
|
|
@@ -19652,7 +19702,39 @@ adminCollectionsRoutes.put("/:collectionId/fields/:fieldId", async (c) => {
|
|
|
19652
19702
|
adminCollectionsRoutes.delete("/:collectionId/fields/:fieldId", async (c) => {
|
|
19653
19703
|
try {
|
|
19654
19704
|
const fieldId = c.req.param("fieldId");
|
|
19705
|
+
const collectionId = c.req.param("collectionId");
|
|
19655
19706
|
const db = c.env.DB;
|
|
19707
|
+
if (fieldId.startsWith("schema-")) {
|
|
19708
|
+
const fieldName = fieldId.replace("schema-", "");
|
|
19709
|
+
const getCollectionStmt = db.prepare("SELECT * FROM collections WHERE id = ?");
|
|
19710
|
+
const collection = await getCollectionStmt.bind(collectionId).first();
|
|
19711
|
+
if (!collection) {
|
|
19712
|
+
return c.json({ success: false, error: "Collection not found." });
|
|
19713
|
+
}
|
|
19714
|
+
let schema = typeof collection.schema === "string" ? JSON.parse(collection.schema) : collection.schema;
|
|
19715
|
+
if (!schema || !schema.properties) {
|
|
19716
|
+
return c.json({ success: false, error: "Field not found in schema." });
|
|
19717
|
+
}
|
|
19718
|
+
if (schema.properties[fieldName]) {
|
|
19719
|
+
delete schema.properties[fieldName];
|
|
19720
|
+
if (schema.required && Array.isArray(schema.required)) {
|
|
19721
|
+
const requiredIndex = schema.required.indexOf(fieldName);
|
|
19722
|
+
if (requiredIndex !== -1) {
|
|
19723
|
+
schema.required.splice(requiredIndex, 1);
|
|
19724
|
+
}
|
|
19725
|
+
}
|
|
19726
|
+
const updateCollectionStmt = db.prepare(`
|
|
19727
|
+
UPDATE collections
|
|
19728
|
+
SET schema = ?, updated_at = ?
|
|
19729
|
+
WHERE id = ?
|
|
19730
|
+
`);
|
|
19731
|
+
await updateCollectionStmt.bind(JSON.stringify(schema), Date.now(), collectionId).run();
|
|
19732
|
+
console.log("[Delete Field] Removed field from schema:", fieldName);
|
|
19733
|
+
return c.json({ success: true });
|
|
19734
|
+
} else {
|
|
19735
|
+
return c.json({ success: false, error: "Field not found in schema." });
|
|
19736
|
+
}
|
|
19737
|
+
}
|
|
19656
19738
|
const deleteStmt = db.prepare("DELETE FROM content_fields WHERE id = ?");
|
|
19657
19739
|
await deleteStmt.bind(fieldId).run();
|
|
19658
19740
|
return c.json({ success: true });
|
|
@@ -21580,5 +21662,5 @@ var ROUTES_INFO = {
|
|
|
21580
21662
|
};
|
|
21581
21663
|
|
|
21582
21664
|
export { PluginBuilder, ROUTES_INFO, adminCheckboxRoutes, adminCollectionsRoutes, adminDesignRoutes, 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, router, test_cleanup_default, userRoutes };
|
|
21583
|
-
//# sourceMappingURL=chunk-
|
|
21584
|
-
//# sourceMappingURL=chunk-
|
|
21665
|
+
//# sourceMappingURL=chunk-RP66TPEJ.js.map
|
|
21666
|
+
//# sourceMappingURL=chunk-RP66TPEJ.js.map
|