autumn-js
Version:
Autumn JS Library
172 lines (166 loc) • 4.94 kB
TypeScript
import { z } from 'zod/v4';
declare const Infinite = "inf";
declare enum FreeTrialDuration {
Day = "day"
}
declare enum UsageModel {
Prepaid = "prepaid",
PayPerUse = "pay_per_use"
}
type UsageModelType = "prepaid" | "pay_per_use";
declare enum ProductItemInterval {
Minute = "minute",
Hour = "hour",
Day = "day",
Week = "week",
Month = "month",
Quarter = "quarter",
SemiAnnual = "semi_annual",
Year = "year",
Multiple = "multiple"
}
type ProductItemIntervalType = "minute" | "hour" | "day" | "week" | "month" | "quarter" | "semi_annual" | "year" | "multiple";
type CheckFeatureScenario = "usage_limit" | "feature_flag";
declare const CheckFeatureResultSchema: z.ZodObject<{
allowed: z.ZodBoolean;
feature_id: z.ZodString;
customer_id: z.ZodString;
entity_id: z.ZodOptional<z.ZodString>;
required_balance: z.ZodNumber;
unlimited: z.ZodOptional<z.ZodBoolean>;
interval: z.ZodOptional<z.ZodEnum<typeof ProductItemInterval>>;
balance: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
usage: z.ZodOptional<z.ZodNumber>;
included_usage: z.ZodOptional<z.ZodNumber>;
next_reset_at: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
overage_allowed: z.ZodOptional<z.ZodBoolean>;
usage_limit: z.ZodOptional<z.ZodNumber>;
rollovers: z.ZodOptional<z.ZodObject<{
balance: z.ZodNumber;
expires_at: z.ZodNumber;
}, z.core.$strip>>;
breakdown: z.ZodOptional<z.ZodArray<z.ZodObject<{
interval: z.ZodEnum<typeof ProductItemInterval>;
balance: z.ZodOptional<z.ZodNumber>;
usage: z.ZodOptional<z.ZodNumber>;
included_usage: z.ZodOptional<z.ZodNumber>;
next_reset_at: z.ZodOptional<z.ZodNumber>;
}, z.core.$strip>>>;
credit_schema: z.ZodOptional<z.ZodArray<z.ZodObject<{
feature_id: z.ZodString;
credit_amount: z.ZodNumber;
}, z.core.$strip>>>;
}, z.core.$strip>;
type CheckFeatureResult = z.infer<typeof CheckFeatureResultSchema>;
interface CheckFeaturePreview {
scenario: CheckFeatureScenario;
title: string;
message: string;
feature_id: string;
feature_name: string;
products: Product[];
}
type ProductScenario = "scheduled" | "active" | "new" | "renew" | "upgrade" | "downgrade" | "cancel";
interface CheckProductResult {
allowed: boolean;
customer_id: string;
product_id: string;
entity_id?: string;
status?: string;
preview?: CheckProductPreview;
}
interface CheckProductPreview {
scenario: ProductScenario;
product_id: string;
product_name: string;
recurring: boolean;
error_on_attach?: boolean;
next_cycle_at?: number;
current_product_name?: string;
items?: {
price: string;
description: string;
usage_model?: UsageModelType;
}[];
options?: {
feature_id: string;
feature_name: string;
billing_units: number;
price?: number;
tiers?: {
to: number | string;
amount: number;
}[];
}[];
due_today?: {
price: number;
currency: string;
};
due_next_cycle?: {
price: number;
currency: string;
};
}
declare enum AppEnv {
Sandbox = "sandbox",
Live = "live"
}
interface Feature {
id: string;
name: string;
type: "boolean" | "continuous_use" | "single_use" | "credit_system";
}
interface ProductItem {
type?: "feature" | "priced_feature" | "price";
feature_id?: string;
included_usage?: number | typeof Infinite;
interval?: ProductItemIntervalType;
feature?: Feature;
usage_model?: UsageModel;
price?: number;
billing_units?: number;
entity_feature_id?: string;
reset_usage_when_enabled?: boolean;
quantity?: number;
next_cycle_quantity?: number;
display?: {
primary_text?: string;
secondary_text?: string;
};
}
interface FreeTrial {
duration: FreeTrialDuration;
length: number;
unique_fingerprint: boolean;
trial_available?: boolean;
}
interface Product {
id: string;
created_at: number;
name: string;
env: AppEnv;
is_add_on: boolean;
is_default: boolean;
group: string;
version: number;
items: ProductItem[];
free_trial: FreeTrial | null;
scenario?: ProductScenario;
base_variant_id: string | null;
properties: {
is_free: boolean;
is_one_off: boolean;
interval_group: string;
has_trial: boolean;
updateable: boolean;
};
display?: {
name?: string;
description?: string;
button_text?: string;
recommend_text?: string;
everything_from?: string;
button_url?: string;
};
}
export { AppEnv as A, type CheckFeaturePreview as C, type Product as P, type CheckFeatureResult as a, type CheckProductResult as b, type ProductItem as c, type ProductScenario as d, ProductItemInterval as e };