@boelabs/billete-sdk 1.1.0-canary.6 → 3.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 +7 -2
- package/dist/client.d.ts +10 -5
- package/dist/client.js +13 -3
- package/dist/{errors-De_fISnn.d.ts → errors-BRQlJDjy.d.ts} +123 -6
- package/dist/{events-Dz2ghaMl.d.ts → events-rtkF8fBQ.d.ts} +25 -2
- package/dist/{http-DNd4UhbT.js → http-PMxK43GM.js} +3 -1
- package/dist/index.d.ts +9 -6
- package/dist/index.js +7 -2
- package/dist/webhooks.d.ts +1 -1
- package/package.json +1 -1
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-09", 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-09",
|
|
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-09", 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
|
|
2
|
-
import { $ as
|
|
1
|
+
import { $ as SubscriptionChangePreviewInput, A as FeatureUpdate, At as currentApiVersion, B as PlanFeaturesInput, C as CustomerMemberUpdate, Ct as ApiVersion, D as FeatureCreate, Dt as LatestApiVersion, E as EventSelector, Et as LATEST_API_VERSION, F as KEY_PATTERN, G as ProductCheckoutCreate, H as PlanPriceInput, I as PaymentLinkCreate, J as ProductUpdate, K as ProductCreate, L as PaymentLinkUpdate, M as FulfillmentTrackingInput, Mt as isApiVersionRetired, N as InvoiceCreate, Nt as supportedApiVersions, O as FeatureOperationCommit, Ot as apiVersionLifecycle, P as InvoiceLineInput, Q as SubscriptionChangeCreate, R as PlanCheckoutCreate, S as CustomerMemberCreate, St as API_VERSION_PATTERN, T as CustomerUpdate, Tt as ApiVersionStage, U as PlanUpdate, V as PlanLinkCreate, W as PortalSessionCreate, X as RetireInput, Y as RefundCreate, Z as SubscriptionCancel, _ as CouponCreate, _t as PublicPaymentLink, a as CheckoutCreate, at as CustomerSubscription, b as CustomerCreate, bt as API_VERSIONS, c as ClientCheckoutUpdate, ct as PaymentInstructions, d as ClientLinkCheckout, dt as PaymentNextAction, et as SubscriptionCreate, f as ClientPaymentCode, ft as PaymentTestScenario, g as CollectInput, gt as PublicInvoice, h as ClientSubscriptionUpdate, ht as PublicFulfillment, i as AfterCompletionInput, it as WebhookEndpointUpdate, j as FulfillmentInput, jt as isApiVersion, k as FeatureOperationCreate, kt as apiVersionStage, l as ClientFulfillmentProblem, lt as PaymentMethodField, m as ClientSubscriptionSeats, mt as PublicCheckout, n as RequestOptions, nt as VariantInput, o as CheckoutItemInput, ot as CustomerSubscriptionChangeResult, p as ClientSubscriptionCancel, pt as PortalFeatures, q as ProductLinkCreate, r as TransportOptions, rt as WebhookEndpointCreate, s as ClientCheckoutPay, st as FulfillmentOption, t as BilleteError, tt as SubscriptionUpdate, u as ClientInvoicePay, ut as PaymentMethodOption, v as CouponUpdate, vt as PublicPaymentState, w as CustomerSessionCreate, wt as ApiVersionLifecycle, x as CustomerInput, xt as API_VERSION_HEADER, y as CustomFieldInput, yt as PublicPortal, z as PlanCreate } from "./errors-BRQlJDjy.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-rtkF8fBQ.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-09", 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
|
|
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: {
|
|
@@ -94,6 +94,11 @@ export declare function createClient(options?: ClientOptions): {
|
|
|
94
94
|
resumeSubscription: (id: string, options?: RequestOptions) => Promise<CustomerSubscription>;
|
|
95
95
|
/** Switches the billing cycle from the next renewal. */
|
|
96
96
|
updateSubscription: (id: string, input: ClientSubscriptionUpdate, options?: RequestOptions) => Promise<CustomerSubscription>;
|
|
97
|
+
/**
|
|
98
|
+
* Buys more seats now, paid in the checkout it returns (`type: "checkout"`), or leaves fewer
|
|
99
|
+
* from the next renewal; during a trial both apply now. Only for plans charged per seat.
|
|
100
|
+
*/
|
|
101
|
+
changeSeats: (id: string, input: ClientSubscriptionSeats, options?: RequestOptions) => Promise<CustomerSubscriptionChangeResult>;
|
|
97
102
|
/** Withdraws the mandate: renewals are then paid by hand from their Cobro. */
|
|
98
103
|
stopAutoCharge: (id: string, options?: RequestOptions) => Promise<CustomerSubscription>;
|
|
99
104
|
features: (options?: RequestOptions) => Promise<List<CustomerFeature>>;
|
|
@@ -102,4 +107,4 @@ export declare function createClient(options?: ClientOptions): {
|
|
|
102
107
|
};
|
|
103
108
|
type BilleteClient = ReturnType<typeof createClient>;
|
|
104
109
|
//#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 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 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 findBank, type isLandlinePhone, type isMobilePhone, type nationalPhone, type tokenEnvironment, type tokenPrefix };
|
|
110
|
+
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 ClientSubscriptionSeats, 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 CustomerSubscriptionChangeResult, 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-
|
|
1
|
+
import { n as segment, r as BilleteError, t as createTransport } from "./http-PMxK43GM.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-DN
|
|
|
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-09", 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,
|
|
@@ -195,6 +195,16 @@ list: (options) => http.request({
|
|
|
195
195
|
body: input,
|
|
196
196
|
options
|
|
197
197
|
}),
|
|
198
|
+
/**
|
|
199
|
+
* Buys more seats now, paid in the checkout it returns (`type: "checkout"`), or leaves fewer
|
|
200
|
+
* from the next renewal; during a trial both apply now. Only for plans charged per seat.
|
|
201
|
+
*/
|
|
202
|
+
changeSeats: (id, input, options) => http.request({
|
|
203
|
+
method: "POST",
|
|
204
|
+
path: `/v1/client/customer/subscriptions/${segment(id)}/seats`,
|
|
205
|
+
body: input,
|
|
206
|
+
options
|
|
207
|
+
}),
|
|
198
208
|
/** Withdraws the mandate: renewals are then paid by hand from their Cobro. */
|
|
199
209
|
stopAutoCharge: (id, options) => http.request({
|
|
200
210
|
method: "POST",
|
|
@@ -1,4 +1,48 @@
|
|
|
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-
|
|
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-rtkF8fBQ.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", "2026-10-09"];
|
|
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
|
|
@@ -8,8 +52,20 @@ interface CustomerSubscription extends Omit<Subscription, "metadata"> {
|
|
|
8
52
|
plan: {
|
|
9
53
|
name: string;
|
|
10
54
|
cycles: PlanPrice[];
|
|
55
|
+
seats: PlanSeats;
|
|
11
56
|
};
|
|
12
57
|
}
|
|
58
|
+
/** What a customer's change from the portal did: applied, scheduled, or a checkout to pay it. */
|
|
59
|
+
type CustomerSubscriptionChangeResult = {
|
|
60
|
+
type: "applied" | "scheduled";
|
|
61
|
+
subscription: CustomerSubscription;
|
|
62
|
+
} | {
|
|
63
|
+
type: "checkout";
|
|
64
|
+
checkout: {
|
|
65
|
+
id: string;
|
|
66
|
+
url: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
13
69
|
/** What the business lets its customers do from the portal. */
|
|
14
70
|
interface PortalFeatures {
|
|
15
71
|
/** Paid and closed Cobros are listed; open ones always are, so they can be paid. */
|
|
@@ -20,6 +76,8 @@ interface PortalFeatures {
|
|
|
20
76
|
cancellationReasons: boolean;
|
|
21
77
|
/** Switch between the plan's billing cycles, from the next renewal. */
|
|
22
78
|
switchCycle: boolean;
|
|
79
|
+
/** Buy more seats of a plan charged per seat, or fewer from the next renewal. */
|
|
80
|
+
changeSeats: boolean;
|
|
23
81
|
/** Turn off automatic charging and pay each renewal by hand. */
|
|
24
82
|
stopAutoCharge: boolean;
|
|
25
83
|
}
|
|
@@ -129,9 +187,14 @@ interface PublicCheckout {
|
|
|
129
187
|
trialDays: number | null;
|
|
130
188
|
couponCode: string | null;
|
|
131
189
|
allowCoupons: boolean;
|
|
132
|
-
/** The customer may change the quantity of the single item. */
|
|
190
|
+
/** The customer may change the quantity of the single item: units, or seats of a plan. */
|
|
133
191
|
adjustableQuantity: boolean;
|
|
134
|
-
/**
|
|
192
|
+
/** Fewest units the customer can choose: 1, or the plan's minimum seats. */
|
|
193
|
+
minQuantity: number;
|
|
194
|
+
/**
|
|
195
|
+
* Most units the customer can choose right now: the link's limit, capped by stock, or the
|
|
196
|
+
* plan's maximum seats.
|
|
197
|
+
*/
|
|
135
198
|
maxQuantity: number;
|
|
136
199
|
/**
|
|
137
200
|
* Variants the customer may switch between for a product checkout. `maxQuantity` is the most
|
|
@@ -350,9 +413,15 @@ interface PublicPaymentLink {
|
|
|
350
413
|
trialDays: number;
|
|
351
414
|
cycles: PlanPrice[];
|
|
352
415
|
} | null;
|
|
353
|
-
/**
|
|
416
|
+
/**
|
|
417
|
+
* The customer chooses how many units to buy, or how many seats of a plan charged per seat;
|
|
418
|
+
* otherwise every purchase is one unit, or the plan's minimum seats.
|
|
419
|
+
*/
|
|
354
420
|
adjustableQuantity: boolean;
|
|
355
|
-
/**
|
|
421
|
+
/**
|
|
422
|
+
* Most units (or seats) per purchase when `adjustableQuantity`; `null` leaves stock (or the
|
|
423
|
+
* plan's maximum) as the only limit.
|
|
424
|
+
*/
|
|
356
425
|
maxQuantity: number | null;
|
|
357
426
|
/** Effective required details; fulfillment adds name and phone to the saved preferences. */
|
|
358
427
|
collect: CollectSettings;
|
|
@@ -383,10 +452,16 @@ interface CustomerUpdate {
|
|
|
383
452
|
interface CustomerMemberCreate {
|
|
384
453
|
externalId: string;
|
|
385
454
|
name?: string;
|
|
455
|
+
/**
|
|
456
|
+
* Takes a seat before the others when there are fewer seats than active members (the
|
|
457
|
+
* organization's admin, say). Defaults to `false`.
|
|
458
|
+
*/
|
|
459
|
+
priority?: boolean;
|
|
386
460
|
metadata?: Metadata;
|
|
387
461
|
}
|
|
388
462
|
interface CustomerMemberUpdate {
|
|
389
463
|
name?: string | null;
|
|
464
|
+
priority?: boolean;
|
|
390
465
|
metadata?: Metadata;
|
|
391
466
|
}
|
|
392
467
|
interface FeatureOperationCreate {
|
|
@@ -537,9 +612,19 @@ interface SubscriptionChangePreviewInput {
|
|
|
537
612
|
plan?: string;
|
|
538
613
|
months?: BillingMonths;
|
|
539
614
|
quantity?: number;
|
|
615
|
+
/**
|
|
616
|
+
* During a trial a change made `now` applies at no cost and the trial goes on; `true` ends the
|
|
617
|
+
* trial instead and charges the new terms from today.
|
|
618
|
+
*/
|
|
619
|
+
endTrial?: boolean;
|
|
540
620
|
}
|
|
541
621
|
interface SubscriptionChangeCreate extends SubscriptionChangePreviewInput {
|
|
542
622
|
when: "now" | "renewal";
|
|
623
|
+
/**
|
|
624
|
+
* Accepts a change that leaves fewer seats than active members: the ones without a seat lose
|
|
625
|
+
* access (`enabled: false`) until seats free up. Otherwise it fails with `seats_in_use`.
|
|
626
|
+
*/
|
|
627
|
+
disableExcessMembers?: boolean;
|
|
543
628
|
acceptUnusedCredit?: boolean;
|
|
544
629
|
successUrl?: string;
|
|
545
630
|
cancelUrl?: string;
|
|
@@ -615,6 +700,13 @@ interface PlanLinkCreate extends PaymentLinkFields {
|
|
|
615
700
|
type: "plan";
|
|
616
701
|
plan: string;
|
|
617
702
|
months?: BillingMonths[];
|
|
703
|
+
/**
|
|
704
|
+
* Lets the customer choose how many seats to buy, within the plan's range; only for plans
|
|
705
|
+
* charged per seat. Defaults to the plan's minimum.
|
|
706
|
+
*/
|
|
707
|
+
adjustableQuantity?: boolean;
|
|
708
|
+
/** Most seats per purchase; only with `adjustableQuantity`. Omit to allow the plan's maximum. */
|
|
709
|
+
maxQuantity?: number;
|
|
618
710
|
}
|
|
619
711
|
type PaymentLinkCreate = ProductLinkCreate | PlanLinkCreate;
|
|
620
712
|
interface PaymentLinkUpdate {
|
|
@@ -650,7 +742,14 @@ interface ProductCheckoutCreate extends CheckoutFields {
|
|
|
650
742
|
items: CheckoutItemInput[];
|
|
651
743
|
}
|
|
652
744
|
interface PlanCheckoutCreate extends CheckoutFields {
|
|
745
|
+
/** Seats of a plan charged per seat; fixed unless `adjustableQuantity`. */
|
|
653
746
|
quantity?: number;
|
|
747
|
+
/**
|
|
748
|
+
* Lets the customer choose the seats in the checkout, within the plan's range, starting at
|
|
749
|
+
* `quantity` (or the plan's minimum). Defaults to `true` for a plan charged per seat when
|
|
750
|
+
* `quantity` is omitted.
|
|
751
|
+
*/
|
|
752
|
+
adjustableQuantity?: boolean;
|
|
654
753
|
plan: string;
|
|
655
754
|
months: BillingMonths;
|
|
656
755
|
}
|
|
@@ -705,11 +804,15 @@ type EventSelector = "*" | EventType;
|
|
|
705
804
|
interface WebhookEndpointCreate {
|
|
706
805
|
url: string;
|
|
707
806
|
events: EventSelector[];
|
|
807
|
+
/** Version its events are delivered in. Defaults to the version of the request. */
|
|
808
|
+
apiVersion?: ApiVersion;
|
|
708
809
|
}
|
|
709
810
|
interface WebhookEndpointUpdate {
|
|
710
811
|
url?: string;
|
|
711
812
|
events?: EventSelector[];
|
|
712
813
|
enabled?: boolean;
|
|
814
|
+
/** Moves the endpoint to another supported version; its next deliveries use it. */
|
|
815
|
+
apiVersion?: ApiVersion;
|
|
713
816
|
}
|
|
714
817
|
interface CustomerSessionCreate {
|
|
715
818
|
customer: string;
|
|
@@ -724,6 +827,13 @@ interface PortalSessionCreate {
|
|
|
724
827
|
interface ClientSubscriptionUpdate {
|
|
725
828
|
months: BillingMonths;
|
|
726
829
|
}
|
|
830
|
+
/**
|
|
831
|
+
* The seats a customer wants from the portal: more are paid now for what is left of the period;
|
|
832
|
+
* fewer apply from the next renewal (during a trial, both apply now).
|
|
833
|
+
*/
|
|
834
|
+
interface ClientSubscriptionSeats {
|
|
835
|
+
quantity: number;
|
|
836
|
+
}
|
|
727
837
|
interface ClientCheckoutUpdate {
|
|
728
838
|
quantity?: number;
|
|
729
839
|
variant?: string;
|
|
@@ -776,6 +886,13 @@ interface ClientFulfillmentProblem {
|
|
|
776
886
|
//#endregion
|
|
777
887
|
//#region src/http.d.ts
|
|
778
888
|
interface TransportOptions {
|
|
889
|
+
/**
|
|
890
|
+
* The Billete API version your integration is written against. Required: Billete never changes
|
|
891
|
+
* a published version, so your integration keeps working until you choose to upgrade. Each SDK
|
|
892
|
+
* release speaks exactly one version; upgrading the SDK to a new major asks you to set the new
|
|
893
|
+
* one after reading what changed.
|
|
894
|
+
*/
|
|
895
|
+
apiVersion: LatestApiVersion;
|
|
779
896
|
/** Defaults to `BILLETE_BASE_URL` on the server, then `https://api.billete.run`. Use
|
|
780
897
|
* `http://localhost:9999` in development. */
|
|
781
898
|
baseUrl?: string;
|
|
@@ -804,4 +921,4 @@ declare class BilleteError extends Error {
|
|
|
804
921
|
}, status: number);
|
|
805
922
|
}
|
|
806
923
|
//#endregion
|
|
807
|
-
export {
|
|
924
|
+
export { SubscriptionChangePreviewInput as $, FeatureUpdate as A, currentApiVersion as At, PlanFeaturesInput as B, CustomerMemberUpdate as C, ApiVersion as Ct, FeatureCreate as D, LatestApiVersion as Dt, EventSelector as E, LATEST_API_VERSION as Et, KEY_PATTERN as F, ProductCheckoutCreate as G, PlanPriceInput as H, PaymentLinkCreate as I, ProductUpdate as J, ProductCreate as K, PaymentLinkUpdate as L, FulfillmentTrackingInput as M, isApiVersionRetired as Mt, InvoiceCreate as N, supportedApiVersions as Nt, FeatureOperationCommit as O, apiVersionLifecycle as Ot, InvoiceLineInput as P, SubscriptionChangeCreate as Q, PlanCheckoutCreate as R, CustomerMemberCreate as S, API_VERSION_PATTERN as St, CustomerUpdate as T, ApiVersionStage as Tt, PlanUpdate as U, PlanLinkCreate as V, PortalSessionCreate as W, RetireInput as X, RefundCreate as Y, SubscriptionCancel as Z, CouponCreate as _, PublicPaymentLink as _t, CheckoutCreate as a, CustomerSubscription as at, CustomerCreate as b, API_VERSIONS as bt, ClientCheckoutUpdate as c, PaymentInstructions as ct, ClientLinkCheckout as d, PaymentNextAction as dt, SubscriptionCreate as et, ClientPaymentCode as f, PaymentTestScenario as ft, CollectInput as g, PublicInvoice as gt, ClientSubscriptionUpdate as h, PublicFulfillment as ht, AfterCompletionInput as i, WebhookEndpointUpdate as it, FulfillmentInput as j, isApiVersion as jt, FeatureOperationCreate as k, apiVersionStage as kt, ClientFulfillmentProblem as l, PaymentMethodField as lt, ClientSubscriptionSeats as m, PublicCheckout as mt, RequestOptions as n, VariantInput as nt, CheckoutItemInput as o, CustomerSubscriptionChangeResult as ot, ClientSubscriptionCancel as p, PortalFeatures as pt, ProductLinkCreate as q, TransportOptions as r, WebhookEndpointCreate as rt, ClientCheckoutPay as s, FulfillmentOption as st, BilleteError as t, SubscriptionUpdate as tt, ClientInvoicePay as u, PaymentMethodOption as ut, CouponUpdate as v, PublicPaymentState as vt, CustomerSessionCreate as w, ApiVersionLifecycle as wt, CustomerInput as x, API_VERSION_HEADER as xt, CustomFieldInput as y, PublicPortal as yt, PlanCreate as z };
|
|
@@ -304,6 +304,9 @@ interface CustomerMember extends Resource<"customer_member"> {
|
|
|
304
304
|
externalId: string;
|
|
305
305
|
name: string | null;
|
|
306
306
|
status: "active" | "removed";
|
|
307
|
+
/** Takes a seat before members without priority; then the longest active go first. */
|
|
308
|
+
priority: boolean;
|
|
309
|
+
/** Active and within the seats: what the customer's subscriptions grant all add up. */
|
|
307
310
|
enabled: boolean;
|
|
308
311
|
activeSince: Timestamp;
|
|
309
312
|
removedAt: Timestamp | null;
|
|
@@ -590,9 +593,15 @@ interface PaymentLink extends Resource<"payment_link">, Retirement {
|
|
|
590
593
|
productId: string | null;
|
|
591
594
|
/** Variants offered for a product link; `null` offers every active variant. */
|
|
592
595
|
variantIds: string[] | null;
|
|
593
|
-
/**
|
|
596
|
+
/**
|
|
597
|
+
* The customer chooses how many units to buy, or how many seats of a plan charged per seat;
|
|
598
|
+
* otherwise every purchase is one unit, or the plan's minimum seats.
|
|
599
|
+
*/
|
|
594
600
|
adjustableQuantity: boolean;
|
|
595
|
-
/**
|
|
601
|
+
/**
|
|
602
|
+
* Most units (or seats) per purchase when `adjustableQuantity`; `null` leaves stock (or the
|
|
603
|
+
* plan's maximum) as the only limit.
|
|
604
|
+
*/
|
|
596
605
|
maxQuantity: number | null;
|
|
597
606
|
planId: string | null;
|
|
598
607
|
/** Billing cycles offered for a plan link; `null` offers every plan price. */
|
|
@@ -700,6 +709,11 @@ interface SubscriptionChangePreview {
|
|
|
700
709
|
version: number;
|
|
701
710
|
currentPeriodEnd: Timestamp;
|
|
702
711
|
periodEndIfPaidNow?: Timestamp;
|
|
712
|
+
/**
|
|
713
|
+
* Active members the change leaves without a seat: remove them first, or accept it with
|
|
714
|
+
* `disableExcessMembers`.
|
|
715
|
+
*/
|
|
716
|
+
excessMembers: number;
|
|
703
717
|
}
|
|
704
718
|
type SubscriptionChangeResult = {
|
|
705
719
|
type: "scheduled" | "applied";
|
|
@@ -983,12 +997,19 @@ interface Payout extends Resource<"payout"> {
|
|
|
983
997
|
interface WebhookEndpoint extends Resource<"webhook_endpoint"> {
|
|
984
998
|
url: string;
|
|
985
999
|
events: string[];
|
|
1000
|
+
/**
|
|
1001
|
+
* Version its events are delivered in. Typed as text: responses never change shape when new
|
|
1002
|
+
* versions are published.
|
|
1003
|
+
*/
|
|
1004
|
+
apiVersion: string;
|
|
986
1005
|
enabled: boolean;
|
|
987
1006
|
/** Returned only when the endpoint is created. */
|
|
988
1007
|
secret?: string;
|
|
989
1008
|
}
|
|
990
1009
|
interface Event<TData = Record<string, unknown>> extends Resource<"event"> {
|
|
991
1010
|
type: string;
|
|
1011
|
+
/** The version whose shape `data` is in: the request's, or the webhook endpoint's. */
|
|
1012
|
+
apiVersion: string;
|
|
992
1013
|
data: TData;
|
|
993
1014
|
}
|
|
994
1015
|
interface ExchangeRate {
|
|
@@ -1080,6 +1101,8 @@ type WebhookEvent = { [TType in EventType]: {
|
|
|
1080
1101
|
id: string;
|
|
1081
1102
|
object: "event";
|
|
1082
1103
|
type: TType;
|
|
1104
|
+
/** The webhook endpoint's version: `data` comes in its shape. */
|
|
1105
|
+
apiVersion: string;
|
|
1083
1106
|
environment: Environment;
|
|
1084
1107
|
createdAt: string;
|
|
1085
1108
|
data: EventDataMap[TType];
|
|
@@ -18,7 +18,7 @@ var BilleteError = class extends Error {
|
|
|
18
18
|
};
|
|
19
19
|
//#endregion
|
|
20
20
|
//#region src/http.ts
|
|
21
|
-
const SDK_VERSION = "
|
|
21
|
+
const SDK_VERSION = "3.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,5 +1,5 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { $ as
|
|
1
|
+
import { $ as SubscriptionChangePreviewInput, A as FeatureUpdate, At as currentApiVersion, B as PlanFeaturesInput, C as CustomerMemberUpdate, Ct as ApiVersion, D as FeatureCreate, Dt as LatestApiVersion, E as EventSelector, Et as LATEST_API_VERSION, F as KEY_PATTERN, G as ProductCheckoutCreate, H as PlanPriceInput, I as PaymentLinkCreate, J as ProductUpdate, K as ProductCreate, L as PaymentLinkUpdate, M as FulfillmentTrackingInput, Mt as isApiVersionRetired, N as InvoiceCreate, Nt as supportedApiVersions, O as FeatureOperationCommit, Ot as apiVersionLifecycle, P as InvoiceLineInput, Q as SubscriptionChangeCreate, R as PlanCheckoutCreate, S as CustomerMemberCreate, St as API_VERSION_PATTERN, T as CustomerUpdate, Tt as ApiVersionStage, U as PlanUpdate, V as PlanLinkCreate, W as PortalSessionCreate, X as RetireInput, Y as RefundCreate, Z as SubscriptionCancel, _ as CouponCreate, _t as PublicPaymentLink, a as CheckoutCreate, at as CustomerSubscription, b as CustomerCreate, bt as API_VERSIONS, c as ClientCheckoutUpdate, ct as PaymentInstructions, d as ClientLinkCheckout, dt as PaymentNextAction, et as SubscriptionCreate, f as ClientPaymentCode, ft as PaymentTestScenario, g as CollectInput, gt as PublicInvoice, h as ClientSubscriptionUpdate, ht as PublicFulfillment, i as AfterCompletionInput, it as WebhookEndpointUpdate, j as FulfillmentInput, jt as isApiVersion, k as FeatureOperationCreate, kt as apiVersionStage, l as ClientFulfillmentProblem, lt as PaymentMethodField, m as ClientSubscriptionSeats, mt as PublicCheckout, n as RequestOptions, nt as VariantInput, o as CheckoutItemInput, ot as CustomerSubscriptionChangeResult, p as ClientSubscriptionCancel, pt as PortalFeatures, q as ProductLinkCreate, r as TransportOptions, rt as WebhookEndpointCreate, s as ClientCheckoutPay, st as FulfillmentOption, t as BilleteError, tt as SubscriptionUpdate, u as ClientInvoicePay, ut as PaymentMethodOption, v as CouponUpdate, vt as PublicPaymentState, w as CustomerSessionCreate, wt as ApiVersionLifecycle, x as CustomerInput, xt as API_VERSION_HEADER, y as CustomFieldInput, yt as PublicPortal, z as PlanCreate } from "./errors-BRQlJDjy.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-rtkF8fBQ.js";
|
|
3
3
|
import { WebhookVerificationError, verifyWebhook } from "./webhooks.js";
|
|
4
4
|
//#region src/server.d.ts
|
|
5
5
|
type Filters<T> = ListQuery & T;
|
|
@@ -24,7 +24,8 @@ interface BilleteOptions extends TransportOptions {
|
|
|
24
24
|
* Server-side Billete client. Works in any runtime with `fetch` (Node, Bun, Deno, edge).
|
|
25
25
|
*
|
|
26
26
|
* ```ts
|
|
27
|
-
*
|
|
27
|
+
* // Reads BILLETE_API_KEY.
|
|
28
|
+
* const billete = createBillete({ apiVersion: "2026-10-09", environment: "test" });
|
|
28
29
|
* const { allowed } = await billete.features.consume("user_123", "tokens", 850);
|
|
29
30
|
* ```
|
|
30
31
|
*/
|
|
@@ -99,8 +100,6 @@ export declare function createBillete(options: BilleteOptions): {
|
|
|
99
100
|
};
|
|
100
101
|
features: {
|
|
101
102
|
create: (input: FeatureCreate, options?: RequestOptions) => Promise<Feature>;
|
|
102
|
-
retrieve: (id: string, options?: RequestOptions) => Promise<Feature>;
|
|
103
|
-
update: (id: string, input: FeatureUpdate, options?: RequestOptions) => Promise<Feature>;
|
|
104
103
|
list: (query?: Filters<{
|
|
105
104
|
sort?: ListSort<"created" | "name">;
|
|
106
105
|
}>, options?: RequestOptions) => Promise<List<Feature>>;
|
|
@@ -108,6 +107,10 @@ export declare function createBillete(options: BilleteOptions): {
|
|
|
108
107
|
iterate: (query?: Filters<{
|
|
109
108
|
sort?: ListSort<"created" | "name">;
|
|
110
109
|
}>) => AsyncGenerator<Feature, any, any>;
|
|
110
|
+
/** A feature by its `key` (`tokens`) or its `feat_` ID. */
|
|
111
|
+
retrieve: (key: string, options?: RequestOptions) => Promise<Feature>;
|
|
112
|
+
/** Renames a feature or changes its schedule; `key` also takes its `feat_` ID. */
|
|
113
|
+
update: (key: string, input: FeatureUpdate, options?: RequestOptions) => Promise<Feature>;
|
|
111
114
|
/**
|
|
112
115
|
* Reserves `amount` of a metered feature for one job: it counts as used right away and the
|
|
113
116
|
* operation is closed later through `features.operations`. Repeating `operation` returns the
|
|
@@ -317,4 +320,4 @@ export declare function createBillete(options: BilleteOptions): {
|
|
|
317
320
|
/** The server client: what `createBillete` returns. */
|
|
318
321
|
type Billete = ReturnType<typeof createBillete>;
|
|
319
322
|
//#endregion
|
|
320
|
-
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 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 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 findBank, type isLandlinePhone, type isMobilePhone, type nationalPhone, type tokenEnvironment, type tokenPrefix, verifyWebhook };
|
|
323
|
+
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 ClientSubscriptionSeats, 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 CustomerSubscriptionChangeResult, 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-
|
|
1
|
+
import { n as segment, r as BilleteError, t as createTransport } from "./http-PMxK43GM.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
|
-
*
|
|
66
|
+
* // Reads BILLETE_API_KEY.
|
|
67
|
+
* const billete = createBillete({ apiVersion: "2026-10-09", environment: "test" });
|
|
67
68
|
* const { allowed } = await billete.features.consume("user_123", "tokens", 850);
|
|
68
69
|
* ```
|
|
69
70
|
*/
|
|
@@ -158,6 +159,10 @@ create: (input, options) => http.request({
|
|
|
158
159
|
const operationPath = (operation, action) => `/v1/feature-operations/${segment(operation)}${action ? `/${action}` : ""}`;
|
|
159
160
|
const features = {
|
|
160
161
|
...featureCrud,
|
|
162
|
+
/** A feature by its `key` (`tokens`) or its `feat_` ID. */
|
|
163
|
+
retrieve: (key, options) => featureCrud.retrieve(key, options),
|
|
164
|
+
/** Renames a feature or changes its schedule; `key` also takes its `feat_` ID. */
|
|
165
|
+
update: (key, input, options) => featureCrud.update(key, input, options),
|
|
161
166
|
/**
|
|
162
167
|
* Reserves `amount` of a metered feature for one job: it counts as used right away and the
|
|
163
168
|
* operation is closed later through `features.operations`. Repeating `operation` returns the
|
package/dist/webhooks.d.ts
CHANGED