@youwen/ai-design-system
Version:
Enterprise AI-driven design system with comprehensive design tokens
178 lines (177 loc) • 8.35 kB
TypeScript
/**
* Layer 1: Token & Schema Validation
* 基础合规验证 - 确保数据结构、类型、必需字段完全正确
*/
import { z } from 'zod';
import { ValidationLayer, LayerValidationResult } from '../validation-pipeline';
export declare const ComponentTypeSchema: z.ZodEnum<["ThreeElementLayout", "TwoLinesBigMedium", "TwoLinesMediumSmall", "TwoLinesSmallMini", "OneLineMediumSmall", "OneLineSmallMini", "ModuleList", "ModuleDivider", "ControlButton", "GraphPlaceholder", "GraphDefault", "WidgetCard", "WidgetGeneral", "SingleElement"]>;
export declare const LayoutSchema: z.ZodEnum<["leftTop", "rightTop", "leftBottom", "rightBottom", "leftTop,rightTop", "leftTop,leftBottom", "leftTop,rightBottom", "rightTop,leftBottom", "rightTop,rightBottom", "leftBottom,rightBottom", "leftTop,rightTop,leftBottom", "leftTop,rightTop,rightBottom", "leftTop,leftBottom,rightBottom", "rightTop,leftBottom,rightBottom", "all"]>;
export declare const ThemeSchema: z.ZodEnum<["blue", "green", "purple", "amber"]>;
export declare const ModeSchema: z.ZodEnum<["light", "dark"]>;
export declare const ContentSchema: z.ZodEffects<z.ZodObject<{
big: z.ZodOptional<z.ZodString>;
medium: z.ZodOptional<z.ZodString>;
small: z.ZodOptional<z.ZodString>;
mini: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
big?: string | undefined;
small?: string | undefined;
mini?: string | undefined;
medium?: string | undefined;
}, {
big?: string | undefined;
small?: string | undefined;
mini?: string | undefined;
medium?: string | undefined;
}>, {
big?: string | undefined;
small?: string | undefined;
mini?: string | undefined;
medium?: string | undefined;
}, {
big?: string | undefined;
small?: string | undefined;
mini?: string | undefined;
medium?: string | undefined;
}>;
export declare const WidgetComponentSchema: z.ZodObject<{
type: z.ZodEnum<["ThreeElementLayout", "TwoLinesBigMedium", "TwoLinesMediumSmall", "TwoLinesSmallMini", "OneLineMediumSmall", "OneLineSmallMini", "ModuleList", "ModuleDivider", "ControlButton", "GraphPlaceholder", "GraphDefault", "WidgetCard", "WidgetGeneral", "SingleElement"]>;
layout: z.ZodEnum<["leftTop", "rightTop", "leftBottom", "rightBottom", "leftTop,rightTop", "leftTop,leftBottom", "leftTop,rightBottom", "rightTop,leftBottom", "rightTop,rightBottom", "leftBottom,rightBottom", "leftTop,rightTop,leftBottom", "leftTop,rightTop,rightBottom", "leftTop,leftBottom,rightBottom", "rightTop,leftBottom,rightBottom", "all"]>;
theme: z.ZodEnum<["blue", "green", "purple", "amber"]>;
mode: z.ZodEnum<["light", "dark"]>;
content: z.ZodEffects<z.ZodObject<{
big: z.ZodOptional<z.ZodString>;
medium: z.ZodOptional<z.ZodString>;
small: z.ZodOptional<z.ZodString>;
mini: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
big?: string | undefined;
small?: string | undefined;
mini?: string | undefined;
medium?: string | undefined;
}, {
big?: string | undefined;
small?: string | undefined;
mini?: string | undefined;
medium?: string | undefined;
}>, {
big?: string | undefined;
small?: string | undefined;
mini?: string | undefined;
medium?: string | undefined;
}, {
big?: string | undefined;
small?: string | undefined;
mini?: string | undefined;
medium?: string | undefined;
}>;
}, "strip", z.ZodTypeAny, {
type: "ThreeElementLayout" | "WidgetCard" | "WidgetGeneral" | "TwoLinesBigMedium" | "TwoLinesMediumSmall" | "TwoLinesSmallMini" | "OneLineMediumSmall" | "OneLineSmallMini" | "ModuleList" | "ModuleDivider" | "ControlButton" | "GraphPlaceholder" | "GraphDefault" | "SingleElement";
content: {
big?: string | undefined;
small?: string | undefined;
mini?: string | undefined;
medium?: string | undefined;
};
theme: "blue" | "green" | "purple" | "amber";
layout: "leftTop" | "rightTop" | "leftBottom" | "rightBottom" | "leftTop,rightTop" | "leftTop,leftBottom" | "leftTop,rightBottom" | "rightTop,leftBottom" | "rightTop,rightBottom" | "leftBottom,rightBottom" | "leftTop,rightTop,leftBottom" | "leftTop,rightTop,rightBottom" | "leftTop,leftBottom,rightBottom" | "rightTop,leftBottom,rightBottom" | "all";
mode: "dark" | "light";
}, {
type: "ThreeElementLayout" | "WidgetCard" | "WidgetGeneral" | "TwoLinesBigMedium" | "TwoLinesMediumSmall" | "TwoLinesSmallMini" | "OneLineMediumSmall" | "OneLineSmallMini" | "ModuleList" | "ModuleDivider" | "ControlButton" | "GraphPlaceholder" | "GraphDefault" | "SingleElement";
content: {
big?: string | undefined;
small?: string | undefined;
mini?: string | undefined;
medium?: string | undefined;
};
theme: "blue" | "green" | "purple" | "amber";
layout: "leftTop" | "rightTop" | "leftBottom" | "rightBottom" | "leftTop,rightTop" | "leftTop,leftBottom" | "leftTop,rightBottom" | "rightTop,leftBottom" | "rightTop,rightBottom" | "leftBottom,rightBottom" | "leftTop,rightTop,leftBottom" | "leftTop,rightTop,rightBottom" | "leftTop,leftBottom,rightBottom" | "rightTop,leftBottom,rightBottom" | "all";
mode: "dark" | "light";
}>;
export declare const ColorTokenSchema: z.ZodObject<{
color: z.ZodString;
usage: z.ZodEnum<["background", "foreground", "border", "accent", "functional"]>;
themes: z.ZodArray<z.ZodEnum<["blue", "green", "purple", "amber"]>, "many">;
contrast: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
color: string;
themes: ("blue" | "green" | "purple" | "amber")[];
usage: "border" | "background" | "foreground" | "accent" | "functional";
contrast?: number | undefined;
}, {
color: string;
themes: ("blue" | "green" | "purple" | "amber")[];
usage: "border" | "background" | "foreground" | "accent" | "functional";
contrast?: number | undefined;
}>;
export declare const TypographyTokenSchema: z.ZodObject<{
fontFamily: z.ZodString;
fontSize: z.ZodString;
lineHeight: z.ZodString;
fontWeight: z.ZodEnum<["400", "500", "600", "700"]>;
minSize: z.ZodNumber;
lineHeightRatio: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
fontSize: string;
lineHeight: string;
fontWeight: "700" | "400" | "500" | "600";
fontFamily: string;
minSize: number;
lineHeightRatio: number;
}, {
fontSize: string;
lineHeight: string;
fontWeight: "700" | "400" | "500" | "600";
fontFamily: string;
minSize: number;
lineHeightRatio: number;
}>;
export declare const SpacingTokenSchema: z.ZodObject<{
value: z.ZodString;
category: z.ZodEnum<["padding", "margin", "gap", "offset"]>;
usage: z.ZodEnum<["widget", "layout", "component", "global"]>;
alignsToGrid: z.ZodOptional<z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
value: string;
usage: "layout" | "component" | "widget" | "global";
category: "padding" | "margin" | "gap" | "offset";
alignsToGrid?: boolean | undefined;
}, {
value: string;
usage: "layout" | "component" | "widget" | "global";
category: "padding" | "margin" | "gap" | "offset";
alignsToGrid?: boolean | undefined;
}>;
export declare const SizeTokenSchema: z.ZodObject<{
width: z.ZodString;
height: z.ZodString;
aspectRatio: z.ZodOptional<z.ZodNumber>;
isTouchTarget: z.ZodOptional<z.ZodBoolean>;
minTouchSize: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
width: string;
height: string;
aspectRatio?: number | undefined;
isTouchTarget?: boolean | undefined;
minTouchSize?: number | undefined;
}, {
width: string;
height: string;
aspectRatio?: number | undefined;
isTouchTarget?: boolean | undefined;
minTouchSize?: number | undefined;
}>;
export declare class Layer1TokenSchemaValidator implements ValidationLayer {
layerNumber: 1;
name: string;
description: string;
maxExecutionTime: number;
validate(input: any, context?: any): Promise<LayerValidationResult>;
private validateBasicSchema;
private validateDesignTokens;
private validateDataIntegrity;
private validateTypeSafety;
private generateSchemaSuggestion;
private calculateLayerScore;
}
export declare const layer1Validator: Layer1TokenSchemaValidator;