import { AsyncStoreProperty } from "../common.js"; import { inlineProductSchema } from "@stackframe/stack-shared/dist/schema-fields"; import * as yup from "yup"; //#region src/lib/stack-app/customers/index.d.ts type InlineProduct = yup.InferType; type Item = { displayName: string; /** * May be negative. */ quantity: number; /** * Equal to Math.max(0, quantity). */ nonNegativeQuantity: number; }; type ServerItem = Item & { increaseQuantity(amount: number): Promise; /** * Decreases the quantity by the given amount. * * Note that you may want to use tryDecreaseQuantity instead, as it will prevent the quantity from going below 0 in a race-condition-free way. */ decreaseQuantity(amount: number): Promise; /** * Decreases the quantity by the given amount and returns true if the result is non-negative; returns false and does nothing if the result would be negative. * * Most useful for pre-paid credits. */ tryDecreaseQuantity(amount: number): Promise; }; type CustomerProduct = { id: string | null; quantity: number; displayName: string; customerType: "user" | "team" | "custom"; isServerOnly: boolean; stackable: boolean; /** @deprecated Product ownership is independent of purchase type. Will be removed in a future version. */ type?: "one_time" | "subscription"; subscription: null | { subscriptionId: string | null; currentPeriodEnd: Date | null; cancelAtPeriodEnd: boolean; isCancelable: boolean; }; switchOptions?: Array<{ productId: string; displayName: string; prices: InlineProduct["prices"]; }>; }; type CustomerProductsList = CustomerProduct[] & { nextCursor: string | null; }; type CustomerProductsListOptions = { cursor?: string; limit?: number; }; type CustomerProductsRequestOptions = ({ userId: string; } & CustomerProductsListOptions) | ({ teamId: string; } & CustomerProductsListOptions) | ({ customCustomerId: string; } & CustomerProductsListOptions); type CustomerInvoiceStatus = "draft" | "open" | "paid" | "uncollectible" | "void" | null; type CustomerInvoice = { createdAt: Date; status: CustomerInvoiceStatus; amountTotal: number; hostedInvoiceUrl: string | null; }; type CustomerInvoicesList = CustomerInvoice[] & { nextCursor: string | null; }; type CustomerInvoicesListOptions = { cursor?: string; limit?: number; }; type CustomerInvoicesRequestOptions = ({ userId: string; } & CustomerInvoicesListOptions) | ({ teamId: string; } & CustomerInvoicesListOptions); type CustomerDefaultPaymentMethod = { id: string; brand: string | null; last4: string | null; exp_month: number | null; exp_year: number | null; } | null; type CustomerBilling = { hasCustomer: boolean; defaultPaymentMethod: CustomerDefaultPaymentMethod; }; type CustomerPaymentMethodSetupIntent = { clientSecret: string; stripeAccountId: string; }; type Customer = { readonly id: string; createCheckoutUrl(options: ({ productId: string; returnUrl?: string; } | (IsServer extends true ? { product: InlineProduct; returnUrl?: string; } : never))): Promise; createPaymentMethodSetupIntent(): Promise; setDefaultPaymentMethodFromSetupIntent(setupIntentId: string): Promise; switchSubscription(options: { fromProductId: string; toProductId: string; priceId?: string; quantity?: number; }): Promise; } & AsyncStoreProperty<"billing", [], CustomerBilling, false> & AsyncStoreProperty<"item", [itemId: string], IsServer extends true ? ServerItem : Item, false> & AsyncStoreProperty<"products", [options?: CustomerProductsListOptions], CustomerProductsList, true> & AsyncStoreProperty<"invoices", [options?: CustomerInvoicesListOptions], CustomerInvoicesList, true> & (IsServer extends true ? { grantProduct(product: { productId: string; quantity?: number; } | { product: InlineProduct; quantity?: number; }): Promise; } : {}); //#endregion export { Customer, CustomerBilling, CustomerDefaultPaymentMethod, CustomerInvoice, CustomerInvoiceStatus, CustomerInvoicesList, CustomerInvoicesListOptions, CustomerInvoicesRequestOptions, CustomerPaymentMethodSetupIntent, CustomerProduct, CustomerProductsList, CustomerProductsListOptions, CustomerProductsRequestOptions, InlineProduct, Item, ServerItem }; //# sourceMappingURL=index.d.ts.map