fix: 收口模板契约与安全门禁
统一模板包 visual 契约并补齐完成证据;修复 release 版本一致性、管理员 token 撤销、CORS 与默认品牌配置;收敛依赖安全风险并完成全量回归验证。
This commit is contained in:
1 parent
456171aa85
commit
4f0b50c7f1
84 files changed
+7367
-5180
No files matched your search
@@ -133,11 +133,24 @@ export type TemplateSampleContent = {
|
||||
capabilityKey: string;
|
||||
};
|
||||
|
||||
export type TemplateVisualPresentation = {
|
||||
description: string;
|
||||
variants: Record<string, string>;
|
||||
theme: { colors: Record<string, string>; radius: Record<string, string> };
|
||||
layout?: {
|
||||
home: string[];
|
||||
offerings: string[];
|
||||
detail: string[];
|
||||
profile: string[];
|
||||
};
|
||||
};
|
||||
|
||||
export type TemplatePackageManifest = {
|
||||
packageKey: string;
|
||||
version: string;
|
||||
displayName: string;
|
||||
visualTemplateKey: string;
|
||||
visualPresentation: TemplateVisualPresentation;
|
||||
runtimeContract: typeof TEMPLATE_RUNTIME_CONTRACT;
|
||||
supportedIndustryTemplates: string[];
|
||||
entrypoints: Record<string, string>;
|
||||
@@ -179,6 +192,36 @@ export function validateTemplatePackageManifest(value: unknown): string[] {
|
||||
if (manifest.runtimeContract !== TEMPLATE_RUNTIME_CONTRACT)
|
||||
errors.push(`runtimeContract must be ${TEMPLATE_RUNTIME_CONTRACT}`);
|
||||
if (!manifest.displayName?.trim()) errors.push("displayName is required");
|
||||
const presentation = manifest.visualPresentation;
|
||||
if (
|
||||
!presentation ||
|
||||
typeof presentation !== "object" ||
|
||||
!presentation.description?.trim() ||
|
||||
!presentation.variants ||
|
||||
typeof presentation.variants !== "object" ||
|
||||
Array.isArray(presentation.variants) ||
|
||||
!Object.values(presentation.variants).every(
|
||||
(variant) => typeof variant === "string" && variant.trim(),
|
||||
) ||
|
||||
!presentation.theme ||
|
||||
typeof presentation.theme !== "object" ||
|
||||
!presentation.theme.colors ||
|
||||
typeof presentation.theme.colors !== "object" ||
|
||||
!presentation.theme.radius ||
|
||||
typeof presentation.theme.radius !== "object"
|
||||
) {
|
||||
errors.push("visualPresentation requires description, variants, theme.colors and theme.radius");
|
||||
} else if (presentation.layout) {
|
||||
const layout = presentation.layout;
|
||||
if (
|
||||
!(["home", "offerings", "detail", "profile"] as const).every(
|
||||
(page) =>
|
||||
Array.isArray(layout[page]) && layout[page].every((item) => typeof item === "string"),
|
||||
)
|
||||
) {
|
||||
errors.push("visualPresentation.layout must contain page module arrays");
|
||||
}
|
||||
}
|
||||
if (
|
||||
!Array.isArray(manifest.supportedIndustryTemplates) ||
|
||||
!manifest.supportedIndustryTemplates.length
|
||||
|
||||
Reference in new issue
Block a user