@leaflow/sdk 0.163.1 → 0.165.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.
Files changed (35) hide show
  1. package/dist/account/v1/generated/functions.d.ts +29 -29
  2. package/dist/account/v1/generated/functions.js +36 -44
  3. package/dist/account/v1/generated/models.d.ts +6 -5
  4. package/dist/account/v1/generated/models.js +0 -4
  5. package/dist/account/v1/generated/schemas.zod.d.ts +2 -2
  6. package/dist/account/v1/generated/schemas.zod.js +6 -3
  7. package/dist/account/v1/generated/validators/{requestAccountDeletionRequestBody.zod.d.ts → requestAccountDeletionParams.zod.d.ts} +3 -3
  8. package/dist/account/v1/generated/validators/{requestAccountDeletionRequestBody.zod.js → requestAccountDeletionParams.zod.js} +2 -4
  9. package/dist/assistant/v1/generated/functions.js +17 -17
  10. package/dist/billing/v1/generated/functions.d.ts +3 -23
  11. package/dist/billing/v1/generated/functions.js +18 -50
  12. package/dist/billing/v1/generated/models.d.ts +51 -52
  13. package/dist/billing/v1/generated/validators/cancellationCreate.zod.js +1 -1
  14. package/dist/billing/v1/generated/validators/quote.zod.d.ts +39 -0
  15. package/dist/billing/v1/generated/validators/quote.zod.js +7 -3
  16. package/dist/billing/v1/generated/validators/{cancellationPreviewRequest.zod.d.ts → quoteCancellation.zod.d.ts} +4 -5
  17. package/dist/billing/v1/generated/validators/{cancellationPreviewRequest.zod.js → quoteCancellation.zod.js} +4 -8
  18. package/dist/billing/v1/generated/validators/{cancellationRefundPreviewItem.zod.d.ts → quoteCancellationItem.zod.d.ts} +3 -3
  19. package/dist/billing/v1/generated/validators/{cancellationRefundPreviewItem.zod.js → quoteCancellationItem.zod.js} +2 -2
  20. package/dist/billing/v1/generated/validators/{cancellationRefundPreview.zod.d.ts → quoteCancellationResult.zod.d.ts} +3 -5
  21. package/dist/billing/v1/generated/validators/{cancellationRefundPreview.zod.js → quoteCancellationResult.zod.js} +4 -9
  22. package/dist/billing/v1/generated/validators/quoteRequest.zod.d.ts +7 -0
  23. package/dist/billing/v1/generated/validators/quoteRequest.zod.js +4 -2
  24. package/dist/canopy/v1/generated/functions.js +3 -3
  25. package/dist/canopy/v1/generated/models.d.ts +2 -0
  26. package/dist/canopy/v1/generated/validators/modelBilling.zod.js +1 -1
  27. package/dist/compute/v1/generated/functions.js +14 -14
  28. package/dist/iam/v1/generated/functions.js +1 -1
  29. package/dist/membership/v1/generated/functions.js +4 -4
  30. package/dist/monitoring/v1/generated/functions.js +6 -6
  31. package/dist/notification/v1/generated/functions.js +12 -12
  32. package/dist/routes.d.ts +81 -89
  33. package/dist/routes.js +81 -90
  34. package/dist/support/v1/generated/functions.js +1 -1
  35. package/package.json +1 -1
@@ -82,7 +82,7 @@ export const createWithdrawal = async (withdrawalCreate, options, fetchFn) => {
82
82
  return { data, status: res.status, headers: res.headers };
83
83
  };
84
84
  export const getPreviewWithdrawalUrl = () => {
85
- return `https://billing.leaflow.cloud/api/v1/withdrawals/preview`;
85
+ return `https://billing.leaflow.cloud/api/v1/withdrawals:preview`;
86
86
  };
87
87
  /**
88
88
  * Previews the balance deduction, fees and refund split by original top-up. Omit amount to preview all available balance. Nothing is created or reserved. Fails when a selected source has no refund route or its original processing cost is not yet known.
@@ -386,7 +386,7 @@ export const updateBillingAccount = async (accountId, billingAccountUpdate, opti
386
386
  return { data, status: res.status, headers: res.headers };
387
387
  };
388
388
  export const getSuspendBillingAccountUrl = (accountId) => {
389
- return `https://billing.leaflow.cloud/api/v1/billing-accounts/${encodeURIComponent(String(accountId))}/suspend`;
389
+ return `https://billing.leaflow.cloud/api/v1/billing-accounts/${encodeURIComponent(String(accountId))}:suspend`;
390
390
  };
391
391
  /**
392
392
  * Suspends your active billing account without closing it, also while it is in arrears. While suspended, it
@@ -406,7 +406,7 @@ export const suspendBillingAccount = async (accountId, options, fetchFn) => {
406
406
  return { data, status: res.status, headers: res.headers };
407
407
  };
408
408
  export const getResumeBillingAccountUrl = (accountId) => {
409
- return `https://billing.leaflow.cloud/api/v1/billing-accounts/${encodeURIComponent(String(accountId))}/resume`;
409
+ return `https://billing.leaflow.cloud/api/v1/billing-accounts/${encodeURIComponent(String(accountId))}:resume`;
410
410
  };
411
411
  /**
412
412
  * Resumes a billing account you suspended. Refused with `BILLING_ACCOUNT_SUSPENDED_BY_OPERATOR` when Leaflow
@@ -656,7 +656,7 @@ export const getTopUp = async (topUpId, options, fetchFn) => {
656
656
  return { data, status: res.status, headers: res.headers };
657
657
  };
658
658
  export const getCancelTopUpUrl = (topUpId) => {
659
- return `https://billing.leaflow.cloud/api/v1/top-ups/${encodeURIComponent(String(topUpId))}/cancel`;
659
+ return `https://billing.leaflow.cloud/api/v1/top-ups/${encodeURIComponent(String(topUpId))}:cancel`;
660
660
  };
661
661
  /**
662
662
  * Withdraws a pending top-up of the authenticated user at the payment gateway. It becomes `canceled` with
@@ -769,7 +769,7 @@ export const deletePaymentMethod = async (paymentMethodId, options, fetchFn) =>
769
769
  return { data, status: res.status, headers: res.headers };
770
770
  };
771
771
  export const getPayInvoiceUrl = (invoiceId) => {
772
- return `https://billing.leaflow.cloud/api/v1/invoices/${encodeURIComponent(String(invoiceId))}/pay`;
772
+ return `https://billing.leaflow.cloud/api/v1/invoices/${encodeURIComponent(String(invoiceId))}:pay`;
773
773
  };
774
774
  /**
775
775
  * Pays the invoice from eligible credit grants and balance as requested, and collects the remainder through the
@@ -831,8 +831,8 @@ export const getPreviewInvoicePaymentUrl = (invoiceId, params) => {
831
831
  });
832
832
  const stringifiedParams = normalizedParams.toString();
833
833
  return stringifiedParams.length > 0
834
- ? `https://billing.leaflow.cloud/api/v1/invoices/${encodeURIComponent(String(invoiceId))}/payment-preview?${stringifiedParams}`
835
- : `https://billing.leaflow.cloud/api/v1/invoices/${encodeURIComponent(String(invoiceId))}/payment-preview`;
834
+ ? `https://billing.leaflow.cloud/api/v1/invoices/${encodeURIComponent(String(invoiceId))}:previewPayment?${stringifiedParams}`
835
+ : `https://billing.leaflow.cloud/api/v1/invoices/${encodeURIComponent(String(invoiceId))}:previewPayment`;
836
836
  };
837
837
  /**
838
838
  * What paying this invoice now would take from credit grants, from the balance and, for the rest,
@@ -897,7 +897,7 @@ export const payTogether = async (payTogetherRequest, options, fetchFn) => {
897
897
  return { data, status: res.status, headers: res.headers };
898
898
  };
899
899
  export const getPreviewPayTogetherUrl = () => {
900
- return `https://billing.leaflow.cloud/api/v1/payments/preview`;
900
+ return `https://billing.leaflow.cloud/api/v1/payments:preview`;
901
901
  };
902
902
  /**
903
903
  * What paying these invoices together now would take from credit grants and from the balance, per invoice in payment order, calculated as paying together does. Nothing is charged, reserved or created. Refused with the same errors as paying together, except that insufficient funds show as a `gateway_amount` above zero instead of an error.
@@ -1244,7 +1244,7 @@ export const deleteSubscription = async (subscriptionId, options, fetchFn) => {
1244
1244
  return { data, status: res.status, headers: res.headers };
1245
1245
  };
1246
1246
  export const getCancelSubscriptionUrl = (subscriptionId) => {
1247
- return `https://billing.leaflow.cloud/api/v1/subscriptions/${encodeURIComponent(String(subscriptionId))}/cancel`;
1247
+ return `https://billing.leaflow.cloud/api/v1/subscriptions/${encodeURIComponent(String(subscriptionId))}:cancel`;
1248
1248
  };
1249
1249
  /**
1250
1250
  * Requests cancellation on the purchase's agreed terms, with the same rules as creating a cancellation. Give the
@@ -1290,7 +1290,8 @@ export const getGetQuoteUrl = () => {
1290
1290
  };
1291
1291
  /**
1292
1292
  * Calculates what a proposed purchase, a change of your subscriptions or their renewal would invoice now, and
1293
- * what each purchased or changed line renews at. Nothing is saved, reserved or redeemed.
1293
+ * what each purchased or changed line renews at, or what ending subscriptions would return. Nothing is saved,
1294
+ * reserved, redeemed or canceled.
1294
1295
  *
1295
1296
  * With `billing_account_id`, the quote is for that billing account: its currency, account discounts,
1296
1297
  * tax and funds apply, changes and renewals use the account currently paying for each subscription, and an
@@ -1457,39 +1458,6 @@ export const createCancellation = async (cancellationCreate, options, fetchFn) =
1457
1458
  const data = body ? JSON.parse(body) : {};
1458
1459
  return { data, status: res.status, headers: res.headers };
1459
1460
  };
1460
- export const getPreviewCancellationUrl = () => {
1461
- return `https://billing.leaflow.cloud/api/v1/cancellations/preview`;
1462
- };
1463
- /**
1464
- * What creating the cancellation now would return, per subscription and in total. Nothing is canceled, ended or refunded. Open to the owner of the subscriptions' current billing account and to members of their project; refused for the same states as creating it.
1465
- * @summary Preview a cancellation
1466
- */
1467
- export const previewCancellation = async (cancellationPreviewRequest, options, fetchFn) => {
1468
- const getHeaders = (h) => {
1469
- if (!h)
1470
- return {};
1471
- if (h instanceof Headers)
1472
- return Object.fromEntries(h.entries());
1473
- if (Symbol.iterator in h) {
1474
- return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1475
- }
1476
- const headers = {};
1477
- for (const [name, value] of Object.entries(h)) {
1478
- if (value !== undefined)
1479
- headers[name] = value;
1480
- }
1481
- return headers;
1482
- };
1483
- const res = await (fetchFn ?? fetch)(getPreviewCancellationUrl(), {
1484
- ...options,
1485
- method: "QUERY",
1486
- headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
1487
- body: JSON.stringify(cancellationPreviewRequest),
1488
- });
1489
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
1490
- const data = body ? JSON.parse(body) : {};
1491
- return { data, status: res.status, headers: res.headers };
1492
- };
1493
1461
  export const getGetCancellationUrl = (cancellationId) => {
1494
1462
  return `https://billing.leaflow.cloud/api/v1/cancellations/${encodeURIComponent(String(cancellationId))}`;
1495
1463
  };
@@ -1507,7 +1475,7 @@ export const getCancellation = async (cancellationId, options, fetchFn) => {
1507
1475
  return { data, status: res.status, headers: res.headers };
1508
1476
  };
1509
1477
  export const getWithdrawCancellationUrl = (cancellationId) => {
1510
- return `https://billing.leaflow.cloud/api/v1/cancellations/${encodeURIComponent(String(cancellationId))}/withdraw`;
1478
+ return `https://billing.leaflow.cloud/api/v1/cancellations/${encodeURIComponent(String(cancellationId))}:withdraw`;
1511
1479
  };
1512
1480
  /**
1513
1481
  * Withdraws the whole cancellation while no resource has begun to be released; afterwards it is refused with 409 `BILLING_CANCELLATION_CONFLICT`. The subscriptions continue, but automatic renewal, turned off when the cancellation was created, stays off until it is turned on again. Withdrawing a withdrawn cancellation returns it unchanged. Open to the owner of the subscriptions' current billing account and to members of their project with the project permission `billing:finance.manage`.
@@ -1548,7 +1516,7 @@ export const listRenewalPrices = async (subscriptionId, params, options, fetchFn
1548
1516
  return { data, status: res.status, headers: res.headers };
1549
1517
  };
1550
1518
  export const getRenewSubscriptionUrl = (subscriptionId) => {
1551
- return `https://billing.leaflow.cloud/api/v1/subscriptions/${encodeURIComponent(String(subscriptionId))}/renew`;
1519
+ return `https://billing.leaflow.cloud/api/v1/subscriptions/${encodeURIComponent(String(subscriptionId))}:renew`;
1552
1520
  };
1553
1521
  /**
1554
1522
  * Buys licensed periods from current_term_end at the agreed recurring amount and pays for them at once. A
@@ -1791,7 +1759,7 @@ export const getCheckoutSessionQuote = async (checkoutSessionId, params, options
1791
1759
  return { data, status: res.status, headers: res.headers };
1792
1760
  };
1793
1761
  export const getConfirmCheckoutSessionUrl = (checkoutSessionId) => {
1794
- return `https://billing.leaflow.cloud/api/v1/checkout-sessions/${encodeURIComponent(String(checkoutSessionId))}/confirm`;
1762
+ return `https://billing.leaflow.cloud/api/v1/checkout-sessions/${encodeURIComponent(String(checkoutSessionId))}:confirm`;
1795
1763
  };
1796
1764
  /**
1797
1765
  * Completes an open session: applies `promotion_code`, or otherwise the best applicable account discount, checks
@@ -1834,7 +1802,7 @@ export const confirmCheckoutSession = async (checkoutSessionId, checkoutSessionC
1834
1802
  return { data, status: res.status, headers: res.headers };
1835
1803
  };
1836
1804
  export const getExpireCheckoutSessionUrl = (checkoutSessionId) => {
1837
- return `https://billing.leaflow.cloud/api/v1/checkout-sessions/${encodeURIComponent(String(checkoutSessionId))}/expire`;
1805
+ return `https://billing.leaflow.cloud/api/v1/checkout-sessions/${encodeURIComponent(String(checkoutSessionId))}:expire`;
1838
1806
  };
1839
1807
  /**
1840
1808
  * Ends an open session without an order; the service that created it releases what it was holding for the purchase. An expired session is returned unchanged. Open to the owner of the session's billing account and to members of its project.
@@ -1899,8 +1867,8 @@ export const getPreviewOrderRefundUrl = (orderId, params) => {
1899
1867
  });
1900
1868
  const stringifiedParams = normalizedParams.toString();
1901
1869
  return stringifiedParams.length > 0
1902
- ? `https://billing.leaflow.cloud/api/v1/orders/${encodeURIComponent(String(orderId))}/refund-preview?${stringifiedParams}`
1903
- : `https://billing.leaflow.cloud/api/v1/orders/${encodeURIComponent(String(orderId))}/refund-preview`;
1870
+ ? `https://billing.leaflow.cloud/api/v1/orders/${encodeURIComponent(String(orderId))}:previewRefund?${stringifiedParams}`
1871
+ : `https://billing.leaflow.cloud/api/v1/orders/${encodeURIComponent(String(orderId))}:previewRefund`;
1904
1872
  };
1905
1873
  /**
1906
1874
  * What canceling the listed items, or the whole order, would refund to the original payment sources. Nothing is canceled or refunded. Open to the owner of the order's billing account and to members of its project.
@@ -1916,7 +1884,7 @@ export const previewOrderRefund = async (orderId, params, options, fetchFn) => {
1916
1884
  return { data, status: res.status, headers: res.headers };
1917
1885
  };
1918
1886
  export const getCancelOrderUrl = (orderId) => {
1919
- return `https://billing.leaflow.cloud/api/v1/orders/${encodeURIComponent(String(orderId))}/cancel`;
1887
+ return `https://billing.leaflow.cloud/api/v1/orders/${encodeURIComponent(String(orderId))}:cancel`;
1920
1888
  };
1921
1889
  /**
1922
1890
  * Cancels the selected undelivered items of an order that has not been accepted, without recording a delivery
@@ -290,29 +290,6 @@ export interface QuotedDiscount {
290
290
  /** `confirmed`: every condition of the discount holds for the billing account. `unverified`: a quote without an account, where conditions that depend on the account, such as a first purchase or a per-account limit, are checked only when a Checkout Session is completed. */
291
291
  eligibility: QuotedDiscountEligibility;
292
292
  }
293
- /**
294
- * A complete calculation in `currency`; nothing is saved or reserved. The request fails if any item cannot be priced. A Checkout Session quote gives what completing the session would invoice.
295
- */
296
- export interface Quote {
297
- /** Account funds for the quoted purchase. Null without an account. */
298
- funds: Funds | null;
299
- subtotal: Money;
300
- discount_amount: Money;
301
- tax_amount: Money;
302
- /** The discount a purchase would get, not yet applied. Null when there is none, and for renewals. */
303
- discount: QuotedDiscount | null;
304
- items: QuoteItem[];
305
- renewals: QuoteRenewalResult[];
306
- total: Money;
307
- currency: string;
308
- /**
309
- * Immediate changes only; null otherwise. The instant the change is priced from; pass it when confirming the Checkout Session so it is priced from the same instant.
310
- * @nullable
311
- */
312
- proration_date: string | null;
313
- /** `complete`: tax is calculated for the billing account's invoice contact, or for `address` without an account. `requires_location_inputs`: a quote without an account or `address`, which leaves out tax that would be added; tax already contained in a price is included. */
314
- tax_status: QuoteTaxStatus;
315
- }
316
293
  /**
317
294
  * When subscriptions end. immediate ends them now and refunds the unused value under their refund terms; period_end
318
295
  * ends them at the end of their paid period. The cancellation terms fixed when a subscription was bought decide which
@@ -325,23 +302,6 @@ export declare const CancellationMode: {
325
302
  readonly immediate: "immediate";
326
303
  readonly period_end: "period_end";
327
304
  };
328
- /**
329
- * What ending these subscriptions together would return, for one mode; preview `immediate` and `period_end` separately to compare. Refused with 409 `BILLING_SUBSCRIPTION_OPERATION_PENDING` when a subscription is already being canceled (`meta.cancellation_id`), is being reclaimed (`meta.reason` `reclaim_requested`) or has a paid change waiting to switch (`meta.order_id`).
330
- */
331
- export interface CancellationPreviewRequest {
332
- /**
333
- * A billing account you own that currently pays for every subscription.
334
- * @minimum 1
335
- */
336
- billing_account_id: number;
337
- /**
338
- * The subscriptions to end together, all of one service, including every subscription released with a resource.
339
- * @minItems 1
340
- * @maxItems 50
341
- */
342
- subscription_ids: string[];
343
- mode: CancellationMode;
344
- }
345
305
  /**
346
306
  * Which object this is, together with what a person currently calls it.
347
307
  *
@@ -358,9 +318,9 @@ export interface NamedIdentity {
358
318
  name: string;
359
319
  }
360
320
  /**
361
- * One subscription of the previewed cancellation.
321
+ * One subscription of the quoted cancellation.
362
322
  */
363
- export interface CancellationRefundPreviewItem {
323
+ export interface QuoteCancellationItem {
364
324
  subscription_id: string;
365
325
  plan_id: string;
366
326
  plan_name: string;
@@ -379,8 +339,8 @@ export interface CancellationRefundPreviewItem {
379
339
  forfeited_amount: Money;
380
340
  }
381
341
  /**
382
- * What the cancellation would return, per subscription and in total, as of now. Give `proration_date` and
383
- * `refundable_amount` when creating the cancellation.
342
+ * What the cancellation would return, per subscription and in total, as of the quote's `proration_date` for
343
+ * `immediate`. Give that `proration_date` and `refundable_amount` when creating the cancellation.
384
344
  *
385
345
  * - `unused_amount`: before tax, the amount paid for the current periods in proportion to the time remaining.
386
346
  * - `short_rate_surcharge_amount`: before tax, the part of `forfeited_amount` due to the short rate of the
@@ -394,13 +354,10 @@ export interface CancellationRefundPreviewItem {
394
354
  *
395
355
  * Metered and one-time subscriptions show zero; their usage until release is charged as usual.
396
356
  */
397
- export interface CancellationRefundPreview {
357
+ export interface QuoteCancellationResult {
398
358
  mode: CancellationMode;
399
359
  /** For `period_end`, when release begins, the end of the paid terms. */
400
360
  scheduled_at?: string;
401
- /** For `immediate`, the second the refund is computed as of. Give it when creating the cancellation. */
402
- proration_date?: string;
403
- currency: string;
404
361
  unused_amount: Money;
405
362
  short_rate_surcharge_amount: Money;
406
363
  refundable_amount: Money;
@@ -408,7 +365,48 @@ export interface CancellationRefundPreview {
408
365
  credit_amount: Money;
409
366
  tax_amount: Money;
410
367
  forfeited_amount: Money;
411
- items: CancellationRefundPreviewItem[];
368
+ items: QuoteCancellationItem[];
369
+ }
370
+ /**
371
+ * A complete calculation in `currency`; nothing is saved or reserved. The request fails if any item cannot be priced. A Checkout Session quote gives what completing the session would invoice.
372
+ */
373
+ export interface Quote {
374
+ /** Account funds for the quoted purchase. Null without an account, and for a cancellation. */
375
+ funds: Funds | null;
376
+ subtotal: Money;
377
+ discount_amount: Money;
378
+ tax_amount: Money;
379
+ /** The discount a purchase would get, not yet applied. Null when there is none, and for renewals and a cancellation. */
380
+ discount: QuotedDiscount | null;
381
+ items: QuoteItem[];
382
+ renewals: QuoteRenewalResult[];
383
+ /** What the cancellation would return. Null unless the request quotes a cancellation. */
384
+ cancellation: QuoteCancellationResult | null;
385
+ total: Money;
386
+ currency: string;
387
+ /**
388
+ * Immediate changes and immediate cancellations only; null otherwise. The instant the change or the refund is priced from; pass it when confirming the Checkout Session or creating the cancellation so it is priced from the same instant.
389
+ * @nullable
390
+ */
391
+ proration_date: string | null;
392
+ /** `complete`: tax is calculated for the billing account's invoice contact, or for `address` without an account. `requires_location_inputs`: a quote without an account or `address`, which leaves out tax that would be added; tax already contained in a price is included. */
393
+ tax_status: QuoteTaxStatus;
394
+ }
395
+ /**
396
+ * Preview ending these subscriptions together in one mode; quote `immediate` and `period_end` separately to
397
+ * compare. Each must currently be paid by `billing_account_id` and be yours to read, as the owner of that account
398
+ * or a member of the subscriptions' project. Refused as creating the cancellation would be, including 409
399
+ * `BILLING_SUBSCRIPTION_OPERATION_PENDING` when a subscription is already being canceled (`meta.cancellation_id`),
400
+ * is being reclaimed (`meta.reason` `reclaim_requested`) or has a paid change waiting to switch (`meta.order_id`).
401
+ */
402
+ export interface QuoteCancellation {
403
+ /**
404
+ * The subscriptions to end together, all of one service, including every subscription released with a resource.
405
+ * @minItems 1
406
+ * @maxItems 50
407
+ */
408
+ subscription_ids: string[];
409
+ mode: CancellationMode;
412
410
  }
413
411
  export interface CancellationCreate {
414
412
  /**
@@ -420,7 +418,7 @@ export interface CancellationCreate {
420
418
  mode: CancellationMode;
421
419
  /** For `immediate`, the quote's `proration_date`: a whole second, not in the future and at most ten minutes old; the refund is computed as of it. Now when omitted. */
422
420
  proration_date?: string;
423
- /** The quote's `refundable_amount`; the cancellation is refused when the refund differs. */
421
+ /** The quote's `cancellation.refundable_amount`; the cancellation is refused when the refund differs. */
424
422
  expected_refundable_amount: Money & string;
425
423
  /**
426
424
  * A note from the account holder, kept with the cancellation.
@@ -2848,11 +2846,11 @@ export interface QuoteAddress {
2848
2846
  state?: string;
2849
2847
  }
2850
2848
  /**
2851
- * Quote proposed items, changes or renewals: exactly one of them. Give exactly one of `billing_account_id` and `currency`; changes and renewals need the account. Promotion codes apply to proposed items and changes. An invalid combination fails with `BILLING_PURCHASE_INVALID` and the field.
2849
+ * Quote proposed items, changes, renewals or a cancellation: exactly one of them. Give exactly one of `billing_account_id` and `currency`; changes, renewals and a cancellation need the account. Promotion codes apply to proposed items and changes. An invalid combination fails with `BILLING_PURCHASE_INVALID` and the field.
2852
2850
  */
2853
2851
  export interface QuoteRequest {
2854
2852
  /**
2855
- * The billing account to price for; it must be yours or currently pay for a project you are a member of, and an access token is required. Renewals must currently be paid by it.
2853
+ * The billing account to price for; it must be yours or currently pay for a project you are a member of, and an access token is required. Renewals and a cancellation must currently be paid by it.
2856
2854
  * @minimum 1
2857
2855
  */
2858
2856
  billing_account_id?: number;
@@ -2880,6 +2878,7 @@ export interface QuoteRequest {
2880
2878
  * @maxItems 100
2881
2879
  */
2882
2880
  changes?: QuoteChangeInput[];
2881
+ cancellation?: QuoteCancellation;
2883
2882
  /** When the changes take effect; defaults to `immediate`. `immediate` prices the rest of the paid period from `proration_date`, charging an upgrade the difference and showing what a downgrade refunds. `period_end` prices the first period at the new terms, which replaces the renewal when the paid period ends. */
2884
2883
  change_effective?: QuoteRequestChangeEffective;
2885
2884
  /** Only with `currency`. Where the customer is, to include the tax that would be added there for a customer who is not tax exempt; `tax_status` is then `complete`. Refused with `billing_account_id`, whose invoice contact decides tax. */
@@ -22,7 +22,7 @@ export const CancellationCreate = zod.strictObject({
22
22
  .datetime({ offset: true })
23
23
  .optional()
24
24
  .describe("For `immediate`, the quote's `proration_date`: a whole second, not in the future and at most ten minutes old; the refund is computed as of it. Now when omitted."),
25
- expected_refundable_amount: Money.and(zod.string().regex(cancellationCreateExpectedRefundableAmountTwoRegExp)).describe("The quote's `refundable_amount`; the cancellation is refused when the refund differs."),
25
+ expected_refundable_amount: Money.and(zod.string().regex(cancellationCreateExpectedRefundableAmountTwoRegExp)).describe("The quote's `cancellation.refundable_amount`; the cancellation is refused when the refund differs."),
26
26
  reason: zod
27
27
  .string()
28
28
  .max(cancellationCreateReasonMax)
@@ -93,6 +93,45 @@ export declare const Quote: zod.ZodObject<{
93
93
  tax_included_amount: zod.ZodString;
94
94
  total: zod.ZodString;
95
95
  }, zod.z.core.$strict>>;
96
+ cancellation: zod.ZodUnion<readonly [zod.ZodObject<{
97
+ mode: zod.ZodEnum<{
98
+ immediate: "immediate";
99
+ period_end: "period_end";
100
+ }>;
101
+ scheduled_at: zod.ZodOptional<zod.z.ZodISODateTime>;
102
+ unused_amount: zod.ZodString;
103
+ short_rate_surcharge_amount: zod.ZodString;
104
+ refundable_amount: zod.ZodString;
105
+ refund_amount: zod.ZodString;
106
+ credit_amount: zod.ZodString;
107
+ tax_amount: zod.ZodString;
108
+ forfeited_amount: zod.ZodString;
109
+ items: zod.ZodArray<zod.ZodObject<{
110
+ subscription_id: zod.ZodUUID;
111
+ plan_id: zod.ZodUUID;
112
+ plan_name: zod.ZodString;
113
+ project: zod.ZodOptional<zod.ZodUnion<readonly [zod.ZodObject<{
114
+ id: zod.ZodUUID;
115
+ name: zod.ZodString;
116
+ }, zod.z.core.$strict>, zod.ZodNull]>>;
117
+ type: zod.ZodEnum<{
118
+ one_time: "one_time";
119
+ recurring: "recurring";
120
+ }>;
121
+ usage_type: zod.ZodEnum<{
122
+ licensed: "licensed";
123
+ metered: "metered";
124
+ }>;
125
+ auto_renew: zod.ZodBoolean;
126
+ unused_amount: zod.ZodString;
127
+ short_rate_surcharge_amount: zod.ZodString;
128
+ refundable_amount: zod.ZodString;
129
+ refund_amount: zod.ZodString;
130
+ credit_amount: zod.ZodString;
131
+ tax_amount: zod.ZodString;
132
+ forfeited_amount: zod.ZodString;
133
+ }, zod.z.core.$strict>>;
134
+ }, zod.z.core.$strict>, zod.ZodNull]>;
96
135
  total: zod.ZodString;
97
136
  currency: zod.ZodString;
98
137
  proration_date: zod.ZodNullable<zod.z.ZodISODateTime>;
@@ -8,6 +8,7 @@
8
8
  import * as zod from "zod";
9
9
  import { Funds } from "./funds.zod.js";
10
10
  import { Money } from "./money.zod.js";
11
+ import { QuoteCancellationResult } from "./quoteCancellationResult.zod.js";
11
12
  import { QuotedDiscount } from "./quotedDiscount.zod.js";
12
13
  import { QuoteItem } from "./quoteItem.zod.js";
13
14
  import { QuoteRenewalResult } from "./quoteRenewalResult.zod.js";
@@ -15,21 +16,24 @@ export const Quote = zod
15
16
  .strictObject({
16
17
  funds: zod
17
18
  .union([Funds, zod.null()])
18
- .describe("Account funds for the quoted purchase. Null without an account."),
19
+ .describe("Account funds for the quoted purchase. Null without an account, and for a cancellation."),
19
20
  subtotal: Money,
20
21
  discount_amount: Money,
21
22
  tax_amount: Money,
22
23
  discount: zod
23
24
  .union([QuotedDiscount, zod.null()])
24
- .describe("The discount a purchase would get, not yet applied. Null when there is none, and for renewals."),
25
+ .describe("The discount a purchase would get, not yet applied. Null when there is none, and for renewals and a cancellation."),
25
26
  items: zod.array(QuoteItem),
26
27
  renewals: zod.array(QuoteRenewalResult),
28
+ cancellation: zod
29
+ .union([QuoteCancellationResult, zod.null()])
30
+ .describe("What the cancellation would return. Null unless the request quotes a cancellation."),
27
31
  total: Money,
28
32
  currency: zod.string(),
29
33
  proration_date: zod.iso
30
34
  .datetime({ offset: true })
31
35
  .nullable()
32
- .describe("Immediate changes only; null otherwise. The instant the change is priced from; pass it when confirming the Checkout Session so it is priced from the same instant."),
36
+ .describe("Immediate changes and immediate cancellations only; null otherwise. The instant the change or the refund is priced from; pass it when confirming the Checkout Session or creating the cancellation so it is priced from the same instant."),
33
37
  tax_status: zod
34
38
  .enum(["complete", "requires_location_inputs"])
35
39
  .describe("`complete`: tax is calculated for the billing account's invoice contact, or for `address` without an account. `requires_location_inputs`: a quote without an account or `address`, which leaves out tax that would be added; tax already contained in a price is included."),
@@ -6,14 +6,13 @@
6
6
  * OpenAPI spec version: v1
7
7
  */
8
8
  import * as zod from "zod";
9
- export declare const cancellationPreviewRequestSubscriptionIdsMax = 50;
10
- export declare const CancellationPreviewRequest: zod.ZodObject<{
11
- billing_account_id: zod.ZodInt;
9
+ export declare const quoteCancellationSubscriptionIdsMax = 50;
10
+ export declare const QuoteCancellation: zod.ZodObject<{
12
11
  subscription_ids: zod.ZodArray<zod.ZodUUID>;
13
12
  mode: zod.ZodEnum<{
14
13
  immediate: "immediate";
15
14
  period_end: "period_end";
16
15
  }>;
17
16
  }, zod.z.core.$strict>;
18
- export type CancellationPreviewRequest = zod.input<typeof CancellationPreviewRequest>;
19
- export type CancellationPreviewRequestOutput = zod.output<typeof CancellationPreviewRequest>;
17
+ export type QuoteCancellation = zod.input<typeof QuoteCancellation>;
18
+ export type QuoteCancellationOutput = zod.output<typeof QuoteCancellation>;
@@ -7,18 +7,14 @@
7
7
  */
8
8
  import * as zod from "zod";
9
9
  import { CancellationMode } from "./cancellationMode.zod.js";
10
- export const cancellationPreviewRequestSubscriptionIdsMax = 50;
11
- export const CancellationPreviewRequest = zod
10
+ export const quoteCancellationSubscriptionIdsMax = 50;
11
+ export const QuoteCancellation = zod
12
12
  .strictObject({
13
- billing_account_id: zod
14
- .int()
15
- .min(1)
16
- .describe("A billing account you own that currently pays for every subscription."),
17
13
  subscription_ids: zod
18
14
  .array(zod.uuid())
19
15
  .min(1)
20
- .max(cancellationPreviewRequestSubscriptionIdsMax)
16
+ .max(quoteCancellationSubscriptionIdsMax)
21
17
  .describe("The subscriptions to end together, all of one service, including every subscription released with a resource."),
22
18
  mode: CancellationMode,
23
19
  })
24
- .describe("What ending these subscriptions together would return, for one mode; preview `immediate` and `period_end` separately to compare. Refused with 409 `BILLING_SUBSCRIPTION_OPERATION_PENDING` when a subscription is already being canceled (`meta.cancellation_id`), is being reclaimed (`meta.reason` `reclaim_requested`) or has a paid change waiting to switch (`meta.order_id`).");
20
+ .describe("Preview ending these subscriptions together in one mode; quote `immediate` and `period_end` separately to\ncompare. Each must currently be paid by `billing_account_id` and be yours to read, as the owner of that account\nor a member of the subscriptions' project. Refused as creating the cancellation would be, including 409\n`BILLING_SUBSCRIPTION_OPERATION_PENDING` when a subscription is already being canceled (`meta.cancellation_id`),\nis being reclaimed (`meta.reason` `reclaim_requested`) or has a paid change waiting to switch (`meta.order_id`).");
@@ -6,7 +6,7 @@
6
6
  * OpenAPI spec version: v1
7
7
  */
8
8
  import * as zod from "zod";
9
- export declare const CancellationRefundPreviewItem: zod.ZodObject<{
9
+ export declare const QuoteCancellationItem: zod.ZodObject<{
10
10
  subscription_id: zod.ZodUUID;
11
11
  plan_id: zod.ZodUUID;
12
12
  plan_name: zod.ZodString;
@@ -31,5 +31,5 @@ export declare const CancellationRefundPreviewItem: zod.ZodObject<{
31
31
  tax_amount: zod.ZodString;
32
32
  forfeited_amount: zod.ZodString;
33
33
  }, zod.z.core.$strict>;
34
- export type CancellationRefundPreviewItem = zod.input<typeof CancellationRefundPreviewItem>;
35
- export type CancellationRefundPreviewItemOutput = zod.output<typeof CancellationRefundPreviewItem>;
34
+ export type QuoteCancellationItem = zod.input<typeof QuoteCancellationItem>;
35
+ export type QuoteCancellationItemOutput = zod.output<typeof QuoteCancellationItem>;
@@ -10,7 +10,7 @@ import { Money } from "./money.zod.js";
10
10
  import { NamedIdentity } from "./namedIdentity.zod.js";
11
11
  import { PriceType } from "./priceType.zod.js";
12
12
  import { UsageType } from "./usageType.zod.js";
13
- export const CancellationRefundPreviewItem = zod
13
+ export const QuoteCancellationItem = zod
14
14
  .strictObject({
15
15
  subscription_id: zod.uuid(),
16
16
  plan_id: zod.uuid(),
@@ -32,4 +32,4 @@ export const CancellationRefundPreviewItem = zod
32
32
  tax_amount: Money,
33
33
  forfeited_amount: Money,
34
34
  })
35
- .describe("One subscription of the previewed cancellation.");
35
+ .describe("One subscription of the quoted cancellation.");
@@ -6,14 +6,12 @@
6
6
  * OpenAPI spec version: v1
7
7
  */
8
8
  import * as zod from "zod";
9
- export declare const CancellationRefundPreview: zod.ZodObject<{
9
+ export declare const QuoteCancellationResult: zod.ZodObject<{
10
10
  mode: zod.ZodEnum<{
11
11
  immediate: "immediate";
12
12
  period_end: "period_end";
13
13
  }>;
14
14
  scheduled_at: zod.ZodOptional<zod.z.ZodISODateTime>;
15
- proration_date: zod.ZodOptional<zod.z.ZodISODateTime>;
16
- currency: zod.ZodString;
17
15
  unused_amount: zod.ZodString;
18
16
  short_rate_surcharge_amount: zod.ZodString;
19
17
  refundable_amount: zod.ZodString;
@@ -47,5 +45,5 @@ export declare const CancellationRefundPreview: zod.ZodObject<{
47
45
  forfeited_amount: zod.ZodString;
48
46
  }, zod.z.core.$strict>>;
49
47
  }, zod.z.core.$strict>;
50
- export type CancellationRefundPreview = zod.input<typeof CancellationRefundPreview>;
51
- export type CancellationRefundPreviewOutput = zod.output<typeof CancellationRefundPreview>;
48
+ export type QuoteCancellationResult = zod.input<typeof QuoteCancellationResult>;
49
+ export type QuoteCancellationResultOutput = zod.output<typeof QuoteCancellationResult>;
@@ -7,20 +7,15 @@
7
7
  */
8
8
  import * as zod from "zod";
9
9
  import { CancellationMode } from "./cancellationMode.zod.js";
10
- import { CancellationRefundPreviewItem } from "./cancellationRefundPreviewItem.zod.js";
11
10
  import { Money } from "./money.zod.js";
12
- export const CancellationRefundPreview = zod
11
+ import { QuoteCancellationItem } from "./quoteCancellationItem.zod.js";
12
+ export const QuoteCancellationResult = zod
13
13
  .strictObject({
14
14
  mode: CancellationMode,
15
15
  scheduled_at: zod.iso
16
16
  .datetime({ offset: true })
17
17
  .optional()
18
18
  .describe("For `period_end`, when release begins, the end of the paid terms."),
19
- proration_date: zod.iso
20
- .datetime({ offset: true })
21
- .optional()
22
- .describe("For `immediate`, the second the refund is computed as of. Give it when creating the cancellation."),
23
- currency: zod.string(),
24
19
  unused_amount: Money,
25
20
  short_rate_surcharge_amount: Money,
26
21
  refundable_amount: Money,
@@ -28,6 +23,6 @@ export const CancellationRefundPreview = zod
28
23
  credit_amount: Money,
29
24
  tax_amount: Money,
30
25
  forfeited_amount: Money,
31
- items: zod.array(CancellationRefundPreviewItem),
26
+ items: zod.array(QuoteCancellationItem),
32
27
  })
33
- .describe("What the cancellation would return, per subscription and in total, as of now. Give `proration_date` and\n`refundable_amount` when creating the cancellation.\n\n- `unused_amount`: before tax, the amount paid for the current periods in proportion to the time remaining.\n- `short_rate_surcharge_amount`: before tax, the part of `forfeited_amount` due to the short rate of the\n refund policy.\n- `refundable_amount`: what is returned the way it was paid, tax included; `refund_amount` plus\n `credit_amount`.\n- `refund_amount`: the part returned to the balance or the payment method.\n- `credit_amount`: the part restored to the credit grants that paid.\n- `tax_amount`: the tax included in `refundable_amount`.\n- `forfeited_amount`: before tax, the part of `unused_amount` the refund terms do not return.\n\nMetered and one-time subscriptions show zero; their usage until release is charged as usual.");
28
+ .describe("What the cancellation would return, per subscription and in total, as of the quote's `proration_date` for\n`immediate`. Give that `proration_date` and `refundable_amount` when creating the cancellation.\n\n- `unused_amount`: before tax, the amount paid for the current periods in proportion to the time remaining.\n- `short_rate_surcharge_amount`: before tax, the part of `forfeited_amount` due to the short rate of the\n refund policy.\n- `refundable_amount`: what is returned the way it was paid, tax included; `refund_amount` plus\n `credit_amount`.\n- `refund_amount`: the part returned to the balance or the payment method.\n- `credit_amount`: the part restored to the credit grants that paid.\n- `tax_amount`: the tax included in `refundable_amount`.\n- `forfeited_amount`: before tax, the part of `unused_amount` the refund terms do not return.\n\nMetered and one-time subscriptions show zero; their usage until release is charged as usual.");
@@ -87,6 +87,13 @@ export declare const QuoteRequest: zod.ZodObject<{
87
87
  quantity: zod.ZodString;
88
88
  dimensions: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodString>>;
89
89
  }, zod.z.core.$strict>>>;
90
+ cancellation: zod.ZodOptional<zod.ZodObject<{
91
+ subscription_ids: zod.ZodArray<zod.ZodUUID>;
92
+ mode: zod.ZodEnum<{
93
+ immediate: "immediate";
94
+ period_end: "period_end";
95
+ }>;
96
+ }, zod.z.core.$strict>>;
90
97
  change_effective: zod.ZodOptional<zod.ZodEnum<{
91
98
  immediate: "immediate";
92
99
  period_end: "period_end";
@@ -7,6 +7,7 @@
7
7
  */
8
8
  import * as zod from "zod";
9
9
  import { QuoteAddress } from "./quoteAddress.zod.js";
10
+ import { QuoteCancellation } from "./quoteCancellation.zod.js";
10
11
  import { QuoteChangeInput } from "./quoteChangeInput.zod.js";
11
12
  import { QuoteItemInput } from "./quoteItemInput.zod.js";
12
13
  import { QuoteRenewal } from "./quoteRenewal.zod.js";
@@ -22,7 +23,7 @@ export const QuoteRequest = zod
22
23
  .int()
23
24
  .min(1)
24
25
  .optional()
25
- .describe("The billing account to price for; it must be yours or currently pay for a project you are a member of, and an access token is required. Renewals must currently be paid by it."),
26
+ .describe("The billing account to price for; it must be yours or currently pay for a project you are a member of, and an access token is required. Renewals and a cancellation must currently be paid by it."),
26
27
  currency: zod
27
28
  .string()
28
29
  .min(quoteRequestCurrencyMin)
@@ -47,6 +48,7 @@ export const QuoteRequest = zod
47
48
  .max(quoteRequestChangesMax)
48
49
  .optional()
49
50
  .describe("Preview changing these subscriptions in one order, each at most once. Each must currently be paid by `billing_account_id` and be yours to read, as the owner of that account or a member of the subscription's project; all must belong to the same project, or all to no project."),
51
+ cancellation: QuoteCancellation.optional(),
50
52
  change_effective: zod
51
53
  .enum(["immediate", "period_end"])
52
54
  .optional()
@@ -54,4 +56,4 @@ export const QuoteRequest = zod
54
56
  address: QuoteAddress.optional().describe("Only with `currency`. Where the customer is, to include the tax that would be added there for a customer who is not tax exempt; `tax_status` is then `complete`. Refused with `billing_account_id`, whose invoice contact decides tax."),
55
57
  promotion_code: zod.string().min(1).max(quoteRequestPromotionCodeMax).optional(),
56
58
  })
57
- .describe("Quote proposed items, changes or renewals: exactly one of them. Give exactly one of `billing_account_id` and `currency`; changes and renewals need the account. Promotion codes apply to proposed items and changes. An invalid combination fails with `BILLING_PURCHASE_INVALID` and the field.");
59
+ .describe("Quote proposed items, changes, renewals or a cancellation: exactly one of them. Give exactly one of `billing_account_id` and `currency`; changes, renewals and a cancellation need the account. Promotion codes apply to proposed items and changes. An invalid combination fails with `BILLING_PURCHASE_INVALID` and the field.");