@commet/node 9.7.0 → 9.8.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.
package/docs/schemas.md CHANGED
@@ -205,6 +205,7 @@ Generated from Commet API version `2026-08-27`.
205
205
  - `billingDayOfMonth` (`number | null`, required)
206
206
  - `nextBillingDate` (`string | null`, required)
207
207
  - `checkoutUrl` (`string | null`, required)
208
+ - `hasPaymentMethod` (`boolean`, required) — Whether Commet can charge this subscription on its own at its next charge (the trial end or the renewal). A trial that started without a payment method reports false until the customer adds one for this subscription; a payment method saved for another subscription does not count. A subscription on a free plan reports false.
208
209
  - `createdAt` (`string`, required)
209
210
  - `updatedAt` (`string`, required)
210
211
  - `offerApplications` (`Array<SubscriptionOfferApplication>`, required)
@@ -413,6 +414,13 @@ Variants:
413
414
  - `object` (`"invoice"`, required)
414
415
  - `livemode` (`boolean`, required)
415
416
 
417
+ ### ManagedBy
418
+
419
+ Variants:
420
+
421
+ - `"dub"`
422
+ - `null`
423
+
416
424
  ### Market
417
425
 
418
426
  - `id` (`string`, required)
@@ -428,11 +436,12 @@ Variants:
428
436
 
429
437
  - `id` (`string`, required)
430
438
  - `name` (`string`, required)
431
- - `phases` (`Array<{ type: "free_trial"; durationDays: number } | { type: "percentage"; durationCycles: number | null; durationInterval: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | null; percentage: number } | { type: "amount_off"; durationCycles: number | null; durationInterval: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | null; amounts: Array<{ currency: string; amount: number }> } | { type: "fixed_price"; durationCycles: number | null; durationInterval: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | null; prices: Array<{ currency: string; amount: number }> }>`, required)
439
+ - `phases` (`Array<{ type: "percentage"; durationCycles: number | null; durationInterval: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | null; percentage: number } | { type: "amount_off"; durationCycles: number | null; durationInterval: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | null; amounts: Array<{ currency: string; amount: number }> } | { type: "fixed_price"; durationCycles: number | null; durationInterval: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | null; prices: Array<{ currency: string; amount: number }> }>`, required)
432
440
  - `metadata` (`Record<string, unknown>`, required)
433
441
  - `startsAt` (`string | null`, required)
434
442
  - `endsAt` (`string | null`, required)
435
443
  - `active` (`boolean`, required)
444
+ - `managedBy` (`ManagedBy`, required) — Integration that manages this record, or null when the merchant does. While an integration manages it, its terms change only in that integration and edits answer 409 managed_by_integration.
436
445
  - `createdAt` (`string`, required)
437
446
  - `updatedAt` (`string`, required)
438
447
  - `object` (`"offer"`, required)
@@ -506,13 +515,15 @@ Variants:
506
515
  - `isDefault` (`boolean`, required)
507
516
  - `isFree` (`boolean`, required)
508
517
  - `blockOnExhaustion` (`boolean | null`, required)
518
+ - `unusedPlanCredits` (`{ type: "expire" } | { type: "roll_over"; maxPlanCredits: number | null } | null`, required) — Credits plans only; null for other consumption models. What happens to unused plan credits at each reset. Purchased credits never expire and never count toward maxPlanCredits.
519
+ - `planCreditLimit` (`{ credits: number; interval: "day" | "week" } | null`, required) — Credits plans only. The most plan credits a subscription spends per day or per week; null means no limit.
509
520
  - `sortOrder` (`number`, required)
510
521
  - `planGroupId` (`string | null`, required)
511
522
  - `metadata` (`Record<string, unknown> | null`, required)
512
523
  - `createdAt` (`string`, required)
513
524
  - `updatedAt` (`string`, required)
514
525
  - `features` (`Array<{ code: string; name: string; type: FeatureType; unitName: string | null; enabled: boolean; includedAmount: number | null; unlimited: boolean; overage: { enabled: boolean; model: "per_unit" | null; unitPrice: number | null } | null; regionalPrices: Array<{ currency: string; overageUnitPrice: number | null; autoSynced: boolean }> }>`, required)
515
- - `prices` (`Array<{ id: string; billingInterval: BillingInterval; price: number; isDefault: boolean; trialDays: number; includedBalance: number | null; includedCredits: number | null; offerId: string | null; inheritsFromPriceId: string | null; metadata: Record<string, unknown>; marketPrices: Array<{ marketGroupId: string; currency: string; price: number }>; regionalPrices: Array<{ currency: string; price: number; includedBalance: number | null; autoSynced: boolean }> }>`, required)
526
+ - `prices` (`Array<{ id: string; billingInterval: BillingInterval; price: number; isDefault: boolean; trialDays: number; trialRequiresPaymentMethod: boolean | null; includedBalance: number | null; includedCredits: number | null; offerId: string | null; inheritsFromPriceId: string | null; metadata: Record<string, unknown>; marketPrices: Array<{ marketGroupId: string; currency: string; price: number }>; regionalPrices: Array<{ currency: string; price: number; includedBalance: number | null; autoSynced: boolean }> }>`, required)
516
527
  - `exchangeRates` (`Array<{ currency: string; exchangeRate: number }>`, required)
517
528
  - `object` (`"plan"`, required)
518
529
  - `livemode` (`boolean`, required)
@@ -592,6 +603,7 @@ Variants:
592
603
  - `price` (`number`, required) — Price in the currency's minor unit (for example, cents for USD).
593
604
  - `isDefault` (`boolean`, required)
594
605
  - `trialDays` (`number`, required)
606
+ - `trialRequiresPaymentMethod` (`boolean | null`, required) — Whether the price's free trial needs a payment method to start. When false, a new subscription starts trialing right away without checkout; without a payment method added by the trial end, the customer moves to the plan group's default plan, or the subscription is canceled when there is none. Null when the price has no trial.
595
607
  - `includedBalance` (`number | null`, required)
596
608
  - `includedCredits` (`number | null`, required)
597
609
  - `offerId` (`string | null`, required) — Automatic introductory offer for this price.
@@ -656,6 +668,8 @@ Variants:
656
668
  - `expiresAt` (`string | null`, required)
657
669
  - `isActive` (`boolean`, required)
658
670
  - `redemptionCount` (`number`, required)
671
+ - `firstPurchaseOnly` (`boolean`, required) — Whether the code only applies to a customer's first purchase: one with no paid invoice above zero and no paid subscription.
672
+ - `managedBy` (`ManagedBy`, required) — Integration that manages this record, or null when the merchant does. While an integration manages it, its terms change only in that integration and edits answer 409 managed_by_integration.
659
673
  - `createdAt` (`string`, required)
660
674
  - `updatedAt` (`string`, required)
661
675
  - `object` (`"promo_code"`, required)
@@ -760,6 +774,7 @@ Variants:
760
774
  - `billingDayOfMonth` (`number | null`, required)
761
775
  - `nextBillingDate` (`string | null`, required)
762
776
  - `checkoutUrl` (`string | null`, required)
777
+ - `hasPaymentMethod` (`boolean`, required) — Whether Commet can charge this subscription on its own at its next charge (the trial end or the renewal). A trial that started without a payment method reports false until the customer adds one for this subscription; a payment method saved for another subscription does not count. A subscription on a free plan reports false.
763
778
  - `createdAt` (`string`, required)
764
779
  - `updatedAt` (`string`, required)
765
780
  - `offerApplications` (`Array<SubscriptionOfferApplication>`, required)
@@ -781,6 +796,19 @@ Variants:
781
796
  - `object` (`"subscription_addon"`, required)
782
797
  - `livemode` (`boolean`, required)
783
798
 
799
+ ### SubscriptionAutoTopUp
800
+
801
+ - `enabled` (`boolean`, required) — Whether credits are bought automatically. Always false when the plan does not sell credits.
802
+ - `threshold` (`number | null`, required) — Credits at or below which a top-up is bought, or null when never configured.
803
+ - `quantity` (`number | null`, required) — Credits each top-up buys, or null when never configured.
804
+ - `maxPerPeriod` (`number | null`, required) — Maximum top-ups per credit renewal period, or null when never configured.
805
+ - `status` (`"active" | "paused" | "off"`, required) — active buys when credits reach the threshold; paused stops after three consecutive failed top-ups, or after one whose charge could not be refunded, until the payment method changes, a credit purchase succeeds or it is saved enabled again; off buys nothing.
806
+ - `topUpsThisPeriod` (`number`, required) — Top-ups bought in the current credit renewal period.
807
+ - `periodResetsAt` (`string | null`, required) — When the top-up count of the period resets, or null before the subscription starts its first period.
808
+ - `lastFailure` (`{ reason: "payment_declined" | "no_payment_method" | "quantity_below_minimum" | "purchase_failed"; at: string } | null`, required) — The last top-up that failed, or null when none has failed.
809
+ - `object` (`"subscription_auto_top_up"`, required)
810
+ - `livemode` (`boolean`, required)
811
+
784
812
  ### SubscriptionOfferApplication
785
813
 
786
814
  - `id` (`string`, required)
@@ -834,6 +862,7 @@ Variants:
834
862
  - `billingDayOfMonth` (`number | null`, required)
835
863
  - `nextBillingDate` (`string | null`, required)
836
864
  - `checkoutUrl` (`string | null`, required)
865
+ - `hasPaymentMethod` (`boolean`, required) — Whether Commet can charge this subscription on its own at its next charge (the trial end or the renewal). A trial that started without a payment method reports false until the customer adds one for this subscription; a payment method saved for another subscription does not count. A subscription on a free plan reports false.
837
866
  - `createdAt` (`string`, required)
838
867
  - `updatedAt` (`string`, required)
839
868
  - `offerApplications` (`Array<SubscriptionOfferApplication>`, required)
@@ -937,7 +966,7 @@ Variants:
937
966
  Variants:
938
967
 
939
968
  - `{ allowed: boolean; subscriptionStatus: string; featureCode: string; quantity: number; reason?: string; message?: string; consumptionModel: "metered"; current: number; remaining: number; unlimited: boolean; included: number; overageEnabled: boolean; overageUnitPrice: number | null; object: "usage_check"; livemode: boolean }`
940
- - `{ allowed: boolean; subscriptionStatus: string; featureCode: string; quantity: number; reason?: string; message?: string; consumptionModel: "credits"; creditsPerUnit: number; estimatedCredits: number; planCredits: number; purchasedCredits: number; totalCredits: number; object: "usage_check"; livemode: boolean }`
969
+ - `{ allowed: boolean; subscriptionStatus: string; featureCode: string; quantity: number; reason?: string; message?: string; consumptionModel: "credits"; creditsPerUnit: number; estimatedCredits: number; planCredits: number; purchasedCredits: number; totalCredits: number; planCreditLimit: { credits: number; interval: "day" | "week"; spent: number; remaining: number; resetsAt: string } | null; object: "usage_check"; livemode: boolean }`
941
970
  - `{ allowed: boolean; subscriptionStatus: string; featureCode: string; quantity: number; reason?: string; message?: string; consumptionModel: "balance"; unitPrice: number; estimatedAmount: number; currentBalance: number; blockOnExhaustion: boolean; currency: string; object: "usage_check"; livemode: boolean }`
942
971
 
943
972
  ### UsageEvent
@@ -950,7 +979,7 @@ Variants:
950
979
  - `ts` (`string`, required)
951
980
  - `createdAt` (`string`, required)
952
981
  - `properties` (`Array<{ property: string; value: string }>`, required)
953
- - `consumption` (`{ model: "credits" | "balance"; deducted: number; remaining: number; blocked: boolean }`, optional)
982
+ - `consumption` (`{ model: "credits" | "balance"; deducted: number; remaining: number; blocked: boolean; planCreditLimit?: { credits: number; interval: "day" | "week"; spent: number; remaining: number; resetsAt: string } | null }`, optional)
954
983
  - `object` (`"usage_event"`, required)
955
984
  - `livemode` (`boolean`, required)
956
985
 
package/docs/webhooks.md CHANGED
@@ -6,7 +6,7 @@ The complete contract, with every field description and example, is in [webhooks
6
6
 
7
7
  ## subscription.created
8
8
 
9
- Fired when a subscription record is created with status pending_payment. The first charge has not been confirmed yet — do NOT grant access here. Wait for subscription.activated.
9
+ Fired when a subscription record is created, usually with status pending_payment: the first charge has not been confirmed yet — do NOT grant access here; wait for subscription.activated. A trial whose price requires no payment method is created already trialing, together with trial.started.
10
10
 
11
11
  ### Data
12
12
 
@@ -137,7 +137,7 @@ Fired when a subscription is actually terminated. A scheduled cancellation fires
137
137
  - `customerId` (`string`, required) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
138
138
  - `status` (`string`, required) — Always "canceled" for this event. Revoke access when you receive this.
139
139
  - `canceledAt` (`string`, optional) — ISO 8601 datetime when the cancellation was requested or triggered.
140
- - `cancelReason` (`string | null`, required) — The reason for cancellation, if provided. Set to "dunning_exhausted" when all payment retries fail. Historical refund-triggered cancellations may have "refund".
140
+ - `cancelReason` (`string | null`, required) — The reason for cancellation, if provided. Set to "dunning_exhausted" when all payment retries fail, and to "trial_ended_without_payment_method" when a trial without a payment method ends with no card and no default plan. Historical refund-triggered cancellations may have "refund".
141
141
  - `endDate` (`string`, optional) — ISO 8601 datetime when the subscription ended. Matches the billing period end for scheduled cancellations; for immediate terminations it is the moment of termination.
142
142
 
143
143
  ## subscription.updated
@@ -209,7 +209,7 @@ Fired when a plan change (downgrade or shorter interval) is scheduled for the en
209
209
 
210
210
  ## subscription.plan_change_revoked
211
211
 
212
- Fired when a scheduled plan change is replaced by a different one before it executes. The replacement also fires subscription.plan_change_scheduled with the new target plan.
212
+ Fired when a scheduled plan change will no longer take effect: it was revoked through the API, the dashboard or the customer portal, an immediate plan change or an immediate cancellation voided it, or a different change replaced it. A replacement also fires subscription.plan_change_scheduled with the new target plan.
213
213
 
214
214
  ### Data
215
215
 
@@ -235,7 +235,7 @@ Fired when a recurring payment fails on a previously paid subscription and its s
235
235
 
236
236
  ## trial.started
237
237
 
238
- Fired when a subscription enters its trial period after checkout. Grant access here — trialing subscriptions have full access until trialEndsAt.
238
+ Fired when a subscription enters its trial period: after checkout, or right away when the price's trial requires no payment method. Grant access here — trialing subscriptions have full access until trialEndsAt.
239
239
 
240
240
  ### Data
241
241
 
@@ -260,7 +260,7 @@ Fired when a trialing customer converts to a paid subscription before the trial
260
260
 
261
261
  ## trial.expired
262
262
 
263
- Fired when a trial period runs out and the billing cycle activates the subscription. The first regular invoice is generated right after — this is the natural trial-to-paid transition.
263
+ Fired when a trial period runs out. With a payment method the billing cycle activates the subscription and generates the first regular invoice right after — the natural trial-to-paid transition. A trial without a payment method instead moves to the plan group's default plan (subscription.plan_changed) or is canceled with cancelReason trial_ended_without_payment_method (subscription.canceled), without an invoice.
264
264
 
265
265
  ### Data
266
266
 
@@ -286,7 +286,7 @@ Predictive event fired once, 3 days before a trial ends. Use it to remind the cu
286
286
 
287
287
  ## trial.checkout_ready
288
288
 
289
- Fired when a trial checkout link is ready to share with the customer. Completing this checkout saves a payment method and starts the trial (trial.started) — the customer is not charged until the trial ends.
289
+ Fired when a trial checkout link is ready to share with the customer. Completing this checkout saves a payment method and starts the trial (trial.started) — the customer is not charged until the trial ends. Not fired for a trial whose price requires no payment method, which starts without checkout.
290
290
 
291
291
  ### Data
292
292
 
@@ -734,7 +734,7 @@ Fired after an active plan grant is durably revoked. The payload is the grant sn
734
734
 
735
735
  ## credits.granted
736
736
 
737
- Fired when non-purchase credits are granted to a subscription: plan-included credits at the start of each billing period, or a manual adjustment from the dashboard. Credit pack purchases fire credits.purchased instead.
737
+ Fired when non-purchase credits are granted to a subscription: plan-included credits at the start of each billing period, or a manual adjustment from the dashboard. Credit purchases through the API, automatic top-ups, or the customer portal fire credits.purchased instead.
738
738
 
739
739
  ### Data
740
740
 
@@ -745,7 +745,7 @@ Fired when non-purchase credits are granted to a subscription: plan-included cre
745
745
 
746
746
  ## credits.purchased
747
747
 
748
- Fired when a customer buys a credit pack through the customer portal and the payment succeeds. Purchased credits never expire — unlike plan credits, they survive period resets. Plan-included credit grants fire credits.granted instead.
748
+ Fired when a customer buys a credit pack or a chosen quantity of credits through the API, an automatic top-up, or the customer portal and the payment succeeds. Purchased credits never expire — unlike plan credits, they survive period resets. Plan-included credit grants fire credits.granted instead.
749
749
 
750
750
  ### Data
751
751
 
@@ -753,7 +753,7 @@ Fired when a customer buys a credit pack through the customer portal and the pay
753
753
  - `customerId` (`string`, required) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
754
754
  - `invoiceId` (`string`, required) — The invoice issued for the purchase.
755
755
  - `invoiceNumber` (`string`, required) — The human-readable invoice number.
756
- - `creditPackName` (`string`, required) — The purchased credit pack's name.
756
+ - `creditPackName` (`string`, required) — The purchased credit pack's name, or Credit purchase for a chosen quantity of credits.
757
757
  - `credits` (`number`, required) — The number of credits purchased.
758
758
 
759
759
  ## credits.low
@@ -780,13 +780,13 @@ Fired when a subscription's credits hit zero. Usage requests that need more cred
780
780
 
781
781
  ## credits.expired
782
782
 
783
- Fired at the period reset when unused plan credits from the previous period are discarded. Plan credits expire at period end; purchased credits never expire and are not affected.
783
+ Fired at a reset when unused plan credits are discarded. On a plan whose unused plan credits expire, every unused plan credit expires at each reset. On a plan that rolls them over, a reset keeps them, up to the plan's maxPlanCredits when it has one, and only the excess expires. A change to another credits plan applies the new plan's terms the same way. Purchased credits never expire and are not affected.
784
784
 
785
785
  ### Data
786
786
 
787
787
  - `subscriptionId` (`string`, required) — The subscription ID.
788
788
  - `customerId` (`string`, required) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
789
- - `expiredCredits` (`number`, required) — The unused plan credits that were discarded.
789
+ - `expiredCredits` (`number`, required) — The plan credits that were discarded.
790
790
 
791
791
  ## balance.topped_up
792
792
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commet/node",
3
- "version": "9.7.0",
3
+ "version": "9.8.0",
4
4
  "description": "Commet SDK for Node.js - Billing and usage tracking",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",