@typescript-eda/domain
Version:
Core domain primitives for event-driven architecture
234 lines • 6.23 kB
TypeScript
/**
* @fileoverview SemanTestCapability entity representing automation capabilities
* @author Semantest Team
* @module domain/semantic-automation/semantest-capability
*/
import { Entity } from '../entity';
import { ParameterDefinition, ParameterType, ExecutionCondition } from './semantest-contract.entity';
/**
* Properties for SemanTestCapability entity
*/
export interface SemanTestCapabilityProps {
readonly id: string;
readonly name: string;
readonly type: CapabilityType;
readonly description: string;
readonly selector: string | SelectorDefinition;
readonly parameters?: ParameterDefinition[];
readonly returnType?: ReturnTypeDefinition;
readonly validation?: ValidationRules;
readonly timeout?: number;
readonly retries?: number;
readonly conditions?: ExecutionCondition[];
readonly examples?: CapabilityExample[];
readonly createdAt: Date;
readonly updatedAt: Date;
}
/**
* Types of automation capabilities
*/
export type CapabilityType = 'action' | 'query' | 'navigation' | 'form' | 'file' | 'wait' | 'validation';
/**
* Selector definition with fallback strategies
*/
export interface SelectorDefinition {
readonly primary: string;
readonly fallback?: string[];
readonly wait?: WaitCondition;
readonly validator?: string;
readonly frame?: string;
readonly shadowRoot?: boolean;
}
/**
* Return type definition
*/
export interface ReturnTypeDefinition {
readonly type: ParameterType | 'void';
readonly description?: string;
readonly schema?: object;
readonly examples?: any[];
}
/**
* Validation rules for capabilities
*/
export interface ValidationRules {
readonly elementExists?: boolean;
readonly elementVisible?: boolean;
readonly elementEnabled?: boolean;
readonly customValidator?: string;
}
/**
* Wait condition definitions
*/
export interface WaitCondition {
readonly type: WaitType;
readonly timeout?: number;
readonly text?: string;
readonly customCondition?: string;
}
/**
* Wait types
*/
export type WaitType = 'visible' | 'present' | 'hidden' | 'enabled' | 'text' | 'custom';
/**
* Capability examples
*/
export interface CapabilityExample {
readonly description: string;
readonly parameters: Record<string, any>;
readonly expectedResult?: any;
readonly executionTime?: number;
}
/**
* Validation result for capabilities
*/
export interface CapabilityValidationResult {
readonly valid: boolean;
readonly errors: string[];
readonly warnings: string[];
readonly timestamp: Date;
}
/**
* SemanTestCapability entity representing individual automation capabilities
* Extends Entity from typescript-eda-domain for consistent domain modeling
*/
export declare class SemanTestCapability extends Entity<SemanTestCapabilityProps> {
constructor(props: SemanTestCapabilityProps);
/**
* Factory method to create a new capability
*/
static create(id: string, name: string, type: CapabilityType, description: string, selector: string | SelectorDefinition, options?: {
parameters?: ParameterDefinition[];
returnType?: ReturnTypeDefinition;
validation?: ValidationRules;
timeout?: number;
retries?: number;
conditions?: ExecutionCondition[];
examples?: CapabilityExample[];
}): SemanTestCapability;
/**
* Get capability ID
*/
getId(): string;
/**
* Get capability name
*/
getName(): string;
/**
* Get capability type
*/
getType(): CapabilityType;
/**
* Get capability description
*/
getDescription(): string;
/**
* Get element selector
*/
getSelector(): string | SelectorDefinition;
/**
* Get primary selector string
*/
getPrimarySelector(): string;
/**
* Get fallback selectors
*/
getFallbackSelectors(): string[];
/**
* Get all selectors (primary + fallbacks)
*/
getAllSelectors(): string[];
/**
* Get capability parameters
*/
getParameters(): ParameterDefinition[];
/**
* Get required parameters
*/
getRequiredParameters(): ParameterDefinition[];
/**
* Get optional parameters
*/
getOptionalParameters(): ParameterDefinition[];
/**
* Get parameter by name
*/
getParameter(name: string): ParameterDefinition | undefined;
/**
* Check if capability has parameter
*/
hasParameter(name: string): boolean;
/**
* Get return type definition
*/
getReturnType(): ReturnTypeDefinition | undefined;
/**
* Get validation rules
*/
getValidation(): ValidationRules | undefined;
/**
* Get execution timeout
*/
getTimeout(): number | undefined;
/**
* Get retry attempts
*/
getRetries(): number | undefined;
/**
* Get execution conditions
*/
getConditions(): ExecutionCondition[];
/**
* Get capability examples
*/
getExamples(): CapabilityExample[];
/**
* Get creation timestamp
*/
getCreatedAt(): Date;
/**
* Get last update timestamp
*/
getUpdatedAt(): Date;
/**
* Check if capability is an action type
*/
isAction(): boolean;
/**
* Check if capability is a query type
*/
isQuery(): boolean;
/**
* Check if capability is a form type
*/
isForm(): boolean;
/**
* Check if capability requires parameters
*/
requiresParameters(): boolean;
/**
* Validate parameter values against capability definition
*/
validateParameters(parameters: Record<string, any>): {
valid: boolean;
errors: string[];
warnings: string[];
};
/**
* Validate capability structure and configuration
*/
validate(): CapabilityValidationResult;
/**
* Basic CSS selector validation
*/
private isValidCSSSelector;
/**
* Convert capability to JSON for serialization
*/
toJSON(): Record<string, any>;
/**
* Create capability from JSON
*/
static fromJSON(json: any): SemanTestCapability;
}
//# sourceMappingURL=semantest-capability.entity.d.ts.map