import {z} from 'zod' export type V1StateAbbreviation = 'AL' | 'AK' | 'AZ' | 'AR' | 'CA' | 'CO' | 'CT' | 'DE' | 'DC' | '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' | 'VI' | 'AE' | 'AA' | 'AP' | 'GU' | 'AS'; export type V1BusinessStructure = 'SOLE_PROPRIETORSHIP' | 'GENERAL_PARTNERSHIP' | 'LLC' | 'LLP' | 'LLLP' | 'LP' | 'C_CORPORATION' | 'S_CORPORATION' | 'B_CORPORATION' | 'NONPROFIT' | 'COOPERATIVE' | 'TRUST' | 'PROFESSIONAL_ASSOCIATION' | 'PROFESSIONAL_CORPORATION' | 'TRADE_NAME' | 'BANK' | 'CREDIT_UNION' | 'INSURANCE' | 'OTHER'; export type V1LienFilingOrganizationRecordOwnerParty = {mailing_address?: (string | null) | undefined, city?: (string | null) | undefined, state?: (V1StateAbbreviation | null) | undefined, postal_code?: (string | null) | undefined, organization_name?: (string | null) | undefined, organization_type?: (V1BusinessStructure | null) | undefined, type: 'ORGANIZATION'}; export type V1LienFilingIndividualRecordOwnerParty = {mailing_address?: (string | null) | undefined, city?: (string | null) | undefined, state?: (V1StateAbbreviation | null) | undefined, postal_code?: (string | null) | undefined, suffix?: (string | null) | undefined, last_name?: (string | null) | undefined, first_name?: (string | null) | undefined, middle_name?: (string | null) | undefined, type: 'INDIVIDUAL'}; export type V1LienFilingRealEstateInfo = {type: 'FILE_IN_REAL_ESTATE_RECORDS', covers_timber?: (boolean | null) | undefined, covers_as_extracted_collateral?: (boolean | null) | undefined, filed_as_fixture?: (boolean | null) | undefined, real_estate_record_owner?: (V1LienFilingOrganizationRecordOwnerParty | V1LienFilingIndividualRecordOwnerParty | null) | undefined, real_estate_description?: (string | null) | undefined}; export type V1LienFilingNoRealEstateInfo = {type: 'NO_REAL_ESTATE_INFO'}; export type StateAbbreviation = 'AL' | 'AK' | 'AZ' | 'AR' | 'CA' | 'CO' | 'CT' | 'DE' | 'DC' | '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' | 'VI' | 'AE' | 'AA' | 'AP' | 'GU' | 'AS'; export type BusinessStructure = 'SOLE_PROPRIETORSHIP' | 'GENERAL_PARTNERSHIP' | 'LLC' | 'LLP' | 'LLLP' | 'LP' | 'C_CORPORATION' | 'S_CORPORATION' | 'B_CORPORATION' | 'NONPROFIT' | 'COOPERATIVE' | 'TRUST' | 'PROFESSIONAL_ASSOCIATION' | 'PROFESSIONAL_CORPORATION' | 'TRADE_NAME' | 'BANK' | 'CREDIT_UNION' | 'INSURANCE' | 'OTHER'; export type LienPartyDebtorCapacity = 'ESTATE' | 'TRUST' | 'TRUSTEE' | 'NONE_OF_THE_ABOVE'; export type V1LienFilingAssignedBusinessDebtorPartyRequest = {mailing_address?: (string | null) | undefined, city?: (string | null) | undefined, state?: (StateAbbreviation | null) | undefined, postal_code?: (string | null) | undefined, organization_name?: (string | null) | undefined, organization_type?: (BusinessStructure | null) | undefined, type: 'ORGANIZATION', capacity?: LienPartyDebtorCapacity | undefined}; export type V1LienFilingAssignedPersonDebtorPartyRequest = {mailing_address?: (string | null) | undefined, city?: (string | null) | undefined, state?: (StateAbbreviation | null) | undefined, postal_code?: (string | null) | undefined, suffix?: (string | null) | undefined, last_name?: (string | null) | undefined, first_name?: (string | null) | undefined, middle_name?: (string | null) | undefined, type: 'INDIVIDUAL', capacity?: LienPartyDebtorCapacity | undefined}; export type V1LienFilingOrganizationDebtorParty = {mailing_address?: (string | null) | undefined, city?: (string | null) | undefined, state?: (StateAbbreviation | null) | undefined, postal_code?: (string | null) | undefined, capacity?: LienPartyDebtorCapacity | undefined, organization_name?: (string | null) | undefined, organization_type?: (BusinessStructure | null) | undefined, type: 'ORGANIZATION'}; export type V1LienFilingIndividualDebtorParty = {mailing_address?: (string | null) | undefined, city?: (string | null) | undefined, state?: (StateAbbreviation | null) | undefined, postal_code?: (string | null) | undefined, capacity?: LienPartyDebtorCapacity | undefined, suffix?: (string | null) | undefined, last_name?: (string | null) | undefined, first_name?: (string | null) | undefined, middle_name?: (string | null) | undefined, type: 'INDIVIDUAL'}; export type V1LienFilingOrganizationSecuredParty = {mailing_address?: (string | null) | undefined, city?: (string | null) | undefined, state?: (V1StateAbbreviation | null) | undefined, postal_code?: (string | null) | undefined, masked?: (boolean | null) | undefined, is_assignor?: (boolean | null) | undefined, organization_name?: (string | null) | undefined, organization_type?: (V1BusinessStructure | null) | undefined, type: 'ORGANIZATION'}; export type V1LienFilingIndividualSecuredParty = {mailing_address?: (string | null) | undefined, city?: (string | null) | undefined, state?: (StateAbbreviation | null) | undefined, postal_code?: (string | null) | undefined, masked?: (boolean | null) | undefined, is_assignor?: (boolean | null) | undefined, suffix?: (string | null) | undefined, last_name?: (string | null) | undefined, first_name?: (string | null) | undefined, middle_name?: (string | null) | undefined, type: 'INDIVIDUAL'}; export type V1LienFilingCollateralStatementDesignation = 'NONE' | 'TRUST' | 'PERSONAL_REPRESENTATIVE'; export type V1LienFilingCollateralStatementText = {collateral_statement_designation?: (V1LienFilingCollateralStatementDesignation | null) | undefined, text?: (string | null) | undefined, type: 'TEXT'}; export type LienFilingCollateralStatementDesignation = 'NONE' | 'TRUST' | 'PERSONAL_REPRESENTATIVE'; export type V1LienFilingCollateralStatementAttachmentsRequest = {collateral_statement_designation?: (LienFilingCollateralStatementDesignation | null) | undefined, type: 'ATTACHMENTS'}; export type LienFilingAlternativeNameDesignation = 'AGLIEN' | 'BAILEE_BAILOR' | 'CONSIGNEE_CONSIGNOR' | 'LESSEE_LESSOR' | 'NON_UCC_FILING' | 'SELLER_BUYER' | 'LICENSEE' | 'DEBTOR_SECURED_PARTY'; export type LienFilingAlternativeType = 'TRANSMITTING_UTILITY' | 'MANUFACTURED_HOME' | 'PUBLIC_FINANCE' | 'NOT_APPLICABLE'; export type LienFilingTaxExemptReason = 'DEBTOR_COOPERATIVE_MARKETING_ASSOCIATION' | 'DEBTOR_CREDIT_UNION' | 'DEBTOR_TELEPHONE_COOPERATIVE' | 'GOVERNMENT_AGENCY' | 'JUDGEMENT_LIEN' | 'MUNICIPALITY' | 'REORGANIZATION' | 'SECURITIES' | 'STATE_AGENCY' | 'NOT_EXEMPT'; export type V1LienFilingSubmissionCreateUCC1Request = {reference_data?: (string | null) | undefined, submission_filing_name?: (string | null) | undefined, search_to_reflect?: (boolean | null) | undefined, email_contact?: (string | null) | undefined, real_estate_info?: (V1LienFilingRealEstateInfo | V1LienFilingNoRealEstateInfo | null) | undefined, miscellaneous_info?: (string | null) | undefined, filing_type: 'UCC1', state?: (StateAbbreviation | null) | undefined, jurisdiction_county?: (string | null) | undefined, assigned_business_debtor?: (V1LienFilingAssignedBusinessDebtorPartyRequest | null) | undefined, assigned_debtor?: (V1LienFilingAssignedBusinessDebtorPartyRequest | V1LienFilingAssignedPersonDebtorPartyRequest | null) | undefined, debtors?: (Array | null) | undefined, secured_parties?: (Array | null) | undefined, collateral_statements?: (V1LienFilingCollateralStatementText | V1LienFilingCollateralStatementAttachmentsRequest | null) | undefined, alternative_name_designation?: (LienFilingAlternativeNameDesignation | null) | undefined, alternative_filing_type?: (LienFilingAlternativeType | null) | undefined, principal_indebted_amount?: (number | string | null) | undefined, documentary_tax_stamp_required?: (boolean | null) | undefined, tax_exempt_reason?: (LienFilingTaxExemptReason | null) | undefined}; export type CreateApiPeoplePersonIdLienSubmissionsArgs = {person_id: string, body: V1LienFilingSubmissionCreateUCC1Request}; export type CreateApiPeoplePersonIdLienSubmissionsOptions = {baseUrl?: string | undefined, APIKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; export const v1StateAbbreviation = z.enum(["AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "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", "VI", "AE", "AA", "AP", "GU", "AS"]); export const v1BusinessStructure = z.enum(["SOLE_PROPRIETORSHIP", "GENERAL_PARTNERSHIP", "LLC", "LLP", "LLLP", "LP", "C_CORPORATION", "S_CORPORATION", "B_CORPORATION", "NONPROFIT", "COOPERATIVE", "TRUST", "PROFESSIONAL_ASSOCIATION", "PROFESSIONAL_CORPORATION", "TRADE_NAME", "BANK", "CREDIT_UNION", "INSURANCE", "OTHER"]); export const v1LienFilingOrganizationRecordOwnerParty = z.object({mailing_address: z.string().max(128).nullable().optional(), city: z.string().max(128).nullable().optional(), state: v1StateAbbreviation.nullable().optional(), postal_code: z.string().max(16).nullable().optional(), organization_name: z.string().max(128).nullable().optional(), organization_type: v1BusinessStructure.nullable().optional(), type: z.literal("ORGANIZATION")}); export const v1LienFilingIndividualRecordOwnerParty = z.object({mailing_address: z.string().max(128).nullable().optional(), city: z.string().max(128).nullable().optional(), state: v1StateAbbreviation.nullable().optional(), postal_code: z.string().max(16).nullable().optional(), suffix: z.string().max(16).nullable().optional(), last_name: z.string().max(16).nullable().optional(), first_name: z.string().max(16).nullable().optional(), middle_name: z.string().max(16).nullable().optional(), type: z.literal("INDIVIDUAL")}); export const v1LienFilingRealEstateInfo = z.object({type: z.literal("FILE_IN_REAL_ESTATE_RECORDS"), covers_timber: z.boolean().nullable().optional(), covers_as_extracted_collateral: z.boolean().nullable().optional(), filed_as_fixture: z.boolean().nullable().optional(), real_estate_record_owner: z.union([v1LienFilingOrganizationRecordOwnerParty, v1LienFilingIndividualRecordOwnerParty]).nullable().optional(), real_estate_description: z.string().max(1024).nullable().optional()}); export const v1LienFilingNoRealEstateInfo = z.object({type: z.literal("NO_REAL_ESTATE_INFO")}); export const v1LienPartyDebtorCapacity = z.enum(["ESTATE", "TRUST", "TRUSTEE", "NONE_OF_THE_ABOVE"]); export const v1LienFilingAssignedBusinessDebtorPartyResponse = z.object({id: z.string().optional(), mailing_address: z.string().max(128).nullable().optional(), city: z.string().max(128).nullable().optional(), state: v1StateAbbreviation.nullable().optional(), postal_code: z.string().max(16).nullable().optional(), organization_name: z.string().max(128).nullable().optional(), organization_type: v1BusinessStructure.nullable().optional(), type: z.literal("ORGANIZATION"), capacity: v1LienPartyDebtorCapacity.optional(), business_id: z.string().optional(), role: z.literal("Debtor")}); export const v1LienFilingAssignedPersonDebtorPartyResponse = z.object({id: z.string().optional(), mailing_address: z.string().max(128).nullable().optional(), city: z.string().max(128).nullable().optional(), state: v1StateAbbreviation.nullable().optional(), postal_code: z.string().max(16).nullable().optional(), suffix: z.string().max(16).nullable().optional(), last_name: z.string().max(16).nullable().optional(), first_name: z.string().max(16).nullable().optional(), middle_name: z.string().max(16).nullable().optional(), type: z.literal("INDIVIDUAL"), capacity: v1LienPartyDebtorCapacity.optional(), person_id: z.string().optional(), role: z.literal("Debtor")}); export const v1LienFilingOrganizationDebtorPartyResponse = z.object({id: z.string().optional(), mailing_address: z.string().max(128).nullable().optional(), city: z.string().max(128).nullable().optional(), state: v1StateAbbreviation.nullable().optional(), postal_code: z.string().max(16).nullable().optional(), capacity: v1LienPartyDebtorCapacity.optional(), organization_name: z.string().max(128).nullable().optional(), organization_type: v1BusinessStructure.nullable().optional(), type: z.literal("ORGANIZATION"), role: z.literal("Debtor")}); export const v1LienFilingIndividualDebtorPartyResponse = z.object({id: z.string().optional(), mailing_address: z.string().max(128).nullable().optional(), city: z.string().max(128).nullable().optional(), state: v1StateAbbreviation.nullable().optional(), postal_code: z.string().max(16).nullable().optional(), capacity: v1LienPartyDebtorCapacity.optional(), suffix: z.string().max(16).nullable().optional(), last_name: z.string().max(16).nullable().optional(), first_name: z.string().max(16).nullable().optional(), middle_name: z.string().max(16).nullable().optional(), type: z.literal("INDIVIDUAL"), role: z.literal("Debtor")}); export const v1LienFilingOrganizationSecuredPartyResponse = z.object({id: z.string().optional(), mailing_address: z.string().max(128).nullable().optional(), city: z.string().max(128).nullable().optional(), state: v1StateAbbreviation.nullable().optional(), postal_code: z.string().max(16).nullable().optional(), masked: z.boolean().nullable().optional(), is_assignor: z.boolean().nullable().optional(), organization_name: z.string().max(128).nullable().optional(), organization_type: v1BusinessStructure.nullable().optional(), type: z.literal("ORGANIZATION"), role: z.literal("Secured Party")}); export const v1LienFilingIndividualSecuredPartyResponse = z.object({id: z.string().optional(), mailing_address: z.string().max(128).nullable().optional(), city: z.string().max(128).nullable().optional(), state: v1StateAbbreviation.nullable().optional(), postal_code: z.string().max(16).nullable().optional(), masked: z.boolean().nullable().optional(), is_assignor: z.boolean().nullable().optional(), suffix: z.string().max(16).nullable().optional(), last_name: z.string().max(16).nullable().optional(), first_name: z.string().max(16).nullable().optional(), middle_name: z.string().max(16).nullable().optional(), type: z.literal("INDIVIDUAL"), role: z.literal("Secured Party")}); export const v1LienFilingCollateralStatementDesignation = z.enum(["NONE", "TRUST", "PERSONAL_REPRESENTATIVE"]); export const v1LienFilingCollateralStatementText = z.object({collateral_statement_designation: v1LienFilingCollateralStatementDesignation.nullable().optional(), text: z.string().nullable().optional(), type: z.literal("TEXT")}); export const v1LienFilingAttachment = z.object({id: z.string(), document_filename: z.string().max(256)}); export const v1LienFilingCollateralStatementAttachmentsResponse = z.object({collateral_statement_designation: v1LienFilingCollateralStatementDesignation.nullable().optional(), attachments: z.array(v1LienFilingAttachment).optional(), type: z.literal("ATTACHMENTS")}); export const v1LienFilingAlternativeNameDesignation = z.enum(["AGLIEN", "BAILEE_BAILOR", "CONSIGNEE_CONSIGNOR", "LESSEE_LESSOR", "NON_UCC_FILING", "SELLER_BUYER", "LICENSEE", "DEBTOR_SECURED_PARTY"]); export const v1LienFilingAlternativeType = z.enum(["TRANSMITTING_UTILITY", "MANUFACTURED_HOME", "PUBLIC_FINANCE", "NOT_APPLICABLE"]); export const v1LienFilingTaxExemptReason = z.enum(["DEBTOR_COOPERATIVE_MARKETING_ASSOCIATION", "DEBTOR_CREDIT_UNION", "DEBTOR_TELEPHONE_COOPERATIVE", "GOVERNMENT_AGENCY", "JUDGEMENT_LIEN", "MUNICIPALITY", "REORGANIZATION", "SECURITIES", "STATE_AGENCY", "NOT_EXEMPT"]); export const v1LienFilingSubmissionStatus = z.enum(["Draft", "Requested", "InReview", "NeedsAttention", "Submitted", "Filed", "Cancelled"]); export const v1LienFilingSubmissionUCC1Response = z.object({reference_data: z.string().max(128).nullable().optional(), submission_filing_name: z.string().max(128).nullable().optional(), search_to_reflect: z.boolean().nullable().optional(), email_contact: z.string().max(256).nullable().optional(), real_estate_info: z.union([v1LienFilingRealEstateInfo, v1LienFilingNoRealEstateInfo]).nullable().optional(), miscellaneous_info: z.string().max(256).nullable().optional(), filing_type: z.literal("UCC1"), state: v1StateAbbreviation.nullable().optional(), jurisdiction_county: z.string().max(128).nullable().optional(), assigned_business_debtor: v1LienFilingAssignedBusinessDebtorPartyResponse.nullable().optional(), assigned_debtor: z.union([v1LienFilingAssignedBusinessDebtorPartyResponse, v1LienFilingAssignedPersonDebtorPartyResponse]).nullable().optional(), debtors: z.array(z.discriminatedUnion("type", [v1LienFilingOrganizationDebtorPartyResponse, v1LienFilingIndividualDebtorPartyResponse])).nullable().optional(), secured_parties: z.array(z.discriminatedUnion("type", [v1LienFilingOrganizationSecuredPartyResponse, v1LienFilingIndividualSecuredPartyResponse])).nullable().optional(), collateral_statements: z.discriminatedUnion("type", [v1LienFilingCollateralStatementText, v1LienFilingCollateralStatementAttachmentsResponse]).optional(), alternative_name_designation: v1LienFilingAlternativeNameDesignation.nullable().optional(), alternative_filing_type: v1LienFilingAlternativeType.nullable().optional(), principal_indebted_amount: z.string().nullable().optional(), documentary_tax_stamp_required: z.boolean().nullable().optional(), tax_exempt_reason: v1LienFilingTaxExemptReason.nullable().optional(), id: z.string().optional(), filing_status: v1LienFilingSubmissionStatus.optional(), filing_number: z.string().max(128).nullable().optional(), filing_date: z.string().nullable().optional(), lapse_date: z.string().nullable().optional(), has_downloadable_document: z.boolean().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 }; /** * Create New Ucc1 Lien Filing Submission For Person * * POST /people/{person_id}/lien_submissions */ export const createApiPeoplePersonIdLienSubmissions = async (args: CreateApiPeoplePersonIdLienSubmissionsArgs, options?: CreateApiPeoplePersonIdLienSubmissionsOptions) => { const {baseUrl = "https://api.baselayer.com", fetch: fetchFn = fetch, APIKeyHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (APIKeyHeader !== undefined) headers.set("X-API-Key", APIKeyHeader) const url = `${baseUrl.replace(/\/+$/, '')}/people/${encodeURIComponent(String(args.person_id))}/lien_submissions${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(v1LienFilingSubmissionUCC1Response, await res.json()) };