UNPKG

@paykit-sdk/core

Version:

The Payment Toolkit for Typescript

245 lines (242 loc) 7.51 kB
import { z } from 'zod'; import { OverrideProps } from '../types.mjs'; import { BillingInfo } from './billing.mjs'; interface Customer { /** * The unique identifier of the customer. */ id: string; /** * The email of the customer. */ email: string; /** * The name of the customer. */ name: string; /** * The phone number of the customer. */ phone: string | null; /** * The metadata of the customer. */ metadata?: Record<string, string>; /** * The custom fields of the customer for provider-specific or custom data. */ custom_fields?: Record<string, unknown>; /** * The created timestamp of the customer. */ created_at: Date; /** * The last updated timestamp of the customer. */ updated_at: Date | null; } declare const customerSchema: z.ZodObject<{ id: z.ZodString; email: z.ZodString; name: z.ZodString; phone: z.ZodNullable<z.ZodString>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; custom_fields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; created_at: z.ZodDate; updated_at: z.ZodNullable<z.ZodDate>; }, "strip", z.ZodTypeAny, { email: string; name: string; phone: string | null; id: string; created_at: Date; updated_at: Date | null; metadata?: Record<string, string> | undefined; custom_fields?: Record<string, unknown> | undefined; }, { email: string; name: string; phone: string | null; id: string; created_at: Date; updated_at: Date | null; metadata?: Record<string, string> | undefined; custom_fields?: Record<string, unknown> | undefined; }>; type EmailPayee = { email: string; }; type IdPayee = { id: string | number; }; type Payee = EmailPayee | IdPayee; declare const payeeSchema: z.ZodUnion<[z.ZodObject<{ email: z.ZodString; }, "strip", z.ZodTypeAny, { email: string; }, { email: string; }>, z.ZodObject<{ id: z.ZodUnion<[z.ZodString, z.ZodNumber]>; }, "strip", z.ZodTypeAny, { id: string | number; }, { id: string | number; }>]>; interface CreateCustomerParams<TProviderMetadata = Record<string, unknown>> extends OverrideProps<Pick<Customer, 'email' | 'name' | 'phone' | 'metadata'>, { name?: string; phone?: string | null; billing: BillingInfo | null; provider_metadata?: TProviderMetadata; }> { } declare const createCustomerSchema: z.ZodObject<{ email: z.ZodString; name: z.ZodOptional<z.ZodString>; phone: z.ZodOptional<z.ZodNullable<z.ZodString>>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; billing: z.ZodNullable<z.ZodObject<{ address: z.ZodObject<{ name: z.ZodString; line1: z.ZodString; line2: z.ZodOptional<z.ZodDefault<z.ZodString>>; city: z.ZodString; state: z.ZodOptional<z.ZodString>; postal_code: z.ZodString; country: z.ZodString; phone: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { name: string; line1: string; city: string; postal_code: string; country: string; line2?: string | undefined; state?: string | undefined; phone?: string | undefined; }, { name: string; line1: string; city: string; postal_code: string; country: string; line2?: string | undefined; state?: string | undefined; phone?: string | undefined; }>; carrier: z.ZodOptional<z.ZodString>; currency: z.ZodString; }, "strip", z.ZodTypeAny, { address: { name: string; line1: string; city: string; postal_code: string; country: string; line2?: string | undefined; state?: string | undefined; phone?: string | undefined; }; currency: string; carrier?: string | undefined; }, { address: { name: string; line1: string; city: string; postal_code: string; country: string; line2?: string | undefined; state?: string | undefined; phone?: string | undefined; }; currency: string; carrier?: string | undefined; }>>; provider_metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; }, "strip", z.ZodTypeAny, { email: string; billing: { address: { name: string; line1: string; city: string; postal_code: string; country: string; line2?: string | undefined; state?: string | undefined; phone?: string | undefined; }; currency: string; carrier?: string | undefined; } | null; name?: string | undefined; phone?: string | null | undefined; metadata?: Record<string, string> | undefined; provider_metadata?: Record<string, unknown> | undefined; }, { email: string; billing: { address: { name: string; line1: string; city: string; postal_code: string; country: string; line2?: string | undefined; state?: string | undefined; phone?: string | undefined; }; currency: string; carrier?: string | undefined; } | null; name?: string | undefined; phone?: string | null | undefined; metadata?: Record<string, string> | undefined; provider_metadata?: Record<string, unknown> | undefined; }>; interface UpdateCustomerParams<TProviderMetadata = Record<string, unknown>> extends Partial<Pick<Customer, 'email' | 'name' | 'phone' | 'metadata'>> { provider_metadata?: TProviderMetadata; billing?: BillingInfo | null; } declare const updateCustomerSchema: z.ZodObject<{ email: z.ZodOptional<z.ZodString>; name: z.ZodOptional<z.ZodString>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; provider_metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; }, "strip", z.ZodTypeAny, { email?: string | undefined; name?: string | undefined; metadata?: Record<string, string> | undefined; provider_metadata?: Record<string, unknown> | undefined; }, { email?: string | undefined; name?: string | undefined; metadata?: Record<string, string> | undefined; provider_metadata?: Record<string, unknown> | undefined; }>; interface RetrieveCustomerParams { /** * The unique identifier of the customer. */ id: string; } declare const retrieveCustomerSchema: z.ZodObject<{ id: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; }, { id: string; }>; declare const isEmailCustomer: (customer: unknown) => customer is EmailPayee; declare const isIdCustomer: (customer: unknown) => customer is IdPayee; declare const parseCustomerName: (params: { name?: string; email: string; }) => { fullName: string; firstName: string; lastName: string; initials: string; }; export { type CreateCustomerParams, type Customer, type Payee, type RetrieveCustomerParams, type UpdateCustomerParams, createCustomerSchema, customerSchema, isEmailCustomer, isIdCustomer, parseCustomerName, payeeSchema, retrieveCustomerSchema, updateCustomerSchema };