/*! * @license * Copyright Squiz Australia Pty Ltd. All Rights Reserved. */ import { AxiosError, AxiosInstance } from 'axios'; import { handleError } from './errorUtils'; /** * Check if a job version already exists * @param apiClient - Axios client for API calls * @param endpoint - API endpoint to check * @returns True if version exists, false otherwise */ export async function checkIfVersionExists(apiClient: AxiosInstance, endpoint: string): Promise { try { const response = await apiClient.get(endpoint, { validateStatus: null, }); if (response.status === 200) { return true; } else if (response.status === 404) { return false; } const error = new AxiosError( response?.data?.message || response.statusText, response.status.toString(), undefined, undefined, response, ); throw handleError(error); } catch (error) { throw handleError(error); } }