@usebillow/sdk 0.7.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/CHANGELOG.md +7 -0
- package/dist/{chunk-JG2OOAMX.js → chunk-J6JIZGWB.js} +68 -2
- package/dist/chunk-J6JIZGWB.js.map +1 -0
- package/dist/config.d.cts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/{hosted-domains-z_I0edmM.d.ts → hosted-domains-BP91tg9P.d.ts} +53 -1
- package/dist/{hosted-domains-BYYl2DSa.d.cts → hosted-domains-BbuyxnuH.d.cts} +53 -1
- package/dist/index.cjs +66 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +65 -5
- package/dist/index.d.ts +65 -5
- package/dist/index.js +1 -1
- package/dist/ingestion.d.cts +1 -1
- package/dist/ingestion.d.ts +1 -1
- package/dist/react.js +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/webhooks.d.cts +1 -1
- package/dist/webhooks.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-JG2OOAMX.js.map +0 -1
|
@@ -274,6 +274,58 @@ interface CreditPacks {
|
|
|
274
274
|
currency: string;
|
|
275
275
|
data: CreditPackListItem[];
|
|
276
276
|
}
|
|
277
|
+
/**
|
|
278
|
+
* How an Included Credit Rule allocates its credits: `billing_period` - the whole period is one
|
|
279
|
+
* window; `month` - each month of the period is its own window, refilled at its start and expiring
|
|
280
|
+
* at its end, with no rollover (only on a Price billed for longer than a month).
|
|
281
|
+
*/
|
|
282
|
+
type CreditAllocationInterval = "billing_period" | "month";
|
|
283
|
+
/**
|
|
284
|
+
* An Included Credit Rule: the credits a subscription on a recurring base Price includes for each
|
|
285
|
+
* period Billow grants it. At most one live (not archived) rule per Price. A change takes effect
|
|
286
|
+
* from the next period granted, never on one already granted.
|
|
287
|
+
*/
|
|
288
|
+
interface CreditIncludedRule {
|
|
289
|
+
id: string;
|
|
290
|
+
/** The recurring base Price it applies to; never changes. */
|
|
291
|
+
priceId: string;
|
|
292
|
+
/** Microcredits each window includes: per billing period, or per month under `month`. */
|
|
293
|
+
credits: string;
|
|
294
|
+
/** Whether `credits` and `trialCredits` are multiplied by the base item's quantity (per seat). */
|
|
295
|
+
perUnit: boolean;
|
|
296
|
+
/** Microcredits a trial includes, as one window; "0" for none. */
|
|
297
|
+
trialCredits: string;
|
|
298
|
+
allocationInterval: CreditAllocationInterval;
|
|
299
|
+
/** An archived rule includes nothing for periods granted after it was archived. */
|
|
300
|
+
archived: boolean;
|
|
301
|
+
createdAt: string;
|
|
302
|
+
updatedAt: string;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Configure an Included Credit Rule on a recurring base Price (`fixed_recurring` or `licensed`, of
|
|
306
|
+
* a product that is not an add-on).
|
|
307
|
+
*/
|
|
308
|
+
interface CreateCreditIncludedRuleInput {
|
|
309
|
+
priceId: string;
|
|
310
|
+
/** Whole microcredits each window includes, as a decimal string; positive. */
|
|
311
|
+
credits: string;
|
|
312
|
+
/**
|
|
313
|
+
* Required: `true` multiplies the credits by the base item's quantity (per-seat credits on a
|
|
314
|
+
* `licensed` Price); `false` includes them once per subscription whatever the quantity.
|
|
315
|
+
*/
|
|
316
|
+
perUnit: boolean;
|
|
317
|
+
/** Whole microcredits a trial includes, as a decimal string; omit for none. */
|
|
318
|
+
trialCredits?: string;
|
|
319
|
+
/** `billing_period` when omitted; `month` only on a Price billed for longer than a month. */
|
|
320
|
+
allocationInterval?: CreditAllocationInterval;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Edit an Included Credit Rule: any of its terms, or `archived` (`false` brings it back while its
|
|
324
|
+
* Price has no other live rule). Its Price never changes.
|
|
325
|
+
*/
|
|
326
|
+
type UpdateCreditIncludedRuleInput = Partial<Omit<CreateCreditIncludedRuleInput, "priceId">> & {
|
|
327
|
+
archived?: boolean;
|
|
328
|
+
};
|
|
277
329
|
/**
|
|
278
330
|
* A top-up's state: `pending` until its payment settles; `succeeded` (credits granted) or
|
|
279
331
|
* `failed` (a later payment on the same checkout still succeeds it); `unfulfilled` - paid after
|
|
@@ -375,4 +427,4 @@ interface HostedDomainDisabledData extends HostedDomainEventBase {
|
|
|
375
427
|
reason: Extract<HostedDomainStatusReason, "dns_lost" | "reassigned" | "entitlement_lapsed" | "suspended">;
|
|
376
428
|
}
|
|
377
429
|
|
|
378
|
-
export type {
|
|
430
|
+
export type { CreditTopUpStatus as A, CreditTransactionType as B, CreditGrantKind as C, CreditUsageGroupBy as D, HostedDomainEventBase as E, HostedDomainStatus as F, HostedDomainStatusReason as G, 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, CreateCreditIncludedRuleInput as l, CreditIncludedRule as m, UpdateCreditIncludedRuleInput as n, CreateCreditTopUpInput as o, CreditTopUpRequestResult as p, CreditTopUpListParams as q, CreditBalance as r, CreditLedgerEntry as s, CreditUsageParams as t, CreditUsage as u, CreditAccountStatus as v, CreditAllocationInterval as w, CreditMoney as x, CreditPackBreakdown as y, CreditPackListItem as z };
|
package/dist/index.cjs
CHANGED
|
@@ -528,6 +528,54 @@ 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
|
+
},
|
|
531
579
|
topUps: {
|
|
532
580
|
/**
|
|
533
581
|
* Buy a Credit Pack for a customer: answers the top-up with `checkoutUrl`, the hosted
|
|
@@ -708,6 +756,24 @@ function createCreditsResource(ctx) {
|
|
|
708
756
|
void 0,
|
|
709
757
|
options
|
|
710
758
|
),
|
|
759
|
+
/**
|
|
760
|
+
* Your project's reservations, oldest first, optionally of one `status`, one `customer` (by
|
|
761
|
+
* external id), or protected more than `protectedLongerThan` seconds ago - with
|
|
762
|
+
* `{ status: "protected", protectedLongerThan: page.protectedHoldMaxSeconds }`, the paid
|
|
763
|
+
* operations waiting past your maximum for a decision (commit or release each). Every page
|
|
764
|
+
* carries `protectedHoldMaxSeconds`. Auto-paginating by cursor: `await` the first page,
|
|
765
|
+
* `for await (…)` every reservation, or `.listAll()` to collect them.
|
|
766
|
+
*/
|
|
767
|
+
list: (params = {}, options) => makeCursorListPromise(
|
|
768
|
+
(p) => apiRequest(
|
|
769
|
+
ctx,
|
|
770
|
+
"GET",
|
|
771
|
+
`/v1/credits/reservations${toQuery(p)}`,
|
|
772
|
+
void 0,
|
|
773
|
+
options
|
|
774
|
+
),
|
|
775
|
+
params
|
|
776
|
+
),
|
|
711
777
|
/**
|
|
712
778
|
* A customer's reservation (by external id) made with `operationKey` - how to find one whose
|
|
713
779
|
* reply was lost. Throws `not_found` (404) when there is none.
|