diff --git a/api-client/src/runs/getRunCommandErrors.ts b/api-client/src/runs/commands/getRunCommandErrors.ts similarity index 50% rename from api-client/src/runs/getRunCommandErrors.ts rename to api-client/src/runs/commands/getRunCommandErrors.ts index 31f9247b8e5..0f961e1a892 100644 --- a/api-client/src/runs/getRunCommandErrors.ts +++ b/api-client/src/runs/commands/getRunCommandErrors.ts @@ -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, @@ -13,6 +13,7 @@ export function getRunCommandErrors( GET, `/runs/${runId}/commandErrors`, null, - config + config, + params ) } diff --git a/api-client/src/runs/commands/types.ts b/api-client/src/runs/commands/types.ts index 1bcdadcc15f..cd18924201c 100644 --- a/api-client/src/runs/commands/types.ts +++ b/api-client/src/runs/commands/types.ts @@ -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 extends any ? Omit : never diff --git a/api-client/src/runs/index.ts b/api-client/src/runs/index.ts index 5de316bbbd2..9f314f4b025 100644 --- a/api-client/src/runs/index.ts +++ b/api-client/src/runs/index.ts @@ -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' diff --git a/api-client/src/runs/types.ts b/api-client/src/runs/types.ts index d3e315ecf30..19127b70bba 100644 --- a/api-client/src/runs/types.ts +++ b/api-client/src/runs/types.ts @@ -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 @@ -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' diff --git a/app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx b/app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx index 1ea733ba688..7912ce40f69 100644 --- a/app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx +++ b/app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx @@ -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 { @@ -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 diff --git a/app/src/pages/RunSummary/index.tsx b/app/src/pages/RunSummary/index.tsx index c3dbba6d1ec..9f9885f918f 100644 --- a/app/src/pages/RunSummary/index.tsx +++ b/app/src/pages/RunSummary/index.tsx @@ -38,7 +38,7 @@ import { useProtocolQuery, useInstrumentsQuery, useDeleteRunMutation, - useAllRunCommandErrorsQuery, + useRunCommandErrors, } from '@opentrons/react-api-client' import { LargeButton } from '../../atoms/buttons' @@ -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 diff --git a/react-api-client/src/runs/index.ts b/react-api-client/src/runs/index.ts index 7aeebe36354..4b04d913487 100644 --- a/react-api-client/src/runs/index.ts +++ b/react-api-client/src/runs/index.ts @@ -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' diff --git a/react-api-client/src/runs/useAllRunCommandErrorsQuery.ts b/react-api-client/src/runs/useRunCommandErrors.ts similarity index 95% rename from react-api-client/src/runs/useAllRunCommandErrorsQuery.ts rename to react-api-client/src/runs/useRunCommandErrors.ts index f1f1189bb4c..63dd5875636 100644 --- a/react-api-client/src/runs/useAllRunCommandErrorsQuery.ts +++ b/react-api-client/src/runs/useRunCommandErrors.ts @@ -14,7 +14,7 @@ export const DEFAULT_PARAMS: GetCommandsParams = { pageLength: DEFAULT_PAGE_LENGTH, } -export function useAllRunCommandErrorsQuery( +export function useRunCommandErrors( runId: string | null, params?: GetCommandsParams | null, options: UseQueryOptions = {}