autumn-js
Version:
Autumn JS Library
236 lines (230 loc) • 7.6 kB
text/typescript
import { i as CheckFeatureResult, j as CheckProductResult } from './cusTypes-DT2ujoSl.mjs';
import { z } from 'zod';
import { A as AutumnError } from './error-DHbclCVh.mjs';
declare const CancelResultSchema: z.ZodObject<{
success: z.ZodBoolean;
customer_id: z.ZodString;
product_id: z.ZodString;
}, "strip", z.ZodTypeAny, {
customer_id: string;
success: boolean;
product_id: string;
}, {
customer_id: string;
success: boolean;
product_id: string;
}>;
type CancelResult = z.infer<typeof CancelResultSchema>;
declare const TrackResultSchema: z.ZodObject<{
id: z.ZodString;
code: z.ZodString;
customer_id: z.ZodString;
feature_id: z.ZodOptional<z.ZodString>;
event_name: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
code: string;
id: string;
customer_id: string;
feature_id?: string | undefined;
event_name?: string | undefined;
}, {
code: string;
id: string;
customer_id: string;
feature_id?: string | undefined;
event_name?: string | undefined;
}>;
type TrackResult = z.infer<typeof TrackResultSchema>;
type CheckResult = CheckFeatureResult & CheckProductResult;
interface SetupPaymentResult {
customer_id: string;
url: string;
}
type Success<T> = {
data: T;
error: null;
statusCode?: number;
};
type Failure<E> = {
data: null;
error: E;
statusCode?: number;
};
type Result<T, E> = Success<T> | Failure<E>;
type AutumnPromise<T> = Promise<Result<T, AutumnError>>;
declare const CancelParamsSchema: z.ZodObject<{
productId: z.ZodString;
entityId: z.ZodOptional<z.ZodString>;
cancelImmediately: z.ZodOptional<z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
productId: string;
entityId?: string | undefined;
cancelImmediately?: boolean | undefined;
}, {
productId: string;
entityId?: string | undefined;
cancelImmediately?: boolean | undefined;
}>;
type CancelParams = z.infer<typeof CancelParamsSchema>;
declare const CheckParamsSchema: z.ZodObject<{
featureId: z.ZodOptional<z.ZodString>;
productId: z.ZodOptional<z.ZodString>;
entityId: z.ZodOptional<z.ZodString>;
requiredBalance: z.ZodOptional<z.ZodNumber>;
sendEvent: z.ZodOptional<z.ZodBoolean>;
withPreview: z.ZodOptional<z.ZodBoolean>;
dialog: z.ZodOptional<z.ZodAny>;
entityData: z.ZodOptional<z.ZodAny>;
}, "strip", z.ZodTypeAny, {
productId?: string | undefined;
entityId?: string | undefined;
featureId?: string | undefined;
dialog?: any;
entityData?: any;
requiredBalance?: number | undefined;
sendEvent?: boolean | undefined;
withPreview?: boolean | undefined;
}, {
productId?: string | undefined;
entityId?: string | undefined;
featureId?: string | undefined;
dialog?: any;
entityData?: any;
requiredBalance?: number | undefined;
sendEvent?: boolean | undefined;
withPreview?: boolean | undefined;
}>;
type CheckParams = z.infer<typeof CheckParamsSchema>;
declare const TrackParamsSchema: z.ZodObject<{
featureId: z.ZodOptional<z.ZodString>;
eventName: z.ZodOptional<z.ZodString>;
entityId: z.ZodOptional<z.ZodString>;
value: z.ZodOptional<z.ZodNumber>;
idempotencyKey: z.ZodOptional<z.ZodString>;
entityData: z.ZodOptional<z.ZodAny>;
}, "strip", z.ZodTypeAny, {
value?: number | undefined;
entityId?: string | undefined;
featureId?: string | undefined;
entityData?: any;
eventName?: string | undefined;
idempotencyKey?: string | undefined;
}, {
value?: number | undefined;
entityId?: string | undefined;
featureId?: string | undefined;
entityData?: any;
eventName?: string | undefined;
idempotencyKey?: string | undefined;
}>;
type TrackParams = z.infer<typeof TrackParamsSchema>;
interface OpenBillingPortalParams {
returnUrl?: string;
openInNewTab?: boolean;
}
interface SetupPaymentParams {
successUrl?: string;
checkoutSessionParams?: Record<string, any>;
openInNewTab?: boolean;
}
declare const AttachParamsSchema: z.ZodObject<{
productId: z.ZodOptional<z.ZodString>;
entityId: z.ZodOptional<z.ZodString>;
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
featureId: z.ZodString;
quantity: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
featureId: string;
quantity: number;
}, {
featureId: string;
quantity: number;
}>, "many">>;
productIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
freeTrial: z.ZodOptional<z.ZodBoolean>;
successUrl: z.ZodOptional<z.ZodString>;
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
forceCheckout: z.ZodOptional<z.ZodBoolean>;
/**
* @deprecated This field is deprecated and will be removed in a future version.
*/
dialog: z.ZodOptional<z.ZodAny>;
entityData: z.ZodOptional<z.ZodAny>;
openInNewTab: z.ZodOptional<z.ZodBoolean>;
reward: z.ZodOptional<z.ZodString>;
checkoutSessionParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
}, "strip", z.ZodTypeAny, {
options?: {
featureId: string;
quantity: number;
}[] | undefined;
metadata?: Record<string, string> | undefined;
productId?: string | undefined;
entityId?: string | undefined;
productIds?: string[] | undefined;
freeTrial?: boolean | undefined;
successUrl?: string | undefined;
forceCheckout?: boolean | undefined;
dialog?: any;
entityData?: any;
openInNewTab?: boolean | undefined;
reward?: string | undefined;
checkoutSessionParams?: Record<string, any> | undefined;
}, {
options?: {
featureId: string;
quantity: number;
}[] | undefined;
metadata?: Record<string, string> | undefined;
productId?: string | undefined;
entityId?: string | undefined;
productIds?: string[] | undefined;
freeTrial?: boolean | undefined;
successUrl?: string | undefined;
forceCheckout?: boolean | undefined;
dialog?: any;
entityData?: any;
openInNewTab?: boolean | undefined;
reward?: string | undefined;
checkoutSessionParams?: Record<string, any> | undefined;
}>;
type AttachParams = z.infer<typeof AttachParamsSchema>;
declare const CheckoutParamsSchema: z.ZodObject<{
productId: z.ZodString;
entityId: z.ZodOptional<z.ZodString>;
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
featureId: z.ZodString;
quantity: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
featureId: string;
quantity: number;
}, {
featureId: string;
quantity: number;
}>, "many">>;
successUrl: z.ZodOptional<z.ZodString>;
openInNewTab: z.ZodOptional<z.ZodBoolean>;
dialog: z.ZodOptional<z.ZodAny>;
}, "strip", z.ZodTypeAny, {
productId: string;
options?: {
featureId: string;
quantity: number;
}[] | undefined;
entityId?: string | undefined;
successUrl?: string | undefined;
dialog?: any;
openInNewTab?: boolean | undefined;
}, {
productId: string;
options?: {
featureId: string;
quantity: number;
}[] | undefined;
entityId?: string | undefined;
successUrl?: string | undefined;
dialog?: any;
openInNewTab?: boolean | undefined;
}>;
type CheckoutParams = z.infer<typeof CheckoutParamsSchema>;
export type { AttachParams as A, CheckResult as C, OpenBillingPortalParams as O, Result as R, SetupPaymentParams as S, TrackParams as T, CheckParams as a, AutumnPromise as b, TrackResult as c, CancelParams as d, CancelResult as e, SetupPaymentResult as f, CheckoutParams as g };