Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
corneliusroemer committed Oct 25, 2024
1 parent 7ba6c68 commit c37d3f4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
13 changes: 7 additions & 6 deletions website/src/services/lapisClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ export class LapisClient extends ZodiosWrapperClient<typeof lapisApi> {
});
}

public getSequenceEntryVersionDetailsTsv(accessionVersion: string): Promise<Result<string, ProblemDetail>> {
return this.call('details', {
public async getSequenceEntryVersionDetailsTsv(accessionVersion: string): Promise<Result<string, ProblemDetail>> {
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<Result<AccessionVersion, ProblemDetail>> {
Expand Down
9 changes: 6 additions & 3 deletions website/src/services/serviceHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
);
Expand Down Expand Up @@ -63,7 +66,7 @@ export function lapisClientHooks(lapisUrl: string) {

function getSequenceHook(
hooks: ZodiosHooksInstance<typeof lapisApi>,
request: LapisBaseRequest,
request: SequenceRequest,
sequenceType: SequenceType,
isMultiSegmented: boolean,
) {
Expand Down
1 change: 1 addition & 0 deletions website/src/types/lapis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type LapisBaseRequest = z.infer<typeof lapisBaseRequest>;
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<typeof sequenceRequest>;

export const mutationProportionCount = z.object({
mutation: z.string(),
Expand Down

0 comments on commit c37d3f4

Please sign in to comment.