import {z} from 'zod' export type SortDirection = 'asc' | 'desc'; export type GetApiScreeningsIdCatalogsCatalogIdEphemeridesArgs = {id: string, catalog_id: string, filters?: (string | null) | undefined, sort_field?: string | undefined, sort_direction?: SortDirection | undefined, offset?: number | undefined, count?: number | undefined}; export type GetApiScreeningsIdCatalogsCatalogIdEphemeridesOptions = {baseUrl: string, Oauth2Scheme?: string | undefined, fetch?: typeof fetch | undefined}; export const offsetPagination = z.object({offset: z.number().int().optional(), count: z.number().int().optional()}); export const ephemerisDataFormat = z.enum(["hdf5", "original", "gem"]); export const ephemerisViewer = z.object({ephemeris_id: z.string().nullable().optional(), event_key_number: z.number().int().nullable().optional()}); export const rSORead = z.object({id: z.string(), norad_id: z.number().int().nullable().optional(), international_designator: z.string().nullable().optional(), object_type: z.string().nullable().optional(), object_type_category: z.string().nullable().optional(), object_name: z.string().nullable().optional()}); export const ephemerisSource = z.enum(["CATALOG", "SPACE_TRACK_PUBLIC", "SPACE_TRACK_PUBLIC_SATCAT", "PATHFINDER_API", "SATCAT_API", "USER_SCREENER", "TERTIARY_SCREENER", "PATHFINDER_AUTO_THIRDPARTY", "KAYHAN_INTERNAL_PROCESS", "EXTRACTED_FROM_CDM", "PATHFINDER_SCREENER_THIRDPARTY", "STARLINK_API_PUBLIC", "PUBLIC_REPOSITORY", "STARLINK_STC_API"]); export const ephemerisType = z.enum(["ON_ORBIT", "LAUNCH"]); export const context = z.enum(["ROUTINE", "COLA", "MAINTENANCE", "NOVEL", "DECAY"]); export const satcatSchemasModelsDesignation = z.enum(["OPERATIONAL", "PREDICTIVE", "DEFINITIVE", "THEORETICAL", "TLE"]); export const catalogType = z.enum(["SP", "TLE", "CUSTOM"]); export const catalogMinimalRead = z.object({ephemerides_count: z.number().int(), id: z.string(), created_at: z.string(), catalog_type: catalogType, epoch: z.string(), archived: z.boolean().optional(), filename: z.string().nullable().optional(), ready: z.boolean().optional(), data_format: z.string().nullable().optional(), usable_time_start: z.string().nullable().optional(), usable_time_end: z.string().nullable().optional(), archive_protected: z.boolean().optional()}); export const ephemerisMetadataScreeningRead = z.object({id: z.string().nullable().optional(), rso_id: z.string().nullable().optional(), filename: z.string().nullable().optional(), data_format: ephemerisDataFormat.nullable().optional(), custom_storage_path: z.string().nullable().optional(), altitude_km: z.number().nullable().optional(), repository_public: z.boolean().optional(), event_public: z.boolean().optional(), shared_event_keys: z.array(ephemerisViewer).nullable().optional(), rso: rSORead.nullable().optional(), user_id: z.string().nullable().optional(), group_id: z.string().nullable().optional(), covariance_corrected: z.boolean().nullable().optional(), source_ephemeris_id: z.string().nullable().optional(), norad_id: z.number().int().nullable().optional(), ephemeris_source: ephemerisSource, solution_time: z.string().nullable().optional(), has_covariance: z.boolean(), covariance_generated: z.boolean().nullable().optional(), ephemeris_type: ephemerisType, discontinuities: z.array(z.string()).optional(), comments: z.string().nullable().optional(), apogee_km: z.number(), perigee_km: z.number(), archived: z.boolean().optional(), hbr_m: z.number().nullable().optional(), current_operational: z.boolean().optional(), launch_time: z.string().nullable().optional(), usable_time_start: z.string().nullable().optional(), usable_time_end: z.string().nullable().optional(), context: context.nullable().optional(), designation: satcatSchemasModelsDesignation.nullable().optional(), catalog: catalogMinimalRead.nullable().optional(), is_primary: z.boolean(), is_secondary: z.boolean()}); export const offsetPageResultEphemerisMetadataScreeningRead = z.object({pagination: offsetPagination, items: z.array(ephemerisMetadataScreeningRead), total_count: z.number().int()}); 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 }; /** * List Ephemerides In Catalog By Screening * * GET /screenings/{id}/catalogs/{catalog_id}/ephemerides */ export const getApiScreeningsIdCatalogsCatalogIdEphemerides = async (args: GetApiScreeningsIdCatalogsCatalogIdEphemeridesArgs, options: GetApiScreeningsIdCatalogsCatalogIdEphemeridesOptions) => { const {baseUrl, fetch: fetchFn = fetch, Oauth2Scheme} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.filters != null) query.append("filters", String(args.filters)) if (args.sort_field != null) query.append("sort_field", String(args.sort_field)) if (args.sort_direction != null) query.append("sort_direction", String(args.sort_direction)) if (args.offset != null) query.append("offset", String(args.offset)) if (args.count != null) query.append("count", String(args.count)) if (Oauth2Scheme !== undefined) headers.set('authorization', `Bearer ${Oauth2Scheme}`) const url = `${baseUrl.replace(/\/+$/, '')}/screenings/${encodeURIComponent(String(args.id))}/catalogs/${encodeURIComponent(String(args.catalog_id))}/ephemerides${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(offsetPageResultEphemerisMetadataScreeningRead, await res.json()) };