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 EntityUpdateBusinessDetailsRequest = {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}; export type PatchApiEntitiesEntityIdBusinessDetailsArgs = {entity_id: string, body: EntityUpdateBusinessDetailsRequest}; export type PatchApiEntitiesEntityIdBusinessDetailsOptions = {baseUrl?: string | undefined, apiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const onboardingApplicationStatus = z.enum(["pending_document_upload", "pending_user_action", "submitted", "under_review", "approved", "rejected"]); export const timestamp = z.string(); export const publicKybProofType = z.enum(["accredited", "address", "articles_of_organization", "bank_statement", "client_contract", "client_invoice", "beneficial_owner_address", "beneficial_owner_id", "beneficial_owner_id_back", "beneficial_ownership_register", "bylaws", "certificate_of_good_standing", "corporate_resolution", "drivers_license", "due_diligence", "ein", "final_edd_report", "periodic_review_report", "government_issued_business_license", "hemp_cultivator_state_license", "incorporation", "industry_related_license", "lease_agreement", "llc_resolution", "money_service_business_license", "money_transmitter_registration", "mortgage_statement", "national_id", "org_chart", "partnership_agreement", "partnership_agreement_due_diligence", "partnership_resolution", "personal_address", "remote_employees_due_diligence", "signed_ss4", "tax_exemption_certificate", "uk_officer_passport", "officer_registry", "uk_registry", "shareholder_registry", "uk_w8_en", "utility_bill", "us_based_office_proof_of_address_due_diligence", "pitch_deck", "active_business_registration", "proof_of_ownership_or_banking_authorization", "non_profit_bylaws", "operating_agreement", "flow_of_funds", "aml_sanction", "registration_or_license", "sec_filing", "legal_opinion", "certificate_of_formation_master_llc", "series_operating_agreement", "share_subscription_agreement", "fund_subscription_agreement", "safe_agreement", "convertible_note_agreement", "loan_promissory_note", "token_purchase_agreement", "saft_agreement", "deal_memo_hybrid_agreement", "issuer_due_diligence_report", "protocol_ecosystem_questionnaire", "investment_company_due_diligence_form", "us_based_operations_due_diligence_form", "register_of_directors", "articles_of_association", "memorandum_of_association", "non_profit_status", "ofac_sanctions_screening_policy", "aml_kyc_policy", "w8_bene", "corporate_structure_chart", "custody_safeguarding_agreement", "reserve_attestation", "sanctions_vendor_service_agreement", "contractual_fund_flow_agreements"]); export const onboardingDocumentStatus = z.object({proof_type: publicKybProofType, file_name: z.string().nullable(), representative_id: z.string().nullable().optional()}); export const onboardingKycStatus = z.enum(["not_started", "pending", "action_required", "approved", "rejected"]); export const publicOnboardingType = z.enum(["api", "smb", "mcp", "partner"]); export const publicOnboardingStep = z.enum(["gather_business_context", "collect_user_info", "collect_business_addresses", "collect_business_details", "collect_additional_details", "complete_due_diligence", "upload_documents", "manage_representatives", "complete_identity_verification", "accept_terms", "submit_application", "monitor_review", "resolve_info_requests", "onboarding_complete"]); export const onboardingPhase = z.enum(["business_info", "ready_to_submit", "submitted"]); export const publicOutstandingItemKind = z.enum(["document", "answers", "tin"]); export const publicOutstandingItem = z.object({kind: publicOutstandingItemKind, proof_type: publicKybProofType.nullable().optional(), detail: z.string()}); export const onboardingInfoRequest = z.object({request_id: z.string(), required_proof_types: z.array(publicKybProofType), questions_pending: z.boolean(), outstanding: z.array(publicOutstandingItem), note: z.string().nullable(), expires_at: timestamp.nullable()}); export const onboardingNextStep = z.object({step: publicOnboardingStep, phase: onboardingPhase, missing: z.array(z.string()), required_proof_types: z.array(publicKybProofType).optional(), can_submit: z.boolean(), info_requests: z.array(onboardingInfoRequest).optional()}); export const onboardingKycFailedCheck = z.enum(["accept_tos", "verify_sms", "kyc_check", "documentary_verification", "selfie_check", "watchlist_screening", "risk_check"]); export const onboardingRepresentativeKyc = z.object({representative_id: z.string(), first_name: z.string().nullable(), last_name: z.string().nullable(), email: z.string(), is_primary: z.boolean(), is_beneficial_owner: z.boolean(), percent_ownership: z.string().nullable(), kyc_status: onboardingKycStatus, failed_checks: z.array(onboardingKycFailedCheck)}); export const onboardingConsentStatus = z.enum(["pending", "viewed", "completed"]); export const agenticOnboardingConsentType = z.enum(["patriot_act", "application_attestation", "stripe_connected_account", "stripe_issuing_accountholder", "lead_bank_prepaid_card", "lead_bank_privacy", "meow_privacy_policy", "meow_terms_of_service", "grasshopper_terms_of_service", "grasshopper_ics_deposit_placement"]); export const onboardingConsentState = z.object({status: onboardingConsentStatus, consented_items: z.array(agenticOnboardingConsentType), remaining_items: z.array(agenticOnboardingConsentType), viewed_at: timestamp.nullable(), completed_at: timestamp.nullable()}); export const entityOnboardingStatusResponse = z.object({entity_id: z.string(), status: onboardingApplicationStatus, business_name: z.string().nullable(), created_at: timestamp, updated_at: timestamp, documents: z.array(onboardingDocumentStatus), kyc_status: onboardingKycStatus, onboarding_type: publicOnboardingType, next_step: onboardingNextStep, representatives: z.array(onboardingRepresentativeKyc), consent_url: z.string().nullable(), consent: onboardingConsentState.nullable()}); 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 }; /** * Update Business Details * * PATCH /entities/{entity_id}/business-details */ export const patchApiEntitiesEntityIdBusinessDetails = async (args: PatchApiEntitiesEntityIdBusinessDetailsArgs, options?: PatchApiEntitiesEntityIdBusinessDetailsOptions) => { 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/${encodeURIComponent(String(args.entity_id))}/business-details${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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(entityOnboardingStatusResponse, await res.json()) };