Skip to content

Commit

Permalink
moving routes under commans
Browse files Browse the repository at this point in the history
  • Loading branch information
TamarZanzouri committed Aug 7, 2024
1 parent 378dbd8 commit 6f34725
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { GET, request } from '../request'
import { GET, request } from '../../request'

import type { ResponsePromise } from '../request'
import type { HostConfig } from '../types'
import type { GetCommandsParams, RunCommandErrors } from './types'
import type { ResponsePromise } from '../../request'
import type { HostConfig } from '../../types'
import type { GetCommandsParams, RunCommandErrors } from '../types'

export function getRunCommandErrors(
config: HostConfig,
Expand All @@ -13,6 +13,7 @@ export function getRunCommandErrors(
GET,
`/runs/${runId}/commandErrors`,
null,
config
config,
params
)
}
7 changes: 6 additions & 1 deletion api-client/src/runs/commands/types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import type { RunTimeCommand } from '@opentrons/shared-data'
import type { RunTimeCommand, RunCommandError } from '@opentrons/shared-data'

export interface GetCommandsParams {
cursor: number | null // the index of the command at the center of the window
pageLength: number // the number of items to include
}

export interface RunCommandErrors {
data: RunCommandError[]
meta: GetCommandsParams & { totalLength: number }
}

// NOTE: this incantation allows us to omit a key from each item in a union distributively
// this means we can, for example, maintain the associated commandType and params after the Omit is applied
type DistributiveOmit<T, K extends keyof T> = T extends any ? Omit<T, K> : never
Expand Down
2 changes: 1 addition & 1 deletion api-client/src/runs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export { getCommand } from './commands/getCommand'
export { getCommands } from './commands/getCommands'
export { getCommandsAsPreSerializedList } from './commands/getCommandsAsPreSerializedList'
export { createRunAction } from './createRunAction'
export { getRunCommandErrors } from './getRunCommandErrors'
export { getRunCommandErrors } from './commands/getRunCommandErrors'
export * from './createLabwareOffset'
export * from './createLabwareDefinition'
export * from './constants'
Expand Down
6 changes: 0 additions & 6 deletions api-client/src/runs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type {
RunTimeParameter,
} from '@opentrons/shared-data'
import type { ResourceLink, ErrorDetails } from '../types'
import type { GetCommandsParams } from './commands/types'
export * from './commands/types'

export const RUN_STATUS_IDLE = 'idle' as const
Expand Down Expand Up @@ -101,11 +100,6 @@ export interface Runs {
links: RunsLinks
}

export interface RunCommandErrors {
data: RunCommandError[]
meta: GetCommandsParams & { totalLength: number }
}

export const RUN_ACTION_TYPE_PLAY: 'play' = 'play'
export const RUN_ACTION_TYPE_PAUSE: 'pause' = 'pause'
export const RUN_ACTION_TYPE_STOP: 'stop' = 'stop'
Expand Down
4 changes: 2 additions & 2 deletions app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
useDoorQuery,
useHost,
useInstrumentsQuery,
useAllRunCommandErrorsQuery,
useRunCommandErrors,
} from '@opentrons/react-api-client'
import { FLEX_ROBOT_TYPE, OT2_ROBOT_TYPE } from '@opentrons/shared-data'
import {
Expand Down Expand Up @@ -169,7 +169,7 @@ export function ProtocolRunHeader({
const { closeCurrentRun, isClosingCurrentRun } = useCloseCurrentRun()
const { startedAt, stoppedAt, completedAt } = useRunTimestamps(runId)
const [showRunFailedModal, setShowRunFailedModal] = React.useState(false)
const { data: commandErrorList } = useAllRunCommandErrorsQuery(runId, null, {
const { data: commandErrorList } = useRunCommandErrors(runId, null, {
enabled:
runStatus != null &&
// @ts-expect-error runStatus expected to possibly not be terminal
Expand Down
4 changes: 2 additions & 2 deletions app/src/pages/RunSummary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
useProtocolQuery,
useInstrumentsQuery,
useDeleteRunMutation,
useAllRunCommandErrorsQuery,
useRunCommandErrors,
} from '@opentrons/react-api-client'

import { LargeButton } from '../../atoms/buttons'
Expand Down Expand Up @@ -146,7 +146,7 @@ export function RunSummary(): JSX.Element {
localRobot?.serverHealth?.serialNumber ??
null

const { data: commandErrorList } = useAllRunCommandErrorsQuery(runId, null, {
const { data: commandErrorList } = useRunCommandErrors(runId, null, {
enabled:
runStatus != null &&
// @ts-expect-error runStatus expected to possibly not be terminal
Expand Down
2 changes: 1 addition & 1 deletion react-api-client/src/runs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export { useRunActionMutations } from './useRunActionMutations'
export { useAllCommandsQuery } from './useAllCommandsQuery'
export { useAllCommandsAsPreSerializedList } from './useAllCommandsAsPreSerializedList'
export { useCommandQuery } from './useCommandQuery'
export { useAllRunCommandErrorsQuery } from './useAllRunCommandErrorsQuery'
export { useRunCommandErrors } from './useRunCommandErrors'
export * from './useCreateLabwareOffsetMutation'
export * from './useCreateLabwareDefinitionMutation'
export * from './useUpdateErrorRecoveryPolicy'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const DEFAULT_PARAMS: GetCommandsParams = {
pageLength: DEFAULT_PAGE_LENGTH,
}

export function useAllRunCommandErrorsQuery<TError = Error>(
export function useRunCommandErrors<TError = Error>(
runId: string | null,
params?: GetCommandsParams | null,
options: UseQueryOptions<RunCommandErrors, TError> = {}
Expand Down

0 comments on commit 6f34725

Please sign in to comment.