@leaflow/sdk 0.110.0 → 0.112.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.
@@ -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, 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";
8
+ import type { AccountBalance, ActiveResourceList, AllowanceList, AutoRenewSet, BillingAccount, BillingAccountCreate, BillingAccountList, BillingAccountUpdate, CancelSubscriptionRequest, 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;
@@ -855,6 +855,7 @@ export type listSubscriptionsResponseError = listSubscriptionsResponseDefault &
855
855
  export type listSubscriptionsResponse = listSubscriptionsResponseSuccess | listSubscriptionsResponseError;
856
856
  export declare const getListSubscriptionsUrl: (params?: ListSubscriptionsParams) => string;
857
857
  /**
858
+ * Lists subscriptions visible to the authorized billing account. Soft-deleted subscriptions are excluded.
858
859
  * @summary List subscriptions
859
860
  */
860
861
  export declare const listSubscriptions: (params?: ListSubscriptionsParams, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<listSubscriptionsResponse>;
@@ -875,9 +876,72 @@ export type getSubscriptionResponseError = getSubscriptionResponseDefault & {
875
876
  export type getSubscriptionResponse = getSubscriptionResponseSuccess | getSubscriptionResponseError;
876
877
  export declare const getGetSubscriptionUrl: (subscriptionId: string) => string;
877
878
  /**
879
+ * Returns a subscription visible to the authorized billing account. Soft-deleted subscriptions are reported as not found.
878
880
  * @summary Get subscription
879
881
  */
880
882
  export declare const getSubscription: (subscriptionId: string, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<getSubscriptionResponse>;
883
+ export type deleteSubscriptionResponse204 = {
884
+ data: void;
885
+ status: 204;
886
+ };
887
+ export type deleteSubscriptionResponseDefault = {
888
+ data: ErrorResponse;
889
+ status: Exclude<HTTPStatusCodes, 204>;
890
+ };
891
+ export type deleteSubscriptionResponseSuccess = deleteSubscriptionResponse204 & {
892
+ headers: Headers;
893
+ };
894
+ export type deleteSubscriptionResponseError = deleteSubscriptionResponseDefault & {
895
+ headers: Headers;
896
+ };
897
+ export type deleteSubscriptionResponse = deleteSubscriptionResponseSuccess | deleteSubscriptionResponseError;
898
+ export declare const getDeleteSubscriptionUrl: (subscriptionId: string) => string;
899
+ /**
900
+ * Sets deleted_at on a canceled or terminated subscription, hiding it from your subscription
901
+ * list and detail. Your account access token must authorize the subscription's current billing
902
+ * account. Preserves commercial status, ended_at and billing and financial history. Completed
903
+ * cancellations and canceled unfulfilled purchases can be deleted directly, without termination.
904
+ * Pending, provisioning, active and suspended subscriptions are refused with 409
905
+ * BILLING_SUBSCRIPTION_NOT_ENDED and status in error params. A scheduled or releasing cancellation
906
+ * does not make a subscription canceled.
907
+ * There is no force, skip-cleanup or override option. Repeating deletion preserves the original
908
+ * deleted_at. Sends no cleanup command and creates no refund; outstanding cleanup continues.
909
+ * @summary Delete subscription
910
+ */
911
+ export declare const deleteSubscription: (subscriptionId: string, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<deleteSubscriptionResponse>;
912
+ export type cancelSubscriptionResponse202 = {
913
+ data: Cancellation;
914
+ status: 202;
915
+ };
916
+ export type cancelSubscriptionResponseDefault = {
917
+ data: ErrorResponse;
918
+ status: Exclude<HTTPStatusCodes, 202>;
919
+ };
920
+ export type cancelSubscriptionResponseSuccess = cancelSubscriptionResponse202 & {
921
+ headers: Headers;
922
+ };
923
+ export type cancelSubscriptionResponseError = cancelSubscriptionResponseDefault & {
924
+ headers: Headers;
925
+ };
926
+ export type cancelSubscriptionResponse = cancelSubscriptionResponseSuccess | cancelSubscriptionResponseError;
927
+ export declare const getCancelSubscriptionUrl: (subscriptionId: string) => string;
928
+ /**
929
+ * Requests cancellation on the purchase's agreed terms. Uses the same quotation, eligibility,
930
+ * metering and original-payment-source refund rules as creating a cancellation.
931
+ * Supply the refund amount from create-quote with this subscription in cancellation.subscription_ids.
932
+ * Your account access token must authorize the subscription's current billing account.
933
+ *
934
+ * Immediate cancellation asks the owning service to clean up now. Period-end cancellation keeps
935
+ * the subscription active or suspended until the paid term ends. Neither payment nor acceptance
936
+ * of this request proves cleanup. The subscription becomes canceled only after the service
937
+ * confirms release and the end of metering; follow the returned cancellation for progress.
938
+ *
939
+ * Related subscriptions released together must be submitted as one group to create-cancellation.
940
+ * Pending or provisioning purchases are canceled through their order, not this operation.
941
+ * Repeating the same open cancellation returns it without another refund or command.
942
+ * @summary Cancel subscription
943
+ */
944
+ export declare const cancelSubscription: (subscriptionId: string, cancelSubscriptionRequest: CancelSubscriptionRequest, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<cancelSubscriptionResponse>;
881
945
  export type createQuoteResponse200 = {
882
946
  data: Quote;
883
947
  status: 200;
@@ -938,6 +938,7 @@ export const getListSubscriptionsUrl = (params) => {
938
938
  : `https://billing.leaflow.cloud/api/v1/subscriptions`;
939
939
  };
940
940
  /**
941
+ * Lists subscriptions visible to the authorized billing account. Soft-deleted subscriptions are excluded.
941
942
  * @summary List subscriptions
942
943
  */
943
944
  export const listSubscriptions = async (params, options, fetchFn) => {
@@ -953,6 +954,7 @@ export const getGetSubscriptionUrl = (subscriptionId) => {
953
954
  return `https://billing.leaflow.cloud/api/v1/subscriptions/${encodeURIComponent(String(subscriptionId))}`;
954
955
  };
955
956
  /**
957
+ * Returns a subscription visible to the authorized billing account. Soft-deleted subscriptions are reported as not found.
956
958
  * @summary Get subscription
957
959
  */
958
960
  export const getSubscription = async (subscriptionId, options, fetchFn) => {
@@ -964,6 +966,75 @@ export const getSubscription = async (subscriptionId, options, fetchFn) => {
964
966
  const data = body ? JSON.parse(body) : {};
965
967
  return { data, status: res.status, headers: res.headers };
966
968
  };
969
+ export const getDeleteSubscriptionUrl = (subscriptionId) => {
970
+ return `https://billing.leaflow.cloud/api/v1/subscriptions/${encodeURIComponent(String(subscriptionId))}`;
971
+ };
972
+ /**
973
+ * Sets deleted_at on a canceled or terminated subscription, hiding it from your subscription
974
+ * list and detail. Your account access token must authorize the subscription's current billing
975
+ * account. Preserves commercial status, ended_at and billing and financial history. Completed
976
+ * cancellations and canceled unfulfilled purchases can be deleted directly, without termination.
977
+ * Pending, provisioning, active and suspended subscriptions are refused with 409
978
+ * BILLING_SUBSCRIPTION_NOT_ENDED and status in error params. A scheduled or releasing cancellation
979
+ * does not make a subscription canceled.
980
+ * There is no force, skip-cleanup or override option. Repeating deletion preserves the original
981
+ * deleted_at. Sends no cleanup command and creates no refund; outstanding cleanup continues.
982
+ * @summary Delete subscription
983
+ */
984
+ export const deleteSubscription = async (subscriptionId, options, fetchFn) => {
985
+ const res = await (fetchFn ?? fetch)(getDeleteSubscriptionUrl(subscriptionId), {
986
+ ...options,
987
+ method: "DELETE",
988
+ });
989
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
990
+ const data = body ? JSON.parse(body) : undefined;
991
+ return { data, status: res.status, headers: res.headers };
992
+ };
993
+ export const getCancelSubscriptionUrl = (subscriptionId) => {
994
+ return `https://billing.leaflow.cloud/api/v1/subscriptions/${encodeURIComponent(String(subscriptionId))}/cancel`;
995
+ };
996
+ /**
997
+ * Requests cancellation on the purchase's agreed terms. Uses the same quotation, eligibility,
998
+ * metering and original-payment-source refund rules as creating a cancellation.
999
+ * Supply the refund amount from create-quote with this subscription in cancellation.subscription_ids.
1000
+ * Your account access token must authorize the subscription's current billing account.
1001
+ *
1002
+ * Immediate cancellation asks the owning service to clean up now. Period-end cancellation keeps
1003
+ * the subscription active or suspended until the paid term ends. Neither payment nor acceptance
1004
+ * of this request proves cleanup. The subscription becomes canceled only after the service
1005
+ * confirms release and the end of metering; follow the returned cancellation for progress.
1006
+ *
1007
+ * Related subscriptions released together must be submitted as one group to create-cancellation.
1008
+ * Pending or provisioning purchases are canceled through their order, not this operation.
1009
+ * Repeating the same open cancellation returns it without another refund or command.
1010
+ * @summary Cancel subscription
1011
+ */
1012
+ export const cancelSubscription = async (subscriptionId, cancelSubscriptionRequest, options, fetchFn) => {
1013
+ const getHeaders = (h) => {
1014
+ if (!h)
1015
+ return {};
1016
+ if (h instanceof Headers)
1017
+ return Object.fromEntries(h.entries());
1018
+ if (Symbol.iterator in h) {
1019
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1020
+ }
1021
+ const headers = {};
1022
+ for (const [name, value] of Object.entries(h)) {
1023
+ if (value !== undefined)
1024
+ headers[name] = value;
1025
+ }
1026
+ return headers;
1027
+ };
1028
+ const res = await (fetchFn ?? fetch)(getCancelSubscriptionUrl(subscriptionId), {
1029
+ ...options,
1030
+ method: "POST",
1031
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
1032
+ body: JSON.stringify(cancelSubscriptionRequest),
1033
+ });
1034
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
1035
+ const data = body ? JSON.parse(body) : {};
1036
+ return { data, status: res.status, headers: res.headers };
1037
+ };
967
1038
  export const getCreateQuoteUrl = () => {
968
1039
  return `https://billing.leaflow.cloud/api/v1/quotes`;
969
1040
  };
@@ -1670,6 +1670,8 @@ export interface PaidWith {
1670
1670
  * pending means the purchase relationship exists but its order has not been accepted.
1671
1671
  * provisioning means the service accepted the order and is delivering. For a service-owned
1672
1672
  * purchase, only confirmed delivery moves it to active; paying alone does not.
1673
+ * canceled means cancellation completed, or an unfulfilled purchase was canceled or failed without delivery.
1674
+ * terminated means an administrator or the owning service immediately ended the commercial relationship.
1673
1675
  */
1674
1676
  export type SubscriptionStatus = (typeof SubscriptionStatus)[keyof typeof SubscriptionStatus];
1675
1677
  export declare const SubscriptionStatus: {
@@ -1694,8 +1696,8 @@ export declare const SubscriptionStatus: {
1694
1696
  *
1695
1697
  * One-time delivery may omit a subscription. Renewals reference and extend existing subscriptions
1696
1698
  * rather than creating another; a change keeps the subscription ID and switches its terms when it
1697
- * takes effect. Canceling or failing an
1698
- * unfulfilled purchase closes its pending or provisioning subscriptions without starting a service period.
1699
+ * takes effect. Canceling or failing an unfulfilled purchase sets its pending or provisioning
1700
+ * subscriptions to canceled without starting a service period.
1699
1701
  * Fixed renewals use the agreed recurring_amount and interval; already paid periods retain their
1700
1702
  * original value. Technical state belongs to the owning service.
1701
1703
  *
@@ -1768,6 +1770,8 @@ export interface Subscription {
1768
1770
  * pending means the purchase relationship exists but its order has not been accepted.
1769
1771
  * provisioning means the service accepted the order and is delivering. For a service-owned
1770
1772
  * purchase, only confirmed delivery moves it to active; paying alone does not.
1773
+ * canceled means cancellation completed, or an unfulfilled purchase was canceled or failed without delivery.
1774
+ * terminated means an administrator or the owning service immediately ended the commercial relationship.
1771
1775
  */
1772
1776
  status: SubscriptionStatus;
1773
1777
  /**
@@ -2646,6 +2650,15 @@ export interface CursorPagination {
2646
2650
  /** @nullable */
2647
2651
  next_cursor?: string | null;
2648
2652
  }
2653
+ export interface CancelSubscriptionRequest {
2654
+ mode: TerminationPolicy;
2655
+ /** For immediate cancellation, the quoted whole-second refund basis. Now when omitted. */
2656
+ proration_date?: string;
2657
+ /** The cancellation quote's refundable amount, including an explicit zero. */
2658
+ expected_refundable_amount: Money & string;
2659
+ /** @maxLength 1024 */
2660
+ reason?: string;
2661
+ }
2649
2662
  /**
2650
2663
  * Error
2651
2664
  */
@@ -507,6 +507,7 @@ export declare const ListUsageChargesQueryParams: zod.ZodObject<{
507
507
  meter_id: zod.ZodOptional<zod.ZodUUID>;
508
508
  }, zod.z.core.$strict>;
509
509
  /**
510
+ * Lists subscriptions visible to the authorized billing account. Soft-deleted subscriptions are excluded.
510
511
  * @summary List subscriptions
511
512
  */
512
513
  export declare const listSubscriptionsQueryPageDefault = 1;
@@ -522,11 +523,55 @@ export declare const ListSubscriptionsQueryParams: zod.ZodObject<{
522
523
  project_ids: zod.ZodOptional<zod.ZodArray<zod.ZodUUID>>;
523
524
  }, zod.z.core.$strict>;
524
525
  /**
526
+ * Returns a subscription visible to the authorized billing account. Soft-deleted subscriptions are reported as not found.
525
527
  * @summary Get subscription
526
528
  */
527
529
  export declare const GetSubscriptionParams: zod.ZodObject<{
528
530
  subscriptionId: zod.ZodUUID;
529
531
  }, zod.z.core.$strict>;
532
+ /**
533
+ * Sets deleted_at on a canceled or terminated subscription, hiding it from your subscription
534
+ * list and detail. Your account access token must authorize the subscription's current billing
535
+ * account. Preserves commercial status, ended_at and billing and financial history. Completed
536
+ * cancellations and canceled unfulfilled purchases can be deleted directly, without termination.
537
+ * Pending, provisioning, active and suspended subscriptions are refused with 409
538
+ * BILLING_SUBSCRIPTION_NOT_ENDED and status in error params. A scheduled or releasing cancellation
539
+ * does not make a subscription canceled.
540
+ * There is no force, skip-cleanup or override option. Repeating deletion preserves the original
541
+ * deleted_at. Sends no cleanup command and creates no refund; outstanding cleanup continues.
542
+ * @summary Delete subscription
543
+ */
544
+ export declare const DeleteSubscriptionParams: zod.ZodObject<{
545
+ subscriptionId: zod.ZodUUID;
546
+ }, zod.z.core.$strict>;
547
+ /**
548
+ * Requests cancellation on the purchase's agreed terms. Uses the same quotation, eligibility,
549
+ * metering and original-payment-source refund rules as creating a cancellation.
550
+ * Supply the refund amount from create-quote with this subscription in cancellation.subscription_ids.
551
+ * Your account access token must authorize the subscription's current billing account.
552
+ *
553
+ * Immediate cancellation asks the owning service to clean up now. Period-end cancellation keeps
554
+ * the subscription active or suspended until the paid term ends. Neither payment nor acceptance
555
+ * of this request proves cleanup. The subscription becomes canceled only after the service
556
+ * confirms release and the end of metering; follow the returned cancellation for progress.
557
+ *
558
+ * Related subscriptions released together must be submitted as one group to create-cancellation.
559
+ * Pending or provisioning purchases are canceled through their order, not this operation.
560
+ * Repeating the same open cancellation returns it without another refund or command.
561
+ * @summary Cancel subscription
562
+ */
563
+ export declare const CancelSubscriptionParams: zod.ZodObject<{
564
+ subscriptionId: zod.ZodUUID;
565
+ }, zod.z.core.$strict>;
566
+ export declare const CancelSubscriptionBody: zod.ZodObject<{
567
+ mode: zod.ZodEnum<{
568
+ immediate: "immediate";
569
+ period_end: "period_end";
570
+ }>;
571
+ proration_date: zod.ZodOptional<zod.z.ZodISODateTime>;
572
+ expected_refundable_amount: zod.ZodIntersection<zod.ZodString, zod.ZodString>;
573
+ reason: zod.ZodOptional<zod.ZodString>;
574
+ }, zod.z.core.$strict>;
530
575
  /**
531
576
  * Calculates exactly one target for a billing account you own: proposed items, existing order checkout, renewals, cancellation or order refund. Returns all requested calculations or a structured error. No quote is saved and no resource, payment, reservation or redemption is created.
532
577
  *
@@ -9,6 +9,7 @@ import * as zod from "zod";
9
9
  import { AutoRenewSet } from "./validators/autoRenewSet.zod.js";
10
10
  import { BillingAccountCreate } from "./validators/billingAccountCreate.zod.js";
11
11
  import { BillingAccountUpdate } from "./validators/billingAccountUpdate.zod.js";
12
+ import { CancelSubscriptionRequest } from "./validators/cancelSubscriptionRequest.zod.js";
12
13
  import { CancellationCreate } from "./validators/cancellationCreate.zod.js";
13
14
  import { CheckoutOrderRequest } from "./validators/checkoutOrderRequest.zod.js";
14
15
  import { OrderCancel } from "./validators/orderCancel.zod.js";
@@ -675,6 +676,7 @@ export const ListUsageChargesQueryParams = zod.strictObject({
675
676
  meter_id: zod.uuid().optional(),
676
677
  });
677
678
  /**
679
+ * Lists subscriptions visible to the authorized billing account. Soft-deleted subscriptions are excluded.
678
680
  * @summary List subscriptions
679
681
  */
680
682
  export const listSubscriptionsQueryPageDefault = 1;
@@ -708,11 +710,47 @@ export const ListSubscriptionsQueryParams = zod.strictObject({
708
710
  .describe("Restrict the account-authorized results to these projects. Omit for all projects and account-level records. This filter does not grant access to another billing account."),
709
711
  });
710
712
  /**
713
+ * Returns a subscription visible to the authorized billing account. Soft-deleted subscriptions are reported as not found.
711
714
  * @summary Get subscription
712
715
  */
713
716
  export const GetSubscriptionParams = zod.strictObject({
714
717
  subscriptionId: zod.uuid(),
715
718
  });
719
+ /**
720
+ * Sets deleted_at on a canceled or terminated subscription, hiding it from your subscription
721
+ * list and detail. Your account access token must authorize the subscription's current billing
722
+ * account. Preserves commercial status, ended_at and billing and financial history. Completed
723
+ * cancellations and canceled unfulfilled purchases can be deleted directly, without termination.
724
+ * Pending, provisioning, active and suspended subscriptions are refused with 409
725
+ * BILLING_SUBSCRIPTION_NOT_ENDED and status in error params. A scheduled or releasing cancellation
726
+ * does not make a subscription canceled.
727
+ * There is no force, skip-cleanup or override option. Repeating deletion preserves the original
728
+ * deleted_at. Sends no cleanup command and creates no refund; outstanding cleanup continues.
729
+ * @summary Delete subscription
730
+ */
731
+ export const DeleteSubscriptionParams = zod.strictObject({
732
+ subscriptionId: zod.uuid(),
733
+ });
734
+ /**
735
+ * Requests cancellation on the purchase's agreed terms. Uses the same quotation, eligibility,
736
+ * metering and original-payment-source refund rules as creating a cancellation.
737
+ * Supply the refund amount from create-quote with this subscription in cancellation.subscription_ids.
738
+ * Your account access token must authorize the subscription's current billing account.
739
+ *
740
+ * Immediate cancellation asks the owning service to clean up now. Period-end cancellation keeps
741
+ * the subscription active or suspended until the paid term ends. Neither payment nor acceptance
742
+ * of this request proves cleanup. The subscription becomes canceled only after the service
743
+ * confirms release and the end of metering; follow the returned cancellation for progress.
744
+ *
745
+ * Related subscriptions released together must be submitted as one group to create-cancellation.
746
+ * Pending or provisioning purchases are canceled through their order, not this operation.
747
+ * Repeating the same open cancellation returns it without another refund or command.
748
+ * @summary Cancel subscription
749
+ */
750
+ export const CancelSubscriptionParams = zod.strictObject({
751
+ subscriptionId: zod.uuid(),
752
+ });
753
+ export const CancelSubscriptionBody = CancelSubscriptionRequest;
716
754
  /**
717
755
  * Calculates exactly one target for a billing account you own: proposed items, existing order checkout, renewals, cancellation or order refund. Returns all requested calculations or a structured error. No quote is saved and no resource, payment, reservation or redemption is created.
718
756
  *
@@ -0,0 +1,21 @@
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 cancelSubscriptionRequestExpectedRefundableAmountTwoRegExp: RegExp;
10
+ export declare const cancelSubscriptionRequestReasonMax = 1024;
11
+ export declare const CancelSubscriptionRequest: zod.ZodObject<{
12
+ mode: zod.ZodEnum<{
13
+ immediate: "immediate";
14
+ period_end: "period_end";
15
+ }>;
16
+ proration_date: zod.ZodOptional<zod.z.ZodISODateTime>;
17
+ expected_refundable_amount: zod.ZodIntersection<zod.ZodString, zod.ZodString>;
18
+ reason: zod.ZodOptional<zod.ZodString>;
19
+ }, zod.z.core.$strict>;
20
+ export type CancelSubscriptionRequest = zod.input<typeof CancelSubscriptionRequest>;
21
+ export type CancelSubscriptionRequestOutput = zod.output<typeof CancelSubscriptionRequest>;
@@ -0,0 +1,21 @@
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
+ import { TerminationPolicy } from "./terminationPolicy.zod.js";
11
+ export const cancelSubscriptionRequestExpectedRefundableAmountTwoRegExp = new RegExp("^[0-9]{1,15}([.][0-9]{1,10})?$");
12
+ export const cancelSubscriptionRequestReasonMax = 1024;
13
+ export const CancelSubscriptionRequest = zod.strictObject({
14
+ mode: TerminationPolicy,
15
+ proration_date: zod.iso
16
+ .datetime({ offset: true })
17
+ .optional()
18
+ .describe("For immediate cancellation, the quoted whole-second refund basis. Now when omitted."),
19
+ expected_refundable_amount: Money.and(zod.string().regex(cancelSubscriptionRequestExpectedRefundableAmountTwoRegExp)).describe("The cancellation quote's refundable amount, including an explicit zero."),
20
+ reason: zod.string().max(cancelSubscriptionRequestReasonMax).optional(),
21
+ });
@@ -9,7 +9,7 @@ import * as zod from "zod";
9
9
  import { Money } from "./money.zod.js";
10
10
  import { TerminationPolicy } from "./terminationPolicy.zod.js";
11
11
  export const cancellationCreateSubscriptionIdsMax = 50;
12
- export const cancellationCreateExpectedRefundableAmountTwoRegExp = new RegExp("^-?[0-9]{1,15}([.][0-9]{1,10})?$");
12
+ export const cancellationCreateExpectedRefundableAmountTwoRegExp = new RegExp("^[0-9]{1,15}([.][0-9]{1,10})?$");
13
13
  export const cancellationCreateReasonMax = 1024;
14
14
  export const CancellationCreate = zod.strictObject({
15
15
  subscription_ids: zod
@@ -70,11 +70,11 @@ export const Subscription = zod
70
70
  auto_renew: zod.boolean(),
71
71
  status: zod
72
72
  .enum(["pending", "provisioning", "active", "suspended", "canceled", "terminated"])
73
- .describe("pending means the purchase relationship exists but its order has not been accepted.\nprovisioning means the service accepted the order and is delivering. For a service-owned\npurchase, only confirmed delivery moves it to active; paying alone does not."),
73
+ .describe("pending means the purchase relationship exists but its order has not been accepted.\nprovisioning means the service accepted the order and is delivering. For a service-owned\npurchase, only confirmed delivery moves it to active; paying alone does not.\ncanceled means cancellation completed, or an unfulfilled purchase was canceled or failed without delivery.\nterminated means an administrator or the owning service immediately ended the commercial relationship."),
74
74
  started_at: zod.iso
75
75
  .datetime({ offset: true })
76
76
  .nullish()
77
77
  .describe("Confirmed start of service. Null until a new subscription becomes active, including after payment."),
78
78
  ended_at: zod.iso.datetime({ offset: true }).nullish(),
79
79
  })
80
- .describe("An independently billed purchase relationship, separate from the owning service's resource.\nPlacing a new prepaid or postpaid service order creates a pending subscription for each line\nin the same purchase transaction. Its ID is returned on the order item and remains stable\nthrough checkout and delivery. One order may create several subscriptions, such as an instance,\nits system disk and its address; it has no single subscription ID.\n\nPending and provisioning do not grant service or accrue usage. A service-owned subscription\nbecomes provisioning when the owning service accepts the order, and active when the service\nconfirms delivery, with started_at set to the confirmed effective time; payment changes neither. Prepaid service periods start\nthen; postpaid usage starts only when the service reports actual delivery and metering.\n\nOne-time delivery may omit a subscription. Renewals reference and extend existing subscriptions\nrather than creating another; a change keeps the subscription ID and switches its terms when it\ntakes effect. Canceling or failing an\nunfulfilled purchase closes its pending or provisioning subscriptions without starting a service period.\nFixed renewals use the agreed recurring_amount and interval; already paid periods retain their\noriginal value. Technical state belongs to the owning service.\n\nA purchased shared capacity limit, such as a regional snapshot count quota, can have its own\nsubscription. Activating that capacity confirms delivery of the quota, not individual snapshots.\nCreating or deleting snapshots within it does not create, activate or terminate more subscriptions;\nthe owning service enforces current holdings against the purchased count.");
80
+ .describe("An independently billed purchase relationship, separate from the owning service's resource.\nPlacing a new prepaid or postpaid service order creates a pending subscription for each line\nin the same purchase transaction. Its ID is returned on the order item and remains stable\nthrough checkout and delivery. One order may create several subscriptions, such as an instance,\nits system disk and its address; it has no single subscription ID.\n\nPending and provisioning do not grant service or accrue usage. A service-owned subscription\nbecomes provisioning when the owning service accepts the order, and active when the service\nconfirms delivery, with started_at set to the confirmed effective time; payment changes neither. Prepaid service periods start\nthen; postpaid usage starts only when the service reports actual delivery and metering.\n\nOne-time delivery may omit a subscription. Renewals reference and extend existing subscriptions\nrather than creating another; a change keeps the subscription ID and switches its terms when it\ntakes effect. Canceling or failing an unfulfilled purchase sets its pending or provisioning\nsubscriptions to canceled without starting a service period.\nFixed renewals use the agreed recurring_amount and interval; already paid periods retain their\noriginal value. Technical state belongs to the owning service.\n\nA purchased shared capacity limit, such as a regional snapshot count quota, can have its own\nsubscription. Activating that capacity confirms delivery of the quota, not individual snapshots.\nCreating or deleting snapshots within it does not create, activate or terminate more subscriptions;\nthe owning service enforces current holdings against the purchased count.");
package/dist/routes.d.ts CHANGED
@@ -3270,5 +3270,29 @@ export declare const routes: readonly [{
3270
3270
  readonly operationId: "rotate-l4-tunnel-subscription";
3271
3271
  readonly securityScheme: "ScopedToken";
3272
3272
  readonly upstreamUrl: "https://tunnel.leaflow.cloud";
3273
+ }, {
3274
+ readonly service: "billing";
3275
+ readonly contract: "billing";
3276
+ readonly method: "DELETE";
3277
+ readonly path: "/api/v1/subscriptions/{subscriptionId}";
3278
+ readonly operationId: "delete-subscription";
3279
+ readonly securityScheme: "AccessToken";
3280
+ readonly upstreamUrl: "https://billing.leaflow.cloud";
3281
+ }, {
3282
+ readonly service: "billing";
3283
+ readonly contract: "billing";
3284
+ readonly method: "POST";
3285
+ readonly path: "/api/v1/subscriptions/{subscriptionId}/cancel";
3286
+ readonly operationId: "cancel-subscription";
3287
+ readonly securityScheme: "AccessToken";
3288
+ readonly upstreamUrl: "https://billing.leaflow.cloud";
3289
+ }, {
3290
+ readonly service: "billing";
3291
+ readonly contract: "billing";
3292
+ readonly method: "POST";
3293
+ readonly path: "/api/v1/subscriptions/{subscriptionId}/terminate";
3294
+ readonly operationId: "terminate-subscription";
3295
+ readonly securityScheme: "AccessToken";
3296
+ readonly upstreamUrl: "https://billing.leaflow.cloud";
3273
3297
  }];
3274
3298
  export type Route = (typeof routes)[number];
package/dist/routes.js CHANGED
@@ -3681,4 +3681,31 @@ export const routes = [
3681
3681
  securityScheme: "ScopedToken",
3682
3682
  upstreamUrl: "https://tunnel.leaflow.cloud",
3683
3683
  },
3684
+ {
3685
+ service: "billing",
3686
+ contract: "billing",
3687
+ method: "DELETE",
3688
+ path: "/api/v1/subscriptions/{subscriptionId}",
3689
+ operationId: "delete-subscription",
3690
+ securityScheme: "AccessToken",
3691
+ upstreamUrl: "https://billing.leaflow.cloud",
3692
+ },
3693
+ {
3694
+ service: "billing",
3695
+ contract: "billing",
3696
+ method: "POST",
3697
+ path: "/api/v1/subscriptions/{subscriptionId}/cancel",
3698
+ operationId: "cancel-subscription",
3699
+ securityScheme: "AccessToken",
3700
+ upstreamUrl: "https://billing.leaflow.cloud",
3701
+ },
3702
+ {
3703
+ service: "billing",
3704
+ contract: "billing",
3705
+ method: "POST",
3706
+ path: "/api/v1/subscriptions/{subscriptionId}/terminate",
3707
+ operationId: "terminate-subscription",
3708
+ securityScheme: "AccessToken",
3709
+ upstreamUrl: "https://billing.leaflow.cloud",
3710
+ },
3684
3711
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leaflow/sdk",
3
- "version": "0.110.0",
3
+ "version": "0.112.0",
4
4
  "description": "Leaflow 平台 API 的 TypeScript SDK",
5
5
  "license": "MIT",
6
6
  "repository": {