import type { OrganizationSourceRecordList, OrganizationSourceRecord, OrganizationSourceRecordListResponse, V2OrganizationSourceRecordsListOrdering, } from './generated/schemas'; export function recordLabel(record: OrganizationSourceRecordList): string { if (record.source_group === 'budget_process_registry') { const type: 'budget_registry_organization' = record.record_type; return type + record.payload.registry.code; } if (record.source_group === 'government_support') { const type: 'sme_support_measure' = record.record_type; return type + record.payload.support_sizes.map((size) => size.value).join(','); } if (record.source_group === 'sro_membership') { const type: 'sro_membership' = record.record_type; return type + record.payload.sro_name; } return record.title || ''; } export function detailCount(record: OrganizationSourceRecord): number { if (record.source_group === 'budget_process_registry') return record.payload.heads.length; if (record.source_group === 'government_support') return record.payload.regulatory_documents.length; if (record.source_group === 'sro_membership') return record.payload.lineage.lookup_value.length; return 0; } export function total(response: OrganizationSourceRecordListResponse): number { return response.meta.pagination.total_count; } export const existingOrder: V2OrganizationSourceRecordsListOrdering = '-payload__united_states';