diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 6419723..c79af35 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -28,3 +28,189 @@ export interface Registry { createdAt: Date; updatedAt: Date; } + +export type CapabilityDisposition = + | "CORE" + | "DEPENDENCY" + | "CHERRY_PICK" + | "ADAPTER" + | "REIMPLEMENT" + | "REFERENCE_ONLY" + | "DROP"; + +export type EvidenceConfidence = + | "measured" + | "observed" + | "inferred" + | "declared" + | "unknown"; + +export type ReconstructionMode = "clone" | "adapt" | "blend"; + +export type EvidenceKind = + | "dom" + | "runtime-html" + | "computed-style" + | "stylesheet" + | "accessibility" + | "screenshot" + | "asset" + | "network-request" + | "network-response" + | "har" + | "websocket" + | "sse" + | "storage" + | "interaction" + | "state-transition" + | "workflow" + | "animation" + | "media" + | "canvas" + | "webgl" + | "performance" + | "semantic-observation"; + +export interface CaptureViewport { + width: number; + height: number; + deviceScaleFactor?: number; + isMobile?: boolean; + hasTouch?: boolean; +} + +export interface CaptureProfile { + id: string; + name: string; + authenticated: boolean; + role?: string; + locale?: string; + colorScheme?: "light" | "dark" | "no-preference"; + viewport?: CaptureViewport; + featureFlags?: Record; +} + +export interface ProvenanceSource { + repository?: string; + commit?: string; + sourcePaths?: string[]; + license?: string; + classification?: CapabilityDisposition; + adapter?: string; + tool?: string; + toolVersion?: string; +} + +export interface EvidenceRecord { + id: string; + targetId: string; + kind: EvidenceKind; + route?: string; + capturedAt: string; + method: string; + confidence: EvidenceConfidence; + captureProfileId: string; + viewport?: CaptureViewport; + source: ProvenanceSource; + payload: T; +} + +export interface RouteNode { + id: string; + path: string; + canonicalUrl?: string; + title?: string; + evidenceIds: string[]; +} + +export interface RouteEdge { + from: string; + to: string; + trigger: "link" | "redirect" | "action" | "script" | "semantic-discovery"; + evidenceIds: string[]; +} + +export interface StateTransition { + id: string; + fromState: string; + toState: string; + action: string; + evidenceIds: string[]; + networkEvidenceIds?: string[]; +} + +export interface ProductEntity { + id: string; + name: string; + attributes: Record; + evidenceIds: string[]; + confidence: EvidenceConfidence; +} + +export interface ProductRelationship { + id: string; + fromEntityId: string; + toEntityId: string; + type: string; + cardinality?: "one-to-one" | "one-to-many" | "many-to-one" | "many-to-many"; + evidenceIds: string[]; + confidence: EvidenceConfidence; +} + +export interface WorkflowStep { + id: string; + action: string; + preconditions?: string[]; + resultingState?: string; + evidenceIds: string[]; +} + +export interface ProductWorkflow { + id: string; + name: string; + steps: WorkflowStep[]; + errorPaths?: WorkflowStep[][]; + evidenceIds: string[]; + confidence: EvidenceConfidence; +} + +export interface FidelityVector { + geometry?: number; + typography?: number; + colors?: number; + assets?: number; + responsiveCoverage?: number; + routeCoverage?: number; + interactionCoverage?: number; + workflowCoverage?: number; + networkContractParity?: number; + motionParity?: number; + accessibilityPass?: boolean; + runtimeErrorCount?: number; + productionBuildPass?: boolean; +} + +export interface UpstreamCapabilityRecord { + id: string; + capability: string; + disposition: CapabilityDisposition; + source: ProvenanceSource; + targetModule?: string; + rationale: string; + tests: string[]; +} + +export interface ReconstructionSpec { + id: string; + targetId: string; + version: string; + mode: ReconstructionMode; + schemaVersion: string; + evidenceIds: string[]; + routes: RouteNode[]; + routeEdges: RouteEdge[]; + entities: ProductEntity[]; + relationships: ProductRelationship[]; + workflows: ProductWorkflow[]; + fidelityRequirements: FidelityVector; +}