Skip to content

Billing

Public billing schema with validated commercial-term constructors; provider selection remains separate.

const Billing: Schema.Union<readonly [Schema.Struct<{
family: Schema.brand<Schema.String, "SubscriptionFamilyKey">;
interval: Schema.Literals<readonly ["month", "year"]>;
meter: Schema.Struct<{
key: Schema.brand<Schema.String, "MeterKey">;
revision: Schema.brand<Schema.Int, "DefinitionRevision">;
}>;
rate: Schema.Struct<{
currency: Schema.brand<Schema.String, "Currency">;
amount: Schema.brand<Schema.BigInt, "MinorCurrencyUnits">;
perUnits: Schema.brand<Schema.BigInt, "MeteredRateUnits">;
rounding: Schema.Literal<"trunc">;
}>;
collection: Schema.Literal<"invoice">;
roundingScope: Schema.Literal<"meter_invoice_period">;
lateUsage: Schema.Literal<"next_invoice_original_rate">;
accessPolicy: Schema.Struct<{
key: Schema.brand<Schema.String, "MerchantAccessPolicyKey">;
revision: Schema.brand<Schema.Int, "DefinitionRevision">;
}>;
type: Schema.tag<"metered_subscription">;
}>, Schema.Struct<{
price: Schema.Struct<{
currency: Schema.brand<Schema.String, "Currency">;
amount: Schema.brand<Schema.BigInt, "MinorCurrencyUnits">;
}>;
minimumQuantity: Schema.brand<Schema.Int, "SeatCapacityQuantity">;
maximumQuantity: Schema.brand<Schema.Int, "SeatCapacityQuantity">;
type: Schema.tag<"per_seat_one_time">;
}>, Schema.Struct<{
family: Schema.brand<Schema.String, "SubscriptionFamilyKey">;
price: Schema.Struct<{
currency: Schema.brand<Schema.String, "Currency">;
amount: Schema.brand<Schema.BigInt, "MinorCurrencyUnits">;
}>;
minimumQuantity: Schema.brand<Schema.Int, "SeatCapacityQuantity">;
maximumQuantity: Schema.brand<Schema.Int, "SeatCapacityQuantity">;
interval: Schema.Literals<readonly ["month", "year"]>;
renewal: Schema.Literal<"manual">;
type: Schema.tag<"per_seat_subscription">;
}>, Schema.Struct<{
price: Schema.Struct<{
currency: Schema.brand<Schema.String, "Currency">;
amount: Schema.brand<Schema.BigInt, "MinorCurrencyUnits">;
}>;
type: Schema.tag<"one_time">;
}>, Schema.Struct<{
family: Schema.brand<Schema.String, "SubscriptionFamilyKey">;
price: Schema.Struct<{
currency: Schema.brand<Schema.String, "Currency">;
amount: Schema.brand<Schema.BigInt, "MinorCurrencyUnits">;
}>;
interval: Schema.Literals<readonly ["month", "year"]>;
renewal: Schema.Literal<"manual">;
type: Schema.tag<"subscription">;
}>]> & {
discriminants: readonly ["metered_subscription", "per_seat_one_time", "per_seat_subscription", "one_time", "subscription"];
cases: {
metered_subscription: Schema.Struct<{
family: Schema.brand<Schema.String, "SubscriptionFamilyKey">;
interval: Schema.Literals<readonly ["month", "year"]>;
meter: Schema.Struct<{
key: Schema.brand<Schema.String, "MeterKey">;
revision: Schema.brand<Schema.Int, "DefinitionRevision">;
}>;
rate: Schema.Struct<{
currency: Schema.brand<Schema.String, "Currency">;
amount: Schema.brand<Schema.BigInt, "MinorCurrencyUnits">;
perUnits: Schema.brand<Schema.BigInt, "MeteredRateUnits">;
rounding: Schema.Literal<"trunc">;
}>;
collection: Schema.Literal<"invoice">;
roundingScope: Schema.Literal<"meter_invoice_period">;
lateUsage: Schema.Literal<"next_invoice_original_rate">;
accessPolicy: Schema.Struct<{
key: Schema.brand<Schema.String, "MerchantAccessPolicyKey">;
revision: Schema.brand<Schema.Int, "DefinitionRevision">;
}>;
type: Schema.tag<"metered_subscription">;
}>;
one_time: Schema.Struct<{
price: Schema.Struct<{
currency: Schema.brand<Schema.String, "Currency">;
amount: Schema.brand<Schema.BigInt, "MinorCurrencyUnits">;
}>;
type: Schema.tag<"one_time">;
}>;
per_seat_one_time: Schema.Struct<{
price: Schema.Struct<{
currency: Schema.brand<Schema.String, "Currency">;
amount: Schema.brand<Schema.BigInt, "MinorCurrencyUnits">;
}>;
minimumQuantity: Schema.brand<Schema.Int, "SeatCapacityQuantity">;
maximumQuantity: Schema.brand<Schema.Int, "SeatCapacityQuantity">;
type: Schema.tag<"per_seat_one_time">;
}>;
per_seat_subscription: Schema.Struct<{
family: Schema.brand<Schema.String, "SubscriptionFamilyKey">;
price: Schema.Struct<{
currency: Schema.brand<Schema.String, "Currency">;
amount: Schema.brand<Schema.BigInt, "MinorCurrencyUnits">;
}>;
minimumQuantity: Schema.brand<Schema.Int, "SeatCapacityQuantity">;
maximumQuantity: Schema.brand<Schema.Int, "SeatCapacityQuantity">;
interval: Schema.Literals<readonly ["month", "year"]>;
renewal: Schema.Literal<"manual">;
type: Schema.tag<"per_seat_subscription">;
}>;
subscription: Schema.Struct<{
family: Schema.brand<Schema.String, "SubscriptionFamilyKey">;
price: Schema.Struct<{
currency: Schema.brand<Schema.String, "Currency">;
amount: Schema.brand<Schema.BigInt, "MinorCurrencyUnits">;
}>;
interval: Schema.Literals<readonly ["month", "year"]>;
renewal: Schema.Literal<"manual">;
type: Schema.tag<"subscription">;
}>;
};
isAnyOf: <Keys>(keys) => (value) => value is Extract<{ family: string & any; interval: "month" | "year"; meter: { key: string & any; revision: number & any }; rate: { currency: string & any; amount: bigint & any; perUnits: bigint & any; rounding: "trunc" }; collection: "invoice"; roundingScope: "meter_invoice_period"; lateUsage: "next_invoice_original_rate"; accessPolicy: { key: string & any; revision: number & any }; type: "metered_subscription" }, { type: Keys }> | Extract<{ price: { currency: string & any; amount: bigint & any }; minimumQuantity: number & any; maximumQuantity: number & any; type: "per_seat_one_time" }, { type: Keys }> | Extract<{ family: string & any; price: { currency: string & any; amount: bigint & any }; minimumQuantity: number & any; maximumQuantity: number & any; interval: "month" | "year"; renewal: "manual"; type: "per_seat_subscription" }, { type: Keys }> | Extract<{ price: { currency: string & any; amount: bigint & any }; type: "one_time" }, { type: Keys }> | Extract<{ family: string & any; price: { currency: string & any; amount: bigint & any }; interval: "month" | "year"; renewal: "manual"; type: "subscription" }, { type: Keys }>;
guards: {
metered_subscription: (u) => u is { family: string & any; interval: "month" | "year"; meter: { key: string & any; revision: number & any }; rate: { currency: string & any; amount: bigint & any; perUnits: bigint & any; rounding: "trunc" }; collection: "invoice"; roundingScope: "meter_invoice_period"; lateUsage: "next_invoice_original_rate"; accessPolicy: { key: string & any; revision: number & any }; type: "metered_subscription" };
one_time: (u) => u is { price: { currency: string & any; amount: bigint & any }; type: "one_time" };
per_seat_one_time: (u) => u is { price: { currency: string & any; amount: bigint & any }; minimumQuantity: number & any; maximumQuantity: number & any; type: "per_seat_one_time" };
per_seat_subscription: (u) => u is { family: string & any; price: { currency: string & any; amount: bigint & any }; minimumQuantity: number & any; maximumQuantity: number & any; interval: "month" | "year"; renewal: "manual"; type: "per_seat_subscription" };
subscription: (u) => u is { family: string & any; price: { currency: string & any; amount: bigint & any }; interval: "month" | "year"; renewal: "manual"; type: "subscription" };
};
match: {
<Cases> (value, cases): Cases[keyof Cases] extends (value) => R ? any : never;
<Cases> (cases): (value) => Cases[keyof Cases] extends (value) => R ? any : never;
};
} & {
oneTime: (input) => Effect.Effect<typeof BillingSchema.cases.one_time.Type, Schema.SchemaError>;
subscription: (input) => Effect.Effect<typeof BillingSchema.cases.subscription.Type, Schema.SchemaError>;
perSeatOneTime: (input) => Effect.Effect<typeof BillingSchema.cases.per_seat_one_time.Type, Schema.SchemaError>;
perSeatSubscription: (input) => Effect.Effect<typeof BillingSchema.cases.per_seat_subscription.Type, Schema.SchemaError>;
meteredSubscription: (input) => Effect.Effect<typeof BillingSchema.cases.metered_subscription.Type, Schema.SchemaError>;
};
readonly discriminants: readonly ["metered_subscription", "per_seat_one_time", "per_seat_subscription", "one_time", "subscription"];
readonly cases: {
metered_subscription: Schema.Struct<{
family: Schema.brand<Schema.String, "SubscriptionFamilyKey">;
interval: Schema.Literals<readonly ["month", "year"]>;
meter: Schema.Struct<{
key: Schema.brand<Schema.String, "MeterKey">;
revision: Schema.brand<Schema.Int, "DefinitionRevision">;
}>;
rate: Schema.Struct<{
currency: Schema.brand<Schema.String, "Currency">;
amount: Schema.brand<Schema.BigInt, "MinorCurrencyUnits">;
perUnits: Schema.brand<Schema.BigInt, "MeteredRateUnits">;
rounding: Schema.Literal<"trunc">;
}>;
collection: Schema.Literal<"invoice">;
roundingScope: Schema.Literal<"meter_invoice_period">;
lateUsage: Schema.Literal<"next_invoice_original_rate">;
accessPolicy: Schema.Struct<{
key: Schema.brand<Schema.String, "MerchantAccessPolicyKey">;
revision: Schema.brand<Schema.Int, "DefinitionRevision">;
}>;
type: Schema.tag<"metered_subscription">;
}>;
one_time: Schema.Struct<{
price: Schema.Struct<{
currency: Schema.brand<Schema.String, "Currency">;
amount: Schema.brand<Schema.BigInt, "MinorCurrencyUnits">;
}>;
type: Schema.tag<"one_time">;
}>;
per_seat_one_time: Schema.Struct<{
price: Schema.Struct<{
currency: Schema.brand<Schema.String, "Currency">;
amount: Schema.brand<Schema.BigInt, "MinorCurrencyUnits">;
}>;
minimumQuantity: Schema.brand<Schema.Int, "SeatCapacityQuantity">;
maximumQuantity: Schema.brand<Schema.Int, "SeatCapacityQuantity">;
type: Schema.tag<"per_seat_one_time">;
}>;
per_seat_subscription: Schema.Struct<{
family: Schema.brand<Schema.String, "SubscriptionFamilyKey">;
price: Schema.Struct<{
currency: Schema.brand<Schema.String, "Currency">;
amount: Schema.brand<Schema.BigInt, "MinorCurrencyUnits">;
}>;
minimumQuantity: Schema.brand<Schema.Int, "SeatCapacityQuantity">;
maximumQuantity: Schema.brand<Schema.Int, "SeatCapacityQuantity">;
interval: Schema.Literals<readonly ["month", "year"]>;
renewal: Schema.Literal<"manual">;
type: Schema.tag<"per_seat_subscription">;
}>;
subscription: Schema.Struct<{
family: Schema.brand<Schema.String, "SubscriptionFamilyKey">;
price: Schema.Struct<{
currency: Schema.brand<Schema.String, "Currency">;
amount: Schema.brand<Schema.BigInt, "MinorCurrencyUnits">;
}>;
interval: Schema.Literals<readonly ["month", "year"]>;
renewal: Schema.Literal<"manual">;
type: Schema.tag<"subscription">;
}>;
};
metered_subscription: Schema.Struct<{
family: Schema.brand<Schema.String, "SubscriptionFamilyKey">;
interval: Schema.Literals<readonly ["month", "year"]>;
meter: Schema.Struct<{
key: Schema.brand<Schema.String, "MeterKey">;
revision: Schema.brand<Schema.Int, "DefinitionRevision">;
}>;
rate: Schema.Struct<{
currency: Schema.brand<Schema.String, "Currency">;
amount: Schema.brand<Schema.BigInt, "MinorCurrencyUnits">;
perUnits: Schema.brand<Schema.BigInt, "MeteredRateUnits">;
rounding: Schema.Literal<"trunc">;
}>;
collection: Schema.Literal<"invoice">;
roundingScope: Schema.Literal<"meter_invoice_period">;
lateUsage: Schema.Literal<"next_invoice_original_rate">;
accessPolicy: Schema.Struct<{
key: Schema.brand<Schema.String, "MerchantAccessPolicyKey">;
revision: Schema.brand<Schema.Int, "DefinitionRevision">;
}>;
type: Schema.tag<"metered_subscription">;
}>;
one_time: Schema.Struct<{
price: Schema.Struct<{
currency: Schema.brand<Schema.String, "Currency">;
amount: Schema.brand<Schema.BigInt, "MinorCurrencyUnits">;
}>;
type: Schema.tag<"one_time">;
}>;
per_seat_one_time: Schema.Struct<{
price: Schema.Struct<{
currency: Schema.brand<Schema.String, "Currency">;
amount: Schema.brand<Schema.BigInt, "MinorCurrencyUnits">;
}>;
minimumQuantity: Schema.brand<Schema.Int, "SeatCapacityQuantity">;
maximumQuantity: Schema.brand<Schema.Int, "SeatCapacityQuantity">;
type: Schema.tag<"per_seat_one_time">;
}>;
per_seat_subscription: Schema.Struct<{
family: Schema.brand<Schema.String, "SubscriptionFamilyKey">;
price: Schema.Struct<{
currency: Schema.brand<Schema.String, "Currency">;
amount: Schema.brand<Schema.BigInt, "MinorCurrencyUnits">;
}>;
minimumQuantity: Schema.brand<Schema.Int, "SeatCapacityQuantity">;
maximumQuantity: Schema.brand<Schema.Int, "SeatCapacityQuantity">;
interval: Schema.Literals<readonly ["month", "year"]>;
renewal: Schema.Literal<"manual">;
type: Schema.tag<"per_seat_subscription">;
}>;
subscription: Schema.Struct<{
family: Schema.brand<Schema.String, "SubscriptionFamilyKey">;
price: Schema.Struct<{
currency: Schema.brand<Schema.String, "Currency">;
amount: Schema.brand<Schema.BigInt, "MinorCurrencyUnits">;
}>;
interval: Schema.Literals<readonly ["month", "year"]>;
renewal: Schema.Literal<"manual">;
type: Schema.tag<"subscription">;
}>;
readonly isAnyOf: <Keys>(keys) => (value) => value is Extract<{ family: string & any; interval: "month" | "year"; meter: { key: string & any; revision: number & any }; rate: { currency: string & any; amount: bigint & any; perUnits: bigint & any; rounding: "trunc" }; collection: "invoice"; roundingScope: "meter_invoice_period"; lateUsage: "next_invoice_original_rate"; accessPolicy: { key: string & any; revision: number & any }; type: "metered_subscription" }, { type: Keys }> | Extract<{ price: { currency: string & any; amount: bigint & any }; minimumQuantity: number & any; maximumQuantity: number & any; type: "per_seat_one_time" }, { type: Keys }> | Extract<{ family: string & any; price: { currency: string & any; amount: bigint & any }; minimumQuantity: number & any; maximumQuantity: number & any; interval: "month" | "year"; renewal: "manual"; type: "per_seat_subscription" }, { type: Keys }> | Extract<{ price: { currency: string & any; amount: bigint & any }; type: "one_time" }, { type: Keys }> | Extract<{ family: string & any; price: { currency: string & any; amount: bigint & any }; interval: "month" | "year"; renewal: "manual"; type: "subscription" }, { type: Keys }>;

Keys

readonly Keys[]

(value) => value is Extract<{ family: string & any; interval: “month” | “year”; meter: { key: string & any; revision: number & any }; rate: { currency: string & any; amount: bigint & any; perUnits: bigint & any; rounding: “trunc” }; collection: “invoice”; roundingScope: “meter_invoice_period”; lateUsage: “next_invoice_original_rate”; accessPolicy: { key: string & any; revision: number & any }; type: “metered_subscription” }, { type: Keys }> | Extract<{ price: { currency: string & any; amount: bigint & any }; minimumQuantity: number & any; maximumQuantity: number & any; type: “per_seat_one_time” }, { type: Keys }> | Extract<{ family: string & any; price: { currency: string & any; amount: bigint & any }; minimumQuantity: number & any; maximumQuantity: number & any; interval: “month” | “year”; renewal: “manual”; type: “per_seat_subscription” }, { type: Keys }> | Extract<{ price: { currency: string & any; amount: bigint & any }; type: “one_time” }, { type: Keys }> | Extract<{ family: string & any; price: { currency: string & any; amount: bigint & any }; interval: “month” | “year”; renewal: “manual”; type: “subscription” }, { type: Keys }>

readonly guards: {
metered_subscription: (u) => u is { family: string & any; interval: "month" | "year"; meter: { key: string & any; revision: number & any }; rate: { currency: string & any; amount: bigint & any; perUnits: bigint & any; rounding: "trunc" }; collection: "invoice"; roundingScope: "meter_invoice_period"; lateUsage: "next_invoice_original_rate"; accessPolicy: { key: string & any; revision: number & any }; type: "metered_subscription" };
one_time: (u) => u is { price: { currency: string & any; amount: bigint & any }; type: "one_time" };
per_seat_one_time: (u) => u is { price: { currency: string & any; amount: bigint & any }; minimumQuantity: number & any; maximumQuantity: number & any; type: "per_seat_one_time" };
per_seat_subscription: (u) => u is { family: string & any; price: { currency: string & any; amount: bigint & any }; minimumQuantity: number & any; maximumQuantity: number & any; interval: "month" | "year"; renewal: "manual"; type: "per_seat_subscription" };
subscription: (u) => u is { family: string & any; price: { currency: string & any; amount: bigint & any }; interval: "month" | "year"; renewal: "manual"; type: "subscription" };
};
metered_subscription: (u) => u is { family: string & any; interval: "month" | "year"; meter: { key: string & any; revision: number & any }; rate: { currency: string & any; amount: bigint & any; perUnits: bigint & any; rounding: "trunc" }; collection: "invoice"; roundingScope: "meter_invoice_period"; lateUsage: "next_invoice_original_rate"; accessPolicy: { key: string & any; revision: number & any }; type: "metered_subscription" };

unknown

u is { family: string & any; interval: “month” | “year”; meter: { key: string & any; revision: number & any }; rate: { currency: string & any; amount: bigint & any; perUnits: bigint & any; rounding: “trunc” }; collection: “invoice”; roundingScope: “meter_invoice_period”; lateUsage: “next_invoice_original_rate”; accessPolicy: { key: string & any; revision: number & any }; type: “metered_subscription” }

one_time: (u) => u is { price: { currency: string & any; amount: bigint & any }; type: "one_time" };

unknown

u is { price: { currency: string & any; amount: bigint & any }; type: "one_time" }

per_seat_one_time: (u) => u is { price: { currency: string & any; amount: bigint & any }; minimumQuantity: number & any; maximumQuantity: number & any; type: "per_seat_one_time" };

unknown

u is { price: { currency: string & any; amount: bigint & any }; minimumQuantity: number & any; maximumQuantity: number & any; type: "per_seat_one_time" }

per_seat_subscription: (u) => u is { family: string & any; price: { currency: string & any; amount: bigint & any }; minimumQuantity: number & any; maximumQuantity: number & any; interval: "month" | "year"; renewal: "manual"; type: "per_seat_subscription" };

unknown

u is { family: string & any; price: { currency: string & any; amount: bigint & any }; minimumQuantity: number & any; maximumQuantity: number & any; interval: “month” | “year”; renewal: “manual”; type: “per_seat_subscription” }

subscription: (u) => u is { family: string & any; price: { currency: string & any; amount: bigint & any }; interval: "month" | "year"; renewal: "manual"; type: "subscription" };

unknown

u is { family: string & any; price: { currency: string & any; amount: bigint & any }; interval: “month” | “year”; renewal: “manual”; type: “subscription” }

readonly match: {
<Cases> (value, cases): Cases[keyof Cases] extends (value) => R ? any : never;
<Cases> (cases): (value) => Cases[keyof Cases] extends (value) => R ? any : never;
};
<Cases>(value, cases): Cases[keyof Cases] extends (value) => R ? any : never;

Cases extends { [key: string]: (value) => any; }

| { family: string & any; interval: "month" | "year"; meter: { key: string & any; revision: number & any; }; rate: { currency: string & any; amount: bigint & any; perUnits: bigint & any; rounding: "trunc"; }; collection: "invoice"; roundingScope: "meter_invoice_period"; lateUsage: "next_invoice_original_rate"; accessPolicy: { key: string & any; revision: number & any; }; type: "metered_subscription"; } | { price: { currency: string & any; amount: bigint & any; }; minimumQuantity: number & any; maximumQuantity: number & any; type: "per_seat_one_time"; } | { family: string & any; price: { currency: string & any; amount: bigint & any; }; minimumQuantity: number & any; maximumQuantity: number & any; interval: "month" | "year"; renewal: "manual"; type: "per_seat_subscription"; } | { price: { currency: string & any; amount: bigint & any; }; type: "one_time"; } | { family: string & any; price: { currency: string & any; amount: bigint & any; }; interval: "month" | "year"; renewal: "manual"; type: "subscription"; }

Cases

Cases[keyof Cases] extends (value) => R ? any : never

<Cases>(cases): (value) => Cases[keyof Cases] extends (value) => R ? any : never;

Cases extends { [key: string]: (value) => any; }

Cases

(value) => Cases[keyof Cases] extends (value) => R ? any : never

oneTime: (input) => Effect.Effect<typeof BillingSchema.cases.one_time.Type, Schema.SchemaError>;

Parses fixed-total one-time billing without requiring its wire-format tag.

Omit<typeof BillingSchema.cases.one_time.Encoded, "type">

Effect.Effect<typeof BillingSchema.cases.one_time.Type, Schema.SchemaError>

subscription: (input) => Effect.Effect<typeof BillingSchema.cases.subscription.Type, Schema.SchemaError>;

Parses fixed-total manual subscription billing without fixed wire-format fields.

Omit<typeof BillingSchema.cases.subscription.Encoded, "type" | "renewal">

Effect.Effect<typeof BillingSchema.cases.subscription.Type, Schema.SchemaError>

perSeatOneTime: (input) => Effect.Effect<typeof BillingSchema.cases.per_seat_one_time.Type, Schema.SchemaError>;

Parses per-seat one-time billing without requiring its wire-format tag.

Omit<typeof BillingSchema.cases.per_seat_one_time.Encoded, "type">

Effect.Effect<typeof BillingSchema.cases.per_seat_one_time.Type, Schema.SchemaError>

perSeatSubscription: (input) => Effect.Effect<typeof BillingSchema.cases.per_seat_subscription.Type, Schema.SchemaError>;

Parses per-seat manual subscription billing without fixed wire-format fields.

Omit<typeof BillingSchema.cases.per_seat_subscription.Encoded, "type" | "renewal">

Effect.Effect<typeof BillingSchema.cases.per_seat_subscription.Type, Schema.SchemaError>

meteredSubscription: (input) => Effect.Effect<typeof BillingSchema.cases.metered_subscription.Type, Schema.SchemaError>;

Parses postpaid metered subscription billing with fixed invoice policies.

Omit<typeof BillingSchema.cases.metered_subscription.Encoded, "type" | "collection" | "roundingScope" | "lateUsage">

Effect.Effect<typeof BillingSchema.cases.metered_subscription.Type, Schema.SchemaError>