import {z} from 'zod' export type GetApiDataEntitiesDegreesEntityIdCardsCardIdArgs = {entity_id: string, card_id: 'organization' | 'person', card_field_ids?: string | undefined, after_id?: string | undefined, before_id?: string | undefined, order?: string | undefined, limit?: number | undefined}; export type GetApiDataEntitiesDegreesEntityIdCardsCardIdOptions = {baseUrl?: string | undefined, ApiKeyAuthHeader?: string | undefined, fetch?: typeof fetch | undefined}; export const dateWithPrecision = z.object({precision: z.enum(["none", "year", "month", "day"]), value: z.string().optional()}); export const entityIdentifier = z.object({entity_def_id: z.enum(["address", "category", "category_group", "degree", "diversity_spotlight", "event", "event_appearance", "ipo", "job", "location", "organization", "ownership", "person"]), image_id: z.string().max(255).optional(), permalink: z.string().max(255).optional(), uuid: z.string(), value: z.string().max(255).optional()}); export const degree = z.object({completed_on: dateWithPrecision.optional(), created_at: z.string().optional(), entity_def_id: z.literal("degree").optional(), identifier: entityIdentifier, name: z.string().max(8192).optional(), person_identifier: entityIdentifier.optional(), school_identifier: entityIdentifier.optional(), started_on: dateWithPrecision.optional(), subject: z.string().max(255).optional(), type_name: z.string().max(255).optional(), updated_at: z.string().optional(), uuid: z.string().optional()}); export const link = z.object({label: z.string().max(8192).optional(), value: z.string().max(8192).optional()}); export const locationTypeEnum = z.enum(["city", "region", "country", "continent", "group"]); export const locationIdentifier = z.object({entity_def_id: z.string(), image_id: z.string().optional(), location_type: locationTypeEnum.optional(), permalink: z.string().optional(), uuid: z.string(), value: z.string().optional()}); export const organization = z.object({acquirer_identifier: entityIdentifier.optional(), aliases: z.array(z.string().max(255)).optional(), categories: z.array(entityIdentifier).optional(), category_groups: z.array(entityIdentifier).optional(), closed_on: dateWithPrecision.optional(), company_type: z.enum(["for_profit", "non_profit"]).optional(), contact_email: z.string().max(8192).optional(), created_at: z.string().optional(), delisted_on: dateWithPrecision.optional(), demo_days: z.boolean().optional(), description: z.string().max(8192).optional(), diversity_spotlights: z.array(entityIdentifier).optional(), entity_def_id: z.literal("organization").optional(), exited_on: dateWithPrecision.optional(), facebook: link.optional(), facet_ids: z.array(z.enum(["company", "government_entity", "investor", "school"])).optional(), founded_on: dateWithPrecision.optional(), founder_identifiers: z.array(entityIdentifier).optional(), hub_tags: z.array(z.enum(["cbvp", "pledge_one_percent", "unicorn", "emerging_unicorn", "exited_unicorn"])).optional(), identifier: entityIdentifier, image_id: z.string().max(255).optional(), image_url: z.string().max(8192).optional(), layout_id: z.enum(["school", "investor"]).optional(), legal_name: z.string().max(255).optional(), linkedin: link.optional(), listed_stock_symbol: z.string().max(8192).optional(), location_group_identifiers: z.array(locationIdentifier).optional(), location_identifiers: z.array(locationIdentifier).optional(), name: z.string().max(8192).optional(), num_alumni: z.number().optional(), num_current_advisor_positions: z.number().optional(), num_current_positions: z.number().optional(), num_employees_enum: z.enum(["c_00001_00010", "c_00011_00050", "c_00051_00100", "c_00101_00250", "c_00251_00500", "c_00501_01000", "c_01001_05000", "c_05001_10000", "c_10001_max"]).optional(), num_enrollments: z.enum(["c_00001_00010", "c_00011_00050", "c_00051_00100", "c_00101_00250", "c_00251_00500", "c_00501_01000", "c_01001_05000", "c_05001_10000", "c_10001_max"]).optional(), num_event_appearances: z.number().optional(), num_portfolio_organizations: z.number().optional(), num_sub_organizations: z.number().optional(), operating_status: z.enum(["active", "closed"]).optional(), owner_identifier: entityIdentifier.optional(), permalink: z.string().max(255).optional(), permalink_aliases: z.array(z.string().max(255)).optional(), phone_number: z.string().max(255).optional(), program_application_deadline: z.string().optional(), program_duration: z.number().optional(), program_type: z.enum(["on_site", "online"]).optional(), rank: z.number().optional(), rank_org: z.number().optional(), school_method: z.enum(["on_compus", "online", "online_and_on_campus"]).optional(), school_program: z.enum(["four_year_university", "two_year_university", "graduate_university", "bootcamp", "trade_school", "community_college", "high_school"]).optional(), school_type: z.enum(["public", "for_profit_private", "non_profit_private"]).optional(), short_description: z.string().max(8192).optional(), status: z.enum(["closed", "ipo", "operating", "was_acquired"]).optional(), stock_exchange_symbol: z.enum(["adx", "afx", "altx", "amx", "amex", "ams", "asce", "asx", "ath", "bcba", "bdp", "belex", "ber", "bfb", "bit", "bkk", "blse", "bme", "bmv", "bom", "brvm", "bse", "bse_lb", "bsse", "bsx", "bvb", "bvc", "bvfb", "bvm", "bvmf", "bvmt", "bx", "cas", "cise", "cnsx", "col", "cph", "cse", "cse_cy", "csx", "dfm", "dse", "dsx", "dus", "ebr", "egx", "eli", "epa", "etr", "eurex", "fra", "fwb", "gha", "gsx", "gsx_gi", "hel", "hkg", "hnx", "hose", "ice", "idx", "iex", "ifb", "ime", "irenex", "ise", "ist", "isx", "jp", "jsc", "jse", "jse_jam", "kase", "klse", "kosdaq", "krx", "kse", "lje", "lse", "lsm", "lsx", "luse", "luxse", "mal", "mcx", "meff", "mnse", "moex", "mse", "mse_md", "mse_mk", "msei", "msm", "mun", "nasdaq", "nbo", "nex", "nepse", "neeq", "ngm", "nig", "notc", "npex", "nse", "nsx", "nyse", "nysearca", "nysemkt", "nze", "ose", "otcbb", "otcpink", "otcqb", "otcqx", "pdex", "pex", "pfts", "pomsox", "prg", "pse", "psx", "qse", "rfb", "rse", "rsebl", "sase", "sbx", "sehk", "sem", "sgbv", "sgx", "six", "spbex", "spse", "sse", "ssx", "sto", "stu", "swx", "szse", "tal", "tfex", "tise", "tlv", "tpe", "tse_al", "tse_ir", "tsec", "tsx", "cve", "tyo", "ttse", "tadawul", "use", "ux", "vie", "vmf", "vse", "wse", "ysx", "zamace", "zse", "zse_hr"]).optional(), stock_symbol: entityIdentifier.optional(), twitter: link.optional(), updated_at: z.string().optional(), uuid: z.string().optional(), website: link.optional(), website_url: z.string().max(8192).optional(), went_public_on: z.string().optional()}); export const person = z.object({aliases: z.array(z.string().max(255)).optional(), born_on: z.string().optional(), created_at: z.string().optional(), description: z.string().max(8192).optional(), died_on: z.string().optional(), entity_def_id: z.literal("person").optional(), facebook: link.optional(), facet_ids: z.array(z.literal("investor")).optional(), first_name: z.string().max(255).optional(), gender: z.enum(["female", "male", "agender", "androgyne", "androgynous", "bigender", "ftm", "mtf", "gender_fluid", "gender_nonconforming", "gender_questioning", "gender_variant", "genderqueer", "non_binary", "neutrois", "pangender", "transgender_person", "transgender_female", "transgender_woman", "transgender_male", "transgender_man", "transfeminine", "transmasculine", "transsexual_person", "transsexual_female", "transsexual_woman", "transsexual_male", "transsexual_man", "two_spirit", "other", "not_provided"]).optional(), identifier: entityIdentifier, image_id: z.string().max(255).optional(), image_url: z.string().max(8192).optional(), last_name: z.string().max(255).optional(), layout_id: z.literal("investor").optional(), linkedin: link.optional(), location_group_identifiers: z.array(locationIdentifier).optional(), location_identifiers: z.array(locationIdentifier).optional(), middle_name: z.string().max(8192).optional(), name: z.string().max(8192).optional(), num_current_advisor_jobs: z.number().optional(), num_current_jobs: z.number().optional(), num_event_appearances: z.number().optional(), num_founded_organizations: z.number().optional(), num_jobs: z.number().optional(), num_past_advisor_jobs: z.number().optional(), num_past_jobs: z.number().optional(), num_portfolio_organizations: z.number().optional(), permalink: z.string().max(255).optional(), permalink_aliases: z.array(z.string().max(255)).optional(), primary_job_title: z.string().max(255).optional(), primary_organization: entityIdentifier.optional(), rank: z.number().optional(), rank_person: z.number().optional(), short_description: z.string().max(8192).optional(), twitter: link.optional(), updated_at: z.string().optional(), uuid: z.string().optional(), website: link.optional(), website_url: z.string().max(8192).optional()}); export const degreeEntity = z.object({cards: z.object({fields: degree.optional(), organization: z.array(organization).optional(), person: z.array(person).optional()}).optional(), properties: degree.optional()}); 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 }; /** * Lookup Degree's single card * * GET /data/entities/degrees/{entity_id}/cards/{card_id} */ export const getApiDataEntitiesDegreesEntityIdCardsCardId = async (args: GetApiDataEntitiesDegreesEntityIdCardsCardIdArgs, options?: GetApiDataEntitiesDegreesEntityIdCardsCardIdOptions) => { const {baseUrl = "https://api.crunchbase.com/v4", fetch: fetchFn = fetch, ApiKeyAuthHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.card_field_ids != null) query.append("card_field_ids", String(args.card_field_ids)) if (args.after_id != null) query.append("after_id", String(args.after_id)) if (args.before_id != null) query.append("before_id", String(args.before_id)) if (args.order != null) query.append("order", String(args.order)) if (args.limit != null) query.append("limit", String(args.limit)) if (ApiKeyAuthHeader !== undefined) headers.set("X-cb-user-key", ApiKeyAuthHeader) const url = `${baseUrl.replace(/\/+$/, '')}/data/entities/degrees/${encodeURIComponent(String(args.entity_id))}/cards/${encodeURIComponent(String(args.card_id))}${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(degreeEntity, await res.json()) };