@usebillow/sdk 0.6.0 → 0.8.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/dist/index.d.cts CHANGED
@@ -6,8 +6,8 @@ import { SubscriptionStatus } from './status.cjs';
6
6
  export { ACTIVE_SUBSCRIPTION_STATUSES, NEVER_ACTIVATED_SUBSCRIPTION_STATUSES, SUBSCRIPTION_STATUSES, TERMINAL_SUBSCRIPTION_STATUSES, grantsAccess, isTerminal } from './status.cjs';
7
7
  import { c as TaxBehavior, d as Customer, U as UnappliedPaymentReason, e as CreateChargeInput, R as RequestOptions, f as Charge, g as CreateMerchantInitiatedChargeInput, I as IdempotentRequestOptions, h as CallOptions, C as CreateProductInput, i as UpdateProductInput, j as MigrationResult, k as CreateSubscriptionInput, B as BillowOptions, a as CreateCouponInput, l as Coupon, F as FeatureKind, M as MeterConfig, m as Feature, n as UpdateFeatureInput, o as UsageAlert, p as CreateUsageAlertInput, b as CheckResult, T as TrackResult, E as EntitlementView, A as AttachResult } from './billing-B-VyZCXV.cjs';
8
8
  export { q as ActivatedSubscriptionResult, r as BillingInterval, s as CouponDuration, t as CouponKind, u as CreateSubscriptionResult, v as EntitlementInput, w as MeterAggregation, x as MeterFilter, y as MeterRoundingMode, z as PendingSubscriptionCheckoutResult, D as PriceInput, P as Product, G as ProductEntitlement, H as ProductPrice, S as Subscription, J as SubscriptionDetail, K as SubscriptionItem, L as UpdatePriceInput, N as UsageAlertKind, O as UsageAlertMetric, Q as UsageModel, V as UsageTier } from './billing-B-VyZCXV.cjs';
9
- import { a as CreditThresholdLevel, e as CreditGrant, f as CreditTopUp, g as CreateCreditGrantInput, h as CreditGrantRequestResult, i as CreditPacks, j as CreateCreditPackInput, k as CreditPack, U as UpdateCreditPackInput, l as CreateCreditTopUpInput, m as CreditTopUpRequestResult, n as CreditTopUpListParams, o as CreditBalance, p as CreditLedgerEntry, q as CreditUsageParams, r as CreditUsage } from './hosted-domains-BtCd-Rur.cjs';
10
- export { s as CreditAccountStatus, C as CreditGrantKind, t as CreditMoney, u as CreditPackListItem, v as CreditTopUpStatus, w as CreditTransactionType, x as CreditUsageGroupBy, H as HostedDomainActivatedData, d as HostedDomainDisabledData, b as HostedDomainDnsFailingData, y as HostedDomainEventBase, c as HostedDomainReassignmentPendingData, z as HostedDomainStatus, A as HostedDomainStatusReason } from './hosted-domains-BtCd-Rur.cjs';
9
+ import { a as CreditThresholdLevel, e as CreditGrant, f as CreditTopUp, g as CreateCreditGrantInput, h as CreditGrantRequestResult, i as CreditPacks, j as CreateCreditPackInput, k as CreditPack, U as UpdateCreditPackInput, l as CreateCreditIncludedRuleInput, m as CreditIncludedRule, n as UpdateCreditIncludedRuleInput, o as CreateCreditTopUpInput, p as CreditTopUpRequestResult, q as CreditTopUpListParams, r as CreditBalance, s as CreditLedgerEntry, t as CreditUsageParams, u as CreditUsage } from './hosted-domains-BbuyxnuH.cjs';
10
+ export { v as CreditAccountStatus, w as CreditAllocationInterval, C as CreditGrantKind, x as CreditMoney, y as CreditPackBreakdown, z as CreditPackListItem, A as CreditTopUpStatus, B as CreditTransactionType, D as CreditUsageGroupBy, H as HostedDomainActivatedData, d as HostedDomainDisabledData, b as HostedDomainDnsFailingData, E as HostedDomainEventBase, c as HostedDomainReassignmentPendingData, F as HostedDomainStatus, G as HostedDomainStatusReason } from './hosted-domains-BbuyxnuH.cjs';
11
11
  import 'zod';
12
12
 
13
13
  /**
@@ -261,9 +261,9 @@ interface CursorPaginated<T> {
261
261
  * The return type of a cursor-paginated `.list()`: like {@link ListPromise}, BOTH a Promise for
262
262
  * the first page AND async-iterable across ALL pages (`for await`, or `.listAll()`). The walk
263
263
  * follows `nextCursor` until it is null, so rows arriving at the head meanwhile never make it skip
264
- * or repeat a row.
264
+ * or repeat a row. `Page` is the first page's type, for a list whose pages carry more than rows.
265
265
  */
266
- interface CursorListPromise<T> extends Promise<CursorPaginated<T>>, AsyncIterable<T> {
266
+ interface CursorListPromise<T, Page extends CursorPaginated<T> = CursorPaginated<T>> extends Promise<Page>, AsyncIterable<T> {
267
267
  /** Page through the entire list and collect every item into one array. */
268
268
  listAll(): Promise<T[]>;
269
269
  }
@@ -716,6 +716,7 @@ interface Whoami {
716
716
  * Every credit quantity - and every count of units - is a `string` of a whole number, e.g.
717
717
  * `"5000000"` for 5 credits: never a `number`, which would silently round past 2^53.
718
718
  */
719
+
719
720
  /** One Credit Action's price in a Rate Card version: `ceil(units * unitPrice / perUnits)` a line. */
720
721
  interface CreditRateCardItem {
721
722
  /** The Credit Action key, e.g. `send_message`. */
@@ -829,6 +830,29 @@ interface CreditReservation {
829
830
  metadata: Record<string, string> | null;
830
831
  createdAt: string;
831
832
  }
833
+ /** Narrow the project's reservations list. */
834
+ interface CreditReservationListParams {
835
+ /** Page size: 1 to 100 (default 25); the server clamps a larger one. */
836
+ limit?: number;
837
+ /** A `nextCursor` to continue from; omit to start at the oldest reservation. */
838
+ cursor?: string;
839
+ status?: CreditReservationStatus;
840
+ /** Only this customer's reservations (by external id). */
841
+ customer?: string;
842
+ /**
843
+ * Only reservations protected more than this many seconds ago, whatever their status now (with
844
+ * `status: "protected"`, the ones still waiting). A reservation never protected never matches.
845
+ */
846
+ protectedLongerThan?: number;
847
+ }
848
+ /** A page of the project's reservations, oldest first. */
849
+ interface CreditReservationPage extends CursorPaginated<CreditReservation> {
850
+ /**
851
+ * Your project's protected-hold maximum, in seconds (7 days unless configured): a protected hold
852
+ * never expires, so one protected longer than this needs your decision - commit or release it.
853
+ */
854
+ protectedHoldMaxSeconds: number;
855
+ }
832
856
  /** What a reservation holds for and how it is identified; give `quoteId` or `items`. */
833
857
  interface CreateCreditReservationBase {
834
858
  /** The customer's external id. */
@@ -902,10 +926,18 @@ interface CreatePortalSessionInput {
902
926
  flow?: PortalSessionFlow;
903
927
  /** Product slug to subscribe to — required when `flow` is `checkout`. */
904
928
  productId?: string;
905
- /** Where the surface returns the Customer when they finish or exit. */
929
+ /**
930
+ * Where the surface returns the Customer when they finish or exit: an absolute `https` URL
931
+ * without credentials (and, in live, without a port other than 443). A loopback host such as
932
+ * `localhost` is also accepted over `http`, on any port, in either environment.
933
+ */
906
934
  returnUrl?: string;
907
935
  }
908
- /** The minted portal session: redirect the Customer to `url` (it carries the bearer). */
936
+ /**
937
+ * The minted portal session: redirect the Customer to `url` at once. Its token is a single-use
938
+ * entry token - Billow's hosted portal exchanges it on first open, after which the link works
939
+ * only for the browser that opened it.
940
+ */
909
941
  interface PortalSession {
910
942
  id: string;
911
943
  url: string;
@@ -913,6 +945,21 @@ interface PortalSession {
913
945
  /** ISO-8601 expiry — the session (and its URL) stop working after this. */
914
946
  expiresAt: string;
915
947
  }
948
+ /** The single-use entry exchange's input (`BillowPortal.exchange`). */
949
+ interface PortalSessionExchangeInput {
950
+ /** The `Host` the link was opened on: it must be the host the session is bound to. */
951
+ host: string;
952
+ /** The session token the browser already holds, if any: a revisit by the browser that
953
+ * exchanged the link lands on its own session, and only that browser's. */
954
+ sessionToken?: string;
955
+ }
956
+ /** What the exchange returns: the session's bearer from now on, and its unchanged expiry. */
957
+ interface PortalSessionExchange {
958
+ sessionToken: string;
959
+ flow: PortalSessionFlow;
960
+ /** ISO-8601 expiry of the session, set when it was minted. */
961
+ expiresAt: string;
962
+ }
916
963
  /**
917
964
  * The portal shell: the session's flow + return URL, the merchant's
918
965
  * customer-facing brand, and the Customer's identity. The lightweight payload a
@@ -1422,6 +1469,33 @@ declare function createCreditsResource(ctx: RequestContext): {
1422
1469
  /** Edit a pack's terms or Price, or archive it; top-ups already made keep their terms. */
1423
1470
  update: (packId: string, input: UpdateCreditPackInput, options?: CallOptions) => Promise<CreditPack>;
1424
1471
  };
1472
+ includedRules: {
1473
+ /**
1474
+ * Configure an Included Credit Rule on a recurring base Price: the credits a subscription on
1475
+ * it includes for each period Billow grants it - per billing period, or per month of a Price
1476
+ * billed for longer than a month - and for a trial. Configuration, so no idempotency key:
1477
+ * a second live rule for the same Price throws `conflict` (409,
1478
+ * `details.reason: "included_rule_exists"`, with the live rule's `ruleId`). Throws
1479
+ * `validation_error` (422) with `details.reason: "not_a_base_price"` for a Price that is not
1480
+ * a recurring base Price, or `"allocation_not_shorter_than_billing"` for a monthly
1481
+ * allocation on a Price not billed for longer than a month.
1482
+ */
1483
+ create: (input: CreateCreditIncludedRuleInput, options?: CallOptions) => Promise<CreditIncludedRule>;
1484
+ /** A rule, archived or not. */
1485
+ get: (ruleId: string, options?: CallOptions) => Promise<CreditIncludedRule>;
1486
+ /**
1487
+ * Every rule, archived ones included, newest first. Auto-paginating by cursor: `await` the
1488
+ * first page, `for await (…)` every rule, or `.listAll()` to collect them.
1489
+ */
1490
+ list: (params?: CursorListParams, options?: CallOptions) => CursorListPromise<CreditIncludedRule>;
1491
+ /**
1492
+ * Edit a rule's credits, per-seat choice, trial credits or allocation interval, or archive
1493
+ * it (`archived: false` brings it back). It takes effect from the next period granted;
1494
+ * periods already granted keep what they were granted. A rule left live is judged against
1495
+ * its Price as it is now, with the same errors as `create`.
1496
+ */
1497
+ update: (ruleId: string, input: UpdateCreditIncludedRuleInput, options?: CallOptions) => Promise<CreditIncludedRule>;
1498
+ };
1425
1499
  topUps: {
1426
1500
  /**
1427
1501
  * Buy a Credit Pack for a customer: answers the top-up with `checkoutUrl`, the hosted
@@ -1512,6 +1586,15 @@ declare function createCreditsResource(ctx: RequestContext): {
1512
1586
  create: (input: CreateCreditReservationInput, options: IdempotentRequestOptions) => Promise<CreditReservationRequestResult>;
1513
1587
  /** A reservation as it now stands. */
1514
1588
  get: (reservationId: string, options?: CallOptions) => Promise<CreditReservation>;
1589
+ /**
1590
+ * Your project's reservations, oldest first, optionally of one `status`, one `customer` (by
1591
+ * external id), or protected more than `protectedLongerThan` seconds ago - with
1592
+ * `{ status: "protected", protectedLongerThan: page.protectedHoldMaxSeconds }`, the paid
1593
+ * operations waiting past your maximum for a decision (commit or release each). Every page
1594
+ * carries `protectedHoldMaxSeconds`. Auto-paginating by cursor: `await` the first page,
1595
+ * `for await (…)` every reservation, or `.listAll()` to collect them.
1596
+ */
1597
+ list: (params?: CreditReservationListParams, options?: CallOptions) => CursorListPromise<CreditReservation, CreditReservationPage>;
1515
1598
  /**
1516
1599
  * A customer's reservation (by external id) made with `operationKey` - how to find one whose
1517
1600
  * reply was lost. Throws `not_found` (404) when there is none.
@@ -2803,6 +2886,13 @@ declare class BillowPortal {
2803
2886
  * the lightweight payload the hosting app frames every page with, and the
2804
2887
  * validate-and-route check at login. */
2805
2888
  session(options?: CallOptions): Promise<PortalSessionInfo>;
2889
+ /**
2890
+ * The single-use entry exchange (ADR-0039): on a client built with a minted link's entry
2891
+ * token, trade it for the session token to use from now on. Succeeds once per link, and
2892
+ * afterwards only for the browser presenting that exchange's `sessionToken`; anything else is
2893
+ * a 401. For a hosted surface; an integrator's own surface may keep using the entry token.
2894
+ */
2895
+ exchange(input: PortalSessionExchangeInput, options?: CallOptions): Promise<PortalSessionExchange>;
2806
2896
  /** The self-serve home payload: identity + subscriptions + usage + saved cards. */
2807
2897
  me(options?: CallOptions): Promise<PortalView>;
2808
2898
  invoices: {
@@ -2810,6 +2900,8 @@ declare class BillowPortal {
2810
2900
  list: (params?: ListParams & {
2811
2901
  status?: InvoiceListItem["status"];
2812
2902
  }, options?: CallOptions) => ListPromise<InvoiceListItem>;
2903
+ /** One of the Customer's invoices, in the list's shape. */
2904
+ get: (id: string, options?: CallOptions) => Promise<InvoiceListItem>;
2813
2905
  /** Open or resume checkout for this customer's outstanding invoice. */
2814
2906
  pay: (id: string, input?: PayInvoiceInput, options?: CallOptions) => Promise<{
2815
2907
  invoiceId: string;
@@ -2881,4 +2973,4 @@ declare class BillowPortal {
2881
2973
  };
2882
2974
  }
2883
2975
 
2884
- export { AttachResult, BILLOW_ERROR_CODES, Billow, BillowApiError, type BillowErrorCode, BillowOptions, BillowPortal, BillowPublishable, type BusinessProfile, CallOptions, type CatalogItem, Charge, type ChargeListItem, type ChargeListParams, type ChargeSearchHit, ChargeStatus, CheckResult, type CheckoutMethodInfo, type ConfigField, type ConfigFieldOption, type ConfigFieldType, Coupon, CreateChargeInput, CreateCouponInput, CreateCreditGrantInput, CreateCreditPackInput, type CreateCreditQuoteInput, type CreateCreditReservationInput, CreateCreditTopUpInput, CreateHostedDomainInput, CreateMerchantInitiatedChargeInput, type CreatePortalSessionInput, CreateProductInput, CreateSubscriptionInput, CreateUsageAlertInput, type CreateWebhookEndpointInput, type CredentialSet, CreditBalance, type CreditDimensions, CreditGrant, CreditGrantRequestResult, CreditLedgerEntry, type CreditLineItem, CreditPack, CreditPacks, type CreditPricedLine, type CreditQuote, type CreditRateCard, type CreditRateCardItem, type CreditReservation, type CreditReservationRequestResult, type CreditReservationStatus, type CreditReversal, type CreditReversalRequestResult, CreditThresholdLevel, CreditTopUp, CreditTopUpListParams, CreditTopUpRequestResult, CreditUsage, CreditUsageParams, type CursorListParams, type CursorListPromise, type CursorPaginated, Customer, type CustomerAnonymizationResult, type CustomerCreditsExport, type CustomerDataExport, type CustomerListItem, type CustomerListParams, type CustomerOverview, type CustomerSearchHit, type CustomerUsage, type CustomerUsageDetail, type EmailDeliveryListItem, type EmailDeliveryListParams, type EmailDeliveryStatus, type EmailTemplateSetting, EntitlementView, type ExchangeRate, type ExportJsonValue, type ExternalPaymentMethod, type ExternalPaymentResult, Feature, FeatureKind, IdempotentRequestOptions, type InboundWebhookListItem, type InboundWebhookListParams, type InboundWebhookOutcome, type IntegrationDefinition, type IntegrationKind, type IntegrationTier, type Invoice, type InvoiceDetail, type InvoiceLineItem, type InvoiceListItem, type InvoiceListParams, type InvoiceSearchHit, InvoiceStatus, type ListParams, type ListPromise, MeterConfig, type MetricsOverview, type MetricsParams, type MetricsRollup, MigrationResult, type OutboxEventListItem, type OutboxEventListParams, type OutboxEventStatus, type Paginated, PayInvoiceInput, type PaymentMethod, PaymentMethodStatus, type PaymentProviderDefinition, type PortalCardSetupResult, type PortalCheckout, type PortalPlanChange, type PortalSession, type PortalSessionFlow, type PortalSessionInfo, type PortalSubscriptionStatus, type PortalView, type ProviderCredentialSummary, type ProviderVerifyResult, type ProviderVerifyTarget, type ProviderVerifyTargetResult, type PublishCreditRateCardInput, type RecordExternalPaymentInput, type Refund, type RefundChargeInput, type RefundRequestResult, type RefundReviewReason, RefundStatus, RequestOptions, type ResolveRefundInput, type ReverseCreditConsumptionInput, SavedPaymentMethod, type ScheduledSubscriptionChange, type SearchResults, type SubscriptionListItem, type SubscriptionListParams, type SubscriptionSearchHit, SubscriptionStatus, TaxBehavior, type TimeseriesInterval, type TimeseriesMetric, type TimeseriesParams, type TimeseriesPoint, type TimeseriesResult, TrackResult, UnappliedPaymentReason, type UpdateBusinessProfileInput, UpdateCreditPackInput, type UpdateEmailTemplateInput, UpdateFeatureInput, UpdateProductInput, type UpdateWebhookEndpointInput, type UpsertCredentialsInput, UsageAlert, type WebhookDelivery, WebhookDeliveryStatus, type WebhookEndpoint, type WebhookEndpointWithSecret, type Whoami, currencyExponent, formatMoney, isSecretField, toMajorUnits, toMinorUnits };
2976
+ export { AttachResult, BILLOW_ERROR_CODES, Billow, BillowApiError, type BillowErrorCode, BillowOptions, BillowPortal, BillowPublishable, type BusinessProfile, CallOptions, type CatalogItem, Charge, type ChargeListItem, type ChargeListParams, type ChargeSearchHit, ChargeStatus, CheckResult, type CheckoutMethodInfo, type ConfigField, type ConfigFieldOption, type ConfigFieldType, Coupon, CreateChargeInput, CreateCouponInput, CreateCreditGrantInput, CreateCreditIncludedRuleInput, CreateCreditPackInput, type CreateCreditQuoteInput, type CreateCreditReservationInput, CreateCreditTopUpInput, CreateHostedDomainInput, CreateMerchantInitiatedChargeInput, type CreatePortalSessionInput, CreateProductInput, CreateSubscriptionInput, CreateUsageAlertInput, type CreateWebhookEndpointInput, type CredentialSet, CreditBalance, type CreditDimensions, CreditGrant, CreditGrantRequestResult, CreditIncludedRule, CreditLedgerEntry, type CreditLineItem, CreditPack, CreditPacks, type CreditPricedLine, type CreditQuote, type CreditRateCard, type CreditRateCardItem, type CreditReservation, type CreditReservationListParams, type CreditReservationPage, type CreditReservationRequestResult, type CreditReservationStatus, type CreditReversal, type CreditReversalRequestResult, CreditThresholdLevel, CreditTopUp, CreditTopUpListParams, CreditTopUpRequestResult, CreditUsage, CreditUsageParams, type CursorListParams, type CursorListPromise, type CursorPaginated, Customer, type CustomerAnonymizationResult, type CustomerCreditsExport, type CustomerDataExport, type CustomerListItem, type CustomerListParams, type CustomerOverview, type CustomerSearchHit, type CustomerUsage, type CustomerUsageDetail, type EmailDeliveryListItem, type EmailDeliveryListParams, type EmailDeliveryStatus, type EmailTemplateSetting, EntitlementView, type ExchangeRate, type ExportJsonValue, type ExternalPaymentMethod, type ExternalPaymentResult, Feature, FeatureKind, IdempotentRequestOptions, type InboundWebhookListItem, type InboundWebhookListParams, type InboundWebhookOutcome, type IntegrationDefinition, type IntegrationKind, type IntegrationTier, type Invoice, type InvoiceDetail, type InvoiceLineItem, type InvoiceListItem, type InvoiceListParams, type InvoiceSearchHit, InvoiceStatus, type ListParams, type ListPromise, MeterConfig, type MetricsOverview, type MetricsParams, type MetricsRollup, MigrationResult, type OutboxEventListItem, type OutboxEventListParams, type OutboxEventStatus, type Paginated, PayInvoiceInput, type PaymentMethod, PaymentMethodStatus, type PaymentProviderDefinition, type PortalCardSetupResult, type PortalCheckout, type PortalPlanChange, type PortalSession, type PortalSessionExchange, type PortalSessionExchangeInput, type PortalSessionFlow, type PortalSessionInfo, type PortalSubscriptionStatus, type PortalView, type ProviderCredentialSummary, type ProviderVerifyResult, type ProviderVerifyTarget, type ProviderVerifyTargetResult, type PublishCreditRateCardInput, type RecordExternalPaymentInput, type Refund, type RefundChargeInput, type RefundRequestResult, type RefundReviewReason, RefundStatus, RequestOptions, type ResolveRefundInput, type ReverseCreditConsumptionInput, SavedPaymentMethod, type ScheduledSubscriptionChange, type SearchResults, type SubscriptionListItem, type SubscriptionListParams, type SubscriptionSearchHit, SubscriptionStatus, TaxBehavior, type TimeseriesInterval, type TimeseriesMetric, type TimeseriesParams, type TimeseriesPoint, type TimeseriesResult, TrackResult, UnappliedPaymentReason, type UpdateBusinessProfileInput, UpdateCreditIncludedRuleInput, UpdateCreditPackInput, type UpdateEmailTemplateInput, UpdateFeatureInput, UpdateProductInput, type UpdateWebhookEndpointInput, type UpsertCredentialsInput, UsageAlert, type WebhookDelivery, WebhookDeliveryStatus, type WebhookEndpoint, type WebhookEndpointWithSecret, type Whoami, currencyExponent, formatMoney, isSecretField, toMajorUnits, toMinorUnits };
package/dist/index.d.ts CHANGED
@@ -6,8 +6,8 @@ import { SubscriptionStatus } from './status.js';
6
6
  export { ACTIVE_SUBSCRIPTION_STATUSES, NEVER_ACTIVATED_SUBSCRIPTION_STATUSES, SUBSCRIPTION_STATUSES, TERMINAL_SUBSCRIPTION_STATUSES, grantsAccess, isTerminal } from './status.js';
7
7
  import { c as TaxBehavior, d as Customer, U as UnappliedPaymentReason, e as CreateChargeInput, R as RequestOptions, f as Charge, g as CreateMerchantInitiatedChargeInput, I as IdempotentRequestOptions, h as CallOptions, C as CreateProductInput, i as UpdateProductInput, j as MigrationResult, k as CreateSubscriptionInput, B as BillowOptions, a as CreateCouponInput, l as Coupon, F as FeatureKind, M as MeterConfig, m as Feature, n as UpdateFeatureInput, o as UsageAlert, p as CreateUsageAlertInput, b as CheckResult, T as TrackResult, E as EntitlementView, A as AttachResult } from './billing-CgjcWmvb.js';
8
8
  export { q as ActivatedSubscriptionResult, r as BillingInterval, s as CouponDuration, t as CouponKind, u as CreateSubscriptionResult, v as EntitlementInput, w as MeterAggregation, x as MeterFilter, y as MeterRoundingMode, z as PendingSubscriptionCheckoutResult, D as PriceInput, P as Product, G as ProductEntitlement, H as ProductPrice, S as Subscription, J as SubscriptionDetail, K as SubscriptionItem, L as UpdatePriceInput, N as UsageAlertKind, O as UsageAlertMetric, Q as UsageModel, V as UsageTier } from './billing-CgjcWmvb.js';
9
- import { a as CreditThresholdLevel, e as CreditGrant, f as CreditTopUp, g as CreateCreditGrantInput, h as CreditGrantRequestResult, i as CreditPacks, j as CreateCreditPackInput, k as CreditPack, U as UpdateCreditPackInput, l as CreateCreditTopUpInput, m as CreditTopUpRequestResult, n as CreditTopUpListParams, o as CreditBalance, p as CreditLedgerEntry, q as CreditUsageParams, r as CreditUsage } from './hosted-domains-CrVDsk2i.js';
10
- export { s as CreditAccountStatus, C as CreditGrantKind, t as CreditMoney, u as CreditPackListItem, v as CreditTopUpStatus, w as CreditTransactionType, x as CreditUsageGroupBy, H as HostedDomainActivatedData, d as HostedDomainDisabledData, b as HostedDomainDnsFailingData, y as HostedDomainEventBase, c as HostedDomainReassignmentPendingData, z as HostedDomainStatus, A as HostedDomainStatusReason } from './hosted-domains-CrVDsk2i.js';
9
+ import { a as CreditThresholdLevel, e as CreditGrant, f as CreditTopUp, g as CreateCreditGrantInput, h as CreditGrantRequestResult, i as CreditPacks, j as CreateCreditPackInput, k as CreditPack, U as UpdateCreditPackInput, l as CreateCreditIncludedRuleInput, m as CreditIncludedRule, n as UpdateCreditIncludedRuleInput, o as CreateCreditTopUpInput, p as CreditTopUpRequestResult, q as CreditTopUpListParams, r as CreditBalance, s as CreditLedgerEntry, t as CreditUsageParams, u as CreditUsage } from './hosted-domains-BP91tg9P.js';
10
+ export { v as CreditAccountStatus, w as CreditAllocationInterval, C as CreditGrantKind, x as CreditMoney, y as CreditPackBreakdown, z as CreditPackListItem, A as CreditTopUpStatus, B as CreditTransactionType, D as CreditUsageGroupBy, H as HostedDomainActivatedData, d as HostedDomainDisabledData, b as HostedDomainDnsFailingData, E as HostedDomainEventBase, c as HostedDomainReassignmentPendingData, F as HostedDomainStatus, G as HostedDomainStatusReason } from './hosted-domains-BP91tg9P.js';
11
11
  import 'zod';
12
12
 
13
13
  /**
@@ -261,9 +261,9 @@ interface CursorPaginated<T> {
261
261
  * The return type of a cursor-paginated `.list()`: like {@link ListPromise}, BOTH a Promise for
262
262
  * the first page AND async-iterable across ALL pages (`for await`, or `.listAll()`). The walk
263
263
  * follows `nextCursor` until it is null, so rows arriving at the head meanwhile never make it skip
264
- * or repeat a row.
264
+ * or repeat a row. `Page` is the first page's type, for a list whose pages carry more than rows.
265
265
  */
266
- interface CursorListPromise<T> extends Promise<CursorPaginated<T>>, AsyncIterable<T> {
266
+ interface CursorListPromise<T, Page extends CursorPaginated<T> = CursorPaginated<T>> extends Promise<Page>, AsyncIterable<T> {
267
267
  /** Page through the entire list and collect every item into one array. */
268
268
  listAll(): Promise<T[]>;
269
269
  }
@@ -716,6 +716,7 @@ interface Whoami {
716
716
  * Every credit quantity - and every count of units - is a `string` of a whole number, e.g.
717
717
  * `"5000000"` for 5 credits: never a `number`, which would silently round past 2^53.
718
718
  */
719
+
719
720
  /** One Credit Action's price in a Rate Card version: `ceil(units * unitPrice / perUnits)` a line. */
720
721
  interface CreditRateCardItem {
721
722
  /** The Credit Action key, e.g. `send_message`. */
@@ -829,6 +830,29 @@ interface CreditReservation {
829
830
  metadata: Record<string, string> | null;
830
831
  createdAt: string;
831
832
  }
833
+ /** Narrow the project's reservations list. */
834
+ interface CreditReservationListParams {
835
+ /** Page size: 1 to 100 (default 25); the server clamps a larger one. */
836
+ limit?: number;
837
+ /** A `nextCursor` to continue from; omit to start at the oldest reservation. */
838
+ cursor?: string;
839
+ status?: CreditReservationStatus;
840
+ /** Only this customer's reservations (by external id). */
841
+ customer?: string;
842
+ /**
843
+ * Only reservations protected more than this many seconds ago, whatever their status now (with
844
+ * `status: "protected"`, the ones still waiting). A reservation never protected never matches.
845
+ */
846
+ protectedLongerThan?: number;
847
+ }
848
+ /** A page of the project's reservations, oldest first. */
849
+ interface CreditReservationPage extends CursorPaginated<CreditReservation> {
850
+ /**
851
+ * Your project's protected-hold maximum, in seconds (7 days unless configured): a protected hold
852
+ * never expires, so one protected longer than this needs your decision - commit or release it.
853
+ */
854
+ protectedHoldMaxSeconds: number;
855
+ }
832
856
  /** What a reservation holds for and how it is identified; give `quoteId` or `items`. */
833
857
  interface CreateCreditReservationBase {
834
858
  /** The customer's external id. */
@@ -902,10 +926,18 @@ interface CreatePortalSessionInput {
902
926
  flow?: PortalSessionFlow;
903
927
  /** Product slug to subscribe to — required when `flow` is `checkout`. */
904
928
  productId?: string;
905
- /** Where the surface returns the Customer when they finish or exit. */
929
+ /**
930
+ * Where the surface returns the Customer when they finish or exit: an absolute `https` URL
931
+ * without credentials (and, in live, without a port other than 443). A loopback host such as
932
+ * `localhost` is also accepted over `http`, on any port, in either environment.
933
+ */
906
934
  returnUrl?: string;
907
935
  }
908
- /** The minted portal session: redirect the Customer to `url` (it carries the bearer). */
936
+ /**
937
+ * The minted portal session: redirect the Customer to `url` at once. Its token is a single-use
938
+ * entry token - Billow's hosted portal exchanges it on first open, after which the link works
939
+ * only for the browser that opened it.
940
+ */
909
941
  interface PortalSession {
910
942
  id: string;
911
943
  url: string;
@@ -913,6 +945,21 @@ interface PortalSession {
913
945
  /** ISO-8601 expiry — the session (and its URL) stop working after this. */
914
946
  expiresAt: string;
915
947
  }
948
+ /** The single-use entry exchange's input (`BillowPortal.exchange`). */
949
+ interface PortalSessionExchangeInput {
950
+ /** The `Host` the link was opened on: it must be the host the session is bound to. */
951
+ host: string;
952
+ /** The session token the browser already holds, if any: a revisit by the browser that
953
+ * exchanged the link lands on its own session, and only that browser's. */
954
+ sessionToken?: string;
955
+ }
956
+ /** What the exchange returns: the session's bearer from now on, and its unchanged expiry. */
957
+ interface PortalSessionExchange {
958
+ sessionToken: string;
959
+ flow: PortalSessionFlow;
960
+ /** ISO-8601 expiry of the session, set when it was minted. */
961
+ expiresAt: string;
962
+ }
916
963
  /**
917
964
  * The portal shell: the session's flow + return URL, the merchant's
918
965
  * customer-facing brand, and the Customer's identity. The lightweight payload a
@@ -1422,6 +1469,33 @@ declare function createCreditsResource(ctx: RequestContext): {
1422
1469
  /** Edit a pack's terms or Price, or archive it; top-ups already made keep their terms. */
1423
1470
  update: (packId: string, input: UpdateCreditPackInput, options?: CallOptions) => Promise<CreditPack>;
1424
1471
  };
1472
+ includedRules: {
1473
+ /**
1474
+ * Configure an Included Credit Rule on a recurring base Price: the credits a subscription on
1475
+ * it includes for each period Billow grants it - per billing period, or per month of a Price
1476
+ * billed for longer than a month - and for a trial. Configuration, so no idempotency key:
1477
+ * a second live rule for the same Price throws `conflict` (409,
1478
+ * `details.reason: "included_rule_exists"`, with the live rule's `ruleId`). Throws
1479
+ * `validation_error` (422) with `details.reason: "not_a_base_price"` for a Price that is not
1480
+ * a recurring base Price, or `"allocation_not_shorter_than_billing"` for a monthly
1481
+ * allocation on a Price not billed for longer than a month.
1482
+ */
1483
+ create: (input: CreateCreditIncludedRuleInput, options?: CallOptions) => Promise<CreditIncludedRule>;
1484
+ /** A rule, archived or not. */
1485
+ get: (ruleId: string, options?: CallOptions) => Promise<CreditIncludedRule>;
1486
+ /**
1487
+ * Every rule, archived ones included, newest first. Auto-paginating by cursor: `await` the
1488
+ * first page, `for await (…)` every rule, or `.listAll()` to collect them.
1489
+ */
1490
+ list: (params?: CursorListParams, options?: CallOptions) => CursorListPromise<CreditIncludedRule>;
1491
+ /**
1492
+ * Edit a rule's credits, per-seat choice, trial credits or allocation interval, or archive
1493
+ * it (`archived: false` brings it back). It takes effect from the next period granted;
1494
+ * periods already granted keep what they were granted. A rule left live is judged against
1495
+ * its Price as it is now, with the same errors as `create`.
1496
+ */
1497
+ update: (ruleId: string, input: UpdateCreditIncludedRuleInput, options?: CallOptions) => Promise<CreditIncludedRule>;
1498
+ };
1425
1499
  topUps: {
1426
1500
  /**
1427
1501
  * Buy a Credit Pack for a customer: answers the top-up with `checkoutUrl`, the hosted
@@ -1512,6 +1586,15 @@ declare function createCreditsResource(ctx: RequestContext): {
1512
1586
  create: (input: CreateCreditReservationInput, options: IdempotentRequestOptions) => Promise<CreditReservationRequestResult>;
1513
1587
  /** A reservation as it now stands. */
1514
1588
  get: (reservationId: string, options?: CallOptions) => Promise<CreditReservation>;
1589
+ /**
1590
+ * Your project's reservations, oldest first, optionally of one `status`, one `customer` (by
1591
+ * external id), or protected more than `protectedLongerThan` seconds ago - with
1592
+ * `{ status: "protected", protectedLongerThan: page.protectedHoldMaxSeconds }`, the paid
1593
+ * operations waiting past your maximum for a decision (commit or release each). Every page
1594
+ * carries `protectedHoldMaxSeconds`. Auto-paginating by cursor: `await` the first page,
1595
+ * `for await (…)` every reservation, or `.listAll()` to collect them.
1596
+ */
1597
+ list: (params?: CreditReservationListParams, options?: CallOptions) => CursorListPromise<CreditReservation, CreditReservationPage>;
1515
1598
  /**
1516
1599
  * A customer's reservation (by external id) made with `operationKey` - how to find one whose
1517
1600
  * reply was lost. Throws `not_found` (404) when there is none.
@@ -2803,6 +2886,13 @@ declare class BillowPortal {
2803
2886
  * the lightweight payload the hosting app frames every page with, and the
2804
2887
  * validate-and-route check at login. */
2805
2888
  session(options?: CallOptions): Promise<PortalSessionInfo>;
2889
+ /**
2890
+ * The single-use entry exchange (ADR-0039): on a client built with a minted link's entry
2891
+ * token, trade it for the session token to use from now on. Succeeds once per link, and
2892
+ * afterwards only for the browser presenting that exchange's `sessionToken`; anything else is
2893
+ * a 401. For a hosted surface; an integrator's own surface may keep using the entry token.
2894
+ */
2895
+ exchange(input: PortalSessionExchangeInput, options?: CallOptions): Promise<PortalSessionExchange>;
2806
2896
  /** The self-serve home payload: identity + subscriptions + usage + saved cards. */
2807
2897
  me(options?: CallOptions): Promise<PortalView>;
2808
2898
  invoices: {
@@ -2810,6 +2900,8 @@ declare class BillowPortal {
2810
2900
  list: (params?: ListParams & {
2811
2901
  status?: InvoiceListItem["status"];
2812
2902
  }, options?: CallOptions) => ListPromise<InvoiceListItem>;
2903
+ /** One of the Customer's invoices, in the list's shape. */
2904
+ get: (id: string, options?: CallOptions) => Promise<InvoiceListItem>;
2813
2905
  /** Open or resume checkout for this customer's outstanding invoice. */
2814
2906
  pay: (id: string, input?: PayInvoiceInput, options?: CallOptions) => Promise<{
2815
2907
  invoiceId: string;
@@ -2881,4 +2973,4 @@ declare class BillowPortal {
2881
2973
  };
2882
2974
  }
2883
2975
 
2884
- export { AttachResult, BILLOW_ERROR_CODES, Billow, BillowApiError, type BillowErrorCode, BillowOptions, BillowPortal, BillowPublishable, type BusinessProfile, CallOptions, type CatalogItem, Charge, type ChargeListItem, type ChargeListParams, type ChargeSearchHit, ChargeStatus, CheckResult, type CheckoutMethodInfo, type ConfigField, type ConfigFieldOption, type ConfigFieldType, Coupon, CreateChargeInput, CreateCouponInput, CreateCreditGrantInput, CreateCreditPackInput, type CreateCreditQuoteInput, type CreateCreditReservationInput, CreateCreditTopUpInput, CreateHostedDomainInput, CreateMerchantInitiatedChargeInput, type CreatePortalSessionInput, CreateProductInput, CreateSubscriptionInput, CreateUsageAlertInput, type CreateWebhookEndpointInput, type CredentialSet, CreditBalance, type CreditDimensions, CreditGrant, CreditGrantRequestResult, CreditLedgerEntry, type CreditLineItem, CreditPack, CreditPacks, type CreditPricedLine, type CreditQuote, type CreditRateCard, type CreditRateCardItem, type CreditReservation, type CreditReservationRequestResult, type CreditReservationStatus, type CreditReversal, type CreditReversalRequestResult, CreditThresholdLevel, CreditTopUp, CreditTopUpListParams, CreditTopUpRequestResult, CreditUsage, CreditUsageParams, type CursorListParams, type CursorListPromise, type CursorPaginated, Customer, type CustomerAnonymizationResult, type CustomerCreditsExport, type CustomerDataExport, type CustomerListItem, type CustomerListParams, type CustomerOverview, type CustomerSearchHit, type CustomerUsage, type CustomerUsageDetail, type EmailDeliveryListItem, type EmailDeliveryListParams, type EmailDeliveryStatus, type EmailTemplateSetting, EntitlementView, type ExchangeRate, type ExportJsonValue, type ExternalPaymentMethod, type ExternalPaymentResult, Feature, FeatureKind, IdempotentRequestOptions, type InboundWebhookListItem, type InboundWebhookListParams, type InboundWebhookOutcome, type IntegrationDefinition, type IntegrationKind, type IntegrationTier, type Invoice, type InvoiceDetail, type InvoiceLineItem, type InvoiceListItem, type InvoiceListParams, type InvoiceSearchHit, InvoiceStatus, type ListParams, type ListPromise, MeterConfig, type MetricsOverview, type MetricsParams, type MetricsRollup, MigrationResult, type OutboxEventListItem, type OutboxEventListParams, type OutboxEventStatus, type Paginated, PayInvoiceInput, type PaymentMethod, PaymentMethodStatus, type PaymentProviderDefinition, type PortalCardSetupResult, type PortalCheckout, type PortalPlanChange, type PortalSession, type PortalSessionFlow, type PortalSessionInfo, type PortalSubscriptionStatus, type PortalView, type ProviderCredentialSummary, type ProviderVerifyResult, type ProviderVerifyTarget, type ProviderVerifyTargetResult, type PublishCreditRateCardInput, type RecordExternalPaymentInput, type Refund, type RefundChargeInput, type RefundRequestResult, type RefundReviewReason, RefundStatus, RequestOptions, type ResolveRefundInput, type ReverseCreditConsumptionInput, SavedPaymentMethod, type ScheduledSubscriptionChange, type SearchResults, type SubscriptionListItem, type SubscriptionListParams, type SubscriptionSearchHit, SubscriptionStatus, TaxBehavior, type TimeseriesInterval, type TimeseriesMetric, type TimeseriesParams, type TimeseriesPoint, type TimeseriesResult, TrackResult, UnappliedPaymentReason, type UpdateBusinessProfileInput, UpdateCreditPackInput, type UpdateEmailTemplateInput, UpdateFeatureInput, UpdateProductInput, type UpdateWebhookEndpointInput, type UpsertCredentialsInput, UsageAlert, type WebhookDelivery, WebhookDeliveryStatus, type WebhookEndpoint, type WebhookEndpointWithSecret, type Whoami, currencyExponent, formatMoney, isSecretField, toMajorUnits, toMinorUnits };
2976
+ export { AttachResult, BILLOW_ERROR_CODES, Billow, BillowApiError, type BillowErrorCode, BillowOptions, BillowPortal, BillowPublishable, type BusinessProfile, CallOptions, type CatalogItem, Charge, type ChargeListItem, type ChargeListParams, type ChargeSearchHit, ChargeStatus, CheckResult, type CheckoutMethodInfo, type ConfigField, type ConfigFieldOption, type ConfigFieldType, Coupon, CreateChargeInput, CreateCouponInput, CreateCreditGrantInput, CreateCreditIncludedRuleInput, CreateCreditPackInput, type CreateCreditQuoteInput, type CreateCreditReservationInput, CreateCreditTopUpInput, CreateHostedDomainInput, CreateMerchantInitiatedChargeInput, type CreatePortalSessionInput, CreateProductInput, CreateSubscriptionInput, CreateUsageAlertInput, type CreateWebhookEndpointInput, type CredentialSet, CreditBalance, type CreditDimensions, CreditGrant, CreditGrantRequestResult, CreditIncludedRule, CreditLedgerEntry, type CreditLineItem, CreditPack, CreditPacks, type CreditPricedLine, type CreditQuote, type CreditRateCard, type CreditRateCardItem, type CreditReservation, type CreditReservationListParams, type CreditReservationPage, type CreditReservationRequestResult, type CreditReservationStatus, type CreditReversal, type CreditReversalRequestResult, CreditThresholdLevel, CreditTopUp, CreditTopUpListParams, CreditTopUpRequestResult, CreditUsage, CreditUsageParams, type CursorListParams, type CursorListPromise, type CursorPaginated, Customer, type CustomerAnonymizationResult, type CustomerCreditsExport, type CustomerDataExport, type CustomerListItem, type CustomerListParams, type CustomerOverview, type CustomerSearchHit, type CustomerUsage, type CustomerUsageDetail, type EmailDeliveryListItem, type EmailDeliveryListParams, type EmailDeliveryStatus, type EmailTemplateSetting, EntitlementView, type ExchangeRate, type ExportJsonValue, type ExternalPaymentMethod, type ExternalPaymentResult, Feature, FeatureKind, IdempotentRequestOptions, type InboundWebhookListItem, type InboundWebhookListParams, type InboundWebhookOutcome, type IntegrationDefinition, type IntegrationKind, type IntegrationTier, type Invoice, type InvoiceDetail, type InvoiceLineItem, type InvoiceListItem, type InvoiceListParams, type InvoiceSearchHit, InvoiceStatus, type ListParams, type ListPromise, MeterConfig, type MetricsOverview, type MetricsParams, type MetricsRollup, MigrationResult, type OutboxEventListItem, type OutboxEventListParams, type OutboxEventStatus, type Paginated, PayInvoiceInput, type PaymentMethod, PaymentMethodStatus, type PaymentProviderDefinition, type PortalCardSetupResult, type PortalCheckout, type PortalPlanChange, type PortalSession, type PortalSessionExchange, type PortalSessionExchangeInput, type PortalSessionFlow, type PortalSessionInfo, type PortalSubscriptionStatus, type PortalView, type ProviderCredentialSummary, type ProviderVerifyResult, type ProviderVerifyTarget, type ProviderVerifyTargetResult, type PublishCreditRateCardInput, type RecordExternalPaymentInput, type Refund, type RefundChargeInput, type RefundRequestResult, type RefundReviewReason, RefundStatus, RequestOptions, type ResolveRefundInput, type ReverseCreditConsumptionInput, SavedPaymentMethod, type ScheduledSubscriptionChange, type SearchResults, type SubscriptionListItem, type SubscriptionListParams, type SubscriptionSearchHit, SubscriptionStatus, TaxBehavior, type TimeseriesInterval, type TimeseriesMetric, type TimeseriesParams, type TimeseriesPoint, type TimeseriesResult, TrackResult, UnappliedPaymentReason, type UpdateBusinessProfileInput, UpdateCreditIncludedRuleInput, UpdateCreditPackInput, type UpdateEmailTemplateInput, UpdateFeatureInput, UpdateProductInput, type UpdateWebhookEndpointInput, type UpsertCredentialsInput, UsageAlert, type WebhookDelivery, WebhookDeliveryStatus, type WebhookEndpoint, type WebhookEndpointWithSecret, type Whoami, currencyExponent, formatMoney, isSecretField, toMajorUnits, toMinorUnits };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { BILLOW_ERROR_CODES, Billow, BillowApiError, BillowPortal, BillowPublishable, currencyExponent, formatMoney, isSecretField, toMajorUnits, toMinorUnits } from './chunk-DYWGZRE2.js';
1
+ export { BILLOW_ERROR_CODES, Billow, BillowApiError, BillowPortal, BillowPublishable, currencyExponent, formatMoney, isSecretField, toMajorUnits, toMinorUnits } from './chunk-J6JIZGWB.js';
2
2
  export { ACTIVE_SUBSCRIPTION_STATUSES, CHARGE_STATUSES, INVOICE_STATUSES, NEVER_ACTIVATED_SUBSCRIPTION_STATUSES, PAYMENT_METHOD_STATUSES, REFUND_STATUSES, SUBSCRIPTION_STATUSES, TERMINAL_SUBSCRIPTION_STATUSES, WEBHOOK_DELIVERY_STATUSES, grantsAccess, isTerminal } from './chunk-CCG4F5FK.js';
3
3
  //# sourceMappingURL=index.js.map
4
4
  //# sourceMappingURL=index.js.map
@@ -4,7 +4,7 @@ import 'zod';
4
4
  import './billing-status-BZQN_gm7.cjs';
5
5
  import './status.cjs';
6
6
  import './billing-B-VyZCXV.cjs';
7
- import './hosted-domains-BtCd-Rur.cjs';
7
+ import './hosted-domains-BbuyxnuH.cjs';
8
8
 
9
9
  /**
10
10
  * Auto-metering (PRD-16): ingestion strategies that call billow's `track()` for you,
@@ -4,7 +4,7 @@ import 'zod';
4
4
  import './billing-status-BZQN_gm7.js';
5
5
  import './status.js';
6
6
  import './billing-CgjcWmvb.js';
7
- import './hosted-domains-CrVDsk2i.js';
7
+ import './hosted-domains-BP91tg9P.js';
8
8
 
9
9
  /**
10
10
  * Auto-metering (PRD-16): ingestion strategies that call billow's `track()` for you,