/** * ModelGenerator - Interface for POWL model construction * * This class provides the API used in the Kourani et al. paper's examples * for constructing POWL models programmatically. * * The generated model tree can be converted to POWL string representation * and parsed by the Powl WASM library. * * Usage: * ```ts * const gen = new ModelGenerator(); * const create = gen.activity("Create order"); * const check = gen.activity("Check order"); * const accept = gen.activity("Accept order"); * const reject = gen.activity("Reject order"); * * const decision = gen.xor(accept, reject); * const model = gen.sequence(create, check, decision); * * const powlString = gen.toString(model); * // powlString -> "S( Create order, Check order, X( Accept order, Reject order ) )" * ``` */ /** * Activity node (leaf in the model tree) */ export interface ActivityNode { type: "activity"; label: string; id: string; } /** * XOR operator (exclusive choice between alternatives) */ export interface XorNode { type: "xor"; children: ModelNode[]; id: string; } /** * Loop operator (repeat-do or repeat-until) */ export interface LoopNode { type: "loop"; do: ModelNode; redo: ModelNode | null; id: string; } /** * Strict partial order (concurrent activities with dependencies) */ export interface PartialOrderNode { type: "partial_order"; dependencies: Array<[ModelNode, ModelNode]>; nodes: ModelNode[]; id: string; } /** * Sequence operator (sequential composition) */ export interface SequenceNode { type: "sequence"; children: ModelNode[]; id: string; } /** * Any node in the POWL model tree */ export type ModelNode = ActivityNode | XorNode | LoopNode | PartialOrderNode | SequenceNode; /** * ModelGenerator class for constructing POWL models */ export declare class ModelGenerator { private nextId; /** * Generate unique ID for node tracking */ private generateId; /** * Create an activity node * * @param label The activity label (e.g., "Create order") * @returns Activity node */ activity(label: string): ActivityNode; /** * Create an XOR (exclusive choice) operator * * Represents mutually exclusive paths where exactly one branch is taken. * Requires at least 2 alternatives. * * @param children Alternative branches (must be >= 2) * @returns XOR node * @throws {Error} if less than 2 children provided */ xor(...children: ModelNode[]): XorNode; /** * Create a LOOP operator * * Represents a repeating structure with a mandatory body ('do' part) * and an optional redo part. If redo is null, the loop repeats the do part. * * @param doPart The mandatory body of the loop * @param redoPart The optional redo part (null for repeat-until) * @returns Loop node */ loop(doPart: ModelNode, redoPart?: ModelNode | null): LoopNode; /** * Create a STRICT PARTIAL ORDER operator * * Represents concurrent activities with ordering constraints. * Dependencies specify which activities must precede others. * * CRITICAL RULES: * - IRREFLEXIVE: No activity can precede itself (A,A is invalid) * - TRANSITIVE: If A→B and B→C, then A→C must be explicitly included * * @param config Configuration with dependencies array * @returns Partial order node * @throws {Error} if dependencies violate irreflexivity or transitivity */ partial_order(config: { dependencies: Array<[ModelNode, ModelNode]>; }): PartialOrderNode; /** * Create a SEQUENCE operator * * Represents sequential composition where activities execute in order. * * @param children Activities to execute in sequence * @returns Sequence node */ sequence(...children: ModelNode[]): SequenceNode; /** * Create a deep copy of a model node * * This is critical when reusing sub-models in multiple places. * Each copy gets a unique ID to avoid conflicts. * * @param node The node to copy * @returns A deep copy with new IDs */ copy(node: ModelNode): ModelNode; /** * Convert model tree to POWL string representation * * The output format matches the Python __repr__ format and can be * parsed by the Powl WASM library. * * @param model The root model node * @returns POWL string representation */ toString(model: ModelNode): string; /** * Recursively convert a node to POWL string format */ private nodeToString; /** * Validate a model node structure * * Checks for common structural errors before converting to POWL string. * * @param node The node to validate * @returns Object with isValid flag and error messages */ validate(node: ModelNode): { isValid: boolean; errors: string[]; warnings: string[]; }; /** * Get statistics about a model tree * * @param node The root node * @returns Statistics object */ getStatistics(node: ModelNode): { totalNodes: number; nodeTypeCounts: Record; maxDepth: number; activities: string[]; }; } /** * Create a default ModelGenerator instance */ export declare function createModelGenerator(): ModelGenerator; //# sourceMappingURL=model-generator.d.ts.map