feat: 分离模板演示数据并校验预览资源
This commit is contained in:
1 parent
6edde5a8d6
commit
b60174885e
31 files changed
+1785
-69
No files matched your search
@@ -5,6 +5,8 @@ import {
|
||||
PayloadTooLargeException,
|
||||
} from "@nestjs/common";
|
||||
import { validateTemplatePackageManifest } from "@personal-brand/config";
|
||||
import { validateTemplatePreviewFixtures } from "@personal-brand/validation";
|
||||
import type { Prisma } from "@prisma/client";
|
||||
import type { FastifyRequest } from "fastify";
|
||||
import { createHash } from "node:crypto";
|
||||
import { execFile } from "node:child_process";
|
||||
@@ -24,6 +26,8 @@ type Manifest = {
|
||||
version: string;
|
||||
displayName: string;
|
||||
visualTemplateKey?: string;
|
||||
supportedIndustryTemplates?: string[];
|
||||
previewFixture?: Prisma.InputJsonValue;
|
||||
};
|
||||
|
||||
type ChecksumFile = {
|
||||
@@ -419,6 +423,16 @@ export class AdminTemplatePackageService {
|
||||
}
|
||||
if (errors.length)
|
||||
throw new BadRequestException(`template.json 不符合模板契约:${errors.join(";")}`);
|
||||
if (manifest.previewFixture !== undefined) {
|
||||
const issues = validateTemplatePreviewFixtures(
|
||||
manifest.previewFixture,
|
||||
manifest.supportedIndustryTemplates ?? [],
|
||||
);
|
||||
if (issues.length)
|
||||
throw new BadRequestException(
|
||||
`previewFixture 不符合预览契约:${issues.map((issue) => `${issue.path}: ${issue.message}`).join(";")}`,
|
||||
);
|
||||
}
|
||||
if (
|
||||
checksums.formatVersion !== "1" ||
|
||||
checksums.packageKey !== manifest.packageKey ||
|
||||
|
||||
Reference in new issue
Block a user