UNPKG

@typescript-eda/domain

Version:

Core domain primitives for event-driven architecture

221 lines 5.9 kB
/** * @fileoverview SemanTestContract entity representing automation contracts * @author Semantest Team * @module domain/semantic-automation/semantest-contract */ import { Entity } from '../entity'; import { SemanTestCapability } from './semantest-capability.entity'; /** * Properties for SemanTestContract entity */ export interface SemanTestContractProps { readonly id: string; readonly version: string; readonly domain: string; readonly title: string; readonly description?: string; readonly capabilities: Record<string, SemanTestCapability>; readonly workflows?: Record<string, WorkflowDefinition>; readonly metadata?: ContractMetadata; readonly createdAt: Date; readonly updatedAt: Date; } /** * Workflow definition for multi-step automation */ export interface WorkflowDefinition { readonly description: string; readonly parameters?: ParameterDefinition[]; readonly steps: WorkflowStep[]; readonly errorHandling?: ErrorHandling; } /** * Individual workflow step */ export interface WorkflowStep { readonly capability: string; readonly parameters?: Record<string, any>; readonly condition?: ExecutionCondition; readonly onSuccess?: string; readonly onFailure?: string; readonly retry?: RetryConfiguration; } /** * Parameter definition for workflows and capabilities */ export interface ParameterDefinition { readonly name: string; readonly type: ParameterType; readonly description?: string; readonly required?: boolean; readonly default?: any; readonly validation?: ParameterValidation; readonly examples?: any[]; } /** * Parameter data types */ export type ParameterType = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'file'; /** * Parameter validation rules */ export interface ParameterValidation { readonly minLength?: number; readonly maxLength?: number; readonly pattern?: string; readonly minimum?: number; readonly maximum?: number; readonly enum?: any[]; } /** * Execution conditions */ export interface ExecutionCondition { readonly type: ConditionType; readonly selector?: string; readonly urlPattern?: string; readonly text?: string; readonly customCondition?: string; readonly negate?: boolean; } /** * Condition types */ export type ConditionType = 'element' | 'url' | 'text' | 'custom'; /** * Retry configuration */ export interface RetryConfiguration { readonly attempts: number; readonly delay: number; } /** * Error handling strategy */ export interface ErrorHandling { readonly strategy: ErrorStrategy; readonly maxRetries?: number; readonly fallbackCapability?: string; } /** * Error handling strategies */ export type ErrorStrategy = 'abort' | 'continue' | 'retry' | 'fallback'; /** * Contract metadata */ export interface ContractMetadata { readonly author?: string; readonly tags?: string[]; readonly compatibilityScore?: number; readonly validationResults?: ValidationResult[]; } /** * Validation result */ export interface ValidationResult { readonly valid: boolean; readonly errors: string[]; readonly warnings: string[]; readonly timestamp: Date; } /** * SemanTestContract entity representing automation contracts * Extends Entity from typescript-eda-domain for consistent domain modeling */ export declare class SemanTestContract extends Entity<SemanTestContractProps> { constructor(props: SemanTestContractProps); /** * Factory method to create a new contract */ static create(id: string, version: string, domain: string, title: string, capabilities: Record<string, SemanTestCapability>, options?: { description?: string; workflows?: Record<string, WorkflowDefinition>; metadata?: ContractMetadata; }): SemanTestContract; /** * Get contract ID */ getId(): string; /** * Get contract version */ getVersion(): string; /** * Get target domain */ getDomain(): string; /** * Get contract title */ getTitle(): string; /** * Get contract description */ getDescription(): string | undefined; /** * Get all capabilities */ getCapabilities(): Record<string, SemanTestCapability>; /** * Get specific capability by name */ getCapability(name: string): SemanTestCapability | undefined; /** * Get capability names */ getCapabilityNames(): string[]; /** * Check if contract has capability */ hasCapability(name: string): boolean; /** * Get workflows */ getWorkflows(): Record<string, WorkflowDefinition> | undefined; /** * Get specific workflow by name */ getWorkflow(name: string): WorkflowDefinition | undefined; /** * Get contract metadata */ getMetadata(): ContractMetadata | undefined; /** * Get creation timestamp */ getCreatedAt(): Date; /** * Get last update timestamp */ getUpdatedAt(): Date; /** * Add or update capability */ withCapability(name: string, capability: SemanTestCapability): SemanTestContract; /** * Remove capability */ withoutCapability(name: string): SemanTestContract; /** * Update contract metadata */ withMetadata(metadata: ContractMetadata): SemanTestContract; /** * Add workflow */ withWorkflow(name: string, workflow: WorkflowDefinition): SemanTestContract; /** * Validate contract structure and capabilities */ validate(): ValidationResult; /** * Convert contract to JSON for serialization */ toJSON(): Record<string, any>; /** * Create contract from JSON */ static fromJSON(json: any): SemanTestContract; } //# sourceMappingURL=semantest-contract.entity.d.ts.map