import {z} from 'zod' export type RFPs = {id: number, unique_id?: (string | null) | undefined, title?: (string | null) | undefined, description?: (string | null) | undefined, agency?: (string | null) | undefined, due_date?: (string | null) | undefined, rfp_url?: (string | null) | undefined, created_at?: (string | null) | undefined, updated_at?: (string | null) | undefined, institution_name?: (string | null) | undefined, institution_city?: (string | null) | undefined, institution_state?: (string | null) | undefined, institution_type?: (string | null) | undefined, source_id?: (number | null) | undefined, label?: (string | null) | undefined, county?: (string | null) | undefined, street?: (string | null) | undefined, latitude?: (number | null) | undefined, longitude?: (number | null) | undefined, geo_shape?: (string | null) | undefined, county_fips_code?: (string | null) | undefined, population?: (number | null) | undefined, entity_understanding?: (string | null) | undefined, is_active?: (boolean | null) | undefined, favicon_path?: (string | null) | undefined, last_processed_at?: (string | null) | undefined, homepage_url?: (string | null) | undefined, contact_url?: (string | null) | undefined, institution_rfp_url?: (string | null) | undefined, meeting_minute_url?: (string | null) | undefined, budget_url?: (string | null) | undefined, strategic_plan_url?: (string | null) | undefined, procurement_guideline_url?: (string | null) | undefined, press_release_url?: (string | null) | undefined, open_data_portal_url?: (string | null) | undefined, youtube_url?: (string | null) | undefined, foia_url?: (string | null) | undefined, homepage_url_status?: (string | null) | undefined, contact_url_status?: (string | null) | undefined, rfp_url_status?: (string | null) | undefined, meeting_minute_url_status?: (string | null) | undefined, budget_url_status?: (string | null) | undefined, strategic_plan_url_status?: (string | null) | undefined, press_release_url_status?: (string | null) | undefined, procurement_guideline_url_status?: (string | null) | undefined, open_data_portal_url_status?: (string | null) | undefined, youtube_url_status?: (string | null) | undefined, foia_url_status?: (string | null) | undefined, score?: (number | null) | undefined, relevance_score?: (number | null) | undefined, decay_score?: (number | null) | undefined}; export type RFPsExportRequest = {rfps: Array}; export type CreateApiApiV3ExportRfpsArgs = {body: RFPsExportRequest}; export type CreateApiApiV3ExportRfpsOptions = {baseUrl: string, HTTPBearer?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiApiV3ExportRfpsResponse = 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 }; /** * Export Rfps Csv * * POST /api/v3/export/rfps */ export const createApiApiV3ExportRfps = async (args: CreateApiApiV3ExportRfpsArgs, options: CreateApiApiV3ExportRfpsOptions) => { const {baseUrl, fetch: fetchFn = fetch, HTTPBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (HTTPBearer !== undefined) headers.set('authorization', `Bearer ${HTTPBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v3/export/rfps${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(createApiApiV3ExportRfpsResponse, await res.json()) };