type BulkCaptureStatus = 'captured' | 'processing' | 'ready' | 'failed' | 'partial'; type CommitChangeLevel = 'BLOCK' | 'NAVE' | 'BED' | 'SQUARE' | 'CELL'; type CommitChangeAction = 'CREATE' | 'UPDATE' | 'DELETE' | 'ACTIVATE' | 'DEACTIVATE'; type FarmSize = 'small' | 'medium' | 'large'; type FarmStateConfig = 'draft' | 'finished'; type FarmType = 'test' | 'production'; type GeoUnitType = 'NAVE' | 'BED' | 'SQUARE' | 'CELL'; type IdentityQuality = 'authoritative' | 'derived' | 'unavailable'; type GeoUnitGranularity = 'squares' | 'cells' | 'lines'; type LineageClassification = 'SAFE_CANDIDATE' | 'QUARANTINE'; type LineageConfidence = 'HIGH' | 'MEDIUM' | 'LOW'; type ObservationStatus = 'open' | 'in_progress' | 'resolved' | 'dismissed'; type PlantingBatchCode = 'VALID_EXACT' | 'VALID_LATEST_EQUIVALENT' | 'STRUCTURE_VERSION_OUTDATED_BUT_EQUIVALENT' | 'STRUCTURE_VERSION_OUTDATED_AND_CHANGED' | 'STRUCTURE_NOT_FOUND' | 'STRUCTURE_VERSION_NOT_FOUND' | 'GEO_UNIT_NOT_FOUND' | 'GEO_UNIT_NOT_IN_STRUCTURE' | 'GEO_UNIT_INACTIVE' | 'INVALID_GEO_UNIT_TYPE' | 'AS_OF_DATE_OUT_OF_RANGE'; type IStructureLocationLevel = 'BLOCK' | 'NAVE' | 'BED' | 'SQUARE' | 'CELL'; type Square = number | null; interface IBed { name: string; active: boolean; squares: Square[]; } interface INave { name: string; maxSquares: number; leftPath: boolean; active: boolean; beds: IBed[]; } interface IStructure { _id?: string; farmId?: string; blockName?: string; sides?: number; bedsNave?: number; maxTotalBeds?: number; maxTotalNaves?: number; centralRoadSize?: number; widthBed?: number; lengthBed?: number; bedRoadSize?: number; pointA?: [number, number]; pointB?: [number, number]; startPoint?: [number, number]; implemented?: number; alignment?: INave[][]; draft?: boolean; version?: number | null; } interface IBulkCaptureItem { index: number; blockName: string; captureId: string; status: BulkCaptureStatus; draftBlockId?: string; error?: string; } interface IBulkCaptureResponse { jobId: string; status: BulkCaptureStatus; items: IBulkCaptureItem[]; } interface IBulkCaptureInput { structure: Partial; idempotencyKey?: string; } interface ICommitChange { id: string; commitId: string; level: CommitChangeLevel; entityId: string; action: CommitChangeAction; beforeJson: Record | null; afterJson: Record | null; createdAt: string; } interface ICommit { id: string; commitKey: string; farmId: string; blockId: string; message: string; occurredAt: string; createdAt: string; changes?: ICommitChange[]; } interface ICommitListResponse { items: ICommit[]; total: number; limit: number; offset: number; } interface IDraftReadiness { blockId: string; readyToConfirm: boolean; openCount: number; orphanCount: number; bulkState?: string | null; bulkFailureCount?: number; } interface IGeoLocation { latitude: string; longitude: string; } interface IFarmCell { id: string; lineageId?: string | null; lineNumber: number; rowNumber: number; colNumber: number; active: boolean; geomJson: unknown | null; createdAt: string; updatedAt: string; } interface IFarmSquare { id: string; lineageId?: string | null; bedId: string; number: number; active: boolean; orderIndex: number; createdAt: string; updatedAt: string; cells: IFarmCell[]; } interface IFarmBed { id: string; lineageId?: string | null; naveId: string; externalCode: string | null; name: string; active: boolean; orderIndex: number; createdAt: string; updatedAt: string; squares: IFarmSquare[]; } interface IFarmNaveAlignment { id?: string; lineageId?: string | null; name: string; maxSquares: number; leftPath: boolean; active: boolean; createdAt?: string; updatedAt?: string; beds: IFarmBed[]; } interface IFarmBlock { _id: string; farmId: string; blockName: string; sides: number; bedsNave: number; maxTotalBeds: number; maxTotalNaves: number; centralRoadSize: number; widthBed: number; lengthBed: number; bedRoadSize: number; pointA: [number, number]; pointB: [number, number]; startPoint: [number, number]; alignment: IFarmNaveAlignment[][]; } interface IFarm { _id: string; name: string; localidad: number; geolocation: IGeoLocation; modules: unknown[]; users: string[]; active: boolean; owner_name: string; mapId: string; total_area: number; group_id: string | null; weekly_start: number; indicator_measurement: string; severity_color_map: string; size: FarmSize; state_config: FarmStateConfig; farm_type: FarmType; blocks: IFarmBlock[]; } type IFarmsResponse = IFarm[]; interface IGeoUnit { farmId: string; structureId: string; structureVersion: number; blockName: string; granularity: GeoUnitGranularity; geoUnitId: string; structureLineageId?: string | null; identityQuality?: IdentityQuality; geoUnitType: 'SQUARE' | 'CELL'; parentGeoUnitId?: string; } interface IGeoUnitsResponse { farmId: string; asOfDateApplied: string | null; items: IGeoUnit[]; limit: number; nextCursor: string | null; } interface ILineageEntry { lineageId: string; blockName: string; latestVersion: number; implementedAt: string | null; implemented: number | null; draft: boolean; totalVersions: number; classification?: LineageClassification; confidence?: LineageConfidence; reason_codes?: string[]; rule_ids?: string[]; evidence?: Record; } interface ILineageAuditResponse { items: ILineageEntry[]; total: number; farmId: string; mode: 'block' | 'leaf'; } interface INote { id: string; blockId: string; level: string; entityId?: string | null; message: string; status: ObservationStatus; createdBy?: string | null; createdAt: string; } interface IObservationTask { id: string; blockId: string; level: string; message: string; status: ObservationStatus; entityId?: string; createdAt: string; } interface IPlantingValidationResponse { farmId: string; squareId: string; isValid: boolean; structureId: string | null; structureVersion: number | null; geoUnitId: string | null; geoUnitType: 'SQUARE' | 'CELL' | null; } interface IPlantingBatchItem { structureId: string; structureVersion: number; geoUnitType: 'SQUARE' | 'CELL'; geoUnitId: string; } interface IPlantingBatchItemResult { index: number; requested: IPlantingBatchItem; status: 'valid' | 'invalid'; code: PlantingBatchCode; message: string; latestStructureVersion?: number | null; isLatestVersion?: boolean; isEquivalentInLatest?: boolean; } interface IPlantingBatchResponse { farmId: string; asOfDate?: string | null; requestedStructureVersion?: number | null; validatedAt: string; total: number; validCount: number; invalidCount: number; items: IPlantingBatchItemResult[]; } interface IRuntimeSurfaceSnapshot { canonicalCount: number; fallbackCount: number; incoherentCount: number; total: number; fallbackRate: number; mismatchRate: number; warningCodes: Record; } interface IRuntimeBoundaryReadiness { observations: IRuntimeSurfaceSnapshot; layers: IRuntimeSurfaceSnapshot; blocks: IRuntimeSurfaceSnapshot; } interface IStructureObservationPayload { farmId: string; blockId: string; level: IStructureLocationLevel; entityId?: string; message: string; status?: string; createdBy?: string; } interface IStructureBlockPayload { id: string; farmId: string; blockName: string; sides: number; bedsNave: number; maxTotalBeds: number; maxTotalNaves: number; centralRoadSize: number; widthBed: number; lengthBed: number; bedRoadSize: number; pointA: [number, number]; pointB: [number, number]; startPoint?: [number, number]; implemented: number; granularity: 'squares' | 'cells' | 'lines'; squaresPerBed?: number; cellsPerLine?: number; cols?: number; linesPerSquare?: number; rows?: number; blockApp: boolean; } interface IStructureUploadRequest { observations: IStructureObservationPayload[]; blocks: IStructureBlockPayload[]; } interface IStructureUploadResponse { id: string; farmId: string; blockId: string; level: IStructureLocationLevel; entityId?: string | null; message: string; status: string; createdBy?: string | null; createdAt: string; updatedAt: string; } interface IVersionSummary { id: string; lineageId: string; blockName: string; version: number; draft: boolean; implementedAt: string | null; implemented: number | null; createdAt: string; updatedAt: string; } type IVersionDetail = IStructure & { version: number; implementedAt: string | null; }; export type { IPlantingBatchItemResult as A, BulkCaptureStatus as B, CommitChangeAction as C, IPlantingBatchResponse as D, IPlantingValidationResponse as E, FarmSize as F, GeoUnitGranularity as G, IRuntimeBoundaryReadiness as H, IBed as I, IRuntimeSurfaceSnapshot as J, IStructure as K, IStructureBlockPayload as L, IStructureLocationLevel as M, IStructureObservationPayload as N, IStructureUploadRequest as O, IStructureUploadResponse as P, IVersionDetail as Q, IVersionSummary as R, IdentityQuality as S, LineageClassification as T, LineageConfidence as U, INave as V, ObservationStatus as W, PlantingBatchCode as X, Square as Y, CommitChangeLevel as a, FarmStateConfig as b, FarmType as c, GeoUnitType as d, IBulkCaptureInput as e, IBulkCaptureItem as f, IBulkCaptureResponse as g, ICommit as h, ICommitChange as i, ICommitListResponse as j, IDraftReadiness as k, IFarm as l, IFarmBed as m, IFarmBlock as n, IFarmCell as o, IFarmNaveAlignment as p, IFarmSquare as q, IFarmsResponse as r, IGeoLocation as s, IGeoUnit as t, IGeoUnitsResponse as u, ILineageAuditResponse as v, ILineageEntry as w, INote as x, IObservationTask as y, IPlantingBatchItem as z };