@yimingliao/cms 0.0.251 → 0.0.253
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/export/server/index.js +1 -1
- package/dist/src/client/interfaces/components/resources/file/file-relations-section.js +6 -6
- package/dist/src/client/interfaces/components/ui/display/html-display.js +98 -4
- package/dist/src/domain/resources/file/utils/is-file-locked.js +2 -2
- package/dist/src/server/infrastructure/database/config/command/create-config-command-repository.js +31 -1
- package/dist/src/server/infrastructure/database/config/include.js +17 -0
- package/dist/src/server/infrastructure/database/config/query/{create-post-query-repository.js → create-config-query-repository.js} +3 -2
- package/dist/src/server/infrastructure/database/file/include.js +6 -6
- package/dist/src/server/infrastructure/database/post/command/create-post-command-repository.js +24 -24
- package/dist/src/server/infrastructure/database/post/include.js +6 -6
- package/dist/src/server/infrastructure/database/utils/build-file-usage.js +6 -6
- package/dist/src/server/infrastructure/zod/schemas/schemas.js +8 -0
- package/dist/src/server/interfaces/actions/resources/config/commands/update/config-update-validator.js +11 -0
- package/dist/src/server/interfaces/actions/resources/file/commands/create/file-create-validator.js +3 -3
- package/dist/src/server/interfaces/actions/resources/file/commands/create-many/file-create-many-validator.js +3 -3
- package/dist/src/server/interfaces/actions/resources/file/commands/update/file-update-validator.js +3 -3
- package/dist/src/server/interfaces/actions/resources/post/commands/create/post-create-validator.js +29 -9
- package/dist/src/server/interfaces/actions/resources/post/commands/update/post-update-validator.js +29 -9
- package/dist/src/server/interfaces/apis/multi-files-upload/validator.js +2 -2
- package/dist/types/src/client/interfaces/components/ui/display/html-display.d.ts +3 -0
- package/dist/types/src/client/interfaces/components/ui/display/html-display.d.ts.map +1 -1
- package/dist/types/src/domain/resources/config/full.d.ts +7 -0
- package/dist/types/src/domain/resources/config/full.d.ts.map +1 -1
- package/dist/types/src/domain/resources/file/full.d.ts +6 -6
- package/dist/types/src/domain/resources/file/full.d.ts.map +1 -1
- package/dist/types/src/domain/resources/post/base.d.ts +12 -4
- package/dist/types/src/domain/resources/post/base.d.ts.map +1 -1
- package/dist/types/src/domain/resources/post/full.d.ts +6 -6
- package/dist/types/src/domain/resources/post/full.d.ts.map +1 -1
- package/dist/types/src/domain/resources/post/translation.d.ts +8 -0
- package/dist/types/src/domain/resources/post/translation.d.ts.map +1 -1
- package/dist/types/src/server/infrastructure/database/config/command/create-config-command-repository.d.ts +1 -1
- package/dist/types/src/server/infrastructure/database/config/command/create-config-command-repository.d.ts.map +1 -1
- package/dist/types/src/server/infrastructure/database/config/command/types.d.ts +7 -1
- package/dist/types/src/server/infrastructure/database/config/command/types.d.ts.map +1 -1
- package/dist/types/src/server/infrastructure/database/config/include.d.ts +34 -0
- package/dist/types/src/server/infrastructure/database/config/include.d.ts.map +1 -0
- package/dist/types/src/server/infrastructure/database/config/query/{create-post-query-repository.d.ts → create-config-query-repository.d.ts} +1 -1
- package/dist/types/src/server/infrastructure/database/config/query/create-config-query-repository.d.ts.map +1 -0
- package/dist/types/src/server/infrastructure/database/config/query/index.d.ts +1 -1
- package/dist/types/src/server/infrastructure/database/config/query/index.d.ts.map +1 -1
- package/dist/types/src/server/infrastructure/database/file/include.d.ts +6 -6
- package/dist/types/src/server/infrastructure/database/post/command/create-post-command-repository.d.ts +2 -2
- package/dist/types/src/server/infrastructure/database/post/command/create-post-command-repository.d.ts.map +1 -1
- package/dist/types/src/server/infrastructure/database/post/command/types.d.ts +44 -12
- package/dist/types/src/server/infrastructure/database/post/command/types.d.ts.map +1 -1
- package/dist/types/src/server/infrastructure/database/post/include.d.ts +6 -6
- package/dist/types/src/server/infrastructure/zod/schemas/schemas.d.ts +1 -0
- package/dist/types/src/server/infrastructure/zod/schemas/schemas.d.ts.map +1 -1
- package/dist/types/src/server/interfaces/actions/resources/config/commands/update/config-update-validator.d.ts +26 -0
- package/dist/types/src/server/interfaces/actions/resources/config/commands/update/config-update-validator.d.ts.map +1 -1
- package/dist/types/src/server/interfaces/actions/resources/post/commands/create/create-post-create-action.d.ts +7 -7
- package/dist/types/src/server/interfaces/actions/resources/post/commands/create/create-post-create-action.d.ts.map +1 -1
- package/dist/types/src/server/interfaces/actions/resources/post/commands/create/post-create-validator.d.ts +82 -18
- package/dist/types/src/server/interfaces/actions/resources/post/commands/create/post-create-validator.d.ts.map +1 -1
- package/dist/types/src/server/interfaces/actions/resources/post/commands/update/create-post-update-action.d.ts +7 -7
- package/dist/types/src/server/interfaces/actions/resources/post/commands/update/create-post-update-action.d.ts.map +1 -1
- package/dist/types/src/server/interfaces/actions/resources/post/commands/update/post-update-validator.d.ts +82 -18
- package/dist/types/src/server/interfaces/actions/resources/post/commands/update/post-update-validator.d.ts.map +1 -1
- package/package.json +1 -1
- package/prisma/schema/Config/Config.prisma +18 -0
- package/prisma/schema/File/File.prisma +21 -11
- package/prisma/schema/Post/{Post.prisma → post.prisma} +39 -15
- package/dist/types/src/server/infrastructure/database/config/query/create-post-query-repository.d.ts.map +0 -1
|
@@ -28,7 +28,7 @@ export { createPostQueryRepository } from '../../src/server/infrastructure/datab
|
|
|
28
28
|
export { POST_LIST_CARD_INCLUDE } from '../../src/server/infrastructure/database/post/include.js';
|
|
29
29
|
export { createSeoMetadataCommandRepository } from '../../src/server/infrastructure/database/seo-metadata/command/create-seo-metadata-command-repository.js';
|
|
30
30
|
export { createConfigCommandRepository } from '../../src/server/infrastructure/database/config/command/create-config-command-repository.js';
|
|
31
|
-
export { createConfigQueryRepository } from '../../src/server/infrastructure/database/config/query/create-
|
|
31
|
+
export { createConfigQueryRepository } from '../../src/server/infrastructure/database/config/query/create-config-query-repository.js';
|
|
32
32
|
export { createInquiryCommandRepository } from '../../src/server/infrastructure/database/inquiry/command/create-inquiry-command-repository.js';
|
|
33
33
|
export { createInquiryQueryRepository } from '../../src/server/infrastructure/database/inquiry/query/create-post-query-repository.js';
|
|
34
34
|
export { ADMIN_ORDER_BY, ORDER_BY, POST_ORDER_BY } from '../../src/server/infrastructure/database/constants.js';
|
|
@@ -37,12 +37,12 @@ import 'next/image';
|
|
|
37
37
|
const postRelations = [
|
|
38
38
|
"postsAsContentImage",
|
|
39
39
|
"postsAsCoverImage",
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
40
|
+
"postsAsFiles1",
|
|
41
|
+
"postsAsFiles2",
|
|
42
|
+
"postsAsFile1",
|
|
43
|
+
"postsAsFile2",
|
|
44
|
+
"postsAsFile3",
|
|
45
|
+
"postsAsFile4"
|
|
46
46
|
];
|
|
47
47
|
function createFileRelationsSection({
|
|
48
48
|
autherEnabled,
|
|
@@ -5,18 +5,27 @@ import 'mime-types';
|
|
|
5
5
|
import { cn } from '../../../../applications/cms/shadcn/utils.js';
|
|
6
6
|
import 'next/navigation';
|
|
7
7
|
|
|
8
|
+
const FIGURE_OEMBED_PATTERN = /<figure\b[^>]*\bclass=(["'])[^"']*\bmedia\b[^"']*\1[^>]*>\s*<oembed\b[^>]*\burl=(["'])(.*?)\2[^>]*>\s*<\/oembed>\s*<\/figure>/gi;
|
|
9
|
+
const YOUTUBE_VIDEO_ID_PATTERN = /^[\w-]{11}$/;
|
|
10
|
+
const HTML_ESCAPE_MAP = {
|
|
11
|
+
'"': """,
|
|
12
|
+
"&": "&",
|
|
13
|
+
"<": "<",
|
|
14
|
+
">": ">"
|
|
15
|
+
};
|
|
8
16
|
function HtmlDisplay({
|
|
9
17
|
html = "",
|
|
10
|
-
textOnly,
|
|
18
|
+
textOnly = false,
|
|
11
19
|
className = "",
|
|
12
20
|
...props
|
|
13
21
|
}) {
|
|
14
|
-
const content = textOnly ?
|
|
22
|
+
const content = textOnly ? toPlainText(html) : normalizeHtml(html ?? "");
|
|
15
23
|
return /* @__PURE__ */ jsx(
|
|
16
24
|
"div",
|
|
17
25
|
{
|
|
18
26
|
className: cn(
|
|
19
27
|
className,
|
|
28
|
+
"w-full",
|
|
20
29
|
"ck ck-content"
|
|
21
30
|
// CKEditor styles prefix: .ck (ckeditor.css)
|
|
22
31
|
),
|
|
@@ -25,9 +34,94 @@ function HtmlDisplay({
|
|
|
25
34
|
}
|
|
26
35
|
);
|
|
27
36
|
}
|
|
28
|
-
function
|
|
37
|
+
function toPlainText(html) {
|
|
29
38
|
if (!html) return "";
|
|
30
|
-
return html.replace(/<\/(p|div|li|h[1-6]|tr|td)>/gi, " ").replace(/<br\s*\/?>/gi, " ").replace(/<[^>]+>/g, " ").replace(/\r?\n|\r/g, " ").replace(/\s{2,}/g, " ").trim();
|
|
39
|
+
return removeMediaContent(html).replace(/<\/(p|div|li|h[1-6]|tr|td)>/gi, " ").replace(/<br\s*\/?>/gi, " ").replace(/<[^>]+>/g, " ").replace(/\r?\n|\r/g, " ").replace(/\s{2,}/g, " ").replace(/\s+([,。!?;:、])/g, "$1").trim();
|
|
40
|
+
}
|
|
41
|
+
function normalizeHtml(html) {
|
|
42
|
+
if (!html) return "";
|
|
43
|
+
return html.replace(
|
|
44
|
+
FIGURE_OEMBED_PATTERN,
|
|
45
|
+
(figureHtml, _classQuote, _urlQuote, rawUrl) => {
|
|
46
|
+
const embedHtml = createEmbedHtml(rawUrl);
|
|
47
|
+
return embedHtml ?? createEmbedFallbackHtml(rawUrl, figureHtml);
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
function removeMediaContent(html) {
|
|
52
|
+
return html.replace(FIGURE_OEMBED_PATTERN, " ").replace(/<iframe\b[^>]*>[\s\S]*?<\/iframe>/gi, " ").replace(/<video\b[^>]*>[\s\S]*?<\/video>/gi, " ").replace(/<picture\b[^>]*>[\s\S]*?<\/picture>/gi, " ").replace(/<img\b[^>]*>/gi, " ").replace(/<source\b[^>]*>/gi, " ");
|
|
53
|
+
}
|
|
54
|
+
function createEmbedHtml(rawUrl) {
|
|
55
|
+
const embedUrl = getYouTubeEmbedUrl(rawUrl);
|
|
56
|
+
if (!embedUrl) return null;
|
|
57
|
+
return `<iframe
|
|
58
|
+
src="${escapeHtmlAttribute(embedUrl)}"
|
|
59
|
+
title="Embedded media"
|
|
60
|
+
frameborder="0"
|
|
61
|
+
loading="lazy"
|
|
62
|
+
referrerpolicy="strict-origin-when-cross-origin"
|
|
63
|
+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
|
|
64
|
+
allowfullscreen
|
|
65
|
+
class="media"
|
|
66
|
+
style="display: block; width: 100%; aspect-ratio: 16 / 9; border: 0;"
|
|
67
|
+
></iframe>`.trim();
|
|
68
|
+
}
|
|
69
|
+
function createEmbedFallbackHtml(rawUrl, fallbackHtml) {
|
|
70
|
+
const safeUrl = getSafeExternalUrl(rawUrl);
|
|
71
|
+
if (!safeUrl) return fallbackHtml;
|
|
72
|
+
return `<figure class="media">
|
|
73
|
+
<a
|
|
74
|
+
href="${escapeHtmlAttribute(safeUrl)}"
|
|
75
|
+
target="_blank"
|
|
76
|
+
rel="noreferrer noopener"
|
|
77
|
+
>
|
|
78
|
+
${escapeHtmlText(safeUrl)}
|
|
79
|
+
</a>
|
|
80
|
+
</figure>`.trim();
|
|
81
|
+
}
|
|
82
|
+
function getYouTubeEmbedUrl(rawUrl) {
|
|
83
|
+
const url = safeParseUrl(rawUrl);
|
|
84
|
+
if (!url) return null;
|
|
85
|
+
const hostname = url.hostname.toLowerCase().replace(/^www\./, "");
|
|
86
|
+
let videoId = "";
|
|
87
|
+
if (hostname === "youtu.be") {
|
|
88
|
+
videoId = url.pathname.split("/").filter(Boolean)[0] ?? "";
|
|
89
|
+
} else if (hostname === "youtube.com" || hostname === "m.youtube.com") {
|
|
90
|
+
if (url.pathname === "/watch") {
|
|
91
|
+
videoId = url.searchParams.get("v") ?? "";
|
|
92
|
+
} else if (url.pathname.startsWith("/embed/")) {
|
|
93
|
+
videoId = url.pathname.split("/")[2] ?? "";
|
|
94
|
+
} else if (url.pathname.startsWith("/shorts/")) {
|
|
95
|
+
videoId = url.pathname.split("/")[2] ?? "";
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (!YOUTUBE_VIDEO_ID_PATTERN.test(videoId)) return null;
|
|
99
|
+
return `https://www.youtube-nocookie.com/embed/${videoId}`;
|
|
100
|
+
}
|
|
101
|
+
function getSafeExternalUrl(rawUrl) {
|
|
102
|
+
const url = safeParseUrl(rawUrl);
|
|
103
|
+
if (!url) return null;
|
|
104
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") return null;
|
|
105
|
+
return url.toString();
|
|
106
|
+
}
|
|
107
|
+
function safeParseUrl(rawUrl) {
|
|
108
|
+
try {
|
|
109
|
+
return new URL(rawUrl);
|
|
110
|
+
} catch {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function escapeHtmlAttribute(value) {
|
|
115
|
+
return value.replaceAll(
|
|
116
|
+
/["&<>]/g,
|
|
117
|
+
(character) => HTML_ESCAPE_MAP[character] ?? character
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
function escapeHtmlText(value) {
|
|
121
|
+
return value.replaceAll(
|
|
122
|
+
/[&<>]/g,
|
|
123
|
+
(character) => HTML_ESCAPE_MAP[character] ?? character
|
|
124
|
+
);
|
|
31
125
|
}
|
|
32
126
|
|
|
33
127
|
export { HtmlDisplay };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const isFileLocked = (file) => {
|
|
2
2
|
if (!file) return false;
|
|
3
|
-
if (!("adminAsAvatarImage" in file && "postsAsCoverImage" in file && "postsAsContentImage" in file && "
|
|
3
|
+
if (!("adminAsAvatarImage" in file && "postsAsCoverImage" in file && "postsAsContentImage" in file && "postsAsFiles1" in file && "postsAsFiles2" in file && "postsAsFile1" in file && "postsAsFile2" in file && "postsAsFile3" in file && "postsAsFile4" in file)) {
|
|
4
4
|
return false;
|
|
5
5
|
}
|
|
6
|
-
const locked = file.adminAsAvatarImage.length > 0 || file.postsAsCoverImage.length > 0 || file.postsAsContentImage.length > 0 || file.
|
|
6
|
+
const locked = file.adminAsAvatarImage.length > 0 || file.postsAsCoverImage.length > 0 || file.postsAsContentImage.length > 0 || file.postsAsFiles1.length > 0 || file.postsAsFiles2.length > 0 || file.postsAsFile1.length > 0 || file.postsAsFile2.length > 0 || file.postsAsFile3.length > 0 || file.postsAsFile4.length > 0;
|
|
7
7
|
return locked;
|
|
8
8
|
};
|
|
9
9
|
|
package/dist/src/server/infrastructure/database/config/command/create-config-command-repository.js
CHANGED
|
@@ -1,8 +1,38 @@
|
|
|
1
|
+
import { updateOne, updateMany } from '../../utils/connect.js';
|
|
2
|
+
|
|
1
3
|
function createConfigCommandRepository(prisma) {
|
|
2
|
-
async function update({
|
|
4
|
+
async function update({
|
|
5
|
+
id,
|
|
6
|
+
// ------------------------------------
|
|
7
|
+
// --- custom fields
|
|
8
|
+
// ------------------------------------
|
|
9
|
+
// multi images
|
|
10
|
+
files1,
|
|
11
|
+
files2,
|
|
12
|
+
// single images
|
|
13
|
+
file1,
|
|
14
|
+
file2,
|
|
15
|
+
file3,
|
|
16
|
+
file4,
|
|
17
|
+
// ------------------------------------
|
|
18
|
+
// translation
|
|
19
|
+
// ------------------------------------
|
|
20
|
+
translations
|
|
21
|
+
}) {
|
|
3
22
|
const updated = await prisma.config.update({
|
|
4
23
|
where: { id },
|
|
5
24
|
data: {
|
|
25
|
+
// ------------------------------------------------------------------------
|
|
26
|
+
// --- custom fields
|
|
27
|
+
// ------------------------------------------------------------------------
|
|
28
|
+
// multi images
|
|
29
|
+
files1: updateMany(files1),
|
|
30
|
+
files2: updateMany(files2),
|
|
31
|
+
// single images
|
|
32
|
+
file1: updateOne(file1),
|
|
33
|
+
file2: updateOne(file2),
|
|
34
|
+
file3: updateOne(file3),
|
|
35
|
+
file4: updateOne(file4),
|
|
6
36
|
translations: {
|
|
7
37
|
upsert: translations.map((t) => ({
|
|
8
38
|
where: { configId_locale: { configId: id, locale: t.locale } },
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const CONFIG_FULL_INCLUDE = {
|
|
2
|
+
// ---------------------------
|
|
3
|
+
// --- custom fields
|
|
4
|
+
// ---------------------------
|
|
5
|
+
files1: { include: { translations: true } },
|
|
6
|
+
files2: { include: { translations: true } },
|
|
7
|
+
file1: { include: { translations: true } },
|
|
8
|
+
file2: { include: { translations: true } },
|
|
9
|
+
file3: { include: { translations: true } },
|
|
10
|
+
file4: { include: { translations: true } },
|
|
11
|
+
// ---------------------------
|
|
12
|
+
// translation
|
|
13
|
+
// ---------------------------
|
|
14
|
+
translations: true
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { CONFIG_FULL_INCLUDE };
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { CONFIG_ORDER_BY } from '../../constants.js';
|
|
2
|
+
import { CONFIG_FULL_INCLUDE } from '../include.js';
|
|
2
3
|
|
|
3
4
|
function createConfigQueryRepository(prisma) {
|
|
4
5
|
async function find({ slug }) {
|
|
5
6
|
return prisma.config.findUnique({
|
|
6
7
|
where: { slug },
|
|
7
|
-
include:
|
|
8
|
+
include: CONFIG_FULL_INCLUDE
|
|
8
9
|
});
|
|
9
10
|
}
|
|
10
11
|
async function findMany() {
|
|
11
12
|
return prisma.config.findMany({
|
|
12
|
-
include:
|
|
13
|
+
include: CONFIG_FULL_INCLUDE,
|
|
13
14
|
orderBy: CONFIG_ORDER_BY
|
|
14
15
|
});
|
|
15
16
|
}
|
|
@@ -15,12 +15,12 @@ const FILE_FULL_INCLUDE = {
|
|
|
15
15
|
// ---------------------------
|
|
16
16
|
// --- custom fields
|
|
17
17
|
// ---------------------------
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
postsAsFiles1: true,
|
|
19
|
+
postsAsFiles2: true,
|
|
20
|
+
postsAsFile1: true,
|
|
21
|
+
postsAsFile2: true,
|
|
22
|
+
postsAsFile3: true,
|
|
23
|
+
postsAsFile4: true,
|
|
24
24
|
// ---------------------------
|
|
25
25
|
// translation
|
|
26
26
|
// ---------------------------
|
package/dist/src/server/infrastructure/database/post/command/create-post-command-repository.js
CHANGED
|
@@ -22,13 +22,13 @@ function createPostCommandRepository(prisma) {
|
|
|
22
22
|
// --- custom fields
|
|
23
23
|
// ------------------------------------
|
|
24
24
|
// multi images
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
files1,
|
|
26
|
+
files2,
|
|
27
27
|
// single images
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
file1,
|
|
29
|
+
file2,
|
|
30
|
+
file3,
|
|
31
|
+
file4,
|
|
32
32
|
// ------------------------------------
|
|
33
33
|
// translation
|
|
34
34
|
// ------------------------------------
|
|
@@ -64,13 +64,13 @@ function createPostCommandRepository(prisma) {
|
|
|
64
64
|
// --- custom fields
|
|
65
65
|
// ------------------------------------------------------------------------
|
|
66
66
|
// multi images
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
files1: connectMany(files1),
|
|
68
|
+
files2: connectMany(files2),
|
|
69
69
|
// single images
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
file1: connectOne(file1),
|
|
71
|
+
file2: connectOne(file2),
|
|
72
|
+
file3: connectOne(file3),
|
|
73
|
+
file4: connectOne(file4),
|
|
74
74
|
// ------------------------------------------------------------------------
|
|
75
75
|
// translation
|
|
76
76
|
// ------------------------------------------------------------------------
|
|
@@ -107,13 +107,13 @@ function createPostCommandRepository(prisma) {
|
|
|
107
107
|
// --- custom fields
|
|
108
108
|
// ------------------------------------
|
|
109
109
|
// multi images
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
files1,
|
|
111
|
+
files2,
|
|
112
112
|
// single images
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
file1,
|
|
114
|
+
file2,
|
|
115
|
+
file3,
|
|
116
|
+
file4,
|
|
117
117
|
// ------------------------------------
|
|
118
118
|
// translation
|
|
119
119
|
// ------------------------------------
|
|
@@ -148,13 +148,13 @@ function createPostCommandRepository(prisma) {
|
|
|
148
148
|
// --- custom fields
|
|
149
149
|
// ------------------------------------------------------------------------
|
|
150
150
|
// multi images
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
files1: updateMany(files1),
|
|
152
|
+
files2: updateMany(files2),
|
|
153
153
|
// single images
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
file1: updateOne(file1),
|
|
155
|
+
file2: updateOne(file2),
|
|
156
|
+
file3: updateOne(file3),
|
|
157
|
+
file4: updateOne(file4),
|
|
158
158
|
// ------------------------------------------------------------------------
|
|
159
159
|
// translation
|
|
160
160
|
// ------------------------------------------------------------------------
|
|
@@ -52,12 +52,12 @@ const POST_FULL_INCLUDE = {
|
|
|
52
52
|
// ---------------------------
|
|
53
53
|
// --- custom fields
|
|
54
54
|
// ---------------------------
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
files1: { include: { translations: true } },
|
|
56
|
+
files2: { include: { translations: true } },
|
|
57
|
+
file1: { include: { translations: true } },
|
|
58
|
+
file2: { include: { translations: true } },
|
|
59
|
+
file3: { include: { translations: true } },
|
|
60
|
+
file4: { include: { translations: true } },
|
|
61
61
|
// ---------------------------
|
|
62
62
|
// translation
|
|
63
63
|
// ---------------------------
|
|
@@ -3,12 +3,12 @@ function buildFileUsage(isLocked) {
|
|
|
3
3
|
"adminAsAvatarImage",
|
|
4
4
|
"postsAsCoverImage",
|
|
5
5
|
"postsAsContentImage",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
6
|
+
"postsAsFiles1",
|
|
7
|
+
"postsAsFiles2",
|
|
8
|
+
"postsAsFile1",
|
|
9
|
+
"postsAsFile2",
|
|
10
|
+
"postsAsFile3",
|
|
11
|
+
"postsAsFile4"
|
|
12
12
|
];
|
|
13
13
|
if (isLocked === void 0 || isLocked === null) return {};
|
|
14
14
|
const condition = relations.map((r) => ({
|
|
@@ -15,6 +15,13 @@ function createSchemas({
|
|
|
15
15
|
return Number.isNaN(num) ? void 0 : num;
|
|
16
16
|
}, z.number().min(0).max(MAX_NUMBER));
|
|
17
17
|
}
|
|
18
|
+
function positiveInteger() {
|
|
19
|
+
return z.preprocess((val) => {
|
|
20
|
+
if (val == null || val === "") return;
|
|
21
|
+
const num = Number(typeof val === "string" ? val.trim() : val);
|
|
22
|
+
return Number.isNaN(num) ? void 0 : Math.trunc(num);
|
|
23
|
+
}, z.number().int().min(0).max(MAX_NUMBER));
|
|
24
|
+
}
|
|
18
25
|
function email() {
|
|
19
26
|
return z.email().max(254).toLowerCase();
|
|
20
27
|
}
|
|
@@ -67,6 +74,7 @@ function createSchemas({
|
|
|
67
74
|
// base
|
|
68
75
|
text,
|
|
69
76
|
positiveNumber,
|
|
77
|
+
positiveInteger,
|
|
70
78
|
// url,
|
|
71
79
|
email,
|
|
72
80
|
password,
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
const configUpdateValidator = (schemas) => schemas.z.object({
|
|
2
|
+
// -----------------------------------------------------------------------
|
|
3
|
+
// --- custom fields
|
|
4
|
+
// -----------------------------------------------------------------------
|
|
5
|
+
// multi images
|
|
6
|
+
files1: schemas.multiItems({ table: "files", column: "id" }),
|
|
7
|
+
files2: schemas.multiItems({ table: "files", column: "id" }),
|
|
8
|
+
// single images
|
|
9
|
+
file1: schemas.singleItem({ table: "files", column: "id" }),
|
|
10
|
+
file2: schemas.singleItem({ table: "files", column: "id" }),
|
|
11
|
+
file3: schemas.singleItem({ table: "files", column: "id" }),
|
|
12
|
+
file4: schemas.singleItem({ table: "files", column: "id" }),
|
|
2
13
|
// ----------------------------------------------------------------------------
|
|
3
14
|
// translation
|
|
4
15
|
// ----------------------------------------------------------------------------
|
package/dist/src/server/interfaces/actions/resources/file/commands/create/file-create-validator.js
CHANGED
|
@@ -4,12 +4,12 @@ const fileCreateValidator = (schemas) => schemas.z.object({
|
|
|
4
4
|
// file meta
|
|
5
5
|
fileMeta: schemas.z.object({
|
|
6
6
|
type: schemas.text(),
|
|
7
|
-
size: schemas.
|
|
7
|
+
size: schemas.positiveInteger(),
|
|
8
8
|
name: schemas.text()
|
|
9
9
|
}),
|
|
10
10
|
// media info
|
|
11
|
-
width: schemas.
|
|
12
|
-
height: schemas.
|
|
11
|
+
width: schemas.positiveInteger().nullable().optional(),
|
|
12
|
+
height: schemas.positiveInteger().nullable().optional(),
|
|
13
13
|
duration: schemas.positiveNumber().nullable().optional(),
|
|
14
14
|
// ----------------------------------------------------------------------------
|
|
15
15
|
// relations
|
|
@@ -7,12 +7,12 @@ const fileCreateManyValidator = (schemas) => schemas.z.object({
|
|
|
7
7
|
// file meta
|
|
8
8
|
fileMeta: schemas.z.object({
|
|
9
9
|
type: schemas.text(),
|
|
10
|
-
size: schemas.
|
|
10
|
+
size: schemas.positiveInteger(),
|
|
11
11
|
name: schemas.text()
|
|
12
12
|
}),
|
|
13
13
|
// media info
|
|
14
|
-
width: schemas.
|
|
15
|
-
height: schemas.
|
|
14
|
+
width: schemas.positiveInteger().nullable(),
|
|
15
|
+
height: schemas.positiveInteger().nullable(),
|
|
16
16
|
duration: schemas.positiveNumber().nullable(),
|
|
17
17
|
// ----------------------------------------------------------------------------
|
|
18
18
|
// translation
|
package/dist/src/server/interfaces/actions/resources/file/commands/update/file-update-validator.js
CHANGED
|
@@ -5,12 +5,12 @@ const fileUpdateValidator = (schemas) => schemas.z.object({
|
|
|
5
5
|
// file meta
|
|
6
6
|
fileMeta: schemas.z.object({
|
|
7
7
|
type: schemas.text(),
|
|
8
|
-
size: schemas.
|
|
8
|
+
size: schemas.positiveInteger(),
|
|
9
9
|
name: schemas.text()
|
|
10
10
|
}),
|
|
11
11
|
// media info
|
|
12
|
-
width: schemas.
|
|
13
|
-
height: schemas.
|
|
12
|
+
width: schemas.positiveInteger().nullable(),
|
|
13
|
+
height: schemas.positiveInteger().nullable(),
|
|
14
14
|
duration: schemas.positiveNumber().nullable(),
|
|
15
15
|
// ----------------------------------------------------------------------------
|
|
16
16
|
// relations
|
package/dist/src/server/interfaces/actions/resources/post/commands/create/post-create-validator.js
CHANGED
|
@@ -59,13 +59,13 @@ const postCreateValidator = ({
|
|
|
59
59
|
state9: schemas.z.boolean(),
|
|
60
60
|
state10: schemas.z.boolean(),
|
|
61
61
|
// multi images
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
files1: schemas.multiItems({ table: "files", column: "id" }),
|
|
63
|
+
files2: schemas.multiItems({ table: "files", column: "id" }),
|
|
64
64
|
// single images
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
file1: schemas.singleItem({ table: "files", column: "id" }),
|
|
66
|
+
file2: schemas.singleItem({ table: "files", column: "id" }),
|
|
67
|
+
file3: schemas.singleItem({ table: "files", column: "id" }),
|
|
68
|
+
file4: schemas.singleItem({ table: "files", column: "id" }),
|
|
69
69
|
// text
|
|
70
70
|
text1: schemas.text().nullable(),
|
|
71
71
|
text2: schemas.text().nullable(),
|
|
@@ -82,6 +82,16 @@ const postCreateValidator = ({
|
|
|
82
82
|
data2: schemas.array(schemas.z.any()),
|
|
83
83
|
data3: schemas.array(schemas.z.any()),
|
|
84
84
|
data4: schemas.array(schemas.z.any()),
|
|
85
|
+
// number (decimal)
|
|
86
|
+
dec1: schemas.positiveNumber().nullable(),
|
|
87
|
+
dec2: schemas.positiveNumber().nullable(),
|
|
88
|
+
dec3: schemas.positiveNumber().nullable(),
|
|
89
|
+
dec4: schemas.positiveNumber().nullable(),
|
|
90
|
+
// number (integer)
|
|
91
|
+
int1: schemas.positiveInteger().nullable(),
|
|
92
|
+
int2: schemas.positiveInteger().nullable(),
|
|
93
|
+
int3: schemas.positiveInteger().nullable(),
|
|
94
|
+
int4: schemas.positiveInteger().nullable(),
|
|
85
95
|
// ----------------------------------------------------------------------------
|
|
86
96
|
// translation
|
|
87
97
|
// ----------------------------------------------------------------------------
|
|
@@ -109,8 +119,8 @@ const postCreateValidator = ({
|
|
|
109
119
|
),
|
|
110
120
|
toc: schemas.array(tocItemSchema),
|
|
111
121
|
// extra
|
|
112
|
-
readTime: schemas.
|
|
113
|
-
wordCount: schemas.
|
|
122
|
+
readTime: schemas.positiveInteger().nullable(),
|
|
123
|
+
wordCount: schemas.positiveInteger(),
|
|
114
124
|
// -------------------------------------------
|
|
115
125
|
// --- custom fields
|
|
116
126
|
// -------------------------------------------
|
|
@@ -129,7 +139,17 @@ const postCreateValidator = ({
|
|
|
129
139
|
data1: schemas.array(schemas.z.any()),
|
|
130
140
|
data2: schemas.array(schemas.z.any()),
|
|
131
141
|
data3: schemas.array(schemas.z.any()),
|
|
132
|
-
data4: schemas.array(schemas.z.any())
|
|
142
|
+
data4: schemas.array(schemas.z.any()),
|
|
143
|
+
// number (decimal)
|
|
144
|
+
dec1: schemas.positiveNumber().nullable(),
|
|
145
|
+
dec2: schemas.positiveNumber().nullable(),
|
|
146
|
+
dec3: schemas.positiveNumber().nullable(),
|
|
147
|
+
dec4: schemas.positiveNumber().nullable(),
|
|
148
|
+
// number (integer)
|
|
149
|
+
int1: schemas.positiveInteger().nullable(),
|
|
150
|
+
int2: schemas.positiveInteger().nullable(),
|
|
151
|
+
int3: schemas.positiveInteger().nullable(),
|
|
152
|
+
int4: schemas.positiveInteger().nullable()
|
|
133
153
|
})
|
|
134
154
|
)
|
|
135
155
|
}).transform((obj) => ({
|
package/dist/src/server/interfaces/actions/resources/post/commands/update/post-update-validator.js
CHANGED
|
@@ -61,13 +61,13 @@ const postUpdateValidator = ({
|
|
|
61
61
|
state9: schemas.z.boolean(),
|
|
62
62
|
state10: schemas.z.boolean(),
|
|
63
63
|
// multi images
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
files1: schemas.multiItems({ table: "files", column: "id" }),
|
|
65
|
+
files2: schemas.multiItems({ table: "files", column: "id" }),
|
|
66
66
|
// single images
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
file1: schemas.singleItem({ table: "files", column: "id" }),
|
|
68
|
+
file2: schemas.singleItem({ table: "files", column: "id" }),
|
|
69
|
+
file3: schemas.singleItem({ table: "files", column: "id" }),
|
|
70
|
+
file4: schemas.singleItem({ table: "files", column: "id" }),
|
|
71
71
|
// text
|
|
72
72
|
text1: schemas.text().nullable(),
|
|
73
73
|
text2: schemas.text().nullable(),
|
|
@@ -84,6 +84,16 @@ const postUpdateValidator = ({
|
|
|
84
84
|
data2: schemas.array(schemas.z.any()),
|
|
85
85
|
data3: schemas.array(schemas.z.any()),
|
|
86
86
|
data4: schemas.array(schemas.z.any()),
|
|
87
|
+
// number (decimal)
|
|
88
|
+
dec1: schemas.positiveNumber().nullable(),
|
|
89
|
+
dec2: schemas.positiveNumber().nullable(),
|
|
90
|
+
dec3: schemas.positiveNumber().nullable(),
|
|
91
|
+
dec4: schemas.positiveNumber().nullable(),
|
|
92
|
+
// number (integer)
|
|
93
|
+
int1: schemas.positiveInteger().nullable(),
|
|
94
|
+
int2: schemas.positiveInteger().nullable(),
|
|
95
|
+
int3: schemas.positiveInteger().nullable(),
|
|
96
|
+
int4: schemas.positiveInteger().nullable(),
|
|
87
97
|
// ----------------------------------------------------------------------------
|
|
88
98
|
// translation
|
|
89
99
|
// ----------------------------------------------------------------------------
|
|
@@ -111,8 +121,8 @@ const postUpdateValidator = ({
|
|
|
111
121
|
),
|
|
112
122
|
toc: schemas.array(tocItemSchema),
|
|
113
123
|
// extra
|
|
114
|
-
readTime: schemas.
|
|
115
|
-
wordCount: schemas.
|
|
124
|
+
readTime: schemas.positiveInteger().nullable(),
|
|
125
|
+
wordCount: schemas.positiveInteger(),
|
|
116
126
|
// -------------------------------------------
|
|
117
127
|
// --- custom fields
|
|
118
128
|
// -------------------------------------------
|
|
@@ -131,7 +141,17 @@ const postUpdateValidator = ({
|
|
|
131
141
|
data1: schemas.array(schemas.z.any()),
|
|
132
142
|
data2: schemas.array(schemas.z.any()),
|
|
133
143
|
data3: schemas.array(schemas.z.any()),
|
|
134
|
-
data4: schemas.array(schemas.z.any())
|
|
144
|
+
data4: schemas.array(schemas.z.any()),
|
|
145
|
+
// number (decimal)
|
|
146
|
+
dec1: schemas.positiveNumber().nullable(),
|
|
147
|
+
dec2: schemas.positiveNumber().nullable(),
|
|
148
|
+
dec3: schemas.positiveNumber().nullable(),
|
|
149
|
+
dec4: schemas.positiveNumber().nullable(),
|
|
150
|
+
// number (integer)
|
|
151
|
+
int1: schemas.positiveInteger().nullable(),
|
|
152
|
+
int2: schemas.positiveInteger().nullable(),
|
|
153
|
+
int3: schemas.positiveInteger().nullable(),
|
|
154
|
+
int4: schemas.positiveInteger().nullable()
|
|
135
155
|
})
|
|
136
156
|
)
|
|
137
157
|
}).transform((obj) => ({
|
|
@@ -3,8 +3,8 @@ const multiFilesUploadValidator = (schemas) => schemas.z.object({
|
|
|
3
3
|
folderKey: schemas.key().exist({ table: "folders", column: "key" }).optional(),
|
|
4
4
|
blobFileInfos: schemas.array(
|
|
5
5
|
schemas.z.object({
|
|
6
|
-
width: schemas.
|
|
7
|
-
height: schemas.
|
|
6
|
+
width: schemas.positiveInteger().nullable(),
|
|
7
|
+
height: schemas.positiveInteger().nullable(),
|
|
8
8
|
duration: schemas.positiveNumber().nullable()
|
|
9
9
|
})
|
|
10
10
|
)
|
|
@@ -3,6 +3,9 @@ interface HtmlDisplayProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
3
3
|
html?: string | null;
|
|
4
4
|
textOnly?: boolean;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Render CMS HTML content with CKEditor-compatible media transforms.
|
|
8
|
+
*/
|
|
6
9
|
export declare function HtmlDisplay({ html, textOnly, className, ...props }: HtmlDisplayProps): import("react/jsx-runtime").JSX.Element;
|
|
7
10
|
export {};
|
|
8
11
|
//# sourceMappingURL=html-display.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-display.d.ts","sourceRoot":"","sources":["../../../../../../../../src/client/interfaces/components/ui/display/html-display.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"html-display.d.ts","sourceRoot":"","sources":["../../../../../../../../src/client/interfaces/components/ui/display/html-display.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAa5C,UAAU,gBAAiB,SAAQ,cAAc,CAAC,cAAc,CAAC;IAC/D,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,EAC1B,IAAS,EACT,QAAgB,EAChB,SAAc,EACd,GAAG,KAAK,EACT,EAAE,gBAAgB,2CAclB"}
|