@commet/node 6.0.0 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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/features.ts","../src/resources/invoices.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/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/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 CreateFeatureParams,\n DeleteFeatureParams,\n GetFeatureAccessParams,\n ListFeaturesParams,\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 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 DeactivateAddonParams,\n GetActiveSubscriptionParams,\n GetSubscriptionParams,\n ListSubscriptionsParams,\n PreviewChangePlanParams,\n PurchaseCreditsParams,\n TopupBalanceParams,\n UncancelSubscriptionParams,\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 TrackModelTokensParams,\n TrackParams,\n TrackUsageParams,\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 WebhookEvent,\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 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 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 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 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} from \"./types/models\";\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(\"/addons/active\", 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 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 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 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 { FeatureType } from \"../types/enums\";\nimport type {\n DeletedObject,\n Feature,\n FeatureAccess,\n FeatureLookup,\n} from \"../types/models\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface ListFeaturesParams {\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 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 all features for a customer's active subscription. */\n async list(\n params: ListFeaturesParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Array<FeatureAccess>>> {\n return this.httpClient.get(\"/features\", params, options);\n }\n\n /** Get feature access details. Use action=canUse to check if 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(`/features/${code}`, rest, options);\n }\n\n /** Get feature access details. Use action=canUse to check if 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 `/features/${code}`,\n { ...rest, action: \"canUse\" },\n options,\n );\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 {\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 | \"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. Sending only currency and exchangeRate derives every regional value (base price, included balance, feature overage, intro offer) from the USD value at that rate. 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}\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 { 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 maxRedemptions?: number;\n /** @format date-time */\n expiresAt?: string;\n planIds?: Array<string>;\n}\n\nexport interface UpdatePromoCodeParams {\n id: string;\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 /** Create a new promo code. Optionally restrict to specific plans. */\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 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 { 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 SubscriptionStatus,\n} from \"../types/enums\";\nimport type {\n BalanceAdjustment,\n BalanceTopup,\n CanceledSubscription,\n CreditGrant,\n DeletedSubscriptionAddon,\n PlanChange,\n PreviewChange,\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 introOffer?: {\n discountType: DiscountType;\n discountValue: number;\n durationCycles: number;\n };\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 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 /** 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. 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. Enqueueing is asynchronous. Sandbox only. */\n async processBilling(): Promise<ApiResponse<TestClockBilling>> {\n return this.httpClient.post(\"/test-clock/process-billing\", {});\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 payment transaction. Creates a new invoice and initiates a new payment attempt. */\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 { FeaturesResource } from \"./resources/features\";\nimport { InvoicesResource } from \"./resources/invoices\";\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 { 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 features!: FeaturesResource;\n public invoices!: InvoicesResource;\n public payouts!: PayoutsResource;\n public planGroups!: PlanGroupsResource;\n public plans!: PlansResource;\n public portal!: PortalResource;\n public promoCodes!: PromoCodesResource;\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.features = new FeaturesResource(http);\n this.invoices = new InvoicesResource(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.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 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","import crypto from \"node:crypto\";\nimport type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { SubscriptionStatus } from \"../types/enums\";\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\n/**\n * Supported webhook events\n */\nexport type WebhookEvent =\n | \"subscription.created\"\n | \"subscription.activated\"\n | \"subscription.canceled\"\n | \"subscription.updated\"\n | \"subscription.plan_changed\"\n | \"payment.received\"\n | \"payment.failed\"\n | \"invoice.created\";\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 constructor(private httpClient?: CommetHTTPClient) {}\n\n /** HMAC-SHA256 verification. Payload must be the raw request body string, not parsed JSON. */\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\n // Use timing-safe comparison to prevent timing attacks\n return crypto.timingSafeEqual(\n Buffer.from(signature, \"hex\"),\n Buffer.from(expectedSignature, \"hex\"),\n );\n } catch (_error) {\n // timingSafeEqual throws if lengths don't match\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 /** Verifies signature and parses JSON in one step. Returns null if invalid. */\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 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-06-07\";\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\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 = Math.min(\n this.retryConfig.baseDelay * 2 ** (attempt - 1),\n this.retryConfig.maxDelay,\n );\n\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 // 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 = Math.min(\n this.retryConfig.baseDelay * 2 ** (attempt - 1),\n this.retryConfig.maxDelay,\n );\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 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 { 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\";\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 }\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;;;ACyCO,IAAM,iBAAN,MAAqB;AAAA,EAC1B,YAAoB,YAA8B;AAA9B;AAAA,EAA+B;AAAA;AAAA,EAGnD,MAAM,WACJ,QACA,SAC0C;AAC1C,WAAO,KAAK,WAAW,IAAI,kBAAkB,QAAQ,OAAO;AAAA,EAC9D;AAAA;AAAA,EAGA,MAAM,KACJ,QACA,SACoC;AACpC,WAAO,KAAK,WAAW,IAAI,WAAW,QAAQ,OAAO;AAAA,EACvD;AAAA;AAAA,EAGA,MAAM,IACJ,QACA,SAC6B;AAC7B,UAAM,EAAE,GAAG,IAAI;AACf,WAAO,KAAK,WAAW,IAAI,WAAW,EAAE,IAAI,QAAW,OAAO;AAAA,EAChE;AAAA;AAAA,EAGA,MAAM,OACJ,QACA,SAC6B;AAC7B,WAAO,KAAK,WAAW,KAAK,WAAW,QAAQ,OAAO;AAAA,EACxD;AAAA;AAAA,EAGA,MAAM,OACJ,QACA,SAC6B;AAC7B,UAAM,EAAE,IAAI,GAAG,KAAK,IAAI;AACxB,WAAO,KAAK,WAAW,IAAI,WAAW,EAAE,IAAI,MAAM,OAAO;AAAA,EAC3D;AAAA;AAAA,EAGA,MAAM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Q,OAAO,OAAO,CAAC;AA1DlE,IAAM,mBAAN;;;ACvBA,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;AAAA,EAC9C;AACF;AAEO,SAAS,aACd,gBACA,SACiB;AACjB,SAAO,IAAI,OAAgB,OAAO;AACpC;;;ACSO,SAAS,aAA4C,QAAc;AACxE,SAAO;AACT;;;AzBwMA,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/payouts.ts","../src/resources/plan-groups.ts","../src/resources/plans.ts","../src/resources/portal.ts","../src/resources/promo-codes.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/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 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 DeactivateAddonParams,\n GetActiveSubscriptionParams,\n GetSubscriptionParams,\n ListSubscriptionsParams,\n PreviewChangePlanParams,\n PurchaseCreditsParams,\n TopupBalanceParams,\n UncancelSubscriptionParams,\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 TrackModelTokensParams,\n TrackParams,\n TrackUsageParams,\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 WebhookEvent,\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 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 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 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 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} from \"./types/models\";\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 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 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 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 {\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 | \"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. Sending only currency and exchangeRate derives every regional value (base price, included balance, feature overage, intro offer) from the USD value at that rate. 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}\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 { 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 maxRedemptions?: number;\n /** @format date-time */\n expiresAt?: string;\n planIds?: Array<string>;\n}\n\nexport interface UpdatePromoCodeParams {\n id: string;\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 /** Create a new promo code. Optionally restrict to specific plans. */\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 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 { 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 SubscriptionStatus,\n} from \"../types/enums\";\nimport type {\n BalanceAdjustment,\n BalanceTopup,\n CanceledSubscription,\n CreditGrant,\n DeletedSubscriptionAddon,\n PlanChange,\n PreviewChange,\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 introOffer?: {\n discountType: DiscountType;\n discountValue: number;\n durationCycles: number;\n };\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 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 /** 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. 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. Enqueueing is asynchronous. Sandbox only. */\n async processBilling(): Promise<ApiResponse<TestClockBilling>> {\n return this.httpClient.post(\"/test-clock/process-billing\", {});\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 payment transaction. Creates a new invoice and initiates a new payment attempt. */\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 { 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 { 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 payouts!: PayoutsResource;\n public planGroups!: PlanGroupsResource;\n public plans!: PlansResource;\n public portal!: PortalResource;\n public promoCodes!: PromoCodesResource;\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.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.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 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","import crypto from \"node:crypto\";\nimport type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { SubscriptionStatus } from \"../types/enums\";\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\n/**\n * Supported webhook events\n */\nexport type WebhookEvent =\n | \"subscription.created\"\n | \"subscription.activated\"\n | \"subscription.canceled\"\n | \"subscription.updated\"\n | \"subscription.plan_changed\"\n | \"payment.received\"\n | \"payment.failed\"\n | \"invoice.created\";\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 constructor(private httpClient?: CommetHTTPClient) {}\n\n /** HMAC-SHA256 verification. Payload must be the raw request body string, not parsed JSON. */\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\n // Use timing-safe comparison to prevent timing attacks\n return crypto.timingSafeEqual(\n Buffer.from(signature, \"hex\"),\n Buffer.from(expectedSignature, \"hex\"),\n );\n } catch (_error) {\n // timingSafeEqual throws if lengths don't match\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 /** Verifies signature and parses JSON in one step. Returns null if invalid. */\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 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-06-10\";\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 { 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\";\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 }\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;;;ACyCO,IAAM,iBAAN,MAAqB;AAAA,EAC1B,YAAoB,YAA8B;AAA9B;AAAA,EAA+B;AAAA;AAAA,EAGnD,MAAM,WACJ,QACA,SAC0C;AAC1C,WAAO,KAAK,WAAW,IAAI,kBAAkB,QAAQ,OAAO;AAAA,EAC9D;AAAA;AAAA,EAGA,MAAM,KACJ,QACA,SACoC;AACpC,WAAO,KAAK,WAAW,IAAI,WAAW,QAAQ,OAAO;AAAA,EACvD;AAAA;AAAA,EAGA,MAAM,IACJ,QACA,SAC6B;AAC7B,UAAM,EAAE,GAAG,IAAI;AACf,WAAO,KAAK,WAAW,IAAI,WAAW,EAAE,IAAI,QAAW,OAAO;AAAA,EACh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