a0-purchases
Version:
Lightweight subscription management for AI apps with auto-detecting providers
433 lines • 11.9 kB
TypeScript
/**
* Minimal RevenueCat types for a0-purchases
*
* These types are adapted from @revenuecat/purchases-typescript-internal
* Copyright (c) RevenueCat Inc. - https://revenuecat.com
*
* We include only the essential types needed for our a0-purchases library.
* For the full RevenueCat SDK and complete type definitions, please use the
* official RevenueCat packages: https://github.com/RevenueCat/purchases-typescript
*/
/**
* Enum indicating possible package types.
* @public
*/
export declare enum PACKAGE_TYPE {
/**
* A package that was defined with a custom identifier.
*/
UNKNOWN = "UNKNOWN",
/**
* A package that was defined with a custom identifier.
*/
CUSTOM = "CUSTOM",
/**
* A package configured with the predefined lifetime identifier.
*/
LIFETIME = "LIFETIME",
/**
* A package configured with the predefined annual identifier.
*/
ANNUAL = "ANNUAL",
/**
* A package configured with the predefined six month identifier.
*/
SIX_MONTH = "SIX_MONTH",
/**
* A package configured with the predefined three month identifier.
*/
THREE_MONTH = "THREE_MONTH",
/**
* A package configured with the predefined two month identifier.
*/
TWO_MONTH = "TWO_MONTH",
/**
* A package configured with the predefined monthly identifier.
*/
MONTHLY = "MONTHLY",
/**
* A package configured with the predefined weekly identifier.
*/
WEEKLY = "WEEKLY"
}
/**
* Contains data about the context in which an offering was presented.
* @public
*/
export interface PresentedOfferingContext {
/**
* The identifier of the offering used to obtain this object.
*/
readonly offeringIdentifier: string;
/**
* The identifier of the placement used to obtain this object.
*/
readonly placementIdentifier: string | null;
/**
* The revision of the targeting used to obtain this object.
*/
readonly targetingContext: PresentedOfferingTargetingContext | null;
}
/**
* Contains data about the targeting context.
* @public
*/
export interface PresentedOfferingTargetingContext {
/**
* The revision of the targeting used to obtain this object.
*/
readonly revision: number;
/**
* The rule id from the targeting used to obtain this object.
*/
readonly ruleId: string;
}
/**
* Product category enum.
* @public
*/
export declare enum PRODUCT_CATEGORY {
NON_SUBSCRIPTION = "NON_SUBSCRIPTION",
SUBSCRIPTION = "SUBSCRIPTION",
UNKNOWN = "UNKNOWN"
}
/**
* Product type enum.
* @public
*/
export declare enum PRODUCT_TYPE {
CONSUMABLE = "CONSUMABLE",
NON_CONSUMABLE = "NON_CONSUMABLE",
NON_RENEWABLE_SUBSCRIPTION = "NON_RENEWABLE_SUBSCRIPTION",
AUTO_RENEWABLE_SUBSCRIPTION = "AUTO_RENEWABLE_SUBSCRIPTION",
PREPAID_SUBSCRIPTION = "PREPAID_SUBSCRIPTION",
UNKNOWN = "UNKNOWN"
}
/**
* Contains information about the introductory price for a product.
* @public
*/
export interface PurchasesIntroPrice {
readonly price: number;
readonly priceString: string;
readonly cycles: number;
readonly period: string;
readonly periodUnit: string;
readonly periodNumberOfUnits: number;
}
/**
* Contains information about a discount offer for a product.
* @public
*/
export interface PurchasesStoreProductDiscount {
readonly identifier: string;
readonly price: number;
readonly priceString: string;
readonly cycles: number;
readonly period: string;
readonly periodUnit: string;
readonly periodNumberOfUnits: number;
}
/**
* Minimal subscription option interface.
* @public
*/
export interface SubscriptionOption {
readonly id: string;
readonly storeProductId: string;
readonly productId: string;
readonly isBasePlan: boolean;
readonly presentedOfferingContext: PresentedOfferingContext | null;
}
/**
* Type representing a product from the Store.
* @public
*/
export interface PurchasesStoreProduct {
/**
* Product Id.
*/
readonly identifier: string;
/**
* Description of the product.
*/
readonly description: string;
/**
* Title of the product.
*/
readonly title: string;
/**
* Price of the product in the local currency.
*/
readonly price: number;
/**
* Formatted price of the item, including its currency sign.
*/
readonly priceString: string;
/**
* Price per week for subscription products.
*/
readonly pricePerWeek: number;
/**
* Price per month for subscription products.
*/
readonly pricePerMonth: number;
/**
* Price per year for subscription products.
*/
readonly pricePerYear: number;
/**
* Formatted price per week for subscription products.
*/
readonly pricePerWeekString: string;
/**
* Formatted price per month for subscription products.
*/
readonly pricePerMonthString: string;
/**
* Formatted price per year for subscription products.
*/
readonly pricePerYearString: string;
/**
* Currency code for price.
*/
readonly currencyCode: string;
/**
* Introductory price information.
*/
readonly introPrice: PurchasesIntroPrice | null;
/**
* Available discounts for this product.
*/
readonly discounts: PurchasesStoreProductDiscount[] | null;
/**
* Product category.
*/
readonly productCategory: PRODUCT_CATEGORY | null;
/**
* Product type.
*/
readonly productType: PRODUCT_TYPE;
/**
* Subscription period in ISO 8601 format.
*/
readonly subscriptionPeriod: string | null;
/**
* Default subscription option (Google Play only).
*/
readonly defaultOption: SubscriptionOption | null;
/**
* Available subscription options (Google Play only).
*/
readonly subscriptionOptions: SubscriptionOption[] | null;
/**
* @deprecated Use presentedOfferingContext
*/
readonly presentedOfferingIdentifier: string | null;
/**
* Offering context this product belongs to.
*/
readonly presentedOfferingContext: PresentedOfferingContext | null;
}
/**
* Contains information about the product available for the user to purchase.
* @public
*/
export interface PurchasesPackage {
/**
* Unique identifier for this package.
*/
readonly identifier: string;
/**
* Package type for the product.
*/
readonly packageType: PACKAGE_TYPE;
/**
* Product assigned to this package.
*/
readonly product: PurchasesStoreProduct;
/**
* Offering this package belongs to.
* @deprecated Use presentedOfferingContext
*/
readonly offeringIdentifier: string;
/**
* Offering context this package belongs to.
*/
readonly presentedOfferingContext: PresentedOfferingContext;
}
/**
* An offering is a collection of Packages available for the user to purchase.
* @public
*/
export interface PurchasesOffering {
/**
* Unique identifier defined in RevenueCat dashboard.
*/
readonly identifier: string;
/**
* Offering description defined in RevenueCat dashboard.
*/
readonly serverDescription: string;
/**
* Offering metadata defined in RevenueCat dashboard.
*/
readonly metadata: {
[key: string]: unknown;
};
/**
* Array of Package objects available for purchase.
*/
readonly availablePackages: PurchasesPackage[];
/**
* Lifetime package type configured in the RevenueCat dashboard, if available.
*/
readonly lifetime: PurchasesPackage | null;
/**
* Annual package type configured in the RevenueCat dashboard, if available.
*/
readonly annual: PurchasesPackage | null;
/**
* Six month package type configured in the RevenueCat dashboard, if available.
*/
readonly sixMonth: PurchasesPackage | null;
/**
* Three month package type configured in the RevenueCat dashboard, if available.
*/
readonly threeMonth: PurchasesPackage | null;
/**
* Two month package type configured in the RevenueCat dashboard, if available.
*/
readonly twoMonth: PurchasesPackage | null;
/**
* Monthly package type configured in the RevenueCat dashboard, if available.
*/
readonly monthly: PurchasesPackage | null;
/**
* Weekly package type configured in the RevenueCat dashboard, if available.
*/
readonly weekly: PurchasesPackage | null;
}
/**
* Contains all the offerings configured in RevenueCat dashboard.
* @public
*/
export interface PurchasesOfferings {
/**
* Map of all Offering objects keyed by their identifier.
*/
readonly all: {
[key: string]: PurchasesOffering;
};
/**
* Current offering configured in the RevenueCat dashboard.
*/
readonly current: PurchasesOffering | null;
}
/**
* Information about entitlements for a customer.
* @public
*/
export interface PurchasesEntitlementInfo {
/**
* The entitlement identifier from the RevenueCat dashboard
*/
readonly identifier: string;
/**
* True if the user has access to this entitlement
*/
readonly isActive: boolean;
/**
* True if the underlying subscription is set to renew at the end of the billing period (expirationDate).
*/
readonly willRenew: boolean;
/**
* The latest purchase or renewal date for the entitlement.
*/
readonly latestPurchaseDate: string;
/**
* The first date this entitlement was purchased.
*/
readonly originalPurchaseDate: string;
/**
* The expiration date for the entitlement.
*/
readonly expirationDate: string | null;
/**
* The store where this entitlement was unlocked from.
*/
readonly store: string;
/**
* The product identifier that unlocked this entitlement.
*/
readonly productIdentifier: string;
}
/**
* Information about entitlements for a customer.
* @public
*/
export interface PurchasesEntitlementInfos {
/**
* Map of all EntitlementInfo objects (active and inactive) keyed by entitlement identifier.
*/
readonly all: {
[key: string]: PurchasesEntitlementInfo;
};
/**
* Map of active EntitlementInfo objects keyed by entitlement identifier.
*/
readonly active: {
[key: string]: PurchasesEntitlementInfo;
};
}
/**
* A customer info object contains all the information about the status of a user's subscriptions.
* @public
*/
export interface CustomerInfo {
/**
* Entitlements attached to this customer info.
*/
readonly entitlements: PurchasesEntitlementInfos;
/**
* Map of skus to purchase dates.
*/
readonly allPurchaseDates: {
[key: string]: string;
};
/**
* Set of active subscription skus.
*/
readonly activeSubscriptions: string[];
/**
* Set of purchased skus, active and inactive.
*/
readonly allPurchasedProductIdentifiers: string[];
/**
* Returns the version number for the version of the application when the user bought the app.
*/
readonly originalApplicationVersion: string | null;
/**
* The date this user was first seen in RevenueCat.
*/
readonly firstSeen: string;
/**
* The original App User Id recorded for this user.
*/
readonly originalAppUserId: string;
/**
* Date when this info was requested.
*/
readonly requestDate: string;
/**
* The latest expiration date of all purchased skus.
*/
readonly latestExpirationDate: string | null;
/**
* Map of skus to expiration dates.
*/
readonly allExpirationDates: {
[key: string]: string | null;
};
}
//# sourceMappingURL=revenuecat-types.d.ts.map