feat: 建立模板运行时契约骨架
This commit is contained in:
1 parent
6c3eb3bfca
commit
40b08b5e1d
3 files changed
+168
No files matched your search
@@ -38,3 +38,5 @@ export interface PublicOffering {
|
||||
categoryKey?: string;
|
||||
config?: Record<string, unknown> | null;
|
||||
}
|
||||
|
||||
export * from "./runtime-workspace.js";
|
||||
@@ -0,0 +1,130 @@
|
||||
export type ManifestCategory = "industry" | "visual" | "hybrid";
|
||||
|
||||
export type WorkspaceModuleType =
|
||||
| "brand-hero"
|
||||
| "founder-card"
|
||||
| "trust-proof"
|
||||
| "offering-list"
|
||||
| "offering-detail"
|
||||
| "gallery"
|
||||
| "timeline"
|
||||
| "faq"
|
||||
| "contact"
|
||||
| "inquiry"
|
||||
| "records"
|
||||
| "custom";
|
||||
|
||||
export interface ThemeManifest {
|
||||
colors: Record<string, string>;
|
||||
typography?: Record<string, string>;
|
||||
spacing?: Record<string, string>;
|
||||
radius?: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface TemplateManifest {
|
||||
templateKey: string;
|
||||
version: string;
|
||||
category: ManifestCategory;
|
||||
displayName: string;
|
||||
requiredModules: string[];
|
||||
optionalModules: string[];
|
||||
offeringSchema: string;
|
||||
inquirySchemas: string[];
|
||||
requiredCapabilities: string[];
|
||||
optionalCapabilities: string[];
|
||||
theme: ThemeManifest;
|
||||
}
|
||||
|
||||
export interface ModuleManifest {
|
||||
key: string;
|
||||
version: string;
|
||||
type: WorkspaceModuleType;
|
||||
propsSchema: string;
|
||||
dataSource?: string;
|
||||
variant?: string;
|
||||
visibilityRules?: VisibilityRule[];
|
||||
}
|
||||
|
||||
export interface VisibilityRule {
|
||||
field: string;
|
||||
operator: "equals" | "not-equals" | "exists" | "in";
|
||||
value?: string | number | boolean | string[];
|
||||
}
|
||||
|
||||
export interface CapabilityManifest {
|
||||
key: string;
|
||||
version: string;
|
||||
permissions: string[];
|
||||
apiContract: string;
|
||||
requiredModules: string[];
|
||||
supportedWorkflows: string[];
|
||||
}
|
||||
|
||||
export interface RuntimeModule extends ModuleManifest {
|
||||
config: Record<string, unknown>;
|
||||
source: "core" | "template" | "custom";
|
||||
}
|
||||
|
||||
export interface RuntimeOffering {
|
||||
id: string;
|
||||
name: string;
|
||||
summary: string;
|
||||
enabled: boolean;
|
||||
schemaKey: string;
|
||||
schemaVersion: string;
|
||||
sections: Array<{
|
||||
key: string;
|
||||
type: "text" | "image-list" | "timeline" | "faq" | "specification";
|
||||
config: Record<string, unknown>;
|
||||
}>;
|
||||
}
|
||||
|
||||
export interface RuntimeInquiryField {
|
||||
key: string;
|
||||
label: string;
|
||||
type: "text" | "tel" | "number" | "select" | "radio" | "checkbox" | "textarea" | "date";
|
||||
required: boolean;
|
||||
options?: Array<{ label: string; value: string }>;
|
||||
visibleWhen?: VisibilityRule[];
|
||||
}
|
||||
|
||||
export interface RuntimeInquiryForm {
|
||||
key: string;
|
||||
version: string;
|
||||
purpose: "inquiry" | "booking" | "quote-request";
|
||||
target: "brand" | "offering";
|
||||
submissionAction: "create-inquiry" | "create-booking" | "create-quote";
|
||||
fields: RuntimeInquiryField[];
|
||||
}
|
||||
|
||||
export interface RuntimeCapability {
|
||||
key: string;
|
||||
version: string;
|
||||
config: Record<string, unknown>;
|
||||
status: "enabled" | "disabled" | "degraded";
|
||||
}
|
||||
|
||||
export interface RuntimeWorkspace {
|
||||
schemaVersion: string;
|
||||
brand: Record<string, unknown>;
|
||||
navigation: {
|
||||
tabs: Array<{ key: string; label: string; page: string }>;
|
||||
};
|
||||
modules: RuntimeModule[];
|
||||
offerings: RuntimeOffering[];
|
||||
inquiryForms: RuntimeInquiryForm[];
|
||||
capabilities: RuntimeCapability[];
|
||||
theme: ThemeManifest;
|
||||
}
|
||||
|
||||
export function validateTemplateManifest(manifest: TemplateManifest): string[] {
|
||||
const errors: string[] = [];
|
||||
if (!manifest.templateKey.trim()) errors.push("templateKey is required");
|
||||
if (!manifest.version.trim()) errors.push("version is required");
|
||||
if (!manifest.displayName.trim()) errors.push("displayName is required");
|
||||
if (!manifest.offeringSchema.trim()) errors.push("offeringSchema is required");
|
||||
if (!manifest.theme || Object.keys(manifest.theme.colors).length === 0) {
|
||||
errors.push("theme.colors must not be empty");
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
Reference in new issue
Block a user