@usebillow/sdk 0.7.0 → 0.9.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/config.d.cts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { Billow } from './index.cjs';
2
- import { F as FeatureKind, M as MeterConfig, C as CreateProductInput, a as CreateCouponInput } from './billing-B-VyZCXV.cjs';
3
- import './index.d-CKQAhQfJ.cjs';
2
+ import { F as FeatureKind, M as MeterConfig, C as CreateProductInput, a as CreateCouponInput } from './billing-B16zL5xU.cjs';
3
+ import './index.d-DSEYhV2c.cjs';
4
4
  import 'zod';
5
5
  import './billing-status-BZQN_gm7.cjs';
6
6
  import './status.cjs';
7
- import './hosted-domains-BYYl2DSa.cjs';
7
+ import './hosted-domains-DwakPG4J.cjs';
8
8
 
9
9
  /**
10
10
  * Code-as-config sync (ARCHITECTURE §12 "code-as-config sync"). Keep your catalog
package/dist/config.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { Billow } from './index.js';
2
- import { F as FeatureKind, M as MeterConfig, C as CreateProductInput, a as CreateCouponInput } from './billing-CgjcWmvb.js';
3
- import './index.d-CKQAhQfJ.js';
2
+ import { F as FeatureKind, M as MeterConfig, C as CreateProductInput, a as CreateCouponInput } from './billing-BF4OGaLI.js';
3
+ import './index.d-DSEYhV2c.js';
4
4
  import 'zod';
5
5
  import './billing-status-BZQN_gm7.js';
6
6
  import './status.js';
7
- import './hosted-domains-z_I0edmM.js';
7
+ import './hosted-domains-DSTQ1GZz.js';
8
8
 
9
9
  /**
10
10
  * Code-as-config sync (ARCHITECTURE §12 "code-as-config sync"). Keep your catalog
@@ -1,4 +1,4 @@
1
- import { H as HostedDomainResponse } from './index.d-CKQAhQfJ.js';
1
+ import { H as HostedDomainResponse } from './index.d-DSEYhV2c.js';
2
2
 
3
3
  /**
4
4
  * Public SDK types for prepaid credits. Re-exported by ../types.ts.
@@ -67,9 +67,33 @@ interface CreateCreditGrantInput {
67
67
  }
68
68
  /** A Credit Account's status: `frozen` takes no new reservations; `closed` (erased) takes nothing. */
69
69
  type CreditAccountStatus = "active" | "frozen" | "closed";
70
+ /** What current Included Credit Windows include, and where it stands. */
71
+ interface IncludedCredits {
72
+ /** What the windows include. */
73
+ granted: string;
74
+ /** Consumed from their credits, net of reversals. */
75
+ used: string;
76
+ held: string;
77
+ /** Unheld and spendable, credits recorded but not issued yet included. */
78
+ remaining: string;
79
+ }
80
+ /** One subscription's current Included Credit Window, in a customer's balance. */
81
+ interface IncludedPeriod extends IncludedCredits {
82
+ subscriptionId: string;
83
+ /** The window (ISO 8601), half-open: its credits expire at `end`. */
84
+ start: string;
85
+ end: string;
86
+ /** The billing period it belongs to (a trial's is the trial). */
87
+ periodStart: string;
88
+ periodEnd: string;
89
+ /** The next window's start within the paid period (a monthly refill), or null. */
90
+ nextRefillAt: string | null;
91
+ }
70
92
  /**
71
93
  * A customer's credit balance, true at `asOf`. A balance never grants spending authority - only a
72
- * reservation does. A customer with no credit account yet reads as zeros, `active`, `exhausted`.
94
+ * reservation does. A customer with no credit account yet reads as their subscriptions' recorded
95
+ * included credits alone (zeros without any), `active`, `exhausted` when nothing is spendable.
96
+ * Included credits count from the instant their window is current, before Billow issues them.
73
97
  */
74
98
  interface CreditBalance {
75
99
  /** The customer's external id. */
@@ -79,7 +103,10 @@ interface CreditBalance {
79
103
  spendable: string;
80
104
  /** Credits held by open reservations. */
81
105
  held: string;
82
- /** Credits consumed since `periodStart`, net of reversals. */
106
+ /**
107
+ * Credits consumed since `periodStart`, net of their reversals: a reversal counts against the
108
+ * period of the consumption it reverses, so this is never negative.
109
+ */
83
110
  consumedThisPeriod: string;
84
111
  /** The current included period's start, else the first instant of the current UTC month. */
85
112
  periodStart: string;
@@ -99,22 +126,23 @@ interface CreditBalance {
99
126
  /** Spendable on a category not listed: the grants that pay for every category. */
100
127
  otherCategories: string;
101
128
  };
102
- /** The active included grants (a subscription's period allowance); null when there are none. */
103
- currentPeriod: {
104
- granted: string;
105
- /** Consumed from them, net of reversals. */
106
- used: string;
107
- held: string;
108
- /** Unheld and spendable. */
109
- remaining: string;
129
+ /**
130
+ * The current Included Credit Windows together - the billing period, or the current month under
131
+ * a monthly allocation - across the customer's subscriptions; null when none is current (between
132
+ * a period's end and the payment that grants the next).
133
+ */
134
+ currentPeriod: (IncludedCredits & {
135
+ /** The earliest current window's start. */
110
136
  start: string;
111
- /** When they expire (the period end); null if one never does. */
112
- end: string | null;
113
- } | null;
137
+ /** The earliest current window's end: when the first of these credits stop. */
138
+ end: string;
139
+ }) | null;
140
+ /** Each subscription's current window, soonest end first (empty when none is current). */
141
+ includedPeriods: IncludedPeriod[];
114
142
  thresholds: {
115
143
  lowPercent: number;
116
144
  criticalPercent: number;
117
- /** What the percentages apply to: the current period's credits, else the last top-up's. */
145
+ /** What the percentages apply to: the current windows' credits, else the last top-up's. */
118
146
  reference: string | null;
119
147
  level: CreditThresholdLevel;
120
148
  };
@@ -144,6 +172,8 @@ interface CreditLedgerEntry {
144
172
  callerReason: string | null;
145
173
  /** The metadata of the resource it belongs to: its reservation, reversal or top-up, else its grant. */
146
174
  metadata: Record<string, string> | null;
175
+ /** On an included grant's transaction: the subscription whose window issued the grant. */
176
+ subscriptionId: string | null;
147
177
  createdAt: string;
148
178
  }
149
179
  /** What `credits.usage.get` totals each row by. */
@@ -274,6 +304,121 @@ interface CreditPacks {
274
304
  currency: string;
275
305
  data: CreditPackListItem[];
276
306
  }
307
+ /**
308
+ * How an Included Credit Rule allocates its credits: `billing_period` - the whole period is one
309
+ * window; `month` - each month of the period is its own window, refilled at its start and expiring
310
+ * at its end, with no rollover (only on a Price billed for longer than a month).
311
+ */
312
+ type CreditAllocationInterval = "billing_period" | "month";
313
+ /**
314
+ * An Included Credit Rule: the credits a subscription on a recurring base Price includes for each
315
+ * period Billow grants it. At most one live (not archived) rule per Price. A change takes effect
316
+ * from the next period granted, never on one already granted.
317
+ */
318
+ interface CreditIncludedRule {
319
+ id: string;
320
+ /** The recurring base Price it applies to; never changes. */
321
+ priceId: string;
322
+ /** Microcredits each window includes: per billing period, or per month under `month`. */
323
+ credits: string;
324
+ /** Whether `credits` and `trialCredits` are multiplied by the base item's quantity (per seat). */
325
+ perUnit: boolean;
326
+ /** Microcredits a trial includes, as one window; "0" for none. */
327
+ trialCredits: string;
328
+ allocationInterval: CreditAllocationInterval;
329
+ /** An archived rule includes nothing for periods granted after it was archived. */
330
+ archived: boolean;
331
+ createdAt: string;
332
+ updatedAt: string;
333
+ }
334
+ /**
335
+ * Configure an Included Credit Rule on a recurring base Price (`fixed_recurring` or `licensed`, of
336
+ * a product that is not an add-on).
337
+ */
338
+ interface CreateCreditIncludedRuleInput {
339
+ priceId: string;
340
+ /** Whole microcredits each window includes, as a decimal string; positive. */
341
+ credits: string;
342
+ /**
343
+ * Required: `true` multiplies the credits by the base item's quantity (per-seat credits on a
344
+ * `licensed` Price); `false` includes them once per subscription whatever the quantity.
345
+ */
346
+ perUnit: boolean;
347
+ /** Whole microcredits a trial includes, as a decimal string; omit for none. */
348
+ trialCredits?: string;
349
+ /** `billing_period` when omitted; `month` only on a Price billed for longer than a month. */
350
+ allocationInterval?: CreditAllocationInterval;
351
+ }
352
+ /**
353
+ * Edit an Included Credit Rule: any of its terms, or `archived` (`false` brings it back while its
354
+ * Price has no other live rule). Its Price never changes.
355
+ */
356
+ type UpdateCreditIncludedRuleInput = Partial<Omit<CreateCreditIncludedRuleInput, "priceId">> & {
357
+ archived?: boolean;
358
+ };
359
+ /**
360
+ * Where an Included Credit Window stands: `scheduled` (a later window, not started), `pending`
361
+ * (current, waiting to be issued - Billow issues it within seconds), `blocked` (current, but its
362
+ * last issue attempt could not go through - see `blockedCause` - and Billow retries it with
363
+ * backoff), `issued`, `suspended` (held by a pause), `lapsed` (over without being issued: a period
364
+ * paid after it ended, or one that passed while paused), `ended` (ended early, with `endCause`),
365
+ * or `account_closed` (the customer was erased, so it never issues).
366
+ */
367
+ type CreditWindowState = "scheduled" | "pending" | "blocked" | "issued" | "suspended" | "lapsed" | "ended" | "account_closed";
368
+ /**
369
+ * An Included Credit Window: what one window of a period Billow granted a subscription includes -
370
+ * the whole billing period, one month of it under a monthly rule, or a trial - and how far its
371
+ * credits have been issued.
372
+ */
373
+ interface CreditIncludedWindow {
374
+ id: string;
375
+ subscriptionId: string;
376
+ /** The customer's external id. */
377
+ customerId: string;
378
+ /** The window (ISO 8601), half-open: its credits expire at `end`. */
379
+ start: string;
380
+ end: string;
381
+ /** The billing period it belongs to (a trial's is the trial). */
382
+ periodStart: string;
383
+ periodEnd: string;
384
+ /** The next window's start within the period (a monthly refill), or null for its last window. */
385
+ nextRefillAt: string | null;
386
+ /** How the rule allocated the period when it was granted. */
387
+ allocation: CreditAllocationInterval;
388
+ /** The categories its credits may pay for; null = every category. */
389
+ eligibility: string[] | null;
390
+ /** Microcredits the window includes. */
391
+ entitled: string;
392
+ /** Microcredits issued to the customer for it so far. */
393
+ issued: string;
394
+ state: CreditWindowState;
395
+ /**
396
+ * For a `blocked` window: `capacity` (its credits would take the customer's balance past the
397
+ * largest total Billow holds) or `error` (an unexpected fault); null otherwise.
398
+ */
399
+ blockedCause: "capacity" | "error" | null;
400
+ /** For a `pending` or `blocked` window: since when it has been due. */
401
+ dueSince: string | null;
402
+ endedAt: string | null;
403
+ endCause: "canceled" | "charged_back" | null;
404
+ createdAt: string;
405
+ }
406
+ /**
407
+ * Whose Included Credit Windows to list: one or more subscriptions, or a customer (by external id)
408
+ * - exactly one of the two.
409
+ */
410
+ type CreditIncludedWindowListParams = ({
411
+ subscription: string | string[];
412
+ customer?: never;
413
+ } | {
414
+ customer: string;
415
+ subscription?: never;
416
+ }) & {
417
+ /** Only each subscription's latest window that has started (what the subscription shows now). */
418
+ current?: boolean;
419
+ limit?: number;
420
+ cursor?: string;
421
+ };
277
422
  /**
278
423
  * A top-up's state: `pending` until its payment settles; `succeeded` (credits granted) or
279
424
  * `failed` (a later payment on the same checkout still succeeds it); `unfulfilled` - paid after
@@ -375,4 +520,4 @@ interface HostedDomainDisabledData extends HostedDomainEventBase {
375
520
  reason: Extract<HostedDomainStatusReason, "dns_lost" | "reassigned" | "entitlement_lapsed" | "suspended">;
376
521
  }
377
522
 
378
- export type { HostedDomainStatus as A, HostedDomainStatusReason as B, CreditGrantKind as C, HostedDomainActivatedData as H, UpdateCreditPackInput as U, CreditThresholdLevel as a, HostedDomainDnsFailingData as b, HostedDomainReassignmentPendingData as c, HostedDomainDisabledData as d, CreditGrant as e, CreditTopUp as f, CreateCreditGrantInput as g, CreditGrantRequestResult as h, CreditPacks as i, CreateCreditPackInput as j, CreditPack as k, CreateCreditTopUpInput as l, CreditTopUpRequestResult as m, CreditTopUpListParams as n, CreditBalance as o, CreditLedgerEntry as p, CreditUsageParams as q, CreditUsage as r, CreditAccountStatus as s, CreditMoney as t, CreditPackBreakdown as u, CreditPackListItem as v, CreditTopUpStatus as w, CreditTransactionType as x, CreditUsageGroupBy as y, HostedDomainEventBase as z };
523
+ export type { CreditPackBreakdown as A, CreditPackListItem as B, CreditGrantKind as C, CreditTopUpStatus as D, CreditTransactionType as E, CreditUsageGroupBy as F, CreditWindowState as G, HostedDomainActivatedData as H, HostedDomainEventBase as I, HostedDomainStatus as J, HostedDomainStatusReason as K, IncludedCredits as L, IncludedPeriod as M, UpdateCreditPackInput as U, CreditThresholdLevel as a, HostedDomainDnsFailingData as b, HostedDomainReassignmentPendingData as c, HostedDomainDisabledData as d, CreditGrant as e, CreditTopUp as f, CreditIncludedWindow as g, CreateCreditGrantInput as h, CreditGrantRequestResult as i, CreditPacks as j, CreateCreditPackInput as k, CreditPack as l, CreateCreditIncludedRuleInput as m, CreditIncludedRule as n, UpdateCreditIncludedRuleInput as o, CreditIncludedWindowListParams as p, CreateCreditTopUpInput as q, CreditTopUpRequestResult as r, CreditTopUpListParams as s, CreditBalance as t, CreditLedgerEntry as u, CreditUsageParams as v, CreditUsage as w, CreditAccountStatus as x, CreditAllocationInterval as y, CreditMoney as z };
@@ -1,4 +1,4 @@
1
- import { H as HostedDomainResponse } from './index.d-CKQAhQfJ.cjs';
1
+ import { H as HostedDomainResponse } from './index.d-DSEYhV2c.cjs';
2
2
 
3
3
  /**
4
4
  * Public SDK types for prepaid credits. Re-exported by ../types.ts.
@@ -67,9 +67,33 @@ interface CreateCreditGrantInput {
67
67
  }
68
68
  /** A Credit Account's status: `frozen` takes no new reservations; `closed` (erased) takes nothing. */
69
69
  type CreditAccountStatus = "active" | "frozen" | "closed";
70
+ /** What current Included Credit Windows include, and where it stands. */
71
+ interface IncludedCredits {
72
+ /** What the windows include. */
73
+ granted: string;
74
+ /** Consumed from their credits, net of reversals. */
75
+ used: string;
76
+ held: string;
77
+ /** Unheld and spendable, credits recorded but not issued yet included. */
78
+ remaining: string;
79
+ }
80
+ /** One subscription's current Included Credit Window, in a customer's balance. */
81
+ interface IncludedPeriod extends IncludedCredits {
82
+ subscriptionId: string;
83
+ /** The window (ISO 8601), half-open: its credits expire at `end`. */
84
+ start: string;
85
+ end: string;
86
+ /** The billing period it belongs to (a trial's is the trial). */
87
+ periodStart: string;
88
+ periodEnd: string;
89
+ /** The next window's start within the paid period (a monthly refill), or null. */
90
+ nextRefillAt: string | null;
91
+ }
70
92
  /**
71
93
  * A customer's credit balance, true at `asOf`. A balance never grants spending authority - only a
72
- * reservation does. A customer with no credit account yet reads as zeros, `active`, `exhausted`.
94
+ * reservation does. A customer with no credit account yet reads as their subscriptions' recorded
95
+ * included credits alone (zeros without any), `active`, `exhausted` when nothing is spendable.
96
+ * Included credits count from the instant their window is current, before Billow issues them.
73
97
  */
74
98
  interface CreditBalance {
75
99
  /** The customer's external id. */
@@ -79,7 +103,10 @@ interface CreditBalance {
79
103
  spendable: string;
80
104
  /** Credits held by open reservations. */
81
105
  held: string;
82
- /** Credits consumed since `periodStart`, net of reversals. */
106
+ /**
107
+ * Credits consumed since `periodStart`, net of their reversals: a reversal counts against the
108
+ * period of the consumption it reverses, so this is never negative.
109
+ */
83
110
  consumedThisPeriod: string;
84
111
  /** The current included period's start, else the first instant of the current UTC month. */
85
112
  periodStart: string;
@@ -99,22 +126,23 @@ interface CreditBalance {
99
126
  /** Spendable on a category not listed: the grants that pay for every category. */
100
127
  otherCategories: string;
101
128
  };
102
- /** The active included grants (a subscription's period allowance); null when there are none. */
103
- currentPeriod: {
104
- granted: string;
105
- /** Consumed from them, net of reversals. */
106
- used: string;
107
- held: string;
108
- /** Unheld and spendable. */
109
- remaining: string;
129
+ /**
130
+ * The current Included Credit Windows together - the billing period, or the current month under
131
+ * a monthly allocation - across the customer's subscriptions; null when none is current (between
132
+ * a period's end and the payment that grants the next).
133
+ */
134
+ currentPeriod: (IncludedCredits & {
135
+ /** The earliest current window's start. */
110
136
  start: string;
111
- /** When they expire (the period end); null if one never does. */
112
- end: string | null;
113
- } | null;
137
+ /** The earliest current window's end: when the first of these credits stop. */
138
+ end: string;
139
+ }) | null;
140
+ /** Each subscription's current window, soonest end first (empty when none is current). */
141
+ includedPeriods: IncludedPeriod[];
114
142
  thresholds: {
115
143
  lowPercent: number;
116
144
  criticalPercent: number;
117
- /** What the percentages apply to: the current period's credits, else the last top-up's. */
145
+ /** What the percentages apply to: the current windows' credits, else the last top-up's. */
118
146
  reference: string | null;
119
147
  level: CreditThresholdLevel;
120
148
  };
@@ -144,6 +172,8 @@ interface CreditLedgerEntry {
144
172
  callerReason: string | null;
145
173
  /** The metadata of the resource it belongs to: its reservation, reversal or top-up, else its grant. */
146
174
  metadata: Record<string, string> | null;
175
+ /** On an included grant's transaction: the subscription whose window issued the grant. */
176
+ subscriptionId: string | null;
147
177
  createdAt: string;
148
178
  }
149
179
  /** What `credits.usage.get` totals each row by. */
@@ -274,6 +304,121 @@ interface CreditPacks {
274
304
  currency: string;
275
305
  data: CreditPackListItem[];
276
306
  }
307
+ /**
308
+ * How an Included Credit Rule allocates its credits: `billing_period` - the whole period is one
309
+ * window; `month` - each month of the period is its own window, refilled at its start and expiring
310
+ * at its end, with no rollover (only on a Price billed for longer than a month).
311
+ */
312
+ type CreditAllocationInterval = "billing_period" | "month";
313
+ /**
314
+ * An Included Credit Rule: the credits a subscription on a recurring base Price includes for each
315
+ * period Billow grants it. At most one live (not archived) rule per Price. A change takes effect
316
+ * from the next period granted, never on one already granted.
317
+ */
318
+ interface CreditIncludedRule {
319
+ id: string;
320
+ /** The recurring base Price it applies to; never changes. */
321
+ priceId: string;
322
+ /** Microcredits each window includes: per billing period, or per month under `month`. */
323
+ credits: string;
324
+ /** Whether `credits` and `trialCredits` are multiplied by the base item's quantity (per seat). */
325
+ perUnit: boolean;
326
+ /** Microcredits a trial includes, as one window; "0" for none. */
327
+ trialCredits: string;
328
+ allocationInterval: CreditAllocationInterval;
329
+ /** An archived rule includes nothing for periods granted after it was archived. */
330
+ archived: boolean;
331
+ createdAt: string;
332
+ updatedAt: string;
333
+ }
334
+ /**
335
+ * Configure an Included Credit Rule on a recurring base Price (`fixed_recurring` or `licensed`, of
336
+ * a product that is not an add-on).
337
+ */
338
+ interface CreateCreditIncludedRuleInput {
339
+ priceId: string;
340
+ /** Whole microcredits each window includes, as a decimal string; positive. */
341
+ credits: string;
342
+ /**
343
+ * Required: `true` multiplies the credits by the base item's quantity (per-seat credits on a
344
+ * `licensed` Price); `false` includes them once per subscription whatever the quantity.
345
+ */
346
+ perUnit: boolean;
347
+ /** Whole microcredits a trial includes, as a decimal string; omit for none. */
348
+ trialCredits?: string;
349
+ /** `billing_period` when omitted; `month` only on a Price billed for longer than a month. */
350
+ allocationInterval?: CreditAllocationInterval;
351
+ }
352
+ /**
353
+ * Edit an Included Credit Rule: any of its terms, or `archived` (`false` brings it back while its
354
+ * Price has no other live rule). Its Price never changes.
355
+ */
356
+ type UpdateCreditIncludedRuleInput = Partial<Omit<CreateCreditIncludedRuleInput, "priceId">> & {
357
+ archived?: boolean;
358
+ };
359
+ /**
360
+ * Where an Included Credit Window stands: `scheduled` (a later window, not started), `pending`
361
+ * (current, waiting to be issued - Billow issues it within seconds), `blocked` (current, but its
362
+ * last issue attempt could not go through - see `blockedCause` - and Billow retries it with
363
+ * backoff), `issued`, `suspended` (held by a pause), `lapsed` (over without being issued: a period
364
+ * paid after it ended, or one that passed while paused), `ended` (ended early, with `endCause`),
365
+ * or `account_closed` (the customer was erased, so it never issues).
366
+ */
367
+ type CreditWindowState = "scheduled" | "pending" | "blocked" | "issued" | "suspended" | "lapsed" | "ended" | "account_closed";
368
+ /**
369
+ * An Included Credit Window: what one window of a period Billow granted a subscription includes -
370
+ * the whole billing period, one month of it under a monthly rule, or a trial - and how far its
371
+ * credits have been issued.
372
+ */
373
+ interface CreditIncludedWindow {
374
+ id: string;
375
+ subscriptionId: string;
376
+ /** The customer's external id. */
377
+ customerId: string;
378
+ /** The window (ISO 8601), half-open: its credits expire at `end`. */
379
+ start: string;
380
+ end: string;
381
+ /** The billing period it belongs to (a trial's is the trial). */
382
+ periodStart: string;
383
+ periodEnd: string;
384
+ /** The next window's start within the period (a monthly refill), or null for its last window. */
385
+ nextRefillAt: string | null;
386
+ /** How the rule allocated the period when it was granted. */
387
+ allocation: CreditAllocationInterval;
388
+ /** The categories its credits may pay for; null = every category. */
389
+ eligibility: string[] | null;
390
+ /** Microcredits the window includes. */
391
+ entitled: string;
392
+ /** Microcredits issued to the customer for it so far. */
393
+ issued: string;
394
+ state: CreditWindowState;
395
+ /**
396
+ * For a `blocked` window: `capacity` (its credits would take the customer's balance past the
397
+ * largest total Billow holds) or `error` (an unexpected fault); null otherwise.
398
+ */
399
+ blockedCause: "capacity" | "error" | null;
400
+ /** For a `pending` or `blocked` window: since when it has been due. */
401
+ dueSince: string | null;
402
+ endedAt: string | null;
403
+ endCause: "canceled" | "charged_back" | null;
404
+ createdAt: string;
405
+ }
406
+ /**
407
+ * Whose Included Credit Windows to list: one or more subscriptions, or a customer (by external id)
408
+ * - exactly one of the two.
409
+ */
410
+ type CreditIncludedWindowListParams = ({
411
+ subscription: string | string[];
412
+ customer?: never;
413
+ } | {
414
+ customer: string;
415
+ subscription?: never;
416
+ }) & {
417
+ /** Only each subscription's latest window that has started (what the subscription shows now). */
418
+ current?: boolean;
419
+ limit?: number;
420
+ cursor?: string;
421
+ };
277
422
  /**
278
423
  * A top-up's state: `pending` until its payment settles; `succeeded` (credits granted) or
279
424
  * `failed` (a later payment on the same checkout still succeeds it); `unfulfilled` - paid after
@@ -375,4 +520,4 @@ interface HostedDomainDisabledData extends HostedDomainEventBase {
375
520
  reason: Extract<HostedDomainStatusReason, "dns_lost" | "reassigned" | "entitlement_lapsed" | "suspended">;
376
521
  }
377
522
 
378
- export type { HostedDomainStatus as A, HostedDomainStatusReason as B, CreditGrantKind as C, HostedDomainActivatedData as H, UpdateCreditPackInput as U, CreditThresholdLevel as a, HostedDomainDnsFailingData as b, HostedDomainReassignmentPendingData as c, HostedDomainDisabledData as d, CreditGrant as e, CreditTopUp as f, CreateCreditGrantInput as g, CreditGrantRequestResult as h, CreditPacks as i, CreateCreditPackInput as j, CreditPack as k, CreateCreditTopUpInput as l, CreditTopUpRequestResult as m, CreditTopUpListParams as n, CreditBalance as o, CreditLedgerEntry as p, CreditUsageParams as q, CreditUsage as r, CreditAccountStatus as s, CreditMoney as t, CreditPackBreakdown as u, CreditPackListItem as v, CreditTopUpStatus as w, CreditTransactionType as x, CreditUsageGroupBy as y, HostedDomainEventBase as z };
523
+ export type { CreditPackBreakdown as A, CreditPackListItem as B, CreditGrantKind as C, CreditTopUpStatus as D, CreditTransactionType as E, CreditUsageGroupBy as F, CreditWindowState as G, HostedDomainActivatedData as H, HostedDomainEventBase as I, HostedDomainStatus as J, HostedDomainStatusReason as K, IncludedCredits as L, IncludedPeriod as M, UpdateCreditPackInput as U, CreditThresholdLevel as a, HostedDomainDnsFailingData as b, HostedDomainReassignmentPendingData as c, HostedDomainDisabledData as d, CreditGrant as e, CreditTopUp as f, CreditIncludedWindow as g, CreateCreditGrantInput as h, CreditGrantRequestResult as i, CreditPacks as j, CreateCreditPackInput as k, CreditPack as l, CreateCreditIncludedRuleInput as m, CreditIncludedRule as n, UpdateCreditIncludedRuleInput as o, CreditIncludedWindowListParams as p, CreateCreditTopUpInput as q, CreditTopUpRequestResult as r, CreditTopUpListParams as s, CreditBalance as t, CreditLedgerEntry as u, CreditUsageParams as v, CreditUsage as w, CreditAccountStatus as x, CreditAllocationInterval as y, CreditMoney as z };
package/dist/index.cjs CHANGED
@@ -528,6 +528,79 @@ function createCreditsResource(ctx) {
528
528
  options
529
529
  )
530
530
  },
531
+ includedRules: {
532
+ /**
533
+ * Configure an Included Credit Rule on a recurring base Price: the credits a subscription on
534
+ * it includes for each period Billow grants it - per billing period, or per month of a Price
535
+ * billed for longer than a month - and for a trial. Configuration, so no idempotency key:
536
+ * a second live rule for the same Price throws `conflict` (409,
537
+ * `details.reason: "included_rule_exists"`, with the live rule's `ruleId`). Throws
538
+ * `validation_error` (422) with `details.reason: "not_a_base_price"` for a Price that is not
539
+ * a recurring base Price, or `"allocation_not_shorter_than_billing"` for a monthly
540
+ * allocation on a Price not billed for longer than a month.
541
+ */
542
+ create: (input, options) => apiRequest(ctx, "POST", "/v1/credits/included-rules", input, options),
543
+ /** A rule, archived or not. */
544
+ get: (ruleId, options) => apiRequest(
545
+ ctx,
546
+ "GET",
547
+ `/v1/credits/included-rules/${encodeURIComponent(ruleId)}`,
548
+ void 0,
549
+ options
550
+ ),
551
+ /**
552
+ * Every rule, archived ones included, newest first. Auto-paginating by cursor: `await` the
553
+ * first page, `for await (…)` every rule, or `.listAll()` to collect them.
554
+ */
555
+ list: (params = {}, options) => makeCursorListPromise(
556
+ (p) => apiRequest(
557
+ ctx,
558
+ "GET",
559
+ `/v1/credits/included-rules${toQuery(p)}`,
560
+ void 0,
561
+ options
562
+ ),
563
+ params
564
+ ),
565
+ /**
566
+ * Edit a rule's credits, per-seat choice, trial credits or allocation interval, or archive
567
+ * it (`archived: false` brings it back). It takes effect from the next period granted;
568
+ * periods already granted keep what they were granted. A rule left live is judged against
569
+ * its Price as it is now, with the same errors as `create`.
570
+ */
571
+ update: (ruleId, input, options) => apiRequest(
572
+ ctx,
573
+ "PATCH",
574
+ `/v1/credits/included-rules/${encodeURIComponent(ruleId)}`,
575
+ input,
576
+ options
577
+ )
578
+ },
579
+ includedWindows: {
580
+ /**
581
+ * The Included Credit Windows of one or more subscriptions (`subscription`, an id or a list
582
+ * of up to 100), or of a customer (`customer`, by external id) - newest first: what each
583
+ * period Billow granted includes (the whole period, each month of it under a monthly rule,
584
+ * or a trial), how far it was issued, and its `state`. With `current: true`, only each
585
+ * subscription's latest window that has started - what it stands at now. Auto-paginating by
586
+ * cursor: `await` the first page, `for await (…)` every window, or `.listAll()` to collect
587
+ * them.
588
+ */
589
+ list: (params, options) => {
590
+ const { subscription, ...rest } = params;
591
+ const subscriptions = Array.isArray(subscription) ? subscription.join(",") : subscription;
592
+ return makeCursorListPromise(
593
+ (p) => apiRequest(
594
+ ctx,
595
+ "GET",
596
+ `/v1/credits/included-windows${toQuery({ ...p, subscription: subscriptions })}`,
597
+ void 0,
598
+ options
599
+ ),
600
+ rest
601
+ );
602
+ }
603
+ },
531
604
  topUps: {
532
605
  /**
533
606
  * Buy a Credit Pack for a customer: answers the top-up with `checkoutUrl`, the hosted
@@ -708,6 +781,24 @@ function createCreditsResource(ctx) {
708
781
  void 0,
709
782
  options
710
783
  ),
784
+ /**
785
+ * Your project's reservations, oldest first, optionally of one `status`, one `customer` (by
786
+ * external id), or protected more than `protectedLongerThan` seconds ago - with
787
+ * `{ status: "protected", protectedLongerThan: page.protectedHoldMaxSeconds }`, the paid
788
+ * operations waiting past your maximum for a decision (commit or release each). Every page
789
+ * carries `protectedHoldMaxSeconds`. Auto-paginating by cursor: `await` the first page,
790
+ * `for await (…)` every reservation, or `.listAll()` to collect them.
791
+ */
792
+ list: (params = {}, options) => makeCursorListPromise(
793
+ (p) => apiRequest(
794
+ ctx,
795
+ "GET",
796
+ `/v1/credits/reservations${toQuery(p)}`,
797
+ void 0,
798
+ options
799
+ ),
800
+ params
801
+ ),
711
802
  /**
712
803
  * A customer's reservation (by external id) made with `operationKey` - how to find one whose
713
804
  * reply was lost. Throws `not_found` (404) when there is none.
@@ -1257,7 +1348,18 @@ function createSubscriptionsResource(ctx) {
1257
1348
  "POST",
1258
1349
  `/v1/subscriptions/${encodeURIComponent(id)}/resume-cancellation`
1259
1350
  ),
1351
+ /**
1352
+ * Pause an active or trialing subscription: no renewals and no access until it is resumed.
1353
+ * Refused while one of its invoices is still being collected.
1354
+ */
1260
1355
  pause: (id) => apiRequest(ctx, "POST", `/v1/subscriptions/${encodeURIComponent(id)}/pause`),
1356
+ /**
1357
+ * Resume a paused subscription. Paused time is never billed: resumed before its paid period
1358
+ * ends, it carries on and renews at `currentPeriodEnd`; resumed after, a fresh full period
1359
+ * starts now and is charged at once like a renewal, with the ended period's usage (a decline
1360
+ * returns it `past_due`). Usage recorded while paused is never billed. A paused trial resumes
1361
+ * `trialing`. Duplicate calls are safe.
1362
+ */
1261
1363
  resume: (id) => apiRequest(ctx, "POST", `/v1/subscriptions/${encodeURIComponent(id)}/resume`),
1262
1364
  /** Apply a coupon to an existing subscription. */
1263
1365
  applyCoupon: (id, code) => apiRequest(