From c37d3f426360594d7ff8fc958b3c382a2d38457a Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Fri, 25 Oct 2024 21:08:03 +0200 Subject: [PATCH] fixes --- website/src/services/lapisClient.ts | 13 +++++++------ website/src/services/serviceHooks.ts | 9 ++++++--- website/src/types/lapis.ts | 1 + 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/website/src/services/lapisClient.ts b/website/src/services/lapisClient.ts index 1011f0d27..fbaf1c85e 100644 --- a/website/src/services/lapisClient.ts +++ b/website/src/services/lapisClient.ts @@ -54,14 +54,15 @@ export class LapisClient extends ZodiosWrapperClient { }); } - public getSequenceEntryVersionDetailsTsv(accessionVersion: string): Promise> { - return this.call('details', { + public async getSequenceEntryVersionDetailsTsv(accessionVersion: string): Promise> { + const result = await this.call('details', { [this.schema.primaryKey]: accessionVersion, dataFormat: 'TSV', - // This type cast isn't pretty, but if the API would be typed correctly, the union type - // of the actual details resonse and the potential 'string' would polute the whole API, - // so I decided to just do this cast here. We know that the return value is a TSV string. - }).then((result) => result.map((data) => data as unknown as string)); + }); + // This type cast isn't pretty, but if the API would be typed correctly, the union type + // of the actual details resonse and the potential 'string' would pollute the whole API, + // so I decided to just do this cast here. We know that the return value is a TSV string. + return result.map((data) => data as unknown as string); } public async getLatestAccessionVersion(accession: string): Promise> { diff --git a/website/src/services/serviceHooks.ts b/website/src/services/serviceHooks.ts index e0a40612c..882cf073d 100644 --- a/website/src/services/serviceHooks.ts +++ b/website/src/services/serviceHooks.ts @@ -6,7 +6,7 @@ import { backendApi } from './backendApi.ts'; import { lapisApi } from './lapisApi.ts'; import { seqSetCitationApi } from './seqSetCitationApi.ts'; import { problemDetail } from '../types/backend.ts'; -import type { LapisBaseRequest } from '../types/lapis.ts'; +import type { SequenceRequest } from '../types/lapis.ts'; import type { ClientConfig } from '../types/runtimeConfig.ts'; import { fastaEntries } from '../utils/parseFasta.ts'; import { isAlignedSequence, isUnalignedSequence, type SequenceType } from '../utils/sequenceTypeHelpers.ts'; @@ -23,7 +23,10 @@ export function lapisClientHooks(lapisUrl: string) { useGetSequence(accessionVersion: string, sequenceType: SequenceType, isMultiSegmented: boolean) { const { data, error, isLoading } = getSequenceHook( zodiosHooks, - { accessionVersion }, + { + accessionVersion, + dataFormat: 'FASTA', + }, sequenceType, isMultiSegmented, ); @@ -63,7 +66,7 @@ export function lapisClientHooks(lapisUrl: string) { function getSequenceHook( hooks: ZodiosHooksInstance, - request: LapisBaseRequest, + request: SequenceRequest, sequenceType: SequenceType, isMultiSegmented: boolean, ) { diff --git a/website/src/types/lapis.ts b/website/src/types/lapis.ts index 170e3a262..6a493d36c 100644 --- a/website/src/types/lapis.ts +++ b/website/src/types/lapis.ts @@ -25,6 +25,7 @@ export type LapisBaseRequest = z.infer; export const mutationsRequest = lapisBaseRequest.extend({ minProportion: z.number().optional() }); export const sequenceRequest = lapisBaseRequest.extend({ dataFormat: z.enum(['FASTA', 'NDJSON', 'JSON']) }); +export type SequenceRequest = z.infer; export const mutationProportionCount = z.object({ mutation: z.string(),