@plank-cms/plank 0.24.1 → 0.24.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/admin/index.html
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
href="https://fonts.googleapis.com/css2?family=Google+Sans:ital,opsz,wght@0,17..18,400..700;1,17..18,400..700&display=swap"
|
|
13
13
|
rel="stylesheet"
|
|
14
14
|
/>
|
|
15
|
-
<script type="module" crossorigin src="/admin/assets/index-
|
|
15
|
+
<script type="module" crossorigin src="/admin/assets/index-DcMspdw2.js"></script>
|
|
16
16
|
<link rel="stylesheet" crossorigin href="/admin/assets/index-BSi0iXTe.css">
|
|
17
17
|
</head>
|
|
18
18
|
<body>
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { randomBytes } from "crypto";
|
|
|
7
7
|
import { resolve, join } from "path";
|
|
8
8
|
import fs from "fs-extra";
|
|
9
9
|
import { execa } from "execa";
|
|
10
|
-
var PACKAGE_VERSION = "0.24.
|
|
10
|
+
var PACKAGE_VERSION = "0.24.3";
|
|
11
11
|
function generateSecret() {
|
|
12
12
|
return randomBytes(32).toString("hex");
|
|
13
13
|
}
|
|
@@ -101,7 +101,7 @@ import { dirname, join as join2, resolve as resolve2 } from "path";
|
|
|
101
101
|
async function start() {
|
|
102
102
|
config({ path: resolve2(process.cwd(), ".env") });
|
|
103
103
|
process.env.PLANK_ADMIN_DIST = join2(dirname(fileURLToPath(import.meta.url)), "admin");
|
|
104
|
-
const { start: startServer } = await import("./server-
|
|
104
|
+
const { start: startServer } = await import("./server-KRX65XUC.js");
|
|
105
105
|
await startServer();
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -3224,6 +3224,73 @@ async function triggerWebhooks(event, payload) {
|
|
|
3224
3224
|
signal: AbortSignal.timeout(1e4)
|
|
3225
3225
|
})));
|
|
3226
3226
|
}
|
|
3227
|
+
async function triggerPreviewSyncWebhook(params) {
|
|
3228
|
+
const settings = await getSettings("preview");
|
|
3229
|
+
const enabled = String(settings.enabled ?? "false").toLowerCase() === "true";
|
|
3230
|
+
const syncUrl = settings.sync_url?.trim();
|
|
3231
|
+
if (!enabled || !syncUrl)
|
|
3232
|
+
return;
|
|
3233
|
+
let parsedSyncUrl;
|
|
3234
|
+
try {
|
|
3235
|
+
parsedSyncUrl = new URL(syncUrl);
|
|
3236
|
+
} catch {
|
|
3237
|
+
return;
|
|
3238
|
+
}
|
|
3239
|
+
const slugField = settings.slug_field?.trim() || "slug";
|
|
3240
|
+
const slugValue = params.entry[slugField];
|
|
3241
|
+
const slug = typeof slugValue === "string" && slugValue.trim() ? slugValue.trim() : null;
|
|
3242
|
+
const previewUrl = resolvePreviewUrlFromSettings(settings, {
|
|
3243
|
+
contentType: params.contentType,
|
|
3244
|
+
entry: params.entry
|
|
3245
|
+
});
|
|
3246
|
+
const payload = {
|
|
3247
|
+
event: "preview.sync",
|
|
3248
|
+
content_type: params.contentType,
|
|
3249
|
+
entry_id: params.entry.id ? String(params.entry.id) : "",
|
|
3250
|
+
status: typeof params.entry.status === "string" ? params.entry.status : null,
|
|
3251
|
+
slug,
|
|
3252
|
+
preview_url: previewUrl,
|
|
3253
|
+
triggered_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3254
|
+
};
|
|
3255
|
+
if (!payload.entry_id)
|
|
3256
|
+
return;
|
|
3257
|
+
try {
|
|
3258
|
+
await fetch(parsedSyncUrl, {
|
|
3259
|
+
method: "POST",
|
|
3260
|
+
headers: { "Content-Type": "application/json" },
|
|
3261
|
+
body: JSON.stringify(payload),
|
|
3262
|
+
signal: AbortSignal.timeout(1e4)
|
|
3263
|
+
});
|
|
3264
|
+
} catch {
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3267
|
+
function resolvePreviewUrlFromSettings(settings, params) {
|
|
3268
|
+
const template = settings.url_template?.trim();
|
|
3269
|
+
if (!template)
|
|
3270
|
+
return null;
|
|
3271
|
+
const slugField = settings.slug_field?.trim() || "slug";
|
|
3272
|
+
const slugValue = params.entry[slugField];
|
|
3273
|
+
const resolved = template.replace(/\{(contentType|entryId|slug|status)\}/g, (_match, key) => {
|
|
3274
|
+
if (key === "contentType")
|
|
3275
|
+
return encodeURIComponent(params.contentType);
|
|
3276
|
+
if (key === "entryId")
|
|
3277
|
+
return params.entry.id ? encodeURIComponent(String(params.entry.id)) : "";
|
|
3278
|
+
if (key === "slug") {
|
|
3279
|
+
return typeof slugValue === "string" && slugValue.trim() ? encodeURIComponent(slugValue.trim()) : "";
|
|
3280
|
+
}
|
|
3281
|
+
if (key === "status") {
|
|
3282
|
+
return typeof params.entry.status === "string" ? encodeURIComponent(params.entry.status) : "";
|
|
3283
|
+
}
|
|
3284
|
+
return "";
|
|
3285
|
+
});
|
|
3286
|
+
if (/\{[^}]+\}/.test(resolved))
|
|
3287
|
+
return null;
|
|
3288
|
+
try {
|
|
3289
|
+
return new URL(resolved).toString();
|
|
3290
|
+
} catch {
|
|
3291
|
+
return null;
|
|
3292
|
+
}
|
|
3293
|
+
}
|
|
3227
3294
|
|
|
3228
3295
|
// ../core/dist/controllers/entries.js
|
|
3229
3296
|
function resolveLocalizedRow(row, ct, locale, fallbacks = []) {
|
|
@@ -3561,6 +3628,7 @@ var createEntry = async (req, res) => {
|
|
|
3561
3628
|
}));
|
|
3562
3629
|
res.status(201).json(normalizeNavigationFields(rows[0], ct.fields));
|
|
3563
3630
|
triggerWebhooks("entry.created", { content_type: req.params.slug, entry_id: rows[0].id });
|
|
3631
|
+
triggerPreviewSyncWebhook({ contentType: req.params.slug, entry: rows[0] });
|
|
3564
3632
|
};
|
|
3565
3633
|
var getSingleEntry = async (req, res) => {
|
|
3566
3634
|
const ct = await findContentTypeBySlug(req.params.slug);
|
|
@@ -3654,6 +3722,7 @@ var updateEntry = async (req, res) => {
|
|
|
3654
3722
|
}));
|
|
3655
3723
|
res.json(normalizeNavigationFields(rows[0], ct.fields));
|
|
3656
3724
|
triggerWebhooks("entry.updated", { content_type: req.params.slug, entry_id: req.params.id });
|
|
3725
|
+
triggerPreviewSyncWebhook({ contentType: req.params.slug, entry: rows[0] });
|
|
3657
3726
|
};
|
|
3658
3727
|
var SNAPSHOT_EXCLUDED = [
|
|
3659
3728
|
"'id'",
|
|
@@ -4789,6 +4858,7 @@ async function getClientSettings(_req, res) {
|
|
|
4789
4858
|
locales: settings.locales ?? '["en"]',
|
|
4790
4859
|
default_locale: settings.default_locale ?? "en",
|
|
4791
4860
|
preview_enabled: previewSettings.enabled ?? "false",
|
|
4861
|
+
preview_sync_url: previewSettings.sync_url ?? "",
|
|
4792
4862
|
preview_url_template: previewSettings.url_template ?? "",
|
|
4793
4863
|
preview_slug_field: previewSettings.slug_field ?? "slug"
|
|
4794
4864
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plank-cms/plank",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.3",
|
|
4
4
|
"description": "Self-hosted headless CMS. Deploy in minutes on your own infrastructure.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/fs-extra": "^11.0.4",
|
|
57
57
|
"tsup": "^8.5.0",
|
|
58
|
-
"@plank-cms/core": "0.24.
|
|
59
|
-
"@plank-cms/schema": "0.24.
|
|
60
|
-
"@plank-cms/db": "0.24.
|
|
58
|
+
"@plank-cms/core": "0.24.3",
|
|
59
|
+
"@plank-cms/schema": "0.24.3",
|
|
60
|
+
"@plank-cms/db": "0.24.3"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "tsup",
|