feat: 建立工作流与能力注册表
This commit is contained in:
1 parent
c00e188392
commit
29d14378a7
5 files changed
+62
-5
No files matched your search
@@ -124,6 +124,11 @@ export interface BrandTemplateDefinition {
|
||||
required: boolean;
|
||||
}>;
|
||||
capabilities: string[];
|
||||
runtimeCapabilities: Array<{
|
||||
key: string;
|
||||
version: string;
|
||||
workflowKey?: string;
|
||||
}>;
|
||||
}
|
||||
export interface OfferingSection {
|
||||
type: "text" | "image-list" | "timeline" | "faq";
|
||||
|
||||
@@ -1,6 +1,41 @@
|
||||
export const configPackageName = "personal-brand-config";
|
||||
|
||||
export type BrandTemplateKey = "personal" | "food";
|
||||
export type CapabilityKey = "offerings" | "inquiry" | "booking";
|
||||
|
||||
export interface WorkflowDefinition {
|
||||
key: string;
|
||||
version: string;
|
||||
initialState: string;
|
||||
transitions: Record<string, readonly string[]>;
|
||||
}
|
||||
|
||||
export interface CapabilityDefinition {
|
||||
key: CapabilityKey;
|
||||
version: string;
|
||||
workflowKey?: string;
|
||||
}
|
||||
|
||||
export const workflowRegistry = {
|
||||
"booking.basic": {
|
||||
key: "booking.basic",
|
||||
version: "1.0.0",
|
||||
initialState: "received",
|
||||
transitions: {
|
||||
received: ["contacting", "cancelled"],
|
||||
contacting: ["confirmed", "cancelled"],
|
||||
confirmed: ["completed", "cancelled"],
|
||||
completed: [],
|
||||
cancelled: [],
|
||||
},
|
||||
},
|
||||
} as const satisfies Record<string, WorkflowDefinition>;
|
||||
|
||||
export const capabilityRegistry = {
|
||||
offerings: { key: "offerings", version: "1.0.0" },
|
||||
inquiry: { key: "inquiry", version: "1.0.0" },
|
||||
booking: { key: "booking", version: "1.0.0", workflowKey: "booking.basic" },
|
||||
} as const satisfies Record<CapabilityKey, CapabilityDefinition>;
|
||||
|
||||
export type BrandTemplateModuleType = "identity" | "trust" | "offering" | "inquiry" | "contact";
|
||||
|
||||
@@ -27,7 +62,17 @@ export interface BrandTemplateDefinition {
|
||||
trustContentTypes: string[];
|
||||
modules: BrandTemplateModuleDefinition[];
|
||||
fields: BrandTemplateFieldDefinition[];
|
||||
capabilities: string[];
|
||||
capabilities: CapabilityKey[];
|
||||
}
|
||||
|
||||
export function canTransitionWorkflow(workflowKey: string, from: string, to: string): boolean {
|
||||
const workflow = workflowRegistry[workflowKey as keyof typeof workflowRegistry] as
|
||||
WorkflowDefinition | undefined;
|
||||
return workflow ? from === to || workflow.transitions[from]?.includes(to) === true : false;
|
||||
}
|
||||
|
||||
export function resolveCapabilities(keys: readonly CapabilityKey[]): CapabilityDefinition[] {
|
||||
return keys.map((key) => capabilityRegistry[key]);
|
||||
}
|
||||
|
||||
export const brandTemplates = {
|
||||
|
||||
Reference in new issue
Block a user