@commet/node 7.10.0 → 8.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -3
- package/dist/index.d.mts +2029 -940
- package/dist/index.d.ts +2029 -940
- package/dist/index.js +396 -342
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +396 -342
- package/dist/index.mjs.map +1 -1
- 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/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/_generated_resources.ts","../src/resources/usage.ts","../src/resources/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":["// Core (hand-written, never generated)\nexport { 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 CreateCustomerParams,\n GetCustomerParams,\n ListCustomersParams,\n UpdateCustomerParams,\n} from \"./resources/customers\";\nexport type {\n CanUseFeatureParams,\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 CreateAdjustmentInvoiceParams,\n DownloadInvoiceParams,\n GetInvoiceParams,\n ListInvoicesParams,\n SendInvoiceParams,\n UpdateInvoiceStatusParams,\n} from \"./resources/invoices\";\nexport type {\n CancelPaymentParams,\n ChargePaymentParams,\n CreatePaymentParams,\n GetPaymentParams,\n ListPaymentsParams,\n} from \"./resources/payments\";\nexport type {\n AddPayoutBankAccountParams,\n CompletePayoutVerificationParams,\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 CancelSubscriptionParams,\n ChangePlanParams,\n CreateSubscriptionParams,\n CreateSubscriptionRecoveryLinkParams,\n DeactivateAddonParams,\n GetActiveSubscriptionParams,\n GetSubscriptionParams,\n ListSubscriptionsParams,\n PreviewChangePlanParams,\n PurchaseCreditsParams,\n ReactivateSubscriptionParams,\n TopupBalanceParams,\n UncancelSubscriptionParams,\n UpdatePaymentMethodParams,\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\";\n// Preserved hand-written resources (custom logic, not generated)\nexport type {\n CheckUsageParams,\n SetUsageParams,\n TrackModelTokensParams,\n TrackParams,\n TrackUsageParams,\n UsageAdjustment,\n UsageCheckDenialReason,\n UsageCheckResult,\n UsageEvent,\n UsageEventProperty,\n} from \"./resources/usage\";\nexport type {\n CreateWebhookParams,\n DeleteWebhookParams,\n GetWebhookParams,\n ListWebhooksParams,\n TestWebhookParams,\n UpdateWebhookParams,\n WebhookData,\n WebhookEndpoint,\n WebhookEndpointCreated,\n WebhookEventHandler,\n WebhookPayload,\n WebhookTestResult,\n} from \"./resources/webhooks\";\nexport { Webhooks } from \"./resources/webhooks\";\nexport type {\n ApiErrorDetail,\n ApiResponse,\n CommetClientOptions,\n Currency,\n CustomerID,\n EventID,\n PaginatedList,\n PaginatedResponse,\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 DiscountType,\n FeatureType,\n InvoiceType,\n PaymentProvider,\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 BulkSeatUpdate,\n CanceledSubscription,\n ClaimLink,\n CreatedApiKey,\n CreatedInvoice,\n CreditGrant,\n CreditPack,\n Customer,\n CustomerBatch,\n DefaultPlanPrice,\n DeletedObject,\n DeletedPlanRegionalPricing,\n DeletedSubscriptionAddon,\n Feature,\n FeatureAccess,\n FeatureLookup,\n Invoice,\n InvoiceDownload,\n InvoiceStatus,\n Payment,\n PaymentMethodUpdateCheckout,\n Payout,\n PayoutBankAccount,\n PayoutVerification,\n Plan,\n PlanChange,\n PlanFeature,\n PlanGroup,\n PlanPrice,\n PlanRegionalPricing,\n PlanRegionalPricingResult,\n PlanVisibility,\n PortalAccess,\n PreviewChange,\n PromoCode,\n ReactivatedSubscription,\n RecoveryLink,\n RemovedPlanFeature,\n RemovedPlanFromGroup,\n ReorderedPlans,\n SeatBalance,\n SeatBalanceListItem,\n SeatEvent,\n SentInvoice,\n Subscription,\n SubscriptionAddon,\n TestClock,\n TestClockBilling,\n Transaction,\n TransactionRefund,\n TransactionRetry,\n UncanceledSubscription,\n UsageQuota,\n UsageQuotaEvent,\n WebhookAddonRef,\n WebhookBalance,\n WebhookBankRef,\n WebhookCardInfo,\n WebhookCreditsBalance,\n WebhookFeatureAccess,\n WebhookPlanRef,\n WebhookSeatSummary,\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 { ApiResponse, 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 ListAddonsParams {\n limit?: number;\n cursor?: string;\n}\n\nexport interface GetAddonParams {\n id: string;\n}\n\nexport interface CreateAddonParams {\n name: string;\n description?: string;\n basePrice: number;\n featureId: string;\n consumptionModel: \"boolean\" | \"metered\" | \"credits\" | \"balance\";\n includedUnits?: number;\n overageRate?: number;\n creditCost?: number;\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 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<ApiResponse<Array<ActiveAddon>>> {\n return this.httpClient.get(\"/active-addons\", params, options);\n }\n\n /** List all add-ons with cursor-based pagination. */\n async list(\n params?: ListAddonsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Array<Addon>>> {\n return this.httpClient.get(\"/addons\", params, options);\n }\n\n /** Retrieve an add-on by its public ID or slug. */\n async get(\n params: GetAddonParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Addon>> {\n const { id } = params;\n return this.httpClient.get(`/addons/${id}`, undefined, 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<ApiResponse<Addon>> {\n return this.httpClient.post(\"/addons\", params, options);\n }\n\n /** Update an add-on's name, description, or pricing. */\n async update(\n params: UpdateAddonParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Addon>> {\n const { id, ...rest } = params;\n return this.httpClient.put(`/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<ApiResponse<DeletedObject>> {\n const { id } = params;\n return this.httpClient.delete(`/addons/${id}`, undefined, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { ApiKey, CreatedApiKey, DeletedObject } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface ListApiKeysParams {\n /** @format date-time */\n cursor?: string;\n limit?: number;\n}\n\nexport interface CreateApiKeyParams {\n name: string;\n expiresInDays?: number;\n}\n\nexport interface DeleteApiKeyParams {\n id: string;\n}\n\nexport class ApiKeysResource {\n constructor(private httpClient: CommetHTTPClient) {}\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<ApiResponse<Array<ApiKey>>> {\n return this.httpClient.get(\"/api-keys\", params, options);\n }\n\n /** Create a new API key. The full key is only returned once in the response. */\n async create(\n params: CreateApiKeyParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CreatedApiKey>> {\n return this.httpClient.post(\"/api-keys\", params, options);\n }\n\n /** Permanently revoke and delete an API key. */\n async delete(\n params: DeleteApiKeyParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<DeletedObject>> {\n const { id } = params;\n return this.httpClient.delete(`/api-keys/${id}`, undefined, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { CreditPack, DeletedObject } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface CreateCreditPackParams {\n name: string;\n description?: string;\n credits: number;\n price: number;\n isActive?: boolean;\n}\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 class CreditPacksResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** List all active credit packs. */\n async list(): Promise<ApiResponse<Array<CreditPack>>> {\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<ApiResponse<CreditPack>> {\n return this.httpClient.post(\"/credit-packs/manage\", params, options);\n }\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<ApiResponse<CreditPack>> {\n const { id, ...rest } = params;\n return this.httpClient.put(`/credit-packs/${id}`, rest, options);\n }\n\n /** Soft-delete a credit pack. */\n async delete(\n params: DeleteCreditPackParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<DeletedObject>> {\n const { id } = params;\n return this.httpClient.delete(`/credit-packs/${id}`, undefined, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { Timezone } from \"../types/enums\";\nimport type { Customer, CustomerBatch } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface ListCustomersParams {\n externalId?: string;\n limit?: number;\n cursor?: string;\n}\n\nexport interface CreateCustomerParams {\n id?: string;\n externalId?: string;\n fullName?: string;\n taxDocument?: 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}\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 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}\n\nexport class CustomersResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** List customers with cursor-based pagination. */\n async list(\n params?: ListCustomersParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Array<Customer>>> {\n return this.httpClient.get(\"/customers\", params, options);\n }\n\n /** Create a new customer. Idempotent when customerId is provided. */\n async create(\n params: CreateCustomerParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Customer>> {\n return this.httpClient.post(\"/customers\", params, 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<ApiResponse<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<ApiResponse<Customer>> {\n const { id, ...rest } = params;\n return this.httpClient.put(`/customers/${id}`, rest, options);\n }\n\n /** Create up to 100 customers in a single request. */\n async createBatch(\n params: BatchCreateCustomersParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CustomerBatch>> {\n return this.httpClient.post(\"/customers/batch\", params, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { FeatureAccess, FeatureLookup } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface ListFeatureAccessParams {\n customerId: string;\n}\n\nexport interface GetFeatureAccessParams {\n code: string;\n customerId: string;\n action?: string;\n}\n\nexport interface CanUseFeatureParams {\n code: string;\n customerId: string;\n}\n\nexport class FeatureAccessResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** List all features for a customer's active subscription, scoped by the customerId query parameter. */\n async list(\n params: ListFeatureAccessParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Array<FeatureAccess>>> {\n return this.httpClient.get(\"/feature-access\", params, options);\n }\n\n /** Get feature access details for a customer. Use action=canUse to check if the customer can consume one more unit. */\n async get(\n params: GetFeatureAccessParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<FeatureLookup>> {\n const { code, ...rest } = params;\n return this.httpClient.get(`/feature-access/${code}`, rest, options);\n }\n\n /** Get feature access details for a customer. Use action=canUse to check if the customer can consume one more unit. */\n async canUse(\n params: CanUseFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<FeatureLookup>> {\n const { code, ...rest } = params;\n return this.httpClient.get(\n `/feature-access/${code}`,\n { ...rest, action: \"canUse\" },\n options,\n );\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { FeatureType } from \"../types/enums\";\nimport type { DeletedObject, Feature } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface GetFeatureParams {\n code: string;\n}\n\nexport interface CreateFeatureParams {\n name: string;\n code: string;\n type: FeatureType;\n description?: string;\n unitName?: 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 class FeaturesResource {\n constructor(private httpClient: CommetHTTPClient) {}\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<ApiResponse<Array<Feature>>> {\n return this.httpClient.get(\"/features\");\n }\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<ApiResponse<Feature>> {\n const { code } = params;\n return this.httpClient.get(`/features/${code}`, undefined, options);\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<ApiResponse<Feature>> {\n return this.httpClient.post(\"/features/manage\", params, 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<ApiResponse<Feature>> {\n const { code, ...rest } = params;\n return this.httpClient.put(`/features/${code}/manage`, 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<ApiResponse<DeletedObject>> {\n const { code } = params;\n return this.httpClient.delete(\n `/features/${code}/manage`,\n undefined,\n options,\n );\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type {\n CreatedInvoice,\n Invoice,\n InvoiceDownload,\n InvoiceStatus,\n SentInvoice,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface ListInvoicesParams {\n customerId?: string;\n status?: \"draft\" | \"outstanding\" | \"paid\" | \"void\" | \"uncollectible\";\n subscriptionId?: string;\n /** @format date-time */\n cursor?: string;\n limit?: number;\n}\n\nexport interface GetInvoiceParams {\n id: string;\n}\n\nexport interface CreateAdjustmentInvoiceParams {\n customerId: string;\n amount: number;\n description: string;\n metadata?: Record<string, unknown>;\n}\n\nexport interface DownloadInvoiceParams {\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 class InvoicesResource {\n constructor(private httpClient: CommetHTTPClient) {}\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<ApiResponse<Array<Invoice>>> {\n return this.httpClient.get(\"/invoices\", params, 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<ApiResponse<Invoice>> {\n const { id } = params;\n return this.httpClient.get(`/invoices/${id}`, undefined, options);\n }\n\n /** Create a one-off adjustment invoice. Use a negative amount for a credit. */\n async createAdjustment(\n params: CreateAdjustmentInvoiceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CreatedInvoice>> {\n return this.httpClient.post(\"/invoices\", params, options);\n }\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<ApiResponse<InvoiceDownload>> {\n const { id } = params;\n return this.httpClient.get(`/invoices/${id}/download`, undefined, options);\n }\n\n /** Send the invoice to the customer via email. */\n async send(\n params: SendInvoiceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<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\". Cannot change the status of already paid or voided invoices. */\n async updateStatus(\n params: UpdateInvoiceStatusParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<InvoiceStatus>> {\n const { id, ...rest } = params;\n return this.httpClient.put(`/invoices/${id}/status`, rest, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { Payment } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface ListPaymentsParams {\n customerId?: string;\n /** @format date-time */\n cursor?: string;\n limit?: number;\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 interface ChargePaymentParams {\n customerId: string;\n amount: number;\n currency: string;\n description: string;\n metadata?: Record<string, string>;\n}\n\nexport interface GetPaymentParams {\n id: string;\n}\n\nexport interface CancelPaymentParams {\n id: string;\n}\n\nexport class PaymentsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** List payments with cursor-based pagination. Filter by customer. */\n async list(\n params?: ListPaymentsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Array<Payment>>> {\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<ApiResponse<Payment>> {\n return this.httpClient.post(\"/payments\", params, 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<ApiResponse<Payment>> {\n return this.httpClient.post(\"/payments/charge\", params, options);\n }\n\n /** Retrieve a payment by its public ID. */\n async get(\n params: GetPaymentParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Payment>> {\n const { id } = params;\n return this.httpClient.get(`/payments/${id}`, undefined, options);\n }\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<ApiResponse<Payment>> {\n const { id } = params;\n return this.httpClient.post(`/payments/${id}/cancel`, {}, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type {\n Payout,\n PayoutBankAccount,\n PayoutVerification,\n} 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 interface CompletePayoutVerificationParams {\n email: string;\n businessType: \"individual\" | \"company\";\n businessUrl: string;\n documentUrl: string;\n bank: {\n accountNumber: string;\n accountHolderName: string;\n routingNumber?: string;\n accountType?: \"checking\" | \"savings\";\n };\n individual?: {\n firstName: string;\n lastName: string;\n phone: string;\n dateOfBirth: string;\n ssnLast4?: string;\n idNumber?: string;\n address: {\n line1: string;\n line2?: string;\n city: string;\n state?: string;\n postalCode: string;\n country: string;\n };\n };\n company?: {\n name: string;\n taxId: string;\n address: {\n line1: string;\n line2?: string;\n city: string;\n state?: string;\n postalCode: string;\n country: string;\n };\n representative: {\n firstName: string;\n lastName: string;\n phone?: string;\n email?: string;\n };\n };\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<ApiResponse<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<ApiResponse<Payout>> {\n return this.httpClient.post(\"/payouts\", params, options);\n }\n\n /** Provision the organization's payout account in a single call with the full KYC + bank payload. Uploads the identity document, persists the destination bank, and creates the connected account through the org's payout provider. The account starts `pending_verification` and flips to `verified` via the provider's webhook. Idempotent: returns the existing account if the org already has one. */\n async completeVerification(\n params: CompletePayoutVerificationParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PayoutVerification>> {\n return this.httpClient.post(\"/payouts/verification\", params, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type {\n AddedPlanToGroup,\n DeletedObject,\n PlanGroup,\n RemovedPlanFromGroup,\n ReorderedPlans,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface ListPlanGroupsParams {\n limit?: number;\n cursor?: string;\n}\n\nexport interface GetPlanGroupParams {\n id: string;\n}\n\nexport interface CreatePlanGroupParams {\n name: string;\n description?: string;\n isPublic?: boolean;\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 AddPlanToGroupParams {\n id: string;\n planId: string;\n sortOrder?: number;\n}\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 class PlanGroupsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** List plan groups with cursor-based pagination. */\n async list(\n params?: ListPlanGroupsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Array<PlanGroup>>> {\n return this.httpClient.get(\"/plan-groups\", params, 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<ApiResponse<PlanGroup>> {\n const { id } = params;\n return this.httpClient.get(`/plan-groups/${id}`, undefined, options);\n }\n\n /** Create a new plan group for organizing plans. */\n async create(\n params: CreatePlanGroupParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanGroup>> {\n return this.httpClient.post(\"/plan-groups\", params, options);\n }\n\n /** Update a plan group's name, description, or visibility. */\n async update(\n params: UpdatePlanGroupParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanGroup>> {\n const { id, ...rest } = params;\n return this.httpClient.put(`/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<ApiResponse<DeletedObject>> {\n const { id } = params;\n return this.httpClient.delete(`/plan-groups/${id}`, undefined, options);\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<ApiResponse<AddedPlanToGroup>> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/plan-groups/${id}/plans`, rest, options);\n }\n\n /** Remove a plan from a plan group. */\n async removePlan(\n params: RemovePlanFromGroupParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<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<ApiResponse<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","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type {\n BillingInterval,\n ConsumptionModel,\n DiscountType,\n} from \"../types/enums\";\nimport type {\n DefaultPlanPrice,\n DeletedObject,\n DeletedPlanRegionalPricing,\n Plan,\n PlanFeature,\n PlanPrice,\n PlanRegionalPricing,\n PlanRegionalPricingResult,\n PlanVisibility,\n RemovedPlanFeature,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface ListPlansParams {\n includePrivate?: \"true\" | \"false\";\n}\n\nexport interface GetPlanParams {\n id: string;\n}\n\nexport interface CreatePlanParams {\n name: string;\n code: string;\n description?: string;\n consumptionModel?: ConsumptionModel;\n isPublic?: boolean;\n isFree?: boolean;\n blockOnExhaustion?: boolean;\n planGroupId?: string;\n metadata?: Record<string, unknown>;\n}\n\nexport interface UpdatePlanParams {\n id: string;\n name?: string;\n description?: string | null;\n metadata?: Record<string, unknown>;\n isPublic?: boolean;\n}\n\nexport interface DeletePlanParams {\n id: string;\n}\n\nexport interface SetPlanVisibilityParams {\n id: string;\n isPublic: boolean;\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 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 AddPlanPriceParams {\n id: string;\n billingInterval: BillingInterval;\n price: number;\n trialDays?: number;\n isDefault?: boolean;\n includedBalance?: number | null;\n includedCredits?: number | null;\n introOffer?: {\n enabled: boolean;\n discountType?: DiscountType | null;\n discountValue?: number | null;\n durationCycles?: number | null;\n };\n}\n\nexport interface UpdatePlanPriceParams {\n id: string;\n priceId: string;\n price?: number;\n isDefault?: boolean;\n trialDays?: number;\n includedBalance?: number | null;\n includedCredits?: number | null;\n introOffer?: {\n enabled?: boolean;\n discountType?: DiscountType | null;\n discountValue?: number | null;\n durationCycles?: number | null;\n };\n}\n\nexport interface DeletePlanPriceParams {\n id: string;\n priceId: 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 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 | \"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 introOffers?: Array<{\n priceId: string;\n discountType: DiscountType;\n discountValue: number;\n durationCycles: number;\n }>;\n}\n\nexport interface DeleteRegionalPricesParams {\n id: string;\n priceId: string;\n}\n\nexport class PlansResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** List all plans with their prices and features. Optionally include private plans. */\n async list(\n params?: ListPlansParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Array<Plan>>> {\n return this.httpClient.get(\"/plans\", params, options);\n }\n\n /** Get detailed plan information by code or ID. */\n async get(\n params: GetPlanParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Plan>> {\n const { id } = params;\n return this.httpClient.get(`/plans/${id}`, undefined, options);\n }\n\n /** Create a new plan with optional consumption model, visibility, and plan group assignment. */\n async create(\n params: CreatePlanParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Plan>> {\n return this.httpClient.post(\"/plans/manage\", params, options);\n }\n\n /** Update a plan's name, description, visibility, or metadata. */\n async update(\n params: UpdatePlanParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Plan>> {\n const { id, ...rest } = params;\n return this.httpClient.put(`/plans/${id}/manage`, rest, options);\n }\n\n /** Soft-delete a plan. */\n async delete(\n params: DeletePlanParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<DeletedObject>> {\n const { id } = params;\n return this.httpClient.delete(`/plans/${id}/manage`, undefined, options);\n }\n\n /** Toggle a plan between public and private. */\n async setVisibility(\n params: SetPlanVisibilityParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanVisibility>> {\n const { id, ...rest } = params;\n return this.httpClient.put(`/plans/${id}/visibility`, rest, options);\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<ApiResponse<PlanFeature>> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/plans/${id}/features`, 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<ApiResponse<PlanFeature>> {\n const { id, featureId, ...rest } = params;\n return this.httpClient.put(\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<ApiResponse<RemovedPlanFeature>> {\n const { id, featureId } = params;\n return this.httpClient.delete(\n `/plans/${id}/features/${featureId}`,\n undefined,\n options,\n );\n }\n\n /** Add a billing interval price to a plan with optional trial days and included balance/credits. */\n async addPrice(\n params: AddPlanPriceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanPrice>> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/plans/${id}/prices`, rest, options);\n }\n\n /** Update an existing price on a plan. */\n async updatePrice(\n params: UpdatePlanPriceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanPrice>> {\n const { id, priceId, ...rest } = params;\n return this.httpClient.put(`/plans/${id}/prices/${priceId}`, rest, options);\n }\n\n /** Remove a price from a plan. */\n async deletePrice(\n params: DeletePlanPriceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<DeletedObject>> {\n const { id, priceId } = params;\n return this.httpClient.delete(\n `/plans/${id}/prices/${priceId}`,\n undefined,\n options,\n );\n }\n\n /** Set a specific price as the default for its plan. Unsets previous default. */\n async setDefaultPrice(\n params: SetDefaultPlanPriceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<DefaultPlanPrice>> {\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<ApiResponse<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 /** Configure a plan's regional pricing for one currency. USD configures the United States variant; exchangeRate acts as its price multiplier. Sending only currency and exchangeRate derives every regional value (base price, included balance, feature overage, intro offer) from the default USD value. Optional per-price and per-feature overrides are stored as manual values. */\n async setRegionalPricing(\n params: SetPlanRegionalPricingParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanRegionalPricingResult>> {\n const { id, ...rest } = params;\n return this.httpClient.put(`/plans/${id}/regional`, rest, options);\n }\n\n /** Remove all regional currency overrides for a plan price. */\n async deleteRegionalPrices(\n params: DeleteRegionalPricesParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<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","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { PortalAccess } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface RequestPortalAccessParams {\n email?: string;\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<ApiResponse<PortalAccess>> {\n return this.httpClient.post(\"/portal/request-access\", params, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { BillingInterval, DiscountType } from \"../types/enums\";\nimport type { PromoCode } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface ListPromoCodesParams {\n limit?: number;\n cursor?: string;\n}\n\nexport interface GetPromoCodeParams {\n id: string;\n}\n\nexport interface CreatePromoCodeParams {\n code: string;\n discountType: DiscountType;\n discountValue: number;\n durationCycles?: number;\n billingInterval?: BillingInterval | null;\n maxRedemptions?: number;\n /** @format date-time */\n expiresAt?: string;\n planIds?: Array<string>;\n}\n\nexport interface UpdatePromoCodeParams {\n id: string;\n billingInterval?: BillingInterval | null;\n maxRedemptions?: number | null;\n expiresAt?: string | null;\n active?: boolean;\n planIds?: Array<string>;\n}\n\nexport class PromoCodesResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** List promo codes with cursor-based pagination. */\n async list(\n params?: ListPromoCodesParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Array<PromoCode>>> {\n return this.httpClient.get(\"/promo-codes\", params, options);\n }\n\n /** Retrieve a promo code by its public ID. */\n async get(\n params: GetPromoCodeParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PromoCode>> {\n const { id } = params;\n return this.httpClient.get(`/promo-codes/${id}`, undefined, options);\n }\n\n /**\n * Create a new promo code. Optionally restrict it to specific plans and a billing interval.\n *\n * **100% discounts are not supported.** Percentage codes must be strictly less than 100% (`discountValue` < 10000 basis points). For full waivers, use an introductory offer on the plan instead. At checkout, any code — percentage or fixed amount — that would reduce the total below the currency's minimum charge ($0.50 USD equivalent) is silently dropped.\n */\n async create(\n params: CreatePromoCodeParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PromoCode>> {\n return this.httpClient.post(\"/promo-codes\", params, 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<ApiResponse<PromoCode>> {\n const { id, ...rest } = params;\n return this.httpClient.put(`/promo-codes/${id}`, rest, options);\n }\n}\n","import type { ApiResponse, 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(\n options?: RequestOptions,\n ): Promise<ApiResponse<ClaimLink>> {\n return this.httpClient.post(\"/claim-link\", {}, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { UsageQuota, UsageQuotaEvent } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface AddQuotaParams {\n customerId?: string;\n externalId?: string;\n featureCode: string;\n count?: number;\n idempotencyKey?: string;\n}\n\nexport interface SetQuotaParams {\n customerId?: string;\n externalId?: string;\n featureCode: string;\n count: number;\n idempotencyKey?: string;\n}\n\nexport interface RemoveQuotaParams {\n customerId?: string;\n externalId?: string;\n featureCode: string;\n count?: number;\n idempotencyKey?: string;\n}\n\nexport interface GetQuotaAllowanceParams {\n customerId: string;\n featureCode: string;\n}\n\nexport interface GetAllQuotaAllowancesParams {\n customerId: string;\n}\n\nexport class QuotaResource {\n constructor(private httpClient: CommetHTTPClient) {}\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<ApiResponse<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<ApiResponse<UsageQuotaEvent>> {\n return this.httpClient.put(\"/usage/quota\", 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<ApiResponse<UsageQuotaEvent>> {\n return this.httpClient.delete(\"/usage/quota\", 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<ApiResponse<UsageQuota>> {\n return this.httpClient.get(\"/usage/quota\", params, options);\n }\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<ApiResponse<Array<UsageQuota>>> {\n return this.httpClient.get(\"/usage/quota/all\", params, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type {\n BulkSeatUpdate,\n SeatBalance,\n SeatBalanceListItem,\n SeatEvent,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\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 interface RemoveSeatsParams {\n customerId: string;\n featureCode: string;\n count: number;\n}\n\nexport interface BulkSetSeatsParams {\n customerId: string;\n seats: Record<string, number>;\n}\n\nexport interface GetSeatBalanceParams {\n customerId: string;\n featureCode: string;\n}\n\nexport interface GetAllSeatBalancesParams {\n customerId: string;\n}\n\nexport class SeatsResource {\n constructor(private httpClient: CommetHTTPClient) {}\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<ApiResponse<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<ApiResponse<SeatEvent>> {\n return this.httpClient.put(\"/seats\", 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<ApiResponse<SeatEvent>> {\n return this.httpClient.delete(\"/seats\", params, options);\n }\n\n /** Set all seat types at once. */\n async setAll(\n params: BulkSetSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Array<BulkSeatUpdate>>> {\n return this.httpClient.put(\"/seats/bulk\", params, options);\n }\n\n /** Get current balance for a specific seat type. */\n async getBalance(\n params: GetSeatBalanceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<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<ApiResponse<SeatBalanceListItem>> {\n return this.httpClient.get(\"/seats/balances\", params, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type {\n BillingInterval,\n DiscountType,\n PaymentProvider,\n SubscriptionStatus,\n} from \"../types/enums\";\nimport type {\n BalanceAdjustment,\n BalanceTopup,\n CanceledSubscription,\n CreditGrant,\n DeletedSubscriptionAddon,\n PaymentMethodUpdateCheckout,\n PlanChange,\n PreviewChange,\n ReactivatedSubscription,\n RecoveryLink,\n Subscription,\n SubscriptionAddon,\n UncanceledSubscription,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface ListSubscriptionsParams {\n customerId?: string;\n status?: SubscriptionStatus;\n}\n\nexport interface CreateSubscriptionParams {\n planId?: string;\n planCode?: string;\n customerId: string;\n billingInterval?: BillingInterval | null;\n initialSeats?: Record<string, number>;\n skipTrial?: boolean;\n customTrialDays?: number;\n introOffer?: {\n discountType: DiscountType;\n discountValue: number;\n durationCycles: number;\n };\n promoCode?: string;\n /** Payment provider for the initial checkout. Overrides country routing when present. */\n provider?: PaymentProvider;\n name?: string;\n /** @format date-time */\n startDate?: string;\n successUrl?: string;\n}\n\nexport interface GetSubscriptionParams {\n id: string;\n}\n\nexport interface GetActiveSubscriptionParams {\n customerId: string;\n}\n\nexport interface CancelSubscriptionParams {\n id: string;\n reason?: string;\n immediate?: boolean;\n}\n\nexport interface UncancelSubscriptionParams {\n id: string;\n}\n\nexport interface ReactivateSubscriptionParams {\n id: string;\n}\n\nexport interface CreateSubscriptionRecoveryLinkParams {\n id: string;\n}\n\nexport interface UpdatePaymentMethodParams {\n id: string;\n successUrl?: string;\n}\n\nexport interface ChangePlanParams {\n id: string;\n newPlanId?: string;\n newBillingInterval?: \"weekly\" | \"monthly\" | \"quarterly\" | \"yearly\";\n successUrl?: string;\n}\n\nexport interface PreviewChangePlanParams {\n id: string;\n planId: string;\n billingInterval?: BillingInterval;\n}\n\nexport interface ActivateAddonParams {\n id: string;\n addonId: string;\n}\n\nexport interface DeactivateAddonParams {\n id: string;\n addonId: string;\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 amount: number;\n}\n\nexport interface PurchaseCreditsParams {\n id: string;\n creditPackId: string;\n}\n\nexport class SubscriptionsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** List all subscriptions. Filter by customer ID or status. */\n async list(\n params?: ListSubscriptionsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Array<Subscription>>> {\n return this.httpClient.get(\"/subscriptions\", params, options);\n }\n\n /** Create a subscription for a customer. Requires planId or planCode plus customerId. */\n async create(\n params: CreateSubscriptionParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Subscription>> {\n return this.httpClient.post(\"/subscriptions\", params, 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<ApiResponse<Subscription>> {\n const { id } = params;\n return this.httpClient.get(`/subscriptions/${id}`, undefined, 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<ApiResponse<Subscription | null>> {\n return this.httpClient.get(\"/subscriptions/active\", params, options);\n }\n\n /** Cancel immediately or at period end. */\n async cancel(\n params: CancelSubscriptionParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CanceledSubscription>> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/subscriptions/${id}/cancel`, rest, options);\n }\n\n /** Revert a scheduled cancellation. Only works when canceledAt is set but status is not yet 'canceled'. */\n async uncancel(\n params: UncancelSubscriptionParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<UncanceledSubscription>> {\n const { id } = params;\n return this.httpClient.post(`/subscriptions/${id}/uncancel`, {}, options);\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. */\n async reactivate(\n params: ReactivateSubscriptionParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<ReactivatedSubscription>> {\n const { id } = params;\n return this.httpClient.post(`/subscriptions/${id}/reactivate`, {}, options);\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<ApiResponse<RecoveryLink>> {\n const { id } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/recovery-link`,\n {},\n options,\n );\n }\n\n /** Creates a hosted checkout session for the customer to update the subscription's default payment method. */\n async updatePaymentMethod(\n params: UpdatePaymentMethodParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<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 /** Upgrade, downgrade, or change billing interval. */\n async changePlan(\n params: ChangePlanParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanChange>> {\n const { id, ...rest } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/change-plan`,\n rest,\n options,\n );\n }\n\n /** Preview proration details for an immediate plan change (an upgrade or a longer interval) without applying it. 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. Downgrades — a cheaper plan in the same group, or a shorter interval — are scheduled for the end of the current period instead of being prorated, so they return a 400 with code `plan_change_scheduled`; apply those via the change-plan endpoint. */\n async previewChange(\n params: PreviewChangePlanParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PreviewChange>> {\n const { id, ...rest } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/preview-change`,\n rest,\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<ApiResponse<SubscriptionAddon>> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/subscriptions/${id}/addons`, rest, options);\n }\n\n /** Deactivate an add-on from a subscription. */\n async deactivateAddon(\n params: DeactivateAddonParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<DeletedSubscriptionAddon>> {\n const { id, addonId } = params;\n return this.httpClient.delete(\n `/subscriptions/${id}/addons/${addonId}`,\n undefined,\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<ApiResponse<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 subscription's balance. Charges the customer's payment method for the specified amount. */\n async topupBalance(\n params: TopupBalanceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<BalanceTopup>> {\n const { id, ...rest } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/balance/topup`,\n rest,\n options,\n );\n }\n\n /** Purchase a credit pack for a subscription. Charges the customer and adds credits to their balance. */\n async purchaseCredits(\n params: PurchaseCreditsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CreditGrant>> {\n const { id, ...rest } = params;\n return this.httpClient.post(`/subscriptions/${id}/credits`, rest, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { TestClock, TestClockBilling } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface AdvanceTestClockParams {\n advanceDays?: number;\n /** @format date-time */\n frozenTime?: string;\n}\n\nexport class TestClockResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Returns the organization's current test clock state. Sandbox only. */\n async get(): Promise<ApiResponse<TestClock>> {\n return this.httpClient.get(\"/test-clock\");\n }\n\n /** Moves the test clock forward, by a number of days (advanceDays) or to an absolute instant (frozenTime). The clock can only move forward. Sandbox only. */\n async advance(\n params?: AdvanceTestClockParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<TestClock>> {\n return this.httpClient.post(\"/test-clock\", params, options);\n }\n\n /** Discovers customers due for billing at the org's current (simulated) time and enqueues a billing cycle for each — renewals, expired trials, pending cancellations. Also fires any dunning retry whose scheduled time has passed. Enqueueing is asynchronous. Sandbox only. */\n async processBilling(\n options?: RequestOptions,\n ): Promise<ApiResponse<TestClockBilling>> {\n return this.httpClient.post(\"/test-clock/process-billing\", {}, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { TransactionStatus } from \"../types/enums\";\nimport type {\n Transaction,\n TransactionRefund,\n TransactionRetry,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface ListTransactionsParams {\n status?: TransactionStatus;\n customerEmail?: string;\n limit?: number;\n cursor?: string;\n}\n\nexport interface GetTransactionParams {\n id: string;\n}\n\nexport interface RefundTransactionParams {\n id: string;\n}\n\nexport interface RetryTransactionParams {\n id: string;\n}\n\nexport class TransactionsResource {\n constructor(private httpClient: CommetHTTPClient) {}\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<ApiResponse<Array<Transaction>>> {\n return this.httpClient.get(\"/transactions\", params, 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<ApiResponse<Transaction>> {\n const { id } = params;\n return this.httpClient.get(`/transactions/${id}`, undefined, options);\n }\n\n /** Issue a full refund for a payment transaction. */\n async refund(\n params: RefundTransactionParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<TransactionRefund>> {\n const { id } = params;\n return this.httpClient.post(`/transactions/${id}/refund`, {}, options);\n }\n\n /** Retry a failed subscription renewal. Re-charges the outstanding renewal invoice through the recovery engine. */\n async retry(\n params: RetryTransactionParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<TransactionRetry>> {\n const { id } = params;\n return this.httpClient.post(`/transactions/${id}/retry`, {}, 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 { 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 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 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\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.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 }\n}\n","import type {\n ApiResponse,\n CustomerID,\n EventID,\n RequestOptions,\n} from \"../types/common\";\nimport type { ConsumptionModel } from \"../types/enums\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport type UsageCheckDenialReason =\n | \"included_limit_reached\"\n | \"insufficient_credits\"\n | \"insufficient_balance\";\n\nexport interface UsageEvent {\n id: EventID;\n object: \"usage_event\";\n livemode: boolean;\n organizationId: string;\n customerId: CustomerID;\n feature: string;\n idempotencyKey?: string;\n ts: string;\n properties?: UsageEventProperty[];\n createdAt: string;\n}\n\nexport interface UsageEventProperty {\n id: string;\n usageEventId: EventID;\n property: string;\n value: string;\n createdAt: string;\n}\n\ninterface TrackBaseParams {\n feature: string;\n customerId: CustomerID;\n idempotencyKey?: string;\n timestamp?: string;\n properties?: Record<string, string>;\n}\n\nexport interface TrackUsageParams extends TrackBaseParams {\n value?: number;\n model?: never;\n}\n\nexport interface TrackModelTokensParams extends TrackBaseParams {\n model: string;\n inputTokens: number;\n outputTokens: number;\n cacheReadTokens?: number;\n cacheWriteTokens?: number;\n value?: never;\n}\n\nexport type TrackParams = TrackUsageParams | TrackModelTokensParams;\n\nexport interface CheckUsageParams {\n customerId: CustomerID;\n featureCode: string;\n quantity: number;\n}\n\nexport interface SetUsageParams {\n customerId: CustomerID;\n feature: string;\n value: number;\n idempotencyKey?: string;\n reason?: string;\n}\n\nexport interface UsageAdjustment {\n id: EventID;\n feature: string;\n value: number;\n previousValue: number;\n adjustment: number;\n customerId: CustomerID;\n idempotencyKey: string | null;\n reason: string | null;\n ts: string;\n createdAt: string;\n object: \"usage_event\";\n livemode: boolean;\n}\n\nexport interface UsageCheckResult {\n allowed: boolean;\n consumptionModel: ConsumptionModel;\n feature: string;\n quantity: number;\n current?: number;\n remaining?: number;\n unlimited?: boolean;\n included?: number;\n overageEnabled?: boolean;\n overageUnitPrice?: number | null;\n creditsPerUnit?: number;\n estimatedCredits?: number;\n planCredits?: number;\n purchasedCredits?: number;\n totalCredits?: number;\n unitPrice?: number;\n estimatedAmount?: number;\n currentBalance?: number;\n blockOnExhaustion?: boolean;\n currency?: string;\n reason?: UsageCheckDenialReason;\n message?: string;\n}\n\nexport class UsageResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Deducts from balance/credits if the plan uses consumption. Duplicate `idempotencyKey` is rejected. */\n async track(\n params: TrackParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<UsageEvent>> {\n const eventData: Record<string, unknown> = {\n feature: params.feature,\n customerId: params.customerId,\n idempotencyKey: params.idempotencyKey,\n timestamp: params.timestamp || new Date().toISOString(),\n properties: params.properties\n ? Object.entries(params.properties).map(([property, value]) => ({\n property,\n value,\n }))\n : undefined,\n };\n\n if (\"model\" in params && params.model) {\n eventData.model = params.model;\n eventData.inputTokens = params.inputTokens;\n eventData.outputTokens = params.outputTokens;\n if (params.cacheReadTokens) {\n eventData.cacheReadTokens = params.cacheReadTokens;\n }\n if (params.cacheWriteTokens) {\n eventData.cacheWriteTokens = params.cacheWriteTokens;\n }\n } else {\n eventData.value = (params as TrackUsageParams).value;\n }\n\n return this.httpClient.post(\"/usage/events\", eventData, options);\n }\n\n /** Dry-run: checks if a usage event would be allowed without actually tracking it. */\n async check(\n params: CheckUsageParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<UsageCheckResult>> {\n return this.httpClient.post(\"/usage/check\", params, options);\n }\n\n /** Set a metered feature's usage to an exact value for the current period. */\n async set(\n params: SetUsageParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<UsageAdjustment>> {\n return this.httpClient.put(\"/usage\", params, options);\n }\n}\n","import crypto from \"node:crypto\";\nimport type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { SubscriptionStatus } from \"../types/enums\";\nimport type {\n WebhookEvent,\n WebhookEventDataMap,\n WebhookEventPayload,\n} from \"../types/webhook-events\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\n/**\n * Webhook payload structure from Commet\n */\nexport interface WebhookPayload {\n event: WebhookEvent;\n timestamp: string;\n organizationId: string;\n mode: \"live\" | \"sandbox\";\n apiVersion: string;\n data: WebhookData;\n}\n\n/**\n * Webhook data structure (subscription-related fields).\n *\n * The `status` field is present on `subscription.*` events. Grant access only\n * when it is `\"active\"` or `\"trialing\"`. `\"pending_payment\"` means the first\n * charge has not been confirmed yet — wait for `subscription.activated` before\n * granting access.\n */\nexport interface WebhookData {\n publicId?: string;\n subscriptionId?: string;\n customerId?: string;\n /**\n * Subscription status. Present on `subscription.*` events.\n * Grant access when this is `\"active\"` or `\"trialing\"`.\n */\n status?: SubscriptionStatus;\n name?: string;\n canceledAt?: string;\n [key: string]: unknown;\n}\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 interface WebhookEndpoint {\n id: string;\n object: \"webhook\";\n livemode: boolean;\n url: string;\n events: string[];\n description: string | null;\n isActive: boolean;\n apiVersion: string | null;\n createdAt: string;\n}\n\nexport interface WebhookEndpointCreated extends WebhookEndpoint {\n secretKey: string;\n}\n\nexport interface WebhookTestResult {\n success: boolean;\n deliveryId: string;\n deliveredAt: string;\n}\n\nexport interface ListWebhooksParams {\n limit?: number;\n cursor?: string;\n}\n\nexport interface CreateWebhookParams {\n url: string;\n events: string[];\n description?: string;\n apiVersion?: string;\n}\n\nexport interface GetWebhookParams {\n id: string;\n}\n\nexport interface UpdateWebhookParams {\n id: string;\n url?: string;\n events?: string[];\n description?: string | null;\n isActive?: boolean;\n apiVersion?: string;\n}\n\nexport interface DeleteWebhookParams {\n id: string;\n}\n\nexport interface TestWebhookParams {\n id: string;\n}\n\nexport class Webhooks {\n private readonly eventHandlers = new Map<\n WebhookEvent,\n WebhookEventHandler<WebhookEvent>\n >();\n\n constructor(private httpClient?: CommetHTTPClient) {}\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 async list(\n params?: ListWebhooksParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<WebhookEndpoint[]>> {\n return this.httpClient!.get(\"/webhooks\", params, options);\n }\n\n async create(\n params: CreateWebhookParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<WebhookEndpointCreated>> {\n return this.httpClient!.post(\"/webhooks\", params, options);\n }\n\n async get(\n params: GetWebhookParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<WebhookEndpoint>> {\n const { id } = params;\n return this.httpClient!.get(`/webhooks/${id}`, undefined, options);\n }\n\n async update(\n params: UpdateWebhookParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<WebhookEndpoint>> {\n const { id, ...body } = params;\n return this.httpClient!.put(`/webhooks/${id}`, body, options);\n }\n\n async delete(\n params: DeleteWebhookParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<{ id: string; deleted: true }>> {\n const { id } = params;\n return this.httpClient!.delete(`/webhooks/${id}`, undefined, options);\n }\n\n async test(\n params: TestWebhookParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<WebhookTestResult>> {\n const { id } = params;\n return this.httpClient!.post(`/webhooks/${id}/test`, undefined, 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 ApiResponse<T = unknown> {\n success: boolean;\n data?: T;\n error?: ApiErrorDetail;\n hasMore?: boolean;\n nextCursor?: string;\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 PaginatedResponse<T> {\n data: T[];\n hasMore: boolean;\n nextCursor?: string;\n totalCount?: number;\n}\n\nexport interface PaginatedList<T> extends PaginatedResponse<T> {\n next(): Promise<PaginatedList<T>>;\n all(): Promise<T[]>;\n}\n\n// Error types\nexport class CommetError extends Error {\n constructor(\n message: string,\n public code?: string,\n public statusCode?: number,\n public details?: unknown,\n ) {\n super(message);\n this.name = \"CommetError\";\n }\n}\n\nexport class CommetAPIError extends CommetError {\n public type?: string;\n public param?: string;\n public docUrl?: string;\n\n constructor(\n message: string,\n public statusCode: number,\n public code?: string,\n public details?: unknown,\n errorDetail?: ApiErrorDetail,\n ) {\n super(message, code, statusCode, details);\n this.name = \"CommetAPIError\";\n this.type = errorDetail?.type;\n this.param = errorDetail?.param;\n this.docUrl = errorDetail?.doc_url;\n }\n}\n\nexport class CommetValidationError extends CommetError {\n constructor(\n message: string,\n public validationErrors: Record<string, string[]>,\n ) {\n super(message);\n this.name = \"CommetValidationError\";\n }\n}\n\nexport type CustomerID = string;\nexport type AgreementID = `agr_${string}`;\nexport type InvoiceID = `inv_${string}`;\nexport type PhaseID = `phs_${string}`;\nexport type ItemID = `itm_${string}`;\nexport type ProductID = `prd_${string}`;\nexport type EventID = `evt_${string}`;\nexport type WebhookID = `wh_${string}`;\n\n// Currency enum\nexport type Currency =\n | \"USD\"\n | \"EUR\"\n | \"GBP\"\n | \"CAD\"\n | \"AUD\"\n | \"JPY\"\n | \"ARS\"\n | \"BRL\"\n | \"MXN\"\n | \"CLP\";\n\n// Common parameters\nexport interface ListParams extends Record<string, unknown> {\n limit?: number;\n cursor?: string;\n startDate?: string;\n endDate?: string;\n}\n\nexport interface RetrieveOptions {\n expand?: string[];\n}\n\n// Request options\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-07-11\";\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 ApiResponse,\n CommetClientOptions,\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<ApiResponse<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<ApiResponse<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<ApiResponse<T>> {\n return this.request(\"PUT\", endpoint, data, options);\n }\n\n async delete<T = unknown>(\n endpoint: string,\n data?: unknown,\n options?: RequestOptions,\n ): Promise<ApiResponse<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<ApiResponse<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<ApiResponse<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\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 );\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 parsed =\n typeof responseData === \"object\" && responseData !== null\n ? (responseData as Record<string, unknown>)\n : {};\n const errorObj =\n typeof parsed.error === \"object\" && parsed.error !== null\n ? (parsed.error as Record<string, unknown>)\n : {};\n\n const errorDetail: ApiErrorDetail = {\n type: (errorObj.type as string) ?? \"api_error\",\n code: (errorObj.code as string) ?? \"unknown\",\n message:\n (errorObj.message as string) ??\n `Request failed with status ${response.status}`,\n param: errorObj.param as string | undefined,\n details: errorObj.details,\n doc_url: errorObj.doc_url as string | undefined,\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 as Array<{\n field: string;\n message: string;\n }>) {\n if (!errors[detail.field]) errors[detail.field] = [];\n errors[detail.field].push(detail.message);\n }\n throw new CommetValidationError(errorDetail.message, errors);\n }\n\n throw new CommetAPIError(\n errorDetail.message,\n response.status,\n errorDetail.code,\n errorDetail.details,\n errorDetail,\n );\n }\n\n if (this.config.debug) {\n console.log(\"[Commet SDK] Response:\", responseData);\n }\n\n if (this.telemetryEnabled) {\n this.lastRequestMetrics = {\n requestId:\n response.headers.get(\"x-request-id\") ?? `req_${Date.now()}`,\n durationMs: Date.now() - requestStart,\n };\n }\n\n return responseData as ApiResponse<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","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(): boolean {\n if (process.env.NODE_ENV !== \"development\") return false;\n if (process.env.CI) return false;\n return process.env.COMMET_NO_UPDATE_CHECK !== \"1\";\n}\n\nexport async function checkForSdkUpdate(\n installedVersion: string,\n): 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 { UsageResource } from \"./resources/usage\";\nimport { Webhooks } from \"./resources/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 usage: UsageResource;\n public readonly webhooks: Webhooks;\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_\")) {\n throw new Error(\n \"Commet SDK: Invalid API key format. Expected format: ck_xxx...\",\n );\n }\n\n this.httpClient = new CommetHTTPClient(config);\n this.initResources(this.httpClient);\n this.usage = new UsageResource(this.httpClient);\n this.webhooks = new Webhooks(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: \"weekly\" | \"monthly\" | \"quarterly\" | \"yearly\" | \"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;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AAe,SAAS,QAAQ,gBAAgB,GACjD;AACA;AAAA,IACF;AAEA,YAAQ;AAAA,MACN,yBAAyB,gBAAgB,0CAA0C,SAAS,MAAM;AAAA;AAAA,IACpG;AAAA,EACF,QAAQ;AAAA,EAAC;AACX;AAEO,SAAS,yBAA+B;AAC7C,MAAI,CAAC,yBAAyB,KAAK,CAAC,oBAAoB,EAAG;AAE3D,QAAM,iBAAiB,aAAa,MAAM;AACxC,SAAK,kBAAkB,WAAW;AAAA,EACpC,CAAC;AACD,iBAAe,MAAM;AACvB;;;AChJO,IAAM,SAAN,cAAyC,mBAAmB;AAAA,EAMjE,YAAY,QAA6B;AACvC,UAAM;AAEN,QAAI,CAAC,OAAO,QAAQ;AAClB,YAAM,IAAI,MAAM,iCAAiC;AAAA,IACnD;AAEA,QAAI,CAAC,OAAO,OAAO,WAAW,KAAK,GAAG;AACpC,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,SAAK,aAAa,IAAI,iBAAiB,MAAM;AAC7C,SAAK,cAAc,KAAK,UAAU;AAClC,SAAK,QAAQ,IAAI,cAAc,KAAK,UAAU;AAC9C,SAAK,WAAW,IAAI,SAAS,KAAK,UAAU;AAC5C,2BAAuB;AAAA,EACzB;AACF;AAEO,SAAS,aACd,gBACA,SACiB;AACjB,SAAO,IAAI,OAAgB,OAAO;AACpC;;;ACOO,SAAS,aAA4C,QAAc;AACxE,SAAO;AACT;;;A7BsOA,IAAO,gBAAQ;","names":["crypto"]}
|
|
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/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/pricing.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 CreateCustomerParams,\n GetCustomerParams,\n ListCustomersParams,\n UpdateCustomerParams,\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 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 CompletePayoutVerificationParams,\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 CreateMarketGroupParams,\n DeleteMarketGroupParams,\n GetMarketGroupParams,\n UpdateMarketGroupParams,\n} from \"./resources/pricing\";\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 CancelSubscriptionParams,\n ChangePlanParams,\n CreateSubscriptionParams,\n CreateSubscriptionRecoveryLinkParams,\n DeactivateAddonParams,\n GetActiveSubscriptionParams,\n GetSubscriptionParams,\n ListSubscriptionsParams,\n PreviewChangePlanParams,\n PurchaseCreditsParams,\n ReactivateSubscriptionParams,\n TopupBalanceParams,\n UncancelSubscriptionParams,\n UpdatePaymentMethodParams,\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 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 PaymentProvider,\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 ClaimLink,\n CreatedApiKey,\n CreatedSubscription,\n CreatedWebhook,\n CreditGrant,\n CreditPack,\n CreditPackListItem,\n Customer,\n CustomerBatch,\n DeletedObject,\n DeletedOffer,\n DeletedPlanRegionalPricing,\n DeletedSubscriptionAddon,\n Feature,\n FeatureAccess,\n Invoice,\n InvoiceDownload,\n InvoiceListItem,\n MarketGroup,\n Offer,\n Payment,\n PaymentMethodUpdateCheckout,\n Payout,\n PayoutBankAccount,\n PayoutVerification,\n Plan,\n PlanChange,\n PlanFeature,\n PlanGroup,\n PlanGroupDetail,\n PlanPrice,\n PlanRegionalPricing,\n PlanRegionalPricingResult,\n PortalAccess,\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 SubscriptionSummary,\n TestClock,\n TestClockBilling,\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 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}\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 new API key. The full key is only returned once in the response. */\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 { Customer, CustomerBatch } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\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 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}\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 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}\n\nexport class CustomersResource {\n constructor(private httpClient: CommetHTTPClient) {}\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. */\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. */\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 { 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 purpose: \"introductory\" | \"promotional\";\n planPriceIds: Array<string>;\n phases: Array<\n | {\n type: \"free_trial\";\n durationDays: number;\n }\n | {\n type: \"percentage\";\n durationCycles: number;\n /** Discount in basis points. 5000 means 50%. */\n percentage: number;\n }\n | {\n type: \"amount_off\";\n durationCycles: number;\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;\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 planPriceId?: string;\n purpose?: \"introductory\" | \"promotional\";\n active?: boolean;\n}\n\nexport interface CreateOfferParams {\n name: string;\n purpose: \"introductory\" | \"promotional\";\n planPriceIds: Array<string>;\n phases: Array<\n | {\n type: \"free_trial\";\n durationDays: number;\n }\n | {\n type: \"percentage\";\n durationCycles: number;\n /** Discount in basis points. 5000 means 50%. */\n percentage: number;\n }\n | {\n type: \"amount_off\";\n durationCycles: number;\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;\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 a canonical offer by its 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 an offer's catalog definition. Existing offer 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 the organization's canonical introductory and promotional offers. */\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 a canonical offer scoped to one or more plan prices. Currency-specific phases require an explicit USD value and never fall back across currencies. */\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 {\n Payout,\n PayoutBankAccount,\n PayoutVerification,\n} 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 type CompletePayoutVerificationParams =\n | {\n email: string;\n businessUrl: string;\n documentUrl: string;\n bank: {\n accountNumber: string;\n accountHolderName: string;\n routingNumber?: string;\n accountType?: \"checking\" | \"savings\";\n };\n businessType: \"individual\";\n individual: {\n firstName: string;\n lastName: string;\n phone: string;\n dateOfBirth: string;\n ssnLast4?: string;\n idNumber?: string;\n address: {\n line1: string;\n line2?: string;\n city: string;\n state?: string;\n postalCode: string;\n country: string;\n };\n };\n }\n | {\n email: string;\n businessUrl: string;\n documentUrl: string;\n bank: {\n accountNumber: string;\n accountHolderName: string;\n routingNumber?: string;\n accountType?: \"checking\" | \"savings\";\n };\n businessType: \"company\";\n company: {\n name: string;\n taxId: string;\n address: {\n line1: string;\n line2?: string;\n city: string;\n state?: string;\n postalCode: string;\n country: string;\n };\n representative: {\n firstName: string;\n lastName: string;\n phone?: string;\n email?: string;\n };\n };\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 /** Provision the organization's payout account in a single call with the full KYC + bank payload. Uploads the identity document, persists the destination bank, and creates the connected account through the org's payout provider. The account starts `pending_verification` and flips to `verified` via the provider's webhook. Idempotent: returns the existing account if the org already has one. */\n async completeVerification(\n params: CompletePayoutVerificationParams,\n options?: RequestOptions,\n ): Promise<PayoutVerification> {\n return this.httpClient.post(\"/payouts/verification\", params, 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 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 | \"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 | \"yearly\"\n | \"one_time\";\n metadata?: Record<string, unknown>;\n price: number;\n trialDays?: number;\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 | \"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 | \"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 | \"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 | \"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}\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 blockOnExhaustion?: boolean;\n planGroupId?: string;\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, or metadata. */\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, and plan group assignment. */\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 { DeletedObject, MarketGroup } from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface GetMarketGroupParams {\n id: string;\n}\n\nexport interface UpdateMarketGroupParams {\n id: string;\n name: string;\n countryCodes: Array<string>;\n metadata?: Record<string, unknown>;\n}\n\nexport interface DeleteMarketGroupParams {\n id: string;\n}\n\nexport interface CreateMarketGroupParams {\n name: string;\n countryCodes: Array<string>;\n metadata?: Record<string, unknown>;\n}\n\nexport class PricingResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Get one reusable pricing market group. */\n async getMarketGroup(\n params: GetMarketGroupParams,\n options?: RequestOptions,\n ): Promise<MarketGroup> {\n const { id } = params;\n return this.httpClient.get(\n `/pricing/market-groups/${id}`,\n undefined,\n options,\n );\n }\n\n /** Replace the name, countries, and metadata of a pricing market group. */\n async updateMarketGroup(\n params: UpdateMarketGroupParams,\n options?: RequestOptions,\n ): Promise<MarketGroup> {\n const { id, ...rest } = params;\n return this.httpClient.patch(`/pricing/market-groups/${id}`, rest, options);\n }\n\n /** Delete an unused pricing market group. Groups referenced by prices or subscriptions cannot be deleted. */\n async deleteMarketGroup(\n params: DeleteMarketGroupParams,\n options?: RequestOptions,\n ): Promise<DeletedObject> {\n const { id } = params;\n return this.httpClient.delete(\n `/pricing/market-groups/${id}`,\n undefined,\n options,\n );\n }\n\n /** List reusable country groups used to resolve market-specific prices independently from currency. */\n async listMarketGroups(): Promise<{\n object: \"list\";\n data: Array<MarketGroup>;\n hasMore: boolean;\n nextCursor?: string;\n }> {\n return this.httpClient.get(\"/pricing/market-groups\");\n }\n\n /** Create a reusable country group. Countries can belong to only one active group; each price chooses its currency independently. */\n async createMarketGroup(\n params: CreateMarketGroupParams,\n options?: RequestOptions,\n ): Promise<MarketGroup> {\n return this.httpClient.post(\"/pricing/market-groups\", 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 | \"yearly\"\n | \"one_time\"\n | null;\n maxRedemptions?: number | null;\n expiresAt?: string | null;\n active?: boolean;\n planIds?: Array<string>;\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 | \"yearly\"\n | \"one_time\"\n | null;\n maxRedemptions?: number;\n /** @format date-time */\n expiresAt?: string;\n planIds?: Array<string>;\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 promotional offer. Offer economics remain owned by the referenced Offer. */\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 PreviewChange,\n ReactivatedSubscription,\n RecoveryLink,\n Subscription,\n SubscriptionAddon,\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 AdjustBalanceParams {\n id: string;\n amount: number;\n reason?: string;\n type?: \"credits\" | \"balance\";\n}\n\nexport interface TopupBalanceParams {\n id: string;\n amount: number;\n}\n\nexport interface CancelSubscriptionParams {\n id: string;\n reason?: string;\n immediate?: boolean;\n}\n\nexport interface ChangePlanParams {\n id: string;\n newPlanId?: string;\n newBillingInterval?: \"weekly\" | \"monthly\" | \"quarterly\" | \"yearly\";\n successUrl?: string;\n offerId?: string;\n}\n\nexport interface PurchaseCreditsParams {\n id: string;\n creditPackId: string;\n}\n\nexport interface UpdatePaymentMethodParams {\n id: string;\n successUrl?: string;\n}\n\nexport interface PreviewChangePlanParams {\n id: string;\n planId: string;\n billingInterval?: \"weekly\" | \"monthly\" | \"quarterly\" | \"yearly\" | \"one_time\";\n offerId?: string;\n}\n\nexport interface ReactivateSubscriptionParams {\n id: string;\n offerId?: string;\n}\n\nexport interface CreateSubscriptionRecoveryLinkParams {\n id: string;\n}\n\nexport interface GetSubscriptionParams {\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 | \"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 for the initial checkout. Overrides country routing when present. */\n provider?: \"stripe\" | \"commet\" | \"dlocal\";\n name?: string;\n /** @format date-time */\n startDate?: string;\n successUrl?: string;\n offerId?: never;\n promoCode?: string;\n customTrialDays?: number;\n skipTrial?: boolean;\n planId: string;\n }\n | {\n customerId: string;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\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 for the initial checkout. Overrides country routing when present. */\n provider?: \"stripe\" | \"commet\" | \"dlocal\";\n name?: string;\n /** @format date-time */\n startDate?: string;\n successUrl?: string;\n offerId?: never;\n promoCode?: string;\n customTrialDays?: number;\n skipTrial?: boolean;\n planCode: string;\n }\n | {\n customerId: string;\n billingInterval?:\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\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 for the initial checkout. Overrides country routing when present. */\n provider?: \"stripe\" | \"commet\" | \"dlocal\";\n name?: string;\n /** @format date-time */\n startDate?: string;\n successUrl?: string;\n offerId: 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 | \"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 for the initial checkout. Overrides country routing when present. */\n provider?: \"stripe\" | \"commet\" | \"dlocal\";\n name?: string;\n /** @format date-time */\n startDate?: string;\n successUrl?: string;\n offerId: 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 /** 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 subscription's balance. Charges the customer's payment method for the specified amount. */\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 a quoted Promotional Offer. Scheduled changes do not accept offers. */\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 credit pack for a subscription. Charges the customer and adds credits to their balance. */\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 /** Creates a hosted checkout session for the customer to update the subscription's default payment method. */\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 /** Preview proration details for an immediate plan change (a higher-sort-order plan or a longer interval) without applying it. 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. Downgrades — a lower-sort-order plan in the same group, or a shorter interval — are scheduled for the end of the current period instead of being prorated, so they return a 400 with code `plan_change_scheduled`; apply those via the change-plan endpoint. Pass offerId to quote the destination plan with a Promotional Offer. */\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 a Promotional 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 /** 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 /** 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 and resolves its market from the customer's billing country. Without an offer override, Commet applies the price's automatic introductory offer. Pass one Promotional Offer through offerId to override it. Experiment assignment remains external. */\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, TestClockBilling } 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 /** Discovers customers due for billing at the org's current (simulated) time and enqueues a billing cycle for each — renewals, expired trials, pending cancellations. Also fires any dunning retry whose scheduled time has passed. Enqueueing is asynchronous. Sandbox only. */\n async processBilling(options?: RequestOptions): Promise<TestClockBilling> {\n return this.httpClient.post(\"/test-clock/process-billing\", {}, options);\n }\n\n /** Returns the organization's current test clock state. Sandbox only. */\n async get(): Promise<TestClock> {\n return this.httpClient.get(\"/test-clock\");\n }\n\n /** Moves the test clock forward, by a number of days (advanceDays) or to an absolute instant (frozenTime). The clock can only move forward. Sandbox only. */\n async advance(\n params?: AdvanceTestClockParams,\n options?: RequestOptions,\n ): Promise<TestClock> {\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 { 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 { PricingResource } from \"./resources/pricing\";\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 offers!: OffersResource;\n public payments!: PaymentsResource;\n public payouts!: PayoutsResource;\n public planGroups!: PlanGroupsResource;\n public plans!: PlansResource;\n public portal!: PortalResource;\n public pricing!: PricingResource;\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.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.pricing = new PricingResource(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.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 | \"customer.created\"\n | \"customer.updated\"\n | \"customer.state_changed\"\n | \"credits.granted\"\n | \"credits.purchased\"\n | \"credits.low\"\n | \"credits.depleted\"\n | \"credits.expired\"\n | \"balance.topped_up\"\n | \"balance.low\"\n | \"balance.depleted\"\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.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 | \"customer.created\"\n | \"customer.updated\"\n | \"customer.state_changed\"\n | \"credits.granted\"\n | \"credits.purchased\"\n | \"credits.low\"\n | \"credits.depleted\"\n | \"credits.expired\"\n | \"balance.topped_up\"\n | \"balance.low\"\n | \"balance.depleted\"\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\n// Error types\nexport class CommetError extends Error {\n constructor(\n message: string,\n public code?: string,\n public statusCode?: number,\n public details?: unknown,\n ) {\n super(message);\n this.name = \"CommetError\";\n }\n}\n\nexport class CommetAPIError extends CommetError {\n public type?: string;\n public param?: string;\n public docUrl?: string;\n\n constructor(\n message: string,\n public statusCode: number,\n public code?: string,\n public details?: unknown,\n errorDetail?: ApiErrorDetail,\n ) {\n super(message, code, statusCode, details);\n this.name = \"CommetAPIError\";\n this.type = errorDetail?.type;\n this.param = errorDetail?.param;\n this.docUrl = errorDetail?.doc_url;\n }\n}\n\nexport class CommetValidationError extends CommetError {\n constructor(\n message: string,\n public validationErrors: Record<string, string[]>,\n ) {\n super(message);\n this.name = \"CommetValidationError\";\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-07-24\";\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 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\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 );\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 parsed =\n typeof responseData === \"object\" && responseData !== null\n ? (responseData as Record<string, unknown>)\n : {};\n const errorObj =\n typeof parsed.error === \"object\" && parsed.error !== null\n ? (parsed.error as Record<string, unknown>)\n : {};\n\n const errorDetail: ApiErrorDetail = {\n type: (errorObj.type as string) ?? \"api_error\",\n code: (errorObj.code as string) ?? \"unknown\",\n message:\n (errorObj.message as string) ??\n `Request failed with status ${response.status}`,\n param: errorObj.param as string | undefined,\n details: errorObj.details,\n doc_url: errorObj.doc_url as string | undefined,\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 as Array<{\n field: string;\n message: string;\n }>) {\n if (!errors[detail.field]) errors[detail.field] = [];\n errors[detail.field].push(detail.message);\n }\n throw new CommetValidationError(errorDetail.message, errors);\n }\n\n throw new CommetAPIError(\n errorDetail.message,\n response.status,\n errorDetail.code,\n errorDetail.details,\n errorDetail,\n );\n }\n\n if (this.config.debug) {\n console.log(\"[Commet SDK] Response:\", responseData);\n }\n\n if (this.telemetryEnabled) {\n this.lastRequestMetrics = {\n requestId:\n response.headers.get(\"x-request-id\") ?? `req_${Date.now()}`,\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","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(): boolean {\n if (process.env.NODE_ENV !== \"development\") return false;\n if (process.env.CI) return false;\n return process.env.COMMET_NO_UPDATE_CHECK !== \"1\";\n}\n\nexport async function checkForSdkUpdate(\n installedVersion: string,\n): 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_\")) {\n throw new Error(\n \"Commet SDK: Invalid API key format. Expected format: ck_xxx...\",\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: \"weekly\" | \"monthly\" | \"quarterly\" | \"yearly\" | \"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,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