@boelabs/billete-sdk 1.1.0-canary.5 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -42,6 +42,10 @@ servidor y tu frontend.
42
42
  npm install @boelabs/billete-sdk
43
43
  ```
44
44
 
45
+ Cada versión del SDK habla una sola versión de la API, la que pide su opción `apiVersion`: una
46
+ versión mayor nueva del SDK es una versión nueva de la API. Las versiones beta de la API tienen su
47
+ SDK en `@boelabs/billete-sdk@beta`.
48
+
45
49
  El paquete tiene tres puntos de entrada:
46
50
 
47
51
  | Import | Dónde se usa | Para qué |
@@ -58,7 +62,7 @@ Crea una clave secreta en el dashboard (**Desarrolladores → Claves API**) y gu
58
62
  ```ts
59
63
  import { createBillete } from "@boelabs/billete-sdk";
60
64
 
61
- const billete = createBillete({ environment: "test" });
65
+ const billete = createBillete({ apiVersion: "2026-10-08", environment: "test" });
62
66
 
63
67
  const checkout = await billete.checkouts.create({
64
68
  plan: "plan_…",
@@ -86,6 +90,7 @@ solicite expresamente. En carritos, solo ofrece los demás métodos que todos lo
86
90
 
87
91
  ```ts
88
92
  const billete = createBillete({
93
+ apiVersion: "2026-10-08",
89
94
  environment: "production",
90
95
  apiKey: process.env.BILLETE_API_KEY,
91
96
  timeoutMs: 30_000,
@@ -251,7 +256,7 @@ return { token: session.token };
251
256
  // Navegador
252
257
  import { createClient } from "@boelabs/billete-sdk/client";
253
258
 
254
- const billete = createClient({ customerSession: token });
259
+ const billete = createClient({ apiVersion: "2026-10-08", customerSession: token });
255
260
 
256
261
  const { data: subscriptions } = await billete.customer.subscriptions();
257
262
  const tokens = await billete.customer.feature("tokens");
package/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { $ as PaymentSettlement, $t as Timestamp, A as FULFILLMENT_METHODS, At as ApiErrorEnvelope, B as FulfillmentTracking, Bt as CURRENCIES, C as Customer, Ct as Weekday, D as Event, Dt as ReceiptSnapshot, E as CustomerSession, Et as ReceiptSend, F as FeatureUsageResult, Ft as Address, G as InvoiceStatus, Gt as ListQuery, H as INVOICE_STATUSES, Ht as GRACE_PERIOD_DAYS, I as Fulfillment, It as AddressInput, J as PRODUCT_CATEGORIES, Jt as MOBILE_PREFIXES, K as LineItem, Kt as ListSort, L as FulfillmentChoice, Lt as BILLING_MONTHS, M as Feature, Mt as PAYMENT_FAILURE_CODES, N as FeatureReset, Nt as PaymentFailureCode, O as ExchangeRate, Ot as API_ERROR_TYPES, P as FeatureType, Pt as ACCOUNT_NUMBER_LENGTH, Q as PaymentLink, Qt as TaxBehavior, R as FulfillmentMethod, Rt as BankCode, S as CustomField, St as WebhookEndpoint, T as CustomerFeature, Tt as ReceiptReference, U as Invoice, Ut as GracePeriodDays, V as INVOICE_REASONS, Vt as Currency, W as InvoiceReason, Wt as List, X as PaymentAttempt, Xt as MobilePrefix, Y as Payment, Yt as Metadata, Z as PaymentFailure, Zt as TAX_BEHAVIORS, _ as CheckoutItem, _t as SubmitLabel, a as Actor, an as ENVIRONMENTS, at as PortalSession, b as Coupon, bt as SubscriptionStatus, c as BalanceAmount, cn as tokenEnvironment, ct as ProductVariant, d as CARRIER_TEST_SCENARIOS, dt as Refund, en as VENEZUELAN_BANKS, et as PaymentStatus, f as CHECKOUT_PURPOSES, ft as ResetFrequency, g as Checkout, gt as SUBSCRIPTION_STATUSES, h as CarrierOffice, ht as SUBMIT_LABELS, i as WebhookEvent, in as nationalPhone, it as PlanPrice, j as FULFILLMENT_STATUSES, jt as ApiErrorType, k as FEATURE_TYPES, kt as ApiErrorBody, l as CANCELLATION_FEEDBACK, ln as tokenPrefix, lt as RESET_FREQUENCIES, m as Carrier, mt as RiskLevel, n as EventDataMap, nn as isLandlinePhone, nt as Plan, o as AfterCompletion, on as Environment, ot as Product, p as CancellationFeedback, pt as Retirement, q as PAYMENT_STATUSES, qt as MAX_QUANTITY, r as EventType, rn as isMobilePhone, rt as PlanFeatureValues, s as Balance, sn as TokenKind, st as ProductCategory, t as EVENT_TYPES, tn as findBank, tt as Payout, u as CARRIERS, ut as RISK_LEVELS, v as CheckoutPurpose, vt as Subscription, w as CustomerDetails, wt as PublicReceipt, x as CurrencyAvailability, xt as USAGE_FEATURE_TYPES, y as CollectSettings, yt as SubscriptionRenewal, z as FulfillmentStatus, zt as BillingMonths } from "./events-kvUK9zvS.js";
2
- import { $ as FulfillmentOption, A as KEY_PATTERN, B as ProductCheckoutCreate, C as EventSelector, D as FulfillmentTrackingInput, E as FulfillmentInput, F as PlanFeaturesInput, G as RetireInput, H as ProductLinkCreate, I as PlanLinkCreate, J as SubscriptionUpdate, K as SubscriptionCancel, L as PlanPriceInput, M as PaymentLinkUpdate, N as PlanCheckoutCreate, O as InvoiceCreate, P as PlanCreate, Q as CustomerSubscription, R as PlanUpdate, S as CustomerUpdate, T as FeatureUpdate, U as ProductUpdate, V as ProductCreate, W as RefundCreate, X as WebhookEndpointCreate, Y as VariantInput, Z as WebhookEndpointUpdate, _ as CouponUpdate, a as CheckoutCreate, at as PortalFeatures, b as CustomerInput, c as ClientCheckoutUpdate, ct as PublicInvoice, d as ClientLinkCheckout, dt as PublicPortal, et as PaymentInstructions, f as ClientPaymentCode, g as CouponCreate, h as CollectInput, i as AfterCompletionInput, it as PaymentTestScenario, j as PaymentLinkCreate, k as InvoiceLineInput, l as ClientFulfillmentProblem, lt as PublicPaymentLink, m as ClientSubscriptionUpdate, n as RequestOptions, nt as PaymentMethodOption, o as CheckoutItemInput, ot as PublicCheckout, p as ClientSubscriptionCancel, q as SubscriptionCreate, r as TransportOptions, rt as PaymentNextAction, s as ClientCheckoutPay, st as PublicFulfillment, t as BilleteError, tt as PaymentMethodField, u as ClientInvoicePay, ut as PublicPaymentState, v as CustomFieldInput, w as FeatureCreate, x as CustomerSessionCreate, y as CustomerCreate, z as PortalSessionCreate } from "./errors-DY-3gWvA.js";
1
+ import { $ as SubscriptionCreate, A as FulfillmentInput, At as isApiVersionRetired, B as PlanLinkCreate, C as CustomerSessionCreate, Ct as ApiVersionStage, D as FeatureOperationCommit, Dt as apiVersionStage, E as FeatureCreate, Et as apiVersionLifecycle, F as PaymentLinkCreate, G as ProductCreate, H as PlanUpdate, I as PaymentLinkUpdate, J as RefundCreate, K as ProductLinkCreate, L as PlanCheckoutCreate, M as InvoiceCreate, N as InvoiceLineInput, O as FeatureOperationCreate, Ot as currentApiVersion, P as KEY_PATTERN, Q as SubscriptionChangePreviewInput, R as PlanCreate, S as CustomerMemberUpdate, St as ApiVersionLifecycle, T as EventSelector, Tt as LatestApiVersion, U as PortalSessionCreate, V as PlanPriceInput, W as ProductCheckoutCreate, X as SubscriptionCancel, Y as RetireInput, Z as SubscriptionChangeCreate, _ as CouponUpdate, _t as PublicPortal, a as CheckoutCreate, at as FulfillmentOption, b as CustomerInput, bt as API_VERSION_PATTERN, c as ClientCheckoutUpdate, ct as PaymentMethodOption, d as ClientLinkCheckout, dt as PortalFeatures, et as SubscriptionUpdate, f as ClientPaymentCode, ft as PublicCheckout, g as CouponCreate, gt as PublicPaymentState, h as CollectInput, ht as PublicPaymentLink, i as AfterCompletionInput, it as CustomerSubscription, j as FulfillmentTrackingInput, jt as supportedApiVersions, k as FeatureUpdate, kt as isApiVersion, l as ClientFulfillmentProblem, lt as PaymentNextAction, m as ClientSubscriptionUpdate, mt as PublicInvoice, n as RequestOptions, nt as WebhookEndpointCreate, o as CheckoutItemInput, ot as PaymentInstructions, p as ClientSubscriptionCancel, pt as PublicFulfillment, q as ProductUpdate, r as TransportOptions, rt as WebhookEndpointUpdate, s as ClientCheckoutPay, st as PaymentMethodField, t as BilleteError, tt as VariantInput, u as ClientInvoicePay, ut as PaymentTestScenario, v as CustomFieldInput, vt as API_VERSIONS, w as CustomerUpdate, wt as LATEST_API_VERSION, x as CustomerMemberCreate, xt as ApiVersion, y as CustomerCreate, yt as API_VERSION_HEADER, z as PlanFeaturesInput } from "./errors-Cu8XMn5I.js";
2
+ import { $ as PRODUCT_CATEGORIES, $t as ListQuery, A as ExchangeRate, At as SubscriptionTerms, B as Fulfillment, Bt as PAYMENT_FAILURE_CODES, C as Customer, Ct as SubmitLabel, D as CustomerMemberList, Dt as SubscriptionChangeResult, E as CustomerMember, Et as SubscriptionChangePreview, F as FeatureOperation, Ft as ReceiptSend, G as INVOICE_REASONS, Gt as BILLING_MONTHS, H as FulfillmentMethod, Ht as ACCOUNT_NUMBER_LENGTH, I as FeatureOperationResult, It as API_ERROR_TYPES, J as InvoiceReason, Jt as CURRENCIES, K as INVOICE_STATUSES, Kt as BankCode, L as FeatureReset, Lt as ApiErrorBody, M as FULFILLMENT_METHODS, Mt as WebhookEndpoint, N as FULFILLMENT_STATUSES, Nt as Weekday, O as CustomerSession, Ot as SubscriptionRenewal, P as Feature, Pt as ReceiptReference, Q as PAYMENT_STATUSES, Qt as List, R as FeatureType, Rt as ApiErrorEnvelope, S as CustomField, St as SUBSCRIPTION_STATUSES, T as CustomerFeature, Tt as SubscriptionChange, U as FulfillmentStatus, Ut as Address, V as FulfillmentChoice, Vt as PaymentFailureCode, W as FulfillmentTracking, Wt as AddressInput, X as LineItem, Xt as GRACE_PERIOD_DAYS, Y as InvoiceStatus, Yt as Currency, Z as MAX_SEATS, Zt as GracePeriodDays, _ as CheckoutItem, _n as tokenPrefix, _t as Refund, a as Actor, an as TAX_BEHAVIORS, at as PaymentStatus, b as Coupon, bt as RiskLevel, c as BalanceAmount, cn as VENEZUELAN_BANKS, ct as PlanFeatureValues, d as CARRIER_TEST_SCENARIOS, dn as isMobilePhone, dt as PortalSession, en as ListSort, et as Payment, f as CHECKOUT_PURPOSES, fn as nationalPhone, ft as Product, g as Checkout, gn as tokenEnvironment, gt as RISK_LEVELS, h as CarrierOffice, hn as TokenKind, ht as RESET_FREQUENCIES, i as WebhookEvent, in as MobilePrefix, it as PaymentSettlement, j as FEATURE_TYPES, jt as USAGE_FEATURE_TYPES, k as Event, kt as SubscriptionStatus, l as CANCELLATION_FEEDBACK, ln as findBank, lt as PlanPrice, m as Carrier, mn as Environment, mt as ProductVariant, n as EventDataMap, nn as MOBILE_PREFIXES, nt as PaymentFailure, o as AfterCompletion, on as TaxBehavior, ot as Payout, p as CancellationFeedback, pn as ENVIRONMENTS, pt as ProductCategory, q as Invoice, qt as BillingMonths, r as EventType, rn as Metadata, rt as PaymentLink, s as Balance, sn as Timestamp, st as Plan, t as EVENT_TYPES, tn as MAX_QUANTITY, tt as PaymentAttempt, u as CARRIERS, un as isLandlinePhone, ut as PlanSeats, v as CheckoutPurpose, vt as ResetFrequency, w as CustomerDetails, wt as Subscription, x as CurrencyAvailability, xt as SUBMIT_LABELS, y as CollectSettings, yt as Retirement, z as FeatureUsageResult, zt as ApiErrorType } from "./events-CrmMdwBX.js";
3
3
  //#region src/create-client.d.ts
4
4
  interface ClientOptions extends TransportOptions {
5
5
  /**
@@ -14,12 +14,12 @@ interface ClientOptions extends TransportOptions {
14
14
  * and customer data requires a short-lived customer session minted by your server.
15
15
  *
16
16
  * ```ts
17
- * const billete = createClient({ customerSession: token });
17
+ * const billete = createClient({ apiVersion: "2026-10-08", customerSession: token });
18
18
  * const [subscription] = (await billete.customer.subscriptions()).data;
19
19
  * if (subscription?.renewal?.status === "overdue") showBanner(subscription.renewal);
20
20
  * ```
21
21
  */
22
- export declare function createClient(options?: ClientOptions): {
22
+ export declare function createClient(options: ClientOptions): {
23
23
  /** Offices offered by a carrier, refreshed daily by Billete. */
24
24
  carrierOffices: (carrier: Carrier, options?: RequestOptions) => Promise<List<CarrierOffice>>;
25
25
  checkouts: {
@@ -102,4 +102,4 @@ export declare function createClient(options?: ClientOptions): {
102
102
  };
103
103
  type BilleteClient = ReturnType<typeof createClient>;
104
104
  //#endregion
105
- export { type ACCOUNT_NUMBER_LENGTH, type API_ERROR_TYPES, type Actor, type Address, type AddressInput, type AfterCompletion, type AfterCompletionInput, type ApiErrorBody, type ApiErrorEnvelope, type ApiErrorType, type BILLING_MONTHS, type Balance, type BalanceAmount, type BankCode, type BilleteClient, BilleteError, type BillingMonths, type CANCELLATION_FEEDBACK, type CARRIERS, type CARRIER_TEST_SCENARIOS, type CHECKOUT_PURPOSES, type CURRENCIES, type CancellationFeedback, type Carrier, type CarrierOffice, type Checkout, type CheckoutCreate, type CheckoutItem, type CheckoutItemInput, type CheckoutPurpose, type ClientCheckoutPay, type ClientCheckoutUpdate, type ClientFulfillmentProblem, type ClientInvoicePay, type ClientLinkCheckout, type ClientOptions, type ClientPaymentCode, type ClientSubscriptionCancel, type ClientSubscriptionUpdate, type CollectInput, type CollectSettings, type Coupon, type CouponCreate, type CouponUpdate, type Currency, type CurrencyAvailability, type CustomField, type CustomFieldInput, type Customer, type CustomerCreate, type CustomerDetails, type CustomerFeature, type CustomerInput, type CustomerSession, type CustomerSessionCreate, type CustomerSubscription, type CustomerUpdate, type ENVIRONMENTS, type EVENT_TYPES, type Environment, type Event, type EventDataMap, type EventSelector, type EventType, type ExchangeRate, type FEATURE_TYPES, type FULFILLMENT_METHODS, type FULFILLMENT_STATUSES, type Feature, type FeatureCreate, type FeatureReset, type FeatureType, type FeatureUpdate, type FeatureUsageResult, type Fulfillment, type FulfillmentChoice, type FulfillmentInput, type FulfillmentMethod, type FulfillmentOption, type FulfillmentStatus, type FulfillmentTracking, type FulfillmentTrackingInput, type GRACE_PERIOD_DAYS, type GracePeriodDays, type INVOICE_REASONS, type INVOICE_STATUSES, type Invoice, type InvoiceCreate, type InvoiceLineInput, type InvoiceReason, type InvoiceStatus, type KEY_PATTERN, type LineItem, type List, type ListQuery, type ListSort, type MAX_QUANTITY, type MOBILE_PREFIXES, type Metadata, type MobilePrefix, type PAYMENT_FAILURE_CODES, type PAYMENT_STATUSES, type PRODUCT_CATEGORIES, type Payment, type PaymentAttempt, type PaymentFailure, type PaymentFailureCode, type PaymentInstructions, type PaymentLink, type PaymentLinkCreate, type PaymentLinkUpdate, type PaymentMethodField, type PaymentMethodOption, type PaymentNextAction, type PaymentSettlement, type PaymentStatus, type PaymentTestScenario, type Payout, type Plan, type PlanCheckoutCreate, type PlanCreate, type PlanFeatureValues, type PlanFeaturesInput, type PlanLinkCreate, type PlanPrice, type PlanPriceInput, type PlanUpdate, type PortalFeatures, type PortalSession, type PortalSessionCreate, type Product, type ProductCategory, type ProductCheckoutCreate, type ProductCreate, type ProductLinkCreate, type ProductUpdate, type ProductVariant, type PublicCheckout, type PublicFulfillment, type PublicInvoice, type PublicPaymentLink, type PublicPaymentState, type PublicPortal, type PublicReceipt, type RESET_FREQUENCIES, type RISK_LEVELS, type ReceiptReference, type ReceiptSend, type ReceiptSnapshot, type Refund, type RefundCreate, type RequestOptions, type ResetFrequency, type RetireInput, type Retirement, type RiskLevel, type SUBMIT_LABELS, type SUBSCRIPTION_STATUSES, type SubmitLabel, type Subscription, type SubscriptionCancel, type SubscriptionCreate, type SubscriptionRenewal, type SubscriptionStatus, type SubscriptionUpdate, type TAX_BEHAVIORS, type TaxBehavior, type Timestamp, type TokenKind, type USAGE_FEATURE_TYPES, type VENEZUELAN_BANKS, type VariantInput, type WebhookEndpoint, type WebhookEndpointCreate, type WebhookEndpointUpdate, type WebhookEvent, type Weekday, type findBank, type isLandlinePhone, type isMobilePhone, type nationalPhone, type tokenEnvironment, type tokenPrefix };
105
+ export { type ACCOUNT_NUMBER_LENGTH, type API_ERROR_TYPES, type API_VERSIONS, type API_VERSION_HEADER, type API_VERSION_PATTERN, type Actor, type Address, type AddressInput, type AfterCompletion, type AfterCompletionInput, type ApiErrorBody, type ApiErrorEnvelope, type ApiErrorType, type ApiVersion, type ApiVersionLifecycle, type ApiVersionStage, type BILLING_MONTHS, type Balance, type BalanceAmount, type BankCode, type BilleteClient, BilleteError, type BillingMonths, type CANCELLATION_FEEDBACK, type CARRIERS, type CARRIER_TEST_SCENARIOS, type CHECKOUT_PURPOSES, type CURRENCIES, type CancellationFeedback, type Carrier, type CarrierOffice, type Checkout, type CheckoutCreate, type CheckoutItem, type CheckoutItemInput, type CheckoutPurpose, type ClientCheckoutPay, type ClientCheckoutUpdate, type ClientFulfillmentProblem, type ClientInvoicePay, type ClientLinkCheckout, type ClientOptions, type ClientPaymentCode, type ClientSubscriptionCancel, type ClientSubscriptionUpdate, type CollectInput, type CollectSettings, type Coupon, type CouponCreate, type CouponUpdate, type Currency, type CurrencyAvailability, type CustomField, type CustomFieldInput, type Customer, type CustomerCreate, type CustomerDetails, type CustomerFeature, type CustomerInput, type CustomerMember, type CustomerMemberCreate, type CustomerMemberList, type CustomerMemberUpdate, type CustomerSession, type CustomerSessionCreate, type CustomerSubscription, type CustomerUpdate, type ENVIRONMENTS, type EVENT_TYPES, type Environment, type Event, type EventDataMap, type EventSelector, type EventType, type ExchangeRate, type FEATURE_TYPES, type FULFILLMENT_METHODS, type FULFILLMENT_STATUSES, type Feature, type FeatureCreate, type FeatureOperation, type FeatureOperationCommit, type FeatureOperationCreate, type FeatureOperationResult, type FeatureReset, type FeatureType, type FeatureUpdate, type FeatureUsageResult, type Fulfillment, type FulfillmentChoice, type FulfillmentInput, type FulfillmentMethod, type FulfillmentOption, type FulfillmentStatus, type FulfillmentTracking, type FulfillmentTrackingInput, type GRACE_PERIOD_DAYS, type GracePeriodDays, type INVOICE_REASONS, type INVOICE_STATUSES, type Invoice, type InvoiceCreate, type InvoiceLineInput, type InvoiceReason, type InvoiceStatus, type KEY_PATTERN, type LATEST_API_VERSION, type LatestApiVersion, type LineItem, type List, type ListQuery, type ListSort, type MAX_QUANTITY, type MAX_SEATS, type MOBILE_PREFIXES, type Metadata, type MobilePrefix, type PAYMENT_FAILURE_CODES, type PAYMENT_STATUSES, type PRODUCT_CATEGORIES, type Payment, type PaymentAttempt, type PaymentFailure, type PaymentFailureCode, type PaymentInstructions, type PaymentLink, type PaymentLinkCreate, type PaymentLinkUpdate, type PaymentMethodField, type PaymentMethodOption, type PaymentNextAction, type PaymentSettlement, type PaymentStatus, type PaymentTestScenario, type Payout, type Plan, type PlanCheckoutCreate, type PlanCreate, type PlanFeatureValues, type PlanFeaturesInput, type PlanLinkCreate, type PlanPrice, type PlanPriceInput, type PlanSeats, type PlanUpdate, type PortalFeatures, type PortalSession, type PortalSessionCreate, type Product, type ProductCategory, type ProductCheckoutCreate, type ProductCreate, type ProductLinkCreate, type ProductUpdate, type ProductVariant, type PublicCheckout, type PublicFulfillment, type PublicInvoice, type PublicPaymentLink, type PublicPaymentState, type PublicPortal, type RESET_FREQUENCIES, type RISK_LEVELS, type ReceiptReference, type ReceiptSend, type Refund, type RefundCreate, type RequestOptions, type ResetFrequency, type RetireInput, type Retirement, type RiskLevel, type SUBMIT_LABELS, type SUBSCRIPTION_STATUSES, type SubmitLabel, type Subscription, type SubscriptionCancel, type SubscriptionChange, type SubscriptionChangeCreate, type SubscriptionChangePreview, type SubscriptionChangePreviewInput, type SubscriptionChangeResult, type SubscriptionCreate, type SubscriptionRenewal, type SubscriptionStatus, type SubscriptionTerms, type SubscriptionUpdate, type TAX_BEHAVIORS, type TaxBehavior, type Timestamp, type TokenKind, type USAGE_FEATURE_TYPES, type VENEZUELAN_BANKS, type VariantInput, type WebhookEndpoint, type WebhookEndpointCreate, type WebhookEndpointUpdate, type WebhookEvent, type Weekday, type apiVersionLifecycle, type apiVersionStage, type currentApiVersion, type findBank, type isApiVersion, type isApiVersionRetired, type isLandlinePhone, type isMobilePhone, type nationalPhone, type supportedApiVersions, type tokenEnvironment, type tokenPrefix };
package/dist/client.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as segment, r as BilleteError, t as createTransport } from "./http-Dp-Du1QO.js";
1
+ import { n as segment, r as BilleteError, t as createTransport } from "./http-CgBMbPS2.js";
2
2
  //#region src/create-client.ts
3
3
  /**
4
4
  * Browser client. It never holds a secret key: checkouts and Cobros are addressed by their
@@ -6,12 +6,12 @@ import { n as segment, r as BilleteError, t as createTransport } from "./http-Dp
6
6
  * and customer data requires a short-lived customer session minted by your server.
7
7
  *
8
8
  * ```ts
9
- * const billete = createClient({ customerSession: token });
9
+ * const billete = createClient({ apiVersion: "2026-10-08", customerSession: token });
10
10
  * const [subscription] = (await billete.customer.subscriptions()).data;
11
11
  * if (subscription?.renewal?.status === "overdue") showBanner(subscription.renewal);
12
12
  * ```
13
13
  */
14
- function createClient(options = {}) {
14
+ function createClient(options) {
15
15
  const session = options.customerSession;
16
16
  const http = createTransport({
17
17
  ...options,
@@ -1,4 +1,48 @@
1
- import { $t as Timestamp, B as FulfillmentTracking, Ft as Address, G as InvoiceStatus, I as Fulfillment, It as AddressInput, K as LineItem, N as FeatureReset, Qt as TaxBehavior, R as FulfillmentMethod, S as CustomField, Tt as ReceiptReference, Ut as GracePeriodDays, Vt as Currency, W as InvoiceReason, Yt as Metadata, Z as PaymentFailure, _ as CheckoutItem, _t as SubmitLabel, et as PaymentStatus, h as CarrierOffice, it as PlanPrice, jt as ApiErrorType, kt as ApiErrorBody, m as Carrier, o as AfterCompletion, on as Environment, p as CancellationFeedback, r as EventType, st as ProductCategory, v as CheckoutPurpose, vt as Subscription, w as CustomerDetails, y as CollectSettings, z as FulfillmentStatus, zt as BillingMonths } from "./events-kvUK9zvS.js";
1
+ import { B as Fulfillment, Ct as SubmitLabel, H as FulfillmentMethod, J as InvoiceReason, L as FeatureReset, Lt as ApiErrorBody, Pt as ReceiptReference, S as CustomField, U as FulfillmentStatus, Ut as Address, W as FulfillmentTracking, Wt as AddressInput, X as LineItem, Y as InvoiceStatus, Yt as Currency, Zt as GracePeriodDays, _ as CheckoutItem, at as PaymentStatus, h as CarrierOffice, lt as PlanPrice, m as Carrier, mn as Environment, nt as PaymentFailure, o as AfterCompletion, on as TaxBehavior, p as CancellationFeedback, pt as ProductCategory, qt as BillingMonths, r as EventType, rn as Metadata, sn as Timestamp, ut as PlanSeats, v as CheckoutPurpose, w as CustomerDetails, wt as Subscription, y as CollectSettings, zt as ApiErrorType } from "./events-CrmMdwBX.js";
2
+ //#region ../contracts/src/api-versions.d.ts
3
+ /**
4
+ * Billete API versions. Kept free of runtime dependencies: the dashboard, the API, the worker and
5
+ * the docs read it, and the public SDK pins its newest entry as a type.
6
+ *
7
+ * A version is named after the day it was published: `2026-11-01` is stable and
8
+ * `2026-11-01.beta` is a beta. Once published a version never changes; anything incompatible
9
+ * ships as a new version. Additive changes (new endpoints, optional fields) reach every version
10
+ * that is still supported.
11
+ */
12
+ /** Every version ever published, oldest first. Append only: retired versions stay listed. */
13
+ declare const API_VERSIONS: readonly ["2026-10-07.beta", "2026-10-08"];
14
+ type ApiVersion = (typeof API_VERSIONS)[number];
15
+ type LatestApiVersion = typeof API_VERSIONS extends readonly [...unknown[], infer Last] ? Last : never;
16
+ /** The version the code speaks: responses are built in its shape. Always the last entry. */
17
+ declare const LATEST_API_VERSION: LatestApiVersion;
18
+ /** The request header that names the version a request is written against. */
19
+ declare const API_VERSION_HEADER = "Billete-Version";
20
+ declare const API_VERSION_PATTERN: RegExp;
21
+ type ApiVersionStage = "stable" | "beta";
22
+ interface ApiVersionLifecycle {
23
+ stage: ApiVersionStage;
24
+ /** Day it was published (UTC), `YYYY-MM-DD`. */
25
+ releasedOn: string;
26
+ /** Day merchants start hearing about its retirement, once a successor exists. */
27
+ noticeOn: string | null;
28
+ /** First day requests with it are rejected, once a successor exists. */
29
+ retiresOn: string | null;
30
+ }
31
+ declare function isApiVersion(value: string): value is ApiVersion;
32
+ declare function apiVersionStage(version: string): ApiVersionStage;
33
+ /**
34
+ * When a version was published, when its retirement is announced and when it stops working. Both
35
+ * dates follow from the registry alone (a successor stable version starts the clock), so retiring a
36
+ * version needs no manual step.
37
+ */
38
+ declare function apiVersionLifecycle(version: string, registry?: readonly string[]): ApiVersionLifecycle;
39
+ declare function isApiVersionRetired(version: string, now: Date, registry?: readonly string[]): boolean;
40
+ /** Versions that still work on `now`, oldest first. */
41
+ declare function supportedApiVersions(now: Date): ApiVersion[];
42
+ declare function supportedApiVersions<T extends string>(now: Date, registry: readonly T[]): T[];
43
+ /** What new integrations should use: the newest stable version, or the newest beta before any. */
44
+ declare function currentApiVersion(): ApiVersion;
45
+ //#endregion
2
46
  //#region ../contracts/src/client.d.ts
3
47
  /**
4
48
  * A subscription as its customer sees it, in the browser: without the business's `metadata`, with
@@ -47,6 +91,12 @@ interface PublicPortal {
47
91
  }
48
92
  /** Where a payment stands, as a payment page shows it. */
49
93
  interface PublicPaymentState {
94
+ /** Settled amount in the currency actually paid; no payer or bank details. */
95
+ paid: {
96
+ amount: number;
97
+ currency: Currency;
98
+ paidAt: Timestamp;
99
+ } | null;
50
100
  receipt: (ReceiptReference & {
51
101
  sentTo: string | null;
52
102
  }) | null;
@@ -91,6 +141,17 @@ interface PublicInvoice {
91
141
  }
92
142
  /** Browser-safe view of a checkout: everything needed to render and pay it, nothing internal. */
93
143
  interface PublicCheckout {
144
+ subscriptionChange: {
145
+ fromPlanName: string;
146
+ toPlanName: string;
147
+ quantity: number;
148
+ kind: "restart" | "add_seats";
149
+ creditApplied: number;
150
+ unusedCredit: number;
151
+ currentPeriodEnd: Timestamp;
152
+ activatedAt: Timestamp | null;
153
+ outcome: "pending" | "applied" | "rejected";
154
+ } | null;
94
155
  id: string;
95
156
  object: "checkout";
96
157
  environment: Environment;
@@ -363,6 +424,26 @@ interface CustomerUpdate {
363
424
  address?: AddressInput | null;
364
425
  metadata?: Metadata;
365
426
  }
427
+ interface CustomerMemberCreate {
428
+ externalId: string;
429
+ name?: string;
430
+ metadata?: Metadata;
431
+ }
432
+ interface CustomerMemberUpdate {
433
+ name?: string | null;
434
+ metadata?: Metadata;
435
+ }
436
+ interface FeatureOperationCreate {
437
+ /** Your own ID for the work (e.g. the job ID): repeating it never consumes twice. */
438
+ operation: string;
439
+ amount: number;
440
+ member?: string;
441
+ expiresInSeconds?: number;
442
+ metadata?: Metadata;
443
+ }
444
+ interface FeatureOperationCommit {
445
+ amount?: number;
446
+ }
366
447
  /** An existing customer (`cus_…` or your `externalId`), or one to create or update on the fly. */
367
448
  type CustomerInput = string | CustomerCreate;
368
449
  interface RetireInput {
@@ -418,22 +499,26 @@ type FeatureCreate = {
418
499
  key: string;
419
500
  name: string;
420
501
  type: "boolean";
502
+ per?: "customer" | "member";
421
503
  } | {
422
504
  key: string;
423
505
  name: string;
424
506
  type: "metered";
425
507
  unit?: string;
426
508
  reset: FeatureReset;
509
+ per?: "customer" | "member";
427
510
  } | {
428
511
  key: string;
429
512
  name: string;
430
513
  type: "count";
431
514
  unit?: string;
515
+ per?: "customer" | "member";
432
516
  } | {
433
517
  key: string;
434
518
  name: string;
435
519
  type: "number";
436
520
  unit?: string;
521
+ per?: "customer" | "member";
437
522
  };
438
523
  /**
439
524
  * The key and type are fixed once created (code and usage depend on them). Changing `reset`
@@ -451,6 +536,8 @@ interface PlanPriceInput {
451
536
  amount: number;
452
537
  }
453
538
  interface PlanCreate {
539
+ seats?: PlanSeats;
540
+ fallbackPlanId?: string | null;
454
541
  name: string;
455
542
  description?: string;
456
543
  currency: Currency;
@@ -463,6 +550,8 @@ interface PlanCreate {
463
550
  metadata?: Metadata;
464
551
  }
465
552
  interface PlanUpdate {
553
+ seats?: PlanSeats;
554
+ fallbackPlanId?: string | null;
466
555
  name?: string;
467
556
  description?: string | null;
468
557
  /** New prices apply to new subscriptions; existing ones keep the price they signed up with. */
@@ -477,17 +566,27 @@ interface PlanUpdate {
477
566
  metadata?: Metadata;
478
567
  }
479
568
  interface SubscriptionCreate {
569
+ quantity?: number;
480
570
  customer: CustomerInput;
481
571
  plan: string;
482
572
  months: BillingMonths;
483
- /** Defaults to the plan trial. A subscription created through the API always starts in trial. */
573
+ /** Paid plans require a trial; free plans start active and do not accept trialDays. */
484
574
  trialDays?: number;
485
575
  metadata?: Metadata;
486
576
  }
487
577
  interface SubscriptionUpdate {
578
+ metadata?: Metadata;
579
+ }
580
+ interface SubscriptionChangePreviewInput {
488
581
  plan?: string;
489
582
  months?: BillingMonths;
490
- metadata?: Metadata;
583
+ quantity?: number;
584
+ }
585
+ interface SubscriptionChangeCreate extends SubscriptionChangePreviewInput {
586
+ when: "now" | "renewal";
587
+ acceptUnusedCredit?: boolean;
588
+ successUrl?: string;
589
+ cancelUrl?: string;
491
590
  }
492
591
  interface SubscriptionCancel {
493
592
  /** `false` ends the subscription immediately. */
@@ -595,6 +694,7 @@ interface ProductCheckoutCreate extends CheckoutFields {
595
694
  items: CheckoutItemInput[];
596
695
  }
597
696
  interface PlanCheckoutCreate extends CheckoutFields {
697
+ quantity?: number;
598
698
  plan: string;
599
699
  months: BillingMonths;
600
700
  }
@@ -649,11 +749,15 @@ type EventSelector = "*" | EventType;
649
749
  interface WebhookEndpointCreate {
650
750
  url: string;
651
751
  events: EventSelector[];
752
+ /** Version its events are delivered in. Defaults to the version of the request. */
753
+ apiVersion?: ApiVersion;
652
754
  }
653
755
  interface WebhookEndpointUpdate {
654
756
  url?: string;
655
757
  events?: EventSelector[];
656
758
  enabled?: boolean;
759
+ /** Moves the endpoint to another supported version; its next deliveries use it. */
760
+ apiVersion?: ApiVersion;
657
761
  }
658
762
  interface CustomerSessionCreate {
659
763
  customer: string;
@@ -720,6 +824,13 @@ interface ClientFulfillmentProblem {
720
824
  //#endregion
721
825
  //#region src/http.d.ts
722
826
  interface TransportOptions {
827
+ /**
828
+ * The Billete API version your integration is written against. Required: Billete never changes
829
+ * a published version, so your integration keeps working until you choose to upgrade. Each SDK
830
+ * release speaks exactly one version; upgrading the SDK to a new major asks you to set the new
831
+ * one after reading what changed.
832
+ */
833
+ apiVersion: LatestApiVersion;
723
834
  /** Defaults to `BILLETE_BASE_URL` on the server, then `https://api.billete.run`. Use
724
835
  * `http://localhost:9999` in development. */
725
836
  baseUrl?: string;
@@ -748,4 +859,4 @@ declare class BilleteError extends Error {
748
859
  }, status: number);
749
860
  }
750
861
  //#endregion
751
- export { FulfillmentOption as $, KEY_PATTERN as A, ProductCheckoutCreate as B, EventSelector as C, FulfillmentTrackingInput as D, FulfillmentInput as E, PlanFeaturesInput as F, RetireInput as G, ProductLinkCreate as H, PlanLinkCreate as I, SubscriptionUpdate as J, SubscriptionCancel as K, PlanPriceInput as L, PaymentLinkUpdate as M, PlanCheckoutCreate as N, InvoiceCreate as O, PlanCreate as P, CustomerSubscription as Q, PlanUpdate as R, CustomerUpdate as S, FeatureUpdate as T, ProductUpdate as U, ProductCreate as V, RefundCreate as W, WebhookEndpointCreate as X, VariantInput as Y, WebhookEndpointUpdate as Z, CouponUpdate as _, CheckoutCreate as a, PortalFeatures as at, CustomerInput as b, ClientCheckoutUpdate as c, PublicInvoice as ct, ClientLinkCheckout as d, PublicPortal as dt, PaymentInstructions as et, ClientPaymentCode as f, CouponCreate as g, CollectInput as h, AfterCompletionInput as i, PaymentTestScenario as it, PaymentLinkCreate as j, InvoiceLineInput as k, ClientFulfillmentProblem as l, PublicPaymentLink as lt, ClientSubscriptionUpdate as m, RequestOptions as n, PaymentMethodOption as nt, CheckoutItemInput as o, PublicCheckout as ot, ClientSubscriptionCancel as p, SubscriptionCreate as q, TransportOptions as r, PaymentNextAction as rt, ClientCheckoutPay as s, PublicFulfillment as st, BilleteError as t, PaymentMethodField as tt, ClientInvoicePay as u, PublicPaymentState as ut, CustomFieldInput as v, FeatureCreate as w, CustomerSessionCreate as x, CustomerCreate as y, PortalSessionCreate as z };
862
+ export { SubscriptionCreate as $, FulfillmentInput as A, isApiVersionRetired as At, PlanLinkCreate as B, CustomerSessionCreate as C, ApiVersionStage as Ct, FeatureOperationCommit as D, apiVersionStage as Dt, FeatureCreate as E, apiVersionLifecycle as Et, PaymentLinkCreate as F, ProductCreate as G, PlanUpdate as H, PaymentLinkUpdate as I, RefundCreate as J, ProductLinkCreate as K, PlanCheckoutCreate as L, InvoiceCreate as M, InvoiceLineInput as N, FeatureOperationCreate as O, currentApiVersion as Ot, KEY_PATTERN as P, SubscriptionChangePreviewInput as Q, PlanCreate as R, CustomerMemberUpdate as S, ApiVersionLifecycle as St, EventSelector as T, LatestApiVersion as Tt, PortalSessionCreate as U, PlanPriceInput as V, ProductCheckoutCreate as W, SubscriptionCancel as X, RetireInput as Y, SubscriptionChangeCreate as Z, CouponUpdate as _, PublicPortal as _t, CheckoutCreate as a, FulfillmentOption as at, CustomerInput as b, API_VERSION_PATTERN as bt, ClientCheckoutUpdate as c, PaymentMethodOption as ct, ClientLinkCheckout as d, PortalFeatures as dt, SubscriptionUpdate as et, ClientPaymentCode as f, PublicCheckout as ft, CouponCreate as g, PublicPaymentState as gt, CollectInput as h, PublicPaymentLink as ht, AfterCompletionInput as i, CustomerSubscription as it, FulfillmentTrackingInput as j, supportedApiVersions as jt, FeatureUpdate as k, isApiVersion as kt, ClientFulfillmentProblem as l, PaymentNextAction as lt, ClientSubscriptionUpdate as m, PublicInvoice as mt, RequestOptions as n, WebhookEndpointCreate as nt, CheckoutItemInput as o, PaymentInstructions as ot, ClientSubscriptionCancel as p, PublicFulfillment as pt, ProductUpdate as q, TransportOptions as r, WebhookEndpointUpdate as rt, ClientCheckoutPay as s, PaymentMethodField as st, BilleteError as t, VariantInput as tt, ClientInvoicePay as u, PaymentTestScenario as ut, CustomFieldInput as v, API_VERSIONS as vt, CustomerUpdate as w, LATEST_API_VERSION as wt, CustomerMemberCreate as x, ApiVersion as xt, CustomerCreate as y, API_VERSION_HEADER as yt, PlanFeaturesInput as z };
@@ -278,55 +278,6 @@ type PaymentFailureCode = (typeof PAYMENT_FAILURE_CODES)[number];
278
278
  interface ReceiptReference {
279
279
  id: string;
280
280
  number: string;
281
- url: string;
282
- }
283
- /** Frozen at settlement; never contains fees, net amounts or raw provider data. */
284
- interface ReceiptSnapshot {
285
- business: {
286
- name: string;
287
- legalName: string | null;
288
- taxId: string | null;
289
- supportEmail: string | null;
290
- supportPhone: string | null;
291
- address: Address | null;
292
- };
293
- customer: {
294
- name: string | null;
295
- email: string;
296
- address: Address | null;
297
- };
298
- timezone: string;
299
- invoiceNumber: string;
300
- lines: LineItem[];
301
- currency: Currency;
302
- subtotal: number;
303
- discount: number;
304
- couponCode: string | null;
305
- tax: number;
306
- taxRateBps: number;
307
- taxBehavior: TaxBehavior;
308
- total: number;
309
- periodStart: Timestamp | null;
310
- periodEnd: Timestamp | null;
311
- paid: {
312
- amount: number;
313
- currency: Currency;
314
- exchangeRate: string | null;
315
- method: string;
316
- details: Record<string, string>;
317
- reference: string | null;
318
- paidAt: Timestamp;
319
- };
320
- }
321
- interface PublicReceipt extends ReceiptReference {
322
- environment: Environment;
323
- snapshot: ReceiptSnapshot;
324
- refunds: Array<{
325
- amount: number;
326
- currency: Currency;
327
- createdAt: Timestamp;
328
- status: "succeeded";
329
- }>;
330
281
  }
331
282
  interface ReceiptSend {
332
283
  email?: string;
@@ -348,6 +299,32 @@ interface Customer extends Resource<"customer"> {
348
299
  metadata: Metadata;
349
300
  updatedAt: Timestamp;
350
301
  }
302
+ interface CustomerMember extends Resource<"customer_member"> {
303
+ customerId: string;
304
+ externalId: string;
305
+ name: string | null;
306
+ status: "active" | "removed";
307
+ enabled: boolean;
308
+ activeSince: Timestamp;
309
+ removedAt: Timestamp | null;
310
+ metadata: Metadata;
311
+ updatedAt: Timestamp;
312
+ }
313
+ interface CustomerMemberList {
314
+ data: CustomerMember[];
315
+ capacity: number | null;
316
+ enabledCount: number;
317
+ nextCursor: string | null;
318
+ }
319
+ declare const MAX_SEATS = 10000;
320
+ type PlanSeats = {
321
+ mode: "included";
322
+ limit: number | null;
323
+ } | {
324
+ mode: "per_seat";
325
+ min: number;
326
+ max: number;
327
+ };
351
328
  declare const PRODUCT_CATEGORIES: readonly ["digital", "physical", "service", "event", "other"];
352
329
  type ProductCategory = (typeof PRODUCT_CATEGORIES)[number];
353
330
  /** Who performed an action: a dashboard user or an API key. */
@@ -403,6 +380,8 @@ interface PlanPrice {
403
380
  */
404
381
  type PlanFeatureValues = Record<string, boolean | number | null>;
405
382
  interface Plan extends Resource<"plan"> {
383
+ seats: PlanSeats;
384
+ fallbackPlanId: string | null;
406
385
  name: string;
407
386
  description: string | null;
408
387
  currency: Currency;
@@ -456,6 +435,7 @@ type FeatureReset = {
456
435
  day: number;
457
436
  };
458
437
  interface Feature extends Resource<"feature"> {
438
+ per: "customer" | "member";
459
439
  key: string;
460
440
  name: string;
461
441
  type: FeatureType;
@@ -471,6 +451,9 @@ interface Feature extends Resource<"feature"> {
471
451
  }
472
452
  /** What a customer can do with a feature right now, across all of their ongoing subscriptions. */
473
453
  interface CustomerFeature {
454
+ per: "customer" | "member";
455
+ reason?: "over_limit";
456
+ reserved: number | null;
474
457
  key: string;
475
458
  name: string;
476
459
  type: FeatureType;
@@ -480,7 +463,7 @@ interface CustomerFeature {
480
463
  limit: number | null;
481
464
  /** `number`: the granted value (`null` when no plan grants it). `null` for the other types. */
482
465
  value: number | null;
483
- used: number;
466
+ used: number | null;
484
467
  /** `null` when unlimited or not a usage type. */
485
468
  remaining: number | null;
486
469
  /** When `metered` usage restores next; `null` for the other types. */
@@ -491,6 +474,23 @@ interface FeatureUsageResult {
491
474
  allowed: boolean;
492
475
  feature: CustomerFeature;
493
476
  }
477
+ interface FeatureOperation extends Resource<"feature_operation"> {
478
+ key: string;
479
+ customerId: string;
480
+ memberId: string | null;
481
+ featureId: string;
482
+ periodStart: Timestamp;
483
+ amount: number;
484
+ committedAmount: number | null;
485
+ status: "reserved" | "committed" | "released" | "expired" | "refunded";
486
+ expiresAt: Timestamp;
487
+ metadata: Metadata;
488
+ updatedAt: Timestamp;
489
+ }
490
+ interface FeatureOperationResult extends FeatureUsageResult {
491
+ created: boolean;
492
+ operation: FeatureOperation | null;
493
+ }
494
494
  declare const SUBSCRIPTION_STATUSES: readonly ["trialing", "active", "past_due", "canceled", "expired"];
495
495
  type SubscriptionStatus = (typeof SUBSCRIPTION_STATUSES)[number];
496
496
  interface SubscriptionRenewal {
@@ -511,11 +511,14 @@ interface SubscriptionRenewal {
511
511
  declare const CANCELLATION_FEEDBACK: readonly ["too_expensive", "missing_features", "switched_service", "unused", "customer_service", "too_complex", "low_quality", "other"];
512
512
  type CancellationFeedback = (typeof CANCELLATION_FEEDBACK)[number];
513
513
  interface Subscription extends Resource<"subscription"> {
514
+ version: number;
515
+ previousPlanId: string | null;
516
+ quantity: number;
514
517
  customerId: string;
515
518
  planId: string;
516
519
  status: SubscriptionStatus;
517
520
  months: BillingMonths;
518
- amount: number;
521
+ unitAmount: number;
519
522
  currency: Currency;
520
523
  currentPeriodStart: Timestamp;
521
524
  currentPeriodEnd: Timestamp;
@@ -532,6 +535,7 @@ interface Subscription extends Resource<"subscription"> {
532
535
  pendingChange: {
533
536
  planId: string;
534
537
  months: BillingMonths;
538
+ quantity: number;
535
539
  } | null;
536
540
  renewal: SubscriptionRenewal | null;
537
541
  /**
@@ -626,9 +630,10 @@ interface CustomerDetails {
626
630
  phone: string | null;
627
631
  address: Address | null;
628
632
  }
629
- declare const CHECKOUT_PURPOSES: readonly ["product", "plan"];
633
+ declare const CHECKOUT_PURPOSES: readonly ["product", "plan", "subscription_change"];
630
634
  type CheckoutPurpose = (typeof CHECKOUT_PURPOSES)[number];
631
635
  interface Checkout extends Resource<"checkout"> {
636
+ subscriptionChange: SubscriptionChange | null;
632
637
  url: string;
633
638
  purpose: CheckoutPurpose;
634
639
  status: "open" | "completed" | "expired";
@@ -663,6 +668,46 @@ interface Checkout extends Resource<"checkout"> {
663
668
  completedAt: Timestamp | null;
664
669
  metadata: Metadata;
665
670
  }
671
+ interface SubscriptionTerms {
672
+ planId: string;
673
+ months: BillingMonths;
674
+ quantity: number;
675
+ unitAmount: number;
676
+ }
677
+ /** The quote a `subscription_change` checkout charges and applies as is once paid. */
678
+ interface SubscriptionChange {
679
+ quotedAt: Timestamp;
680
+ version: number;
681
+ kind: "restart" | "add_seats";
682
+ from: SubscriptionTerms;
683
+ to: SubscriptionTerms;
684
+ currentPeriodEnd: Timestamp;
685
+ creditApplied: number;
686
+ unusedCredit: number;
687
+ subtotal: number;
688
+ discount: number;
689
+ tax: number;
690
+ total: number;
691
+ activatedAt: Timestamp | null;
692
+ outcome: "pending" | "applied" | "rejected";
693
+ }
694
+ interface SubscriptionChangePreview {
695
+ credit: number;
696
+ charge: number;
697
+ tax: number;
698
+ total: number;
699
+ unusedCredit: number;
700
+ version: number;
701
+ currentPeriodEnd: Timestamp;
702
+ periodEndIfPaidNow?: Timestamp;
703
+ }
704
+ type SubscriptionChangeResult = {
705
+ type: "scheduled" | "applied";
706
+ subscription: Subscription;
707
+ } | {
708
+ type: "checkout";
709
+ checkout: Checkout;
710
+ };
666
711
  /**
667
712
  * `pickup`: the customer collects it at the business. `delivery`: the business takes it to them.
668
713
  * `shipping`: the business sends it through a carrier to the office the customer chose.
@@ -938,12 +983,19 @@ interface Payout extends Resource<"payout"> {
938
983
  interface WebhookEndpoint extends Resource<"webhook_endpoint"> {
939
984
  url: string;
940
985
  events: string[];
986
+ /**
987
+ * Version its events are delivered in. Typed as text: responses never change shape when new
988
+ * versions are published.
989
+ */
990
+ apiVersion: string;
941
991
  enabled: boolean;
942
992
  /** Returned only when the endpoint is created. */
943
993
  secret?: string;
944
994
  }
945
995
  interface Event<TData = Record<string, unknown>> extends Resource<"event"> {
946
996
  type: string;
997
+ /** The version whose shape `data` is in: the request's, or the webhook endpoint's. */
998
+ apiVersion: string;
947
999
  data: TData;
948
1000
  }
949
1001
  interface ExchangeRate {
@@ -984,6 +1036,12 @@ interface EventDataMap {
984
1036
  "payment_link.retired": PaymentLink;
985
1037
  "customer.created": Customer;
986
1038
  "customer.updated": Customer;
1039
+ "customer.member_added": CustomerMember;
1040
+ "customer.member_removed": CustomerMember;
1041
+ "subscription.change_failed": {
1042
+ subscription: Subscription;
1043
+ checkoutId: string;
1044
+ };
987
1045
  "checkout.completed": Checkout;
988
1046
  "checkout.expired": Checkout;
989
1047
  "payment.succeeded": Payment;
@@ -1023,15 +1081,17 @@ interface EventDataMap {
1023
1081
  "subscription.expired": Subscription;
1024
1082
  }
1025
1083
  type EventType = keyof EventDataMap;
1026
- declare const EVENT_TYPES: readonly ["product.retired", "product.updated", "payment_link.retired", "customer.created", "customer.updated", "checkout.completed", "checkout.expired", "payment.succeeded", "payment.failed", "payment.refunded", "fulfillment.created", "fulfillment.shipped", "fulfillment.ready_for_pickup", "fulfillment.delivered", "fulfillment.received", "fulfillment.problem_reported", "fulfillment.canceled", "refund.created", "refund.failed", "invoice.created", "invoice.paid", "invoice.voided", "invoice.uncollectible", "subscription.created", "subscription.updated", "subscription.renewal_due", "subscription.renewed", "subscription.past_due", "subscription.canceled", "subscription.expired"];
1084
+ declare const EVENT_TYPES: readonly ["product.retired", "product.updated", "payment_link.retired", "customer.created", "customer.updated", "customer.member_added", "customer.member_removed", "subscription.change_failed", "checkout.completed", "checkout.expired", "payment.succeeded", "payment.failed", "payment.refunded", "fulfillment.created", "fulfillment.shipped", "fulfillment.ready_for_pickup", "fulfillment.delivered", "fulfillment.received", "fulfillment.problem_reported", "fulfillment.canceled", "refund.created", "refund.failed", "invoice.created", "invoice.paid", "invoice.voided", "invoice.uncollectible", "subscription.created", "subscription.updated", "subscription.renewal_due", "subscription.renewed", "subscription.past_due", "subscription.canceled", "subscription.expired"];
1027
1085
  /** A delivered webhook, discriminated by `type` so `data` narrows automatically. */
1028
1086
  type WebhookEvent = { [TType in EventType]: {
1029
1087
  id: string;
1030
1088
  object: "event";
1031
1089
  type: TType;
1090
+ /** The webhook endpoint's version: `data` comes in its shape. */
1091
+ apiVersion: string;
1032
1092
  environment: Environment;
1033
1093
  createdAt: string;
1034
1094
  data: EventDataMap[TType];
1035
1095
  }; }[EventType];
1036
1096
  //#endregion
1037
- export { PaymentSettlement as $, Timestamp as $t, FULFILLMENT_METHODS as A, ApiErrorEnvelope as At, FulfillmentTracking as B, CURRENCIES as Bt, Customer as C, Weekday as Ct, Event as D, ReceiptSnapshot as Dt, CustomerSession as E, ReceiptSend as Et, FeatureUsageResult as F, Address as Ft, InvoiceStatus as G, ListQuery as Gt, INVOICE_STATUSES as H, GRACE_PERIOD_DAYS as Ht, Fulfillment as I, AddressInput as It, PRODUCT_CATEGORIES as J, MOBILE_PREFIXES as Jt, LineItem as K, ListSort as Kt, FulfillmentChoice as L, BILLING_MONTHS as Lt, Feature as M, PAYMENT_FAILURE_CODES as Mt, FeatureReset as N, PaymentFailureCode as Nt, ExchangeRate as O, API_ERROR_TYPES as Ot, FeatureType as P, ACCOUNT_NUMBER_LENGTH as Pt, PaymentLink as Q, TaxBehavior as Qt, FulfillmentMethod as R, BankCode as Rt, CustomField as S, WebhookEndpoint as St, CustomerFeature as T, ReceiptReference as Tt, Invoice as U, GracePeriodDays as Ut, INVOICE_REASONS as V, Currency as Vt, InvoiceReason as W, List as Wt, PaymentAttempt as X, MobilePrefix as Xt, Payment as Y, Metadata as Yt, PaymentFailure as Z, TAX_BEHAVIORS as Zt, CheckoutItem as _, SubmitLabel as _t, Actor as a, ENVIRONMENTS as an, PortalSession as at, Coupon as b, SubscriptionStatus as bt, BalanceAmount as c, tokenEnvironment as cn, ProductVariant as ct, CARRIER_TEST_SCENARIOS as d, Refund as dt, VENEZUELAN_BANKS as en, PaymentStatus as et, CHECKOUT_PURPOSES as f, ResetFrequency as ft, Checkout as g, SUBSCRIPTION_STATUSES as gt, CarrierOffice as h, SUBMIT_LABELS as ht, WebhookEvent as i, nationalPhone as in, PlanPrice as it, FULFILLMENT_STATUSES as j, ApiErrorType as jt, FEATURE_TYPES as k, ApiErrorBody as kt, CANCELLATION_FEEDBACK as l, tokenPrefix as ln, RESET_FREQUENCIES as lt, Carrier as m, RiskLevel as mt, EventDataMap as n, isLandlinePhone as nn, Plan as nt, AfterCompletion as o, Environment as on, Product as ot, CancellationFeedback as p, Retirement as pt, PAYMENT_STATUSES as q, MAX_QUANTITY as qt, EventType as r, isMobilePhone as rn, PlanFeatureValues as rt, Balance as s, TokenKind as sn, ProductCategory as st, EVENT_TYPES as t, findBank as tn, Payout as tt, CARRIERS as u, RISK_LEVELS as ut, CheckoutPurpose as v, Subscription as vt, CustomerDetails as w, PublicReceipt as wt, CurrencyAvailability as x, USAGE_FEATURE_TYPES as xt, CollectSettings as y, SubscriptionRenewal as yt, FulfillmentStatus as z, BillingMonths as zt };
1097
+ export { PRODUCT_CATEGORIES as $, ListQuery as $t, ExchangeRate as A, SubscriptionTerms as At, Fulfillment as B, PAYMENT_FAILURE_CODES as Bt, Customer as C, SubmitLabel as Ct, CustomerMemberList as D, SubscriptionChangeResult as Dt, CustomerMember as E, SubscriptionChangePreview as Et, FeatureOperation as F, ReceiptSend as Ft, INVOICE_REASONS as G, BILLING_MONTHS as Gt, FulfillmentMethod as H, ACCOUNT_NUMBER_LENGTH as Ht, FeatureOperationResult as I, API_ERROR_TYPES as It, InvoiceReason as J, CURRENCIES as Jt, INVOICE_STATUSES as K, BankCode as Kt, FeatureReset as L, ApiErrorBody as Lt, FULFILLMENT_METHODS as M, WebhookEndpoint as Mt, FULFILLMENT_STATUSES as N, Weekday as Nt, CustomerSession as O, SubscriptionRenewal as Ot, Feature as P, ReceiptReference as Pt, PAYMENT_STATUSES as Q, List as Qt, FeatureType as R, ApiErrorEnvelope as Rt, CustomField as S, SUBSCRIPTION_STATUSES as St, CustomerFeature as T, SubscriptionChange as Tt, FulfillmentStatus as U, Address as Ut, FulfillmentChoice as V, PaymentFailureCode as Vt, FulfillmentTracking as W, AddressInput as Wt, LineItem as X, GRACE_PERIOD_DAYS as Xt, InvoiceStatus as Y, Currency as Yt, MAX_SEATS as Z, GracePeriodDays as Zt, CheckoutItem as _, tokenPrefix as _n, Refund as _t, Actor as a, TAX_BEHAVIORS as an, PaymentStatus as at, Coupon as b, RiskLevel as bt, BalanceAmount as c, VENEZUELAN_BANKS as cn, PlanFeatureValues as ct, CARRIER_TEST_SCENARIOS as d, isMobilePhone as dn, PortalSession as dt, ListSort as en, Payment as et, CHECKOUT_PURPOSES as f, nationalPhone as fn, Product as ft, Checkout as g, tokenEnvironment as gn, RISK_LEVELS as gt, CarrierOffice as h, TokenKind as hn, RESET_FREQUENCIES as ht, WebhookEvent as i, MobilePrefix as in, PaymentSettlement as it, FEATURE_TYPES as j, USAGE_FEATURE_TYPES as jt, Event as k, SubscriptionStatus as kt, CANCELLATION_FEEDBACK as l, findBank as ln, PlanPrice as lt, Carrier as m, Environment as mn, ProductVariant as mt, EventDataMap as n, MOBILE_PREFIXES as nn, PaymentFailure as nt, AfterCompletion as o, TaxBehavior as on, Payout as ot, CancellationFeedback as p, ENVIRONMENTS as pn, ProductCategory as pt, Invoice as q, BillingMonths as qt, EventType as r, Metadata as rn, PaymentLink as rt, Balance as s, Timestamp as sn, Plan as st, EVENT_TYPES as t, MAX_QUANTITY as tn, PaymentAttempt as tt, CARRIERS as u, isLandlinePhone as un, PlanSeats as ut, CheckoutPurpose as v, ResetFrequency as vt, CustomerDetails as w, Subscription as wt, CurrencyAvailability as x, SUBMIT_LABELS as xt, CollectSettings as y, Retirement as yt, FeatureUsageResult as z, ApiErrorType as zt };
@@ -18,7 +18,7 @@ var BilleteError = class extends Error {
18
18
  };
19
19
  //#endregion
20
20
  //#region src/http.ts
21
- const SDK_VERSION = "1.1.0-canary.5";
21
+ const SDK_VERSION = "2.0.0";
22
22
  const DEFAULT_BASE_URL = "https://api.billete.run";
23
23
  const RETRYABLE_STATUS = /* @__PURE__ */ new Set([
24
24
  429,
@@ -58,6 +58,7 @@ async function toError(response) {
58
58
  }, response.status);
59
59
  }
60
60
  function createTransport(options) {
61
+ if (!options.apiVersion) throw new TypeError("Billete needs apiVersion: the API version your integration is written against");
61
62
  const baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;
62
63
  const fetchImpl = options.fetch ?? ((...args) => globalThis.fetch(...args));
63
64
  const timeoutMs = options.timeoutMs ?? 3e4;
@@ -66,6 +67,7 @@ function createTransport(options) {
66
67
  const token = options.token?.();
67
68
  const headers = {
68
69
  Accept: "application/json",
70
+ "Billete-Version": options.apiVersion,
69
71
  "X-Billete-Client": `billete-js/${SDK_VERSION}`,
70
72
  ...token ? { Authorization: `Bearer ${token}` } : {},
71
73
  ...request.body === void 0 ? {} : { "Content-Type": "application/json" },
package/dist/index.d.ts CHANGED
@@ -1,8 +1,14 @@
1
- import { $ as PaymentSettlement, $t as Timestamp, A as FULFILLMENT_METHODS, At as ApiErrorEnvelope, B as FulfillmentTracking, Bt as CURRENCIES, C as Customer, Ct as Weekday, D as Event, Dt as ReceiptSnapshot, E as CustomerSession, Et as ReceiptSend, F as FeatureUsageResult, Ft as Address, G as InvoiceStatus, Gt as ListQuery, H as INVOICE_STATUSES, Ht as GRACE_PERIOD_DAYS, I as Fulfillment, It as AddressInput, J as PRODUCT_CATEGORIES, Jt as MOBILE_PREFIXES, K as LineItem, Kt as ListSort, L as FulfillmentChoice, Lt as BILLING_MONTHS, M as Feature, Mt as PAYMENT_FAILURE_CODES, N as FeatureReset, Nt as PaymentFailureCode, O as ExchangeRate, Ot as API_ERROR_TYPES, P as FeatureType, Pt as ACCOUNT_NUMBER_LENGTH, Q as PaymentLink, Qt as TaxBehavior, R as FulfillmentMethod, Rt as BankCode, S as CustomField, St as WebhookEndpoint, T as CustomerFeature, Tt as ReceiptReference, U as Invoice, Ut as GracePeriodDays, V as INVOICE_REASONS, Vt as Currency, W as InvoiceReason, Wt as List, X as PaymentAttempt, Xt as MobilePrefix, Y as Payment, Yt as Metadata, Z as PaymentFailure, Zt as TAX_BEHAVIORS, _ as CheckoutItem, _t as SubmitLabel, a as Actor, an as ENVIRONMENTS, at as PortalSession, b as Coupon, bt as SubscriptionStatus, c as BalanceAmount, cn as tokenEnvironment, ct as ProductVariant, d as CARRIER_TEST_SCENARIOS, dt as Refund, en as VENEZUELAN_BANKS, et as PaymentStatus, f as CHECKOUT_PURPOSES, ft as ResetFrequency, g as Checkout, gt as SUBSCRIPTION_STATUSES, h as CarrierOffice, ht as SUBMIT_LABELS, i as WebhookEvent, in as nationalPhone, it as PlanPrice, j as FULFILLMENT_STATUSES, jt as ApiErrorType, k as FEATURE_TYPES, kt as ApiErrorBody, l as CANCELLATION_FEEDBACK, ln as tokenPrefix, lt as RESET_FREQUENCIES, m as Carrier, mt as RiskLevel, n as EventDataMap, nn as isLandlinePhone, nt as Plan, o as AfterCompletion, on as Environment, ot as Product, p as CancellationFeedback, pt as Retirement, q as PAYMENT_STATUSES, qt as MAX_QUANTITY, r as EventType, rn as isMobilePhone, rt as PlanFeatureValues, s as Balance, sn as TokenKind, st as ProductCategory, t as EVENT_TYPES, tn as findBank, tt as Payout, u as CARRIERS, ut as RISK_LEVELS, v as CheckoutPurpose, vt as Subscription, w as CustomerDetails, wt as PublicReceipt, x as CurrencyAvailability, xt as USAGE_FEATURE_TYPES, y as CollectSettings, yt as SubscriptionRenewal, z as FulfillmentStatus, zt as BillingMonths } from "./events-kvUK9zvS.js";
2
- import { $ as FulfillmentOption, A as KEY_PATTERN, B as ProductCheckoutCreate, C as EventSelector, D as FulfillmentTrackingInput, E as FulfillmentInput, F as PlanFeaturesInput, G as RetireInput, H as ProductLinkCreate, I as PlanLinkCreate, J as SubscriptionUpdate, K as SubscriptionCancel, L as PlanPriceInput, M as PaymentLinkUpdate, N as PlanCheckoutCreate, O as InvoiceCreate, P as PlanCreate, Q as CustomerSubscription, R as PlanUpdate, S as CustomerUpdate, T as FeatureUpdate, U as ProductUpdate, V as ProductCreate, W as RefundCreate, X as WebhookEndpointCreate, Y as VariantInput, Z as WebhookEndpointUpdate, _ as CouponUpdate, a as CheckoutCreate, at as PortalFeatures, b as CustomerInput, c as ClientCheckoutUpdate, ct as PublicInvoice, d as ClientLinkCheckout, dt as PublicPortal, et as PaymentInstructions, f as ClientPaymentCode, g as CouponCreate, h as CollectInput, i as AfterCompletionInput, it as PaymentTestScenario, j as PaymentLinkCreate, k as InvoiceLineInput, l as ClientFulfillmentProblem, lt as PublicPaymentLink, m as ClientSubscriptionUpdate, n as RequestOptions, nt as PaymentMethodOption, o as CheckoutItemInput, ot as PublicCheckout, p as ClientSubscriptionCancel, q as SubscriptionCreate, r as TransportOptions, rt as PaymentNextAction, s as ClientCheckoutPay, st as PublicFulfillment, t as BilleteError, tt as PaymentMethodField, u as ClientInvoicePay, ut as PublicPaymentState, v as CustomFieldInput, w as FeatureCreate, x as CustomerSessionCreate, y as CustomerCreate, z as PortalSessionCreate } from "./errors-DY-3gWvA.js";
1
+ import { $ as SubscriptionCreate, A as FulfillmentInput, At as isApiVersionRetired, B as PlanLinkCreate, C as CustomerSessionCreate, Ct as ApiVersionStage, D as FeatureOperationCommit, Dt as apiVersionStage, E as FeatureCreate, Et as apiVersionLifecycle, F as PaymentLinkCreate, G as ProductCreate, H as PlanUpdate, I as PaymentLinkUpdate, J as RefundCreate, K as ProductLinkCreate, L as PlanCheckoutCreate, M as InvoiceCreate, N as InvoiceLineInput, O as FeatureOperationCreate, Ot as currentApiVersion, P as KEY_PATTERN, Q as SubscriptionChangePreviewInput, R as PlanCreate, S as CustomerMemberUpdate, St as ApiVersionLifecycle, T as EventSelector, Tt as LatestApiVersion, U as PortalSessionCreate, V as PlanPriceInput, W as ProductCheckoutCreate, X as SubscriptionCancel, Y as RetireInput, Z as SubscriptionChangeCreate, _ as CouponUpdate, _t as PublicPortal, a as CheckoutCreate, at as FulfillmentOption, b as CustomerInput, bt as API_VERSION_PATTERN, c as ClientCheckoutUpdate, ct as PaymentMethodOption, d as ClientLinkCheckout, dt as PortalFeatures, et as SubscriptionUpdate, f as ClientPaymentCode, ft as PublicCheckout, g as CouponCreate, gt as PublicPaymentState, h as CollectInput, ht as PublicPaymentLink, i as AfterCompletionInput, it as CustomerSubscription, j as FulfillmentTrackingInput, jt as supportedApiVersions, k as FeatureUpdate, kt as isApiVersion, l as ClientFulfillmentProblem, lt as PaymentNextAction, m as ClientSubscriptionUpdate, mt as PublicInvoice, n as RequestOptions, nt as WebhookEndpointCreate, o as CheckoutItemInput, ot as PaymentInstructions, p as ClientSubscriptionCancel, pt as PublicFulfillment, q as ProductUpdate, r as TransportOptions, rt as WebhookEndpointUpdate, s as ClientCheckoutPay, st as PaymentMethodField, t as BilleteError, tt as VariantInput, u as ClientInvoicePay, ut as PaymentTestScenario, v as CustomFieldInput, vt as API_VERSIONS, w as CustomerUpdate, wt as LATEST_API_VERSION, x as CustomerMemberCreate, xt as ApiVersion, y as CustomerCreate, yt as API_VERSION_HEADER, z as PlanFeaturesInput } from "./errors-Cu8XMn5I.js";
2
+ import { $ as PRODUCT_CATEGORIES, $t as ListQuery, A as ExchangeRate, At as SubscriptionTerms, B as Fulfillment, Bt as PAYMENT_FAILURE_CODES, C as Customer, Ct as SubmitLabel, D as CustomerMemberList, Dt as SubscriptionChangeResult, E as CustomerMember, Et as SubscriptionChangePreview, F as FeatureOperation, Ft as ReceiptSend, G as INVOICE_REASONS, Gt as BILLING_MONTHS, H as FulfillmentMethod, Ht as ACCOUNT_NUMBER_LENGTH, I as FeatureOperationResult, It as API_ERROR_TYPES, J as InvoiceReason, Jt as CURRENCIES, K as INVOICE_STATUSES, Kt as BankCode, L as FeatureReset, Lt as ApiErrorBody, M as FULFILLMENT_METHODS, Mt as WebhookEndpoint, N as FULFILLMENT_STATUSES, Nt as Weekday, O as CustomerSession, Ot as SubscriptionRenewal, P as Feature, Pt as ReceiptReference, Q as PAYMENT_STATUSES, Qt as List, R as FeatureType, Rt as ApiErrorEnvelope, S as CustomField, St as SUBSCRIPTION_STATUSES, T as CustomerFeature, Tt as SubscriptionChange, U as FulfillmentStatus, Ut as Address, V as FulfillmentChoice, Vt as PaymentFailureCode, W as FulfillmentTracking, Wt as AddressInput, X as LineItem, Xt as GRACE_PERIOD_DAYS, Y as InvoiceStatus, Yt as Currency, Z as MAX_SEATS, Zt as GracePeriodDays, _ as CheckoutItem, _n as tokenPrefix, _t as Refund, a as Actor, an as TAX_BEHAVIORS, at as PaymentStatus, b as Coupon, bt as RiskLevel, c as BalanceAmount, cn as VENEZUELAN_BANKS, ct as PlanFeatureValues, d as CARRIER_TEST_SCENARIOS, dn as isMobilePhone, dt as PortalSession, en as ListSort, et as Payment, f as CHECKOUT_PURPOSES, fn as nationalPhone, ft as Product, g as Checkout, gn as tokenEnvironment, gt as RISK_LEVELS, h as CarrierOffice, hn as TokenKind, ht as RESET_FREQUENCIES, i as WebhookEvent, in as MobilePrefix, it as PaymentSettlement, j as FEATURE_TYPES, jt as USAGE_FEATURE_TYPES, k as Event, kt as SubscriptionStatus, l as CANCELLATION_FEEDBACK, ln as findBank, lt as PlanPrice, m as Carrier, mn as Environment, mt as ProductVariant, n as EventDataMap, nn as MOBILE_PREFIXES, nt as PaymentFailure, o as AfterCompletion, on as TaxBehavior, ot as Payout, p as CancellationFeedback, pn as ENVIRONMENTS, pt as ProductCategory, q as Invoice, qt as BillingMonths, r as EventType, rn as Metadata, rt as PaymentLink, s as Balance, sn as Timestamp, st as Plan, t as EVENT_TYPES, tn as MAX_QUANTITY, tt as PaymentAttempt, u as CARRIERS, un as isLandlinePhone, ut as PlanSeats, v as CheckoutPurpose, vt as ResetFrequency, w as CustomerDetails, wt as Subscription, x as CurrencyAvailability, xt as SUBMIT_LABELS, y as CollectSettings, yt as Retirement, z as FeatureUsageResult, zt as ApiErrorType } from "./events-CrmMdwBX.js";
3
3
  import { WebhookVerificationError, verifyWebhook } from "./webhooks.js";
4
4
  //#region src/server.d.ts
5
5
  type Filters<T> = ListQuery & T;
6
+ type MemberOptions = RequestOptions & {
7
+ member?: string;
8
+ };
9
+ type UsageOptions = MemberOptions & {
10
+ operation?: string;
11
+ };
6
12
  interface BilleteOptions extends TransportOptions {
7
13
  /**
8
14
  * Where this client operates: `test` or `production`. Required, and it must match the API key
@@ -18,7 +24,8 @@ interface BilleteOptions extends TransportOptions {
18
24
  * Server-side Billete client. Works in any runtime with `fetch` (Node, Bun, Deno, edge).
19
25
  *
20
26
  * ```ts
21
- * const billete = createBillete({ environment: "test" }); // reads BILLETE_API_KEY
27
+ * // Reads BILLETE_API_KEY.
28
+ * const billete = createBillete({ apiVersion: "2026-10-08", environment: "test" });
22
29
  * const { allowed } = await billete.features.consume("user_123", "tokens", 850);
23
30
  * ```
24
31
  */
@@ -37,6 +44,17 @@ export declare function createBillete(options: BilleteOptions): {
37
44
  search?: string;
38
45
  }>) => AsyncGenerator<Customer, any, any>;
39
46
  };
47
+ members: {
48
+ list: (customer: string, query?: Filters<{
49
+ status?: "active" | "removed";
50
+ search?: string;
51
+ }>, options?: RequestOptions) => Promise<CustomerMemberList>;
52
+ /** Re-adding a removed externalId restores its member ID and keeps its usage. */
53
+ create: (customer: string, input: CustomerMemberCreate, options?: RequestOptions) => Promise<CustomerMember>;
54
+ retrieve: (customer: string, member: string, options?: RequestOptions) => Promise<CustomerMember>;
55
+ update: (customer: string, member: string, input: CustomerMemberUpdate, options?: RequestOptions) => Promise<CustomerMember>;
56
+ remove: (customer: string, member: string, options?: RequestOptions) => Promise<CustomerMember>;
57
+ };
40
58
  customerSessions: {
41
59
  /** Short-lived token for the client SDK to read one customer's billing state. */
42
60
  create: (input: CustomerSessionCreate, options?: RequestOptions) => Promise<CustomerSession>;
@@ -91,21 +109,40 @@ export declare function createBillete(options: BilleteOptions): {
91
109
  iterate: (query?: Filters<{
92
110
  sort?: ListSort<"created" | "name">;
93
111
  }>) => AsyncGenerator<Feature, any, any>;
112
+ /**
113
+ * Reserves `amount` of a metered feature for one job: it counts as used right away and the
114
+ * operation is closed later through `features.operations`. Repeating `operation` returns the
115
+ * same reservation without consuming again; running each job once is your queue's job.
116
+ */
117
+ reserve: (customer: string, key: string, amount: number, input: Omit<FeatureOperationCreate, "amount">, options?: RequestOptions) => Promise<FeatureOperationResult>;
118
+ /** Closes reservations. Each call is idempotent, so retry it on doubt instead of releasing. */
119
+ operations: {
120
+ retrieve: (operation: string, options?: RequestOptions) => Promise<FeatureOperation>;
121
+ /** Confirms what the job used (all by default) and returns the rest. */
122
+ commit: (operation: string, input?: FeatureOperationCommit, options?: RequestOptions) => Promise<FeatureOperation>;
123
+ /** Returns a reservation whose job failed. */
124
+ release: (operation: string, options?: RequestOptions) => Promise<FeatureOperation>;
125
+ /** Returns everything a committed operation used, to the period it was counted in. */
126
+ refund: (operation: string, options?: RequestOptions) => Promise<FeatureOperation>;
127
+ };
94
128
  /** Current access to one feature. `customer` is a `cus_…` ID or your own `externalId`. */
95
- check: (customer: string, key: string, options?: RequestOptions) => Promise<CustomerFeature>;
129
+ check: (customer: string, key: string, options?: MemberOptions) => Promise<CustomerFeature>;
96
130
  /** `true` when the customer can use a boolean feature (or has a limit feature). */
97
- isEnabled: (customer: string, key: string, options?: RequestOptions) => Promise<boolean>;
131
+ isEnabled: (customer: string, key: string, options?: MemberOptions) => Promise<boolean>;
98
132
  /** Every feature and its usage for one customer. */
99
- listForCustomer: (customer: string, options?: RequestOptions) => Promise<List<CustomerFeature>>;
133
+ listForCustomer: (customer: string, options?: MemberOptions) => Promise<List<CustomerFeature>>;
100
134
  /**
101
135
  * Atomically consumes `amount` units. When the limit would be exceeded nothing is consumed
102
136
  * and `allowed` is false, so it is safe to call right before doing the work.
103
137
  */
104
- consume: (customer: string, key: string, amount?: number, options?: RequestOptions) => Promise<FeatureUsageResult>;
105
- /** Gives back `amount` units (e.g. a folder was deleted). Usage never drops below zero. */
106
- release: (customer: string, key: string, amount?: number, options?: RequestOptions) => Promise<FeatureUsageResult>;
138
+ consume: (customer: string, key: string, amount?: number, options?: UsageOptions) => Promise<FeatureUsageResult & Partial<Pick<FeatureOperationResult, "created" | "operation">>>;
139
+ /**
140
+ * Gives back `amount` units of a `count` feature (e.g. a folder was deleted). Usage never drops
141
+ * below zero; metered usage is returned through its operation instead.
142
+ */
143
+ release: (customer: string, key: string, amount?: number, options?: MemberOptions) => Promise<FeatureUsageResult>;
107
144
  /** Reports the absolute current usage (e.g. the customer now has 7 folders). */
108
- set: (customer: string, key: string, value: number, options?: RequestOptions) => Promise<CustomerFeature>;
145
+ set: (customer: string, key: string, value: number, options?: MemberOptions) => Promise<CustomerFeature>;
109
146
  };
110
147
  coupons: {
111
148
  create: (input: CouponCreate, options?: RequestOptions) => Promise<Coupon>;
@@ -186,7 +223,15 @@ export declare function createBillete(options: BilleteOptions): {
186
223
  search?: string;
187
224
  sort?: ListSort<"created" | "amount">;
188
225
  }>) => AsyncGenerator<Subscription, any, any>;
189
- /** Cancels at period end by default; pass `{ atPeriodEnd: false }` to end it now. */
226
+ changes: {
227
+ /** Apply on renewal, or return a hosted checkout that applies only after payment. */
228
+ create: (id: string, input: SubscriptionChangeCreate, options?: RequestOptions) => Promise<SubscriptionChangeResult>;
229
+ preview: (id: string, input: SubscriptionChangePreviewInput, options?: RequestOptions) => Promise<SubscriptionChangePreview>;
230
+ };
231
+ /**
232
+ * Cancels at period end by default; pass `{ atPeriodEnd: false }` to end it now. With a
233
+ * fallback plan it moves to that free plan instead (`subscription.updated`), keeping its ID.
234
+ */
190
235
  cancel: (id: string, input?: SubscriptionCancel, options?: RequestOptions) => Promise<Subscription>;
191
236
  resume: (id: string, options?: RequestOptions) => Promise<Subscription>;
192
237
  };
@@ -273,4 +318,4 @@ export declare function createBillete(options: BilleteOptions): {
273
318
  /** The server client: what `createBillete` returns. */
274
319
  type Billete = ReturnType<typeof createBillete>;
275
320
  //#endregion
276
- export { type ACCOUNT_NUMBER_LENGTH, type API_ERROR_TYPES, type Actor, type Address, type AddressInput, type AfterCompletion, type AfterCompletionInput, type ApiErrorBody, type ApiErrorEnvelope, type ApiErrorType, type BILLING_MONTHS, type Balance, type BalanceAmount, type BankCode, type Billete, BilleteError, type BilleteOptions, type BillingMonths, type CANCELLATION_FEEDBACK, type CARRIERS, type CARRIER_TEST_SCENARIOS, type CHECKOUT_PURPOSES, type CURRENCIES, type CancellationFeedback, type Carrier, type CarrierOffice, type Checkout, type CheckoutCreate, type CheckoutItem, type CheckoutItemInput, type CheckoutPurpose, type ClientCheckoutPay, type ClientCheckoutUpdate, type ClientFulfillmentProblem, type ClientInvoicePay, type ClientLinkCheckout, type ClientPaymentCode, type ClientSubscriptionCancel, type ClientSubscriptionUpdate, type CollectInput, type CollectSettings, type Coupon, type CouponCreate, type CouponUpdate, type Currency, type CurrencyAvailability, type CustomField, type CustomFieldInput, type Customer, type CustomerCreate, type CustomerDetails, type CustomerFeature, type CustomerInput, type CustomerSession, type CustomerSessionCreate, type CustomerSubscription, type CustomerUpdate, type ENVIRONMENTS, type EVENT_TYPES, type Environment, type Event, type EventDataMap, type EventSelector, type EventType, type ExchangeRate, type FEATURE_TYPES, type FULFILLMENT_METHODS, type FULFILLMENT_STATUSES, type Feature, type FeatureCreate, type FeatureReset, type FeatureType, type FeatureUpdate, type FeatureUsageResult, type Fulfillment, type FulfillmentChoice, type FulfillmentInput, type FulfillmentMethod, type FulfillmentOption, type FulfillmentStatus, type FulfillmentTracking, type FulfillmentTrackingInput, type GRACE_PERIOD_DAYS, type GracePeriodDays, type INVOICE_REASONS, type INVOICE_STATUSES, type Invoice, type InvoiceCreate, type InvoiceLineInput, type InvoiceReason, type InvoiceStatus, type KEY_PATTERN, type LineItem, type List, type ListQuery, type ListSort, type MAX_QUANTITY, type MOBILE_PREFIXES, type Metadata, type MobilePrefix, type PAYMENT_FAILURE_CODES, type PAYMENT_STATUSES, type PRODUCT_CATEGORIES, type Payment, type PaymentAttempt, type PaymentFailure, type PaymentFailureCode, type PaymentInstructions, type PaymentLink, type PaymentLinkCreate, type PaymentLinkUpdate, type PaymentMethodField, type PaymentMethodOption, type PaymentNextAction, type PaymentSettlement, type PaymentStatus, type PaymentTestScenario, type Payout, type Plan, type PlanCheckoutCreate, type PlanCreate, type PlanFeatureValues, type PlanFeaturesInput, type PlanLinkCreate, type PlanPrice, type PlanPriceInput, type PlanUpdate, type PortalFeatures, type PortalSession, type PortalSessionCreate, type Product, type ProductCategory, type ProductCheckoutCreate, type ProductCreate, type ProductLinkCreate, type ProductUpdate, type ProductVariant, type PublicCheckout, type PublicFulfillment, type PublicInvoice, type PublicPaymentLink, type PublicPaymentState, type PublicPortal, type PublicReceipt, type RESET_FREQUENCIES, type RISK_LEVELS, type ReceiptReference, type ReceiptSend, type ReceiptSnapshot, type Refund, type RefundCreate, type RequestOptions, type ResetFrequency, type RetireInput, type Retirement, type RiskLevel, type SUBMIT_LABELS, type SUBSCRIPTION_STATUSES, type SubmitLabel, type Subscription, type SubscriptionCancel, type SubscriptionCreate, type SubscriptionRenewal, type SubscriptionStatus, type SubscriptionUpdate, type TAX_BEHAVIORS, type TaxBehavior, type Timestamp, type TokenKind, type TransportOptions, type USAGE_FEATURE_TYPES, type VENEZUELAN_BANKS, type VariantInput, type WebhookEndpoint, type WebhookEndpointCreate, type WebhookEndpointUpdate, type WebhookEvent, WebhookVerificationError, type Weekday, type findBank, type isLandlinePhone, type isMobilePhone, type nationalPhone, type tokenEnvironment, type tokenPrefix, verifyWebhook };
321
+ export { type ACCOUNT_NUMBER_LENGTH, type API_ERROR_TYPES, type API_VERSIONS, type API_VERSION_HEADER, type API_VERSION_PATTERN, type Actor, type Address, type AddressInput, type AfterCompletion, type AfterCompletionInput, type ApiErrorBody, type ApiErrorEnvelope, type ApiErrorType, type ApiVersion, type ApiVersionLifecycle, type ApiVersionStage, type BILLING_MONTHS, type Balance, type BalanceAmount, type BankCode, type Billete, BilleteError, type BilleteOptions, type BillingMonths, type CANCELLATION_FEEDBACK, type CARRIERS, type CARRIER_TEST_SCENARIOS, type CHECKOUT_PURPOSES, type CURRENCIES, type CancellationFeedback, type Carrier, type CarrierOffice, type Checkout, type CheckoutCreate, type CheckoutItem, type CheckoutItemInput, type CheckoutPurpose, type ClientCheckoutPay, type ClientCheckoutUpdate, type ClientFulfillmentProblem, type ClientInvoicePay, type ClientLinkCheckout, type ClientPaymentCode, type ClientSubscriptionCancel, type ClientSubscriptionUpdate, type CollectInput, type CollectSettings, type Coupon, type CouponCreate, type CouponUpdate, type Currency, type CurrencyAvailability, type CustomField, type CustomFieldInput, type Customer, type CustomerCreate, type CustomerDetails, type CustomerFeature, type CustomerInput, type CustomerMember, type CustomerMemberCreate, type CustomerMemberList, type CustomerMemberUpdate, type CustomerSession, type CustomerSessionCreate, type CustomerSubscription, type CustomerUpdate, type ENVIRONMENTS, type EVENT_TYPES, type Environment, type Event, type EventDataMap, type EventSelector, type EventType, type ExchangeRate, type FEATURE_TYPES, type FULFILLMENT_METHODS, type FULFILLMENT_STATUSES, type Feature, type FeatureCreate, type FeatureOperation, type FeatureOperationCommit, type FeatureOperationCreate, type FeatureOperationResult, type FeatureReset, type FeatureType, type FeatureUpdate, type FeatureUsageResult, type Fulfillment, type FulfillmentChoice, type FulfillmentInput, type FulfillmentMethod, type FulfillmentOption, type FulfillmentStatus, type FulfillmentTracking, type FulfillmentTrackingInput, type GRACE_PERIOD_DAYS, type GracePeriodDays, type INVOICE_REASONS, type INVOICE_STATUSES, type Invoice, type InvoiceCreate, type InvoiceLineInput, type InvoiceReason, type InvoiceStatus, type KEY_PATTERN, type LATEST_API_VERSION, type LatestApiVersion, type LineItem, type List, type ListQuery, type ListSort, type MAX_QUANTITY, type MAX_SEATS, type MOBILE_PREFIXES, type Metadata, type MobilePrefix, type PAYMENT_FAILURE_CODES, type PAYMENT_STATUSES, type PRODUCT_CATEGORIES, type Payment, type PaymentAttempt, type PaymentFailure, type PaymentFailureCode, type PaymentInstructions, type PaymentLink, type PaymentLinkCreate, type PaymentLinkUpdate, type PaymentMethodField, type PaymentMethodOption, type PaymentNextAction, type PaymentSettlement, type PaymentStatus, type PaymentTestScenario, type Payout, type Plan, type PlanCheckoutCreate, type PlanCreate, type PlanFeatureValues, type PlanFeaturesInput, type PlanLinkCreate, type PlanPrice, type PlanPriceInput, type PlanSeats, type PlanUpdate, type PortalFeatures, type PortalSession, type PortalSessionCreate, type Product, type ProductCategory, type ProductCheckoutCreate, type ProductCreate, type ProductLinkCreate, type ProductUpdate, type ProductVariant, type PublicCheckout, type PublicFulfillment, type PublicInvoice, type PublicPaymentLink, type PublicPaymentState, type PublicPortal, type RESET_FREQUENCIES, type RISK_LEVELS, type ReceiptReference, type ReceiptSend, type Refund, type RefundCreate, type RequestOptions, type ResetFrequency, type RetireInput, type Retirement, type RiskLevel, type SUBMIT_LABELS, type SUBSCRIPTION_STATUSES, type SubmitLabel, type Subscription, type SubscriptionCancel, type SubscriptionChange, type SubscriptionChangeCreate, type SubscriptionChangePreview, type SubscriptionChangePreviewInput, type SubscriptionChangeResult, type SubscriptionCreate, type SubscriptionRenewal, type SubscriptionStatus, type SubscriptionTerms, type SubscriptionUpdate, type TAX_BEHAVIORS, type TaxBehavior, type Timestamp, type TokenKind, type TransportOptions, type USAGE_FEATURE_TYPES, type VENEZUELAN_BANKS, type VariantInput, type WebhookEndpoint, type WebhookEndpointCreate, type WebhookEndpointUpdate, type WebhookEvent, WebhookVerificationError, type Weekday, type apiVersionLifecycle, type apiVersionStage, type currentApiVersion, type findBank, type isApiVersion, type isApiVersionRetired, type isLandlinePhone, type isMobilePhone, type nationalPhone, type supportedApiVersions, type tokenEnvironment, type tokenPrefix, verifyWebhook };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as segment, r as BilleteError, t as createTransport } from "./http-Dp-Du1QO.js";
1
+ import { n as segment, r as BilleteError, t as createTransport } from "./http-CgBMbPS2.js";
2
2
  import { WebhookVerificationError, verifyWebhook } from "./webhooks.js";
3
3
  //#region ../contracts/src/environment.ts
4
4
  /**
@@ -63,7 +63,8 @@ function fromEnv(name) {
63
63
  * Server-side Billete client. Works in any runtime with `fetch` (Node, Bun, Deno, edge).
64
64
  *
65
65
  * ```ts
66
- * const billete = createBillete({ environment: "test" }); // reads BILLETE_API_KEY
66
+ * // Reads BILLETE_API_KEY.
67
+ * const billete = createBillete({ apiVersion: "2026-10-08", environment: "test" });
67
68
  * const { allowed } = await billete.features.consume("user_123", "tokens", 850);
68
69
  * ```
69
70
  */
@@ -80,6 +81,38 @@ function createBillete(options) {
80
81
  token: () => apiKey
81
82
  });
82
83
  const customers = collection(http, "/v1/customers");
84
+ const memberPath = (customer) => `/v1/customers/${segment(customer)}/members`;
85
+ const members = {
86
+ list: (customer, query = {}, options) => http.request({
87
+ method: "GET",
88
+ path: memberPath(customer),
89
+ query,
90
+ options
91
+ }),
92
+ /** Re-adding a removed externalId restores its member ID and keeps its usage. */
93
+ create: (customer, input, options) => http.request({
94
+ method: "POST",
95
+ path: memberPath(customer),
96
+ body: input,
97
+ options
98
+ }),
99
+ retrieve: (customer, member, options) => http.request({
100
+ method: "GET",
101
+ path: `${memberPath(customer)}/${segment(member)}`,
102
+ options
103
+ }),
104
+ update: (customer, member, input, options) => http.request({
105
+ method: "PATCH",
106
+ path: `${memberPath(customer)}/${segment(member)}`,
107
+ body: input,
108
+ options
109
+ }),
110
+ remove: (customer, member, options) => http.request({
111
+ method: "DELETE",
112
+ path: `${memberPath(customer)}/${segment(member)}`,
113
+ options
114
+ })
115
+ };
83
116
  const customerSessions = {
84
117
  /** Short-lived token for the client SDK to read one customer's billing state. */
85
118
  create: (input, options) => http.request({
@@ -122,24 +155,70 @@ create: (input, options) => http.request({
122
155
  })
123
156
  };
124
157
  const customerFeature = (customer, key) => `/v1/customers/${segment(customer)}/features/${segment(key)}`;
158
+ const featureCrud = collection(http, "/v1/features");
159
+ const operationPath = (operation, action) => `/v1/feature-operations/${segment(operation)}${action ? `/${action}` : ""}`;
125
160
  const features = {
126
- ...collection(http, "/v1/features"),
161
+ ...featureCrud,
162
+ /**
163
+ * Reserves `amount` of a metered feature for one job: it counts as used right away and the
164
+ * operation is closed later through `features.operations`. Repeating `operation` returns the
165
+ * same reservation without consuming again; running each job once is your queue's job.
166
+ */
167
+ reserve: (customer, key, amount, input, options) => http.request({
168
+ method: "POST",
169
+ path: `${customerFeature(customer, key)}/operations`,
170
+ body: {
171
+ ...input,
172
+ amount
173
+ },
174
+ options
175
+ }),
176
+ /** Closes reservations. Each call is idempotent, so retry it on doubt instead of releasing. */
177
+ operations: {
178
+ retrieve: (operation, options) => http.request({
179
+ method: "GET",
180
+ path: operationPath(operation),
181
+ options
182
+ }),
183
+ /** Confirms what the job used (all by default) and returns the rest. */
184
+ commit: (operation, input = {}, options) => http.request({
185
+ method: "POST",
186
+ path: operationPath(operation, "commit"),
187
+ body: input,
188
+ options
189
+ }),
190
+ /** Returns a reservation whose job failed. */
191
+ release: (operation, options) => http.request({
192
+ method: "POST",
193
+ path: operationPath(operation, "release"),
194
+ options
195
+ }),
196
+ /** Returns everything a committed operation used, to the period it was counted in. */
197
+ refund: (operation, options) => http.request({
198
+ method: "POST",
199
+ path: operationPath(operation, "refund"),
200
+ options
201
+ })
202
+ },
127
203
  /** Current access to one feature. `customer` is a `cus_…` ID or your own `externalId`. */
128
204
  check: (customer, key, options) => http.request({
129
205
  method: "GET",
130
206
  path: customerFeature(customer, key),
207
+ query: { member: options?.member },
131
208
  options
132
209
  }),
133
210
  /** `true` when the customer can use a boolean feature (or has a limit feature). */
134
211
  isEnabled: async (customer, key, options) => (await http.request({
135
212
  method: "GET",
136
213
  path: customerFeature(customer, key),
214
+ query: { member: options?.member },
137
215
  options
138
216
  })).enabled,
139
217
  /** Every feature and its usage for one customer. */
140
218
  listForCustomer: (customer, options) => http.request({
141
219
  method: "GET",
142
220
  path: `/v1/customers/${segment(customer)}/features`,
221
+ query: { member: options?.member },
143
222
  options
144
223
  }),
145
224
  /**
@@ -149,21 +228,34 @@ create: (input, options) => http.request({
149
228
  consume: (customer, key, amount = 1, options) => http.request({
150
229
  method: "POST",
151
230
  path: `${customerFeature(customer, key)}/usage`,
152
- body: { delta: amount },
231
+ body: {
232
+ delta: amount,
233
+ member: options?.member,
234
+ operation: options?.operation
235
+ },
153
236
  options
154
237
  }),
155
- /** Gives back `amount` units (e.g. a folder was deleted). Usage never drops below zero. */
238
+ /**
239
+ * Gives back `amount` units of a `count` feature (e.g. a folder was deleted). Usage never drops
240
+ * below zero; metered usage is returned through its operation instead.
241
+ */
156
242
  release: (customer, key, amount = 1, options) => http.request({
157
243
  method: "POST",
158
244
  path: `${customerFeature(customer, key)}/usage`,
159
- body: { delta: -amount },
245
+ body: {
246
+ delta: -amount,
247
+ member: options?.member
248
+ },
160
249
  options
161
250
  }),
162
251
  /** Reports the absolute current usage (e.g. the customer now has 7 folders). */
163
252
  set: (customer, key, value, options) => http.request({
164
253
  method: "PUT",
165
254
  path: `${customerFeature(customer, key)}/usage`,
166
- body: { value },
255
+ body: {
256
+ value,
257
+ member: options?.member
258
+ },
167
259
  options
168
260
  })
169
261
  };
@@ -195,7 +287,25 @@ create: (input, options) => http.request({
195
287
  };
196
288
  const subscriptions = {
197
289
  ...collection(http, "/v1/subscriptions"),
198
- /** Cancels at period end by default; pass `{ atPeriodEnd: false }` to end it now. */
290
+ changes: {
291
+ /** Apply on renewal, or return a hosted checkout that applies only after payment. */
292
+ create: (id, input, options) => http.request({
293
+ method: "POST",
294
+ path: `/v1/subscriptions/${segment(id)}/changes`,
295
+ body: input,
296
+ options
297
+ }),
298
+ preview: (id, input, options) => http.request({
299
+ method: "POST",
300
+ path: `/v1/subscriptions/${segment(id)}/changes/preview`,
301
+ body: input,
302
+ options
303
+ })
304
+ },
305
+ /**
306
+ * Cancels at period end by default; pass `{ atPeriodEnd: false }` to end it now. With a
307
+ * fallback plan it moves to that free plan instead (`subscription.updated`), keeping its ID.
308
+ */
199
309
  cancel: (id, input = {}, options) => http.request({
200
310
  method: "POST",
201
311
  path: `/v1/subscriptions/${segment(id)}/cancel`,
@@ -273,6 +383,7 @@ create: (input, options) => http.request({
273
383
  const eventCrud = collection(http, "/v1/events");
274
384
  return {
275
385
  customers,
386
+ members,
276
387
  customerSessions,
277
388
  portalSessions,
278
389
  products,
@@ -1,4 +1,4 @@
1
- import { i as WebhookEvent } from "./events-kvUK9zvS.js";
1
+ import { i as WebhookEvent } from "./events-CrmMdwBX.js";
2
2
  //#region src/webhooks.d.ts
3
3
  export declare class WebhookVerificationError extends Error {
4
4
  constructor(message: string);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boelabs/billete-sdk",
3
- "version": "1.1.0-canary.5",
3
+ "version": "2.0.0",
4
4
  "description": "Billete SDK: server client, browser client and webhook verification",
5
5
  "keywords": [
6
6
  "billete",