Skip to content

Commit

Permalink
More use of strong typing
Browse files Browse the repository at this point in the history
  • Loading branch information
dariober committed Aug 23, 2024
1 parent b0e2f03 commit 847942f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/apollo-cli/src/commands/assembly/sequence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export default class ApolloCmd extends BaseCommand<typeof ApolloCmd> {
const seq: string = new TextDecoder().decode(seqObj?.value)
let header = ''
for (const x of refSeqs) {
if (x['_id' as keyof typeof x] === rid) {
if (x._id === rid) {
const rname = x.name
header = `>${rname}:${flags.start}..${flags.start + seq.length - 1}`
break
Expand Down
14 changes: 9 additions & 5 deletions packages/apollo-cli/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ import { SingleBar } from 'cli-progress'
import { Agent, RequestInit, Response, fetch } from 'undici'

import { ApolloConf, ConfigError } from './ApolloConf.js'
import {
ApolloAssemblySnapshot,
CheckResultSnapshot,
} from '@apollo-annotation/mst'

const CONFIG_PATH = path.resolve(os.homedir(), '.clirc')
export const CLI_SERVER_ADDRESS = 'http://127.0.0.1:5657'
Expand Down Expand Up @@ -125,10 +129,10 @@ export async function getAssembly(
return {}
}
const res: Response = await queryApollo(address, accessToken, 'assemblies')
const assemblies: object[] = (await res.json()) as object[]
const assemblies = (await res.json()) as ApolloAssemblySnapshot[]
let assemblyObj = {}
for (const x of assemblies) {
if (x['_id' as keyof typeof x] === assemblyId[0]) {
if (x._id === assemblyId[0]) {
assemblyObj = JSON.parse(JSON.stringify(x))
break
}
Expand Down Expand Up @@ -193,11 +197,11 @@ async function checkNameToIdDict(
accessToken: string,
): Promise<Record<string, string>> {
const asm = await queryApollo(address, accessToken, 'checks/types')
const ja = (await asm.json()) as object[]
const ja = (await asm.json()) as CheckResultSnapshot[] // Not sure if CheckResultSnapshot is the right interface
const nameToId: Record<string, string> = {}
for (const x of ja) {
const name: string = x['name' as keyof typeof x]
nameToId[name] = x['_id' as keyof typeof x]
const { _id, name } = x // x['name' as keyof typeof x]
nameToId[name] = _id // x['_id' as keyof typeof x]
}
return nameToId
}
Expand Down

0 comments on commit 847942f

Please sign in to comment.