import {z} from 'zod' export type SpaceXTransporterDeployment = {name: string, sequence_number: number, date: string, launch_date?: (string | null) | undefined, mission_time_s?: (number | null) | undefined, r_ecef_m: Array, v_ecef_m_per_s: Array, ballistic_coef_kg_per_m2: number, catid?: (number | string | null) | undefined, norad_id?: (number | string | null) | undefined, propagation_duration_hours?: number | undefined}; export type CreateApiLeopSpacexOpmTransporterSingleArgs = {body: SpaceXTransporterDeployment}; export type CreateApiLeopSpacexOpmTransporterSingleOptions = {baseUrl: string, Oauth2Scheme?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiLeopSpacexOpmTransporterSingleResponse = z.unknown(); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Spacex Transporter Single Opm To Tle * * POST /leop/spacex_opm_transporter_single */ export const createApiLeopSpacexOpmTransporterSingle = async (args: CreateApiLeopSpacexOpmTransporterSingleArgs, options: CreateApiLeopSpacexOpmTransporterSingleOptions) => { const {baseUrl, fetch: fetchFn = fetch, Oauth2Scheme} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (Oauth2Scheme !== undefined) headers.set('authorization', `Bearer ${Oauth2Scheme}`) const url = `${baseUrl.replace(/\/+$/, '')}/leop/spacex_opm_transporter_single${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(createApiLeopSpacexOpmTransporterSingleResponse, await res.json()) };