@xec-sh/core
Version:
Universal shell execution engine
54 lines (53 loc) • 2.17 kB
TypeScript
import type { Command } from '../core/command.js';
import type { ExecutionResult } from '../core/result.js';
import type { ExecutionConfig } from '../core/config.js';
import type { CallableExecutionEngine } from '../types/engine.js';
import type { ExecutionEngine } from '../core/execution-engine.js';
export interface TemplateOptions extends Partial<ExecutionConfig> {
validate?: (params: Record<string, any>) => void | Promise<void>;
transform?: (result: ExecutionResult) => any;
defaults?: Record<string, any>;
}
export declare class CommandTemplate {
private template;
private options;
private requiredParams;
constructor(template: string, options?: TemplateOptions);
private extractRequiredParams;
private interpolate;
private escapeShellArg;
execute(engine: ExecutionEngine | CallableExecutionEngine, params?: Record<string, any>): Promise<any>;
bind(engine: ExecutionEngine | CallableExecutionEngine): BoundTemplate;
getRequiredParams(): string[];
describe(): string;
}
export declare class BoundTemplate {
private template;
private engine;
constructor(template: CommandTemplate, engine: ExecutionEngine | CallableExecutionEngine);
execute(params?: Record<string, any>): Promise<any>;
with(config: Partial<Command>): BoundTemplate;
}
export declare class TemplateRegistry {
private templates;
register(name: string, template: string | CommandTemplate, options?: TemplateOptions): void;
get(name: string): CommandTemplate | undefined;
has(name: string): boolean;
list(): string[];
bind(engine: ExecutionEngine | CallableExecutionEngine): BoundRegistry;
}
export declare class BoundRegistry {
private registry;
private engine;
constructor(registry: TemplateRegistry, engine: ExecutionEngine | CallableExecutionEngine);
execute(name: string, params?: Record<string, any>): Promise<any>;
get(name: string): BoundTemplate | undefined;
}
export declare const commonTemplates: {
gitClone: CommandTemplate;
dockerRun: CommandTemplate;
curl: CommandTemplate;
mkdir: CommandTemplate;
rsync: CommandTemplate;
tar: CommandTemplate;
};