import {z} from 'zod' export type PublicKybProofType = '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 type EntityDocumentConfirmRequest = {object_key: string, proof_type: PublicKybProofType, representative_id?: (string | null) | undefined}; export type CreateApiEntitiesEntityIdDocumentsConfirmArgs = {entity_id: string, body: EntityDocumentConfirmRequest}; export type CreateApiEntitiesEntityIdDocumentsConfirmOptions = {baseUrl?: string | undefined, apiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const partnerDocumentConfirmResponse = z.object({confirmed: z.boolean(), file_name: z.string()}); 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 }; /** * Confirm Entity Document Upload * * POST /entities/{entity_id}/documents/confirm */ export const createApiEntitiesEntityIdDocumentsConfirm = async (args: CreateApiEntitiesEntityIdDocumentsConfirmArgs, options?: CreateApiEntitiesEntityIdDocumentsConfirmOptions) => { 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))}/documents/confirm${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(partnerDocumentConfirmResponse, await res.json()) };