import { FieldMetadata, InfoMetadata, RecordSampleType, VcfRecord } from "@molgenis/vip-report-vcf"; import { Item } from "@molgenis/vip-report-api"; import { CellValueCustom } from "./configCellComposed"; import { FieldValue } from "../utils/vcf.ts"; export type CellId = string; export type CellType = | "chrom" | "pos" | "id" | "ref" | "alt" | "qual" | "filter" | "info" | "format" | "genotype" | "composed"; interface ConfigCellBase { type: CellType; label: () => string; parentLabel?: () => string; description: () => string | null; value: (record: Item, valueIndex: number) => T; valueCount: (record: Item) => number; } export type CellValueChrom = string; export interface ConfigCellChrom extends ConfigCellBase { type: "chrom"; } export type CellValuePos = number; export interface ConfigCellPos extends ConfigCellBase { type: "pos"; } export type CellValueId = string[]; export interface ConfigCellId extends ConfigCellBase { type: "id"; } export type CellValueRef = string; export interface ConfigCellRef extends ConfigCellBase { type: "ref"; } export type CellValueAlt = (string | null)[]; export interface ConfigCellAlt extends ConfigCellBase { type: "alt"; } export type CellValueQual = number | null; export interface ConfigCellQual extends ConfigCellBase { type: "qual"; } export type CellValueFilter = string[]; export interface ConfigCellFilter extends ConfigCellBase { type: "filter"; } export type ConfigCellFixed = | ConfigCellChrom | ConfigCellPos | ConfigCellId | ConfigCellRef | ConfigCellAlt | ConfigCellQual | ConfigCellFilter; export type CellValueInfo = FieldValue | undefined; export interface ConfigCellInfo extends ConfigCellBase { type: "info"; field: InfoMetadata; } export type CellValueFormat = string[]; export interface ConfigCellFormat extends ConfigCellBase { type: "format"; } export type CellValueGenotype = RecordSampleType | undefined; export interface ConfigCellGenotype extends ConfigCellBase { type: "genotype"; field: FieldMetadata; } interface ConfigCellCustom extends ConfigCellBase { type: "composed"; id: CellId; } export type ConfigCellItem = | ConfigCellFixed | ConfigCellFormat | ConfigCellInfo | ConfigCellGenotype | ConfigCellCustom; export interface ConfigCellGroup { type: "group"; fieldConfigs: ConfigCellItem[]; } export type ConfigCell = ConfigCellItem | ConfigCellGroup; export type CellValueFixed = | CellValueChrom | CellValuePos | CellValueId | CellValueRef | CellValueAlt | CellValueQual | CellValueFilter; export type CellValue = CellValueFixed | CellValueFormat | CellValueInfo | CellValueGenotype | CellValueCustom; // note: add composed field to configCellComposed.d.ts