@plank-cms/plank 0.21.0 → 0.21.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.
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-Cyv_3rmL.js"></script>
|
|
16
16
|
<link rel="stylesheet" crossorigin href="/admin/assets/index-Dlj9367E.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.21.
|
|
10
|
+
var PACKAGE_VERSION = "0.21.1";
|
|
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-CW3GRBTB.js");
|
|
105
105
|
await startServer();
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -613,7 +613,7 @@ function validate(contentType, payload) {
|
|
|
613
613
|
}
|
|
614
614
|
} else if (subField.type === "media") {
|
|
615
615
|
if (typeof subValue !== "string" || !subValue.trim()) {
|
|
616
|
-
errors.push(`Field "${field.name}[${i2}].${subField.name}" must be a non-empty string
|
|
616
|
+
errors.push(`Field "${field.name}[${i2}].${subField.name}" must be a non-empty media reference string`);
|
|
617
617
|
}
|
|
618
618
|
} else if (subField.type === "mixed") {
|
|
619
619
|
if (!isMixedArrayValue(subValue)) {
|
|
@@ -4933,26 +4933,73 @@ function normalizeArrayItemsBySchema(value, field) {
|
|
|
4933
4933
|
return normalized;
|
|
4934
4934
|
});
|
|
4935
4935
|
}
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4936
|
+
function collectMediaIdsFromValue(field, value, idSet) {
|
|
4937
|
+
if (field.type === "media") {
|
|
4938
|
+
if (typeof value === "string" && value && !value.startsWith("http"))
|
|
4939
|
+
idSet.add(value);
|
|
4940
|
+
return;
|
|
4941
|
+
}
|
|
4942
|
+
if (field.type === "media-gallery") {
|
|
4943
|
+
if (!Array.isArray(value))
|
|
4944
|
+
return;
|
|
4945
|
+
for (const item of value) {
|
|
4946
|
+
if (typeof item === "string" && item && !item.startsWith("http"))
|
|
4947
|
+
idSet.add(item);
|
|
4948
|
+
}
|
|
4940
4949
|
return;
|
|
4950
|
+
}
|
|
4951
|
+
if (field.type !== "array" || !Array.isArray(value))
|
|
4952
|
+
return;
|
|
4953
|
+
const subFields = field.arrayFields ?? [];
|
|
4954
|
+
for (const item of value) {
|
|
4955
|
+
if (typeof item !== "object" || item === null || Array.isArray(item))
|
|
4956
|
+
continue;
|
|
4957
|
+
const raw = item;
|
|
4958
|
+
for (const subField of subFields) {
|
|
4959
|
+
collectMediaIdsFromValue(subField, raw[subField.name], idSet);
|
|
4960
|
+
}
|
|
4961
|
+
}
|
|
4962
|
+
}
|
|
4963
|
+
function resolveMediaValue(field, value, mediaMap) {
|
|
4964
|
+
if (field.type === "media") {
|
|
4965
|
+
if (typeof value === "string" && value.startsWith("http"))
|
|
4966
|
+
return createMediaValue(value);
|
|
4967
|
+
if (typeof value === "string" && mediaMap.has(value))
|
|
4968
|
+
return mediaMap.get(value);
|
|
4969
|
+
return value;
|
|
4970
|
+
}
|
|
4971
|
+
if (field.type === "media-gallery") {
|
|
4972
|
+
if (!Array.isArray(value))
|
|
4973
|
+
return value;
|
|
4974
|
+
return value.map((item) => {
|
|
4975
|
+
if (typeof item === "string" && item.startsWith("http"))
|
|
4976
|
+
return createMediaValue(item);
|
|
4977
|
+
if (typeof item === "string" && mediaMap.has(item))
|
|
4978
|
+
return mediaMap.get(item);
|
|
4979
|
+
return item;
|
|
4980
|
+
});
|
|
4981
|
+
}
|
|
4982
|
+
if (field.type !== "array" || !Array.isArray(value))
|
|
4983
|
+
return value;
|
|
4984
|
+
const subFields = field.arrayFields ?? [];
|
|
4985
|
+
return value.map((item) => {
|
|
4986
|
+
if (typeof item !== "object" || item === null || Array.isArray(item))
|
|
4987
|
+
return item;
|
|
4988
|
+
const raw = item;
|
|
4989
|
+
const next = { ...raw };
|
|
4990
|
+
for (const subField of subFields) {
|
|
4991
|
+
if (!(subField.name in raw))
|
|
4992
|
+
continue;
|
|
4993
|
+
next[subField.name] = resolveMediaValue(subField, raw[subField.name], mediaMap);
|
|
4994
|
+
}
|
|
4995
|
+
return next;
|
|
4996
|
+
});
|
|
4997
|
+
}
|
|
4998
|
+
async function resolveMediaFields(entries, ct) {
|
|
4941
4999
|
const idSet = /* @__PURE__ */ new Set();
|
|
4942
5000
|
for (const entry of entries) {
|
|
4943
|
-
for (const
|
|
4944
|
-
|
|
4945
|
-
if (typeof val === "string" && val && !val.startsWith("http"))
|
|
4946
|
-
idSet.add(val);
|
|
4947
|
-
}
|
|
4948
|
-
for (const name of galleryFields) {
|
|
4949
|
-
const val = entry[name];
|
|
4950
|
-
if (Array.isArray(val)) {
|
|
4951
|
-
for (const id of val) {
|
|
4952
|
-
if (typeof id === "string" && id && !id.startsWith("http"))
|
|
4953
|
-
idSet.add(id);
|
|
4954
|
-
}
|
|
4955
|
-
}
|
|
5001
|
+
for (const field of ct.fields) {
|
|
5002
|
+
collectMediaIdsFromValue(field, entry[field.name], idSet);
|
|
4956
5003
|
}
|
|
4957
5004
|
}
|
|
4958
5005
|
const mediaMap = /* @__PURE__ */ new Map();
|
|
@@ -4972,26 +5019,8 @@ async function resolveMediaFields(entries, ct) {
|
|
|
4972
5019
|
}));
|
|
4973
5020
|
}
|
|
4974
5021
|
for (const entry of entries) {
|
|
4975
|
-
for (const
|
|
4976
|
-
|
|
4977
|
-
if (typeof val === "string" && val.startsWith("http")) {
|
|
4978
|
-
entry[name] = createMediaValue(val);
|
|
4979
|
-
continue;
|
|
4980
|
-
}
|
|
4981
|
-
if (typeof val === "string" && mediaMap.has(val))
|
|
4982
|
-
entry[name] = mediaMap.get(val);
|
|
4983
|
-
}
|
|
4984
|
-
for (const name of galleryFields) {
|
|
4985
|
-
const val = entry[name];
|
|
4986
|
-
if (Array.isArray(val)) {
|
|
4987
|
-
entry[name] = val.map((item) => {
|
|
4988
|
-
if (typeof item === "string" && item.startsWith("http"))
|
|
4989
|
-
return createMediaValue(item);
|
|
4990
|
-
if (typeof item === "string" && mediaMap.has(item))
|
|
4991
|
-
return mediaMap.get(item);
|
|
4992
|
-
return item;
|
|
4993
|
-
});
|
|
4994
|
-
}
|
|
5022
|
+
for (const field of ct.fields) {
|
|
5023
|
+
entry[field.name] = resolveMediaValue(field, entry[field.name], mediaMap);
|
|
4995
5024
|
}
|
|
4996
5025
|
}
|
|
4997
5026
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plank-cms/plank",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.1",
|
|
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.21.
|
|
59
|
-
"@plank-cms/schema": "0.21.
|
|
60
|
-
"@plank-cms/db": "0.21.
|
|
58
|
+
"@plank-cms/core": "0.21.1",
|
|
59
|
+
"@plank-cms/schema": "0.21.1",
|
|
60
|
+
"@plank-cms/db": "0.21.1"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "tsup",
|