export interface ClockRequest {
id?: string;
name?: string;
present: Date | string;
}
export interface ClockResponse {
id: string;
link: string;
present: string;
status: string;
}
/**
* The name of an organization, used to uniquely reference a
* customer account within Tier. Any unique string identifier,
* prefixed with 'org:'
*/
export type OrgName = `org:${string}`;
/**
* Test whether a value is a valid {@link OrgName}
*/
export declare const isOrgName: (o: any) => o is `org:${string}`;
/**
* The name of a feature within Tier. Can be any string
* containing ASCII alphanumeric characters and ':'
*/
export type FeatureName = `feature:${string}`;
/**
* Test whether a value is a valid {@link FeatureName}
*/
export declare const isFeatureName: (f: any) => f is `feature:${string}`;
/**
* A Tier pricing model, as would be stored within a `pricing.json`
* file, or created on
*/
export interface Model {
plans: {
[p: PlanName]: Plan;
};
}
/**
* Test whether a value is a valid {@link Model}
*/
export declare const isModel: (m: any) => m is Model;
/**
* Asserts that a value is a valid {@link Model}
*
* If it is not, then a string is thrown indicating the problem.
*/
export declare const validateModel: (m: any) => asserts m is Model;
/**
* The definition of a plan within a {@link Model}.
*/
export interface Plan {
title?: string;
features?: {
[f: FeatureName]: FeatureDefinition;
};
currency?: string;
interval?: Interval;
}
/**
* Test whether a value is a valid {@link Plan}
*/
export declare const isPlan: (p: any) => p is Plan;
/**
* Asserts that a value is a valid {@link Plan}
*
* If not, throws a string indicating the source of the problem.
*/
export declare const validatePlan: (p: any) => void;
/**
* Valid values for the `interval` field in a {@link FeatureDefinition}
*/
export type Interval = '@daily' | '@weekly' | '@monthly' | '@yearly';
/**
* Test whether a value is a valid {@link Interval}
*/
export declare const isInterval: (i: any) => i is Interval;
/**
* {@link FeatureDefinition} transforms.
*/
export interface Divide {
by?: number;
rounding?: 'up';
}
/**
* Test whether a `divide` field is a valid transform config
*/
export declare const isDivide: (a: any) => a is Divide;
export declare const validateDivide: (a: any) => void;
/**
* The definition of a feature within a {@link Plan}.
*/
export interface FeatureDefinition {
title?: string;
base?: number;
tiers?: FeatureTier[];
mode?: Mode;
aggregate?: Aggregate;
divide?: Divide;
}
/**
* Valid values for the `aggregate` field in a {@link FeatureDefinition}
*/
export type Aggregate = 'sum' | 'max' | 'last' | 'perpetual';
/**
* Test whether a value is a valid {@link Aggregate}
*/
export declare const isAggregate: (a: any) => a is Aggregate;
/**
* Test whether a value is a valid {@link FeatureDefinition}
*/
export declare const isFeatureDefinition: (f: any) => f is FeatureDefinition;
/**
* Asserts that a value is a valid {@link FeatureDefinition}
*
* If not, a string is thrown indicating the source of the problem.
*/
export declare const validateFeatureDefinition: (f: any) => void;
/**
* Valid values for the `mode` field in a {@link FeatureDefinition}
*/
export type Mode = 'graduated' | 'volume';
/**
* Test whether a value is a valiid {@link Mode}
*/
export declare const isMode: (m: any) => m is Mode;
/**
* Entry in the {@link FeatureDefinition} `tier` array
*/
export interface FeatureTier {
upto?: number;
price?: number;
base?: number;
}
/**
* Test whether a value is a valid {@link FeatureTier}
*/
export declare const isFeatureTier: (t: any) => t is FeatureTier;
/**
* Validate that a value is a valid {@link FeatureTier}
*
* If not, a string is thrown indicating the source of the problem.
*/
export declare const validateFeatureTier: (t: any) => void;
/**
* Object representing some amount of feature consumption.
*/
export interface Usage {
feature: FeatureName;
used: number;
limit: number;
}
/**
* The set of {@link Usage} values for each feature that an
* org has access to.
*/
export interface Limits {
org: OrgName;
usage: Usage[];
}
/**
* A {@link Plan} identifier. Format is `plan:@`.
* Name can contain any ASCII alphanumeric characters and `:`.
* Version can contain any ASCII alphanumeric characters.
*/
export type PlanName = `plan:${string}@${string}`;
/**
* An identifier for a feature as defined within a given plan.
* Format is `@` where `feature` is a {@link FeatureName}
* and `plan` is a {@link PlanName}.
*
* FeatureNameVersioned and {@link PlanName} strings may be used
* equivalently to specify prices and entitlements to Tier methods.
*/
export type FeatureNameVersioned = `${FeatureName}@${PlanName}`;
/**
* alias for {@link FeatureNameVersioned}
* @deprecated
*/
export type VersionedFeatureName = FeatureNameVersioned;
/**
* Either a {@link PlanName} or {@link FeatureNameVersioned}
*
* The type of values that may be used to specify prices and entitlements.
*/
export type Features = PlanName | FeatureNameVersioned;
/**
* Test whether a value is a valid {@link PlanName}
*/
export declare const isPlanName: (p: any) => p is `plan:${string}@${string}`;
/**
* Test whether a value is a valid {@link FeatureNameVersioned}
*/
export declare const isFeatureNameVersioned: (f: any) => f is `feature:${string}@plan:${string}@${string}`;
/**
* @deprecated alias for {@link isFeatureNameVersioned}
*/
export declare const isVersionedFeatureName: (f: any) => f is `feature:${string}@plan:${string}@${string}`;
/**
* Test whether a value is a valid {@link Features}
*/
export declare const isFeatures: (f: any) => f is Features;
/**
* Object representing the current phase in an org's subscription schedule
*/
export interface CurrentPhase {
/**
* When the current phase became effective
*/
effective: Date;
/**
* When the current phase will end (if defined)
*/
end?: Date;
/**
* The set of versioned features the customer is subscribed to in this phase
*/
features?: FeatureNameVersioned[];
/**
* The set of plans the customer is currently subscribed to in this phase
*/
plans?: PlanName[];
/**
* One-off versioned features that the customer is subscribed to
*/
fragments?: FeatureNameVersioned[];
/**
* Whether or not this is a trial phase
*/
trial: boolean;
/**
* The effective and end date of the current billing period
*
* For trial periods, this will be the start and end of the trial phase,
* no matter how long it is.
*/
current?: {
effective: Date;
end: Date;
};
}
export interface CurrentPhaseResponse {
effective: string;
end?: string;
features?: FeatureNameVersioned[];
plans?: PlanName[];
fragments?: FeatureNameVersioned[];
trial?: boolean;
current: {
effective: string;
end: string;
};
}
/**
* Object representing a phase in an org's subscription schedule, for
* creating new schedules via `tier.schedule()`.
*/
export interface Phase {
effective?: Date;
features: Features[];
trial?: boolean;
}
/**
* Special empty {@link Phase} object that has no features, indicating
* that the org's plan should be terminated.
*/
export interface CancelPhase {
}
/**
* Test whether a value is a valid {@link Phase}
*/
export declare const isPhase: (p: any) => p is Phase;
/**
* Options for the {@link client.Tier.checkout} method
*/
export interface CheckoutParams {
cancelUrl?: string;
features?: Features | Features[];
trialDays?: number;
requireBillingAddress?: boolean;
}
export interface CheckoutRequest {
org: OrgName;
success_url: string;
features?: Features[];
trial_days?: number;
cancel_url?: string;
require_billing_address?: boolean;
}
/**
* Response from the {@link client.Tier.checkout} method, indicating the url
* that the user must visit to complete the checkout process.
*/
export interface CheckoutResponse {
url: string;
}
export interface ScheduleRequest {
org: OrgName;
phases?: Phase[] | [CancelPhase];
info?: OrgInfoJSON;
payment_method_id?: string;
}
/**
* Response from the methods that use the `/v1/subscribe` endpoint.
*/
export interface ScheduleResponse {
}
/**
* Options for the {@link client.Tier.subscribe} method
*/
export interface SubscribeParams {
effective?: Date;
info?: OrgInfo;
trialDays?: number;
paymentMethodID?: string;
}
/**
* Options for the {@link client.Tier.schedule} method
*/
export interface ScheduleParams {
info?: OrgInfo;
paymentMethodID?: string;
}
export interface PaymentMethodsResponseJSON {
org: string;
methods: null | string[];
}
/**
* Response from the {@link client.Tier.lookupPaymentMethods} method
*/
export interface PaymentMethodsResponse {
org: string;
methods: string[];
}
/**
* Options for the {@link client.Tier.report} and {@link answer.Answer.report} methods
*/
export interface ReportParams {
at?: Date;
clobber?: boolean;
}
export interface ReportRequest {
org: OrgName;
feature: FeatureName;
n?: number;
at?: Date;
clobber?: boolean;
}
export interface ReportResponse {
}
/**
* Response from the {@link client.Tier.whois} method
*/
export interface WhoIsResponse {
org: OrgName;
stripe_id: string;
}
/**
* The object shape we send/receive from the API itself.
* Converted between this and OrgInfo when talking to the API,
* to avoid the excess of snake case.
*/
export interface OrgInfoJSON {
email: string;
name: string;
description: string;
phone: string;
invoice_settings: {
default_payment_method: string;
};
metadata: {
[key: string]: string;
};
}
/**
* Object representing an org's billing metadata. Note that any fields
* not set (other than `metadata`) will be reset to empty `''` values
* on any update.
*
* Used by {@link client.Tier.lookupOrg}, {@link client.Tier.schedule}, and
* {@link client.Tier.subscribe} methods.
*/
export interface OrgInfo {
email: string;
name: string;
description: string;
phone: string;
invoiceSettings?: {
defaultPaymentMethod?: string;
};
metadata: {
[key: string]: string;
};
}
/**
* Response from the {@link client.Tier.lookupOrg} method
*/
export type LookupOrgResponse = WhoIsResponse & OrgInfo;
/**
* Raw JSON response from the lookupOrg API route
*/
export type LookupOrgResponseJSON = WhoIsResponse & OrgInfoJSON;
/**
* Object indicating the success status of a given feature and plan
* when using {@link client.Tier.push}
*/
export interface PushResult {
feature: FeatureNameVersioned;
status: string;
reason: string;
}
/**
* Response from the {@link client.Tier.push} method
*/
export interface PushResponse {
results?: PushResult[];
}
/**
* Response from the {@link client.Tier.whoami} method
*/
export interface WhoAmIResponse {
id: string;
email: string;
key_source: string;
isolated: boolean;
url: string;
}
//# sourceMappingURL=tier-types.d.ts.map