@leaflow/sdk 0.109.0 → 0.110.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 (31) hide show
  1. package/dist/billing/v1/generated/functions.d.ts +82 -12
  2. package/dist/billing/v1/generated/functions.js +101 -11
  3. package/dist/billing/v1/generated/models.d.ts +98 -3
  4. package/dist/billing/v1/generated/models.js +4 -0
  5. package/dist/billing/v1/generated/schemas.zod.d.ts +56 -10
  6. package/dist/billing/v1/generated/schemas.zod.js +78 -10
  7. package/dist/billing/v1/generated/validators/creditNote.zod.d.ts +24 -0
  8. package/dist/billing/v1/generated/validators/creditNote.zod.js +28 -0
  9. package/dist/billing/v1/generated/validators/creditNoteItem.zod.d.ts +17 -0
  10. package/dist/billing/v1/generated/validators/creditNoteItem.zod.js +16 -0
  11. package/dist/billing/v1/generated/validators/creditNoteItemList.zod.d.ts +24 -0
  12. package/dist/billing/v1/generated/validators/creditNoteItemList.zod.js +14 -0
  13. package/dist/billing/v1/generated/validators/creditNoteList.zod.d.ts +31 -0
  14. package/dist/billing/v1/generated/validators/creditNoteList.zod.js +14 -0
  15. package/dist/billing/v1/generated/validators/invoice.zod.d.ts +2 -0
  16. package/dist/billing/v1/generated/validators/invoice.zod.js +3 -1
  17. package/dist/billing/v1/generated/validators/invoiceList.zod.d.ts +2 -0
  18. package/dist/billing/v1/generated/validators/invoiceSummary.zod.d.ts +2 -0
  19. package/dist/billing/v1/generated/validators/invoiceSummary.zod.js +4 -1
  20. package/dist/billing/v1/generated/validators/listCreditNoteItemsParams.zod.d.ts +18 -0
  21. package/dist/billing/v1/generated/validators/listCreditNoteItemsParams.zod.js +24 -0
  22. package/dist/billing/v1/generated/validators/listCreditNotesParams.zod.d.ts +20 -0
  23. package/dist/billing/v1/generated/validators/listCreditNotesParams.zod.js +26 -0
  24. package/dist/billing/v1/generated/validators/order.zod.d.ts +2 -1
  25. package/dist/billing/v1/generated/validators/order.zod.js +0 -1
  26. package/dist/billing/v1/generated/validators/orderCancel.zod.d.ts +14 -0
  27. package/dist/billing/v1/generated/validators/orderCancel.zod.js +17 -0
  28. package/dist/billing/v1/generated/validators/orderList.zod.d.ts +2 -1
  29. package/dist/routes.d.ts +24 -0
  30. package/dist/routes.js +27 -0
  31. package/package.json +1 -1
@@ -5,7 +5,7 @@
5
5
  * Products, prices, orders, subscriptions and account billing. Financial operations require an account access token and billing-account authorization. Public catalogue operations declare no security requirement.
6
6
  * OpenAPI spec version: v1
7
7
  */
8
- import type { AccountBalance, ActiveResourceList, AllowanceList, AutoRenewSet, BillingAccount, BillingAccountCreate, BillingAccountList, BillingAccountUpdate, Cancellation, CancellationCreate, CancellationList, CheckoutOrderRequest, CreditGrantList, CurrencyList, DiscountList, EntitlementList, Error, ErrorResponse, GetPlanHeaders, GetPriceHeaders, GetProductHeaders, Invoice, InvoiceItemList, InvoiceList, ListAccountDiscountsParams, ListActiveResourcesParams, ListAllowancesParams, ListBillingAccountsParams, ListCancellationsParams, ListCreditGrantsParams, ListCurrenciesParams, ListEntitlementsParams, ListInvoiceItemsParams, ListInvoicesParams, ListOrderItemsParams, ListOrdersParams, ListPaymentMethodsParams, ListPaymentOptionsParams, ListPlansHeaders, ListPlansParams, ListPricesByPlanHeaders, ListPricesByPlanParams, ListPricesHeaders, ListPricesParams, ListProductsHeaders, ListProductsParams, ListProjectAssignmentsParams, ListRatesHeaders, ListRatesParams, ListRefundsParams, ListRenewalPricesParams, ListSpendParams, ListSubscriptionsParams, ListTopUpsParams, ListTransactionsParams, ListUsageChargesParams, MeteredUsage, NotModifiedResponse, Order, OrderItemList, OrderList, PayInvoiceRequest, PayTogetherRequest, PaymentMethod, PaymentMethodList, PaymentMethodSetup, PaymentMethodSetupResult, PaymentOptionList, PaymentPreview, PaymentResult, Plan, PlanList, PreviewInvoicePaymentParams, Price, PriceList, Product, ProductID, ProductList, ProjectAssignment, ProjectAssignmentList, Quote, QuoteRequest, RateList, RefundList, RenewRequest, RenewalOrderRequest, RenewalPriceList, SetProjectAssignmentRequest, SpendRowList, Subscription, SubscriptionList, TopUp, TopUpCreate, TopUpList, TransactionList, UsageChargeList } from "./models.js";
8
+ import type { AccountBalance, ActiveResourceList, AllowanceList, AutoRenewSet, BillingAccount, BillingAccountCreate, BillingAccountList, BillingAccountUpdate, Cancellation, CancellationCreate, CancellationList, CheckoutOrderRequest, CreditGrantList, CreditNote, CreditNoteItemList, CreditNoteList, CurrencyList, DiscountList, EntitlementList, Error, ErrorResponse, GetPlanHeaders, GetPriceHeaders, GetProductHeaders, Invoice, InvoiceItemList, InvoiceList, ListAccountDiscountsParams, ListActiveResourcesParams, ListAllowancesParams, ListBillingAccountsParams, ListCancellationsParams, ListCreditGrantsParams, ListCreditNoteItemsParams, ListCreditNotesParams, ListCurrenciesParams, ListEntitlementsParams, ListInvoiceItemsParams, ListInvoicesParams, ListOrderItemsParams, ListOrdersParams, ListPaymentMethodsParams, ListPaymentOptionsParams, ListPlansHeaders, ListPlansParams, ListPricesByPlanHeaders, ListPricesByPlanParams, ListPricesHeaders, ListPricesParams, ListProductsHeaders, ListProductsParams, ListProjectAssignmentsParams, ListRatesHeaders, ListRatesParams, ListRefundsParams, ListRenewalPricesParams, ListSpendParams, ListSubscriptionsParams, ListTopUpsParams, ListTransactionsParams, ListUsageChargesParams, MeteredUsage, NotModifiedResponse, Order, OrderCancel, OrderItemList, OrderList, PayInvoiceRequest, PayTogetherRequest, PaymentMethod, PaymentMethodList, PaymentMethodSetup, PaymentMethodSetupResult, PaymentOptionList, PaymentPreview, PaymentResult, Plan, PlanList, PreviewInvoicePaymentParams, Price, PriceList, Product, ProductID, ProductList, ProjectAssignment, ProjectAssignmentList, Quote, QuoteRequest, RateList, RefundList, RenewRequest, RenewalOrderRequest, RenewalPriceList, SetProjectAssignmentRequest, SpendRowList, Subscription, SubscriptionList, TopUp, TopUpCreate, TopUpList, TransactionList, UsageChargeList } 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;
@@ -729,6 +729,69 @@ export declare const getListCreditGrantsUrl: (params?: ListCreditGrantsParams) =
729
729
  * @summary List credit grants
730
730
  */
731
731
  export declare const listCreditGrants: (params?: ListCreditGrantsParams, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<listCreditGrantsResponse>;
732
+ export type listCreditNotesResponse200 = {
733
+ data: CreditNoteList;
734
+ status: 200;
735
+ };
736
+ export type listCreditNotesResponseDefault = {
737
+ data: ErrorResponse;
738
+ status: Exclude<HTTPStatusCodes, 200>;
739
+ };
740
+ export type listCreditNotesResponseSuccess = listCreditNotesResponse200 & {
741
+ headers: Headers;
742
+ };
743
+ export type listCreditNotesResponseError = listCreditNotesResponseDefault & {
744
+ headers: Headers;
745
+ };
746
+ export type listCreditNotesResponse = listCreditNotesResponseSuccess | listCreditNotesResponseError;
747
+ export declare const getListCreditNotesUrl: (params?: ListCreditNotesParams) => string;
748
+ /**
749
+ * Newest issued_at first, then ID. Requires authorization for the invoice's billing account. Filters narrow authorized results and apply before counting and paging.
750
+ * @summary List credit notes
751
+ */
752
+ export declare const listCreditNotes: (params?: ListCreditNotesParams, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<listCreditNotesResponse>;
753
+ export type getCreditNoteResponse200 = {
754
+ data: CreditNote;
755
+ status: 200;
756
+ };
757
+ export type getCreditNoteResponseDefault = {
758
+ data: ErrorResponse;
759
+ status: Exclude<HTTPStatusCodes, 200>;
760
+ };
761
+ export type getCreditNoteResponseSuccess = getCreditNoteResponse200 & {
762
+ headers: Headers;
763
+ };
764
+ export type getCreditNoteResponseError = getCreditNoteResponseDefault & {
765
+ headers: Headers;
766
+ };
767
+ export type getCreditNoteResponse = getCreditNoteResponseSuccess | getCreditNoteResponseError;
768
+ export declare const getGetCreditNoteUrl: (creditNoteId: string) => string;
769
+ /**
770
+ * Requires authorization for the invoice's billing account.
771
+ * @summary Get credit note
772
+ */
773
+ export declare const getCreditNote: (creditNoteId: string, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<getCreditNoteResponse>;
774
+ export type listCreditNoteItemsResponse200 = {
775
+ data: CreditNoteItemList;
776
+ status: 200;
777
+ };
778
+ export type listCreditNoteItemsResponseDefault = {
779
+ data: ErrorResponse;
780
+ status: Exclude<HTTPStatusCodes, 200>;
781
+ };
782
+ export type listCreditNoteItemsResponseSuccess = listCreditNoteItemsResponse200 & {
783
+ headers: Headers;
784
+ };
785
+ export type listCreditNoteItemsResponseError = listCreditNoteItemsResponseDefault & {
786
+ headers: Headers;
787
+ };
788
+ export type listCreditNoteItemsResponse = listCreditNoteItemsResponseSuccess | listCreditNoteItemsResponseError;
789
+ export declare const getListCreditNoteItemsUrl: (creditNoteId: string, params?: ListCreditNoteItemsParams) => string;
790
+ /**
791
+ * The original invoice lines reduced by this note. Requires authorization for their invoice's billing account.
792
+ * @summary List credit note items
793
+ */
794
+ export declare const listCreditNoteItems: (creditNoteId: string, params?: ListCreditNoteItemsParams, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<listCreditNoteItemsResponse>;
732
795
  export type listRefundsResponse200 = {
733
796
  data: RefundList;
734
797
  status: 200;
@@ -1228,20 +1291,27 @@ export type cancelOrderResponseError = (cancelOrderResponse409 | cancelOrderResp
1228
1291
  export type cancelOrderResponse = cancelOrderResponseSuccess | cancelOrderResponseError;
1229
1292
  export declare const getCancelOrderUrl: (orderId: string) => string;
1230
1293
  /**
1231
- * Withdraws an unaccepted order without recording a delivery failure. Payment may be absent,
1232
- * partial or complete; the order becomes canceled and any collected amount is automatically
1233
- * returned to its original payment sources. External payment-method refunds can finish
1234
- * asynchronously. Canceling an already canceled order returns it unchanged. A previously failed
1235
- * order keeps its failure outcome. The order and financial history are retained.
1294
+ * Cancels the selected, still-undelivered items of an unaccepted order without recording a
1295
+ * delivery failure. Omit order_item_ids to select every still-pending item, or name one or
1296
+ * more items. Successful items remain delivered and are not refunded. Whole-order and partial
1297
+ * cancellation both require confirmed non-delivery and necessary cleanup. The order keeps
1298
+ * its existing pending phase while any item is still pending; its final outcome follows all
1299
+ * item outcomes. Previously failed items keep their failure outcome.
1300
+ *
1301
+ * Payment may be absent, partial or complete. Confirmed checkout keeps the selected items'
1302
+ * agreed amounts and discounts; credit notes reduce issued invoices, and collected amounts
1303
+ * are returned to their original payment sources. When checkout has not been confirmed, the
1304
+ * remaining items are quoted again. External payment-method refunds can finish asynchronously.
1305
+ * The order and financial history are retained; the same cancellation does not refund twice.
1236
1306
  *
1237
- * Refused once the order is accepted: its owning service must coordinate cancellation during
1238
- * provisioning and confirm non-delivery and necessary cleanup before recording cancellation.
1239
- * Delivered items are ended through subscription cancellation. An unknown or in-flight payment
1240
- * outcome must first be reconciled; it is not assumed to be unpaid. Scheduled changes continue
1241
- * to be canceled through the service that owns them. Refund quotations use CreateQuote.refund.
1307
+ * Once the order is accepted, its owning service coordinates cancellation and confirms
1308
+ * non-delivery and cleanup through the cancellation RPC. Delivered items are ended through
1309
+ * subscription cancellation. Unknown delivery or payment outcomes are not refund evidence;
1310
+ * in-flight or unknown payments must be reconciled first. Scheduled changes continue to be
1311
+ * canceled through the owning service. Refund quotations use CreateQuote.refund.
1242
1312
  * @summary Cancel order
1243
1313
  */
1244
- export declare const cancelOrder: (orderId: string, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<cancelOrderResponse>;
1314
+ export declare const cancelOrder: (orderId: string, orderCancel?: OrderCancel, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<cancelOrderResponse>;
1245
1315
  export type listOrderItemsResponse200 = {
1246
1316
  data: OrderItemList;
1247
1317
  status: 200;
@@ -805,6 +805,72 @@ export const listCreditGrants = async (params, options, fetchFn) => {
805
805
  const data = body ? JSON.parse(body) : {};
806
806
  return { data, status: res.status, headers: res.headers };
807
807
  };
808
+ export const getListCreditNotesUrl = (params) => {
809
+ const normalizedParams = new URLSearchParams();
810
+ Object.entries(params || {}).forEach(([key, value]) => {
811
+ if (value !== undefined) {
812
+ normalizedParams.append(key, value === null ? "null" : String(value));
813
+ }
814
+ });
815
+ const stringifiedParams = normalizedParams.toString();
816
+ return stringifiedParams.length > 0
817
+ ? `https://billing.leaflow.cloud/api/v1/credit-notes?${stringifiedParams}`
818
+ : `https://billing.leaflow.cloud/api/v1/credit-notes`;
819
+ };
820
+ /**
821
+ * Newest issued_at first, then ID. Requires authorization for the invoice's billing account. Filters narrow authorized results and apply before counting and paging.
822
+ * @summary List credit notes
823
+ */
824
+ export const listCreditNotes = async (params, options, fetchFn) => {
825
+ const res = await (fetchFn ?? fetch)(getListCreditNotesUrl(params), {
826
+ ...options,
827
+ method: "GET",
828
+ });
829
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
830
+ const data = body ? JSON.parse(body) : {};
831
+ return { data, status: res.status, headers: res.headers };
832
+ };
833
+ export const getGetCreditNoteUrl = (creditNoteId) => {
834
+ return `https://billing.leaflow.cloud/api/v1/credit-notes/${encodeURIComponent(String(creditNoteId))}`;
835
+ };
836
+ /**
837
+ * Requires authorization for the invoice's billing account.
838
+ * @summary Get credit note
839
+ */
840
+ export const getCreditNote = async (creditNoteId, options, fetchFn) => {
841
+ const res = await (fetchFn ?? fetch)(getGetCreditNoteUrl(creditNoteId), {
842
+ ...options,
843
+ method: "GET",
844
+ });
845
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
846
+ const data = body ? JSON.parse(body) : {};
847
+ return { data, status: res.status, headers: res.headers };
848
+ };
849
+ export const getListCreditNoteItemsUrl = (creditNoteId, params) => {
850
+ const normalizedParams = new URLSearchParams();
851
+ Object.entries(params || {}).forEach(([key, value]) => {
852
+ if (value !== undefined) {
853
+ normalizedParams.append(key, value === null ? "null" : String(value));
854
+ }
855
+ });
856
+ const stringifiedParams = normalizedParams.toString();
857
+ return stringifiedParams.length > 0
858
+ ? `https://billing.leaflow.cloud/api/v1/credit-notes/${encodeURIComponent(String(creditNoteId))}/items?${stringifiedParams}`
859
+ : `https://billing.leaflow.cloud/api/v1/credit-notes/${encodeURIComponent(String(creditNoteId))}/items`;
860
+ };
861
+ /**
862
+ * The original invoice lines reduced by this note. Requires authorization for their invoice's billing account.
863
+ * @summary List credit note items
864
+ */
865
+ export const listCreditNoteItems = async (creditNoteId, params, options, fetchFn) => {
866
+ const res = await (fetchFn ?? fetch)(getListCreditNoteItemsUrl(creditNoteId, params), {
867
+ ...options,
868
+ method: "GET",
869
+ });
870
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
871
+ const data = body ? JSON.parse(body) : {};
872
+ return { data, status: res.status, headers: res.headers };
873
+ };
808
874
  export const getListRefundsUrl = (params) => {
809
875
  const normalizedParams = new URLSearchParams();
810
876
  Object.entries(params || {}).forEach(([key, value]) => {
@@ -1351,23 +1417,47 @@ export const getCancelOrderUrl = (orderId) => {
1351
1417
  return `https://billing.leaflow.cloud/api/v1/orders/${encodeURIComponent(String(orderId))}/cancel`;
1352
1418
  };
1353
1419
  /**
1354
- * Withdraws an unaccepted order without recording a delivery failure. Payment may be absent,
1355
- * partial or complete; the order becomes canceled and any collected amount is automatically
1356
- * returned to its original payment sources. External payment-method refunds can finish
1357
- * asynchronously. Canceling an already canceled order returns it unchanged. A previously failed
1358
- * order keeps its failure outcome. The order and financial history are retained.
1420
+ * Cancels the selected, still-undelivered items of an unaccepted order without recording a
1421
+ * delivery failure. Omit order_item_ids to select every still-pending item, or name one or
1422
+ * more items. Successful items remain delivered and are not refunded. Whole-order and partial
1423
+ * cancellation both require confirmed non-delivery and necessary cleanup. The order keeps
1424
+ * its existing pending phase while any item is still pending; its final outcome follows all
1425
+ * item outcomes. Previously failed items keep their failure outcome.
1359
1426
  *
1360
- * Refused once the order is accepted: its owning service must coordinate cancellation during
1361
- * provisioning and confirm non-delivery and necessary cleanup before recording cancellation.
1362
- * Delivered items are ended through subscription cancellation. An unknown or in-flight payment
1363
- * outcome must first be reconciled; it is not assumed to be unpaid. Scheduled changes continue
1364
- * to be canceled through the service that owns them. Refund quotations use CreateQuote.refund.
1427
+ * Payment may be absent, partial or complete. Confirmed checkout keeps the selected items'
1428
+ * agreed amounts and discounts; credit notes reduce issued invoices, and collected amounts
1429
+ * are returned to their original payment sources. When checkout has not been confirmed, the
1430
+ * remaining items are quoted again. External payment-method refunds can finish asynchronously.
1431
+ * The order and financial history are retained; the same cancellation does not refund twice.
1432
+ *
1433
+ * Once the order is accepted, its owning service coordinates cancellation and confirms
1434
+ * non-delivery and cleanup through the cancellation RPC. Delivered items are ended through
1435
+ * subscription cancellation. Unknown delivery or payment outcomes are not refund evidence;
1436
+ * in-flight or unknown payments must be reconciled first. Scheduled changes continue to be
1437
+ * canceled through the owning service. Refund quotations use CreateQuote.refund.
1365
1438
  * @summary Cancel order
1366
1439
  */
1367
- export const cancelOrder = async (orderId, options, fetchFn) => {
1440
+ export const cancelOrder = async (orderId, orderCancel, options, fetchFn) => {
1441
+ const getHeaders = (h) => {
1442
+ if (!h)
1443
+ return {};
1444
+ if (h instanceof Headers)
1445
+ return Object.fromEntries(h.entries());
1446
+ if (Symbol.iterator in h) {
1447
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1448
+ }
1449
+ const headers = {};
1450
+ for (const [name, value] of Object.entries(h)) {
1451
+ if (value !== undefined)
1452
+ headers[name] = value;
1453
+ }
1454
+ return headers;
1455
+ };
1368
1456
  const res = await (fetchFn ?? fetch)(getCancelOrderUrl(orderId), {
1369
1457
  ...options,
1370
1458
  method: "POST",
1459
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
1460
+ body: JSON.stringify(orderCancel),
1371
1461
  });
1372
1462
  const body = [204, 205, 304].includes(res.status) ? null : await res.text();
1373
1463
  const data = body ? JSON.parse(body) : {};
@@ -30,6 +30,14 @@ export declare const RefundPolicy: {
30
30
  readonly none: "none";
31
31
  readonly prorated: "prorated";
32
32
  };
33
+ export interface OrderCancel {
34
+ /**
35
+ * Omit to select all still-pending items. Explicit selections name one or more items of this order; successful items cannot be reversed here.
36
+ * @minItems 1
37
+ * @maxItems 100
38
+ */
39
+ order_item_ids?: string[];
40
+ }
33
41
  /**
34
42
  * A decimal string, in the currency stated alongside it.
35
43
  *
@@ -1304,7 +1312,11 @@ export interface Invoice {
1304
1312
  /** Subtotal less discount plus tax. Balance and credit grants are payment sources, not reductions of the receivable. */
1305
1313
  total: Money;
1306
1314
  amount_paid?: Money;
1307
- /** What is still collectible after applied credits and successful payments; never below zero. A draft order invoice is not collectible until checkout confirms it, and a paid or void invoice has none. */
1315
+ /** Issued, non-void credit notes that reduced unpaid receivables. Does not rewrite the original invoice total. */
1316
+ unpaid_credit_notes_amount: Money;
1317
+ /** Issued credit notes against payments already received. This is a return obligation, not evidence of completed refunds. */
1318
+ paid_credit_notes_amount: Money;
1319
+ /** What is still collectible after unpaid credit notes and successful payments; never below zero. A draft order invoice is not collectible until checkout confirms it, and a paid or void invoice has none. */
1308
1320
  amount_due: Money;
1309
1321
  /** @nullable */
1310
1322
  period_start?: string | null;
@@ -1416,6 +1428,50 @@ export interface CreditGrantList {
1416
1428
  items: CreditGrant[];
1417
1429
  pagination: OffsetPagination;
1418
1430
  }
1431
+ export type CreditNoteStatus = (typeof CreditNoteStatus)[keyof typeof CreditNoteStatus];
1432
+ export declare const CreditNoteStatus: {
1433
+ readonly issued: "issued";
1434
+ readonly void: "void";
1435
+ };
1436
+ /**
1437
+ * An issued invoice reduction. Its credited amount is unpaid_amount plus paid_amount. A paid credit records a return obligation; refund_id identifies its refund, whose outcome may still be pending. Original invoice amounts remain unchanged.
1438
+ */
1439
+ export interface CreditNote {
1440
+ id: string;
1441
+ invoice_id: string;
1442
+ currency: string;
1443
+ issued_at: string;
1444
+ status: CreditNoteStatus;
1445
+ /**
1446
+ * When this note was voided; null while issued.
1447
+ * @nullable
1448
+ */
1449
+ voided_at: string | null;
1450
+ /** The reduction of unpaid receivables. A void note no longer reduces what is due. */
1451
+ unpaid_amount: Money;
1452
+ /** The credited part of payments already received. This is not proof that its refund has completed. */
1453
+ paid_amount: Money;
1454
+ /**
1455
+ * The refund to the original payment sources, or null when no paid amount was credited.
1456
+ * @nullable
1457
+ */
1458
+ refund_id: string | null;
1459
+ }
1460
+ export interface CreditNoteItem {
1461
+ id: string;
1462
+ credit_note_id: string;
1463
+ invoice_item_id: string;
1464
+ unpaid_amount: Money;
1465
+ paid_amount: Money;
1466
+ }
1467
+ export interface CreditNoteList {
1468
+ items: CreditNote[];
1469
+ pagination: OffsetPagination;
1470
+ }
1471
+ export interface CreditNoteItemList {
1472
+ items: CreditNoteItem[];
1473
+ pagination: OffsetPagination;
1474
+ }
1419
1475
  /**
1420
1476
  * Use balance_amount, credit_amount and gateway_amount, which also show a refund split between several destinations.
1421
1477
  * @deprecated
@@ -1911,8 +1967,12 @@ export interface InvoiceSummary {
1911
1967
  tax_amount: string;
1912
1968
  total: string;
1913
1969
  amount_paid: string;
1970
+ /** Issued, non-void credit notes that reduced unpaid receivables. Does not rewrite the original invoice total. */
1971
+ unpaid_credit_notes_amount: Money;
1972
+ /** Issued credit notes against payments already received. This is a return obligation, not evidence of completed refunds. */
1973
+ paid_credit_notes_amount: Money;
1914
1974
  /**
1915
- * What is still collectible after applied credits and successful payments; never below zero.
1975
+ * What is still collectible after unpaid credit notes and successful payments; never below zero.
1916
1976
  * @pattern ^\d+(\.\d{1,10})?$
1917
1977
  */
1918
1978
  amount_due: string;
@@ -2046,7 +2106,6 @@ export interface Order {
2046
2106
  /** How the order was paid. Absent until it is paid. */
2047
2107
  paid_with?: PaidWith;
2048
2108
  account?: AccountIdentity;
2049
- cancel_reason?: string;
2050
2109
  change_effective_at?: string;
2051
2110
  id: string;
2052
2111
  /**
@@ -2834,6 +2893,42 @@ export declare const ListCreditGrantsStatus: {
2834
2893
  readonly expired: "expired";
2835
2894
  readonly voided: "voided";
2836
2895
  };
2896
+ export type ListCreditNotesParams = {
2897
+ /**
2898
+ * 1-based page number. Defaults to 1.
2899
+ * @minimum 1
2900
+ * @maximum 2147483647
2901
+ */
2902
+ page?: number;
2903
+ /**
2904
+ * Items per page. Defaults to 50; at most 200.
2905
+ * @minimum 1
2906
+ * @maximum 200
2907
+ */
2908
+ page_size?: number;
2909
+ /**
2910
+ * Restrict to one of your accounts. All of them when omitted.
2911
+ */
2912
+ billing_account_id?: AccountIdQueryParameter;
2913
+ /**
2914
+ * Only the notes for this invoice.
2915
+ */
2916
+ invoice_id?: string;
2917
+ };
2918
+ export type ListCreditNoteItemsParams = {
2919
+ /**
2920
+ * 1-based page number. Defaults to 1.
2921
+ * @minimum 1
2922
+ * @maximum 2147483647
2923
+ */
2924
+ page?: number;
2925
+ /**
2926
+ * Items per page. Defaults to 50; at most 200.
2927
+ * @minimum 1
2928
+ * @maximum 200
2929
+ */
2930
+ page_size?: number;
2931
+ };
2837
2932
  export type ListRefundsParams = {
2838
2933
  /**
2839
2934
  * 1-based page number. Defaults to 1.
@@ -160,6 +160,10 @@ export const CreditGrantStatus = {
160
160
  expired: "expired",
161
161
  voided: "voided",
162
162
  };
163
+ export const CreditNoteStatus = {
164
+ issued: "issued",
165
+ void: "void",
166
+ };
163
167
  export const RefundDestination = {
164
168
  balance: "balance",
165
169
  gateway: "gateway",
@@ -428,6 +428,42 @@ export declare const ListCreditGrantsQueryParams: zod.ZodObject<{
428
428
  voided: "voided";
429
429
  }>>;
430
430
  }, zod.z.core.$strict>;
431
+ /**
432
+ * Newest issued_at first, then ID. Requires authorization for the invoice's billing account. Filters narrow authorized results and apply before counting and paging.
433
+ * @summary List credit notes
434
+ */
435
+ export declare const listCreditNotesQueryPageDefault = 1;
436
+ export declare const listCreditNotesQueryPageMax = 2147483647;
437
+ export declare const listCreditNotesQueryPageSizeDefault = 50;
438
+ export declare const listCreditNotesQueryPageSizeMax = 200;
439
+ export declare const ListCreditNotesQueryParams: zod.ZodObject<{
440
+ page: zod.ZodDefault<zod.ZodInt>;
441
+ page_size: zod.ZodDefault<zod.ZodInt>;
442
+ billing_account_id: zod.ZodOptional<zod.ZodInt>;
443
+ invoice_id: zod.ZodOptional<zod.ZodUUID>;
444
+ }, zod.z.core.$strict>;
445
+ /**
446
+ * Requires authorization for the invoice's billing account.
447
+ * @summary Get credit note
448
+ */
449
+ export declare const GetCreditNoteParams: zod.ZodObject<{
450
+ creditNoteId: zod.ZodUUID;
451
+ }, zod.z.core.$strict>;
452
+ /**
453
+ * The original invoice lines reduced by this note. Requires authorization for their invoice's billing account.
454
+ * @summary List credit note items
455
+ */
456
+ export declare const ListCreditNoteItemsParams: zod.ZodObject<{
457
+ creditNoteId: zod.ZodUUID;
458
+ }, zod.z.core.$strict>;
459
+ export declare const listCreditNoteItemsQueryPageDefault = 1;
460
+ export declare const listCreditNoteItemsQueryPageMax = 2147483647;
461
+ export declare const listCreditNoteItemsQueryPageSizeDefault = 50;
462
+ export declare const listCreditNoteItemsQueryPageSizeMax = 200;
463
+ export declare const ListCreditNoteItemsQueryParams: zod.ZodObject<{
464
+ page: zod.ZodDefault<zod.ZodInt>;
465
+ page_size: zod.ZodDefault<zod.ZodInt>;
466
+ }, zod.z.core.$strict>;
431
467
  /**
432
468
  * Newest first.
433
469
  * @summary List refunds
@@ -847,22 +883,32 @@ export declare const CheckoutOrderBody: zod.ZodObject<{
847
883
  expected_amount: zod.ZodOptional<zod.ZodIntersection<zod.ZodString, zod.ZodString>>;
848
884
  }, zod.z.core.$strict>;
849
885
  /**
850
- * Withdraws an unaccepted order without recording a delivery failure. Payment may be absent,
851
- * partial or complete; the order becomes canceled and any collected amount is automatically
852
- * returned to its original payment sources. External payment-method refunds can finish
853
- * asynchronously. Canceling an already canceled order returns it unchanged. A previously failed
854
- * order keeps its failure outcome. The order and financial history are retained.
886
+ * Cancels the selected, still-undelivered items of an unaccepted order without recording a
887
+ * delivery failure. Omit order_item_ids to select every still-pending item, or name one or
888
+ * more items. Successful items remain delivered and are not refunded. Whole-order and partial
889
+ * cancellation both require confirmed non-delivery and necessary cleanup. The order keeps
890
+ * its existing pending phase while any item is still pending; its final outcome follows all
891
+ * item outcomes. Previously failed items keep their failure outcome.
855
892
  *
856
- * Refused once the order is accepted: its owning service must coordinate cancellation during
857
- * provisioning and confirm non-delivery and necessary cleanup before recording cancellation.
858
- * Delivered items are ended through subscription cancellation. An unknown or in-flight payment
859
- * outcome must first be reconciled; it is not assumed to be unpaid. Scheduled changes continue
860
- * to be canceled through the service that owns them. Refund quotations use CreateQuote.refund.
893
+ * Payment may be absent, partial or complete. Confirmed checkout keeps the selected items'
894
+ * agreed amounts and discounts; credit notes reduce issued invoices, and collected amounts
895
+ * are returned to their original payment sources. When checkout has not been confirmed, the
896
+ * remaining items are quoted again. External payment-method refunds can finish asynchronously.
897
+ * The order and financial history are retained; the same cancellation does not refund twice.
898
+ *
899
+ * Once the order is accepted, its owning service coordinates cancellation and confirms
900
+ * non-delivery and cleanup through the cancellation RPC. Delivered items are ended through
901
+ * subscription cancellation. Unknown delivery or payment outcomes are not refund evidence;
902
+ * in-flight or unknown payments must be reconciled first. Scheduled changes continue to be
903
+ * canceled through the owning service. Refund quotations use CreateQuote.refund.
861
904
  * @summary Cancel order
862
905
  */
863
906
  export declare const CancelOrderParams: zod.ZodObject<{
864
907
  orderId: zod.ZodUUID;
865
908
  }, zod.z.core.$strict>;
909
+ export declare const CancelOrderBody: zod.ZodObject<{
910
+ order_item_ids: zod.ZodOptional<zod.ZodArray<zod.ZodUUID>>;
911
+ }, zod.z.core.$strict>;
866
912
  /**
867
913
  * One entry per item bought, with the price charged and the period it covers.
868
914
  * @summary List order items
@@ -11,6 +11,7 @@ import { BillingAccountCreate } from "./validators/billingAccountCreate.zod.js";
11
11
  import { BillingAccountUpdate } from "./validators/billingAccountUpdate.zod.js";
12
12
  import { CancellationCreate } from "./validators/cancellationCreate.zod.js";
13
13
  import { CheckoutOrderRequest } from "./validators/checkoutOrderRequest.zod.js";
14
+ import { OrderCancel } from "./validators/orderCancel.zod.js";
14
15
  import { PayInvoiceRequest } from "./validators/payInvoiceRequest.zod.js";
15
16
  import { PayTogetherRequest } from "./validators/payTogetherRequest.zod.js";
16
17
  import { PaymentMethodSetup } from "./validators/paymentMethodSetup.zod.js";
@@ -529,6 +530,65 @@ export const ListCreditGrantsQueryParams = zod.strictObject({
529
530
  .describe("Restrict to one of your accounts. All of them when omitted."),
530
531
  status: zod.enum(["active", "depleted", "expired", "voided"]).optional(),
531
532
  });
533
+ /**
534
+ * Newest issued_at first, then ID. Requires authorization for the invoice's billing account. Filters narrow authorized results and apply before counting and paging.
535
+ * @summary List credit notes
536
+ */
537
+ export const listCreditNotesQueryPageDefault = 1;
538
+ export const listCreditNotesQueryPageMax = 2147483647;
539
+ export const listCreditNotesQueryPageSizeDefault = 50;
540
+ export const listCreditNotesQueryPageSizeMax = 200;
541
+ export const ListCreditNotesQueryParams = zod.strictObject({
542
+ page: zod
543
+ .int()
544
+ .min(1)
545
+ .max(listCreditNotesQueryPageMax)
546
+ .default(listCreditNotesQueryPageDefault)
547
+ .describe("1-based page number. Defaults to 1."),
548
+ page_size: zod
549
+ .int()
550
+ .min(1)
551
+ .max(listCreditNotesQueryPageSizeMax)
552
+ .default(listCreditNotesQueryPageSizeDefault)
553
+ .describe("Items per page. Defaults to 50; at most 200."),
554
+ billing_account_id: zod
555
+ .int()
556
+ .optional()
557
+ .describe("Restrict to one of your accounts. All of them when omitted."),
558
+ invoice_id: zod.uuid().optional().describe("Only the notes for this invoice."),
559
+ });
560
+ /**
561
+ * Requires authorization for the invoice's billing account.
562
+ * @summary Get credit note
563
+ */
564
+ export const GetCreditNoteParams = zod.strictObject({
565
+ creditNoteId: zod.uuid(),
566
+ });
567
+ /**
568
+ * The original invoice lines reduced by this note. Requires authorization for their invoice's billing account.
569
+ * @summary List credit note items
570
+ */
571
+ export const ListCreditNoteItemsParams = zod.strictObject({
572
+ creditNoteId: zod.uuid(),
573
+ });
574
+ export const listCreditNoteItemsQueryPageDefault = 1;
575
+ export const listCreditNoteItemsQueryPageMax = 2147483647;
576
+ export const listCreditNoteItemsQueryPageSizeDefault = 50;
577
+ export const listCreditNoteItemsQueryPageSizeMax = 200;
578
+ export const ListCreditNoteItemsQueryParams = zod.strictObject({
579
+ page: zod
580
+ .int()
581
+ .min(1)
582
+ .max(listCreditNoteItemsQueryPageMax)
583
+ .default(listCreditNoteItemsQueryPageDefault)
584
+ .describe("1-based page number. Defaults to 1."),
585
+ page_size: zod
586
+ .int()
587
+ .min(1)
588
+ .max(listCreditNoteItemsQueryPageSizeMax)
589
+ .default(listCreditNoteItemsQueryPageSizeDefault)
590
+ .describe("Items per page. Defaults to 50; at most 200."),
591
+ });
532
592
  /**
533
593
  * Newest first.
534
594
  * @summary List refunds
@@ -977,22 +1037,30 @@ export const CheckoutOrderParams = zod.strictObject({
977
1037
  });
978
1038
  export const CheckoutOrderBody = CheckoutOrderRequest;
979
1039
  /**
980
- * Withdraws an unaccepted order without recording a delivery failure. Payment may be absent,
981
- * partial or complete; the order becomes canceled and any collected amount is automatically
982
- * returned to its original payment sources. External payment-method refunds can finish
983
- * asynchronously. Canceling an already canceled order returns it unchanged. A previously failed
984
- * order keeps its failure outcome. The order and financial history are retained.
1040
+ * Cancels the selected, still-undelivered items of an unaccepted order without recording a
1041
+ * delivery failure. Omit order_item_ids to select every still-pending item, or name one or
1042
+ * more items. Successful items remain delivered and are not refunded. Whole-order and partial
1043
+ * cancellation both require confirmed non-delivery and necessary cleanup. The order keeps
1044
+ * its existing pending phase while any item is still pending; its final outcome follows all
1045
+ * item outcomes. Previously failed items keep their failure outcome.
1046
+ *
1047
+ * Payment may be absent, partial or complete. Confirmed checkout keeps the selected items'
1048
+ * agreed amounts and discounts; credit notes reduce issued invoices, and collected amounts
1049
+ * are returned to their original payment sources. When checkout has not been confirmed, the
1050
+ * remaining items are quoted again. External payment-method refunds can finish asynchronously.
1051
+ * The order and financial history are retained; the same cancellation does not refund twice.
985
1052
  *
986
- * Refused once the order is accepted: its owning service must coordinate cancellation during
987
- * provisioning and confirm non-delivery and necessary cleanup before recording cancellation.
988
- * Delivered items are ended through subscription cancellation. An unknown or in-flight payment
989
- * outcome must first be reconciled; it is not assumed to be unpaid. Scheduled changes continue
990
- * to be canceled through the service that owns them. Refund quotations use CreateQuote.refund.
1053
+ * Once the order is accepted, its owning service coordinates cancellation and confirms
1054
+ * non-delivery and cleanup through the cancellation RPC. Delivered items are ended through
1055
+ * subscription cancellation. Unknown delivery or payment outcomes are not refund evidence;
1056
+ * in-flight or unknown payments must be reconciled first. Scheduled changes continue to be
1057
+ * canceled through the owning service. Refund quotations use CreateQuote.refund.
991
1058
  * @summary Cancel order
992
1059
  */
993
1060
  export const CancelOrderParams = zod.strictObject({
994
1061
  orderId: zod.uuid(),
995
1062
  });
1063
+ export const CancelOrderBody = OrderCancel;
996
1064
  /**
997
1065
  * One entry per item bought, with the price charged and the period it covers.
998
1066
  * @summary List order items
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Leaflow Billing API
5
+ * Products, prices, orders, subscriptions and account billing. Financial operations require an account access token and billing-account authorization. Public catalogue operations declare no security requirement.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ export declare const CreditNote: zod.ZodObject<{
10
+ id: zod.ZodUUID;
11
+ invoice_id: zod.ZodUUID;
12
+ currency: zod.ZodString;
13
+ issued_at: zod.z.ZodISODateTime;
14
+ status: zod.ZodEnum<{
15
+ void: "void";
16
+ issued: "issued";
17
+ }>;
18
+ voided_at: zod.ZodNullable<zod.z.ZodISODateTime>;
19
+ unpaid_amount: zod.ZodString;
20
+ paid_amount: zod.ZodString;
21
+ refund_id: zod.ZodNullable<zod.ZodUUID>;
22
+ }, zod.z.core.$strict>;
23
+ export type CreditNote = zod.input<typeof CreditNote>;
24
+ export type CreditNoteOutput = zod.output<typeof CreditNote>;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Leaflow Billing API
5
+ * Products, prices, orders, subscriptions and account billing. Financial operations require an account access token and billing-account authorization. Public catalogue operations declare no security requirement.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ import { Money } from "./money.zod.js";
10
+ export const CreditNote = zod
11
+ .strictObject({
12
+ id: zod.uuid(),
13
+ invoice_id: zod.uuid(),
14
+ currency: zod.string(),
15
+ issued_at: zod.iso.datetime({ offset: true }),
16
+ status: zod.enum(["issued", "void"]),
17
+ voided_at: zod.iso
18
+ .datetime({ offset: true })
19
+ .nullable()
20
+ .describe("When this note was voided; null while issued."),
21
+ unpaid_amount: Money.describe("The reduction of unpaid receivables. A void note no longer reduces what is due."),
22
+ paid_amount: Money.describe("The credited part of payments already received. This is not proof that its refund has completed."),
23
+ refund_id: zod
24
+ .uuid()
25
+ .nullable()
26
+ .describe("The refund to the original payment sources, or null when no paid amount was credited."),
27
+ })
28
+ .describe("An issued invoice reduction. Its credited amount is unpaid_amount plus paid_amount. A paid credit records a return obligation; refund_id identifies its refund, whose outcome may still be pending. Original invoice amounts remain unchanged.");
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Leaflow Billing API
5
+ * Products, prices, orders, subscriptions and account billing. Financial operations require an account access token and billing-account authorization. Public catalogue operations declare no security requirement.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ export declare const CreditNoteItem: zod.ZodObject<{
10
+ id: zod.ZodUUID;
11
+ credit_note_id: zod.ZodUUID;
12
+ invoice_item_id: zod.ZodUUID;
13
+ unpaid_amount: zod.ZodString;
14
+ paid_amount: zod.ZodString;
15
+ }, zod.z.core.$strict>;
16
+ export type CreditNoteItem = zod.input<typeof CreditNoteItem>;
17
+ export type CreditNoteItemOutput = zod.output<typeof CreditNoteItem>;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Leaflow Billing API
5
+ * Products, prices, orders, subscriptions and account billing. Financial operations require an account access token and billing-account authorization. Public catalogue operations declare no security requirement.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ import { Money } from "./money.zod.js";
10
+ export const CreditNoteItem = zod.strictObject({
11
+ id: zod.uuid(),
12
+ credit_note_id: zod.uuid(),
13
+ invoice_item_id: zod.uuid(),
14
+ unpaid_amount: Money,
15
+ paid_amount: Money,
16
+ });
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Leaflow Billing API
5
+ * Products, prices, orders, subscriptions and account billing. Financial operations require an account access token and billing-account authorization. Public catalogue operations declare no security requirement.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ export declare const CreditNoteItemList: zod.ZodObject<{
10
+ items: zod.ZodArray<zod.ZodObject<{
11
+ id: zod.ZodUUID;
12
+ credit_note_id: zod.ZodUUID;
13
+ invoice_item_id: zod.ZodUUID;
14
+ unpaid_amount: zod.ZodString;
15
+ paid_amount: zod.ZodString;
16
+ }, zod.z.core.$strict>>;
17
+ pagination: zod.ZodObject<{
18
+ page: zod.ZodInt;
19
+ page_size: zod.ZodInt;
20
+ total_count: zod.ZodOptional<zod.ZodInt>;
21
+ }, zod.z.core.$strict>;
22
+ }, zod.z.core.$strict>;
23
+ export type CreditNoteItemList = zod.input<typeof CreditNoteItemList>;
24
+ export type CreditNoteItemListOutput = zod.output<typeof CreditNoteItemList>;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Leaflow Billing API
5
+ * Products, prices, orders, subscriptions and account billing. Financial operations require an account access token and billing-account authorization. Public catalogue operations declare no security requirement.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ import { CreditNoteItem } from "./creditNoteItem.zod.js";
10
+ import { OffsetPagination } from "./offsetPagination.zod.js";
11
+ export const CreditNoteItemList = zod.strictObject({
12
+ items: zod.array(CreditNoteItem),
13
+ pagination: OffsetPagination,
14
+ });
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Leaflow Billing API
5
+ * Products, prices, orders, subscriptions and account billing. Financial operations require an account access token and billing-account authorization. Public catalogue operations declare no security requirement.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ export declare const CreditNoteList: zod.ZodObject<{
10
+ items: zod.ZodArray<zod.ZodObject<{
11
+ id: zod.ZodUUID;
12
+ invoice_id: zod.ZodUUID;
13
+ currency: zod.ZodString;
14
+ issued_at: zod.z.ZodISODateTime;
15
+ status: zod.ZodEnum<{
16
+ void: "void";
17
+ issued: "issued";
18
+ }>;
19
+ voided_at: zod.ZodNullable<zod.z.ZodISODateTime>;
20
+ unpaid_amount: zod.ZodString;
21
+ paid_amount: zod.ZodString;
22
+ refund_id: zod.ZodNullable<zod.ZodUUID>;
23
+ }, zod.z.core.$strict>>;
24
+ pagination: zod.ZodObject<{
25
+ page: zod.ZodInt;
26
+ page_size: zod.ZodInt;
27
+ total_count: zod.ZodOptional<zod.ZodInt>;
28
+ }, zod.z.core.$strict>;
29
+ }, zod.z.core.$strict>;
30
+ export type CreditNoteList = zod.input<typeof CreditNoteList>;
31
+ export type CreditNoteListOutput = zod.output<typeof CreditNoteList>;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Leaflow Billing API
5
+ * Products, prices, orders, subscriptions and account billing. Financial operations require an account access token and billing-account authorization. Public catalogue operations declare no security requirement.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ import { CreditNote } from "./creditNote.zod.js";
10
+ import { OffsetPagination } from "./offsetPagination.zod.js";
11
+ export const CreditNoteList = zod.strictObject({
12
+ items: zod.array(CreditNote),
13
+ pagination: OffsetPagination,
14
+ });
@@ -44,6 +44,8 @@ export declare const Invoice: zod.ZodObject<{
44
44
  credit_applied: zod.ZodOptional<zod.ZodString>;
45
45
  total: zod.ZodString;
46
46
  amount_paid: zod.ZodOptional<zod.ZodString>;
47
+ unpaid_credit_notes_amount: zod.ZodString;
48
+ paid_credit_notes_amount: zod.ZodString;
47
49
  amount_due: zod.ZodString;
48
50
  period_start: zod.ZodOptional<zod.ZodNullable<zod.z.ZodISODateTime>>;
49
51
  period_end: zod.ZodOptional<zod.ZodNullable<zod.z.ZodISODateTime>>;
@@ -32,7 +32,9 @@ export const Invoice = zod.strictObject({
32
32
  credit_applied: Money.optional().describe("Successful credit-grant payments included in amount_paid. Does not reduce the receivable or tax base."),
33
33
  total: Money.describe("Subtotal less discount plus tax. Balance and credit grants are payment sources, not reductions of the receivable."),
34
34
  amount_paid: Money.optional(),
35
- amount_due: Money.describe("What is still collectible after applied credits and successful payments; never below zero. A draft order invoice is not collectible until checkout confirms it, and a paid or void invoice has none."),
35
+ unpaid_credit_notes_amount: Money.describe("Issued, non-void credit notes that reduced unpaid receivables. Does not rewrite the original invoice total."),
36
+ paid_credit_notes_amount: Money.describe("Issued credit notes against payments already received. This is a return obligation, not evidence of completed refunds."),
37
+ amount_due: Money.describe("What is still collectible after unpaid credit notes and successful payments; never below zero. A draft order invoice is not collectible until checkout confirms it, and a paid or void invoice has none."),
36
38
  period_start: zod.iso.datetime({ offset: true }).nullish(),
37
39
  period_end: zod.iso.datetime({ offset: true }).nullish().describe("Exclusive."),
38
40
  customer_name: zod
@@ -45,6 +45,8 @@ export declare const InvoiceList: zod.ZodObject<{
45
45
  credit_applied: zod.ZodOptional<zod.ZodString>;
46
46
  total: zod.ZodString;
47
47
  amount_paid: zod.ZodOptional<zod.ZodString>;
48
+ unpaid_credit_notes_amount: zod.ZodString;
49
+ paid_credit_notes_amount: zod.ZodString;
48
50
  amount_due: zod.ZodString;
49
51
  period_start: zod.ZodOptional<zod.ZodNullable<zod.z.ZodISODateTime>>;
50
52
  period_end: zod.ZodOptional<zod.ZodNullable<zod.z.ZodISODateTime>>;
@@ -24,6 +24,8 @@ export declare const InvoiceSummary: zod.ZodObject<{
24
24
  tax_amount: zod.ZodString;
25
25
  total: zod.ZodString;
26
26
  amount_paid: zod.ZodString;
27
+ unpaid_credit_notes_amount: zod.ZodString;
28
+ paid_credit_notes_amount: zod.ZodString;
27
29
  amount_due: zod.ZodString;
28
30
  amount_refunded: zod.ZodString;
29
31
  due_at: zod.ZodOptional<zod.z.ZodISODateTime>;
@@ -7,6 +7,7 @@
7
7
  */
8
8
  import * as zod from "zod";
9
9
  import { InvoiceStatus } from "./invoiceStatus.zod.js";
10
+ import { Money } from "./money.zod.js";
10
11
  export const invoiceSummaryAmountDueRegExp = new RegExp("^\\d+(\\.\\d{1,10})?$");
11
12
  export const InvoiceSummary = zod
12
13
  .strictObject({
@@ -21,10 +22,12 @@ export const InvoiceSummary = zod
21
22
  tax_amount: zod.string(),
22
23
  total: zod.string(),
23
24
  amount_paid: zod.string(),
25
+ unpaid_credit_notes_amount: Money.describe("Issued, non-void credit notes that reduced unpaid receivables. Does not rewrite the original invoice total."),
26
+ paid_credit_notes_amount: Money.describe("Issued credit notes against payments already received. This is a return obligation, not evidence of completed refunds."),
24
27
  amount_due: zod
25
28
  .string()
26
29
  .regex(invoiceSummaryAmountDueRegExp)
27
- .describe("What is still collectible after applied credits and successful payments; never below zero."),
30
+ .describe("What is still collectible after unpaid credit notes and successful payments; never below zero."),
28
31
  amount_refunded: zod.string(),
29
32
  due_at: zod.iso.datetime({ offset: true }).optional(),
30
33
  })
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Leaflow Billing API
5
+ * Products, prices, orders, subscriptions and account billing. Financial operations require an account access token and billing-account authorization. Public catalogue operations declare no security requirement.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ export declare const listCreditNoteItemsParamsPageDefault = 1;
10
+ export declare const listCreditNoteItemsParamsPageMax = 2147483647;
11
+ export declare const listCreditNoteItemsParamsPageSizeDefault = 50;
12
+ export declare const listCreditNoteItemsParamsPageSizeMax = 200;
13
+ export declare const ListCreditNoteItemsParams: zod.ZodObject<{
14
+ page: zod.ZodDefault<zod.ZodInt>;
15
+ page_size: zod.ZodDefault<zod.ZodInt>;
16
+ }, zod.z.core.$strict>;
17
+ export type ListCreditNoteItemsParams = zod.input<typeof ListCreditNoteItemsParams>;
18
+ export type ListCreditNoteItemsParamsOutput = zod.output<typeof ListCreditNoteItemsParams>;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Leaflow Billing API
5
+ * Products, prices, orders, subscriptions and account billing. Financial operations require an account access token and billing-account authorization. Public catalogue operations declare no security requirement.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ export const listCreditNoteItemsParamsPageDefault = 1;
10
+ export const listCreditNoteItemsParamsPageMax = 2147483647;
11
+ export const listCreditNoteItemsParamsPageSizeDefault = 50;
12
+ export const listCreditNoteItemsParamsPageSizeMax = 200;
13
+ export const ListCreditNoteItemsParams = zod.strictObject({
14
+ page: zod
15
+ .int()
16
+ .min(1)
17
+ .max(listCreditNoteItemsParamsPageMax)
18
+ .default(listCreditNoteItemsParamsPageDefault),
19
+ page_size: zod
20
+ .int()
21
+ .min(1)
22
+ .max(listCreditNoteItemsParamsPageSizeMax)
23
+ .default(listCreditNoteItemsParamsPageSizeDefault),
24
+ });
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Leaflow Billing API
5
+ * Products, prices, orders, subscriptions and account billing. Financial operations require an account access token and billing-account authorization. Public catalogue operations declare no security requirement.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ export declare const listCreditNotesParamsPageDefault = 1;
10
+ export declare const listCreditNotesParamsPageMax = 2147483647;
11
+ export declare const listCreditNotesParamsPageSizeDefault = 50;
12
+ export declare const listCreditNotesParamsPageSizeMax = 200;
13
+ export declare const ListCreditNotesParams: zod.ZodObject<{
14
+ page: zod.ZodDefault<zod.ZodInt>;
15
+ page_size: zod.ZodDefault<zod.ZodInt>;
16
+ billing_account_id: zod.ZodOptional<zod.ZodInt>;
17
+ invoice_id: zod.ZodOptional<zod.ZodUUID>;
18
+ }, zod.z.core.$strict>;
19
+ export type ListCreditNotesParams = zod.input<typeof ListCreditNotesParams>;
20
+ export type ListCreditNotesParamsOutput = zod.output<typeof ListCreditNotesParams>;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Leaflow Billing API
5
+ * Products, prices, orders, subscriptions and account billing. Financial operations require an account access token and billing-account authorization. Public catalogue operations declare no security requirement.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ export const listCreditNotesParamsPageDefault = 1;
10
+ export const listCreditNotesParamsPageMax = 2147483647;
11
+ export const listCreditNotesParamsPageSizeDefault = 50;
12
+ export const listCreditNotesParamsPageSizeMax = 200;
13
+ export const ListCreditNotesParams = zod.strictObject({
14
+ page: zod
15
+ .int()
16
+ .min(1)
17
+ .max(listCreditNotesParamsPageMax)
18
+ .default(listCreditNotesParamsPageDefault),
19
+ page_size: zod
20
+ .int()
21
+ .min(1)
22
+ .max(listCreditNotesParamsPageSizeMax)
23
+ .default(listCreditNotesParamsPageSizeDefault),
24
+ billing_account_id: zod.int().optional(),
25
+ invoice_id: zod.uuid().optional(),
26
+ });
@@ -32,6 +32,8 @@ export declare const Order: zod.ZodObject<{
32
32
  tax_amount: zod.ZodString;
33
33
  total: zod.ZodString;
34
34
  amount_paid: zod.ZodString;
35
+ unpaid_credit_notes_amount: zod.ZodString;
36
+ paid_credit_notes_amount: zod.ZodString;
35
37
  amount_due: zod.ZodString;
36
38
  amount_refunded: zod.ZodString;
37
39
  due_at: zod.ZodOptional<zod.z.ZodISODateTime>;
@@ -48,7 +50,6 @@ export declare const Order: zod.ZodObject<{
48
50
  name: zod.ZodString;
49
51
  currency: zod.ZodString;
50
52
  }, zod.z.core.$strict>>;
51
- cancel_reason: zod.ZodOptional<zod.ZodString>;
52
53
  change_effective_at: zod.ZodOptional<zod.z.ZodISODateTime>;
53
54
  id: zod.ZodUUID;
54
55
  project_id: zod.ZodOptional<zod.ZodNullable<zod.ZodUUID>>;
@@ -25,7 +25,6 @@ export const Order = zod
25
25
  invoice: InvoiceSummary.optional(),
26
26
  paid_with: PaidWith.optional().describe("How the order was paid. Absent until it is paid."),
27
27
  account: AccountIdentity.optional(),
28
- cancel_reason: zod.string().optional(),
29
28
  change_effective_at: zod.iso.datetime({ offset: true }).optional(),
30
29
  id: zod.uuid(),
31
30
  project_id: zod
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Leaflow Billing API
5
+ * Products, prices, orders, subscriptions and account billing. Financial operations require an account access token and billing-account authorization. Public catalogue operations declare no security requirement.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ export declare const orderCancelOrderItemIdsMax = 100;
10
+ export declare const OrderCancel: zod.ZodObject<{
11
+ order_item_ids: zod.ZodOptional<zod.ZodArray<zod.ZodUUID>>;
12
+ }, zod.z.core.$strict>;
13
+ export type OrderCancel = zod.input<typeof OrderCancel>;
14
+ export type OrderCancelOutput = zod.output<typeof OrderCancel>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Leaflow Billing API
5
+ * Products, prices, orders, subscriptions and account billing. Financial operations require an account access token and billing-account authorization. Public catalogue operations declare no security requirement.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ export const orderCancelOrderItemIdsMax = 100;
10
+ export const OrderCancel = zod.strictObject({
11
+ order_item_ids: zod
12
+ .array(zod.uuid())
13
+ .min(1)
14
+ .max(orderCancelOrderItemIdsMax)
15
+ .optional()
16
+ .describe("Omit to select all still-pending items. Explicit selections name one or more items of this order; successful items cannot be reversed here."),
17
+ });
@@ -33,6 +33,8 @@ export declare const OrderList: zod.ZodObject<{
33
33
  tax_amount: zod.ZodString;
34
34
  total: zod.ZodString;
35
35
  amount_paid: zod.ZodString;
36
+ unpaid_credit_notes_amount: zod.ZodString;
37
+ paid_credit_notes_amount: zod.ZodString;
36
38
  amount_due: zod.ZodString;
37
39
  amount_refunded: zod.ZodString;
38
40
  due_at: zod.ZodOptional<zod.z.ZodISODateTime>;
@@ -49,7 +51,6 @@ export declare const OrderList: zod.ZodObject<{
49
51
  name: zod.ZodString;
50
52
  currency: zod.ZodString;
51
53
  }, zod.z.core.$strict>>;
52
- cancel_reason: zod.ZodOptional<zod.ZodString>;
53
54
  change_effective_at: zod.ZodOptional<zod.z.ZodISODateTime>;
54
55
  id: zod.ZodUUID;
55
56
  project_id: zod.ZodOptional<zod.ZodNullable<zod.ZodUUID>>;
package/dist/routes.d.ts CHANGED
@@ -1,4 +1,28 @@
1
1
  export declare const routes: readonly [{
2
+ readonly service: "billing";
3
+ readonly contract: "billing";
4
+ readonly method: "GET";
5
+ readonly path: "/api/v1/credit-notes";
6
+ readonly operationId: "list-credit-notes";
7
+ readonly securityScheme: "AccessToken";
8
+ readonly upstreamUrl: "https://billing.leaflow.cloud";
9
+ }, {
10
+ readonly service: "billing";
11
+ readonly contract: "billing";
12
+ readonly method: "GET";
13
+ readonly path: "/api/v1/credit-notes/{creditNoteId}";
14
+ readonly operationId: "get-credit-note";
15
+ readonly securityScheme: "AccessToken";
16
+ readonly upstreamUrl: "https://billing.leaflow.cloud";
17
+ }, {
18
+ readonly service: "billing";
19
+ readonly contract: "billing";
20
+ readonly method: "GET";
21
+ readonly path: "/api/v1/credit-notes/{creditNoteId}/items";
22
+ readonly operationId: "list-credit-note-items";
23
+ readonly securityScheme: "AccessToken";
24
+ readonly upstreamUrl: "https://billing.leaflow.cloud";
25
+ }, {
2
26
  readonly service: "account";
3
27
  readonly contract: "account";
4
28
  readonly method: "GET";
package/dist/routes.js CHANGED
@@ -1,5 +1,32 @@
1
1
  // Static contract routing and authentication facts for frontend gateways.
2
2
  export const routes = [
3
+ {
4
+ service: "billing",
5
+ contract: "billing",
6
+ method: "GET",
7
+ path: "/api/v1/credit-notes",
8
+ operationId: "list-credit-notes",
9
+ securityScheme: "AccessToken",
10
+ upstreamUrl: "https://billing.leaflow.cloud",
11
+ },
12
+ {
13
+ service: "billing",
14
+ contract: "billing",
15
+ method: "GET",
16
+ path: "/api/v1/credit-notes/{creditNoteId}",
17
+ operationId: "get-credit-note",
18
+ securityScheme: "AccessToken",
19
+ upstreamUrl: "https://billing.leaflow.cloud",
20
+ },
21
+ {
22
+ service: "billing",
23
+ contract: "billing",
24
+ method: "GET",
25
+ path: "/api/v1/credit-notes/{creditNoteId}/items",
26
+ operationId: "list-credit-note-items",
27
+ securityScheme: "AccessToken",
28
+ upstreamUrl: "https://billing.leaflow.cloud",
29
+ },
3
30
  {
4
31
  service: "account",
5
32
  contract: "account",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leaflow/sdk",
3
- "version": "0.109.0",
3
+ "version": "0.110.0",
4
4
  "description": "Leaflow 平台 API 的 TypeScript SDK",
5
5
  "license": "MIT",
6
6
  "repository": {