@commet/node 7.0.0 → 7.2.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/dist/index.d.mts CHANGED
@@ -140,7 +140,7 @@ type ResolvedPlanCode<TConfig> = [InferPlanCodes<TConfig>] extends [
140
140
  type SubscriptionStatus = "draft" | "pending_payment" | "trialing" | "active" | "past_due" | "canceled";
141
141
  type BillingInterval = "weekly" | "monthly" | "quarterly" | "yearly" | "one_time";
142
142
  type ConsumptionModel = "metered" | "credits" | "balance";
143
- type InvoiceType = "recurring" | "overage" | "plan_change" | "adjustment" | "credit_purchase" | "balance_topup" | "addon_activation";
143
+ type InvoiceType = "recurring" | "overage" | "plan_change" | "adjustment" | "credit_purchase" | "balance_topup" | "addon_activation" | "one_time_payment";
144
144
  type TransactionStatus = "pending" | "succeeded" | "failed" | "refunded" | "disputed";
145
145
  type FeatureType = "boolean" | "usage" | "seats" | "quota";
146
146
  type DiscountType = "percentage" | "amount";
@@ -436,7 +436,7 @@ interface Invoice {
436
436
  /** @format date-time */
437
437
  updatedAt: string;
438
438
  lineItems?: Array<{
439
- lineType: "plan_base" | "feature_overage" | "feature_seats" | "feature_quota" | "discount" | "promo_code_discount" | "credit" | "balance_overage" | "addon_base";
439
+ lineType: "plan_base" | "feature_overage" | "feature_seats" | "feature_quota" | "discount" | "promo_code_discount" | "credit" | "balance_overage" | "addon_base" | "one_time";
440
440
  featureName: string | null;
441
441
  description: string;
442
442
  quantity: number;
@@ -468,6 +468,32 @@ interface InvoiceStatus {
468
468
  object: "invoice";
469
469
  livemode: boolean;
470
470
  }
471
+ interface Payment {
472
+ id: string;
473
+ customerId: string | null;
474
+ kind: "link" | "charge";
475
+ status: "pending" | "processing" | "succeeded" | "requires_action" | "failed" | "canceled";
476
+ provider: "stripe" | "commet";
477
+ amountSubtotal: number;
478
+ taxAmount: number;
479
+ amountTotal: number;
480
+ currency: string;
481
+ description: string;
482
+ metadata: Record<string, unknown> | null;
483
+ url: string | null;
484
+ expiresAt: string | null;
485
+ /** @format date-time */
486
+ createdAt: string;
487
+ /** @format date-time */
488
+ updatedAt: string;
489
+ object: "payment";
490
+ livemode: boolean;
491
+ }
492
+ interface PaymentMethodUpdateCheckout {
493
+ checkoutUrl: string;
494
+ object: "subscription";
495
+ livemode: boolean;
496
+ }
471
497
  interface Payout {
472
498
  id: string;
473
499
  status: "pending" | "in_transit" | "paid" | "failed" | "canceled";
@@ -603,6 +629,15 @@ interface PlanChange {
603
629
  remainingCreditBalance: number;
604
630
  };
605
631
  invoiceId?: string;
632
+ seatLimitWarning?: {
633
+ featureCode: string;
634
+ featureName: string;
635
+ currentSeats: number;
636
+ included: number;
637
+ newPlanName: string;
638
+ /** @format date-time */
639
+ effectiveDate: string;
640
+ };
606
641
  object: "subscription";
607
642
  livemode: boolean;
608
643
  }
@@ -721,6 +756,18 @@ interface PromoCode {
721
756
  object: "promo_code";
722
757
  livemode: boolean;
723
758
  }
759
+ interface ReactivatedSubscription {
760
+ id: string;
761
+ retryInitiated: boolean;
762
+ object: "subscription";
763
+ livemode: boolean;
764
+ }
765
+ interface RecoveryLink {
766
+ url: string;
767
+ token: string;
768
+ object: "subscription";
769
+ livemode: boolean;
770
+ }
724
771
  interface RemovedPlanFeature {
725
772
  id: string;
726
773
  removed: true;
@@ -897,7 +944,6 @@ interface TransactionRefund {
897
944
  interface TransactionRetry {
898
945
  id: string;
899
946
  status: "processing";
900
- retryInvoiceNumber: string;
901
947
  object: "transaction";
902
948
  livemode: boolean;
903
949
  }
@@ -957,6 +1003,8 @@ declare class CommetHTTPClient {
957
1003
  * Build full URL from endpoint and params
958
1004
  */
959
1005
  private buildURL;
1006
+ private retryDelayMs;
1007
+ private backoffDelayMs;
960
1008
  private generateIdempotencyKey;
961
1009
  /**
962
1010
  * Sleep for specified milliseconds
@@ -1244,6 +1292,48 @@ declare class InvoicesResource {
1244
1292
  updateStatus(params: UpdateInvoiceStatusParams, options?: RequestOptions): Promise<ApiResponse<InvoiceStatus>>;
1245
1293
  }
1246
1294
 
1295
+ interface ListPaymentsParams {
1296
+ customerId?: string;
1297
+ /** @format date-time */
1298
+ cursor?: string;
1299
+ limit?: number;
1300
+ }
1301
+ interface CreatePaymentParams {
1302
+ amount: number;
1303
+ currency: string;
1304
+ customerId?: string;
1305
+ description: string;
1306
+ successUrl?: string;
1307
+ metadata?: Record<string, string>;
1308
+ }
1309
+ interface ChargePaymentParams {
1310
+ customerId: string;
1311
+ amount: number;
1312
+ currency: string;
1313
+ description: string;
1314
+ metadata?: Record<string, string>;
1315
+ }
1316
+ interface GetPaymentParams {
1317
+ id: string;
1318
+ }
1319
+ interface CancelPaymentParams {
1320
+ id: string;
1321
+ }
1322
+ declare class PaymentsResource {
1323
+ private httpClient;
1324
+ constructor(httpClient: CommetHTTPClient);
1325
+ /** List payments with cursor-based pagination. Filter by customer. */
1326
+ list(params?: ListPaymentsParams, options?: RequestOptions): Promise<ApiResponse<Array<Payment>>>;
1327
+ /** Create a hosted payment link. Returns a url the customer opens to pay with any card. Calculates tax, generates an invoice, and vaults the payment method on confirmation. No subscription or plan required. */
1328
+ create(params: CreatePaymentParams, options?: RequestOptions): Promise<ApiResponse<Payment>>;
1329
+ /** Charge a customer's vaulted payment method off-session. Calculates tax, generates an invoice, and sends a receipt. No subscription or plan required. */
1330
+ charge(params: ChargePaymentParams, options?: RequestOptions): Promise<ApiResponse<Payment>>;
1331
+ /** Retrieve a payment by its public ID. */
1332
+ get(params: GetPaymentParams, options?: RequestOptions): Promise<ApiResponse<Payment>>;
1333
+ /** Cancel a pending payment link so it can no longer be paid. Only a link that has not been paid or started processing can be canceled; canceling an already canceled link is a no-op. Charges cannot be canceled. */
1334
+ cancel(params: CancelPaymentParams, options?: RequestOptions): Promise<ApiResponse<Payment>>;
1335
+ }
1336
+
1247
1337
  interface AddPayoutBankAccountParams {
1248
1338
  accountNumber: string;
1249
1339
  accountHolderName: string;
@@ -1705,6 +1795,16 @@ interface CancelSubscriptionParams {
1705
1795
  interface UncancelSubscriptionParams {
1706
1796
  id: string;
1707
1797
  }
1798
+ interface ReactivateSubscriptionParams {
1799
+ id: string;
1800
+ }
1801
+ interface CreateSubscriptionRecoveryLinkParams {
1802
+ id: string;
1803
+ }
1804
+ interface UpdatePaymentMethodParams {
1805
+ id: string;
1806
+ successUrl?: string;
1807
+ }
1708
1808
  interface ChangePlanParams {
1709
1809
  id: string;
1710
1810
  newPlanId?: string;
@@ -1753,6 +1853,12 @@ declare class SubscriptionsResource {
1753
1853
  cancel(params: CancelSubscriptionParams, options?: RequestOptions): Promise<ApiResponse<CanceledSubscription>>;
1754
1854
  /** Revert a scheduled cancellation. Only works when canceledAt is set but status is not yet 'canceled'. */
1755
1855
  uncancel(params: UncancelSubscriptionParams, options?: RequestOptions): Promise<ApiResponse<UncanceledSubscription>>;
1856
+ /** Retries the outstanding renewal charge for a past_due subscription. On a successful charge the subscription recovers to active and a payment.recovered webhook is delivered; a declined charge returns an error and the subscription stays past_due. */
1857
+ reactivate(params: ReactivateSubscriptionParams, options?: RequestOptions): Promise<ApiResponse<ReactivatedSubscription>>;
1858
+ /** Generates a hosted, signed recovery link that lets the customer pay the outstanding renewal charge for a past_due subscription. Unlike reactivate, which charges server-to-server, this returns a link the merchant can deliver through their own email, SMS, or dashboard. The link carries a self-contained signed token and stays valid until the charge is paid or the subscription is no longer past due. */
1859
+ createRecoveryLink(params: CreateSubscriptionRecoveryLinkParams, options?: RequestOptions): Promise<ApiResponse<RecoveryLink>>;
1860
+ /** Creates a hosted checkout session for the customer to update the subscription's default payment method. */
1861
+ updatePaymentMethod(params: UpdatePaymentMethodParams, options?: RequestOptions): Promise<ApiResponse<PaymentMethodUpdateCheckout>>;
1756
1862
  /** Upgrade, downgrade, or change billing interval. */
1757
1863
  changePlan(params: ChangePlanParams, options?: RequestOptions): Promise<ApiResponse<PlanChange>>;
1758
1864
  /** Preview proration details for an immediate plan change (an upgrade or a longer interval) without applying it. Returns credit, charge, and net amount. Downgrades — a cheaper plan in the same group, or a shorter interval — are scheduled for the end of the current period instead of being prorated, so they return a 400 with code `plan_change_scheduled`; apply those via the change-plan endpoint. */
@@ -1809,7 +1915,7 @@ declare class TransactionsResource {
1809
1915
  get(params: GetTransactionParams, options?: RequestOptions): Promise<ApiResponse<Transaction>>;
1810
1916
  /** Issue a full refund for a payment transaction. */
1811
1917
  refund(params: RefundTransactionParams, options?: RequestOptions): Promise<ApiResponse<TransactionRefund>>;
1812
- /** Retry a failed payment transaction. Creates a new invoice and initiates a new payment attempt. */
1918
+ /** Retry a failed subscription renewal. Re-charges the outstanding renewal invoice through the recovery engine. */
1813
1919
  retry(params: RetryTransactionParams, options?: RequestOptions): Promise<ApiResponse<TransactionRetry>>;
1814
1920
  }
1815
1921
 
@@ -1821,6 +1927,7 @@ declare class GeneratedResources {
1821
1927
  featureAccess: FeatureAccessResource;
1822
1928
  features: FeaturesResource;
1823
1929
  invoices: InvoicesResource;
1930
+ payments: PaymentsResource;
1824
1931
  payouts: PayoutsResource;
1825
1932
  planGroups: PlanGroupsResource;
1826
1933
  plans: PlansResource;
@@ -2036,4 +2143,4 @@ declare function registerIntegration(name: string, version: string): void;
2036
2143
  declare const API_VERSION = "2026-06-10";
2037
2144
  declare const SDK_VERSION: string;
2038
2145
 
2039
- export { API_VERSION, type ActivateAddonParams, type ActiveAddon, type AddPayoutBankAccountParams, type AddPlanFeatureParams, type AddPlanPriceParams, type AddPlanToGroupParams, type AddQuotaParams, type AddSeatsParams, type AddedPlanToGroup, type Addon, type AdjustBalanceParams, type AdvanceTestClockParams, type ApiErrorDetail, type ApiKey, type ApiResponse, type BalanceAdjustment, type BalanceTopup, type BatchCreateCustomersParams, type BillingConfig, type BillingInterval, type BulkSeatUpdate, type BulkSetSeatsParams, type CanUseFeatureParams, type CancelSubscriptionParams, type CanceledSubscription, type ChangePlanParams, type CheckUsageParams, Commet, CommetAPIError, type CommetClientOptions, CommetError, CommetValidationError, type CompletePayoutVerificationParams, type ConsumptionModel, type CreateAddonParams, type CreateAdjustmentInvoiceParams, type CreateApiKeyParams, type CreateCreditPackParams, type CreateCustomerParams, type CreateFeatureParams, type CreatePlanGroupParams, type CreatePlanParams, type CreatePromoCodeParams, type CreateSubscriptionParams, type CreateWebhookParams, type CreatedApiKey, type CreatedInvoice, type CreditGrant, type CreditPack, type Currency, type Customer, type CustomerBatch, type CustomerID, type DeactivateAddonParams, type DefaultPlanPrice, type DeleteAddonParams, type DeleteApiKeyParams, type DeleteCreditPackParams, type DeleteFeatureParams, type DeletePlanGroupParams, type DeletePlanParams, type DeletePlanPriceParams, type DeleteRegionalPricesParams, type DeleteWebhookParams, type DeletedObject, type DeletedPlanRegionalPricing, type DeletedSubscriptionAddon, type DiscountType, type DownloadInvoiceParams, type EventID, type Feature, type FeatureAccess, type FeatureDef, type FeatureLookup, type FeatureType, type GetActiveSubscriptionParams, type GetAddonParams, type GetAllQuotaAllowancesParams, type GetAllSeatBalancesParams, type GetCustomerParams, type GetFeatureAccessParams, type GetFeatureParams, type GetInvoiceParams, type GetPlanGroupParams, type GetPlanParams, type GetPromoCodeParams, type GetQuotaAllowanceParams, type GetSeatBalanceParams, type GetSubscriptionParams, type GetTransactionParams, type GetWebhookParams, type InferFeatureCodes, type InferPlanCodes, type InferSeatCodes, type InferUsageCodes, type Invoice, type InvoiceDownload, type InvoiceStatus, type InvoiceType, type ListActiveAddonsParams, type ListAddonsParams, type ListApiKeysParams, type ListCustomersParams, type ListFeatureAccessParams, type ListInvoicesParams, type ListPlanGroupsParams, type ListPlansParams, type ListPromoCodesParams, type ListSubscriptionsParams, type ListTransactionsParams, type ListWebhooksParams, type PaginatedList, type PaginatedResponse, type Payout, type PayoutBankAccount, type PayoutVerification, type Plan, type PlanChange, type PlanDef, type PlanFeature, type PlanFeatureValue, type PlanGroup, type PlanPrice, type PlanRegionalPricing, type PlanRegionalPricingResult, type PlanVisibility, type PortalAccess, type PreviewChange, type PreviewChangePlanParams, type PriceDef, type PromoCode, type PurchaseCreditsParams, type RefundTransactionParams, type RemovePlanFeatureParams, type RemovePlanFromGroupParams, type RemoveQuotaParams, type RemoveSeatsParams, type RemovedPlanFeature, type RemovedPlanFromGroup, type ReorderPlansInGroupParams, type ReorderedPlans, type RequestOptions, type RequestPayoutParams, type RequestPortalAccessParams, type ResolvedFeatureCode, type ResolvedPlanCode, type ResolvedSeatCode, type ResolvedUsageCode, type RetryTransactionParams, SDK_VERSION, type SeatBalance, type SeatBalanceListItem, type SeatEvent, type SendInvoiceParams, type SentInvoice, type SetDefaultPlanPriceParams, type SetPlanRegionalPricingParams, type SetPlanVisibilityParams, type SetQuotaParams, type SetSeatsParams, type Subscription, type SubscriptionAddon, type SubscriptionStatus, type TestClock, type TestClockBilling, type TestWebhookParams, type Timezone, type TopupBalanceParams, type TrackModelTokensParams, type TrackParams, type TrackUsageParams, type Transaction, type TransactionRefund, type TransactionRetry, type TransactionStatus, type UncancelSubscriptionParams, type UncanceledSubscription, type UpdateAddonParams, type UpdateCreditPackParams, type UpdateCustomerParams, type UpdateFeatureParams, type UpdateInvoiceStatusParams, type UpdatePlanFeatureParams, type UpdatePlanGroupParams, type UpdatePlanParams, type UpdatePlanPriceParams, type UpdatePromoCodeParams, type UpdateWebhookParams, type UpsertRegionalPricesParams, type UsageCheckDenialReason, type UsageCheckResult, type UsageEvent, type UsageEventProperty, type UsageQuota, type UsageQuotaEvent, type WebhookData, type WebhookEndpoint, type WebhookEndpointCreated, type WebhookEvent, type WebhookPayload, type WebhookTestResult, Webhooks, createCommet, Commet as default, defineConfig, registerIntegration };
2146
+ export { API_VERSION, type ActivateAddonParams, type ActiveAddon, type AddPayoutBankAccountParams, type AddPlanFeatureParams, type AddPlanPriceParams, type AddPlanToGroupParams, type AddQuotaParams, type AddSeatsParams, type AddedPlanToGroup, type Addon, type AdjustBalanceParams, type AdvanceTestClockParams, type ApiErrorDetail, type ApiKey, type ApiResponse, type BalanceAdjustment, type BalanceTopup, type BatchCreateCustomersParams, type BillingConfig, type BillingInterval, type BulkSeatUpdate, type BulkSetSeatsParams, type CanUseFeatureParams, type CancelPaymentParams, type CancelSubscriptionParams, type CanceledSubscription, type ChangePlanParams, type ChargePaymentParams, type CheckUsageParams, Commet, CommetAPIError, type CommetClientOptions, CommetError, CommetValidationError, type CompletePayoutVerificationParams, type ConsumptionModel, type CreateAddonParams, type CreateAdjustmentInvoiceParams, type CreateApiKeyParams, type CreateCreditPackParams, type CreateCustomerParams, type CreateFeatureParams, type CreatePaymentParams, type CreatePlanGroupParams, type CreatePlanParams, type CreatePromoCodeParams, type CreateSubscriptionParams, type CreateSubscriptionRecoveryLinkParams, type CreateWebhookParams, type CreatedApiKey, type CreatedInvoice, type CreditGrant, type CreditPack, type Currency, type Customer, type CustomerBatch, type CustomerID, type DeactivateAddonParams, type DefaultPlanPrice, type DeleteAddonParams, type DeleteApiKeyParams, type DeleteCreditPackParams, type DeleteFeatureParams, type DeletePlanGroupParams, type DeletePlanParams, type DeletePlanPriceParams, type DeleteRegionalPricesParams, type DeleteWebhookParams, type DeletedObject, type DeletedPlanRegionalPricing, type DeletedSubscriptionAddon, type DiscountType, type DownloadInvoiceParams, type EventID, type Feature, type FeatureAccess, type FeatureDef, type FeatureLookup, type FeatureType, type GetActiveSubscriptionParams, type GetAddonParams, type GetAllQuotaAllowancesParams, type GetAllSeatBalancesParams, type GetCustomerParams, type GetFeatureAccessParams, type GetFeatureParams, type GetInvoiceParams, type GetPaymentParams, type GetPlanGroupParams, type GetPlanParams, type GetPromoCodeParams, type GetQuotaAllowanceParams, type GetSeatBalanceParams, type GetSubscriptionParams, type GetTransactionParams, type GetWebhookParams, type InferFeatureCodes, type InferPlanCodes, type InferSeatCodes, type InferUsageCodes, type Invoice, type InvoiceDownload, type InvoiceStatus, type InvoiceType, type ListActiveAddonsParams, type ListAddonsParams, type ListApiKeysParams, type ListCustomersParams, type ListFeatureAccessParams, type ListInvoicesParams, type ListPaymentsParams, type ListPlanGroupsParams, type ListPlansParams, type ListPromoCodesParams, type ListSubscriptionsParams, type ListTransactionsParams, type ListWebhooksParams, type PaginatedList, type PaginatedResponse, type Payment, type PaymentMethodUpdateCheckout, type Payout, type PayoutBankAccount, type PayoutVerification, type Plan, type PlanChange, type PlanDef, type PlanFeature, type PlanFeatureValue, type PlanGroup, type PlanPrice, type PlanRegionalPricing, type PlanRegionalPricingResult, type PlanVisibility, type PortalAccess, type PreviewChange, type PreviewChangePlanParams, type PriceDef, type PromoCode, type PurchaseCreditsParams, type ReactivateSubscriptionParams, type ReactivatedSubscription, type RecoveryLink, type RefundTransactionParams, type RemovePlanFeatureParams, type RemovePlanFromGroupParams, type RemoveQuotaParams, type RemoveSeatsParams, type RemovedPlanFeature, type RemovedPlanFromGroup, type ReorderPlansInGroupParams, type ReorderedPlans, type RequestOptions, type RequestPayoutParams, type RequestPortalAccessParams, type ResolvedFeatureCode, type ResolvedPlanCode, type ResolvedSeatCode, type ResolvedUsageCode, type RetryTransactionParams, SDK_VERSION, type SeatBalance, type SeatBalanceListItem, type SeatEvent, type SendInvoiceParams, type SentInvoice, type SetDefaultPlanPriceParams, type SetPlanRegionalPricingParams, type SetPlanVisibilityParams, type SetQuotaParams, type SetSeatsParams, type Subscription, type SubscriptionAddon, type SubscriptionStatus, type TestClock, type TestClockBilling, type TestWebhookParams, type Timezone, type TopupBalanceParams, type TrackModelTokensParams, type TrackParams, type TrackUsageParams, type Transaction, type TransactionRefund, type TransactionRetry, type TransactionStatus, type UncancelSubscriptionParams, type UncanceledSubscription, type UpdateAddonParams, type UpdateCreditPackParams, type UpdateCustomerParams, type UpdateFeatureParams, type UpdateInvoiceStatusParams, type UpdatePaymentMethodParams, type UpdatePlanFeatureParams, type UpdatePlanGroupParams, type UpdatePlanParams, type UpdatePlanPriceParams, type UpdatePromoCodeParams, type UpdateWebhookParams, type UpsertRegionalPricesParams, type UsageCheckDenialReason, type UsageCheckResult, type UsageEvent, type UsageEventProperty, type UsageQuota, type UsageQuotaEvent, type WebhookData, type WebhookEndpoint, type WebhookEndpointCreated, type WebhookEvent, type WebhookPayload, type WebhookTestResult, Webhooks, createCommet, Commet as default, defineConfig, registerIntegration };
package/dist/index.d.ts CHANGED
@@ -140,7 +140,7 @@ type ResolvedPlanCode<TConfig> = [InferPlanCodes<TConfig>] extends [
140
140
  type SubscriptionStatus = "draft" | "pending_payment" | "trialing" | "active" | "past_due" | "canceled";
141
141
  type BillingInterval = "weekly" | "monthly" | "quarterly" | "yearly" | "one_time";
142
142
  type ConsumptionModel = "metered" | "credits" | "balance";
143
- type InvoiceType = "recurring" | "overage" | "plan_change" | "adjustment" | "credit_purchase" | "balance_topup" | "addon_activation";
143
+ type InvoiceType = "recurring" | "overage" | "plan_change" | "adjustment" | "credit_purchase" | "balance_topup" | "addon_activation" | "one_time_payment";
144
144
  type TransactionStatus = "pending" | "succeeded" | "failed" | "refunded" | "disputed";
145
145
  type FeatureType = "boolean" | "usage" | "seats" | "quota";
146
146
  type DiscountType = "percentage" | "amount";
@@ -436,7 +436,7 @@ interface Invoice {
436
436
  /** @format date-time */
437
437
  updatedAt: string;
438
438
  lineItems?: Array<{
439
- lineType: "plan_base" | "feature_overage" | "feature_seats" | "feature_quota" | "discount" | "promo_code_discount" | "credit" | "balance_overage" | "addon_base";
439
+ lineType: "plan_base" | "feature_overage" | "feature_seats" | "feature_quota" | "discount" | "promo_code_discount" | "credit" | "balance_overage" | "addon_base" | "one_time";
440
440
  featureName: string | null;
441
441
  description: string;
442
442
  quantity: number;
@@ -468,6 +468,32 @@ interface InvoiceStatus {
468
468
  object: "invoice";
469
469
  livemode: boolean;
470
470
  }
471
+ interface Payment {
472
+ id: string;
473
+ customerId: string | null;
474
+ kind: "link" | "charge";
475
+ status: "pending" | "processing" | "succeeded" | "requires_action" | "failed" | "canceled";
476
+ provider: "stripe" | "commet";
477
+ amountSubtotal: number;
478
+ taxAmount: number;
479
+ amountTotal: number;
480
+ currency: string;
481
+ description: string;
482
+ metadata: Record<string, unknown> | null;
483
+ url: string | null;
484
+ expiresAt: string | null;
485
+ /** @format date-time */
486
+ createdAt: string;
487
+ /** @format date-time */
488
+ updatedAt: string;
489
+ object: "payment";
490
+ livemode: boolean;
491
+ }
492
+ interface PaymentMethodUpdateCheckout {
493
+ checkoutUrl: string;
494
+ object: "subscription";
495
+ livemode: boolean;
496
+ }
471
497
  interface Payout {
472
498
  id: string;
473
499
  status: "pending" | "in_transit" | "paid" | "failed" | "canceled";
@@ -603,6 +629,15 @@ interface PlanChange {
603
629
  remainingCreditBalance: number;
604
630
  };
605
631
  invoiceId?: string;
632
+ seatLimitWarning?: {
633
+ featureCode: string;
634
+ featureName: string;
635
+ currentSeats: number;
636
+ included: number;
637
+ newPlanName: string;
638
+ /** @format date-time */
639
+ effectiveDate: string;
640
+ };
606
641
  object: "subscription";
607
642
  livemode: boolean;
608
643
  }
@@ -721,6 +756,18 @@ interface PromoCode {
721
756
  object: "promo_code";
722
757
  livemode: boolean;
723
758
  }
759
+ interface ReactivatedSubscription {
760
+ id: string;
761
+ retryInitiated: boolean;
762
+ object: "subscription";
763
+ livemode: boolean;
764
+ }
765
+ interface RecoveryLink {
766
+ url: string;
767
+ token: string;
768
+ object: "subscription";
769
+ livemode: boolean;
770
+ }
724
771
  interface RemovedPlanFeature {
725
772
  id: string;
726
773
  removed: true;
@@ -897,7 +944,6 @@ interface TransactionRefund {
897
944
  interface TransactionRetry {
898
945
  id: string;
899
946
  status: "processing";
900
- retryInvoiceNumber: string;
901
947
  object: "transaction";
902
948
  livemode: boolean;
903
949
  }
@@ -957,6 +1003,8 @@ declare class CommetHTTPClient {
957
1003
  * Build full URL from endpoint and params
958
1004
  */
959
1005
  private buildURL;
1006
+ private retryDelayMs;
1007
+ private backoffDelayMs;
960
1008
  private generateIdempotencyKey;
961
1009
  /**
962
1010
  * Sleep for specified milliseconds
@@ -1244,6 +1292,48 @@ declare class InvoicesResource {
1244
1292
  updateStatus(params: UpdateInvoiceStatusParams, options?: RequestOptions): Promise<ApiResponse<InvoiceStatus>>;
1245
1293
  }
1246
1294
 
1295
+ interface ListPaymentsParams {
1296
+ customerId?: string;
1297
+ /** @format date-time */
1298
+ cursor?: string;
1299
+ limit?: number;
1300
+ }
1301
+ interface CreatePaymentParams {
1302
+ amount: number;
1303
+ currency: string;
1304
+ customerId?: string;
1305
+ description: string;
1306
+ successUrl?: string;
1307
+ metadata?: Record<string, string>;
1308
+ }
1309
+ interface ChargePaymentParams {
1310
+ customerId: string;
1311
+ amount: number;
1312
+ currency: string;
1313
+ description: string;
1314
+ metadata?: Record<string, string>;
1315
+ }
1316
+ interface GetPaymentParams {
1317
+ id: string;
1318
+ }
1319
+ interface CancelPaymentParams {
1320
+ id: string;
1321
+ }
1322
+ declare class PaymentsResource {
1323
+ private httpClient;
1324
+ constructor(httpClient: CommetHTTPClient);
1325
+ /** List payments with cursor-based pagination. Filter by customer. */
1326
+ list(params?: ListPaymentsParams, options?: RequestOptions): Promise<ApiResponse<Array<Payment>>>;
1327
+ /** Create a hosted payment link. Returns a url the customer opens to pay with any card. Calculates tax, generates an invoice, and vaults the payment method on confirmation. No subscription or plan required. */
1328
+ create(params: CreatePaymentParams, options?: RequestOptions): Promise<ApiResponse<Payment>>;
1329
+ /** Charge a customer's vaulted payment method off-session. Calculates tax, generates an invoice, and sends a receipt. No subscription or plan required. */
1330
+ charge(params: ChargePaymentParams, options?: RequestOptions): Promise<ApiResponse<Payment>>;
1331
+ /** Retrieve a payment by its public ID. */
1332
+ get(params: GetPaymentParams, options?: RequestOptions): Promise<ApiResponse<Payment>>;
1333
+ /** Cancel a pending payment link so it can no longer be paid. Only a link that has not been paid or started processing can be canceled; canceling an already canceled link is a no-op. Charges cannot be canceled. */
1334
+ cancel(params: CancelPaymentParams, options?: RequestOptions): Promise<ApiResponse<Payment>>;
1335
+ }
1336
+
1247
1337
  interface AddPayoutBankAccountParams {
1248
1338
  accountNumber: string;
1249
1339
  accountHolderName: string;
@@ -1705,6 +1795,16 @@ interface CancelSubscriptionParams {
1705
1795
  interface UncancelSubscriptionParams {
1706
1796
  id: string;
1707
1797
  }
1798
+ interface ReactivateSubscriptionParams {
1799
+ id: string;
1800
+ }
1801
+ interface CreateSubscriptionRecoveryLinkParams {
1802
+ id: string;
1803
+ }
1804
+ interface UpdatePaymentMethodParams {
1805
+ id: string;
1806
+ successUrl?: string;
1807
+ }
1708
1808
  interface ChangePlanParams {
1709
1809
  id: string;
1710
1810
  newPlanId?: string;
@@ -1753,6 +1853,12 @@ declare class SubscriptionsResource {
1753
1853
  cancel(params: CancelSubscriptionParams, options?: RequestOptions): Promise<ApiResponse<CanceledSubscription>>;
1754
1854
  /** Revert a scheduled cancellation. Only works when canceledAt is set but status is not yet 'canceled'. */
1755
1855
  uncancel(params: UncancelSubscriptionParams, options?: RequestOptions): Promise<ApiResponse<UncanceledSubscription>>;
1856
+ /** Retries the outstanding renewal charge for a past_due subscription. On a successful charge the subscription recovers to active and a payment.recovered webhook is delivered; a declined charge returns an error and the subscription stays past_due. */
1857
+ reactivate(params: ReactivateSubscriptionParams, options?: RequestOptions): Promise<ApiResponse<ReactivatedSubscription>>;
1858
+ /** Generates a hosted, signed recovery link that lets the customer pay the outstanding renewal charge for a past_due subscription. Unlike reactivate, which charges server-to-server, this returns a link the merchant can deliver through their own email, SMS, or dashboard. The link carries a self-contained signed token and stays valid until the charge is paid or the subscription is no longer past due. */
1859
+ createRecoveryLink(params: CreateSubscriptionRecoveryLinkParams, options?: RequestOptions): Promise<ApiResponse<RecoveryLink>>;
1860
+ /** Creates a hosted checkout session for the customer to update the subscription's default payment method. */
1861
+ updatePaymentMethod(params: UpdatePaymentMethodParams, options?: RequestOptions): Promise<ApiResponse<PaymentMethodUpdateCheckout>>;
1756
1862
  /** Upgrade, downgrade, or change billing interval. */
1757
1863
  changePlan(params: ChangePlanParams, options?: RequestOptions): Promise<ApiResponse<PlanChange>>;
1758
1864
  /** Preview proration details for an immediate plan change (an upgrade or a longer interval) without applying it. Returns credit, charge, and net amount. Downgrades — a cheaper plan in the same group, or a shorter interval — are scheduled for the end of the current period instead of being prorated, so they return a 400 with code `plan_change_scheduled`; apply those via the change-plan endpoint. */
@@ -1809,7 +1915,7 @@ declare class TransactionsResource {
1809
1915
  get(params: GetTransactionParams, options?: RequestOptions): Promise<ApiResponse<Transaction>>;
1810
1916
  /** Issue a full refund for a payment transaction. */
1811
1917
  refund(params: RefundTransactionParams, options?: RequestOptions): Promise<ApiResponse<TransactionRefund>>;
1812
- /** Retry a failed payment transaction. Creates a new invoice and initiates a new payment attempt. */
1918
+ /** Retry a failed subscription renewal. Re-charges the outstanding renewal invoice through the recovery engine. */
1813
1919
  retry(params: RetryTransactionParams, options?: RequestOptions): Promise<ApiResponse<TransactionRetry>>;
1814
1920
  }
1815
1921
 
@@ -1821,6 +1927,7 @@ declare class GeneratedResources {
1821
1927
  featureAccess: FeatureAccessResource;
1822
1928
  features: FeaturesResource;
1823
1929
  invoices: InvoicesResource;
1930
+ payments: PaymentsResource;
1824
1931
  payouts: PayoutsResource;
1825
1932
  planGroups: PlanGroupsResource;
1826
1933
  plans: PlansResource;
@@ -2036,4 +2143,4 @@ declare function registerIntegration(name: string, version: string): void;
2036
2143
  declare const API_VERSION = "2026-06-10";
2037
2144
  declare const SDK_VERSION: string;
2038
2145
 
2039
- export { API_VERSION, type ActivateAddonParams, type ActiveAddon, type AddPayoutBankAccountParams, type AddPlanFeatureParams, type AddPlanPriceParams, type AddPlanToGroupParams, type AddQuotaParams, type AddSeatsParams, type AddedPlanToGroup, type Addon, type AdjustBalanceParams, type AdvanceTestClockParams, type ApiErrorDetail, type ApiKey, type ApiResponse, type BalanceAdjustment, type BalanceTopup, type BatchCreateCustomersParams, type BillingConfig, type BillingInterval, type BulkSeatUpdate, type BulkSetSeatsParams, type CanUseFeatureParams, type CancelSubscriptionParams, type CanceledSubscription, type ChangePlanParams, type CheckUsageParams, Commet, CommetAPIError, type CommetClientOptions, CommetError, CommetValidationError, type CompletePayoutVerificationParams, type ConsumptionModel, type CreateAddonParams, type CreateAdjustmentInvoiceParams, type CreateApiKeyParams, type CreateCreditPackParams, type CreateCustomerParams, type CreateFeatureParams, type CreatePlanGroupParams, type CreatePlanParams, type CreatePromoCodeParams, type CreateSubscriptionParams, type CreateWebhookParams, type CreatedApiKey, type CreatedInvoice, type CreditGrant, type CreditPack, type Currency, type Customer, type CustomerBatch, type CustomerID, type DeactivateAddonParams, type DefaultPlanPrice, type DeleteAddonParams, type DeleteApiKeyParams, type DeleteCreditPackParams, type DeleteFeatureParams, type DeletePlanGroupParams, type DeletePlanParams, type DeletePlanPriceParams, type DeleteRegionalPricesParams, type DeleteWebhookParams, type DeletedObject, type DeletedPlanRegionalPricing, type DeletedSubscriptionAddon, type DiscountType, type DownloadInvoiceParams, type EventID, type Feature, type FeatureAccess, type FeatureDef, type FeatureLookup, type FeatureType, type GetActiveSubscriptionParams, type GetAddonParams, type GetAllQuotaAllowancesParams, type GetAllSeatBalancesParams, type GetCustomerParams, type GetFeatureAccessParams, type GetFeatureParams, type GetInvoiceParams, type GetPlanGroupParams, type GetPlanParams, type GetPromoCodeParams, type GetQuotaAllowanceParams, type GetSeatBalanceParams, type GetSubscriptionParams, type GetTransactionParams, type GetWebhookParams, type InferFeatureCodes, type InferPlanCodes, type InferSeatCodes, type InferUsageCodes, type Invoice, type InvoiceDownload, type InvoiceStatus, type InvoiceType, type ListActiveAddonsParams, type ListAddonsParams, type ListApiKeysParams, type ListCustomersParams, type ListFeatureAccessParams, type ListInvoicesParams, type ListPlanGroupsParams, type ListPlansParams, type ListPromoCodesParams, type ListSubscriptionsParams, type ListTransactionsParams, type ListWebhooksParams, type PaginatedList, type PaginatedResponse, type Payout, type PayoutBankAccount, type PayoutVerification, type Plan, type PlanChange, type PlanDef, type PlanFeature, type PlanFeatureValue, type PlanGroup, type PlanPrice, type PlanRegionalPricing, type PlanRegionalPricingResult, type PlanVisibility, type PortalAccess, type PreviewChange, type PreviewChangePlanParams, type PriceDef, type PromoCode, type PurchaseCreditsParams, type RefundTransactionParams, type RemovePlanFeatureParams, type RemovePlanFromGroupParams, type RemoveQuotaParams, type RemoveSeatsParams, type RemovedPlanFeature, type RemovedPlanFromGroup, type ReorderPlansInGroupParams, type ReorderedPlans, type RequestOptions, type RequestPayoutParams, type RequestPortalAccessParams, type ResolvedFeatureCode, type ResolvedPlanCode, type ResolvedSeatCode, type ResolvedUsageCode, type RetryTransactionParams, SDK_VERSION, type SeatBalance, type SeatBalanceListItem, type SeatEvent, type SendInvoiceParams, type SentInvoice, type SetDefaultPlanPriceParams, type SetPlanRegionalPricingParams, type SetPlanVisibilityParams, type SetQuotaParams, type SetSeatsParams, type Subscription, type SubscriptionAddon, type SubscriptionStatus, type TestClock, type TestClockBilling, type TestWebhookParams, type Timezone, type TopupBalanceParams, type TrackModelTokensParams, type TrackParams, type TrackUsageParams, type Transaction, type TransactionRefund, type TransactionRetry, type TransactionStatus, type UncancelSubscriptionParams, type UncanceledSubscription, type UpdateAddonParams, type UpdateCreditPackParams, type UpdateCustomerParams, type UpdateFeatureParams, type UpdateInvoiceStatusParams, type UpdatePlanFeatureParams, type UpdatePlanGroupParams, type UpdatePlanParams, type UpdatePlanPriceParams, type UpdatePromoCodeParams, type UpdateWebhookParams, type UpsertRegionalPricesParams, type UsageCheckDenialReason, type UsageCheckResult, type UsageEvent, type UsageEventProperty, type UsageQuota, type UsageQuotaEvent, type WebhookData, type WebhookEndpoint, type WebhookEndpointCreated, type WebhookEvent, type WebhookPayload, type WebhookTestResult, Webhooks, createCommet, Commet as default, defineConfig, registerIntegration };
2146
+ export { API_VERSION, type ActivateAddonParams, type ActiveAddon, type AddPayoutBankAccountParams, type AddPlanFeatureParams, type AddPlanPriceParams, type AddPlanToGroupParams, type AddQuotaParams, type AddSeatsParams, type AddedPlanToGroup, type Addon, type AdjustBalanceParams, type AdvanceTestClockParams, type ApiErrorDetail, type ApiKey, type ApiResponse, type BalanceAdjustment, type BalanceTopup, type BatchCreateCustomersParams, type BillingConfig, type BillingInterval, type BulkSeatUpdate, type BulkSetSeatsParams, type CanUseFeatureParams, type CancelPaymentParams, type CancelSubscriptionParams, type CanceledSubscription, type ChangePlanParams, type ChargePaymentParams, type CheckUsageParams, Commet, CommetAPIError, type CommetClientOptions, CommetError, CommetValidationError, type CompletePayoutVerificationParams, type ConsumptionModel, type CreateAddonParams, type CreateAdjustmentInvoiceParams, type CreateApiKeyParams, type CreateCreditPackParams, type CreateCustomerParams, type CreateFeatureParams, type CreatePaymentParams, type CreatePlanGroupParams, type CreatePlanParams, type CreatePromoCodeParams, type CreateSubscriptionParams, type CreateSubscriptionRecoveryLinkParams, type CreateWebhookParams, type CreatedApiKey, type CreatedInvoice, type CreditGrant, type CreditPack, type Currency, type Customer, type CustomerBatch, type CustomerID, type DeactivateAddonParams, type DefaultPlanPrice, type DeleteAddonParams, type DeleteApiKeyParams, type DeleteCreditPackParams, type DeleteFeatureParams, type DeletePlanGroupParams, type DeletePlanParams, type DeletePlanPriceParams, type DeleteRegionalPricesParams, type DeleteWebhookParams, type DeletedObject, type DeletedPlanRegionalPricing, type DeletedSubscriptionAddon, type DiscountType, type DownloadInvoiceParams, type EventID, type Feature, type FeatureAccess, type FeatureDef, type FeatureLookup, type FeatureType, type GetActiveSubscriptionParams, type GetAddonParams, type GetAllQuotaAllowancesParams, type GetAllSeatBalancesParams, type GetCustomerParams, type GetFeatureAccessParams, type GetFeatureParams, type GetInvoiceParams, type GetPaymentParams, type GetPlanGroupParams, type GetPlanParams, type GetPromoCodeParams, type GetQuotaAllowanceParams, type GetSeatBalanceParams, type GetSubscriptionParams, type GetTransactionParams, type GetWebhookParams, type InferFeatureCodes, type InferPlanCodes, type InferSeatCodes, type InferUsageCodes, type Invoice, type InvoiceDownload, type InvoiceStatus, type InvoiceType, type ListActiveAddonsParams, type ListAddonsParams, type ListApiKeysParams, type ListCustomersParams, type ListFeatureAccessParams, type ListInvoicesParams, type ListPaymentsParams, type ListPlanGroupsParams, type ListPlansParams, type ListPromoCodesParams, type ListSubscriptionsParams, type ListTransactionsParams, type ListWebhooksParams, type PaginatedList, type PaginatedResponse, type Payment, type PaymentMethodUpdateCheckout, type Payout, type PayoutBankAccount, type PayoutVerification, type Plan, type PlanChange, type PlanDef, type PlanFeature, type PlanFeatureValue, type PlanGroup, type PlanPrice, type PlanRegionalPricing, type PlanRegionalPricingResult, type PlanVisibility, type PortalAccess, type PreviewChange, type PreviewChangePlanParams, type PriceDef, type PromoCode, type PurchaseCreditsParams, type ReactivateSubscriptionParams, type ReactivatedSubscription, type RecoveryLink, type RefundTransactionParams, type RemovePlanFeatureParams, type RemovePlanFromGroupParams, type RemoveQuotaParams, type RemoveSeatsParams, type RemovedPlanFeature, type RemovedPlanFromGroup, type ReorderPlansInGroupParams, type ReorderedPlans, type RequestOptions, type RequestPayoutParams, type RequestPortalAccessParams, type ResolvedFeatureCode, type ResolvedPlanCode, type ResolvedSeatCode, type ResolvedUsageCode, type RetryTransactionParams, SDK_VERSION, type SeatBalance, type SeatBalanceListItem, type SeatEvent, type SendInvoiceParams, type SentInvoice, type SetDefaultPlanPriceParams, type SetPlanRegionalPricingParams, type SetPlanVisibilityParams, type SetQuotaParams, type SetSeatsParams, type Subscription, type SubscriptionAddon, type SubscriptionStatus, type TestClock, type TestClockBilling, type TestWebhookParams, type Timezone, type TopupBalanceParams, type TrackModelTokensParams, type TrackParams, type TrackUsageParams, type Transaction, type TransactionRefund, type TransactionRetry, type TransactionStatus, type UncancelSubscriptionParams, type UncanceledSubscription, type UpdateAddonParams, type UpdateCreditPackParams, type UpdateCustomerParams, type UpdateFeatureParams, type UpdateInvoiceStatusParams, type UpdatePaymentMethodParams, type UpdatePlanFeatureParams, type UpdatePlanGroupParams, type UpdatePlanParams, type UpdatePlanPriceParams, type UpdatePromoCodeParams, type UpdateWebhookParams, type UpsertRegionalPricesParams, type UsageCheckDenialReason, type UsageCheckResult, type UsageEvent, type UsageEventProperty, type UsageQuota, type UsageQuotaEvent, type WebhookData, type WebhookEndpoint, type WebhookEndpointCreated, type WebhookEvent, type WebhookPayload, type WebhookTestResult, Webhooks, createCommet, Commet as default, defineConfig, registerIntegration };
package/dist/index.js CHANGED
@@ -246,6 +246,35 @@ var InvoicesResource = class {
246
246
  }
247
247
  };
248
248
 
249
+ // src/resources/payments.ts
250
+ var PaymentsResource = class {
251
+ constructor(httpClient) {
252
+ this.httpClient = httpClient;
253
+ }
254
+ /** List payments with cursor-based pagination. Filter by customer. */
255
+ async list(params, options) {
256
+ return this.httpClient.get("/payments", params, options);
257
+ }
258
+ /** Create a hosted payment link. Returns a url the customer opens to pay with any card. Calculates tax, generates an invoice, and vaults the payment method on confirmation. No subscription or plan required. */
259
+ async create(params, options) {
260
+ return this.httpClient.post("/payments", params, options);
261
+ }
262
+ /** Charge a customer's vaulted payment method off-session. Calculates tax, generates an invoice, and sends a receipt. No subscription or plan required. */
263
+ async charge(params, options) {
264
+ return this.httpClient.post("/payments/charge", params, options);
265
+ }
266
+ /** Retrieve a payment by its public ID. */
267
+ async get(params, options) {
268
+ const { id } = params;
269
+ return this.httpClient.get(`/payments/${id}`, void 0, options);
270
+ }
271
+ /** Cancel a pending payment link so it can no longer be paid. Only a link that has not been paid or started processing can be canceled; canceling an already canceled link is a no-op. Charges cannot be canceled. */
272
+ async cancel(params, options) {
273
+ const { id } = params;
274
+ return this.httpClient.post(`/payments/${id}/cancel`, {}, options);
275
+ }
276
+ };
277
+
249
278
  // src/resources/payouts.ts
250
279
  var PayoutsResource = class {
251
280
  constructor(httpClient) {
@@ -553,6 +582,29 @@ var SubscriptionsResource = class {
553
582
  const { id } = params;
554
583
  return this.httpClient.post(`/subscriptions/${id}/uncancel`, {}, options);
555
584
  }
585
+ /** Retries the outstanding renewal charge for a past_due subscription. On a successful charge the subscription recovers to active and a payment.recovered webhook is delivered; a declined charge returns an error and the subscription stays past_due. */
586
+ async reactivate(params, options) {
587
+ const { id } = params;
588
+ return this.httpClient.post(`/subscriptions/${id}/reactivate`, {}, options);
589
+ }
590
+ /** Generates a hosted, signed recovery link that lets the customer pay the outstanding renewal charge for a past_due subscription. Unlike reactivate, which charges server-to-server, this returns a link the merchant can deliver through their own email, SMS, or dashboard. The link carries a self-contained signed token and stays valid until the charge is paid or the subscription is no longer past due. */
591
+ async createRecoveryLink(params, options) {
592
+ const { id } = params;
593
+ return this.httpClient.post(
594
+ `/subscriptions/${id}/recovery-link`,
595
+ {},
596
+ options
597
+ );
598
+ }
599
+ /** Creates a hosted checkout session for the customer to update the subscription's default payment method. */
600
+ async updatePaymentMethod(params, options) {
601
+ const { id, ...rest } = params;
602
+ return this.httpClient.post(
603
+ `/subscriptions/${id}/payment-method/update`,
604
+ rest,
605
+ options
606
+ );
607
+ }
556
608
  /** Upgrade, downgrade, or change billing interval. */
557
609
  async changePlan(params, options) {
558
610
  const { id, ...rest } = params;
@@ -648,7 +700,7 @@ var TransactionsResource = class {
648
700
  const { id } = params;
649
701
  return this.httpClient.post(`/transactions/${id}/refund`, {}, options);
650
702
  }
651
- /** Retry a failed payment transaction. Creates a new invoice and initiates a new payment attempt. */
703
+ /** Retry a failed subscription renewal. Re-charges the outstanding renewal invoice through the recovery engine. */
652
704
  async retry(params, options) {
653
705
  const { id } = params;
654
706
  return this.httpClient.post(`/transactions/${id}/retry`, {}, options);
@@ -665,6 +717,7 @@ var GeneratedResources = class {
665
717
  this.featureAccess = new FeatureAccessResource(http);
666
718
  this.features = new FeaturesResource(http);
667
719
  this.invoices = new InvoicesResource(http);
720
+ this.payments = new PaymentsResource(http);
668
721
  this.payouts = new PayoutsResource(http);
669
722
  this.planGroups = new PlanGroupsResource(http);
670
723
  this.plans = new PlansResource(http);
@@ -810,7 +863,7 @@ var CommetValidationError = class extends CommetError {
810
863
 
811
864
  // src/version.ts
812
865
  var API_VERSION = "2026-06-10";
813
- var SDK_VERSION = "7.0.0";
866
+ var SDK_VERSION = "7.2.0";
814
867
 
815
868
  // src/utils/telemetry.ts
816
869
  var registeredIntegrations = /* @__PURE__ */ new Set();
@@ -894,6 +947,7 @@ var DEFAULT_RETRY_CONFIG = {
894
947
  // 8s
895
948
  retryableStatusCodes: [408, 429, 500, 502, 503, 504]
896
949
  };
950
+ var RETRY_AFTER_CAP_MS = 3e4;
897
951
  var _CommetHTTPClient = class _CommetHTTPClient {
898
952
  constructor(config) {
899
953
  this.lastRequestMetrics = null;
@@ -1005,17 +1059,16 @@ var _CommetHTTPClient = class _CommetHTTPClient {
1005
1059
  }
1006
1060
  if (!response.ok) {
1007
1061
  if (attempt <= this.retryConfig.maxRetries && this.retryConfig.retryableStatusCodes.includes(response.status)) {
1008
- const delay = Math.min(
1009
- this.retryConfig.baseDelay * 2 ** (attempt - 1),
1010
- this.retryConfig.maxDelay
1011
- );
1012
- if (this.config.debug) {
1013
- console.log(
1014
- `[Commet SDK] Retrying in ${delay}ms (attempt ${attempt}/${this.retryConfig.maxRetries})`
1015
- );
1062
+ const delay = this.retryDelayMs(attempt, response);
1063
+ if (delay !== null) {
1064
+ if (this.config.debug) {
1065
+ console.log(
1066
+ `[Commet SDK] Retrying in ${delay}ms (attempt ${attempt}/${this.retryConfig.maxRetries})`
1067
+ );
1068
+ }
1069
+ await this.sleep(delay);
1070
+ return this.executeRequest(method, url, data, options, attempt + 1);
1016
1071
  }
1017
- await this.sleep(delay);
1018
- return this.executeRequest(method, url, data, options, attempt + 1);
1019
1072
  }
1020
1073
  if (this.config.debug) {
1021
1074
  console.log(
@@ -1065,10 +1118,7 @@ var _CommetHTTPClient = class _CommetHTTPClient {
1065
1118
  const isTimeoutErrorModern = typeof globalThis.DOMException !== "undefined" && error instanceof DOMException && error.name === "TimeoutError";
1066
1119
  if (isNetworkError || isTimeoutError || isTimeoutErrorModern) {
1067
1120
  if (attempt <= this.retryConfig.maxRetries) {
1068
- const delay = Math.min(
1069
- this.retryConfig.baseDelay * 2 ** (attempt - 1),
1070
- this.retryConfig.maxDelay
1071
- );
1121
+ const delay = this.backoffDelayMs(attempt);
1072
1122
  if (this.config.debug) {
1073
1123
  console.log(`[Commet SDK] Network error, retrying in ${delay}ms`);
1074
1124
  }
@@ -1104,6 +1154,26 @@ var _CommetHTTPClient = class _CommetHTTPClient {
1104
1154
  }
1105
1155
  return finalUrl;
1106
1156
  }
1157
+ // 429 retries wait exactly what the rate limiter reports in Retry-After
1158
+ // (seconds until the window resets); a 429 without the header did not come
1159
+ // from the rate limiter, so it is not retried (returns null). Exponential
1160
+ // backoff only applies to statuses that carry no server-provided wait.
1161
+ retryDelayMs(attempt, response) {
1162
+ if (response.status === 429) {
1163
+ const retryAfterSeconds = Number(response.headers.get("retry-after"));
1164
+ if (Number.isFinite(retryAfterSeconds) && retryAfterSeconds > 0) {
1165
+ return Math.min(retryAfterSeconds * 1e3, RETRY_AFTER_CAP_MS);
1166
+ }
1167
+ return null;
1168
+ }
1169
+ return this.backoffDelayMs(attempt);
1170
+ }
1171
+ backoffDelayMs(attempt) {
1172
+ return Math.min(
1173
+ this.retryConfig.baseDelay * 2 ** (attempt - 1),
1174
+ this.retryConfig.maxDelay
1175
+ );
1176
+ }
1107
1177
  generateIdempotencyKey() {
1108
1178
  return `commet-node-retry-${crypto.randomUUID()}`;
1109
1179
  }