import {z} from 'zod' export type Industry = 'accounting_bookkeeping' | 'accounting_bookkeeping_tax_preparation' | 'advertising' | 'art' | 'art_theater' | 'art_painting' | 'art_sculpting' | 'beauty_cosmetic_services' | 'biotech' | 'business_management' | 'cafeterias_grill_buffets_buffets' | 'caterers' | 'cleaning_services' | 'construction' | 'consulting' | 'consulting_strategy' | 'consulting_business' | 'consulting_financial' | 'crypto' | 'crypto_exchange' | 'crypto_investments' | 'crypto_daos' | 'crypto_nfts' | 'crypto_mining' | 'saas' | 'design' | 'design_web' | 'design_digital' | 'design_interior' | 'design_fashion' | 'drinking_places_alcoholic_beverages' | 'ecommerce' | 'ecommerce_amazon' | 'ecommerce_ebay' | 'ecommerce_shopify' | 'education' | 'education_university' | 'education_financial' | 'energy' | 'energy_solar' | 'energy_wind' | 'energy_refining' | 'energy_fuel' | 'entertainment' | 'entertainment_television' | 'entertainment_film' | 'entertainment_music' | 'entertainment_print' | 'financial_services' | 'financial_services_money_services_business' | 'financial_services_payment_processor' | 'financial_services_fintech' | 'financial_services_consumer_commercial_lending' | 'fitness' | 'food' | 'food_restaurant_food_truck' | 'food_manufacturing' | 'food_service_contractors' | 'full_service_restaurants' | 'hardware' | 'health_services' | 'health_services_clinic' | 'health_services_telehealth' | 'health_services_holistic_services' | 'health_services_healthcare_tech' | 'holding' | 'insurance' | 'investment' | 'investment_venture_capital' | 'legal' | 'legal_attorney' | 'legal_paralegal' | 'limited_service_restaurants' | 'marketing' | 'marketplace' | 'merchant_banking' | 'merges_and_acquisitions' | 'mining' | 'mobile_food_services' | 'nonprofit' | 'other' | 'private_equity' | 'professional_services' | 'professional_services_architect' | 'professional_services_attorney' | 'professional_services_doctor' | 'professional_services_engineer' | 'professional_services_paralegal' | 'real_estate' | 'real_estate_short_term_rental' | 'real_estate_development' | 'real_estate_investing' | 'real_estate_property_management' | 'recruiting' | 'research' | 'research_medical' | 'research_scientific' | 'research_market' | 'retail_wholesale' | 'security' | 'security_private' | 'security_infosec' | 'shipping_warehousing' | 'sports_team' | 'support_services' | 'snack_and_nonalcoholic_beverage_bars' | 'software' | 'software_b2b' | 'software_developer_tools' | 'software_enterprise_software' | 'technology' | 'technology_agriculture' | 'technology_artificial_intelligence' | 'technology_augmented_reality' | 'technology_community' | 'technology_consumer' | 'technology_drones' | 'technology_government' | 'technology_it_telecom' | 'technology_robotics' | 'technology_virtual_reality' | 'transportation' | 'transportation_limo_car_service' | 'transportation_ride_share' | 'travel' | 'travel_agency' | 'travel_hotel_reservations' | 'waste_management' | 'cannabis'; export type AccountPurpose = 'additional_yield' | 'business_operations' | 'other'; export type DateString = string; export type StateCode = 'AL' | 'AK' | 'AZ' | 'AR' | 'CA' | 'CO' | 'CT' | 'DC' | 'DE' | 'FL' | 'GA' | 'HI' | 'ID' | 'IL' | 'IN' | 'IA' | 'KS' | 'KY' | 'LA' | 'ME' | 'MD' | 'MA' | 'MI' | 'MN' | 'MS' | 'MO' | 'MT' | 'NE' | 'NV' | 'NH' | 'NJ' | 'NM' | 'NY' | 'NC' | 'ND' | 'OH' | 'OK' | 'OR' | 'PA' | 'RI' | 'SC' | 'SD' | 'TN' | 'TX' | 'UT' | 'VT' | 'VA' | 'WA' | 'WV' | 'WI' | 'WY' | 'PR'; export type LegalStructure = 'ccorp' | 'corp' | 'estate' | 'foreign_entity' | 'llc' | 'llp' | 'lp' | 'nonprofit' | 'partnership' | 'scheme' | 'scorp' | 'soleprop' | 'trust'; export type CountryCodeAlpha2 = 'AW' | 'AF' | 'AO' | 'AI' | 'AX' | 'AL' | 'AD' | 'AE' | 'AR' | 'AM' | 'AS' | 'AQ' | 'TF' | 'AG' | 'AU' | 'AT' | 'AZ' | 'BI' | 'BE' | 'BJ' | 'BQ' | 'BF' | 'BD' | 'BG' | 'BH' | 'BS' | 'BA' | 'BL' | 'BY' | 'BZ' | 'BM' | 'BO' | 'BR' | 'BB' | 'BN' | 'BT' | 'BV' | 'BW' | 'CF' | 'CA' | 'CC' | 'CH' | 'CL' | 'CN' | 'CI' | 'CM' | 'CD' | 'CG' | 'CK' | 'CO' | 'KM' | 'CV' | 'CR' | 'CU' | 'CW' | 'CX' | 'KY' | 'CY' | 'CZ' | 'DE' | 'DJ' | 'DM' | 'DK' | 'DO' | 'DZ' | 'EC' | 'EG' | 'ER' | 'EH' | 'ES' | 'EE' | 'ET' | 'FI' | 'FJ' | 'FK' | 'FR' | 'FO' | 'FM' | 'GA' | 'GB' | 'GE' | 'GG' | 'GH' | 'GI' | 'GN' | 'GP' | 'GM' | 'GW' | 'GQ' | 'GR' | 'GD' | 'GL' | 'GT' | 'GF' | 'GU' | 'GY' | 'HK' | 'HM' | 'HN' | 'HR' | 'HT' | 'HU' | 'ID' | 'IM' | 'IN' | 'IO' | 'IE' | 'IR' | 'IQ' | 'IS' | 'IL' | 'IT' | 'JM' | 'JE' | 'JO' | 'JP' | 'KZ' | 'KE' | 'KG' | 'KH' | 'KI' | 'KN' | 'KR' | 'KW' | 'LA' | 'LB' | 'LR' | 'LY' | 'LC' | 'LI' | 'LK' | 'LS' | 'LT' | 'LU' | 'LV' | 'MO' | 'MF' | 'MA' | 'MC' | 'MD' | 'MG' | 'MV' | 'MX' | 'MH' | 'MK' | 'ML' | 'MT' | 'MM' | 'ME' | 'MN' | 'MP' | 'MZ' | 'MR' | 'MS' | 'MQ' | 'MU' | 'MW' | 'MY' | 'YT' | 'NA' | 'NC' | 'NE' | 'NF' | 'NG' | 'NI' | 'NU' | 'NL' | 'NO' | 'NP' | 'NR' | 'NZ' | 'OM' | 'PK' | 'PA' | 'PN' | 'PE' | 'PH' | 'PW' | 'PG' | 'PL' | 'PR' | 'KP' | 'PT' | 'PY' | 'PS' | 'PF' | 'QA' | 'RE' | 'RO' | 'RU' | 'RW' | 'SA' | 'SD' | 'SN' | 'SG' | 'GS' | 'SH' | 'SJ' | 'SB' | 'SL' | 'SV' | 'SM' | 'SO' | 'PM' | 'RS' | 'SS' | 'ST' | 'SR' | 'SK' | 'SI' | 'SE' | 'SZ' | 'SX' | 'SC' | 'SY' | 'TC' | 'TD' | 'TG' | 'TH' | 'TJ' | 'TK' | 'TM' | 'TL' | 'TO' | 'TT' | 'TN' | 'TR' | 'TV' | 'TW' | 'TZ' | 'UG' | 'UA' | 'UM' | 'UY' | 'US' | 'UZ' | 'VA' | 'VC' | 'VE' | 'VG' | 'VI' | 'VN' | 'VU' | 'WF' | 'WS' | 'XK' | 'YE' | 'ZA' | 'ZM' | 'ZW'; export type OnboardingAddress = {address: string, address_2?: (string | null) | undefined, city: string, state?: (string | null) | undefined, zip: string, country: CountryCodeAlpha2}; export type CreateBusinessEntityRequest = {business_phone?: (string | null) | undefined, business_taxid?: (string | null) | undefined, business_website?: (string | null) | undefined, business_description?: (string | null) | undefined, business_asset_source_description?: (string | null) | undefined, industry?: (Industry | null) | undefined, account_purpose?: (AccountPurpose | null) | undefined, account_purpose_description?: (string | null) | undefined, provides_blockchain_or_digital_currency_services?: (boolean | null) | undefined, transacts_in_digital_currency?: (boolean | null) | undefined, develops_governs_supports_blockchain_protocol?: (boolean | null) | undefined, business_name?: (string | null) | undefined, business_date_of_incorporation?: (DateString | null) | undefined, incorporation_state?: (StateCode | null) | undefined, legal_structure?: (LegalStructure | null) | undefined, business_address?: (OnboardingAddress | null) | undefined, physical_address?: (OnboardingAddress | null) | undefined, reference_id?: (string | null) | undefined}; export type CreateApiEntitiesArgs = {body: CreateBusinessEntityRequest | null}; export type CreateApiEntitiesOptions = {baseUrl?: string | undefined, apiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const timestamp = z.string(); export const createBusinessEntityResponse = z.object({id: z.string(), business_name: z.string().nullable(), created_at: timestamp}); 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 }; /** * Create Business Entity * * POST /entities */ export const createApiEntities = async (args: CreateApiEntitiesArgs, options?: CreateApiEntitiesOptions) => { const {baseUrl = "https://api.meow.com/v1", fetch: fetchFn = fetch, apiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (apiKeyAuth !== undefined) headers.set("x-api-key", apiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/entities${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(createBusinessEntityResponse, await res.json()) };