@leaflow/sdk 0.0.0-dev.397.g4ade82b → 0.0.0-dev.399.g3371eb3
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/billing/v1/generated/functions.d.ts +3 -23
- package/dist/billing/v1/generated/functions.js +2 -34
- package/dist/billing/v1/generated/models.d.ts +51 -52
- package/dist/billing/v1/generated/validators/cancellationCreate.zod.js +1 -1
- package/dist/billing/v1/generated/validators/quote.zod.d.ts +39 -0
- package/dist/billing/v1/generated/validators/quote.zod.js +7 -3
- package/dist/billing/v1/generated/validators/{cancellationPreviewRequest.zod.d.ts → quoteCancellation.zod.d.ts} +4 -5
- package/dist/billing/v1/generated/validators/{cancellationPreviewRequest.zod.js → quoteCancellation.zod.js} +4 -8
- package/dist/billing/v1/generated/validators/{cancellationRefundPreviewItem.zod.d.ts → quoteCancellationItem.zod.d.ts} +3 -3
- package/dist/billing/v1/generated/validators/{cancellationRefundPreviewItem.zod.js → quoteCancellationItem.zod.js} +2 -2
- package/dist/billing/v1/generated/validators/{cancellationRefundPreview.zod.d.ts → quoteCancellationResult.zod.d.ts} +3 -5
- package/dist/billing/v1/generated/validators/{cancellationRefundPreview.zod.js → quoteCancellationResult.zod.js} +4 -9
- package/dist/billing/v1/generated/validators/quoteRequest.zod.d.ts +7 -0
- package/dist/billing/v1/generated/validators/quoteRequest.zod.js +4 -2
- package/dist/canopy/v1/generated/models.d.ts +2 -0
- package/dist/canopy/v1/generated/validators/modelBilling.zod.js +1 -1
- package/dist/routes.d.ts +0 -8
- package/dist/routes.js +0 -9
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Products, prices, orders, subscriptions and account billing. Operations on a billing account require an account access token. The account, its balance, payment options and quotes are also readable by members of the projects it currently pays for; changing the account and moving its funds need the owner. Members of a project, as each operation states, can also read the project's billing account, subscriptions and orders, complete and pay for its purchases, quote purchases, changes, renewals and cancellations, and, with the project permission `billing:finance.manage` granted in IAM, renew, cancel and turn automatic renewal of its subscriptions on or off, change its billing account and read its costs. A member without the permission an operation needs is refused with 403 `PERMISSION_DENIED` and `meta.permission`; a caller who is not a member, with 403 `IAM_NOT_PROJECT_MEMBER`. Public catalogue operations declare no security requirement.
|
|
6
6
|
* OpenAPI spec version: v1
|
|
7
7
|
*/
|
|
8
|
-
import type { AccountBalance, AccountDeletionReadiness, ActiveResourceList, AllowanceList, AutoRenewSet, BillingAccount, BillingAccountCreate, BillingAccountList, BillingAccountUpdate, CancelSubscriptionRequest, Cancellation, CancellationCreate, CancellationList,
|
|
8
|
+
import type { AccountBalance, AccountDeletionReadiness, ActiveResourceList, AllowanceList, AutoRenewSet, BillingAccount, BillingAccountCreate, BillingAccountList, BillingAccountUpdate, CancelSubscriptionRequest, Cancellation, CancellationCreate, CancellationList, CheckoutSession, CheckoutSessionConfirm, CheckoutSessionCreate, CheckoutSessionItemList, CheckoutSessionList, CheckoutSessionResult, Contact, ContactCreate, ContactList, ContactUpdate, CreditGrantList, CreditNote, CreditNoteItemList, CreditNoteList, CurrencyList, DiscountList, EntitlementList, Error, ErrorResponse, FeatureGrantList, GetCheckoutSessionQuoteParams, GetPlanHeaders, GetPriceHeaders, GetProductHeaders, GetStatementUsageParams, Invoice, InvoiceItemList, InvoiceList, ListAccountDiscountsParams, ListActiveResourcesParams, ListAllowancesParams, ListBillingAccountsParams, ListCancellationsParams, ListCheckoutSessionItemsParams, ListCheckoutSessionsParams, ListContactsParams, ListCreditGrantsParams, ListCreditNoteItemsParams, ListCreditNotesParams, ListCurrenciesParams, ListEntitlementsParams, ListFeatureGrantsParams, ListInvoiceItemsParams, ListInvoicesParams, ListMonthlyStatementsParams, ListOrderItemsParams, ListOrdersParams, ListPaymentMethodsParams, ListPaymentOptionsParams, ListPlansHeaders, ListPlansParams, ListPricesByPlanHeaders, ListPricesByPlanParams, ListPricesHeaders, ListPricesParams, ListProductsHeaders, ListProductsParams, ListProjectAssignmentsParams, ListRefundsParams, ListRenewalPricesParams, ListSpendParams, ListStatementsParams, ListSubscriptionsParams, ListTopUpsParams, ListTransactionsParams, ListUsageChargesParams, ListWithdrawalItemsParams, ListWithdrawalsParams, MonthlyStatementList, NotModifiedResponse, Order, OrderCancel, OrderItemList, OrderList, OrderRefundPreview, PayInvoiceRequest, PayTogetherRequest, PaymentMethod, PaymentMethodList, PaymentMethodSetup, PaymentMethodSetupResult, PaymentOptionList, PaymentPreview, PaymentResult, Plan, PlanList, PreviewInvoicePaymentParams, PreviewOrderRefundParams, Price, PriceList, PriceSearch, Product, ProductID, ProductList, ProjectAssignment, ProjectAssignmentList, Quote, QuoteRequest, RefundList, RenewRequest, RenewalPriceList, SetProjectAssignmentRequest, SpendRowList, Statement, StatementList, StatementSummary, Subscription, SubscriptionList, TopUp, TopUpCreate, TopUpList, TransactionList, UsageChargeList, UsageEstimate, UsageEstimateRequest, Withdrawal, WithdrawalCreate, WithdrawalItemList, WithdrawalList, WithdrawalPreview, WithdrawalPreviewRequest } from "./models.js";
|
|
9
9
|
export type HTTPStatusCode1xx = 100 | 101 | 102 | 103;
|
|
10
10
|
export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207;
|
|
11
11
|
export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308;
|
|
@@ -1175,7 +1175,8 @@ export type getQuoteResponse = getQuoteResponseSuccess | getQuoteResponseError;
|
|
|
1175
1175
|
export declare const getGetQuoteUrl: () => string;
|
|
1176
1176
|
/**
|
|
1177
1177
|
* Calculates what a proposed purchase, a change of your subscriptions or their renewal would invoice now, and
|
|
1178
|
-
* what each purchased or changed line renews at. Nothing is saved,
|
|
1178
|
+
* what each purchased or changed line renews at, or what ending subscriptions would return. Nothing is saved,
|
|
1179
|
+
* reserved, redeemed or canceled.
|
|
1179
1180
|
*
|
|
1180
1181
|
* With `billing_account_id`, the quote is for that billing account: its currency, account discounts,
|
|
1181
1182
|
* tax and funds apply, changes and renewals use the account currently paying for each subscription, and an
|
|
@@ -1293,27 +1294,6 @@ export declare const getCreateCancellationUrl: () => string;
|
|
|
1293
1294
|
* @summary Cancel subscriptions
|
|
1294
1295
|
*/
|
|
1295
1296
|
export declare const createCancellation: (cancellationCreate: CancellationCreate, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<createCancellationResponse>;
|
|
1296
|
-
export type previewCancellationResponse200 = {
|
|
1297
|
-
data: CancellationRefundPreview;
|
|
1298
|
-
status: 200;
|
|
1299
|
-
};
|
|
1300
|
-
export type previewCancellationResponseDefault = {
|
|
1301
|
-
data: ErrorResponse;
|
|
1302
|
-
status: Exclude<HTTPStatusCodes, 200>;
|
|
1303
|
-
};
|
|
1304
|
-
export type previewCancellationResponseSuccess = previewCancellationResponse200 & {
|
|
1305
|
-
headers: Headers;
|
|
1306
|
-
};
|
|
1307
|
-
export type previewCancellationResponseError = previewCancellationResponseDefault & {
|
|
1308
|
-
headers: Headers;
|
|
1309
|
-
};
|
|
1310
|
-
export type previewCancellationResponse = previewCancellationResponseSuccess | previewCancellationResponseError;
|
|
1311
|
-
export declare const getPreviewCancellationUrl: () => string;
|
|
1312
|
-
/**
|
|
1313
|
-
* 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.
|
|
1314
|
-
* @summary Preview a cancellation
|
|
1315
|
-
*/
|
|
1316
|
-
export declare const previewCancellation: (cancellationPreviewRequest: CancellationPreviewRequest, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<previewCancellationResponse>;
|
|
1317
1297
|
export type getCancellationResponse200 = {
|
|
1318
1298
|
data: Cancellation;
|
|
1319
1299
|
status: 200;
|
|
@@ -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,
|
|
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
|
};
|
|
@@ -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
|
|
321
|
+
* One subscription of the quoted cancellation.
|
|
362
322
|
*/
|
|
363
|
-
export interface
|
|
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
|
|
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
|
|
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:
|
|
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
|
|
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
|
|
10
|
-
export declare const
|
|
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
|
|
19
|
-
export type
|
|
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
|
|
11
|
-
export const
|
|
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(
|
|
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("
|
|
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
|
|
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
|
|
35
|
-
export type
|
|
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
|
|
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
|
|
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
|
|
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
|
|
51
|
-
export type
|
|
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
|
-
|
|
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(
|
|
26
|
+
items: zod.array(QuoteCancellationItem),
|
|
32
27
|
})
|
|
33
|
-
.describe("What the cancellation would return, per subscription and in total, as of
|
|
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
|
|
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.");
|
|
@@ -349,6 +349,8 @@ export interface ModelMeter {
|
|
|
349
349
|
* How requests to a model are billed: under the service's subscription, on the Billing plan `plan_id`, one rate for each token kind. Read the rates from Billing with `search-prices` for the plan, narrowing each price's `rates` with each meter's `dimensions`.
|
|
350
350
|
*
|
|
351
351
|
* Each token kind is priced on its own. `input` excludes cached input, which is `cache_read`, and `output` excludes reasoning the provider reports separately, which is `reasoning`; a request is billed for each kind it used.
|
|
352
|
+
*
|
|
353
|
+
* Rates are set per currency, and a currency may not offer a model at all. A model is offered in the currency of the project's billing account when at least one of its token kinds has a rate there; a token kind without a rate in that currency is not charged. Requests to a model with no rate in that currency are refused with 403 `BILLING_MODEL_NOT_OFFERED`.
|
|
352
354
|
*/
|
|
353
355
|
export interface ModelBilling {
|
|
354
356
|
/**
|
|
@@ -50,4 +50,4 @@ export const ModelBilling = zod
|
|
|
50
50
|
.array(ModelMeter)
|
|
51
51
|
.describe("One entry for each of the five token kinds, in the order input, output, cache_read, cache_write, reasoning."),
|
|
52
52
|
})
|
|
53
|
-
.describe("How requests to a model are billed: under the service's subscription, on the Billing plan `plan_id`, one rate for each token kind. Read the rates from Billing with `search-prices` for the plan, narrowing each price's `rates` with each meter's `dimensions`.\n\nEach token kind is priced on its own. `input` excludes cached input, which is `cache_read`, and `output` excludes reasoning the provider reports separately, which is `reasoning`; a request is billed for each kind it used.");
|
|
53
|
+
.describe("How requests to a model are billed: under the service's subscription, on the Billing plan `plan_id`, one rate for each token kind. Read the rates from Billing with `search-prices` for the plan, narrowing each price's `rates` with each meter's `dimensions`.\n\nEach token kind is priced on its own. `input` excludes cached input, which is `cache_read`, and `output` excludes reasoning the provider reports separately, which is `reasoning`; a request is billed for each kind it used.\n\nRates are set per currency, and a currency may not offer a model at all. A model is offered in the currency of the project's billing account when at least one of its token kinds has a rate there; a token kind without a rate in that currency is not charged. Requests to a model with no rate in that currency are refused with 403 `BILLING_MODEL_NOT_OFFERED`.");
|
package/dist/routes.d.ts
CHANGED
|
@@ -1223,14 +1223,6 @@ export declare const routes: readonly [{
|
|
|
1223
1223
|
readonly operationId: "create-cancellation";
|
|
1224
1224
|
readonly securityScheme: "AccessToken";
|
|
1225
1225
|
readonly upstreamUrl: "https://billing.leaflow.cloud";
|
|
1226
|
-
}, {
|
|
1227
|
-
readonly service: "billing";
|
|
1228
|
-
readonly contract: "billing";
|
|
1229
|
-
readonly method: "QUERY";
|
|
1230
|
-
readonly path: "/api/v1/cancellations/preview";
|
|
1231
|
-
readonly operationId: "preview-cancellation";
|
|
1232
|
-
readonly securityScheme: "AccessToken";
|
|
1233
|
-
readonly upstreamUrl: "https://billing.leaflow.cloud";
|
|
1234
1226
|
}, {
|
|
1235
1227
|
readonly service: "billing";
|
|
1236
1228
|
readonly contract: "billing";
|
package/dist/routes.js
CHANGED
|
@@ -1378,15 +1378,6 @@ export const routes = [
|
|
|
1378
1378
|
securityScheme: "AccessToken",
|
|
1379
1379
|
upstreamUrl: "https://billing.leaflow.cloud",
|
|
1380
1380
|
},
|
|
1381
|
-
{
|
|
1382
|
-
service: "billing",
|
|
1383
|
-
contract: "billing",
|
|
1384
|
-
method: "QUERY",
|
|
1385
|
-
path: "/api/v1/cancellations/preview",
|
|
1386
|
-
operationId: "preview-cancellation",
|
|
1387
|
-
securityScheme: "AccessToken",
|
|
1388
|
-
upstreamUrl: "https://billing.leaflow.cloud",
|
|
1389
|
-
},
|
|
1390
1381
|
{
|
|
1391
1382
|
service: "billing",
|
|
1392
1383
|
contract: "billing",
|