@commet/node 9.9.0 → 9.11.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 (61) hide show
  1. package/dist/index.d.mts +932 -59
  2. package/dist/index.d.ts +932 -59
  3. package/dist/index.js +209 -13
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +209 -13
  6. package/dist/index.mjs.map +1 -1
  7. package/docs/ai-onboarding/mcp-server.md +2 -0
  8. package/docs/api-reference/addons.md +3 -1
  9. package/docs/api-reference/credit-packs.md +3 -1
  10. package/docs/api-reference/customers.md +3 -3
  11. package/docs/api-reference/generated-webhooks.md +2 -2
  12. package/docs/api-reference/index.md +3 -3
  13. package/docs/api-reference/invoices.md +4 -3
  14. package/docs/api-reference/plans.md +487 -6
  15. package/docs/api-reference/subscriptions.md +45 -4
  16. package/docs/api-reference/transactions.md +2 -1
  17. package/docs/documentation/api-versioning.md +8 -2
  18. package/docs/documentation/cli.md +4 -0
  19. package/docs/documentation/customers/customer-portal.md +2 -2
  20. package/docs/documentation/invoicing/manage-invoices.md +1 -1
  21. package/docs/documentation/plans/add-ons.md +16 -5
  22. package/docs/documentation/plans/balance-and-top-ups.md +1 -1
  23. package/docs/documentation/plans/consumption-models.md +23 -3
  24. package/docs/documentation/plans/create-plans.md +5 -1
  25. package/docs/documentation/plans/credit-packs.md +22 -10
  26. package/docs/documentation/plans/plan-groups.md +1 -1
  27. package/docs/documentation/plans/plan-versions.md +267 -0
  28. package/docs/documentation/sales/regional-prices.md +23 -9
  29. package/docs/documentation/sales/trial-periods.md +3 -3
  30. package/docs/documentation/subscriptions/manage-subscriptions.md +50 -13
  31. package/docs/documentation/subscriptions/upgrade-and-downgrade-plans.md +2 -0
  32. package/docs/errors/addon_has_activations.md +2 -2
  33. package/docs/errors/addon_unavailable.md +22 -0
  34. package/docs/errors/credit_pack_unavailable.md +22 -0
  35. package/docs/errors/currency_held_by_balance_plan.md +22 -0
  36. package/docs/errors/currency_held_by_customer_credit.md +22 -0
  37. package/docs/errors/currency_held_by_fixed_amount_discount.md +22 -0
  38. package/docs/errors/currency_held_by_payment_method.md +22 -0
  39. package/docs/errors/currency_held_by_prepaid_period.md +22 -0
  40. package/docs/errors/currency_held_by_scheduled_pause.md +22 -0
  41. package/docs/errors/index.md +14 -2
  42. package/docs/errors/missing_regional_price.md +3 -3
  43. package/docs/errors/plan_experiment_not_found.md +22 -0
  44. package/docs/errors/plan_version_not_found.md +22 -0
  45. package/docs/errors/subscribers_do_not_fit.md +22 -0
  46. package/docs/errors/version_not_newer.md +22 -0
  47. package/docs/knowledge-base/how-do-free-plans-work-without-payment.md +4 -3
  48. package/docs/knowledge-base/how-do-trial-periods-work.md +3 -3
  49. package/docs/knowledge-base/how-does-billing-work.md +26 -28
  50. package/docs/knowledge-base/how-does-quota-based-billing-work.md +12 -22
  51. package/docs/knowledge-base/how-does-seat-based-billing-work.md +12 -22
  52. package/docs/knowledge-base/what-happens-when-a-customer-changes-plans.md +11 -8
  53. package/docs/knowledge-base/what-happens-when-you-change-your-prices.md +34 -29
  54. package/docs/knowledge-base/what-invoices-do-customers-receive-and-when.md +1 -1
  55. package/docs/manifest.json +227 -2
  56. package/docs/platform-documentation.md +1 -0
  57. package/docs/schemas.md +128 -13
  58. package/docs/webhooks/introduction.md +3 -1
  59. package/docs/webhooks.md +27 -2
  60. package/docs/webhooks.openapi.json +231 -1
  61. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -58,7 +58,7 @@ var AddonsResource = class {
58
58
  const { id } = params;
59
59
  return this.httpClient.get(`/addons/${id}`, void 0, options);
60
60
  }
61
- /** Update an add-on's name, description, or pricing. */
61
+ /** Update an add-on's name, description, pricing, or the plans that sell it. */
62
62
  async update(params, options) {
63
63
  const { id, ...rest } = params;
64
64
  return this.httpClient.patch(`/addons/${id}`, rest, options);
@@ -103,7 +103,7 @@ var CreditPacksResource = class {
103
103
  constructor(httpClient) {
104
104
  this.httpClient = httpClient;
105
105
  }
106
- /** Update a credit pack's name, description, credits, price, or active status. */
106
+ /** Update a credit pack's name, description, credits, price, active status, or the plans that sell it. */
107
107
  async update(params, options) {
108
108
  const { id, ...rest } = params;
109
109
  return this.httpClient.patch(`/credit-packs/${id}`, rest, options);
@@ -269,10 +269,13 @@ var InvoicesResource = class {
269
269
  const { id } = params;
270
270
  return this.httpClient.post(`/invoices/${id}/send`, {}, options);
271
271
  }
272
- /** Mark an outstanding invoice as "paid" or "void" and return the updated invoice. Cannot change the status of already paid or voided invoices. */
272
+ /**
273
+ * Deprecated. No longer changes the invoice. An invoice is paid when its charge settles: to collect a past-due subscription, reactivate it or send the customer a recovery link.
274
+ * @deprecated
275
+ */
273
276
  async updateStatus(params, options) {
274
- const { id, ...rest } = params;
275
- return this.httpClient.patch(`/invoices/${id}/status`, rest, options);
277
+ const { id } = params;
278
+ return this.httpClient.patch(`/invoices/${id}/status`, {}, options);
276
279
  }
277
280
  /** List invoices with cursor-based pagination. Filter by customer, status, or subscription. */
278
281
  async list(params, options) {
@@ -453,6 +456,98 @@ var PlansResource = class {
453
456
  constructor(httpClient) {
454
457
  this.httpClient = httpClient;
455
458
  }
459
+ /** Publish a draft as the plan's current version, as a new experiment with its own code, or as the next version of the experiment it started from. A country missing a price, or removing the signup trial of the plan's group from the current version, stops the publication. With move, subscribers of earlier versions move at their renewal or now; if any of them does not fit the new version, nothing is published and the response lists each one with what would make it fit, to send back in changes. Paused subscribers stay where they are. Send preview to check without publishing. */
460
+ async publishDraft(params, options) {
461
+ const { id, draftId, ...rest } = params;
462
+ return this.httpClient.post(
463
+ `/plans/${id}/drafts/${draftId}/publish`,
464
+ rest,
465
+ options
466
+ );
467
+ }
468
+ /** Retrieve a draft with the version it started from and what it changes. */
469
+ async getDraft(params, options) {
470
+ const { id, draftId } = params;
471
+ return this.httpClient.get(
472
+ `/plans/${id}/drafts/${draftId}`,
473
+ void 0,
474
+ options
475
+ );
476
+ }
477
+ /** Change a draft's prices per interval, trials, the interval shown first, countries with their currency and prices, and credit or balance rules, or undo single changes. Each block sent replaces that block; blocks left out stay as they are. Buyers and subscribers see nothing until the draft is published. */
478
+ async updateDraft(params, options) {
479
+ const { id, draftId, ...rest } = params;
480
+ return this.httpClient.patch(
481
+ `/plans/${id}/drafts/${draftId}`,
482
+ rest,
483
+ options
484
+ );
485
+ }
486
+ /** Discard a draft. Nothing it changed was ever sold. */
487
+ async deleteDraft(params, options) {
488
+ const { id, draftId } = params;
489
+ return this.httpClient.delete(
490
+ `/plans/${id}/drafts/${draftId}`,
491
+ void 0,
492
+ options
493
+ );
494
+ }
495
+ /** List the plan's open drafts, oldest first, each with the version it started from and what it changes. Drafts sell nothing until published. */
496
+ async listDrafts(params, options) {
497
+ const { id } = params;
498
+ return this.httpClient.get(`/plans/${id}/drafts`, void 0, options);
499
+ }
500
+ /** Start a draft from a version of the plan: the current one, an experiment's version or an older one. A plan can have any number of drafts. Edit it, then publish it as the current version, as an experiment or as an experiment's next version; nothing changes for buyers or subscribers until then. */
501
+ async createDraft(params, options) {
502
+ const { id, ...rest } = params;
503
+ return this.httpClient.post(`/plans/${id}/drafts`, rest, options);
504
+ }
505
+ /** Stop selling the experiment. Its code sells the plan's current version from then on, so links already shared keep working. Choose what happens to its subscribers: keep them on its versions, or move them to the current version at their renewal or now. If any of them does not fit, nothing changes and the response lists each one with what would make it fit, to send back in changes. */
506
+ async archiveExperiment(params, options) {
507
+ const { id, code, ...rest } = params;
508
+ return this.httpClient.post(
509
+ `/plans/${id}/experiments/${code}/archive`,
510
+ rest,
511
+ options
512
+ );
513
+ }
514
+ /** Make the experiment's latest version the plan's current version, with exactly its content and the next version number. New buyers get it; its subscribers are already on it. The experiment closes, and its code sells the plan's current version from then on. Nobody else moves. */
515
+ async makeExperimentCurrent(params, options) {
516
+ const { id, code } = params;
517
+ return this.httpClient.post(
518
+ `/plans/${id}/experiments/${code}/make-current`,
519
+ {},
520
+ options
521
+ );
522
+ }
523
+ /** Get one experiment of a plan by its own code, with the version it sells and how many subscriptions are on it. */
524
+ async getExperiment(params, options) {
525
+ const { id, code } = params;
526
+ return this.httpClient.get(
527
+ `/plans/${id}/experiments/${code}`,
528
+ void 0,
529
+ options
530
+ );
531
+ }
532
+ /** Publish the experiment's next version from its latest version with the changes given. Its code sells the new version from now on; subscribers on its earlier versions stay where they are until moved. */
533
+ async createExperimentVersion(params, options) {
534
+ const { id, code, ...rest } = params;
535
+ return this.httpClient.post(
536
+ `/plans/${id}/experiments/${code}/versions`,
537
+ rest,
538
+ options
539
+ );
540
+ }
541
+ /** List a plan's experiments, newest first, with the version each one sells and how many subscriptions are on them. */
542
+ async listExperiments(params, options) {
543
+ const { id } = params;
544
+ return this.httpClient.get(`/plans/${id}/experiments`, void 0, options);
545
+ }
546
+ /** Start an experiment from the plan's current version with the changes given. It is sold only through its code (planCode `<plan code>:<code>`); new buyers of the plan keep getting the current version. */
547
+ async createExperiment(params, options) {
548
+ const { id, ...rest } = params;
549
+ return this.httpClient.post(`/plans/${id}/experiments`, rest, options);
550
+ }
456
551
  /** Update limits, overage, or enabled status of a feature on a plan. */
457
552
  async updateFeature(params, options) {
458
553
  const { id, featureId, ...rest } = params;
@@ -476,6 +571,61 @@ var PlansResource = class {
476
571
  const { id, ...rest } = params;
477
572
  return this.httpClient.post(`/plans/${id}/features`, rest, options);
478
573
  }
574
+ /** Cancel a move for every subscriber who has not moved yet. They stay on their version; those already moved stay moved. */
575
+ async cancelMove(params, options) {
576
+ const { id, moveId } = params;
577
+ return this.httpClient.post(
578
+ `/plans/${id}/moves/${moveId}/cancel`,
579
+ {},
580
+ options
581
+ );
582
+ }
583
+ /** Read a move of subscribers between plan versions with each subscriber's status: moving, moved, needs a change, left out, canceled or kept on its version. */
584
+ async getMove(params, options) {
585
+ const { id, moveId } = params;
586
+ return this.httpClient.get(
587
+ `/plans/${id}/moves/${moveId}`,
588
+ void 0,
589
+ options
590
+ );
591
+ }
592
+ /** Cancel a move for one subscriber who has not moved yet. It stays on its version; the rest of the move continues. */
593
+ async cancelMoveSubscription(params, options) {
594
+ const { id, moveId, subscriptionId } = params;
595
+ return this.httpClient.post(
596
+ `/plans/${id}/moves/${moveId}/subscriptions/${subscriptionId}/cancel`,
597
+ {},
598
+ options
599
+ );
600
+ }
601
+ /** List a plan's latest moves of subscribers between versions, newest first, including the change of a single subscription, with how many are moving, moved, need a change, were left out, canceled or kept on their version. */
602
+ async listMoves(params, options) {
603
+ const { id } = params;
604
+ return this.httpClient.get(`/plans/${id}/moves`, void 0, options);
605
+ }
606
+ /** Move a list of subscriptions, or every subscription of another version, to a newer version of the plan, at their next renewal or now. Nobody moves unless every one of them fits or has a change in changes; otherwise the response lists each one with what would make it fit. Only active, trialing and past due subscriptions move. Paused ones, and listed subscriptions in another status or already on the destination, are left out. Send preview to check without moving anyone. */
607
+ async createMove(params, options) {
608
+ const { id, ...rest } = params;
609
+ return this.httpClient.post(`/plans/${id}/moves`, rest, options);
610
+ }
611
+ /** Leave a subscriber that needs a change on its version. It stops appearing among the subscribers that need a change; move it later like any other subscriber. */
612
+ async keepSubscriberOnVersion(params, options) {
613
+ const { id, subscriptionId } = params;
614
+ return this.httpClient.post(
615
+ `/plans/${id}/needs-a-change/${subscriptionId}/keep`,
616
+ {},
617
+ options
618
+ );
619
+ }
620
+ /** List the plan's subscribers whose move could not complete, with the version they stay on, the one they could not move to and why. Move them again with a change, or keep them on their version so they leave this list. */
621
+ async listSubscribersNeedingAChange(params, options) {
622
+ const { id } = params;
623
+ return this.httpClient.get(
624
+ `/plans/${id}/needs-a-change`,
625
+ void 0,
626
+ options
627
+ );
628
+ }
479
629
  /** Set a specific price as the default and return the updated plan price. */
480
630
  async setDefaultPrice(params, options) {
481
631
  const { id, priceId } = params;
@@ -512,7 +662,7 @@ var PlansResource = class {
512
662
  options
513
663
  );
514
664
  }
515
- /** Archive a price for new subscriptions. Existing subscriptions that selected it continue using its current catalog value. */
665
+ /** Archive a price for new subscriptions. This publishes a new version of the plan; existing subscriptions that selected the price keep paying it on their version until moved. */
516
666
  async deletePrice(params, options) {
517
667
  const { id, priceId } = params;
518
668
  return this.httpClient.delete(
@@ -546,6 +696,34 @@ var PlansResource = class {
546
696
  const { id } = params;
547
697
  return this.httpClient.delete(`/plans/${id}`, void 0, options);
548
698
  }
699
+ /** List what changes from one version of a plan to another: prices, trials, features, rules, add-ons, credit packs and countries. */
700
+ async compareVersions(params, options) {
701
+ const { id, versionId, ...rest } = params;
702
+ return this.httpClient.get(
703
+ `/plans/${id}/versions/${versionId}/changes`,
704
+ rest,
705
+ options
706
+ );
707
+ }
708
+ /** Get one published version of a plan with its prices and how many subscriptions are on it. */
709
+ async getVersion(params, options) {
710
+ const { id, versionId } = params;
711
+ return this.httpClient.get(
712
+ `/plans/${id}/versions/${versionId}`,
713
+ void 0,
714
+ options
715
+ );
716
+ }
717
+ /** List a plan's published versions, newest first, with their prices and how many subscriptions are on each. Versions published before Commet recorded every term are not listed. */
718
+ async listVersions(params, options) {
719
+ const { id, ...rest } = params;
720
+ return this.httpClient.get(`/plans/${id}/versions`, rest, options);
721
+ }
722
+ /** Publish a new current version of the plan from its current version, changing prices per interval, included credits or balance, per-currency amounts and the rollover cap. New buyers get it; every subscriber stays on its version until moved. To try changes without selling them to everyone, create an experiment instead. */
723
+ async createVersion(params, options) {
724
+ const { id, ...rest } = params;
725
+ return this.httpClient.post(`/plans/${id}/versions`, rest, options);
726
+ }
549
727
  /** Set a plan's public visibility and return the updated plan. */
550
728
  async setVisibility(params, options) {
551
729
  const { id, ...rest } = params;
@@ -680,7 +858,7 @@ var SubscriptionsResource = class {
680
858
  options
681
859
  );
682
860
  }
683
- /** Activate an add-on on a subscription. Charges a prorated amount for the current billing period. */
861
+ /** Activate an add-on on a subscription. Creates the activation invoice and charges a prorated amount for the current billing period; the add-on is active once the payment is confirmed. Rejected with 409 while the add-on is active or an activation of it is still processing. An add-on that the subscription's plan version does not sell is rejected with addon_unavailable. */
684
862
  async activateAddon(params, options) {
685
863
  const { id, ...rest } = params;
686
864
  return this.httpClient.post(`/subscriptions/${id}/addons`, rest, options);
@@ -712,7 +890,7 @@ var SubscriptionsResource = class {
712
890
  options
713
891
  );
714
892
  }
715
- /** 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. */
893
+ /** Top up a balance subscription. Creates the top-up invoice and charges the customer's payment method for the amount plus tax. Once the payment is confirmed, adds the amount to the subscription's purchased balance (after paying back any overage owed on the plan balance), marks the invoice paid 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. */
716
894
  async topupBalance(params, options) {
717
895
  const { id, ...rest } = params;
718
896
  return this.httpClient.post(
@@ -735,7 +913,16 @@ var SubscriptionsResource = class {
735
913
  options
736
914
  );
737
915
  }
738
- /** 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. */
916
+ /** Move a subscription to a newer published version of its plan, now or at the end of the period, without proration; an older version is rejected with version_not_newer, and a subscription on a running experiment moves only to a later version of that experiment. The subscription keeps its currency and its price: a destination that does not sell its currency is rejected with missing_regional_price unless currency asks to charge it in USD from its renewal, and one that does not sell the price it pays with price_not_found. A free version moves only to a free version and a paid one only to a paid one (validation_error). A subscription whose usage does not fit the destination, or with an active add-on the destination does not sell, is not moved either, and the error says why. Each change is recorded as a move of this one subscription in the plan's moves. Repeating the same request changes nothing; a new one replaces the pending move. */
917
+ async changeVersion(params, options) {
918
+ const { id, ...rest } = params;
919
+ return this.httpClient.post(
920
+ `/subscriptions/${id}/change-version`,
921
+ rest,
922
+ options
923
+ );
924
+ }
925
+ /** Purchase a fixed credit pack or choose a whole credit quantity at the subscription plan price and minimum. Creates the purchase invoice, charges the saved payment method and adds the purchased credits once the payment is confirmed. A credit pack that the subscription's plan version does not sell is rejected with credit_pack_unavailable. */
739
926
  async purchaseCredits(params, options) {
740
927
  const { id, ...rest } = params;
741
928
  return this.httpClient.post(`/subscriptions/${id}/credits`, rest, options);
@@ -837,6 +1024,15 @@ var SubscriptionsResource = class {
837
1024
  options
838
1025
  );
839
1026
  }
1027
+ /** Cancel the move to another plan version pending for the next renewal, so the subscription stays on its version, and send subscription.version_change_canceled with reason canceled_by_merchant. A move made now has nothing pending to revoke. With nothing pending it changes nothing. Returns the subscription. */
1028
+ async revokeScheduledVersionChange(params, options) {
1029
+ const { id } = params;
1030
+ return this.httpClient.delete(
1031
+ `/subscriptions/${id}/scheduled-version-change`,
1032
+ void 0,
1033
+ options
1034
+ );
1035
+ }
840
1036
  /** Revert a scheduled cancellation and return the updated subscription. Only works before cancellation takes effect. */
841
1037
  async uncancel(params, options) {
842
1038
  const { id } = params;
@@ -883,10 +1079,10 @@ var TransactionsResource = class {
883
1079
  constructor(httpClient) {
884
1080
  this.httpClient = httpClient;
885
1081
  }
886
- /** Issue a full refund and return the provider-neutral refund resource with its actual status. */
1082
+ /** Refund a positive amount in the payment currency’s smallest unit, or omit amount to refund the remaining amount. Returns the refund resource with its actual status. */
887
1083
  async refund(params, options) {
888
- const { id } = params;
889
- return this.httpClient.post(`/transactions/${id}/refund`, {}, options);
1084
+ const { id, ...rest } = params;
1085
+ return this.httpClient.post(`/transactions/${id}/refund`, rest, options);
890
1086
  }
891
1087
  /** Retry a failed subscription renewal and return an honest retry result. The original failed transaction remains immutable. */
892
1088
  async retry(params, options) {
@@ -1097,7 +1293,7 @@ var CommetValidationError = class extends CommetAPIError {
1097
1293
 
1098
1294
  // src/version.ts
1099
1295
  var API_VERSION = "2026-08-27";
1100
- var SDK_VERSION = "9.9.0";
1296
+ var SDK_VERSION = "9.11.0";
1101
1297
 
1102
1298
  // src/utils/telemetry.ts
1103
1299
  var registeredIntegrations = /* @__PURE__ */ new Set();