@commet/node 9.7.0 → 9.9.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 (64) hide show
  1. package/dist/index.d.mts +413 -52
  2. package/dist/index.d.ts +413 -52
  3. package/dist/index.js +39 -12
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +39 -12
  6. package/dist/index.mjs.map +1 -1
  7. package/docs/ai-onboarding/mcp-server.md +1 -1
  8. package/docs/api-reference/customers.md +6 -2
  9. package/docs/api-reference/generated-webhooks.md +2 -2
  10. package/docs/api-reference/index.md +2 -2
  11. package/docs/api-reference/offers.md +2 -2
  12. package/docs/api-reference/plans.md +16 -3
  13. package/docs/api-reference/promo-codes.md +3 -1
  14. package/docs/api-reference/subscriptions.md +84 -9
  15. package/docs/api-reference/usage.md +0 -4
  16. package/docs/documentation/cli.md +60 -49
  17. package/docs/documentation/create-api-key.md +3 -1
  18. package/docs/documentation/customers/customer-portal.md +10 -2
  19. package/docs/documentation/customers/manage-customers.md +2 -1
  20. package/docs/documentation/finance/payouts.md +11 -0
  21. package/docs/documentation/finance/supported-countries.md +5 -5
  22. package/docs/documentation/invoicing/handle-failed-payments.md +9 -9
  23. package/docs/documentation/payments/accept-one-time-payments.md +1 -1
  24. package/docs/documentation/payments/payment-orchestration.md +2 -0
  25. package/docs/documentation/payments/payment-providers.md +46 -0
  26. package/docs/documentation/payments/transactions-refunds-and-retries.md +1 -1
  27. package/docs/documentation/plans/add-ons.md +1 -1
  28. package/docs/documentation/plans/consumption-models.md +44 -9
  29. package/docs/documentation/plans/credit-packs.md +49 -1
  30. package/docs/documentation/plans/one-time-payments.md +3 -3
  31. package/docs/documentation/plans/plan-groups.md +46 -10
  32. package/docs/documentation/platform/dashboard-metrics-and-events.md +40 -9
  33. package/docs/documentation/sales/connect-dub-affiliates.md +52 -0
  34. package/docs/documentation/sales/introductory-offers.md +7 -13
  35. package/docs/documentation/sales/offers.md +10 -6
  36. package/docs/documentation/sales/promo-codes.md +47 -17
  37. package/docs/documentation/sales/promotional-offers.md +6 -7
  38. package/docs/documentation/sales/regional-prices.md +16 -0
  39. package/docs/documentation/sales/trial-periods.md +67 -40
  40. package/docs/documentation/subscriptions/manage-subscriptions.md +65 -2
  41. package/docs/documentation/subscriptions/pay-in-advance.md +4 -7
  42. package/docs/documentation/subscriptions/upgrade-and-downgrade-plans.md +20 -2
  43. package/docs/documentation/testing-sandbox.md +2 -0
  44. package/docs/documentation/usage/track-usage.md +23 -0
  45. package/docs/errors/customer_deleted.md +22 -0
  46. package/docs/errors/index.md +5 -0
  47. package/docs/errors/managed_by_integration.md +22 -0
  48. package/docs/errors/no_scheduled_plan_change.md +22 -0
  49. package/docs/errors/plan_balance_limit_reached.md +22 -0
  50. package/docs/errors/plan_credit_limit_reached.md +22 -0
  51. package/docs/knowledge-base/how-do-credits-credit-packs-and-customer-credits-differ.md +8 -8
  52. package/docs/knowledge-base/how-do-discounts-work.md +7 -5
  53. package/docs/knowledge-base/how-do-free-plans-work-without-payment.md +14 -8
  54. package/docs/knowledge-base/how-do-offers-promo-codes-and-card-promotions-work-together.md +1 -1
  55. package/docs/knowledge-base/how-do-trial-periods-work.md +30 -24
  56. package/docs/knowledge-base/how-does-billing-work.md +1 -0
  57. package/docs/knowledge-base/what-happens-when-a-payment-fails.md +11 -9
  58. package/docs/manifest.json +54 -2
  59. package/docs/platform-documentation.md +1 -0
  60. package/docs/schemas.md +51 -9
  61. package/docs/webhooks/introduction.md +14 -12
  62. package/docs/webhooks.md +53 -17
  63. package/docs/webhooks.openapi.json +857 -745
  64. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -143,7 +143,7 @@ var CustomersResource = class {
143
143
  const { id, ...rest } = params;
144
144
  return this.httpClient.patch(`/customers/${id}`, rest, options);
145
145
  }
146
- /** Create up to 100 customers in a single request. */
146
+ /** Create up to 100 customers in a single request. With planGroupId, each customer without an open subscription starts on that group's starting plan (see planGroupId), and the entry of a deleted customer fails with customer_deleted. */
147
147
  async createBatch(params, options) {
148
148
  return this.httpClient.post("/customers/batch", params, options);
149
149
  }
@@ -151,7 +151,7 @@ var CustomersResource = class {
151
151
  async list(params, options) {
152
152
  return this.httpClient.get("/customers", params, options);
153
153
  }
154
- /** Create a new customer. Idempotent when customerId is provided. */
154
+ /** Create a new customer. Idempotent when customerId is provided. With planGroupId, a customer without an open subscription starts on that group's starting plan (see planGroupId), and the externalId of a deleted customer is rejected. */
155
155
  async create(params, options) {
156
156
  return this.httpClient.post("/customers", params, options);
157
157
  }
@@ -490,7 +490,7 @@ var PlansResource = class {
490
490
  const { id } = params;
491
491
  return this.httpClient.get(`/plans/${id}`, void 0, options);
492
492
  }
493
- /** Update a plan's name, description, visibility, or metadata. */
493
+ /** Update a plan's name, description, visibility, default status, metadata, overage behavior, what happens to its unused plan credits or plan balance, or its plan credit or plan balance limit. */
494
494
  async update(params, options) {
495
495
  const { id, ...rest } = params;
496
496
  return this.httpClient.patch(`/plans/${id}`, rest, options);
@@ -509,7 +509,7 @@ var PlansResource = class {
509
509
  async list(params, options) {
510
510
  return this.httpClient.get("/plans", params, options);
511
511
  }
512
- /** Create a new plan with optional consumption model, visibility, and plan group assignment. */
512
+ /** Create a new plan with optional consumption model, visibility, plan group assignment, overage behavior, and the rollover and spend limit of its plan credits or plan balance. */
513
513
  async create(params, options) {
514
514
  return this.httpClient.post("/plans", params, options);
515
515
  }
@@ -545,7 +545,7 @@ var PromoCodesResource = class {
545
545
  async list(params, options) {
546
546
  return this.httpClient.get("/promo-codes", params, options);
547
547
  }
548
- /** Create a distribution code for an existing Offer with one or more sequential discount phases and an optional leading trial. The code owns redemption restrictions. */
548
+ /** Create a distribution code for an existing Offer with one or more sequential discount phases. The code owns redemption restrictions. */
549
549
  async create(params, options) {
550
550
  return this.httpClient.post("/promo-codes", params, options);
551
551
  }
@@ -639,6 +639,24 @@ var SubscriptionsResource = class {
639
639
  const { id, ...rest } = params;
640
640
  return this.httpClient.post(`/subscriptions/${id}/addons`, rest, options);
641
641
  }
642
+ /** Read whether the subscription tops up automatically with its saved payment method when its available credits or balance reach a threshold, with the top-ups used this period and the last failure. */
643
+ async getAutoTopUp(params, options) {
644
+ const { id } = params;
645
+ return this.httpClient.get(
646
+ `/subscriptions/${id}/auto-top-up`,
647
+ void 0,
648
+ options
649
+ );
650
+ }
651
+ /** Turn automatic top-ups on or off and set the threshold, the size of each top-up and the maximum top-ups per period. Send only the fields that change. On a credits plan each top-up buys `quantity` credits; on a balance plan it adds `amount` in minor units of the subscription currency, plus tax, and `threshold` is in the same minor units. Enabling requires a plan that sells credits or has balance top-ups on. The size must be at least the plan's minimum when auto top-up is enabled or when the size changes, so turning it off keeps working after the minimum rises. Saving it enabled resumes a paused auto top-up. */
652
+ async updateAutoTopUp(params, options) {
653
+ const { id, ...rest } = params;
654
+ return this.httpClient.patch(
655
+ `/subscriptions/${id}/auto-top-up`,
656
+ rest,
657
+ options
658
+ );
659
+ }
642
660
  /** Adjust a subscription's balance or credits by a signed amount. Positive adds, negative subtracts. */
643
661
  async adjustBalance(params, options) {
644
662
  const { id, ...rest } = params;
@@ -648,7 +666,7 @@ var SubscriptionsResource = class {
648
666
  options
649
667
  );
650
668
  }
651
- /** Top up a subscription's balance. Charges the customer's payment method for the specified amount. */
669
+ /** Top up a balance subscription. Charges the customer's payment method for the amount plus tax, adds it to the subscription's purchased balance (after paying back any overage owed on the plan balance), creates its invoice and emits `balance.topped_up`. Purchased balance is spent after the plan balance and is kept until the subscription ends. Rejected with 400 when the subscription is not on a balance plan, its plan has top-ups turned off, or the amount is below the effective minimum: the plan's minimum top-up in the subscription currency, raised to the currency's minimum charge. */
652
670
  async topupBalance(params, options) {
653
671
  const { id, ...rest } = params;
654
672
  return this.httpClient.post(
@@ -662,7 +680,7 @@ var SubscriptionsResource = class {
662
680
  const { id, ...rest } = params;
663
681
  return this.httpClient.post(`/subscriptions/${id}/cancel`, rest, options);
664
682
  }
665
- /** Upgrade or change billing interval immediately, optionally applying an Offer. Scheduled changes do not accept offers. */
683
+ /** Upgrade or change billing interval immediately, optionally applying an Offer by offerId or the Offer of a promoCode. Scheduled changes accept neither offerId nor promoCode. From a free plan, a promoCode opens the checkout with the code applied and counts its use when the checkout is paid; without offerId or promoCode, a destination price whose free trial requires no payment method starts that trial right away without checkout. During a trial without a payment method, an immediate change returns 409 no_payment_method; scheduled changes still apply. */
666
684
  async changePlan(params, options) {
667
685
  const { id, ...rest } = params;
668
686
  return this.httpClient.post(
@@ -671,12 +689,12 @@ var SubscriptionsResource = class {
671
689
  options
672
690
  );
673
691
  }
674
- /** Purchase a credit pack for a subscription. Charges the customer and adds credits to their balance. */
692
+ /** Purchase a fixed credit pack or choose a whole credit quantity at the subscription plan price and minimum. Charges the saved payment method and adds purchased credits. */
675
693
  async purchaseCredits(params, options) {
676
694
  const { id, ...rest } = params;
677
695
  return this.httpClient.post(`/subscriptions/${id}/credits`, rest, options);
678
696
  }
679
- /** Apply a direct Offer to a subscription. On a pending payment checkout it quotes or replaces the checkout discount and the existing checkout URL remains unchanged. On an active subscription it applies the Offer immediately with its discount phases starting at the next billing cycle; the call is rejected while another applied Offer still has active or upcoming discount phases. Offers with a free trial phase cannot be applied after checkout creation. */
697
+ /** Apply a direct Offer to a subscription. On a pending checkout it quotes or replaces the checkout discount, which starts after the plan price trial when there is one, and the existing checkout URL remains unchanged. On an active subscription it applies the Offer immediately with its discount phases starting at the next billing cycle; the call is rejected while another applied Offer still has active or upcoming discount phases. */
680
698
  async applyOffer(params, options) {
681
699
  const { id, ...rest } = params;
682
700
  return this.httpClient.put(`/subscriptions/${id}/offer`, rest, options);
@@ -727,7 +745,7 @@ var SubscriptionsResource = class {
727
745
  options
728
746
  );
729
747
  }
730
- /** Preview proration details for an immediate plan change without applying it. Free-to-paid changes are never scheduled and the change-plan endpoint always returns hosted checkout for them. For paid plans, interval direction takes precedence: a longer interval is immediate and a shorter interval is scheduled. When the interval is unchanged, a higher-sort-order plan is immediate and a lower-sort-order plan is scheduled. A paid-to-free change is always scheduled. Returns credit, charge, and net amount. The target plan must belong to the same plan group as the current plan, otherwise a 400 with code `plans_not_in_same_group` is returned. A change between two free plans has nothing to prorate and returns a zero-amount estimate. Scheduled changes return a 400 with code `plan_change_scheduled`; apply those via the change-plan endpoint. Pass offerId to quote the destination plan with an Offer. */
748
+ /** Preview proration details for an immediate plan change without applying it. Free-to-paid changes are never scheduled and the change-plan endpoint returns hosted checkout for them, except a change without offerId or promoCode to a price whose free trial needs no payment method, for a customer who never had that plan: it starts the trial at once, so the preview reports nothing due today. For paid plans, interval direction takes precedence: a longer interval is immediate and a shorter interval is scheduled. When the interval is unchanged, a higher-sort-order plan is immediate and a lower-sort-order plan is scheduled. A paid-to-free change is always scheduled. Returns credit, charge, and net amount. The target plan must belong to the same plan group as the current plan, otherwise a 400 with code `plans_not_in_same_group` is returned. A change between two free plans has nothing to prorate and returns a zero-amount estimate. Scheduled changes return a 400 with code `plan_change_scheduled`; apply those via the change-plan endpoint. Pass offerId to quote the destination plan with an Offer, or promoCode to quote it with the Offer of a promo code validated with the checkout's rules. */
731
749
  async previewChange(params, options) {
732
750
  const { id, ...rest } = params;
733
751
  return this.httpClient.post(
@@ -764,6 +782,15 @@ var SubscriptionsResource = class {
764
782
  const { id } = params;
765
783
  return this.httpClient.get(`/subscriptions/${id}`, void 0, options);
766
784
  }
785
+ /** Revoke the plan or interval change scheduled for the end of the period, so the subscription stays on its current plan. Returns the updated subscription. */
786
+ async revokeScheduledPlanChange(params, options) {
787
+ const { id } = params;
788
+ return this.httpClient.delete(
789
+ `/subscriptions/${id}/scheduled-plan-change`,
790
+ void 0,
791
+ options
792
+ );
793
+ }
767
794
  /** Revert a scheduled cancellation and return the updated subscription. Only works before cancellation takes effect. */
768
795
  async uncancel(params, options) {
769
796
  const { id } = params;
@@ -777,7 +804,7 @@ var SubscriptionsResource = class {
777
804
  async list(params, options) {
778
805
  return this.httpClient.get("/subscriptions", params, options);
779
806
  }
780
- /** Create a subscription for a customer. Commet selects the default price when priceId is omitted. The subscription starts at the base USD price; market and currency are resolved from the buyer's request country when the checkout opens. Without an offer override, Commet applies the price's automatic introductory Offer. Pass offerId to apply an active compatible Offer directly, or cardPromotionId to preselect a card-eligible Promotional Offer for the initial checkout when card promotions are enabled for the organization. For the initial checkout, provider accepts either a processor name or an exact payment connection ID. */
807
+ /** Create a subscription for a customer. Commet selects the default price when priceId is omitted. The subscription starts at the base USD price; market and currency are resolved from the buyer's request country when the checkout opens. Without an offer override, Commet applies the price's automatic introductory Offer. Pass offerId to apply an active compatible Offer directly, or cardPromotionId to preselect a card-eligible Promotional Offer for the initial checkout when card promotions are enabled for the organization. For the initial checkout, provider accepts either a processor name or an exact payment connection ID. When the price's free trial requires no payment method, the subscription starts trialing right away with no checkout (checkoutUrl null, hasPaymentMethod false); it cannot be combined with offerId, promoCode, cardPromotionId or provider, and an organization that cannot charge yet receives 403. */
781
808
  async create(params, options) {
782
809
  return this.httpClient.post("/subscriptions", params, options);
783
810
  }
@@ -1024,7 +1051,7 @@ var CommetValidationError = class extends CommetAPIError {
1024
1051
 
1025
1052
  // src/version.ts
1026
1053
  var API_VERSION = "2026-08-27";
1027
- var SDK_VERSION = "9.7.0";
1054
+ var SDK_VERSION = "9.9.0";
1028
1055
 
1029
1056
  // src/utils/telemetry.ts
1030
1057
  var registeredIntegrations = /* @__PURE__ */ new Set();