import type { DataFrameColumn, SelectOption, } from '../types' import { getTemplateData } from './templateEnvelopes' import { validateSampleSheetData } from './templateValidators' import type { SampleColumnsAdapterResult, SampleDataFrameAdapterResult, SampleOptionsAdapterResult, SampleRowsAdapterResult, SampleSheetTemplate, SampleSheetTemplateData, } from './types' /** @deprecated Scheduled for removal from the core SDK in MINT 1.4; the biology templates move to a dedicated package or the owning plugins. */ export function toSampleRows( template: SampleSheetTemplate | SampleSheetTemplateData ): SampleRowsAdapterResult { const data = getTemplateData(template, 'sample-sheet') validateSampleSheetData(data) return data.samples.map(sample => ({ sampleId: sample.sampleId, name: sample.name, group: sample.group, batch: sample.batch, replicate: sample.replicate, plateId: sample.plateId, wellId: sample.wellId, ...(sample.metadata ?? {}), })) } /** @deprecated Scheduled for removal from the core SDK in MINT 1.4; the biology templates move to a dedicated package or the owning plugins. */ export function toSampleColumns( template: SampleSheetTemplate | SampleSheetTemplateData ): SampleColumnsAdapterResult { const data = getTemplateData(template, 'sample-sheet') validateSampleSheetData(data) return data.columns.map((column): DataFrameColumn> => ({ key: sampleColumnKey(column.id), label: column.label, sortable: true, align: column.type === 'number' || column.type === 'integer' ? 'right' : 'left', })) } /** @deprecated Scheduled for removal from the core SDK in MINT 1.4; the biology templates move to a dedicated package or the owning plugins. */ export function toSampleDataFrame( template: SampleSheetTemplate | SampleSheetTemplateData ): SampleDataFrameAdapterResult { return { data: toSampleRows(template), columns: toSampleColumns(template), rowKey: 'sampleId', } } /** @deprecated Scheduled for removal from the core SDK in MINT 1.4; the biology templates move to a dedicated package or the owning plugins. */ export function toSampleOptions( template: SampleSheetTemplate | SampleSheetTemplateData ): SampleOptionsAdapterResult { const data = getTemplateData(template, 'sample-sheet') validateSampleSheetData(data) return data.samples.map((sample): SelectOption => ({ value: sample.sampleId, label: sample.name ?? sample.sampleId, description: [sample.group, sample.batch].filter(Boolean).join(' / ') || undefined, })) } function sampleColumnKey(columnId: string): string { const aliases: Record = { sample_id: 'sampleId', plate_id: 'plateId', well_id: 'wellId', } return aliases[columnId] ?? columnId }