@commet/node 9.9.0 → 9.10.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 (50) hide show
  1. package/dist/index.d.mts +813 -15
  2. package/dist/index.d.ts +813 -15
  3. package/dist/index.js +199 -6
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +199 -6
  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/generated-webhooks.md +2 -2
  11. package/docs/api-reference/index.md +3 -3
  12. package/docs/api-reference/plans.md +483 -6
  13. package/docs/api-reference/subscriptions.md +43 -3
  14. package/docs/documentation/api-versioning.md +8 -2
  15. package/docs/documentation/cli.md +4 -0
  16. package/docs/documentation/customers/customer-portal.md +2 -2
  17. package/docs/documentation/plans/add-ons.md +14 -3
  18. package/docs/documentation/plans/consumption-models.md +3 -3
  19. package/docs/documentation/plans/create-plans.md +5 -1
  20. package/docs/documentation/plans/credit-packs.md +19 -9
  21. package/docs/documentation/plans/plan-groups.md +1 -1
  22. package/docs/documentation/plans/plan-versions.md +265 -0
  23. package/docs/documentation/sales/regional-prices.md +23 -9
  24. package/docs/documentation/sales/trial-periods.md +3 -3
  25. package/docs/documentation/subscriptions/manage-subscriptions.md +50 -13
  26. package/docs/documentation/subscriptions/upgrade-and-downgrade-plans.md +2 -0
  27. package/docs/errors/addon_has_activations.md +2 -2
  28. package/docs/errors/addon_unavailable.md +22 -0
  29. package/docs/errors/credit_pack_unavailable.md +22 -0
  30. package/docs/errors/index.md +8 -2
  31. package/docs/errors/missing_regional_price.md +3 -3
  32. package/docs/errors/plan_experiment_not_found.md +22 -0
  33. package/docs/errors/plan_version_not_found.md +22 -0
  34. package/docs/errors/subscribers_do_not_fit.md +22 -0
  35. package/docs/errors/version_not_newer.md +22 -0
  36. package/docs/knowledge-base/how-do-free-plans-work-without-payment.md +4 -3
  37. package/docs/knowledge-base/how-do-trial-periods-work.md +3 -3
  38. package/docs/knowledge-base/how-does-billing-work.md +26 -28
  39. package/docs/knowledge-base/how-does-quota-based-billing-work.md +12 -22
  40. package/docs/knowledge-base/how-does-seat-based-billing-work.md +12 -22
  41. package/docs/knowledge-base/what-happens-when-a-customer-changes-plans.md +11 -8
  42. package/docs/knowledge-base/what-happens-when-you-change-your-prices.md +34 -29
  43. package/docs/knowledge-base/what-invoices-do-customers-receive-and-when.md +1 -1
  44. package/docs/manifest.json +191 -2
  45. package/docs/platform-documentation.md +1 -0
  46. package/docs/schemas.md +107 -0
  47. package/docs/webhooks/introduction.md +3 -1
  48. package/docs/webhooks.md +24 -0
  49. package/docs/webhooks.openapi.json +231 -1
  50. package/package.json +1 -1
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/resources/addons.ts","../src/resources/api-keys.ts","../src/resources/credit-packs.ts","../src/resources/customers.ts","../src/resources/feature-access.ts","../src/resources/features.ts","../src/resources/invoices.ts","../src/resources/markets.ts","../src/resources/offers.ts","../src/resources/payments.ts","../src/resources/payouts.ts","../src/resources/plan-groups.ts","../src/resources/plans.ts","../src/resources/portal.ts","../src/resources/promo-codes.ts","../src/resources/provisioning.ts","../src/resources/quota.ts","../src/resources/seats.ts","../src/resources/subscriptions.ts","../src/resources/test-clock.ts","../src/resources/transactions.ts","../src/resources/usage.ts","../src/_generated_resources.ts","../src/resources/webhooks.ts","../src/resources/generated-webhooks.ts","../src/types/common.ts","../src/version.ts","../src/utils/telemetry.ts","../src/utils/http.ts","../src/utils/update-check.ts","../src/client.ts","../src/types/config.ts"],"sourcesContent":["export { Commet, createCommet } from \"./client\";\nexport type {\n CreateAddonParams,\n DeleteAddonParams,\n GetAddonParams,\n ListActiveAddonsParams,\n ListAddonsParams,\n UpdateAddonParams,\n} from \"./resources/addons\";\nexport type {\n CreateApiKeyParams,\n DeleteApiKeyParams,\n ListApiKeysParams,\n} from \"./resources/api-keys\";\nexport type {\n CreateCreditPackParams,\n DeleteCreditPackParams,\n UpdateCreditPackParams,\n} from \"./resources/credit-packs\";\nexport type {\n BatchCreateCustomersParams,\n CreateCustomerCreditParams,\n CreateCustomerParams,\n CreatePlanGrantParams,\n GetCustomerParams,\n ListCustomerCreditsParams,\n ListCustomersParams,\n ListPlanGrantsParams,\n RevokeCustomerCreditParams,\n RevokePlanGrantParams,\n UpdateCustomerParams,\n UpdatePlanGrantParams,\n} from \"./resources/customers\";\nexport type {\n GetFeatureAccessParams,\n ListFeatureAccessParams,\n} from \"./resources/feature-access\";\nexport type {\n CreateFeatureParams,\n DeleteFeatureParams,\n GetFeatureParams,\n UpdateFeatureParams,\n} from \"./resources/features\";\nexport type {\n CreateWebhookEndpointParams,\n DeleteWebhookEndpointParams,\n GetWebhookEndpointParams,\n ListWebhookEndpointsParams,\n TestWebhookEndpointParams,\n UpdateWebhookEndpointParams,\n} from \"./resources/generated-webhooks\";\nexport type {\n CreateAdjustmentInvoiceParams,\n DownloadInvoiceParams,\n GetInvoiceParams,\n ListInvoicesParams,\n SendInvoiceParams,\n UpdateInvoiceStatusParams,\n} from \"./resources/invoices\";\nexport type {\n CreateMarketParams,\n DeleteMarketParams,\n GetMarketParams,\n UpdateMarketParams,\n} from \"./resources/markets\";\nexport type {\n CreateOfferParams,\n DeleteOfferParams,\n GetOfferParams,\n ListOffersParams,\n UpdateOfferParams,\n} from \"./resources/offers\";\nexport type {\n CancelPaymentParams,\n ChargePaymentParams,\n CreatePaymentParams,\n GetPaymentParams,\n ListPaymentsParams,\n} from \"./resources/payments\";\nexport type {\n AddPayoutBankAccountParams,\n RequestPayoutParams,\n} from \"./resources/payouts\";\nexport type {\n AddPlanToGroupParams,\n CreatePlanGroupParams,\n DeletePlanGroupParams,\n GetPlanGroupParams,\n ListPlanGroupsParams,\n RemovePlanFromGroupParams,\n ReorderPlansInGroupParams,\n UpdatePlanGroupParams,\n} from \"./resources/plan-groups\";\nexport type {\n AddPlanFeatureParams,\n AddPlanPriceParams,\n CreatePlanParams,\n DeletePlanParams,\n DeletePlanPriceParams,\n DeleteRegionalPricesParams,\n GetPlanParams,\n ListPlansParams,\n RemovePlanFeatureParams,\n SetDefaultPlanPriceParams,\n SetPlanRegionalPricingParams,\n SetPlanVisibilityParams,\n UpdatePlanFeatureParams,\n UpdatePlanParams,\n UpdatePlanPriceParams,\n UpsertRegionalPricesParams,\n} from \"./resources/plans\";\nexport type { RequestPortalAccessParams } from \"./resources/portal\";\nexport type {\n CreatePromoCodeParams,\n GetPromoCodeParams,\n ListPromoCodesParams,\n UpdatePromoCodeParams,\n} from \"./resources/promo-codes\";\nexport type {\n AddQuotaParams,\n GetAllQuotaAllowancesParams,\n GetQuotaAllowanceParams,\n RemoveQuotaParams,\n SetQuotaParams,\n} from \"./resources/quota\";\nexport type {\n AddSeatsParams,\n BulkSetSeatsParams,\n GetAllSeatBalancesParams,\n GetSeatBalanceParams,\n RemoveSeatsParams,\n SetSeatsParams,\n} from \"./resources/seats\";\nexport type {\n ActivateAddonParams,\n AdjustBalanceParams,\n ApplySubscriptionOfferParams,\n CancelSubscriptionParams,\n ChangePlanParams,\n CreatePrepaidPeriodsCheckoutParams,\n CreateSubscriptionParams,\n CreateSubscriptionRecoveryLinkParams,\n DeactivateAddonParams,\n GetActiveSubscriptionParams,\n GetSubscriptionAutoTopUpParams,\n GetSubscriptionParams,\n ListSubscriptionsParams,\n PauseSubscriptionParams,\n PreviewChangePlanParams,\n PurchaseCreditsParams,\n ReactivateSubscriptionParams,\n RemoveSubscriptionOfferParams,\n ResumeSubscriptionParams,\n RevokeScheduledPlanChangeParams,\n RevokeSubscriptionPauseParams,\n TopupBalanceParams,\n UncancelSubscriptionParams,\n UpdatePaymentMethodParams,\n UpdateSubscriptionAutoTopUpParams,\n UpdateSubscriptionPauseParams,\n} from \"./resources/subscriptions\";\nexport type { AdvanceTestClockParams } from \"./resources/test-clock\";\nexport type {\n GetTransactionParams,\n ListTransactionsParams,\n RefundTransactionParams,\n RetryTransactionParams,\n} from \"./resources/transactions\";\nexport type {\n CheckUsageAvailabilityParams,\n SetUsageParams,\n TrackUsageParams,\n} from \"./resources/usage\";\nexport type {\n WebhookData,\n WebhookEventHandler,\n WebhookPayload,\n} from \"./resources/webhooks\";\nexport { Webhooks } from \"./resources/webhooks\";\nexport type {\n ApiErrorDetail,\n CommetClientOptions,\n CommetErrorContext,\n RequestOptions,\n ResolvedFeatureCode,\n ResolvedPlanCode,\n ResolvedSeatCode,\n ResolvedUsageCode,\n} from \"./types/common\";\nexport {\n CommetAPIError,\n CommetError,\n CommetValidationError,\n} from \"./types/common\";\nexport type {\n BillingConfig,\n FeatureDef,\n InferFeatureCodes,\n InferPlanCodes,\n InferSeatCodes,\n InferUsageCodes,\n PlanDef,\n PlanFeatureValue,\n PriceDef,\n} from \"./types/config\";\nexport { defineConfig } from \"./types/config\";\nexport type {\n BillingInterval,\n ConsumptionModel,\n FeatureType,\n InvoiceType,\n PaymentMethod,\n PaymentProvider,\n SubPaymentMethod,\n SubscriptionStatus,\n Timezone,\n TransactionStatus,\n} from \"./types/enums\";\nexport type {\n ActiveAddon,\n AddedPlanToGroup,\n Addon,\n ApiKey,\n BalanceAdjustment,\n BalanceTopup,\n BusinessTaxId,\n ClaimLink,\n CreatedApiKey,\n CreatedSubscription,\n CreatedWebhook,\n CreditGrant,\n CreditPack,\n CreditPackListItem,\n Customer,\n CustomerBatch,\n CustomerCredit,\n CustomerCreditRevocation,\n DeletedObject,\n DeletedOffer,\n DeletedPlanRegionalPricing,\n DeletedSubscriptionAddon,\n Feature,\n FeatureAccess,\n Invoice,\n InvoiceDownload,\n InvoiceListItem,\n ManagedBy,\n Market,\n Offer,\n Payment,\n PaymentMethodUpdateCheckout,\n Payout,\n PayoutBankAccount,\n Plan,\n PlanChange,\n PlanFeature,\n PlanGrant,\n PlanGroup,\n PlanGroupDetail,\n PlanPrice,\n PlanRegionalPricing,\n PlanRegionalPricingResult,\n PortalAccess,\n PrepaidPeriodsCheckout,\n PreviewChange,\n PromoCode,\n ReactivatedSubscription,\n RecoveryLink,\n Refund,\n RemovedPlanFeature,\n RemovedPlanFromGroup,\n ReorderedPlans,\n SeatBalance,\n SeatBalanceCollection,\n SeatEvent,\n SentInvoice,\n Subscription,\n SubscriptionAddon,\n SubscriptionAutoTopUp,\n SubscriptionOfferApplication,\n SubscriptionOfferApplicationPhase,\n SubscriptionResume,\n SubscriptionSummary,\n TestClock,\n TestClockRun,\n Transaction,\n TransactionListItem,\n TransactionRetry,\n UsageAdjustment,\n UsageCheck,\n UsageEvent,\n UsageQuota,\n UsageQuotaEvent,\n Webhook,\n WebhookAddonRef,\n WebhookBalance,\n WebhookBankRef,\n WebhookCardInfo,\n WebhookCreditsBalance,\n WebhookPlanGrantTimelineEvent,\n WebhookPlanRef,\n WebhookSeatSummary,\n WebhookTest,\n} from \"./types/models\";\nexport type * from \"./types/webhook-events\";\nexport { registerIntegration } from \"./utils/telemetry\";\nexport { API_VERSION, SDK_VERSION } from \"./version\";\n\nimport { Commet } from \"./client\";\nexport default Commet;\n","import type { RequestOptions } from \"../types/common\";\nimport type { ActiveAddon, Addon, DeletedObject } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface ListActiveAddonsParams {\n customerId: string;\n}\n\nexport interface GetAddonParams {\n id: string;\n}\n\nexport interface UpdateAddonParams {\n id: string;\n name?: string;\n description?: string;\n basePrice?: number;\n includedUnits?: number;\n overageRate?: number;\n}\n\nexport interface DeleteAddonParams {\n id: string;\n}\n\nexport interface ListAddonsParams {\n cursor?: string;\n limit?: number;\n}\n\nexport type CreateAddonParams =\n | {\n name: string;\n description?: string;\n basePrice: number;\n featureId: string;\n consumptionModel: \"boolean\";\n }\n | {\n name: string;\n description?: string;\n basePrice: number;\n featureId: string;\n consumptionModel: \"metered\";\n includedUnits: number;\n overageRate: number;\n }\n | {\n name: string;\n description?: string;\n basePrice: number;\n featureId: string;\n consumptionModel: \"credits\";\n creditCost: number;\n }\n | {\n name: string;\n description?: string;\n basePrice: number;\n featureId: string;\n consumptionModel: \"balance\";\n overageRate: number;\n };\n\nexport class AddonsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** List all active add-ons for a customer's subscription. */\n async listActive(\n params: ListActiveAddonsParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<ActiveAddon>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/active-addons\", params, options);\n }\n\n /** Retrieve an add-on by its public ID or slug. */\n async get(params: GetAddonParams, options?: RequestOptions): Promise<Addon> {\n const { id } = params;\n return this.httpClient.get(`/addons/${id}`, undefined, options);\n }\n\n /** Update an add-on's name, description, or pricing. */\n async update(\n params: UpdateAddonParams,\n options?: RequestOptions,\n ): Promise<Addon> {\n const { id, ...rest } = params;\n return this.httpClient.patch(`/addons/${id}`, rest, options);\n }\n\n /** Soft-delete an add-on. Fails if the add-on has active subscriptions. */\n async delete(\n params: DeleteAddonParams,\n options?: RequestOptions,\n ): Promise<DeletedObject> {\n const { id } = params;\n return this.httpClient.delete(`/addons/${id}`, undefined, options);\n }\n\n /** List all add-ons with cursor-based pagination. */\n async list(\n params?: ListAddonsParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<Addon>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/addons\", params, options);\n }\n\n /** Create a new add-on linked to a feature. Each feature can only be assigned to one add-on. */\n async create(\n params: CreateAddonParams,\n options?: RequestOptions,\n ): Promise<Addon> {\n return this.httpClient.post(\"/addons\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { ApiKey, CreatedApiKey, DeletedObject } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface DeleteApiKeyParams {\n id: string;\n}\n\nexport interface ListApiKeysParams {\n cursor?: string;\n limit?: number;\n}\n\nexport interface CreateApiKeyParams {\n name: string;\n expiresInDays?: number;\n permissions?: {\n customer?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n subscription?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n invoice?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n usage?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n seat?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n plan?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n plan_group?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n feature?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n addon?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n credit_pack?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n offer?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n promo_code?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n market_group?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n payment?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n transaction?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n payout?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n test_clock?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n organization?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n api_key?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n };\n}\n\nexport class ApiKeysResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Permanently revoke and delete an API key. */\n async delete(\n params: DeleteApiKeyParams,\n options?: RequestOptions,\n ): Promise<DeletedObject> {\n const { id } = params;\n return this.httpClient.delete(`/api-keys/${id}`, undefined, options);\n }\n\n /** List API keys with cursor-based pagination. Keys are returned without the full secret. */\n async list(\n params?: ListApiKeysParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<ApiKey>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/api-keys\", params, options);\n }\n\n /** Create a full-access or restricted API key. Provide permissions to restrict access; the full key is returned only once. A restricted key with api_key: write may only create restricted keys with the same or fewer permissions, and they expire no later than the key that creates them. */\n async create(\n params: CreateApiKeyParams,\n options?: RequestOptions,\n ): Promise<CreatedApiKey> {\n return this.httpClient.post(\"/api-keys\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type {\n CreditPack,\n CreditPackListItem,\n DeletedObject,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface UpdateCreditPackParams {\n id: string;\n name?: string;\n description?: string;\n credits?: number;\n price?: number;\n isActive?: boolean;\n}\n\nexport interface DeleteCreditPackParams {\n id: string;\n}\n\nexport interface CreateCreditPackParams {\n name: string;\n description?: string;\n credits: number;\n price: number;\n isActive?: boolean;\n}\n\nexport class CreditPacksResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Update a credit pack's name, description, credits, price, or active status. */\n async update(\n params: UpdateCreditPackParams,\n options?: RequestOptions,\n ): Promise<CreditPack> {\n const { id, ...rest } = params;\n return this.httpClient.patch(`/credit-packs/${id}`, rest, options);\n }\n\n /** Soft-delete a credit pack. */\n async delete(\n params: DeleteCreditPackParams,\n options?: RequestOptions,\n ): Promise<DeletedObject> {\n const { id } = params;\n return this.httpClient.delete(`/credit-packs/${id}`, undefined, options);\n }\n\n /** List all active credit packs. */\n async list(): Promise<{\n object: \"list\";\n data: Array<CreditPackListItem>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/credit-packs\");\n }\n\n /** Create a new credit pack. */\n async create(\n params: CreateCreditPackParams,\n options?: RequestOptions,\n ): Promise<CreditPack> {\n return this.httpClient.post(\"/credit-packs\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { Timezone } from \"../types/enums\";\nimport type {\n Customer,\n CustomerBatch,\n CustomerCredit,\n CustomerCreditRevocation,\n PlanGrant,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface RevokeCustomerCreditParams {\n id: string;\n creditId: string;\n}\n\nexport interface ListCustomerCreditsParams {\n id: string;\n}\n\nexport interface CreateCustomerCreditParams {\n id: string;\n /** Amount in the currency's smallest unit. */\n amount: number;\n currency:\n | \"usd\"\n | \"ars\"\n | \"brl\"\n | \"clp\"\n | \"cop\"\n | \"pen\"\n | \"uyu\"\n | \"pyg\"\n | \"bob\"\n | \"mxn\"\n | \"cad\"\n | \"eur\"\n | \"gbp\"\n | \"jpy\"\n | \"cny\"\n | \"krw\"\n | \"hkd\"\n | \"sgd\"\n | \"twd\"\n | \"inr\"\n | \"thb\";\n reason: string;\n expiresAt?: string | null;\n}\n\nexport interface RevokePlanGrantParams {\n id: string;\n grantId: string;\n reason: string;\n}\n\nexport type UpdatePlanGrantParams =\n | {\n id: string;\n grantId: string;\n reason: string;\n duration: \"cycles\";\n durationCycles: number;\n }\n | {\n id: string;\n grantId: string;\n reason: string;\n duration: \"until_date\";\n /** @format date-time */\n expiresAt: string;\n }\n | {\n id: string;\n grantId: string;\n reason: string;\n duration: \"until_revoked\";\n };\n\nexport interface ListPlanGrantsParams {\n id: string;\n}\n\nexport type CreatePlanGrantParams =\n | {\n id: string;\n subscriptionId: string;\n planId: string;\n reason: string;\n duration: \"cycles\";\n durationCycles: number;\n }\n | {\n id: string;\n subscriptionId: string;\n planId: string;\n reason: string;\n duration: \"until_date\";\n /** @format date-time */\n expiresAt: string;\n }\n | {\n id: string;\n subscriptionId: string;\n planId: string;\n reason: string;\n duration: \"until_revoked\";\n };\n\nexport interface GetCustomerParams {\n id: string;\n}\n\nexport interface UpdateCustomerParams {\n id: string;\n email?: string;\n fullName?: string;\n taxDocument?: string;\n /** Business tax ID, such as an EU VAT number or a Peruvian RUC, for the country of the customer's address. Accepted only where Commet collects tax; a valid ID replaces consumer tax with the business treatment. Send null to remove it. */\n businessTaxId?: string | null;\n externalId?: string;\n timezone?: Timezone;\n metadata?: Record<string, unknown>;\n address?: {\n line1: string;\n line2?: string;\n city: string;\n state?: string;\n postalCode: string;\n country: string;\n region?: string;\n };\n}\n\nexport interface BatchCreateCustomersParams {\n customers: Array<{\n email: string;\n id?: string;\n externalId?: string;\n fullName?: string;\n taxDocument?: string;\n timezone?: Timezone;\n metadata?: Record<string, unknown>;\n address?: {\n line1: string;\n line2?: string;\n city: string;\n state?: string;\n postalCode: string;\n country: string;\n region?: string;\n };\n }>;\n /** Plan group whose starting plan the customer starts on when it has no open subscription: its signup trial, a trial without a payment method, when the group has one and the customer never had that plan, otherwise its default plan. A customer who already had the signup trial plan in a group without a default plan starts on none. Without it, no plan is assigned. */\n planGroupId?: string;\n}\n\nexport interface ListCustomersParams {\n cursor?: string;\n limit?: number;\n externalId?: string;\n}\n\nexport interface CreateCustomerParams {\n id?: string;\n externalId?: string;\n fullName?: string;\n taxDocument?: string;\n /** Business tax ID, such as an EU VAT number or a Peruvian RUC, for the country of the customer's address. Accepted only where Commet collects tax; a valid ID replaces consumer tax with the business treatment. */\n businessTaxId?: string;\n address?: {\n line1: string;\n line2?: string;\n city: string;\n state?: string;\n postalCode: string;\n country: string;\n region?: string;\n };\n addressId?: string;\n email: string;\n timezone?: Timezone;\n metadata?: Record<string, unknown>;\n /** Plan group whose starting plan the customer starts on when it has no open subscription: its signup trial, a trial without a payment method, when the group has one and the customer never had that plan, otherwise its default plan. A customer who already had the signup trial plan in a group without a default plan starts on none. Without it, no plan is assigned. */\n planGroupId?: string;\n}\n\nexport class CustomersResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Revoke the unallocated remainder of a customer credit grant. Applied invoice history is unchanged. */\n async revokeCredit(\n params: RevokeCustomerCreditParams,\n options?: RequestOptions,\n ): Promise<CustomerCreditRevocation> {\n const { id, creditId } = params;\n return this.httpClient.post(\n `/customers/${id}/credits/${creditId}/revoke`,\n {},\n options,\n );\n }\n\n /** List currency-specific invoice credit grants and their remaining balances for a customer. */\n async listCredits(\n params: ListCustomerCreditsParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<CustomerCredit>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n const { id } = params;\n return this.httpClient.get(`/customers/${id}/credits`, undefined, options);\n }\n\n /** Grant monetary credit in one currency. Credit is applied FIFO before tax to eligible recurring invoices. */\n async createCredit(\n params: CreateCustomerCreditParams,\n options?: RequestOptions,\n ): Promise<CustomerCredit> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/customers/${id}/credits`, rest, options);\n }\n\n /** End expanded access immediately and restore the base plan's limits. The subscription, billing cycle, invoices, and payment state remain unchanged. */\n async revokePlanGrant(\n params: RevokePlanGrantParams,\n options?: RequestOptions,\n ): Promise<PlanGrant> {\n const { id, grantId, ...rest } = params;\n return this.httpClient.post(\n `/customers/${id}/plan-grants/${grantId}/revoke`,\n rest,\n options,\n );\n }\n\n /** Keep the overlay for a number of the subscription's existing billing cycles, set an exact deadline, or leave it active until revoked. The billing anchor is never reset. */\n async updatePlanGrant(\n params: UpdatePlanGrantParams,\n options?: RequestOptions,\n ): Promise<PlanGrant> {\n const { id, grantId, ...rest } = params;\n return this.httpClient.patch(\n `/customers/${id}/plan-grants/${grantId}`,\n rest,\n options,\n );\n }\n\n /** List the independent audit timeline for paid-plan access granted without checkout or payment credentials. */\n async listPlanGrants(\n params: ListPlanGrantsParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<PlanGrant>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n const { id } = params;\n return this.httpClient.get(\n `/customers/${id}/plan-grants`,\n undefined,\n options,\n );\n }\n\n /** Temporarily expand an active subscription's feature access using a higher plan in the same plan group. Billing, prices, periods, invoices, and the base subscription remain unchanged. */\n async createPlanGrant(\n params: CreatePlanGrantParams,\n options?: RequestOptions,\n ): Promise<PlanGrant> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/customers/${id}/plan-grants`, rest, options);\n }\n\n /** Retrieve a customer by their public ID, including subscription status and metadata. */\n async get(\n params: GetCustomerParams,\n options?: RequestOptions,\n ): Promise<Customer> {\n const { id } = params;\n return this.httpClient.get(`/customers/${id}`, undefined, options);\n }\n\n /** Update a customer's name, external ID, or metadata. */\n async update(\n params: UpdateCustomerParams,\n options?: RequestOptions,\n ): Promise<Customer> {\n const { id, ...rest } = params;\n return this.httpClient.patch(`/customers/${id}`, rest, options);\n }\n\n /** Create up to 100 customers in a single request. With planGroupId, each customer without an open subscription starts on that group's starting plan (see planGroupId), and the entry of a deleted customer fails with customer_deleted. */\n async createBatch(\n params: BatchCreateCustomersParams,\n options?: RequestOptions,\n ): Promise<CustomerBatch> {\n return this.httpClient.post(\"/customers/batch\", params, options);\n }\n\n /** List customers with cursor-based pagination. */\n async list(\n params?: ListCustomersParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<Customer>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/customers\", params, options);\n }\n\n /** Create a new customer. Idempotent when customerId is provided. With planGroupId, a customer without an open subscription starts on that group's starting plan (see planGroupId), and the externalId of a deleted customer is rejected. */\n async create(\n params: CreateCustomerParams,\n options?: RequestOptions,\n ): Promise<Customer> {\n return this.httpClient.post(\"/customers\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { FeatureAccess } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface GetFeatureAccessParams {\n code: string;\n customerId: string;\n}\n\nexport interface ListFeatureAccessParams {\n customerId: string;\n}\n\nexport class FeatureAccessResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Get one feature's access and current usage for a customer. To evaluate a prospective consumption, use POST /usage/check. */\n async get(\n params: GetFeatureAccessParams,\n options?: RequestOptions,\n ): Promise<FeatureAccess> {\n const { code, ...rest } = params;\n return this.httpClient.get(`/feature-access/${code}`, rest, options);\n }\n\n /** List a customer's feature access and current usage. */\n async list(\n params: ListFeatureAccessParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<FeatureAccess>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/feature-access\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { DeletedObject, Feature } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface GetFeatureParams {\n code: string;\n}\n\nexport interface UpdateFeatureParams {\n code: string;\n name?: string;\n description?: string | null;\n unitName?: string | null;\n}\n\nexport interface DeleteFeatureParams {\n code: string;\n}\n\nexport interface CreateFeatureParams {\n name: string;\n code: string;\n type: \"boolean\" | \"usage\" | \"seats\" | \"quota\";\n description?: string;\n unitName?: string;\n}\n\nexport class FeaturesResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Get a single feature definition by code from the organization's feature catalog. */\n async get(\n params: GetFeatureParams,\n options?: RequestOptions,\n ): Promise<Feature> {\n const { code } = params;\n return this.httpClient.get(`/features/${code}`, undefined, options);\n }\n\n /** Update a feature's name, description, or unit name. At least one field must be provided. */\n async update(\n params: UpdateFeatureParams,\n options?: RequestOptions,\n ): Promise<Feature> {\n const { code, ...rest } = params;\n return this.httpClient.patch(`/features/${code}`, rest, options);\n }\n\n /** Delete a feature. Fails if the feature is attached to active plans or has an active add-on. */\n async delete(\n params: DeleteFeatureParams,\n options?: RequestOptions,\n ): Promise<DeletedObject> {\n const { code } = params;\n return this.httpClient.delete(`/features/${code}`, undefined, options);\n }\n\n /** List every feature defined in the organization. This is the organization's feature catalog (definitions), not a customer's feature access. */\n async list(): Promise<{\n object: \"list\";\n data: Array<Feature>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/features\");\n }\n\n /** Create a new feature. Code must be lowercase alphanumeric with underscores. */\n async create(\n params: CreateFeatureParams,\n options?: RequestOptions,\n ): Promise<Feature> {\n return this.httpClient.post(\"/features\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type {\n Invoice,\n InvoiceDownload,\n InvoiceListItem,\n SentInvoice,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface DownloadInvoiceParams {\n id: string;\n}\n\nexport interface GetInvoiceParams {\n id: string;\n}\n\nexport interface SendInvoiceParams {\n id: string;\n}\n\nexport interface UpdateInvoiceStatusParams {\n id: string;\n status: \"paid\" | \"void\";\n}\n\nexport interface ListInvoicesParams {\n cursor?: string;\n limit?: number;\n customerId?: string;\n status?: \"draft\" | \"outstanding\" | \"paid\" | \"void\" | \"uncollectible\";\n subscriptionId?: string;\n}\n\nexport interface CreateAdjustmentInvoiceParams {\n customerId: string;\n amount: number;\n description: string;\n metadata?: Record<string, unknown>;\n}\n\nexport class InvoicesResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Generate a signed URL to download the invoice as a PDF. The URL expires after 7 days. */\n async getDownloadUrl(\n params: DownloadInvoiceParams,\n options?: RequestOptions,\n ): Promise<InvoiceDownload> {\n const { id } = params;\n return this.httpClient.post(`/invoices/${id}/download-links`, {}, options);\n }\n\n /** Retrieve a single invoice by its public ID, including line items. */\n async get(\n params: GetInvoiceParams,\n options?: RequestOptions,\n ): Promise<Invoice> {\n const { id } = params;\n return this.httpClient.get(`/invoices/${id}`, undefined, options);\n }\n\n /** Send the invoice to the customer via email. */\n async send(\n params: SendInvoiceParams,\n options?: RequestOptions,\n ): Promise<SentInvoice> {\n const { id } = params;\n return this.httpClient.post(`/invoices/${id}/send`, {}, options);\n }\n\n /** Mark an outstanding invoice as \"paid\" or \"void\" and return the updated invoice. Cannot change the status of already paid or voided invoices. */\n async updateStatus(\n params: UpdateInvoiceStatusParams,\n options?: RequestOptions,\n ): Promise<Invoice> {\n const { id, ...rest } = params;\n return this.httpClient.patch(`/invoices/${id}/status`, rest, options);\n }\n\n /** List invoices with cursor-based pagination. Filter by customer, status, or subscription. */\n async list(\n params?: ListInvoicesParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<InvoiceListItem>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/invoices\", params, options);\n }\n\n /** Create a one-off adjustment invoice and return the created invoice. Use a negative amount for a credit. */\n async createAdjustment(\n params: CreateAdjustmentInvoiceParams,\n options?: RequestOptions,\n ): Promise<Invoice> {\n return this.httpClient.post(\"/invoices\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { DeletedObject, Market } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface GetMarketParams {\n id: string;\n}\n\nexport interface UpdateMarketParams {\n id: string;\n name: string;\n countryCodes: Array<string>;\n metadata?: Record<string, unknown>;\n}\n\nexport interface DeleteMarketParams {\n id: string;\n}\n\nexport interface CreateMarketParams {\n name: string;\n countryCodes: Array<string>;\n metadata?: Record<string, unknown>;\n}\n\nexport class MarketsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Get one reusable market. */\n async get(\n params: GetMarketParams,\n options?: RequestOptions,\n ): Promise<Market> {\n const { id } = params;\n return this.httpClient.get(`/markets/${id}`, undefined, options);\n }\n\n /** Replace the name, countries, and metadata of a market. */\n async update(\n params: UpdateMarketParams,\n options?: RequestOptions,\n ): Promise<Market> {\n const { id, ...rest } = params;\n return this.httpClient.patch(`/markets/${id}`, rest, options);\n }\n\n /** Delete an unused market. Markets referenced by prices or subscriptions cannot be deleted. */\n async delete(\n params: DeleteMarketParams,\n options?: RequestOptions,\n ): Promise<DeletedObject> {\n const { id } = params;\n return this.httpClient.delete(`/markets/${id}`, undefined, options);\n }\n\n /** List reusable country groups that resolve market-specific prices independently from currency. */\n async list(): Promise<{\n object: \"list\";\n data: Array<Market>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/markets\");\n }\n\n /** Create a reusable market without attaching it to a plan or price. Countries can belong to only one active market. */\n async create(\n params: CreateMarketParams,\n options?: RequestOptions,\n ): Promise<Market> {\n return this.httpClient.post(\"/markets\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { DeletedOffer, Offer } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface GetOfferParams {\n id: string;\n}\n\nexport interface UpdateOfferParams {\n id: string;\n name: string;\n phases: Array<\n | {\n type: \"percentage\";\n durationCycles: number | null;\n /** Unit the phase duration is counted in. Only a fixed-price phase may set it, because its amount is declared rather than derived from the plan. Defaults to the plan's own billing interval. */\n durationInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | null;\n /** Discount in basis points. 5000 means 50%. */\n percentage: number;\n }\n | {\n type: \"amount_off\";\n durationCycles: number | null;\n /** Unit the phase duration is counted in. Only a fixed-price phase may set it, because its amount is declared rather than derived from the plan. Defaults to the plan's own billing interval. */\n durationInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | null;\n amounts: Array<{\n currency: string;\n /** Amount in the currency's minor unit (for example, cents for USD). */\n amount: number;\n }>;\n }\n | {\n type: \"fixed_price\";\n durationCycles: number | null;\n /** Unit the phase duration is counted in. Only a fixed-price phase may set it, because its amount is declared rather than derived from the plan. Defaults to the plan's own billing interval. */\n durationInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | null;\n prices: Array<{\n currency: string;\n /** Amount in the currency's minor unit (for example, cents for USD). */\n amount: number;\n }>;\n }\n >;\n metadata?: Record<string, unknown>;\n startsAt?: string | null;\n endsAt?: string | null;\n active?: boolean;\n}\n\nexport interface DeleteOfferParams {\n id: string;\n}\n\nexport interface ListOffersParams {\n cursor?: string;\n limit?: number;\n active?: boolean;\n}\n\nexport interface CreateOfferParams {\n name: string;\n phases: Array<\n | {\n type: \"percentage\";\n durationCycles: number | null;\n /** Unit the phase duration is counted in. Only a fixed-price phase may set it, because its amount is declared rather than derived from the plan. Defaults to the plan's own billing interval. */\n durationInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | null;\n /** Discount in basis points. 5000 means 50%. */\n percentage: number;\n }\n | {\n type: \"amount_off\";\n durationCycles: number | null;\n /** Unit the phase duration is counted in. Only a fixed-price phase may set it, because its amount is declared rather than derived from the plan. Defaults to the plan's own billing interval. */\n durationInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | null;\n amounts: Array<{\n currency: string;\n /** Amount in the currency's minor unit (for example, cents for USD). */\n amount: number;\n }>;\n }\n | {\n type: \"fixed_price\";\n durationCycles: number | null;\n /** Unit the phase duration is counted in. Only a fixed-price phase may set it, because its amount is declared rather than derived from the plan. Defaults to the plan's own billing interval. */\n durationInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | null;\n prices: Array<{\n currency: string;\n /** Amount in the currency's minor unit (for example, cents for USD). */\n amount: number;\n }>;\n }\n >;\n metadata?: Record<string, unknown>;\n startsAt?: string | null;\n endsAt?: string | null;\n active?: boolean;\n}\n\nexport class OffersResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Retrieve reusable offer terms by public ID. */\n async get(params: GetOfferParams, options?: RequestOptions): Promise<Offer> {\n const { id } = params;\n return this.httpClient.get(`/offers/${id}`, undefined, options);\n }\n\n /** Replace reusable offer terms. Existing applications keep their immutable accepted terms. */\n async update(\n params: UpdateOfferParams,\n options?: RequestOptions,\n ): Promise<Offer> {\n const { id, ...rest } = params;\n return this.httpClient.patch(`/offers/${id}`, rest, options);\n }\n\n /** Soft-delete an Offer. Existing applications and their accepted terms remain available for billing and audit. */\n async delete(\n params: DeleteOfferParams,\n options?: RequestOptions,\n ): Promise<DeletedOffer> {\n const { id } = params;\n return this.httpClient.delete(`/offers/${id}`, undefined, options);\n }\n\n /** List reusable offer terms. Offers are independent from plans, prices, eligibility, and distribution channels. */\n async list(\n params?: ListOffersParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<Offer>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/offers\", params, options);\n }\n\n /** Create reusable offer terms without assigning a plan, price, eligibility rule, or distribution channel. */\n async create(\n params: CreateOfferParams,\n options?: RequestOptions,\n ): Promise<Offer> {\n return this.httpClient.post(\"/offers\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { Payment } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface CancelPaymentParams {\n id: string;\n}\n\nexport interface GetPaymentParams {\n id: string;\n}\n\nexport interface ChargePaymentParams {\n customerId: string;\n amount: number;\n currency: string;\n description: string;\n metadata?: Record<string, string>;\n}\n\nexport interface ListPaymentsParams {\n cursor?: string;\n limit?: number;\n customerId?: string;\n}\n\nexport interface CreatePaymentParams {\n amount: number;\n currency: string;\n customerId?: string;\n description: string;\n successUrl?: string;\n metadata?: Record<string, string>;\n}\n\nexport class PaymentsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** 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. */\n async cancel(\n params: CancelPaymentParams,\n options?: RequestOptions,\n ): Promise<Payment> {\n const { id } = params;\n return this.httpClient.post(`/payments/${id}/cancel`, {}, options);\n }\n\n /** Retrieve a payment by its public ID. */\n async get(\n params: GetPaymentParams,\n options?: RequestOptions,\n ): Promise<Payment> {\n const { id } = params;\n return this.httpClient.get(`/payments/${id}`, undefined, options);\n }\n\n /** Charge a customer's vaulted payment method off-session. Calculates tax, generates an invoice, and sends a receipt. Requires the customer to have a subscription in active, trialing, or past_due state. */\n async charge(\n params: ChargePaymentParams,\n options?: RequestOptions,\n ): Promise<Payment> {\n return this.httpClient.post(\"/payments/charge\", params, options);\n }\n\n /** List payments with cursor-based pagination. Filter by customer. */\n async list(\n params?: ListPaymentsParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<Payment>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/payments\", params, options);\n }\n\n /** 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. */\n async create(\n params: CreatePaymentParams,\n options?: RequestOptions,\n ): Promise<Payment> {\n return this.httpClient.post(\"/payments\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { Payout, PayoutBankAccount } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface AddPayoutBankAccountParams {\n accountNumber: string;\n accountHolderName: string;\n routingNumber?: string;\n accountType?: \"checking\" | \"savings\";\n setDefault?: boolean;\n}\n\nexport interface RequestPayoutParams {\n amount: number;\n description?: string;\n}\n\nexport class PayoutsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Add an additional destination bank account to the organization's existing payout account. Country and currency are resolved from the organization. The full account number is never returned — only `last4`. */\n async addBankAccount(\n params: AddPayoutBankAccountParams,\n options?: RequestOptions,\n ): Promise<PayoutBankAccount> {\n return this.httpClient.post(\"/payouts/bank-accounts\", params, options);\n }\n\n /** Withdraw available balance to the organization's verified payout account. `amount` is in cents (USD, minimum 1000 = $10). The payout is created in `pending` and settles to `paid` asynchronously as provider webhooks arrive. */\n async request(\n params: RequestPayoutParams,\n options?: RequestOptions,\n ): Promise<Payout> {\n return this.httpClient.post(\"/payouts\", params, options);\n }\n\n /**\n * Deprecated. Complete business and identity verification in the Commet dashboard. This endpoint no longer accepts or processes KYC data.\n * @deprecated\n */\n async completeVerification(options?: RequestOptions): Promise<void> {\n return this.httpClient.post(\"/payouts/verification\", {}, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type {\n AddedPlanToGroup,\n DeletedObject,\n PlanGroup,\n PlanGroupDetail,\n RemovedPlanFromGroup,\n ReorderedPlans,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface RemovePlanFromGroupParams {\n id: string;\n planId: string;\n}\n\nexport interface ReorderPlansInGroupParams {\n id: string;\n planIds: Array<string>;\n}\n\nexport interface AddPlanToGroupParams {\n id: string;\n planId: string;\n sortOrder?: number;\n}\n\nexport interface GetPlanGroupParams {\n id: string;\n}\n\nexport interface UpdatePlanGroupParams {\n id: string;\n name?: string;\n description?: string | null;\n isPublic?: boolean;\n}\n\nexport interface DeletePlanGroupParams {\n id: string;\n}\n\nexport interface ListPlanGroupsParams {\n cursor?: string;\n limit?: number;\n}\n\nexport interface CreatePlanGroupParams {\n name: string;\n description?: string;\n isPublic?: boolean;\n}\n\nexport class PlanGroupsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Remove a plan from a plan group. */\n async removePlan(\n params: RemovePlanFromGroupParams,\n options?: RequestOptions,\n ): Promise<RemovedPlanFromGroup> {\n const { id, planId } = params;\n return this.httpClient.delete(\n `/plan-groups/${id}/plans/${planId}`,\n undefined,\n options,\n );\n }\n\n /** Set the display order of plans within a group. All plan IDs in the group must be provided. */\n async reorderPlans(\n params: ReorderPlansInGroupParams,\n options?: RequestOptions,\n ): Promise<ReorderedPlans> {\n const { id, ...rest } = params;\n return this.httpClient.put(\n `/plan-groups/${id}/plans/reorder`,\n rest,\n options,\n );\n }\n\n /** Add an existing plan to a plan group with optional sort order. */\n async addPlan(\n params: AddPlanToGroupParams,\n options?: RequestOptions,\n ): Promise<AddedPlanToGroup> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/plan-groups/${id}/plans`, rest, options);\n }\n\n /** Retrieve a plan group by ID, including its plans ordered by sortOrder. */\n async get(\n params: GetPlanGroupParams,\n options?: RequestOptions,\n ): Promise<PlanGroupDetail> {\n const { id } = params;\n return this.httpClient.get(`/plan-groups/${id}`, undefined, options);\n }\n\n /** Update a plan group's name, description, or visibility. */\n async update(\n params: UpdatePlanGroupParams,\n options?: RequestOptions,\n ): Promise<PlanGroup> {\n const { id, ...rest } = params;\n return this.httpClient.patch(`/plan-groups/${id}`, rest, options);\n }\n\n /** Delete a plan group. Plans in the group are unlinked, not deleted. */\n async delete(\n params: DeletePlanGroupParams,\n options?: RequestOptions,\n ): Promise<DeletedObject> {\n const { id } = params;\n return this.httpClient.delete(`/plan-groups/${id}`, undefined, options);\n }\n\n /** List plan groups with cursor-based pagination. */\n async list(\n params?: ListPlanGroupsParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<PlanGroup>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/plan-groups\", params, options);\n }\n\n /** Create a new plan group for organizing plans. */\n async create(\n params: CreatePlanGroupParams,\n options?: RequestOptions,\n ): Promise<PlanGroup> {\n return this.httpClient.post(\"/plan-groups\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type {\n DeletedObject,\n DeletedPlanRegionalPricing,\n Plan,\n PlanFeature,\n PlanPrice,\n PlanRegionalPricing,\n PlanRegionalPricingResult,\n RemovedPlanFeature,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface UpdatePlanFeatureParams {\n id: string;\n featureId: string;\n enabled?: boolean;\n includedAmount?: number;\n unlimited?: boolean;\n overage?: {\n enabled?: boolean;\n unitPrice?: number;\n };\n creditsPerUnit?: number | null;\n}\n\nexport interface RemovePlanFeatureParams {\n id: string;\n featureId: string;\n}\n\nexport interface AddPlanFeatureParams {\n id: string;\n featureId: string;\n enabled?: boolean;\n includedAmount?: number;\n unlimited?: boolean;\n overage?: {\n enabled?: boolean;\n unitPrice?: number;\n };\n creditsPerUnit?: number | null;\n pricingMode?: \"fixed\" | \"ai_model\";\n margin?: number | null;\n}\n\nexport interface SetDefaultPlanPriceParams {\n id: string;\n priceId: string;\n}\n\nexport interface UpsertRegionalPricesParams {\n id: string;\n priceId: string;\n overrides: Array<{\n currency: string;\n price: number;\n includedBalance?: number;\n }>;\n}\n\nexport interface DeleteRegionalPricesParams {\n id: string;\n priceId: string;\n}\n\nexport interface UpdatePlanPriceParams {\n id: string;\n priceId: string;\n price?: number;\n isDefault?: boolean;\n trialDays?: number;\n /** Set to false so the price's free trial starts without a payment method. Requires trialDays on the price. */\n trialRequiresPaymentMethod?: boolean;\n includedBalance?: number | null;\n includedCredits?: number | null;\n /** Metadata keys to merge into the existing price metadata. */\n metadata?: Record<string, unknown>;\n marketPrices?: Array<{\n marketGroupId: string;\n currency:\n | \"usd\"\n | \"ars\"\n | \"brl\"\n | \"clp\"\n | \"cop\"\n | \"pen\"\n | \"uyu\"\n | \"pyg\"\n | \"bob\"\n | \"mxn\"\n | \"cad\"\n | \"eur\"\n | \"gbp\"\n | \"jpy\"\n | \"cny\"\n | \"krw\"\n | \"hkd\"\n | \"sgd\"\n | \"twd\"\n | \"inr\"\n | \"thb\";\n price: number;\n }>;\n}\n\nexport interface DeletePlanPriceParams {\n id: string;\n priceId: string;\n}\n\nexport type AddPlanPriceParams =\n | {\n id: string;\n billingInterval:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\";\n metadata?: Record<string, unknown>;\n price: number;\n trialDays?: number;\n /** Set to false so the price's free trial starts without a payment method. Requires trialDays on the price. */\n trialRequiresPaymentMethod?: boolean;\n isDefault?: boolean;\n includedBalance?: number | null;\n includedCredits?: number | null;\n marketPrices?: Array<{\n /** Public ID of a reusable pricing market group. */\n marketGroupId: string;\n /** Presentment currency configured for this plan and market. */\n currency:\n | \"usd\"\n | \"ars\"\n | \"brl\"\n | \"clp\"\n | \"cop\"\n | \"pen\"\n | \"uyu\"\n | \"pyg\"\n | \"bob\"\n | \"mxn\"\n | \"cad\"\n | \"eur\"\n | \"gbp\"\n | \"jpy\"\n | \"cny\"\n | \"krw\"\n | \"hkd\"\n | \"sgd\"\n | \"twd\"\n | \"inr\"\n | \"thb\";\n /** Market price in the currency's minor unit. */\n price: number;\n }>;\n }\n | {\n id: string;\n billingInterval:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\";\n metadata?: Record<string, unknown>;\n inheritsFromPriceId: string;\n marketPrices: Array<{\n /** Public ID of a reusable pricing market group. */\n marketGroupId: string;\n /** Presentment currency configured for this plan and market. */\n currency:\n | \"usd\"\n | \"ars\"\n | \"brl\"\n | \"clp\"\n | \"cop\"\n | \"pen\"\n | \"uyu\"\n | \"pyg\"\n | \"bob\"\n | \"mxn\"\n | \"cad\"\n | \"eur\"\n | \"gbp\"\n | \"jpy\"\n | \"cny\"\n | \"krw\"\n | \"hkd\"\n | \"sgd\"\n | \"twd\"\n | \"inr\"\n | \"thb\";\n /** Market price in the currency's minor unit. */\n price: number;\n }>;\n };\n\nexport interface SetPlanRegionalPricingParams {\n id: string;\n currency:\n | \"usd\"\n | \"ars\"\n | \"brl\"\n | \"clp\"\n | \"cop\"\n | \"pen\"\n | \"uyu\"\n | \"pyg\"\n | \"bob\"\n | \"mxn\"\n | \"cad\"\n | \"eur\"\n | \"gbp\"\n | \"jpy\"\n | \"cny\"\n | \"krw\"\n | \"hkd\"\n | \"sgd\"\n | \"twd\"\n | \"inr\"\n | \"thb\";\n exchangeRate: number;\n prices?: Array<{\n priceId: string;\n price: number;\n includedBalance?: number;\n }>;\n features?: Array<{\n featureId: string;\n overageUnitPrice: number;\n }>;\n}\n\nexport interface GetPlanParams {\n id: string;\n}\n\nexport interface UpdatePlanParams {\n id: string;\n name?: string;\n description?: string | null;\n metadata?: Record<string, unknown>;\n isPublic?: boolean;\n /** Credits plans only. What happens to unused plan credits at each reset. Existing subscriptions apply it from their next reset. */\n unusedPlanCredits?:\n | {\n type: \"expire\";\n }\n | {\n type: \"roll_over\";\n /** The most plan credits a subscription holds after a reset, including the credits that reset grants; credits above it expire. At least the included credits of every price. null means no limit other than the largest storable balance, 2,147,483,647 plan credits. */\n maxPlanCredits: number | null;\n };\n /** Credits plans only. The most plan credits a subscription spends per day or per week; null removes the limit. Raising or removing it applies to existing subscriptions at once; lowering it, adding it or changing its interval applies from their next period. */\n planCreditLimit?: {\n /** The most plan credits a subscription spends in one window. */\n credits: number;\n /** The window length: `day` is 24 hours and `week` is 7 days, starting at the time of day of the subscription's billing anchor. */\n interval: \"day\" | \"week\";\n } | null;\n /** Balance plans only. What happens to unused plan balance at each reset. Existing subscriptions apply it from their next reset. */\n unusedPlanBalance?:\n | {\n type: \"expire\";\n }\n | {\n type: \"roll_over\";\n /** The most plan balance a subscription holds after a reset, in USD cents, including the balance that reset grants; balance above it expires. At least the included balance of every price. Other currencies convert it with the plan's exchange rate unless the dashboard sets a custom amount for that currency. null means no limit other than the largest storable amount, 2,147,483,647 cents. */\n maxPlanBalance: number | null;\n };\n /** Balance plans only. The most plan balance a subscription spends per day or per week, in USD cents; null removes the limit. Raising or removing it applies to existing subscriptions at once; lowering it, adding it or changing its interval applies from their next period. */\n planBalanceLimit?: {\n /** The most plan balance a subscription spends in one window, in USD cents. Other currencies convert it with the plan's exchange rate unless the dashboard sets a custom amount for that currency. */\n amount: number;\n /** The window length: `day` is 24 hours and `week` is 7 days, starting at the time of day of the subscription's billing anchor. */\n interval: \"day\" | \"week\";\n } | null;\n /** Credits and balance plans only. false lets usage continue past the plan and purchased amounts and bills the missing amount as overage at the next renewal; a credits plan bills it at the price per credit and needs one. Trials and free plans always stop, so free plans accept only true. Existing subscriptions apply it from their next reset. */\n blockOnExhaustion?: boolean;\n /** Make this plan the default plan of its plan group: customers created with that planGroupId start on it, and a paid plan of the group that ends from the customer portal, a revoked payment authorization or exhausted dunning moves to it instead of canceling. Requires a free plan in a plan group; replaces the group's previous default plan. false unmarks it. */\n isDefault?: boolean;\n}\n\nexport interface DeletePlanParams {\n id: string;\n}\n\nexport interface SetPlanVisibilityParams {\n id: string;\n isPublic: boolean;\n}\n\nexport interface ListPlansParams {\n includePrivate?: boolean;\n}\n\nexport interface CreatePlanParams {\n name: string;\n code: string;\n description?: string;\n consumptionModel?: \"metered\" | \"credits\" | \"balance\";\n isPublic?: boolean;\n isFree?: boolean;\n /** Credits and balance plans. Omitted, credits plans and free plans stop usage when the plan and purchased amounts run out, and paid balance plans bill the missing balance as overage. A new credits plan always stops usage: it allows overage only with a price per credit, which is set after creation, and then `PATCH /v1/plans/{id}` turns overage on. */\n blockOnExhaustion?: boolean;\n /** Credits plans only. What happens to unused plan credits at each reset; omitted means they expire. */\n unusedPlanCredits?:\n | {\n type: \"expire\";\n }\n | {\n type: \"roll_over\";\n /** The most plan credits a subscription holds after a reset, including the credits that reset grants; credits above it expire. At least the included credits of every price. null means no limit other than the largest storable balance, 2,147,483,647 plan credits. */\n maxPlanCredits: number | null;\n };\n /** Credits plans only. The most plan credits a subscription spends per day or per week; omitted or null means no limit. */\n planCreditLimit?: {\n /** The most plan credits a subscription spends in one window. */\n credits: number;\n /** The window length: `day` is 24 hours and `week` is 7 days, starting at the time of day of the subscription's billing anchor. */\n interval: \"day\" | \"week\";\n } | null;\n /** Balance plans only. What happens to unused plan balance at each reset; omitted means it expires. */\n unusedPlanBalance?:\n | {\n type: \"expire\";\n }\n | {\n type: \"roll_over\";\n /** The most plan balance a subscription holds after a reset, in USD cents, including the balance that reset grants; balance above it expires. At least the included balance of every price. Other currencies convert it with the plan's exchange rate unless the dashboard sets a custom amount for that currency. null means no limit other than the largest storable amount, 2,147,483,647 cents. */\n maxPlanBalance: number | null;\n };\n /** Balance plans only. The most plan balance a subscription spends per day or per week, in USD cents; omitted or null means no limit. */\n planBalanceLimit?: {\n /** The most plan balance a subscription spends in one window, in USD cents. Other currencies convert it with the plan's exchange rate unless the dashboard sets a custom amount for that currency. */\n amount: number;\n /** The window length: `day` is 24 hours and `week` is 7 days, starting at the time of day of the subscription's billing anchor. */\n interval: \"day\" | \"week\";\n } | null;\n planGroupId?: string;\n /** Make this plan the default plan of its plan group: customers created with that planGroupId start on it, and a paid plan of the group that ends from the customer portal, a revoked payment authorization or exhausted dunning moves to it instead of canceling. Requires a free plan with a planGroupId; replaces the group's previous default plan. */\n isDefault?: boolean;\n metadata?: Record<string, unknown>;\n}\n\nexport class PlansResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Update limits, overage, or enabled status of a feature on a plan. */\n async updateFeature(\n params: UpdatePlanFeatureParams,\n options?: RequestOptions,\n ): Promise<PlanFeature> {\n const { id, featureId, ...rest } = params;\n return this.httpClient.patch(\n `/plans/${id}/features/${featureId}`,\n rest,\n options,\n );\n }\n\n /** Detach a feature from a plan. */\n async removeFeature(\n params: RemovePlanFeatureParams,\n options?: RequestOptions,\n ): Promise<RemovedPlanFeature> {\n const { id, featureId } = params;\n return this.httpClient.delete(\n `/plans/${id}/features/${featureId}`,\n undefined,\n options,\n );\n }\n\n /** Attach a feature to a plan with limits, overage, and credits configuration. */\n async addFeature(\n params: AddPlanFeatureParams,\n options?: RequestOptions,\n ): Promise<PlanFeature> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/plans/${id}/features`, rest, options);\n }\n\n /** Set a specific price as the default and return the updated plan price. */\n async setDefaultPrice(\n params: SetDefaultPlanPriceParams,\n options?: RequestOptions,\n ): Promise<PlanPrice> {\n const { id, priceId } = params;\n return this.httpClient.put(\n `/plans/${id}/prices/${priceId}/default`,\n {},\n options,\n );\n }\n\n /** Create or update regional currency price overrides for a plan price. */\n async setRegionalPrices(\n params: UpsertRegionalPricesParams,\n options?: RequestOptions,\n ): Promise<PlanRegionalPricing> {\n const { id, priceId, ...rest } = params;\n return this.httpClient.put(\n `/plans/${id}/prices/${priceId}/regional`,\n rest,\n options,\n );\n }\n\n /** Remove all regional currency overrides for a plan price. The request is rejected while billable subscriptions depend on an override. */\n async deleteRegionalPrices(\n params: DeleteRegionalPricesParams,\n options?: RequestOptions,\n ): Promise<DeletedPlanRegionalPricing> {\n const { id, priceId } = params;\n return this.httpClient.delete(\n `/plans/${id}/prices/${priceId}/regional`,\n undefined,\n options,\n );\n }\n\n /** Update a base price or market price variant. Removing a base market override is rejected while a variant depends on it. Offer terms are managed through Offers. */\n async updatePrice(\n params: UpdatePlanPriceParams,\n options?: RequestOptions,\n ): Promise<PlanPrice> {\n const { id, priceId, ...rest } = params;\n return this.httpClient.patch(\n `/plans/${id}/prices/${priceId}`,\n rest,\n options,\n );\n }\n\n /** Archive a price for new subscriptions. Existing subscriptions that selected it continue using its current catalog value. */\n async deletePrice(\n params: DeletePlanPriceParams,\n options?: RequestOptions,\n ): Promise<DeletedObject> {\n const { id, priceId } = params;\n return this.httpClient.delete(\n `/plans/${id}/prices/${priceId}`,\n undefined,\n options,\n );\n }\n\n /** Add a base price or a selectable market price variant. Variants inherit their base price outside the markets they override. Configure introductory and promotional benefits through Offers. */\n async addPrice(\n params: AddPlanPriceParams,\n options?: RequestOptions,\n ): Promise<PlanPrice> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/plans/${id}/prices`, rest, options);\n }\n\n /** Configure regional prices and feature overage values for one currency. Currency-specific offer terms are managed through Offers. */\n async setRegionalPricing(\n params: SetPlanRegionalPricingParams,\n options?: RequestOptions,\n ): Promise<PlanRegionalPricingResult> {\n const { id, ...rest } = params;\n return this.httpClient.put(`/plans/${id}/regional`, rest, options);\n }\n\n /** Get a plan with public price IDs and their automatic introductory offer IDs. */\n async get(params: GetPlanParams, options?: RequestOptions): Promise<Plan> {\n const { id } = params;\n return this.httpClient.get(`/plans/${id}`, undefined, options);\n }\n\n /** Update a plan's name, description, visibility, default status, metadata, overage behavior, what happens to its unused plan credits or plan balance, or its plan credit or plan balance limit. */\n async update(\n params: UpdatePlanParams,\n options?: RequestOptions,\n ): Promise<Plan> {\n const { id, ...rest } = params;\n return this.httpClient.patch(`/plans/${id}`, rest, options);\n }\n\n /** Soft-delete a plan. */\n async delete(\n params: DeletePlanParams,\n options?: RequestOptions,\n ): Promise<DeletedObject> {\n const { id } = params;\n return this.httpClient.delete(`/plans/${id}`, undefined, options);\n }\n\n /** Set a plan's public visibility and return the updated plan. */\n async setVisibility(\n params: SetPlanVisibilityParams,\n options?: RequestOptions,\n ): Promise<Plan> {\n const { id, ...rest } = params;\n return this.httpClient.put(`/plans/${id}/visibility`, rest, options);\n }\n\n /** List plans with public price IDs and their automatic introductory offer IDs. */\n async list(\n params?: ListPlansParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<Plan>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/plans\", params, options);\n }\n\n /** Create a new plan with optional consumption model, visibility, plan group assignment, overage behavior, and the rollover and spend limit of its plan credits or plan balance. */\n async create(\n params: CreatePlanParams,\n options?: RequestOptions,\n ): Promise<Plan> {\n return this.httpClient.post(\"/plans\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { PortalAccess } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport type RequestPortalAccessParams =\n | {\n email: string;\n returnUrl?: string;\n }\n | {\n customerId: string;\n returnUrl?: string;\n };\n\nexport class PortalResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Generate a customer portal URL. Exactly one identifier (email or customerId) is required. */\n async getUrl(\n params: RequestPortalAccessParams,\n options?: RequestOptions,\n ): Promise<PortalAccess> {\n return this.httpClient.post(\"/portal/sessions\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { PromoCode } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface GetPromoCodeParams {\n id: string;\n}\n\nexport interface UpdatePromoCodeParams {\n id: string;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\"\n | null;\n maxRedemptions?: number | null;\n expiresAt?: string | null;\n active?: boolean;\n planIds?: Array<string>;\n /** Whether the code only applies to a customer's first purchase: one with no paid invoice above zero and no paid subscription. */\n firstPurchaseOnly?: boolean;\n}\n\nexport interface ListPromoCodesParams {\n cursor?: string;\n limit?: number;\n}\n\nexport interface CreatePromoCodeParams {\n code: string;\n offerId: string;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\"\n | null;\n maxRedemptions?: number;\n /** @format date-time */\n expiresAt?: string;\n planIds?: Array<string>;\n /** Whether the code only applies to a customer's first purchase: one with no paid invoice above zero and no paid subscription. Defaults to false. */\n firstPurchaseOnly?: boolean;\n}\n\nexport class PromoCodesResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Retrieve a promo code by its public ID. */\n async get(\n params: GetPromoCodeParams,\n options?: RequestOptions,\n ): Promise<PromoCode> {\n const { id } = params;\n return this.httpClient.get(`/promo-codes/${id}`, undefined, options);\n }\n\n /** Update a promo code's billing interval, redemption limits, expiration, active status, or plan restrictions. */\n async update(\n params: UpdatePromoCodeParams,\n options?: RequestOptions,\n ): Promise<PromoCode> {\n const { id, ...rest } = params;\n return this.httpClient.patch(`/promo-codes/${id}`, rest, options);\n }\n\n /** List promo codes with cursor-based pagination. */\n async list(\n params?: ListPromoCodesParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<PromoCode>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/promo-codes\", params, options);\n }\n\n /** Create a distribution code for an existing Offer with one or more sequential discount phases. The code owns redemption restrictions. */\n async create(\n params: CreatePromoCodeParams,\n options?: RequestOptions,\n ): Promise<PromoCode> {\n return this.httpClient.post(\"/promo-codes\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { ClaimLink } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport class ProvisioningResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Issue a fresh claim link for an organization that was provisioned headlessly and has not been claimed yet. Any previously issued link stops working. */\n async createClaimLink(options?: RequestOptions): Promise<ClaimLink> {\n return this.httpClient.post(\"/claim-link\", {}, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { UsageQuota, UsageQuotaEvent } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface GetAllQuotaAllowancesParams {\n customerId: string;\n}\n\nexport type RemoveQuotaParams =\n | {\n featureCode: string;\n count?: number;\n customerId: string;\n }\n | {\n featureCode: string;\n count?: number;\n externalId: string;\n };\n\nexport interface GetQuotaAllowanceParams {\n customerId: string;\n featureCode: string;\n}\n\nexport type AddQuotaParams =\n | {\n featureCode: string;\n count?: number;\n customerId: string;\n }\n | {\n featureCode: string;\n count?: number;\n externalId: string;\n };\n\nexport type SetQuotaParams =\n | {\n featureCode: string;\n count: number;\n customerId: string;\n }\n | {\n featureCode: string;\n count: number;\n externalId: string;\n };\n\nexport class QuotaResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Get all quota allowances for a customer across every quota feature in their plan. */\n async getAll(\n params: GetAllQuotaAllowancesParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<UsageQuota>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/usage/quota/all\", params, options);\n }\n\n /** Remove from a customer's quota allowance for a feature. Defaults to 1 if count is omitted. Returns 400 insufficient_balance if the balance would go negative. */\n async remove(\n params: RemoveQuotaParams,\n options?: RequestOptions,\n ): Promise<UsageQuotaEvent> {\n return this.httpClient.post(\"/usage/quota/remove\", params, options);\n }\n\n /** Get the current quota allowance (used vs included) for a specific feature. */\n async get(\n params: GetQuotaAllowanceParams,\n options?: RequestOptions,\n ): Promise<UsageQuota> {\n return this.httpClient.get(\"/usage/quota\", params, options);\n }\n\n /** Add to a customer's quota allowance for a feature. Defaults to 1 if count is omitted. */\n async add(\n params: AddQuotaParams,\n options?: RequestOptions,\n ): Promise<UsageQuotaEvent> {\n return this.httpClient.post(\"/usage/quota\", params, options);\n }\n\n /** Set a customer's quota allowance for a feature to an exact value. */\n async set(\n params: SetQuotaParams,\n options?: RequestOptions,\n ): Promise<UsageQuotaEvent> {\n return this.httpClient.put(\"/usage/quota\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type {\n SeatBalance,\n SeatBalanceCollection,\n SeatEvent,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface GetSeatBalanceParams {\n customerId: string;\n featureCode: string;\n}\n\nexport interface GetAllSeatBalancesParams {\n customerId: string;\n}\n\nexport interface BulkSetSeatsParams {\n customerId: string;\n seats: Record<string, number>;\n}\n\nexport interface RemoveSeatsParams {\n customerId: string;\n featureCode: string;\n count: number;\n}\n\nexport interface AddSeatsParams {\n customerId: string;\n featureCode: string;\n count: number;\n}\n\nexport interface SetSeatsParams {\n customerId: string;\n featureCode: string;\n count: number;\n}\n\nexport class SeatsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Get current balance for a specific seat type. */\n async getBalance(\n params: GetSeatBalanceParams,\n options?: RequestOptions,\n ): Promise<SeatBalance> {\n return this.httpClient.get(\"/seats/balance\", params, options);\n }\n\n /** Get the current balance for all seat types in a customer's subscription. */\n async getAllBalances(\n params: GetAllSeatBalancesParams,\n options?: RequestOptions,\n ): Promise<SeatBalanceCollection> {\n return this.httpClient.get(\"/seats/balances\", params, options);\n }\n\n /** Set all seat types at once. */\n async setAll(\n params: BulkSetSeatsParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<SeatEvent>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.put(\"/seats/bulk\", params, options);\n }\n\n /** Remove seats from a customer's subscription. Takes effect at the end of the billing period. */\n async remove(\n params: RemoveSeatsParams,\n options?: RequestOptions,\n ): Promise<SeatEvent> {\n return this.httpClient.post(\"/seats/remove\", params, options);\n }\n\n /** Add seats to a customer's subscription. Prorates charges for the current billing period. */\n async add(\n params: AddSeatsParams,\n options?: RequestOptions,\n ): Promise<SeatEvent> {\n return this.httpClient.post(\"/seats\", params, options);\n }\n\n /** Set seats to an exact count. */\n async set(\n params: SetSeatsParams,\n options?: RequestOptions,\n ): Promise<SeatEvent> {\n return this.httpClient.put(\"/seats\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { SubscriptionStatus } from \"../types/enums\";\nimport type {\n BalanceAdjustment,\n BalanceTopup,\n CreatedSubscription,\n CreditGrant,\n DeletedSubscriptionAddon,\n PaymentMethodUpdateCheckout,\n PlanChange,\n PrepaidPeriodsCheckout,\n PreviewChange,\n ReactivatedSubscription,\n RecoveryLink,\n Subscription,\n SubscriptionAddon,\n SubscriptionAutoTopUp,\n SubscriptionResume,\n SubscriptionSummary,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface DeactivateAddonParams {\n id: string;\n addonId: string;\n}\n\nexport interface ActivateAddonParams {\n id: string;\n addonId: string;\n}\n\nexport interface GetSubscriptionAutoTopUpParams {\n id: string;\n}\n\nexport interface UpdateSubscriptionAutoTopUpParams {\n id: string;\n enabled?: boolean;\n threshold?: number;\n /** Credits each top-up buys. Credits plans only. */\n quantity?: number;\n /** Minor units of the subscription currency each top-up adds. Balance plans only. */\n amount?: number;\n maxPerPeriod?: number;\n}\n\nexport interface AdjustBalanceParams {\n id: string;\n amount: number;\n reason?: string;\n type?: \"credits\" | \"balance\";\n}\n\nexport interface TopupBalanceParams {\n id: string;\n /** The amount to add, in minor units of the subscription currency (cents; whole units for zero-decimal currencies). */\n amount: number;\n}\n\nexport interface CancelSubscriptionParams {\n id: string;\n reason?: string;\n immediate?: boolean;\n}\n\nexport type ChangePlanParams =\n | {\n id: string;\n newPlanId?: string;\n newBillingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\";\n successUrl?: string;\n offerId?: string;\n promoCode?: never;\n }\n | {\n id: string;\n newPlanId?: string;\n newBillingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\";\n successUrl?: string;\n offerId?: never;\n /** Promo code whose Offer prices the change, validated with the checkout's rules: a code the checkout would refuse returns 400 validation_error with the checkout's reason in details.reason. Cannot be combined with offerId. */\n promoCode: string;\n };\n\nexport type PurchaseCreditsParams =\n | {\n id: string;\n creditPackId: string;\n quantity?: never;\n }\n | {\n id: string;\n quantity: number;\n };\n\nexport interface ApplySubscriptionOfferParams {\n id: string;\n offerId: string;\n /** @format date-time */\n expiresAt?: string;\n}\n\nexport interface RemoveSubscriptionOfferParams {\n id: string;\n}\n\nexport interface PauseSubscriptionParams {\n id: string;\n mode: \"immediate\" | \"period_end\";\n durationDays: number | null;\n}\n\nexport interface UpdateSubscriptionPauseParams {\n id: string;\n durationDays: number | null;\n}\n\nexport interface RevokeSubscriptionPauseParams {\n id: string;\n}\n\nexport interface UpdatePaymentMethodParams {\n id: string;\n successUrl?: string;\n}\n\nexport interface CreatePrepaidPeriodsCheckoutParams {\n id: string;\n /** Active subscriptions: billing periods to add after the last paid period. Pending-payment subscriptions: total billing periods the first payment covers, including the current one. */\n periods: number;\n /** Offer applied from the first added period for its full configured duration. Active subscriptions only; assign an Offer to a pending-payment subscription with PUT /subscriptions/{id}/offer. */\n offerId?: string;\n successUrl?: string;\n}\n\nexport type PreviewChangePlanParams =\n | {\n id: string;\n planId: string;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\";\n offerId?: string;\n promoCode?: never;\n }\n | {\n id: string;\n planId: string;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\";\n offerId?: never;\n /** Promo code whose Offer prices the change, validated with the checkout's rules: a code the checkout would refuse returns 400 validation_error with the checkout's reason in details.reason. Cannot be combined with offerId. */\n promoCode: string;\n };\n\nexport interface ReactivateSubscriptionParams {\n id: string;\n offerId?: string;\n}\n\nexport interface CreateSubscriptionRecoveryLinkParams {\n id: string;\n}\n\nexport interface ResumeSubscriptionParams {\n id: string;\n}\n\nexport interface GetSubscriptionParams {\n id: string;\n}\n\nexport interface RevokeScheduledPlanChangeParams {\n id: string;\n}\n\nexport interface UncancelSubscriptionParams {\n id: string;\n}\n\nexport interface GetActiveSubscriptionParams {\n customerId: string;\n}\n\nexport interface ListSubscriptionsParams {\n customerId?: string;\n status?: SubscriptionStatus;\n}\n\nexport type CreateSubscriptionParams =\n | {\n customerId: string;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\"\n | null;\n /** Public price ID. When omitted, Commet selects the default price for the billing interval and still applies its market pricing. */\n priceId?: string;\n initialSeats?: Record<string, number>;\n /** Payment provider name or exact public payment connection ID for the initial checkout. Overrides country routing when present. */\n provider?: \"stripe\" | \"commet\" | \"dlocal\" | string;\n /** Payment methods the initial checkout may offer. Restricts what the checkout already offers for the buyer's country, currency and payment connection; it never enables a method the connection does not have and never changes routing. When none of them is available to the buyer, the checkout shows that it cannot accept payments. */\n paymentMethodTypes?: Array<\n \"card\" | \"oxxo\" | \"mercado_pago\" | \"google_pay\" | \"smartpix\"\n >;\n name?: string;\n /** @format date-time */\n startDate?: string;\n successUrl?: string;\n /** Billing periods of the subscription's interval paid with the first payment, including the current one. Defaults to 1. The interval does not change: each paid period renews at zero and the subscription renews normally after the last one unless `cancelAtPeriodEnd` is true. */\n prepaidPeriods?: number;\n /** Schedules the cancellation from creation so the subscription ends after its last paid period and never renews with any payment method. */\n cancelAtPeriodEnd?: boolean;\n offerId?: never;\n promoCode?: string;\n /** Trial length in days, replacing the price's trial. A customer who already had this plan, in a trial or paying, gets no trial and goes through the regular checkout. */\n customTrialDays?: number;\n skipTrial?: boolean;\n planId: string;\n }\n | {\n customerId: string;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\"\n | null;\n /** Public price ID. When omitted, Commet selects the default price for the billing interval and still applies its market pricing. */\n priceId?: string;\n initialSeats?: Record<string, number>;\n /** Payment provider name or exact public payment connection ID for the initial checkout. Overrides country routing when present. */\n provider?: \"stripe\" | \"commet\" | \"dlocal\" | string;\n /** Payment methods the initial checkout may offer. Restricts what the checkout already offers for the buyer's country, currency and payment connection; it never enables a method the connection does not have and never changes routing. When none of them is available to the buyer, the checkout shows that it cannot accept payments. */\n paymentMethodTypes?: Array<\n \"card\" | \"oxxo\" | \"mercado_pago\" | \"google_pay\" | \"smartpix\"\n >;\n name?: string;\n /** @format date-time */\n startDate?: string;\n successUrl?: string;\n /** Billing periods of the subscription's interval paid with the first payment, including the current one. Defaults to 1. The interval does not change: each paid period renews at zero and the subscription renews normally after the last one unless `cancelAtPeriodEnd` is true. */\n prepaidPeriods?: number;\n /** Schedules the cancellation from creation so the subscription ends after its last paid period and never renews with any payment method. */\n cancelAtPeriodEnd?: boolean;\n offerId?: never;\n promoCode?: string;\n /** Trial length in days, replacing the price's trial. A customer who already had this plan, in a trial or paying, gets no trial and goes through the regular checkout. */\n customTrialDays?: number;\n skipTrial?: boolean;\n planCode: string;\n }\n | {\n customerId: string;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\"\n | null;\n /** Public price ID. When omitted, Commet selects the default price for the billing interval and still applies its market pricing. */\n priceId?: string;\n initialSeats?: Record<string, number>;\n /** Payment provider name or exact public payment connection ID for the initial checkout. Overrides country routing when present. */\n provider?: \"stripe\" | \"commet\" | \"dlocal\" | string;\n /** Payment methods the initial checkout may offer. Restricts what the checkout already offers for the buyer's country, currency and payment connection; it never enables a method the connection does not have and never changes routing. When none of them is available to the buyer, the checkout shows that it cannot accept payments. */\n paymentMethodTypes?: Array<\n \"card\" | \"oxxo\" | \"mercado_pago\" | \"google_pay\" | \"smartpix\"\n >;\n name?: string;\n /** @format date-time */\n startDate?: string;\n successUrl?: string;\n /** Billing periods of the subscription's interval paid with the first payment, including the current one. Defaults to 1. The interval does not change: each paid period renews at zero and the subscription renews normally after the last one unless `cancelAtPeriodEnd` is true. */\n prepaidPeriods?: number;\n /** Schedules the cancellation from creation so the subscription ends after its last paid period and never renews with any payment method. */\n cancelAtPeriodEnd?: boolean;\n offerId: string;\n promoCode?: never;\n /** Trial length in days, replacing the price's trial. A customer who already had this plan, in a trial or paying, gets no trial and goes through the regular checkout. */\n customTrialDays?: number;\n skipTrial?: boolean;\n planId: string;\n }\n | {\n customerId: string;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\"\n | null;\n /** Public price ID. When omitted, Commet selects the default price for the billing interval and still applies its market pricing. */\n priceId?: string;\n initialSeats?: Record<string, number>;\n /** Payment provider name or exact public payment connection ID for the initial checkout. Overrides country routing when present. */\n provider?: \"stripe\" | \"commet\" | \"dlocal\" | string;\n /** Payment methods the initial checkout may offer. Restricts what the checkout already offers for the buyer's country, currency and payment connection; it never enables a method the connection does not have and never changes routing. When none of them is available to the buyer, the checkout shows that it cannot accept payments. */\n paymentMethodTypes?: Array<\n \"card\" | \"oxxo\" | \"mercado_pago\" | \"google_pay\" | \"smartpix\"\n >;\n name?: string;\n /** @format date-time */\n startDate?: string;\n successUrl?: string;\n /** Billing periods of the subscription's interval paid with the first payment, including the current one. Defaults to 1. The interval does not change: each paid period renews at zero and the subscription renews normally after the last one unless `cancelAtPeriodEnd` is true. */\n prepaidPeriods?: number;\n /** Schedules the cancellation from creation so the subscription ends after its last paid period and never renews with any payment method. */\n cancelAtPeriodEnd?: boolean;\n offerId: string;\n promoCode?: never;\n /** Trial length in days, replacing the price's trial. A customer who already had this plan, in a trial or paying, gets no trial and goes through the regular checkout. */\n customTrialDays?: number;\n skipTrial?: boolean;\n planCode: string;\n }\n | {\n customerId: string;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\"\n | null;\n /** Public price ID. When omitted, Commet selects the default price for the billing interval and still applies its market pricing. */\n priceId?: string;\n initialSeats?: Record<string, number>;\n /** Payment provider name or exact public payment connection ID for the initial checkout. Overrides country routing when present. */\n provider?: \"stripe\" | \"commet\" | \"dlocal\" | string;\n /** Payment methods the initial checkout may offer. Restricts what the checkout already offers for the buyer's country, currency and payment connection; it never enables a method the connection does not have and never changes routing. When none of them is available to the buyer, the checkout shows that it cannot accept payments. */\n paymentMethodTypes?: Array<\n \"card\" | \"oxxo\" | \"mercado_pago\" | \"google_pay\" | \"smartpix\"\n >;\n name?: string;\n /** @format date-time */\n startDate?: string;\n successUrl?: string;\n /** Billing periods of the subscription's interval paid with the first payment, including the current one. Defaults to 1. The interval does not change: each paid period renews at zero and the subscription renews normally after the last one unless `cancelAtPeriodEnd` is true. */\n prepaidPeriods?: number;\n /** Schedules the cancellation from creation so the subscription ends after its last paid period and never renews with any payment method. */\n cancelAtPeriodEnd?: boolean;\n offerId?: never;\n /** Public card promotion ID. The offer is shown immediately and remains conditional on card eligibility until checkout confirmation. */\n cardPromotionId: string;\n promoCode?: never;\n customTrialDays?: never;\n skipTrial?: false;\n planId: string;\n }\n | {\n customerId: string;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\"\n | null;\n /** Public price ID. When omitted, Commet selects the default price for the billing interval and still applies its market pricing. */\n priceId?: string;\n initialSeats?: Record<string, number>;\n /** Payment provider name or exact public payment connection ID for the initial checkout. Overrides country routing when present. */\n provider?: \"stripe\" | \"commet\" | \"dlocal\" | string;\n /** Payment methods the initial checkout may offer. Restricts what the checkout already offers for the buyer's country, currency and payment connection; it never enables a method the connection does not have and never changes routing. When none of them is available to the buyer, the checkout shows that it cannot accept payments. */\n paymentMethodTypes?: Array<\n \"card\" | \"oxxo\" | \"mercado_pago\" | \"google_pay\" | \"smartpix\"\n >;\n name?: string;\n /** @format date-time */\n startDate?: string;\n successUrl?: string;\n /** Billing periods of the subscription's interval paid with the first payment, including the current one. Defaults to 1. The interval does not change: each paid period renews at zero and the subscription renews normally after the last one unless `cancelAtPeriodEnd` is true. */\n prepaidPeriods?: number;\n /** Schedules the cancellation from creation so the subscription ends after its last paid period and never renews with any payment method. */\n cancelAtPeriodEnd?: boolean;\n offerId?: never;\n /** Public card promotion ID. The offer is shown immediately and remains conditional on card eligibility until checkout confirmation. */\n cardPromotionId: string;\n promoCode?: never;\n customTrialDays?: never;\n skipTrial?: false;\n planCode: string;\n };\n\nexport class SubscriptionsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Deactivate an add-on from a subscription. */\n async deactivateAddon(\n params: DeactivateAddonParams,\n options?: RequestOptions,\n ): Promise<DeletedSubscriptionAddon> {\n const { id, addonId } = params;\n return this.httpClient.delete(\n `/subscriptions/${id}/addons/${addonId}`,\n undefined,\n options,\n );\n }\n\n /** Activate an add-on on a subscription. Charges a prorated amount for the current billing period. */\n async activateAddon(\n params: ActivateAddonParams,\n options?: RequestOptions,\n ): Promise<SubscriptionAddon> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/subscriptions/${id}/addons`, rest, options);\n }\n\n /** Read whether the subscription tops up automatically with its saved payment method when its available credits or balance reach a threshold, with the top-ups used this period and the last failure. */\n async getAutoTopUp(\n params: GetSubscriptionAutoTopUpParams,\n options?: RequestOptions,\n ): Promise<SubscriptionAutoTopUp> {\n const { id } = params;\n return this.httpClient.get(\n `/subscriptions/${id}/auto-top-up`,\n undefined,\n options,\n );\n }\n\n /** Turn automatic top-ups on or off and set the threshold, the size of each top-up and the maximum top-ups per period. Send only the fields that change. On a credits plan each top-up buys `quantity` credits; on a balance plan it adds `amount` in minor units of the subscription currency, plus tax, and `threshold` is in the same minor units. Enabling requires a plan that sells credits or has balance top-ups on. The size must be at least the plan's minimum when auto top-up is enabled or when the size changes, so turning it off keeps working after the minimum rises. Saving it enabled resumes a paused auto top-up. */\n async updateAutoTopUp(\n params: UpdateSubscriptionAutoTopUpParams,\n options?: RequestOptions,\n ): Promise<SubscriptionAutoTopUp> {\n const { id, ...rest } = params;\n return this.httpClient.patch(\n `/subscriptions/${id}/auto-top-up`,\n rest,\n options,\n );\n }\n\n /** Adjust a subscription's balance or credits by a signed amount. Positive adds, negative subtracts. */\n async adjustBalance(\n params: AdjustBalanceParams,\n options?: RequestOptions,\n ): Promise<BalanceAdjustment> {\n const { id, ...rest } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/balance/adjust`,\n rest,\n options,\n );\n }\n\n /** 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. */\n async topupBalance(\n params: TopupBalanceParams,\n options?: RequestOptions,\n ): Promise<BalanceTopup> {\n const { id, ...rest } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/balance/topup`,\n rest,\n options,\n );\n }\n\n /** Cancel immediately or at period end and return the updated subscription. */\n async cancel(\n params: CancelSubscriptionParams,\n options?: RequestOptions,\n ): Promise<Subscription> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/subscriptions/${id}/cancel`, rest, options);\n }\n\n /** Upgrade or change billing interval immediately, optionally applying an Offer by offerId or the Offer of a promoCode. Scheduled changes accept neither offerId nor promoCode. From a free plan, a promoCode opens the checkout with the code applied and counts its use when the checkout is paid; without offerId or promoCode, a destination price whose free trial requires no payment method starts that trial right away without checkout. During a trial without a payment method, an immediate change returns 409 no_payment_method; scheduled changes still apply. */\n async changePlan(\n params: ChangePlanParams,\n options?: RequestOptions,\n ): Promise<PlanChange> {\n const { id, ...rest } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/change-plan`,\n rest,\n options,\n );\n }\n\n /** 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. */\n async purchaseCredits(\n params: PurchaseCreditsParams,\n options?: RequestOptions,\n ): Promise<CreditGrant> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/subscriptions/${id}/credits`, rest, options);\n }\n\n /** Apply a direct Offer to a subscription. On a pending checkout it quotes or replaces the checkout discount, which starts after the plan price trial when there is one, and the existing checkout URL remains unchanged. On an active subscription it applies the Offer immediately with its discount phases starting at the next billing cycle; the call is rejected while another applied Offer still has active or upcoming discount phases. */\n async applyOffer(\n params: ApplySubscriptionOfferParams,\n options?: RequestOptions,\n ): Promise<Subscription> {\n const { id, ...rest } = params;\n return this.httpClient.put(`/subscriptions/${id}/offer`, rest, options);\n }\n\n /** Remove the quoted direct Offer from a subscription's pending payment checkout. The existing checkout URL remains unchanged and returns to its undiscounted price. */\n async removeOffer(\n params: RemoveSubscriptionOfferParams,\n options?: RequestOptions,\n ): Promise<Subscription> {\n const { id } = params;\n return this.httpClient.delete(\n `/subscriptions/${id}/offer`,\n undefined,\n options,\n );\n }\n\n /** Pause immediately or schedule a pause for the end of the current billing or trial period. Set durationDays to null for an indefinite pause. */\n async pause(\n params: PauseSubscriptionParams,\n options?: RequestOptions,\n ): Promise<Subscription> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/subscriptions/${id}/pause`, rest, options);\n }\n\n /** Change the duration of a scheduled or active pause. Set durationDays to null to make it indefinite. */\n async updatePause(\n params: UpdateSubscriptionPauseParams,\n options?: RequestOptions,\n ): Promise<Subscription> {\n const { id, ...rest } = params;\n return this.httpClient.patch(`/subscriptions/${id}/pause`, rest, options);\n }\n\n /** Revoke a pause before it becomes effective. Active pauses must be resumed instead. */\n async revokePause(\n params: RevokeSubscriptionPauseParams,\n options?: RequestOptions,\n ): Promise<Subscription> {\n const { id } = params;\n return this.httpClient.delete(\n `/subscriptions/${id}/pause`,\n undefined,\n options,\n );\n }\n\n /** Creates a hosted checkout to update the payment method of an active, trialing or past_due subscription. Pending-payment subscriptions must use their payment checkout. */\n async updatePaymentMethod(\n params: UpdatePaymentMethodParams,\n options?: RequestOptions,\n ): Promise<PaymentMethodUpdateCheckout> {\n const { id, ...rest } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/payment-method/update`,\n rest,\n options,\n );\n }\n\n /** Creates a hosted checkout to pay billing periods of a recurring subscription in advance with any payment method. On an active subscription the paid periods start after the last paid period and replace any open prepaid-periods checkout. On a pending-payment subscription the first payment covers the requested periods and replaces its pending checkout. The billing interval does not change. */\n async createPrepaidPeriodsCheckout(\n params: CreatePrepaidPeriodsCheckoutParams,\n options?: RequestOptions,\n ): Promise<PrepaidPeriodsCheckout> {\n const { id, ...rest } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/prepaid-periods`,\n rest,\n options,\n );\n }\n\n /** Preview proration details for an immediate plan change without applying it. Free-to-paid changes are never scheduled and the change-plan endpoint returns hosted checkout for them, except a change without offerId or promoCode to a price whose free trial needs no payment method, for a customer who never had that plan: it starts the trial at once, so the preview reports nothing due today. For paid plans, interval direction takes precedence: a longer interval is immediate and a shorter interval is scheduled. When the interval is unchanged, a higher-sort-order plan is immediate and a lower-sort-order plan is scheduled. A paid-to-free change is always scheduled. Returns credit, charge, and net amount. The target plan must belong to the same plan group as the current plan, otherwise a 400 with code `plans_not_in_same_group` is returned. A change between two free plans has nothing to prorate and returns a zero-amount estimate. Scheduled changes return a 400 with code `plan_change_scheduled`; apply those via the change-plan endpoint. Pass offerId to quote the destination plan with an Offer, or promoCode to quote it with the Offer of a promo code validated with the checkout's rules. */\n async previewChange(\n params: PreviewChangePlanParams,\n options?: RequestOptions,\n ): Promise<PreviewChange> {\n const { id, ...rest } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/preview-change`,\n rest,\n options,\n );\n }\n\n /** Reactivates a subscription. A past_due subscription retries its outstanding renewal charge (recovering to active on success). A canceled subscription generates a fresh invoice, charges the saved card, and resets the billing period. On a successful charge the subscription becomes active; a declined charge returns an error with a recoveryUrl in the error details that can be sent to the customer to update their card. A canceled subscription may apply an Offer by offerId; past-due recovery cannot. */\n async reactivate(\n params: ReactivateSubscriptionParams,\n options?: RequestOptions,\n ): Promise<ReactivatedSubscription> {\n const { id, ...rest } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/reactivate`,\n rest,\n options,\n );\n }\n\n /** 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. */\n async createRecoveryLink(\n params: CreateSubscriptionRecoveryLinkParams,\n options?: RequestOptions,\n ): Promise<RecoveryLink> {\n const { id } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/recovery-links`,\n {},\n options,\n );\n }\n\n /** Resume a paused subscription. Immediate pauses continue the preserved period without a charge. Period-end pauses charge a new period before access is restored. */\n async resume(\n params: ResumeSubscriptionParams,\n options?: RequestOptions,\n ): Promise<SubscriptionResume> {\n const { id } = params;\n return this.httpClient.post(`/subscriptions/${id}/resume`, {}, options);\n }\n\n /** Get a subscription by its public ID, regardless of status (including pending_payment and past_due). */\n async get(\n params: GetSubscriptionParams,\n options?: RequestOptions,\n ): Promise<Subscription> {\n const { id } = params;\n return this.httpClient.get(`/subscriptions/${id}`, undefined, options);\n }\n\n /** Revoke the plan or interval change scheduled for the end of the period, so the subscription stays on its current plan. Returns the updated subscription. */\n async revokeScheduledPlanChange(\n params: RevokeScheduledPlanChangeParams,\n options?: RequestOptions,\n ): Promise<Subscription> {\n const { id } = params;\n return this.httpClient.delete(\n `/subscriptions/${id}/scheduled-plan-change`,\n undefined,\n options,\n );\n }\n\n /** Revert a scheduled cancellation and return the updated subscription. Only works before cancellation takes effect. */\n async uncancel(\n params: UncancelSubscriptionParams,\n options?: RequestOptions,\n ): Promise<Subscription> {\n const { id } = params;\n return this.httpClient.post(`/subscriptions/${id}/uncancel`, {}, options);\n }\n\n /** Get the active subscription for a customer. Returns null if none. */\n async getActive(\n params: GetActiveSubscriptionParams,\n options?: RequestOptions,\n ): Promise<Subscription | null> {\n return this.httpClient.get(\"/subscriptions/active\", params, options);\n }\n\n /** List all subscriptions. Filter by customer ID or status. */\n async list(\n params?: ListSubscriptionsParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<SubscriptionSummary>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/subscriptions\", params, options);\n }\n\n /** Create a subscription for a customer. Commet selects the default price when priceId is omitted. The subscription starts at the base USD price; market and currency are resolved from the buyer's request country when the checkout opens. Without an offer override, Commet applies the price's automatic introductory Offer. Pass offerId to apply an active compatible Offer directly, or cardPromotionId to preselect a card-eligible Promotional Offer for the initial checkout when card promotions are enabled for the organization. For the initial checkout, provider accepts either a processor name or an exact payment connection ID. When the price's free trial requires no payment method, the subscription starts trialing right away with no checkout (checkoutUrl null, hasPaymentMethod false); it cannot be combined with offerId, promoCode, cardPromotionId or provider, and an organization that cannot charge yet receives 403. */\n async create(\n params: CreateSubscriptionParams,\n options?: RequestOptions,\n ): Promise<CreatedSubscription> {\n return this.httpClient.post(\"/subscriptions\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { TestClock, TestClockRun } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport type AdvanceTestClockParams =\n | {\n advanceDays: number;\n }\n | {\n /** @format date-time */\n frozenTime: string;\n };\n\nexport class TestClockResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /**\n * Deprecated. POST /test-clock now advances time and processes every due billing deadline in one durable run.\n * @deprecated\n */\n async processBilling(options?: RequestOptions): Promise<void> {\n return this.httpClient.post(\"/test-clock/process-billing\", {}, options);\n }\n\n /** Returns the organization's current test clock state and latest durable run. Sandbox only. */\n async get(): Promise<TestClock> {\n return this.httpClient.get(\"/test-clock\");\n }\n\n /** Starts a durable run that moves the test clock forward and processes every billing deadline due before the target time. Poll GET /test-clock for progress and terminal results. Sandbox only. */\n async advance(\n params: AdvanceTestClockParams,\n options?: RequestOptions,\n ): Promise<TestClockRun> {\n return this.httpClient.post(\"/test-clock\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { TransactionStatus } from \"../types/enums\";\nimport type {\n Refund,\n Transaction,\n TransactionListItem,\n TransactionRetry,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface RefundTransactionParams {\n id: string;\n}\n\nexport interface RetryTransactionParams {\n id: string;\n}\n\nexport interface GetTransactionParams {\n id: string;\n}\n\nexport interface ListTransactionsParams {\n cursor?: string;\n limit?: number;\n status?: TransactionStatus;\n customerEmail?: string;\n}\n\nexport class TransactionsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Issue a full refund and return the provider-neutral refund resource with its actual status. */\n async refund(\n params: RefundTransactionParams,\n options?: RequestOptions,\n ): Promise<Refund> {\n const { id } = params;\n return this.httpClient.post(`/transactions/${id}/refund`, {}, options);\n }\n\n /** Retry a failed subscription renewal and return an honest retry result. The original failed transaction remains immutable. */\n async retry(\n params: RetryTransactionParams,\n options?: RequestOptions,\n ): Promise<TransactionRetry> {\n const { id } = params;\n return this.httpClient.post(`/transactions/${id}/retry`, {}, options);\n }\n\n /** Retrieve a single payment transaction by its public ID, including provider details. */\n async get(\n params: GetTransactionParams,\n options?: RequestOptions,\n ): Promise<Transaction> {\n const { id } = params;\n return this.httpClient.get(`/transactions/${id}`, undefined, options);\n }\n\n /** List payment transactions with cursor-based pagination. Filter by status or customer email. */\n async list(\n params?: ListTransactionsParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<TransactionListItem>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/transactions\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { UsageAdjustment, UsageCheck, UsageEvent } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface CheckUsageAvailabilityParams {\n customerId: string;\n featureCode: string;\n quantity?: number;\n}\n\nexport type TrackUsageParams =\n | {\n featureCode: string;\n customerId: string;\n eventId?: string;\n /** @format date-time */\n timestamp?: string;\n properties?: Array<{\n property: string;\n value: string;\n }>;\n model: string;\n inputTokens: number;\n outputTokens: number;\n value?: never;\n cacheReadTokens?: number;\n cacheWriteTokens?: number;\n }\n | {\n featureCode: string;\n customerId: string;\n eventId?: string;\n /** @format date-time */\n timestamp?: string;\n properties?: Array<{\n property: string;\n value: string;\n }>;\n value?: number;\n model?: never;\n inputTokens?: never;\n outputTokens?: never;\n cacheReadTokens?: never;\n cacheWriteTokens?: never;\n };\n\nexport interface SetUsageParams {\n customerId: string;\n featureCode: string;\n value: number;\n reason?: string;\n}\n\nexport class UsageResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Check if a customer can consume a feature before actual consumption. Returns availability and cost estimates based on the plan's consumption model. */\n async check(\n params: CheckUsageAvailabilityParams,\n options?: RequestOptions,\n ): Promise<UsageCheck> {\n return this.httpClient.post(\"/usage/check\", params, options);\n }\n\n /** Track a usage event for a metered feature. Deducts from balance/credits if applicable. */\n async track(\n params: TrackUsageParams,\n options?: RequestOptions,\n ): Promise<UsageEvent> {\n return this.httpClient.post(\"/usage/events\", params, options);\n }\n\n /** Set a metered feature's usage to an exact value for the current period. Use the Idempotency-Key header to make retries safe. */\n async set(\n params: SetUsageParams,\n options?: RequestOptions,\n ): Promise<UsageAdjustment> {\n return this.httpClient.put(\"/usage\", params, options);\n }\n}\n","import { AddonsResource } from \"./resources/addons\";\nimport { ApiKeysResource } from \"./resources/api-keys\";\nimport { CreditPacksResource } from \"./resources/credit-packs\";\nimport { CustomersResource } from \"./resources/customers\";\nimport { FeatureAccessResource } from \"./resources/feature-access\";\nimport { FeaturesResource } from \"./resources/features\";\nimport { InvoicesResource } from \"./resources/invoices\";\nimport { MarketsResource } from \"./resources/markets\";\nimport { OffersResource } from \"./resources/offers\";\nimport { PaymentsResource } from \"./resources/payments\";\nimport { PayoutsResource } from \"./resources/payouts\";\nimport { PlanGroupsResource } from \"./resources/plan-groups\";\nimport { PlansResource } from \"./resources/plans\";\nimport { PortalResource } from \"./resources/portal\";\nimport { PromoCodesResource } from \"./resources/promo-codes\";\nimport { ProvisioningResource } from \"./resources/provisioning\";\nimport { QuotaResource } from \"./resources/quota\";\nimport { SeatsResource } from \"./resources/seats\";\nimport { SubscriptionsResource } from \"./resources/subscriptions\";\nimport { TestClockResource } from \"./resources/test-clock\";\nimport { TransactionsResource } from \"./resources/transactions\";\nimport { UsageResource } from \"./resources/usage\";\nimport type { CommetHTTPClient } from \"./utils/http\";\n\nexport class GeneratedResources {\n public addons!: AddonsResource;\n public apiKeys!: ApiKeysResource;\n public creditPacks!: CreditPacksResource;\n public customers!: CustomersResource;\n public featureAccess!: FeatureAccessResource;\n public features!: FeaturesResource;\n public invoices!: InvoicesResource;\n public markets!: MarketsResource;\n public offers!: OffersResource;\n public payments!: PaymentsResource;\n public payouts!: PayoutsResource;\n public planGroups!: PlanGroupsResource;\n public plans!: PlansResource;\n public portal!: PortalResource;\n public promoCodes!: PromoCodesResource;\n public provisioning!: ProvisioningResource;\n public quota!: QuotaResource;\n public seats!: SeatsResource;\n public subscriptions!: SubscriptionsResource;\n public testClock!: TestClockResource;\n public transactions!: TransactionsResource;\n public usage!: UsageResource;\n\n protected initResources(http: CommetHTTPClient): void {\n this.addons = new AddonsResource(http);\n this.apiKeys = new ApiKeysResource(http);\n this.creditPacks = new CreditPacksResource(http);\n this.customers = new CustomersResource(http);\n this.featureAccess = new FeatureAccessResource(http);\n this.features = new FeaturesResource(http);\n this.invoices = new InvoicesResource(http);\n this.markets = new MarketsResource(http);\n this.offers = new OffersResource(http);\n this.payments = new PaymentsResource(http);\n this.payouts = new PayoutsResource(http);\n this.planGroups = new PlanGroupsResource(http);\n this.plans = new PlansResource(http);\n this.portal = new PortalResource(http);\n this.promoCodes = new PromoCodesResource(http);\n this.provisioning = new ProvisioningResource(http);\n this.quota = new QuotaResource(http);\n this.seats = new SeatsResource(http);\n this.subscriptions = new SubscriptionsResource(http);\n this.testClock = new TestClockResource(http);\n this.transactions = new TransactionsResource(http);\n this.usage = new UsageResource(http);\n }\n}\n","import crypto from \"node:crypto\";\nimport type {\n WebhookEvent,\n WebhookEventDataMap,\n WebhookEventPayload,\n} from \"../types/webhook-events\";\n\nexport type WebhookPayload = WebhookEventPayload;\nexport type WebhookData = WebhookPayload[\"data\"];\n\nexport type WebhookEventHandler<E extends WebhookEvent> = (\n data: WebhookEventDataMap[E],\n payload: Extract<WebhookEventPayload, { event: E }>,\n) => void | Promise<void>;\n\nexport interface VerifyParams {\n payload: string;\n signature: string | null;\n secret: string;\n}\n\nexport interface GenerateSignatureParams {\n payload: string;\n secret: string;\n}\n\nexport interface VerifyAndParseParams {\n rawBody: string;\n signature: string | null;\n secret: string;\n}\n\nexport class Webhooks {\n private readonly eventHandlers = new Map<\n WebhookEvent,\n WebhookEventHandler<WebhookEvent>\n >();\n\n verify(params: VerifyParams): boolean {\n const { payload, signature, secret } = params;\n\n if (!signature || !secret || !payload) {\n return false;\n }\n\n try {\n const expectedSignature = this.generateSignature({ payload, secret });\n return crypto.timingSafeEqual(\n Buffer.from(signature, \"hex\"),\n Buffer.from(expectedSignature, \"hex\"),\n );\n } catch (_error) {\n // timingSafeEqual throws when the two buffers differ in length\n return false;\n }\n }\n\n private generateSignature(params: GenerateSignatureParams): string {\n const { payload, secret } = params;\n return crypto.createHmac(\"sha256\", secret).update(payload).digest(\"hex\");\n }\n\n verifyAndParse(params: VerifyAndParseParams): WebhookPayload | null {\n const { rawBody, signature, secret } = params;\n\n if (!this.verify({ payload: rawBody, signature, secret })) {\n return null;\n }\n\n try {\n return JSON.parse(params.rawBody) as WebhookPayload;\n } catch {\n return null;\n }\n }\n\n on<E extends WebhookEvent>(event: E, handler: WebhookEventHandler<E>): this {\n this.eventHandlers.set(\n event,\n handler as unknown as WebhookEventHandler<WebhookEvent>,\n );\n return this;\n }\n\n async process(params: VerifyAndParseParams): Promise<WebhookPayload | null> {\n const payload = this.verifyAndParse(params);\n if (!payload) return null;\n const handler = this.eventHandlers.get(payload.event);\n if (handler) await handler(payload.data as never, payload as never);\n return payload;\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type {\n CreatedWebhook,\n DeletedObject,\n Webhook,\n WebhookTest,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\nimport { Webhooks } from \"./webhooks\";\n\nexport interface GetWebhookEndpointParams {\n id: string;\n}\n\nexport interface UpdateWebhookEndpointParams {\n id: string;\n url?: string;\n events?: Array<\n | \"subscription.created\"\n | \"subscription.activated\"\n | \"subscription.reactivated\"\n | \"subscription.pause_scheduled\"\n | \"subscription.pause_updated\"\n | \"subscription.pause_revoked\"\n | \"subscription.paused\"\n | \"subscription.resumed\"\n | \"subscription.resume_failed\"\n | \"subscription.canceled\"\n | \"subscription.updated\"\n | \"subscription.plan_changed\"\n | \"subscription.cancellation_scheduled\"\n | \"subscription.cancellation_revoked\"\n | \"subscription.plan_change_scheduled\"\n | \"subscription.plan_change_revoked\"\n | \"subscription.past_due\"\n | \"trial.started\"\n | \"trial.converted\"\n | \"trial.expired\"\n | \"trial.will_end\"\n | \"trial.checkout_ready\"\n | \"checkout.ready\"\n | \"payment.received\"\n | \"payment.failed\"\n | \"payment.recovered\"\n | \"payment.retry_failed\"\n | \"payment.refunded\"\n | \"payment.disputed\"\n | \"payment.dispute_resolved\"\n | \"payment_link.created\"\n | \"payment_link.completed\"\n | \"payment_link.failed\"\n | \"payment_link.canceled\"\n | \"invoice.created\"\n | \"invoice.voided\"\n | \"invoice.overdue\"\n | \"invoice.upcoming\"\n | \"payment_method.attached\"\n | \"payment_method.updated\"\n | \"payment_method.detached\"\n | \"customer.created\"\n | \"customer.updated\"\n | \"customer.state_changed\"\n | \"plan_grant.created\"\n | \"plan_grant.updated\"\n | \"plan_grant.expired\"\n | \"plan_grant.revoked\"\n | \"credits.granted\"\n | \"credits.purchased\"\n | \"credits.low\"\n | \"credits.depleted\"\n | \"credits.expired\"\n | \"balance.granted\"\n | \"balance.topped_up\"\n | \"balance.low\"\n | \"balance.depleted\"\n | \"balance.expired\"\n | \"quota.threshold_reached\"\n | \"quota.exceeded\"\n | \"seats.updated\"\n | \"seats.limit_reached\"\n | \"addon.activated\"\n | \"addon.deactivated\"\n | \"usage.recorded\"\n | \"payout.available\"\n | \"payout.created\"\n | \"payout.paid\"\n | \"payout.failed\"\n >;\n description?: string | null;\n isActive?: boolean;\n apiVersion?: string;\n}\n\nexport interface DeleteWebhookEndpointParams {\n id: string;\n}\n\nexport interface TestWebhookEndpointParams {\n id: string;\n}\n\nexport interface ListWebhookEndpointsParams {\n cursor?: string;\n limit?: number;\n}\n\nexport interface CreateWebhookEndpointParams {\n url: string;\n events: Array<\n | \"subscription.created\"\n | \"subscription.activated\"\n | \"subscription.reactivated\"\n | \"subscription.pause_scheduled\"\n | \"subscription.pause_updated\"\n | \"subscription.pause_revoked\"\n | \"subscription.paused\"\n | \"subscription.resumed\"\n | \"subscription.resume_failed\"\n | \"subscription.canceled\"\n | \"subscription.updated\"\n | \"subscription.plan_changed\"\n | \"subscription.cancellation_scheduled\"\n | \"subscription.cancellation_revoked\"\n | \"subscription.plan_change_scheduled\"\n | \"subscription.plan_change_revoked\"\n | \"subscription.past_due\"\n | \"trial.started\"\n | \"trial.converted\"\n | \"trial.expired\"\n | \"trial.will_end\"\n | \"trial.checkout_ready\"\n | \"checkout.ready\"\n | \"payment.received\"\n | \"payment.failed\"\n | \"payment.recovered\"\n | \"payment.retry_failed\"\n | \"payment.refunded\"\n | \"payment.disputed\"\n | \"payment.dispute_resolved\"\n | \"payment_link.created\"\n | \"payment_link.completed\"\n | \"payment_link.failed\"\n | \"payment_link.canceled\"\n | \"invoice.created\"\n | \"invoice.voided\"\n | \"invoice.overdue\"\n | \"invoice.upcoming\"\n | \"payment_method.attached\"\n | \"payment_method.updated\"\n | \"payment_method.detached\"\n | \"customer.created\"\n | \"customer.updated\"\n | \"customer.state_changed\"\n | \"plan_grant.created\"\n | \"plan_grant.updated\"\n | \"plan_grant.expired\"\n | \"plan_grant.revoked\"\n | \"credits.granted\"\n | \"credits.purchased\"\n | \"credits.low\"\n | \"credits.depleted\"\n | \"credits.expired\"\n | \"balance.granted\"\n | \"balance.topped_up\"\n | \"balance.low\"\n | \"balance.depleted\"\n | \"balance.expired\"\n | \"quota.threshold_reached\"\n | \"quota.exceeded\"\n | \"seats.updated\"\n | \"seats.limit_reached\"\n | \"addon.activated\"\n | \"addon.deactivated\"\n | \"usage.recorded\"\n | \"payout.available\"\n | \"payout.created\"\n | \"payout.paid\"\n | \"payout.failed\"\n >;\n description?: string;\n apiVersion?: string;\n}\n\nexport class GeneratedWebhooksResource extends Webhooks {\n constructor(private httpClient: CommetHTTPClient) {\n super();\n }\n\n /** Retrieve a webhook endpoint by its public ID. */\n async get(\n params: GetWebhookEndpointParams,\n options?: RequestOptions,\n ): Promise<Webhook> {\n const { id } = params;\n return this.httpClient.get(`/webhooks/${id}`, undefined, options);\n }\n\n /** Update a webhook endpoint. Only the provided fields change. */\n async update(\n params: UpdateWebhookEndpointParams,\n options?: RequestOptions,\n ): Promise<Webhook> {\n const { id, ...rest } = params;\n return this.httpClient.patch(`/webhooks/${id}`, rest, options);\n }\n\n /** Permanently delete a webhook endpoint. */\n async delete(\n params: DeleteWebhookEndpointParams,\n options?: RequestOptions,\n ): Promise<DeletedObject> {\n const { id } = params;\n return this.httpClient.delete(`/webhooks/${id}`, undefined, options);\n }\n\n /** Send a test event to a webhook endpoint to verify connectivity. */\n async test(\n params: TestWebhookEndpointParams,\n options?: RequestOptions,\n ): Promise<WebhookTest> {\n const { id } = params;\n return this.httpClient.post(`/webhooks/${id}/test`, {}, options);\n }\n\n /** List webhook endpoints with cursor-based pagination. */\n async list(\n params?: ListWebhookEndpointsParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<Webhook>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/webhooks\", params, options);\n }\n\n /** Create a new webhook endpoint. The response includes the signing secret which is only returned once. */\n async create(\n params: CreateWebhookEndpointParams,\n options?: RequestOptions,\n ): Promise<CreatedWebhook> {\n return this.httpClient.post(\"/webhooks\", params, options);\n }\n}\n","export type CommetClientOptions = {\n apiKey: string;\n apiVersion?: string;\n debug?: boolean;\n timeout?: number;\n retries?: number;\n telemetry?: boolean;\n};\n\nexport interface ApiErrorDetail {\n type: string;\n code: string;\n message: string;\n param?: string;\n details?: unknown;\n doc_url?: string;\n}\n\nexport interface CommetErrorContext {\n type?: string;\n param?: string;\n requestId?: string;\n docUrl?: string;\n}\n\nexport class CommetError extends Error {\n public type?: string;\n public param?: string;\n public requestId?: string;\n public docUrl?: string;\n\n constructor(\n message: string,\n public code?: string,\n public statusCode?: number,\n public details?: unknown,\n context?: CommetErrorContext,\n ) {\n super(message);\n this.name = \"CommetError\";\n this.type = context?.type;\n this.param = context?.param;\n this.requestId = context?.requestId;\n this.docUrl = context?.docUrl;\n }\n\n toJSON(): Record<string, unknown> {\n return {\n name: this.name,\n message: this.message,\n type: this.type,\n code: this.code,\n statusCode: this.statusCode,\n param: this.param,\n details: this.details,\n requestId: this.requestId,\n docUrl: this.docUrl,\n };\n }\n}\n\nexport class CommetAPIError extends CommetError {\n constructor(\n message: string,\n statusCode: number,\n code?: string,\n details?: unknown,\n errorDetail?: ApiErrorDetail,\n responseContext?: Pick<CommetErrorContext, \"requestId\">,\n ) {\n super(message, code, statusCode, details, {\n type: errorDetail?.type,\n param: errorDetail?.param,\n requestId: responseContext?.requestId,\n docUrl: errorDetail?.doc_url,\n });\n this.name = \"CommetAPIError\";\n }\n}\n\nexport class CommetValidationError extends CommetAPIError {\n constructor(\n message: string,\n public validationErrors: Record<string, string[]>,\n statusCode = 422,\n errorDetail?: ApiErrorDetail,\n responseContext?: Pick<CommetErrorContext, \"requestId\">,\n ) {\n super(\n message,\n statusCode,\n errorDetail?.code ?? \"validation_error\",\n errorDetail?.details,\n errorDetail,\n responseContext,\n );\n this.name = \"CommetValidationError\";\n }\n\n override toJSON(): Record<string, unknown> {\n return { ...super.toJSON(), validationErrors: this.validationErrors };\n }\n}\n\nexport interface RequestOptions {\n apiVersion?: string;\n idempotencyKey?: string;\n timeout?: number;\n}\n\nimport type {\n InferFeatureCodes,\n InferPlanCodes,\n InferSeatCodes,\n InferUsageCodes,\n} from \"./config\";\n\nexport type ResolvedFeatureCode<TConfig> = [\n InferFeatureCodes<TConfig>,\n] extends [never]\n ? string\n : InferFeatureCodes<TConfig>;\n\nexport type ResolvedSeatCode<TConfig> = [InferSeatCodes<TConfig>] extends [\n never,\n]\n ? string\n : InferSeatCodes<TConfig>;\n\nexport type ResolvedUsageCode<TConfig> = [InferUsageCodes<TConfig>] extends [\n never,\n]\n ? string\n : InferUsageCodes<TConfig>;\n\nexport type ResolvedPlanCode<TConfig> = [InferPlanCodes<TConfig>] extends [\n never,\n]\n ? string\n : InferPlanCodes<TConfig>;\n","export const API_VERSION = \"2026-08-27\";\n\ndeclare const __SDK_VERSION__: string;\nexport const SDK_VERSION: string = __SDK_VERSION__;\n","import { SDK_VERSION } from \"../version\";\n\ninterface RequestMetrics {\n requestId: string;\n durationMs: number;\n}\n\ntype ExecutionContext = \"test\" | \"ci\";\n\ninterface ClientInfo {\n sdk: string;\n sdk_version: string;\n lang: string;\n lang_version: string;\n platform: string;\n arch: string;\n runtime: string;\n runtime_version: string;\n integrations: string[];\n execution_context?: ExecutionContext;\n}\n\nconst registeredIntegrations: Set<string> = new Set();\n\nexport function registerIntegration(name: string, version: string): void {\n registeredIntegrations.add(`${name}@${version}`);\n cachedClientInfo = null;\n}\n\nfunction detectRuntime(): { name: string; version: string } {\n const g = globalThis as Record<string, unknown>;\n const bun = g.Bun as { version: string } | undefined;\n if (bun) return { name: \"bun\", version: bun.version };\n const deno = g.Deno as { version: { deno: string } } | undefined;\n if (deno) return { name: \"deno\", version: deno.version.deno };\n return { name: \"node\", version: process.versions.node };\n}\n\nfunction detectExecutionContext(): ExecutionContext | undefined {\n const g = globalThis as Record<string, unknown>;\n if (g.__vitest_worker__ !== undefined || g.jest !== undefined) {\n return \"test\";\n }\n if (typeof process === \"undefined\" || !process.env) return undefined;\n const env = process.env;\n if (\n env.VITEST ||\n env.JEST_WORKER_ID ||\n env.BUN_TEST ||\n env.NODE_ENV === \"test\" ||\n env.npm_lifecycle_event === \"test\"\n ) {\n return \"test\";\n }\n if (env.CI || env.GITHUB_ACTIONS || env.GITLAB_CI || env.CIRCLECI) {\n return \"ci\";\n }\n return undefined;\n}\n\nlet cachedClientInfo: string | null = null;\nlet cachedUserAgent: string | null = null;\n\nfunction collectClientInfo(): ClientInfo {\n const runtime = detectRuntime();\n const executionContext = detectExecutionContext();\n const info: ClientInfo = {\n sdk: \"commet-node\",\n sdk_version: SDK_VERSION,\n lang: \"node\",\n lang_version: process.versions.node,\n platform: process.platform,\n arch: process.arch,\n runtime: runtime.name,\n runtime_version: runtime.version,\n integrations: [...registeredIntegrations],\n };\n if (executionContext) {\n info.execution_context = executionContext;\n }\n return info;\n}\n\nexport function getClientInfoHeader(): string {\n if (!cachedClientInfo) {\n cachedClientInfo = JSON.stringify(collectClientInfo());\n }\n return cachedClientInfo;\n}\n\nexport function getUserAgent(): string {\n if (!cachedUserAgent) {\n const runtime = detectRuntime();\n cachedUserAgent = `commet-node/${SDK_VERSION} ${runtime.name}/${runtime.version} ${process.platform}/${process.arch}`;\n }\n return cachedUserAgent;\n}\n\nexport function formatRequestMetrics(metrics: RequestMetrics): string {\n return JSON.stringify({\n last_request_metrics: {\n request_id: metrics.requestId,\n duration_ms: metrics.durationMs,\n },\n });\n}\n","import type {\n ApiErrorDetail,\n CommetClientOptions,\n CommetErrorContext,\n RequestOptions,\n} from \"../types/common\";\nimport { CommetAPIError, CommetValidationError } from \"../types/common\";\nimport { API_VERSION } from \"../version\";\nimport {\n formatRequestMetrics,\n getClientInfoHeader,\n getUserAgent,\n} from \"./telemetry\";\n\nconst BASE_URL = \"https://commet.co\";\n\nexport interface RetryConfig {\n maxRetries: number;\n baseDelay: number;\n maxDelay: number;\n retryableStatusCodes: number[];\n}\n\nconst DEFAULT_RETRY_CONFIG: RetryConfig = {\n maxRetries: 3,\n baseDelay: 1000, // 1s\n maxDelay: 8000, // 8s\n retryableStatusCodes: [408, 429, 500, 502, 503, 504],\n};\n\n// Upper bound for server-provided Retry-After waits, so a misbehaving proxy\n// cannot stall the client indefinitely.\nconst RETRY_AFTER_CAP_MS = 30000;\n\nexport class CommetHTTPClient {\n private config: CommetClientOptions;\n private retryConfig: RetryConfig;\n private telemetryEnabled: boolean;\n private lastRequestMetrics: { requestId: string; durationMs: number } | null =\n null;\n\n constructor(config: CommetClientOptions) {\n this.config = config;\n this.telemetryEnabled = config.telemetry !== false;\n this.retryConfig = {\n ...DEFAULT_RETRY_CONFIG,\n maxRetries: config.retries ?? DEFAULT_RETRY_CONFIG.maxRetries,\n };\n }\n\n async get<T = unknown>(\n endpoint: string,\n params?: Record<string, unknown> | object,\n options?: RequestOptions,\n ): Promise<T> {\n return this.request(\n \"GET\",\n endpoint,\n undefined,\n options,\n params as Record<string, unknown>,\n );\n }\n\n async post<T = unknown>(\n endpoint: string,\n data?: unknown,\n options?: RequestOptions,\n ): Promise<T> {\n return this.request(\"POST\", endpoint, data, options);\n }\n\n async put<T = unknown>(\n endpoint: string,\n data?: unknown,\n options?: RequestOptions,\n ): Promise<T> {\n return this.request(\"PUT\", endpoint, data, options);\n }\n\n async patch<T = unknown>(\n endpoint: string,\n data?: unknown,\n options?: RequestOptions,\n ): Promise<T> {\n return this.request(\"PATCH\", endpoint, data, options);\n }\n\n async delete<T = unknown>(\n endpoint: string,\n data?: unknown,\n options?: RequestOptions,\n ): Promise<T> {\n return this.request(\"DELETE\", endpoint, data, options);\n }\n\n private resolveApiVersion(options?: RequestOptions): string {\n return options?.apiVersion ?? this.config.apiVersion ?? API_VERSION;\n }\n\n private static readonly BODY_METHODS = new Set([\"POST\", \"PUT\", \"PATCH\"]);\n\n private async request<T = unknown>(\n method: string,\n endpoint: string,\n data?: unknown,\n options?: RequestOptions,\n params?: Record<string, unknown>,\n ): Promise<T> {\n const url = this.buildURL(endpoint, params);\n\n // Generate idempotency key once before retries — all attempts reuse the same key\n if (\n CommetHTTPClient.BODY_METHODS.has(method) &&\n this.retryConfig.maxRetries > 0 &&\n !options?.idempotencyKey\n ) {\n options = { ...options, idempotencyKey: this.generateIdempotencyKey() };\n }\n\n return this.executeRequest(method, url, data, options);\n }\n\n /**\n * Execute real API request with retry logic\n */\n private async executeRequest<T = unknown>(\n method: string,\n url: string,\n data?: unknown,\n options?: RequestOptions,\n attempt = 1,\n ): Promise<T> {\n try {\n const apiVersion = this.resolveApiVersion(options);\n\n const headers: Record<string, string> = {\n \"x-api-key\": this.config.apiKey,\n \"commet-version\": apiVersion,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": getUserAgent(),\n };\n\n if (this.telemetryEnabled) {\n headers[\"commet-client-info\"] = getClientInfoHeader();\n if (this.lastRequestMetrics) {\n headers[\"commet-client-telemetry\"] = formatRequestMetrics(\n this.lastRequestMetrics,\n );\n this.lastRequestMetrics = null;\n }\n }\n\n if (options?.idempotencyKey) {\n headers[\"Idempotency-Key\"] = options.idempotencyKey;\n }\n\n const requestConfig: RequestInit = {\n method,\n headers,\n signal: AbortSignal.timeout(\n options?.timeout ?? this.config.timeout ?? 30000,\n ),\n };\n\n if (data) {\n requestConfig.body = JSON.stringify(data);\n }\n\n if (this.config.debug) {\n console.log(`[Commet SDK] ${method} ${url}`);\n if (data) {\n console.log(\"Request data:\", JSON.stringify(data, null, 2));\n }\n }\n\n const requestStart = Date.now();\n const response = await fetch(url, requestConfig);\n const responseContext = readResponseContext(response.headers);\n\n if (this.config.debug) {\n console.log(\n `[Commet SDK] Response status: ${response.status} ${response.statusText}`,\n );\n }\n\n let responseData: unknown;\n let responseText: string;\n\n try {\n responseData = await response.json();\n responseText = \"\";\n } catch (_jsonError) {\n try {\n responseText = await response.text();\n } catch (_textError) {\n responseText = \"Failed to read response body\";\n }\n if (this.config.debug) {\n console.log(\n \"[Commet SDK] Failed to parse JSON response:\",\n responseText,\n );\n }\n\n throw new CommetAPIError(\n `Invalid JSON response: ${response.status} ${response.statusText}`,\n response.status,\n \"INVALID_JSON\",\n { responseText },\n undefined,\n responseContext,\n );\n }\n\n if (!response.ok) {\n // Check if we should retry\n if (\n attempt <= this.retryConfig.maxRetries &&\n this.retryConfig.retryableStatusCodes.includes(response.status)\n ) {\n const delay = this.retryDelayMs(attempt, response);\n\n if (delay !== null) {\n if (this.config.debug) {\n console.log(\n `[Commet SDK] Retrying in ${delay}ms (attempt ${attempt}/${this.retryConfig.maxRetries})`,\n );\n }\n\n await this.sleep(delay);\n return this.executeRequest(method, url, data, options, attempt + 1);\n }\n }\n\n // Log error response for debugging\n if (this.config.debug) {\n console.log(\n \"[Commet SDK] Error response:\",\n JSON.stringify(responseData, null, 2),\n );\n }\n\n const errorObj = readObjectProperty(responseData, \"error\");\n\n const errorDetail: ApiErrorDetail = {\n type: readStringProperty(errorObj, \"type\") ?? \"api_error\",\n code: readStringProperty(errorObj, \"code\") ?? \"unknown\",\n message:\n readStringProperty(errorObj, \"message\") ??\n `Request failed with status ${response.status}`,\n param: readStringProperty(errorObj, \"param\"),\n details: Reflect.get(errorObj, \"details\"),\n doc_url: readStringProperty(errorObj, \"doc_url\"),\n };\n\n if (\n errorDetail.code === \"validation_error\" &&\n Array.isArray(errorDetail.details)\n ) {\n const errors: Record<string, string[]> = {};\n for (const detail of errorDetail.details) {\n const field = readStringProperty(detail, \"field\");\n const message = readStringProperty(detail, \"message\");\n if (!(field && message)) continue;\n if (!errors[field]) errors[field] = [];\n errors[field].push(message);\n }\n throw new CommetValidationError(\n errorDetail.message,\n errors,\n response.status,\n errorDetail,\n responseContext,\n );\n }\n\n throw new CommetAPIError(\n errorDetail.message,\n response.status,\n errorDetail.code,\n errorDetail.details,\n errorDetail,\n responseContext,\n );\n }\n\n if (this.config.debug) {\n console.log(\"[Commet SDK] Response:\", responseData);\n }\n\n if (this.telemetryEnabled && responseContext.requestId) {\n this.lastRequestMetrics = {\n requestId: responseContext.requestId,\n durationMs: Date.now() - requestStart,\n };\n }\n\n return responseData as T;\n } catch (error) {\n // Handle network errors and timeouts\n const isNetworkError =\n error instanceof TypeError && error.message.includes(\"fetch\");\n const isTimeoutError =\n error instanceof DOMException && error.name === \"AbortError\";\n const isTimeoutErrorModern =\n typeof globalThis.DOMException !== \"undefined\" &&\n error instanceof DOMException &&\n error.name === \"TimeoutError\";\n\n if (isNetworkError || isTimeoutError || isTimeoutErrorModern) {\n if (attempt <= this.retryConfig.maxRetries) {\n const delay = this.backoffDelayMs(attempt);\n\n if (this.config.debug) {\n console.log(`[Commet SDK] Network error, retrying in ${delay}ms`);\n }\n\n await this.sleep(delay);\n return this.executeRequest(method, url, data, options, attempt + 1);\n }\n }\n\n throw error;\n }\n }\n\n /**\n * Build full URL from endpoint and params\n */\n private buildURL(endpoint: string, params?: Record<string, unknown>): string {\n // Construct full path with /api prefix\n const normalizedEndpoint = endpoint.startsWith(\"/\")\n ? endpoint\n : `/${endpoint}`;\n const fullPath = `/api/v1${normalizedEndpoint}`;\n\n // Debug logging\n if (this.config.debug) {\n console.log(\n `[Commet SDK] Building URL - endpoint: ${endpoint}, fullPath: ${fullPath}`,\n );\n }\n\n const url = new URL(fullPath, BASE_URL);\n\n if (params) {\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined && value !== null) {\n url.searchParams.append(key, String(value));\n }\n }\n }\n\n const finalUrl = url.toString();\n\n // Debug final URL\n if (this.config.debug) {\n console.log(`[Commet SDK] Final URL: ${finalUrl}`);\n }\n\n return finalUrl;\n }\n\n // 429 retries wait exactly what the rate limiter reports in Retry-After\n // (seconds until the window resets); a 429 without the header did not come\n // from the rate limiter, so it is not retried (returns null). Exponential\n // backoff only applies to statuses that carry no server-provided wait.\n private retryDelayMs(attempt: number, response: Response): number | null {\n if (response.status === 429) {\n const retryAfterSeconds = Number(response.headers.get(\"retry-after\"));\n if (Number.isFinite(retryAfterSeconds) && retryAfterSeconds > 0) {\n return Math.min(retryAfterSeconds * 1000, RETRY_AFTER_CAP_MS);\n }\n return null;\n }\n return this.backoffDelayMs(attempt);\n }\n\n private backoffDelayMs(attempt: number): number {\n return Math.min(\n this.retryConfig.baseDelay * 2 ** (attempt - 1),\n this.retryConfig.maxDelay,\n );\n }\n\n private generateIdempotencyKey(): string {\n return `commet-node-retry-${crypto.randomUUID()}`;\n }\n\n /**\n * Sleep for specified milliseconds\n */\n private sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n}\n\nexport function readResponseContext(\n headers: Headers,\n): Pick<CommetErrorContext, \"requestId\"> {\n return { requestId: headers.get(\"x-request-id\") ?? undefined };\n}\n\nfunction readObjectProperty(value: unknown, property: string): object {\n if (typeof value !== \"object\" || value === null) return {};\n const propertyValue = Reflect.get(value, property);\n return typeof propertyValue === \"object\" && propertyValue !== null\n ? propertyValue\n : {};\n}\n\nfunction readStringProperty(\n value: unknown,\n property: string,\n): string | undefined {\n if (typeof value !== \"object\" || value === null) return undefined;\n const propertyValue = Reflect.get(value, property);\n return typeof propertyValue === \"string\" ? propertyValue : undefined;\n}\n","import { SDK_VERSION } from \"../version\";\n\nconst NPM_DIST_TAGS_URL =\n \"https://registry.npmjs.org/-/package/%40commet%2Fnode/dist-tags\";\nconst UPDATE_CHECK_TIMEOUT_MS = 3000;\nconst UPDATE_CHECK_STATE_KEY = Symbol.for(\"@commet/node.update-check\");\n\ntype VersionNumbers = readonly [number, number, number];\n\ninterface ParsedVersion {\n numbers: VersionNumbers;\n prereleaseIdentifiers: string[];\n}\n\nfunction parseVersion(version: string): ParsedVersion | null {\n const match =\n /^(\\d+)\\.(\\d+)\\.(\\d+)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$/.exec(\n version,\n );\n if (!match) return null;\n\n const numbers: VersionNumbers = [\n Number(match[1]),\n Number(match[2]),\n Number(match[3]),\n ];\n if (!numbers.every(Number.isSafeInteger)) return null;\n\n return {\n numbers,\n prereleaseIdentifiers: match[4] ? match[4].split(\".\") : [],\n };\n}\n\nfunction compareNumericIdentifier(latest: string, installed: string): number {\n const normalizedLatest = latest.replace(/^0+(?=\\d)/, \"\");\n const normalizedInstalled = installed.replace(/^0+(?=\\d)/, \"\");\n if (normalizedLatest.length > normalizedInstalled.length) return 1;\n if (normalizedLatest.length < normalizedInstalled.length) return -1;\n if (normalizedLatest > normalizedInstalled) return 1;\n if (normalizedLatest < normalizedInstalled) return -1;\n return 0;\n}\n\nfunction comparePrereleaseIdentifier(\n latest: string,\n installed: string,\n): number {\n const latestIsNumber = /^\\d+$/.test(latest);\n const installedIsNumber = /^\\d+$/.test(installed);\n\n if (latestIsNumber && installedIsNumber) {\n return compareNumericIdentifier(latest, installed);\n }\n if (latestIsNumber) return -1;\n if (installedIsNumber) return 1;\n if (latest > installed) return 1;\n if (latest < installed) return -1;\n return 0;\n}\n\nfunction comparePrereleaseVersions(\n latest: string[],\n installed: string[],\n): number {\n if (latest.length === 0) return installed.length === 0 ? 0 : 1;\n if (installed.length === 0) return -1;\n\n const identifierCount = Math.max(latest.length, installed.length);\n for (let index = 0; index < identifierCount; index++) {\n const latestIdentifier = latest[index];\n const installedIdentifier = installed[index];\n if (latestIdentifier === undefined) return -1;\n if (installedIdentifier === undefined) return 1;\n\n const comparison = comparePrereleaseIdentifier(\n latestIdentifier,\n installedIdentifier,\n );\n if (comparison !== 0) return comparison;\n }\n\n return 0;\n}\n\nexport function isNewerVersion(latest: string, installed: string): boolean {\n const latestVersion = parseVersion(latest);\n const installedVersion = parseVersion(installed);\n if (!latestVersion || !installedVersion) return false;\n\n for (let index = 0; index < latestVersion.numbers.length; index++) {\n if (latestVersion.numbers[index] > installedVersion.numbers[index]) {\n return true;\n }\n if (latestVersion.numbers[index] < installedVersion.numbers[index]) {\n return false;\n }\n }\n\n return (\n comparePrereleaseVersions(\n latestVersion.prereleaseIdentifiers,\n installedVersion.prereleaseIdentifiers,\n ) > 0\n );\n}\n\nfunction claimSdkUpdateCheck(): boolean {\n if (Reflect.get(globalThis, UPDATE_CHECK_STATE_KEY) === true) return false;\n Reflect.set(globalThis, UPDATE_CHECK_STATE_KEY, true);\n return true;\n}\n\nexport function shouldCheckForSdkUpdates(\n environment: NodeJS.ProcessEnv = process.env,\n): boolean {\n if (environment.NODE_ENV !== \"development\") return false;\n if (environment.CI) return false;\n return environment.COMMET_NO_UPDATE_CHECK !== \"1\";\n}\n\nasync function checkForSdkUpdate(installedVersion: string): Promise<void> {\n try {\n const response = await fetch(NPM_DIST_TAGS_URL, {\n signal: AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS),\n });\n if (!response.ok) return;\n\n const distTags: unknown = await response.json();\n if (\n typeof distTags !== \"object\" ||\n distTags === null ||\n !(\"latest\" in distTags) ||\n typeof distTags.latest !== \"string\" ||\n !isNewerVersion(distTags.latest, installedVersion)\n ) {\n return;\n }\n\n console.warn(\n `[Commet] @commet/node ${installedVersion} is out of date. The latest version is ${distTags.latest}.\\nUpdate with: npm install @commet/node@latest`,\n );\n } catch {}\n}\n\nexport function scheduleSdkUpdateCheck(): void {\n if (!shouldCheckForSdkUpdates() || !claimSdkUpdateCheck()) return;\n\n const scheduledCheck = setImmediate(() => {\n void checkForSdkUpdate(SDK_VERSION);\n });\n scheduledCheck.unref();\n}\n","import { GeneratedResources } from \"./_generated_resources\";\nimport { GeneratedWebhooksResource } from \"./resources/generated-webhooks\";\nimport type { CommetClientOptions } from \"./types/common\";\nimport type { BillingConfig } from \"./types/config\";\nimport { CommetHTTPClient } from \"./utils/http\";\nimport { scheduleSdkUpdateCheck } from \"./utils/update-check\";\n\nexport class Commet<_TConfig = unknown> extends GeneratedResources {\n private httpClient: CommetHTTPClient;\n\n public readonly webhooks: GeneratedWebhooksResource;\n\n constructor(config: CommetClientOptions) {\n super();\n\n if (!config.apiKey) {\n throw new Error(\"Commet SDK: API key is required\");\n }\n\n if (!config.apiKey.startsWith(\"ck_\") && !config.apiKey.startsWith(\"rk_\")) {\n throw new Error(\n \"Commet SDK: Invalid API key format. Expected prefix ck_ or rk_\",\n );\n }\n\n this.httpClient = new CommetHTTPClient(config);\n this.initResources(this.httpClient);\n this.webhooks = new GeneratedWebhooksResource(this.httpClient);\n scheduleSdkUpdateCheck();\n }\n}\n\nexport function createCommet<const TConfig extends BillingConfig>(\n _billingConfig: TConfig,\n options: CommetClientOptions,\n): Commet<TConfig> {\n return new Commet<TConfig>(options);\n}\n","export type FeatureDef =\n | { name: string; type: \"boolean\"; description?: string }\n | {\n name: string;\n type: \"usage\";\n unitName?: string;\n description?: string;\n }\n | {\n name: string;\n type: \"seats\";\n unitName?: string;\n description?: string;\n };\n\nexport interface PriceDef {\n interval:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\";\n /** Rate scale: 10000 = $1.00 */\n amount: number;\n trialDays?: number;\n}\n\nexport type PlanFeatureValue =\n | boolean\n | {\n included?: number;\n unlimited?: boolean;\n overage?: { unitPrice: number };\n };\n\nexport interface PlanDef {\n name: string;\n description?: string;\n consumptionModel?: \"metered\" | \"credits\" | \"balance\";\n defaultInterval?: PriceDef[\"interval\"];\n isFree?: boolean;\n isPublic?: boolean;\n sortOrder?: number;\n prices: PriceDef[];\n features?: Record<string, PlanFeatureValue>;\n}\n\nexport interface BillingConfig {\n features: Record<string, FeatureDef>;\n plans: Record<string, PlanDef>;\n}\n\nexport function defineConfig<const T extends BillingConfig>(config: T): T {\n return config;\n}\n\nexport type InferFeatureCodes<T> = T extends { features: infer F }\n ? keyof F & string\n : never;\n\nexport type InferPlanCodes<T> = T extends { plans: infer P }\n ? keyof P & string\n : never;\n\nexport type InferSeatCodes<T> = T extends { features: infer F }\n ? {\n [K in keyof F]: F[K] extends { type: \"seats\" } ? K & string : never;\n }[keyof F]\n : never;\n\nexport type InferUsageCodes<T> = T extends { features: infer F }\n ? {\n [K in keyof F]: F[K] extends { type: \"usage\" } ? K & string : never;\n }[keyof F]\n : never;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACgEO,IAAM,iBAAN,MAAqB;AAAA,EAC1B,YAAoB,YAA8B;AAA9B;AAAA,EAA+B;AAAA;AAAA,EAGnD,MAAM,WACJ,QACA,SAMC;AACD,WAAO,KAAK,WAAW,IAAI,kBAAkB,QAAQ,OAAO;AAAA,EAC9D;AAAA;AAAA,EAGA,MAAM,IAAI,QAAwB,SAA0C;AAC1E,UAAM,EAAE,GAAG,IAAI;AACf,WAAO,KAAK,WAAW,IAAI,WAAW,EAAE,IAAI,QAAW,OAAO;AAAA,EAChE;AAAA;AAAA,EAGA,MAAM,OACJ,QACA,SACgB;AAChB,UAAM,EAAE,IAAI,GAAG,KAAK,IAAI;AACxB,WAAO,KAAK,WAAW,MAAM,WAAW,EAAE,IAAI,MAAM,OAAO;AAAA,EAC7D;AAAA;AAAA,EAGA,MAAM,OACJ,QACA,SACwB;AACxB,UAAM,EAAE,GAAG,IAAI;AACf,WAAO,KAAK,WAAW,OAAO,WAAW,EAAE,IAAI,QAAW,OAAO;AAAA,EACnE;AAAA;AAAA,EAGA,MAAM,KACJ,QACA,SAMC;AACD,WAAO,KAAK,WAAW,IAAI,WAAW,QAAQ,OAAO;AAAA,EACvD;AAAA;AAAA,EAGA,MAAM,OACJ,QACA,SACgB;AAChB,WAAO,KAAK,WAAW,KAAK,WAAW,QAAQ,OAAO;AAAA,EACxD;AACF;;;ACrFO,IAAM,kBAAN,MAAsB;AAAA,EAC3B,YAAoB,YAA8B;AAA9B;AAAA,EAA+B;AAAA;AAAA,EAGnD,MAAM,OACJ,QACA,SACwB;AACxB,UAAM,EAAE,GAAG,IAAI;AACf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","../src/resources/api-keys.ts","../src/resources/credit-packs.ts","../src/resources/customers.ts","../src/resources/feature-access.ts","../src/resources/features.ts","../src/resources/invoices.ts","../src/resources/markets.ts","../src/resources/offers.ts","../src/resources/payments.ts","../src/resources/payouts.ts","../src/resources/plan-groups.ts","../src/resources/plans.ts","../src/resources/portal.ts","../src/resources/promo-codes.ts","../src/resources/provisioning.ts","../src/resources/quota.ts","../src/resources/seats.ts","../src/resources/subscriptions.ts","../src/resources/test-clock.ts","../src/resources/transactions.ts","../src/resources/usage.ts","../src/_generated_resources.ts","../src/resources/webhooks.ts","../src/resources/generated-webhooks.ts","../src/types/common.ts","../src/version.ts","../src/utils/telemetry.ts","../src/utils/http.ts","../src/utils/update-check.ts","../src/client.ts","../src/types/config.ts"],"sourcesContent":["export { Commet, createCommet } from \"./client\";\nexport type {\n CreateAddonParams,\n DeleteAddonParams,\n GetAddonParams,\n ListActiveAddonsParams,\n ListAddonsParams,\n UpdateAddonParams,\n} from \"./resources/addons\";\nexport type {\n CreateApiKeyParams,\n DeleteApiKeyParams,\n ListApiKeysParams,\n} from \"./resources/api-keys\";\nexport type {\n CreateCreditPackParams,\n DeleteCreditPackParams,\n UpdateCreditPackParams,\n} from \"./resources/credit-packs\";\nexport type {\n BatchCreateCustomersParams,\n CreateCustomerCreditParams,\n CreateCustomerParams,\n CreatePlanGrantParams,\n GetCustomerParams,\n ListCustomerCreditsParams,\n ListCustomersParams,\n ListPlanGrantsParams,\n RevokeCustomerCreditParams,\n RevokePlanGrantParams,\n UpdateCustomerParams,\n UpdatePlanGrantParams,\n} from \"./resources/customers\";\nexport type {\n GetFeatureAccessParams,\n ListFeatureAccessParams,\n} from \"./resources/feature-access\";\nexport type {\n CreateFeatureParams,\n DeleteFeatureParams,\n GetFeatureParams,\n UpdateFeatureParams,\n} from \"./resources/features\";\nexport type {\n CreateWebhookEndpointParams,\n DeleteWebhookEndpointParams,\n GetWebhookEndpointParams,\n ListWebhookEndpointsParams,\n TestWebhookEndpointParams,\n UpdateWebhookEndpointParams,\n} from \"./resources/generated-webhooks\";\nexport type {\n CreateAdjustmentInvoiceParams,\n DownloadInvoiceParams,\n GetInvoiceParams,\n ListInvoicesParams,\n SendInvoiceParams,\n UpdateInvoiceStatusParams,\n} from \"./resources/invoices\";\nexport type {\n CreateMarketParams,\n DeleteMarketParams,\n GetMarketParams,\n UpdateMarketParams,\n} from \"./resources/markets\";\nexport type {\n CreateOfferParams,\n DeleteOfferParams,\n GetOfferParams,\n ListOffersParams,\n UpdateOfferParams,\n} from \"./resources/offers\";\nexport type {\n CancelPaymentParams,\n ChargePaymentParams,\n CreatePaymentParams,\n GetPaymentParams,\n ListPaymentsParams,\n} from \"./resources/payments\";\nexport type {\n AddPayoutBankAccountParams,\n RequestPayoutParams,\n} from \"./resources/payouts\";\nexport type {\n AddPlanToGroupParams,\n CreatePlanGroupParams,\n DeletePlanGroupParams,\n GetPlanGroupParams,\n ListPlanGroupsParams,\n RemovePlanFromGroupParams,\n ReorderPlansInGroupParams,\n UpdatePlanGroupParams,\n} from \"./resources/plan-groups\";\nexport type {\n AddPlanFeatureParams,\n AddPlanPriceParams,\n ArchivePlanExperimentParams,\n CancelPlanMoveParams,\n CancelPlanMoveSubscriptionParams,\n ComparePlanVersionsParams,\n CreatePlanDraftParams,\n CreatePlanExperimentParams,\n CreatePlanExperimentVersionParams,\n CreatePlanMoveParams,\n CreatePlanParams,\n CreatePlanVersionParams,\n DeletePlanDraftParams,\n DeletePlanParams,\n DeletePlanPriceParams,\n DeleteRegionalPricesParams,\n GetPlanDraftParams,\n GetPlanExperimentParams,\n GetPlanMoveParams,\n GetPlanParams,\n GetPlanVersionParams,\n KeepPlanSubscriberOnVersionParams,\n ListPlanDraftsParams,\n ListPlanExperimentsParams,\n ListPlanMovesParams,\n ListPlanSubscribersNeedingAChangeParams,\n ListPlanVersionsParams,\n ListPlansParams,\n MakePlanExperimentCurrentParams,\n PublishPlanDraftParams,\n RemovePlanFeatureParams,\n SetDefaultPlanPriceParams,\n SetPlanRegionalPricingParams,\n SetPlanVisibilityParams,\n UpdatePlanDraftParams,\n UpdatePlanFeatureParams,\n UpdatePlanParams,\n UpdatePlanPriceParams,\n UpsertRegionalPricesParams,\n} from \"./resources/plans\";\nexport type { RequestPortalAccessParams } from \"./resources/portal\";\nexport type {\n CreatePromoCodeParams,\n GetPromoCodeParams,\n ListPromoCodesParams,\n UpdatePromoCodeParams,\n} from \"./resources/promo-codes\";\nexport type {\n AddQuotaParams,\n GetAllQuotaAllowancesParams,\n GetQuotaAllowanceParams,\n RemoveQuotaParams,\n SetQuotaParams,\n} from \"./resources/quota\";\nexport type {\n AddSeatsParams,\n BulkSetSeatsParams,\n GetAllSeatBalancesParams,\n GetSeatBalanceParams,\n RemoveSeatsParams,\n SetSeatsParams,\n} from \"./resources/seats\";\nexport type {\n ActivateAddonParams,\n AdjustBalanceParams,\n ApplySubscriptionOfferParams,\n CancelSubscriptionParams,\n ChangePlanParams,\n ChangeSubscriptionVersionParams,\n CreatePrepaidPeriodsCheckoutParams,\n CreateSubscriptionParams,\n CreateSubscriptionRecoveryLinkParams,\n DeactivateAddonParams,\n GetActiveSubscriptionParams,\n GetSubscriptionAutoTopUpParams,\n GetSubscriptionParams,\n ListSubscriptionsParams,\n PauseSubscriptionParams,\n PreviewChangePlanParams,\n PurchaseCreditsParams,\n ReactivateSubscriptionParams,\n RemoveSubscriptionOfferParams,\n ResumeSubscriptionParams,\n RevokeScheduledPlanChangeParams,\n RevokeScheduledVersionChangeParams,\n RevokeSubscriptionPauseParams,\n TopupBalanceParams,\n UncancelSubscriptionParams,\n UpdatePaymentMethodParams,\n UpdateSubscriptionAutoTopUpParams,\n UpdateSubscriptionPauseParams,\n} from \"./resources/subscriptions\";\nexport type { AdvanceTestClockParams } from \"./resources/test-clock\";\nexport type {\n GetTransactionParams,\n ListTransactionsParams,\n RefundTransactionParams,\n RetryTransactionParams,\n} from \"./resources/transactions\";\nexport type {\n CheckUsageAvailabilityParams,\n SetUsageParams,\n TrackUsageParams,\n} from \"./resources/usage\";\nexport type {\n WebhookData,\n WebhookEventHandler,\n WebhookPayload,\n} from \"./resources/webhooks\";\nexport { Webhooks } from \"./resources/webhooks\";\nexport type {\n ApiErrorDetail,\n CommetClientOptions,\n CommetErrorContext,\n RequestOptions,\n ResolvedFeatureCode,\n ResolvedPlanCode,\n ResolvedSeatCode,\n ResolvedUsageCode,\n} from \"./types/common\";\nexport {\n CommetAPIError,\n CommetError,\n CommetValidationError,\n} from \"./types/common\";\nexport type {\n BillingConfig,\n FeatureDef,\n InferFeatureCodes,\n InferPlanCodes,\n InferSeatCodes,\n InferUsageCodes,\n PlanDef,\n PlanFeatureValue,\n PriceDef,\n} from \"./types/config\";\nexport { defineConfig } from \"./types/config\";\nexport type {\n BillingInterval,\n ConsumptionModel,\n FeatureType,\n InvoiceType,\n PaymentMethod,\n PaymentProvider,\n SubPaymentMethod,\n SubscriptionStatus,\n Timezone,\n TransactionStatus,\n} from \"./types/enums\";\nexport type {\n ActiveAddon,\n AddedPlanToGroup,\n Addon,\n ApiKey,\n BalanceAdjustment,\n BalanceTopup,\n BusinessTaxId,\n ClaimLink,\n CreatedApiKey,\n CreatedSubscription,\n CreatedWebhook,\n CreditGrant,\n CreditPack,\n CreditPackListItem,\n Customer,\n CustomerBatch,\n CustomerCredit,\n CustomerCreditRevocation,\n DeletedObject,\n DeletedOffer,\n DeletedPlanRegionalPricing,\n DeletedSubscriptionAddon,\n Feature,\n FeatureAccess,\n Invoice,\n InvoiceDownload,\n InvoiceListItem,\n KeptOnVersion,\n ManagedBy,\n Market,\n Offer,\n Payment,\n PaymentMethodUpdateCheckout,\n Payout,\n PayoutBankAccount,\n Plan,\n PlanChange,\n PlanDraft,\n PlanDraftPublication,\n PlanExperiment,\n PlanExperimentArchive,\n PlanFeature,\n PlanGrant,\n PlanGroup,\n PlanGroupDetail,\n PlanMove,\n PlanPrice,\n PlanRegionalPricing,\n PlanRegionalPricingResult,\n PlanVersion,\n PlanVersionComparison,\n PortalAccess,\n PrepaidPeriodsCheckout,\n PreviewChange,\n PromoCode,\n ReactivatedSubscription,\n RecoveryLink,\n Refund,\n RemovedPlanFeature,\n RemovedPlanFromGroup,\n ReorderedPlans,\n SeatBalance,\n SeatBalanceCollection,\n SeatEvent,\n SentInvoice,\n SubscriberNeedingAChange,\n Subscription,\n SubscriptionAddon,\n SubscriptionAutoTopUp,\n SubscriptionOfferApplication,\n SubscriptionOfferApplicationPhase,\n SubscriptionResume,\n SubscriptionSummary,\n TestClock,\n TestClockRun,\n Transaction,\n TransactionListItem,\n TransactionRetry,\n UsageAdjustment,\n UsageCheck,\n UsageEvent,\n UsageQuota,\n UsageQuotaEvent,\n Webhook,\n WebhookAddonRef,\n WebhookBalance,\n WebhookBankRef,\n WebhookCardInfo,\n WebhookCreditsBalance,\n WebhookPlanGrantTimelineEvent,\n WebhookPlanRef,\n WebhookSeatSummary,\n WebhookTest,\n} from \"./types/models\";\nexport type * from \"./types/webhook-events\";\nexport { registerIntegration } from \"./utils/telemetry\";\nexport { API_VERSION, SDK_VERSION } from \"./version\";\n\nimport { Commet } from \"./client\";\nexport default Commet;\n","import type { RequestOptions } from \"../types/common\";\nimport type { ActiveAddon, Addon, DeletedObject } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface ListActiveAddonsParams {\n customerId: string;\n}\n\nexport interface GetAddonParams {\n id: string;\n}\n\nexport interface UpdateAddonParams {\n id: string;\n name?: string;\n description?: string;\n basePrice?: number;\n includedUnits?: number;\n overageRate?: number;\n /** Plans that sell the add-on, replacing the current ones. Empty means every plan; omitted keeps them. Removing a plan is rejected with addon_has_activations while a subscription of that plan has the add-on active. */\n planIds?: Array<string>;\n}\n\nexport interface DeleteAddonParams {\n id: string;\n}\n\nexport interface ListAddonsParams {\n cursor?: string;\n limit?: number;\n}\n\nexport type CreateAddonParams =\n | {\n name: string;\n description?: string;\n basePrice: number;\n featureId: string;\n /** Plans that sell the add-on. Omitted or empty, every plan sells it. Plans created later sell it too. */\n planIds?: Array<string>;\n consumptionModel: \"boolean\";\n }\n | {\n name: string;\n description?: string;\n basePrice: number;\n featureId: string;\n /** Plans that sell the add-on. Omitted or empty, every plan sells it. Plans created later sell it too. */\n planIds?: Array<string>;\n consumptionModel: \"metered\";\n includedUnits: number;\n overageRate: number;\n }\n | {\n name: string;\n description?: string;\n basePrice: number;\n featureId: string;\n /** Plans that sell the add-on. Omitted or empty, every plan sells it. Plans created later sell it too. */\n planIds?: Array<string>;\n consumptionModel: \"credits\";\n creditCost: number;\n }\n | {\n name: string;\n description?: string;\n basePrice: number;\n featureId: string;\n /** Plans that sell the add-on. Omitted or empty, every plan sells it. Plans created later sell it too. */\n planIds?: Array<string>;\n consumptionModel: \"balance\";\n overageRate: number;\n };\n\nexport class AddonsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** List all active add-ons for a customer's subscription. */\n async listActive(\n params: ListActiveAddonsParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<ActiveAddon>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/active-addons\", params, options);\n }\n\n /** Retrieve an add-on by its public ID or slug. */\n async get(params: GetAddonParams, options?: RequestOptions): Promise<Addon> {\n const { id } = params;\n return this.httpClient.get(`/addons/${id}`, undefined, options);\n }\n\n /** Update an add-on's name, description, pricing, or the plans that sell it. */\n async update(\n params: UpdateAddonParams,\n options?: RequestOptions,\n ): Promise<Addon> {\n const { id, ...rest } = params;\n return this.httpClient.patch(`/addons/${id}`, rest, options);\n }\n\n /** Soft-delete an add-on. Fails if the add-on has active subscriptions. */\n async delete(\n params: DeleteAddonParams,\n options?: RequestOptions,\n ): Promise<DeletedObject> {\n const { id } = params;\n return this.httpClient.delete(`/addons/${id}`, undefined, options);\n }\n\n /** List all add-ons with cursor-based pagination. */\n async list(\n params?: ListAddonsParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<Addon>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/addons\", params, options);\n }\n\n /** Create a new add-on linked to a feature. Each feature can only be assigned to one add-on. */\n async create(\n params: CreateAddonParams,\n options?: RequestOptions,\n ): Promise<Addon> {\n return this.httpClient.post(\"/addons\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { ApiKey, CreatedApiKey, DeletedObject } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface DeleteApiKeyParams {\n id: string;\n}\n\nexport interface ListApiKeysParams {\n cursor?: string;\n limit?: number;\n}\n\nexport interface CreateApiKeyParams {\n name: string;\n expiresInDays?: number;\n permissions?: {\n customer?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n subscription?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n invoice?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n usage?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n seat?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n plan?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n plan_group?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n feature?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n addon?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n credit_pack?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n offer?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n promo_code?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n market_group?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n payment?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n transaction?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n payout?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n test_clock?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n organization?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n api_key?: Array<\"read\"> | [\"read\", \"write\"] | [\"write\", \"read\"];\n };\n}\n\nexport class ApiKeysResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Permanently revoke and delete an API key. */\n async delete(\n params: DeleteApiKeyParams,\n options?: RequestOptions,\n ): Promise<DeletedObject> {\n const { id } = params;\n return this.httpClient.delete(`/api-keys/${id}`, undefined, options);\n }\n\n /** List API keys with cursor-based pagination. Keys are returned without the full secret. */\n async list(\n params?: ListApiKeysParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<ApiKey>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/api-keys\", params, options);\n }\n\n /** Create a full-access or restricted API key. Provide permissions to restrict access; the full key is returned only once. A restricted key with api_key: write may only create restricted keys with the same or fewer permissions, and they expire no later than the key that creates them. */\n async create(\n params: CreateApiKeyParams,\n options?: RequestOptions,\n ): Promise<CreatedApiKey> {\n return this.httpClient.post(\"/api-keys\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type {\n CreditPack,\n CreditPackListItem,\n DeletedObject,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface UpdateCreditPackParams {\n id: string;\n name?: string;\n description?: string;\n credits?: number;\n price?: number;\n isActive?: boolean;\n /** Plans that sell the credit pack, replacing the current ones. Empty means every plan; omitted keeps them. */\n planIds?: Array<string>;\n}\n\nexport interface DeleteCreditPackParams {\n id: string;\n}\n\nexport interface CreateCreditPackParams {\n name: string;\n description?: string;\n credits: number;\n price: number;\n isActive?: boolean;\n /** Plans that sell the credit pack. Omitted or empty, every plan sells it. Plans created later sell it too. */\n planIds?: Array<string>;\n}\n\nexport class CreditPacksResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Update a credit pack's name, description, credits, price, active status, or the plans that sell it. */\n async update(\n params: UpdateCreditPackParams,\n options?: RequestOptions,\n ): Promise<CreditPack> {\n const { id, ...rest } = params;\n return this.httpClient.patch(`/credit-packs/${id}`, rest, options);\n }\n\n /** Soft-delete a credit pack. */\n async delete(\n params: DeleteCreditPackParams,\n options?: RequestOptions,\n ): Promise<DeletedObject> {\n const { id } = params;\n return this.httpClient.delete(`/credit-packs/${id}`, undefined, options);\n }\n\n /** List all active credit packs. */\n async list(): Promise<{\n object: \"list\";\n data: Array<CreditPackListItem>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/credit-packs\");\n }\n\n /** Create a new credit pack. */\n async create(\n params: CreateCreditPackParams,\n options?: RequestOptions,\n ): Promise<CreditPack> {\n return this.httpClient.post(\"/credit-packs\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { Timezone } from \"../types/enums\";\nimport type {\n Customer,\n CustomerBatch,\n CustomerCredit,\n CustomerCreditRevocation,\n PlanGrant,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface RevokeCustomerCreditParams {\n id: string;\n creditId: string;\n}\n\nexport interface ListCustomerCreditsParams {\n id: string;\n}\n\nexport interface CreateCustomerCreditParams {\n id: string;\n /** Amount in the currency's smallest unit. */\n amount: number;\n currency:\n | \"usd\"\n | \"ars\"\n | \"brl\"\n | \"clp\"\n | \"cop\"\n | \"pen\"\n | \"uyu\"\n | \"pyg\"\n | \"bob\"\n | \"mxn\"\n | \"cad\"\n | \"eur\"\n | \"gbp\"\n | \"jpy\"\n | \"cny\"\n | \"krw\"\n | \"hkd\"\n | \"sgd\"\n | \"twd\"\n | \"inr\"\n | \"thb\";\n reason: string;\n expiresAt?: string | null;\n}\n\nexport interface RevokePlanGrantParams {\n id: string;\n grantId: string;\n reason: string;\n}\n\nexport type UpdatePlanGrantParams =\n | {\n id: string;\n grantId: string;\n reason: string;\n duration: \"cycles\";\n durationCycles: number;\n }\n | {\n id: string;\n grantId: string;\n reason: string;\n duration: \"until_date\";\n /** @format date-time */\n expiresAt: string;\n }\n | {\n id: string;\n grantId: string;\n reason: string;\n duration: \"until_revoked\";\n };\n\nexport interface ListPlanGrantsParams {\n id: string;\n}\n\nexport type CreatePlanGrantParams =\n | {\n id: string;\n subscriptionId: string;\n planId: string;\n reason: string;\n duration: \"cycles\";\n durationCycles: number;\n }\n | {\n id: string;\n subscriptionId: string;\n planId: string;\n reason: string;\n duration: \"until_date\";\n /** @format date-time */\n expiresAt: string;\n }\n | {\n id: string;\n subscriptionId: string;\n planId: string;\n reason: string;\n duration: \"until_revoked\";\n };\n\nexport interface GetCustomerParams {\n id: string;\n}\n\nexport interface UpdateCustomerParams {\n id: string;\n email?: string;\n fullName?: string;\n taxDocument?: string;\n /** Business tax ID, such as an EU VAT number or a Peruvian RUC, for the country of the customer's address. Accepted only where Commet collects tax; a valid ID replaces consumer tax with the business treatment. Send null to remove it. */\n businessTaxId?: string | null;\n externalId?: string;\n timezone?: Timezone;\n metadata?: Record<string, unknown>;\n address?: {\n line1: string;\n line2?: string;\n city: string;\n state?: string;\n postalCode: string;\n country: string;\n region?: string;\n };\n}\n\nexport interface BatchCreateCustomersParams {\n customers: Array<{\n email: string;\n id?: string;\n externalId?: string;\n fullName?: string;\n taxDocument?: string;\n timezone?: Timezone;\n metadata?: Record<string, unknown>;\n address?: {\n line1: string;\n line2?: string;\n city: string;\n state?: string;\n postalCode: string;\n country: string;\n region?: string;\n };\n }>;\n /** Plan group whose starting plan the customer starts on when it has no open subscription: its signup trial, a trial without a payment method, when the group has one and the customer never had that plan, otherwise its default plan. A customer who already had the signup trial plan in a group without a default plan starts on none. Without it, no plan is assigned. */\n planGroupId?: string;\n}\n\nexport interface ListCustomersParams {\n cursor?: string;\n limit?: number;\n externalId?: string;\n}\n\nexport interface CreateCustomerParams {\n id?: string;\n externalId?: string;\n fullName?: string;\n taxDocument?: string;\n /** Business tax ID, such as an EU VAT number or a Peruvian RUC, for the country of the customer's address. Accepted only where Commet collects tax; a valid ID replaces consumer tax with the business treatment. */\n businessTaxId?: string;\n address?: {\n line1: string;\n line2?: string;\n city: string;\n state?: string;\n postalCode: string;\n country: string;\n region?: string;\n };\n addressId?: string;\n email: string;\n timezone?: Timezone;\n metadata?: Record<string, unknown>;\n /** Plan group whose starting plan the customer starts on when it has no open subscription: its signup trial, a trial without a payment method, when the group has one and the customer never had that plan, otherwise its default plan. A customer who already had the signup trial plan in a group without a default plan starts on none. Without it, no plan is assigned. */\n planGroupId?: string;\n}\n\nexport class CustomersResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Revoke the unallocated remainder of a customer credit grant. Applied invoice history is unchanged. */\n async revokeCredit(\n params: RevokeCustomerCreditParams,\n options?: RequestOptions,\n ): Promise<CustomerCreditRevocation> {\n const { id, creditId } = params;\n return this.httpClient.post(\n `/customers/${id}/credits/${creditId}/revoke`,\n {},\n options,\n );\n }\n\n /** List currency-specific invoice credit grants and their remaining balances for a customer. */\n async listCredits(\n params: ListCustomerCreditsParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<CustomerCredit>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n const { id } = params;\n return this.httpClient.get(`/customers/${id}/credits`, undefined, options);\n }\n\n /** Grant monetary credit in one currency. Credit is applied FIFO before tax to eligible recurring invoices. */\n async createCredit(\n params: CreateCustomerCreditParams,\n options?: RequestOptions,\n ): Promise<CustomerCredit> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/customers/${id}/credits`, rest, options);\n }\n\n /** End expanded access immediately and restore the base plan's limits. The subscription, billing cycle, invoices, and payment state remain unchanged. */\n async revokePlanGrant(\n params: RevokePlanGrantParams,\n options?: RequestOptions,\n ): Promise<PlanGrant> {\n const { id, grantId, ...rest } = params;\n return this.httpClient.post(\n `/customers/${id}/plan-grants/${grantId}/revoke`,\n rest,\n options,\n );\n }\n\n /** Keep the overlay for a number of the subscription's existing billing cycles, set an exact deadline, or leave it active until revoked. The billing anchor is never reset. */\n async updatePlanGrant(\n params: UpdatePlanGrantParams,\n options?: RequestOptions,\n ): Promise<PlanGrant> {\n const { id, grantId, ...rest } = params;\n return this.httpClient.patch(\n `/customers/${id}/plan-grants/${grantId}`,\n rest,\n options,\n );\n }\n\n /** List the independent audit timeline for paid-plan access granted without checkout or payment credentials. */\n async listPlanGrants(\n params: ListPlanGrantsParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<PlanGrant>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n const { id } = params;\n return this.httpClient.get(\n `/customers/${id}/plan-grants`,\n undefined,\n options,\n );\n }\n\n /** Temporarily expand an active subscription's feature access using a higher plan in the same plan group. Billing, prices, periods, invoices, and the base subscription remain unchanged. */\n async createPlanGrant(\n params: CreatePlanGrantParams,\n options?: RequestOptions,\n ): Promise<PlanGrant> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/customers/${id}/plan-grants`, rest, options);\n }\n\n /** Retrieve a customer by their public ID, including subscription status and metadata. */\n async get(\n params: GetCustomerParams,\n options?: RequestOptions,\n ): Promise<Customer> {\n const { id } = params;\n return this.httpClient.get(`/customers/${id}`, undefined, options);\n }\n\n /** Update a customer's name, external ID, or metadata. */\n async update(\n params: UpdateCustomerParams,\n options?: RequestOptions,\n ): Promise<Customer> {\n const { id, ...rest } = params;\n return this.httpClient.patch(`/customers/${id}`, rest, options);\n }\n\n /** Create up to 100 customers in a single request. With planGroupId, each customer without an open subscription starts on that group's starting plan (see planGroupId), and the entry of a deleted customer fails with customer_deleted. */\n async createBatch(\n params: BatchCreateCustomersParams,\n options?: RequestOptions,\n ): Promise<CustomerBatch> {\n return this.httpClient.post(\"/customers/batch\", params, options);\n }\n\n /** List customers with cursor-based pagination. */\n async list(\n params?: ListCustomersParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<Customer>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/customers\", params, options);\n }\n\n /** Create a new customer. Idempotent when customerId is provided. With planGroupId, a customer without an open subscription starts on that group's starting plan (see planGroupId), and the externalId of a deleted customer is rejected. */\n async create(\n params: CreateCustomerParams,\n options?: RequestOptions,\n ): Promise<Customer> {\n return this.httpClient.post(\"/customers\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { FeatureAccess } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface GetFeatureAccessParams {\n code: string;\n customerId: string;\n}\n\nexport interface ListFeatureAccessParams {\n customerId: string;\n}\n\nexport class FeatureAccessResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Get one feature's access and current usage for a customer. To evaluate a prospective consumption, use POST /usage/check. */\n async get(\n params: GetFeatureAccessParams,\n options?: RequestOptions,\n ): Promise<FeatureAccess> {\n const { code, ...rest } = params;\n return this.httpClient.get(`/feature-access/${code}`, rest, options);\n }\n\n /** List a customer's feature access and current usage. */\n async list(\n params: ListFeatureAccessParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<FeatureAccess>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/feature-access\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { DeletedObject, Feature } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface GetFeatureParams {\n code: string;\n}\n\nexport interface UpdateFeatureParams {\n code: string;\n name?: string;\n description?: string | null;\n unitName?: string | null;\n}\n\nexport interface DeleteFeatureParams {\n code: string;\n}\n\nexport interface CreateFeatureParams {\n name: string;\n code: string;\n type: \"boolean\" | \"usage\" | \"seats\" | \"quota\";\n description?: string;\n unitName?: string;\n}\n\nexport class FeaturesResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Get a single feature definition by code from the organization's feature catalog. */\n async get(\n params: GetFeatureParams,\n options?: RequestOptions,\n ): Promise<Feature> {\n const { code } = params;\n return this.httpClient.get(`/features/${code}`, undefined, options);\n }\n\n /** Update a feature's name, description, or unit name. At least one field must be provided. */\n async update(\n params: UpdateFeatureParams,\n options?: RequestOptions,\n ): Promise<Feature> {\n const { code, ...rest } = params;\n return this.httpClient.patch(`/features/${code}`, rest, options);\n }\n\n /** Delete a feature. Fails if the feature is attached to active plans or has an active add-on. */\n async delete(\n params: DeleteFeatureParams,\n options?: RequestOptions,\n ): Promise<DeletedObject> {\n const { code } = params;\n return this.httpClient.delete(`/features/${code}`, undefined, options);\n }\n\n /** List every feature defined in the organization. This is the organization's feature catalog (definitions), not a customer's feature access. */\n async list(): Promise<{\n object: \"list\";\n data: Array<Feature>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/features\");\n }\n\n /** Create a new feature. Code must be lowercase alphanumeric with underscores. */\n async create(\n params: CreateFeatureParams,\n options?: RequestOptions,\n ): Promise<Feature> {\n return this.httpClient.post(\"/features\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type {\n Invoice,\n InvoiceDownload,\n InvoiceListItem,\n SentInvoice,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface DownloadInvoiceParams {\n id: string;\n}\n\nexport interface GetInvoiceParams {\n id: string;\n}\n\nexport interface SendInvoiceParams {\n id: string;\n}\n\nexport interface UpdateInvoiceStatusParams {\n id: string;\n status: \"paid\" | \"void\";\n}\n\nexport interface ListInvoicesParams {\n cursor?: string;\n limit?: number;\n customerId?: string;\n status?: \"draft\" | \"outstanding\" | \"paid\" | \"void\" | \"uncollectible\";\n subscriptionId?: string;\n}\n\nexport interface CreateAdjustmentInvoiceParams {\n customerId: string;\n amount: number;\n description: string;\n metadata?: Record<string, unknown>;\n}\n\nexport class InvoicesResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Generate a signed URL to download the invoice as a PDF. The URL expires after 7 days. */\n async getDownloadUrl(\n params: DownloadInvoiceParams,\n options?: RequestOptions,\n ): Promise<InvoiceDownload> {\n const { id } = params;\n return this.httpClient.post(`/invoices/${id}/download-links`, {}, options);\n }\n\n /** Retrieve a single invoice by its public ID, including line items. */\n async get(\n params: GetInvoiceParams,\n options?: RequestOptions,\n ): Promise<Invoice> {\n const { id } = params;\n return this.httpClient.get(`/invoices/${id}`, undefined, options);\n }\n\n /** Send the invoice to the customer via email. */\n async send(\n params: SendInvoiceParams,\n options?: RequestOptions,\n ): Promise<SentInvoice> {\n const { id } = params;\n return this.httpClient.post(`/invoices/${id}/send`, {}, options);\n }\n\n /** Mark an outstanding invoice as \"paid\" or \"void\" and return the updated invoice. Cannot change the status of already paid or voided invoices. */\n async updateStatus(\n params: UpdateInvoiceStatusParams,\n options?: RequestOptions,\n ): Promise<Invoice> {\n const { id, ...rest } = params;\n return this.httpClient.patch(`/invoices/${id}/status`, rest, options);\n }\n\n /** List invoices with cursor-based pagination. Filter by customer, status, or subscription. */\n async list(\n params?: ListInvoicesParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<InvoiceListItem>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/invoices\", params, options);\n }\n\n /** Create a one-off adjustment invoice and return the created invoice. Use a negative amount for a credit. */\n async createAdjustment(\n params: CreateAdjustmentInvoiceParams,\n options?: RequestOptions,\n ): Promise<Invoice> {\n return this.httpClient.post(\"/invoices\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { DeletedObject, Market } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface GetMarketParams {\n id: string;\n}\n\nexport interface UpdateMarketParams {\n id: string;\n name: string;\n countryCodes: Array<string>;\n metadata?: Record<string, unknown>;\n}\n\nexport interface DeleteMarketParams {\n id: string;\n}\n\nexport interface CreateMarketParams {\n name: string;\n countryCodes: Array<string>;\n metadata?: Record<string, unknown>;\n}\n\nexport class MarketsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Get one reusable market. */\n async get(\n params: GetMarketParams,\n options?: RequestOptions,\n ): Promise<Market> {\n const { id } = params;\n return this.httpClient.get(`/markets/${id}`, undefined, options);\n }\n\n /** Replace the name, countries, and metadata of a market. */\n async update(\n params: UpdateMarketParams,\n options?: RequestOptions,\n ): Promise<Market> {\n const { id, ...rest } = params;\n return this.httpClient.patch(`/markets/${id}`, rest, options);\n }\n\n /** Delete an unused market. Markets referenced by prices or subscriptions cannot be deleted. */\n async delete(\n params: DeleteMarketParams,\n options?: RequestOptions,\n ): Promise<DeletedObject> {\n const { id } = params;\n return this.httpClient.delete(`/markets/${id}`, undefined, options);\n }\n\n /** List reusable country groups that resolve market-specific prices independently from currency. */\n async list(): Promise<{\n object: \"list\";\n data: Array<Market>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/markets\");\n }\n\n /** Create a reusable market without attaching it to a plan or price. Countries can belong to only one active market. */\n async create(\n params: CreateMarketParams,\n options?: RequestOptions,\n ): Promise<Market> {\n return this.httpClient.post(\"/markets\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { DeletedOffer, Offer } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface GetOfferParams {\n id: string;\n}\n\nexport interface UpdateOfferParams {\n id: string;\n name: string;\n phases: Array<\n | {\n type: \"percentage\";\n durationCycles: number | null;\n /** Unit the phase duration is counted in. Only a fixed-price phase may set it, because its amount is declared rather than derived from the plan. Defaults to the plan's own billing interval. */\n durationInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | null;\n /** Discount in basis points. 5000 means 50%. */\n percentage: number;\n }\n | {\n type: \"amount_off\";\n durationCycles: number | null;\n /** Unit the phase duration is counted in. Only a fixed-price phase may set it, because its amount is declared rather than derived from the plan. Defaults to the plan's own billing interval. */\n durationInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | null;\n amounts: Array<{\n currency: string;\n /** Amount in the currency's minor unit (for example, cents for USD). */\n amount: number;\n }>;\n }\n | {\n type: \"fixed_price\";\n durationCycles: number | null;\n /** Unit the phase duration is counted in. Only a fixed-price phase may set it, because its amount is declared rather than derived from the plan. Defaults to the plan's own billing interval. */\n durationInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | null;\n prices: Array<{\n currency: string;\n /** Amount in the currency's minor unit (for example, cents for USD). */\n amount: number;\n }>;\n }\n >;\n metadata?: Record<string, unknown>;\n startsAt?: string | null;\n endsAt?: string | null;\n active?: boolean;\n}\n\nexport interface DeleteOfferParams {\n id: string;\n}\n\nexport interface ListOffersParams {\n cursor?: string;\n limit?: number;\n active?: boolean;\n}\n\nexport interface CreateOfferParams {\n name: string;\n phases: Array<\n | {\n type: \"percentage\";\n durationCycles: number | null;\n /** Unit the phase duration is counted in. Only a fixed-price phase may set it, because its amount is declared rather than derived from the plan. Defaults to the plan's own billing interval. */\n durationInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | null;\n /** Discount in basis points. 5000 means 50%. */\n percentage: number;\n }\n | {\n type: \"amount_off\";\n durationCycles: number | null;\n /** Unit the phase duration is counted in. Only a fixed-price phase may set it, because its amount is declared rather than derived from the plan. Defaults to the plan's own billing interval. */\n durationInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | null;\n amounts: Array<{\n currency: string;\n /** Amount in the currency's minor unit (for example, cents for USD). */\n amount: number;\n }>;\n }\n | {\n type: \"fixed_price\";\n durationCycles: number | null;\n /** Unit the phase duration is counted in. Only a fixed-price phase may set it, because its amount is declared rather than derived from the plan. Defaults to the plan's own billing interval. */\n durationInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | null;\n prices: Array<{\n currency: string;\n /** Amount in the currency's minor unit (for example, cents for USD). */\n amount: number;\n }>;\n }\n >;\n metadata?: Record<string, unknown>;\n startsAt?: string | null;\n endsAt?: string | null;\n active?: boolean;\n}\n\nexport class OffersResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Retrieve reusable offer terms by public ID. */\n async get(params: GetOfferParams, options?: RequestOptions): Promise<Offer> {\n const { id } = params;\n return this.httpClient.get(`/offers/${id}`, undefined, options);\n }\n\n /** Replace reusable offer terms. Existing applications keep their immutable accepted terms. */\n async update(\n params: UpdateOfferParams,\n options?: RequestOptions,\n ): Promise<Offer> {\n const { id, ...rest } = params;\n return this.httpClient.patch(`/offers/${id}`, rest, options);\n }\n\n /** Soft-delete an Offer. Existing applications and their accepted terms remain available for billing and audit. */\n async delete(\n params: DeleteOfferParams,\n options?: RequestOptions,\n ): Promise<DeletedOffer> {\n const { id } = params;\n return this.httpClient.delete(`/offers/${id}`, undefined, options);\n }\n\n /** List reusable offer terms. Offers are independent from plans, prices, eligibility, and distribution channels. */\n async list(\n params?: ListOffersParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<Offer>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/offers\", params, options);\n }\n\n /** Create reusable offer terms without assigning a plan, price, eligibility rule, or distribution channel. */\n async create(\n params: CreateOfferParams,\n options?: RequestOptions,\n ): Promise<Offer> {\n return this.httpClient.post(\"/offers\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { Payment } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface CancelPaymentParams {\n id: string;\n}\n\nexport interface GetPaymentParams {\n id: string;\n}\n\nexport interface ChargePaymentParams {\n customerId: string;\n amount: number;\n currency: string;\n description: string;\n metadata?: Record<string, string>;\n}\n\nexport interface ListPaymentsParams {\n cursor?: string;\n limit?: number;\n customerId?: string;\n}\n\nexport interface CreatePaymentParams {\n amount: number;\n currency: string;\n customerId?: string;\n description: string;\n successUrl?: string;\n metadata?: Record<string, string>;\n}\n\nexport class PaymentsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** 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. */\n async cancel(\n params: CancelPaymentParams,\n options?: RequestOptions,\n ): Promise<Payment> {\n const { id } = params;\n return this.httpClient.post(`/payments/${id}/cancel`, {}, options);\n }\n\n /** Retrieve a payment by its public ID. */\n async get(\n params: GetPaymentParams,\n options?: RequestOptions,\n ): Promise<Payment> {\n const { id } = params;\n return this.httpClient.get(`/payments/${id}`, undefined, options);\n }\n\n /** Charge a customer's vaulted payment method off-session. Calculates tax, generates an invoice, and sends a receipt. Requires the customer to have a subscription in active, trialing, or past_due state. */\n async charge(\n params: ChargePaymentParams,\n options?: RequestOptions,\n ): Promise<Payment> {\n return this.httpClient.post(\"/payments/charge\", params, options);\n }\n\n /** List payments with cursor-based pagination. Filter by customer. */\n async list(\n params?: ListPaymentsParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<Payment>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/payments\", params, options);\n }\n\n /** 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. */\n async create(\n params: CreatePaymentParams,\n options?: RequestOptions,\n ): Promise<Payment> {\n return this.httpClient.post(\"/payments\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { Payout, PayoutBankAccount } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface AddPayoutBankAccountParams {\n accountNumber: string;\n accountHolderName: string;\n routingNumber?: string;\n accountType?: \"checking\" | \"savings\";\n setDefault?: boolean;\n}\n\nexport interface RequestPayoutParams {\n amount: number;\n description?: string;\n}\n\nexport class PayoutsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Add an additional destination bank account to the organization's existing payout account. Country and currency are resolved from the organization. The full account number is never returned — only `last4`. */\n async addBankAccount(\n params: AddPayoutBankAccountParams,\n options?: RequestOptions,\n ): Promise<PayoutBankAccount> {\n return this.httpClient.post(\"/payouts/bank-accounts\", params, options);\n }\n\n /** Withdraw available balance to the organization's verified payout account. `amount` is in cents (USD, minimum 1000 = $10). The payout is created in `pending` and settles to `paid` asynchronously as provider webhooks arrive. */\n async request(\n params: RequestPayoutParams,\n options?: RequestOptions,\n ): Promise<Payout> {\n return this.httpClient.post(\"/payouts\", params, options);\n }\n\n /**\n * Deprecated. Complete business and identity verification in the Commet dashboard. This endpoint no longer accepts or processes KYC data.\n * @deprecated\n */\n async completeVerification(options?: RequestOptions): Promise<void> {\n return this.httpClient.post(\"/payouts/verification\", {}, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type {\n AddedPlanToGroup,\n DeletedObject,\n PlanGroup,\n PlanGroupDetail,\n RemovedPlanFromGroup,\n ReorderedPlans,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface RemovePlanFromGroupParams {\n id: string;\n planId: string;\n}\n\nexport interface ReorderPlansInGroupParams {\n id: string;\n planIds: Array<string>;\n}\n\nexport interface AddPlanToGroupParams {\n id: string;\n planId: string;\n sortOrder?: number;\n}\n\nexport interface GetPlanGroupParams {\n id: string;\n}\n\nexport interface UpdatePlanGroupParams {\n id: string;\n name?: string;\n description?: string | null;\n isPublic?: boolean;\n}\n\nexport interface DeletePlanGroupParams {\n id: string;\n}\n\nexport interface ListPlanGroupsParams {\n cursor?: string;\n limit?: number;\n}\n\nexport interface CreatePlanGroupParams {\n name: string;\n description?: string;\n isPublic?: boolean;\n}\n\nexport class PlanGroupsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Remove a plan from a plan group. */\n async removePlan(\n params: RemovePlanFromGroupParams,\n options?: RequestOptions,\n ): Promise<RemovedPlanFromGroup> {\n const { id, planId } = params;\n return this.httpClient.delete(\n `/plan-groups/${id}/plans/${planId}`,\n undefined,\n options,\n );\n }\n\n /** Set the display order of plans within a group. All plan IDs in the group must be provided. */\n async reorderPlans(\n params: ReorderPlansInGroupParams,\n options?: RequestOptions,\n ): Promise<ReorderedPlans> {\n const { id, ...rest } = params;\n return this.httpClient.put(\n `/plan-groups/${id}/plans/reorder`,\n rest,\n options,\n );\n }\n\n /** Add an existing plan to a plan group with optional sort order. */\n async addPlan(\n params: AddPlanToGroupParams,\n options?: RequestOptions,\n ): Promise<AddedPlanToGroup> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/plan-groups/${id}/plans`, rest, options);\n }\n\n /** Retrieve a plan group by ID, including its plans ordered by sortOrder. */\n async get(\n params: GetPlanGroupParams,\n options?: RequestOptions,\n ): Promise<PlanGroupDetail> {\n const { id } = params;\n return this.httpClient.get(`/plan-groups/${id}`, undefined, options);\n }\n\n /** Update a plan group's name, description, or visibility. */\n async update(\n params: UpdatePlanGroupParams,\n options?: RequestOptions,\n ): Promise<PlanGroup> {\n const { id, ...rest } = params;\n return this.httpClient.patch(`/plan-groups/${id}`, rest, options);\n }\n\n /** Delete a plan group. Plans in the group are unlinked, not deleted. */\n async delete(\n params: DeletePlanGroupParams,\n options?: RequestOptions,\n ): Promise<DeletedObject> {\n const { id } = params;\n return this.httpClient.delete(`/plan-groups/${id}`, undefined, options);\n }\n\n /** List plan groups with cursor-based pagination. */\n async list(\n params?: ListPlanGroupsParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<PlanGroup>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/plan-groups\", params, options);\n }\n\n /** Create a new plan group for organizing plans. */\n async create(\n params: CreatePlanGroupParams,\n options?: RequestOptions,\n ): Promise<PlanGroup> {\n return this.httpClient.post(\"/plan-groups\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type {\n DeletedObject,\n DeletedPlanRegionalPricing,\n KeptOnVersion,\n Plan,\n PlanDraft,\n PlanDraftPublication,\n PlanExperiment,\n PlanExperimentArchive,\n PlanFeature,\n PlanMove,\n PlanPrice,\n PlanRegionalPricing,\n PlanRegionalPricingResult,\n PlanVersion,\n PlanVersionComparison,\n RemovedPlanFeature,\n SubscriberNeedingAChange,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport type PublishPlanDraftParams =\n | {\n id: string;\n draftId: string;\n /** current sells the draft to every new buyer. */\n publishAs: \"current\";\n /** What happens to subscribers of earlier versions: keep them, move them at their next renewal, or move them now (features and balance change today, the price at renewal). Nobody moves unless every one of them fits or has a change below. */\n move?: \"keep\" | \"period_end\" | \"now\";\n /** Per-subscriber changes that make each one fit, applied at its renewal. */\n changes?: Array<{\n subscriptionId: string;\n /** Leave this subscriber on its version. */\n keepOnVersion?: true;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\";\n /** Lower its seats to the version's limit at renewal. */\n seatLimit?: true;\n /** Add-ons it stops paying at renewal. */\n removeAddonIds?: Array<string>;\n }>;\n /** Check everything without publishing. */\n preview?: boolean;\n }\n | {\n id: string;\n draftId: string;\n /** experiment starts an experiment with experimentCode, sold with planCode plan:code. Starting an experiment moves nobody, so it takes no move or changes. */\n publishAs: \"experiment\";\n /** The experiment's own code, after the plan's code. */\n experimentCode: string;\n /** Check everything without publishing. */\n preview?: boolean;\n }\n | {\n id: string;\n draftId: string;\n /** experiment_version publishes the next version of the experiment the draft started from. */\n publishAs: \"experiment_version\";\n /** What happens to subscribers of earlier versions: keep them, move them at their next renewal, or move them now (features and balance change today, the price at renewal). Nobody moves unless every one of them fits or has a change below. */\n move?: \"keep\" | \"period_end\" | \"now\";\n /** Per-subscriber changes that make each one fit, applied at its renewal. */\n changes?: Array<{\n subscriptionId: string;\n /** Leave this subscriber on its version. */\n keepOnVersion?: true;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\";\n /** Lower its seats to the version's limit at renewal. */\n seatLimit?: true;\n /** Add-ons it stops paying at renewal. */\n removeAddonIds?: Array<string>;\n }>;\n /** Check everything without publishing. */\n preview?: boolean;\n };\n\nexport interface GetPlanDraftParams {\n id: string;\n draftId: string;\n}\n\nexport interface UpdatePlanDraftParams {\n id: string;\n draftId: string;\n /** Every interval the draft sells. An interval the draft sold and this list leaves out is removed from the draft. */\n prices?: Array<{\n billingInterval:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\";\n /** USD price in cents. */\n price: number;\n includedCredits?: number | null;\n includedBalance?: number | null;\n /** Days of trial on this price. Null removes the trial. */\n trialDays?: number | null;\n trialRequiresPaymentMethod?: boolean;\n /** Show this interval first at checkout and in pricing tables. */\n isDefault?: boolean;\n }>;\n /** Every country with its own currency or prices. A country the draft sold and this list leaves out is removed. A country missing a price blocks publishing. */\n countries?: Array<{\n /** ISO country code. */\n country: string;\n /** The currency the country pays in, USD included. */\n currency: string;\n /** Local units per USD for prices that follow the USD base. USD defaults to 1. */\n exchangeRate?: number | null;\n prices: Array<\n | {\n billingInterval:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\";\n /** The price set by hand, in the currency's minor unit. */\n price: number;\n /** The balance included each period in this country, in the currency's minor unit. Required when the plan's price includes a balance. */\n includedBalance?: number;\n }\n | {\n billingInterval:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\";\n /** Follow the USD base at the exchange rate. */\n followBase: true;\n }\n >;\n /** Smallest balance top-up in this country, in the currency's minor unit. Null follows the USD minimum at the exchange rate; left out keeps it. */\n topUpMinimum?: number | null;\n /** Most unused plan balance that rolls over in this country. Null follows the USD cap at the exchange rate; left out keeps it. */\n maxPlanBalance?: number | null;\n /** Most plan balance spent per limit interval in this country. Null follows the USD limit at the exchange rate; left out keeps it. */\n planBalanceLimit?: number | null;\n /** What the country pays for each add-on the draft sells. Left out keeps the country's add-on prices; sent, it replaces them, and add-ons not listed follow the USD price. */\n addonPrices?: Array<\n | {\n addonId: string;\n /** The add-on's price set by hand, in the currency's minor unit. */\n price: number;\n }\n | {\n addonId: string;\n /** Follow the add-on's USD price at the exchange rate. */\n followBase: true;\n }\n >;\n /** What the country pays for each credit pack the draft sells. Left out keeps the country's pack prices; sent, it replaces them, and packs not listed follow the USD price. */\n creditPackPrices?: Array<\n | {\n creditPackId: string;\n /** The pack's price set by hand, in the currency's minor unit. */\n price: number;\n }\n | {\n creditPackId: string;\n /** Follow the pack's USD price at the exchange rate. */\n followBase: true;\n }\n >;\n }>;\n /** Credit or balance rules; fields left out stay as they are. */\n rules?: {\n /** Credits a free plan includes each month. */\n freeIncludedCredits?: number | null;\n /** Balance a free plan includes each month, in cents. */\n freeIncludedBalance?: number | null;\n unusedPlanCredits?: \"expire\" | \"roll_over\";\n maxPlanCredits?: number | null;\n planCreditLimit?: number | null;\n planCreditLimitInterval?: \"day\" | \"week\" | null;\n unusedPlanBalance?: \"expire\" | \"roll_over\";\n maxPlanBalance?: number | null;\n planBalanceLimit?: number | null;\n planBalanceLimitInterval?: \"day\" | \"week\" | null;\n blockOnExhaustion?: boolean;\n purchasesEnabled?: boolean;\n creditPurchaseUnitPrice?: number | null;\n creditPurchaseMinimum?: number | null;\n topUpMinimum?: number | null;\n };\n /** Change keys to put back as the version the draft started from had them. */\n undo?: Array<string>;\n}\n\nexport interface DeletePlanDraftParams {\n id: string;\n draftId: string;\n}\n\nexport interface ListPlanDraftsParams {\n id: string;\n}\n\nexport interface CreatePlanDraftParams {\n id: string;\n /** The version to start from: the current version, an experiment's version or an older version. Defaults to the current version. */\n fromVersionId?: string;\n}\n\nexport interface ArchivePlanExperimentParams {\n id: string;\n code: string;\n /** What happens to the experiment's subscribers: keep them on its versions, move them to the plan's current version at their next renewal, or move them now. Nobody moves, and the experiment keeps running, unless every one of them fits or has a change. */\n subscribers?: \"keep\" | \"period_end\" | \"now\";\n /** Per-subscriber changes that make each one fit, applied at its renewal. */\n changes?: Array<{\n subscriptionId: string;\n /** Leave this subscriber on its version. */\n keepOnVersion?: true;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\";\n /** Lower its seats to the version's limit at renewal. */\n seatLimit?: true;\n /** Add-ons it stops paying at renewal. */\n removeAddonIds?: Array<string>;\n }>;\n /** Check the archive and the move without changing anything. */\n preview?: boolean;\n}\n\nexport interface MakePlanExperimentCurrentParams {\n id: string;\n code: string;\n}\n\nexport interface GetPlanExperimentParams {\n id: string;\n code: string;\n}\n\nexport interface CreatePlanExperimentVersionParams {\n id: string;\n code: string;\n prices?: Array<{\n /** An interval the plan already sells. Prices not listed are copied unchanged from the current version. */\n billingInterval:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\";\n /** USD price in the currency's minor unit (cents). */\n price: number;\n includedCredits?: number | null;\n includedBalance?: number | null;\n /** Per-currency amounts. A currency the current version does not sell also needs its exchangeRate in currencies; its amounts not listed here are derived from the USD price. */\n regionalPrices?: Array<{\n currency: string;\n price: number;\n includedBalance?: number | null;\n }>;\n }>;\n /** Currencies the current version does not sell, with the exchange rate (local units per USD) used for the amounts not listed, credit purchases, add-ons and overage. */\n currencies?: Array<{\n currency: string;\n exchangeRate: number;\n }>;\n /** Credits plans that roll over unused credits: the most plan credits a subscription can hold. Null removes the cap. */\n maxPlanCredits?: number | null;\n /** Balance plans that roll over unused balance: the most plan balance a subscription can hold, in USD cents. Other currencies convert it with the plan's exchange rate unless the dashboard sets a custom amount for that currency. Null removes the cap. */\n maxPlanBalance?: number | null;\n}\n\nexport interface ListPlanExperimentsParams {\n id: string;\n}\n\nexport interface CreatePlanExperimentParams {\n id: string;\n prices?: Array<{\n /** An interval the plan already sells. Prices not listed are copied unchanged from the current version. */\n billingInterval:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\";\n /** USD price in the currency's minor unit (cents). */\n price: number;\n includedCredits?: number | null;\n includedBalance?: number | null;\n /** Per-currency amounts. A currency the current version does not sell also needs its exchangeRate in currencies; its amounts not listed here are derived from the USD price. */\n regionalPrices?: Array<{\n currency: string;\n price: number;\n includedBalance?: number | null;\n }>;\n }>;\n /** Currencies the current version does not sell, with the exchange rate (local units per USD) used for the amounts not listed, credit purchases, add-ons and overage. */\n currencies?: Array<{\n currency: string;\n exchangeRate: number;\n }>;\n /** Credits plans that roll over unused credits: the most plan credits a subscription can hold. Null removes the cap. */\n maxPlanCredits?: number | null;\n /** Balance plans that roll over unused balance: the most plan balance a subscription can hold, in USD cents. Other currencies convert it with the plan's exchange rate unless the dashboard sets a custom amount for that currency. Null removes the cap. */\n maxPlanBalance?: number | null;\n /** The experiment's own code: lowercase letters, numbers, hyphens and underscores. It is sold as planCode `<plan code>:<code>` and is never reused in the plan. */\n code: string;\n}\n\nexport interface UpdatePlanFeatureParams {\n id: string;\n featureId: string;\n enabled?: boolean;\n includedAmount?: number;\n unlimited?: boolean;\n overage?: {\n enabled?: boolean;\n unitPrice?: number;\n };\n creditsPerUnit?: number | null;\n}\n\nexport interface RemovePlanFeatureParams {\n id: string;\n featureId: string;\n}\n\nexport interface AddPlanFeatureParams {\n id: string;\n featureId: string;\n enabled?: boolean;\n includedAmount?: number;\n unlimited?: boolean;\n overage?: {\n enabled?: boolean;\n unitPrice?: number;\n };\n creditsPerUnit?: number | null;\n pricingMode?: \"fixed\" | \"ai_model\";\n margin?: number | null;\n}\n\nexport interface CancelPlanMoveParams {\n id: string;\n moveId: string;\n}\n\nexport interface GetPlanMoveParams {\n id: string;\n moveId: string;\n}\n\nexport interface CancelPlanMoveSubscriptionParams {\n id: string;\n moveId: string;\n subscriptionId: string;\n}\n\nexport interface ListPlanMovesParams {\n id: string;\n}\n\nexport type CreatePlanMoveParams =\n | {\n id: string;\n /** Public IDs of the subscriptions to move. */\n subscriptionIds: Array<string>;\n /** The version subscribers move to. */\n toVersionId: string;\n /** now changes features and the included amount today and the price at renewal; period_end moves each subscriber at its next renewal. */\n effective: \"now\" | \"period_end\";\n /** Per-subscriber changes that make each one fit, applied at its renewal. */\n changes?: Array<{\n subscriptionId: string;\n /** Leave this subscriber on its version. */\n keepOnVersion?: true;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\";\n /** Lower its seats to the version's limit at renewal. */\n seatLimit?: true;\n /** Add-ons it stops paying at renewal. */\n removeAddonIds?: Array<string>;\n }>;\n /** Check every subscriber without moving anyone. */\n preview?: boolean;\n }\n | {\n id: string;\n /** Move every active, trialing and past due subscription on this version of the plan. */\n fromVersionId: string;\n /** The version subscribers move to. */\n toVersionId: string;\n /** now changes features and the included amount today and the price at renewal; period_end moves each subscriber at its next renewal. */\n effective: \"now\" | \"period_end\";\n /** Per-subscriber changes that make each one fit, applied at its renewal. */\n changes?: Array<{\n subscriptionId: string;\n /** Leave this subscriber on its version. */\n keepOnVersion?: true;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\";\n /** Lower its seats to the version's limit at renewal. */\n seatLimit?: true;\n /** Add-ons it stops paying at renewal. */\n removeAddonIds?: Array<string>;\n }>;\n /** Check every subscriber without moving anyone. */\n preview?: boolean;\n };\n\nexport interface KeepPlanSubscriberOnVersionParams {\n id: string;\n subscriptionId: string;\n}\n\nexport interface ListPlanSubscribersNeedingAChangeParams {\n id: string;\n}\n\nexport interface SetDefaultPlanPriceParams {\n id: string;\n priceId: string;\n}\n\nexport interface UpsertRegionalPricesParams {\n id: string;\n priceId: string;\n overrides: Array<{\n currency: string;\n price: number;\n includedBalance?: number;\n }>;\n}\n\nexport interface DeleteRegionalPricesParams {\n id: string;\n priceId: string;\n}\n\nexport interface UpdatePlanPriceParams {\n id: string;\n priceId: string;\n price?: number;\n isDefault?: boolean;\n trialDays?: number;\n /** Set to false so the price's free trial starts without a payment method. Requires trialDays on the price. */\n trialRequiresPaymentMethod?: boolean;\n includedBalance?: number | null;\n includedCredits?: number | null;\n /** Metadata keys to merge into the existing price metadata. */\n metadata?: Record<string, unknown>;\n marketPrices?: Array<{\n marketGroupId: string;\n currency:\n | \"usd\"\n | \"ars\"\n | \"brl\"\n | \"clp\"\n | \"cop\"\n | \"pen\"\n | \"uyu\"\n | \"pyg\"\n | \"bob\"\n | \"mxn\"\n | \"cad\"\n | \"eur\"\n | \"gbp\"\n | \"jpy\"\n | \"cny\"\n | \"krw\"\n | \"hkd\"\n | \"sgd\"\n | \"twd\"\n | \"inr\"\n | \"thb\";\n price: number;\n }>;\n}\n\nexport interface DeletePlanPriceParams {\n id: string;\n priceId: string;\n}\n\nexport type AddPlanPriceParams =\n | {\n id: string;\n billingInterval:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\";\n metadata?: Record<string, unknown>;\n price: number;\n trialDays?: number;\n /** Set to false so the price's free trial starts without a payment method. Requires trialDays on the price. */\n trialRequiresPaymentMethod?: boolean;\n isDefault?: boolean;\n includedBalance?: number | null;\n includedCredits?: number | null;\n marketPrices?: Array<{\n /** Public ID of a reusable pricing market group. */\n marketGroupId: string;\n /** Presentment currency configured for this plan and market. */\n currency:\n | \"usd\"\n | \"ars\"\n | \"brl\"\n | \"clp\"\n | \"cop\"\n | \"pen\"\n | \"uyu\"\n | \"pyg\"\n | \"bob\"\n | \"mxn\"\n | \"cad\"\n | \"eur\"\n | \"gbp\"\n | \"jpy\"\n | \"cny\"\n | \"krw\"\n | \"hkd\"\n | \"sgd\"\n | \"twd\"\n | \"inr\"\n | \"thb\";\n /** Market price in the currency's minor unit. */\n price: number;\n }>;\n }\n | {\n id: string;\n billingInterval:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\";\n metadata?: Record<string, unknown>;\n inheritsFromPriceId: string;\n marketPrices: Array<{\n /** Public ID of a reusable pricing market group. */\n marketGroupId: string;\n /** Presentment currency configured for this plan and market. */\n currency:\n | \"usd\"\n | \"ars\"\n | \"brl\"\n | \"clp\"\n | \"cop\"\n | \"pen\"\n | \"uyu\"\n | \"pyg\"\n | \"bob\"\n | \"mxn\"\n | \"cad\"\n | \"eur\"\n | \"gbp\"\n | \"jpy\"\n | \"cny\"\n | \"krw\"\n | \"hkd\"\n | \"sgd\"\n | \"twd\"\n | \"inr\"\n | \"thb\";\n /** Market price in the currency's minor unit. */\n price: number;\n }>;\n };\n\nexport interface SetPlanRegionalPricingParams {\n id: string;\n currency:\n | \"usd\"\n | \"ars\"\n | \"brl\"\n | \"clp\"\n | \"cop\"\n | \"pen\"\n | \"uyu\"\n | \"pyg\"\n | \"bob\"\n | \"mxn\"\n | \"cad\"\n | \"eur\"\n | \"gbp\"\n | \"jpy\"\n | \"cny\"\n | \"krw\"\n | \"hkd\"\n | \"sgd\"\n | \"twd\"\n | \"inr\"\n | \"thb\";\n exchangeRate: number;\n prices?: Array<{\n priceId: string;\n price: number;\n includedBalance?: number;\n }>;\n features?: Array<{\n featureId: string;\n overageUnitPrice: number;\n }>;\n}\n\nexport interface GetPlanParams {\n id: string;\n}\n\nexport interface UpdatePlanParams {\n id: string;\n name?: string;\n description?: string | null;\n metadata?: Record<string, unknown>;\n isPublic?: boolean;\n /** Credits plans only. What happens to unused plan credits at each reset. Changing it publishes a new version of the plan; each subscription stays on its version until moved. */\n unusedPlanCredits?:\n | {\n type: \"expire\";\n }\n | {\n type: \"roll_over\";\n /** The most plan credits a subscription holds after a reset, including the credits that reset grants; credits above it expire. At least the included credits of every price. null means no limit other than the largest storable balance, 2,147,483,647 plan credits. */\n maxPlanCredits: number | null;\n };\n /** Credits plans only. The most plan credits a subscription spends per day or per week; null removes the limit. Changing it publishes a new version of the plan; each subscription stays on its version until moved. */\n planCreditLimit?: {\n /** The most plan credits a subscription spends in one window. */\n credits: number;\n /** The window length: `day` is 24 hours and `week` is 7 days, starting at the time of day of the subscription's billing anchor. */\n interval: \"day\" | \"week\";\n } | null;\n /** Balance plans only. What happens to unused plan balance at each reset. Changing it publishes a new version of the plan; each subscription stays on its version until moved. */\n unusedPlanBalance?:\n | {\n type: \"expire\";\n }\n | {\n type: \"roll_over\";\n /** The most plan balance a subscription holds after a reset, in USD cents, including the balance that reset grants; balance above it expires. At least the included balance of every price. Other currencies convert it with the plan's exchange rate unless the dashboard sets a custom amount for that currency. null means no limit other than the largest storable amount, 2,147,483,647 cents. */\n maxPlanBalance: number | null;\n };\n /** Balance plans only. The most plan balance a subscription spends per day or per week, in USD cents; null removes the limit. Changing it publishes a new version of the plan; each subscription stays on its version until moved. */\n planBalanceLimit?: {\n /** The most plan balance a subscription spends in one window, in USD cents. Other currencies convert it with the plan's exchange rate unless the dashboard sets a custom amount for that currency. */\n amount: number;\n /** The window length: `day` is 24 hours and `week` is 7 days, starting at the time of day of the subscription's billing anchor. */\n interval: \"day\" | \"week\";\n } | null;\n /** Credits and balance plans only. false lets usage continue past the plan and purchased amounts and bills the missing amount as overage at the next renewal; a credits plan bills it at the price per credit and needs one. Trials and free plans always stop, so free plans accept only true. Changing it publishes a new version of the plan; each subscription stays on its version until moved. */\n blockOnExhaustion?: boolean;\n /** Make this plan the default plan of its plan group: customers created with that planGroupId start on it, and a paid plan of the group that ends from the customer portal, a revoked payment authorization or exhausted dunning moves to it instead of canceling. Requires a free plan in a plan group; replaces the group's previous default plan. false unmarks it. */\n isDefault?: boolean;\n}\n\nexport interface DeletePlanParams {\n id: string;\n}\n\nexport interface ComparePlanVersionsParams {\n id: string;\n versionId: string;\n against: string;\n}\n\nexport interface GetPlanVersionParams {\n id: string;\n versionId: string;\n}\n\nexport interface ListPlanVersionsParams {\n id: string;\n cursor?: string;\n limit?: number;\n}\n\nexport interface CreatePlanVersionParams {\n id: string;\n prices?: Array<{\n /** An interval the plan already sells. Prices not listed are copied unchanged from the current version. */\n billingInterval:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\";\n /** USD price in the currency's minor unit (cents). */\n price: number;\n includedCredits?: number | null;\n includedBalance?: number | null;\n /** Per-currency amounts. A currency the current version does not sell also needs its exchangeRate in currencies; its amounts not listed here are derived from the USD price. */\n regionalPrices?: Array<{\n currency: string;\n price: number;\n includedBalance?: number | null;\n }>;\n }>;\n /** Currencies the current version does not sell, with the exchange rate (local units per USD) used for the amounts not listed, credit purchases, add-ons and overage. */\n currencies?: Array<{\n currency: string;\n exchangeRate: number;\n }>;\n /** Credits plans that roll over unused credits: the most plan credits a subscription can hold. Null removes the cap. */\n maxPlanCredits?: number | null;\n /** Balance plans that roll over unused balance: the most plan balance a subscription can hold, in USD cents. Other currencies convert it with the plan's exchange rate unless the dashboard sets a custom amount for that currency. Null removes the cap. */\n maxPlanBalance?: number | null;\n}\n\nexport interface SetPlanVisibilityParams {\n id: string;\n isPublic: boolean;\n}\n\nexport interface ListPlansParams {\n includePrivate?: boolean;\n}\n\nexport interface CreatePlanParams {\n name: string;\n code: string;\n description?: string;\n consumptionModel?: \"metered\" | \"credits\" | \"balance\";\n isPublic?: boolean;\n isFree?: boolean;\n /** Credits and balance plans. Omitted, credits plans and free plans stop usage when the plan and purchased amounts run out, and paid balance plans bill the missing balance as overage. A new credits plan always stops usage: it allows overage only with a price per credit, which is set after creation, and then `PATCH /v1/plans/{id}` turns overage on. */\n blockOnExhaustion?: boolean;\n /** Credits plans only. What happens to unused plan credits at each reset; omitted means they expire. */\n unusedPlanCredits?:\n | {\n type: \"expire\";\n }\n | {\n type: \"roll_over\";\n /** The most plan credits a subscription holds after a reset, including the credits that reset grants; credits above it expire. At least the included credits of every price. null means no limit other than the largest storable balance, 2,147,483,647 plan credits. */\n maxPlanCredits: number | null;\n };\n /** Credits plans only. The most plan credits a subscription spends per day or per week; omitted or null means no limit. */\n planCreditLimit?: {\n /** The most plan credits a subscription spends in one window. */\n credits: number;\n /** The window length: `day` is 24 hours and `week` is 7 days, starting at the time of day of the subscription's billing anchor. */\n interval: \"day\" | \"week\";\n } | null;\n /** Balance plans only. What happens to unused plan balance at each reset; omitted means it expires. */\n unusedPlanBalance?:\n | {\n type: \"expire\";\n }\n | {\n type: \"roll_over\";\n /** The most plan balance a subscription holds after a reset, in USD cents, including the balance that reset grants; balance above it expires. At least the included balance of every price. Other currencies convert it with the plan's exchange rate unless the dashboard sets a custom amount for that currency. null means no limit other than the largest storable amount, 2,147,483,647 cents. */\n maxPlanBalance: number | null;\n };\n /** Balance plans only. The most plan balance a subscription spends per day or per week, in USD cents; omitted or null means no limit. */\n planBalanceLimit?: {\n /** The most plan balance a subscription spends in one window, in USD cents. Other currencies convert it with the plan's exchange rate unless the dashboard sets a custom amount for that currency. */\n amount: number;\n /** The window length: `day` is 24 hours and `week` is 7 days, starting at the time of day of the subscription's billing anchor. */\n interval: \"day\" | \"week\";\n } | null;\n planGroupId?: string;\n /** Make this plan the default plan of its plan group: customers created with that planGroupId start on it, and a paid plan of the group that ends from the customer portal, a revoked payment authorization or exhausted dunning moves to it instead of canceling. Requires a free plan with a planGroupId; replaces the group's previous default plan. */\n isDefault?: boolean;\n metadata?: Record<string, unknown>;\n}\n\nexport class PlansResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** 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. */\n async publishDraft(\n params: PublishPlanDraftParams,\n options?: RequestOptions,\n ): Promise<PlanDraftPublication> {\n const { id, draftId, ...rest } = params;\n return this.httpClient.post(\n `/plans/${id}/drafts/${draftId}/publish`,\n rest,\n options,\n );\n }\n\n /** Retrieve a draft with the version it started from and what it changes. */\n async getDraft(\n params: GetPlanDraftParams,\n options?: RequestOptions,\n ): Promise<PlanDraft> {\n const { id, draftId } = params;\n return this.httpClient.get(\n `/plans/${id}/drafts/${draftId}`,\n undefined,\n options,\n );\n }\n\n /** 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. */\n async updateDraft(\n params: UpdatePlanDraftParams,\n options?: RequestOptions,\n ): Promise<PlanDraft> {\n const { id, draftId, ...rest } = params;\n return this.httpClient.patch(\n `/plans/${id}/drafts/${draftId}`,\n rest,\n options,\n );\n }\n\n /** Discard a draft. Nothing it changed was ever sold. */\n async deleteDraft(\n params: DeletePlanDraftParams,\n options?: RequestOptions,\n ): Promise<DeletedObject> {\n const { id, draftId } = params;\n return this.httpClient.delete(\n `/plans/${id}/drafts/${draftId}`,\n undefined,\n options,\n );\n }\n\n /** List the plan's open drafts, oldest first, each with the version it started from and what it changes. Drafts sell nothing until published. */\n async listDrafts(\n params: ListPlanDraftsParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<PlanDraft>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n const { id } = params;\n return this.httpClient.get(`/plans/${id}/drafts`, undefined, options);\n }\n\n /** 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. */\n async createDraft(\n params: CreatePlanDraftParams,\n options?: RequestOptions,\n ): Promise<PlanDraft> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/plans/${id}/drafts`, rest, options);\n }\n\n /** 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. */\n async archiveExperiment(\n params: ArchivePlanExperimentParams,\n options?: RequestOptions,\n ): Promise<PlanExperimentArchive> {\n const { id, code, ...rest } = params;\n return this.httpClient.post(\n `/plans/${id}/experiments/${code}/archive`,\n rest,\n options,\n );\n }\n\n /** 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. */\n async makeExperimentCurrent(\n params: MakePlanExperimentCurrentParams,\n options?: RequestOptions,\n ): Promise<PlanVersion> {\n const { id, code } = params;\n return this.httpClient.post(\n `/plans/${id}/experiments/${code}/make-current`,\n {},\n options,\n );\n }\n\n /** Get one experiment of a plan by its own code, with the version it sells and how many subscriptions are on it. */\n async getExperiment(\n params: GetPlanExperimentParams,\n options?: RequestOptions,\n ): Promise<PlanExperiment> {\n const { id, code } = params;\n return this.httpClient.get(\n `/plans/${id}/experiments/${code}`,\n undefined,\n options,\n );\n }\n\n /** 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. */\n async createExperimentVersion(\n params: CreatePlanExperimentVersionParams,\n options?: RequestOptions,\n ): Promise<PlanVersion> {\n const { id, code, ...rest } = params;\n return this.httpClient.post(\n `/plans/${id}/experiments/${code}/versions`,\n rest,\n options,\n );\n }\n\n /** List a plan's experiments, newest first, with the version each one sells and how many subscriptions are on them. */\n async listExperiments(\n params: ListPlanExperimentsParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<PlanExperiment>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n const { id } = params;\n return this.httpClient.get(`/plans/${id}/experiments`, undefined, options);\n }\n\n /** 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. */\n async createExperiment(\n params: CreatePlanExperimentParams,\n options?: RequestOptions,\n ): Promise<PlanExperiment> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/plans/${id}/experiments`, rest, options);\n }\n\n /** Update limits, overage, or enabled status of a feature on a plan. */\n async updateFeature(\n params: UpdatePlanFeatureParams,\n options?: RequestOptions,\n ): Promise<PlanFeature> {\n const { id, featureId, ...rest } = params;\n return this.httpClient.patch(\n `/plans/${id}/features/${featureId}`,\n rest,\n options,\n );\n }\n\n /** Detach a feature from a plan. */\n async removeFeature(\n params: RemovePlanFeatureParams,\n options?: RequestOptions,\n ): Promise<RemovedPlanFeature> {\n const { id, featureId } = params;\n return this.httpClient.delete(\n `/plans/${id}/features/${featureId}`,\n undefined,\n options,\n );\n }\n\n /** Attach a feature to a plan with limits, overage, and credits configuration. */\n async addFeature(\n params: AddPlanFeatureParams,\n options?: RequestOptions,\n ): Promise<PlanFeature> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/plans/${id}/features`, rest, options);\n }\n\n /** Cancel a move for every subscriber who has not moved yet. They stay on their version; those already moved stay moved. */\n async cancelMove(\n params: CancelPlanMoveParams,\n options?: RequestOptions,\n ): Promise<PlanMove> {\n const { id, moveId } = params;\n return this.httpClient.post(\n `/plans/${id}/moves/${moveId}/cancel`,\n {},\n options,\n );\n }\n\n /** 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. */\n async getMove(\n params: GetPlanMoveParams,\n options?: RequestOptions,\n ): Promise<PlanMove> {\n const { id, moveId } = params;\n return this.httpClient.get(\n `/plans/${id}/moves/${moveId}`,\n undefined,\n options,\n );\n }\n\n /** Cancel a move for one subscriber who has not moved yet. It stays on its version; the rest of the move continues. */\n async cancelMoveSubscription(\n params: CancelPlanMoveSubscriptionParams,\n options?: RequestOptions,\n ): Promise<PlanMove> {\n const { id, moveId, subscriptionId } = params;\n return this.httpClient.post(\n `/plans/${id}/moves/${moveId}/subscriptions/${subscriptionId}/cancel`,\n {},\n options,\n );\n }\n\n /** 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. */\n async listMoves(\n params: ListPlanMovesParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<PlanMove>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n const { id } = params;\n return this.httpClient.get(`/plans/${id}/moves`, undefined, options);\n }\n\n /** 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. */\n async createMove(\n params: CreatePlanMoveParams,\n options?: RequestOptions,\n ): Promise<PlanMove> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/plans/${id}/moves`, rest, options);\n }\n\n /** 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. */\n async keepSubscriberOnVersion(\n params: KeepPlanSubscriberOnVersionParams,\n options?: RequestOptions,\n ): Promise<KeptOnVersion> {\n const { id, subscriptionId } = params;\n return this.httpClient.post(\n `/plans/${id}/needs-a-change/${subscriptionId}/keep`,\n {},\n options,\n );\n }\n\n /** 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. */\n async listSubscribersNeedingAChange(\n params: ListPlanSubscribersNeedingAChangeParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<SubscriberNeedingAChange>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n const { id } = params;\n return this.httpClient.get(\n `/plans/${id}/needs-a-change`,\n undefined,\n options,\n );\n }\n\n /** Set a specific price as the default and return the updated plan price. */\n async setDefaultPrice(\n params: SetDefaultPlanPriceParams,\n options?: RequestOptions,\n ): Promise<PlanPrice> {\n const { id, priceId } = params;\n return this.httpClient.put(\n `/plans/${id}/prices/${priceId}/default`,\n {},\n options,\n );\n }\n\n /** Create or update regional currency price overrides for a plan price. */\n async setRegionalPrices(\n params: UpsertRegionalPricesParams,\n options?: RequestOptions,\n ): Promise<PlanRegionalPricing> {\n const { id, priceId, ...rest } = params;\n return this.httpClient.put(\n `/plans/${id}/prices/${priceId}/regional`,\n rest,\n options,\n );\n }\n\n /** Remove all regional currency overrides for a plan price. The request is rejected while billable subscriptions depend on an override. */\n async deleteRegionalPrices(\n params: DeleteRegionalPricesParams,\n options?: RequestOptions,\n ): Promise<DeletedPlanRegionalPricing> {\n const { id, priceId } = params;\n return this.httpClient.delete(\n `/plans/${id}/prices/${priceId}/regional`,\n undefined,\n options,\n );\n }\n\n /** Update a base price or market price variant. Removing a base market override is rejected while a variant depends on it. Offer terms are managed through Offers. */\n async updatePrice(\n params: UpdatePlanPriceParams,\n options?: RequestOptions,\n ): Promise<PlanPrice> {\n const { id, priceId, ...rest } = params;\n return this.httpClient.patch(\n `/plans/${id}/prices/${priceId}`,\n rest,\n options,\n );\n }\n\n /** 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. */\n async deletePrice(\n params: DeletePlanPriceParams,\n options?: RequestOptions,\n ): Promise<DeletedObject> {\n const { id, priceId } = params;\n return this.httpClient.delete(\n `/plans/${id}/prices/${priceId}`,\n undefined,\n options,\n );\n }\n\n /** Add a base price or a selectable market price variant. Variants inherit their base price outside the markets they override. Configure introductory and promotional benefits through Offers. */\n async addPrice(\n params: AddPlanPriceParams,\n options?: RequestOptions,\n ): Promise<PlanPrice> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/plans/${id}/prices`, rest, options);\n }\n\n /** Configure regional prices and feature overage values for one currency. Currency-specific offer terms are managed through Offers. */\n async setRegionalPricing(\n params: SetPlanRegionalPricingParams,\n options?: RequestOptions,\n ): Promise<PlanRegionalPricingResult> {\n const { id, ...rest } = params;\n return this.httpClient.put(`/plans/${id}/regional`, rest, options);\n }\n\n /** Get a plan with public price IDs and their automatic introductory offer IDs. */\n async get(params: GetPlanParams, options?: RequestOptions): Promise<Plan> {\n const { id } = params;\n return this.httpClient.get(`/plans/${id}`, undefined, options);\n }\n\n /** Update a plan's name, description, visibility, default status, metadata, overage behavior, what happens to its unused plan credits or plan balance, or its plan credit or plan balance limit. */\n async update(\n params: UpdatePlanParams,\n options?: RequestOptions,\n ): Promise<Plan> {\n const { id, ...rest } = params;\n return this.httpClient.patch(`/plans/${id}`, rest, options);\n }\n\n /** Soft-delete a plan. */\n async delete(\n params: DeletePlanParams,\n options?: RequestOptions,\n ): Promise<DeletedObject> {\n const { id } = params;\n return this.httpClient.delete(`/plans/${id}`, undefined, options);\n }\n\n /** List what changes from one version of a plan to another: prices, trials, features, rules, add-ons, credit packs and countries. */\n async compareVersions(\n params: ComparePlanVersionsParams,\n options?: RequestOptions,\n ): Promise<PlanVersionComparison> {\n const { id, versionId, ...rest } = params;\n return this.httpClient.get(\n `/plans/${id}/versions/${versionId}/changes`,\n rest,\n options,\n );\n }\n\n /** Get one published version of a plan with its prices and how many subscriptions are on it. */\n async getVersion(\n params: GetPlanVersionParams,\n options?: RequestOptions,\n ): Promise<PlanVersion> {\n const { id, versionId } = params;\n return this.httpClient.get(\n `/plans/${id}/versions/${versionId}`,\n undefined,\n options,\n );\n }\n\n /** 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. */\n async listVersions(\n params: ListPlanVersionsParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<PlanVersion>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n const { id, ...rest } = params;\n return this.httpClient.get(`/plans/${id}/versions`, rest, options);\n }\n\n /** 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. */\n async createVersion(\n params: CreatePlanVersionParams,\n options?: RequestOptions,\n ): Promise<PlanVersion> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/plans/${id}/versions`, rest, options);\n }\n\n /** Set a plan's public visibility and return the updated plan. */\n async setVisibility(\n params: SetPlanVisibilityParams,\n options?: RequestOptions,\n ): Promise<Plan> {\n const { id, ...rest } = params;\n return this.httpClient.put(`/plans/${id}/visibility`, rest, options);\n }\n\n /** List plans with public price IDs and their automatic introductory offer IDs. */\n async list(\n params?: ListPlansParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<Plan>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/plans\", params, options);\n }\n\n /** Create a new plan with optional consumption model, visibility, plan group assignment, overage behavior, and the rollover and spend limit of its plan credits or plan balance. */\n async create(\n params: CreatePlanParams,\n options?: RequestOptions,\n ): Promise<Plan> {\n return this.httpClient.post(\"/plans\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { PortalAccess } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport type RequestPortalAccessParams =\n | {\n email: string;\n returnUrl?: string;\n }\n | {\n customerId: string;\n returnUrl?: string;\n };\n\nexport class PortalResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Generate a customer portal URL. Exactly one identifier (email or customerId) is required. */\n async getUrl(\n params: RequestPortalAccessParams,\n options?: RequestOptions,\n ): Promise<PortalAccess> {\n return this.httpClient.post(\"/portal/sessions\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { PromoCode } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface GetPromoCodeParams {\n id: string;\n}\n\nexport interface UpdatePromoCodeParams {\n id: string;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\"\n | null;\n maxRedemptions?: number | null;\n expiresAt?: string | null;\n active?: boolean;\n planIds?: Array<string>;\n /** Whether the code only applies to a customer's first purchase: one with no paid invoice above zero and no paid subscription. */\n firstPurchaseOnly?: boolean;\n}\n\nexport interface ListPromoCodesParams {\n cursor?: string;\n limit?: number;\n}\n\nexport interface CreatePromoCodeParams {\n code: string;\n offerId: string;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\"\n | null;\n maxRedemptions?: number;\n /** @format date-time */\n expiresAt?: string;\n planIds?: Array<string>;\n /** Whether the code only applies to a customer's first purchase: one with no paid invoice above zero and no paid subscription. Defaults to false. */\n firstPurchaseOnly?: boolean;\n}\n\nexport class PromoCodesResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Retrieve a promo code by its public ID. */\n async get(\n params: GetPromoCodeParams,\n options?: RequestOptions,\n ): Promise<PromoCode> {\n const { id } = params;\n return this.httpClient.get(`/promo-codes/${id}`, undefined, options);\n }\n\n /** Update a promo code's billing interval, redemption limits, expiration, active status, or plan restrictions. */\n async update(\n params: UpdatePromoCodeParams,\n options?: RequestOptions,\n ): Promise<PromoCode> {\n const { id, ...rest } = params;\n return this.httpClient.patch(`/promo-codes/${id}`, rest, options);\n }\n\n /** List promo codes with cursor-based pagination. */\n async list(\n params?: ListPromoCodesParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<PromoCode>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/promo-codes\", params, options);\n }\n\n /** Create a distribution code for an existing Offer with one or more sequential discount phases. The code owns redemption restrictions. */\n async create(\n params: CreatePromoCodeParams,\n options?: RequestOptions,\n ): Promise<PromoCode> {\n return this.httpClient.post(\"/promo-codes\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { ClaimLink } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport class ProvisioningResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Issue a fresh claim link for an organization that was provisioned headlessly and has not been claimed yet. Any previously issued link stops working. */\n async createClaimLink(options?: RequestOptions): Promise<ClaimLink> {\n return this.httpClient.post(\"/claim-link\", {}, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { UsageQuota, UsageQuotaEvent } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface GetAllQuotaAllowancesParams {\n customerId: string;\n}\n\nexport type RemoveQuotaParams =\n | {\n featureCode: string;\n count?: number;\n customerId: string;\n }\n | {\n featureCode: string;\n count?: number;\n externalId: string;\n };\n\nexport interface GetQuotaAllowanceParams {\n customerId: string;\n featureCode: string;\n}\n\nexport type AddQuotaParams =\n | {\n featureCode: string;\n count?: number;\n customerId: string;\n }\n | {\n featureCode: string;\n count?: number;\n externalId: string;\n };\n\nexport type SetQuotaParams =\n | {\n featureCode: string;\n count: number;\n customerId: string;\n }\n | {\n featureCode: string;\n count: number;\n externalId: string;\n };\n\nexport class QuotaResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Get all quota allowances for a customer across every quota feature in their plan. */\n async getAll(\n params: GetAllQuotaAllowancesParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<UsageQuota>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/usage/quota/all\", params, options);\n }\n\n /** Remove from a customer's quota allowance for a feature. Defaults to 1 if count is omitted. Returns 400 insufficient_balance if the balance would go negative. */\n async remove(\n params: RemoveQuotaParams,\n options?: RequestOptions,\n ): Promise<UsageQuotaEvent> {\n return this.httpClient.post(\"/usage/quota/remove\", params, options);\n }\n\n /** Get the current quota allowance (used vs included) for a specific feature. */\n async get(\n params: GetQuotaAllowanceParams,\n options?: RequestOptions,\n ): Promise<UsageQuota> {\n return this.httpClient.get(\"/usage/quota\", params, options);\n }\n\n /** Add to a customer's quota allowance for a feature. Defaults to 1 if count is omitted. */\n async add(\n params: AddQuotaParams,\n options?: RequestOptions,\n ): Promise<UsageQuotaEvent> {\n return this.httpClient.post(\"/usage/quota\", params, options);\n }\n\n /** Set a customer's quota allowance for a feature to an exact value. */\n async set(\n params: SetQuotaParams,\n options?: RequestOptions,\n ): Promise<UsageQuotaEvent> {\n return this.httpClient.put(\"/usage/quota\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type {\n SeatBalance,\n SeatBalanceCollection,\n SeatEvent,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface GetSeatBalanceParams {\n customerId: string;\n featureCode: string;\n}\n\nexport interface GetAllSeatBalancesParams {\n customerId: string;\n}\n\nexport interface BulkSetSeatsParams {\n customerId: string;\n seats: Record<string, number>;\n}\n\nexport interface RemoveSeatsParams {\n customerId: string;\n featureCode: string;\n count: number;\n}\n\nexport interface AddSeatsParams {\n customerId: string;\n featureCode: string;\n count: number;\n}\n\nexport interface SetSeatsParams {\n customerId: string;\n featureCode: string;\n count: number;\n}\n\nexport class SeatsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Get current balance for a specific seat type. */\n async getBalance(\n params: GetSeatBalanceParams,\n options?: RequestOptions,\n ): Promise<SeatBalance> {\n return this.httpClient.get(\"/seats/balance\", params, options);\n }\n\n /** Get the current balance for all seat types in a customer's subscription. */\n async getAllBalances(\n params: GetAllSeatBalancesParams,\n options?: RequestOptions,\n ): Promise<SeatBalanceCollection> {\n return this.httpClient.get(\"/seats/balances\", params, options);\n }\n\n /** Set all seat types at once. */\n async setAll(\n params: BulkSetSeatsParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<SeatEvent>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.put(\"/seats/bulk\", params, options);\n }\n\n /** Remove seats from a customer's subscription. Takes effect at the end of the billing period. */\n async remove(\n params: RemoveSeatsParams,\n options?: RequestOptions,\n ): Promise<SeatEvent> {\n return this.httpClient.post(\"/seats/remove\", params, options);\n }\n\n /** Add seats to a customer's subscription. Prorates charges for the current billing period. */\n async add(\n params: AddSeatsParams,\n options?: RequestOptions,\n ): Promise<SeatEvent> {\n return this.httpClient.post(\"/seats\", params, options);\n }\n\n /** Set seats to an exact count. */\n async set(\n params: SetSeatsParams,\n options?: RequestOptions,\n ): Promise<SeatEvent> {\n return this.httpClient.put(\"/seats\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { SubscriptionStatus } from \"../types/enums\";\nimport type {\n BalanceAdjustment,\n BalanceTopup,\n CreatedSubscription,\n CreditGrant,\n DeletedSubscriptionAddon,\n PaymentMethodUpdateCheckout,\n PlanChange,\n PrepaidPeriodsCheckout,\n PreviewChange,\n ReactivatedSubscription,\n RecoveryLink,\n Subscription,\n SubscriptionAddon,\n SubscriptionAutoTopUp,\n SubscriptionResume,\n SubscriptionSummary,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface DeactivateAddonParams {\n id: string;\n addonId: string;\n}\n\nexport interface ActivateAddonParams {\n id: string;\n addonId: string;\n}\n\nexport interface GetSubscriptionAutoTopUpParams {\n id: string;\n}\n\nexport interface UpdateSubscriptionAutoTopUpParams {\n id: string;\n enabled?: boolean;\n threshold?: number;\n /** Credits each top-up buys. Credits plans only. */\n quantity?: number;\n /** Minor units of the subscription currency each top-up adds. Balance plans only. */\n amount?: number;\n maxPerPeriod?: number;\n}\n\nexport interface AdjustBalanceParams {\n id: string;\n amount: number;\n reason?: string;\n type?: \"credits\" | \"balance\";\n}\n\nexport interface TopupBalanceParams {\n id: string;\n /** The amount to add, in minor units of the subscription currency (cents; whole units for zero-decimal currencies). */\n amount: number;\n}\n\nexport interface CancelSubscriptionParams {\n id: string;\n reason?: string;\n immediate?: boolean;\n}\n\nexport type ChangePlanParams =\n | {\n id: string;\n newPlanId?: string;\n newBillingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\";\n successUrl?: string;\n offerId?: string;\n promoCode?: never;\n }\n | {\n id: string;\n newPlanId?: string;\n newBillingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\";\n successUrl?: string;\n offerId?: never;\n /** Promo code whose Offer prices the change, validated with the checkout's rules: a code the checkout would refuse returns 400 validation_error with the checkout's reason in details.reason. Cannot be combined with offerId. */\n promoCode: string;\n };\n\nexport interface ChangeSubscriptionVersionParams {\n id: string;\n /** A published version of the subscription's plan. */\n planVersionId: string;\n /** now changes features, limits and the included credits or balance at once (the included difference is added to or subtracted from the plan credits or plan balance: an increase first pays any plan-part debt, a decrease never creates new debt, and purchased credits and purchased balance are untouched) and charges the new price from the next renewal. period_end changes everything at the next renewal. There is never a proration charge or refund. */\n effective: \"now\" | \"period_end\";\n}\n\nexport type PurchaseCreditsParams =\n | {\n id: string;\n creditPackId: string;\n quantity?: never;\n }\n | {\n id: string;\n quantity: number;\n };\n\nexport interface ApplySubscriptionOfferParams {\n id: string;\n offerId: string;\n /** @format date-time */\n expiresAt?: string;\n}\n\nexport interface RemoveSubscriptionOfferParams {\n id: string;\n}\n\nexport interface PauseSubscriptionParams {\n id: string;\n mode: \"immediate\" | \"period_end\";\n durationDays: number | null;\n}\n\nexport interface UpdateSubscriptionPauseParams {\n id: string;\n durationDays: number | null;\n}\n\nexport interface RevokeSubscriptionPauseParams {\n id: string;\n}\n\nexport interface UpdatePaymentMethodParams {\n id: string;\n successUrl?: string;\n}\n\nexport interface CreatePrepaidPeriodsCheckoutParams {\n id: string;\n /** Active subscriptions: billing periods to add after the last paid period. Pending-payment subscriptions: total billing periods the first payment covers, including the current one. */\n periods: number;\n /** Offer applied from the first added period for its full configured duration. Active subscriptions only; assign an Offer to a pending-payment subscription with PUT /subscriptions/{id}/offer. */\n offerId?: string;\n successUrl?: string;\n}\n\nexport type PreviewChangePlanParams =\n | {\n id: string;\n planId: string;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\";\n offerId?: string;\n promoCode?: never;\n }\n | {\n id: string;\n planId: string;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\";\n offerId?: never;\n /** Promo code whose Offer prices the change, validated with the checkout's rules: a code the checkout would refuse returns 400 validation_error with the checkout's reason in details.reason. Cannot be combined with offerId. */\n promoCode: string;\n };\n\nexport interface ReactivateSubscriptionParams {\n id: string;\n offerId?: string;\n}\n\nexport interface CreateSubscriptionRecoveryLinkParams {\n id: string;\n}\n\nexport interface ResumeSubscriptionParams {\n id: string;\n}\n\nexport interface GetSubscriptionParams {\n id: string;\n}\n\nexport interface RevokeScheduledPlanChangeParams {\n id: string;\n}\n\nexport interface RevokeScheduledVersionChangeParams {\n id: string;\n}\n\nexport interface UncancelSubscriptionParams {\n id: string;\n}\n\nexport interface GetActiveSubscriptionParams {\n customerId: string;\n}\n\nexport interface ListSubscriptionsParams {\n customerId?: string;\n status?: SubscriptionStatus;\n planVersionId?: string;\n}\n\nexport type CreateSubscriptionParams =\n | {\n customerId: string;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\"\n | null;\n /** Public price ID. When omitted, Commet selects the default price for the billing interval and still applies its market pricing. */\n priceId?: string;\n initialSeats?: Record<string, number>;\n /** Payment provider name or exact public payment connection ID for the initial checkout. Overrides country routing when present. */\n provider?: \"stripe\" | \"commet\" | \"dlocal\" | string;\n /** Payment methods the initial checkout may offer. Restricts what the checkout already offers for the buyer's country, currency and payment connection; it never enables a method the connection does not have and never changes routing. When none of them is available to the buyer, the checkout shows that it cannot accept payments. */\n paymentMethodTypes?: Array<\n \"card\" | \"oxxo\" | \"mercado_pago\" | \"google_pay\" | \"smartpix\"\n >;\n name?: string;\n /** @format date-time */\n startDate?: string;\n successUrl?: string;\n /** Billing periods of the subscription's interval paid with the first payment, including the current one. Defaults to 1. The interval does not change: each paid period renews at zero and the subscription renews normally after the last one unless `cancelAtPeriodEnd` is true. */\n prepaidPeriods?: number;\n /** Schedules the cancellation from creation so the subscription ends after its last paid period and never renews with any payment method. */\n cancelAtPeriodEnd?: boolean;\n /** Public ID of a published version of the plan, current or not, including an experiment's versions. The subscription is created on that version and stays on it: checkout charges its price and activation grants its credits, add-ons and credit packs. When omitted, the subscription gets the current version, or the version an experiment code (planCode `<plan code>:<experiment code>`) sells. */\n planVersionId?: string;\n offerId?: never;\n promoCode?: string;\n /** Trial length in days, replacing the price's trial. A customer who already had this plan, in a trial or paying, gets no trial and goes through the regular checkout. */\n customTrialDays?: number;\n skipTrial?: boolean;\n planId: string;\n }\n | {\n customerId: string;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\"\n | null;\n /** Public price ID. When omitted, Commet selects the default price for the billing interval and still applies its market pricing. */\n priceId?: string;\n initialSeats?: Record<string, number>;\n /** Payment provider name or exact public payment connection ID for the initial checkout. Overrides country routing when present. */\n provider?: \"stripe\" | \"commet\" | \"dlocal\" | string;\n /** Payment methods the initial checkout may offer. Restricts what the checkout already offers for the buyer's country, currency and payment connection; it never enables a method the connection does not have and never changes routing. When none of them is available to the buyer, the checkout shows that it cannot accept payments. */\n paymentMethodTypes?: Array<\n \"card\" | \"oxxo\" | \"mercado_pago\" | \"google_pay\" | \"smartpix\"\n >;\n name?: string;\n /** @format date-time */\n startDate?: string;\n successUrl?: string;\n /** Billing periods of the subscription's interval paid with the first payment, including the current one. Defaults to 1. The interval does not change: each paid period renews at zero and the subscription renews normally after the last one unless `cancelAtPeriodEnd` is true. */\n prepaidPeriods?: number;\n /** Schedules the cancellation from creation so the subscription ends after its last paid period and never renews with any payment method. */\n cancelAtPeriodEnd?: boolean;\n /** Public ID of a published version of the plan, current or not, including an experiment's versions. The subscription is created on that version and stays on it: checkout charges its price and activation grants its credits, add-ons and credit packs. When omitted, the subscription gets the current version, or the version an experiment code (planCode `<plan code>:<experiment code>`) sells. */\n planVersionId?: string;\n offerId?: never;\n promoCode?: string;\n /** Trial length in days, replacing the price's trial. A customer who already had this plan, in a trial or paying, gets no trial and goes through the regular checkout. */\n customTrialDays?: number;\n skipTrial?: boolean;\n /** The plan code, or an experiment code as `<plan code>:<experiment code>` to sell the version the experiment sells. */\n planCode: string;\n }\n | {\n customerId: string;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\"\n | null;\n /** Public price ID. When omitted, Commet selects the default price for the billing interval and still applies its market pricing. */\n priceId?: string;\n initialSeats?: Record<string, number>;\n /** Payment provider name or exact public payment connection ID for the initial checkout. Overrides country routing when present. */\n provider?: \"stripe\" | \"commet\" | \"dlocal\" | string;\n /** Payment methods the initial checkout may offer. Restricts what the checkout already offers for the buyer's country, currency and payment connection; it never enables a method the connection does not have and never changes routing. When none of them is available to the buyer, the checkout shows that it cannot accept payments. */\n paymentMethodTypes?: Array<\n \"card\" | \"oxxo\" | \"mercado_pago\" | \"google_pay\" | \"smartpix\"\n >;\n name?: string;\n /** @format date-time */\n startDate?: string;\n successUrl?: string;\n /** Billing periods of the subscription's interval paid with the first payment, including the current one. Defaults to 1. The interval does not change: each paid period renews at zero and the subscription renews normally after the last one unless `cancelAtPeriodEnd` is true. */\n prepaidPeriods?: number;\n /** Schedules the cancellation from creation so the subscription ends after its last paid period and never renews with any payment method. */\n cancelAtPeriodEnd?: boolean;\n /** Public ID of a published version of the plan, current or not, including an experiment's versions. The subscription is created on that version and stays on it: checkout charges its price and activation grants its credits, add-ons and credit packs. When omitted, the subscription gets the current version, or the version an experiment code (planCode `<plan code>:<experiment code>`) sells. */\n planVersionId?: string;\n offerId: string;\n promoCode?: never;\n /** Trial length in days, replacing the price's trial. A customer who already had this plan, in a trial or paying, gets no trial and goes through the regular checkout. */\n customTrialDays?: number;\n skipTrial?: boolean;\n planId: string;\n }\n | {\n customerId: string;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\"\n | null;\n /** Public price ID. When omitted, Commet selects the default price for the billing interval and still applies its market pricing. */\n priceId?: string;\n initialSeats?: Record<string, number>;\n /** Payment provider name or exact public payment connection ID for the initial checkout. Overrides country routing when present. */\n provider?: \"stripe\" | \"commet\" | \"dlocal\" | string;\n /** Payment methods the initial checkout may offer. Restricts what the checkout already offers for the buyer's country, currency and payment connection; it never enables a method the connection does not have and never changes routing. When none of them is available to the buyer, the checkout shows that it cannot accept payments. */\n paymentMethodTypes?: Array<\n \"card\" | \"oxxo\" | \"mercado_pago\" | \"google_pay\" | \"smartpix\"\n >;\n name?: string;\n /** @format date-time */\n startDate?: string;\n successUrl?: string;\n /** Billing periods of the subscription's interval paid with the first payment, including the current one. Defaults to 1. The interval does not change: each paid period renews at zero and the subscription renews normally after the last one unless `cancelAtPeriodEnd` is true. */\n prepaidPeriods?: number;\n /** Schedules the cancellation from creation so the subscription ends after its last paid period and never renews with any payment method. */\n cancelAtPeriodEnd?: boolean;\n /** Public ID of a published version of the plan, current or not, including an experiment's versions. The subscription is created on that version and stays on it: checkout charges its price and activation grants its credits, add-ons and credit packs. When omitted, the subscription gets the current version, or the version an experiment code (planCode `<plan code>:<experiment code>`) sells. */\n planVersionId?: string;\n offerId: string;\n promoCode?: never;\n /** Trial length in days, replacing the price's trial. A customer who already had this plan, in a trial or paying, gets no trial and goes through the regular checkout. */\n customTrialDays?: number;\n skipTrial?: boolean;\n /** The plan code, or an experiment code as `<plan code>:<experiment code>` to sell the version the experiment sells. */\n planCode: string;\n }\n | {\n customerId: string;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\"\n | null;\n /** Public price ID. When omitted, Commet selects the default price for the billing interval and still applies its market pricing. */\n priceId?: string;\n initialSeats?: Record<string, number>;\n /** Payment provider name or exact public payment connection ID for the initial checkout. Overrides country routing when present. */\n provider?: \"stripe\" | \"commet\" | \"dlocal\" | string;\n /** Payment methods the initial checkout may offer. Restricts what the checkout already offers for the buyer's country, currency and payment connection; it never enables a method the connection does not have and never changes routing. When none of them is available to the buyer, the checkout shows that it cannot accept payments. */\n paymentMethodTypes?: Array<\n \"card\" | \"oxxo\" | \"mercado_pago\" | \"google_pay\" | \"smartpix\"\n >;\n name?: string;\n /** @format date-time */\n startDate?: string;\n successUrl?: string;\n /** Billing periods of the subscription's interval paid with the first payment, including the current one. Defaults to 1. The interval does not change: each paid period renews at zero and the subscription renews normally after the last one unless `cancelAtPeriodEnd` is true. */\n prepaidPeriods?: number;\n /** Schedules the cancellation from creation so the subscription ends after its last paid period and never renews with any payment method. */\n cancelAtPeriodEnd?: boolean;\n /** Public ID of a published version of the plan, current or not, including an experiment's versions. The subscription is created on that version and stays on it: checkout charges its price and activation grants its credits, add-ons and credit packs. When omitted, the subscription gets the current version, or the version an experiment code (planCode `<plan code>:<experiment code>`) sells. */\n planVersionId?: string;\n offerId?: never;\n /** Public card promotion ID. The offer is shown immediately and remains conditional on card eligibility until checkout confirmation. */\n cardPromotionId: string;\n promoCode?: never;\n customTrialDays?: never;\n skipTrial?: false;\n planId: string;\n }\n | {\n customerId: string;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\"\n | null;\n /** Public price ID. When omitted, Commet selects the default price for the billing interval and still applies its market pricing. */\n priceId?: string;\n initialSeats?: Record<string, number>;\n /** Payment provider name or exact public payment connection ID for the initial checkout. Overrides country routing when present. */\n provider?: \"stripe\" | \"commet\" | \"dlocal\" | string;\n /** Payment methods the initial checkout may offer. Restricts what the checkout already offers for the buyer's country, currency and payment connection; it never enables a method the connection does not have and never changes routing. When none of them is available to the buyer, the checkout shows that it cannot accept payments. */\n paymentMethodTypes?: Array<\n \"card\" | \"oxxo\" | \"mercado_pago\" | \"google_pay\" | \"smartpix\"\n >;\n name?: string;\n /** @format date-time */\n startDate?: string;\n successUrl?: string;\n /** Billing periods of the subscription's interval paid with the first payment, including the current one. Defaults to 1. The interval does not change: each paid period renews at zero and the subscription renews normally after the last one unless `cancelAtPeriodEnd` is true. */\n prepaidPeriods?: number;\n /** Schedules the cancellation from creation so the subscription ends after its last paid period and never renews with any payment method. */\n cancelAtPeriodEnd?: boolean;\n /** Public ID of a published version of the plan, current or not, including an experiment's versions. The subscription is created on that version and stays on it: checkout charges its price and activation grants its credits, add-ons and credit packs. When omitted, the subscription gets the current version, or the version an experiment code (planCode `<plan code>:<experiment code>`) sells. */\n planVersionId?: string;\n offerId?: never;\n /** Public card promotion ID. The offer is shown immediately and remains conditional on card eligibility until checkout confirmation. */\n cardPromotionId: string;\n promoCode?: never;\n customTrialDays?: never;\n skipTrial?: false;\n /** The plan code, or an experiment code as `<plan code>:<experiment code>` to sell the version the experiment sells. */\n planCode: string;\n };\n\nexport class SubscriptionsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Deactivate an add-on from a subscription. */\n async deactivateAddon(\n params: DeactivateAddonParams,\n options?: RequestOptions,\n ): Promise<DeletedSubscriptionAddon> {\n const { id, addonId } = params;\n return this.httpClient.delete(\n `/subscriptions/${id}/addons/${addonId}`,\n undefined,\n options,\n );\n }\n\n /** Activate an add-on on a subscription. Charges a prorated amount for the current billing period. An add-on that the subscription's plan version does not sell is rejected with addon_unavailable. */\n async activateAddon(\n params: ActivateAddonParams,\n options?: RequestOptions,\n ): Promise<SubscriptionAddon> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/subscriptions/${id}/addons`, rest, options);\n }\n\n /** Read whether the subscription tops up automatically with its saved payment method when its available credits or balance reach a threshold, with the top-ups used this period and the last failure. */\n async getAutoTopUp(\n params: GetSubscriptionAutoTopUpParams,\n options?: RequestOptions,\n ): Promise<SubscriptionAutoTopUp> {\n const { id } = params;\n return this.httpClient.get(\n `/subscriptions/${id}/auto-top-up`,\n undefined,\n options,\n );\n }\n\n /** Turn automatic top-ups on or off and set the threshold, the size of each top-up and the maximum top-ups per period. Send only the fields that change. On a credits plan each top-up buys `quantity` credits; on a balance plan it adds `amount` in minor units of the subscription currency, plus tax, and `threshold` is in the same minor units. Enabling requires a plan that sells credits or has balance top-ups on. The size must be at least the plan's minimum when auto top-up is enabled or when the size changes, so turning it off keeps working after the minimum rises. Saving it enabled resumes a paused auto top-up. */\n async updateAutoTopUp(\n params: UpdateSubscriptionAutoTopUpParams,\n options?: RequestOptions,\n ): Promise<SubscriptionAutoTopUp> {\n const { id, ...rest } = params;\n return this.httpClient.patch(\n `/subscriptions/${id}/auto-top-up`,\n rest,\n options,\n );\n }\n\n /** Adjust a subscription's balance or credits by a signed amount. Positive adds, negative subtracts. */\n async adjustBalance(\n params: AdjustBalanceParams,\n options?: RequestOptions,\n ): Promise<BalanceAdjustment> {\n const { id, ...rest } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/balance/adjust`,\n rest,\n options,\n );\n }\n\n /** 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. */\n async topupBalance(\n params: TopupBalanceParams,\n options?: RequestOptions,\n ): Promise<BalanceTopup> {\n const { id, ...rest } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/balance/topup`,\n rest,\n options,\n );\n }\n\n /** Cancel immediately or at period end and return the updated subscription. */\n async cancel(\n params: CancelSubscriptionParams,\n options?: RequestOptions,\n ): Promise<Subscription> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/subscriptions/${id}/cancel`, rest, options);\n }\n\n /** Upgrade or change billing interval immediately, optionally applying an Offer by offerId or the Offer of a promoCode. Scheduled changes accept neither offerId nor promoCode. From a free plan, a promoCode opens the checkout with the code applied and counts its use when the checkout is paid; without offerId or promoCode, a destination price whose free trial requires no payment method starts that trial right away without checkout. During a trial without a payment method, an immediate change returns 409 no_payment_method; scheduled changes still apply. */\n async changePlan(\n params: ChangePlanParams,\n options?: RequestOptions,\n ): Promise<PlanChange> {\n const { id, ...rest } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/change-plan`,\n rest,\n options,\n );\n }\n\n /** 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, 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. */\n async changeVersion(\n params: ChangeSubscriptionVersionParams,\n options?: RequestOptions,\n ): Promise<Subscription> {\n const { id, ...rest } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/change-version`,\n rest,\n options,\n );\n }\n\n /** 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. A credit pack that the subscription's plan version does not sell is rejected with credit_pack_unavailable. */\n async purchaseCredits(\n params: PurchaseCreditsParams,\n options?: RequestOptions,\n ): Promise<CreditGrant> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/subscriptions/${id}/credits`, rest, options);\n }\n\n /** Apply a direct Offer to a subscription. On a pending checkout it quotes or replaces the checkout discount, which starts after the plan price trial when there is one, and the existing checkout URL remains unchanged. On an active subscription it applies the Offer immediately with its discount phases starting at the next billing cycle; the call is rejected while another applied Offer still has active or upcoming discount phases. */\n async applyOffer(\n params: ApplySubscriptionOfferParams,\n options?: RequestOptions,\n ): Promise<Subscription> {\n const { id, ...rest } = params;\n return this.httpClient.put(`/subscriptions/${id}/offer`, rest, options);\n }\n\n /** Remove the quoted direct Offer from a subscription's pending payment checkout. The existing checkout URL remains unchanged and returns to its undiscounted price. */\n async removeOffer(\n params: RemoveSubscriptionOfferParams,\n options?: RequestOptions,\n ): Promise<Subscription> {\n const { id } = params;\n return this.httpClient.delete(\n `/subscriptions/${id}/offer`,\n undefined,\n options,\n );\n }\n\n /** Pause immediately or schedule a pause for the end of the current billing or trial period. Set durationDays to null for an indefinite pause. */\n async pause(\n params: PauseSubscriptionParams,\n options?: RequestOptions,\n ): Promise<Subscription> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/subscriptions/${id}/pause`, rest, options);\n }\n\n /** Change the duration of a scheduled or active pause. Set durationDays to null to make it indefinite. */\n async updatePause(\n params: UpdateSubscriptionPauseParams,\n options?: RequestOptions,\n ): Promise<Subscription> {\n const { id, ...rest } = params;\n return this.httpClient.patch(`/subscriptions/${id}/pause`, rest, options);\n }\n\n /** Revoke a pause before it becomes effective. Active pauses must be resumed instead. */\n async revokePause(\n params: RevokeSubscriptionPauseParams,\n options?: RequestOptions,\n ): Promise<Subscription> {\n const { id } = params;\n return this.httpClient.delete(\n `/subscriptions/${id}/pause`,\n undefined,\n options,\n );\n }\n\n /** Creates a hosted checkout to update the payment method of an active, trialing or past_due subscription. Pending-payment subscriptions must use their payment checkout. */\n async updatePaymentMethod(\n params: UpdatePaymentMethodParams,\n options?: RequestOptions,\n ): Promise<PaymentMethodUpdateCheckout> {\n const { id, ...rest } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/payment-method/update`,\n rest,\n options,\n );\n }\n\n /** Creates a hosted checkout to pay billing periods of a recurring subscription in advance with any payment method. On an active subscription the paid periods start after the last paid period and replace any open prepaid-periods checkout. On a pending-payment subscription the first payment covers the requested periods and replaces its pending checkout. The billing interval does not change. */\n async createPrepaidPeriodsCheckout(\n params: CreatePrepaidPeriodsCheckoutParams,\n options?: RequestOptions,\n ): Promise<PrepaidPeriodsCheckout> {\n const { id, ...rest } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/prepaid-periods`,\n rest,\n options,\n );\n }\n\n /** Preview proration details for an immediate plan change without applying it. Free-to-paid changes are never scheduled and the change-plan endpoint returns hosted checkout for them, except a change without offerId or promoCode to a price whose free trial needs no payment method, for a customer who never had that plan: it starts the trial at once, so the preview reports nothing due today. For paid plans, interval direction takes precedence: a longer interval is immediate and a shorter interval is scheduled. When the interval is unchanged, a higher-sort-order plan is immediate and a lower-sort-order plan is scheduled. A paid-to-free change is always scheduled. Returns credit, charge, and net amount. The target plan must belong to the same plan group as the current plan, otherwise a 400 with code `plans_not_in_same_group` is returned. A change between two free plans has nothing to prorate and returns a zero-amount estimate. Scheduled changes return a 400 with code `plan_change_scheduled`; apply those via the change-plan endpoint. Pass offerId to quote the destination plan with an Offer, or promoCode to quote it with the Offer of a promo code validated with the checkout's rules. */\n async previewChange(\n params: PreviewChangePlanParams,\n options?: RequestOptions,\n ): Promise<PreviewChange> {\n const { id, ...rest } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/preview-change`,\n rest,\n options,\n );\n }\n\n /** Reactivates a subscription. A past_due subscription retries its outstanding renewal charge (recovering to active on success). A canceled subscription generates a fresh invoice, charges the saved card, and resets the billing period. On a successful charge the subscription becomes active; a declined charge returns an error with a recoveryUrl in the error details that can be sent to the customer to update their card. A canceled subscription may apply an Offer by offerId; past-due recovery cannot. */\n async reactivate(\n params: ReactivateSubscriptionParams,\n options?: RequestOptions,\n ): Promise<ReactivatedSubscription> {\n const { id, ...rest } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/reactivate`,\n rest,\n options,\n );\n }\n\n /** 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. */\n async createRecoveryLink(\n params: CreateSubscriptionRecoveryLinkParams,\n options?: RequestOptions,\n ): Promise<RecoveryLink> {\n const { id } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/recovery-links`,\n {},\n options,\n );\n }\n\n /** Resume a paused subscription. Immediate pauses continue the preserved period without a charge. Period-end pauses charge a new period before access is restored. */\n async resume(\n params: ResumeSubscriptionParams,\n options?: RequestOptions,\n ): Promise<SubscriptionResume> {\n const { id } = params;\n return this.httpClient.post(`/subscriptions/${id}/resume`, {}, options);\n }\n\n /** Get a subscription by its public ID, regardless of status (including pending_payment and past_due). */\n async get(\n params: GetSubscriptionParams,\n options?: RequestOptions,\n ): Promise<Subscription> {\n const { id } = params;\n return this.httpClient.get(`/subscriptions/${id}`, undefined, options);\n }\n\n /** Revoke the plan or interval change scheduled for the end of the period, so the subscription stays on its current plan. Returns the updated subscription. */\n async revokeScheduledPlanChange(\n params: RevokeScheduledPlanChangeParams,\n options?: RequestOptions,\n ): Promise<Subscription> {\n const { id } = params;\n return this.httpClient.delete(\n `/subscriptions/${id}/scheduled-plan-change`,\n undefined,\n options,\n );\n }\n\n /** 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. */\n async revokeScheduledVersionChange(\n params: RevokeScheduledVersionChangeParams,\n options?: RequestOptions,\n ): Promise<Subscription> {\n const { id } = params;\n return this.httpClient.delete(\n `/subscriptions/${id}/scheduled-version-change`,\n undefined,\n options,\n );\n }\n\n /** Revert a scheduled cancellation and return the updated subscription. Only works before cancellation takes effect. */\n async uncancel(\n params: UncancelSubscriptionParams,\n options?: RequestOptions,\n ): Promise<Subscription> {\n const { id } = params;\n return this.httpClient.post(`/subscriptions/${id}/uncancel`, {}, options);\n }\n\n /** Get the active subscription for a customer. Returns null if none. */\n async getActive(\n params: GetActiveSubscriptionParams,\n options?: RequestOptions,\n ): Promise<Subscription | null> {\n return this.httpClient.get(\"/subscriptions/active\", params, options);\n }\n\n /** List all subscriptions. Filter by customer ID or status. */\n async list(\n params?: ListSubscriptionsParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<SubscriptionSummary>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/subscriptions\", params, options);\n }\n\n /** Create a subscription for a customer. Commet selects the default price when priceId is omitted. The subscription starts at the base USD price; market and currency are resolved from the buyer's request country when the checkout opens. Without an offer override, Commet applies the price's automatic introductory Offer. Pass offerId to apply an active compatible Offer directly, or cardPromotionId to preselect a card-eligible Promotional Offer for the initial checkout when card promotions are enabled for the organization. For the initial checkout, provider accepts either a processor name or an exact payment connection ID. When the price's free trial requires no payment method, the subscription starts trialing right away with no checkout (checkoutUrl null, hasPaymentMethod false); it cannot be combined with offerId, promoCode, cardPromotionId or provider, and an organization that cannot charge yet receives 403. */\n async create(\n params: CreateSubscriptionParams,\n options?: RequestOptions,\n ): Promise<CreatedSubscription> {\n return this.httpClient.post(\"/subscriptions\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { TestClock, TestClockRun } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport type AdvanceTestClockParams =\n | {\n advanceDays: number;\n }\n | {\n /** @format date-time */\n frozenTime: string;\n };\n\nexport class TestClockResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /**\n * Deprecated. POST /test-clock now advances time and processes every due billing deadline in one durable run.\n * @deprecated\n */\n async processBilling(options?: RequestOptions): Promise<void> {\n return this.httpClient.post(\"/test-clock/process-billing\", {}, options);\n }\n\n /** Returns the organization's current test clock state and latest durable run. Sandbox only. */\n async get(): Promise<TestClock> {\n return this.httpClient.get(\"/test-clock\");\n }\n\n /** Starts a durable run that moves the test clock forward and processes every billing deadline due before the target time. Poll GET /test-clock for progress and terminal results. Sandbox only. */\n async advance(\n params: AdvanceTestClockParams,\n options?: RequestOptions,\n ): Promise<TestClockRun> {\n return this.httpClient.post(\"/test-clock\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { TransactionStatus } from \"../types/enums\";\nimport type {\n Refund,\n Transaction,\n TransactionListItem,\n TransactionRetry,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface RefundTransactionParams {\n id: string;\n}\n\nexport interface RetryTransactionParams {\n id: string;\n}\n\nexport interface GetTransactionParams {\n id: string;\n}\n\nexport interface ListTransactionsParams {\n cursor?: string;\n limit?: number;\n status?: TransactionStatus;\n customerEmail?: string;\n}\n\nexport class TransactionsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Issue a full refund and return the provider-neutral refund resource with its actual status. */\n async refund(\n params: RefundTransactionParams,\n options?: RequestOptions,\n ): Promise<Refund> {\n const { id } = params;\n return this.httpClient.post(`/transactions/${id}/refund`, {}, options);\n }\n\n /** Retry a failed subscription renewal and return an honest retry result. The original failed transaction remains immutable. */\n async retry(\n params: RetryTransactionParams,\n options?: RequestOptions,\n ): Promise<TransactionRetry> {\n const { id } = params;\n return this.httpClient.post(`/transactions/${id}/retry`, {}, options);\n }\n\n /** Retrieve a single payment transaction by its public ID, including provider details. */\n async get(\n params: GetTransactionParams,\n options?: RequestOptions,\n ): Promise<Transaction> {\n const { id } = params;\n return this.httpClient.get(`/transactions/${id}`, undefined, options);\n }\n\n /** List payment transactions with cursor-based pagination. Filter by status or customer email. */\n async list(\n params?: ListTransactionsParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<TransactionListItem>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/transactions\", params, options);\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type { UsageAdjustment, UsageCheck, UsageEvent } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface CheckUsageAvailabilityParams {\n customerId: string;\n featureCode: string;\n quantity?: number;\n}\n\nexport type TrackUsageParams =\n | {\n featureCode: string;\n customerId: string;\n eventId?: string;\n /** @format date-time */\n timestamp?: string;\n properties?: Array<{\n property: string;\n value: string;\n }>;\n model: string;\n inputTokens: number;\n outputTokens: number;\n value?: never;\n cacheReadTokens?: number;\n cacheWriteTokens?: number;\n }\n | {\n featureCode: string;\n customerId: string;\n eventId?: string;\n /** @format date-time */\n timestamp?: string;\n properties?: Array<{\n property: string;\n value: string;\n }>;\n value?: number;\n model?: never;\n inputTokens?: never;\n outputTokens?: never;\n cacheReadTokens?: never;\n cacheWriteTokens?: never;\n };\n\nexport interface SetUsageParams {\n customerId: string;\n featureCode: string;\n value: number;\n reason?: string;\n}\n\nexport class UsageResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Check if a customer can consume a feature before actual consumption. Returns availability and cost estimates based on the plan's consumption model. */\n async check(\n params: CheckUsageAvailabilityParams,\n options?: RequestOptions,\n ): Promise<UsageCheck> {\n return this.httpClient.post(\"/usage/check\", params, options);\n }\n\n /** Track a usage event for a metered feature. Deducts from balance/credits if applicable. */\n async track(\n params: TrackUsageParams,\n options?: RequestOptions,\n ): Promise<UsageEvent> {\n return this.httpClient.post(\"/usage/events\", params, options);\n }\n\n /** Set a metered feature's usage to an exact value for the current period. Use the Idempotency-Key header to make retries safe. */\n async set(\n params: SetUsageParams,\n options?: RequestOptions,\n ): Promise<UsageAdjustment> {\n return this.httpClient.put(\"/usage\", params, options);\n }\n}\n","import { AddonsResource } from \"./resources/addons\";\nimport { ApiKeysResource } from \"./resources/api-keys\";\nimport { CreditPacksResource } from \"./resources/credit-packs\";\nimport { CustomersResource } from \"./resources/customers\";\nimport { FeatureAccessResource } from \"./resources/feature-access\";\nimport { FeaturesResource } from \"./resources/features\";\nimport { InvoicesResource } from \"./resources/invoices\";\nimport { MarketsResource } from \"./resources/markets\";\nimport { OffersResource } from \"./resources/offers\";\nimport { PaymentsResource } from \"./resources/payments\";\nimport { PayoutsResource } from \"./resources/payouts\";\nimport { PlanGroupsResource } from \"./resources/plan-groups\";\nimport { PlansResource } from \"./resources/plans\";\nimport { PortalResource } from \"./resources/portal\";\nimport { PromoCodesResource } from \"./resources/promo-codes\";\nimport { ProvisioningResource } from \"./resources/provisioning\";\nimport { QuotaResource } from \"./resources/quota\";\nimport { SeatsResource } from \"./resources/seats\";\nimport { SubscriptionsResource } from \"./resources/subscriptions\";\nimport { TestClockResource } from \"./resources/test-clock\";\nimport { TransactionsResource } from \"./resources/transactions\";\nimport { UsageResource } from \"./resources/usage\";\nimport type { CommetHTTPClient } from \"./utils/http\";\n\nexport class GeneratedResources {\n public addons!: AddonsResource;\n public apiKeys!: ApiKeysResource;\n public creditPacks!: CreditPacksResource;\n public customers!: CustomersResource;\n public featureAccess!: FeatureAccessResource;\n public features!: FeaturesResource;\n public invoices!: InvoicesResource;\n public markets!: MarketsResource;\n public offers!: OffersResource;\n public payments!: PaymentsResource;\n public payouts!: PayoutsResource;\n public planGroups!: PlanGroupsResource;\n public plans!: PlansResource;\n public portal!: PortalResource;\n public promoCodes!: PromoCodesResource;\n public provisioning!: ProvisioningResource;\n public quota!: QuotaResource;\n public seats!: SeatsResource;\n public subscriptions!: SubscriptionsResource;\n public testClock!: TestClockResource;\n public transactions!: TransactionsResource;\n public usage!: UsageResource;\n\n protected initResources(http: CommetHTTPClient): void {\n this.addons = new AddonsResource(http);\n this.apiKeys = new ApiKeysResource(http);\n this.creditPacks = new CreditPacksResource(http);\n this.customers = new CustomersResource(http);\n this.featureAccess = new FeatureAccessResource(http);\n this.features = new FeaturesResource(http);\n this.invoices = new InvoicesResource(http);\n this.markets = new MarketsResource(http);\n this.offers = new OffersResource(http);\n this.payments = new PaymentsResource(http);\n this.payouts = new PayoutsResource(http);\n this.planGroups = new PlanGroupsResource(http);\n this.plans = new PlansResource(http);\n this.portal = new PortalResource(http);\n this.promoCodes = new PromoCodesResource(http);\n this.provisioning = new ProvisioningResource(http);\n this.quota = new QuotaResource(http);\n this.seats = new SeatsResource(http);\n this.subscriptions = new SubscriptionsResource(http);\n this.testClock = new TestClockResource(http);\n this.transactions = new TransactionsResource(http);\n this.usage = new UsageResource(http);\n }\n}\n","import crypto from \"node:crypto\";\nimport type {\n WebhookEvent,\n WebhookEventDataMap,\n WebhookEventPayload,\n} from \"../types/webhook-events\";\n\nexport type WebhookPayload = WebhookEventPayload;\nexport type WebhookData = WebhookPayload[\"data\"];\n\nexport type WebhookEventHandler<E extends WebhookEvent> = (\n data: WebhookEventDataMap[E],\n payload: Extract<WebhookEventPayload, { event: E }>,\n) => void | Promise<void>;\n\nexport interface VerifyParams {\n payload: string;\n signature: string | null;\n secret: string;\n}\n\nexport interface GenerateSignatureParams {\n payload: string;\n secret: string;\n}\n\nexport interface VerifyAndParseParams {\n rawBody: string;\n signature: string | null;\n secret: string;\n}\n\nexport class Webhooks {\n private readonly eventHandlers = new Map<\n WebhookEvent,\n WebhookEventHandler<WebhookEvent>\n >();\n\n verify(params: VerifyParams): boolean {\n const { payload, signature, secret } = params;\n\n if (!signature || !secret || !payload) {\n return false;\n }\n\n try {\n const expectedSignature = this.generateSignature({ payload, secret });\n return crypto.timingSafeEqual(\n Buffer.from(signature, \"hex\"),\n Buffer.from(expectedSignature, \"hex\"),\n );\n } catch (_error) {\n // timingSafeEqual throws when the two buffers differ in length\n return false;\n }\n }\n\n private generateSignature(params: GenerateSignatureParams): string {\n const { payload, secret } = params;\n return crypto.createHmac(\"sha256\", secret).update(payload).digest(\"hex\");\n }\n\n verifyAndParse(params: VerifyAndParseParams): WebhookPayload | null {\n const { rawBody, signature, secret } = params;\n\n if (!this.verify({ payload: rawBody, signature, secret })) {\n return null;\n }\n\n try {\n return JSON.parse(params.rawBody) as WebhookPayload;\n } catch {\n return null;\n }\n }\n\n on<E extends WebhookEvent>(event: E, handler: WebhookEventHandler<E>): this {\n this.eventHandlers.set(\n event,\n handler as unknown as WebhookEventHandler<WebhookEvent>,\n );\n return this;\n }\n\n async process(params: VerifyAndParseParams): Promise<WebhookPayload | null> {\n const payload = this.verifyAndParse(params);\n if (!payload) return null;\n const handler = this.eventHandlers.get(payload.event);\n if (handler) await handler(payload.data as never, payload as never);\n return payload;\n }\n}\n","import type { RequestOptions } from \"../types/common\";\nimport type {\n CreatedWebhook,\n DeletedObject,\n Webhook,\n WebhookTest,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\nimport { Webhooks } from \"./webhooks\";\n\nexport interface GetWebhookEndpointParams {\n id: string;\n}\n\nexport interface UpdateWebhookEndpointParams {\n id: string;\n url?: string;\n events?: Array<\n | \"subscription.created\"\n | \"subscription.activated\"\n | \"subscription.reactivated\"\n | \"subscription.pause_scheduled\"\n | \"subscription.pause_updated\"\n | \"subscription.pause_revoked\"\n | \"subscription.paused\"\n | \"subscription.resumed\"\n | \"subscription.resume_failed\"\n | \"subscription.canceled\"\n | \"subscription.updated\"\n | \"subscription.plan_changed\"\n | \"subscription.cancellation_scheduled\"\n | \"subscription.cancellation_revoked\"\n | \"subscription.plan_change_scheduled\"\n | \"subscription.plan_change_revoked\"\n | \"subscription.version_changed\"\n | \"subscription.version_change_canceled\"\n | \"subscription.past_due\"\n | \"trial.started\"\n | \"trial.converted\"\n | \"trial.expired\"\n | \"trial.will_end\"\n | \"trial.checkout_ready\"\n | \"checkout.ready\"\n | \"payment.received\"\n | \"payment.failed\"\n | \"payment.recovered\"\n | \"payment.retry_failed\"\n | \"payment.refunded\"\n | \"payment.disputed\"\n | \"payment.dispute_resolved\"\n | \"payment_link.created\"\n | \"payment_link.completed\"\n | \"payment_link.failed\"\n | \"payment_link.canceled\"\n | \"invoice.created\"\n | \"invoice.voided\"\n | \"invoice.overdue\"\n | \"invoice.upcoming\"\n | \"payment_method.attached\"\n | \"payment_method.updated\"\n | \"payment_method.detached\"\n | \"customer.created\"\n | \"customer.updated\"\n | \"customer.state_changed\"\n | \"plan_grant.created\"\n | \"plan_grant.updated\"\n | \"plan_grant.expired\"\n | \"plan_grant.revoked\"\n | \"credits.granted\"\n | \"credits.purchased\"\n | \"credits.low\"\n | \"credits.depleted\"\n | \"credits.expired\"\n | \"balance.granted\"\n | \"balance.topped_up\"\n | \"balance.low\"\n | \"balance.depleted\"\n | \"balance.expired\"\n | \"quota.threshold_reached\"\n | \"quota.exceeded\"\n | \"seats.updated\"\n | \"seats.limit_reached\"\n | \"addon.activated\"\n | \"addon.deactivated\"\n | \"usage.recorded\"\n | \"payout.available\"\n | \"payout.created\"\n | \"payout.paid\"\n | \"payout.failed\"\n >;\n description?: string | null;\n isActive?: boolean;\n apiVersion?: string;\n}\n\nexport interface DeleteWebhookEndpointParams {\n id: string;\n}\n\nexport interface TestWebhookEndpointParams {\n id: string;\n}\n\nexport interface ListWebhookEndpointsParams {\n cursor?: string;\n limit?: number;\n}\n\nexport interface CreateWebhookEndpointParams {\n url: string;\n events: Array<\n | \"subscription.created\"\n | \"subscription.activated\"\n | \"subscription.reactivated\"\n | \"subscription.pause_scheduled\"\n | \"subscription.pause_updated\"\n | \"subscription.pause_revoked\"\n | \"subscription.paused\"\n | \"subscription.resumed\"\n | \"subscription.resume_failed\"\n | \"subscription.canceled\"\n | \"subscription.updated\"\n | \"subscription.plan_changed\"\n | \"subscription.cancellation_scheduled\"\n | \"subscription.cancellation_revoked\"\n | \"subscription.plan_change_scheduled\"\n | \"subscription.plan_change_revoked\"\n | \"subscription.version_changed\"\n | \"subscription.version_change_canceled\"\n | \"subscription.past_due\"\n | \"trial.started\"\n | \"trial.converted\"\n | \"trial.expired\"\n | \"trial.will_end\"\n | \"trial.checkout_ready\"\n | \"checkout.ready\"\n | \"payment.received\"\n | \"payment.failed\"\n | \"payment.recovered\"\n | \"payment.retry_failed\"\n | \"payment.refunded\"\n | \"payment.disputed\"\n | \"payment.dispute_resolved\"\n | \"payment_link.created\"\n | \"payment_link.completed\"\n | \"payment_link.failed\"\n | \"payment_link.canceled\"\n | \"invoice.created\"\n | \"invoice.voided\"\n | \"invoice.overdue\"\n | \"invoice.upcoming\"\n | \"payment_method.attached\"\n | \"payment_method.updated\"\n | \"payment_method.detached\"\n | \"customer.created\"\n | \"customer.updated\"\n | \"customer.state_changed\"\n | \"plan_grant.created\"\n | \"plan_grant.updated\"\n | \"plan_grant.expired\"\n | \"plan_grant.revoked\"\n | \"credits.granted\"\n | \"credits.purchased\"\n | \"credits.low\"\n | \"credits.depleted\"\n | \"credits.expired\"\n | \"balance.granted\"\n | \"balance.topped_up\"\n | \"balance.low\"\n | \"balance.depleted\"\n | \"balance.expired\"\n | \"quota.threshold_reached\"\n | \"quota.exceeded\"\n | \"seats.updated\"\n | \"seats.limit_reached\"\n | \"addon.activated\"\n | \"addon.deactivated\"\n | \"usage.recorded\"\n | \"payout.available\"\n | \"payout.created\"\n | \"payout.paid\"\n | \"payout.failed\"\n >;\n description?: string;\n apiVersion?: string;\n}\n\nexport class GeneratedWebhooksResource extends Webhooks {\n constructor(private httpClient: CommetHTTPClient) {\n super();\n }\n\n /** Retrieve a webhook endpoint by its public ID. */\n async get(\n params: GetWebhookEndpointParams,\n options?: RequestOptions,\n ): Promise<Webhook> {\n const { id } = params;\n return this.httpClient.get(`/webhooks/${id}`, undefined, options);\n }\n\n /** Update a webhook endpoint. Only the provided fields change. */\n async update(\n params: UpdateWebhookEndpointParams,\n options?: RequestOptions,\n ): Promise<Webhook> {\n const { id, ...rest } = params;\n return this.httpClient.patch(`/webhooks/${id}`, rest, options);\n }\n\n /** Permanently delete a webhook endpoint. */\n async delete(\n params: DeleteWebhookEndpointParams,\n options?: RequestOptions,\n ): Promise<DeletedObject> {\n const { id } = params;\n return this.httpClient.delete(`/webhooks/${id}`, undefined, options);\n }\n\n /** Send a test event to a webhook endpoint to verify connectivity. */\n async test(\n params: TestWebhookEndpointParams,\n options?: RequestOptions,\n ): Promise<WebhookTest> {\n const { id } = params;\n return this.httpClient.post(`/webhooks/${id}/test`, {}, options);\n }\n\n /** List webhook endpoints with cursor-based pagination. */\n async list(\n params?: ListWebhookEndpointsParams,\n options?: RequestOptions,\n ): Promise<{\n object: \"list\";\n data: Array<Webhook>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/webhooks\", params, options);\n }\n\n /** Create a new webhook endpoint. The response includes the signing secret which is only returned once. */\n async create(\n params: CreateWebhookEndpointParams,\n options?: RequestOptions,\n ): Promise<CreatedWebhook> {\n return this.httpClient.post(\"/webhooks\", params, options);\n }\n}\n","export type CommetClientOptions = {\n apiKey: string;\n apiVersion?: string;\n debug?: boolean;\n timeout?: number;\n retries?: number;\n telemetry?: boolean;\n};\n\nexport interface ApiErrorDetail {\n type: string;\n code: string;\n message: string;\n param?: string;\n details?: unknown;\n doc_url?: string;\n}\n\nexport interface CommetErrorContext {\n type?: string;\n param?: string;\n requestId?: string;\n docUrl?: string;\n}\n\nexport class CommetError extends Error {\n public type?: string;\n public param?: string;\n public requestId?: string;\n public docUrl?: string;\n\n constructor(\n message: string,\n public code?: string,\n public statusCode?: number,\n public details?: unknown,\n context?: CommetErrorContext,\n ) {\n super(message);\n this.name = \"CommetError\";\n this.type = context?.type;\n this.param = context?.param;\n this.requestId = context?.requestId;\n this.docUrl = context?.docUrl;\n }\n\n toJSON(): Record<string, unknown> {\n return {\n name: this.name,\n message: this.message,\n type: this.type,\n code: this.code,\n statusCode: this.statusCode,\n param: this.param,\n details: this.details,\n requestId: this.requestId,\n docUrl: this.docUrl,\n };\n }\n}\n\nexport class CommetAPIError extends CommetError {\n constructor(\n message: string,\n statusCode: number,\n code?: string,\n details?: unknown,\n errorDetail?: ApiErrorDetail,\n responseContext?: Pick<CommetErrorContext, \"requestId\">,\n ) {\n super(message, code, statusCode, details, {\n type: errorDetail?.type,\n param: errorDetail?.param,\n requestId: responseContext?.requestId,\n docUrl: errorDetail?.doc_url,\n });\n this.name = \"CommetAPIError\";\n }\n}\n\nexport class CommetValidationError extends CommetAPIError {\n constructor(\n message: string,\n public validationErrors: Record<string, string[]>,\n statusCode = 422,\n errorDetail?: ApiErrorDetail,\n responseContext?: Pick<CommetErrorContext, \"requestId\">,\n ) {\n super(\n message,\n statusCode,\n errorDetail?.code ?? \"validation_error\",\n errorDetail?.details,\n errorDetail,\n responseContext,\n );\n this.name = \"CommetValidationError\";\n }\n\n override toJSON(): Record<string, unknown> {\n return { ...super.toJSON(), validationErrors: this.validationErrors };\n }\n}\n\nexport interface RequestOptions {\n apiVersion?: string;\n idempotencyKey?: string;\n timeout?: number;\n}\n\nimport type {\n InferFeatureCodes,\n InferPlanCodes,\n InferSeatCodes,\n InferUsageCodes,\n} from \"./config\";\n\nexport type ResolvedFeatureCode<TConfig> = [\n InferFeatureCodes<TConfig>,\n] extends [never]\n ? string\n : InferFeatureCodes<TConfig>;\n\nexport type ResolvedSeatCode<TConfig> = [InferSeatCodes<TConfig>] extends [\n never,\n]\n ? string\n : InferSeatCodes<TConfig>;\n\nexport type ResolvedUsageCode<TConfig> = [InferUsageCodes<TConfig>] extends [\n never,\n]\n ? string\n : InferUsageCodes<TConfig>;\n\nexport type ResolvedPlanCode<TConfig> = [InferPlanCodes<TConfig>] extends [\n never,\n]\n ? string\n : InferPlanCodes<TConfig>;\n","export const API_VERSION = \"2026-08-27\";\n\ndeclare const __SDK_VERSION__: string;\nexport const SDK_VERSION: string = __SDK_VERSION__;\n","import { SDK_VERSION } from \"../version\";\n\ninterface RequestMetrics {\n requestId: string;\n durationMs: number;\n}\n\ntype ExecutionContext = \"test\" | \"ci\";\n\ninterface ClientInfo {\n sdk: string;\n sdk_version: string;\n lang: string;\n lang_version: string;\n platform: string;\n arch: string;\n runtime: string;\n runtime_version: string;\n integrations: string[];\n execution_context?: ExecutionContext;\n}\n\nconst registeredIntegrations: Set<string> = new Set();\n\nexport function registerIntegration(name: string, version: string): void {\n registeredIntegrations.add(`${name}@${version}`);\n cachedClientInfo = null;\n}\n\nfunction detectRuntime(): { name: string; version: string } {\n const g = globalThis as Record<string, unknown>;\n const bun = g.Bun as { version: string } | undefined;\n if (bun) return { name: \"bun\", version: bun.version };\n const deno = g.Deno as { version: { deno: string } } | undefined;\n if (deno) return { name: \"deno\", version: deno.version.deno };\n return { name: \"node\", version: process.versions.node };\n}\n\nfunction detectExecutionContext(): ExecutionContext | undefined {\n const g = globalThis as Record<string, unknown>;\n if (g.__vitest_worker__ !== undefined || g.jest !== undefined) {\n return \"test\";\n }\n if (typeof process === \"undefined\" || !process.env) return undefined;\n const env = process.env;\n if (\n env.VITEST ||\n env.JEST_WORKER_ID ||\n env.BUN_TEST ||\n env.NODE_ENV === \"test\" ||\n env.npm_lifecycle_event === \"test\"\n ) {\n return \"test\";\n }\n if (env.CI || env.GITHUB_ACTIONS || env.GITLAB_CI || env.CIRCLECI) {\n return \"ci\";\n }\n return undefined;\n}\n\nlet cachedClientInfo: string | null = null;\nlet cachedUserAgent: string | null = null;\n\nfunction collectClientInfo(): ClientInfo {\n const runtime = detectRuntime();\n const executionContext = detectExecutionContext();\n const info: ClientInfo = {\n sdk: \"commet-node\",\n sdk_version: SDK_VERSION,\n lang: \"node\",\n lang_version: process.versions.node,\n platform: process.platform,\n arch: process.arch,\n runtime: runtime.name,\n runtime_version: runtime.version,\n integrations: [...registeredIntegrations],\n };\n if (executionContext) {\n info.execution_context = executionContext;\n }\n return info;\n}\n\nexport function getClientInfoHeader(): string {\n if (!cachedClientInfo) {\n cachedClientInfo = JSON.stringify(collectClientInfo());\n }\n return cachedClientInfo;\n}\n\nexport function getUserAgent(): string {\n if (!cachedUserAgent) {\n const runtime = detectRuntime();\n cachedUserAgent = `commet-node/${SDK_VERSION} ${runtime.name}/${runtime.version} ${process.platform}/${process.arch}`;\n }\n return cachedUserAgent;\n}\n\nexport function formatRequestMetrics(metrics: RequestMetrics): string {\n return JSON.stringify({\n last_request_metrics: {\n request_id: metrics.requestId,\n duration_ms: metrics.durationMs,\n },\n });\n}\n","import type {\n ApiErrorDetail,\n CommetClientOptions,\n CommetErrorContext,\n RequestOptions,\n} from \"../types/common\";\nimport { CommetAPIError, CommetValidationError } from \"../types/common\";\nimport { API_VERSION } from \"../version\";\nimport {\n formatRequestMetrics,\n getClientInfoHeader,\n getUserAgent,\n} from \"./telemetry\";\n\nconst BASE_URL = \"https://commet.co\";\n\nexport interface RetryConfig {\n maxRetries: number;\n baseDelay: number;\n maxDelay: number;\n retryableStatusCodes: number[];\n}\n\nconst DEFAULT_RETRY_CONFIG: RetryConfig = {\n maxRetries: 3,\n baseDelay: 1000, // 1s\n maxDelay: 8000, // 8s\n retryableStatusCodes: [408, 429, 500, 502, 503, 504],\n};\n\n// Upper bound for server-provided Retry-After waits, so a misbehaving proxy\n// cannot stall the client indefinitely.\nconst RETRY_AFTER_CAP_MS = 30000;\n\nexport class CommetHTTPClient {\n private config: CommetClientOptions;\n private retryConfig: RetryConfig;\n private telemetryEnabled: boolean;\n private lastRequestMetrics: { requestId: string; durationMs: number } | null =\n null;\n\n constructor(config: CommetClientOptions) {\n this.config = config;\n this.telemetryEnabled = config.telemetry !== false;\n this.retryConfig = {\n ...DEFAULT_RETRY_CONFIG,\n maxRetries: config.retries ?? DEFAULT_RETRY_CONFIG.maxRetries,\n };\n }\n\n async get<T = unknown>(\n endpoint: string,\n params?: Record<string, unknown> | object,\n options?: RequestOptions,\n ): Promise<T> {\n return this.request(\n \"GET\",\n endpoint,\n undefined,\n options,\n params as Record<string, unknown>,\n );\n }\n\n async post<T = unknown>(\n endpoint: string,\n data?: unknown,\n options?: RequestOptions,\n ): Promise<T> {\n return this.request(\"POST\", endpoint, data, options);\n }\n\n async put<T = unknown>(\n endpoint: string,\n data?: unknown,\n options?: RequestOptions,\n ): Promise<T> {\n return this.request(\"PUT\", endpoint, data, options);\n }\n\n async patch<T = unknown>(\n endpoint: string,\n data?: unknown,\n options?: RequestOptions,\n ): Promise<T> {\n return this.request(\"PATCH\", endpoint, data, options);\n }\n\n async delete<T = unknown>(\n endpoint: string,\n data?: unknown,\n options?: RequestOptions,\n ): Promise<T> {\n return this.request(\"DELETE\", endpoint, data, options);\n }\n\n private resolveApiVersion(options?: RequestOptions): string {\n return options?.apiVersion ?? this.config.apiVersion ?? API_VERSION;\n }\n\n private static readonly BODY_METHODS = new Set([\"POST\", \"PUT\", \"PATCH\"]);\n\n private async request<T = unknown>(\n method: string,\n endpoint: string,\n data?: unknown,\n options?: RequestOptions,\n params?: Record<string, unknown>,\n ): Promise<T> {\n const url = this.buildURL(endpoint, params);\n\n // Generate idempotency key once before retries — all attempts reuse the same key\n if (\n CommetHTTPClient.BODY_METHODS.has(method) &&\n this.retryConfig.maxRetries > 0 &&\n !options?.idempotencyKey\n ) {\n options = { ...options, idempotencyKey: this.generateIdempotencyKey() };\n }\n\n return this.executeRequest(method, url, data, options);\n }\n\n /**\n * Execute real API request with retry logic\n */\n private async executeRequest<T = unknown>(\n method: string,\n url: string,\n data?: unknown,\n options?: RequestOptions,\n attempt = 1,\n ): Promise<T> {\n try {\n const apiVersion = this.resolveApiVersion(options);\n\n const headers: Record<string, string> = {\n \"x-api-key\": this.config.apiKey,\n \"commet-version\": apiVersion,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": getUserAgent(),\n };\n\n if (this.telemetryEnabled) {\n headers[\"commet-client-info\"] = getClientInfoHeader();\n if (this.lastRequestMetrics) {\n headers[\"commet-client-telemetry\"] = formatRequestMetrics(\n this.lastRequestMetrics,\n );\n this.lastRequestMetrics = null;\n }\n }\n\n if (options?.idempotencyKey) {\n headers[\"Idempotency-Key\"] = options.idempotencyKey;\n }\n\n const requestConfig: RequestInit = {\n method,\n headers,\n signal: AbortSignal.timeout(\n options?.timeout ?? this.config.timeout ?? 30000,\n ),\n };\n\n if (data) {\n requestConfig.body = JSON.stringify(data);\n }\n\n if (this.config.debug) {\n console.log(`[Commet SDK] ${method} ${url}`);\n if (data) {\n console.log(\"Request data:\", JSON.stringify(data, null, 2));\n }\n }\n\n const requestStart = Date.now();\n const response = await fetch(url, requestConfig);\n const responseContext = readResponseContext(response.headers);\n\n if (this.config.debug) {\n console.log(\n `[Commet SDK] Response status: ${response.status} ${response.statusText}`,\n );\n }\n\n let responseData: unknown;\n let responseText: string;\n\n try {\n responseData = await response.json();\n responseText = \"\";\n } catch (_jsonError) {\n try {\n responseText = await response.text();\n } catch (_textError) {\n responseText = \"Failed to read response body\";\n }\n if (this.config.debug) {\n console.log(\n \"[Commet SDK] Failed to parse JSON response:\",\n responseText,\n );\n }\n\n throw new CommetAPIError(\n `Invalid JSON response: ${response.status} ${response.statusText}`,\n response.status,\n \"INVALID_JSON\",\n { responseText },\n undefined,\n responseContext,\n );\n }\n\n if (!response.ok) {\n // Check if we should retry\n if (\n attempt <= this.retryConfig.maxRetries &&\n this.retryConfig.retryableStatusCodes.includes(response.status)\n ) {\n const delay = this.retryDelayMs(attempt, response);\n\n if (delay !== null) {\n if (this.config.debug) {\n console.log(\n `[Commet SDK] Retrying in ${delay}ms (attempt ${attempt}/${this.retryConfig.maxRetries})`,\n );\n }\n\n await this.sleep(delay);\n return this.executeRequest(method, url, data, options, attempt + 1);\n }\n }\n\n // Log error response for debugging\n if (this.config.debug) {\n console.log(\n \"[Commet SDK] Error response:\",\n JSON.stringify(responseData, null, 2),\n );\n }\n\n const errorObj = readObjectProperty(responseData, \"error\");\n\n const errorDetail: ApiErrorDetail = {\n type: readStringProperty(errorObj, \"type\") ?? \"api_error\",\n code: readStringProperty(errorObj, \"code\") ?? \"unknown\",\n message:\n readStringProperty(errorObj, \"message\") ??\n `Request failed with status ${response.status}`,\n param: readStringProperty(errorObj, \"param\"),\n details: Reflect.get(errorObj, \"details\"),\n doc_url: readStringProperty(errorObj, \"doc_url\"),\n };\n\n if (\n errorDetail.code === \"validation_error\" &&\n Array.isArray(errorDetail.details)\n ) {\n const errors: Record<string, string[]> = {};\n for (const detail of errorDetail.details) {\n const field = readStringProperty(detail, \"field\");\n const message = readStringProperty(detail, \"message\");\n if (!(field && message)) continue;\n if (!errors[field]) errors[field] = [];\n errors[field].push(message);\n }\n throw new CommetValidationError(\n errorDetail.message,\n errors,\n response.status,\n errorDetail,\n responseContext,\n );\n }\n\n throw new CommetAPIError(\n errorDetail.message,\n response.status,\n errorDetail.code,\n errorDetail.details,\n errorDetail,\n responseContext,\n );\n }\n\n if (this.config.debug) {\n console.log(\"[Commet SDK] Response:\", responseData);\n }\n\n if (this.telemetryEnabled && responseContext.requestId) {\n this.lastRequestMetrics = {\n requestId: responseContext.requestId,\n durationMs: Date.now() - requestStart,\n };\n }\n\n return responseData as T;\n } catch (error) {\n // Handle network errors and timeouts\n const isNetworkError =\n error instanceof TypeError && error.message.includes(\"fetch\");\n const isTimeoutError =\n error instanceof DOMException && error.name === \"AbortError\";\n const isTimeoutErrorModern =\n typeof globalThis.DOMException !== \"undefined\" &&\n error instanceof DOMException &&\n error.name === \"TimeoutError\";\n\n if (isNetworkError || isTimeoutError || isTimeoutErrorModern) {\n if (attempt <= this.retryConfig.maxRetries) {\n const delay = this.backoffDelayMs(attempt);\n\n if (this.config.debug) {\n console.log(`[Commet SDK] Network error, retrying in ${delay}ms`);\n }\n\n await this.sleep(delay);\n return this.executeRequest(method, url, data, options, attempt + 1);\n }\n }\n\n throw error;\n }\n }\n\n /**\n * Build full URL from endpoint and params\n */\n private buildURL(endpoint: string, params?: Record<string, unknown>): string {\n // Construct full path with /api prefix\n const normalizedEndpoint = endpoint.startsWith(\"/\")\n ? endpoint\n : `/${endpoint}`;\n const fullPath = `/api/v1${normalizedEndpoint}`;\n\n // Debug logging\n if (this.config.debug) {\n console.log(\n `[Commet SDK] Building URL - endpoint: ${endpoint}, fullPath: ${fullPath}`,\n );\n }\n\n const url = new URL(fullPath, BASE_URL);\n\n if (params) {\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined && value !== null) {\n url.searchParams.append(key, String(value));\n }\n }\n }\n\n const finalUrl = url.toString();\n\n // Debug final URL\n if (this.config.debug) {\n console.log(`[Commet SDK] Final URL: ${finalUrl}`);\n }\n\n return finalUrl;\n }\n\n // 429 retries wait exactly what the rate limiter reports in Retry-After\n // (seconds until the window resets); a 429 without the header did not come\n // from the rate limiter, so it is not retried (returns null). Exponential\n // backoff only applies to statuses that carry no server-provided wait.\n private retryDelayMs(attempt: number, response: Response): number | null {\n if (response.status === 429) {\n const retryAfterSeconds = Number(response.headers.get(\"retry-after\"));\n if (Number.isFinite(retryAfterSeconds) && retryAfterSeconds > 0) {\n return Math.min(retryAfterSeconds * 1000, RETRY_AFTER_CAP_MS);\n }\n return null;\n }\n return this.backoffDelayMs(attempt);\n }\n\n private backoffDelayMs(attempt: number): number {\n return Math.min(\n this.retryConfig.baseDelay * 2 ** (attempt - 1),\n this.retryConfig.maxDelay,\n );\n }\n\n private generateIdempotencyKey(): string {\n return `commet-node-retry-${crypto.randomUUID()}`;\n }\n\n /**\n * Sleep for specified milliseconds\n */\n private sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n}\n\nexport function readResponseContext(\n headers: Headers,\n): Pick<CommetErrorContext, \"requestId\"> {\n return { requestId: headers.get(\"x-request-id\") ?? undefined };\n}\n\nfunction readObjectProperty(value: unknown, property: string): object {\n if (typeof value !== \"object\" || value === null) return {};\n const propertyValue = Reflect.get(value, property);\n return typeof propertyValue === \"object\" && propertyValue !== null\n ? propertyValue\n : {};\n}\n\nfunction readStringProperty(\n value: unknown,\n property: string,\n): string | undefined {\n if (typeof value !== \"object\" || value === null) return undefined;\n const propertyValue = Reflect.get(value, property);\n return typeof propertyValue === \"string\" ? propertyValue : undefined;\n}\n","import { SDK_VERSION } from \"../version\";\n\nconst NPM_DIST_TAGS_URL =\n \"https://registry.npmjs.org/-/package/%40commet%2Fnode/dist-tags\";\nconst UPDATE_CHECK_TIMEOUT_MS = 3000;\nconst UPDATE_CHECK_STATE_KEY = Symbol.for(\"@commet/node.update-check\");\n\ntype VersionNumbers = readonly [number, number, number];\n\ninterface ParsedVersion {\n numbers: VersionNumbers;\n prereleaseIdentifiers: string[];\n}\n\nfunction parseVersion(version: string): ParsedVersion | null {\n const match =\n /^(\\d+)\\.(\\d+)\\.(\\d+)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$/.exec(\n version,\n );\n if (!match) return null;\n\n const numbers: VersionNumbers = [\n Number(match[1]),\n Number(match[2]),\n Number(match[3]),\n ];\n if (!numbers.every(Number.isSafeInteger)) return null;\n\n return {\n numbers,\n prereleaseIdentifiers: match[4] ? match[4].split(\".\") : [],\n };\n}\n\nfunction compareNumericIdentifier(latest: string, installed: string): number {\n const normalizedLatest = latest.replace(/^0+(?=\\d)/, \"\");\n const normalizedInstalled = installed.replace(/^0+(?=\\d)/, \"\");\n if (normalizedLatest.length > normalizedInstalled.length) return 1;\n if (normalizedLatest.length < normalizedInstalled.length) return -1;\n if (normalizedLatest > normalizedInstalled) return 1;\n if (normalizedLatest < normalizedInstalled) return -1;\n return 0;\n}\n\nfunction comparePrereleaseIdentifier(\n latest: string,\n installed: string,\n): number {\n const latestIsNumber = /^\\d+$/.test(latest);\n const installedIsNumber = /^\\d+$/.test(installed);\n\n if (latestIsNumber && installedIsNumber) {\n return compareNumericIdentifier(latest, installed);\n }\n if (latestIsNumber) return -1;\n if (installedIsNumber) return 1;\n if (latest > installed) return 1;\n if (latest < installed) return -1;\n return 0;\n}\n\nfunction comparePrereleaseVersions(\n latest: string[],\n installed: string[],\n): number {\n if (latest.length === 0) return installed.length === 0 ? 0 : 1;\n if (installed.length === 0) return -1;\n\n const identifierCount = Math.max(latest.length, installed.length);\n for (let index = 0; index < identifierCount; index++) {\n const latestIdentifier = latest[index];\n const installedIdentifier = installed[index];\n if (latestIdentifier === undefined) return -1;\n if (installedIdentifier === undefined) return 1;\n\n const comparison = comparePrereleaseIdentifier(\n latestIdentifier,\n installedIdentifier,\n );\n if (comparison !== 0) return comparison;\n }\n\n return 0;\n}\n\nexport function isNewerVersion(latest: string, installed: string): boolean {\n const latestVersion = parseVersion(latest);\n const installedVersion = parseVersion(installed);\n if (!latestVersion || !installedVersion) return false;\n\n for (let index = 0; index < latestVersion.numbers.length; index++) {\n if (latestVersion.numbers[index] > installedVersion.numbers[index]) {\n return true;\n }\n if (latestVersion.numbers[index] < installedVersion.numbers[index]) {\n return false;\n }\n }\n\n return (\n comparePrereleaseVersions(\n latestVersion.prereleaseIdentifiers,\n installedVersion.prereleaseIdentifiers,\n ) > 0\n );\n}\n\nfunction claimSdkUpdateCheck(): boolean {\n if (Reflect.get(globalThis, UPDATE_CHECK_STATE_KEY) === true) return false;\n Reflect.set(globalThis, UPDATE_CHECK_STATE_KEY, true);\n return true;\n}\n\nexport function shouldCheckForSdkUpdates(\n environment: NodeJS.ProcessEnv = process.env,\n): boolean {\n if (environment.NODE_ENV !== \"development\") return false;\n if (environment.CI) return false;\n return environment.COMMET_NO_UPDATE_CHECK !== \"1\";\n}\n\nasync function checkForSdkUpdate(installedVersion: string): Promise<void> {\n try {\n const response = await fetch(NPM_DIST_TAGS_URL, {\n signal: AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS),\n });\n if (!response.ok) return;\n\n const distTags: unknown = await response.json();\n if (\n typeof distTags !== \"object\" ||\n distTags === null ||\n !(\"latest\" in distTags) ||\n typeof distTags.latest !== \"string\" ||\n !isNewerVersion(distTags.latest, installedVersion)\n ) {\n return;\n }\n\n console.warn(\n `[Commet] @commet/node ${installedVersion} is out of date. The latest version is ${distTags.latest}.\\nUpdate with: npm install @commet/node@latest`,\n );\n } catch {}\n}\n\nexport function scheduleSdkUpdateCheck(): void {\n if (!shouldCheckForSdkUpdates() || !claimSdkUpdateCheck()) return;\n\n const scheduledCheck = setImmediate(() => {\n void checkForSdkUpdate(SDK_VERSION);\n });\n scheduledCheck.unref();\n}\n","import { GeneratedResources } from \"./_generated_resources\";\nimport { GeneratedWebhooksResource } from \"./resources/generated-webhooks\";\nimport type { CommetClientOptions } from \"./types/common\";\nimport type { BillingConfig } from \"./types/config\";\nimport { CommetHTTPClient } from \"./utils/http\";\nimport { scheduleSdkUpdateCheck } from \"./utils/update-check\";\n\nexport class Commet<_TConfig = unknown> extends GeneratedResources {\n private httpClient: CommetHTTPClient;\n\n public readonly webhooks: GeneratedWebhooksResource;\n\n constructor(config: CommetClientOptions) {\n super();\n\n if (!config.apiKey) {\n throw new Error(\"Commet SDK: API key is required\");\n }\n\n if (!config.apiKey.startsWith(\"ck_\") && !config.apiKey.startsWith(\"rk_\")) {\n throw new Error(\n \"Commet SDK: Invalid API key format. Expected prefix ck_ or rk_\",\n );\n }\n\n this.httpClient = new CommetHTTPClient(config);\n this.initResources(this.httpClient);\n this.webhooks = new GeneratedWebhooksResource(this.httpClient);\n scheduleSdkUpdateCheck();\n }\n}\n\nexport function createCommet<const TConfig extends BillingConfig>(\n _billingConfig: TConfig,\n options: CommetClientOptions,\n): Commet<TConfig> {\n return new Commet<TConfig>(options);\n}\n","export type FeatureDef =\n | { name: string; type: \"boolean\"; description?: string }\n | {\n name: string;\n type: \"usage\";\n unitName?: string;\n description?: string;\n }\n | {\n name: string;\n type: \"seats\";\n unitName?: string;\n description?: string;\n };\n\nexport interface PriceDef {\n interval:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"semiannual\"\n | \"yearly\"\n | \"one_time\";\n /** Rate scale: 10000 = $1.00 */\n amount: number;\n trialDays?: number;\n}\n\nexport type PlanFeatureValue =\n | boolean\n | {\n included?: number;\n unlimited?: boolean;\n overage?: { unitPrice: number };\n };\n\nexport interface PlanDef {\n name: string;\n description?: string;\n consumptionModel?: \"metered\" | \"credits\" | \"balance\";\n defaultInterval?: PriceDef[\"interval\"];\n isFree?: boolean;\n isPublic?: boolean;\n sortOrder?: number;\n prices: PriceDef[];\n features?: Record<string, PlanFeatureValue>;\n}\n\nexport interface BillingConfig {\n features: Record<string, FeatureDef>;\n plans: Record<string, PlanDef>;\n}\n\nexport function defineConfig<const T extends BillingConfig>(config: T): T {\n return config;\n}\n\nexport type InferFeatureCodes<T> = T extends { features: infer F }\n ? keyof F & string\n : never;\n\nexport type InferPlanCodes<T> = T extends { plans: infer P }\n ? keyof P & string\n : never;\n\nexport type InferSeatCodes<T> = T extends { features: infer F }\n ? {\n [K in keyof F]: F[K] extends { type: \"seats\" } ? K & string : never;\n }[keyof F]\n : never;\n\nexport type InferUsageCodes<T> = T extends { features: infer F }\n ? {\n [K in keyof F]: F[K] extends { type: \"usage\" } ? K & string : never;\n }[keyof F]\n : never;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC0EO,IAAM,iBAAN,MAAqB;AAAA,EAC1B,YAAoB,YAA8B;AAA9B;AAAA,EAA+B;AAAA;AAAA,EAGnD,MAAM,WACJ,QACA,SAMC;AACD,WAAO,KAAK,WAAW,IAAI,kBAAk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